/** * 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 = OmmuTemplate::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.')); } return $model; }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { // Guest Subscribe if ($this->user_id == 0 && $this->subscribe == 1) { $message = OmmuTemplate::getMessage('user_subscribe_launching', array(CHtml::encode($this->email))); SupportMailSetting::sendEmail($this->email, $this->email, 'Subscribe Success', $message, 1); } } else { if ($this->subscribe == 0) { // Guest Unsubscribe if ($this->user_id == 0) { SupportMailSetting::sendEmail($this->email, $this->email, 'Unsubscribe Success', 'Unsubscribe Success', 1); // Member Unsubscribe } else { SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, 'Unsubscribe Success', 'Unsubscribe Success', 1); } } } }