From: <gem...@li...> - 2011-09-15 16:00:21
|
Revision: 26 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=26&view=rev Author: matijsdejong Date: 2011-09-15 16:00:09 +0000 (Thu, 15 Sep 2011) Log Message: ----------- - moved privilege based views to Roles instead of project for #5 Reorganize menu - added default templates to mail tempplates Modified Paths: -------------- trunk/library/classes/Gems/Default/ProjectInformationAction.php trunk/library/classes/Gems/Default/RoleAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Menu.php trunk/library/configs/db/tables/gems__mail_templates.200.sql Modified: trunk/library/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-09-15 15:08:23 UTC (rev 25) +++ trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-09-15 16:00:09 UTC (rev 26) @@ -1,47 +1,47 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package Gems + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems * @subpackage Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: StaffAction.php 460 2011-08-31 16:17:26Z mjong $ */ /** - * - * @author Matijs de Jong - * @package Gems + * + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class Gems_Default_ProjectInformationAction extends Gems_Controller_Action { @@ -54,12 +54,6 @@ $this->html[] = $table; } - public function aclAction() - { - $this->html->h2($this->_('Access Control Lists')); - $this->_showTable($this->_('ACL\'s'), $this->acl->getRoles()); - } - public function changelogAction() { $this->html->h2($this->_('Changelog')); @@ -107,7 +101,7 @@ $this->html->h2($this->_('Project information')); $versions = $this->loader->getVersions(); - + $data[$this->_('Project name')] = $this->project->name; $data[$this->_('Project version')] = $versions->getProjectVersion(); $data[$this->_('Gems version')] = $versions->getGemsVersion(); @@ -139,23 +133,6 @@ $this->html->raw($php->getInfo()); } - public function privilegeAction() - { - $privileges = array(); - - foreach ($this->acl->getPrivilegeRoles() as $privilege => $roles) { - $privileges[$privilege][$this->_('Privilege')] = $privilege; - $privileges[$privilege][$this->_('Allowed')] = $roles[Zend_Acl::TYPE_ALLOW] ? implode(', ', $roles[Zend_Acl::TYPE_ALLOW]) : null; - $privileges[$privilege][$this->_('Denied')] = $roles[Zend_Acl::TYPE_DENY] ? implode(', ', $roles[Zend_Acl::TYPE_DENY]) : null; - } - ksort($privileges); - - $this->html->h2($this->_('Project privileges')); - $this->_showTable($this->_('Privileges'), $privileges, true); - - // $this->acl->echoRules(); - } - public function projectAction() { $project = $this->project; @@ -166,24 +143,6 @@ } - public function roleAction() - { - $roles = array(); - - foreach ($this->acl->getRolePrivileges() as $role => $privileges) { - $roles[$role][$this->_('Role')] = $role; - $roles[$role][$this->_('Parents')] = $privileges[MUtil_Acl::PARENTS] ? implode(', ', $privileges[MUtil_Acl::PARENTS]) : null; - $roles[$role][$this->_('Allowed')] = $privileges[Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[Zend_Acl::TYPE_ALLOW]) : null; - $roles[$role][$this->_('Denied')] = $privileges[Zend_Acl::TYPE_DENY] ? implode(', ', $privileges[Zend_Acl::TYPE_DENY]) : null; - } - ksort($roles); - - $this->html->h2($this->_('Project roles')); - $this->_showTable($this->_('Roles'), $roles, true); - - // $this->acl->echoRules(); - } - public function sessionAction() { $this->html->h2($this->_('Session content')); Modified: trunk/library/classes/Gems/Default/RoleAction.php =================================================================== --- trunk/library/classes/Gems/Default/RoleAction.php 2011-09-15 15:08:23 UTC (rev 25) +++ trunk/library/classes/Gems/Default/RoleAction.php 2011-09-15 16:00:09 UTC (rev 26) @@ -1,10 +1,9 @@ <?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 @@ -15,7 +14,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -26,78 +25,38 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * - * @author Michiel Rook - * @since 1.0 - * @version 1.3 - * @package Gems + * + * + * @package Gems * @subpackage Default + * @author Michiel Rook + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: StaffAction.php 460 2011-08-31 16:17:26Z mjong $ */ /** - * + * * @author Michiel Rook - * @package Gems + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.3 */ class Gems_Default_RoleAction extends Gems_Controller_BrowseEditAction { - - /** - * Check the disabled (=inherited) privileges - * - * @param Gems_Form $form - * @param boolean $isNew - * @return Gems_Form - */ - public function beforeFormDisplay($form, $isNew) { - $form = parent::beforeFormDisplay($form, $isNew); - $checkbox = $form->getElement('grl_privileges'); - $values = $checkbox->getValue(); - $disabled = $checkbox->getAttrib('disable'); - - $values = array_merge($values, $disabled); - $checkbox->setValue($values); - return $form; + protected function _showTable($caption, $data, $nested = false) + { + $table = MUtil_Html_TableElement::createArray($data, $caption, $nested); + $table->class = 'browser'; + $this->html[] = $table; } - - /** - * - * @param array $data The data that will be saved. - * @param boolean $isNew - * $param Zend_Form $form - * @return array|null Returns null if save was already handled, the data otherwise. - */ - public function beforeSave(array &$data, $isNew, Zend_Form $form = null) - { - if (isset($data['grl_parents'])) { - $data['grl_parents'] = implode(',', $data['grl_parents']); - } - if (isset($data['grl_privileges'])) { - $data['grl_privileges'] = implode(',', $data['grl_privileges']); - } - - return true; - } - - /** - * @param array $data - * @param bool $isNew - * @return array - */ - public function afterFormLoad(array &$data, $isNew) + public function aclAction() { - if (isset($data['grl_parents']) && (! is_array($data['grl_parents']))) { - $data['grl_parents'] = explode(',', $data['grl_parents']); - } - - if (isset($data['grl_privileges']) && (! is_array($data['grl_privileges']))) { - $data['grl_privileges'] = explode(',', $data['grl_privileges']); - } + $this->html->h2($this->_('Access Control Lists')); + $this->_showTable($this->_('ACL\'s'), $this->acl->getRoles()); } /** @@ -128,14 +87,68 @@ $disable = array(); foreach($result[$data['grl_name']][MUtil_Acl::INHERITED][Zend_Acl::TYPE_ALLOW] as $key=>$value) { $disable[] = $value; - } + } $checkbox->setAttrib('disable', $disable); //Don't use escaping, so the line breaks work $checkbox->setAttrib('escape', false); } - + /** + * @param array $data + * @param bool $isNew + * @return array + */ + public function afterFormLoad(array &$data, $isNew) + { + if (isset($data['grl_parents']) && (! is_array($data['grl_parents']))) { + $data['grl_parents'] = explode(',', $data['grl_parents']); + } + + if (isset($data['grl_privileges']) && (! is_array($data['grl_privileges']))) { + $data['grl_privileges'] = explode(',', $data['grl_privileges']); + } + } + + /** + * Check the disabled (=inherited) privileges + * + * @param Gems_Form $form + * @param boolean $isNew + * @return Gems_Form + */ + public function beforeFormDisplay($form, $isNew) { + $form = parent::beforeFormDisplay($form, $isNew); + $checkbox = $form->getElement('grl_privileges'); + $values = $checkbox->getValue(); + $disabled = $checkbox->getAttrib('disable'); + + $values = array_merge($values, $disabled); + $checkbox->setValue($values); + return $form; + } + + /** + * + * @param array $data The data that will be saved. + * @param boolean $isNew + * $param Zend_Form $form + * @return array|null Returns null if save was already handled, the data otherwise. + */ + public function beforeSave(array &$data, $isNew, Zend_Form $form = null) + { + if (isset($data['grl_parents'])) { + $data['grl_parents'] = implode(',', $data['grl_parents']); + } + + if (isset($data['grl_privileges'])) { + $data['grl_privileges'] = implode(',', $data['grl_privileges']); + } + + return true; + } + + /** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed @@ -156,14 +169,14 @@ $model->set('grl_privileges', 'label', $this->_('Privileges'), 'formatFunction', array($this, 'formatLongLine')); Gems_Model::setChangeFieldsByPrefix($model, 'grl'); - + return $model; } - + public function formatLongLine($line) { if (strlen($line) > 50) { - return substr($line, 0, 50) . '...'; + return substr($line, 0, 50) . '...'; } else { return $line; } @@ -178,12 +191,46 @@ { return $this->_('Administrative roles'); } - + protected function getUsedPrivileges() { $privileges = $this->menu->getUsedPrivileges(); asort($privileges); return $privileges; - } + } + + public function overviewAction() + { + $roles = array(); + + foreach ($this->acl->getRolePrivileges() as $role => $privileges) { + $roles[$role][$this->_('Role')] = $role; + $roles[$role][$this->_('Parents')] = $privileges[MUtil_Acl::PARENTS] ? implode(', ', $privileges[MUtil_Acl::PARENTS]) : null; + $roles[$role][$this->_('Allowed')] = $privileges[Zend_Acl::TYPE_ALLOW] ? implode(', ', $privileges[Zend_Acl::TYPE_ALLOW]) : null; + $roles[$role][$this->_('Denied')] = $privileges[Zend_Acl::TYPE_DENY] ? implode(', ', $privileges[Zend_Acl::TYPE_DENY]) : null; + } + ksort($roles); + + $this->html->h2($this->_('Project role overview')); + + $this->_showTable($this->_('Roles'), $roles, true); + } + + public function privilegeAction() + { + $privileges = array(); + + foreach ($this->acl->getPrivilegeRoles() as $privilege => $roles) { + $privileges[$privilege][$this->_('Privilege')] = $privilege; + $privileges[$privilege][$this->_('Allowed')] = $roles[Zend_Acl::TYPE_ALLOW] ? implode(', ', $roles[Zend_Acl::TYPE_ALLOW]) : null; + $privileges[$privilege][$this->_('Denied')] = $roles[Zend_Acl::TYPE_DENY] ? implode(', ', $roles[Zend_Acl::TYPE_DENY]) : null; + } + ksort($privileges); + + $this->html->h2($this->_('Project privileges')); + $this->_showTable($this->_('Privileges'), $privileges, true); + + // $this->acl->echoRules(); + } } Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-09-15 15:08:23 UTC (rev 25) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-09-15 16:00:09 UTC (rev 26) @@ -36,7 +36,7 @@ /** * - * @package Gems + * @package Gems * @subpackage Default * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License @@ -184,7 +184,7 @@ 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); } - + $model->set('gsf_id_primary_group', 'label', $this->_('Primary function'), 'multiOptions', MUtil_Lazy::call($this->util->getDbLookup()->getStaffGroups)); $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2011-09-15 15:08:23 UTC (rev 25) +++ trunk/library/classes/Gems/Menu.php 2011-09-15 16:00:09 UTC (rev 26) @@ -185,12 +185,9 @@ // PROJECT $page = $setup->addPage($this->_('Project setup'), 'pr.project-information', 'project-information'); - $page->addAction($this->_('ACL'), null, 'acl'); $page->addAction($this->_('Errors'), null, 'errors'); $page->addAction($this->_('PHP'), null, 'php'); - $page->addAction($this->_('Privileges'), null, 'privilege'); $page->addAction($this->_('Project'), null, 'project'); - $page->addAction($this->_('Roles'), null, 'role'); $page->addAction($this->_('Session'), null, 'session'); // COUNTRIES CONTROLLER @@ -209,9 +206,11 @@ $setup->addBrowsePage($this->_('Groups'), 'pr.group', 'group'); // ROLES CONTROLLER - $setup->addBrowsePage($this->_('Roles'), 'pr.role', 'role'); + $page = $setup->addBrowsePage($this->_('Roles'), 'pr.role', 'role'); + $page->addAction($this->_('ACL'), null, 'acl'); + $page->addAction($this->_('Assigned'), null, 'overview'); + $page->addAction($this->_('Privileges'), null, 'privilege'); - // RECEPTION CODE CONTROLLER $setup->addBrowsePage($this->_('Reception codes'), 'pr.reception', 'reception'); Modified: trunk/library/configs/db/tables/gems__mail_templates.200.sql =================================================================== --- trunk/library/configs/db/tables/gems__mail_templates.200.sql 2011-09-15 15:08:23 UTC (rev 25) +++ trunk/library/configs/db/tables/gems__mail_templates.200.sql 2011-09-15 16:00:09 UTC (rev 26) @@ -20,3 +20,19 @@ AUTO_INCREMENT = 20 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'; +INSERT INTO gems__mail_templates (gmt_subject, gmt_body, gmt_changed, gmt_changed_by, gmt_created, gmt_created_by) + VALUES + ('Questions for your treatement at {organization}', 'Dear {greeting}, + +Recently you visited [b]{organization}[/b] for treatment. For your proper treatment you are required to answer some questions. + +Click on [url={token_url}]this link[/url] to start or go to [url]{site_ask_url}[/url] and enter your token "{token}". + +{organization_signature}', CURRENT_TIMESTAMP, 1, CURRENT_TIMESTAMP, 1), + ('Reminder: your treatement at {organization}', 'Dear {greeting}, + +We remind you that for your proper treatment at [b]{organization}[/b] you are required to answer some questions. + +Click on [url={token_url}]this link[/url] to start or go to [url]{site_ask_url}[/url] and enter your token "{token}". + +{organization_signature}', CURRENT_TIMESTAMP, 1, CURRENT_TIMESTAMP, 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |