]> git.mxchange.org Git - friendica.git/blobdiff - mod/network.php
admin mail list seems wrong escaped
[friendica.git] / mod / network.php
index 29a340afdc240c6d8b3c1c786f1c2af388f5674b..b5c218de24a0a80b550887d11a5b54610190fcd6 100644 (file)
@@ -12,7 +12,6 @@ use Friendica\Content\Pager;
 use Friendica\Content\Widget;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\ACL;
-use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
@@ -201,15 +200,16 @@ function saved_searches($search)
  * Return selected tab from query
  *
  * urls -> returns
- *             '/network'                                      => $no_active = 'active'
- *             '/network?f=&order=comment'     => $comment_active = 'active'
- *             '/network?f=&order=post'        => $postord_active = 'active'
- *             '/network?f=&conv=1',           => $conv_active = 'active'
- *             '/network/new',                         => $new_active = 'active'
- *             '/network?f=&star=1',           => $starred_active = 'active'
- *             '/network?f=&bmark=1',          => $bookmarked_active = 'active'
+ *        '/network'                    => $no_active = 'active'
+ *        '/network?f=&order=comment'    => $comment_active = 'active'
+ *        '/network?f=&order=post'    => $postord_active = 'active'
+ *        '/network?f=&conv=1',        => $conv_active = 'active'
+ *        '/network/new',                => $new_active = 'active'
+ *        '/network?f=&star=1',        => $starred_active = 'active'
+ *        '/network?f=&bmark=1',        => $bookmarked_active = 'active'
  *
- * @return Array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active);
+ * @param App $a
+ * @return array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active);
  */
 function network_query_get_sel_tab(App $a)
 {
@@ -265,9 +265,11 @@ function network_query_get_sel_group(App $a)
 /**
  * @brief Sets the pager data and returns SQL
  *
- * @param App $a The global App
+ * @param App     $a      The global App
+ * @param Pager   $pager
  * @param integer $update Used for the automatic reloading
  * @return string SQL with the appropriate LIMIT clause
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function networkPager(App $a, Pager $pager, $update)
 {
@@ -301,6 +303,7 @@ function networkPager(App $a, Pager $pager, $update)
  * @brief Sets items as seen
  *
  * @param array $condition The array with the SQL condition
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function networkSetSeen($condition)
 {
@@ -311,7 +314,7 @@ function networkSetSeen($condition)
        $unseen = Item::exists($condition);
 
        if ($unseen) {
-               $r = Item::update(['unseen' => false], $condition);
+               Item::update(['unseen' => false], $condition);
        }
 }
 
@@ -320,9 +323,13 @@ function networkSetSeen($condition)
  *
  * @param App     $a      The global App
  * @param array   $items  Items of the conversation
+ * @param Pager   $pager
  * @param string  $mode   Display mode for the conversation
  * @param integer $update Used for the automatic reloading
+ * @param string  $ordering
  * @return string HTML of the conversation
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function networkConversation(App $a, $items, Pager $pager, $mode, $update, $ordering = '')
 {
@@ -355,7 +362,7 @@ function network_content(App $a, $update = 0, $parent = 0)
 
        /// @TODO Is this really necessary? $a is already available to hooks
        $arr = ['query' => $a->query_string];
-       Addon::callHooks('network_content_init', $arr);
+       Hook::callAll('network_content_init', $arr);
 
        $flat_mode = false;
 
@@ -387,10 +394,12 @@ function network_content(App $a, $update = 0, $parent = 0)
 /**
  * @brief Get the network content in flat view
  *
- * @param Pager   $pager
  * @param App     $a      The global App
  * @param integer $update Used for the automatic reloading
  * @return string HTML of the network content in flat view
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @global Pager  $pager
  */
 function networkFlatView(App $a, $update = 0)
 {
@@ -398,12 +407,6 @@ function networkFlatView(App $a, $update = 0)
        // Rawmode is used for fetching new content at the end of the page
        $rawmode = (isset($_GET['mode']) && ($_GET['mode'] == 'raw'));
 
-       if (isset($_GET['last_id'])) {
-               $last_id = intval($_GET['last_id']);
-       } else {
-               $last_id = 0;
-       }
-
        $o = '';
 
        $file = defaults($_GET, 'file', '');
@@ -440,14 +443,13 @@ function networkFlatView(App $a, $update = 0)
 
        $pager = new Pager($a->query_string);
 
-       /// @TODO Figure out why this variable is unused
-       $pager_sql = networkPager($a, $pager, $update);
+       networkPager($a, $pager, $update);
 
        if (strlen($file)) {
                $condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?",
                        $file, TERM_OBJ_POST, TERM_FILE, local_user()];
                $params = ['order' => ['tid' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
-               $result = DBA::select('term', ['oid'], $condition);
+               $result = DBA::select('term', ['oid'], $condition, $params);
 
                $posts = [];
                while ($term = DBA::fetch($result)) {
@@ -478,11 +480,13 @@ function networkFlatView(App $a, $update = 0)
 /**
  * @brief Get the network content in threaded view
  *
- * @global Pager   $pager
  * @param  App     $a      The global App
  * @param  integer $update Used for the automatic reloading
  * @param  integer $parent
  * @return string HTML of the network content in flat view
+ * @throws ImagickException
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @global Pager   $pager
  */
 function networkThreadedView(App $a, $update, $parent)
 {
@@ -521,7 +525,7 @@ function networkThreadedView(App $a, $update, $parent)
                                }
                        } elseif (intval($a->argv[$x])) {
                                $gid = intval($a->argv[$x]);
-                               $default_permissions = ['allow_gid' => '<' . $gid . '>'];
+                               $default_permissions['allow_gid'] = [$gid];
                        }
                }
        }
@@ -536,18 +540,18 @@ function networkThreadedView(App $a, $update, $parent)
        $nets  =        defaults($_GET, 'nets' , '');
 
        if ($cid) {
-               $default_permissions = ['allow_cid' => '<' . intval($cid) . '>'];
+               $default_permissions['allow_cid'] = [(int) $cid];
        }
 
        if ($nets) {
                $r = DBA::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]);
 
-               $str = '';
+               $str = [];
                while ($rr = DBA::fetch($r)) {
-                       $str .= '<' . $rr['id'] . '>';
+                       $str[] = (int) $rr['id'];
                }
                if (strlen($str)) {
-                       $default_permissions = ['allow_cid' => $str];
+                       $default_permissions['allow_cid'] = $str;
                }
        }
 
@@ -610,7 +614,6 @@ function networkThreadedView(App $a, $update, $parent)
        $sql_extra3 = '';
        $sql_table = '`thread`';
        $sql_parent = '`iid`';
-       $sql_order = '';
 
        if ($update) {
                $sql_table = '`item`';
@@ -625,7 +628,7 @@ function networkThreadedView(App $a, $update, $parent)
                $group = DBA::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]);
                if (!DBA::isResult($group)) {
                        if ($update) {
-                               killme();
+                               exit();
                        }
                        notice(L10n::t('No such group') . EOL);
                        $a->internalRedirect('network/0');
@@ -941,6 +944,7 @@ function networkThreadedView(App $a, $update, $parent)
  *
  * @param App $a The global App
  * @return string Html of the networktab
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function network_tabs(App $a)
 {
@@ -1024,7 +1028,7 @@ function network_tabs(App $a)
        }
 
        $arr = ['tabs' => $tabs];
-       Addon::callHooks('network_tabs', $arr);
+       Hook::callAll('network_tabs', $arr);
 
        $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
 
@@ -1040,13 +1044,17 @@ function network_tabs(App $a)
  * of the page to make the correct asynchronous call. This is obtained through the Pager that was instantiated in
  * networkThreadedView or networkFlatView.
  *
- * @global Pager  $pager
- * @param  App    $a
+ * @param App     $a
  * @param  string $htmlhead The head tag HTML string
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @global Pager  $pager
  */
 function network_infinite_scroll_head(App $a, &$htmlhead)
 {
        /// @TODO this will have to be converted to a static property of the converted Module\Network class
+       /**
+        * @var $pager Pager
+        */
        global $pager;
 
        if (PConfig::get(local_user(), 'system', 'infinite_scroll')