From: <gem...@li...> - 2011-09-27 11:09:01
|
Revision: 77 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=77&view=rev Author: matijsdejong Date: 2011-09-27 11:08:50 +0000 (Tue, 27 Sep 2011) Log Message: ----------- - added documentation to BrowseEditAction.php - corrected whitespace in gems__staff.20.sql - bug #13 fixed StaffAction.php for correct treatment of rights Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/configs/db/tables/gems__staff.20.sql Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2011-09-27 10:38:07 UTC (rev 76) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2011-09-27 11:08:50 UTC (rev 77) @@ -608,6 +608,16 @@ return $data; } + /** + * Additional data filter statements for the user input. + * + * User input that has the same name as a model field is automatically + * used as a filter, but if the name is different processing is needed. + * That processing should happen here. + * + * @param array $data The current user input + * @return array New filter statements + */ protected function getDataFilter(array $data) { if ($this->filterStandard) { @@ -617,6 +627,13 @@ return array(); } + /** + * Returns the default search values for this class instance. + * + * Used to specify the filter when no values have been entered by the user. + * + * @return array + */ public function getDefaultSearchData() { return array(); Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-09-27 10:38:07 UTC (rev 76) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-09-27 11:08:50 UTC (rev 77) @@ -42,7 +42,7 @@ * @license New BSD License * @since Class available since version 1.0 */ -class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction // implements Gems_Menu_ParameterSourceInterface +class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { public $filterStandard = array('gsf_active' => 1); public $sortKey = array('name' => SORT_ASC); @@ -133,7 +133,7 @@ $this->_groups = MUtil_Lazy::call(array($this->db, 'fetchPairs'), $sql); $bridge->addExhibitor('gsf_id_organization'); - $bridge->addSelect( 'gsf_id_primary_group', 'multiOptions', $dbLookup->getStaffGroupsNoSuper()); + $bridge->addSelect( 'gsf_id_primary_group', 'multiOptions', $dbLookup->getStaffGroupsNoSuper()); } $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); @@ -149,9 +149,8 @@ $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; $groups = $this->db->fetchPairs($sql); - if (($this->session->user_role == 'admin' && isset($groups) && $groups[$data['gsf_id_primary_group']] == 'super') - || (! $this->escort->hasPrivilege('pr.staff.edit.all') && - $data['gsf_id_organization'] != $this->escort->getCurrentOrganization())) { + if (! ($this->escort->hasPrivilege('pr.staff.edit.all') || + $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -179,7 +178,9 @@ 'column_expression', "CONCAT(COALESCE(CONCAT(gsf_last_name, ', '), '-, '), COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, ''))"); $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); - if ($this->escort->hasPrivilege('pr.staff.see.all')) { + if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { + $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); + $model->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); @@ -208,18 +209,35 @@ // Select organization $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsf_id_organization', 'multiOptions'); $select = new Zend_Form_Element_Select('gsf_id_organization', array('multiOptions' => $options)); - } else { - $select = new Zend_Form_Element_Hidden('gsf_id_organization', - array('value' => $this->escort->getCurrentOrganization())); + + // Position as second element + $search = array_shift($elements); + array_unshift($elements, $search, $select); } - // Position as second element - $search = array_shift($elements); - array_unshift($elements, $search, $select); - return $elements; } + /** + * Additional data filter statements for the user input. + * + * User input that has the same name as a model field is automatically + * used as a filter, but if the name is different processing is needed. + * That processing should happen here. + * + * @param array $data The current user input + * @return array New filter statements + */ + protected function getDataFilter(array $data) + { + $filter = parent::getDataFilter($data); + + if (! $this->escort->hasPrivilege('pr.staff.see.all')) { + $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization(); + } + return $filter; + } + public function getInstanceId() { if ($this->_instanceId) { @@ -229,11 +247,27 @@ return parent::getInstanceId(); } - /* - public function getMenuParameter($name, $default) + /** + * Creates from the model a MUtil_Html_TableElement for display of a single item. + * + * Overruled to add css classes for Gems + * + * @param integer $columns The number of columns to use for presentation + * @param mixed $filter A valid filter for MUtil_Model_ModelAbstract->load() + * @param mixed $sort A valid sort for MUtil_Model_ModelAbstract->load() + * @return MUtil_Html_TableElement + */ + public function getShowTable($columns = 1, $filter = null, $sort = null) { + if ($this->escort->hasPrivilege('pr.staff.see.all')) { + // Model filter has now been set. + $data = $this->getModel()->loadFirst(); - } // */ + $this->_setParam('gsf_id_organization', $data['gsf_id_organization']); + $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $data['gsf_id_organization']); + } + return parent::getShowTable($columns, $filter, $sort); + } public function getTopic($count = 1) { Modified: trunk/library/configs/db/tables/gems__staff.20.sql =================================================================== --- trunk/library/configs/db/tables/gems__staff.20.sql 2011-09-27 10:38:07 UTC (rev 76) +++ trunk/library/configs/db/tables/gems__staff.20.sql 2011-09-27 11:08:50 UTC (rev 77) @@ -1,5 +1,5 @@ --- Table containing the project staff +-- Table containing the project staff -- CREATE TABLE if not exists gems__staff ( gsf_id_user bigint unsigned not null auto_increment, @@ -9,12 +9,12 @@ gsf_password varchar(32) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, - gsf_active boolean not null default 1, - gsf_failed_logins int(11) unsigned not null default 0, + gsf_active boolean not null default 1, + gsf_failed_logins int(11) unsigned not null default 0, gsf_last_failed timestamp null, gsf_id_primary_group bigint unsigned references gems__groups (ggp_id_group), - gsf_id_organization bigint not null + gsf_id_organization bigint not null references gems__organizations (gor_id_organization), gsf_iso_lang char(2) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default 'nl' references gems__languages (gml_iso_lang), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |