setHideOnlineStatus() public static method

public static setHideOnlineStatus ( $UserData )
Exemplo n.º 1
0
         $response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('user.edit.photo_resize_150', array('mime_type' => $file["data"]['mime_type'], 'user' => $UserData));
         if ($response === false) {
             erLhcoreClassImageConverter::getInstance()->converter->transform('photow_150', $UserData->file_path_server, $UserData->file_path_server);
             chmod($UserData->file_path_server, 0644);
         }
     }
 }
 if (count($Errors) == 0) {
     // Update password if neccesary
     if ($form->hasInputField('Password') && $form->hasInputField('Password1') && $form->Password != '') {
         $UserData->setPassword($form->Password);
     }
     $UserData->email = $form->Email;
     $UserData->name = $form->Name;
     erLhcoreClassUser::getSession()->update($UserData);
     erLhcoreClassUserDep::setHideOnlineStatus($UserData);
     erLhcoreClassModelGroupUser::removeUserFromGroups($UserData->id);
     foreach ($UserData->user_groups_id as $group_id) {
         $groupUser = new erLhcoreClassModelGroupUser();
         $groupUser->group_id = $group_id;
         $groupUser->user_id = $UserData->id;
         $groupUser->saveThis();
     }
     $CacheManager = erConfigClassLhCacheConfig::getInstance();
     $CacheManager->expireCache();
     if (isset($_POST['Save_account'])) {
         erLhcoreClassModule::redirect('user/userlist');
         exit;
     } else {
         $tpl->set('updated', true);
     }
 /**
  * Handlers requests like
  *
  * May 08 23:02:11 [Warning] [default] [default] {"action":"ping","user":"******"}
  * May 08 23:02:14 [Warning] [default] [default] {"action":"disconnect","user":"******","server":"xmpp.livehelperchat.com"}
  * May 08 23:21:52 [Warning] [default] [default] {"action":"connect","user":"******","server":"xmpp.livehelperchat.com"}
  */
 public static function handleOperatorPing($jsonContent)
 {
     $params = json_decode($jsonContent, true);
     $xmppService = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice');
     // If ping just update last action
     if ($params['action'] == 'ping') {
         // Parse user parts
         $userParts = self::parseXMPPUser($params['user']);
         // Fetches user id by xmpp username
         $userId = self::getUserIDByXMPPUsername($userParts['xmppuser']);
         // Updates last activity
         if (is_numeric($userId)) {
             self::updateActivityByUserId($userId, time() + $xmppService->settings['append_time']);
         } else {
             throw new Exception("Could not find LHC user by user - " . $userParts['xmppuser']);
         }
     } elseif ($params['action'] == 'disconnect' || $params['action'] == 'connect') {
         // Fetches user id by xmpp username
         $userId = self::getUserIDByXMPPUsername($params['user'] . '@' . $params['server']);
         // Updates last activity to zero
         if (is_numeric($userId)) {
             self::updateActivityByUserId($userId, $params['action'] == 'connect' ? time() + $xmppService->settings['append_time'] : 0);
             if ($params['action'] == 'connect') {
                 $userData = erLhcoreClassModelUser::fetch($userId);
                 if ($userData instanceof erLhcoreClassModelUser && $userData->hide_online == 1) {
                     $userData->hide_online = 0;
                     erLhcoreClassUser::getSession()->update($userData);
                     erLhcoreClassUserDep::setHideOnlineStatus($userData);
                 }
             }
         } else {
             throw new Exception("Could not find LHC user by user - " . $params['user'] . '@' . $params['server']);
         }
     }
     return true;
 }