/**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // set last mark as read time
     WCF::getUser()->setLastMarkAllAsReadTime(TIME_NOW);
     // update subscriptions
     if (WCF::getUser()->userID) {
         require_once WBB_DIR . 'lib/data/thread/SubscribedThread.class.php';
         SubscribedThread::clearSubscriptions();
         $sql = "UPDATE\twbb" . WBB_N . "_board_subscription\n\t\t\t\tSET\temails = 0\n\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
         WCF::getDB()->registerShutdownUpdate($sql);
         $sql = "UPDATE\twbb" . WBB_N . "_thread_subscription\n\t\t\t\tSET\temails = 0\n\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
         WCF::getDB()->registerShutdownUpdate($sql);
     }
     // reset session
     WCF::getSession()->resetUserData();
     WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime');
     $this->executed();
     if (empty($_REQUEST['ajax'])) {
         HeaderUtil::redirect('index.php' . SID_ARG_1ST);
     }
     exit;
 }
 /**
  * Returns the number of unread subscribed threads.
  * 
  * @return	integer
  */
 public function getSubscriptionsUnreadCount()
 {
     if ($this->subscriptionsUnreadCount === null) {
         $this->subscriptionsUnreadCount = 0;
         // update subscriptions status
         $lastSubscriptionsStatusUpdateTime = intval(WCF::getSession()->getVar('lastSubscriptionsStatusUpdateTime'));
         if ($lastSubscriptionsStatusUpdateTime < TIME_NOW - 180) {
             require_once WBB_DIR . 'lib/data/thread/SubscribedThread.class.php';
             $this->subscriptionsUnreadCount = SubscribedThread::getUnreadCount();
             // save status
             WCF::getSession()->register('subscriptionsUnreadCount', $this->subscriptionsUnreadCount);
             WCF::getSession()->register('lastSubscriptionsStatusUpdateTime', TIME_NOW);
         } else {
             $this->subscriptionsUnreadCount = intval(WCF::getSession()->getVar('subscriptionsUnreadCount'));
         }
     }
     return $this->subscriptionsUnreadCount;
 }
 /**
  * @see Page::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     // assign
     $this->boardList->renderBoards();
     WCF::getTPL()->assign(array('threads' => $this->threadList->threads, 'markedThreads' => count(SubscribedThread::getMarkedThreads()), 'daysPrune' => $this->daysPrune, 'allItems' => $this->daysPrune != 1000 ? $this->threadList->countAllThreads() : $this->items));
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     if (!WCF::getUser()->userID) {
         throw new PermissionDeniedException();
     }
     parent::show();
     switch ($this->action) {
         case 'mark':
         case 'unmark':
             if (!is_array($this->threadID)) {
                 $this->threadID = array($this->threadID);
             }
             foreach ($this->threadID as $threadID) {
                 $thread = new SubscribedThread($threadID);
                 if ($thread->threadID) {
                     $thread->{$this->action}();
                 }
             }
             break;
         case 'unmarkAll':
             SubscribedThread::unmarkAll();
             break;
         case 'unsubscribeThread':
             $thread = new SubscribedThread($this->threadID);
             if ($thread->threadID) {
                 $thread->unsubscribe();
             }
             $thread->unmark();
             if (!empty($this->url)) {
                 HeaderUtil::redirect($this->url);
             } else {
                 HeaderUtil::redirect('index.php?page=SubscriptionsList' . SID_ARG_2ND_NOT_ENCODED);
             }
             exit;
         case 'unsubscribeMarkedThreads':
             SubscribedThread::unsubscribeMarked();
             SubscribedThread::unmarkAll();
             if (!empty($this->url)) {
                 HeaderUtil::redirect($this->url);
             } else {
                 HeaderUtil::redirect('index.php?page=SubscriptionsList' . SID_ARG_2ND_NOT_ENCODED);
             }
             exit;
         case 'unsubscribeThreads':
             SubscribedThread::unsubscribeAll();
             SubscribedThread::unmarkAll();
             if (!empty($this->url)) {
                 HeaderUtil::redirect($this->url);
             } else {
                 HeaderUtil::redirect('index.php?page=SubscriptionsList' . SID_ARG_2ND_NOT_ENCODED);
             }
             exit;
         case 'unsubscribeBoard':
             // remove subscriptions
             $sql = "DELETE FROM\twbb" . WBB_N . "_board_subscription\n\t\t\t\t\tWHERE\t\tuserID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND boardID = " . $this->boardID;
             WCF::getDB()->sendQuery($sql);
             // reset user data
             WCF::getSession()->resetUserData();
             WCF::getSession()->unregister('hasSubscriptions');
             HeaderUtil::redirect('index.php?page=SubscriptionsList' . SID_ARG_2ND_NOT_ENCODED);
             exit;
         case 'unsubscribeBoards':
             // remove subscriptions
             $sql = "DELETE FROM\twbb" . WBB_N . "_board_subscription\n\t\t\t\t\tWHERE\t\tuserID = " . WCF::getUser()->userID;
             WCF::getDB()->sendQuery($sql);
             // reset user data
             WCF::getSession()->resetUserData();
             WCF::getSession()->unregister('hasSubscriptions');
             HeaderUtil::redirect('index.php?page=SubscriptionsList' . SID_ARG_2ND_NOT_ENCODED);
             exit;
         default:
             throw new IllegalLinkException();
     }
 }