/** * @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(); }
/** * @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; }