viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]
diff --git a/src/controllers/components/AccountaccessComponent.php b/src/controllers/components/AccountaccessComponent.php index fe58f951a..02d5ea56c 100644 --- a/src/controllers/components/AccountaccessComponent.php +++ b/src/controllers/components/AccountaccessComponent.php @@ -184,21 +184,16 @@ class AccountaccessComponent extends Component continue; } $data['GROUPS'][$i] = $tmp_group; - $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'] = $group_model->getGroupThreadCount($group_id); $data['GROUPS'][$i]['NUM_PAGES'] = $group_model->getGroupPageCount($group_id); - if (isset($item[0]['TITLE'])) { - $data['GROUPS'][$i]["ITEM_TITLE"] = $item[0]['TITLE']; - $data['GROUPS'][$i]["THREAD_ID"] = $item[0]['PARENT_ID']; + if (isset($item['TITLE'])) { + $data['GROUPS'][$i]["ITEM_TITLE"] = $item['TITLE']; + $data['GROUPS'][$i]["THREAD_ID"] = $item['PARENT_ID']; } else { $data['GROUPS'][$i]["ITEM_TITLE"] = tl('accountaccess_component_no_posts_yet'); diff --git a/src/models/GroupModel.php b/src/models/GroupModel.php index ae3d2f0f6..1b7e5abd6 100644 --- a/src/models/GroupModel.php +++ b/src/models/GroupModel.php @@ -1106,13 +1106,47 @@ class GroupModel extends Model implements MediaConstants $row = $db->fetchArray($result); return $row['NUM'] ?? false; } + /** + * + */ + public function getMostRecentGroupPost($group_id) + { + $db = $this->db; + $sql = "SELECT MAX(GI.PUBDATE) AS PUBDATE + FROM GROUP_ITEM GI + WHERE GI.GROUP_ID = ?"; + $result = $db->execute($sql, [$group_id]); + if (empty($result)) { + return ""; + } + $row = $db->fetchArray($result); + if (empty($row)) { + return ""; + } + $sql = "SELECT DISTINCT GI.ID AS ID, GI.PARENT_ID AS PARENT_ID, + GI.GROUP_ID AS GROUP_ID, GI.TITLE AS TITLE, + GI.DESCRIPTION AS DESCRIPTION, GI.PUBDATE AS PUBDATE, + GI.EDIT_DATE AS EDIT_DATE, G.OWNER_ID AS OWNER_ID, + G.MEMBER_ACCESS AS MEMBER_ACCESS, G.GROUP_NAME AS GROUP_NAME, + P.USER_NAME AS USER_NAME, P.USER_ID AS USER_ID, GI.TYPE AS TYPE, + GI.UPS AS UPS, GI.DOWNS AS DOWNS, G.VOTE_ACCESS AS VOTE_ACCESS + FROM GROUP_ITEM GI, GROUPS G, USERS P + WHERE GI.GROUP_ID = ? AND GI.GROUP_ID=G.GROUP_ID AND + GI.USER_ID = P.USER_ID AND GI.PUBDATE = ? LIMIT 0 , 1"; + $result = $db->execute($sql, [$group_id, $row['PUBDATE']]); + if (empty($result)) { + return ""; + } + return $db->fetchArray($result); + } /** * */ public function getGroupThreadCount($group_id) { $db = $this->db; - $sql = "SELECT COUNT(DISTINCT GI.PARENT_ID) AS NUM FROM GROUP_ITEM GI + $sql = "SELECT COUNT(DISTINCT GI.PARENT_ID) AS NUM + FROM GROUP_ITEM GI WHERE GI.GROUP_ID = ?"; $result = $db->execute($sql, [$group_id]); if (!$result) {