]> git.mxchange.org Git - friendica.git/blobdiff - include/ForumManager.php
Issue 3857: There is the possibility of a bad handling of dislikes
[friendica.git] / include / ForumManager.php
index 49417d1831564c0fbc0ce5e635213c0bc883449b..8473035affe43faf33440faa3479f22543c77584 100644 (file)
@@ -1,12 +1,15 @@
 <?php
 
+use Friendica\App;
+use Friendica\Core\System;
+
 /**
- * @file include/forum.php
- * @brief Functions related to forum functionality *
+ * @file include/ForumManager.php
+ * @brief ForumManager class with its methods related to forum functionality *
  */
 
 /**
- * @brief This class handles functions related to the forum functionality
+ * @brief This class handles metheods related to the forum functionality
  */
 class ForumManager {
 
@@ -26,6 +29,7 @@ class ForumManager {
         *      'name'  => forum name
         *      'id'    => number of the key from the array
         *      'micro' => contact photo in format micro
+        *      'thumb' => contact photo in format thumb
         */
        public static function get_list($uid, $showhidden = true, $lastitem, $showprivate = false) {
 
@@ -38,25 +42,28 @@ class ForumManager {
                        $select = '(`forum` OR `prv`)';
                }
 
-               $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` FROM `contact`
-                               WHERE `network`= 'dfrn' AND $select AND `uid` = %d
+               $contacts = dba::p("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro`, `contact`.`thumb` FROM `contact`
+                               WHERE `network`= 'dfrn' AND $select AND `uid` = ?
                                AND NOT `blocked` AND NOT `hidden` AND NOT `pending` AND NOT `archive`
                                AND `success_update` > `failure_update`
                                $order ",
-                               intval($uid)
+                               $uid
                );
 
                if (!$contacts)
                        return($forumlist);
 
-               foreach($contacts as $contact) {
+               while ($contact = dba::fetch($contacts)) {
                        $forumlist[] = array(
                                'url'   => $contact['url'],
                                'name'  => $contact['name'],
                                'id'    => $contact['id'],
                                'micro' => $contact['micro'],
+                               'thumb' => $contact['thumb'],
                        );
                }
+               dba::close($contacts);
+
                return($forumlist);
        }
 
@@ -86,7 +93,7 @@ class ForumManager {
                $total = count($contacts);
                $visible_forums = 10;
 
-               if(count($contacts)) {
+               if (dbm::is_result($contacts)) {
 
                        $id = 0;
 
@@ -95,12 +102,12 @@ class ForumManager {
                                $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
 
                                $entry = array(
-                                       'url' => z_root() . '/network?f=&cid=' . $contact['id'],
-                                       'external_url' => z_root() . '/redir/' . $contact['id'],
+                                       'url' => 'network?f=&cid=' . $contact['id'],
+                                       'external_url' => 'redir/' . $contact['id'],
                                        'name' => $contact['name'],
                                        'cid' => $contact['id'],
                                        'selected'      => $selected,
-                                       'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
+                                       'micro' => System::removedBaseUrl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
                                        'id' => ++$id,
                                );
                                $entries[] = $entry;
@@ -187,4 +194,4 @@ class ForumManager {
                return $r;
        }
 
-}
\ No newline at end of file
+}