From: <gem...@li...> - 2011-10-24 17:16:16
|
Revision: 134 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=134&view=rev Author: matijsdejong Date: 2011-10-24 17:16:04 +0000 (Mon, 24 Oct 2011) Log Message: ----------- #29 seems finished, test it further tomorrow and add some nice on/off options to the auto mail. Bug fix in DbLookup.php Reset super role to standard method. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Email/TemplateMailer.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Roles.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/configs/db/tables/gems__mail_jobs.300.sql trunk/library/controllers/EmailController.php Added Paths: ----------- trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/MUtil/Mail/ trunk/library/classes/MUtil/Mail/Transport/ trunk/library/classes/MUtil/Mail/Transport/EchoLog.php trunk/library/controllers/CronController.php Removed Paths: ------------- trunk/library/classes/Gems/Default/EmailAction.php Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/changelog.txt 2011-10-24 17:16:04 UTC (rev 134) @@ -1,6 +1,7 @@ Important changes from 1.4.3 => 1.5 ============================================================ -MailController is now claaed MailTemplateController +MailController is now called MailTemplateController +EmailController is now called CronController (with stub for compatibility) Important changes from 1.4.2 => 1.4.3 ============================================================ Copied: trunk/library/classes/Gems/Default/CronAction.php (from rev 133, trunk/library/classes/Gems/Default/EmailAction.php) =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php (rev 0) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -0,0 +1,217 @@ +<?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 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; + + /** + * 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(); + $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(); + } + } + + $this->html->append($mailer->getMessages()); + + 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 Deleted: trunk/library/classes/Gems/Default/EmailAction.php =================================================================== --- trunk/library/classes/Gems/Default/EmailAction.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Default/EmailAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -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: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -98,27 +98,28 @@ 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'), + $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'), + $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); + $model->set('gmj_from_method', 'label', $this->_('From address used'), 'multiOptions', $fromMethods); if ($detailed) { - $model->set('gmj_from_fixed', 'label', $this->_('From other'), + $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_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('gsu_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); + $model->set('gmj_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); } return $model; Modified: trunk/library/classes/Gems/Email/TemplateMailer.php =================================================================== --- trunk/library/classes/Gems/Email/TemplateMailer.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Email/TemplateMailer.php 2011-10-24 17:16:04 UTC (rev 134) @@ -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 list of tokens that will be mailed. + * * @param string[] $tokens + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setTokens(array $tokens) { $this->_tokens = $tokens; + return $this; } /** * Sets verbose (noisy) operation * * @param boolean $verbose + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setVerbose($verbose) { $this->_verbose = $verbose; + return $this; } /** Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Menu.php 2011-10-24 17:16:04 UTC (rev 134) @@ -551,6 +551,7 @@ $this->addButtonOnly($this->_('Changelog'), 'pr.project-information.changelog', 'project-information','changelog'); // Special page for automated e-mail cronjob + $this->addPage(null, null, 'cron', 'index'); $this->addPage(null, null, 'email', 'index'); } Modified: trunk/library/classes/Gems/Roles.php =================================================================== --- trunk/library/classes/Gems/Roles.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Roles.php 2011-10-24 17:16:04 UTC (rev 134) @@ -113,7 +113,9 @@ return self::$_instanceOfSelf; } -//Reset de ACL en bouw opnieuw op + /** + * Reset de ACL en bouw opnieuw op + */ private function initAcl() { $this->_acl = new MUtil_Acl(); if (get_class(self::$_instanceOfSelf)!=='Gems_Roles') { @@ -139,8 +141,8 @@ } //Now allow super admin all access, except for the actions that have the nologin privilege (->the login action) - $this->_acl->allow('super'); - $this->_acl->deny('super', null, 'pr.nologin'); + // $this->_acl->allow('super'); + // $this->_acl->deny('super', null, 'pr.nologin'); } public function load() { Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 17:16:04 UTC (rev 134) @@ -243,7 +243,7 @@ if (! $data) { $data = $this->db->fetchPairs("SELECT gsf_id_user, CONCAT(COALESCE(gsf_last_name, '-'), ', ', COALESCE(gsf_first_name, ''), COALESCE(CONCAT(' ', gsf_surname_prefix), '')) - FROM gems__staff WHERE ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); + FROM gems__staff ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); } return $data; Property changes on: trunk/library/classes/MUtil/Mail ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Property changes on: trunk/library/classes/MUtil/Mail/Transport ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Mail/Transport/EchoLog.php =================================================================== --- trunk/library/classes/MUtil/Mail/Transport/EchoLog.php (rev 0) +++ trunk/library/classes/MUtil/Mail/Transport/EchoLog.php 2011-10-24 17:16:04 UTC (rev 134) @@ -0,0 +1,63 @@ +<?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 MUtil + * @subpackage Mail + * @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 $ + */ + +/** + * Zend Mail transport adapter that does not send the mail, but just echo's the output. + * + * @package MUtil + * @subpackage Mail + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class MUtil_Mail_Transport_EchoLog extends Zend_Mail_Transport_Abstract +{ + /** + * Send an email independent from the used transport + * + * The requisite information for the email will be found in the following + * properties: + * + * - {@link $recipients} - list of recipients (string) + * - {@link $header} - message header + * - {@link $body} - message body + */ + protected function _sendMail() + { + MUtil_Echo::r(reset($this->_headers['Subject']), reset($this->_headers['From']) . '=>' . reset($this->_headers['To'])); + } +} \ No newline at end of file Modified: trunk/library/configs/db/tables/gems__mail_jobs.300.sql =================================================================== --- trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-24 17:16:04 UTC (rev 134) @@ -25,11 +25,12 @@ -- N => notmailed -- R => reminder gmj_filter_mode varchar(1) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, + gmj_filter_days_between int unsigned not null default 7, -- Optional filters gmj_id_organization bigint unsigned null references gems__organizations (gor_id_organization), gmj_id_track int unsigned null references gems__tracks (gtr_id_track), - gsu_id_survey int unsigned null references gems__surveys (gsu_id_survey), + gmj_id_survey int unsigned null references gems__surveys (gsu_id_survey), gmj_changed timestamp not null default current_timestamp on update current_timestamp, gmj_changed_by bigint unsigned not null, Copied: trunk/library/controllers/CronController.php (from rev 133, trunk/library/controllers/EmailController.php) =================================================================== --- trunk/library/controllers/CronController.php (rev 0) +++ trunk/library/controllers/CronController.php 2011-10-24 17:16:04 UTC (rev 134) @@ -0,0 +1,48 @@ +<?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 Michiel Rook <mi...@to...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * This action performs automatic timed actions on the server. + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class CronController extends Gems_Default_CronAction +{ } \ No newline at end of file Modified: trunk/library/controllers/EmailController.php =================================================================== --- trunk/library/controllers/EmailController.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/controllers/EmailController.php 2011-10-24 17:16:04 UTC (rev 134) @@ -25,11 +25,26 @@ * 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 controllers + * + * + * @deprecated Since 1.5, use CronController + * @package Gems + * @subpackage Default + * @author Michiel Rook <mi...@to...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ -class EmailController extends Gems_Default_EmailAction -{ -} \ No newline at end of file +/** + * This action performs automatic timed actions on the server. + * + * @deprecated Since 1.5, use CronController + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class EmailController extends Gems_Default_CronAction +{ } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |