Ejemplo n.º 1
0
 public function onUnsubscribe(CM_Model_Stream_Subscribe $streamSubscribe)
 {
     $unsubscriber = $streamSubscribe->getUser();
     if ($unsubscriber && !$this->isSubscriber($unsubscriber, $streamSubscribe)) {
         $unsubscriber->setOfflineStamp();
     }
 }
Ejemplo n.º 2
0
 public function onUnsubscribe(CM_Model_Stream_Subscribe $streamSubscribe)
 {
     if ($this->hasUser()) {
         $user = $streamSubscribe->getUser();
         if ($user && !$this->isSubscriber($user, $streamSubscribe)) {
             $delayedJobQueue = CM_Service_Manager::getInstance()->getDelayedJobQueue();
             $delayedJobQueue->addJob(new CM_User_OfflineJob(), ['user' => $user], CM_Model_User::OFFLINE_DELAY);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param CM_Model_Stream_Subscribe $streamSubscribe
  * @return bool
  * @throws CM_Exception_Invalid
  */
 protected function _isSubscribeAllowed(CM_Model_Stream_Subscribe $streamSubscribe)
 {
     /** @var CM_Model_StreamChannel_Media|CM_StreamChannel_DisallowInterface $streamChannel */
     $streamChannel = $streamSubscribe->getStreamChannel();
     if (!$streamChannel instanceof CM_StreamChannel_DisallowInterface) {
         throw new CM_Exception_Invalid('Streamchannel does not disallow client-connections', ['streamChannel' => $streamChannel]);
     }
     if ($streamSubscribe->getAllowedUntil() < time()) {
         $canSubscribeUntil = $streamChannel->canSubscribe($streamSubscribe->getUser(), $streamSubscribe->getAllowedUntil());
         $streamSubscribe->setAllowedUntil($canSubscribeUntil);
         if ($streamSubscribe->getAllowedUntil() < time()) {
             return false;
         }
     }
     return true;
 }