[SOLVED] CBSubs undoes group-add actions

9 years 9 months ago #247307 by krileon
Replied by krileon on topic Merged with above

We will implement this advice trapping for whether the user in question, is the user in the session -- however it raises the question about activations/deactivations peformed via other means (expiration, admin action). In other words we need it to work in all cases of activation/deactivation.

It will work in all cases, but it can only update the users session in database if the user is the one performing the action. For example this is relevant if you update the usergroups while the user is still browsing the site.

however I anticipate possible problems on this (i.e., if CB's objects need me to avoid direct table writes, but the present session is not applicable to the user who is subject to the status change, what do I do?)

The session has no effect on the storage. It's purely user browsing experience. For example lets say the user is logged in, I change his usergroups after he logs in, his session won't have the new usergroups. So any access associated with the new usergroups won't be seen by the user until they logout and back in again.

If this is done during registration or by CRON you don't need to bother with the session. It's only relevant if you change the usergroups while the user is already logged in.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: wlc11

Please Log in to join the conversation.

9 years 9 months ago - 9 years 9 months ago #247322 by wlc11
Replied by wlc11 on topic Merged with above
Tagging OP solved! Thanks.

I didn't fully understand your solution at first and apologize for that.

If this section of the forum is meant to contain solutions for posterity, I suggest editing the code block in one of your messages just a tad; my changes are noted in the right margin; the major one tripping me up was jUser vs user.
$session	=	JFactory::getSession();
$jUser		=	$session->get( 'user' );

$groups		=	$user->gids;                         // these 3 lines added
// make whatever modifications to their gids e.g.:
$groups[]	=	$group_id;

$user->gids	=	$groups;
 
$user->store();
 
if ( $jUser->id == $user->id ) {
	JAccess::clearStatics();
 
	$session->set( 'user', new JUser( $jUser->id ) );    // correct user var
}

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.162 seconds

Facebook Twitter LinkedIn