From: <gem...@li...> - 2011-10-18 16:35:41
|
Revision: 113 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=113&view=rev Author: matijsdejong Date: 2011-10-18 16:35:34 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Modified Paths: -------------- branches/newUser/classes/Gems/Cookies.php branches/newUser/classes/Gems/Default/IndexAction.php branches/newUser/classes/Gems/Loader/LoaderAbstract.php branches/newUser/classes/Gems/Loader.php branches/newUser/classes/GemsEscort.php branches/newUser/configs/db/patches.sql Added Paths: ----------- branches/newUser/ Modified: branches/newUser/classes/Gems/Cookies.php =================================================================== --- trunk/library/classes/Gems/Cookies.php 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/classes/Gems/Cookies.php 2011-10-18 16:35:34 UTC (rev 113) @@ -1,63 +1,86 @@ <?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 $Id$ + +/** + * 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 Cookies + * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @version $Id$ */ /** * Static Gems cookie utilities - * - * @author Matijs de Jong + * * @package Gems * @subpackage Cookies * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @since Class available since version 1.0 */ class Gems_Cookies { const LOCALE_COOKIE = 'gems_locale'; - public static function get(Zend_Controller_Request_Abstract $request, $name) + /** + * Get a specific cookie from the request. + * + * @param Zend_Controller_Request_Abstract $request + * @param string $name + * @param mixed $default + * @return mixed Cookie value + */ + public static function get(Zend_Controller_Request_Abstract $request, $name, $default = null) { - return $request->getCookie($name); + return $request->getCookie($name, $default); } + /** + * Get the current locale from the cookie. + * + * @param Zend_Controller_Request_Abstract $request + * @return string The current locale + */ public static function getLocale(Zend_Controller_Request_Abstract $request) { return self::get($request, self::LOCALE_COOKIE); } + /** + * Store this cookie in a generic save method that works for both sub-directory + * installations and own url installations. + * + * @param string $name Name of the cookie + * @param mixed $value Value to set + * @param int $days Number of days to keep this cookie + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function set($name, $value, $days = 30, $basepath = '/') { // Gems uses the empty string when the base path is '/' @@ -69,6 +92,13 @@ return setcookie($name, $value, time() + ($days * 86400), $basepath); } + /** + * Store the locale in a cookie. + * + * @param string $locale Locale to store + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function setLocale($locale, $basepath = '/') { // Set the cookie for 30 days Modified: branches/newUser/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-18 16:35:34 UTC (rev 113) @@ -92,6 +92,21 @@ $form->setMethod('post'); $form->setDescription(sprintf($this->_('Login to %s application'), $this->project->name)); + if ($this->escort instanceof Gems_Project_Organization_SingleOrganizationInterface) { + $element = new Zend_Form_Element_Hidden('organization'); + $element->setValue($this->escort->getRespondentOrganization()); + } else { + $element = new Zend_Form_Element_Select('organization'); + $element->setLabel($this->_('Organization')); + $element->setMultiOptions($this->util->getDbLookup()->getOrganizations()); + $element->setRequired(true); + + if (! $this->_request->isPost()) { + $element->setValue($this->escort->getCurrentOrganization()); + } + } + $form->addElement($element); + // Veld inlognaam $element = new Zend_Form_Element_Text('userlogin'); $element->setLabel($this->_('Username')); @@ -130,7 +145,7 @@ return $form; } - // Dummy: always rerouted by Gems + // Dummy: always rerouted by GemsEscort public function indexAction() { } public function loginAction() @@ -138,11 +153,17 @@ if (isset($this->session->user_id)) { $this->_reroute(array('controller' => 'respondent')); } + // MUtil_Echo::track(get_class($this->loader->getUser('super', null))); $form = $this->_getLoginForm(); if ($this->_request->isPost()) { if ($form->isValid($_POST, false)) { + /* + if ($user = $this->loader->getUser($_POST['userlogin'], $_POST['organization'])) { + + } // */ + if (isset($this->project->admin) && $this->project->admin['user'] == $_POST['userlogin'] && $this->project->admin['pwd'] == $_POST['password']) { $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; Modified: branches/newUser/classes/Gems/Loader/LoaderAbstract.php =================================================================== --- trunk/library/classes/Gems/Loader/LoaderAbstract.php 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/classes/Gems/Loader/LoaderAbstract.php 2011-10-18 16:35:34 UTC (rev 113) @@ -154,7 +154,7 @@ { // echo '_loadClassPath: ' . $this->cascade . '-' . $classname . '-' . ($create ? 1 : 0) . "<br/>\n"; // debug_print_backtrace(); - // MUtil_Echo::r($filepath, $classname, $this->cascade); + // MUtil_Echo::track($filepath, $classname, $this->cascade); if (file_exists($filepath)) { if (! class_exists($classname)) { Modified: branches/newUser/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/classes/Gems/Loader.php 2011-10-18 16:35:34 UTC (rev 113) @@ -90,6 +90,12 @@ /** * + * @var Gems_User_UserLoader + */ + protected $userLoader; + + /** + * * @var Gems_Util */ protected $util; @@ -177,6 +183,28 @@ /** * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return Gems_User_UserInterface + */ + public function getUser($login_name, $organization) + { + $loader = $this->getUserLoader(); + + return $loader->getUser($login_name, $organization); + } + + /** + * + * @return Gems_User_UserLoader + */ + protected function getUserLoader() + { + return $this->_getClass('userLoader', 'User_UserLoader'); + } + + /** + * * @return Gems_Util */ public function getUtil() Modified: branches/newUser/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/classes/GemsEscort.php 2011-10-18 16:35:34 UTC (rev 113) @@ -207,7 +207,7 @@ * * Use $this->acl to access afterwards * - * @return Zend_View + * @return MUtil_Acl */ protected function _initAcl() { Modified: branches/newUser/configs/db/patches.sql =================================================================== --- trunk/library/configs/db/patches.sql 2011-10-17 13:51:03 UTC (rev 112) +++ branches/newUser/configs/db/patches.sql 2011-10-18 16:35:34 UTC (rev 113) @@ -203,4 +203,14 @@ -- PATCH: Assign maintenance mode toggle to super role UPDATE gems__roles SET grl_privileges = CONCAT(grl_privileges,',pr.maintenance') WHERE grl_name = 'super' AND grl_privileges NOT LIKE '%pr.maintenance%'; --- GEMS VERSION: 42 \ No newline at end of file +-- GEMS VERSION: 42 +-- PATCH: New user login structure +INSERT INTO gems__users (gsu_id_user, gsu_login, gsu_id_organization, gsu_user_class, gsu_active, + gsu_password, gsu_failed_logins, gsu_last_failed, gsu_reset_key, gsu_reset_requested, gsu_reset_required, + gsu_changed, gsu_changed_by, gsu_created, gsu_created_by) + SELECT grs_id_user, gr2o_patient_nr, gr2o_id_organization, 'RespondentUser', CASE WHEN gr2o_reception_code = 'OK' THEN 1 ELSE 0 END, + NULL, 0, NULL, NULL, NULL, 0, + gr2o_changed, gr2o_changed_by, gr2o_created, gr2o_created_by + FROM gems__respondents INNER JOIN gems__respondent2org ON grs_id_user = gr2o_id_user + INNER JOIN gems__organizations ON gr2o_id_organization = gor_id_organization + WHERE gor_name = 'HCU / Xpert Clinic'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |