/**
  * Returns the conversation label management.
  * 
  * @return	array
  */
 public function getLabelManagement()
 {
     WCF::getTPL()->assign(array('cssClassNames' => ConversationLabel::getLabelCssClassNames(), 'labelList' => ConversationLabel::getLabelsByUser()));
     return array('actionName' => 'getLabelManagement', 'template' => WCF::getTPL()->fetch('conversationLabelManagement'), 'maxLabels' => WCF::getSession()->getPermission('user.conversation.maxLabels'), 'labelCount' => count(ConversationLabel::getLabelsByUser()));
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['filter'])) {
         $this->filter = $_REQUEST['filter'];
     }
     if (!in_array($this->filter, UserConversationList::$availableFilters)) {
         $this->filter = '';
     }
     // user settings
     if (WCF::getUser()->conversationsPerPage) {
         $this->itemsPerPage = WCF::getUser()->conversationsPerPage;
     }
     // labels
     $this->labelList = ConversationLabel::getLabelsByUser();
     if (isset($_REQUEST['labelID'])) {
         $this->labelID = intval($_REQUEST['labelID']);
         $validLabel = false;
         foreach ($this->labelList as $label) {
             if ($label->labelID == $this->labelID) {
                 $validLabel = true;
                 break;
             }
         }
         if (!$validLabel) {
             throw new IllegalLinkException();
         }
     }
 }
 /**
  * Converts a conversation into a viewable conversation.
  * 
  * @param	\wcf\data\conversation\Conversation			$conversation
  * @param	\wcf\data\conversation\label\ConversationLabelList	$labelList
  * @return	\wcf\data\conversation\ViewableConversation
  */
 public static function getViewableConversation(Conversation $conversation, ConversationLabelList $labelList = null)
 {
     $conversation = new ViewableConversation($conversation);
     if ($labelList === null) {
         $labelList = ConversationLabel::getLabelsByUser();
     }
     $labels = $labelList->getObjects();
     if (!empty($labels)) {
         $conditions = new PreparedStatementConditionBuilder();
         $conditions->add("conversationID = ?", array($conversation->conversationID));
         $conditions->add("labelID IN (?)", array(array_keys($labels)));
         $sql = "SELECT\tlabelID\n\t\t\t\tFROM\twcf" . WCF_N . "_conversation_label_to_object\n\t\t\t\t" . $conditions;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditions->getParameters());
         $data = array();
         while ($row = $statement->fetchArray()) {
             $conversation->assignLabel($labels[$row['labelID']]);
         }
     }
     return $conversation;
 }
 /**
  * Validates parameters for label assignment form.
  */
 public function validateGetLabelForm()
 {
     if (!WCF::getSession()->getPermission('user.conversation.canUseConversation')) {
         throw new PermissionDeniedException();
     }
     // validate conversation id
     $this->parameters['conversationIDs'] = isset($this->parameters['conversationIDs']) ? ArrayUtil::toIntegerArray($this->parameters['conversationIDs']) : array();
     if (empty($this->parameters['conversationIDs'])) {
         throw new UserInputException('conversationID');
     }
     if (!Conversation::isParticipant($this->parameters['conversationIDs'])) {
         throw new PermissionDeniedException();
     }
     // validate available labels
     $this->labelList = ConversationLabel::getLabelsByUser();
     if (!count($this->labelList)) {
         throw new IllegalLinkException();
     }
 }
 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['id'])) {
         $this->conversationID = intval($_REQUEST['id']);
     }
     if (isset($_REQUEST['messageID'])) {
         $this->messageID = intval($_REQUEST['messageID']);
     }
     if ($this->messageID) {
         $this->message = new ConversationMessage($this->messageID);
         if (!$this->message->messageID) {
             throw new IllegalLinkException();
         }
         $this->conversationID = $this->message->conversationID;
     }
     $this->conversation = Conversation::getUserConversation($this->conversationID, WCF::getUser()->userID);
     if ($this->conversation === null) {
         throw new IllegalLinkException();
     }
     if (!$this->conversation->canRead()) {
         throw new PermissionDeniedException();
     }
     // load labels
     $this->labelList = ConversationLabel::getLabelsByUser();
     $this->conversation = ViewableConversation::getViewableConversation($this->conversation, $this->labelList);
     // posts per page
     if (WCF::getUser()->conversationMessagesPerPage) {
         $this->itemsPerPage = WCF::getUser()->conversationMessagesPerPage;
     }
     $this->canonicalURL = LinkHandler::getInstance()->getLink('Conversation', array('object' => $this->conversation), $this->pageNo ? 'pageNo=' . $this->pageNo : '');
 }
 /**
  * Returns a list of conversation labels.
  * 
  * @return	array<\wcf\data\conversation\label\ConversationLabel>
  */
 protected function getLabels()
 {
     if ($this->labelList === null) {
         $this->labelList = ConversationLabel::getLabelsByUser();
     }
     return $this->labelList->getObjects();
 }