public function uniqueOnUserId($attribute, $params = array()) { $aspect = Aspect::model()->findByAttributes(array('user_id' => $this->user_id, 'name' => $this->name)); if ($aspect !== null && $aspect->id !== $this->id) { $this->addError('name', Yii::t('application', 'You already have an aspect named "{name}".', array('{name}' => $this->name))); } }
public function loadAspect($aspectId) { $aspect = Aspect::model()->findByPk($aspectId); if ($aspect === null || $aspect->user_id !== Yii::app()->getUser()->getModel()->id) { throw new CHttpException(404, Yii::t('application', 'The requested page does not exist.')); } else { return $aspect; } }