/**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // get message list
     $this->readMessages();
     $this->readAvailableSenders();
     // columns
     $this->showRecipientColumn = $this->folderID == PMFolderList::FOLDER_DRAFTS || $this->folderID == PMFolderList::FOLDER_OUTBOX;
     $this->showIconColumn = !$this->showRecipientColumn;
     $this->showViewedColumn = $this->showRecipientColumn;
     // marked messages
     $this->markedMessages = PMAction::getMarkedCount();
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // get pm ids
     switch ($this->folderID) {
         // outbox
         case PMFolderList::FOLDER_OUTBOX:
             $sql = "SELECT\t\tpmID \n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_pm\n\t\t\t\t\tWHERE \t\tuserID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND saveInOutbox = 1";
             break;
             // drafts
         // drafts
         case PMFolderList::FOLDER_DRAFTS:
             $sql = "SELECT\t\tpmID \n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_pm\n\t\t\t\t\tWHERE \t\tuserID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND isDraft = 1";
             break;
             // trash
         // trash
         case PMFolderList::FOLDER_TRASH:
             $sql = "SELECT\t\tpmID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE\t\trecipientID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND isDeleted = 1";
             break;
             // inbox & own folders
         // inbox & own folders
         default:
             $sql = "SELECT\t\tpmID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE\t\trecipientID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\t\tAND folderID = " . $this->folderID;
     }
     $pmIDArray = array();
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $pmIDArray[] = $row['pmID'];
     }
     // update session
     $markedMessages = PMAction::getMarkedMessages();
     if ($markedMessages == null || !is_array($markedMessages)) {
         WCF::getSession()->register('markedPMs', $pmIDArray);
     } else {
         $update = false;
         foreach ($pmIDArray as $pmID) {
             if (!in_array($pmID, $markedMessages)) {
                 array_push($markedMessages, $pmID);
                 $update = true;
             }
         }
         if ($update) {
             WCF::getSession()->register('markedPMs', $markedMessages);
         }
     }
     WCF::getSession()->update();
     WCF::getSession()->disableUpdate(true);
     $this->executed();
     HeaderUtil::redirect('index.php?page=PMList&folderID=' . $this->folderID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // get ids
     $sql = "SELECT\tpm.pmID\n\t\t\tFROM\twcf" . WCF_N . "_pm pm\n\t\t\tWHERE\tpm.parentPmID = " . $this->parentPmID . "\n\t\t\t\tAND (\n\t\t\t\t\t(pm.userID = " . WCF::getUser()->userID . " AND pm.saveInOutbox = 1)\n\t\t\t\t\tOR pm.pmID IN (\n\t\t\t\t\t\tSELECT\tpmID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\t\tWHERE\trecipientID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\tAND isDeleted < 2\n\t\t\t\t\t)\n\t\t\t\t)";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->pmIDArray[] = $row['pmID'];
     }
     if (!count($this->pmIDArray)) {
         throw new IllegalLinkException();
     }
     // download
     PMAction::downloadAll(implode(',', $this->pmIDArray));
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     if (!MODULE_PM) {
         throw new IllegalLinkException();
     }
     // check permission
     WCF::getUser()->checkPermission('user.pm.canUsePm');
     if (!WCF::getUser()->userID) {
         throw new PermissionDeniedException();
     }
     parent::show();
     // handle action request
     switch ($this->action) {
         // mark/unmark pm
         case 'mark':
         case 'unmark':
             if ($this->pmID) {
                 require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
                 $a = $this->action;
                 PMAction::$a($this->pmID);
             }
             break;
             // disable notifications
         // disable notifications
         case 'disableNotifications':
             require_once WCF_DIR . 'lib/data/message/pm/PM.class.php';
             PM::disableNotifications();
             if (!isset($_REQUEST['ajax'])) {
                 HeaderUtil::redirect('index.php' . SID_ARG_1ST);
                 exit;
             }
             break;
             // unmark all
         // unmark all
         case 'unmarkAll':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             PMAction::unmarkAll();
             break;
             // empty recycle bin
         // empty recycle bin
         case 'emptyRecycleBin':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             PMAction::emptyRecycleBin();
             break;
             // delete
             // edit unread
             // cancel
             // recover
             // download
             // mark as read/unread
         // delete
         // edit unread
         // cancel
         // recover
         // download
         // mark as read/unread
         case 'delete':
         case 'edit':
         case 'cancel':
         case 'recover':
         case 'download':
         case 'markAsRead':
         case 'markAsUnread':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             $action = new PMAction($this->pmID, $this->folderID);
             $action->{$this->action}();
             break;
             // move to
         // move to
         case 'moveTo':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             $action = new PMAction($this->pmID);
             $action->moveTo($this->folderID);
             break;
             // move marked to
         // move marked to
         case 'moveMarkedTo':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             PMAction::moveMarkedTo($this->folderID);
             break;
             // download marked
             // delete marked
             // cancel marked
         // download marked
         // delete marked
         // cancel marked
         case 'downloadMarked':
         case 'deleteMarked':
         case 'cancelMarked':
             require_once WCF_DIR . 'lib/data/message/pm/PMAction.class.php';
             $a = $this->action;
             PMAction::$a($this->folderID);
             break;
     }
 }