From: <gem...@li...> - 2011-10-25 15:58:11
|
Revision: 140 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=140&view=rev Author: matijsdejong Date: 2011-10-25 15:58:01 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Brought up to date with revisions up to 139 Modified Paths: -------------- branches/newUser/changelog.txt branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php branches/newUser/classes/Gems/Default/DatabaseAction.php branches/newUser/classes/Gems/Default/IndexAction.php branches/newUser/classes/Gems/Default/MailLogAction.php branches/newUser/classes/Gems/Default/ProjectInformationAction.php branches/newUser/classes/Gems/Default/RoleAction.php branches/newUser/classes/Gems/Default/StaffAction.php branches/newUser/classes/Gems/Email/EmailFormAbstract.php branches/newUser/classes/Gems/Email/MultiMailForm.php branches/newUser/classes/Gems/Email/TemplateMailer.php branches/newUser/classes/Gems/Menu/MenuAbstract.php branches/newUser/classes/Gems/Menu.php branches/newUser/classes/Gems/Roles.php branches/newUser/classes/Gems/Snippets/ModelFormSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php branches/newUser/classes/Gems/Tracker/Engine/StepEngineAbstract.php branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php branches/newUser/classes/Gems/Util/DbLookup.php branches/newUser/classes/Gems/Util/Translated.php branches/newUser/classes/Gems/Util.php branches/newUser/classes/GemsEscort.php branches/newUser/classes/MUtil/Controller/ModelSnippetActionAbstract.php branches/newUser/classes/MUtil/Snippets/ModelFormSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php branches/newUser/configs/db/patches.sql branches/newUser/configs/db/tables/gems__mail_jobs.300.sql branches/newUser/controllers/EmailController.php branches/newUser/languages/default-en.mo branches/newUser/languages/default-en.po branches/newUser/languages/default-nl.mo branches/newUser/languages/default-nl.po branches/newUser/snippets/Generic/ModelItemTableSnippet.php branches/newUser/snippets/Mail/Log/MailLogBrowseSnippet.php Added Paths: ----------- branches/newUser/classes/Gems/Default/CronAction.php branches/newUser/classes/Gems/Default/MailJobAction.php branches/newUser/classes/Gems/Default/MailTemplateAction.php branches/newUser/classes/Gems/Snippets/ModelFormSnippetGeneric.php branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php branches/newUser/classes/Gems/Util/LockFile.php branches/newUser/classes/MUtil/Mail/ branches/newUser/classes/MUtil/Mail/Transport/ branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php branches/newUser/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php branches/newUser/controllers/CronController.php branches/newUser/controllers/MailJobController.php branches/newUser/controllers/MailTemplateController.php branches/newUser/snippets/Generic/ModelFormSnippet.php branches/newUser/snippets/Generic/ModelItemYesNoDeleteSnippet.php Removed Paths: ------------- branches/newUser/classes/Gems/Default/EmailAction.php branches/newUser/classes/Gems/Default/MailAction.php branches/newUser/classes/MUtil/Mail/Transport/ branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php branches/newUser/controllers/MailController.php Property Changed: ---------------- branches/newUser/ Property changes on: branches/newUser ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/library:114-122 + /trunk/library:114-122,125-139 Modified: branches/newUser/changelog.txt =================================================================== --- branches/newUser/changelog.txt 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/changelog.txt 2011-10-25 15:58:01 UTC (rev 140) @@ -1,3 +1,8 @@ +Important changes from 1.4.3 => 1.5 +============================================================ +MailController is now called MailTemplateController +EmailController is now called CronController (with stub for compatibility) + Important changes from 1.4.2 => 1.4.3 ============================================================ * gtr_organisations renamed to gtr_organizations Modified: branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:58:01 UTC (rev 140) @@ -26,7 +26,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Short description of file * * @package Gems * @subpackage Controller @@ -37,10 +36,8 @@ */ /** - * Short description for class + * Class contains Gems specific adaptations to parent class. * - * Long description for class (if any)... - * * @package Gems * @subpackage Controller * @copyright Copyright (c) 2011 Erasmus MC @@ -50,12 +47,6 @@ abstract class Gems_Controller_ModelSnippetActionAbstract extends MUtil_Controller_ModelSnippetActionAbstract { /** - * - * @var GemsEscort - */ - public $escort; - - /** * The parameters used for the autofilter action. * * @var array Mixed key => value array for snippet initialization @@ -74,6 +65,32 @@ protected $autofilterSnippets = 'Generic_ModelTableSnippet'; /** + * The snippets used for the create and edit actions. + * + * @var mixed String or array of snippets name + */ + protected $createEditSnippets = 'Generic_ModelFormSnippet'; + + /** + * The snippets used for the delete action. + * + * @var mixed String or array of snippets name + */ + protected $deleteSnippets = 'Generic_ModelItemYesNoDeleteSnippet'; + + /** + * + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Menu + */ + public $menu; + + /** * The snippets used for the index action, before those in autofilter * * @var mixed String or array of snippets name Copied: branches/newUser/classes/Gems/Default/CronAction.php (from rev 139, trunk/library/classes/Gems/Default/CronAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/CronAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/CronAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,252 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @author Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ + +/** + * Performs bulk-mail action, can be called from a cronjob + * + * @author Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ +class Gems_Default_CronAction extends MUtil_Controller_Action +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * Standard filter that must be true for every token query. + * + * @var array + */ + protected $defaultFilter = array( + 'can_email' => 1, + 'gtr_active' => 1, + 'gsu_active' => 1, + 'grc_success' => 1, + 'gto_completion_time' => NULL, + 'gto_valid_from <= CURRENT_DATE', + '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' + ); + + /** + * + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Menu + */ + public $menu; + + /** + * + * @var Zend_Session_Namespace + */ + public $session; + + /** + * Set to true in child class for automatic creation of $this->html. + * + * Otherwise call $this->initHtml() + * + * @var boolean $useHtmlView + */ + public $useHtmlView = true; + + /** + * + * @var Gems_Util + */ + public $util; + + /** + * Action that switches the cron job lock on or off. + */ + public function cronLockAction() + { + // Switch lock + $this->util->getCronJobLock()->reverse(); + + // Redirect + $request = $this->getRequest(); + $this->_reroute($this->menu->getCurrentParent()->toRouteUrl()); + } + + /** + * Loads an e-mail template + * + * @param integer|null $templateId + */ + protected function getTemplate($templateId) + { + return $this->db->fetchRow('SELECT * FROM gems__mail_templates WHERE gmt_id_message = ?', $templateId); + } + + /** + * Returns the login name belonging to this user. + * + * @param int $userId + * @return string + */ + protected function getUserLogin($userId) + { + return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + } + + public function indexAction() + { + $this->initHtml(); + + if ($this->util->getCronJobLock()->isLocked()) { + $this->html->append($this->_('Cron jobs turned off.')); + } else { + $this->mailJob(); + } + } + + public function mailJob() + { + // Test: update `gems__tokens` set `gto_mail_sent_date` = null where `gto_mail_sent_date` > '2011-10-23' + + $currentUser = isset($this->session->user_login) ? $this->session->user_login : null; + + $model = $this->loader->getTracker()->getTokenModel(); + $mailer = new Gems_Email_TemplateMailer($this->escort); + // $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog()); + + $jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1"); + + if ($jobs) { + foreach ($jobs as $job) { + $this->escort->loadLoginInfo($this->getUserLogin($job['gmj_id_user_as'])); + + // Set up filter + $filter = $this->defaultFilter; + if ($job['gmj_filter_mode'] == 'R') { + $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $job['gmj_filter_days_between'] . ' DAY)'; + } else { + $filter['gto_mail_sent_date'] = NULL; + } + if ($job['gmj_id_organization']) { + $filter['gto_id_organization'] = $job['gmj_id_organization']; + } + if ($job['gmj_id_track']) { + $filter['gto_id_track'] = $job['gmj_id_track']; + } + if ($job['gmj_id_survey']) { + $filter['gto_id_survey'] = $job['gmj_id_survey']; + } + + $tokensData = $model->load($filter); + + if (count($tokensData)) { + $mailer->setMethod($job['gmj_process_method']); + if ($job['gmj_from_method'] == 'F') { + $mailer->setFrom($job['gmj_from_fixed']); + } else { + $mailer->setFrom($job['gmj_from_method']); + } + + $templateData = $this->getTemplate($job['gmj_id_message']); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + + $mailer->setTokens(MUtil_Ra::column('gto_id_token', $tokensData)); + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + + $msg = $mailer->getMessages(); + if (! $msg) { + $msg[] = $this->_('No mails sent'); + } + + $this->html->append($msg); + + if ($currentUser) { + $this->escort->loadLoginInfo($currentUser); + } else { + $this->escort->afterLogout(); + } + + /* + if (isset($this->project->email['automatic'])) { + $batches = $this->project->email['automatic']; + $numBatches = count($batches['mode']); + + for ($i = 0; $i < $numBatches; $i++) { + $this->_organizationId = $batches['organization'][$i]; + + if (isset($batches['days'][$i])) { + $this->_intervalDays = $batches['days'][$i]; + } + + $this->escort->loadLoginInfo($batches['user'][$i]); + + $model->setFilter($this->getFilter($batches['mode'][$i])); + + $tokensData = $model->load(); + + if (count($tokensData)) { + $tokens = array(); + + foreach ($tokensData as $tokenData) { + $tokens[] = $tokenData['gto_id_token']; + } + + $templateData = $this->getTemplate($batches['template'][$i]); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + $mailer->setMethod($batches['method'][$i]); + $mailer->setFrom($batches['from'][$i]); + $mailer->setTokens($tokens); + + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + // */ + } +} \ No newline at end of file Modified: branches/newUser/classes/Gems/Default/DatabaseAction.php =================================================================== --- branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -93,6 +93,18 @@ } /** + * Set the parameters needed by the menu. + * + * @param array $data The current model item + */ + private function _setMenuParameters(array $data) + { + $source = $this->menu->getParameterSource(); + $source['script'] = $data['script'] ? true : false; + $source['exists'] = $data['exists'] ? true : false; + } + + /** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without @@ -180,6 +192,8 @@ $model = $this->getModel(); $data = $model->applyRequest($this->getRequest())->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists']) && $data['exists'])) { $this->addMessage($this->_('This database object does not exist. You cannot delete it.')); $this->html->buttonDiv($this->createMenuLinks(1)); @@ -438,6 +452,8 @@ $model = $this->getModel(); $data = $model->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists'], $data['script']) && ($data['exists'] || $data['script']))) { $this->addMessage($this->_('This database object does not exist. You cannot create it.')); $this->html->buttonDiv($this->createMenuLinks(1)); @@ -580,9 +596,9 @@ $model = $this->getModel(); $data = $model->loadFirst(); - $source = $this->menu->getParameterSource(); - $source['script'] = $data['script']; - $source['exists'] = $data['exists']; + if ($data) { + $this->_setMenuParameters($data); + } parent::showAction(); } @@ -592,6 +608,8 @@ $model = $this->getModel(); $data = $model->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists']) && $data['exists'])) { $this->addMessage($this->_('This database object does not exist. You cannot view it.')); $this->html->buttonDiv($this->createMenuLinks(1)); Deleted: branches/newUser/classes/Gems/Default/EmailAction.php =================================================================== --- branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,135 +0,0 @@ -<?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ - -/** - * Performs bulk-mail action, can be called from a cronjob - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ -class Gems_Default_EmailAction extends Gems_Default_TokenPlanAction -{ - private $_organizationId = null; - private $_intervalDays = 7; - - /** - * Constructs - * @param strings $mode Either 'notmailed' or 'reminder' - */ - protected function getFilter($mode = null) - { - $filter = array( - 'can_email' => 1, - 'gto_id_organization' => $this->_organizationId, - 'gtr_active' => 1, - 'gsu_active' => 1, - 'grc_success' => 1, - 'gto_completion_time' => NULL, - '`gto_valid_from` >= DATE_ADD(CURRENT_DATE, INTERVAL -4 WEEK)', - '`gto_valid_from` <= DATE_ADD(CURRENT_DATE, INTERVAL 2 WEEK)', - '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' - ); - - if (isset($mode) && $mode == 'reminder') { - $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $this->_intervalDays . ' DAY)'; - } else { - $filter['gto_mail_sent_date'] = NULL; - } - - return $filter; - } - - /** - * Loads an e-mail template - * @param integer|null $templateId - */ - protected function getTemplate($templateId) - { - $model = new MUtil_Model_TableModel('gems__mail_templates'); - - return $model->loadFirst(array('gmt_id_message' => $templateId)); - } - - public function indexAction() - { - $this->initHtml(); - - $model = $this->loader->getTracker()->getTokenModel(); - $model->setCreate(false); - - $mailer = new Gems_Email_TemplateMailer($this->escort); - - if (isset($this->project->email['automatic'])) { - $batches = $this->project->email['automatic']; - $numBatches = count($batches['mode']); - - for ($i = 0; $i < $numBatches; $i++) { - $this->_organizationId = $batches['organization'][$i]; - - if (isset($batches['days'][$i])) { - $this->_intervalDays = $batches['days'][$i]; - } - - $this->escort->loadLoginInfo($batches['user'][$i]); - - $model->setFilter($this->getFilter($batches['mode'][$i])); - - $tokensData = $model->load(); - - if (count($tokensData)) { - $tokens = array(); - - foreach ($tokensData as $tokenData) { - $tokens[] = $tokenData['gto_id_token']; - } - - $templateData = $this->getTemplate($batches['template'][$i]); - $mailer->setSubject($templateData['gmt_subject']); - $mailer->setBody($templateData['gmt_body']); - $mailer->setMethod($batches['method'][$i]); - $mailer->setFrom($batches['from'][$i]); - $mailer->setTokens($tokens); - - $mailer->process($tokensData); - } - - Gems_Auth::getInstance()->clearIdentity(); - $this->escort->session->unsetAll(); - } - } - - $this->html->append($mailer->getMessages()); - - } -} \ No newline at end of file Modified: branches/newUser/classes/Gems/Default/IndexAction.php =================================================================== --- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -61,6 +61,11 @@ public $escort; /** + * @var Gems_Menu + */ + public $menu; + + /** * Extension point, use different auth adapter if needed depending on the provided formValues * * This could be an organization passed in the login-form or something else. @@ -150,8 +155,17 @@ public function loginAction() { + /** + * If already logged in, try to redirect to the first allowed and visible menu item + * if that fails, try to reroute to respondent/index + */ if (isset($this->session->user_id)) { - $this->_reroute(array('controller' => 'respondent')); + if ($menuItem = $this->menu->findFirst(array('allowed' => true, 'visible' => true))) { + $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + $redirector->gotoRoute($menuItem->toRouteUrl($this->getRequest())); + } else { + $this->_reroute(array('controller' => 'respondent', 'action'=>'index')); + } } // MUtil_Echo::track(get_class($this->loader->getUser('super', null))); @@ -168,10 +182,10 @@ $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; $this->session->user_group = 800; - $this->session->user_role = 'super'; + $this->session->user_role = 'master'; $this->session->user_organization_id = 70; $this->session->user_organization_name = 'SUPER ADMIN'; - $this->session->user_style = 'pulse'; + $this->session->user_style = 'gems'; //Als er nog geen tabellen zijn, moet dit ingesteld worden //@@TODO Nog kijken hoe beter op te lossen (met try op tabel ofzo) $this->session->allowedOrgs = array($this->session->user_organization_id=>$this->session->user_organization_name); Deleted: branches/newUser/classes/Gems/Default/MailAction.php =================================================================== --- branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,130 +0,0 @@ -<?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @package Gems - * @subpackage Default - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * - * @package Gems - * @subpackage Default - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.1 - */ -class Gems_Default_MailAction extends Gems_Controller_BrowseEditAction -{ - /** - * Creates a model for getModel(). Called only for each new $action. - * - * The parameters allow you to easily adapt the model to the current action. The $detailed - * parameter was added, because the most common use of action is a split between detailed - * and summarized actions. - * - * @param boolean $detailed True when the current action is not in $summarizedActions. - * @param string $action The current action. - * $return MUtil_Model_ModelAbstract - */ - public function createModel($detailed, $action) - { - $model = new MUtil_Model_TableModel('gems__mail_templates'); - $model->set('gmt_subject', 'label', $this->_('Subject')); - - if ($detailed) { - $model->set('gmt_body', - 'label', $this->_('Message'), - 'itemDisplay', array('Gems_Email_EmailFormAbstract', 'displayMailText')); - } - - return $model; - } - - public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) - { - $elements = parent::getAutoSearchElements($model, $data); - $options = array('' => $this->_('(all organizations)')) + $this->util->getDbLookup()->getOrganizations(); - - $elements[] = new Zend_Form_Element_Select('org_id', array('multiOptions' => $options)); - - return $elements; - } - - protected function getDataFilter(array $data) - { - if (isset($data['org_id']) && $data['org_id']) { - $organizationId = intval($data['org_id']); - return array("LOCATE('|$organizationId|', gmt_organizations) > 0"); - } - - return parent::getDataFilter($data); - } - - public function getTopic($count = 1) - { - return $this->plural('email template', 'email templates', $count); - } - - public function getTopicTitle() - { - return $this->_('Email templates'); - } - - protected function processForm($saveLabel = null, $data = null) - { - $model = $this->getModel(); - $isNew = ! $model->applyRequest($this->getRequest())->hasFilter(); - $form = new Gems_Email_MailTemplateForm($this->escort); - - $wasSaved = $form->processRequest($this->_request); - - if ($form->hasMessages()) { - $this->addMessage($form->getMessages()); - } - - if ($wasSaved) { - $this->addMessage(sprintf($this->_('%2$u %1$s saved'), $this->getTopic($wasSaved), $wasSaved)); - $this->afterSaveRoute($form->getValues()); - - } else { - $table = new MUtil_Html_TableElement(array('class' => 'formTable')); - $table->setAsFormLayout($form, true, true); - $table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class. - if ($links = $this->createMenuLinks(10)) { - $table->tf(); // Add empty cell, no label - $linksCell = $table->tf($links); - } - - return $form; - } - } -} Copied: branches/newUser/classes/Gems/Default/MailJobAction.php (from rev 139, trunk/library/classes/Gems/Default/MailJobAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/MailJobAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/MailJobAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,212 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Default_MailJobAction extends Gems_Controller_ModelSnippetActionAbstract +{ + /** + * + * @var ArrayObject + */ + public $project; + + + /** + * The automatically filtered result + * + * @param $resetMvc When true only the filtered resulsts + */ + public function autofilterAction($resetMvc = true) + { + $this->autofilterParameters['onEmpty'] = $this->_('No automatic mail jobs found...'); + + parent::autofilterAction($resetMvc); + } + + /** + * Action for showing a create new item page + */ + public function createAction() + { + $this->createEditParameters['formTitle'] = $this->_('New automatic mail job...'); + + parent::createAction(); + } + + /** + * Creates a model for getModel(). Called only for each new $action. + * + * The parameters allow you to easily adapt the model to the current action. The $detailed + * parameter was added, because the most common use of action is a split between detailed + * and summarized actions. + * + * @param boolean $detailed True when the current action is not in $summarizedActions. + * @param string $action The current action. + * @return MUtil_Model_ModelAbstract + */ + protected function createModel($detailed, $action) + { + $dbLookup = $this->util->getDbLookup(); + $dbTracks = $this->util->getTrackData(); + $translated = $this->util->getTranslated(); + $empty = $translated->getEmptyDropdownArray(); + $unselected = array('' => ''); + + $model = new MUtil_Model_TableModel('gems__mail_jobs'); + + Gems_Model::setChangeFieldsByPrefix($model, 'gmj'); + + $model->set('gmj_id_message', 'label', $this->_('Template'), 'multiOptions', $unselected + $dbLookup->getMailTemplates()); + $model->set('gmj_id_user_as', 'label', $this->_('By staff member'), + 'multiOptions', $unselected + $dbLookup->getActiveStaff(), 'default', $this->escort->getCurrentUserId(), + 'description', $this->_('Used for logging and possibly from address.')); + $model->set('gmj_active', 'label', $this->_('Active'), + 'multiOptions', $translated->getYesNo(), 'elementClass', 'Checkbox', 'required', true, + 'description', $this->_('Job is only run when active.')); + + $fromMethods = $unselected + $this->getBulkMailFromOptions(); + $model->set('gmj_from_method', 'label', $this->_('From address used'), 'multiOptions', $fromMethods); + if ($detailed) { + $model->set('gmj_from_fixed', 'label', $this->_('From other'), + 'description', sprintf($this->_("Only when '%s' is '%s'."), $model->get('gmj_from_method', 'label'), end($fromMethods))); + } + $model->set('gmj_process_method', 'label', $this->_('Processing Method'), 'multiOptions', $unselected + $translated->getBulkMailProcessOptions()); + $model->set('gmj_filter_mode', 'label', $this->_('Filter for'), 'multiOptions', $unselected + $this->getBulkMailFilterOptions()); + $model->set('gmj_filter_days_between', 'label', $this->_('Days between reminders'), 'validators[]', 'Digits'); + + if ($detailed) { + $model->set('gmj_id_organization', 'label', $this->_('Organization'), 'multiOptions', $empty + $dbLookup->getOrganizations()); + $model->set('gmj_id_track', 'label', $this->_('Track'), 'multiOptions', $empty + $dbTracks->getAllTracks()); + $model->set('gmj_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); + } + + return $model; + } + + /** + * Action for showing a delete item page + */ + public function deleteAction() + { + $this->deleteParameters['deleteQuestion'] = $this->_('Do you want to delete this mail job?'); + $this->deleteParameters['displayTitle'] = $this->deleteParameters['deleteQuestion']; + + parent::deleteAction(); + } + + /** + * Action for showing a edit item page + */ + public function editAction() + { + $this->createEditParameters['formTitle'] = $this->_('Edit automatic mail job'); + + parent::editAction(); + } + + /** + * The types of mail filters + * + * @return array + */ + protected function getBulkMailFilterOptions() + { + return array( + 'N' => $this->_('First mail'), + 'R' => $this->_('Reminder'), + ); + } + + /** + * Options for from address use. + * + * @return array + */ + protected function getBulkMailFromOptions() + { + $results['O'] = $this->_('Use organizational from address'); + + if (isset($project->email['site']) && $project->email['site']) { + $results['S'] = sprintf($this->_('Use site %s address'), $project->email['site']); + } + + $results['U'] = $this->_("Use the 'By staff member' address"); + $results['F'] = $this->_('Other'); + + return $results; + } + + /** + * Action for showing a browse page + */ + public function indexAction() + { + $this->html->h3($this->_('Automatic mail jobs')); + + $lock = $this->util->getCronJobLock(); + if ($lock->isLocked()) { + $this->addMessage(sprintf($this->_('Automatic mails have been turned off since %s.'), $lock->getLockTime())); + + $request = $this->getRequest(); + if ($menuItem = $this->menu->findFirst(array($request->getControllerKey() => 'cron', $request->getActionKey() => 'cron-lock'))) { + $menuItem->set('label', $this->_('Turn Automatic Mail Jobs ON')); + } + } + + parent::indexAction(); + + $this->html->pInfo($this->_('With automatic mail jobs and a cron job on the server, mails can be sent without manual user action.')); + } + + /** + * Action for showing an item page + */ + public function showAction() + { + $this->showParameters['displayTitle'] = $this->_('Automatic mail job details'); + + parent::showAction(); + } +} Modified: branches/newUser/classes/Gems/Default/MailLogAction.php =================================================================== --- branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -137,7 +137,7 @@ */ public function showAction() { - $this->html->h3($this->_('Show Mail Activity Log item')); + $this->showParameters['displayTitle'] = $this->_('Show Mail Activity Log item'); // MUtil_Echo::track($this->indexParameters); parent::showAction(); Copied: branches/newUser/classes/Gems/Default/MailTemplateAction.php (from rev 139, trunk/library/classes/Gems/Default/MailTemplateAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/MailTemplateAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/MailTemplateAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,130 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @package Gems + * @subpackage Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 + */ +class Gems_Default_MailTemplateAction extends Gems_Controller_BrowseEditAction +{ + /** + * Creates a model for getModel(). Called only for each new $action. + * + * The parameters allow you to easily adapt the model to the current action. The $detailed + * parameter was added, because the most common use of action is a split between detailed + * and summarized actions. + * + * @param boolean $detailed True when the current action is not in $summarizedActions. + * @param string $action The current action. + * $return MUtil_Model_ModelAbstract + */ + public function createModel($detailed, $action) + { + $model = new MUtil_Model_TableModel('gems__mail_templates'); + $model->set('gmt_subject', 'label', $this->_('Subject')); + + if ($detailed) { + $model->set('gmt_body', + 'label', $this->_('Message'), + 'itemDisplay', array('Gems_Email_EmailFormAbstract', 'displayMailText')); + } + + return $model; + } + + public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) + { + $elements = parent::getAutoSearchElements($model, $data); + $options = array('' => $this->_('(all organizations)')) + $this->util->getDbLookup()->getOrganizations(); + + $elements[] = new Zend_Form_Element_Select('org_id', array('multiOptions' => $options)); + + return $elements; + } + + protected function getDataFilter(array $data) + { + if (isset($data['org_id']) && $data['org_id']) { + $organizationId = intval($data['org_id']); + return array("LOCATE('|$organizationId|', gmt_organizations) > 0"); + } + + return parent::getDataFilter($data); + } + + public function getTopic($count = 1) + { + return $this->plural('email template', 'email templates', $count); + } + + public function getTopicTitle() + { + return $this->_('Email templates'); + } + + protected function processForm($saveLabel = null, $data = null) + { + $model = $this->getModel(); + $isNew = ! $model->applyRequest($this->getRequest())->hasFilter(); + $form = new Gems_Email_MailTemplateForm($this->escort); + + $wasSaved = $form->processRequest($this->_request); + + if ($form->hasMessages()) { + $this->addMessage($form->getMessages()); + } + + if ($wasSaved) { + $this->addMessage(sprintf($this->_('%2$u %1$s saved'), $this->getTopic($wasSaved), $wasSaved)); + $this->afterSaveRoute($form->getValues()); + + } else { + $table = new MUtil_Html_TableElement(array('class' => 'formTable')); + $table->setAsFormLayout($form, true, true); + $table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class. + if ($links = $this->createMenuLinks(10)) { + $table->tf(); // Add empty cell, no label + $linksCell = $table->tf($links); + } + + return $form; + } + } +} Modified: branches/newUser/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -144,7 +144,8 @@ $data[$this->_('Server OS')] = php_uname('s'); $data[$this->_('Time on server')] = date('r'); - if (file_exists($this->escort->getMaintenanceLockFilename())) { + $lock = $this->util->getMaintenanceLock(); + if ($lock->isLocked()) { $label = $this->_('Turn Maintenance Mode OFF'); } else { $label = $this->_('Turn Maintenance Mode ON'); @@ -161,14 +162,13 @@ $this->html->buttonDiv($buttonList); } + /** + * Action that switches the maintenance lock on or off. + */ public function maintenanceAction() { - $lockFile = $this->escort->getMaintenanceLockFilename(); - if (file_exists($lockFile)) { - unlink($lockFile); - } else { - touch($lockFile); - } + // Switch lock + $this->util->getMaintenanceLock()->reverse(); // Dump the existing maintenance mode messages. $this->escort->getMessenger()->clearCurrentMessages(); Modified: branches/newUser/classes/Gems/Default/RoleAction.php =================================================================== --- branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -120,7 +120,7 @@ $disabled = $checkbox->getAttrib('disable'); if ($disabled) { - $values = array_merge($values, $disabled); + $values = array_merge((array) $values, $disabled); } $checkbox->setValue($values); return $form; @@ -139,10 +139,23 @@ $data['grl_parents'] = implode(',', $data['grl_parents']); } + //Always add nologin privilege to 'nologin' role + if (isset($data['grl_name']) && $data['grl_name'] == 'nologin') { + $data['grl_privileges'][] = 'pr.nologin'; + } elseif (isset($data['grl_name']) && $data['grl_name'] !== 'nologin') { + //Assign islogin to all other roles + $data['grl_privileges'][] = 'pr.islogin'; + } + if (isset($data['grl_privileges'])) { $data['grl_privileges'] = implode(',', $data['grl_privileges']); } + if(isset($data['grl_name']) && $data['grl_name'] == 'master') { + $form->getElement('grl_name')->setErrors(array($this->_('Illegal name'))); + return false; + } + return true; } @@ -171,6 +184,20 @@ return $model; } + public function editAction() + { + $model = $this->getModel(); + $data = $model->loadFirst(); + + //If we try to edit master, add an error message and reroute + if (isset($data['grl_name']) && $data['grl_name']=='master') { + $this->addMessage($this->_('Editing `master` is not allowed')); + $this->_reroute(array('action'=>'index'), true); + } + + parent::editAction(); + } + public function formatLongLine($line) { if (strlen($line) > 50) { @@ -195,6 +222,10 @@ $privileges = $this->menu->getUsedPrivileges(); asort($privileges); + //don't allow to edit the pr.nologin and pr.islogin privilege + unset($privileges['pr.nologin']); + unset($privileges['pr.islogin']); + return $privileges; } Modified: branches/newUser/classes/Gems/Default/StaffAction.php =================================================================== --- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -92,7 +92,7 @@ { $dbLookup = $this->util->getDbLookup(); - $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getActiveStaffGroups)); + $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { @@ -125,11 +125,10 @@ if ($this->escort->hasPrivilege('pr.staff.edit.all')) { $bridge->addSelect('gsf_id_organization'); - $bridge->addSelect('gsf_id_primary_group'); } else { $bridge->addExhibitor('gsf_id_organization'); - $bridge->addSelect( 'gsf_id_primary_group', 'multiOptions', $dbLookup->getAllowedStaffGroups()); } + $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); $bridge->addSelect('gsf_iso_lang'); Modified: branches/newUser/classes/Gems/Email/EmailFormAbstract.php =================================================================== --- branches/newUser/classes/Gems/Email/EmailFormAbstract.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/EmailFormAbstract.php 2011-10-25 15:58:01 UTC (rev 140) @@ -345,7 +345,7 @@ $options = $this->model->get($name, 'maxlength', 'required'); $options['label'] = $this->escort->_('Subject'); - $options['size'] = $options['maxlength']; + $options['size'] = min(array($options['maxlength'], 80)); return new Zend_Form_Element_Text($name, $options); } Modified: branches/newUser/classes/Gems/Email/MultiMailForm.php =================================================================== --- branches/newUser/classes/Gems/Email/MultiMailForm.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/MultiMailForm.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,31 +1,31 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * * @version $Id$ * @package Gems * @subpackage Email @@ -69,15 +69,11 @@ protected function createMethodElement() { - $options = array( - 'M' => $this->escort->_('Send multiple mails per respondent, one for each checked token.'), - 'O' => $this->escort->_('Send one mail per respondent, mark all checked tokens as send.'), - 'A' => $this->escort->_('Send one mail per respondent, mark only mailed tokens as send.'), - ); + $options = $this->escort->getUtil()->getTranslated()->getBulkMailProcessOptions(); return new Zend_Form_Element_Radio('multi_method', array( 'label' => $this->escort->_('Method'), - 'multiOptions' => $options, + 'multiOptions' => $options, 'required' => true, )); } @@ -138,11 +134,11 @@ $title = null; } - return $this->_createMultiOption($tokenData, - $this->mailer->getTokenName($tokenData), - $tokenData['grs_email'], - $tokenData['survey_short'], - $title, + return $this->_createMultiOption($tokenData, + $this->mailer->getTokenName($tokenData), + $tokenData['grs_email'], + $tokenData['survey_short'], + $title, $menuFind); } @@ -202,7 +198,7 @@ $this->tokensData = $tokensData; $this->setTokenData(reset($tokensData)); - + return $this; } } Modified: branches/newUser/classes/Gems/Email/TemplateMailer.php =================================================================== --- branches/newUser/classes/Gems/Email/TemplateMailer.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/TemplateMailer.php 2011-10-25 15:58:01 UTC (rev 140) @@ -49,6 +49,12 @@ const MAIL_TLS = 2; /** + * + * @var Zend_Mail_Transport + */ + protected $defaultTransport = null; + + /** * @var GemsEscort $escort */ protected $escort; @@ -161,7 +167,7 @@ $mailServers[$from] = new Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); } else { - $mailServers[$from] = null; + $mailServers[$from] = $this->defaultTransport; } } @@ -317,7 +323,7 @@ * @param string $from * @param string $from_name * @param array $tokenData - * @return boolean|string + * @return boolean|string String = error message from protocol. */ public function sendMail($to, $to_name, $from, $from_name, array $tokenData) { @@ -368,23 +374,39 @@ /** * Sets the body of the mail * @param string $body + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setBody($body) { $this->_body = $body; + return $this; } /** + * Set a different default transport protocol. + * + * @param Zend_Mail_Transport_Abstract $transport + * @return Gems_Email_TemplateMailer (continuation pattern) + */ + public function setDefaultTransport(Zend_Mail_Transport_Abstract $transport) + { + $this->defaultTransport = $transport; + return $this; + } + + /** * Sets sender (regular e-mail address) or one of: * 'O' - Uses the contact information of the selected organization * 'S' - Uses the site-wide contact information * 'U' - Uses the contact information of the currently logged in user * * @param string $from + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setFrom($from) { $this->_from = $from; + return $this; } /** @@ -394,15 +416,18 @@ * 'A' - Send one mail per respondent, mark only mailed tokens as send. * * @param string $method + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setMethod($method) { $this->_method = $method; + return $this; } /** * Sets the subject of the mail * @param string $subject + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setSubject($subject) { @@ -412,7 +437,6 @@ public function setTemplateId($templatedId) { $this->_templateId = $templatedId; - return $this; } @@ -438,22 +462,27 @@ } /** - * Sets a list of tokens + * Sets the li... [truncated message content] |