User: Fix usergroup table loading and form updates - refs BT#22277

pull/5984/head
Christian Beeznest 9 months ago
parent 2476ea2bf7
commit 481e8998c9
  1. 6
      public/main/inc/lib/display.lib.php
  2. 25
      public/main/inc/lib/usergroup.lib.php

@ -1200,11 +1200,13 @@ class Display
// Default row quantity
if (!isset($extra_params['rowList'])) {
$extra_params['rowList'] = [20, 50, 100, 500, 1000, $all_value];
$defaultRowList = [20, 50, 100, 500, 1000, $all_value];
$rowList = api_get_setting('platform.table_row_list', true);
if (!empty($rowList) && isset($rowList['options'])) {
if (is_array($rowList) && isset($rowList['options']) && is_array($rowList['options'])) {
$rowList = $rowList['options'];
$rowList[] = $all_value;
} else {
$rowList = $defaultRowList;
}
$extra_params['rowList'] = $rowList;
}

@ -1371,7 +1371,7 @@ class UserGroupModel extends Model
}
$result = Database::store_result(
Database::query("SELECT u.* FROM $sqlFrom WHERE $sqlWhere ORDER BY title $sord LIMIT $start, $limit")
Database::query("SELECT DISTINCT u.* FROM $sqlFrom WHERE $sqlWhere ORDER BY title $sord LIMIT $start, $limit")
);
$new_result = [];
@ -1588,8 +1588,9 @@ class UserGroupModel extends Model
return false;
}
public function update($params, $showQuery = false)
public function update($params, $showQuery = false): bool
{
$em = Database::getManager();
$repo = Container::getUsergroupRepository();
/** @var Usergroup $userGroup */
$userGroup = $repo->find($params['id']);
@ -1597,7 +1598,22 @@ class UserGroupModel extends Model
return false;
}
//$params['updated_on'] = api_get_utc_datetime();
if (isset($params['title'])) {
$userGroup->setTitle($params['title']);
}
if (isset($params['description'])) {
$userGroup->setDescription($params['description']);
}
if (isset($params['visibility'])) {
$userGroup->setVisibility($params['visibility']);
}
if (isset($params['url'])) {
$userGroup->setUrl($params['url']);
}
$userGroup
->setGroupType(isset($params['group_type']) ? Usergroup::SOCIAL_CLASS : Usergroup::NORMAL_CLASS)
->setAllowMembersToLeaveGroup(isset($params['allow_members_leave_group']) ? 1 : 0)
@ -1612,7 +1628,8 @@ class UserGroupModel extends Model
}
}
$repo->update($userGroup);
$em->persist($userGroup);
$em->flush();
if (isset($params['delete_picture'])) {
$this->delete_group_picture($params['id']);

Loading…
Cancel
Save