_binary From 615992c1511f4d085ce8d573403ba3cfab565bf4 Mon Sep 17 00:00:00 2001
From: Anirudh Mallya <anirudh.mallya09@gmail.com>
Date: Fri, 7 May 2021 13:31:16 -0700
Subject: [PATCH] Adding pre-defined 'Chats' group to users on Yioop for direct
 messaging & Generating URL Shortener

---
 src/configs/Config.php                        |  6 +-
 src/controllers/RegisterController.php        | 77 ++++++++++++++++++-
 .../components/AccountaccessComponent.php     | 67 +++++++++++++++-
 .../components/SocialComponent.php            | 35 +++++++--
 src/models/GroupModel.php                     | 33 ++++----
 src/views/elements/AdminmenuElement.php       |  3 +-
 src/views/elements/Element.php                | 61 ++++++++++++++-
 src/views/elements/GroupbarElement.php        |  3 +-
 src/views/elements/GroupfeedElement.php       | 17 +++-
 src/views/elements/GroupmenuElement.php       |  3 +-
 src/views/elements/ManageaccountElement.php   |  9 ++-
 src/views/elements/ManagegroupsElement.php    |  4 +-
 src/views/elements/WikiElement.php            | 33 +++++++-
 13 files changed, 316 insertions(+), 35 deletions(-)

diff --git a/src/configs/Config.php b/src/configs/Config.php
index 6812680cc..60b2c0d8a 100755
--- a/src/configs/Config.php
+++ b/src/configs/Config.php
@@ -979,7 +979,9 @@ nsconddefine('NAME_TRUNCATE_LEN', 7);
 /** USER STATUS value used for someone who is not in a group but can browse*/
 nsdefine('NOT_MEMBER_STATUS', -1);
 /** USER STATUS value used for a user who can log in and perform activities */
-nsdefine('ACTIVE_STATUS', 1);
+nsdefine('ACTIVE_STATUS', 5);
+/** USER STATUS value used for to identify if logged in user is running on an older version of Yioop*/
+nsdefine('ACTIVE_STATUS_USER_V1', 1);
 /**
  * USER STATUS value used for a user whose account is created, but which
  * still needs to undergo admin or email verification/activation
@@ -1199,4 +1201,4 @@ nsconddefine('AD_LOGO','resources/adv-logo.png');
 /** sentence compression enabled or not*/
 nsconddefine('SENTENCE_COMPRESSION_ENABLED', false);
 /** The number of rows to be used in bulk insert from Lexicon */
-nsconddefine('NUM_LEX_BULK_INSERTS',100000);
+nsconddefine('NUM_LEX_BULK_INSERTS',100000);
\ No newline at end of file
diff --git a/src/controllers/RegisterController.php b/src/controllers/RegisterController.php
index cd9d70c8b..df45c787a 100755
--- a/src/controllers/RegisterController.php
+++ b/src/controllers/RegisterController.php
@@ -307,6 +307,81 @@ class RegisterController extends Controller implements CrawlConstants
                 break;
         }
         $user = $user_model->getUser($data['USER']);
+        $group_name_id = 'Chats$'.$user['USER_NAME'].'$'.$user['USER_ID'];
+        $group_model = $this->model("group");
+        if ($user['USER_ID'] == C\PUBLIC_USER_ID) {
+            return $this->redirectWithMessage(
+                tl('social_component_public_cant_create'));
+        } else {
+            $group_fields = [
+                "member_access" => ["ACCESS_CODES", C\ACTIVE_STATUS],
+                "register" => ["REGISTER_CODES", C\NO_JOIN],
+                "vote_access" => ["VOTING_CODES",
+                    C\NON_VOTING_GROUP],
+                "post_lifetime" => ["POST_LIFETIMES", C\FOREVER],
+                "encryption" => ["ENCRYPTION_CODES", 0]
+            ];
+            foreach ($group_fields as $field => $info) {
+                if (!isset($_REQUEST[$field]) ||
+                    !in_array($_REQUEST[$field],
+                    array_keys($data[$info[0]]))) {
+                    $_REQUEST[$field] = $info[1];
+                }
+            }
+            $group_model->addGroup($group_name_id,
+                $user['USER_ID'], $_REQUEST['register'],
+                $_REQUEST['member_access'],
+                $_REQUEST['vote_access'],
+                $_REQUEST['post_lifetime'],
+                $_REQUEST['encryption']);
+            //one exception to setting $group_id
+            $gid = $group_model->getGroupId($group_name_id);
+            $group_model->addUserGroup($user['USER_ID'], $gid);
+        }
+        $data['NUM_SHOWN'] = 5;
+        $data['NUM_GROUPS'] = $group_model->countUserGroups($user['USER_ID']);
+
+        $group_ids = $this->model("impression")->recent($user['USER_ID'],
+            C\GROUP_IMPRESSION, $data['NUM_SHOWN']);
+        $num_shown = count($group_ids);
+        if ($num_shown < $data['NUM_GROUPS'] && $num_shown <
+            $data['NUM_SHOWN']) {
+            $groups = $group_model->getUserGroups($user['USER_ID'], "", 0,"");
+            foreach ($groups as $group) {
+                if (!in_array($group['GROUP_ID'], $group_ids)) {
+                    $group_ids[] = $group['GROUP_ID'];
+                }
+                if (count($group_ids) >= $data['NUM_SHOWN']) {
+                    break;
+                }
+            }
+        }
+        $num_shown = count($group_ids);
+        $data['GROUPS'] = [];
+        $i = 0;
+        foreach ($group_ids as $group_id) {
+            $tmp_group = $group_model->getGroupById($group_id, $user['USER_ID']);
+            if (!$tmp_group) {
+                continue;
+            }
+            $data['GROUPS'][$i] = $tmp_group;
+            $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['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');
+                $data['GROUPS'][$i]["THREAD_ID"] = -1;
+            }
+            $i++;
+        }
         if (!empty($user['USER_ID'])) {
             $user_model->setUserSession($user['USER_ID'], $_SESSION);
         }
@@ -1170,4 +1245,4 @@ class RegisterController extends Controller implements CrawlConstants
         }
         return false;
     }
-}
+}
\ No newline at end of file
diff --git a/src/controllers/components/AccountaccessComponent.php b/src/controllers/components/AccountaccessComponent.php
index 0fe2c299c..ae55d448c 100644
--- a/src/controllers/components/AccountaccessComponent.php
+++ b/src/controllers/components/AccountaccessComponent.php
@@ -158,6 +158,34 @@ class AccountaccessComponent extends Component
         }
         $data['USERNAME'] = $username;
         $data['NUM_SHOWN'] = 5;
+        if ($data['USER']['STATUS'] == C\ACTIVE_STATUS_USER_V1){
+            $data['USER_NAMES'][$username] = $username;
+            $username = strtolower($username);
+            $group_name_id = 'Chats$'.$username.'$'.$user_id;
+            $group_fields = [
+                "member_access" => ["ACCESS_CODES", C\ACTIVE_STATUS],
+                "register" => ["REGISTER_CODES", C\NO_JOIN],
+                "vote_access" => ["VOTING_CODES",
+                    C\NON_VOTING_GROUP],
+                "post_lifetime" => ["POST_LIFETIMES", C\FOREVER],
+                "encryption" => ["ENCRYPTION_CODES", 0]
+            ];
+            foreach ($group_fields as $field => $info) {
+                if (!isset($_REQUEST[$field]) ||
+                    !in_array($_REQUEST[$field],
+                    array_keys($data[$info[0]]))) {
+                    $_REQUEST[$field] = $info[1];
+                }
+            }
+            $group_model->addGroup($group_name_id,
+                $user_id, $_REQUEST['register'],
+                $_REQUEST['member_access'],
+                $_REQUEST['vote_access'],
+                $_REQUEST['post_lifetime'],
+                $_REQUEST['encryption']);
+            $group_id = $group_model->getGroupId($group_name_id);
+            $user_model->updateUserStatus($user_id, C\ACTIVE_STATUS);
+        }
         $data['NUM_GROUPS'] = $group_model->countUserGroups($user_id);
         $group_ids = $parent->model("impression")->recent($user_id,
             C\GROUP_IMPRESSION, $data['NUM_SHOWN']);
@@ -454,7 +482,8 @@ class AccountaccessComponent extends Component
                             substr($parent->clean($_REQUEST['password'],
                             "string"), 0, C\LONG_NAME_LEN);
                         $username = trim($username);
-                        $user_model->addUser($username, $norm_password,
+                        $user_id = $user_model->addUser($username,
+                            $norm_password,
                             substr(trim($parent->clean($_REQUEST['first_name'],
                                 "string")), 0, C\NAME_LEN),
                             substr(trim($parent->clean($_REQUEST['last_name'],
@@ -464,6 +493,40 @@ class AccountaccessComponent extends Component
                             $_REQUEST['status']
                         );
                         $data['USER_NAMES'][$username] = $username;
+                        $username = strtolower($username);
+                        $group_name_id = 'Chats$'.$username.'$'.$user_id;
+                        if ($user_id == C\PUBLIC_USER_ID) {
+                            return $parent->redirectWithMessage(
+                                tl('social_component_public_cant_create'));
+                        } else if ($group_model->
+                                    getGroupId($group_name_id) > 0) {
+                            return $parent->redirectWithMessage(
+                                tl('social_component_groupname_exists'));
+                        } else {
+                            $group_fields = [
+                                "member_access" => ["ACCESS_CODES",
+                                C\ACTIVE_STATUS],
+                                "register" => ["REGISTER_CODES", C\NO_JOIN],
+                                "vote_access" => ["VOTING_CODES",
+                                    C\NON_VOTING_GROUP],
+                                "post_lifetime" => ["POST_LIFETIMES", C\FOREVER],
+                                "encryption" => ["ENCRYPTION_CODES", 0]
+                            ];
+                            foreach ($group_fields as $field => $info) {
+                                if (!isset($_REQUEST[$field]) ||
+                                    !in_array($_REQUEST[$field],
+                                    array_keys($data[$info[0]]))) {
+                                    $_REQUEST[$field] = $info[1];
+                                }
+                            }
+                            $group_model->addGroup($group_name_id,
+                                $user_id, $_REQUEST['register'],
+                                $_REQUEST['member_access'],
+                                $_REQUEST['vote_access'],
+                                $_REQUEST['post_lifetime'],
+                                $_REQUEST['encryption']);
+                            $group_id = $group_model->getGroupId($group_name_id);
+                        }
                         return $parent->redirectWithMessage(
                             tl('accountaccess_component_user_added'),
                             $request_fields);
@@ -1126,4 +1189,4 @@ class AccountaccessComponent extends Component
             C\DEFAULT_ADMIN_PAGING_NUM, $search_array, "");
         return $data;
     }
-}
+}
\ No newline at end of file
diff --git a/src/controllers/components/SocialComponent.php b/src/controllers/components/SocialComponent.php
index b75b5b506..a434271e9 100644
--- a/src/controllers/components/SocialComponent.php
+++ b/src/controllers/components/SocialComponent.php
@@ -2913,6 +2913,10 @@ class SocialComponent extends Component implements CrawlConstants
                     $data["HEAD"]['page_alias'],
                     true, $controller_name, $group_id) . C\CSRF_TOKEN . '=' .
                     $parent->generateCSRFToken($user_id));
+            } else if (isset($data["HEAD"]['page_type']) &&
+                    $data["HEAD"]['page_type'] == 'url_shortener' &&
+                    in_array($data['MODE'], ["read"])) {
+                    $parent->redirectLocation($data["HEAD"]['url_shortener']);
             }
             if ($data['MODE'] == "read") {
                 $data['GROUP_STATUS'] = $group['STATUS'];
@@ -4126,7 +4130,8 @@ EOD;
             "page_and_feedback" => tl('social_component_page_and_feedback'),
             "page_alias" => tl('social_component_page_alias'),
             "media_list" => tl('social_component_media_list'),
-            "presentation" => tl('social_component_presentation')
+            "presentation" => tl('social_component_presentation'),
+            "url_shortener" => tl('social_component_url_shortener')
         ];
         $data['page_borders'] = [
             "solid-border" => tl('social_component_solid'),
@@ -4180,6 +4185,7 @@ EOD;
         $page_defaults = [
             'page_type' => 'standard',
             'page_alias' => '',
+            'url_shortener' => '',
             'page_border' => 'solid',
             'toc' => true,
             'title' => '',
@@ -4257,11 +4263,14 @@ EOD;
             is_media_list = ('media_list'=='{$data['current_page_type']}');
             is_settings = {$data['settings']};
             is_page_alias = ('page_alias'=='{$data['current_page_type']}');
+            is_url_shortener = ('url_shortener'=='{$data['current_page_type']}');
             setDisplay('page-settings', is_settings || is_page_alias);
-            setDisplay("media-list-page", is_media_list && !is_page_alias);
-            setDisplay("page-container", !is_media_list && !is_page_alias);
-            setDisplay("non-alias-type", !is_page_alias);
+            setDisplay("media-list-page", is_media_list && !is_page_alias && !is_url_shortener);
+            setDisplay("page-container", !is_media_list && !is_page_alias && !is_url_shortener);
+            setDisplay("non-alias-type", !is_page_alias && !is_url_shortener);
             setDisplay("alias-type", is_page_alias);
+            setDisplay("url-shortener", is_url_shortener);
+            setDisplay("short-url-label", is_url_shortener);
             if (mode == 'edit') {
                 setDisplay('save-container', !is_media_list || is_settings);
                 setDisplay('resource-upload-form', is_media_list);
@@ -4276,6 +4285,8 @@ EOD;
                     $toggle_settings_on
                     setDisplay("non-alias-type", true);
                     setDisplay("alias-type", false);
+                    setDisplay("url-shortener", false);
+                    setDisplay("short-url-label", false);
                     setDisplay("page-resources", true);
                     if (mode == 'edit') {
                         setDisplay("resource-upload-form", true);
@@ -4286,13 +4297,27 @@ EOD;
                     setDisplay("page-container", false);
                     setDisplay("non-alias-type", false);
                     setDisplay("alias-type", true);
+                    setDisplay("url-shortener", false);
+                    setDisplay("short-url-label", false);
                     setDisplay("page-resources", false);
+                } else if (cur_type == "url_shortener") {
+                     $toggle_settings_false
+                     setDisplay("media-list-page", false);
+                     setDisplay("page-container", false);
+                     setDisplay("non-alias-type", false);
+                     setDisplay("alias-type", false);
+                     setDisplay("url-shortener", true);
+                     setDisplay("short-url-label", true);
+                     setDisplay("page-resources", false);
+                     setDisplay("resource_msg", false);
                 } else {
                     setDisplay("page-container", true);
                     setDisplay("media-list-page", false);
                     $toggle_settings_inline
                     setDisplay("non-alias-type", true);
                     setDisplay("alias-type", false);
+                    setDisplay("url-shortener", false);
+                    setDisplay("short-url-label", false);
                     setDisplay("page-resources", true);
                     if (mode == 'edit') {
                         setDisplay("resource-upload-form", false);
@@ -4301,4 +4326,4 @@ EOD;
             }
 EOD;
     }
-}
+}
\ No newline at end of file
diff --git a/src/models/GroupModel.php b/src/models/GroupModel.php
index b9eb94e03..73aa0de82 100644
--- a/src/models/GroupModel.php
+++ b/src/models/GroupModel.php
@@ -552,7 +552,6 @@ class GroupModel extends Model implements MediaConstants
     {
         $db = $this->db;
         $groups = [];
-        $limit = $db->limitOffset($limit, $num);
         $like = "";
         $param_array = [$user_id];
         if ($filter != "") {
@@ -575,11 +574,19 @@ class GroupModel extends Model implements MediaConstants
                 }
             }
         }
-        $sql = "SELECT UG.GROUP_ID AS GROUP_ID, UG.USER_ID AS USER_ID," .
-            " G.GROUP_NAME AS GROUP_NAME, UG.STATUS AS STATUS ".
-            " FROM USER_GROUP UG, GROUPS G" .
-            " WHERE USER_ID = ? AND UG.GROUP_ID = G.GROUP_ID $like ".
-            " $order_by $limit";
+        if ($limit == "") {
+            $sql = "SELECT UG.GROUP_ID AS GROUP_ID, UG.USER_ID AS USER_ID," .
+                " G.GROUP_NAME AS GROUP_NAME, UG.STATUS AS STATUS ".
+                " FROM USER_GROUP UG, GROUPS G" .
+                " WHERE USER_ID = ? AND UG.GROUP_ID = G.GROUP_ID $like ";
+        } else {
+            $limit = $db->limitOffset($limit, $num);
+            $sql = "SELECT UG.GROUP_ID AS GROUP_ID, UG.USER_ID AS USER_ID," .
+                " G.GROUP_NAME AS GROUP_NAME, UG.STATUS AS STATUS ".
+                " FROM USER_GROUP UG, GROUPS G" .
+                " WHERE USER_ID = ? AND UG.GROUP_ID = G.GROUP_ID $like ".
+                " $order_by $limit";
+        }
         $result = $db->execute($sql, $param_array);
         $groups = [];
         while ($group = $db->fetchArray($result)) {
@@ -1949,7 +1956,7 @@ class GroupModel extends Model implements MediaConstants
                             foreach ($points as $point) {
                                 preg_match("/^\s*\((.+)\,(.+)\)\s*$/",
                                     $point, $point_matches);
-                                if(empty($point_matches[2])) {
+                                if (empty($point_matches[2])) {
                                     break;
                                 }
                                 $x_values[] = $point_matches[1];
@@ -2359,7 +2366,7 @@ EOD;
     {
         if ($spreadsheet_coords &&
             is_array($spreadsheet_coords) && count($spreadsheet_coords) <= 2) {
-            if(count($spreadsheet_coords) == 1) {
+            if (count($spreadsheet_coords) == 1) {
                 $spreadsheet_coords[] = $spreadsheet_coords[0];
             }
         } else {
@@ -2711,7 +2718,7 @@ EOD;
                 return $sub_out;
             }
             if (is_array($sub_out[1])) {
-                for($i = 0 ; $i < count($sub_out[1]); $i++) {
+                for ($i = 0 ; $i < count($sub_out[1]); $i++) {
                     array_push($out[1], $sub_out[1][$i]);
                 }
             } else {
@@ -3231,7 +3238,7 @@ EOD;
             $file_size = strlen($data);
             $vcs->headPutContents("$folder/$file_name", $data);
         }
-        $this->makeThumbStripExif($file_name, $folder, $thumb_folder,
+        $this->makeThumbStripExif ($file_name, $folder, $thumb_folder,
             $mime_type);
         if (C\nsdefined('FFMPEG') && in_array($mime_type, [
             'video/mp4', 'video/webm', 'video/ogg', 'video/avi',
@@ -3333,7 +3340,7 @@ EOD;
      * @param string $mime_type the mime type of the file
      * @return bool whether a thumb was made or not
      */
-    function makeThumbStripExif($file_name, $folder, $thumb_folder,
+    function makeThumbStripExif ($file_name, $folder, $thumb_folder,
         $mime_type = "")
     {
         if ($mime_type == "") {
@@ -3545,7 +3552,7 @@ EOD;
             } else if ($thumb_folder && !$resource['is_dir'] &&
                 time() < $time + C\PAGE_TIMEOUT/2) {
                 $resource['has_thumb'] =
-                    $this->makeThumbStripExif($name, $folder, $thumb_folder);
+                    $this->makeThumbStripExif ($name, $folder, $thumb_folder);
             }
             $resources[] = $resource;
         }
@@ -3721,4 +3728,4 @@ EOD;
         }
         return $bots;
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/AdminmenuElement.php b/src/views/elements/AdminmenuElement.php
index c05dcf291..49a34f702 100644
--- a/src/views/elements/AdminmenuElement.php
+++ b/src/views/elements/AdminmenuElement.php
@@ -52,6 +52,7 @@ class AdminmenuElement extends Element
      */
     public function render($data)
     {
+        $data = editChatGroupName($data);
         $logged_in = !empty($data["ADMIN"]);
         $is_submenu = false;
         $admin_prefix = "";
@@ -151,4 +152,4 @@ class AdminmenuElement extends Element
         </nav>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/Element.php b/src/views/elements/Element.php
index 0a993c74b..9ef1e1951 100755
--- a/src/views/elements/Element.php
+++ b/src/views/elements/Element.php
@@ -58,6 +58,65 @@ function e($text)
 {
     echo $text;
 }
+/* To edit chat group name*/
+function editChatGroupName($data)
+{
+    if (isset($data['GROUPS'])) {
+        foreach ($data['GROUPS'] as $key  => $group_value) {
+            if (str_contains($group_value['GROUP_NAME'],
+                "Chats" . "$")) {
+                $data['GROUPS'][$key]['GROUP_NAME'] = tl('element_chat_name');
+                break;
+            }
+        }
+    }
+    if (isset($data['PAGES'])) {
+        $data['SUBTITLE'] = tl('element_chat_name');
+        foreach ($data['PAGES'] as $key  => $page_value) {
+            if (str_contains($data['PAGES'][$key]['ci'],
+                "Chats" . "$" . $data['USERNAME'])) {
+                if (isset($data['GROUP_NAME'])) {
+                    $data['GROUP_NAME'] = tl('element_chat_name');;
+                }
+                $data['PAGES'][$key]['ci'] = tl('element_chat_name');;
+                $strS = $data['PAGES'][$key]['s'];
+                $chatPos = strpos($strS, tl('element_chat_name'));
+                $str1 = substr($strS, $chatPos);
+                $str1 = substr($strS, 0, -strlen($str1));
+                $data['PAGES'][$key]['s'] = $str1 . tl('element_chat_name');
+                $strT = $data['PAGES'][$key]['t'];
+                $chatPos = strpos($strT, tl('element_chat_name'));
+                $str1 = substr($strT, $chatPos);
+                $str1 = substr($strT, 0, -strlen($str1));
+                $data['PAGES'][$key]['t'] = trim($str1) . " " . tl('element_chat_name');
+                break;
+            }
+        }
+    }
+    if (isset($data['GROUP']) && str_contains($data['GROUP']['GROUP_NAME'],
+        "Chats" . "$" . $data['USERNAME'])) {
+        $data['GROUP']['GROUP_NAME'] = tl('element_chat_name');
+    }
+    if (isset($data['CURRENT_GROUP']) && str_contains($data['CURRENT_GROUP']['name'],
+        "Chats" ."$" . $data['USERNAME'])) {
+        $data['CURRENT_GROUP']['name'] = tl('element_chat_name');
+    }
+    if (is_string($data)) {
+        return tl('element_chat_name');
+    }
+    return $data;
+}
+/*To edit wiki page side bar*/
+function editOptions($group_name, $options){
+    foreach ($options as $key  => $option_value) {
+        if (str_contains($option_value, "Chats")) {
+            $strS = $option_value;
+            $str1 = substr($strS, -(strlen($strS)-strlen($group_name)));
+            $options[$key] = tl('element_chat_name') . " " . $str1;
+        }
+    }
+    return $options;
+}
 /**
  * Base Element Class.
  * Elements are classes are used to render portions of
@@ -120,4 +179,4 @@ abstract class Element
                 tl('element_settings_toggle').'">&equiv;</span>');
         }?></div></div><?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/GroupbarElement.php b/src/views/elements/GroupbarElement.php
index e76d028ce..eb14e14bd 100644
--- a/src/views/elements/GroupbarElement.php
+++ b/src/views/elements/GroupbarElement.php
@@ -49,6 +49,7 @@ class GroupbarElement extends Element
      */
     public function render($data)
     {
+        $data = editChatGroupName($data);
         if (isset($data["HEAD"]['page_type']) &&
             $data["HEAD"]['page_type'] == 'presentation' &&
             $data['MODE'] == 'read' ) {
@@ -160,4 +161,4 @@ class GroupbarElement extends Element
         </div>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/GroupfeedElement.php b/src/views/elements/GroupfeedElement.php
index 7dabe0f8d..5cdb900f4 100644
--- a/src/views/elements/GroupfeedElement.php
+++ b/src/views/elements/GroupfeedElement.php
@@ -51,6 +51,7 @@ class GroupfeedElement extends Element implements CrawlConstants
      */
     public function render($data)
     {
+        $data = editChatGroupName($data);
         $logged_in = !empty($data["ADMIN"]);
         $is_status = isset($data['STATUS']);
         $is_api = !empty($data['API']);
@@ -136,13 +137,19 @@ class GroupfeedElement extends Element implements CrawlConstants
         <h2><?=
             tl('groupfeed_element_my_groups') ?></h2><?php
         foreach ($data['GROUPS'] as $group) {
+            if (str_contains($group['GROUP_NAME'],
+                "Chats$".$data['USERNAME'])) {
+                $group_name = "Chats";
+            } else {
+                $group_name = $group['GROUP_NAME'];
+            }
             e("<div class=\"access-result\">" .
                 "<div><b>" .
                 "<a href=\"". htmlentities(
                 B\feedsUrl("group", $group['GROUP_ID'], true,
                 $data['CONTROLLER'])) . $token_string . "&amp;v=grouped" .
                 "\" rel=\"nofollow\">" .
-                $group['GROUP_NAME'] . "</a> " .
+                $group_name . "</a> " .
                 "[<a href=\"".htmlentities(
                 B\wikiUrl("", true, $data['CONTROLLER'],
                     $group['GROUP_ID'])) . $token_string .
@@ -726,12 +733,16 @@ class GroupfeedElement extends Element implements CrawlConstants
             $token_string = C\CSRF_TOKEN . "=". $data[C\CSRF_TOKEN];
             $add_options[tl('groupfeed_element_recent_groups')] = "";
             $found_new = false;
+            $options[tl('groupfeed_element_recent_groups')] = "";
             foreach ($data['RECENT_GROUPS'] as $group_name => $url) {
                 $out_token = (strstr($url, C\CSRF_TOKEN) === false) ?
                     $token_string : "";
                 if (!empty($out_token) && (strstr($url, "?") === false)) {
                     $url .= "?";
                 }
+                if (str_contains($group_name, "Chats$".$data['USERNAME'])) {
+                    $group_name = "Chats";
+                }
                 if (empty($options[$url . $out_token])) {
                     $add_options[$url . $out_token] =
                         $group_name ;
@@ -739,7 +750,7 @@ class GroupfeedElement extends Element implements CrawlConstants
                 }
             }
             if ($found_new) {
-                $options = array_merge($options, $add_options);
+                $options[$url . $token_string] = $group_name;
             }
         }
         $this->view->helper('options')->renderLinkDropDown('feed-path',
@@ -979,4 +990,4 @@ class GroupfeedElement extends Element implements CrawlConstants
         </script>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/GroupmenuElement.php b/src/views/elements/GroupmenuElement.php
index a6b06a5cd..51aaaeaf8 100644
--- a/src/views/elements/GroupmenuElement.php
+++ b/src/views/elements/GroupmenuElement.php
@@ -52,6 +52,7 @@ class GroupmenuElement extends Element implements CrawlConstants
      */
     public function render($data)
     {
+        $data = editChatGroupName($data);
         $logged_in = !empty($data["ADMIN"]);
         $is_wiki = isset($data['ELEMENT']) && $data['ELEMENT'] == 'wiki';
         $token_string = ($logged_in && isset($data[C\CSRF_TOKEN])) ?
@@ -281,4 +282,4 @@ class GroupmenuElement extends Element implements CrawlConstants
         </nav>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/ManageaccountElement.php b/src/views/elements/ManageaccountElement.php
index 21c464225..e279b44c1 100755
--- a/src/views/elements/ManageaccountElement.php
+++ b/src/views/elements/ManageaccountElement.php
@@ -50,6 +50,13 @@ class ManageaccountElement extends Element
      */
     public function render($data)
     {
+        foreach ($data['GROUPS'] as $key  => $groupValue) {
+            if (str_contains($groupValue['GROUP_NAME'],
+                "Chats$".$data['USERNAME'])) {
+                $data['GROUPS'][$key]['GROUP_NAME'] = "Chats";
+                break;
+            }
+        }
         $token = C\CSRF_TOKEN . "=". $data[C\CSRF_TOKEN];
         $admin_url = htmlentities(B\controllerUrl('admin', true));
         $feed_url =  htmlentities(B\feedsUrl("", "",
@@ -395,4 +402,4 @@ class ManageaccountElement extends Element
         </div>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/ManagegroupsElement.php b/src/views/elements/ManagegroupsElement.php
index e14baec32..b8fb3fd9d 100755
--- a/src/views/elements/ManagegroupsElement.php
+++ b/src/views/elements/ManagegroupsElement.php
@@ -51,6 +51,7 @@ class ManagegroupsElement extends Element
      */
     public function render($data)
     {
+        $data = editChatGroupName($data);
         $admin_url = htmlentities(B\controllerUrl("admin", true));
         $token_string = C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN];
         ?>
@@ -374,6 +375,7 @@ class ManagegroupsElement extends Element
      */
     public function renderGroupsForm($data)
     {
+        $data = editChatGroupName($data);
         $admin_url = htmlentities(B\controllerUrl('admin', true));
         $base_url = $admin_url . C\CSRF_TOKEN . "=" . $data[C\CSRF_TOKEN].
             "&amp;a=manageGroups&amp;visible_users=" . $data['visible_users'];
@@ -1100,4 +1102,4 @@ class ManagegroupsElement extends Element
         </table>
         <?php
     }
-}
+}
\ No newline at end of file
diff --git a/src/views/elements/WikiElement.php b/src/views/elements/WikiElement.php
index 1813c5bf9..04ea1d85c 100644
--- a/src/views/elements/WikiElement.php
+++ b/src/views/elements/WikiElement.php
@@ -480,6 +480,25 @@ class WikiElement extends Element implements CrawlConstants
                 maxlength="<?= C\SHORT_TITLE_LEN ?>" class="wide-field"/>
             </div>
             </div>
+            <?php $shortenedURL = '';
+            if ($data['url_shortener']) {
+                $shortenedURL = C\BASE_URL . "group/" . $_REQUEST['group_id'] . "/" . $_REQUEST['page_name'];
+            }?>
+            <div id='url-shortener'>
+            <div class="top-margin">
+            <label for="url-shortener"><b><?=tl('wiki_element_url_shortener')
+            ?></b></label><input type="text" id='url_shortener'
+                name="url_shortener" value="<?= $data['url_shortener']?>"
+                class="wide-field"/>
+            </div>
+            </div>
+            <div id='short-url-label'>
+            <div class="top-margin">
+            <label for="short-url-label"><b><?=tl('wiki_element_shortURL_label')
+            ?></b></label><label for="short-url-label"><b>
+            <?=$shortenedURL?></b></label>
+            </div>
+            </div>
             <div id='non-alias-type'>
             <div class="top-margin">
             <label for="page-border"><b><?=tl('wiki_element_page_border')
@@ -613,7 +632,7 @@ class WikiElement extends Element implements CrawlConstants
         <p><?= tl('wiki_element_ml_description')?></p>
         </div>
         <?php
-        if ($show_resources) {
+        if ($show_resources && $data['page_type'] != "url_shortener") {
         ?>
         <div id="page-resources">
         <h3><?= tl('wiki_element_page_resources')?></h3>
@@ -895,7 +914,7 @@ class WikiElement extends Element implements CrawlConstants
                             $written_name = $name_parts['filename'] .
                                 "[".tl('wiki_element_audio')."]";
                         } else if ($name_parts['extension'] == "vtt") {
-                            if( $read_mode) {
+                            if ( $read_mode) {
                                 continue;
                             }
                             $use_editable_thumb = true;
@@ -1145,6 +1164,10 @@ class WikiElement extends Element implements CrawlConstants
         $selected_url = "", $top_name = "", $render_type = "paths",
         $as_list = false)
     {
+        if (str_contains($data['GROUP']['GROUP_NAME'],
+            "Chats" . "$" . $data['USERNAME'])) {
+            $options = editOptions($data['GROUP']['GROUP_NAME'], $options);
+        }
         $folder_prefix = "";
         if (empty($options)) {
             $options = [];
@@ -1216,6 +1239,10 @@ class WikiElement extends Element implements CrawlConstants
                 $add_options = [tl('wiki_element_recent_groups') => ""];
                 $found_new = false;
                 foreach ($data['RECENT_GROUPS'] as $group_name => $url) {
+                    if (str_contains($group_name,
+                        "Chats" . "$" . $data['USERNAME'])) {
+                        $group_name = editChatGroupName($group_name);
+                    }
                     $out_token = (strstr($url, C\CSRF_TOKEN) === false) ?
                         $token_string : "";
                     if (!empty($out_token) && (strstr($url, "?") === false)) {
@@ -1754,4 +1781,4 @@ class WikiElement extends Element implements CrawlConstants
         }
         return $pre_page;
     }
-}
+}
\ No newline at end of file
-- 
2.29.2.windows.3

