Skip to content

Commit

Permalink
Updated to 6.1.1.1
Browse files Browse the repository at this point in the history
Updated to new version; Added in Remove All Reaction notifications to the All Notifications page as a convenience. Removed extraneous files that were in the older versions that shouldn't have been there.
  • Loading branch information
michieal committed Feb 26, 2022
1 parent 8be4792 commit 5b21227
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 88 deletions.
35 changes: 23 additions & 12 deletions MarkNotification/actions/delnotif.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@
/**
* Open Source Social Network
* @link https://www.opensource-socialnetwork.org/
* @package MarkNotification
* @package Delete Notifications
* @author Michieal O'Sullivan
* @copyright (C) Apophis Software
* @license GNU General Public License https://www.gnu.org/licenses/gpl-3.0.en.html
*/
require_once(__MARKNOTIFICATION__ . "libraries/marknotif.php");

$guid = filter_var($_GET['guid'], FILTER_VALIDATE_INT);
$guid = filter_var($_GET['guid'], FILTER_VALIDATE_INT);

if (empty($guid)){
ossn_trigger_message(ossn_print('mark:notification:delete:error'));
redirect(REF);
return;
}
$delalllikes = filter_var($_GET['dal'], FILTER_VALIDATE_INT, array('default' => 0, 'min_range' => 0, 'max_range' => 1));
if ($delalllikes == 1) {
if (marknotif_delete_allreactions()) {
ossn_trigger_message(ossn_print('mark:notification:delete:likes:success'), 'success');
} else {
ossn_trigger_message(ossn_print('mark:notification:delete:likes:error'));
}
redirect(REF);
exit;
}

if (marknotif_delete($guid)){
ossn_trigger_message(ossn_print('mark:notification:delete:success'), 'success');
} else {
ossn_trigger_message(ossn_print('mark:notification:delete:error'));
}
if (empty($guid)) {
ossn_trigger_message(ossn_print('mark:notification:delete:error'));
redirect(REF);
return;
}

if (marknotif_delete($guid)) {
ossn_trigger_message(ossn_print('mark:notification:delete:success'), 'success');
} else {
ossn_trigger_message(ossn_print('mark:notification:delete:error'));
}
redirect(REF);

?>
119 changes: 113 additions & 6 deletions MarkNotification/libraries/marknotif.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ function marknotif_read($guid) {
$Notification = new OssnNotifications;
$ownerGuid = ossn_loggedin_user()->getGUID();
$Notification->statement("UPDATE ossn_notifications SET viewed='' WHERE(owner_guid='{$ownerGuid}' and guid='{$guid}');");
if($Notification->execute()) {
if ($Notification->execute()) {
return true;
}
error_log("Notification failed to mark read.",0);
//error_log("Notification failed to mark read.",0);
return false;

}

/*
/**
* Mark the singular Notification as unread.
*
* [DO NOT USE] Included here because I wanted to make it, but it fails. If anyone gets it working, please let me know.
* @param integer $guid Notification guid
*
* @return boolean;
*/
*//*
function marknotif_unread($guid) {
if (empty($guid)) {
return false;
Expand All @@ -54,7 +55,7 @@ function marknotif_unread($guid) {
error_log("Notification failed to mark unread.",0);
return false;
}

*/
/**
* Delete the singular Notification.
*
Expand All @@ -74,7 +75,113 @@ function marknotif_delete($guid) {
return true;
}
}
error_log("Notification Deletion Failed.",0);
//error_log("Notification Deletion Failed.",0);
return false;
}

/**
* Delete all reaction Notifications.
*
* @return boolean;
*/
function marknotif_delete_allreactions(): bool {
$Notification = new OssnDatabase();
$ownerGuid = ossn_loggedin_user()->getGUID();
$check = false;
$checknext = false;
$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:post:group:wall');
");
$check = $Notification->execute();

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:file:ossn:aphoto');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:annotation');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:blog');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:file:profile:cover');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:file:profile:photo');");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:post');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:event:wall');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:entity:poll_entity');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:post:businesspage:wall');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

$Notification->statement("DELETE FROM ossn_notifications WHERE(
owner_guid='{$ownerGuid}' and type = 'like:annotation:comments:post');
");
$checknext = $Notification->execute();
if ($check == false) {
$check = $checknext;
}

//error_log("Notification Deletion Failed.",0);
return $check;
}

28 changes: 16 additions & 12 deletions MarkNotification/locale/ossn.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
* @license GNU General Public License https://www.gnu.org/licenses/gpl-3.0.en.html
*/
ossn_register_languages('en', array(
'mark:notification:read' => 'Mark Read ✔️',
'mark:notification:read:title' => 'Mark Notification as read.',
'mark:notification:read:success' => 'Successfully marked notification as read.',
'mark:notification:read:error' => 'Error in marking notification as read.',
'mark:notification:delete' => 'Delete ❌',
'mark:notification:delete:title' => 'Delete Notification.',
'mark:notification:delete:success' => 'Successfully deleted notification.',
'mark:notification:delete:error' => 'Error in deleting notification.',
'mark:notification:unread' => 'Mark Unread',
'mark:notification:unread:title' => 'Mark Notification as unread.',
'mark:notification:unread:success' => 'Successfully marked notification as unread.',
'mark:notification:unread:error' => 'Error in marking notification as unread.',
'mark:notification:read' => 'Mark Read ✔️',
'mark:notification:read:title' => 'Mark Notification as read.',
'mark:notification:read:success' => 'Successfully marked notification as read.',
'mark:notification:read:error' => 'Error in marking notification as read.',
'mark:notification:delete' => 'Delete ❌',
'mark:notification:delete:title' => 'Delete Notification.',
'mark:notification:delete:success' => 'Successfully deleted notification.',
'mark:notification:delete:error' => 'Error in deleting notification.',
'mark:notification:unread' => 'Mark Unread',
'mark:notification:unread:title' => 'Mark Notification as unread.',
'mark:notification:unread:success' => 'Successfully marked notification as unread.',
'mark:notification:unread:error' => 'Error in marking notification as unread.',
'mark:notification:delete:likes' => '❌ Delete All Reactions <div class="ossn-notification-icon-like"></div>',
'mark:notification:delete:likes:title' => 'Remove every Like style Notification.',
'mark:notification:delete:likes:success' => 'Successfully deleted reaction notifications [Under Development].',
'mark:notification:delete:likes:error' => 'Error in deleting reaction notifications.',
));
66 changes: 14 additions & 52 deletions MarkNotification/ossn_com.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

/**
* Apophis Software Component for OSSN v. 5.6 - 6.1.
*
* @package Apophis Software MarkNotification
* @author Apophis Software
* Open Source Social Network
* @link https://www.opensource-socialnetwork.org/
* @package MarkNotification
* @author Michieal O'Sullivan
* @copyright (C) Apophis Software
* @license Open Source Social Network License (OSSN LICENSE) http://www.opensource-socialnetwork.org/licence
* @link https://www.apophissoftware.com/
* @license GNU General Public License https://www.gnu.org/licenses/gpl-3.0.en.html
*/

define('__MARKNOTIFICATION__', ossn_route()->com . 'MarkNotification/');
Expand Down Expand Up @@ -72,8 +71,6 @@ function notification_insert_custom_html($hook, $htype, $return, $params) {

$frag = $doc->createDocumentFragment();

if ($div->hasAttributes() )

//Mark the notification as read
$link = htmlspecialchars(ossn_site_url("action/mark/read?guid=" . $nguid, true));
$notif_text = ossn_print('mark:notification:read');
Expand All @@ -88,56 +85,21 @@ function notification_insert_custom_html($hook, $htype, $return, $params) {
$data = "<a href='" . $link . "' class='apop-notif-delete' title='" . $notif_title . "'>" . $notif_text . "</a>";
$frag->appendXml($data);

/* //Mark the notification as unread
$link = htmlspecialchars(ossn_site_url("action/mark/unread?guid=" . $nguid, true));
$notif_text = ossn_print('mark:notification:unread');
$notif_title = ossn_print('mark:notification:unread:title');
$data = "<a href='" . $link . "' class='apop-notif-unread' title='" . $notif_title . "'>" . $notif_text . "</a>";
$frag->appendXml($data);
*/
$data = "<br/><hr class='apop-hr'/>";
$frag->appendXML($data);

$div->appendChild($frag);

return $doc->saveHTML();
//return $doc->saveHTML();
return str_replace('<?xml encoding="UTF-8">', '', $doc->saveHTML());
}
return $return;
}

/**
* Mark Notifications page (Copy of Notifications All page.)
*
* @param (array) $pages Array containing pages
*
* @return false|null data;
* @access public
*/
function mark_notifications_page($pages) {
$page = $pages[0];
if (empty($page)) {
return false;
}
switch ($page) {
case 'all':
$title = 'Mark Notifications';
$contents = array(
'content' => ossn_plugin_view('marknotif/pages/all')
);
$content = ossn_set_page_layout('media', $contents);
echo ossn_view_page($title, $content);

break;
case 'read':
redirect('home');
break;

case 'delete':
redirect('home');
break;

default:
$title = 'Mark Notifications';
$contents = array(
'content' => ossn_plugin_view('marknotif/pages/all')
);
$content = ossn_set_page_layout('media', $contents);
echo ossn_view_page($title, $content);
break;
}
}

ossn_register_callback('ossn', 'init', 'ossn_mark_notifications_init');
2 changes: 1 addition & 1 deletion MarkNotification/ossn_com.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<author_url>https://www.apophissoftware.com/</author_url>
<license>GNU General Public License v3</license>
<license_url>https://www.gnu.org/licenses/gpl-3.0.en.html</license_url>
<version>6.1.0.1</version>
<version>6.1.1.1</version>
<requires>
<type>ossn_version</type>
<version>6.1</version>
Expand Down
24 changes: 19 additions & 5 deletions MarkNotification/plugins/default/css/marknotif.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*Apophis Software*/

.ossn-notification-page .notification-image,
.ossn-notification-page .notification-image img {
display: inline-block;
margin-right: 5px;
}

.ossn-notification-page .notfi-meta{
display: inline-block;
}

.apop-notif-delete{
float:left;
position:relative;
Expand All @@ -19,7 +18,22 @@
position:relative;
display:inline;
}

.apop-notif-unread{
text-align: center;
text-anchor: middle;
position:relative;
}
.apop-hr{
color: #777
}
color: #777;
}

.apop-notif-delete-button{
float:right;
position:relative;
display:inline;
background-color: red;
color: white;
border: 1px solid white;
border-radius: 3px;
padding: 5px
}
Loading

0 comments on commit 5b21227

Please sign in to comment.