Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Display user's group next to username

Display user's group next to username 8 Monate 2 Wochen her #111367

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 205
  • Dank erhalten: 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
Anhang:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Display user's group next to username 8 Monate 2 Wochen her #111383

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 7020
  • Dank erhalten: 939
  • Karma: 282
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Display user's group next to username 8 Monate 2 Wochen her #111385

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 205
  • Dank erhalten: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Display user's group next to username 7 Monate 2 Tage her #112532

  • c_schmitz
  • c_schmitzs Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 859
  • Dank erhalten: 124
  • Karma: 95
Ehm, so you want to code something but you have no clue how to code?
Support us, too. Donate to the LimeSurvey project and help keep us going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Display user's group next to username 7 Monate 2 Tage her #112541

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Gold Lime
  • Beiträge: 205
  • Dank erhalten: 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
Letzte Änderung: 7 Monate 2 Tage her von dweisser.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Display user's group next to username 7 Monate 2 Tage her #112543

  • c_schmitz
  • c_schmitzs Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 859
  • Dank erhalten: 124
  • Karma: 95
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.
Support us, too. Donate to the LimeSurvey project and help keep us going!
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.244 Sekunden
Donation Image