]> git.mxchange.org Git - friendica.git/blobdiff - mod/notifications.php
Merge pull request #3769 from annando/show-forum-posts
[friendica.git] / mod / notifications.php
index e9e5081cbccf58f4d7e292c6b1f8bbbbc5c93dd1..95467a584f68df4c600d010aae76847c535fd7b3 100644 (file)
@@ -5,6 +5,9 @@
  * @brief The notifications module
  */
 
+use Friendica\App;
+use Friendica\Core\System;
+
 require_once("include/NotificationsManager.php");
 require_once("include/contact_selectors.php");
 require_once("include/network.php");
@@ -12,15 +15,15 @@ require_once("include/network.php");
 function notifications_post(App $a) {
 
        if (! local_user()) {
-               goaway(z_root());
+               goaway(System::baseUrl());
        }
 
        $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
 
-       if ($request_id === "all")
+       if($request_id === "all")
                return;
 
-       if ($request_id) {
+       if($request_id) {
 
                $r = q("SELECT * FROM `intro` WHERE `id` = %d  AND `uid` = %d LIMIT 1",
                        intval($request_id),
@@ -41,11 +44,11 @@ function notifications_post(App $a) {
 
                $fid = $r[0]['fid'];
 
-               if ($_POST['submit'] == t('Discard')) {
+               if($_POST['submit'] == t('Discard')) {
                        $r = q("DELETE FROM `intro` WHERE `id` = %d",
                                intval($intro_id)
                        );
-                       if (! $fid) {
+                       if(! $fid) {
 
                                // The check for blocked and pending is in case the friendship was already approved
                                // and we just want to get rid of the now pointless notification
@@ -57,7 +60,7 @@ function notifications_post(App $a) {
                        }
                        goaway('notifications/intros');
                }
-               if ($_POST['submit'] == t('Ignore')) {
+               if($_POST['submit'] == t('Ignore')) {
                        $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
                                intval($intro_id));
                        goaway('notifications/intros');
@@ -91,7 +94,7 @@ function notifications_content(App $a) {
        $startrec = ($page * $perpage) - $perpage;
 
        // Get introductions
-       if ( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
+       if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
                nav_set_selected('introductions');
                $notif_header = t('Notifications');
 
@@ -100,25 +103,25 @@ function notifications_content(App $a) {
                $notifs = $nm->introNotifs($all, $startrec, $perpage);
 
        // Get the network notifications
-       } elseif (($a->argc > 1) && ($a->argv[1] == 'network')) {
+       } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
 
                $notif_header = t('Network Notifications');
                $notifs = $nm->networkNotifs($show, $startrec, $perpage);
 
        // Get the system notifications
-       } elseif (($a->argc > 1) && ($a->argv[1] == 'system')) {
+       } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
 
                $notif_header = t('System Notifications');
                $notifs = $nm->systemNotifs($show, $startrec, $perpage);
 
        // Get the personal notifications
-       } elseif (($a->argc > 1) && ($a->argv[1] == 'personal')) {
+       } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
 
                $notif_header = t('Personal Notifications');
                $notifs = $nm->personalNotifs($show, $startrec, $perpage);
 
        // Get the home notifications
-       } elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
+       } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
 
                $notif_header = t('Home Notifications');
                $notifs = $nm->homeNotifs($show, $startrec, $perpage);
@@ -135,13 +138,13 @@ function notifications_content(App $a) {
        $notifs['page'] = $a->pager['page'];
 
        // Json output
-       if (intval($json) === 1)
+       if(intval($json) === 1)
                json_return_and_die($notifs);
 
        $notif_tpl = get_markup_template('notifications.tpl');
 
        // Process the data for template creation
-       if ($notifs['ident'] === 'introductions') {
+       if($notifs['ident'] === 'introductions') {
 
                $sugg = get_markup_template('suggestions.tpl');
                $tpl = get_markup_template("intros.tpl");
@@ -190,8 +193,8 @@ function notifications_content(App $a) {
                                        $knowyou   = '';
                                        $dfrn_text = '';
 
-                                       if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
-                                               if ($it['network'] === NETWORK_DFRN) {
+                                       if($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
+                                               if($it['network'] === NETWORK_DFRN) {
                                                        $lbl_knowyou = t('Claims to be known to you: ');
                                                        $knowyou = (($it['knowyou']) ? t('yes') : t('no'));
                                                        $helptext = t('Shall your connection be bidirectional or not?');
@@ -223,6 +226,12 @@ function notifications_content(App $a) {
 
                                        $header .= " (".network_to_name($it['network'], $it['url']).")";
 
+                                       if ($it['network'] != NETWORK_DIASPORA) {
+                                               $discard = t('Discard');
+                                       } else {
+                                               $discard = '';
+                                       }
+
                                        $notif_content[] = replace_macros($tpl, array(
                                                '$header' => htmlentities($header),
                                                '$str_notifytype' => t('Notification type: '),
@@ -255,14 +264,14 @@ function notifications_content(App $a) {
                                                '$approve' => t('Approve'),
                                                '$note' => $it['note'],
                                                '$ignore' => t('Ignore'),
-                                               '$discard' => t('Discard'),
+                                               '$discard' => $discard,
 
                                        ));
                                        break;
                        }
                }
 
-               if ($notifs['total'] == 0)
+               if($notifs['total'] == 0)
                        info( t('No introductions.') . EOL);
 
        // Normal notifications (no introductions)
@@ -292,7 +301,7 @@ function notifications_content(App $a) {
                                '$item_link' => $it['link'],
                                '$item_image' => $it['image'],
                                '$item_url' => $it['url'],
-                               '$item_text' => htmlentities($it['text']),
+                               '$item_text' => $it['text'],
                                '$item_when' => $it['when'],
                                '$item_ago' => $it['ago'],
                                '$item_seen' => $it['seen'],
@@ -301,7 +310,7 @@ function notifications_content(App $a) {
 
                // It doesn't make sense to show the Show unread / Show all link visible if the user is on the
                // "Show all" page and there are no notifications. So we will hide it.
-               if ($show == 0 || intval($show) && $notifs['total'] > 0) {
+               if($show == 0 || intval($show) && $notifs['total'] > 0) {
                        $notif_show_lnk = array(
                                'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
                                'text' => ($show ? t('Show unread') : t('Show all')),
@@ -309,9 +318,8 @@ function notifications_content(App $a) {
                }
 
                // Output if there aren't any notifications available
-               if ($notifs['total'] == 0) {
+               if($notifs['total'] == 0)
                        $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
-               }
        }
 
        $o .= replace_macros($notif_tpl, array(