本文整理汇总了PHP中EmailTemplate::save方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailTemplate::save方法的具体用法?PHP EmailTemplate::save怎么用?PHP EmailTemplate::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailTemplate
的用法示例。
在下文中一共展示了EmailTemplate::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show / process email template form
*
* @param void
* @return null
*/
function edit()
{
if ($this->active_template->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$locale = $this->request->get('locale', null);
$template_data = $this->request->post('template');
if (!is_array($template_data)) {
$template_data = array('subject' => $this->active_template->getSubject($locale), 'body' => $this->active_template->getBody($locale));
}
// if
$template_variables = $this->active_template->getVariables() ? explode("\n", $this->active_template->getVariables()) : null;
$this->smarty->assign(array('template_data' => $template_data, 'template_variables' => $template_variables, 'locale' => $locale));
if ($this->request->isSubmitted()) {
if ($locale) {
$this->active_template->writeLocaleProperties(array_var($template_data, 'subject'), array_var($template_data, 'body'), $locale);
} else {
$this->active_template->setAttributes($template_data);
}
// if
$save = $this->active_template->save();
if ($save && !is_error($save)) {
flash_success('Email template has been updated');
$this->redirectToUrl($this->active_template->getUrl());
} else {
$this->smarty->assign('errors', $save);
}
// if
}
// if
}
示例2: actionCreate
/**
* Add a new template action
*/
public function actionCreate()
{
// Check Access
checkAccessThrowException('op_emailtemplate_add');
$model = new EmailTemplate();
if (isset($_POST['EmailTemplate'])) {
$model->attributes = $_POST['EmailTemplate'];
if (isset($_POST['submit'])) {
if ($model->save()) {
fok(at('Email Template Created.'));
alog(at("Created Email Template '{name}'.", array('{name}' => $model->title)));
$this->redirect(array('emailtemplate/index'));
}
} else {
if (isset($_POST['preview'])) {
$model->attributes = $_POST['EmailTemplate'];
}
}
}
// Add Breadcrumb
$this->addBreadCrumb(at('Creating New Email Template'));
$this->title[] = at('Creating New Email Template');
// Display form
$this->render('form', array('model' => $model));
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$super = User::getByUsername('super');
$super->primaryEmail = new Email();
$super->primaryEmail->emailAddress = 'super@zurmo.com';
assert($super->save());
// Not Coding Standard
$bobby = UserTestHelper::createBasicUserWithEmailAddress('bobby');
$sarah = UserTestHelper::createBasicUserWithEmailAddress('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$emailTemplate = new EmailTemplate();
$emailTemplate->modelClassName = 'WorkflowModelTestItem';
$emailTemplate->type = 1;
$emailTemplate->name = 'some template';
$emailTemplate->subject = 'some subject [[LAST^NAME]]';
$emailTemplate->htmlContent = 'html content [[STRING]]';
$emailTemplate->textContent = 'text content [[PHONE]]';
$saved = $emailTemplate->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
self::$emailTemplate = $emailTemplate;
}
示例4: makeBuilderPredefinedEmailTemplate
protected function makeBuilderPredefinedEmailTemplate($name, $unserializedData, $subject = null, $modelClassName = null, $language = null, $type = null, $isDraft = 0, $textContent = null, $htmlContent = null)
{
$emailTemplate = new EmailTemplate();
$emailTemplate->type = $type;
//EmailTemplate::TYPE_WORKFLOW;
$emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
$emailTemplate->isDraft = $isDraft;
$emailTemplate->modelClassName = $modelClassName;
$emailTemplate->name = $name;
if (empty($subject)) {
$subject = $name;
}
$emailTemplate->subject = $subject;
if (!isset($language)) {
$language = Yii::app()->languageHelper->getForCurrentUser();
}
$emailTemplate->language = $language;
$emailTemplate->htmlContent = $htmlContent;
$emailTemplate->textContent = $textContent;
$emailTemplate->serializedData = CJSON::encode($unserializedData);
$emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
$saved = $emailTemplate->save(false);
if (!$saved) {
throw new FailedToSaveModelException();
}
$emailTemplate = EmailTemplate::getById($emailTemplate->id);
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
$saved = $emailTemplate->save(false);
assert('$saved');
}
示例5: testRun
/**
* Test sending an email that should go out as a processing that this job would typically do.
* Also tests that item does not get trashed when deleting the WorkflowMessageInQueue.
* Also tests that if there is more than one emailmessage against the workflow, that it does not send
* to all of them
* @depends testWorkflowMessageInQueueProperlySavesWithoutTrashingRelatedModelItem
*/
public function testRun()
{
Yii::app()->user->userModel = User::getByUsername('super');
$emailTemplate = new EmailTemplate();
$emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
$emailTemplate->name = 'the name';
$emailTemplate->modelClassName = 'Account';
$emailTemplate->type = 2;
$emailTemplate->subject = 'subject';
$emailTemplate->textContent = 'sample text content';
$saved = $emailTemplate->save();
$this->assertTrue($saved);
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$model = ContactTestHelper::createContactByNameForOwner('Jason', Yii::app()->user->userModel);
$model->primaryEmail->emailAddress = 'jason@zurmoland.com';
$saved = $model->save();
$this->assertTrue($saved);
$modelId = $model->id;
$model->forget();
$model = Contact::getById($modelId);
$trigger = array('attributeIndexOrDerivedType' => 'firstName', 'operator' => OperatorRules::TYPE_EQUALS, 'durationInterval' => '333');
$actions = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, ActionForWorkflowForm::ACTION_ATTRIBUTES => array('description' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'some new description'))));
$emailMessages = array();
$emailMessages[0]['emailTemplateId'] = $emailTemplate->id;
$emailMessages[0]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
$emailMessages[0]['sendAfterDurationSeconds'] = '0';
$emailMessages[0][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
$emailMessages[1]['emailTemplateId'] = $emailTemplate->id;
$emailMessages[1]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
$emailMessages[1]['sendAfterDurationSeconds'] = '10000';
$emailMessages[1][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
$savedWorkflow = new SavedWorkflow();
$savedWorkflow->name = 'some workflow';
$savedWorkflow->description = 'description';
$savedWorkflow->moduleClassName = 'ContactsModule';
$savedWorkflow->triggerOn = Workflow::TRIGGER_ON_NEW_AND_EXISTING;
$savedWorkflow->type = Workflow::TYPE_ON_SAVE;
$data[ComponentForWorkflowForm::TYPE_TRIGGERS] = array($trigger);
$data[ComponentForWorkflowForm::TYPE_ACTIONS] = $actions;
$data[ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES] = $emailMessages;
$savedWorkflow->serializedData = serialize($data);
$savedWorkflow->isActive = true;
$saved = $savedWorkflow->save();
$this->assertTrue($saved);
WorkflowTestHelper::createExpiredWorkflowMessageInQueue($model, $savedWorkflow, serialize(array($emailMessages[1])));
RedBeanModelsCache::forgetAll(true);
//simulates page change, required to confirm Item does not get trashed
$this->assertEquals(1, WorkflowMessageInQueue::getCount());
$job = new WorkflowMessageInQueueJob();
$this->assertTrue($job->run());
$this->assertEquals(0, WorkflowMessageInQueue::getCount());
RedBeanModelsCache::forgetAll(true);
//simulates page change, required to confirm Item does not get trashed
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
}
示例6: actionCreate
/**
* Create
*/
public function actionCreate()
{
$emailTemplate = new EmailTemplate('create');
if (isset($_POST['EmailTemplate'])) {
$emailTemplate->attributes = $_POST['EmailTemplate'];
if ($emailTemplate->save()) {
$this->redirect(array('template/view', 'id' => $emailTemplate->id));
}
}
$this->render('create', array('emailTemplate' => $emailTemplate));
}
示例7: create
protected function create()
{
$emailTemplate = new EmailTemplate('create');
$emailTemplate->name = 'the name';
$emailTemplate->subject = 'the subject';
$emailTemplate->heading = 'the heading';
$emailTemplate->message = 'the message';
$save = $emailTemplate->save();
$this->emailTemplate = $emailTemplate;
$this->assertTrue($save);
$this->codeGuy->seeInDatabase('email_template', array('name' => 'the name', 'subject' => 'the subject', 'heading' => 'the heading', 'message' => 'the message'));
}
示例8: executeAjaxSave
public function executeAjaxSave(sfWebRequest $request)
{
$template = trim($request->getParameter('template'));
if (empty($template)) {
return $this->renderText('Please specify template name');
}
$email_template = new EmailTemplate();
$email_template->setName($template);
$email_template->setSubject($request->getParameter('subject'));
$email_template->setSenderEmail($request->getParameter('email'));
$email_template->setSenderName($request->getParameter('name'));
$email_template->setBody($request->getParameter('body'));
$email_template->setPersonId($this->getUser()->getId());
$email_template->save();
return $this->renderText('#New template have successfully saved!');
}
示例9: install_aoe
function install_aoe()
{
require_once 'modules/Administration/Administration.php';
require_once 'modules/EmailTemplates/EmailTemplate.php';
$emailTemp = new EmailTemplate();
//$emailTemp->id = '7b618b3d-913b-6d2d-6bfb-519f7948a271';
$emailTemp->date_entered = '2013-05-24 14:31:45';
$emailTemp->date_modified = '2013-05-30 14:37:12';
$emailTemp->name = 'Event Invite Template';
$emailTemp->description = 'Default event invite template.';
$emailTemp->published = 'off';
$emailTemp->subject = "You have been invited to \$fp_events_name";
$emailTemp->body = "Dear \$contact_name,\r\nYou have been invited to \$fp_events_name on \$fp_events_date_start to \$fp_events_date_end\r\n\$fp_events_description\r\nYours Sincerely,\r\n";
$emailTemp->body_html = "\n<p>Dear \$contact_name,</p>\n<p>You have been invited to \$fp_events_name on \$fp_events_date_start to \$fp_events_date_end</p>\n<p>\$fp_events_description</p>\n<p>If you would like to accept this invititation please click accept.</p>\n<p> \$fp_events_link or \$fp_events_link_declined</p>\n<p>Yours Sincerely,</p>\n";
$emailTemp->type = 'email';
$emailTemp->save();
}
示例10: action
public function action()
{
if (isset($_POST['action']['save'])) {
$fields = $_POST['fields'];
$et = new EmailTemplate();
$et->subject = $fields['subject'];
$et->type = $fields['type'];
$et->body = $fields['body'];
if (isset($fields['roles']) && strlen(trim($fields['roles'])) > 0) {
$roles = preg_split('/\\s*,\\s*/i', $fields['roles'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($roles as $r) {
$et->addRoleFromName($r);
}
}
EmailTemplate::save($et);
redirect(extension_members::baseURL() . 'email_templates_edit/' . $et->id . '/created/');
}
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'update' page.
*/
public function actionCreate()
{
$this->breadcrumbs = array('Шаблоны' => array('/messages/emailtemplate'), 'Новая запись');
$model = new EmailTemplate();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
// set attributes from get
if (isset($_GET['EmailTemplate'])) {
$model->attributes = $_GET['EmailTemplate'];
}
if (isset($_POST['EmailTemplate'])) {
$model->attributes = $_POST['EmailTemplate'];
if ($model->save()) {
$url = isset($_POST['go_to_list']) ? $this->listUrl('index') : $this->itemUrl('update', $model->id);
$this->redirect($url);
}
}
$this->render('create', array('model' => $model));
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if (!isset($_SESSION['filemanager'])) {
$_SESSION['filemanager'] = TRUE;
}
$_SESSION['currentFolder'] = 'emailTemplate/';
$model = new EmailTemplate('create');
if (isset($_POST['EmailTemplate'])) {
$model->attributes = $_POST['EmailTemplate'];
if ($model->validate()) {
if ($model->save()) {
Yii::app()->user->setFlash('success', Yii::t('emailTemplate', 'Add emailTemplate successfully.'));
} else {
Yii::app()->user->setFlash('error', Yii::t('emailTemplate', 'Add emailTemplate failed. Please try it later.'));
}
$this->redirect(array('/' . backend . '/emailTemplate/admin'));
}
}
$this->render(strtolower($this->action->Id), array('model' => $model));
}
示例13: install_aop
function install_aop()
{
require_once 'modules/EmailTemplates/EmailTemplate.php';
global $sugar_config;
$sugar_config['aop']['enable_portal'] = false;
$sugar_config['aop']['joomla_url'] = '';
$sugar_config['aop']['distribution_user_id'] = '';
$sugar_config['aop']['support_from_address'] = '';
$sugar_config['aop']['support_from_name'] = '';
$sugar_config['aop'] = array('distribution_method' => 'roundRobin');
$templates = getTemplates();
foreach ($templates as $configKey => $templateData) {
$template = new EmailTemplate();
foreach ($templateData as $field => $value) {
$template->{$field} = $value;
}
$template->save();
$sugar_config['aop'][$configKey . "_id"] = $template->id;
}
ksort($sugar_config);
write_array_to_file('sugar_config', $sugar_config, 'config.php');
}
示例14: action
public function action()
{
$email_template_id = $this->_context[0];
$fields = $_POST['fields'];
if (isset($_POST['action']['delete'])) {
EmailTemplate::delete($email_template_id);
redirect(extension_members::baseURL() . 'email_templates/');
} elseif (isset($_POST['action']['save'])) {
$et = EmailTemplate::loadFromID($email_template_id);
$et->removeAllRoles();
$et->subject = $fields['subject'];
$et->type = $fields['type'];
$et->body = $fields['body'];
if (isset($fields['roles']) && strlen(trim($fields['roles'])) > 0) {
$roles = preg_split('/\\s*,\\s*/i', $fields['roles'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($roles as $r) {
$et->addRoleFromName($r);
}
}
EmailTemplate::save($et);
redirect(extension_members::baseURL() . 'email_templates_edit/' . $et->id . '/saved/');
}
}
示例15: makeSampleOnSaveWorkflow
protected function makeSampleOnSaveWorkflow()
{
Yii::app()->user->userModel = User::getByUsername('super');
$emailTemplate = new EmailTemplate();
$emailTemplate->type = EmailTemplate::TYPE_WORKFLOW;
$emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
$emailTemplate->subject = 'We closed a deal';
$emailTemplate->name = 'We closed a deal - Sample Email Template';
$emailTemplate->textContent = 'Hello!!!
We just closed new deal, please check details: [[MODEL^URL]]
Thanks!';
$emailTemplate->htmlContent = '<p>Hello!!!</p>
<p>We just closed new deal, please check details: [[MODEL^URL]]</p>
<p>Thanks!</p>';
$emailTemplate->modelClassName = 'Opportunity';
$emailTemplate->isDraft = false;
$emailTemplate->save();
$trigger = new TriggerForWorkflowForm('OpportunitiesModule', 'Opportunity', Workflow::TYPE_ON_SAVE);
$trigger->attributeIndexOrDerivedType = 'stage';
$trigger->value = 'Closed Won';
$trigger->operator = OperatorRules::TYPE_BECOMES;
$trigger->relationFilter = TriggerForWorkflowForm::RELATION_FILTER_ANY;
$message = new EmailMessageForWorkflowForm('Opportunity', Workflow::TYPE_ON_SAVE);
$message->sendAfterDurationInterval = 0;
$message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_MINUTE;
$message->emailTemplateId = $emailTemplate->id;
$message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
$recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_ADDRESS, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'toName' => 'The Sales Team', 'toAddress' => 'SalesTeam@mycompany.com'));
$message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
$workflow = new Workflow();
$workflow->setDescription('This will send an email to recipients that you choose when you close a deal!');
$workflow->setIsActive(false);
$workflow->setOrder(2);
$workflow->setModuleClassName('OpportunitiesModule');
$workflow->setName('Closed won Opportunity alert');
$workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
$workflow->setType(Workflow::TYPE_ON_SAVE);
$workflow->setTriggersStructure('1');
$workflow->addTrigger($trigger);
$workflow->addEmailMessage($message);
$savedWorkflow = new SavedWorkflow();
SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
$savedWorkflow->save();
}