Esempio n. 1
0
 protected function canDelete($record)
 {
     $rootComment = JUDirectoryFrontHelperComment::getRootComment();
     if (isset($record->id) && $record->id == $rootComment->id) {
         return false;
     }
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         return JUDirectoryFrontHelperPermission::canDeleteComment($record->id);
     }
     return parent::canDelete($record);
 }
Esempio n. 2
0
 public function deleteComment()
 {
     JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $commentId = $app->input->getInt('comment_id', 0);
     $commentObject = JUDirectoryFrontHelperComment::getCommentObject($commentId);
     $listingId = $commentObject->listing_id;
     $canDeleteComment = JUDirectoryFrontHelperPermission::canDeleteComment($commentId);
     if ($canDeleteComment) {
         $commentModel = $this->getModel('Modcomment', 'JUDirectoryModel');
         if ($commentModel->delete($commentId)) {
             $this->setMessage(JText::_('COM_JUDIRECTORY_DELETE_COMMENT_SUCCESSFULLY'));
             $this->setRedirect(JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingId), false));
             return true;
         }
     }
     $this->setMessage(JText::_('COM_JUDIRECTORY_DELETE_COMMENT_FAILED'), 'error');
     $this->setRedirect(JRoute::_(JUDirectoryHelperRoute::getListingRoute($listingId), false));
     return false;
 }
Esempio n. 3
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;
 }