From 5b212276877442f70c357621ff0b6bd97791e558 Mon Sep 17 00:00:00 2001 From: Michieal Date: Sat, 26 Feb 2022 01:25:47 -0500 Subject: [PATCH] Updated to 6.1.1.1 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. --- MarkNotification/actions/delnotif.php | 35 ++++-- MarkNotification/libraries/marknotif.php | 119 +++++++++++++++++- MarkNotification/locale/ossn.en.php | 28 +++-- MarkNotification/ossn_com.php | 66 +++------- MarkNotification/ossn_com.xml | 2 +- .../plugins/default/css/marknotif.php | 24 +++- .../default/notifications/pages/all.php | 40 ++++++ 7 files changed, 226 insertions(+), 88 deletions(-) create mode 100644 MarkNotification/plugins/default/notifications/pages/all.php diff --git a/MarkNotification/actions/delnotif.php b/MarkNotification/actions/delnotif.php index ce4e4a8..2729ef2 100644 --- a/MarkNotification/actions/delnotif.php +++ b/MarkNotification/actions/delnotif.php @@ -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); ?> diff --git a/MarkNotification/libraries/marknotif.php b/MarkNotification/libraries/marknotif.php index 8825cab..40b65aa 100644 --- a/MarkNotification/libraries/marknotif.php +++ b/MarkNotification/libraries/marknotif.php @@ -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; @@ -54,7 +55,7 @@ function marknotif_unread($guid) { error_log("Notification failed to mark unread.",0); return false; } - +*/ /** * Delete the singular Notification. * @@ -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; +} + diff --git a/MarkNotification/locale/ossn.en.php b/MarkNotification/locale/ossn.en.php index 8534883..90070db 100644 --- a/MarkNotification/locale/ossn.en.php +++ b/MarkNotification/locale/ossn.en.php @@ -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
', + '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.', )); diff --git a/MarkNotification/ossn_com.php b/MarkNotification/ossn_com.php index 27a5a8c..c68ac02 100644 --- a/MarkNotification/ossn_com.php +++ b/MarkNotification/ossn_com.php @@ -1,13 +1,12 @@ com . 'MarkNotification/'); @@ -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'); @@ -88,56 +85,21 @@ function notification_insert_custom_html($hook, $htype, $return, $params) { $data = "" . $notif_text . ""; $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 = "" . $notif_text . ""; + $frag->appendXml($data); +*/ $data = "

"; $frag->appendXML($data); $div->appendChild($frag); - return $doc->saveHTML(); + //return $doc->saveHTML(); + return str_replace('', '', $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'); diff --git a/MarkNotification/ossn_com.xml b/MarkNotification/ossn_com.xml index a3f5f7b..15739ff 100644 --- a/MarkNotification/ossn_com.xml +++ b/MarkNotification/ossn_com.xml @@ -7,7 +7,7 @@ https://www.apophissoftware.com/ GNU General Public License v3 https://www.gnu.org/licenses/gpl-3.0.en.html - 6.1.0.1 + 6.1.1.1 ossn_version 6.1 diff --git a/MarkNotification/plugins/default/css/marknotif.php b/MarkNotification/plugins/default/css/marknotif.php index e1ac9f0..f59f8fa 100644 --- a/MarkNotification/plugins/default/css/marknotif.php +++ b/MarkNotification/plugins/default/css/marknotif.php @@ -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; @@ -19,7 +18,22 @@ position:relative; display:inline; } - +.apop-notif-unread{ +text-align: center; +text-anchor: middle; +position:relative; +} .apop-hr{ -color: #777 -} \ No newline at end of file +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 +} diff --git a/MarkNotification/plugins/default/notifications/pages/all.php b/MarkNotification/plugins/default/notifications/pages/all.php new file mode 100644 index 0000000..807f9ee --- /dev/null +++ b/MarkNotification/plugins/default/notifications/pages/all.php @@ -0,0 +1,40 @@ + + * @copyright (C) OpenTeknik LLC + * @license Open Source Social Network License (OSSN LICENSE) http://www.opensource-socialnetwork.org/licence + * @link https://www.opensource-socialnetwork.org/ + */ + +$get = new OssnNotifications; +$notifications = $get->searchNotifications(array( + 'owner_guid' => ossn_loggedin_user()->guid, + 'offset' => input('offset', '', 1), + 'order_by' => 'n.guid DESC', +)); +$count = $get->searchNotifications(array( + 'owner_guid' => ossn_loggedin_user()->guid, + 'count' => true, +)); +$list = '
'; +$notif_text = ossn_print('mark:notification:delete:likes'); +$notif_title = ossn_print('mark:notification:delete:likes:title'); +$link = htmlspecialchars(ossn_site_url("action/mark/delete?dal=1", true)); +$data = "" . $notif_text . ""; +$list .= '
' . $data . '

'; + + +if ($notifications) { + foreach ($notifications as $item) { + $list .= $item->toTemplate(); + } +} +$list .= "
"; +$pagination = ossn_view_pagination($count); +echo ossn_plugin_view('widget/view', array( + 'title' => ossn_print('notifications'), + 'contents' => $list . $pagination, +));