Cal extension and css

Hello,

Is there a way to set different color of an event for different users? Depending on user id, to change css, or something like that?

Thanks!

I guess not natively, but you can easily store a CSS variable or a CSS filename in the DB along with the user information. Then you retrieve that upon (successful) login, and you use it everywhere. In order to do that, you may use something like this in UserIdentity.php component


class UserIdentity extends CUserIdentity

{

	public function authenticate()

	{

		// Suppositions:

		// 1) 'login', 'password' and 'CSSFilename' would be your DB field names and also User model attributes

		// 2) 'username' is the LoginForm model attribute and site/login view form input element

		$user = User::model()->findByAttributes(array('login'=>$this->username));

		if($user===null)

			$this->errorCode=self::ERROR_USERNAME_INVALID;

		else if( ( /* put here your method of hashing password */ ) !== $user->password)

			$this->errorCode=self::ERROR_PASSWORD_INVALID;

		else {

			$this->errorCode=self::ERROR_NONE;

			// Supposing filename without extension

			$this->setState('CSSFilename', $user->CSSFilename);

		}

		return !$this->errorCode;

	}

}

And now, you can use the following in layouts/main.php


<?php if(!Yii::app()->user->isGuest && (Yii::app()->user->CSSFilename != '') { ?>

	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/' . Yii::app()->user->CSSFilename;  ?>.css" />

<?php

} else { ?>

	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/default.css" />

<?php

} ?>



Thank you for your reply, but thats not what I really want. I didnt wrote well what I wanted. Maybe better question is: Is there a way to set different color of an event for different events? Not users.

Any suggestions?

I figured it out. You just need to set your own class for events in fullcalendar.css and set property className in database table events to name of that class.