public function actionGetNotification() { $this->layout = '//layouts/column2'; $datatext = ''; $datatext1 = ''; if (Yii::app()->user->id != '') { $models = Userinbox::model()->findallbyattributes(array('username' => Yii::app()->user->id)); foreach ($models as $model) { if ($model->usermessages != '') { $datatext = $model->userfrom . '(' . $model->inboxdatetime . '): ' . $model->usermessages . '<br>' . $datatext; } } } if (Yii::app()->user->id != '') { $users = Useraccess::model()->findall(array('select' => 'username', 'condition' => "username<>'" . Yii::app()->user->id . "' and recordstatus=2")); foreach ($users as $user) { $datatext1 = $user->username . '<br>' . $datatext1; } } echo CJSON::encode(array('data' => $datatext, 'data1' => $datatext1)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Userinbox::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }