Skip to content

Commit

Permalink
User: Fix usergroup table loading and form updates - refs BT#22277
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbeeznest committed Dec 17, 2024
1 parent 2476ea2 commit 481e899
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
6 changes: 4 additions & 2 deletions public/main/inc/lib/display.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,11 +1200,13 @@ public static function grid_js(

// 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;
}
Expand Down
25 changes: 21 additions & 4 deletions public/main/inc/lib/usergroup.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ public function getUsergroupsPagination($sidx, $sord, $start, $limit, $extraWher
}

$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 = [];
Expand Down Expand Up @@ -1588,16 +1588,32 @@ public function save($params, $showQuery = false)
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']);
if (null === $userGroup) {
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)
Expand All @@ -1612,7 +1628,8 @@ public function update($params, $showQuery = false)
}
}

$repo->update($userGroup);
$em->persist($userGroup);
$em->flush();

if (isset($params['delete_picture'])) {
$this->delete_group_picture($params['id']);
Expand Down

0 comments on commit 481e899

Please sign in to comment.