/** * @param CM_Model_User $user * @param int $actionType OPTIONAL * @param int $actionVerb OPTIONAL * @param int $limitType OPTIONAL * @param int $period OPTIONAL */ public function __construct(CM_Model_User $user, $actionType = null, $actionVerb = null, $limitType = null, $period = null) { $this->_user = $user; $where = '`actorId` = ' . $user->getId(); if ($actionType) { $actionType = (int) $actionType; $where .= ' AND `type` = ' . $actionType; } if ($actionVerb) { $actionVerb = (int) $actionVerb; $where .= ' AND `verb` = ' . $actionVerb; } if ($limitType) { $limitType = (int) $limitType; $where .= ' AND `actionLimitType` = ' . $limitType; } else { $where .= ' AND `actionLimitType` IS NOT NULL'; } if ($period) { $period = (int) $period; $time = time() - $period; $where .= ' AND `createStamp` > ' . $time; } $source = new CM_PagingSource_Sql_Deferred('type, verb, createStamp', 'cm_action', $where, '`createStamp` DESC'); parent::__construct($source); }
/** * @param int|CM_Model_User $user * @return bool */ public function contains($user) { if ($user instanceof CM_Model_User) { $userId = $user->getId(); } else { $userId = (int) $user; } return in_array($userId, $this->getItemsRaw()); }
/** * @param CM_Model_User $user * @throws CM_Exception_Invalid * @return boolean */ public function getEnabled(CM_Model_User $user) { $cacheKey = CM_CacheConst::SplitFeature_Fixtures . '_userId:' . $user->getId(); $cacheWrite = false; $cache = CM_Cache_Local::getInstance(); if (($fixtures = $cache->get($cacheKey)) === false) { $fixtures = CM_Db_Db::select('cm_splitfeature_fixture', array('splitfeatureId', 'fixtureId'), array('userId' => $user->getId()))->fetchAllTree(); $cacheWrite = true; } if (!array_key_exists($this->getId(), $fixtures)) { $fixtureId = CM_Db_Db::replace('cm_splitfeature_fixture', array('splitfeatureId' => $this->getId(), 'userId' => $user->getId())); $fixtures[$this->getId()] = $fixtureId; $cacheWrite = true; } if ($cacheWrite) { $cache->set($cacheKey, $fixtures); } return $this->_calculateEnabled($fixtures[$this->getId()]); }
/** * @param string $useragent */ public function add($useragent) { $useragent = (string) $useragent; CM_Db_Db::replaceDelayed('cm_useragent', array('userId' => $this->_user->getId(), 'useragent' => $useragent, 'createStamp' => time())); }
/** * @param CM_Model_User $user */ public function setUser(CM_Model_User $user) { $user->setOnline(true); $this->set('userId', $user->getId()); $this->regenerateId(); if ($request = $this->getRequest()) { CM_Splittest_Fixture::setUserForRequestClient($request, $user); $user->getUseragents()->addFromRequest($request); } }
public function add(CM_Action_Abstract $action) { CM_Db_Db::insertDelayed('cm_action', array('actorId' => $this->_user->getId(), 'verb' => $action->getVerb(), 'type' => $action->getType(), 'createStamp' => time())); }
/** * @param CM_Model_User $user * @return CM_Queue */ protected function _getTrackingQueue(CM_Model_User $user) { return new CM_Queue(__METHOD__ . ':' . $user->getId()); }
/** * @param CM_Model_User $user * @return string */ public static function getKeyByUser(CM_Model_User $user) { return self::_encryptKey($user->getId(), self::SALT); }
/** * @param CM_Model_User $user * @return CM_Queue */ protected function _getTrackingQueue(CM_Model_User $user) { return new CM_Queue(get_called_class() . '::_getTrackingQueue:' . $user->getId()); }
public function canSubscribe(CM_Model_User $user, $allowedUntil) { return $user->getId() != 1 ? $allowedUntil + 100 : $allowedUntil; }
/** * @param CM_Model_User $user * @param CM_Model_Stream_Abstract|null $excludedStream * @return bool */ public function isPublisher(CM_Model_User $user, CM_Model_Stream_Abstract $excludedStream = null) { /** @var $stream CM_Model_Stream_Publish */ foreach ($this->getStreamPublishs() as $stream) { if (!$stream->equals($excludedStream) && $stream->getUserId() == $user->getId()) { return true; } } return false; }
/** * @param CM_Http_Request_Abstract $request * @param CM_Model_User $user */ public static function setUserForRequestClient(CM_Http_Request_Abstract $request, CM_Model_User $user) { $requestClientId = $request->getClientId(); $userId = $user->getId(); CM_Db_Db::updateIgnore('cm_splittestVariation_fixture', array('userId' => $userId), array('requestClientId' => $requestClientId)); }
/** * @param CM_Model_User $user */ public function __construct(CM_Model_User $user) { $source = new CM_PagingSource_Sql('`id`', 'cm_stream_subscribe', '`userId` = ' . $user->getId()); parent::__construct($source); }
/** * @param CM_Model_User $user OPTIONAL */ public static function deleteOld(CM_Model_User $user = null) { $userWhere = $user ? ' AND `userId` = ' . (int) $user->getId() : ''; $result = CM_Db_Db::exec("SELECT `userId`, `role` FROM `cm_role` WHERE `expirationStamp` < ?" . $userWhere, array(time())); while ($row = $result->fetch()) { $user = CM_Model_User::factory($row['userId']); $user->getRoles()->delete($row['role']); $user->getSite()->getEventHandler()->trigger('roleExpired', array('user' => $user, 'role' => $row['role'])); } }
/** * @param CM_Model_User $user */ public function __construct(CM_Model_User $user) { $source = new CM_PagingSource_Sql('id', 'cm_streamChannelArchive_video', '`userId` = ' . $user->getId(), 'createStamp DESC'); parent::__construct($source); }