Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Display user's group next to username

Display user's group next to username 2 years 3 weeks ago #111367

  • dweisser
  • dweisser's Avatar
  • Offline
  • Gold Lime
  • Posts: 222
  • Thank you received: 5
  • Karma: 5
When a user logs in, I need to display the group to which the user belong as well.
I can't seem to figure out how to do it. :-)
Any advice would be much appreciated.
David
Attachments:
The administrator has disabled public write access.

Display user's group next to username 2 years 2 weeks ago #111383

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9298
  • Thank you received: 1330
  • Karma: 386
A user don't have only one group ...

Then you need to:
- Get the user group's : Yii... findAll
- Show the list of user group

Denis
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Display user's group next to username 2 years 2 weeks ago #111385

  • dweisser
  • dweisser's Avatar
  • Offline
  • Gold Lime
  • Posts: 222
  • Thank you received: 5
  • Karma: 5
I really have no idea how to implement that. I found another post where the limer was trying to get int on the statistics page, but I'm trying to show it in the header.php.
The administrator has disabled public write access.

Display user's group next to username 1 year 11 months ago #112532

  • c_schmitz
  • c_schmitz's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 1008
  • Thank you received: 135
  • Karma: 97
Ehm, so you want to code something but you have no clue how to code?
Best regards

Carsten Schmitz
LimeSurvey project leader
The administrator has disabled public write access.

Display user's group next to username 1 year 11 months ago #112541

  • dweisser
  • dweisser's Avatar
  • Offline
  • Gold Lime
  • Posts: 222
  • Thank you received: 5
  • Karma: 5
Well, I wouldn't say no idea, but I admit, I'm out of my element. :(
I gather from Denis that is not as simple as this to show the user's group:
$string_user = Yii::app()->session['user'];

I found this in another post that seems to execute what Denis describes, but when I place it into header.php, after checking to see whether the user is logged in, the page breaks:
if(Yii::app()->session['loginID']) {  
 
	$oUserId= User::model()->findByPk(Yii::app()->session);
	$oUserInGroup= UserInGroup::model()->find('uid= :uid',array(':uid'=>$oUserId->uid);
	$oUserGroup=UserGroup::model()->find('ugid= :ugid',array(':ugid'=>$oUserInGroup->ugid);
 
}
Any nudge in the right direction would be appreciated - as always.

David
Last Edit: 1 year 11 months ago by dweisser.
The administrator has disabled public write access.

Display user's group next to username 1 year 11 months ago #112543

  • c_schmitz
  • c_schmitz's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 1008
  • Thank you received: 135
  • Karma: 97
No, because a user can be member of multiple groups at the same time.
So you will need to query the database tables to find of which groups he/she is a member of.
Check out existing code and the Yii manual how a database query is done. Also some SQL knowledge is usually required.
Best regards

Carsten Schmitz
LimeSurvey project leader
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.242 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form