Пример #1
0
 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!');
 }
Пример #2
0
 global $smarty, $createdid, $availableRequestStates;
 /* New page for managing Emails, since I would rather not be handling editing
 	interface messages (such as the Sitenotice) and the new Emails in the same place. */
 if (isset($_GET['create'])) {
     if (!User::getCurrent()->isAdmin()) {
         BootstrapSkin::displayAccessDenied();
         BootstrapSkin::displayInternalFooter();
         die;
     }
     if (isset($_POST['submit'])) {
         $database = gGetDb();
         $database->transactionally(function () use($database) {
             global $baseurl;
             $emailTemplate = new EmailTemplate();
             $emailTemplate->setDatabase($database);
             $emailTemplate->setName($_POST['name']);
             $emailTemplate->setText($_POST['text']);
             $emailTemplate->setJsquestion($_POST['jsquestion']);
             $emailTemplate->setDefaultAction($_POST['defaultaction']);
             $emailTemplate->setActive(isset($_POST['active']));
             // Check if the entered name already exists (since these names are going to be used as the labels for buttons on the zoom page).
             // getByName(...) returns false on no records found.
             if (EmailTemplate::getByName($_POST['name'], $database)) {
                 throw new TransactionException("That Email template name is already being used. Please choose another.");
             }
             $emailTemplate->save();
             Logger::createEmail($database, $emailTemplate);
             Notification::emailCreated($emailTemplate);
             SessionAlert::success("Email template has been saved successfully.");
             header("Location: {$baseurl}/acc.php?action=emailmgmt");
         });