当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailTemplate::model方法代码示例

本文整理汇总了PHP中EmailTemplate::model方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailTemplate::model方法的具体用法?PHP EmailTemplate::model怎么用?PHP EmailTemplate::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailTemplate的用法示例。


在下文中一共展示了EmailTemplate::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCheckPostponedOrders

 /**
  * Check for orders without carrier chosen
  *
  * @return int
  */
 public function actionCheckPostponedOrders()
 {
     echo "Finding postponed orders..." . PHP_EOL;
     /** @var Order[] $orders */
     $orders = Order::model()->getPostponedOrders();
     $ordersCount = count($orders);
     Yii::log(sprintf("Found %s delayed %s" . PHP_EOL, $ordersCount, $this->pluralize('order', $ordersCount)), CLogger::LEVEL_ERROR, 'email_notification');
     foreach ($orders as $order) {
         Yii::log(sprintf("Sending notification email about postponed Order #%s to User #%s %s <%s>", $order->id, $order->creator_id, $order->creator->fullname, $order->creator->email), CLogger::LEVEL_INFO, 'email_notification');
         /** @var SwiftMailer $mailer */
         $mailer = Yii::app()->mailer;
         /** @var EmailTemplate $emailTemplateModel */
         $emailTemplateModel = EmailTemplate::model();
         $template = $emailTemplateModel->getEmailTemplateBySlug(EmailTemplate::TEMPLATE_ORDER_DELAYED);
         $replacements = [$order->creator->email => ['{{order}}' => CHtml::link('#' . $order->id, Yii::app()->createAbsoluteUrl('order/view', ['id' => $order->id]))]];
         if ($template) {
             $mailer->setSubject($template->subject)->setBody($template->body)->setTo($order->creator->email)->setDecoratorReplacements($replacements)->send();
         } else {
             Yii::log("Email template not found!", CLogger::LEVEL_ERROR, 'email_notification');
             return 1;
         }
     }
     echo "Done!" . PHP_EOL;
     return 0;
 }
开发者ID:septembermd,项目名称:n1,代码行数:30,代码来源:OrderCommand.php

示例2: loadModel

 public function loadModel($id)
 {
     $model = EmailTemplate::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('emailTemplate', 'The requested page does not exist.'));
     }
     return $model;
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:8,代码来源:EmailTemplateController.php

示例3: update

 public function update()
 {
     $emailTemplate = EmailTemplate::model()->findByPk($this->emailTemplate->id);
     $emailTemplate->name = 'the name changed';
     $emailTemplate->subject = 'the subject changed';
     $emailTemplate->heading = 'the heading changed';
     $emailTemplate->message = 'the message changed';
     $save = $emailTemplate->save();
     $this->assertTrue($save);
     $this->codeGuy->seeInDatabase('email_template', array('name' => 'the name changed', 'subject' => 'the subject changed', 'heading' => 'the heading changed', 'message' => 'the message changed'));
 }
开发者ID:Khan143,项目名称:yii-email-module,代码行数:11,代码来源:EmailTemplateTest.php

示例4: actionReply

 public function actionReply($id)
 {
     $model = $this->loadModel($id);
     $model->scenario = 'replyFeedback';
     if (isset($_POST['Manager'])) {
         $managerPhone = isset($_POST['Manager']['phone']) ? $_POST['Manager']['phone'] : NULL;
         $model->template = isset($_POST['Feedback']['template']) ? $_POST['Feedback']['template'] : NULL;
         if (isset($_POST['Feedback']['variables'])) {
             foreach ($_POST['Feedback']['variables'] as $key => $var) {
                 $model->variables[$key] = isset($_POST['Feedback']['variables'][$key]) ? strip_tags($_POST['Feedback']['variables'][$key]) : NULL;
             }
         }
         if ($model->validate('template', 'variables')) {
             $modelEmailTemplate = EmailTemplate::model()->findByPK($model->template);
             if ($modelEmailTemplate !== NULL) {
                 $manager = User::model()->find(Yii::app()->user->id);
                 $managerName = $manager->first_name . ' ' . $manager->last_name;
                 $managerEmail = $manager->email;
                 $clientEmail = $model->email;
                 $final_array = Yii::app()->extraFunctions->emailSendArray($modelEmailTemplate->description, $model->variables);
                 //replace varibles
                 if (!empty($managerPhone)) {
                     $appendContent = '<br/><p>Nếu quý khách cần tư vấn trực tiếp, vui lòng liên lạc qua số điện thoại:<strong> ' . $managerPhone . '</strong></p>';
                     $final_array .= $appendContent;
                 }
                 $send_mail_data = array('subject' => $modelEmailTemplate->subject, 'firstName' => ucwords($model->name), 'content' => $final_array);
                 $message = $this->renderPartial('//site/_emailTemplate', $send_mail_data, true);
                 //call a template view
                 $result = Yii::app()->extraFunctions->sendEmail($clientEmail, $modelEmailTemplate->subject, $message, $model->name, $managerEmail);
                 //send mail
                 if ($result) {
                     Feedback::model()->updateStatus($id, 0);
                 }
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('backend', 'Your request failed. Please contact administrators.'));
             }
             $this->redirect(array('/' . backend . '/feedback/reply', 'id' => $id));
         }
     }
     $this->render(strtolower($this->action->id), array('model' => $model));
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:41,代码来源:FeedbackController.php

