From: <gem...@li...> - 2012-01-31 15:36:10
|
Revision: 441 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=441&view=rev Author: matijsdejong Date: 2012-01-31 15:35:59 +0000 (Tue, 31 Jan 2012) Log Message: ----------- Added 'default organization' for login to single organization projects ModelSnippetActionAbstract.php pages now also show menu position in the document title Modified Paths: -------------- branches/1.5.x/library/classes/Gems/Controller/ModelActionAbstract.php branches/1.5.x/library/classes/Gems/Controller/ModelSnippetActionAbstract.php branches/1.5.x/library/classes/Gems/Default/OrganizationAction.php branches/1.5.x/library/classes/Gems/Menu.php branches/1.5.x/library/classes/Gems/Project/ProjectSettings.php branches/1.5.x/library/classes/Gems/User/UserLoader.php branches/1.5.x/library/snippets/ShowTrackTokenSnippet.php Modified: branches/1.5.x/library/classes/Gems/Controller/ModelActionAbstract.php =================================================================== --- branches/1.5.x/library/classes/Gems/Controller/ModelActionAbstract.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/Controller/ModelActionAbstract.php 2012-01-31 15:35:59 UTC (rev 441) @@ -147,13 +147,30 @@ } } + /** + * Return the current request ID, if any. + * + * Overrule this function if the last item in the page title + * should be something other than te value of + * MUtil_Model::REQUEST_ID. + * + * @return mixed + */ public function getInstanceId() { - if ($id = $this->request->getParam(MUtil_Model::REQUEST_ID)) { + if ($id = $this->_getParam(MUtil_Model::REQUEST_ID)) { return $id; } } + /** + * Returns the current html/head/title for this page. + * + * If the title is an array the seperator concatenates the parts. + * + * @param string $separator + * @return string + */ public function getTitle($separator = null) { if ($title_set = parent::getTitle($separator)) { Modified: branches/1.5.x/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- branches/1.5.x/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-01-31 15:35:59 UTC (rev 441) @@ -208,6 +208,47 @@ } /** + * Return the current request ID, if any. + * + * Overrule this function if the last item in the page title + * should be something other than te value of + * MUtil_Model::REQUEST_ID. + * + * @return mixed + */ + public function getInstanceId() + { + if ($id = $this->_getParam(MUtil_Model::REQUEST_ID)) { + return $id; + } + } + + /** + * Returns the current html/head/title for this page. + * + * If the title is an array the seperator concatenates the parts. + * + * @param string $separator + * @return string + */ + public function getTitle($separator = null) + { + if ($title_set = parent::getTitle($separator)) { + return $title_set; + } + + $title = array(); + foreach($this->menu->getActivePath($this->getRequest()) as $menuItem) { + $title[] = $menuItem->get('label'); + } + if ($id = $this->getInstanceId()) { + $title[] = $id; + } + + return implode($separator, $title); + } + + /** * Intializes the html component. * * @param boolean $reset Throws away any existing html output when true Modified: branches/1.5.x/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- branches/1.5.x/library/classes/Gems/Default/OrganizationAction.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/Default/OrganizationAction.php 2012-01-31 15:35:59 UTC (rev 441) @@ -166,7 +166,8 @@ if($model->has('gor_user_class')) { $definitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions(); //Use first element as default - $default = array_shift(array_keys($definitions)); + $tmp = array_keys($definitions); + $default = array_shift($tmp); $model->set('gor_user_class', 'default', $default); if (count($definitions)>1) { if ($action !== 'create') { Modified: branches/1.5.x/library/classes/Gems/Menu.php =================================================================== --- branches/1.5.x/library/classes/Gems/Menu.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/Menu.php 2012-01-31 15:35:59 UTC (rev 441) @@ -282,7 +282,7 @@ $trType = 'T'; $subPage = $page->addPage($this->_('Track'), 'pr.track', 'track', 'show-track') ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr') - ->addHiddenParameter(Gems_Model::TRACK_ID, $this->escort->getTrackId(), 'gtr_track_type', 'T'); + ->addHiddenParameter(Gems_Model::TRACK_ID, $this->escort->getTrackId(), 'gtr_track_type', $trType); $tkPages[$trType] = $subPage->addAction($this->_('Token'), 'pr.token', 'show') ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gto_id_token') Modified: branches/1.5.x/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- branches/1.5.x/library/classes/Gems/Project/ProjectSettings.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/Project/ProjectSettings.php 2012-01-31 15:35:59 UTC (rev 441) @@ -225,6 +225,24 @@ } /** + * Returns an (optional) default organization from the project settings + * + * @return int Organization number or -1 when not set + */ + public function getDefaultOrganization() + { + if ($this->offsetExists('organization')) { + $orgs = $this->offsetGet('organization'); + + if (isset($orgs['default'])) { + return $orgs['default']; + } + } + + return -1; + } + + /** * Returns the public name of this project. * @return string */ Modified: branches/1.5.x/library/classes/Gems/User/UserLoader.php =================================================================== --- branches/1.5.x/library/classes/Gems/User/UserLoader.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/classes/Gems/User/UserLoader.php 2012-01-31 15:35:59 UTC (rev 441) @@ -321,6 +321,23 @@ $row = $this->db->fetchRow($sql, $params, Zend_Db::FETCH_NUM); } + if ((! $row) && ($organization == $this->project->getDefaultOrganization())) { + // Check for the current organization being the default one + // + // For optimization do set the allowed organizations + // Try to get see if this is another allowed organization for this user + $sql = "SELECT CONCAT(gul_user_class, 'Definition'), gul_id_organization + FROM gems__user_logins INNER JOIN gems__organizations ON gor_id_organization != gul_id_organization + WHERE gor_active = 1 AND + gul_can_login = 1 AND + gul_login = ? + LIMIT 1"; + + // MUtil_Echo::track($sql, $login_name); + + $row = $this->db->fetchRow($sql, $login_name, Zend_Db::FETCH_NUM); + } + if ($row) { // MUtil_Echo::track($row); return $row; @@ -338,7 +355,20 @@ gems__organizations ON gsf_id_organization = gor_id_organization WHERE gor_active = 1 AND gsf_active = 1 AND gsf_login = ? AND gsf_id_organization = ?"; - if ($user_id = $this->db->fetchOne($sql, array($login_name, $organization))) { + $user_id = $this->db->fetchOne($sql, $params); + + if ((! $user_id) && ($organization == $this->project->getDefaultOrganization())) { + $sql = "SELECT gsf_id_user + FROM gems__staff INNER JOIN + gems__organizations ON gsf_id_organization = gor_id_organization + WHERE gor_active = 1 AND gsf_active = 1 AND gsf_login = ?"; + + // MUtil_Echo::track($sql, $login_name); + + $user_id = $this->db->fetchOne($sql, $login_name); + } + + if ($user_id) { // Move user to new staff. $values['gul_login'] = $login_name; $values['gul_id_organization'] = $organization; Modified: branches/1.5.x/library/snippets/ShowTrackTokenSnippet.php =================================================================== --- branches/1.5.x/library/snippets/ShowTrackTokenSnippet.php 2012-01-31 12:30:08 UTC (rev 440) +++ branches/1.5.x/library/snippets/ShowTrackTokenSnippet.php 2012-01-31 15:35:59 UTC (rev 441) @@ -72,7 +72,7 @@ $bridge->addItem('gto_id_token', null, array('colspan' => 1.5)); $buttons = $links->getActionLinks(true, 'ask', 'take', 'pdf', 'show', $controller, 'questions', $controller, 'answer'); - if ($buttons) { + if (count($buttons)) { $bridge->tr(); $bridge->tdh($this->_('Actions')); $bridge->td($buttons, array('colspan' => 2, 'skiprowclass' => true)); @@ -144,8 +144,11 @@ ->addByController('respondent', 'show', $this->_('Show respondent')) ->addByController('track', 'index', $this->_('Show tracks')) ->addCurrentSiblings() + ->addCurrentChildren() ->showDisabled(); + MUtil_Echo::track($links->count()); + return $links; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |