-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User: Fix usergroup table loading and form updates - refs BT#22277 #5984
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method grid_js uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. |
||
$rowList = $defaultRowList; | ||
} | ||
$extra_params['rowList'] = $rowList; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = []; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing function doc comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method update() has an NPath complexity of 768. The configured NPath complexity threshold is 200. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid unused parameters such as '$showQuery'. |
||
{ | ||
$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) | ||
|
@@ -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']); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable "all_value" is not in valid camel caps format