public function run() { $uid = Yii::app()->user->id; if (!$uid || !$this->commentableType) { return; } $this->notifyUser = $nu = NotifyUser::loadDefault($this->commentableType); $cr = new CDbCriteria(); $cr->condition = "t.user_id = ? AND t.commentable_type = ?"; $cr->params = array($uid, $this->commentableType); $cr->with = 'item'; $this->subProvider = new CActiveDataProvider('NotifySubscription', array('criteria' => $cr, 'pagination' => array('pageSize' => 5))); $this->render('notifySubscription'); }
/** * изменение настроек подписки пользователя */ public function actionUserSettings() { $postNU = @$_POST['NotifyUser']; $nu = NotifyUser::loadDefault(@$postNU['commentable_type']); if (!empty($postNU)) { // todo: filter notify_all option (admin-only) $nu->attributes = $_POST['NotifyUser']; } if ($nu->save()) { Yii::app()->user->setFlash('user-notify', YCommentsModule::t('Settings saved')); } else { Yii::app()->user->setFlash('user-notify', print_r($nu->getErrors(), true)); } $this->widget('ycomments.widgets.NotifySubscriptionWidget', array('commentableType' => $nu->commentable_type)); }