|
From: <gem...@li...> - 2011-10-21 12:15:53
|
Revision: 123
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=123&view=rev
Author: matijsdejong
Date: 2011-10-21 12:15:43 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
Saving last changes
Added Paths:
-----------
branches/newUser/classes/Gems/Model/UserModel.php
branches/newUser/classes/Gems/User/
branches/newUser/classes/Gems/User/ProjectSuperUser.php
branches/newUser/classes/Gems/User/UserAbstract.php
branches/newUser/classes/Gems/User/UserInterface.php
branches/newUser/classes/Gems/User/UserLoader.php
branches/newUser/configs/db/tables/gems__users.10.sql
Added: branches/newUser/classes/Gems/Model/UserModel.php
===================================================================
--- branches/newUser/classes/Gems/Model/UserModel.php (rev 0)
+++ branches/newUser/classes/Gems/Model/UserModel.php 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,117 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage Model
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
+ */
+
+/**
+ *
+ *
+ * @package Gems
+ * @subpackage Model
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+class Gems_Model_UserModel extends Gems_Model_JoinModel
+{
+ /**
+ * The length of a user id.
+ *
+ * @var int
+ */
+ protected $userIdLen = 8;
+
+ /**
+ * Create a model that joins two or more tables
+ *
+ * @param string $name The name of the model
+ * @param string $secondTable The optional second base table for the model
+ * @param array $joinFields Array of source->dest primary keys for this join
+ * @param string $fieldPrefix Prefix to use for change fields (date/userid)
+ * @param bool $saveable Will changes to this table be saved
+ */
+ public function __construct($name, $secondTable = null, array $joinFields = null, $fieldPrefix = null, $saveable = null)
+ {
+ parent::__construct($name, 'gems__users', (null === $saveable ? $fieldPrefix : $saveable));
+
+ if ($fieldPrefix) {
+ Gems_Model::setChangeFieldsByPrefix($this, 'gsu');
+ }
+
+ if ($secondTable) {
+ $this->addTable($secondTable, $joinFields, $fieldPrefix, $saveable);
+ }
+ }
+
+ /**
+ * Finds a random unique user id.
+ *
+ * @return int
+ */
+ protected function _createUserId()
+ {
+ $max = $this->userIdLen;
+
+ do {
+ $out = mt_rand(1, 9);
+ for ($i = 1; $i < $this->userIdLen; $i++) {
+ $out .= mt_rand(0, 9);
+ }
+ // Make it a number
+ $out = intval($out);
+
+ } while ($this->db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out));
+
+ return $out;
+ }
+
+ /**
+ * Save a single model item.
+ *
+ * @param array $newValues The values to store for a single model item.
+ * @param array $filter If the filter contains old key values these are used
+ * to decide on update versus insert.
+ * @return array The values as they are after saving (they may change).
+ */
+ public function save(array $newValues, array $filter = null, array $saveTables = null)
+ {
+ if (! (isset($newValues['gsu_id_user']) && $newValues['gsu_id_user'])) {
+ // Load a new user id if needed
+ $newValues['gsu_id_user'] = $this->_createUserId();
+ }
+
+ parent::save($newValues, $filter, $saveTables);
+ }
+}
Property changes on: branches/newUser/classes/Gems/User
___________________________________________________________________
Added: bugtraq:url
+ http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID%
Added: bugtraq:number
+ true
Added: bugtraq:logregex
+ #(\d+)
Added: branches/newUser/classes/Gems/User/ProjectSuperUser.php
===================================================================
--- branches/newUser/classes/Gems/User/ProjectSuperUser.php (rev 0)
+++ branches/newUser/classes/Gems/User/ProjectSuperUser.php 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,120 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
+ */
+
+/**
+ *
+ *
+ * @package Gems
+ * @subpackage
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+class Gems_User_ProjectSuperUser extends Gems_User_UserAbstract
+{
+ const MIN_PASSWORD_LENGTH = 10;
+
+ /**
+ * The role of this user.
+ *
+ * @var string
+ */
+ protected $_role = 'super';
+
+ /**
+ *
+ * @var ArrayObject
+ */
+ protected $project;
+
+ /**
+ *
+ * @var Gems_Util_Translated
+ */
+ protected $translated;
+
+ /**
+ * Check that the password is correct for this user.
+ *
+ * @param string $password Unencrypted password
+ * @return boolean
+ */
+ public function checkPassword($password)
+ {
+ if (isset($this->project->admin['pwd']) && ($this->project->admin['pwd'] == $password)) {
+ if (APPLICATION_ENV === 'production') {
+ if (strlen($string) < self::MIN_PASSWORD_LENGTH) {
+ throw new Gems_Exception(sprintf($this->translated->_('The password for the super user should be at least %s characters long on production systems.'), self::MIN_PASSWORD_LENGTH));
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns true if the role of this user has the given privilege.
+ *
+ * @param string $privilege
+ * @return bool
+ */
+ public function hasPrivilege($privilege)
+ {
+ // Overloaded!!
+ //
+ // Return true also for any not 'nologin' privilege
+ return parent::hasPrivilege($privilege) || (! $this->acl) || (! $this->acl->isAllowed('nologin', null, $privilege));
+ }
+
+ /**
+ * Intialize the values for this user.
+ *
+ * Skipped when the user is the active user and is stored in the session.
+ *
+ * @param string $login_name
+ * @param int $organization Only used when more than one organization uses this $login_name
+ * @return boolean False when the object could not load.
+ */
+ protected function initVariables($login_name, $organization)
+ {
+ $this->setRole('super');
+ return true;
+ }
+
+}
Added: branches/newUser/classes/Gems/User/UserAbstract.php
===================================================================
--- branches/newUser/classes/Gems/User/UserAbstract.php (rev 0)
+++ branches/newUser/classes/Gems/User/UserAbstract.php 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,288 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage User
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
+ */
+
+/**
+ *
+ *
+ * @package Gems
+ * @subpackage User
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+abstract class Gems_User_UserAbstract extends Gems_Registry_TargetAbstract implements Gems_User_UserInterface
+{
+ /**
+ *
+ * @var string
+ */
+ private $_login_name;
+
+ /**
+ *
+ * @var int
+ */
+ private $_organization_id;
+
+ /**
+ *
+ * @var mixed ArrayObject or Zend_Session_Namespace
+ */
+ private $_vars;
+
+ /**
+ *
+ * @var MUtil_Acl
+ */
+ protected $acl;
+
+ /**
+ * The escort session.
+ *
+ * For compatibility reasons only.
+ *
+ * @var Zend_Session_Namespace
+ */
+ protected $session;
+
+ /**
+ *
+ * @param string $login_name
+ * @param int $organization Only used when more than one organization uses this $login_name
+ */
+ public function __construct($login_name, $organization)
+ {
+ $this->_login_name = $login_name;
+ $this->_organization_id = $organization;
+ }
+
+ /**
+ * Returns the session namespace containing user data.
+ *
+ * @staticvar Zend_Session_Namespace $session
+ * @return Zend_Session_Namespace
+ */
+ private static function _getSessionStore()
+ {
+ static $session;
+
+ if (! $session) {
+ $session = new Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.userdata', true);
+ }
+
+ return $session;
+ }
+
+ /**
+ * The store currently used.
+ *
+ * @return mixed ArrayObject or Zend_Session_Namespace
+ */
+ private function _getVariableStore()
+ {
+ $loginName = 'loginName';
+ $organizationId = 'organizationId';
+
+ if (! $this->_vars) {
+ $sessionStore = self::_getSessionStore();
+
+ if (isset($sessionStore->$loginName, $sessionStore->$organizationId) && ($sessionStore->$loginName == $this->_login_name) && ($sessionStore->$organizationId == $this->_organization_id)) {
+ $this->_vars = $sessionStore;
+ $this->_vars->__set($loginName, $this->_login_name);
+ $this->_vars->__set($organizationId, $this->_organization_id);
+ } else {
+ $this->_vars = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
+ $this->_vars->offsetSet($loginName, $this->_login_name);
+ $this->_vars->offsetSet($organizationId, $this->_organization_id);
+ }
+
+ }
+
+ return $this->_vars;
+ }
+
+ /**
+ * Should be called after answering the request to allow the Target
+ * to check if all required registry values have been set correctly.
+ *
+ * @return boolean False if required variables are missing.
+ */
+ public function checkRegistryRequestsAnswers()
+ {
+ if ($this->_getVariableStore() instanceof Zend_Session_Namespace) {
+ $init = true;
+ } else {
+ $init = $this->initVariables($this->_login_name, $this->_organization_id);
+ }
+
+ return $init && parent::checkRegistryRequestsAnswers();
+ }
+
+ /**
+ *
+ * @return string
+ */
+ protected function getLoginName()
+ {
+ return $this->_login_name;
+ }
+
+ /**
+ *
+ * @return int
+ */
+ protected function getOrganizationId()
+ {
+ return $this->_organization_id;
+ }
+
+ /**
+ * Returns the (current) role of this user.
+ *
+ * @return string
+ */
+ public function getRole()
+ {
+ return $this->getVar('user_role');
+ }
+
+ /**
+ * Get a value in whatever store is used by this object.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ protected function getVar($name)
+ {
+ $store = $this->_getVariableStore();
+
+ if ($store instanceof Zend_Session_Namespace) {
+ if ($store->__isset($name)) {
+ return $store->__get($name);
+ }
+ } else {
+ if ($store->offsetExists($name)) {
+ return $store->offsetSet($name);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the role of this user has the given privilege.
+ *
+ * @param string $privilege
+ * @return bool
+ */
+ public function hasPrivilege($privilege)
+ {
+ return (! $this->acl) || $this->acl->isAllowed($this->getRole(), null, $privilege);
+ }
+
+ /**
+ * Intialize the values for this user.
+ *
+ * Skipped when the user is the active user and is stored in the session.
+ *
+ * @param string $login_name
+ * @param int $organization Only used when more than one organization uses this $login_name
+ * @return boolean False when the object could not load.
+ */
+ abstract protected function initVariables($login_name, $organization);
+
+ /**
+ * Set this user as the current user.
+ *
+ * This means that the data about this user will be stored in a session.
+ *
+ * @return Gems_User_UserAbstract
+ */
+ public function setAsCurrentUser()
+ {
+ // Get the current variables
+ $oldStore = $this->_getVariableStore();
+
+ // When $oldStore is a Zend_Session_Namespace, then this user is already the current user.
+ if (! $oldStore instanceof Zend_Session_Namespace) {
+ $this->_vars = self::_getSessionStore();
+
+ // Clean up what is there now.
+ $this->_vars->unsetAll();
+ $this->session->unsetAll();
+
+ foreach ($oldStore as $name => $value) {
+ $this->_vars->__set($name, $value);
+ $this->session->__set($name, $value);
+ }
+
+ }
+
+ return $this;
+ }
+
+ /**
+ * Sets the (current) role of this user.
+ *
+ * @param string $value Role
+ * @return Gems_User_UserAbstract (continuation pattern)
+ */
+ protected function setRole($value)
+ {
+ $this->setVar('user_role', $value);
+
+ return $this;
+ }
+
+ /**
+ * Store a value in whatever store is used by this object.
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return Gems_User_UserAbstract (continuation pattern)
+ */
+ protected function setVar($name, $value)
+ {
+ $store = $this->_getVariableStore();
+
+ if ($store instanceof Zend_Session_Namespace) {
+ $store->__set($name, $value);
+ } else {
+ $store->offsetSet($name, $value);
+ }
+ return $this;
+ }
+}
Added: branches/newUser/classes/Gems/User/UserInterface.php
===================================================================
--- branches/newUser/classes/Gems/User/UserInterface.php (rev 0)
+++ branches/newUser/classes/Gems/User/UserInterface.php 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,60 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage User
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
+ */
+
+/**
+ *
+ *
+ * @package Gems
+ * @subpackage User
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+interface Gems_User_UserInterface
+{
+ /**
+ * Check that the password is correct for this user.
+ *
+ * @param string $password Unencrypted password
+ * @return boolean
+ */
+ public function checkPassword($password);
+
+ public function hasPrivilege($privilege);
+
+ public function setAsCurrentUser();
+}
Added: branches/newUser/classes/Gems/User/UserLoader.php
===================================================================
--- branches/newUser/classes/Gems/User/UserLoader.php (rev 0)
+++ branches/newUser/classes/Gems/User/UserLoader.php 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,85 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage User
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
+ */
+
+/**
+ * Loads users.
+ *
+ * @package Gems
+ * @subpackage User
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+class Gems_User_UserLoader extends Gems_Loader_TargetLoaderAbstract
+{
+ /**
+ * Allows sub classes of Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.
+ *
+ * @var string $cascade An optional subdirectory where this subclass always loads from.
+ */
+ protected $cascade = 'User';
+
+ /**
+ *
+ * @var ArrayObject
+ */
+ protected $project;
+
+
+ /**
+ *
+ * @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)
+ {
+ if ($this->isProjectUser($login_name)) {
+ return $this->loadProjectUser($login_name, $organization);
+ }
+ }
+
+ protected function isProjectUser($login_name)
+ {
+ return isset($this->project->admin['user']) && ($this->project->admin['user'] == $login_name);
+ }
+
+ protected function loadProjectUser($login_name, $organization)
+ {
+ return $this->_getClass('ProjectSuperUser', null, array($login_name, $organization));
+ }
+}
Added: branches/newUser/configs/db/tables/gems__users.10.sql
===================================================================
--- branches/newUser/configs/db/tables/gems__users.10.sql (rev 0)
+++ branches/newUser/configs/db/tables/gems__users.10.sql 2011-10-21 12:15:43 UTC (rev 123)
@@ -0,0 +1,31 @@
+
+-- Table containing the users that are allowed to login
+--
+CREATE TABLE if not exists gems__users (
+ gsu_id_user bigint unsigned not null,
+
+ gsu_login varchar(30) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null,
+ gsu_id_organization bigint not null references gems__organizations (gor_id_organization),
+
+ gsu_user_class varchar(30) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null,
+ gsu_active boolean not null default 1,
+
+ -- Common fields for standard 'store password in Gems' logins
+ -- Not every gsu_user_class will use them
+ gsu_password varchar(32) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null,
+ gsu_failed_logins int(11) unsigned not null default 0,
+ gsu_last_failed timestamp null,
+ gsu_reset_key varchar(64) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null,
+ gsu_reset_requested timestamp null,
+ gsu_reset_required boolean not null default 0,
+
+ gsu_changed timestamp not null default current_timestamp on update current_timestamp,
+ gsu_changed_by bigint unsigned not null,
+ gsu_created timestamp not null,
+ gsu_created_by bigint unsigned not null,
+
+ PRIMARY KEY(gsu_id_user),
+ UNIQUE(gsu_login, gsu_id_organization)
+ )
+ ENGINE=InnoDB
+ CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gem...@li...> - 2011-10-21 12:29:46
|
Revision: 124
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=124&view=rev
Author: matijsdejong
Date: 2011-10-21 12:29:37 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
Merge from trunk r144-r122
Revision Links:
--------------
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=144&view=rev
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=122&view=rev
Modified Paths:
--------------
branches/newUser/classes/Gems/Default/MailLogAction.php
branches/newUser/classes/Gems/Default/ProjectInformationAction.php
branches/newUser/classes/Gems/Default/SourceAction.php
branches/newUser/classes/Gems/Menu/MenuAbstract.php
branches/newUser/classes/Gems/Menu/SubMenuItem.php
branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php
branches/newUser/classes/Gems/Tracker/Survey.php
branches/newUser/classes/Gems/Tracker.php
branches/newUser/classes/Gems/Util/DatabasePatcher.php
branches/newUser/classes/GemsEscort.php
branches/newUser/classes/MUtil/Controller/ModelSnippetActionAbstract.php
branches/newUser/classes/MUtil/Snippets/ModelTableSnippetAbstract.php
branches/newUser/configs/db/patches.sql
branches/newUser/configs/db/tables/gems__mail_jobs.300.sql
branches/newUser/configs/db/tables/gems__reception_codes.10.sql
branches/newUser/configs/db/tables/gems__roles.20.sql
branches/newUser/configs/db/tables/gems__surveys.30.sql
branches/newUser/controllers/MailLogController.php
branches/newUser/languages/default-en.mo
branches/newUser/languages/default-en.po
branches/newUser/languages/default-nl.mo
branches/newUser/languages/default-nl.po
branches/newUser/snippets/Generic/ModelItemTableSnippet.php
branches/newUser/snippets/Generic/ModelTableSnippet.php
Added Paths:
-----------
branches/newUser/classes/Gems/Snippets/ModelTableSnippetGeneric.php
branches/newUser/snippets/Mail/
branches/newUser/snippets/Mail/Log/
branches/newUser/snippets/Mail/Log/MailLogBrowseSnippet.php
Removed Paths:
-------------
branches/newUser/classes/Gems/Default/MailLogActionOldStyle.php
branches/newUser/snippets/Mail/Log/
branches/newUser/snippets/Mail/Log/MailLogBrowseSnippet.php
Property Changed:
----------------
branches/newUser/
Property changes on: branches/newUser
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/library:114-122
Modified: branches/newUser/classes/Gems/Default/MailLogAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -37,10 +37,8 @@
*/
/**
- * Short description for class
+ * Controller for looking at mail activity
*
- * Long description for class (if any)...
- *
* @package Gems
* @subpackage Default
* @copyright Copyright (c) 2011 Erasmus MC
@@ -50,28 +48,12 @@
class Gems_Default_MailLogAction extends Gems_Controller_ModelSnippetActionAbstract
{
/**
- * Adds columns from the model to the bridge that creates the browse table.
+ * The snippets used for the autofilter action.
*
- * Adds a button column to the model, if such a button exists in the model.
- *
- * @param MUtil_Model_TableBridge $bridge
- * @param MUtil_Model_ModelAbstract $model
- * @rturn void
+ * @var mixed String or array of snippets name
*/
- public function addTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model)
- {
- if ($menuItem = $this->firstAllowedMenuItem('show')) {
- $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge));
- }
+ protected $autofilterSnippets = 'Mail_Log_MailLogBrowseSnippet';
- // Newline placeholder
- $br = MUtil_Html::create('br');
-
- $bridge->addMultiSort('grco_created', $br, 'respondent_name', $br, 'grco_address');
- $bridge->addMultiSort('grco_id_token', $br, 'assigned_by', $br, 'grco_sender');
- $bridge->addMultiSort('grco_topic');
- }
-
/**
* The automatically filtered result
*/
@@ -79,7 +61,6 @@
{
$filter = array('grco_organization' => $this->escort->getCurrentOrganization());
- $this->autofilterParameters['addTableColumns'] = array($this, 'addTableColumns');
$this->autofilterParameters['extraFilter'] = $filter;
$this->autofilterParameters['extraSort'] = array('grco_created' => SORT_DESC);
@@ -147,7 +128,6 @@
{
$this->html->h3($this->_('Mail Activity Log'));
- // MUtil_Echo::track($this->indexParameters);
parent::indexAction();
}
Deleted: branches/newUser/classes/Gems/Default/MailLogActionOldStyle.php
===================================================================
--- branches/newUser/classes/Gems/Default/MailLogActionOldStyle.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Default/MailLogActionOldStyle.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -1,150 +0,0 @@
-<?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.
- *
- * Short description of file
- *
- * @package Gems
- * @subpackage Default
- * @author Matijs de Jong <mj...@ma...>
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $
- */
-
-/**
- * Temprary class until Gems_Controller_ModelSnippetActionAbstract works
- *
- * @package Gems
- * @subpackage Default
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.4.2
- */
-class Gems_Default_MailLogActionOldStyle extends Gems_Controller_BrowseEditAction
-{
- public $sortKey = array('grco_created' => SORT_DESC);
-
- /**
- * Adds columns from the model to the bridge that creates the browse table.
- *
- * Adds a button column to the model, if such a button exists in the model.
- *
- * @param MUtil_Model_TableBridge $bridge
- * @param MUtil_Model_ModelAbstract $model
- * @rturn void
- */
- protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model)
- {
- if ($menuItem = $this->findAllowedMenuItem('show')) {
- $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge));
- }
-
- // Newline placeholder
- $br = MUtil_Html::create('br');
-
- $bridge->addMultiSort('grco_created', $br, 'respondent_name', $br, 'grco_address');
- $bridge->addMultiSort('grco_id_token', $br, 'assigned_by', $br, 'grco_sender');
- $bridge->addMultiSort('grco_topic');
- }
-
- /**
- * 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
- * parameter was added, because the most common use of action is a split between detailed
- * and summarized actions.
- *
- * @param boolean $detailed True when the current action is not in $summarizedActions.
- * @param string $action The current action.
- * @return MUtil_Model_ModelAbstract
- */
- public function createModel($detailed, $action)
- {
- $model = new Gems_Model_JoinModel('maillog', 'gems__log_respondent_communications');
-
- $model->addLeftTable('gems__respondents', array('grco_id_to' => 'grs_id_user'));
- $model->addLeftTable('gems__staff', array('grco_id_by' => 'gsf_id_user'));
- $model->addLeftTable('gems__mail_templates', array('grco_id_message' => 'gmt_id_message'));
-
- $model->addColumn(
- "TRIM(CONCAT(COALESCE(CONCAT(grs_last_name, ', '), '-, '), COALESCE(CONCAT(grs_first_name, ' '), ''), COALESCE(grs_surname_prefix, '')))",
- 'respondent_name');
- $model->addColumn(
- "CASE WHEN gems__staff.gsf_id_user IS NULL
- THEN '-'
- ELSE
- CONCAT(
- COALESCE(gems__staff.gsf_last_name, ''),
- ', ',
- COALESCE(gems__staff.gsf_first_name, ''),
- COALESCE(CONCAT(' ', gems__staff.gsf_surname_prefix), '')
- )
- END",
- 'assigned_by');
-
- $model->resetOrder();
-
- $model->set('grco_created', 'label', $this->_('Date sent'));
- $model->set('respondent_name', 'label', $this->_('Receiver'));
- $model->set('grco_address', 'label', $this->_('To address'), 'itemDisplay', 'MUtil_Html_AElement::ifmail');
- $model->set('assigned_by', 'label', $this->_('Sender'));
- $model->set('grco_sender', 'label', $this->_('From address'), 'itemDisplay', 'MUtil_Html_AElement::ifmail');
- $model->set('grco_id_token', 'label', $this->_('Token'));
- $model->set('grco_topic', 'label', $this->_('Subject'));
-
- if ($detailed) {
- $model->set('gmt_subject', 'label', $this->_('Template'));
- } else {
- $model->set('grco_created', 'formatFunction', $this->util->getTranslated()->formatDate);
- }
-
- return $model;
- }
-
- /**
- * Helper function to allow generalized statements about the items in the model.
- *
- * @param int $count
- * @return $string
- */
- public function getTopic($count = 1)
- {
- return $this->plural('Activity Log', 'Activity Logs', $count);
- }
-
-
- /**
- * Helper function to allow generalized treatment of the header.
- *
- * return $string
- */
- public function getTopicTitle()
- {
- return $this->_('Mail Activity Log');
- }
-}
Modified: branches/newUser/classes/Gems/Default/ProjectInformationAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -45,6 +45,18 @@
*/
class Gems_Default_ProjectInformationAction extends Gems_Controller_Action
{
+ /**
+ *
+ * @var GemsEscort
+ */
+ public $escort;
+
+ /**
+ *
+ * @var Gems_Menu
+ */
+ public $menu;
+
public $useHtmlView = true;
protected function _showTable($caption, $data, $nested = false)
@@ -132,18 +144,40 @@
$data[$this->_('Server OS')] = php_uname('s');
$data[$this->_('Time on server')] = date('r');
+ if (file_exists($this->escort->getMaintenanceLockFilename())) {
+ $label = $this->_('Turn Maintenance Mode OFF');
+ } else {
+ $label = $this->_('Turn Maintenance Mode ON');
+ }
+ $request = $this->getRequest();
+ $buttonList = $this->menu->getMenuList();
+ $buttonList->addParameterSources($request)
+ ->addByController($request->getControllerName(), 'maintenance', $label);
+
+ // $this->html->buttonDiv($buttonList);
+
$this->_showTable($this->_('Version information'), $data);
+
+ $this->html->buttonDiv($buttonList);
}
public function maintenanceAction()
{
- $lockFile = GEMS_ROOT_DIR . '/var/settings/lock.txt';
- if(file_exists($lockFile)) {
+ $lockFile = $this->escort->getMaintenanceLockFilename();
+ if (file_exists($lockFile)) {
unlink($lockFile);
} else {
touch($lockFile);
}
- $this->_forward('index');
+
+ // Dump the existing maintenance mode messages.
+ $this->escort->getMessenger()->clearCurrentMessages();
+ $this->escort->getMessenger()->clearMessages();
+ MUtil_Echo::out();
+
+ // Redirect
+ $request = $this->getRequest();
+ $this->_reroute(array($request->getActionKey() => 'index'));
}
public function phpAction()
Modified: branches/newUser/classes/Gems/Default/SourceAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/SourceAction.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Default/SourceAction.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -76,14 +76,14 @@
}
$bridge->addHidden('gso_id_source');
- $bridge->addText('gso_source_name', array('size' => 15, 'minlength' => 4));
+ $bridge->addText('gso_source_name', 'description', $this->_('E.g. the name of the project - for single source projects.'), 'size', 15, 'minlength', 4);
$bridge->addValidator('gso_source_name', $model->createUniqueValidator('gso_source_name'));
- $bridge->addText('gso_ls_url', array('size' => 50));
+ $bridge->addText('gso_ls_url', 'description', $this->_('For creating token-survey url.'), 'size', 50);
$bridge->addValidator('gso_ls_url', $model->createUniqueValidator('gso_ls_url'));
$bridge->addValidator('gso_ls_url', new MUtil_Validate_Url());
$bridge->addSelect('gso_ls_class');
- $bridge->addSelect('gso_ls_adapter');
+ $bridge->addSelect('gso_ls_adapter', 'description', $this->_('The database server used by the source.'));
$bridge->addText('gso_ls_table_prefix', array('size' => 15, 'description' => $this->_('Do not forget the underscores.')));
$bridge->addText('gso_ls_dbhost', array('size' => 15, 'description' => $in_gems));
@@ -140,15 +140,16 @@
$model = new MUtil_Model_TableModel('gems__sources');
$model->set('gso_source_name', 'label', $this->_('Name'));
- $model->set('gso_ls_url', 'label', $this->_('Url'), 'default', 'http://');
+ $model->set('gso_ls_url', 'label', $this->_('Source Url'), 'default', 'http://');
$model->set('gso_ls_class', 'label', $this->_('Adaptor class'), 'multiOptions', $tracker->getSourceClasses());
if ($detailed) {
- $model->set('gso_ls_adapter', 'label', $this->_('DB Adaptor'), 'multiOptions', $tracker->getSourceDatabaseClasses());
+ $model->set('gso_ls_adapter', 'label', $this->_('Database Server'), 'multiOptions', $tracker->getSourceDatabaseClasses(), 'default', substr(get_class($this->db), strlen('Zend_Db_Adapter_')));
$model->set('gso_ls_dbhost', 'label', $this->_('Database host'));
$model->set('gso_ls_database', 'label', $this->_('Database'));
}
+
$model->set('gso_ls_table_prefix', 'label', $this->_('Table prefix'), 'default', 'ls__');
$model->set('gso_active', 'default', 0);
Modified: branches/newUser/classes/Gems/Menu/MenuAbstract.php
===================================================================
--- branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -230,7 +230,7 @@
// MAIL ACTIVITY CONTROLLER
//$setup->addBrowsePage();
- $page = $setup->addPage($this->_('Activity'), 'pr.mail.log', 'mail-log');
+ $page = $setup->addPage($this->_('Activity log'), 'pr.mail.log', 'mail-log');
$page->addAutofilterAction();
$page->addExcelAction();
$page->addShowAction();
@@ -300,7 +300,7 @@
$page->addAction($this->_('PHP'), null, 'php');
$page->addAction($this->_('Project'), null, 'project');
$page->addAction($this->_('Session'), null, 'session');
- $page->addAction($this->_('Maintenance mode'), 'pr.maintenance', 'maintenance');
+ $page->addButtonOnly($this->_('Maintenance mode'), 'pr.maintenance', 'project-information', 'maintenance');
return $page;
}
Modified: branches/newUser/classes/Gems/Menu/SubMenuItem.php
===================================================================
--- branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -551,11 +551,12 @@
return $menu;
}
- public function applyHiddenParameters(Gems_Menu_ParameterSource $source)
+ public function applyHiddenParameters(Zend_Controller_Request_Abstract $request, Gems_Menu_ParameterSource $source)
{
if ($this->_hiddenParameters) {
- foreach ($this->_hiddenParameters as $key => $name) {
- $source[$key] = $name;
+ foreach ($this->_hiddenParameters as $key => $value) {
+ $request->setParam($key, $value);
+ $source[$key] = $value;
}
}
Modified: branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php
===================================================================
--- branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -103,6 +103,24 @@
protected $sortParamDesc = 'dsrt';
/**
+ * Adds columns from the model to the bridge that creates the browse table.
+ *
+ * Overrule this function to add different columns to the browse table, without
+ * having to recode the core table building code.
+ *
+ * @param MUtil_Model_TableBridge $bridge
+ * @param MUtil_Model_ModelAbstract $model
+ * @return void
+ */
+ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model)
+ {
+ // make sure search results are highlighted
+ $this->applyTextMarker();
+
+ return parent::addBrowseTableColumns($bridge, $model);
+ }
+
+ /**
* Add the paginator panel to the table.
*
* Only called when $this->browse is true. Overrule this function
@@ -116,6 +134,30 @@
}
/**
+ * Make sure generic search text results are marked
+ *
+ * @return void
+ */
+ protected function applyTextMarker()
+ {
+ $model = $this->getModel();
+
+ $textKey = $model->getTextFilter();
+ $filter = $model->getFilter();
+
+ if (isset($filter[$textKey])) {
+ $searchText = $filter[$textKey];
+ // MUtil_Echo::r('[' . $searchText . ']');
+ $marker = new MUtil_Html_Marker($model->getTextSearches($searchText), 'strong', 'UTF-8');
+ foreach ($model->getItemNames() as $name) {
+ if ($model->get($name, 'label')) {
+ $model->set($name, 'markCallback', array($marker, 'mark'));
+ }
+ }
+ }
+ }
+
+ /**
* Should be called after answering the request to allow the Target
* to check if all required registry values have been set correctly.
*
@@ -204,7 +246,7 @@
$data = $this->requestCache->getProgramParams();
$model->applyParameters($data);
-
+
} else {
parent::processFilterAndSort($model);
}
Copied: branches/newUser/classes/Gems/Snippets/ModelTableSnippetGeneric.php (from rev 122, trunk/library/classes/Gems/Snippets/ModelTableSnippetGeneric.php)
===================================================================
--- branches/newUser/classes/Gems/Snippets/ModelTableSnippetGeneric.php (rev 0)
+++ branches/newUser/classes/Gems/Snippets/ModelTableSnippetGeneric.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -0,0 +1,94 @@
+<?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.
+ *
+ *
+ * @package MUtil
+ * @subpackage Snippets
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id$
+ */
+
+/**
+ * Displays multiple items from a model in a tabel by row using
+ * the model set through the $model snippet parameter.
+ *
+ * If you want to use this class "as is" use the 'Generic_ModelTableSnippet' snippet.
+ *
+ * This class is not in the standard snippet loading directories and does not follow
+ * their naming conventions, but exists only to make it simple to extend this class
+ * for a specific implementation.
+ *
+ * @package MUtil
+ * @subpackage Snippets
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.4.4
+ */
+class Gems_Snippets_ModelTableSnippetGeneric extends Gems_Snippets_ModelTableSnippetAbstract
+{
+ /**
+ *
+ * @var MUtil_Model_ModelAbstract
+ */
+ protected $model;
+
+ /**
+ *
+ * @var Gems_Util
+ */
+ protected $util;
+
+ /**
+ * Automatically add request cacge
+ *
+ * Should be called after answering the request to allow the Target
+ * to check if all required registry values have been set correctly.
+ *
+ * @return boolean False if required are missing.
+ */
+ public function checkRegistryRequestsAnswers()
+ {
+ if ($this->util && (! $this->requestCache)) {
+ $this->requestCache = $this->util->getRequestCache();
+ }
+
+ return parent::checkRegistryRequestsAnswers();
+ }
+
+ /**
+ * Creates the model
+ *
+ * @return MUtil_Model_ModelAbstract
+ */
+ protected function createModel()
+ {
+ return $this->model;
+ }
+}
Modified: branches/newUser/classes/Gems/Tracker/Survey.php
===================================================================
--- branches/newUser/classes/Gems/Tracker/Survey.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Tracker/Survey.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -104,6 +104,26 @@
}
/**
+ * Makes sure the receptioncode data is part of the $this->_gemsData
+ *
+ * @param boolean $reload Optional parameter to force reload.
+ */
+ private function _ensureGroupData($reload = false)
+ {
+ if ($reload || (! isset($this->_gemsSurvey['ggp_id_group']))) {
+ $sql = "SELECT * FROM gems__groups WHERE ggp_id_group = ?";
+ $code = $this->_gemsSurvey['gsu_id_primary_group'];
+
+ if ($row = $this->db->fetchRow($sql, $code)) {
+ $this->_gemsSurvey = $row + $this->_gemsSurvey;
+ } else {
+ $name = $this->getName();
+ throw new Gems_Exception("Group code $code is missing for survey '$name'.");
+ }
+ }
+ }
+
+ /**
* Update the survey, both in the database and in memory.
*
* @param array $values The values that this token should be set to
@@ -466,6 +486,20 @@
}
/**
+ * Should this survey be filled in by staff members.
+ *
+ * @return boolean
+ */
+ public function isTakenByStaff()
+ {
+ if (! isset($this->_gemsSurvey['ggp_staff_members'])) {
+ $this->_ensureGroupData();
+ }
+
+ return (boolean) $this->_gemsSurvey['ggp_staff_members'];
+ }
+
+ /**
* Update the survey, both in the database and in memory.
*
* @param array $values The values that this token should be set to
Modified: branches/newUser/classes/Gems/Tracker.php
===================================================================
--- branches/newUser/classes/Gems/Tracker.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Tracker.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -73,7 +73,7 @@
* @var array Of classname => description
*/
protected $_sourceClasses = array(
- 'LimeSurvey1m9Database' => 'Lime Survey 1.90 DB',
+ 'LimeSurvey1m9Database' => 'Lime Survey 1.90 DB',
'LimeSurvey1m91Database' => 'Lime Survey 1.91+ DB',
);
@@ -114,29 +114,29 @@
private $_trackEngines = array();
/**
+ * Allows sub classes of Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.
*
- * @var Zend_Translate
+ * @var string $cascade An optional subdirectory where this subclass always loads from.
*/
- protected $translate;
+ protected $cascade = 'Tracker';
/**
*
- * @var Zend_Session
+ * @var Zend_Db_Adapter_Abstract
*/
- protected $session;
+ protected $db;
/**
- * Allows sub classes of Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.
*
- * @var string $cascade An optional subdirectory where this subclass always loads from.
+ * @var Zend_Translate
*/
- protected $cascade = 'Tracker';
+ protected $translate;
/**
*
- * @var Zend_Db_Adapter_Abstract
+ * @var Zend_Session
*/
- protected $db;
+ protected $session;
/**
* Set to true to get detailed information on all tracker actions
@@ -413,12 +413,18 @@
// TODO: this should be moved to Gems_Tracker_Source_SourceInterface,
// but do not have time to implement is of minor importance at this moment.
- return array(
- '' => '-- none --',
- 'Mysqli' => 'MySQL',
- 'Pdo_Mysql' => 'MySQL (PDO)',
- 'Sqlsrv' => 'SQL Server',
- 'Pdo_Mssql' => 'SQL Server (PDO)');
+ // If the project uses Pdo database, use Pdo classes, otherwise MySQL
+ if (stripos(get_class($this->db), '_Pdo_')) {
+ return array(
+ '' => '-- none --',
+ 'Pdo_Mysql' => 'MySQL (PDO)',
+ 'Pdo_Mssql' => 'SQL Server (PDO)');
+ } else {
+ return array(
+ '' => '-- none --',
+ 'Mysqli' => 'MySQL',
+ 'Sqlsrv' => 'SQL Server');
+ }
}
/**
Modified: branches/newUser/classes/Gems/Util/DatabasePatcher.php
===================================================================
--- branches/newUser/classes/Gems/Util/DatabasePatcher.php 2011-10-21 12:15:43 UTC (rev 123)
+++ branches/newUser/classes/Gems/Util/DatabasePatcher.php 2011-10-21 12:29:37 UTC (rev 124)
@@ -1,43 +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 ...
[truncated message content] |
|
From: <gem...@li...> - 2011-10-25 15:58:11
|
Revision: 140
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=140&view=rev
Author: matijsdejong
Date: 2011-10-25 15:58:01 +0000 (Tue, 25 Oct 2011)
Log Message:
-----------
Brought up to date with revisions up to 139
Modified Paths:
--------------
branches/newUser/changelog.txt
branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php
branches/newUser/classes/Gems/Default/DatabaseAction.php
branches/newUser/classes/Gems/Default/IndexAction.php
branches/newUser/classes/Gems/Default/MailLogAction.php
branches/newUser/classes/Gems/Default/ProjectInformationAction.php
branches/newUser/classes/Gems/Default/RoleAction.php
branches/newUser/classes/Gems/Default/StaffAction.php
branches/newUser/classes/Gems/Email/EmailFormAbstract.php
branches/newUser/classes/Gems/Email/MultiMailForm.php
branches/newUser/classes/Gems/Email/TemplateMailer.php
branches/newUser/classes/Gems/Menu/MenuAbstract.php
branches/newUser/classes/Gems/Menu.php
branches/newUser/classes/Gems/Roles.php
branches/newUser/classes/Gems/Snippets/ModelFormSnippetAbstract.php
branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php
branches/newUser/classes/Gems/Tracker/Engine/StepEngineAbstract.php
branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php
branches/newUser/classes/Gems/Util/DbLookup.php
branches/newUser/classes/Gems/Util/Translated.php
branches/newUser/classes/Gems/Util.php
branches/newUser/classes/GemsEscort.php
branches/newUser/classes/MUtil/Controller/ModelSnippetActionAbstract.php
branches/newUser/classes/MUtil/Snippets/ModelFormSnippetAbstract.php
branches/newUser/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php
branches/newUser/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php
branches/newUser/configs/db/patches.sql
branches/newUser/configs/db/tables/gems__mail_jobs.300.sql
branches/newUser/controllers/EmailController.php
branches/newUser/languages/default-en.mo
branches/newUser/languages/default-en.po
branches/newUser/languages/default-nl.mo
branches/newUser/languages/default-nl.po
branches/newUser/snippets/Generic/ModelItemTableSnippet.php
branches/newUser/snippets/Mail/Log/MailLogBrowseSnippet.php
Added Paths:
-----------
branches/newUser/classes/Gems/Default/CronAction.php
branches/newUser/classes/Gems/Default/MailJobAction.php
branches/newUser/classes/Gems/Default/MailTemplateAction.php
branches/newUser/classes/Gems/Snippets/ModelFormSnippetGeneric.php
branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php
branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php
branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php
branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php
branches/newUser/classes/Gems/Util/LockFile.php
branches/newUser/classes/MUtil/Mail/
branches/newUser/classes/MUtil/Mail/Transport/
branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php
branches/newUser/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php
branches/newUser/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php
branches/newUser/controllers/CronController.php
branches/newUser/controllers/MailJobController.php
branches/newUser/controllers/MailTemplateController.php
branches/newUser/snippets/Generic/ModelFormSnippet.php
branches/newUser/snippets/Generic/ModelItemYesNoDeleteSnippet.php
Removed Paths:
-------------
branches/newUser/classes/Gems/Default/EmailAction.php
branches/newUser/classes/Gems/Default/MailAction.php
branches/newUser/classes/MUtil/Mail/Transport/
branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php
branches/newUser/controllers/MailController.php
Property Changed:
----------------
branches/newUser/
Property changes on: branches/newUser
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/library:114-122
+ /trunk/library:114-122,125-139
Modified: branches/newUser/changelog.txt
===================================================================
--- branches/newUser/changelog.txt 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/changelog.txt 2011-10-25 15:58:01 UTC (rev 140)
@@ -1,3 +1,8 @@
+Important changes from 1.4.3 => 1.5
+============================================================
+MailController is now called MailTemplateController
+EmailController is now called CronController (with stub for compatibility)
+
Important changes from 1.4.2 => 1.4.3
============================================================
* gtr_organisations renamed to gtr_organizations
Modified: branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php
===================================================================
--- branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -26,7 +26,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Short description of file
*
* @package Gems
* @subpackage Controller
@@ -37,10 +36,8 @@
*/
/**
- * Short description for class
+ * Class contains Gems specific adaptations to parent class.
*
- * Long description for class (if any)...
- *
* @package Gems
* @subpackage Controller
* @copyright Copyright (c) 2011 Erasmus MC
@@ -50,12 +47,6 @@
abstract class Gems_Controller_ModelSnippetActionAbstract extends MUtil_Controller_ModelSnippetActionAbstract
{
/**
- *
- * @var GemsEscort
- */
- public $escort;
-
- /**
* The parameters used for the autofilter action.
*
* @var array Mixed key => value array for snippet initialization
@@ -74,6 +65,32 @@
protected $autofilterSnippets = 'Generic_ModelTableSnippet';
/**
+ * The snippets used for the create and edit actions.
+ *
+ * @var mixed String or array of snippets name
+ */
+ protected $createEditSnippets = 'Generic_ModelFormSnippet';
+
+ /**
+ * The snippets used for the delete action.
+ *
+ * @var mixed String or array of snippets name
+ */
+ protected $deleteSnippets = 'Generic_ModelItemYesNoDeleteSnippet';
+
+ /**
+ *
+ * @var GemsEscort
+ */
+ public $escort;
+
+ /**
+ *
+ * @var Gems_Menu
+ */
+ public $menu;
+
+ /**
* The snippets used for the index action, before those in autofilter
*
* @var mixed String or array of snippets name
Copied: branches/newUser/classes/Gems/Default/CronAction.php (from rev 139, trunk/library/classes/Gems/Default/CronAction.php)
===================================================================
--- branches/newUser/classes/Gems/Default/CronAction.php (rev 0)
+++ branches/newUser/classes/Gems/Default/CronAction.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -0,0 +1,252 @@
+<?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 Michiel Rook <mi...@to...>
+ * @package Gems
+ * @subpackage Default
+ */
+
+/**
+ * Performs bulk-mail action, can be called from a cronjob
+ *
+ * @author Michiel Rook <mi...@to...>
+ * @package Gems
+ * @subpackage Default
+ */
+class Gems_Default_CronAction extends MUtil_Controller_Action
+{
+ /**
+ *
+ * @var Zend_Db_Adapter_Abstract
+ */
+ public $db;
+
+ /**
+ * Standard filter that must be true for every token query.
+ *
+ * @var array
+ */
+ protected $defaultFilter = array(
+ 'can_email' => 1,
+ 'gtr_active' => 1,
+ 'gsu_active' => 1,
+ 'grc_success' => 1,
+ 'gto_completion_time' => NULL,
+ 'gto_valid_from <= CURRENT_DATE',
+ '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)'
+ );
+
+ /**
+ *
+ * @var GemsEscort
+ */
+ public $escort;
+
+ /**
+ *
+ * @var Gems_Menu
+ */
+ public $menu;
+
+ /**
+ *
+ * @var Zend_Session_Namespace
+ */
+ public $session;
+
+ /**
+ * Set to true in child class for automatic creation of $this->html.
+ *
+ * Otherwise call $this->initHtml()
+ *
+ * @var boolean $useHtmlView
+ */
+ public $useHtmlView = true;
+
+ /**
+ *
+ * @var Gems_Util
+ */
+ public $util;
+
+ /**
+ * Action that switches the cron job lock on or off.
+ */
+ public function cronLockAction()
+ {
+ // Switch lock
+ $this->util->getCronJobLock()->reverse();
+
+ // Redirect
+ $request = $this->getRequest();
+ $this->_reroute($this->menu->getCurrentParent()->toRouteUrl());
+ }
+
+ /**
+ * Loads an e-mail template
+ *
+ * @param integer|null $templateId
+ */
+ protected function getTemplate($templateId)
+ {
+ return $this->db->fetchRow('SELECT * FROM gems__mail_templates WHERE gmt_id_message = ?', $templateId);
+ }
+
+ /**
+ * Returns the login name belonging to this user.
+ *
+ * @param int $userId
+ * @return string
+ */
+ protected function getUserLogin($userId)
+ {
+ return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId);
+ }
+
+ public function indexAction()
+ {
+ $this->initHtml();
+
+ if ($this->util->getCronJobLock()->isLocked()) {
+ $this->html->append($this->_('Cron jobs turned off.'));
+ } else {
+ $this->mailJob();
+ }
+ }
+
+ public function mailJob()
+ {
+ // Test: update `gems__tokens` set `gto_mail_sent_date` = null where `gto_mail_sent_date` > '2011-10-23'
+
+ $currentUser = isset($this->session->user_login) ? $this->session->user_login : null;
+
+ $model = $this->loader->getTracker()->getTokenModel();
+ $mailer = new Gems_Email_TemplateMailer($this->escort);
+ // $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog());
+
+ $jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1");
+
+ if ($jobs) {
+ foreach ($jobs as $job) {
+ $this->escort->loadLoginInfo($this->getUserLogin($job['gmj_id_user_as']));
+
+ // Set up filter
+ $filter = $this->defaultFilter;
+ if ($job['gmj_filter_mode'] == 'R') {
+ $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $job['gmj_filter_days_between'] . ' DAY)';
+ } else {
+ $filter['gto_mail_sent_date'] = NULL;
+ }
+ if ($job['gmj_id_organization']) {
+ $filter['gto_id_organization'] = $job['gmj_id_organization'];
+ }
+ if ($job['gmj_id_track']) {
+ $filter['gto_id_track'] = $job['gmj_id_track'];
+ }
+ if ($job['gmj_id_survey']) {
+ $filter['gto_id_survey'] = $job['gmj_id_survey'];
+ }
+
+ $tokensData = $model->load($filter);
+
+ if (count($tokensData)) {
+ $mailer->setMethod($job['gmj_process_method']);
+ if ($job['gmj_from_method'] == 'F') {
+ $mailer->setFrom($job['gmj_from_fixed']);
+ } else {
+ $mailer->setFrom($job['gmj_from_method']);
+ }
+
+ $templateData = $this->getTemplate($job['gmj_id_message']);
+ $mailer->setSubject($templateData['gmt_subject']);
+ $mailer->setBody($templateData['gmt_body']);
+
+ $mailer->setTokens(MUtil_Ra::column('gto_id_token', $tokensData));
+ $mailer->process($tokensData);
+ }
+
+ Gems_Auth::getInstance()->clearIdentity();
+ $this->escort->session->unsetAll();
+ }
+ }
+
+ $msg = $mailer->getMessages();
+ if (! $msg) {
+ $msg[] = $this->_('No mails sent');
+ }
+
+ $this->html->append($msg);
+
+ if ($currentUser) {
+ $this->escort->loadLoginInfo($currentUser);
+ } else {
+ $this->escort->afterLogout();
+ }
+
+ /*
+ if (isset($this->project->email['automatic'])) {
+ $batches = $this->project->email['automatic'];
+ $numBatches = count($batches['mode']);
+
+ for ($i = 0; $i < $numBatches; $i++) {
+ $this->_organizationId = $batches['organization'][$i];
+
+ if (isset($batches['days'][$i])) {
+ $this->_intervalDays = $batches['days'][$i];
+ }
+
+ $this->escort->loadLoginInfo($batches['user'][$i]);
+
+ $model->setFilter($this->getFilter($batches['mode'][$i]));
+
+ $tokensData = $model->load();
+
+ if (count($tokensData)) {
+ $tokens = array();
+
+ foreach ($tokensData as $tokenData) {
+ $tokens[] = $tokenData['gto_id_token'];
+ }
+
+ $templateData = $this->getTemplate($batches['template'][$i]);
+ $mailer->setSubject($templateData['gmt_subject']);
+ $mailer->setBody($templateData['gmt_body']);
+ $mailer->setMethod($batches['method'][$i]);
+ $mailer->setFrom($batches['from'][$i]);
+ $mailer->setTokens($tokens);
+
+ $mailer->process($tokensData);
+ }
+
+ Gems_Auth::getInstance()->clearIdentity();
+ $this->escort->session->unsetAll();
+ }
+ }
+ // */
+ }
+}
\ No newline at end of file
Modified: branches/newUser/classes/Gems/Default/DatabaseAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -93,6 +93,18 @@
}
/**
+ * Set the parameters needed by the menu.
+ *
+ * @param array $data The current model item
+ */
+ private function _setMenuParameters(array $data)
+ {
+ $source = $this->menu->getParameterSource();
+ $source['script'] = $data['script'] ? true : false;
+ $source['exists'] = $data['exists'] ? true : false;
+ }
+
+ /**
* Adds elements from the model to the bridge that creates the form.
*
* Overrule this function to add different elements to the browse table, without
@@ -180,6 +192,8 @@
$model = $this->getModel();
$data = $model->applyRequest($this->getRequest())->loadFirst();
+ $this->_setMenuParameters($data);
+
if (! ($data && isset($data['exists']) && $data['exists'])) {
$this->addMessage($this->_('This database object does not exist. You cannot delete it.'));
$this->html->buttonDiv($this->createMenuLinks(1));
@@ -438,6 +452,8 @@
$model = $this->getModel();
$data = $model->loadFirst();
+ $this->_setMenuParameters($data);
+
if (! ($data && isset($data['exists'], $data['script']) && ($data['exists'] || $data['script']))) {
$this->addMessage($this->_('This database object does not exist. You cannot create it.'));
$this->html->buttonDiv($this->createMenuLinks(1));
@@ -580,9 +596,9 @@
$model = $this->getModel();
$data = $model->loadFirst();
- $source = $this->menu->getParameterSource();
- $source['script'] = $data['script'];
- $source['exists'] = $data['exists'];
+ if ($data) {
+ $this->_setMenuParameters($data);
+ }
parent::showAction();
}
@@ -592,6 +608,8 @@
$model = $this->getModel();
$data = $model->loadFirst();
+ $this->_setMenuParameters($data);
+
if (! ($data && isset($data['exists']) && $data['exists'])) {
$this->addMessage($this->_('This database object does not exist. You cannot view it.'));
$this->html->buttonDiv($this->createMenuLinks(1));
Deleted: branches/newUser/classes/Gems/Default/EmailAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -1,135 +0,0 @@
-<?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 Michiel Rook <mi...@to...>
- * @package Gems
- * @subpackage Default
- */
-
-/**
- * Performs bulk-mail action, can be called from a cronjob
- *
- * @author Michiel Rook <mi...@to...>
- * @package Gems
- * @subpackage Default
- */
-class Gems_Default_EmailAction extends Gems_Default_TokenPlanAction
-{
- private $_organizationId = null;
- private $_intervalDays = 7;
-
- /**
- * Constructs
- * @param strings $mode Either 'notmailed' or 'reminder'
- */
- protected function getFilter($mode = null)
- {
- $filter = array(
- 'can_email' => 1,
- 'gto_id_organization' => $this->_organizationId,
- 'gtr_active' => 1,
- 'gsu_active' => 1,
- 'grc_success' => 1,
- 'gto_completion_time' => NULL,
- '`gto_valid_from` >= DATE_ADD(CURRENT_DATE, INTERVAL -4 WEEK)',
- '`gto_valid_from` <= DATE_ADD(CURRENT_DATE, INTERVAL 2 WEEK)',
- '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)'
- );
-
- if (isset($mode) && $mode == 'reminder') {
- $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $this->_intervalDays . ' DAY)';
- } else {
- $filter['gto_mail_sent_date'] = NULL;
- }
-
- return $filter;
- }
-
- /**
- * Loads an e-mail template
- * @param integer|null $templateId
- */
- protected function getTemplate($templateId)
- {
- $model = new MUtil_Model_TableModel('gems__mail_templates');
-
- return $model->loadFirst(array('gmt_id_message' => $templateId));
- }
-
- public function indexAction()
- {
- $this->initHtml();
-
- $model = $this->loader->getTracker()->getTokenModel();
- $model->setCreate(false);
-
- $mailer = new Gems_Email_TemplateMailer($this->escort);
-
- if (isset($this->project->email['automatic'])) {
- $batches = $this->project->email['automatic'];
- $numBatches = count($batches['mode']);
-
- for ($i = 0; $i < $numBatches; $i++) {
- $this->_organizationId = $batches['organization'][$i];
-
- if (isset($batches['days'][$i])) {
- $this->_intervalDays = $batches['days'][$i];
- }
-
- $this->escort->loadLoginInfo($batches['user'][$i]);
-
- $model->setFilter($this->getFilter($batches['mode'][$i]));
-
- $tokensData = $model->load();
-
- if (count($tokensData)) {
- $tokens = array();
-
- foreach ($tokensData as $tokenData) {
- $tokens[] = $tokenData['gto_id_token'];
- }
-
- $templateData = $this->getTemplate($batches['template'][$i]);
- $mailer->setSubject($templateData['gmt_subject']);
- $mailer->setBody($templateData['gmt_body']);
- $mailer->setMethod($batches['method'][$i]);
- $mailer->setFrom($batches['from'][$i]);
- $mailer->setTokens($tokens);
-
- $mailer->process($tokensData);
- }
-
- Gems_Auth::getInstance()->clearIdentity();
- $this->escort->session->unsetAll();
- }
- }
-
- $this->html->append($mailer->getMessages());
-
- }
-}
\ No newline at end of file
Modified: branches/newUser/classes/Gems/Default/IndexAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -61,6 +61,11 @@
public $escort;
/**
+ * @var Gems_Menu
+ */
+ public $menu;
+
+ /**
* Extension point, use different auth adapter if needed depending on the provided formValues
*
* This could be an organization passed in the login-form or something else.
@@ -150,8 +155,17 @@
public function loginAction()
{
+ /**
+ * If already logged in, try to redirect to the first allowed and visible menu item
+ * if that fails, try to reroute to respondent/index
+ */
if (isset($this->session->user_id)) {
- $this->_reroute(array('controller' => 'respondent'));
+ if ($menuItem = $this->menu->findFirst(array('allowed' => true, 'visible' => true))) {
+ $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
+ $redirector->gotoRoute($menuItem->toRouteUrl($this->getRequest()));
+ } else {
+ $this->_reroute(array('controller' => 'respondent', 'action'=>'index'));
+ }
}
// MUtil_Echo::track(get_class($this->loader->getUser('super', null)));
@@ -168,10 +182,10 @@
$this->session->user_id = 2000;
$this->session->user_name = $_POST['userlogin'];
$this->session->user_group = 800;
- $this->session->user_role = 'super';
+ $this->session->user_role = 'master';
$this->session->user_organization_id = 70;
$this->session->user_organization_name = 'SUPER ADMIN';
- $this->session->user_style = 'pulse';
+ $this->session->user_style = 'gems';
//Als er nog geen tabellen zijn, moet dit ingesteld worden
//@@TODO Nog kijken hoe beter op te lossen (met try op tabel ofzo)
$this->session->allowedOrgs = array($this->session->user_organization_id=>$this->session->user_organization_name);
Deleted: branches/newUser/classes/Gems/Default/MailAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:34:11 UTC (rev 139)
+++ branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:58:01 UTC (rev 140)
@@ -1,130 +0,0 @@
-<?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.
- *
- * @package Gems
- * @subpackage Default
- * @author Matijs de Jong <mj...@ma...>
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @version $Id$
- */
-
-/**
- *
- * @package Gems
- * @subpackage Default
- * @copyright Copyright (c) 2011 Erasmus MC
- * @license New BSD License
- * @since Class available since version 1.1
- */
-class Gems_Default_MailAction extends Gems_Controller_BrowseEditAction
-{
- /**
- * 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
- * parameter was added, because the most common use of action is a split between detailed
- * and summarized actions.
- *
- * @param boolean $detailed True when the current action is not in $summarizedActions.
- * @param string $action The current action.
- * $return MUtil_Model_ModelAbstract
- */
- public function createModel($detailed, $action)
- {
- $model = new MUtil_Model_TableModel('gems__mail_templates');
- $model->set('gmt_subject', 'label', $this->_('Subject'));
-
- if ($detailed) {
- $model->set('gmt_body',
- 'label', $this->_('Message'),
- 'itemDisplay', array('Gems_Email_EmailFormAbstract', 'displayMailText'));
- }
-
- return $model;
- }
-
- public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data)
- {
- $elements = parent::getAutoSearchElements($model, $data);
- $options = array('' => $this->_('(all organizations)')) + $this->util->getDbLookup()->getOrganizations();
-
- $elements[] = new Zend_Form_Element_Select('org_id', array('multiOptions' => $options));
-
- return $elements;
- }
-
- protected function getDataFilter(array $data)
- {
- if (isset($data['org_id']) && $data['org_id']) {
- $organizationId = intval($data['org_id']);
- return array("LOCATE('|$organizationId|', gmt_organizations...
[truncated message content] |
|
From: <gem...@li...> - 2011-10-27 09:04:05
|
Revision: 146
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=146&view=rev
Author: matijsdejong
Date: 2011-10-27 09:03:59 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
Merged changes 142-144
Modified Paths:
--------------
branches/newUser/classes/Gems/Default/ConsentAction.php
branches/newUser/classes/Gems/Default/ProjectInformationAction.php
branches/newUser/classes/Gems/Default/ReceptionAction.php
branches/newUser/classes/Gems/Default/RoleAction.php
branches/newUser/classes/Gems/Menu/MenuAbstract.php
branches/newUser/classes/Gems/Roles.php
branches/newUser/classes/GemsEscort.php
Property Changed:
----------------
branches/newUser/
Property changes on: branches/newUser
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/library:114-122,125-139
+ /trunk/library:114-122,125-139,142-144
Modified: branches/newUser/classes/Gems/Default/ConsentAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/ConsentAction.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Default/ConsentAction.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -1,35 +1,35 @@
<?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.
- */
-
+
/**
- *
+ * 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
@@ -38,22 +38,24 @@
*/
/**
- *
+ *
* @author Matijs de Jong
* @package Gems
* @subpackage Default
*/
class Gems_Default_ConsentAction extends Gems_Controller_BrowseEditAction
{
+ public $menuIndexIncludeLevel = 1;
+
public $sortKey = array('gco_order' => SORT_ASC);
- /**
- * 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
- * parameter was added, because the most common use of action is a split between detailed
+ /**
+ * 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
+ * parameter was added, because the most common use of action is a split between detailed
* and summarized actions.
- *
+ *
* @param boolean $detailed True when the current action is not in $summarizedActions.
* @param string $action The current action.
* @return MUtil_Model_ModelAbstract
Modified: branches/newUser/classes/Gems/Default/ProjectInformationAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -153,7 +153,8 @@
$request = $this->getRequest();
$buttonList = $this->menu->getMenuList();
$buttonList->addParameterSources($request)
- ->addByController($request->getControllerName(), 'maintenance', $label);
+ ->addByController($request->getControllerName(), 'maintenance', $label)
+ ->addByController($request->getControllerName(), 'cacheclean');
// $this->html->buttonDiv($buttonList);
@@ -180,6 +181,15 @@
$this->_reroute(array($request->getActionKey() => 'index'));
}
+ public function cachecleanAction()
+ {
+ $this->escort->cache->clean();
+ $this->addMessage($this->_('Cache cleaned'));
+ // Redirect
+ $request = $this->getRequest();
+ $this->_reroute(array($request->getActionKey() => 'index'));
+ }
+
public function phpAction()
{
$this->html->h2($this->_('Server PHP Info'));
Modified: branches/newUser/classes/Gems/Default/ReceptionAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/ReceptionAction.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Default/ReceptionAction.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -46,6 +46,8 @@
*/
class Gems_Default_ReceptionAction extends Gems_Controller_BrowseEditAction
{
+ public $menuIndexIncludeLevel = 1;
+
public $sortKey = array('grc_id_reception_code' => SORT_ASC);
public function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false)
Modified: branches/newUser/classes/Gems/Default/RoleAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -46,6 +46,11 @@
*/
class Gems_Default_RoleAction extends Gems_Controller_BrowseEditAction
{
+ /**
+ * @var GemsEscort
+ */
+ public $escort;
+
protected function _showTable($caption, $data, $nested = false)
{
$table = MUtil_Html_TableElement::createArray($data, $caption, $nested);
@@ -107,6 +112,21 @@
}
/**
+ * As the ACL might have to be updated, rebuild the acl
+ *
+ * @param array $data
+ * @param type $isNew
+ * @return type
+ */
+ public function afterSave(array $data, $isNew)
+ {
+ $roles = $this->loader->getRoles($this->escort);
+ $roles->build();
+
+ return true;
+ }
+
+ /**
* Check the disabled (=inherited) privileges
*
* @param Gems_Form $form
Modified: branches/newUser/classes/Gems/Menu/MenuAbstract.php
===================================================================
--- branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -316,6 +316,7 @@
$page->addAction($this->_('Project'), null, 'project');
$page->addAction($this->_('Session'), null, 'session');
$page->addButtonOnly($this->_('Maintenance mode'), 'pr.maintenance', 'project-information', 'maintenance');
+ $page->addButtonOnly($this->_('Clean cache'), 'pr.maintenance', 'project-information', 'cacheclean');
return $page;
}
Modified: branches/newUser/classes/Gems/Roles.php
===================================================================
--- branches/newUser/classes/Gems/Roles.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/Gems/Roles.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -241,13 +241,16 @@
private function save() {
if ($this->_cache instanceof Zend_Cache_Core) {
if (!$this->_cache->save($this->_acl, $this->_cacheid, array(), null))
- echo "MISLUKT!";
+ throw new Gems_Exception('Failed to save acl to cache');
}
}
public function setCache($cache) {
- if ($cache instanceof Zend_Cache_Core)
+ if ($cache instanceof Zend_Cache_Core) {
$this->_cache = $cache;
- }
+ } elseif ($cache instanceof GemsEscort) {
+ $this->_cache = $cache->cache;
+ }
+ }
}
\ No newline at end of file
Modified: branches/newUser/classes/GemsEscort.php
===================================================================
--- branches/newUser/classes/GemsEscort.php 2011-10-26 17:18:45 UTC (rev 145)
+++ branches/newUser/classes/GemsEscort.php 2011-10-27 09:03:59 UTC (rev 146)
@@ -138,6 +138,36 @@
}
/**
+ * Create a default file cache for the Translate and DB adapters to speed up execution
+ *
+ * @return Zend_Cache_Core
+ */
+ protected function _initCache()
+ {
+ $exists = false;
+ $cacheDir = GEMS_ROOT_DIR . "/var/cache/";
+ if (!file_exists($cacheDir)) {
+ if (mkdir($cacheDir, 0777, true)) {
+ $exists = true;
+ }
+ } else {
+ $exists = true;
+ }
+
+ if ($exists) {
+ $cacheFrontendOptions = array('automatic_serialization' => true);
+ $cacheBackendOptions = array('cache_dir' => $cacheDir);
+
+ $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
+
+ Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
+ Zend_Translate::setCache($cache);
+ }
+
+ return $cache;
+ }
+
+ /**
* Initialize the logger
*
* @return Gems_Log
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gem...@li...> - 2011-10-27 15:38:05
|
Revision: 148
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=148&view=rev
Author: matijsdejong
Date: 2011-10-27 15:37:58 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
For #31: gems__staff split into gems__users
Temp fix for moving to new password situation while retaining the older versions.
DeleteValues moved up to DatabaseModelAbstract.
setModelParameters() added to menu for 2 parameter menu items.
Modified Paths:
--------------
branches/newUser/classes/Gems/Auth.php
branches/newUser/classes/Gems/Default/CronAction.php
branches/newUser/classes/Gems/Default/IndexAction.php
branches/newUser/classes/Gems/Default/OptionAction.php
branches/newUser/classes/Gems/Default/RespondentAction.php
branches/newUser/classes/Gems/Default/StaffAction.php
branches/newUser/classes/Gems/Default/TokenPlanAction.php
branches/newUser/classes/Gems/Menu/MenuAbstract.php
branches/newUser/classes/Gems/Menu/SubMenuItem.php
branches/newUser/classes/Gems/Model/UserModel.php
branches/newUser/classes/Gems/User/RespondentUser.php
branches/newUser/classes/Gems/User/StaffUser.php
branches/newUser/classes/Gems/Util/DbLookup.php
branches/newUser/classes/Gems/Validate/GemsPasswordUsername.php
branches/newUser/classes/GemsEscort.php
branches/newUser/classes/MUtil/Model/DatabaseModelAbstract.php
branches/newUser/classes/MUtil/Model/JoinModel.php
branches/newUser/classes/MUtil/Model/ModelAbstract.php
branches/newUser/classes/MUtil/Model/TableBridgeAbstract.php
branches/newUser/classes/MUtil/Model/TableModel.php
branches/newUser/configs/db/patches.sql
branches/newUser/configs/db/tables/gems__staff.20.sql
branches/newUser/configs/db/tables/gems__users.10.sql
branches/newUser/controllers/StaffController.php
Modified: branches/newUser/classes/Gems/Auth.php
===================================================================
--- branches/newUser/classes/Gems/Auth.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Auth.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -98,8 +98,8 @@
* Lookup last failed login and number of failed logins
*/
try {
- $sql = "SELECT gsf_failed_logins, UNIX_TIMESTAMP(gsf_last_failed)
- AS gsf_last_failed FROM gems__staff WHERE gsf_login = ?";
+ $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed)
+ AS gsu_last_failed FROM gems__users WHERE gsu_login = ?";
$results = $this->db->fetchRow($sql, array($username));
} catch (Zend_Db_Exception $zde) {
//If we need to apply a db patch, just use a default value
@@ -107,10 +107,10 @@
MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database'));
}
- $delay = pow($results['gsf_failed_logins'], $this->_delayFactor);
- $remaining = ($results['gsf_last_failed'] + $delay) - time();
+ $delay = pow($results['gsu_failed_logins'], $this->_delayFactor);
+ $remaining = ($results['gsu_last_failed'] + $delay) - time();
- if ($results['gsf_failed_logins'] > 0 && $remaining > 0) {
+ if ($results['gsu_failed_logins'] > 0 && $remaining > 0) {
//$this->_obscureValue = false;
$result = $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60));
}
Modified: branches/newUser/classes/Gems/Default/CronAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/CronAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/CronAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -125,7 +125,7 @@
*/
protected function getUserLogin($userId)
{
- return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId);
+ return $this->db->fetchOne("SELECT gsu_login FROM gems__users WHERE gsu_id_user = ?", $userId);
}
public function indexAction()
Modified: branches/newUser/classes/Gems/Default/IndexAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -74,7 +74,7 @@
* @return Zend_Auth_Adapter_Interface
*/
protected function _getAuthAdapter($formValues) {
- $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_login', 'gsf_password');
+ $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__users', 'gsu_login', 'gsu_password');
$adapter->setIdentity($formValues['userlogin']);
$adapter->setCredential($this->escort->passwordHash(null, $formValues['password'], false));
return $adapter;
@@ -201,6 +201,19 @@
$adapter = $this->_getAuthAdapter($form->getValues());
$auth = Gems_Auth::getInstance();
$result = $auth->authenticate($adapter, $_POST['userlogin']);
+
+ // Allow login using old password.
+ if ((! $result->isValid()) && ($userid = $this->db->fetchOne("SELECT gsu_id_user FROM gems__users WHERE gsu_active = 1 AND gsu_password IS NULL AND gsu_login = ?", $_POST['userlogin']))) {
+
+ $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_id_user', 'gsf_password');
+ $adapter->setIdentity($userid);
+ $adapter->setCredential(md5($_POST['password'], false));
+ $result = $auth->authenticate($adapter, $_POST['userlogin']);
+ MUtil_Echo::track('old autho');
+ } else {
+ MUtil_Echo::track('new autho');
+ }
+
if (!$result->isValid()) {
// Invalid credentials
$errors = $result->getMessages();
@@ -316,19 +329,19 @@
}
if ($this->_request->isPost() && $form->isValid($_POST)) {
- $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email,gsf_reset_key,DATEDIFF(NOW(), gsf_reset_req) AS gsf_days FROM gems__staff WHERE gsf_login = ?", $_POST['userlogin']);
+ $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email, gsu_reset_key, DATEDIFF(NOW(), gsu_reset_requested) AS gsf_days FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_login = ?", $_POST['userlogin']);
$result = $this->db->fetchRow($sql);
if (empty($result) || empty($result['gsf_email'])) {
$this->addMessage($this->_('No such user found or no e-mail address known'));
- } else if (!empty($result['gsf_reset_key']) && $result['gsf_days'] < 1) {
+ } else if (!empty($result['gsu_reset_key']) && $result['gsf_days'] < 1) {
$this->addMessage($this->_('Reset e-mail already sent, please try again after 24 hours'));
} else {
$email = $result['gsf_email'];
$key = md5(time() . $email);
$url = $this->util->getCurrentURI('index/resetpassword/key/' . $key);
- $this->db->update('gems__staff', array('gsf_reset_key' => $key, 'gsf_reset_req' => new Zend_Db_Expr('NOW()')), 'gsf_id_user = ' . $result['gsf_id_user']);
+ $this->db->update('gems__users', array('gsu_reset_key' => $key, 'gsu_reset_requested' => new Zend_Db_Expr('NOW()')), 'gsu_id_user = ' . $result['gsu_id_user']);
$mail->setSubject('Password reset requested');
$mail->setBodyText('To reset your password, please click this link: ' . $url);
@@ -344,7 +357,7 @@
}
}
} else if ($key = $this->_request->getParam('key')) {
- $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email FROM gems__staff WHERE gsf_reset_key = ?", $key);
+ $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_reset_key = ?", $key);
$result = $this->db->fetchRow($sql);
if (!empty($result)) {
@@ -360,7 +373,7 @@
try {
$mail->send();
$this->addMessage($this->_('An e-mail was sent containing your new password'));
- $this->db->update('gems__staff', array('gsf_reset_key' => new Zend_Db_Expr('NULL'), 'gsf_reset_req' => new Zend_Db_Expr('NULL'), 'gsf_password' => $passwordHash), 'gsf_id_user = ' . $result['gsf_id_user']);
+ $this->db->update('gems__users', array('gsu_reset_key' => new Zend_Db_Expr('NULL'), 'gsu_reset_requested' => new Zend_Db_Expr('NULL'), 'gsu_password' => $passwordHash), 'gsu_id_user = ' . $result['gsu_id_user']);
$this->_reroute(array('action' => 'index'), true);
} catch (Exception $e) {
$this->addMessage($this->_('Unable to send e-mail'));
Modified: branches/newUser/classes/Gems/Default/OptionAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/OptionAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/OptionAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -61,8 +61,10 @@
*/
protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false)
{
+ $bridge->addHidden( 'gsu_id_user');
+ $bridge->addHidden( 'gsu_id_organization');
$bridge->addHidden( 'gsf_id_user');
- $bridge->addExhibitor('gsf_login', array('size' => 15, 'minlength' => 4));
+ $bridge->addExhibitor('gsu_login', array('size' => 15, 'minlength' => 4));
$bridge->addText( 'gsf_first_name');
$bridge->addText( 'gsf_surname_prefix');
$bridge->addText( 'gsf_last_name');
@@ -71,12 +73,11 @@
$bridge->addRadio( 'gsf_gender', 'separator', '');
$bridge->addSelect( 'gsf_iso_lang', array('label' => $this->_('Language'), 'multiOptions' => $this->util->getLocalized()->getLanguages()));
- $bridge->addCheckbox( 'gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked you will logoff after answering a survey.'));
}
public function afterSave(array $data, $isNew)
{
- $this->escort->loadLoginInfo($data['gsf_login']);
+ $this->escort->loadLoginInfo($data['gsu_login']);
}
public function changePasswordAction()
@@ -86,15 +87,18 @@
*************/
$form = $this->createForm();
- // Veld current password
- $element = new Zend_Form_Element_Password('old_password');
- $element->setLabel($this->_('Current password'));
- $element->setAttrib('size', 10);
- $element->setAttrib('maxlength', 20);
- $element->setRenderPassword(true);
- $element->setRequired(true);
- $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db));
- $form->addElement($element);
+ $sql = "SELECT CASE WHEN gsu_password IS NULL THEN 0 ELSE 1 END FROM gems__users WHERE gsu_id_user = ? AND gsu_id_organization = ?";
+ if ($this->db->fetchOne($sql, array($this->session->user_id, $this->session->user_organization_id))) {
+ // Veld current password
+ $element = new Zend_Form_Element_Password('old_password');
+ $element->setLabel($this->_('Current password'));
+ $element->setAttrib('size', 10);
+ $element->setAttrib('maxlength', 20);
+ $element->setRenderPassword(true);
+ $element->setRequired(true);
+ $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db));
+ $form->addElement($element);
+ }
// Veld new password
$element = new Zend_Form_Element_Password('new_password');
@@ -127,8 +131,9 @@
****************/
if ($this->_request->isPost() && $form->isValid($_POST)) {
- $data['gsf_id_user'] = $this->session->user_id;
- $data['gsf_password'] = $this->escort->passwordHash(null,$_POST['new_password']);
+ $data['gsu_id_user'] = $this->session->user_id;
+ $data['gsu_id_organization'] = $this->session->user_organization_id;
+ $data['gsu_password'] = $this->escort->passwordHash(null, $_POST['new_password']);
$this->getModel()->save($data);
@@ -180,10 +185,10 @@
*/
public function createModel($detailed, $action)
{
- $model = new MUtil_Model_TableModel('gems__staff');
- $model->canCreate = false;
+ $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf');
+ $model->copyKeys();
- $model->set('gsf_login', 'label', $this->_('Login Name'));
+ $model->set('gsu_login', 'label', $this->_('Login Name'));
$model->set('gsf_email', 'label', $this->_('E-Mail'));
$model->set('gsf_first_name', 'label', $this->_('First name'));
$model->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...');
@@ -191,14 +196,12 @@
$model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders());
- Gems_Model::setChangeFieldsByPrefix($model, 'gsf');
-
return $model;
}
public function editAction()
{
- $this->getModel()->setFilter(array('gsf_id_user' => $this->session->user_id));
+ $this->getModel()->setFilter(array('gsu_id_user' => $this->session->user_id));
if ($form = $this->processForm()) {
$this->html->h3(sprintf($this->_('Options'), $this->getTopic()));
Modified: branches/newUser/classes/Gems/Default/RespondentAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/RespondentAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/RespondentAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -326,8 +326,8 @@
$values = $this->db->fetchPairs("
SELECT gsf_id_user,
CONCAT(gsf_last_name, ', ', COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, '')) AS name
- FROM gems__staff INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group
- WHERE gsf_active=1 AND gsf_id_organization = ? AND ggp_role = 'physician'
+ FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group
+ WHERE gsu_active=1 AND gsu_id_organization = ? AND ggp_role = 'physician'
ORDER BY 2", $organizationId);
$session->physicians = $values;
Modified: branches/newUser/classes/Gems/Default/StaffAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -44,7 +44,7 @@
*/
class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction
{
- public $filterStandard = array('gsf_active' => 1);
+ public $filterStandard = array('gsu_active' => 1);
public $sortKey = array('name' => SORT_ASC);
protected $_instanceId;
@@ -96,18 +96,27 @@
if ($new) {
$model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup());
} else {
- $model->set('gsf_password', 'description', $this->_('Enter only when changing'));
- $model->setSaveWhenNotNull('gsf_password');
+ $model->set('gsu_password', 'description', $this->_('Enter only when changing'));
+ $model->setSaveWhenNotNull('gsu_password');
}
- $model->setOnSave('gsf_password', array($this->escort, 'passwordHash'));
+ $model->setOnSave('gsu_password', array($this->escort, 'passwordHash'));
$ucfirst = new Zend_Filter_Callback('ucfirst');
- $bridge->addHidden( 'gsf_id_user');
- $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4,
- 'validator', $model->createUniqueValidator('gsf_login'));
+ $bridge->addHidden( 'gsu_id_user');
+ $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation
+ $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4,
+ 'validator', $model->createUniqueValidator('gsu_login'));
- $bridge->addPassword('gsf_password',
+ // Can the organization be changed?
+ if ($this->escort->hasPrivilege('pr.staff.edit.all')) {
+ $bridge->addHiddenMulti($model->getKeyCopyName('gsu_id_organization'));
+ $bridge->addSelect('gsu_id_organization');
+ } else {
+ $bridge->addExhibitor('gsu_id_organization');
+ }
+
+ $bridge->addPassword('gsu_password',
'label', $this->_('Password'),
'minlength', $this->project->passwords['MinimumLength'],
// 'renderPassword', true,
@@ -123,11 +132,6 @@
$bridge->addFilter( 'gsf_last_name', $ucfirst);
$bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email'));
- if ($this->escort->hasPrivilege('pr.staff.edit.all')) {
- $bridge->addSelect('gsf_id_organization');
- } else {
- $bridge->addExhibitor('gsf_id_organization');
- }
$bridge->addSelect('gsf_id_primary_group');
$bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.'));
@@ -136,15 +140,15 @@
public function afterFormLoad(array &$data, $isNew)
{
- if (array_key_exists('gsf_login', $data)) {
- $this->_instanceId = $data['gsf_login'];
+ if (array_key_exists('gsu_login', $data)) {
+ $this->_instanceId = $data['gsu_login'];
}
$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->escort->hasPrivilege('pr.staff.edit.all') ||
- $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) {
+ $data['gsu_id_organization'] == $this->escort->getCurrentOrganization())) {
throw new Zend_Exception($this->_('You are not allowed to edit this staff member.'));
}
}
@@ -164,18 +168,21 @@
{
// MUtil_Model::$verbose = true;
- $model = new MUtil_Model_TableModel('gems__staff');
+ $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf');
+ if ($detailed) {
+ $model->copyKeys();
+ }
//$model->resetOrder();
- $model->set('gsf_login', 'label', $this->_('Login'));
+ $model->set('gsu_login', 'label', $this->_('Login'));
$model->set('name', 'label', $this->_('Name'),
'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 ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) {
- $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization());
+ $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $this->escort->getCurrentOrganization());
- $model->set('gsf_id_organization', 'label', $this->_('Organization'),
+ $model->set('gsu_id_organization', 'label', $this->_('Organization'),
'multiOptions', $this->util->getDbLookup()->getOrganizations(),
'default', $this->escort->getCurrentOrganization());
}
@@ -188,10 +195,8 @@
$model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo());
}
- $model->setDeleteValues('gsf_active', 0);
+ $model->setDeleteValues('gsu_active', 0);
- Gems_Model::setChangeFieldsByPrefix($model, 'gsf');
-
return $model;
}
@@ -201,8 +206,8 @@
if ($this->escort->hasPrivilege('pr.staff.see.all')) {
// 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));
+ $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsu_id_organization', 'multiOptions');
+ $select = new Zend_Form_Element_Select('gsu_id_organization', array('multiOptions' => $options));
// Position as second element
$search = array_shift($elements);
@@ -227,7 +232,7 @@
$filter = parent::getDataFilter($data);
if (! $this->escort->hasPrivilege('pr.staff.see.all')) {
- $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization();
+ $filter['gsu_id_organization'] = $this->escort->getCurrentOrganization();
}
return $filter;
}
@@ -257,8 +262,8 @@
// 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']);
+ $this->_setParam('gsu_id_organization', $data['gsu_id_organization']);
+ $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $data['gsu_id_organization']);
}
return parent::getShowTable($columns, $filter, $sort);
}
Modified: branches/newUser/classes/Gems/Default/TokenPlanAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/TokenPlanAction.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Default/TokenPlanAction.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -351,9 +351,9 @@
COALESCE(gems__staff.gsf_first_name, ''),
COALESCE(CONCAT(' ', gems__staff.gsf_surname_prefix), '')
) AS gsf_name
- FROM gems__staff INNER JOIN gems__respondent2track ON gsf_id_user = gr2t_created_by
+ FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__respondent2track ON gsu_id_user = gr2t_created_by
WHERE gr2t_id_organization = $orgId AND
- gsf_active = 1 AND
+ gsu_active = 1 AND
gr2t_active = 1";
$elements[] = $this->_createSelectElement('gr2t_created_by', $sql, $this->_('(all staff)'));
Modified: branches/newUser/classes/Gems/Menu/MenuAbstract.php
===================================================================
--- branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -381,13 +381,12 @@
$page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other);
$page->addAutofilterAction();
$page->addCreateAction();
- $page->addShowAction();
- if ($this->escort->hasPrivilege('pr.staff.edit.all')) {
- $page->addEditAction();
- $page->addDeleteAction();
- } else {
- $page->addEditAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization());
- $page->addDeleteAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization());
+ $page->addShowAction()->setModelParameters(2);
+ $editPage = $page->addEditAction()->setModelParameters(2);
+ $delPage = $page->addDeleteAction()->setModelParameters(2);
+ if (! $this->escort->hasPrivilege('pr.staff.edit.all')) {
+ $editPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization());
+ $delPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization());
}
return $page;
Modified: branches/newUser/classes/Gems/Menu/SubMenuItem.php
===================================================================
--- branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -417,7 +417,7 @@
}
$menu = $this->addAction($label, $privilege, 'delete', $other);
- $menu->addParameters(MUtil_Model::REQUEST_ID);
+ $menu->setModelParameters(1);
return $menu;
}
@@ -436,7 +436,7 @@
}
$menu = $this->addAction($label, $privilege, 'edit', $other);
- $menu->addParameters(MUtil_Model::REQUEST_ID);
+ $menu->setModelParameters(1);
return $menu;
}
@@ -475,6 +475,17 @@
return $this;
}
+ /**
+ * Add required parameters - shown in the url - for this
+ * menu item.
+ *
+ * Numeric array keys are changed into the same string as the
+ * array value.
+ *
+ * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array
+ * @param mixed $key2
+ * @return Gems_Menu_SubMenuItem (continuation pattern)
+ */
public function addNamedParameters($arrayOrKey1 = null, $altName1 = null)
{
$params = MUtil_Ra::pairs(func_get_args());
@@ -483,16 +494,8 @@
$this->_parameters = new MUtil_Lazy_ArrayWrap();
}
foreach ($params as $param => $name) {
- if (! $name) {
- if (is_int($param)) {
- throw new Zend_Exception('Invalid integer required parameter key with empty name.');
- } else {
- $name = $param;
- }
- } else {
- if (is_int($param)) {
- $param = $name;
- }
+ if (is_int($param)) {
+ $param = $name;
}
$this->_requiredParameters[$param] = $name;
$this->_parameters[$param] = MUtil_Lazy::L($name);
@@ -546,7 +549,7 @@
}
$menu = $this->addAction($label, $privilege, 'show', $other);
- $menu->addParameters(MUtil_Model::REQUEST_ID);
+ $menu->setModelParameters(1);
return $menu;
}
@@ -755,6 +758,41 @@
return $this;
}
+ /**
+ * Defines the number of named parameters using the model naming
+ * convention: id=x or id1=x id2=y
+ *
+ * @see setNamedParamenters()
+ *
+ * @param int $idCount The number of parameters to define
+ * @return Gems_Menu_SubMenuItem (continuation pattern)
+ */
+ public function setModelParameters($idCount)
+ {
+ $params = array();
+ if (1 == $idCount) {
+ $params[MUtil_Model::REQUEST_ID] = MUtil_Model::REQUEST_ID;
+ } else {
+ for ($i = 1; $i <= $idCount; $i++) {
+ $params[MUtil_Model::REQUEST_ID . $i] = MUtil_Model::REQUEST_ID . $i;
+ }
+ }
+ $this->setNamedParameters($params);
+
+ return $this;
+ }
+
+ /**
+ * Set the required parameters - shown in the url - for this
+ * menu item.
+ *
+ * Numeric array keys are changed into the same string as the
+ * array value.
+ *
+ * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array
+ * @param mixed $key2
+ * @return Gems_Menu_SubMenuItem (continuation pattern)
+ */
public function setNamedParameters($arrayOrKey1 = null, $key2 = null)
{
$params = MUtil_Ra::pairs(func_get_args());
Modified: branches/newUser/classes/Gems/Model/UserModel.php
===================================================================
--- branches/newUser/classes/Gems/Model/UserModel.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/Model/UserModel.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -82,6 +82,8 @@
*/
protected function _createUserId()
{
+ $db = $this->getAdapter();
+
$max = $this->userIdLen;
do {
@@ -92,7 +94,7 @@
// Make it a number
$out = intval($out);
- } while ($this->db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out));
+ } while ($db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out));
return $out;
}
@@ -112,6 +114,6 @@
$newValues['gsu_id_user'] = $this->_createUserId();
}
- parent::save($newValues, $filter, $saveTables);
+ return parent::save($newValues, $filter, $saveTables);
}
}
Modified: branches/newUser/classes/Gems/User/RespondentUser.php
===================================================================
--- branches/newUser/classes/Gems/User/RespondentUser.php 2011-10-27 13:29:59 UTC (rev 147)
+++ branches/newUser/classes/Gems/User/RespondentUser.php 2011-10-27 15:37:58 UTC (rev 148)
@@ -38,6 +38,18 @@
/**
*
*
+-- 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_...
[truncated message content] |
|
From: <gem...@li...> - 2011-10-27 15:49:55
|
Revision: 149
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=149&view=rev
Author: matijsdejong
Date: 2011-10-27 15:49:44 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
Some final fixes for creating staff users and deleting items
Modified Paths:
--------------
branches/newUser/classes/Gems/Default/StaffAction.php
branches/newUser/classes/MUtil/Model/JoinModel.php
branches/newUser/configs/db/patches.sql
Modified: branches/newUser/classes/Gems/Default/StaffAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:37:58 UTC (rev 148)
+++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:49:44 UTC (rev 149)
@@ -105,6 +105,7 @@
$bridge->addHidden( 'gsu_id_user');
$bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation
+ $bridge->addHidden( 'gsu_user_class');
$bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4,
'validator', $model->createUniqueValidator('gsu_login'));
@@ -191,6 +192,7 @@
$model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders());
if ($detailed) {
+ $model->set('gsu_user_class', 'default', 'StaffUser');
$model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages());
$model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo());
}
Modified: branches/newUser/classes/MUtil/Model/JoinModel.php
===================================================================
--- branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 15:37:58 UTC (rev 148)
+++ branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 15:49:44 UTC (rev 149)
@@ -175,8 +175,7 @@
$filter = $this->_checkFilterUsed($filter);
if ($this->_deleteValues) {
- MUtil_Echo::track($filter);
- $changed = $this->save($this->_deleteValues, $filter, $saveTables);
+ $changed = $this->save($this->_deleteValues + $filter, $filter, $saveTables);
} else {
$changed = 0;
foreach ($saveTables as $table_name) {
Modified: branches/newUser/configs/db/patches.sql
===================================================================
--- branches/newUser/configs/db/patches.sql 2011-10-27 15:37:58 UTC (rev 148)
+++ branches/newUser/configs/db/patches.sql 2011-10-27 15:49:44 UTC (rev 149)
@@ -227,3 +227,5 @@
FROM gems__staff;
ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL;
+
+ALTER TABLE `gems__staff` DROP INDEX `gsf_login`;
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gem...@li...> - 2011-10-27 15:56:03
|
Revision: 150
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=150&view=rev
Author: matijsdejong
Date: 2011-10-27 15:55:57 +0000 (Thu, 27 Oct 2011)
Log Message:
-----------
Last change merged
Modified Paths:
--------------
branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php
Property Changed:
----------------
branches/newUser/
Property changes on: branches/newUser
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/library:114-122,125-139,142-144
+ /trunk/library:114-122,125-139,142-144,147
Modified: branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php
===================================================================
--- branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 15:49:44 UTC (rev 149)
+++ branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 15:55:57 UTC (rev 150)
@@ -59,6 +59,11 @@
protected $_titlesMap;
/**
+ * @var Zend_Cache_Core
+ */
+ protected $cache;
+
+ /**
* The language of this fieldmap
*
* @var string
@@ -108,6 +113,7 @@
$this->lsDb = $lsDb;
$this->translate = $translate;
$this->tablePrefix = $tablePrefix;
+ $this->cache = GemsEscort::getInstance()->cache; //Load the cache from escort
}
/**
@@ -198,7 +204,9 @@
protected function _getMap()
{
- if (! $this->_fieldMap) {
+ $cacheId = 'lsFieldMap'.$this->sourceSurveyId.$this->language;
+
+ if( ($this->_fieldMap = $this->cache->load($cacheId)) === false ) {
$gTable = $this->_getGroupsTableName();
$qTable = $this->_getQuestionsTableName();
@@ -333,9 +341,10 @@
}
}
$this->_fieldMap = $map;
- // MUtil_Echo::track($this->_fieldMap);
+ $this->cache->save($this->_fieldMap, $cacheId);
}
+
return $this->_fieldMap;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gem...@li...> - 2011-10-28 10:54:48
|
Revision: 152
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=152&view=rev
Author: matijsdejong
Date: 2011-10-28 10:54:42 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
Fixes for #31
Modified Paths:
--------------
branches/newUser/classes/Gems/Default/IndexAction.php
branches/newUser/configs/db/patches.sql
Modified: branches/newUser/classes/Gems/Default/IndexAction.php
===================================================================
--- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 16:21:42 UTC (rev 151)
+++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-28 10:54:42 UTC (rev 152)
@@ -209,9 +209,9 @@
$adapter->setIdentity($userid);
$adapter->setCredential(md5($_POST['password'], false));
$result = $auth->authenticate($adapter, $_POST['userlogin']);
- MUtil_Echo::track('old autho');
+ // MUtil_Echo::track('old autho');
} else {
- MUtil_Echo::track('new autho');
+ // MUtil_Echo::track('new autho');
}
if (!$result->isValid()) {
Modified: branches/newUser/configs/db/patches.sql
===================================================================
--- branches/newUser/configs/db/patches.sql 2011-10-27 16:21:42 UTC (rev 151)
+++ branches/newUser/configs/db/patches.sql 2011-10-28 10:54:42 UTC (rev 152)
@@ -228,4 +228,8 @@
ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL;
-ALTER TABLE `gems__staff` DROP INDEX `gsf_login`;
\ No newline at end of file
+ALTER TABLE `gems__staff` DROP INDEX `gsf_login`;
+
+ALTER TABLE `gems__staff` CHANGE `gsf_login` `gsf_login` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+ CHANGE `gsf_password` `gsf_password` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+ CHANGE `gsf_id_organization` `gsf_id_organization` BIGINT( 20 ) NULL DEFAULT NULL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gem...@li...> - 2011-10-28 12:37:03
|
Revision: 153
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=153&view=rev
Author: matijsdejong
Date: 2011-10-28 12:36:57 +0000 (Fri, 28 Oct 2011)
Log Message:
-----------
AddTrackSnippet can now handle organization switches correctly.
Made it easier to write your own AnswerModel.
Modified Paths:
--------------
branches/newUser/snippets/AddTracksSnippet.php
branches/newUser/snippets/AnswerModelSnippet.php
branches/newUser/snippets/TrackAnswersModelSnippet.php
Added Paths:
-----------
branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php
Added: branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php
===================================================================
--- branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php (rev 0)
+++ branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2011-10-28 12:36:57 UTC (rev 153)
@@ -0,0 +1,229 @@
+<?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.
+ *
+ *
+ * @package Gems
+ * @subpackage Tracker
+ * @author Matijs de Jong <mj...@ma...>
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: AnswerModelSnippet.php 28 2011-09-16 06:24:15Z mennodekker $
+ */
+
+/**
+ * Displays answers to a survey.
+ *
+ * @package Gems
+ * @subpackage Tracker
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.5
+ */
+class Gems_Tracker_Snippets_AnswerModelSnippetGeneric extends Gems_Snippets_ModelTableSnippetAbstract
+{
+ /**
+ * Set a fixed model sort.
+ *
+ * Leading _ means not overwritten by sources.
+ *
+ * @var array
+ */
+ protected $_fixedSort = array('gto_round_order' => SORT_ASC);
+
+ /**
+ * Shortfix to add class attribute
+ *
+ * @var string
+ */
+ protected $class = 'browser';
+
+ /**
+ *
+ * @var string Format used for displaying dates.
+ */
+ protected $dateFormat = Zend_Date::DATE_MEDIUM;
+
+ /**
+ * Required
+ *
+ * @var Gems_Loader
+ */
+ protected $loader;
+
+ /**
+ * Required
+ *
+ * @var Zend_Locale
+ */
+ protected $locale;
+
+ /**
+ * Optional: $request or $tokenData must be set
+ *
+ * The display data of the token shown
+ *
+ * @var Gems_Tracker_Token
+ */
+ protected $token;
+
+ /**
+ * Required: id of the selected token to show
+ *
+ * @var string
+ */
+ protected $tokenId;
+
+ /**
+ * Adds columns from the model to the bridge that creates the browse table.
+ *
+ * Overrule this function to add different columns to the browse table, without
+ * having to recode the core table building code.
+ *
+ * @param MUtil_Model_TableBridge $bridge
+ * @param MUtil_Model_ModelAbstract $model
+ * @return void
+ */
+ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model)
+ {
+ $br = MUtil_Html::create('br');
+ $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null);
+
+ $bridge->th($this->_('Status'));
+ $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK')));
+ $td->appendAttrib('class', $selectedClass);
+
+ $bridge->th($this->_('Question'));
+ $td = $bridge->tdh(
+ $bridge->gto_round_description,
+ MUtil_Lazy::iif($bridge->gto_round_description, $br),
+ MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)
+ );
+ $td->appendAttrib('class', $selectedClass);
+ $td->appendAttrib('class', $bridge->row_class);
+
+ foreach($model->getItemsOrdered() as $name) {
+ if ($label = $model->get($name, 'label')) {
+ $bridge->thd($label, array('class' => $model->get($name, 'thClass')));
+ $td = $bridge->td($bridge->$name);
+
+ $td->appendAttrib('class', 'answer');
+ $td->appendAttrib('class', $selectedClass);
+ $td->appendAttrib('class', $bridge->row_class);
+ }
+ }
+
+ $bridge->th($this->_('Token'));
+ $td = $bridge->tdh($bridge->gto_id_token->strtoupper());
+ $td->appendAttrib('class', $selectedClass);
+ $td->appendAttrib('class', $bridge->row_class);
+ }
+
+ /**
+ * Creates the model
+ *
+ * @return MUtil_Model_ModelAbstract
+ */
+ protected function createModel()
+ {
+ $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage());
+
+ $model->set('gto_valid_from', 'dateFormat', $this->dateFormat);
+ $model->set('gto_completion_time', 'dateFormat', $this->dateFormat);
+
+ return $model;
+ }
+
+
+ /**
+ * Create the snippets content
+ *
+ * This is a stub function either override getHtmlOutput() or override render()
+ *
+ * @param Zend_View_Abstract $view Just in case it is needed here
+ * @return MUtil_Html_HtmlInterface Something that can be rendered
+ */
+ public function getHtmlOutput(Zend_View_Abstract $view)
+ {
+ $htmlDiv = MUtil_Html::create()->div();
+
+ if ($this->tokenId) {
+ if ($this->token->exists) {
+ $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber()));
+
+ $htmlDiv->pInfo(sprintf(
+ $this->_('Answers for token %s, patient number %s: %s.'),
+ strtoupper($this->tokenId),
+ $this->token->getPatientNumber(),
+ $this->token->getRespondentName()))
+ ->appendAttrib('class', 'noprint');
+
+ $table = parent::getHtmlOutput($view);
+ $table->setPivot(true, 2, 1);
+
+ $this->applyHtmlAttributes($table);
+ $htmlDiv[] = $table;
+
+ } else {
+ $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors'));
+ }
+
+ } else {
+ $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors'));
+ }
+
+ $buttonDiv = $htmlDiv->buttonDiv();
+ $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();'));
+ $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
+ return $htmlDiv;
+ }
+
+ /**
+ * The place to check if the data set in the snippet is valid
+ * to generate the snippet.
+ *
+ * When invalid data should result in an error, you can throw it
+ * here but you can also perform the check in the
+ * checkRegistryRequestsAnswers() function from the
+ * {@see MUtil_Registry_TargetInterface}.
+ *
+ * @return boolean
+ */
+ public function hasHtmlOutput()
+ {
+ if (! $this->tokenId) {
+ if (isset($this->token)) {
+ $this->tokenId = $this->token->getTokenId();
+ }
+ } elseif (! $this->token) {
+ $this->token = $this->loader->getTracker()->getToken($this->tokenId);
+ }
+
+ // Output always true, returns an error message as html when anything is wrong
+ return true;
+ }
+}
Modified: branches/newUser/snippets/AddTracksSnippet.php
===================================================================
--- branches/newUser/snippets/AddTracksSnippet.php 2011-10-28 10:54:42 UTC (rev 152)
+++ branches/newUser/snippets/AddTracksSnippet.php 2011-10-28 12:36:57 UTC (rev 153)
@@ -103,10 +103,11 @@
throw new exception('Invalid track type requested.');
}
- $trackTypeTime = $trackType . '_time';
+ $trackTypeCache = $trackType . '_' . $this->session->user_style;
+ $trackTypeTime = $trackType . '_time';
- if (isset($this->session->$trackType, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) {
- $tracks = $this->session->$trackType;
+ if (isset($this->session->$trackTypeCache, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) {
+ $tracks = $this->session->$trackTypeCache;
} else {
$organization_id = $this->escort->getCurrentOrganization();
switch ($trackType) {
@@ -153,8 +154,8 @@
}
$tracks = $this->db->fetchPairs($sql);
- $this->session->$trackType = $tracks;
- $this->session->$trackTypeTime = time() + 600;
+ $this->session->$trackTypeCache = $tracks;
+ $this->session->$trackTypeTime = time() + 600;
}
$div = MUtil_Html::create()->div(array('class' => 'toolbox'));
Modified: branches/newUser/snippets/AnswerModelSnippet.php
===================================================================
--- branches/newUser/snippets/AnswerModelSnippet.php 2011-10-28 10:54:42 UTC (rev 152)
+++ branches/newUser/snippets/AnswerModelSnippet.php 2011-10-28 12:36:57 UTC (rev 153)
@@ -44,186 +44,5 @@
* @license New BSD License
* @since Class available since version 1.4
*/
-class AnswerModelSnippet extends Gems_Snippets_ModelTableSnippetAbstract
-{
- /**
- * Set a fixed model sort.
- *
- * Leading _ means not overwritten by sources.
- *
- * @var array
- */
- protected $_fixedSort = array('gto_round_order' => SORT_ASC);
-
- /**
- * Shortfix to add class attribute
- *
- * @var string
- */
- protected $class = 'browser';
-
- /**
- *
- * @var string Format used for displaying dates.
- */
- protected $dateFormat = Zend_Date::DATE_MEDIUM;
-
- /**
- * Required
- *
- * @var Gems_Loader
- */
- protected $loader;
-
- /**
- * Required
- *
- * @var Zend_Locale
- */
- protected $locale;
-
- /**
- * Optional: $request or $tokenData must be set
- *
- * The display data of the token shown
- *
- * @var Gems_Tracker_Token
- */
- protected $token;
-
- /**
- * Required: id of the selected token to show
- *
- * @var string
- */
- protected $tokenId;
-
- /**
- * Adds columns from the model to the bridge that creates the browse table.
- *
- * Overrule this function to add different columns to the browse table, without
- * having to recode the core table building code.
- *
- * @param MUtil_Model_TableBridge $bridge
- * @param MUtil_Model_ModelAbstract $model
- * @return void
- */
- protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model)
- {
- $br = MUtil_Html::create('br');
- $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null);
-
- $bridge->th($this->_('Status'));
- $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK')));
- $td->appendAttrib('class', $selectedClass);
-
- $bridge->th($this->_('Question'));
- $td = $bridge->tdh(
- $bridge->gto_round_description,
- MUtil_Lazy::iif($bridge->gto_round_description, $br),
- MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from)
- );
- $td->appendAttrib('class', $selectedClass);
- $td->appendAttrib('class', $bridge->row_class);
-
- foreach($model->getItemsOrdered() as $name) {
- if ($label = $model->get($name, 'label')) {
- $bridge->thd($label, array('class' => $model->get($name, 'thClass')));
- $td = $bridge->td($bridge->$name);
-
- $td->appendAttrib('class', 'answer');
- $td->appendAttrib('class', $selectedClass);
- $td->appendAttrib('class', $bridge->row_class);
- }
- }
-
- $bridge->th($this->_('Token'));
- $td = $bridge->tdh($bridge->gto_id_token->strtoupper());
- $td->appendAttrib('class', $selectedClass);
- $td->appendAttrib('class', $bridge->row_class);
- }
-
- /**
- * Creates the model
- *
- * @return MUtil_Model_ModelAbstract
- */
- protected function createModel()
- {
- $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage());
-
- $model->set('gto_valid_from', 'dateFormat', $this->dateFormat);
- $model->set('gto_completion_time', 'dateFormat', $this->dateFormat);
-
- return $model;
- }
-
-
- /**
- * Create the snippets content
- *
- * This is a stub function either override getHtmlOutput() or override render()
- *
- * @param Zend_View_Abstract $view Just in case it is needed here
- * @return MUtil_Html_HtmlInterface Something that can be rendered
- */
- public function getHtmlOutput(Zend_View_Abstract $view)
- {
- $htmlDiv = MUtil_Html::create()->div();
-
- if ($this->tokenId) {
- if ($this->token->exists) {
- $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber()));
-
- $htmlDiv->pInfo(sprintf(
- $this->_('Answers for token %s, patient number %s: %s.'),
- strtoupper($this->tokenId),
- $this->token->getPatientNumber(),
- $this->token->getRespondentName()))
- ->appendAttrib('class', 'noprint');
-
- $table = parent::getHtmlOutput($view);
- $table->setPivot(true, 2, 1);
-
- $this->applyHtmlAttributes($table);
- $htmlDiv[] = $table;
-
- } else {
- $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors'));
- }
-
- } else {
- $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors'));
- }
-
- $buttonDiv = $htmlDiv->buttonDiv();
- $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();'));
- $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
- return $htmlDiv;
- }
-
- /**
- * The place to check if the data set in the snippet is valid
- * to generate the snippet.
- *
- * When invalid data should result in an error, you can throw it
- * here but you can also perform the check in the
- * checkRegistryRequestsAnswers() function from the
- * {@see MUtil_Registry_TargetInterface}.
- *
- * @return boolean
- */
- public function hasHtmlOutput()
- {
- if (! $this->tokenId) {
- if (isset($this->token)) {
- $this->tokenId = $this->token->getTokenId();
- }
- } elseif (! $this->token) {
- $this->token = $this->loader->getTracker()->getToken($this->tokenId);
- }
-
- // Output always true, returns an error message as html when anything is wrong
- return true;
- }
-}
+class AnswerModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric
+{ }
Modified: branches/newUser/snippets/TrackAnswersModelSnippet.php
===================================================================
--- branches/newUser/snippets/TrackAnswersModelSnippet.php 2011-10-28 10:54:42 UTC (rev 152)
+++ branches/newUser/snippets/TrackAnswersModelSnippet.php 2011-10-28 12:36:57 UTC (rev 153)
@@ -36,8 +36,6 @@
* @version $Id$
*/
-include_once(dirname(__FILE__) . '/AnswerModelSnippet.php');
-
/**
* Class description of TrackAnswersModelSnippet
*
@@ -47,7 +45,7 @@
* @license New BSD License
* @since Class available since version 1.4
*/
-class TrackAnswersModelSnippet extends AnswerModelSnippet
+class TrackAnswersModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric
{
/**
* Overrule to implement snippet specific filtering and sorting.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|