Yum Profile Not Work

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

Do you have in your “[color=”#00BFFF"]main.php[/color]" ‘[color="#FF0000"]import [/color][color="#708090"]application.modules.user.models.*[/color]’ and the ‘[color="#FF0000"]modules [/color][color="#808080"]profile[/color]’?




.....

'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',

		),

),

.....



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 :(

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

I have implement the code… but i got


Error 500

Undefined variable: relations

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

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!

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

I opened an issue of that … waiting the author response

github.com/thyseus/yii-user-management/issues/192