From: <gem...@li...> - 2011-10-24 10:20:34
|
Revision: 127 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=127&view=rev Author: matijsdejong Date: 2011-10-24 10:20:26 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Renamed MailController to MailTemplateController Snippet based browse edit replacement #10 and mails configurable from interface #29 are done, except for removing items and the mail jobs are not yet used. Bug #18 is corrected. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php trunk/library/configs/db/tables/gems__mail_jobs.300.sql trunk/library/snippets/Generic/ModelItemTableSnippet.php trunk/library/snippets/Mail/Log/MailLogBrowseSnippet.php Added Paths: ----------- trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Default/MailTemplateAction.php trunk/library/controllers/MailJobController.php trunk/library/controllers/MailTemplateController.php Removed Paths: ------------- trunk/library/classes/Gems/Default/MailAction.php trunk/library/controllers/MailController.php Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/changelog.txt 2011-10-24 10:20:26 UTC (rev 127) @@ -1,3 +1,7 @@ +Important changes from 1.4.3 => 1.5 +============================================================ +MailController is now claaed MailTemplateController + Important changes from 1.4.2 => 1.4.3 ============================================================ * gtr_organisations renamed to gtr_organizations Deleted: trunk/library/classes/Gems/Default/MailAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailAction.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/Gems/Default/MailAction.php 2011-10-24 10:20:26 UTC (rev 127) @@ -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; - } - } -} Added: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php (rev 0) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 10:20:26 UTC (rev 127) @@ -0,0 +1,180 @@ +<?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->getStaff(), '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()); + + 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()); + } + + return $model; + } + + /** + * 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')); + + 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.')); + } +} Copied: trunk/library/classes/Gems/Default/MailTemplateAction.php (from rev 126, trunk/library/classes/Gems/Default/MailAction.php) =================================================================== --- trunk/library/classes/Gems/Default/MailTemplateAction.php (rev 0) +++ trunk/library/classes/Gems/Default/MailTemplateAction.php 2011-10-24 10:20:26 UTC (rev 127) @@ -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: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-24 10:20:26 UTC (rev 127) @@ -235,12 +235,15 @@ $page->addExcelAction(); $page->addShowAction(); - // MAIL Server CONTROLLER + // MAIL JOB CONTROLLER + $page = $setup->addBrowsePage($this->_('Automatic mail'), 'pr.mail.job', 'mail-job'); + + // MAIL SERVER CONTROLLER $page = $setup->addBrowsePage($this->_('Servers'), 'pr.mail.server', 'mail-server'); // $page->addAction($this->_('Test'), 'pr.mail.server.test', 'test')->addParameters(MUtil_Model::REQUEST_ID); // MAIL CONTROLLER - $setup->addBrowsePage($this->_('Templates'), 'pr.mail', 'mail'); + $setup->addBrowsePage($this->_('Templates'), 'pr.mail', 'mail-template'); return $setup; } Modified: trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2011-10-24 10:20:26 UTC (rev 127) @@ -3,7 +3,7 @@ /** * 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 @@ -14,7 +14,7 @@ * * 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 @@ -25,8 +25,8 @@ * 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 Snippets * @author Matijs de Jong <mj...@ma...> @@ -37,13 +37,13 @@ /** * Adds Gems specific display details and helper functions: - * + * * Items set are: * = Default route: 'show' * - Display class: 'formTable' * - Gems_Form use: createForm() * - Table display: beforeDispay() - * + * * Extra helpers are: * - Form title: getTitle() * - Menu helpers: $this->menu, beforeDispay() & getMenuList() @@ -62,21 +62,28 @@ * @var string */ protected $class = 'formTable'; - + /** + * An optional title for the form. replacing the current generic form title. + * + * @var string Optional + */ + protected $formTitle; + + /** * Required - * + * * @var Gems_Menu */ protected $menu; - + /** * The name of the action to forward to after form completion - * + * * @var string */ protected $routeAction = 'show'; - + /** * Perform some actions on the form, right before it is displayed but already populated * @@ -90,7 +97,7 @@ $table->setAsFormLayout($this->_form, true, true); // There is only one row with formLayout, so all in output fields get class. - $table['tbody'][0][0]->appendAttrib('class', $this->labelClass); + $table['tbody'][0][0]->appendAttrib('class', $this->labelClass); if ($links = $this->getMenuList()) { $table->tf(); // Add empty cell, no label @@ -108,7 +115,7 @@ { return $this->menu && parent::checkRegistryRequestsAnswers(); } - + /** * Creates an empty form. Allows overruling in sub-classes. * @@ -119,10 +126,10 @@ { // $form = new Zend_Form($options); $form = new Gems_Form($options); - + return $form; } - + /** * Create the snippets content * @@ -140,13 +147,13 @@ $form = parent::getHtmlOutput($view); $htmlDiv[] = $form; - + return $htmlDiv; } /** * overrule to add your own buttons. - * + * * @return Gems_Menu_MenuList */ protected function getMenuList() @@ -158,14 +165,16 @@ return $links; } - + /** - * + * * @return string The header title to display */ protected function getTitle() { - if ($this->createData) { + if ($this->formTitle) { + return $this->formTitle; + } elseif ($this->createData) { return sprintf($this->_('New %s...'), $this->getTopic()); } else { return sprintf($this->_('Edit %s'), $this->getTopic()); Modified: trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-10-24 10:20:26 UTC (rev 127) @@ -114,10 +114,19 @@ */ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) { + if ($showMenuItem = $this->getShowMenuItem()) { + $bridge->addItemLink($showMenuItem->toActionLinkLower($this->request, $bridge)); + } + // make sure search results are highlighted $this->applyTextMarker(); - return parent::addBrowseTableColumns($bridge, $model); + parent::addBrowseTableColumns($bridge, $model); + + if ($editMenuItem = $this->getEditMenuItem()) { + $bridge->addItemLink($editMenuItem->toActionLinkLower($this->request, $bridge)); + } + } /** @@ -197,17 +206,28 @@ } /** + * Finds a specific active menu item * * @param string $controller * @param string $action * @return Gems_Menu_SubMenuItem */ - public function findMenuItem($controller, $action = 'index') + protected function findMenuItem($controller, $action = 'index') { return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); } /** + * Returns an edit menu item, if access is allowed by privileges + * + * @return Gems_Menu_SubMenuItem + */ + protected function getEditMenuItem() + { + return $this->findMenuItem($this->request->getControllerName(), 'edit'); + } + + /** * Create the snippets content * * This is a stub function either override getHtmlOutput() or override render() @@ -236,6 +256,16 @@ } /** + * Returns a show menu item, if access is allowed by privileges + * + * @return Gems_Menu_SubMenuItem + */ + protected function getShowMenuItem() + { + return $this->findMenuItem($this->request->getControllerName(), 'show'); + } + + /** * Overrule to implement snippet specific filtering and sorting. * * @param MUtil_Model_ModelAbstract $model Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-10-24 10:20:26 UTC (rev 127) @@ -197,7 +197,7 @@ } /** - * Action for showing a create new page + * Action for showing a create new item page */ public function createAction() { Modified: trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2011-10-24 10:20:26 UTC (rev 127) @@ -36,15 +36,15 @@ */ /** - * Abstract class for creating & processing a form based on a model. To use this + * Abstract class for creating & processing a form based on a model. To use this * class either subclass or use the existing default ModelFormSnippet. - * + * * The processForm() method executes e sequence of methods that - * depending on the input display the form or save the form and + * depending on the input display the form or save the form and * redirects the output to another controller/action. * * @see ModelFormSnippet - * + * * @package MUtil * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC @@ -466,6 +466,27 @@ // Default is just go to the index if ($this->routeAction && ($this->request->getActionName() !== $this->routeAction)) { $this->afterSaveRouteUrl = array($this->request->getActionKey() => $this->routeAction); + + // Set the key identifiers for the route. + // + // Mind you the values may have changed, either because of an edit or + // because a new item was created. + $model = $this->getModel(); + $keys = $model->getKeys(); + if (count($keys) == 1) { + $key = reset($keys); + if (isset($this->formData[$key])) { + $this->afterSaveRouteUrl[MUtil_Model::REQUEST_ID] = $this->formData[$key]; + } + } else { + $i = 1; + foreach ($model->getKeys() as $key) { + if (isset($this->formData[$key])) { + $this->afterSaveRouteUrl[MUtil_Model::REQUEST_ID . $i] = $this->formData[$key]; + } + $i++; + } + } } return $this; Modified: trunk/library/configs/db/tables/gems__mail_jobs.300.sql =================================================================== --- trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-24 10:20:26 UTC (rev 127) @@ -1,33 +1,42 @@ CREATE TABLE if not exists gems__mail_jobs ( - gmj_id_message bigint unsigned not null auto_increment, + gmj_id_job bigint unsigned not null auto_increment, - gmj_id_organization bigint unsigned not null - references gems__organizations (gor_id_organization), + gmj_id_message bigint unsigned not null + references gems__mail_templates (gmt_id_message), gmj_id_user_as bigint unsigned not null references gems__staff (gsf_id_user), + gmj_active boolean not null default 1, + -- O Use organization from address -- S Use site from address -- U Use gmj_id_user_as from address + -- F Fixed gmj_from_fixed gmj_from_method varchar(1) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, + gmj_from_fixed varchar(254) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, -- M => multiple per respondent, one for each token -- O => One per respondent, mark all tokens as send - -- U / A? => Send only one token, do not mark + -- A => Send only one token, do not mark gmj_process_method varchar(1) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, -- N => notmailed -- R => reminder gmj_filter_mode varchar(1) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, + -- 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_changed timestamp not null default current_timestamp on update current_timestamp, gmj_changed_by bigint unsigned not null, gmj_created timestamp not null default '0000-00-00 00:00:00', gmj_created_by bigint unsigned not null, - PRIMARY KEY (gmj_id_message) + PRIMARY KEY (gmj_id_job) ) ENGINE=InnoDB AUTO_INCREMENT = 800 Deleted: trunk/library/controllers/MailController.php =================================================================== --- trunk/library/controllers/MailController.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/controllers/MailController.php 2011-10-24 10:20:26 UTC (rev 127) @@ -1,48 +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.4.2 - */ -class MailController extends Gems_Default_MailAction -{ -} Added: trunk/library/controllers/MailJobController.php =================================================================== --- trunk/library/controllers/MailJobController.php (rev 0) +++ trunk/library/controllers/MailJobController.php 2011-10-24 10:20:26 UTC (rev 127) @@ -0,0 +1,50 @@ +<?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 MailJobController extends Gems_Default_MailJobAction +{ + +} Copied: trunk/library/controllers/MailTemplateController.php (from rev 126, trunk/library/controllers/MailController.php) =================================================================== --- trunk/library/controllers/MailTemplateController.php (rev 0) +++ trunk/library/controllers/MailTemplateController.php 2011-10-24 10:20:26 UTC (rev 127) @@ -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 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.4.2 + */ +class MailTemplateController extends Gems_Default_MailTemplateAction +{ +} Modified: trunk/library/snippets/Generic/ModelItemTableSnippet.php =================================================================== --- trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-10-24 10:20:26 UTC (rev 127) @@ -102,6 +102,11 @@ */ protected function addShowTableRows(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) { + if ($menuItem = $this->getEditMenuItem()) { + // Add click to edit + $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); + } + parent::addShowTableRows($bridge, $model); $controller = $this->request->getControllerName(); @@ -124,4 +129,26 @@ { return $this->model; } + + /** + * Finds a specific active menu item + * + * @param string $controller + * @param string $action + * @return Gems_Menu_SubMenuItem + */ + protected function findMenuItem($controller, $action = 'index') + { + return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); + } + + /** + * Returns an edit menu item, if access is allowed by privileges + * + * @return Gems_Menu_SubMenuItem + */ + protected function getEditMenuItem() + { + return $this->findMenuItem($this->request->getControllerName(), 'edit'); + } } Modified: trunk/library/snippets/Mail/Log/MailLogBrowseSnippet.php =================================================================== --- trunk/library/snippets/Mail/Log/MailLogBrowseSnippet.php 2011-10-21 15:43:06 UTC (rev 126) +++ trunk/library/snippets/Mail/Log/MailLogBrowseSnippet.php 2011-10-24 10:20:26 UTC (rev 127) @@ -59,7 +59,7 @@ */ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) { - if ($menuItem = $this->findMenuItem($this->request->getControllerName(), 'show')) { + if ($menuItem = $this->getShowMenuItem()) { $bridge->addItemLink($menuItem->toActionLinkLower($this->request, $bridge)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |