]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Group.php
Misc cleanups (#5417)
[friendica.git] / src / Model / Group.php
index f48dd5043190bc56b891a49caeda1527c81f6391..79604e2ca0b7e2948c071ca833c1993507da52bd 100644 (file)
@@ -40,7 +40,7 @@ class Group extends BaseObject
                                // was restricted to this group may now be seen by the new group members.
                                $group = dba::selectFirst('group', ['deleted'], ['id' => $gid]);
                                if (DBM::is_result($group) && $group['deleted']) {
-                                       dba::update('group', ['deleted' => 0], ['gid' => $gid]);
+                                       dba::update('group', ['deleted' => 0], ['id' => $gid]);
                                        notice(L10n::t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
                                }
                                return true;
@@ -54,6 +54,19 @@ class Group extends BaseObject
                return $return;
        }
 
+       /**
+        * Update group information.
+        *
+        * @param  int    $id   Group ID
+        * @param  string $name Group name
+        *
+        * @return bool Was the update successful?
+        */
+       public static function update($id, $name)
+       {
+               return dba::update('group', ['name' => $name], ['id' => $id]);
+       }
+
        /**
         * @brief Get a list of group ids a contact belongs to
         *
@@ -138,7 +151,7 @@ class Group extends BaseObject
                        return false;
                }
 
-               $group = dba::selectFirst('group', ['uid'], ['gid' => $gid]);
+               $group = dba::selectFirst('group', ['uid'], ['id' => $gid]);
                if (!DBM::is_result($group)) {
                        return false;
                }
@@ -348,7 +361,7 @@ class Group extends BaseObject
         * @param int $cid
         * @return string
         */
-       public static function sidebarWidget($every = 'contacts', $each = 'group', $editmode = 'standard', $group_id = 0, $cid = 0)
+       public static function sidebarWidget($every = 'contacts', $each = 'group', $editmode = 'standard', $group_id = '', $cid = 0)
        {
                $o = '';
 
@@ -360,7 +373,7 @@ class Group extends BaseObject
                        [
                                'text' => L10n::t('Everybody'),
                                'id' => 0,
-                               'selected' => (($group_id == 0) ? 'group-selected' : ''),
+                               'selected' => (($group_id === 'everyone') ? 'group-selected' : ''),
                                'href' => $every,
                        ]
                ];
@@ -404,6 +417,7 @@ class Group extends BaseObject
                        'grouppage' => 'group/',
                        '$edittext' => L10n::t('Edit group'),
                        '$ungrouped' => $every === 'contacts' ? L10n::t('Contacts not in any group') : '',
+                       '$ungrouped_selected' => (($group_id === 'none') ? 'group-selected' : ''),
                        '$createtext' => L10n::t('Create a new group'),
                        '$creategroup' => L10n::t('Group Name: '),
                        '$editgroupstext' => L10n::t('Edit groups'),