示例#1
0
 function display($mode = '')
 {
     $message = $this->msg;
     $this->id = $message->id;
     $this->catid = $message->catid;
     $this->thread = $message->thread;
     // Link to individual message
     if ($this->config->ordering_system == 'replyid') {
         $this->numLink = CKunenaLink::GetSamePageAnkerLink($this->id, '#' . $this->replynum);
     } else {
         $this->numLink = CKunenaLink::GetSamePageAnkerLink($this->id, '#' . $this->id);
     }
     // New post suffix for class
     if ($message->new) {
         $this->msgsuffix = '-new';
     }
     // Add attachments
     if (!empty($message->attachments)) {
         $this->attachments = $message->attachments;
     }
     $subject = $message->subject;
     $this->resubject = JString::strtolower(JString::substr($subject, 0, JString::strlen(JText::_('COM_KUNENA_POST_RE')))) == JString::strtolower(JText::_('COM_KUNENA_POST_RE')) ? $subject : JText::_('COM_KUNENA_POST_RE') . ' ' . $subject;
     $this->subjectHtml = KunenaParser::parseText($subject);
     $this->messageHtml = KunenaParser::parseBBCode($message->message, $this);
     //Show admins the IP address of the user:
     if ($message->ip && (CKunenaTools::isAdmin() || CKunenaTools::isModerator($this->my->id, $this->catid) && !$this->config->hide_ip)) {
         $this->ipLink = CKunenaLink::GetMessageIPLink($message->ip);
     }
     $this->profile = KunenaFactory::getUser($message->userid);
     // Modify profile values by integration
     $triggerParams = array('userid' => $message->userid, 'userinfo' => &$this->profile);
     $integration = KunenaFactory::getProfile();
     $integration->trigger('profileIntegration', $triggerParams);
     // Choose username
     $this->userid = $this->profile->userid;
     $this->username = $this->config->username ? $this->profile->username : $this->profile->name;
     if ((!$this->username || !$message->userid || $this->config->changename) && $message->name) {
         $this->username = $message->name;
     }
     if ($this->params->get('avatarPosition') == 'left' || $this->params->get('avatarPosition') == 'right') {
         $avatar = $this->profile->getAvatarLink('kavatar', 'post');
     } else {
         $avatar = $this->profile->getAvatarLink('kavatar', 'welcome');
     }
     if ($avatar) {
         $this->avatar = '<span class="kavatar">' . $avatar . '</span>';
     }
     if ($this->config->showuserstats) {
         $activityIntegration = KunenaFactory::getActivityIntegration();
         if ($this->config->userlist_usertype) {
             $this->usertype = $this->profile->getType($this->catid);
         }
         $this->userrankimage = $this->profile->getRank($this->catid, 'image');
         $this->userranktitle = $this->profile->getRank($this->catid, 'title');
         $this->userposts = $this->profile->posts;
         $this->userpoints = $activityIntegration->getUserPoints($this->profile->userid);
         $this->usermedals = $activityIntegration->getUserMedals($this->profile->userid);
     }
     //karma points and buttons
     $this->userkarma_minus = $this->userkarma_plus = '';
     if ($this->config->showkarma && $this->profile->userid) {
         $this->userkarma = JText::_('COM_KUNENA_KARMA') . ": " . $this->profile->karma;
         if ($this->my->id && $this->my->id != $this->profile->userid) {
             $this->userkarma_minus = CKunenaLink::GetKarmaLink('decrease', $this->catid, $this->id, $this->userid, '<span class="kkarma-minus" alt="Karma-" border="0" title="' . JText::_('COM_KUNENA_KARMA_SMITE') . '"> </span>');
             $this->userkarma_plus = CKunenaLink::GetKarmaLink('increase', $this->catid, $this->id, $this->userid, '<span class="kkarma-plus" alt="Karma+" border="0" title="' . JText::_('COM_KUNENA_KARMA_APPLAUD') . '"> </span>');
         }
     }
     $this->profilelink = $this->profile->profileIcon('profile');
     $this->personaltext = $this->profile->personalText;
     $this->signatureHtml = KunenaParser::parseBBCode($this->profile->signature);
     //Thankyou info and buttons
     if ($this->config->showthankyou && $this->profile->userid && $mode != 'threaded') {
         require_once KPATH_SITE . '/lib/kunena.thankyou.php';
         $thankyou = new CKunenaThankyou();
         $this->total_thankyou = $thankyou->getThankYouUser($this->id);
         $this->thankyou = array_slice($this->total_thankyou, 0, $this->config->thankyou_max);
         if ($this->my->id && $this->my->id != $this->profile->userid) {
             $this->message_thankyou = CKunenaLink::GetThankYouLink($this->catid, $this->id, $this->userid, CKunenaTools::showButton('thankyou', JText::_('COM_KUNENA_BUTTON_THANKYOU')), JText::_('COM_KUNENA_BUTTON_THANKYOU_LONG'), 'kicon-button kbuttonuser btn-left');
         }
     }
     if (!$message->hold && (CKunenaTools::isModerator($this->my->id, $this->catid) || !$this->topicLocked)) {
         //user is allowed to reply/quote
         $this->captcha = KunenaSpamRecaptcha::getInstance();
         if ($this->my->id && (CKunenaTools::isModerator($this->my->id, $this->catid) || $this->me->posts >= $this->config->captcha_post_limit)) {
             $this->message_quickreply = CKunenaLink::GetTopicPostReplyLink('reply', $this->catid, $this->id, CKunenaTools::showButton('reply', JText::_('COM_KUNENA_BUTTON_QUICKREPLY')), 'nofollow', 'kicon-button kbuttoncomm btn-left kqreply', JText::_('COM_KUNENA_BUTTON_QUICKREPLY_LONG'), ' id="kreply' . $this->id . '"');
         }
         $this->message_reply = CKunenaLink::GetTopicPostReplyLink('reply', $this->catid, $this->id, CKunenaTools::showButton('reply', JText::_('COM_KUNENA_BUTTON_REPLY')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_REPLY_LONG'));
         $this->message_quote = CKunenaLink::GetTopicPostReplyLink('quote', $this->catid, $this->id, CKunenaTools::showButton('quote', JText::_('COM_KUNENA_BUTTON_QUOTE')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_QUOTE_LONG'));
     } else {
         //user is not allowed to write a post
         if ($this->topicLocked) {
             $this->message_closed = JText::_('COM_KUNENA_POST_LOCK_SET');
         } else {
             $this->message_closed = JText::_('COM_KUNENA_VIEW_DISABLED');
         }
     }
     $this->msgclass = 'kmsg';
     //Offer an moderator a few tools
     if (CKunenaTools::isModerator($this->my->id, $this->catid)) {
         unset($this->message_closed);
         $this->message_edit = CKunenaLink::GetTopicPostReplyLink('edit', $this->catid, $this->id, CKunenaTools::showButton('edit', JText::_('COM_KUNENA_BUTTON_EDIT')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_EDIT_LONG'));
         $this->message_moderate = CKunenaLink::GetTopicPostReplyLink('moderate', $this->catid, $this->id, CKunenaTools::showButton('moderate', JText::_('COM_KUNENA_BUTTON_MODERATE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_MODERATE_LONG'));
         if ($message->hold == 1) {
             $this->message_publish = CKunenaLink::GetTopicPostLink('approve', $this->catid, $this->id, CKunenaTools::showButton('approve', JText::_('COM_KUNENA_BUTTON_APPROVE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_APPROVE_LONG'));
             $this->msgclass .= ' kunapproved';
         }
         if ($message->hold == 2 || $message->hold == 3) {
             $this->msgclass .= ' kunapproved kdeleted';
             $this->message_undelete = CKunenaLink::GetTopicPostLink('undelete', $this->catid, $this->id, CKunenaTools::showButton('undelete', JText::_('COM_KUNENA_BUTTON_UNDELETE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNDELETE_LONG'));
             $this->message_permdelete = CKunenaLink::GetTopicPostLink('permdelete', $this->catid, $this->id, CKunenaTools::showButton('permdelete', JText::_('COM_KUNENA_BUTTON_PERMDELETE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_PERMDELETE_LONG'));
         } else {
             $this->message_delete = CKunenaLink::GetTopicPostLink('delete', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_LONG'));
         }
     } else {
         if ($this->config->useredit && $this->my->id && $this->my->id == $this->profile->userid) {
             //Now, if the viewer==author and the viewer is allowed to edit his/her own post then offer an 'edit' link
             if ($message->hold != 2 && CKunenaTools::editTimeCheck($message->modified_time, $message->time)) {
                 $this->message_edit = CKunenaLink::GetTopicPostReplyLink('edit', $this->catid, $this->id, CKunenaTools::showButton('edit', JText::_('COM_KUNENA_BUTTON_EDIT')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_EDIT_LONG'));
                 if ($this->config->userdeletetmessage == '1') {
                     if ($this->replynum == $this->replycnt) {
                         $this->message_delete = CKunenaLink::GetTopicPostLink('delete', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_LONG'));
                     }
                 } else {
                     if ($this->config->userdeletetmessage == '2') {
                         $this->message_delete = CKunenaLink::GetTopicPostLink('delete', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_LONG'));
                     }
                 }
             }
         }
     }
     $this->class = 'class="' . $this->msgclass . '"';
     if (!$mode) {
         $templatefile = '/view/message.php';
     } else {
         $templatefile = "/view/message.{$mode}.php";
     }
     CKunenaTools::loadTemplate($templatefile, false, $this->templatepath);
 }