[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Allow self-assignment to groups with userChoice in user_group_modify action
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a034c9ba7774_38ac0af83205d@gitlab-sidekiq-low-urgency-cpu-bound-v2-8b6f44c4b-prbg9.mail> |
Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
aa99ead6 by Bernard Sfez at 2026-05-12T15:33:20+00:00
[FIX] Allow self-assignment to groups with userChoice in user_group_modify action
---
* Fix PHPCS: add missing newline at end of file
* Allow self-assignment to groups with userChoice in user_group_modify action
See merge request tikiwiki/tiki!10164
- - - - -
1 changed file:
- lib/core/Search/Action/UserGroupModify.php
Changes:
=====================================
lib/core/Search/Action/UserGroupModify.php
=====================================
@@ -71,36 +71,51 @@ class Search_Action_UserGroupModify implements Search_Action_Action
public function execute(JitFilter $data)
{
$lib = TikiLib::lib('user');
- $user = $data->user->text();
+ $targetUsers = $data->user->text();
$add = $data->add->text();
$remove = $data->remove->text();
$operation = $data->operation->word();
$value = $data->value->text();
+ // Determine operation type
+ $isAddOperation = (! empty($add) || $operation === 'add');
+ $permName = $isAddOperation ? 'group_add_member' : 'group_remove_member';
+
+ if (! is_array($targetUsers)) {
+ $targetUsers = [$targetUsers];
+ }
+
+ // Resolve target group from add/remove/operation inputs
if ($add) {
- $permName = 'group_add_member';
$group = $add;
} elseif ($remove) {
- $permName = 'group_remove_member';
$group = $remove;
- } elseif ($operation == 'add') {
- $permName = 'group_add_member';
- $group = $value;
- } elseif ($operation == 'remove') {
- $permName = 'group_remove_member';
+ } elseif (! empty($value)) {
$group = $value;
} else {
- throw new Search_Action_Exception(tr('Failed exeucting user_group_modify: nothing to add or remove.'));
+ throw new Search_Action_Exception(tr('Failed executing user_group_modify: nothing to add or remove.'));
}
- if (! is_array($user)) {
- $user = [$user];
- }
+ $groupInfo = $lib->get_group_info($group);
+ $perms = Perms::get();
- foreach ($user as $u) {
+ global $user;
+ $currentUser = $user ?? null;
+
+ foreach ($targetUsers as $u) {
$userGroups = $lib->get_user_groups_inclusion($u);
- if (Perms::get()->$permName || (array_key_exists($group, $userGroups) && Perms::get()->group_join)) {
- if ($add || $operation == 'add') {
+
+ $canSelfJoin = $u === $currentUser
+ && $isAddOperation
+ && ($groupInfo['userChoice'] ?? null) === 'y';
+
+ $hasPermission =
+ $perms->$permName
+ || (! empty($userGroups[$group]) && $perms->group_join)
+ || $canSelfJoin;
+
+ if ($hasPermission) {
+ if ($isAddOperation) {
$lib->assign_user_to_group($u, $group);
} else {
$lib->remove_user_from_group($u, $group);
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/aa99ead62860da3702f74eaf94e875c11f18a709
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/aa99ead62860da3702f74eaf94e875c11f18a709
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs