?
Solved

yii user management

Posted on 2012-09-15
5
Medium Priority
?
429 Views
Last Modified: 2014-09-29
Hi, I am trying to get yii user management to work. There seems to be a number of problems with this extension. I am a newbie to yii, so maybe I'm expecting too much from it.
Anyway, the first issue is allowing guest user to access a profile page(rather than be redirected to login)

In the ProfileModule.php. I changed this from false to true:
	
// set this to true to allow all users to access user profiles
public $profilesViewableByGuests = true;

Open in new window


This seems to have no affect. I thought this would override the controller?
Anyway, I then edited YumProfileController to allow all users to view and index
public function accessRules()
	{
		return array(
			array('allow',
				'actions'=>array('index', 'admin', 'visits'),
				'expression' => 'Yii::app()->user->isAdmin()'
				),
			array('allow',
				'actions'=>array('view', 'update', 'edit'),
				'users' => array('@'),
				),

			array('allow',  // allow all users to perform 'index' and 'view' actions
                                'actions'=>array('index','view'),
                                'users'=>array('*'),
                        ),

                       /* array('deny',  // deny all users
				'users'=>array('*'),
			),*/
		);
	}

Open in new window


This resulted in a partial page with no header
<div id="profile">........

</div>

Open in new window

and an error
Call to a member function getFriends() on a non-object in /protected/modules/friendship/controllers/YumFriendshipController.php on line 150

Open in new window


YumFriendship model

public function getFriend() {
    if($this->friend_id == Yii::app()->user->id)
        return $this->inviter->username;
    else
        return $this->invited->username;
}

Open in new window


I understand this is because there is no user id as they are a guest but then you start getting into recoding.

The impression is there should be functionality in the extension for this basic requirement without a recode?

If anyone has used yii-user-management with guest user access to view a profile , I would really appreciate your help.

I have posted in several places but it seems no-one can answer this?
0
Comment
Question by:mmguide
1 Comment
 
LVL 1

Accepted Solution

by:
PrplHaz4 earned 2000 total points
ID: 38763723
You are correct that there are a number of problems with this extension - that being said, there are a lot of people using it, and it does prevent you from having to code a lot of things.

For the $profilesViewableByGuests setting, I beleive it is actually mis-named - it would be more accurately named $profileViewableByAuthenticatedUsers.  As you can see in the accessRules:
public function accessRules()
	{
		return array(
			array('allow',
				'actions'=>array('index', 'admin', 'visits'),
				'expression' => 'Yii::app()->user->isAdmin()'
				),
			array('allow',
				'actions'=>array('view', 'update', 'edit'),
				'users' => array('@'),
				),

			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}

Open in new window

the view action is only allowed for AUTHENTICATED ("@") users.

My suggestion would be to override the profile controller, and add an action called guestview or something - so it does not conflict.  Here you can allow ALL (*) users, and define your own accompanying views that render the data you're interested in (likely will be a near-copy of the existing profile view, with some fields removed, and the friend information omitted.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question