/**
  * @see Page::readData()
  */
 public function readData()
 {
     if ($this->messageID) {
         $message = new NMessage($this->messageID);
         $sender = $message->getSender();
         if ($sender instanceof UserMessageSender) {
             $this->user = $sender->getUser();
             $this->username = $this->user->username;
             $this->subject = 'Re: ' . $message->subject;
         }
     } else {
         if ($this->userID) {
             $this->user = new LWUser($this->userID);
             $this->username = $this->user->username;
         }
     }
     parent::readData();
 }
Пример #2
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (WCF::getUser()->hasDiliziumFeature("messageFolders")) {
         $this->folders = MessageFolder::getByUserID(WCF::getUser()->userID);
         if (WCF::getUser()->new_message && $this->active === null && !$this->checked) {
             // show new messages
             $this->messages = NMessage::getByUserID(WCF::getUser()->userID, null, null, true, self::MESSAGES_FOLDERS + 1, ($this->pageNo - 1) * self::MESSAGES_FOLDERS);
             foreach ($this->messages as $message) {
                 if (!isset($this->spare[$message->folderID])) {
                     $this->spare[$message->folderID] = $message->folderID;
                 }
             }
         } else {
             // show requested messages
             if ($this->active === null && !$this->checked) {
                 $this->active = array();
             }
             $this->messages = NMessage::getByUserID(WCF::getUser()->userID, $this->checked, $this->active, false, self::MESSAGES_FOLDERS + 1, ($this->pageNo - 1) * self::MESSAGES_FOLDERS);
         }
         $this->nextPage = count($this->messages) > self::MESSAGES_FOLDERS;
         if ($this->nextPage) {
             array_pop($this->messages);
         }
     } else {
         $this->pageNo = 1;
         $this->messages = NMessage::getByUserID(WCF::getUser()->userID, $this->checked, $this->active, false, self::MESSAGES);
     }
     // update data
     $messageUpdates = array();
     foreach ($this->messages as $message) {
         if (!$message->viewed) {
             $messageUpdates[] = $message->messageID;
         }
     }
     if (count($messageUpdates)) {
         NMessageEditor::view($messageUpdates, WCF::getUser()->userID);
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     if (!WCF::getUser()->userID) {
         die('invalid userID');
     }
     if (!preg_match('/^(?:check(?:|All|Visible)|delete(?:|All|(?:Unc|C)hecked)|notify|uncheck(?:Checked|Visible))$/', $this->command)) {
         die('invalid command');
     }
     // message-related commands
     if (preg_match('/^(?:check|delete|notify)$/', $this->command)) {
         $message = new NMessage($this->messageID);
         if (!$message->messageID || $message->recipentID != WCF::getUser()->userID) {
             die('invalid messageID');
         }
         if ($this->command == 'notify' && !$message->getSender() instanceof UserMessageSender) {
             die('invalid messageID');
         }
         $editor = $message->getEditor();
     }
     if ($this->command == 'check') {
         $editor->check();
     }
     if ($this->command == 'checkAll') {
         NMessageEditor::checkAll(WCF::getUser()->userID);
     }
     if ($this->command == 'checkVisible') {
         NMessageEditor::checkAll(WCF::getUser()->userID, 1, $this->folderIDs);
     }
     if ($this->command == 'delete') {
         $editor->delete();
     }
     if ($this->command == 'deleteAll') {
         NMessageEditor::deleteAll(WCF::getUser()->userID);
     }
     if ($this->command == 'deleteChecked') {
         NMessageEditor::deleteAll(WCF::getUser()->userID, 1);
     }
     if ($this->command == 'deleteUnchecked') {
         NMessageEditor::deleteAll(WCF::getUser()->userID, 0);
     }
     if ($this->command == 'notify') {
         $message->notify();
     }
     if ($this->command == 'uncheckChecked') {
         NMessageEditor::checkAll(WCF::getUser()->userID, 0);
     }
     if ($this->command == 'uncheckVisible') {
         NMessageEditor::checkAll(WCF::getUser()->userID, 0, $this->folderIDs);
     }
     $this->executed();
     // message-related commands
     if (preg_match('/^(?:check|delete|notify)$/', $this->command)) {
         die('done');
     }
     $matches = array();
     $referrer = $_SERVER["HTTP_REFERER"];
     $url = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
     preg_match('/^https?:(\\/\\/[^\\/]*)\\/[^\\?]*\\??[^\\?]*$/', $url, $matches);
     $base = $matches[1];
     preg_match('/^https?:(\\/\\/[^\\/]*)\\/[^\\?]*\\??[^\\?]*$/', $referrer, $matches);
     $base2 = $matches[1];
     if ($base == $base2) {
         header('Location: ' . $referrer);
     } else {
         header('Location: index.php?page=Messages');
     }
     exit;
 }