Application->RecallVar('UserGroups'); if($user_groups === false || $force_reload) { // primary group goes first $sql = 'SELECT GroupId FROM ' . TABLE_PREFIX . 'UserGroup WHERE (PortalUserId = ' . $this->GetID() . ') AND ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) ) ORDER BY IF(GroupId = ' . $this->GetDBField('PrimaryGroupId') . ', 1, 0) DESC'; return $this->Conn->GetCol($sql); } else { return explode(',', $user_groups); } } function SendEmailEvents() { switch ($this->GetDBField('Status')) { case STATUS_ACTIVE: $event_name = $this->Application->ConfigValue('User_Password_Auto') ? 'USER.VALIDATE' : 'USER.ADD'; $this->Application->EmailEventAdmin($event_name); $this->Application->EmailEventUser($event_name, $this->GetID()); break; case STATUS_PENDING: $this->Application->EmailEventAdmin('USER.ADD.PENDING'); $this->Application->EmailEventUser('USER.ADD.PENDING', $this->GetID()); break; } } /** * Checks that user is subscriber only * * @return bool */ function isSubscriberOnly() { return $this->GetDBField('PrimaryGroupId') == $this->Application->ConfigValue('User_SubscriberGroup'); } function Create($force_id=false, $system_create=false) { $ret = parent::Create($force_id, $system_create); if ($ret) { // find out how to syncronize user only when it's copied to live table $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); $sync_manager->performAction('createUser', $this->FieldValues); } return $ret; } function Update($id=null, $system_update=false) { $ret = parent::Update($id, $system_update); if ($ret) { // find out how to syncronize user only when it's copied to live table $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize')); $sync_manager->performAction('updateUser', $this->FieldValues); } return $ret; } /** * Deletes the record from databse * * @access public * @return bool */ function Delete($id = null) { $ret = parent::Delete($id); if ($ret) { $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 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); } else { $last_name = $full_name[1]; $first_name = $full_name[0]; } $this->SetDBField('FirstName', $first_name); $this->SetDBField('LastName', $last_name); } /** * Generates new password for given user * * @param int $length * @return string * @access public */ public function generatePassword($length = 10) { $password = kUtil::generatePassword($length); $this->SetField('Password', $password); $this->SetField('VerifyPassword', $password); return $password; } }