From: <gem...@li...> - 2012-06-28 08:46:11
|
Revision: 793 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=793&view=rev Author: mennodekker Date: 2012-06-28 08:46:02 +0000 (Thu, 28 Jun 2012) Log Message: ----------- Made mutli-org a little safer Updated respondentexport to work with new model Slider values applied to logaction Optimised tableform a little Modified Paths: -------------- trunk/library/classes/Gems/Default/LogAction.php trunk/library/classes/Gems/Export/RespondentExport.php trunk/library/classes/Gems/Form/TableForm.php trunk/library/classes/Gems/Model/RespondentModel.php Modified: trunk/library/classes/Gems/Default/LogAction.php =================================================================== --- trunk/library/classes/Gems/Default/LogAction.php 2012-06-27 11:59:17 UTC (rev 792) +++ trunk/library/classes/Gems/Default/LogAction.php 2012-06-28 08:46:02 UTC (rev 793) @@ -71,8 +71,8 @@ } // Create date range elements - $min = -91; - $max = 91; + $min = $this->minPeriod; + $max = $this->maxPeriod; $size = max(strlen($min), strlen($max)); $element = new Zend_Form_Element_Text('period_start', array('label' => $this->_('from'), 'size' => $size - 1, 'maxlength' => $size, 'class' => 'rightAlign')); Modified: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php 2012-06-27 11:59:17 UTC (rev 792) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-06-28 08:46:02 UTC (rev 793) @@ -285,7 +285,9 @@ protected function _exportRespondent($respondentId) { $respondentModel = $this->loader->getModels()->getRespondentModel(false); - $respondentModel->setFilter(array('gr2o_patient_nr' => $respondentId)); + //Insert orgId when set + $respondentModel->applyRequest(Zend_Controller_Front::getInstance()->getRequest()); + $respondentModel->addFilter(array('gr2o_patient_nr' => $respondentId)); $respondentData = $respondentModel->loadFirst(); $this->html->snippet($this->_respondentSnippet, Modified: trunk/library/classes/Gems/Form/TableForm.php =================================================================== --- trunk/library/classes/Gems/Form/TableForm.php 2012-06-27 11:59:17 UTC (rev 792) +++ trunk/library/classes/Gems/Form/TableForm.php 2012-06-28 08:46:02 UTC (rev 793) @@ -65,24 +65,16 @@ * @return null|Zend_Form_Decorator_Abstract */ private function _getImportantDecorator($element) { - $dec1 = null; + $class = get_class($element); - if ($dec1 = $element->getDecorator('ViewHelper')) { - return $dec1; - } elseif ($dec1 = $element->getDecorator('UiWidgetElement')) { - return $dec1; - } elseif ($dec1 = $element->getDecorator('File')) { - return $dec1; - } else { - $decorators = $element->getDecorators(); - foreach($decorators as $name=>$decorator) { - if (substr($name, 0, 5) == 'ZendX') { - $dec1 = $decorator; - break; - } - } - return $dec1; + if (strpos($class, 'JQuery')) { + return $element->getDecorator('UiWidgetElement'); } + if (strpos($class, 'File')) { + return $element->getDecorator('File'); + } + + return $element->getDecorator('ViewHelper'); } /** @@ -225,7 +217,7 @@ if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } - + $class = $this->getAttrib('class'); if (empty($class)) { $class = 'formTable'; @@ -256,7 +248,7 @@ } } } - + return parent::setView($view); } } \ No newline at end of file Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2012-06-27 11:59:17 UTC (rev 792) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2012-06-28 08:46:02 UTC (rev 793) @@ -104,9 +104,11 @@ $filter = parent::_checkFilterUsed($filter); if (! isset($filter['gr2o_id_organization'])) { - if ($this->isMultiOrganization()) { + if ($this->isMultiOrganization() && !isset($filter['gr2o_patient_nr'])) { + // If we are not looking for a specific patient, we can look at all patients $filter[] = 'gr2o_id_organization IN (' . implode(', ', array_keys($this->user->getAllowedOrganizations())) . ')'; } else { + // Otherwise, we can only see in our current organization $filter['gr2o_id_organization'] = $this->getCurrentOrganization(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-28 14:17:55
|
Revision: 796 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=796&view=rev Author: matijsdejong Date: 2012-06-28 14:17:45 +0000 (Thu, 28 Jun 2012) Log Message: ----------- Container menu items are in a class of their own Allows empty privilege: container only shown when one of the sub items is allowed Modified Paths: -------------- trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Menu.php Added Paths: ----------- trunk/library/classes/Gems/Menu/ContainerItem.php Added: trunk/library/classes/Gems/Menu/ContainerItem.php =================================================================== --- trunk/library/classes/Gems/Menu/ContainerItem.php (rev 0) +++ trunk/library/classes/Gems/Menu/ContainerItem.php 2012-06-28 14:17:45 UTC (rev 796) @@ -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 <COPYRIGHT HOLDER> 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 Menu + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * A container item is one that gathers multiple sub menu + * items, but does not have it's own controller/action pair + * but selects the first sub item instead. + * + * @package Gems + * @subpackage Menu + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Menu_ContainerItem extends Gems_Menu_SubMenuItem +{ + /** + * Returns a Zend_Navigation creation array for this menu item, with + * sub menu items in 'pages' + * + * @param Gems_Menu_ParameterCollector $source + * @return array + */ + protected function _toNavigationArray(Gems_Menu_ParameterCollector $source) + { + $result = parent::_toNavigationArray($source); + + // Get any missing MVC keys from children, even when invisible + if ($requiredIndices = $this->notSet('controller', 'action')) { + + if (isset($result['pages'])) { + $firstChild = null; + $order = 0; + foreach ($result['pages'] as $page) { + if ($page['allowed']) { + if ($page['order'] < $order || $order == 0) { + $firstChild = $page; + $order = $page['order']; + } + } + } + + if (null === $firstChild) { + // No children are visible and required mvc properties + // are missing: ergo this page is not visible. + $result['visible'] = false; + + // Use first (invisible) child as firstChild + $firstChild = reset($result['pages']); + } + } else { + // Use '/' slash as default to ensure any not visible + // menu items points to another existing item that is + // active. + $firstChild = array_fill_keys($requiredIndices, '/'); + } + + foreach ($requiredIndices as $key) { + $result[$key] = $firstChild[$key]; + } + } + + return $result; + } + + /** + * Set the visibility of the menu item and any sub items in accordance + * with the specified user role. + * + * @param Zend_Acl $acl + * @param string $userRole + * @return Gems_Menu_MenuAbstract (continuation pattern) + */ + protected function applyAcl(Zend_Acl $acl, $userRole) + { + parent::applyAcl($acl, $userRole); + + if ($this->isVisible()) { + $this->set('allowed', false); + $this->set('visible', false); + + if ($this->_subItems) { + foreach ($this->_subItems as $item) { + + if ($item->get('visible', true)) { + $this->set('allowed', true); + $this->set('visible', true); + + return $this; + } + } + } + } + return $this; + } +} Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-06-28 10:08:16 UTC (rev 795) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-06-28 14:17:45 UTC (rev 796) @@ -92,6 +92,13 @@ } } + /** + * Returns a Zend_Navigation creation array for this menu item, with + * sub menu items in 'pages' + * + * @param Gems_Menu_ParameterCollector $source + * @return array + */ protected function _toNavigationArray(Gems_Menu_ParameterCollector $source) { if ($this->_subItems) { @@ -105,9 +112,9 @@ if (($this instanceof Gems_Menu_SubMenuItem) && (! $this->notSet('controller', 'action')) && isset($page['params'])) { + $params = $page['params']; - // TODO: ugly! Make beautiful! - unset($params['reset']); + unset($params['reset']); // Ignore this setting if (count($params)) { $class = ''; @@ -116,13 +123,6 @@ } if ((null !== $lastParams) && ($lastParams !== $params)) { - // $pages[$i++] = array('type' => 'uri'); - /* $l = $i - 1; - if (isset($pages[$l]['class'])) { - $pages[$l]['class'] .= ' breakAfter'; - } else { - $pages[$l]['class'] = 'breakAfter'; - } // */ $class .= 'breakBefore'; } else { $class = trim($class); @@ -231,7 +231,24 @@ $other['privilege'] = $privilege; } - return $this->add($other); + // Process parameters. + $defaults = array( + 'visible' => (boolean) $label, // All menu containers are initally visible unless stated otherwise or specified without label + 'allowed' => true, // Same as with visible, need this for t_oNavigationArray() + 'order' => 10 * (count($this->_subItems) + 1), + ); + + foreach ($defaults as $key => $value) { + if (! isset($other[$key])) { + $other[$key] = $value; + } + } + + $page = new Gems_Menu_ContainerItem($this->escort, $this, $other); + + $this->_subItems[] = $page; + + return $page; } /** @@ -355,7 +372,7 @@ // MUtil_Echo::track($infoPage->_toNavigationArray(array($this->escort->request))); } else { if ($this->escort instanceof Gems_Project_Tracks_StandAloneSurveysInterface) { - $infoPage = $this->addContainer($label, 'pr.project'); + $infoPage = $this->addContainer($label); $tracksPage = $infoPage->addPage($this->_('Tracks'), 'pr.project', 'project-tracks'); $tracksPage->addAutofilterAction(); @@ -469,7 +486,15 @@ return $setup; } - public function applyAcl(Zend_Acl $acl, $userRole) + /** + * Set the visibility of the menu item and any sub items in accordance + * with the specified user role. + * + * @param Zend_Acl $acl + * @param string $userRole + * @return Gems_Menu_MenuAbstract (continuation pattern) + */ + protected function applyAcl(Zend_Acl $acl, $userRole) { if ($this->_subItems) { $anyVisible = false; @@ -498,12 +523,12 @@ } } - // Do not show a 'container' menu item (that depends for controller + /*/ Do not show a 'container' menu item (that depends for controller // on it's children) when no sub item is allowed. if ((! $anyVisible) && $this->notSet('controller', 'action')) { $this->set('allowed', false); $this->set('visible', false); - } + } // */ } return $this; Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-28 10:08:16 UTC (rev 795) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-28 14:17:45 UTC (rev 796) @@ -253,6 +253,13 @@ } } + /** + * Returns a Zend_Navigation creation array for this menu item, with + * sub menu items in 'pages' + * + * @param Gems_Menu_ParameterCollector $source + * @return array + */ protected function _toNavigationArray(Gems_Menu_ParameterCollector $source) { $result = $this->_itemOptions; @@ -270,41 +277,6 @@ $result['pages'] = parent::_toNavigationArray($source); } - // Get any missing MVC keys from children, even when invisible - if ($requiredIndices = $this->notSet('controller', 'action')) { - - if (isset($result['pages'])) { - $firstChild = null; - $order = 0; - foreach ($result['pages'] as $page) { - if ($page['allowed']) { - if ($page['order'] < $order || $order == 0) { - $firstChild = $page; - $order = $page['order']; - } - } - } - - if (null === $firstChild) { - // No children are visible and required mvc properties - // are missing: ergo this page is not visible. - $result['visible'] = false; - - // Use first (invisible) child as firstChild - $firstChild = reset($result['pages']); - } - } else { - // Use '/' slash as default to ensure any not visible - // menu items points to another existing item that is - // active. - $firstChild = array_fill_keys($requiredIndices, '/'); - } - - foreach ($requiredIndices as $key) { - $result[$key] = $firstChild[$key]; - } - } - return $result; } Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-06-28 10:08:16 UTC (rev 795) +++ trunk/library/classes/Gems/Menu.php 2012-06-28 14:17:45 UTC (rev 796) @@ -89,7 +89,7 @@ $this->loadProjectMenu(); $this->setOnlyActiveBranchVisible(); - $this->applyAcl($escort->acl, $escort->session->user_role); + $this->applyAcl($escort->acl, $escort->getLoader()->getCurrentUser()->getRole()); } private function _findPath($request) @@ -589,10 +589,10 @@ $this->addMailSetupMenu($this->_('Mail')); // EXPORT DATA - $this->addContainer('Export data', 'pr.export', array('controller'=>'export', 'action'=>'index')); + $this->addPage('Export data', 'pr.export', 'export', 'index'); // EXPORT TO HTML - $this->addContainer($this->_('Export respondent'), 'pr.export-html', array('controller' => 'respondent-export', 'action'=>'index')); + $this->addPage($this->_('Export respondent'), 'pr.export-html', 'respondent-export', 'index'); // OTHER ITEMS $this->addLogonOffToken(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-29 12:52:12
|
Revision: 802 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=802&view=rev Author: mennodekker Date: 2012-06-29 12:52:01 +0000 (Fri, 29 Jun 2012) Log Message: ----------- Update to data export: source needs to be active, gems survey status and source survey status are interpreted by a helper method to allow other sources to have their own logic. Fixed a notice in survey when adding a new survey and tracker::verbose Modified Paths: -------------- trunk/library/classes/Gems/Default/ExportAction.php trunk/library/classes/Gems/Tracker/Survey.php trunk/library/classes/Gems/Util/DbLookup.php Modified: trunk/library/classes/Gems/Default/ExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/ExportAction.php 2012-06-29 10:14:01 UTC (rev 801) +++ trunk/library/classes/Gems/Default/ExportAction.php 2012-06-29 12:52:01 UTC (rev 802) @@ -140,8 +140,7 @@ */ public function getForm(&$data) { - //Read some data from tables, initialize defaults... - $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 ORDER BY gsu_survey_name'); + $surveys = $this->loader->getUtil()->getDbLookup()->getSurveysForExport(); $organizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); $types = $this->export->getExportClasses(); @@ -151,7 +150,7 @@ //Start adding elements $element = new Zend_Form_Element_Select('sid'); $element->setLabel($this->_('Survey')) - ->setMultiOptions($surveys); + ->setMultiOptions($surveys); $elements[] = $element; //Add a field to the form showing the record count. If this is too slow for large recordsets Modified: trunk/library/classes/Gems/Tracker/Survey.php =================================================================== --- trunk/library/classes/Gems/Tracker/Survey.php 2012-06-29 10:14:01 UTC (rev 801) +++ trunk/library/classes/Gems/Tracker/Survey.php 2012-06-29 12:52:01 UTC (rev 802) @@ -137,7 +137,8 @@ if (Gems_Tracker::$verbose) { $echo = ''; foreach ($values as $key => $val) { - $echo .= $key . ': ' . $this->_gemsSurvey[$key] . ' => ' . $val . "\n"; + $old = isset($this->_gemsSurvey[$key]) ? $this->_gemsSurvey[$key] : null; + $echo .= $key . ': ' . $old . ' => ' . $val . "\n"; } MUtil_Echo::r($echo, 'Updated values for ' . $this->_surveyId); } Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2012-06-29 10:14:01 UTC (rev 801) +++ trunk/library/classes/Gems/Util/DbLookup.php 2012-06-29 12:52:01 UTC (rev 802) @@ -342,6 +342,55 @@ return $groups; } + /** + * Get all surveys that can be exported + * + * For export not only active surveys should be returned, but all surveys that can be exported. + * As this depends on the kind of source used it is in this method so projects can change to + * adapt to their own sources. + * + * @return array + */ + public function getSurveysForExport() + { + // Read some data from tables, initialize defaults... + $select = $this->db->select(); + + // Fetch al surveys + $select->from('gems__surveys') + ->join('gems__sources', 'gsu_id_source = gso_id_source') + ->where('gso_active = 1') + ->order(array('gsu_active DESC', 'gsu_survey_name')); + $result = $this->db->fetchAll($select); + + if ($result) { + // And transform to have inactive surveys in gems and source in a + // different group at the bottom + $surveys = array(); + $Inactive = $this->translate->_('inactive'); + $sourceInactive = $this->translate->_('source inactive'); + foreach ($result as $survey) { + $id = $survey['gsu_id_survey']; + $name = $survey['gsu_survey_name']; + if ($survey['gsu_surveyor_active'] == 0) { + // Inactive in the source, for LimeSurvey this is a problem! + if (!strpos($survey['gso_ls_class'], 'LimeSurvey')) { + $surveys[$sourceInactive][$id] = $name; + } + } elseif ($survey['gsu_active'] == 0) { + // Inactive in GemsTracker + $surveys[$Inactive][$id] = $name; + } else { + $surveys[$id] = $name; + } + } + } else { + $surveys = array(); + } + + return $surveys; + } + public function getUserConsents() { static $consents; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-09 12:26:47
|
Revision: 825 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=825&view=rev Author: michieltcs Date: 2012-07-09 12:26:37 +0000 (Mon, 09 Jul 2012) Log Message: ----------- Refactor (most of) the export form to RespondentExport Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/RespondentExportAction.php trunk/library/classes/Gems/Export/RespondentExport.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-07-09 08:10:13 UTC (rev 824) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-07-09 12:26:37 UTC (rev 825) @@ -62,40 +62,6 @@ public $useTabbedForms = true; /** - * Constructs the form - * - * @param Gems_Export_RespondentExport $export - * @return Gems_Form_TableForm - */ - protected function _getExportForm($export) - { - $form = new Gems_Form_TableForm(); - $form->setAttrib('target', '_blank'); - - $element = new Zend_Form_Element_Checkbox('group'); - $element->setLabel($this->_('Group surveys')); - $element->setValue(1); - $form->addElement($element); - - $element = new Zend_Form_Element_Select('format'); - $element->setLabel($this->_('Output format')); - $outputFormats = array('html' => 'HTML'); - if (!empty($export->_wkhtmltopdfLocation)) { - $outputFormats['pdf'] = 'PDF'; - $element->setValue('pdf'); - } - $element->setMultiOptions($outputFormats); - $form->addElement($element); - - $element = new Zend_Form_Element_Submit('export'); - $element->setLabel($this->_('Export')) - ->setAttrib('class', 'button'); - $form->addElement($element); - - return $form; - } - - /** * Adds columns from the model to the bridge that creates the browse table. * * Adds a button column to the model, if such a button exists in the model. @@ -530,7 +496,7 @@ //Now show the export form $export = $this->loader->getRespondentExport($this); - $form = $this->_getExportForm($export); + $form = $export->getForm(); $this->html->h2($this->_('Export respondent')); $div = $this->html->div(array('id' => 'mainform')); $div[] = $form; Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-07-09 08:10:13 UTC (rev 824) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-07-09 12:26:37 UTC (rev 825) @@ -46,55 +46,17 @@ { public $useHtmlView = true; - /** - * Constructs the form - * - * @param Gems_Export_RespondentExport $export - * @return Gems_Form_TableForm - */ - protected function _getForm($export) + public function indexAction() { - $form = new Gems_Form_TableForm(); - $form->setAttrib('target', '_blank'); + $export = $this->loader->getRespondentExport($this); $element = new Zend_Form_Element_Text('id'); $element->setLabel($this->_('Respondent number')); - - // only show description if we got here directly (id is empty) - if ($this->getRequest()->getParam('id') == '') { - $element->setDescription($this->_('Separate multiple respondents with a comma (,)')); - } - + $element->setOrder(-1); + $element->setDescription($this->_('Separate multiple respondents with a comma (,)')); + $form = $export->getForm(); $form->addElement($element); - $element = new Zend_Form_Element_Checkbox('group'); - $element->setLabel($this->_('Group surveys')); - $element->setValue(1); - $form->addElement($element); - - $element = new Zend_Form_Element_Select('format'); - $element->setLabel($this->_('Output format')); - $outputFormats = array('html' => 'HTML'); - if (!empty($export->_wkhtmltopdfLocation)) { - $outputFormats['pdf'] = 'PDF'; - $element->setValue('pdf'); - } - $element->setMultiOptions($outputFormats); - $form->addElement($element); - - $element = new Zend_Form_Element_Submit('export'); - $element->setLabel($this->_('Export')) - ->setAttrib('class', 'button'); - $form->addElement($element); - - return $form; - } - - public function indexAction() - { - $export = $this->loader->getRespondentExport($this); - - $form = $this->_getForm($export); $this->html->h2($this->_('Export respondent')); $div = $this->html->div(array('id' => 'mainform')); $div[] = $form; Modified: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php 2012-07-09 08:10:13 UTC (rev 824) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-07-09 12:26:37 UTC (rev 825) @@ -307,7 +307,40 @@ $this->_exportTrack($track); } } + + /** + * Constructs the form + * + * @return Gems_Form_TableForm + */ + public function getForm() + { + $form = new Gems_Form_TableForm(); + $form->setAttrib('target', '_blank'); + $element = new Zend_Form_Element_Checkbox('group'); + $element->setLabel($this->_('Group surveys')); + $element->setValue(1); + $form->addElement($element); + + $element = new Zend_Form_Element_Select('format'); + $element->setLabel($this->_('Output format')); + $outputFormats = array('html' => 'HTML'); + if (!empty($this->_wkhtmltopdfLocation)) { + $outputFormats['pdf'] = 'PDF'; + $element->setValue('pdf'); + } + $element->setMultiOptions($outputFormats); + $form->addElement($element); + + $element = new Zend_Form_Element_Submit('export'); + $element->setLabel($this->_('Export')) + ->setAttrib('class', 'button'); + $form->addElement($element); + + return $form; + } + /** * Renders the entire report (including layout) * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-19 13:04:16
|
Revision: 859 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=859&view=rev Author: michieltcs Date: 2012-07-19 13:04:06 +0000 (Thu, 19 Jul 2012) Log Message: ----------- Refactoring: move html to pdf conversion to Gems_Pdf Modified Paths: -------------- trunk/library/classes/Gems/Export/RespondentExport.php trunk/library/classes/Gems/Pdf.php Modified: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php 2012-07-19 11:12:13 UTC (rev 858) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-07-19 13:04:06 UTC (rev 859) @@ -43,8 +43,6 @@ */ class Gems_Export_RespondentExport extends Gems_Registry_TargetAbstract { - public $_pdfExportCommand = ""; - protected $_reportFooter = 'Export_ReportFooterSnippet'; protected $_reportHeader = 'Export_ReportHeaderSnippet'; protected $_respondentSnippet = 'Export_RespondentSnippet'; @@ -84,58 +82,22 @@ public $util; public $view; + + /** + * @var Gems_Pdf + */ + protected $_pdf; - public function _($messageid, $locale = null) - { - return $this->translate->_($messageid, $locale); - } - public function afterRegistry() { parent::afterRegistry(); - - // Load the pdf class from the project settings if available - if (isset($this->project->export) && isset($this->project->export['pdfExportCommand'])) { - $this->_pdfExportCommand = $this->project->export['pdfExportCommand']; - } + + $this->_pdf = $this->loader->getPdf(); } - - /** - * Calls 'wkhtmltopdf' to convert HTML to PDF - * - * @param string $content The HTML source - * @return string The converted PDF file - * @throws Exception - */ - protected function _convertToPdf($content) + + public function _($messageid, $locale = null) { - $tempInputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.html'; - $tempOutputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.pdf'; - - file_put_contents($tempInputFilename, $content); - - if (!file_exists($tempInputFilename)) { - throw new Exception("Unable to create temporary file '{$tempInputFilename}'"); - } - - $command = sprintf($this->_pdfExportCommand, escapeshellarg($tempInputFilename), - escapeshellarg($tempOutputFilename)); - - $lastLine = exec($command, $outputLines, $return); - - if ($return > 0) { - @unlink($tempInputFilename); - @unlink($tempOutputFilename); - - throw new Exception(sprintf($this->_('Unable to run PDF conversion (%s): "%s"'), $command, $lastLine)); - } - - $pdfContents = file_get_contents($tempOutputFilename); - - @unlink($tempInputFilename); - @unlink($tempOutputFilename); - - return $pdfContents; + return $this->translate->_($messageid, $locale); } /** @@ -328,7 +290,7 @@ $element = new Zend_Form_Element_Select('format'); $element->setLabel($this->_('Output format')); $outputFormats = array('html' => 'HTML'); - if (!empty($this->_pdfExportCommand)) { + if ($this->_pdf->hasPdfExport()) { $outputFormats['pdf'] = 'PDF'; $element->setValue('pdf'); } @@ -386,14 +348,9 @@ $content = $this->view->layout->render(); if ($this->_format == 'pdf') { - $content = $this->_convertToPdf($content); $filename = 'respondent-export-' . strtolower($respondentId) . '.pdf'; - - header('Content-Type: application/x-download'); - header('Content-Length: '.strlen($content)); - header('Content-Disposition: inline; filename="'.$filename.'"'); - header('Cache-Control: private, max-age=0, must-revalidate'); - header('Pragma: public'); + $content = $this->_pdf->convertFromHtml($content); + $this->_pdf->echoPdfContent($content, $filename, true); } echo $content; Modified: trunk/library/classes/Gems/Pdf.php =================================================================== --- trunk/library/classes/Gems/Pdf.php 2012-07-19 11:12:13 UTC (rev 858) +++ trunk/library/classes/Gems/Pdf.php 2012-07-19 13:04:06 UTC (rev 859) @@ -52,6 +52,12 @@ */ protected $db; + /** + * + * @var string + */ + protected $_pdfExportCommand = ""; + protected $pageFont = Zend_Pdf_Font::FONT_COURIER; protected $pageFontSize = 12; protected $pageX = 10; @@ -71,6 +77,16 @@ */ protected $translate; + public function afterRegistry() + { + parent::afterRegistry(); + + // Load the pdf class from the project settings if available + if (isset($this->project->export) && isset($this->project->export['pdfExportCommand'])) { + $this->_pdfExportCommand = $this->project->export['pdfExportCommand']; + } + } + protected function addTokenToDocument(Zend_Pdf $pdf, $tokenId, $surveyId) { $token = strtoupper($tokenId); @@ -123,7 +139,17 @@ protected function echoPdf(Zend_Pdf $pdf, $filename, $download = false, $exit = true) { $content = $pdf->render(); + + $this->echoPdfContent($content, $filename, $download); + if ($exit) { + // No further output + exit; + } + } + + public function echoPdfContent($content, $filename, $download = false) + { // MUtil_Echo::track($filename); if ($download) { // Download & save @@ -138,11 +164,6 @@ header('Pragma: public'); echo $content; - - if ($exit) { - // No further output - exit; - } } /** @@ -284,4 +305,50 @@ } throw new Gems_Exception_Coding($msg); } + + /** + * Calls the PDF convertor (wkhtmltopdf / phantom.js) to convert HTML to PDF + * + * @param string $content The HTML source + * @return string The converted PDF file + * @throws Exception + */ + public function convertFromHtml($content) + { + $tempInputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.html'; + $tempOutputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.pdf'; + + file_put_contents($tempInputFilename, $content); + + if (!file_exists($tempInputFilename)) { + throw new Exception("Unable to create temporary file '{$tempInputFilename}'"); + } + + $command = sprintf($this->_pdfExportCommand, escapeshellarg($tempInputFilename), + escapeshellarg($tempOutputFilename)); + + $lastLine = exec($command, $outputLines, $return); + + if ($return > 0) { + @unlink($tempInputFilename); + @unlink($tempOutputFilename); + + throw new Exception(sprintf($this->_('Unable to run PDF conversion (%s): "%s"'), $command, $lastLine)); + } + + $pdfContents = file_get_contents($tempOutputFilename); + + @unlink($tempInputFilename); + @unlink($tempOutputFilename); + + return $pdfContents; + } + + /** + * @return boolean + */ + public function hasPdfExport() + { + return !empty($this->_pdfExportCommand); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-26 12:33:47
|
Revision: 881 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=881&view=rev Author: mennodekker Date: 2012-07-26 12:33:37 +0000 (Thu, 26 Jul 2012) Log Message: ----------- Doc and interface compliance updates Modified Paths: -------------- trunk/library/classes/Gems/Snippets/SnippetLoader.php trunk/library/classes/Gems/User/Form/LayeredLoginForm.php Modified: trunk/library/classes/Gems/Snippets/SnippetLoader.php =================================================================== --- trunk/library/classes/Gems/Snippets/SnippetLoader.php 2012-07-26 10:46:40 UTC (rev 880) +++ trunk/library/classes/Gems/Snippets/SnippetLoader.php 2012-07-26 12:33:37 UTC (rev 881) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,26 +25,27 @@ * (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 + * Gems specific version of the snippet loader * * @package Gems - * @subpackage + * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ */ /** - * Short description for SnippetLoader + * Gems specific version of the snippet loader * - * Long description for class SnippetLoader (if any)... + * Loads snippets like all other classes in gems first with project prefix, then gems, mutil + * and when all that fails it will try without prefix from the project\snippets and gems\snippets + * folders * * @package Gems - * @subpackage Sample + * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.5.5 */ class Gems_Snippets_SnippetLoader extends Gems_Loader_TargetLoaderAbstract implements MUtil_Snippets_SnippetLoaderInterface { @@ -58,6 +58,12 @@ */ protected $backup; + /** + * Initialize the snippetloader (Gems style) + * + * @param mixed $container A container acting as source for MUtil_Registry_Source + * @param array $dirs The directories where to look for requested classes + */ public function __construct($container = null, $dirs = array()) { parent::__construct($container, $dirs); $this->backup = new MUtil_Snippets_SnippetLoader($this); @@ -65,6 +71,12 @@ } + /** + * Add a directory to the front of the list of places where snippets are loaded from. + * + * @param string $dir + * @return MUtil_Snippets_SnippetLoader + */ public function addDirectory($dir) { if (!array_key_exists('', $this->_dirs)) { @@ -72,19 +84,38 @@ } array_unshift($this->_dirs[''], $dir); - $this->backup->addDirectory($dir); + return $this->backup->addDirectory($dir); } + /** + * Add parameter values to the source for snippets. + * + * @param mixed $container_or_pairs This function can be called with either a single container or a list of name/value pairs. + * @return MUtil_Snippets_SnippetLoader + */ public function addSource($container_or_pairs) { - $this->backup->addSource($container_or_pairs); + return $this->backup->addSource($container_or_pairs); } + /** + * Returns the directories where snippets are loaded from. + * + * @param array $dirs + * @return array + */ public function getDirectories() { - $this->backup->getDirectories(); + return $this->backup->getDirectories(); } + /** + * Searches and loads a .php snippet file. + * + * @param string $filename The name of the snippet + * @param array $extraSourceParameters name/value pairs to add to the source for this snippet + * @return MUtil_Snippets_SnippetInterface The snippet + */ public function getSnippet($filename, array $extraSourceParameters = null) { try { @@ -101,18 +132,35 @@ return $snippet; } + /** + * Returns a source of values for snippets. + * + * @return MUtil_Registry_SourceInterface + */ public function getSource() { - $this->backup->getSource(); + return $this->backup->getSource(); } + /** + * Set the directories where snippets are loaded from. + * + * @param array $dirs + * @return MUtil_Snippets_SnippetLoader (continuation pattern) + */ public function setDirectories(array $dirs) { - $this->backup->setDirectories($dirs); + return $this->backup->setDirectories($dirs); } + /** + * Sets the source of variables for snippets + * + * @param MUtil_Registry_SourceInterface $source + * @return MUtil_Snippets_SnippetLoader (continuation pattern) + */ public function setSource(MUtil_Registry_SourceInterface $source) { - $this->backup->setSource($source); + return $this->backup->setSource($source); } } \ No newline at end of file Modified: trunk/library/classes/Gems/User/Form/LayeredLoginForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/LayeredLoginForm.php 2012-07-26 10:46:40 UTC (rev 880) +++ trunk/library/classes/Gems/User/Form/LayeredLoginForm.php 2012-07-26 12:33:37 UTC (rev 881) @@ -25,27 +25,23 @@ * 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. - * - * Short description of file * * @package Gems - * @subpackage + * @subpackage User\Form * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ */ /** - * Short description for LoginForm + * A layered login form, useful when organizations have some kind of + * hierarchy * - * Long description for class LoginForm (if any)... - * * @package Gems - * @subpackage Sample + * @subpackage User\Form * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.5.5 */ class Gems_User_Form_LayeredLoginForm extends Gems_User_Form_LoginForm { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-09-18 17:14:21
|
Revision: 944 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=944&view=rev Author: matijsdejong Date: 2012-09-18 17:14:15 +0000 (Tue, 18 Sep 2012) Log Message: ----------- Fix in ModelFormSnippetAbstract.php where menu item was not found so reroute went to index, not show Extra cache clean for new organizations Modified Paths: -------------- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2012-09-18 15:19:39 UTC (rev 943) +++ trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2012-09-18 17:14:15 UTC (rev 944) @@ -217,8 +217,12 @@ $this->afterSaveRouteUrl['controller'] = $this->request->getControllerName(); } + // Search array for menu item + $find['controller'] = $this->afterSaveRouteUrl['controller']; + $find['action'] = $this->afterSaveRouteUrl['action']; + // If not allowed, redirect to index - if (null == $this->menu->find($this->afterSaveRouteUrl)) { + if (null == $this->menu->find($find)) { $this->afterSaveRouteUrl['action'] = 'index'; $this->resetRoute = true; } Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-09-18 15:19:39 UTC (rev 943) +++ trunk/library/classes/Gems/User/User.php 2012-09-18 17:14:15 UTC (rev 944) @@ -1221,6 +1221,9 @@ $this->_setVar('__allowedOrgs', $orgs); + // Clean this cache + $this->_unsetVar('__allowedRespOrgs'); + return $this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-09-21 16:42:28
|
Revision: 952 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=952&view=rev Author: matijsdejong Date: 2012-09-21 16:42:22 +0000 (Fri, 21 Sep 2012) Log Message: ----------- Fix for pulse bugs #556 and #551: user cannot be changed when in an inactive group Modified Paths: -------------- trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2012-09-21 08:20:22 UTC (rev 951) +++ trunk/library/classes/Gems/Default/StaffAction.php 2012-09-21 16:42:22 UTC (rev 952) @@ -392,7 +392,7 @@ } } - return parent::getAfterSaveRoute($data, $isNew); + return parent::getAfterSaveRoute($data); } protected function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) Modified: trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2012-09-21 08:20:22 UTC (rev 951) +++ trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2012-09-21 16:42:22 UTC (rev 952) @@ -102,6 +102,7 @@ // MUtil_Echo::track($name, $model->get($name, 'thClass'), $model->get($name, 'label')); } } + // MUtil_Echo::track($names); return $names; } Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-09-21 08:20:22 UTC (rev 951) +++ trunk/library/classes/Gems/User/User.php 2012-09-21 16:42:22 UTC (rev 952) @@ -990,10 +990,25 @@ */ public function hasAllowedRole() { - if ($allowedGroups = $this->util->getDbLookup()->getAllowedStaffGroups()) { - return isset($allowedGroups[$this->getGroup()]) ? 1 : 0; + if (! $this->isStaff()) { + // Always allow editing of non-staff user + // for the time being + return true; + } + + $dbLookup = $this->util->getDbLookup(); + $groups = $dbLookup->getActiveStaffGroups(); + $group = $this->getGroup(); + + if (! isset($groups[$group])) { + // Allow editing when the group does not exist or is no longer active. + return true; + } + + if ($allowedGroups = $dbLookup->getAllowedStaffGroups()) { + return (boolean) isset($allowedGroups[$this->getGroup()]); } else { - return 0; + return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-09-25 14:30:37
|
Revision: 955 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=955&view=rev Author: mennodekker Date: 2012-09-25 14:30:28 +0000 (Tue, 25 Sep 2012) Log Message: ----------- Minor optimization for excel export + increased max_execution_time for as long as it is not yet moved to a BatchTask Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/FormattedData.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-09-25 12:26:47 UTC (rev 954) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-09-25 14:30:28 UTC (rev 955) @@ -429,6 +429,8 @@ */ public function excelAction() { + ini_set('max_execution_time', 90); // Quickfix as long as it is not in a batchtask + // Set the request cache to use the search params from the index action $this->getCachedRequestData(true, 'index'); Modified: trunk/library/classes/Gems/FormattedData.php =================================================================== --- trunk/library/classes/Gems/FormattedData.php 2012-09-25 12:26:47 UTC (rev 954) +++ trunk/library/classes/Gems/FormattedData.php 2012-09-25 14:30:28 UTC (rev 955) @@ -86,7 +86,7 @@ return $row; } - /** + /** * This is the actual format function, copied from the Exhibitor for field * * @param type $name @@ -95,10 +95,8 @@ */ private static function _format($name, $result, $model) { - if ($default = $model->get($name,'default')) { - if (null === $result) { - $result = $default; - } + if (null === $result && $default = $model->get($name,'default')) { + $result = $default; } if ($multiOptions = $model->get($name, 'multiOptions')) { @@ -146,13 +144,11 @@ // If it is Lazy, execute it if ($result instanceof MUtil_Lazy_LazyInterface) { - if ($result instanceof MUtil_Lazy_LazyInterface) { - $result = MUtil_Lazy::rise($result); - } + $result = MUtil_Lazy::rise($result); } // If it is Html, render it - if ($result instanceof MUtil_Html_HtmlInterface || $result instanceof MUtil_Lazy_LazyInterface) { + if ($result instanceof MUtil_Html_HtmlInterface) { $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); if (null === $viewRenderer->view) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-09-26 10:33:46
|
Revision: 957 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=957&view=rev Author: mennodekker Date: 2012-09-26 10:33:36 +0000 (Wed, 26 Sep 2012) Log Message: ----------- Some further optimization of excel export Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/FormattedData.php trunk/library/classes/Gems/View/Helper/Excel.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-09-25 15:34:45 UTC (rev 956) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-09-26 10:33:36 UTC (rev 957) @@ -439,7 +439,7 @@ $this->_applySearchParameters($model, true); $this->addExcelColumns($model); // Hook to modify the model - + // Use $this->formatExcelData to switch between formatted and unformatted data $excelData = new Gems_FormattedData($this->getExcelData($model->load(), $model), $model, $this->formatExcelData); @@ -695,10 +695,7 @@ if ($headings) { if ($data) { foreach ($data as $row) { - foreach ($headings as $key => $value) { - $result[$key] = isset($row[$key]) ? $row[$key] : null; - } - $results[] = $result; + $results[] = array_intersect_key($row, $headings); } return $results; } else { @@ -997,4 +994,4 @@ $this->html[] = $table; } -} +} \ No newline at end of file Modified: trunk/library/classes/Gems/FormattedData.php =================================================================== --- trunk/library/classes/Gems/FormattedData.php 2012-09-25 15:34:45 UTC (rev 956) +++ trunk/library/classes/Gems/FormattedData.php 2012-09-26 10:33:36 UTC (rev 957) @@ -80,7 +80,7 @@ * @return array The formatted array */ static function format($row, $model) { - foreach ($row as $fieldname=>$value) { + foreach ($row as $fieldname=>$value) { $row[$fieldname] = self::_format($fieldname, $row[$fieldname], $model); } return $row; @@ -91,76 +91,113 @@ * * @param type $name * @param type $result + *@param MUtil_Model_ModelAbstract $model * @return type */ private static function _format($name, $result, $model) { - if (null === $result && $default = $model->get($name,'default')) { - $result = $default; + static $opts = array(); + static $view = null; + + if (!isset($opts[$name])) { + $opts[$name] = $model->get($name, array('default', 'multiOptions', 'formatFunction', 'dateFormat', 'storageFormat', 'itemDisplay')); } - if ($multiOptions = $model->get($name, 'multiOptions')) { - if (is_array($multiOptions)) { - /* - * Sometimes a field is an array and will be formatted later on using the - * formatFunction -> handle each element in the array. - */ - if (is_array($result)) { - foreach($result as $key => $value) { - if (array_key_exists($value, $multiOptions)) { - $result[$key] = $multiOptions[$value]; + $options = $opts[$name]; + + foreach($options as $key => $value) { + switch ($key) { + case 'default': + if (is_null($result)) { + $result = $value; + } + break; + + case 'multiOptions': + $multiOptions = $value; + if (is_array($multiOptions)) { + /* + * Sometimes a field is an array and will be formatted later on using the + * formatFunction -> handle each element in the array. + */ + if (is_array($result)) { + foreach($result as $key => $value) { + if (array_key_exists($value, $multiOptions)) { + $result[$key] = $multiOptions[$value]; + } + } + } else { + if (array_key_exists($result, $multiOptions)) { + $result = $multiOptions[$result]; + } } } - } else { - if (array_key_exists($result, $multiOptions)) { - $result = $multiOptions[$result]; + break; + + case 'formatFunction': + $callback = $value; + $result = call_user_func($callback, $result); + break; + + case 'dateFormat': + if (array_key_exists('formatFunction', $options)) { + // if there is a formatFunction skip the date formatting + continue; } - } - } - } + + $dateFormat = $value; + $storageFormat = $model->get($name, 'storageFormat'); + $result = MUtil_Date::format($result, $dateFormat, $storageFormat); + break; + case 'itemDisplay': + $function = $value; + if (is_callable($function)) { + $result = call_user_func($function, $result); + } elseif (is_object($function)) { + if (($function instanceof MUtil_Html_ElementInterface) + || method_exists($function, 'append')) { + $object = clone $function; + $result = $object->append($result); + } + } elseif (is_string($function)) { + // Assume it is a html tag when a string + $result = MUtil_Html::create($function, $result); + } - if ($callback = $model->get($name, 'formatFunction')) { - $result = call_user_func($callback, $result); - } elseif ($dateFormat = $model->get($name, 'dateFormat')) { - $storageFormat = $model->get($name, 'storageFormat'); - $result = MUtil_Date::format($result, $dateFormat, $storageFormat); + default: + break; + } } - if ($function = $model->get($name, 'itemDisplay')) { - if (is_callable($function)) { - $result = call_user_func($function, $result); - } elseif (is_object($function)) { - if (($function instanceof MUtil_Html_ElementInterface) - || method_exists($function, 'append')) { - $object = clone $function; - $result = $object->append($result); - } - } elseif (is_string($function)) { - // Assume it is a html tag when a string - $result = MUtil_Html::create($function, $result); + if (is_object($result)) { + // If it is Lazy, execute it + if ($result instanceof MUtil_Lazy_LazyInterface) { + $result = MUtil_Lazy::rise($result); } - } - // If it is Lazy, execute it - if ($result instanceof MUtil_Lazy_LazyInterface) { - $result = MUtil_Lazy::rise($result); - } + // If it is Html, render it + if ($result instanceof MUtil_Html_HtmlInterface) { - // If it is Html, render it - if ($result instanceof MUtil_Html_HtmlInterface) { + if (is_null($view)) { + $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); + if (null === $viewRenderer->view) { + $viewRenderer->initView(); + } + $view = $viewRenderer->view; + } - $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); - if (null === $viewRenderer->view) { - $viewRenderer->initView(); + $result = $result->render($view); } - $view = $viewRenderer->view; - $result = $result->render($view); } return $result; } + public function getFormatted() { + return $this->formatted; + } + public function setFormatted($bool) { - $this->formatted = $bool; + $this->formatted = (bool) $bool; } } \ No newline at end of file Modified: trunk/library/classes/Gems/View/Helper/Excel.php =================================================================== --- trunk/library/classes/Gems/View/Helper/Excel.php 2012-09-25 15:34:45 UTC (rev 956) +++ trunk/library/classes/Gems/View/Helper/Excel.php 2012-09-26 10:33:36 UTC (rev 957) @@ -50,6 +50,7 @@ } catch (Exception $e) {} $this->view->layout()->setLayout('excel'); if ($rowset instanceof Gems_FormattedData) { + $formatted = $rowset->getFormatted(); $rowset->setFormatted(false); } $rowcnt = 0; @@ -72,7 +73,7 @@ $output .= "\t</thead>\r\n"; $output .= "\t<tbody>\r\n"; if ($rowset instanceof Gems_FormattedData) { - $rowset->setFormatted(true); + $rowset->setFormatted($formatted); } } else { $output .= "\t\t<tr>\r\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-01 12:57:26
|
Revision: 965 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=965&view=rev Author: mennodekker Date: 2012-10-01 12:57:20 +0000 (Mon, 01 Oct 2012) Log Message: ----------- Fix error with tabs and autosearch (request doesn't know about tabs) Add Excel to survey maintenance Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-09-27 11:14:25 UTC (rev 964) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-10-01 12:57:20 UTC (rev 965) @@ -640,6 +640,9 @@ } } + // Make sure to update the request + $this->getRequest()->setParams($data); + return $data; } Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-09-27 11:14:25 UTC (rev 964) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-10-01 12:57:20 UTC (rev 965) @@ -444,6 +444,7 @@ // SURVEY MAINTENANCE CONTROLLER $page = $setup->addPage($this->_('Surveys'), 'pr.survey-maintenance', 'survey-maintenance'); $page->addEditAction(); + $page->addExcelAction(); $page->addShowAction(); $page->addPdfButton($this->_('PDF'), 'pr.survey-maintenance') ->addParameters(MUtil_Model::REQUEST_ID) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-08 09:35:08
|
Revision: 972 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=972&view=rev Author: mennodekker Date: 2012-10-08 09:35:02 +0000 (Mon, 08 Oct 2012) Log Message: ----------- Fixed #572: Show selected tokens in mailjob overview Modified Paths: -------------- trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Util/DbLookup.php Added Paths: ----------- trunk/library/classes/Gems/Snippets/TokenPlanTableSnippet.php Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2012-10-02 14:38:55 UTC (rev 971) +++ trunk/library/classes/Gems/Default/CronAction.php 2012-10-08 09:35:02 UTC (rev 972) @@ -44,7 +44,7 @@ * @license New BSD License * @since Class available since version 1.4 */ -class Gems_Default_CronAction extends MUtil_Controller_Action +class Gems_Default_CronAction extends Gems_Controller_Action { /** * @@ -53,22 +53,7 @@ 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; @@ -179,23 +164,7 @@ $user->setAsCurrentUser(); } - // 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)'; - $filter[] = 'gto_mail_sent_num < ' . $job['gmj_filter_max_reminders']; - } 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']; - } + $filter = $this->loader->getUtil()->getDbLookup()->getFilterForMailJob($job); $tokensData = $model->load($filter); Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2012-10-02 14:38:55 UTC (rev 971) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2012-10-08 09:35:02 UTC (rev 972) @@ -175,4 +175,22 @@ $this->html->pInfo($this->_('With automatic mail jobs and a cron job on the server, mails can be sent without manual user action.')); } + + public function showAction() + { + parent::showAction(); + + $id = $this->getRequest()->getParam('id'); + if (!is_null($id)) { + $id = (int) $id; + $job = $this->db->fetchRow("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1 and gmj_id_job = ?", $id); + if ($job) { + $model = $this->loader->getTracker()->getTokenModel(); + $filter = $this->loader->getUtil()->getDbLookup()->getFilterForMailJob($job); + $params['model'] = $model; + $params['filter'] = $filter; + $this->addSnippet('TokenPlanTableSnippet', $params); + } + } + } } Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-10-02 14:38:55 UTC (rev 971) +++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-10-08 09:35:02 UTC (rev 972) @@ -110,7 +110,7 @@ public function createModel($detailed, $action) { // MUtil_Model::$verbose = true; - $model = $this->loader->getTracker()->getTokenModel();; + $model = $this->loader->getTracker()->getTokenModel(); $model->setCreate(false); $model->set('gr2o_patient_nr', 'label', $this->_('Respondent')); Added: trunk/library/classes/Gems/Snippets/TokenPlanTableSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/TokenPlanTableSnippet.php (rev 0) +++ trunk/library/classes/Gems/Snippets/TokenPlanTableSnippet.php 2012-10-08 09:35:02 UTC (rev 972) @@ -0,0 +1,143 @@ +<?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 Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Displays a table for TokenModel + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.6 + */ +class Gems_Snippets_TokenPlanTableSnippet extends Gems_Snippets_ModelTableSnippetGeneric +{ + public $filter = array(); + + /** + * @var GemsEscort + */ + public $escort; + + public function addBrowseTableColumns(\MUtil_Model_TableBridge $bridge, \MUtil_Model_ModelAbstract $model) + { + $model->set('gr2o_patient_nr', 'label', $this->_('Respondent')); + $model->set('gto_round_description', 'label', $this->_('Round / Details')); + $model->set('gto_valid_from', 'label', $this->_('Valid from')); + $model->set('gto_valid_until', 'label', $this->_('Valid until')); + $model->set('gto_mail_sent_date', 'label', $this->_('Contact date')); + $model->set('respondent_name', 'label', $this->_('Name')); + + $HTML = MUtil_Html::create(); + + // Row with dates and patient data + $bridge->gtr_track_type; // Data needed for buttons + + $bridge->setDefaultRowClass(MUtil_Html_TableElement::createAlternateRowClass('even', 'even', 'odd', 'odd')); + $bridge->addColumn($this->getTokenLinks($bridge), ' ')->rowspan = 2; // Space needed because TableElement does not look at rowspans + $bridge->addSortable('gto_valid_from'); + $bridge->addSortable('gto_valid_until'); + + $bridge->addMultiSort('gr2o_patient_nr', $HTML->raw('; '), 'respondent_name'); + $bridge->addMultiSort('ggp_name', array($this->getActionLinks($bridge))); + + $bridge->tr(); + $bridge->addSortable('gto_mail_sent_date'); + $bridge->addSortable('gto_completion_time'); + + if ($this->escort instanceof Gems_Project_Tracks_SingleTrackInterface) { + $bridge->addMultiSort('calc_round_description', $HTML->raw('; '), 'gsu_survey_name'); + } else { + $model->set('calc_track_info', 'tableDisplay', 'smallData'); + $model->set('calc_round_description', 'tableDisplay', 'smallData'); + $bridge->addMultiSort( + 'calc_track_name', 'calc_track_info', + $bridge->calc_track_name->if($HTML->raw(' » ')), + 'gsu_survey_name', 'calc_round_description'); + } + + $bridge->addSortable('assigned_by'); + } + + public function getActionLinks(MUtil_Model_TableBridge $bridge) + { + // Get the other token buttons + if ($menuItems = $this->menu->findAll(array('controller' => array('track', 'survey'), 'action' => array('email', 'answer'), 'allowed' => true))) { + $buttons = $menuItems->toActionLink($this->request, $bridge); + $buttons->appendAttrib('class', 'rightFloat'); + } else { + $buttons = null; + } + // Add the ask button + if ($menuItem = $this->menu->find(array('controller' => 'ask', 'action' => 'take', 'allowed' => true))) { + $askLink = $menuItem->toActionLink($this->request, $bridge); + $askLink->appendAttrib('class', 'rightFloat'); + + if ($buttons) { + // Show previous link if show, otherwise show ask link + $buttons = array($buttons, $askLink); + } else { + $buttons = $askLink; + } + } + + return $buttons; + } + + public function getTokenLinks(MUtil_Model_TableBridge $bridge) + { + // Get the token buttons + if ($menuItems = $this->menu->findAll(array('controller' => array('track', 'survey'), 'action' => 'show', 'allowed' => true))) { + $buttons = $menuItems->toActionLink($this->request, $bridge, $this->_('+')); + $buttons->title = $bridge->gto_id_token->strtoupper(); + + return $buttons; + } + } + + public function processFilterAndSort(MUtil_Model_ModelAbstract $model) + { + if (!empty($this->filter)) { + $model->setFilter($this->filter); + } + + parent::processFilterAndSort($model); + + if (!empty($this->filter)) { + $filter = $model->getFilter(); + unset($filter['gto_id_token']); + $model->setFilter($filter); + } + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2012-10-02 14:38:55 UTC (rev 971) +++ trunk/library/classes/Gems/Util/DbLookup.php 2012-10-08 09:35:02 UTC (rev 972) @@ -185,6 +185,44 @@ } } + /** + * Get the filter to use on the tokenmodel when working with a mailjob. + * + * @param array $job + * @return array + */ + public function getFilterForMailJob($job) + { + // Set up filter + $filter = 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)' + ); + + if ($job['gmj_filter_mode'] == 'R') { + $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $job['gmj_filter_days_between'] . ' DAY)'; + $filter[] = 'gto_mail_sent_num < ' . $job['gmj_filter_max_reminders']; + } 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']; + } + + return $filter; + } + public function getGroups() { static $groups; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-11 12:15:07
|
Revision: 978 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=978&view=rev Author: matijsdejong Date: 2012-10-11 12:14:57 +0000 (Thu, 11 Oct 2012) Log Message: ----------- Switching organizations now switches organization search term in auto search from the old organization to the new organization. Modified Paths: -------------- trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2012-10-10 18:00:13 UTC (rev 977) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2012-10-11 12:14:57 UTC (rev 978) @@ -74,14 +74,22 @@ $user = $this->loader->getCurrentUser(); $request = $this->getRequest(); $orgId = urldecode($request->getParam('org')); - $url = base64_decode($request->getParam('current_uri')); + $oldOrg = $user->getCurrentOrganizationId(); + $origUrl = base64_decode($request->getParam('current_uri')); $allowedOrganizations = $user->getAllowedOrganizations(); if (isset($allowedOrganizations[$orgId])) { $user->setCurrentOrganization($orgId); - if ($url) { - $this->getResponse()->setRedirect($url); + if ($origUrl) { + foreach ($user->possibleOrgIds as $key) { + $finds[] = '/' . $key. '/' . $oldOrg; + $replaces[] = '/' . $key. '/' . $orgId; + } + $correctUrl = str_replace($finds, $replaces, $origUrl); + // MUtil_Echo::track($origUrl, $correctUrl); + + $this->getResponse()->setRedirect($correctUrl); } else { $user->gotoStartPage($this->menu, $request); } Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-10-10 18:00:13 UTC (rev 977) +++ trunk/library/classes/Gems/User/User.php 2012-10-11 12:14:57 UTC (rev 978) @@ -94,7 +94,17 @@ protected $failureIgnoreTime = 600; /** + * Array containing the parameter names that may point to an organization * + * @var array + */ + public $possibleOrgIds = array( + MUtil_Model::REQUEST_ID2, + 'gr2o_id_organization', + 'gto_id_organization'); + + /** + * * @var Gems_Project_ProjectSettings */ protected $project; @@ -1376,15 +1386,11 @@ if ($requestCache = $this->session->requestCache) { //Create the list of request cache keys that match an organization ID (to be extended) - $possibleOrgIds = array( - MUtil_Model::REQUEST_ID2, - 'gr2o_id_organization', - 'gto_id_organization'); - foreach ($requestCache as $key => $value) { if (is_array($value)) { foreach ($value as $paramKey => $paramValue) { - if (in_array($paramKey, $possibleOrgIds)) { + if (in_array($paramKey, $this->possibleOrgIds)) { + if ($paramValue == $oldOrganizationId) { $requestCache[$key][$paramKey] = $organizationId; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-12 13:02:15
|
Revision: 982 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=982&view=rev Author: matijsdejong Date: 2012-10-12 13:02:04 +0000 (Fri, 12 Oct 2012) Log Message: ----------- Temporary fix for org-switch/setParam() problem Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Default/OrganizationAction.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-10-11 16:30:59 UTC (rev 981) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-10-12 13:02:04 UTC (rev 982) @@ -439,7 +439,7 @@ $this->_applySearchParameters($model, true); $this->addExcelColumns($model); // Hook to modify the model - + // Use $this->formatExcelData to switch between formatted and unformatted data $excelData = new Gems_FormattedData($this->getExcelData($model->load(), $model), $model, $this->formatExcelData); @@ -636,7 +636,7 @@ foreach ($data as $key => $value) { if ((is_array($value) && empty($value)) || (is_string($value) && 0 === strlen($value))) { unset($data[$key]); - } + } } } Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2012-10-11 16:30:59 UTC (rev 981) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2012-10-12 13:02:04 UTC (rev 982) @@ -82,13 +82,16 @@ $user->setCurrentOrganization($orgId); if ($origUrl) { - foreach ($user->possibleOrgIds as $key) { - $finds[] = '/' . $key. '/' . $oldOrg; - $replaces[] = '/' . $key. '/' . $orgId; + if (strpos($origUrl, '/index/') === false) { + $correctUrl = $origUrl; + } else { + foreach ($user->possibleOrgIds as $key) { + $finds[] = '/' . $key. '/' . $oldOrg; + $replaces[] = '/' . $key. '/' . $orgId; + } + $correctUrl = str_replace($finds, $replaces, $origUrl); } - $correctUrl = str_replace($finds, $replaces, $origUrl); // MUtil_Echo::track($origUrl, $correctUrl); - $this->getResponse()->setRedirect($correctUrl); } else { $user->gotoStartPage($this->menu, $request); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-01 16:35:01
|
Revision: 1005 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1005&view=rev Author: matijsdejong Date: 2012-11-01 16:34:55 +0000 (Thu, 01 Nov 2012) Log Message: ----------- Fix for bug 547 superadmin cannot change email template Fix for bug 570 wrong reception code shown while deleting Modified Paths: -------------- trunk/library/classes/Gems/Email/MailTemplateForm.php trunk/library/classes/Gems/Util/ReceptionCodeLibrary.php Modified: trunk/library/classes/Gems/Email/MailTemplateForm.php =================================================================== --- trunk/library/classes/Gems/Email/MailTemplateForm.php 2012-11-01 11:08:38 UTC (rev 1004) +++ trunk/library/classes/Gems/Email/MailTemplateForm.php 2012-11-01 16:34:55 UTC (rev 1005) @@ -131,10 +131,10 @@ $org_id = $this->getValue('gto_id_organization'); $filter['gto_id_organization'] = $org_id ? $org_id : $this->escort->getCurrentOrganization(); + $filter[] = 'grs_email IS NOT NULL'; - // By sorting descending we get the filled values first, so we usually get a correct value - // with email and valid_from date, but use any other token afterwards - $sort = array('grs_email' => SORT_DESC, 'gto_valid_from' => SORT_DESC); + // Without sorting we get the fastest load times + $sort = false; $tokenData = $model->loadFirst($filter, $sort); Modified: trunk/library/classes/Gems/Util/ReceptionCodeLibrary.php =================================================================== --- trunk/library/classes/Gems/Util/ReceptionCodeLibrary.php 2012-11-01 11:08:38 UTC (rev 1004) +++ trunk/library/classes/Gems/Util/ReceptionCodeLibrary.php 2012-11-01 16:34:55 UTC (rev 1005) @@ -136,7 +136,7 @@ public function getRespondentDeletionCodes() { $select = $this->_getDeletionCodeSelect(); - $select->where('(grc_for_respondents = 1 OR grc_for_surveys = ?)', self::APPLY_STOP); + $select->where('grc_for_respondents = 1'); return $this->db->fetchPairs($select); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-21 15:10:42
|
Revision: 1024 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1024&view=rev Author: matijsdejong Date: 2012-11-21 15:10:31 +0000 (Wed, 21 Nov 2012) Log Message: ----------- When there are no answers the answer headers are shown in OnlyAnswered.php FixBugfixes in maintenance actions Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php trunk/library/classes/Gems/Default/TrackMaintenanceAction.php trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-11-16 16:47:15 UTC (rev 1023) +++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-11-21 15:10:31 UTC (rev 1024) @@ -248,7 +248,7 @@ */ public function afterSave(array $data, $isNew) { - $this->cache->clean('matchTags', array('surveys', 'tracks')); + $this->cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('surveys', 'tracks')); return true; } Modified: trunk/library/classes/Gems/Default/TrackMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-11-16 16:47:15 UTC (rev 1023) +++ trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2012-11-21 15:10:31 UTC (rev 1024) @@ -161,7 +161,7 @@ */ public function afterSave(array $data, $isNew) { - $this->cache->clean('matchTags', array('surveys', 'tracks')); + $this->cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('surveys', 'tracks')); return true; } Modified: trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2012-11-16 16:47:15 UTC (rev 1023) +++ trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php 2012-11-21 15:10:31 UTC (rev 1024) @@ -74,10 +74,16 @@ $keys += array_filter($row->getArrayCopy()); } - $results = array_intersect($currentNames, array_keys($keys)); + $results = array_intersect($currentNames, array_keys($keys), array_keys($this->token->getRawAnswers())); // MUtil_Echo::track($results); - return $this->restoreHeaderPositions($model, $results); + $results = $this->restoreHeaderPositions($model, $results); + + if ($results) { + return $results; + } + + return $this->getHeaders($model, $currentNames); } /** Modified: trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php =================================================================== --- trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php 2012-11-16 16:47:15 UTC (rev 1023) +++ trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php 2012-11-21 15:10:31 UTC (rev 1024) @@ -87,6 +87,30 @@ // public function getEventName() /** + * Returns only the headers + * + * @param MUtil_Model_ModelAbstract $model + * @param array $currentNames The current names in use (allows chaining) + * @return array Of the names of labels that should be shown + */ + protected function getHeaders(MUtil_Model_ModelAbstract $model, array $currentNames) + { + $lastParent = null; + $results = array(); + foreach ($currentNames as $name) { + if ($model->is($name, 'type', MUtil_Model::TYPE_NOVALUE)) { + $results[$name] = $name; + + } elseif ($parent = $model->get($name, 'parent_question')) { + // Insert parent header on name if it was not shown before + $results[$parent] = $parent; + } + } + + return $results; + } + + /** * Restores the header position of question before their corresponding question_sub * * When sub-questions with the same parent are shown continuous the parent is shown This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-22 11:19:42
|
Revision: 1030 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1030&view=rev Author: mennodekker Date: 2012-11-22 11:19:31 +0000 (Thu, 22 Nov 2012) Log Message: ----------- doc fixes Modified Paths: -------------- trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php trunk/library/classes/Gems/Tracker/Survey.php Modified: trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php 2012-11-22 11:17:29 UTC (rev 1029) +++ trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php 2012-11-22 11:19:31 UTC (rev 1030) @@ -39,7 +39,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.6 */ class Gems_Snippets_Export_SurveyHeaderSnippet extends MUtil_Snippets_SnippetAbstract { Modified: trunk/library/classes/Gems/Tracker/Survey.php =================================================================== --- trunk/library/classes/Gems/Tracker/Survey.php 2012-11-22 11:17:29 UTC (rev 1029) +++ trunk/library/classes/Gems/Tracker/Survey.php 2012-11-22 11:19:31 UTC (rev 1030) @@ -111,7 +111,7 @@ } /** - * Makes sure the receptioncode data is part of the $this->_gemsData + * Makes sure the group data is part of the $this->_gemsSurvey * * @param boolean $reload Optional parameter to force reload. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-12-17 12:27:29
|
Revision: 1067 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1067&view=rev Author: mennodekker Date: 2012-12-17 12:27:22 +0000 (Mon, 17 Dec 2012) Log Message: ----------- Fixes for date calculations to accept MUtil_Date instead of a string Modified Paths: -------------- trunk/library/classes/Gems/Tracker/RespondentTrack.php trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/Gems/Util/Translated.php Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-12-17 10:01:04 UTC (rev 1066) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-12-17 12:27:22 UTC (rev 1067) @@ -410,6 +410,10 @@ } if ($date) { + if ($date instanceof MUtil_Date) { + return $date; + } + if (Zend_Date::isDate($date, Gems_Tracker::DB_DATETIME_FORMAT)) { return new MUtil_Date($date, Gems_Tracker::DB_DATETIME_FORMAT); } Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-12-17 10:01:04 UTC (rev 1066) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-12-17 12:27:22 UTC (rev 1067) @@ -611,6 +611,9 @@ public function getCompletionTime() { if (isset($this->_gemsData['gto_completion_time']) && $this->_gemsData['gto_completion_time']) { + if ($this->_gemsData['gto_completion_time'] instanceof MUtil_Date) { + return $this->_gemsData['gto_completion_time']; + } return new MUtil_Date($this->_gemsData['gto_completion_time'], Gems_Tracker::DB_DATETIME_FORMAT); } } @@ -651,7 +654,10 @@ public function getDateTime($fieldName) { if (isset($this->_gemsData[$fieldName])) { - + if ($this->_gemsData[$fieldName] instanceof MUtil_Date) { + return $this->_gemsData[$fieldName]; + } + if (Zend_Date::isDate($this->_gemsData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT)) { return new MUtil_Date($this->_gemsData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT); } @@ -1173,6 +1179,9 @@ public function getValidFrom() { if (isset($this->_gemsData['gto_valid_from']) && $this->_gemsData['gto_valid_from']) { + if ($this->_gemsData['gto_valid_from'] instanceof MUtil_Date) { + return $this->_gemsData['gto_valid_from']; + } return new MUtil_Date($this->_gemsData['gto_valid_from'], Gems_Tracker::DB_DATETIME_FORMAT); } } @@ -1184,6 +1193,9 @@ public function getValidUntil() { if (isset($this->_gemsData['gto_valid_until']) && $this->_gemsData['gto_valid_until']) { + if ($this->_gemsData['gto_valid_until'] instanceof MUtil_Date) { + return $this->_gemsData['gto_valid_until']; + } return new MUtil_Date($this->_gemsData['gto_valid_until'], Gems_Tracker::DB_DATETIME_FORMAT); } } Modified: trunk/library/classes/Gems/Util/Translated.php =================================================================== --- trunk/library/classes/Gems/Util/Translated.php 2012-12-17 10:01:04 UTC (rev 1066) +++ trunk/library/classes/Gems/Util/Translated.php 2012-12-17 12:27:22 UTC (rev 1067) @@ -131,7 +131,11 @@ // MUtil_Echo::track($dateTimeValue, date('c', $dateTime), $dateTime / 86400, date('c', time()), time() / 86400); // TODO: Timezone seems to screw this one up //$days = floor($dateTime / 86400) - floor(time() / 86400); // 86400 = 24*60*60 - $dateTime = new MUtil_Date($dateTimeValue, Zend_Date::ISO_8601); + if ($dateTimeValue instanceof MUtil_Date) { + $dateTime = clone $dateTimeValue; + } else { + $dateTime = new MUtil_Date($dateTimeValue, Zend_Date::ISO_8601); + } $days = $dateTime->diffDays(); switch ($days) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-16 11:20:45
|
Revision: 1104 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1104&view=rev Author: mennodekker Date: 2013-01-16 11:20:38 +0000 (Wed, 16 Jan 2013) Log Message: ----------- Removed mailer class and moved Gems specific mail handling to Gems_Mail Modified Paths: -------------- trunk/library/classes/Gems/Mail.php Removed Paths: ------------- trunk/library/classes/Gems/Email/Mailer.php Deleted: trunk/library/classes/Gems/Email/Mailer.php =================================================================== --- trunk/library/classes/Gems/Email/Mailer.php 2013-01-15 20:18:29 UTC (rev 1103) +++ trunk/library/classes/Gems/Email/Mailer.php 2013-01-16 11:20:38 UTC (rev 1104) @@ -1,322 +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. - * - * @version $Id: TemplateMailer.php 792 2012-06-27 11:59:17Z matijsdejong $ - * @package Gems - * @subpackage Email - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - */ - -/** - * Mailer utility class - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Email - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - */ -class Gems_Email_Mailer -{ - const MAIL_NO_ENCRYPT = 0; - const MAIL_SSL = 1; - const MAIL_TLS = 2; - - /** - * Should the mailer continue sending mails, even when it encounters errors? - * - * @var boolean - */ - public $continueOnError = false; - - /** - * - * @var Zend_Mail_Transport - */ - protected $defaultTransport = null; - - /** - * @var GemsEscort $escort - */ - protected $escort; - - /** - * Feedback messages for this action. - * - * @var array of string - */ - protected $messages = array(); - - private $_changeDate; - private $_mailSubject; - private $_mailDate; - - private $_subject = null; - private $_body = null; - private $_templateId = null; // Not used for lookup - - private $_verbose = false; - - /** - * Constructs a new Gems_Email_TemplateMailer - * @param GemsEscort $escort - */ - public function __construct(GemsEscort $escort) - { - $this->escort = $escort; - $this->_mailDate = MUtil_Date::format(new Zend_Date(), 'yyyy-MM-dd'); - } - - protected function addMessage($message) - { - $this->messages[] = $message; - return $this; - } - - /** - * Returns true if the "email.bounce" setting exists in the project - * configuration and is true - * @return boolean - */ - public function bounceCheck() - { - return $this->escort->project->getEmailBounce(); - } - - /** - * Returns Zend_Mail_Transport_Abstract when something else than the default mail protocol should be used. - * - * @staticvar array $mailServers - * @param email address $from - * @return Zend_Mail_Transport_Abstract or null - */ - public function checkTransport($from) - { - static $mailServers = array(); - - if (! array_key_exists($from, $mailServers)) { - $sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1'; - - // Always set cache, se we know when not to check for this row. - $serverData = $this->escort->db->fetchRow($sql, $from); - - // MUtil_Echo::track($serverData); - - if (isset($serverData['gms_server'])) { - $options = array(); - if (isset($serverData['gms_user'], $serverData['gms_password'])) { - $options['auth'] = 'login'; - $options['username'] = $serverData['gms_user']; - $options['password'] = $serverData['gms_password']; - } - if (isset($serverData['gms_port'])) { - $options['port'] = $serverData['gms_port']; - } - if (isset($serverData['gms_ssl'])) { - switch ($serverData['gms_ssl']) { - case self::MAIL_SSL: - $options['ssl'] = 'ssl'; - break; - - case self::MAIL_TLS: - $options['ssl'] = 'tls'; - break; - - default: - // intentional fall through - - } - } - - $mailServers[$from] = new Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); - } else { - $mailServers[$from] = $this->defaultTransport; - } - } - - return $mailServers[$from]; - } - - public function getMessages() - { - return $this->messages; - } - - /** - * Logs the communication if needed - * - * @param string $to Optional, if available the communication is logged. - * @param string $from Optional - * @param array $tokenData Optional, array containing grs_id_user, gor_id_organization, gto_id_token - */ - protected function logCommunication($to = null, $from = null, $tokenData = array() ) - { - if (null === $this->_changeDate) { - $this->_changeDate = new MUtil_Db_Expr_CurrentTimestamp(); - } - - $db = $this->escort->db; - $uid = $this->escort->getCurrentUserId(); - - if ($to) { - $cdata['grco_id_to'] = array_key_exists('grs_id_user', $tokenData) ? $tokenData['grs_id_user'] : 0 ; - $cdata['grco_id_by'] = $uid; - $cdata['grco_organization'] = array_key_exists('gor_id_organization', $tokenData) ? $tokenData['gor_id_organization'] : 0; - $cdata['grco_id_token'] = array_key_exists('gto_id_token', $tokenData) ? $tokenData['gto_id_token'] : null ; - - $cdata['grco_method'] = 'email'; - $cdata['grco_topic'] = substr($this->_mailSubject, 0, 120); - $cdata['grco_address'] = substr($to, 0, 120); - $cdata['grco_sender'] = substr($from, 0, 120); - - $cdata['grco_id_message'] = $this->_templateId ? $this->_templateId : null; - - $cdata['grco_changed'] = $this->_changeDate; - $cdata['grco_changed_by'] = $uid; - $cdata['grco_created'] = $this->_changeDate; - $cdata['grco_created_by'] = $uid; - - $db->insert('gems__log_respondent_communications', $cdata); - } - } - - /** - * Sends a single e-mail - * @param string $to - * @param string $to_name - * @param string $from - * @param string $from_name - * @param array $tokenData - * @return boolean|string String = error message from protocol. - */ - public function sendMail($to, $to_name, $from, $from_name, array $tokenData) - { - if (empty($from) || empty($to)) { - return "Need a sender and a recipient to continue"; - } - - if ($this->_verbose) { - MUtil_Echo::r($to, $to_name); - MUtil_Echo::r($from, $from_name); - } - - - // If bounce is active, the Gems_Mail will take care of resetting the to field - if (!$this->bounceCheck()) { - $validate = new Zend_Validate_EmailAddress(); - - if (!$validate->isValid($to)) { - return sprintf($this->escort->_("Invalid e-mail address '%s'."), $to); - } - } - - $mail = new Gems_Mail(); - - $mail->setFrom($from, $from_name); - $mail->addTo($to, $to_name); - if (isset($this->escort->project->email['bcc'])) { - $mail->addBcc($this->escort->project->email['bcc']); - } - - $subject = $this->_subject; - $body = $this->_body; - - $mail->setSubject($subject); - $mail->setBodyBBCode($body); - - $this->_mailSubject = $subject; - - try { - $mail->send($this->checkTransport($from)); - $result = false; - - // communication successful, now log it - $this->logCommunication($to, $from, $tokenData); - - } catch (Exception $e) { - $result = $e->getMessage(); - - // Log to error file - $this->escort->logger->logError($e, $this->escort->request); - } - - return $result; - } - - /** - * 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 the subject of the mail - * @param string $subject - * @return Gems_Email_TemplateMailer (continuation pattern) - */ - public function setSubject($subject) - { - $this->_subject = $subject; - } - - public function setTemplateId($templatedId) - { - $this->_templateId = $templatedId; - return $this; - } - - /** - * Sets verbose (noisy) operation - * - * @param boolean $verbose - * @return Gems_Email_TemplateMailer (continuation pattern) - */ - public function setVerbose($verbose) - { - $this->_verbose = $verbose; - return $this; - } -} \ No newline at end of file Modified: trunk/library/classes/Gems/Mail.php =================================================================== --- trunk/library/classes/Gems/Mail.php 2013-01-15 20:18:29 UTC (rev 1103) +++ trunk/library/classes/Gems/Mail.php 2013-01-16 11:20:38 UTC (rev 1104) @@ -46,17 +46,36 @@ */ class Gems_Mail extends MUtil_Mail { + const MAIL_NO_ENCRYPT = 0; + const MAIL_SSL = 1; + const MAIL_TLS = 2; + /** + * @var GemsEscort + */ + public $escort = null; + + protected static $mailServers = array(); + + public function __construct($charset = null) { + parent::__construct($charset); + $this->escort = GemsEscort::getInstance(); + } + + /** * Adds To-header and recipient, $email can be an array, or a single string address * * @param string|array $email * @param string $name - * @param boolean $bounce When true the e-mail is bounced to the from address + * @param boolean $bounce When true the e-mail is bounced to the from address, when omitted bounce is read from project settings * @return Zend_Mail Provides fluent interface */ - public function addTo($email, $name = '', $bounce = false) + public function addTo($email, $name = '', $bounce = null) { - if ($bounce) { + if (is_null($bounce)) { + $bounce = $this->bounceCheck(); + } + if ($bounce === true) { $name = str_replace('@', ' at ', $email); $email = $this->getFrom(); @@ -67,7 +86,69 @@ return parent::addTo($email, $name); } + + /** + * Returns true if the "email.bounce" setting exists in the project + * configuration and is true + * @return boolean + */ + public function bounceCheck() + { + return $this->escort->project->getEmailBounce(); + } + + /** + * Returns Zend_Mail_Transport_Abstract when something else than the default mail protocol should be used. + * + * @staticvar array $mailServers + * @param email address $from + * @return Zend_Mail_Transport_Abstract or null + */ + public function checkTransport($from) + { + if (! array_key_exists($from, self::$mailServers)) { + $sql = 'SELECT * FROM gems__mail_servers WHERE ? LIKE gms_from ORDER BY LENGTH(gms_from) DESC LIMIT 1'; + // Always set cache, se we know when not to check for this row. + $serverData = $this->escort->db->fetchRow($sql, $from); + + // MUtil_Echo::track($serverData); + + if (isset($serverData['gms_server'])) { + $options = array(); + if (isset($serverData['gms_user'], $serverData['gms_password'])) { + $options['auth'] = 'login'; + $options['username'] = $serverData['gms_user']; + $options['password'] = $serverData['gms_password']; + } + if (isset($serverData['gms_port'])) { + $options['port'] = $serverData['gms_port']; + } + if (isset($serverData['gms_ssl'])) { + switch ($serverData['gms_ssl']) { + case self::MAIL_SSL: + $options['ssl'] = 'ssl'; + break; + + case self::MAIL_TLS: + $options['ssl'] = 'tls'; + break; + + default: + // intentional fall through + + } + } + + self::$mailServers[$from] = new Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); + } else { + self::$mailServers[$from] = $this->getDefaultTransport(); + } + } + + return self::$mailServers[$from]; + } + /** * Returns the the current template * @@ -97,4 +178,13 @@ return $this; } + + public function send($transport = null) { + // Before we forward to the Zend_Mail send method, first perfom a bounce check + if (is_null($transport)) { + $transport = $this->checkTransport($this->getFrom()); + } + + parent::send($transport); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-17 17:34:20
|
Revision: 1110 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1110&view=rev Author: matijsdejong Date: 2013-01-17 17:34:11 +0000 (Thu, 17 Jan 2013) Log Message: ----------- ComplianceAction.php now looks nice and exports to excel Simple _addPeriodSelectors function, will add to TokenPlanAction and RespondentPlanAction Modified Paths: -------------- trunk/library/classes/Gems/Default/ComplianceAction.php trunk/library/classes/Gems/Default/SummaryAction.php trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceSearchFormSnippet.php trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php trunk/library/classes/Gems/Snippets/Tracker/Summary/SummarySearchFormSnippet.php trunk/library/classes/Gems/Snippets/Tracker/Summary/SummaryTableSnippet.php Modified: trunk/library/classes/Gems/Default/ComplianceAction.php =================================================================== --- trunk/library/classes/Gems/Default/ComplianceAction.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Default/ComplianceAction.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -79,12 +79,88 @@ 'gr2t_id_organization' => 'gr2o_id_organization' )); $model->addTable('gems__tracks', array('gr2t_id_track' => 'gtr_id_track')); + $model->addTable('gems__reception_codes', array('gr2t_reception_code' => 'grc_id_reception_code')); + $model->addFilter(array('grc_success' => 1)); $model->resetOrder(); $model->set('gr2o_patient_nr', 'label', $this->_('Respondent nr')); $model->set('gr2t_start_date', 'label', $this->_('Start date'), 'dateFormat', 'dd-MM-yyyy'); $model->set('gr2t_end_date', 'label', $this->_('End date'), 'dateFormat', 'dd-MM-yyyy'); + $filter = $this->util->getRequestCache('index')->getProgramParams(); + MUtil_Echo::track($filter); + if (! (isset($filter['gr2t_id_track']) && $filter['gr2t_id_track'])) { + $model->setFilter(array('1=0')); + $this->autofilterParameters['onEmpty'] = $this->_('No track selected...'); + return $model; + } + + // Add the period filter - if any + if ($where = Gems_Snippets_AutosearchFormSnippet::getPeriodFilter($filter, $this->db)) { + $model->addFilter(array($where)); + } + + $select = $this->db->select(); + $select->from('gems__rounds', array('gro_id_round', 'gro_id_order', 'gro_round_description')) + ->joinInner('gems__surveys', 'gro_id_survey = gsu_id_survey', array('gsu_survey_name')) + ->where('gro_id_track = ?', $filter['gr2t_id_track']) + ->order('gro_id_order'); + + if (isset($filter['gsu_id_primary_group']) && $filter['gsu_id_primary_group']) { + $select->where('gsu_id_primary_group = ?', $filter['gsu_id_primary_group']); + } + + $data = $this->db->fetchAll($select); + + if (! $data) { + return $model; + } + + $status = new Zend_Db_Expr(" + CASE + WHEN gto_completion_time IS NOT NULL THEN 'A' + WHEN gto_valid_from IS NULL THEN 'U' + WHEN gto_valid_from > CURRENT_TIMESTAMP THEN 'W' + WHEN gto_valid_until < CURRENT_TIMESTAMP THEN 'M' + ELSE 'O' + END + "); + + $select = $this->db->select(); + $select->from('gems__tokens', array('gto_id_respondent_track', 'gto_id_round', 'status' => $status)) + ->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array()) + ->where('grc_success = 1') + ->where('gto_id_track = ?', $filter['gr2t_id_track']) + ->order('gto_id_respondent_track') + ->order('gto_round_order'); + + // MUtil_Echo::track($this->db->fetchAll($select)); + $newModel = new MUtil_Model_SelectModel($select, 'tok'); + $newModel->setKeys(array('gto_id_respondent_track')); + + $transformer = new MUtil_Model_Transform_CrossTabTransformer(); + $transformer->setCrosstabFields('gto_id_round', 'status'); + + foreach ($data as $row) { + $name = 'col_' . $row['gro_id_round']; + $transformer->set($name, 'label', MUtil_Lazy::call('substr', $row['gsu_survey_name'], 0, 2), + 'description', sprintf("%s\n[%s]", $row['gsu_survey_name'], $row['gro_round_description']), + 'noSort', true, + 'round', $row['gro_round_description'] + ); + } + + $newModel->addTransformer($transformer); + // MUtil_Echo::track($data); + + $joinTrans = new MUtil_Model_Transform_JoinTransformer(); + $joinTrans->addModel($newModel, array('gr2t_id_respondent_track' => 'gto_id_respondent_track')); + + $model->resetOrder(); + $model->set('gr2o_patient_nr'); + $model->set('gr2t_start_date'); + $model->addTransformer($joinTrans); + return $model; } Modified: trunk/library/classes/Gems/Default/SummaryAction.php =================================================================== --- trunk/library/classes/Gems/Default/SummaryAction.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Default/SummaryAction.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -153,7 +153,6 @@ ->joinInner('gems__surveys', 'gro_id_survey = gsu_id_survey', array('gsu_survey_name', 'gsu_id_primary_group')) ->group(array('gro_id_order', 'gro_round_description', 'gsu_survey_name', 'gsu_id_primary_group')); - // ->order('gto_round_order'); // MUtil_Model::$verbose = true; $model = new MUtil_Model_SelectModel($select, 'summary'); @@ -181,7 +180,14 @@ $model->set('gsu_id_primary_group', 'label', $this->_('Filler'), 'multiOptions', $this->util->getDbLookup()->getGroups()); - if (!$this->getTrackId()) { + $data = $this->util->getRequestCache('index')->getProgramParams(); + if (isset($data['gto_id_track'])) { + // Add the period filter + if ($where = Gems_Snippets_AutosearchFormSnippet::getPeriodFilter($data, $this->db)) { + $select->joinInner('gems__respondent2track', 'gto_id_respondent_track = gr2t_id_respondent_track', array()); + $model->addFilter(array($where)); + } + } else { $model->setFilter(array('1=0')); $this->autofilterParameters['onEmpty'] = $this->_('No track selected...'); } @@ -209,16 +215,4 @@ { return $this->plural('token', 'tokens', $count); } - - /** - * - * @return int Return the track id if any or null - */ - public function getTrackId() - { - $data = $this->util->getRequestCache('index')->getProgramParams(); - if (isset($data['gto_id_track'])) { - return $data['gto_id_track']; - } - } } Modified: trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -89,18 +89,71 @@ */ protected $searchButtonId = 'AUTO_SEARCH_TEXT_BUTTON'; + /** + * Generate two date selectors and - depending on the number of $dates passed - + * either a hidden element containing the field name or an radio button or + * dropdown selector for the type of date to use. + * + * @param array $elements Search element array to which the element are added. + * @param mixed $dates A string fieldName to use or an array of fieldName => Label + * @param string $defaultDate Optional element, otherwise first is used. + * @param int $switchToSelect The number of dates where this function should switch to select display + */ + protected function _addPeriodSelectors(array &$elements, $dates, $defaultDate = null, $switchToSelect = 4) + { + if (is_array($dates) && (1 === count($dates))) { + reset($dates); + $dates = key($dates); + } + if (is_string($dates)) { + $element = new Zend_Form_Element_Hidden('dateused'); + $element->setValue($dates); + $fromLabel = $this->_('From'); + } else { + if (count($dates) >= $switchToSelect) { + $element = $this->_createSelectElement('dateused', $dates); + $element->setLabel($this->_('For date')); + + $fromLabel = ''; + } else { + $element = $this->_createRadioElement('dateused', $dates); + $element->setSeparator(' '); + + $fromLabel = html_entity_decode(' » ', ENT_QUOTES, 'UTF-8'); + } + $fromLabel .= $this->_('from'); + + if ((null === $defaultDate) || (! isset($dates[$defaultDate]))) { + // Set value to first key + reset($dates); + $defaultDate = key($dates); + } + $element->setValue($defaultDate); + } + $elements[] = $element; + + $options = array(); + $options['label'] = $fromLabel; + MUtil_Model_FormBridge::applyFixedOptions('date', $options); + $elements[] = new Gems_JQuery_Form_Element_DatePicker('datefrom', $options); + + $options['label'] = ' ' . $this->_('until'); + $elements[] = new Gems_JQuery_Form_Element_DatePicker('dateuntil', $options); + } + /** * Creates a Zend_Form_Element_Select * * If $options is a string it is assumed to contain an SQL statement. * + * @param string $class Name of the class to use * @param string $name Name of the select element * @param string|array $options Can be a SQL select string or key/value array of options * @param string $empty Text to display for the empty selector - * @return Zend_Form_Element_Select + * @return Zend_Form_Element_Multi */ - protected function _createSelectElement($name, $options, $empty = null) + private function _createMultiElement($class, $name, $options, $empty) { if ($options instanceof MUtil_Model_ModelAbstract) { $options = $options->get($name, 'multiOptions'); @@ -113,13 +166,43 @@ if (null !== $empty) { $options = array('' => $empty) + $options; } - $element = new Zend_Form_Element_Select($name, array('multiOptions' => $options)); + $element = new $class($name, array('multiOptions' => $options)); return $element; } } /** + * Creates a Zend_Form_Element_Select + * + * If $options is a string it is assumed to contain an SQL statement. + * + * @param string $name Name of the select element + * @param string|array $options Can be a SQL select string or key/value array of options + * @param string $empty Text to display for the empty selector + * @return Zend_Form_Element_Radio + */ + protected function _createRadioElement($name, $options, $empty = null) + { + return $this->_createMultiElement('Zend_Form_Element_Radio', $name, $options, $empty); + } + + /** + * Creates a Zend_Form_Element_Select + * + * If $options is a string it is assumed to contain an SQL statement. + * + * @param string $name Name of the select element + * @param string|array $options Can be a SQL select string or key/value array of options + * @param string $empty Text to display for the empty selector + * @return Zend_Form_Element_Select + */ + protected function _createSelectElement($name, $options, $empty = null) + { + return $this->_createMultiElement('Zend_Form_Element_Select', $name, $options, $empty); + } + + /** * Called after the check that all required registry values * have been set correctly has run. * @@ -255,7 +338,48 @@ } /** + * Helper function to generate a period query string * + * @param array $data A filter array or $request->getParams() + * @param Zend_Db_Adapter_Abstract $db + * @return string + */ + public static function getPeriodFilter(array $data, Zend_Db_Adapter_Abstract $db) + { + if (isset($data['dateused'])) { + $options = array(); + MUtil_Model_FormBridge::applyFixedOptions('date', $options); + + $outFormat = 'yyyy-MM-dd'; + $inFormat = isset($options['dateFormat']) ? $options['dateFormat'] : null; + + if (isset($data['datefrom']) && $data['datefrom']) { + if (isset($data['dateuntil']) && $data['dateuntil']) { + return sprintf( + '%s BETWEEN %s AND %s', + $db->quoteIdentifier($data['dateused']), + $db->quote(MUtil_Date::format($data['datefrom'], $outFormat, $inFormat)), + $db->quote(MUtil_Date::format($data['dateuntil'], $outFormat, $inFormat)) + ); + } + return sprintf( + '%s >= %s', + $db->quoteIdentifier($data['dateused']), + $db->quote(MUtil_Date::format($data['datefrom'], $outFormat, $inFormat)) + ); + } + if (isset($data['dateuntil']) && $data['dateuntil']) { + return sprintf( + '%s <= %s', + $db->quoteIdentifier($data['dateused']), + $db->quote(MUtil_Date::format($data['dateuntil'], $outFormat, $inFormat)) + ); + } + } + } + + /** + * * @return array The data to fill the form with */ protected function getSearchData() Modified: trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceSearchFormSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceSearchFormSnippet.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceSearchFormSnippet.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -65,6 +65,28 @@ $this->util->getDbLookup()->getOrganizationsWithRespondents(), $this->_('(all organizations)')); + $elements[] = null; + + $dates = array( + 'gr2t_start_date' => $this->_('Track start'), + 'gr2t_end_date' => $this->_('Track end'), + ); + // $dates = 'gto_valid_from'; + $this->_addPeriodSelectors($elements, $dates, 'gto_valid_from'); + + $elements[] = null; + + $sql = "SELECT DISTINCT ggp_id_group, ggp_name + FROM gems__groups INNER JOIN gems__surveys ON ggp_id_group = gsu_id_primary_group + INNER JOIN gems__rounds ON gsu_id_survey = gro_id_survey + INNER JOIN gems__tracks ON gro_id_track = gtr_id_track + WHERE ggp_group_active = 1 AND + gro_active=1 AND + gtr_active=1 AND + gtr_track_type='T' + ORDER BY ggp_name"; + $elements[] = $this->_createSelectElement('gsu_id_primary_group', $sql, $this->_('(all fillers)')); + return $elements; } Modified: trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -47,126 +47,126 @@ class Gems_Snippets_Tracker_Compliance_ComplianceTableSnippet extends Gems_Snippets_ModelTableSnippetGeneric { /** + * Adds columns from the model to the bridge that creates the browse table. * - * @var Zend_Db_Adapter_Abstract - */ - protected $db; - - /** + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. * - * @var Gems_Loader + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void */ - protected $loader; - - /** - * Creates the model - * - * @return MUtil_Model_ModelAbstract - */ - protected function createModel() + protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) { - $model = parent::createModel(); - $trackId = $this->getTrackId(); + $table = $bridge->getTable(); + $table->appendAttrib('class', 'compliance'); - if (! $trackId) { - return $model; - } + $thead = $table->thead(); + $th_row = $thead->tr(array('class' => 'rounds')); + $th = $th_row->td(); + $span = 1; + $cRound = null; + $thead->tr(); - $select = $this->db->select(); - $select->from('gems__rounds', array('gro_id_round', 'gro_id_order', 'gro_round_description')) - ->where('gro_id_track = ?', $trackId) - ->order('gro_id_order'); - - $data = $this->db->fetchAll($select); - - if (! $data) { - return $model; + if ($showMenuItem = $this->getShowMenuItem()) { + $bridge->addItemLink($showMenuItem->toActionLinkLower($this->request, $bridge)); } - $status = new Zend_Db_Expr(" - CASE - WHEN gto_completion_time IS NOT NULL THEN 'A' - WHEN gto_valid_from IS NULL THEN 'U' - WHEN gto_valid_from > CURRENT_TIMESTAMP THEN 'W' - WHEN gto_valid_until < CURRENT_TIMESTAMP THEN 'M' - ELSE 'O' - END - "); + foreach($model->getItemsOrdered() as $name) { + if ($label = $model->get($name, 'label')) { + $round = $model->get($name, 'round'); + if ($round == $cRound) { + $span++; + $class = null; + } else { + $th->append($cRound); + $th->colspan = $span; - $select = $this->db->select(); - $select->from('gems__tokens', array('gto_id_respondent_track', 'gto_id_round', 'status' => $status)) - ->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array()) - ->where('grc_success = 1') - ->where('gto_id_track = ?', $trackId) - ->order('gto_id_respondent_track') - ->order('gto_round_order'); + $span = 1; + $cRound = $round; + $class = 'newRound'; + $th = $th_row->td(array('class' => $class)); + } - // MUtil_Echo::track($this->db->fetchAll($select)); - - $newModel = new MUtil_Model_SelectModel($select, 'tok'); - $newModel->setKeys(array('gto_id_respondent_track')); - - $transformer = new MUtil_Model_Transform_CrossTabTransformer(); - $transformer->setCrosstabFields('gto_id_round', 'status'); - - foreach ($data as $row) { - $name = 'col_' . $row['gro_id_round']; - $transformer->set($name, 'label', $row['gro_id_order'], 'description', $row['gro_round_description']); + if ($model->get($name, 'noSort')) { + $tds = $bridge->addColumn( + array( + $bridge->$name, + 'class' => array('round', MUtil_Lazy::method($this, 'getClassFor', $bridge->$name)), + 'title' => array( + MUtil_Lazy::method($this, 'getDescriptionFor', $bridge->$name), + "\n" . $model->get($name, 'description') + ), + ), + array($label, 'title' => $model->get($name, 'description'), 'class' => 'round') + ); + } else { + $tds = $bridge->addSortable($name, $label); + } + if ($class) { + $tds->appendAttrib('class', $class); + } + } } - - $newModel->addTransformer($transformer); - // MUtil_Echo::track($data); - - $joinTrans = new MUtil_Model_Transform_JoinTransformer(); - $joinTrans->addModel($newModel, array('gr2t_id_respondent_track' => 'gto_id_respondent_track')); - - $model->resetOrder(); - $model->set('gr2o_patient_nr'); - $model->set('gr2t_start_date'); - $model->addTransformer($joinTrans); - return $model; + $th->append($cRound); + $th->colspan = $span; } /** - * Returns a show menu item, if access is allowed by privileges + * Returns the class to display the answer * - * @return Gems_Menu_SubMenuItem + * @param string $value Character + * @return string */ - protected function getShowMenuItem() + public function getClassFor($value) { - return $this->findMenuItem('track', 'show-track'); + switch ($value) { + case 'A': + return 'answered'; + case 'M': + return 'missed'; + case 'O': + return 'open'; + case 'U': + return 'unknown'; + case 'W': + return 'waiting'; + default: + return 'empty'; + } } /** + * Returns the decription to add to the answer * - * @return int Return the track id if any or null + * @param string $value Character + * @return string */ - public function getTrackId() + public function getDescriptionFor($value) { - if ($this->requestCache) { - $data = $this->requestCache->getProgramParams(); - if (isset($data['gr2t_id_track'])) { - return $data['gr2t_id_track']; - } - } else { - return $this->request->getParam('gr2t_id_track'); + switch ($value) { + case 'A': + return $this->_('Answered'); + case 'M': + return $this->_('Missed deadline'); + case 'O': + return $this->_('Open - can be answered now'); + case 'U': + return $this->_('Valid from date unknown'); + case 'W': + return $this->_('Valid from date in the future'); + default: + return $this->_('Token does not exist'); } } /** - * Overrule to implement snippet specific filtering and sorting. + * Returns a show menu item, if access is allowed by privileges * - * @param MUtil_Model_ModelAbstract $model + * @return Gems_Menu_SubMenuItem */ - protected function processFilterAndSort(MUtil_Model_ModelAbstract $model) + protected function getShowMenuItem() { - $trackId = $this->getTrackId(); - - if ($trackId) { - parent::processFilterAndSort($model); - } else { - $model->setFilter(array('1=0')); - $this->onEmpty = $this->_('No track selected...'); - } + return $this->findMenuItem('track', 'show-track'); } } Modified: trunk/library/classes/Gems/Snippets/Tracker/Summary/SummarySearchFormSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Summary/SummarySearchFormSnippet.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Snippets/Tracker/Summary/SummarySearchFormSnippet.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -66,7 +66,18 @@ $this->_('(all organizations)')); $elements[] = null; - + + $dates = array( + 'gr2t_start_date' => $this->_('Track start'), + 'gr2t_end_date' => $this->_('Track end'), + 'gto_valid_from' => $this->_('Valid from'), + 'gto_valid_until' => $this->_('Valid until'), + ); + // $dates = 'gto_valid_from'; + $this->_addPeriodSelectors($elements, $dates, 'gto_valid_from'); + + $elements[] = null; + $sql = "SELECT DISTINCT ggp_id_group, ggp_name FROM gems__groups INNER JOIN gems__surveys ON ggp_id_group = gsu_id_primary_group INNER JOIN gems__rounds ON gsu_id_survey = gro_id_survey @@ -80,5 +91,4 @@ return $elements; } - } Modified: trunk/library/classes/Gems/Snippets/Tracker/Summary/SummaryTableSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Summary/SummaryTableSnippet.php 2013-01-17 14:21:18 UTC (rev 1109) +++ trunk/library/classes/Gems/Snippets/Tracker/Summary/SummaryTableSnippet.php 2013-01-17 17:34:11 UTC (rev 1110) @@ -122,6 +122,10 @@ */ public function showPercentage($part, $total) { - return sprintf($this->_('%d%%'), round($part / $total * 100, 0)); + if ($total) { + return sprintf($this->_('%d%%'), round($part / $total * 100, 0)); + } else { + return $this->_('-'); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-21 14:29:36
|
Revision: 1117 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1117&view=rev Author: matijsdejong Date: 2013-01-21 14:29:29 +0000 (Mon, 21 Jan 2013) Log Message: ----------- Making sure the whole compliance token cell is clickable Modified Paths: -------------- trunk/library/classes/Gems/Default/ComplianceAction.php trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php Modified: trunk/library/classes/Gems/Default/ComplianceAction.php =================================================================== --- trunk/library/classes/Gems/Default/ComplianceAction.php 2013-01-21 13:55:56 UTC (rev 1116) +++ trunk/library/classes/Gems/Default/ComplianceAction.php 2013-01-21 14:29:29 UTC (rev 1117) @@ -136,8 +136,7 @@ $select = $this->db->select(); $select->from('gems__tokens', array( 'gto_id_respondent_track', 'gto_id_round', 'gto_id_token', 'status' => $status, - )) - ->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array()) + ))->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array()) // ->where('grc_success = 1') ->where('gto_id_track = ?', $filter['gr2t_id_track']) ->order('grc_success') Modified: trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php 2013-01-21 13:55:56 UTC (rev 1116) +++ trunk/library/classes/Gems/Snippets/Tracker/Compliance/ComplianceTableSnippet.php 2013-01-21 14:29:29 UTC (rev 1117) @@ -102,23 +102,33 @@ ); $token = 'tok_' . substr($name, 5); + $href = new MUtil_Html_HrefArrayAttribute(array( + $this->request->getControllerKey() => 'track', // This code is only used for tracks :) + $this->request->getActionKey() => 'show', + MUtil_Model::REQUEST_ID => $bridge->$token, + )); + $href->setRouteReset(); + + $onclick = new MUtil_Html_OnClickArrayAttribute(); + $onclick->addUrl($href) + ->addCancelBubble(); + $tds = $bridge->addColumn( array( MUtil_Html_AElement::iflink( $bridge->$token, array( - 'href' => array( - 'controller' => 'track', // This code is only used for tracks :) - 'action' => 'show', - MUtil_Model::REQUEST_ID => $bridge->$token, - ), + $href, 'onclick' => 'event.cancelBubble = true;', 'title' => $title, $bridge->$name, ), - $bridge->$name), - 'class' => array('round', MUtil_Lazy::method($tUtil, 'getStatusClass', $bridge->$name)), - 'title' => $title, + $bridge->$name + ), + 'class' => array('round', MUtil_Lazy::method($tUtil, 'getStatusClass', $bridge->$name)), + 'title' => $title, + // onclick is needed because the link does not fill the whole cell + 'onclick' => MUtil_Lazy::iff($bridge->$token, $onclick), ), array($label, 'title' => $model->get($name, 'description'), 'class' => 'round') ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-02-27 18:20:30
|
Revision: 1158 http://sourceforge.net/p/gemstracker/code/1158 Author: matijsdejong Date: 2013-02-27 18:20:27 +0000 (Wed, 27 Feb 2013) Log Message: ----------- A better sort for these display types (apparently) Modified Paths: -------------- trunk/library/classes/Gems/Event/Survey/Display/AllSingleTrack.php trunk/library/classes/Gems/Snippets/Tracker/Answers/SurveyAnswersModelSnippet.php Modified: trunk/library/classes/Gems/Event/Survey/Display/AllSingleTrack.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/Display/AllSingleTrack.php 2013-02-27 12:26:06 UTC (rev 1157) +++ trunk/library/classes/Gems/Event/Survey/Display/AllSingleTrack.php 2013-02-27 18:20:27 UTC (rev 1158) @@ -47,7 +47,20 @@ class Gems_Event_Survey_Display_AllSingleTrack extends Gems_Registry_TargetAbstract implements Gems_Event_SurveyDisplayEventInterface { /** + * Set a fixed model sort. * + * Leading _ means not overwritten by sources. + * + * @var array + */ + protected $_fixedSort = array( + 'grc_success' => SORT_DESC, + 'gto_valid_from' => SORT_ASC, + 'gto_completion_time' => SORT_ASC, + 'gto_round_order' => SORT_ASC); + + /** + * * @var Zend_Translate */ protected $translate; Modified: trunk/library/classes/Gems/Snippets/Tracker/Answers/SurveyAnswersModelSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Tracker/Answers/SurveyAnswersModelSnippet.php 2013-02-27 12:26:06 UTC (rev 1157) +++ trunk/library/classes/Gems/Snippets/Tracker/Answers/SurveyAnswersModelSnippet.php 2013-02-27 18:20:27 UTC (rev 1158) @@ -47,6 +47,19 @@ class Gems_Snippets_Tracker_Answers_SurveyAnswersModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric { /** + * Set a fixed model sort. + * + * Leading _ means not overwritten by sources. + * + * @var array + */ + protected $_fixedSort = array( + 'grc_success' => SORT_DESC, + 'gto_valid_from' => SORT_ASC, + 'gto_completion_time' => SORT_ASC, + 'gto_round_order' => SORT_ASC); + + /** * Use compact view and show all tokens of the same surveyId in * one view. Property used by respondent export * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-02-28 10:29:55
|
Revision: 1161 http://sourceforge.net/p/gemstracker/code/1161 Author: mennodekker Date: 2013-02-28 10:29:51 +0000 (Thu, 28 Feb 2013) Log Message: ----------- Preparing for release 1.6 instead of 1.5.8 Modified Paths: -------------- trunk/library/classes/Gems/Upgrades.php trunk/library/classes/Gems/Versions.php Modified: trunk/library/classes/Gems/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2013-02-28 10:22:25 UTC (rev 1160) +++ trunk/library/classes/Gems/Upgrades.php 2013-02-28 10:29:51 UTC (rev 1161) @@ -64,6 +64,7 @@ $this->register(array($this, 'Upgrade154to155'), 'Upgrade from 1.5.4 to 1.5.5'); $this->register(array($this, 'Upgrade155to156'), 'Upgrade from 1.5.5 to 1.5.6'); $this->register(array($this, 'Upgrade156to157'), 'Upgrade from 1.5.6 to 1.5.7'); + $this->register(array($this, 'Upgrade157to16'), 'Upgrade from 1.5.7 to 1.6'); /** * To have the new_project updated to the highest level, update @@ -174,4 +175,16 @@ return true; } + + /** + * To upgrade to 1.6 just execute patchlevel 51 + */ + public function Upgrade157to16() + { + $this->_batch->addTask('Db_ExecutePatch', 51); + + $this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions')); + + return true; + } } \ No newline at end of file Modified: trunk/library/classes/Gems/Versions.php =================================================================== --- trunk/library/classes/Gems/Versions.php 2013-02-28 10:22:25 UTC (rev 1160) +++ trunk/library/classes/Gems/Versions.php 2013-02-28 10:29:51 UTC (rev 1161) @@ -69,7 +69,7 @@ */ public final function getGemsVersion() { - return '1.5.8'; + return '1.6'; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-03-14 11:27:23
|
Revision: 1182 http://sourceforge.net/p/gemstracker/code/1182 Author: mennodekker Date: 2013-03-14 11:27:20 +0000 (Thu, 14 Mar 2013) Log Message: ----------- Added a field to track-maintenance -> show to display what group should answer the survey Modified Paths: -------------- trunk/library/classes/Gems/Default/TrackMaintenanceAction.php trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php trunk/library/classes/Gems/Tracker/Engine/TrackEngineInterface.php Modified: trunk/library/classes/Gems/Default/TrackMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2013-03-14 11:05:26 UTC (rev 1181) +++ trunk/library/classes/Gems/Default/TrackMaintenanceAction.php 2013-03-14 11:27:20 UTC (rev 1182) @@ -309,6 +309,8 @@ $trackId = $this->_getIdParam(); $engine = $tracker->getTrackEngine($trackId); $model = $engine->getRoundModel(false, $action); + $model->addLeftTable('gems__surveys', array('gro_id_survey' => 'gsu_id_survey')); + $model->set('gsu_id_primary_group', 'label', $this->_('Group'), 'multiOptions', $this->util->getDbLookup()->getGroups()); } break; case "fields": { Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2013-03-14 11:05:26 UTC (rev 1181) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2013-03-14 11:27:20 UTC (rev 1182) @@ -425,12 +425,11 @@ /** * Create model for rounds. Allowes overriding by sub classes. * - * @return MUtil_Model_ModelAbstract + * @return Gems_Model_JoinModel */ protected function createRoundModel() { - $model = new MUtil_Model_TableModel('gems__rounds'); - Gems_Model::setChangeFieldsByPrefix($model, 'gro'); + $model = new Gems_Model_JoinModel('rounds', 'gems__rounds', 'gro'); return $model; } Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineInterface.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineInterface.php 2013-03-14 11:05:26 UTC (rev 1181) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineInterface.php 2013-03-14 11:27:20 UTC (rev 1182) @@ -215,7 +215,7 @@ * * @param boolean $detailed Create a model for the display of detailed item data or just a browse table * @param string $action The current action - * @return MUtil_Model_ModelAbstract + * @return Gems_Model_JoinModel */ public function getRoundModel($detailed, $action); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-03-18 12:58:16
|
Revision: 1189 http://sourceforge.net/p/gemstracker/code/1189 Author: mennodekker Date: 2013-03-18 12:58:11 +0000 (Mon, 18 Mar 2013) Log Message: ----------- Old style tabforms (BrowseEditAction) had duplicate button row Modified Paths: -------------- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php trunk/library/classes/Gems/TabForm.php Modified: trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2013-03-18 12:24:26 UTC (rev 1188) +++ trunk/library/classes/Gems/Snippets/ModelFormSnippetAbstract.php 2013-03-18 12:58:11 UTC (rev 1189) @@ -200,7 +200,6 @@ ->removeDecorator('HtmlTag') ->removeDecorator('Label') ->removeDecorator('DtDdWrapper'); -; $this->_form->resetContext(); $this->_form->addElement($element); Modified: trunk/library/classes/Gems/TabForm.php =================================================================== --- trunk/library/classes/Gems/TabForm.php 2013-03-18 12:24:26 UTC (rev 1188) +++ trunk/library/classes/Gems/TabForm.php 2013-03-18 12:58:11 UTC (rev 1189) @@ -111,8 +111,8 @@ $element = $this->getElement($name); } - $this->addToOtherGroup($element); - + //$this->addToOtherGroup($element); // Causes duplicate links on old browse edit + if ($element instanceof Zend_Form_Element_Hidden) { //Remove decorators $element->removeDecorator('HtmlTag'); @@ -122,6 +122,11 @@ } elseif ($element instanceof Zend_Form_Element) { $element->removeDecorator('DtDdWrapper'); + + if ($element instanceof MUtil_Form_Element_Html) { + $element->removeDecorator('HtmlTag'); + $element->removeDecorator('Label'); + } $error = $element->getDecorator('Errors'); if ($error instanceof Zend_Form_Decorator_Errors) { @@ -274,7 +279,7 @@ )); } } - + /** * Reset the currentTab to be the main form again * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |