viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Fix notice in GroupController.php

Chris Pollett [2020-06-24 04:Jun:th]
Fix notice in GroupController.php
Filename
src/controllers/GroupController.php
src/controllers/SearchController.php
src/controllers/components/SocialComponent.php
diff --git a/src/controllers/GroupController.php b/src/controllers/GroupController.php
index b966b20de..2a1036e55 100644
--- a/src/controllers/GroupController.php
+++ b/src/controllers/GroupController.php
@@ -97,12 +97,15 @@ class GroupController extends Controller implements CrawlConstants
             $_REQUEST["c"] = "group";
         }
         $data = array_merge($data, $this->processSession());
-        $allowed_activities =
-             $this->model("user")->getUserActivities($_SESSION['USER_ID']);
         $data['MENU'] = 'groupmenu';
         $data['MENU_NAME'] = tl('group_controller_groupmenu');
-        $data['COMPONENT_ACTIVITIES'] =
-            AdminController::computeComponentActivities($allowed_activities);
+        if (!empty($_SESSION['USER_ID'])) {
+            $allowed_activities =
+                 $this->model("user")->getUserActivities($_SESSION['USER_ID']);
+            $data['COMPONENT_ACTIVITIES'] =
+                AdminController::computeComponentActivities(
+                    $allowed_activities);
+        }
         if (!isset($data['REFRESH'])) {
             $view = "group";
         } else {
diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php
index 606b97a91..364ade925 100755
--- a/src/controllers/SearchController.php
+++ b/src/controllers/SearchController.php
@@ -990,7 +990,7 @@ EOD;
         }
         $data['MENU'] = 'searchmenu';
         $data['MENU_NAME'] = tl('search_controller_searchmenu');
-        if (!empty($data["ADMIN"])) {
+        if (!empty($_SESSION['USER_ID'])) {
             $allowed_activities =
                  $this->model("user")->getUserActivities($_SESSION['USER_ID']);
             $data['COMPONENT_ACTIVITIES'] =
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index 58783282b..f37ea50df 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -2265,10 +2265,7 @@ class SocialComponent extends Component implements CrawlConstants
         $num_shown = count($data['GROUPS']);
         for ($i = 0; $i < $num_shown; $i++) {
             $group_id = $data['GROUPS'][$i]['GROUP_ID'];
-            $search_array = [
-                ["group_id", "=", $group_id, ""],
-                ["pub_date", "", "", "DESC"] ];
-            $item = $group_model->getGroupItems(0, 1, $search_array, $user_id);
+            $item = $group_model->getMostRecentGroupPost($group_id);
             $data['GROUPS'][$i]['NUM_POSTS'] = $group_model->getGroupPostCount(
                 $group_id);
             $data['GROUPS'][$i]['NUM_THREADS']=
@@ -2276,8 +2273,8 @@ class SocialComponent extends Component implements CrawlConstants
             $data['GROUPS'][$i]['NUM_PAGES'] = $group_model->getGroupPageCount(
                 $data['GROUPS'][$i]['GROUP_ID']);
             if (isset($item[0]['TITLE'])) {
-                $data['GROUPS'][$i]["ITEM_TITLE"] = $item[0]['TITLE'];
-                $data['GROUPS'][$i]["THREAD_ID"] = $item[0]['PARENT_ID'];
+                $data['GROUPS'][$i]["ITEM_TITLE"] = $item['TITLE'];
+                $data['GROUPS'][$i]["THREAD_ID"] = $item['PARENT_ID'];
             } else {
                 $data['GROUPS'][$i]["ITEM_TITLE"] =
                     tl('social_component_no_posts_yet');
ViewGit