Yii Framework Forum: Yum Profile Not Work - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yum Profile Not Work Property "YumUser.profile" is not defined. Rate Topic: -----

#1 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 31 May 2013 - 05:03 AM

Hi there,

I'm installed Yii User Management (Yum) extension in my project. It's ok when I'm using The User Module. But there is a error when I'm access Profile Modules as following link "../profile/profile/update/id/1". It brought me a error page : Property "YumUser.profile" is not defined.

any ideas?
Thanks for support :)
Regards
0

#2 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 31 May 2013 - 05:18 AM

View Postlogos010, on 31 May 2013 - 05:03 AM, said:

Hi there,

I'm installed Yii User Management (Yum) extension in my project. It's ok when I'm using The User Module. But there is a error when I'm access Profile Modules as following link "../profile/profile/update/id/1". It brought me a error page : Property "YumUser.profile" is not defined.

any ideas?
Thanks for support :)
Regards


Hi there,

after review the error, I found it may be caused by the relations in YumUser. In YumUser model, there is a relation function which return an array of relations but it is cached? I have no idea for this type of relation because I've ever did it before:
// possible relations are cached because they depend on the active submodules
	// and it takes many expensive milliseconds to evaluate them all the time
	public function relations()
	{
		Yii::import('application.modules.profile.models.*');

		$relations = Yii::app()->cache->get('yum_user_relations');
		if($relations === false) {
			$relations = array();

			if (Yum::hasModule('role')) {
				Yii::import('application.modules.role.models.*');
				$relations['permissions'] = array(
						self::HAS_MANY, 'YumPermission', 'principal_id');

				$relations['managed_by'] = array(
						self::HAS_MANY, 'YumPermission', 'subordinate_id');

				$relations['roles'] = array(
						self::MANY_MANY, 'YumRole',
						Yum::module('role')->userRoleTable . '(user_id, role_id)');
			}

			if (Yum::hasModule('message')) {
				Yii::import('application.modules.message.models.*');
				$relations['messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'order' => 'timestamp DESC');

				$relations['unread_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'condition' => 'message_read = 0',
						'order' => 'timestamp DESC');

				$relations['sent_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'from_user_id');

			}

			if (Yum::hasModule('profile')) {
				$relations['visits'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visited_id');
				$relations['visited'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visitor_id');
				$relations['profile'] = array(
						self::HAS_ONE, 'YumProfile', 'user_id');
				$relations['privacy'] = array(
						self::HAS_ONE, 'YumPrivacySetting', 'user_id');
			}

			if (Yum::hasModule('friendship')) {
				$relations['friendships'] = array(
						self::HAS_MANY, 'YumFriendship', 'inviter_id');
				$relations['friendships2'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id');
				$relations['friendship_requests'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id',
						'condition' => 'status = 1'); // 1 = FRIENDSHIP_REQUEST
			}

			if (Yum::hasModule('membership')) {
				Yii::import('application.modules.membership.models.*');
				$relations['memberships'] = array(
						self::HAS_MANY, 'YumMembership', 'user_id');
			}

			Yii::app()->cache->set('yum_user_relations', $relations, 3600);
		}

		return $relations;
	}


anyone help?
Thanks
0

#3 User is offline   CSnet 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 08-May 13
  • Location:Spain

Posted 01 June 2013 - 06:47 AM

View Postlogos010, on 31 May 2013 - 05:03 AM, said:

Hi there,

I'm installed Yii User Management (Yum) extension in my project. It's ok when I'm using The User Module. But there is a error when I'm access Profile Modules as following link "../profile/profile/update/id/1". It brought me a error page : Property "YumUser.profile" is not defined.

any ideas?
Thanks for support :)
Regards


Do you have in your "main.php" 'import application.modules.user.models.*' and the 'modules profile'?
.....
'import'=>array(
		'application.models.*',
		'application.components.*',
                'application.modules.user.models.*',
),
.....
'modules'=>array(
		'profile' => array(
			'privacySettingTable' => 'privacysetting',
			'profileFieldTable' => 'profile_field',
			'profileTable' => 'profile',
			'profileCommentTable' => 'profile_comment',
			'profileVisitTable' => 'profile_visit',
		),
),
.....

0

#4 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 02 June 2013 - 11:53 PM

Thanks CSNnet,

I tried to add profile's properties into main.php, but it is not work by alert a error message:

Property "YumUser.profile" is not defined.


any idea? help :(
0

#5 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 03 June 2013 - 11:08 PM

Hi guys,

Finally, I found a solution for the problem! I don't know does it matter about the running system, but this is some information my XAMPP Server:

Quote

XAMPP 1.7.3
PHP Version 5.3.1


So, I tried to change something in the models/YumUser/relations:

  • Remove cache comment
  • In condition, add an addition comment which check is the $relations is a null value


That's all, so, this is my whole code in models/YumUser/relations:

public function relations()
	{
		Yii::import('application.modules.profile.models.*');                

//		$relations = Yii::app()->cache->get('yum_user_relations');
		if($relations === false || is_null($relations)) {
			$relations = array();

			if (Yum::hasModule('role')) {
				Yii::import('application.modules.role.models.*');
				$relations['permissions'] = array(
						self::HAS_MANY, 'YumPermission', 'principal_id');

				$relations['managed_by'] = array(
						self::HAS_MANY, 'YumPermission', 'subordinate_id');

				$relations['roles'] = array(
						self::MANY_MANY, 'YumRole',
						Yum::module('role')->userRoleTable . '(user_id, role_id)');
			}

			if (Yum::hasModule('message')) {
				Yii::import('application.modules.message.models.*');
				$relations['messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'order' => 'timestamp DESC');

				$relations['unread_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'condition' => 'message_read = 0',
						'order' => 'timestamp DESC');

				$relations['sent_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'from_user_id');

			}

			if (Yum::hasModule('profile')) {
				$relations['visits'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visited_id');
				$relations['visited'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visitor_id');
				$relations['profile'] = array(
						self::HAS_ONE, 'YumProfile', 'user_id');
				$relations['privacy'] = array(
						self::HAS_ONE, 'YumPrivacySetting', 'user_id');
			}

			if (Yum::hasModule('friendship')) {
				$relations['friendships'] = array(
						self::HAS_MANY, 'YumFriendship', 'inviter_id');
				$relations['friendships2'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id');
				$relations['friendship_requests'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id',
						'condition' => 'status = 1'); // 1 = FRIENDSHIP_REQUEST
			}

			if (Yum::hasModule('membership')) {
				Yii::import('application.modules.membership.models.*');
				$relations['memberships'] = array(
						self::HAS_MANY, 'YumMembership', 'user_id');
			}

//			Yii::app()->cache->set('yum_user_relations', $relations, 3600);
		}

		return $relations;
	}


Hope this can help anyone has the same issue

This post has been edited by logos010: 03 June 2013 - 11:09 PM

0

#6 User is offline   JimBond 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 22-March 13

Posted 11 June 2013 - 08:40 PM

I have implement the code.. but i got

Error 500
Undefined variable: relations



View Postlogos010, on 03 June 2013 - 11:08 PM, said:

Hi guys,

Finally, I found a solution for the problem! I don't know does it matter about the running system, but this is some information my XAMPP Server:



So, I tried to change something in the models/YumUser/relations:

  • Remove cache comment
  • In condition, add an addition comment which check is the $relations is a null value


That's all, so, this is my whole code in models/YumUser/relations:

public function relations()
	{
		Yii::import('application.modules.profile.models.*');                

//		$relations = Yii::app()->cache->get('yum_user_relations');
		if($relations === false || is_null($relations)) {
			$relations = array();

			if (Yum::hasModule('role')) {
				Yii::import('application.modules.role.models.*');
				$relations['permissions'] = array(
						self::HAS_MANY, 'YumPermission', 'principal_id');

				$relations['managed_by'] = array(
						self::HAS_MANY, 'YumPermission', 'subordinate_id');

				$relations['roles'] = array(
						self::MANY_MANY, 'YumRole',
						Yum::module('role')->userRoleTable . '(user_id, role_id)');
			}

			if (Yum::hasModule('message')) {
				Yii::import('application.modules.message.models.*');
				$relations['messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'order' => 'timestamp DESC');

				$relations['unread_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'to_user_id',
						'condition' => 'message_read = 0',
						'order' => 'timestamp DESC');

				$relations['sent_messages'] = array(
						self::HAS_MANY, 'YumMessage', 'from_user_id');

			}

			if (Yum::hasModule('profile')) {
				$relations['visits'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visited_id');
				$relations['visited'] = array(
						self::HAS_MANY, 'YumProfileVisit', 'visitor_id');
				$relations['profile'] = array(
						self::HAS_ONE, 'YumProfile', 'user_id');
				$relations['privacy'] = array(
						self::HAS_ONE, 'YumPrivacySetting', 'user_id');
			}

			if (Yum::hasModule('friendship')) {
				$relations['friendships'] = array(
						self::HAS_MANY, 'YumFriendship', 'inviter_id');
				$relations['friendships2'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id');
				$relations['friendship_requests'] = array(
						self::HAS_MANY, 'YumFriendship', 'friend_id',
						'condition' => 'status = 1'); // 1 = FRIENDSHIP_REQUEST
			}

			if (Yum::hasModule('membership')) {
				Yii::import('application.modules.membership.models.*');
				$relations['memberships'] = array(
						self::HAS_MANY, 'YumMembership', 'user_id');
			}

//			Yii::app()->cache->set('yum_user_relations', $relations, 3600);
		}

		return $relations;
	}


Hope this can help anyone has the same issue

0

#7 User is offline   logos010 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 12-November 10
  • Location:VietNam

Posted 22 June 2013 - 03:45 AM

View PostJimBond, on 11 June 2013 - 08:40 PM, said:

I have implement the code.. but i got

Error 500
Undefined variable: relations



Have you checked the return value? it must be return $relations
0

#8 User is offline   Tizak 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 11-January 14

Posted 11 January 2014 - 12:28 PM

View Postlogos010, on 31 May 2013 - 05:03 AM, said:

Hi there,

I'm installed Yii User Management (Yum) extension in my project. It's ok when I'm using The User Module. But there is a error when I'm access Profile Modules as following link "../profile/profile/update/id/1". It brought me a error page : Property "YumUser.profile" is not defined.

any ideas?
Thanks for support :)
Regards


You must have changed the default profile fields. The same thing happened to me when I removed the lastname field and changed the firstname field to name, in order to have a single profile field for name.

On the profile fields management page, it displays correctly and shows the new field(name), but the change is not reflected in the database. So you have to access your database table for profiles(profile in my case) and change the field firstname to name.

Cheers!
0

#9 User is offline   ramila 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 09-July 14

Posted 20 July 2014 - 09:03 AM

hi
I'm installed Yii User Management (Yum) extension in my project. It's ok when I'm using The User Module. But there is a error :Undefined variable: profile
c:\protected\modules\profile\controllers\YumPrivacysettingController.php(55)
and in page yum privacy setting not work
plz help me
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users