コード例 #1
0
 public function run()
 {
     $userPref = EventsUserPreference::model()->findByPk($this->userId);
     if (is_null($userPref)) {
         $userPref = new EventsUserPreference();
         $userPref->user_id = $this->userId;
         $userPref->save();
     }
     $formUserPref = new CForm('application.modules.cal.views.main.formUserPref', $userPref);
     echo $formUserPref;
 }
コード例 #2
0
 /**
  *  Store preference (e-mail, mobile) for current user
  */
 public function actionUserpreference()
 {
     if (Yii::app()->request->isAjaxRequest) {
         if (!Yii::app()->user->hasState('userId')) {
             Yii::app()->end();
         }
         $userPref = EventsUserPreference::model();
         $userPref->attributes = $_POST['EventsUserpreference'];
         $userPref->updateByPk(Yii::app()->user->getState('calUserId'), $_POST['EventsUserpreference']);
         Yii::app()->end();
     }
 }