本文整理汇总了PHP中MailTemplate::model方法的典型用法代码示例。如果您正苦于以下问题:PHP MailTemplate::model方法的具体用法?PHP MailTemplate::model怎么用?PHP MailTemplate::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailTemplate
的用法示例。
在下文中一共展示了MailTemplate::model方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Возвращает модель по указанному идентификатору
* Если модель не будет найдена - возникнет HTTP-исключение.
*
* @param integer $id - идентификатор нужной модели
*
* @return class $model
*
* @throws CHttpException
*/
public function loadModel($id)
{
if (($model = MailTemplate::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('MailModule.mail', 'Requested page was not found'));
}
return $model;
}
示例2: sendTemplate
/**
* sendTemplate:
*
* @param string $code - код
* @param array $data - данные
* @return bool
* @throws CException
**/
public function sendTemplate($code, array $data)
{
$template = MailTemplate::model()->find(array('condition' => 't.code = :code', 'params' => array(':code' => $code)));
if (!$template) {
throw new CException(Yii::t('MailModule.mail', 'Template with "{code}" was not found!'), array('{code}' => $code));
}
$parsedData = $this->parseTemplate($template, $data);
if (!$this->getMailComponent()->send($parsedData['from'], $parsedData['to'], $parsedData['theme'], $parsedData['body'])) {
throw new CException(Yii::t('MailModule.mail', 'Error when sending mail!'));
}
return true;
}
示例3: sendCodes
public function sendCodes($controller)
{
if (!($student = Student::model()->findByAttributes(array('email' => $this->email)))) {
return false;
}
$exercises = Exercise::model()->with('assignment')->sortByDuedate()->findAllByAttributes(array('student_id' => $student->id));
foreach ($exercises as $exercise) {
$exercise->link = Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $exercise->generateAckKey()));
}
$options = array();
if (Helpers::getYiiParam('addOriginatingIP')) {
$options['originating_IP'] = sprintf('[%s]', Yii::app()->request->userHostAddress);
}
return MailTemplate::model()->mailFromTemplate('send_codes', array($student->email => $student->name), array('student' => $student, 'exercises' => $exercises), $options);
}
示例4: prepareMessages
public function prepareMessages($students)
{
$result = array('prepared' => 0, 'failed' => 0);
foreach ($students as $student) {
if (!$student->email) {
$result['failed']++;
continue;
}
if (MailTemplate::model()->messageFromTemplate('direct_message', $student->id, array('student' => $student, 'subject' => $this->subject, 'body' => $this->body), $this->confirmed, $this->acknowledgement)) {
$result['prepared']++;
} else {
$result['failed']++;
}
}
return $result;
}
示例5: actionContact
/**
* Displays the contact page
*/
public function actionContact($name = '', $subject = '', $body = '')
{
$model = new ContactForm();
$model->name = $name;
$model->subject = $subject;
$model->body = $body;
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
MailTemplate::model()->mailFromTemplate('contact_form', Helpers::getYiiParam('adminEmail'), array('subject' => $model->subject, 'name' => $model->name, 'email' => $model->email, 'body' => $model->body), array('replyto' => $model->email));
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例6: loadModel
/**
* 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 = MailTemplate::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例7: actionUpload
/**
* Allows the upload of a file.
*/
public function actionUpload($code = '')
{
$model = new UploadForm();
if (!Yii::app()->user->isGuest) {
$model->byteacher = true;
}
$model->code = $code;
$model->setUrlExample();
if (isset($_POST['UploadForm'])) {
$model->uploadedfile = CUploadedFile::getInstance($model, 'uploadedfile');
$model->attributes = $_POST['UploadForm'];
if ($model->validate()) {
if ($file = $model->saveData(Yii::app()->basePath . DIRECTORY_SEPARATOR . Helpers::getYiiParam('uploadDirectory'))) {
if (!$model->byteacher) {
if ($file->exercise->assignment->notification) {
MailTemplate::model()->mailFromTemplate('new_work_notification', Helpers::getYiiParam('adminEmail'), array('student' => $model->exercise->student, 'file' => $file, 'url' => $this->createAbsoluteSslUrl('file/view', array('id' => $file->id, 'hash' => $file->md5))));
}
if ($model->exercise->student->email) {
MailTemplate::model()->mailFromTemplate('new_work_acknowledgement', array($model->exercise->student->email => $model->exercise->student), array('student' => $model->exercise->student, 'file' => $file, 'url' => $this->createAbsoluteSslUrl('file/view', array('id' => $file->id, 'hash' => $file->md5))));
Yii::app()->getUser()->setFlash('success', 'Work correctly uploaded / saved. An email has been sent to your address.');
}
} else {
Yii::app()->getUser()->setFlash('success', 'Work correctly uploaded / saved.');
}
$this->redirect(array('file/view', 'id' => $file->id, 'hash' => $file->md5, 'status' => 1));
} else {
Yii::app()->getUser()->setFlash('error', 'The work could not be saved.');
}
}
}
$this->render('upload', array('model' => $model));
}
示例8: generateInvitation
public function generateInvitation()
{
if (!$this->student->email) {
return 0;
}
if (MailTemplate::model()->messageFromTemplate('new_assignment_notification', $this->student->id, array('student' => $this->student, 'assignment' => $this->assignment, 'exercise' => $this, 'link' => Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $this->generateAckKey()))), true, false)) {
$this->increaseStatus(self::STATUS_NOTIFIED);
}
return 1;
}