Index: trunk/kernel/units/users/users_item.php =================================================================== diff -u -N -r4758 -r6583 --- trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 4758) +++ trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 6583) @@ -2,20 +2,22 @@ class UsersItem extends kDBItem { var $persistantVars = Array(); - - function LoadPersistantVars() + + function LoadPersistantVars($id=null) { + $id = $id == -1 ? -1 : $this->GetID(); + if (!$id) return ; $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE PortalUserId = '.$this->GetID(); + WHERE PortalUserId = '.$id; $this->persistantVars = $this->Conn->GetCol($sql, 'VariableName'); } - + function setPersistantVar($var_name, $var_value) { $this->persistantVars[$var_name] = $var_value; - - if ($this->GetID() > 0) { + + if ($this->GetID() > 0 || $this->GetID() == -1) { $replace_hash = Array( 'PortalUserId' => $this->GetID(), 'VariableName' => $var_name, 'VariableValue' => $var_value @@ -26,21 +28,21 @@ $this->Application->StoreVar($var_name, $var_value); } } - + function getPersistantVar($var_name) { return getArrayValue($this->persistantVars, $var_name); } - + function Load($id, $id_field_name = null) { $ret = parent::Load($id, $id_field_name); - if ($ret) { - $this->LoadPersistantVars(); + if ($ret || $id == -1) { + $this->LoadPersistantVars($id); } return $ret; } - + /** * Returns IDs of groups to which user belongs and membership is not expired * @@ -61,7 +63,7 @@ return explode(',', $user_groups); } } - + /** * Set's Login from Email if required by configuration settings * @@ -70,10 +72,10 @@ { if( $this->Application->ConfigValue('Email_As_Login') ) { - $this->SetDBField('Login', $this->GetDBField('Email') ); + $this->SetDBField('Login', $this->GetDBField('Email') ); } } - + function SendEmailEvents() { switch( $this->GetDBField('Status') ) @@ -82,25 +84,25 @@ $this->Application->EmailEventAdmin('USER.ADD', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD', $this->GetID() ); break; - + case 2: $this->Application->EmailEventAdmin('USER.ADD.PENDING', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD.PENDING', $this->GetID() ); break; } } - + function isSubscriberOnly() { $subscribers_group_id = $this->Application->ConfigValue('User_SubscriberGroup'); $sql = 'SELECT PortalUserId FROM '.TABLE_PREFIX.'UserGroup - WHERE GroupId = '.$subscribers_group_id.' AND - PortalUserId = '.$this->GetDBField('PortalUserId').' AND + WHERE GroupId = '.$subscribers_group_id.' AND + PortalUserId = '.$this->GetDBField('PortalUserId').' AND PrimaryGroup = 1'; return $this->Conn->GetOne($sql) == $this->GetDBField('PortalUserId'); } - + function Create($force_id=false, $system_create=false) { $ret = parent::Create($force_id, $system_create); @@ -111,8 +113,8 @@ } return $ret; } - - + + function Update($id=null, $system_update=false) { $ret = parent::Update($id, $system_update); @@ -123,7 +125,7 @@ } return $ret; } - + /** * Deletes the record from databse * @@ -137,14 +139,14 @@ $sync_manager =& $this->Application->recallObjectP('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); $sync_manager->performAction('deleteUser', $this->FieldValues); } - + return $ret; } - + function setName($full_name) { $full_name = explode(' ', $full_name); - + if (count($full_name) > 2) { $last_name = array_pop($full_name); $first_name = implode(' ', $full_name); @@ -153,11 +155,11 @@ $last_name = $full_name[1]; $first_name = $full_name[0]; } - + $this->SetDBField('FirstName', $first_name); $this->SetDBField('LastName', $last_name); } - - + + } ?> \ No newline at end of file