]> git.mxchange.org Git - friendica.git/commitdiff
You can now comment on the community page
authorMichael <heluecht@pirati.ca>
Sat, 23 Dec 2017 07:33:51 +0000 (07:33 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 23 Dec 2017 07:33:51 +0000 (07:33 +0000)
include/conversation.php
mod/community.php
src/Object/Thread.php

index ee68d8f5c91fc0351c7aa73835f5fbc27ec8b17b..0fc6a418d734c9c3fe0ccd24d99896617a5b48d7 100644 (file)
@@ -574,10 +574,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                }
        } elseif ($mode === 'community') {
                $profile_owner = 0;
-               if (!$update) {
-                       $live_update_div = '<div id="live-community"></div>' . "\r\n"
-                               . "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
-               }
+//             if (!$update) {
+//                     $live_update_div = '<div id="live-community"></div>' . "\r\n"
+//                             . "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+//             }
        } elseif ($mode === 'search') {
                $live_update_div = '<div id="live-search"></div>' . "\r\n";
        }
@@ -617,8 +617,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
                } else {
                        $writable = false;
                }
+                       $writable = true;
 
-               if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
+               if ($mode === 'network-new' || $mode === 'search') {
+// || $mode === 'community') {
 
                        /*
                         * "New Item View" on network page or search page results
index df21263278b7f60c82abf9b7fb8e6f134a03d56a..10852b49e27917428b4812e9a5f33937bd1e5e66 100644 (file)
@@ -114,9 +114,34 @@ function community_getpublicitems($start, $itemspage) {
        $r = dba::p("SELECT ".item_fieldlists()." FROM `thread`
                INNER JOIN `item` ON `item`.`id` = `thread`.`iid` ".item_joins().
                "WHERE `thread`.`uid` = 0 AND `verb` = ?
-               ORDER BY `thread`.`created` DESC LIMIT ".intval($start).", ".intval($itemspage),
+               ORDER BY `thread`.`commented` DESC LIMIT ".intval($start).", ".intval($itemspage),
                ACTIVITY_POST
        );
 
-       return dba::inArray($r);
+       while ($rr = dba::fetch($r)) {
+               if (!in_array($rr['item_id'], $parents_arr)) {
+                       $parents_arr[] = $rr['item_id'];
+               }
+       }
+
+       dba::close();
+
+       $max_comments = Config::get("system", "max_comments", 100);
+
+       $items = array();
+
+       foreach ($parents_arr AS $parents) {
+               $thread_items = dba::p(item_query()." AND `item`.`uid` = 0
+                       AND `item`.`parent` = ?
+                       ORDER BY `item`.`commented` DESC LIMIT ".intval($max_comments + 1),
+                       $parents
+               );
+
+               if (DBM::is_result($thread_items)) {
+                       $items = array_merge($items, dba::inArray($thread_items));
+               }
+       }
+       $items = conv_sort($items, "`commented`");
+
+       return $items;
 }
index 2872fe4a024ae6e5aafca808d3d4f111abde89bd..a03bae6e9d1da65f3b052293fb0d1090e86f8d72 100644 (file)
@@ -66,6 +66,10 @@ class Thread extends BaseObject
                                $this->profile_owner = $a->profile['uid'];
                                $this->writable = can_write_wall($a, $this->profile_owner) || $writable;
                                break;
+                       case 'community':
+                               $this->profile_owner = local_user();
+                               $this->writable = $writable;
+                               break;
                        default:
                                logger('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG);
                                return false;