? ? Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
13 Aug 2020

Pull Request for Issue #30324.

Summary of Changes

all credits goes to @veperr

Testing Instructions

  • create a group, get groupId
  • create a user, get userId
  • add user to group
  • try to remove user from group using: UserHelper::removeUserFromGroup($userId, $groupId)

for the last point i've used the CLI command php cli/joomla.php user:removefromgroup

Actual result BEFORE applying this Pull Request

despite the successfull message from CLI command the user is not removed from that group ie it is not removed from the #__user_usergroup_map table

Expected result AFTER applying this Pull Request

the user is removed correctly from that table

avatar alikon alikon - open - 13 Aug 2020
avatar alikon alikon - change - 13 Aug 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Aug 2020
Category Libraries
avatar ceford ceford - test_item - 13 Aug 2020 - Tested successfully
avatar ceford
ceford - comment - 13 Aug 2020

I have tested this item successfully on 127ef93

Works as described.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar sandewt sandewt - test_item - 13 Aug 2020 - Tested unsuccessfully
avatar sandewt
sandewt - comment - 13 Aug 2020

I have tested this item ? unsuccessfully on 127ef93

Joomla! 4.0.0-beta4-dev Development [ Mañana ] 29-July-2020 18:21 GMT

See comment.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar sandewt
sandewt - comment - 13 Aug 2020

screen shot 2020-08-13 at 16 31 04

Result:
screen shot 2020-08-13 at 16 31 05


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar veperr
veperr - comment - 13 Aug 2020

For clarification, the usage that failed for me (as reported in issue 30324) was calling UserHelper::removeUserFromGroup($userId, $groupId) from PHP code.
I did not try the CLI.

One the other hand I wrote a minimal custom function that did the job:
private function removeUserFromGroup($userId, $groupId){
$user = User::getInstance($userId);
// $user = new User($userId);
// $user->load($userId);
$userGrps = Access::getGroupsByUser($userId, false);

unset($userGrps[array_search($groupId, $userGrps)]);

$user->groups = $userGrps;
$user->save();

// Store the data.
if (!$user->save())
{
$this->setError($user->getError());

return false;

}
return $user->id;
}


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar alikon alikon - change - 15 Aug 2020
Labels Added: ?
avatar alikon
alikon - comment - 15 Aug 2020

please retest

avatar sandewt sandewt - test_item - 15 Aug 2020 - Tested successfully
avatar sandewt
sandewt - comment - 15 Aug 2020

I have tested this item successfully on 1d44613

Joomla! 4.0.0-beta4-dev Development [ Mañana ] 29-July-2020 18:21 GMT


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar Quy Quy - test_item - 2 Sep 2020 - Tested successfully
avatar Quy
Quy - comment - 2 Sep 2020

I have tested this item successfully on 1d44613


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar Quy Quy - change - 2 Sep 2020
Status Pending Ready to Commit
avatar Quy Quy - edited - 2 Sep 2020
avatar Quy
Quy - comment - 2 Sep 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30355.

avatar wilsonge wilsonge - change - 15 Sep 2020
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-09-15 11:27:38
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 15 Sep 2020
avatar wilsonge wilsonge - merge - 15 Sep 2020
avatar wilsonge
wilsonge - comment - 15 Sep 2020

Thanks!

Add a Comment

Login with GitHub to post a comment