示例5: sendNotification

 /**
  * Send mail
  *
  * @return mixed
  */
 public function sendNotification()
 {
     /** @var OrderBids $orderBid */
     $orderBid = $this->sender;
     $currentUser = $this->controller->acl->getUser();
     /** @var SwiftMailer $mailer */
     $mailer = $this->getMailer();
     $orderAbsoluteUrl = Yii::app()->createAbsoluteUrl('order/view', ['id' => $orderBid->id]);
     $emailTemplate = $this->getTemplate();
     if ($emailTemplate) {
         $mailer->setSubject($emailTemplate->subject)->setBody($emailTemplate->body);
         $replacements = [];
         $users = [$orderBid->user->email];
         $mailer->addAddress($users);
         foreach ($users as $email) {
             $replacements[$email] = ['{{order}}' => CHtml::link('#' . $orderBid->id, $orderAbsoluteUrl), '{{carrier}}' => CHtml::link($orderBid->user->fullname, Yii::app()->createAbsoluteUrl('user/view', ['id' => $currentUser->id])), '{{reason}}' => $this->form->reason, '{{bids_url}}' => CHtml::link(Yii::app()->createAbsoluteUrl('orderBids/index'), Yii::app()->createAbsoluteUrl('orderBids/index', ['orderId' => $orderBid->order_id]))];
         }
         $mailer->setDecoratorReplacements($replacements)->send();
         Yii::log(sprintf('Sent email notification about withdrawn order bid for order #%s by user #%s. Reason: %s', $orderBid->order_id, $orderBid->user_id, $this->form->reason));
     } else {
         Yii::log(sprintf('Failed to send notification. Not found template %s', $this->getTemplateName()), CLogger::LEVEL_ERROR);
     }
     $supervisorEmailTemplate = EmailTemplate::model()->findByAttributes(['slug' => $this->getSupervisorTemplateName()]);
     if ($supervisorEmailTemplate) {
         $mailer->setSubject($supervisorEmailTemplate->subject)->setBody($supervisorEmailTemplate->body);
         $users = [];
         $supervisors = User::model()->findAllSupervisors();
         $replacements = [];
         foreach ($supervisors as $supervisor) {
             $users[] = $supervisor->email;
         }
         $mailer->addAddress($users);
         foreach ($users as $email) {
             $replacements[$email] = ['{{order}}' => CHtml::link('#' . $orderBid->id, $orderAbsoluteUrl), '{{carrier}}' => CHtml::link($orderBid->user->fullname, Yii::app()->createAbsoluteUrl('user/view', ['id' => $currentUser->id])), '{{reason}}' => $this->form->reason, '{{currency}}' => $orderBid->order->currency->title, '{{cost}}' => $orderBid->cost, '{{bids_number}}' => $orderBid->order->orderBidsCount, '{{bids_url}}' => CHtml::link(Yii::app()->createAbsoluteUrl('orderBids/index'), Yii::app()->createAbsoluteUrl('orderBids/index', ['orderId' => $orderBid->order_id]))];
         }
         $mailer->setDecoratorReplacements($replacements)->send();
     } else {
         Yii::log(sprintf('Failed to send notification. Not found template %s', $this->getSupervisorTemplateName()), CLogger::LEVEL_ERROR);
     }
 }
开发者ID:septembermd,项目名称:n1,代码行数:45,代码来源:OrderBidWithdrawnEvent.php

示例6: buildTemplateMessage_db

 /**
  * @param $template string
  * @param $viewParams array
  * @param string $layout
  * @throws CException
  * @return array
  */
 private function buildTemplateMessage_db($template, $viewParams = array(), $layout = null)
 {
     // load template
     $emailTemplate = EmailTemplate::model()->findByAttributes(array('name' => $template));
     if (!$emailTemplate) {
         throw new CException('missing EmailTemplate - ' . $template);
     }
     // load layout
     $emailLayout = $layout ? EmailTemplate::model()->findByAttributes(array('name' => $layout)) : false;
     if ($layout && !$emailLayout) {
         throw new CException('missing EmailTemplate - ' . $layout);
     }
     // parse template
     $message = array();
     Yii::setPathOfAlias('mustache', realpath($this->mustachePath));
     Yii::import('mustache.Mustache');
     $mustache = new Mustache_Engine();
     foreach ($this->templateFields as $field) {
         $viewParams['contents'] = $mustache->render($emailTemplate->{$field}, $viewParams);
         if (!$layout) {
             $viewParams[$field] = $message[$field] = $viewParams['contents'];
         } else {
             $viewParams[$field] = $message[$field] = $mustache->render($emailLayout->{$field}, $viewParams);
         }
         unset($viewParams['contents']);
     }
     return $message;
 }
开发者ID:cornernote,项目名称:yii-email-module,代码行数:35,代码来源:EEmailManager.php

示例7: beforeSave

 protected function beforeSave()
 {
     $this->user_id = Yii::app()->user->id;
     //Смотрим, определен ли шаблон, если определен - используем
     if (!empty($this->template_id) && ($model_template = EmailTemplate::model()->findByPk($this->template_id))) {
         $this->body = str_replace('%email_body%', $this->body, $model_template->body);
     }
     Yii::app()->mailer->send(array('email' => $this->to_email, 'subject' => $this->title, 'body' => $this->body));
     $this->status = 1;
     $this->send_date = date('Y-m-d h:m:s');
     return true;
 }
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:12,代码来源:EmailMessages.php

示例8: array

                                    <?php 
echo CHtml::label(Yii::t('feedback', 'Phone'), 'phone', array('style' => 'padding-right:23px', 'class' => 'control-label col-lg-2'));
?>
                                    <div class="col-lg-10">
                                        <?php 
echo CHtml::textField('Manager[phone]', '', array('size' => 30, 'maxlength' => 255, 'class' => 'form-control', 'placeholder' => 'If you want to reply via phone number.'));
?>

                                        <?php 
//echo CHtml::error('Phone', 'phone');
?>
                                    </div>
                                </div>

                                <?php 
$listTemplates = EmailTemplate::model()->findAll('status=1 AND autoload=0');
?>
                                <div class="form-group">
                                    <?php 
echo $form->labelEx($model, 'template', array('style' => 'padding-right:23px', 'class' => 'control-label col-lg-2'));
?>
                                    <div class="col-lg-10">
                                        <?php 
echo $form->dropDownList($model, 'template', CHtml::listData($listTemplates, 'id', 'name'), array('empty' => Yii::t('feedback', '--- Select an email template ---'), 'class' => 'form-control'));
?>

                                        <?php 
echo $form->error($model, 'template');
?>
                                    </div>
                                </div>
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:31,代码来源:reply.php

示例9: array

echo Yii::t("Bootstrap", "PHRASE.FIELDS_REQUIRED");
?>
</p>-->

	<?php 
echo $form->errorSummary($model);
?>

<?php 
/* echo $form->dropDownListRow($model, "user_id",
       CHtml::listData( User::model()->findAll(), "id", "title"),
       array("empty" => "Не выбран")
   ); */
echo $form->textFieldRow($model, 'to_email', array('class' => 'span5', 'maxlength' => 250));
echo $form->textFieldRow($model, 'title', array('class' => 'span5', 'maxlength' => 250));
echo $form->dropDownListRow($model, 'template_id', CHtml::listData(EmailTemplate::model()->findAll(), "id", "name"), array("empty" => "Не выбран", 'class' => 'span5'));
?>

<?php 
//$model->body="sssssss!";
Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget');
$this->widget('ImperaviRedactorWidget', array('model' => $model, 'attribute' => 'body', 'options' => array('lang' => 'ru', 'imageUpload' => Yii::app()->createAbsoluteUrl('/messages/messages/imageUpload')), 'plugins' => array('fullscreen' => array('js' => array('fullscreen.js')), 'video' => array('js' => array('video.js')), 'table' => array('js' => array('table.js')), 'fontcolor' => array('js' => array('fontcolor.js')), 'fontfamily' => array('js' => array('fontfamily.js')), 'fontsize' => array('js' => array('fontsize.js')))));
?>

<?php 
/*
echo $form->DatePickerRow($model, 'created_at', array(
				'options'=>array(
					'autoclose' => true,
					//'showAnim'=>'fold',
					'type' => 'Component',
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:31,代码来源:_form.php

示例10: findEMailTempalte

 public function findEMailTempalte($name)
 {
     return EmailTemplate::model()->find("name='" . $name . "' AND status='1'");
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:4,代码来源:EmailTemplate.php

示例11: getTemplate

 /**
  * @return EmailTemplate
  */
 public function getTemplate()
 {
     $emailTemplate = EmailTemplate::model()->findByAttributes(['slug' => $this->getTemplateName()]);
     return $emailTemplate;
 }
开发者ID:septembermd,项目名称:n1,代码行数:8,代码来源:NotificationEvent.php

示例12: actionDelete

 /**
  * Delete Email Template action
  */
 public function actionDelete()
 {
     // Check Access
     checkAccessThrowException('op_emailtemplate_delete');
     if (isset($_GET['id']) && ($model = EmailTemplate::model()->findByPk($_GET['id']))) {
         alog(at("Deleted Email Template '{name}'.", array('{name}' => $model->title)));
         $model->delete();
         fok(at('Email Template Deleted.'));
         $this->redirect(array('emailtemplate/index'));
     } else {
         $this->redirect(array('emailtemplate/index'));
     }
 }
开发者ID:qhyabdoel,项目名称:hris_mujigae,代码行数:16,代码来源:EmailtemplateController.php

示例13: actionSendMailResetPassword

 public function actionSendMailResetPassword()
 {
     if (isset($_POST['ForgotPasswordForm'])) {
         $model = new ForgotPasswordForm();
         $model->attributes = $_POST['ForgotPasswordForm'];
         if ($model->validate()) {
             $modelBarcode = new UserBarcode();
             $modelBarcode->id = UserBarcode::model()->getMaxId() + 1;
             $modelEmailTemplate = EmailTemplate::model()->findEMailTempalte('User Reset Password');
             $modelUser = User::model()->findByAttributes(array('email' => $model->emailReset));
             $modelBarcode->barcode = Yii::app()->extraFunctions->randomString(32);
             if ($modelEmailTemplate !== NULL && $modelUser !== NULL) {
                 $description = $modelEmailTemplate->description;
                 $subject = $modelEmailTemplate->subject;
                 $variables = array('{link}' => CHtml::link(Yii::app()->createAbsoluteUrl('site/resetPassword', array('barcodeId' => $modelBarcode->id)), Yii::app()->createAbsoluteUrl('site/resetPassword', array('barcodeId' => $modelBarcode->id))), '{barcode}' => $modelBarcode->barcode);
                 $final_array = Yii::app()->extraFunctions->emailSendArray($description, $variables);
                 //replace varibles
                 $send_mail_data = array('subject' => $subject, 'firstName' => ucwords($modelUser->first_name), 'content' => $final_array);
                 $message = $this->renderPartial('_emailTemplate', $send_mail_data, true);
                 //call a template view
                 $result = Yii::app()->extraFunctions->sendEmail($modelUser->email, $subject, $message, $modelUser->first_name . ' ' . $modelUser->last_name);
                 //send mail
                 if ($result === TRUE) {
                     $modelBarcode->userid = $modelUser->id;
                     $modelBarcode->start_time = date('Y-m-d H:i:s');
                     $temp_startTime = Yii::app()->extraFunctions->getFormatDate($modelBarcode->start_time);
                     $modelBarcode->end_time = Yii::app()->extraFunctions->getEndTime($temp_startTime, 1);
                     $modelBarcode->action = 'resetPassword';
                     $modelBarcode->save();
                 }
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('backend', 'Your request failed. Please contact administrators.'));
             }
             $this->redirect(array('site/login'));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('backend', 'Your email has not registered in our system.'));
             $this->redirect('login');
         }
     }
 }
开发者ID:huuly188,项目名称:vietnamrealty,代码行数:40,代码来源:SiteController.php

示例14: actionView

 public function actionView($template_id, $group_id, $campaign_id)
 {
     $this->layout = '/layouts/vanilla';
     $fromEmailDomain = Yii::app()->params['insiderEmailDomain'];
     $testEmailInvalid = false;
     $EmailTemplate = EmailTemplate::model()->findByPK($template_id);
     if (is_null($EmailTemplate)) {
         throw new CHttpException(404, 'Unable to find template.');
     }
     $CampaignGroup = CampaignGroup::model()->with(array('campaign'))->findByPK($group_id);
     if (is_null($CampaignGroup)) {
         throw new CHttpException(404, 'Unable to find campaign group.');
     }
     if (isset($_POST['delete'])) {
         $path = dirname(Yii::app()->request->scriptFile) . '/templates/' . $EmailTemplate->folder;
         $this->deleteDir($path);
         $EmailTemplate->delete();
         $this->redirect(array('emailTemplate/create', 'campaign_id' => $campaign_id, 'group_id' => $group_id));
     }
     //send a test email
     if (isset($_POST['EmailTemplate']['email_test_recipient']) && $_POST['EmailTemplate']['email_test_recipient']) {
         $insiderEmailDomain = 'abc123.mailgun.org';
         $mailgunApiVerify = new MailgunCampaign($fromEmailDomain, Yii::app()->params['mailgun']['public-key']);
         try {
             $emails = explode(',', $_POST['EmailTemplate']['email_test_recipient']);
             foreach ($emails as $key => $email) {
                 $emails[$key] = trim($email);
                 $validEmailResponse = $mailgunApiVerify->validateEmailAddress($emails[$key]);
                 if ($validEmailResponse['is_valid'] != true) {
                     unset($emails[$key]);
                 }
             }
             if (sizeof($emails)) {
                 // send it
                 foreach ($emails as $key => $email) {
                     $mailgunApi = new MailgunCampaign($fromEmailDomain, Yii::app()->params['mailgun']['key']);
                     $message = $mailgunApi->newMessage();
                     $message->setFrom('email@' . $fromEmailDomain, 'Application Name');
                     $message->addTo($email);
                     $html = $EmailTemplate->exampleEmail;
                     $html = preg_replace("@%recipient.warehouse_id%@", '000', $html);
                     foreach ($CampaignGroup->campaign->outcomes as $Outcome) {
                         if (strlen($Outcome->url)) {
                             $html = preg_replace("@%recipient.outcome_" . $Outcome->id . "%@", $Outcome->url, $html);
                         }
                     }
                     $message->setHtml($html);
                     $message->setSubject($CampaignGroup->subject);
                     $message->send();
                 }
                 Yii::app()->user->setFlash('success', "Emails sent to " . implode(', ', $emails) . '.');
             } else {
                 Yii::app()->user->setFlash('danger', 'No valid email addresses found to send to');
             }
             $this->refresh();
         } catch (Exception $e) {
             var_dump($e);
             exit;
             $testEmailInvalid = true;
         }
     }
     //check template for first_name
     if (stripos($EmailTemplate->html, '%recipient.first_name%') === false) {
         $EmailTemplate->addNotice('Are you aware that the template.html file does not have a recipient first name tag?: "%recipient.first_name%');
     }
     //check template for last_name
     if (stripos($EmailTemplate->html, '%recipient.last_name%') === false) {
         $EmailTemplate->addNotice('Are you aware that the template.html file does not have a recipient last name tag?: "%recipient.last_name%');
     }
     //check we have an email subject
     if (!strlen($CampaignGroup->subject)) {
         $EmailTemplate->addNotice('You have not set an email subject for this group.');
     }
     //check for outcomes in the template
     preg_match_all("/%recipient.outcome_(\\d+)%/", $EmailTemplate->html, $outcomes);
     if (!sizeof($outcomes[0])) {
         $EmailTemplate->addNotice('Are you aware there are no outcome tags in the template?');
     } else {
         foreach ($outcomes[0] as $tag) {
             $EmailTemplate->addNotice('We found the following tag in your template: ' . $tag);
         }
     }
     $this->breadcrumbs = array('Campaigns' => array('campaign/index'), $CampaignGroup->campaign->name => array('campaign/createUpdate', 'id' => $CampaignGroup->campaign_id), 'Group ' . $CampaignGroup->name => array('campaignGroup/update', 'id' => $CampaignGroup->id, 'campaign_id' => $CampaignGroup->campaign_id), 'View Email Template');
     $this->render('view', array('EmailTemplate' => $EmailTemplate, 'subject' => $CampaignGroup->subject, 'has_ran' => $CampaignGroup->campaign->hasBeenRun, 'testEmailInvalid' => $testEmailInvalid));
 }
开发者ID:newga,项目名称:newga,代码行数:85,代码来源:EmailTemplateController.php

示例15: array

<legend><?php 
echo Yii::t("Bootstrap", "LIST.EmailTemplate");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = EmailTemplate::model()->attributeLabels();
echo '<a href="/admin/' . Yii::app()->controller->module->id . '/' . Yii::app()->controller->id . '/create" class="btn" style="margin-bottom:20px;">Добавить</a>';
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'email-template-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
开发者ID:Diakonrus,项目名称:fastweb-yii,代码行数:10,代码来源:list.php


注:本文中的EmailTemplate::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。