pages/manager/EmailHandler.inc.php

00001 <?php
00002 
00015 //$Id$
00016 
00017 import('pages.manager.ManagerHandler');
00018 
00019 class EmailHandler extends ManagerHandler {
00023    function EmailHandler() {
00024       parent::ManagerHandler();
00025    }
00026 
00030    function emails() {
00031       $this->validate();
00032       $this->setupTemplate(true);
00033       $conference =& Request::getConference();
00034 
00035       $rangeInfo = Handler::getRangeInfo('emails', array());
00036 
00037       $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00038       $emailTemplatesArray =& $emailTemplateDao->getEmailTemplates(
00039          AppLocale::getLocale(),
00040          $conference->getId()
00041       );
00042 
00043       import('core.ArrayItemIterator');
00044       if ($rangeInfo && $rangeInfo->isValid()) {
00045          while (true) {
00046             $emailTemplates = new ArrayItemIterator($emailTemplatesArray, $rangeInfo->getPage(), $rangeInfo->getCount());
00047             if ($emailTemplates->isInBounds()) break;
00048             unset($rangeInfo);
00049             $rangeInfo =& $emailTemplates->getLastPageRangeInfo();
00050             unset($emailTemplates);
00051          }
00052       } else {
00053          $emailTemplates = new ArrayItemIterator($emailTemplatesArray);
00054       }
00055 
00056       $templateMgr =& TemplateManager::getManager();
00057 
00058       // The bread crumbs depends on whether we're doing scheduled conference or conference
00059       // management. FIXME: this is going to be a common situation, and this isn't
00060       // an elegant way of testing for it.
00061       if(Request::getRequestedPage() === 'manager') {
00062          $templateMgr->assign('pageHierarchy', array(
00063             array(Request::url(null, 'index', 'manager'), 'manager.conferenceSiteManagement')
00064          ));
00065       } else {
00066          $templateMgr->assign('pageHierarchy', array(
00067             array(Request::url(null, null, 'manager'), 'manager.schedConfManagement')
00068          ));
00069       }
00070 
00071       $templateMgr->assign_by_ref('emailTemplates', $emailTemplates);
00072       $templateMgr->assign('helpTopicId','conference.generalManagement.emails');
00073       $templateMgr->display('manager/emails/emails.tpl');
00074    }
00075 
00076    function createEmail($args = array()) {
00077       EmailHandler::editEmail($args);
00078    }
00079 
00084    function editEmail($args = array()) {
00085       $this->validate();
00086       $this->setupTemplate(true);
00087       $conference =& Request::getConference();
00088 
00089       $templateMgr =& TemplateManager::getManager();
00090       $templateMgr->append('pageHierarchy', array(Request::url(null, null, null, 'emails'), 'manager.emails'));
00091 
00092       $emailKey = !isset($args) || empty($args) ? null : $args[0];
00093 
00094       import('manager.form.EmailTemplateForm');
00095 
00096       $emailTemplateForm = new EmailTemplateForm($emailKey, $conference);
00097       $emailTemplateForm->initData();
00098       $emailTemplateForm->display();
00099    }
00100 
00104    function updateEmail() {
00105       $this->validate();
00106       $this->setupTemplate(true);
00107 
00108       import('manager.form.EmailTemplateForm');
00109 
00110       $emailKey = Request::getUserVar('emailKey');
00111 
00112       $conference =& Request::getConference();
00113       $emailTemplateForm = new EmailTemplateForm($emailKey, $conference);
00114       $emailTemplateForm->readInputData();
00115 
00116       if ($emailTemplateForm->validate()) {
00117          $emailTemplateForm->execute();
00118          Request::redirect(null, null, null, 'emails');
00119       } else {
00120          $emailTemplateForm->display();
00121       }
00122    }
00123 
00128    function deleteCustomEmail($args) {
00129       $this->validate();
00130       $conference =& Request::getConference();
00131 
00132       $emailKey = array_shift($args);
00133       $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00134       if ($emailTemplateDao->customTemplateExistsByKey($emailKey, $conference->getId())) {
00135          $emailTemplateDao->deleteEmailTemplateByKey($emailKey, $conference->getId());
00136       }
00137 
00138       Request::redirect(null, null, null, 'emails');
00139    }
00140 
00145    function resetEmail($args) {
00146       $this->validate();
00147       if (isset($args) && !empty($args)) {
00148          $conference =& Request::getConference();
00149 
00150          $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00151          $emailTemplateDao->deleteEmailTemplateByKey($args[0], $conference->getId());
00152       }
00153 
00154       Request::redirect(null, null, null, 'emails');
00155    }
00156 
00160    function resetAllEmails() {
00161       $this->validate();
00162 
00163       $conference =& Request::getConference();
00164       
00165       $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00166       $emailTemplateDao->deleteEmailTemplatesByConference($conference->getId());
00167 
00168       Request::redirect(null, null, null, 'emails');
00169    }
00170 
00175    function disableEmail($args) {
00176       $this->validate();
00177 
00178       if (isset($args) && !empty($args)) {
00179          $conference =& Request::getConference();
00180 
00181          $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00182          $emailTemplate = $emailTemplateDao->getBaseEmailTemplate($args[0], $conference->getId());
00183 
00184          if (isset($emailTemplate)) {
00185             if ($emailTemplate->getCanDisable()) {
00186                $emailTemplate->setEnabled(0);
00187                if ($emailTemplate->getEmailId() != null) {
00188                   $emailTemplateDao->updateBaseEmailTemplate($emailTemplate);
00189                } else {
00190                   $emailTemplate->setAssocType(ASSOC_TYPE_CONFERENCE);
00191                   $emailTemplate->setAssocId($conference->getId());
00192                   $emailTemplateDao->insertBaseEmailTemplate($emailTemplate);
00193                }
00194             }
00195          }
00196       }
00197 
00198       Request::redirect(null, null, null, 'emails');
00199    }
00200 
00205    function enableEmail($args) {
00206       $this->validate();
00207       $conference =& Request::getConference();
00208 
00209       if (isset($args) && !empty($args)) {
00210          $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00211          $emailTemplate = $emailTemplateDao->getBaseEmailTemplate($args[0], $conference->getId());
00212 
00213          if (isset($emailTemplate)) {
00214             if ($emailTemplate->getCanDisable()) {
00215                $emailTemplate->setEnabled(1);
00216 
00217                if ($emailTemplate->getEmailId() != null) {
00218                   $emailTemplateDao->updateBaseEmailTemplate($emailTemplate);
00219                } else {
00220                   $emailTemplateDao->insertBaseEmailTemplate($emailTemplate);
00221                }
00222             }
00223          }
00224       }
00225 
00226       Request::redirect(null, null, null, 'emails');
00227    }
00228 
00233    function validate() {
00234       parent::validate();
00235       
00236       $schedConf =& Request::getSchedConf();
00237 
00238       // If the user is a Conference Manager, but has specified a scheduled conference,
00239       // redirect so no scheduled conference is present (otherwise they would end up managing
00240       // scheduled conference e-mails.)
00241       if($schedConf && !Validation::isConferenceManager()) {
00242          Request::redirect(null, 'index', Request::getRequestedPage(), Request::getRequestedOp());
00243       }
00244 
00245       return true;
00246    }
00247 }
00248 
00249 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7