Exemplo n.º 1
0
 public function getItems()
 {
     $user = JFactory::getUser();
     $token = JSession::getFormToken();
     $items = parent::getItems();
     $listingId = (int) $this->getState('listing.id');
     $params = $this->getState('params');
     if (count($items) > 0) {
         $commentsRecursive = array();
         foreach ($items as $item) {
             $commentsRecursive[] = $item;
             $commentsRecursive = array_merge($commentsRecursive, $this->getCommentRecursive($item->id));
         }
         $items = $commentsRecursive;
     }
     foreach ($items as $item) {
         $item->comment_edit = $item->comment;
         $item->comment = JUDirectoryFrontHelper::BBCode2Html($item->comment);
         $item->comment = JUDirectoryFrontHelperComment::parseCommentText($item->comment, $listingId);
         $item->can_reply = JUDirectoryFrontHelperPermission::canReplyComment($listingId, $item->id);
         $item->can_vote = JUDirectoryFrontHelperPermission::canVoteComment($listingId, $item->id);
         $item->can_report = JUDirectoryFrontHelperPermission::canReportComment($listingId, $item->id);
         $item->can_subscribe = false;
         $item->can_edit = false;
         $item->can_delete = false;
         $isOwnerComment = JUDirectoryFrontHelperPermission::isCommentOwner($item->id);
         if ($isOwnerComment) {
             $item->can_edit = JUDirectoryFrontHelperPermission::canEditComment($item->id);
             $item->can_delete = JUDirectoryFrontHelperPermission::canDeleteComment($item->id);
             $item->link_delete = JRoute::_('index.php?option=com_judirectory&task=listing.deleteComment&comment_id=' . $item->id . '&' . $token . '=1');
             if ($params->get('can_subscribe_own_comment', 1)) {
                 $item->can_subscribe = true;
                 if ($this->isSubscriber($user->id, $item->id, 'comment')) {
                     $item->is_subscriber = true;
                     $secret = JFactory::getConfig()->get('secret');
                     $type = 'comment';
                     $code = md5($user->id . $user->email . $type . $secret);
                     $subscriptionObject = JUDirectoryFrontHelper::getSubscriptionObjectByType($user->id, $item->id, $type);
                     $item->subscribe_link = JRoute::_('index.php?option=com_judirectory&task=subscribe.remove&sub_id=' . (int) $subscriptionObject->id . '&code=' . $code . '&' . $token . '=1');
                 } else {
                     $item->is_subscriber = false;
                     $item->subscribe_link = JRoute::_('index.php?option=com_judirectory&task=subscribe.save' . '&comment_id=' . $item->id . '&' . $token . '=1');
                 }
             }
         }
         $item->voted_value = $this->getCommentVotedValue($item->id);
     }
     return $items;
 }