public function loadModel($id) { $m = D2mmMessages::model(); // apply scope, if available $scopes = $m->scopes(); if (isset($scopes[$this->scope])) { $m->{$this->scope}(); } $model = $m->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('D2messagesModule.crud', 'The requested page does not exist.')); } return $model; }
/** * registre message as send. Set * status = SENT * sender = user person id * created = now * @param int $d2mm_id */ public static function send($d2mm_id) { $model = D2mmMessages::model()->findByPk($d2mm_id); $model->d2mm_status = D2mmMessages::D2MM_STATUS_SENT; $model->d2mm_sender_pprs_id = Yii::app()->getModule('user')->user()->profile->person_id; $model->d2mm_created = new CDbExpression('NOW()'); $model->save(); }