From: <gem...@li...> - 2012-01-02 10:17:48
|
Revision: 391 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=391&view=rev Author: mennodekker Date: 2012-01-02 10:17:42 +0000 (Mon, 02 Jan 2012) Log Message: ----------- Possibly incompatible fix: Fixed userloading for inactive users (i.e. userdata returns no row) Fix for delete in staffModel resulting in an error because not all key values where present and the joined table got an insert instead of an update Doc for code completion in Model Modified Paths: -------------- trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php trunk/library/classes/Gems/User/User.php trunk/library/classes/MUtil/Model/JoinModel.php Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2011-12-30 12:12:18 UTC (rev 390) +++ trunk/library/classes/Gems/Model.php 2012-01-02 10:17:42 UTC (rev 391) @@ -171,6 +171,11 @@ return $model; } + /** + * Load the organization model + * + * @return Gems_Model_OrganizationModel + */ public function getOrganizationModel() { $model = $this->_loadClass('OrganizationModel', true); @@ -227,6 +232,11 @@ return $model; } + /** + * Load the staffmodel + * + * @return Gems_Model_StaffModel + */ public function getStaffModel() { $model = $this->_loadClass('StaffModel', true); Modified: trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php =================================================================== --- trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2011-12-30 12:12:18 UTC (rev 390) +++ trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2012-01-02 10:17:42 UTC (rev 391) @@ -168,7 +168,20 @@ { $select = $this->getUserSelect($login_name, $organization); - return $this->db->fetchRow($select, array($login_name, $organization), Zend_Db::FETCH_ASSOC); + $result = $this->db->fetchRow($select, array($login_name, $organization), Zend_Db::FETCH_ASSOC); + + /* + * Handle the case that we have a login record, but no matching userdata (ie. user is inactive) + * if you want some kind of auto-register you should change this + */ + if ($result == false) { + $result = array( + 'user_active' => false, + 'user_role' => 'nologin', + ); + } + + return $result; } /** Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-12-30 12:12:18 UTC (rev 390) +++ trunk/library/classes/Gems/User/User.php 2012-01-02 10:17:42 UTC (rev 391) @@ -222,6 +222,17 @@ } /** + * Helper method for the case a user tries to authenticate while he is inactive + * + * @param array $params + * @return boolean + */ + public function alwaysFalse($params) + { + return false; + } + + /** * Authenticate a users credentials using the submitted form * * @param array $formValues the array containing all formvalues from the login form @@ -229,17 +240,21 @@ */ public function authenticate($formValues) { - $auth = Gems_Auth::getInstance(); + $auth = Gems_Auth::getInstance(); - $formValues['allowed_ip_ranges'] = $this->getAllowedIPRanges(); - $formValues['organization'] = $this->getBaseOrganizationId(); + $formValues['allowed_ip_ranges'] = $this->getAllowedIPRanges(); + $formValues['organization'] = $this->getBaseOrganizationId(); - $adapter = $this->definition->getAuthAdapter($formValues); - $authResult = $auth->authenticate($adapter, $formValues); + if ($this->isActive()) { + $adapter = $this->definition->getAuthAdapter($formValues); + } else { + $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $formValues['userlogin'], $formValues); + } - $this->_authResult = $authResult; + $authResult = $auth->authenticate($adapter, $formValues); + $this->_authResult = $authResult; - return $authResult; + return $authResult; } /** Modified: trunk/library/classes/MUtil/Model/JoinModel.php =================================================================== --- trunk/library/classes/MUtil/Model/JoinModel.php 2011-12-30 12:12:18 UTC (rev 390) +++ trunk/library/classes/MUtil/Model/JoinModel.php 2012-01-02 10:17:42 UTC (rev 391) @@ -175,8 +175,11 @@ $filter = $this->_checkFilterUsed($filter); if ($this->_deleteValues) { - // MUtil_Model::$verbose = true; - $changed = $this->save($this->_deleteValues + $filter, $filter, $saveTables); + // First get the old values so we can have all the key values + $oldValues = $this->loadFirst($filter); + + // Add the oldValues to the save + $changed = $this->save($this->_deleteValues + $oldValues, $filter, $saveTables); } else { $changed = 0; foreach ($saveTables as $table_name) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |