Ejemplo n.º 1
0
 /**
  * Return user's session
  *
  * @param int    $iUserId     User ID
  * @param string $sSessionKey Session ID
  *
  * @return ModuleUser_EntitySession|null
  */
 public function GetSessionByUserId($iUserId, $sSessionKey = null)
 {
     if ($sSessionKey) {
         $aSessions = $this->oMapper->GetSessionsByArrayId(array($iUserId), $sSessionKey);
         if ($aSessions) {
             return reset($aSessions);
         }
     } else {
         $aSessions = $this->GetSessionsByArrayId($iUserId);
         if (isset($aSessions[$iUserId])) {
             return $aSessions[$iUserId];
         }
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * Получить список сессий по списку айдишников, но используя единый кеш
  *
  * @param array $aUserId	Список ID пользователей
  * @return array
  */
 public function GetSessionsByArrayIdSolid($aUserId)
 {
     if (!is_array($aUserId)) {
         $aUserId = array($aUserId);
     }
     $aUserId = array_unique($aUserId);
     $aSessions = array();
     $s = join(',', $aUserId);
     if (false === ($data = $this->Cache_Get("user_session_id_{$s}"))) {
         $data = $this->oMapper->GetSessionsByArrayId($aUserId);
         foreach ($data as $oSession) {
             $aSessions[$oSession->getUserId()] = $oSession;
         }
         $this->Cache_Set($aSessions, "user_session_id_{$s}", array("user_session_update"), 60 * 60 * 24 * 1);
         return $aSessions;
     }
     return $data;
 }