From: <gem...@li...> - 2012-10-25 15:05:36
|
Revision: 998 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=998&view=rev Author: matijsdejong Date: 2012-10-25 15:05:27 +0000 (Thu, 25 Oct 2012) Log Message: ----------- Code cleanup + documentation Extr unitility getRespondentId in DbLookup.php Modified Paths: -------------- trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-10-25 12:55:41 UTC (rev 997) +++ trunk/library/classes/Gems/Menu.php 2012-10-25 15:05:27 UTC (rev 998) @@ -278,7 +278,6 @@ { $orgId = $this->escort->getLoader()->getCurrentUser()->getCurrentOrganizationId(); - // $params = array(MUtil_Model::REQUEST_ID => 'gr2o_patient_nr'); $params = array(MUtil_Model::REQUEST_ID1 => 'gr2o_patient_nr', MUtil_Model::REQUEST_ID2 => 'gr2o_id_organization'); // MAIN RESPONDENTS ITEM Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2012-10-25 12:55:41 UTC (rev 997) +++ trunk/library/classes/Gems/Util/DbLookup.php 2012-10-25 15:05:27 UTC (rev 998) @@ -92,7 +92,7 @@ return $organizations; } - + /** * Return key/value pairs of all active staff members * @@ -338,6 +338,27 @@ return $organizations; } + /** + * Find the respondent id corresponding to this patientNr / Orgid combo + * + * @param string $patientNr + * @param int $orgid + * @return int A respondent id or null + */ + public function getRespondentId($patientNr, $orgid) + { + $result = $this->db->fetchOne("SELECT gr2o_id_user FROM gems__respondent2org WHERE gr2o_patient_nr = ? AND gr2o_id_organization = ?", array($patientNr, $orgid)); + + if ($result !== false) { + return $result; + } + } + + /** + * Returns the roles in the acl + * + * @return array roleId => ucfirst(roleId) + */ public function getRoles() { $roles = array(); Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-10-25 12:55:41 UTC (rev 997) +++ trunk/library/classes/GemsEscort.php 2012-10-25 15:05:27 UTC (rev 998) @@ -572,9 +572,9 @@ if ($menuItem) { $contactDiv = MUtil_Html::create()->div( - $args, - array('id' => 'contact') - ); // tooltip + $args, + array('id' => 'contact') + ); // tooltip $contactDiv->a($menuItem->toHRefAttribute(), $menuItem->get('label')); $ul = $menuItem->toUl(); @@ -689,13 +689,13 @@ $icon = isset($this->project->favicon) ? $this->project->favicon : 'favicon.ico'; if (file_exists(GEMS_WEB_DIR . '/' . $icon)) { $this->view->headLink( - array( - 'rel' => 'shortcut icon', - 'href' => $this->basepath->getBasePath() . '/' . $icon, - 'type' => 'image/x-icon' - ), - Zend_View_Helper_Placeholder_Container_Abstract::PREPEND - ); + array( + 'rel' => 'shortcut icon', + 'href' => $this->basepath->getBasePath() . '/' . $icon, + 'type' => 'image/x-icon' + ), + Zend_View_Helper_Placeholder_Container_Abstract::PREPEND + ); } } @@ -749,12 +749,15 @@ if ($locale == $this->view->locale) { $localeDiv->span(strtoupper($locale)); } else { - $localeDiv->a(array( + $localeDiv->a( + array( 'controller' => 'language', 'action' => 'change-ui', 'language' => urlencode($locale), 'current_uri' => $currentUri - ), strtoupper($locale)); + ), + strtoupper($locale) + ); } $localeDiv[] = ' '; } @@ -914,7 +917,12 @@ $url = $this->view->url(array('controller' => 'organization', 'action' => 'change-ui'), null, true); $formDiv = $orgSwitch->form(array('method' => 'get', 'action' => $url))->div(); - $formDiv->input(array('type' => "hidden", 'name' => "current_uri", 'value' => base64_encode($currentUri))); + $formDiv->input( + array( + 'type' => "hidden", + 'name' => "current_uri", + 'value' => base64_encode($currentUri)) + ); $select = $formDiv->select(array('name' => "org", 'onchange' => "javascript:this.form.submit();")); foreach ($orgs as $id => $org) { @@ -1122,7 +1130,9 @@ protected function createProjectClass($className, $paramOne = null, $paramTwo = null) { - if (file_exists(APPLICATION_PATH . '/classes/' . GEMS_PROJECT_NAME_UC . '/' . str_replace('_', '/', $className) . '.php')) { + $filename = APPLICATION_PATH . '/classes/' . GEMS_PROJECT_NAME_UC . '/'; + $filename .= str_replace('_', '/', $className) . '.php'; + if (file_exists($filename)) { $className = GEMS_PROJECT_NAME_UC . '_' . $className; } else { $className = 'Gems_' . $className; @@ -1140,7 +1150,9 @@ return new $className($paramOne, $paramTwo); default: - throw new Gems_Exception_Coding(__CLASS__ . '->' . __FUNCTION__ . '() called with more parameters than possible.'); + throw new Gems_Exception_Coding( + __CLASS__ . '->' . __FUNCTION__ . '() called with more parameters than possible.' + ); } } @@ -1167,7 +1179,9 @@ { // Check the installation if (! isset($this->db)) { - $this->setException(new Gems_Exception_Coding('No database registered in ' . GEMS_PROJECT_NAME . 'Application.ini for key resources.db.')); + $this->setException(new Gems_Exception_Coding( + 'No database registered in ' . GEMS_PROJECT_NAME . 'Application.ini for key resources.db.') + ); } } @@ -1315,7 +1329,9 @@ break; default: - throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type ' . $extension); + throw new Zend_Application_Exception( + 'Invalid configuration file provided; unknown config type ' . $extension + ); } @@ -1402,7 +1418,8 @@ if ($request->isDispatched()) { // Only when we need to render the layout, we run the layout prepare - if (Zend_Controller_Action_HelperBroker::hasHelper('layout') && Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->isEnabled()) { + if (Zend_Controller_Action_HelperBroker::hasHelper('layout') && + Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->isEnabled()) { // Per project layout preparation if (isset($this->project->layoutPrepare)) { @@ -1609,7 +1626,8 @@ // Gems does not use index/index $action = $request->getActionName(); - if (('index' == $request->getControllerName()) && (('index' == $action) || ($user->isActive() && ('login' == $action)))) { + if (('index' == $request->getControllerName()) && + (('index' == $action) || ($user->isActive() && ('login' == $action)))) { // Instead Gems routes to the first available menu item when this is the request target if (! $user->gotoStartPage($this->menu, $request)) { $this->setError( @@ -1758,7 +1776,10 @@ // Count todo $tSelect = $this->getLoader()->getTracker()->getTokenSelect(array( 'all' => 'COUNT(*)', - 'track' => $this->db->quoteInto('SUM(CASE WHEN gto_id_respondent_track = ? THEN 1 ELSE 0 END)', $tokenData['gto_id_respondent_track']))); + 'track' => $this->db->quoteInto( + 'SUM(CASE WHEN gto_id_respondent_track = ? THEN 1 ELSE 0 END)', + $tokenData['gto_id_respondent_track']) + )); $tSelect->andSurveys(array()) ->forRespondent($tokenData['gto_id_respondent'], $tokenData['gto_id_organization']) ->forGroupId($tokenData['gsu_id_primary_group']) @@ -1770,7 +1791,8 @@ $result['{first_name}'] = $tokenData['grs_first_name']; $result['{full_name}'] = implode(' ', $hello); $result['{greeting}'] = implode(' ', $greeting); - $result['{last_name}'] = ($tokenData['grs_surname_prefix'] ? $tokenData['grs_surname_prefix'] . ' ' : '') . $tokenData['grs_last_name']; + $result['{last_name}'] = ($tokenData['grs_surname_prefix'] ? $tokenData['grs_surname_prefix'] . ' ' : ''); + $result['{last_name}'] .= $tokenData['grs_last_name']; array_shift($hello); $result['{name}'] = implode(' ', $hello); @@ -1780,8 +1802,9 @@ $result['{site_ask_url}'] = $orgResults['organization_login_url'] . '/ask/'; // Url's - $url = $orgResults['organization_login_url'] . '/ask/forward/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']; - $url_input = $result['{site_ask_url}'] . 'index/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']; + $url = $orgResults['organization_login_url'] . '/ask/forward/' . MUtil_Model::REQUEST_ID . '/'; + $url .= $tokenData['gto_id_token']; + $urlInput = $result['{site_ask_url}'] . 'index/' . MUtil_Model::REQUEST_ID . '/' . $tokenData['gto_id_token']; $result['{survey}'] = $tokenData['gsu_survey_name']; @@ -1792,14 +1815,14 @@ $result['{token}'] = strtoupper($tokenData['gto_id_token']); $result['{token_from}'] = MUtil_Date::format($tokenData['gto_valid_from'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); - // $result['{token_input}'] = MUtil_Html::create()->a($url_input, $tokenData['gsu_survey_name']); + // $result['{token_input}'] = MUtil_Html::create()->a($urlInput, $tokenData['gsu_survey_name']); // $result['{token_link}'] = MUtil_Html::create()->a($url, $tokenData['gsu_survey_name']); // $result['{token_link}'] = '<a href="' . $url . '">' . $tokenData['gsu_survey_name'] . '</a>'; $result['{token_link}'] = '[url=' . $url . ']' . $tokenData['gsu_survey_name'] . '[/url]'; $result['{token_until}'] = MUtil_Date::format($tokenData['gto_valid_until'], Zend_Date::DATE_LONG, 'yyyy-MM-dd', $locale); $result['{token_url}'] = $url; - $result['{token_url_input}'] = $url_input; + $result['{token_url_input}'] = $urlInput; $result['{track}'] = $tokenData['gtr_track_name']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |