Exemple #1
0
 /**
  * Delete a reply
  *
  * @return     void
  */
 public function deletereply()
 {
     $database = App::get('db');
     $publication =& $this->publication;
     // Incoming
     $replyid = Request::getInt('comment', 0);
     // Do we have a review ID?
     if (!$replyid) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_ERROR_NO_REFERENCE_ID'));
         return;
     }
     // Do we have a publication ID?
     if (!$publication->exists()) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_RESOURCE_ID'));
         return;
     }
     // Delete the review
     $reply = new \Hubzero\Item\Comment($database);
     $reply->load($replyid);
     // Permissions check
     if ($reply->created_by != User::get('id')) {
         return;
     }
     $reply->setState($replyid, 2);
     // Redirect
     App::redirect(Route::url($publication->link('reviews')), Lang::txt('PLG_PUBLICATIONS_REVIEWS_COMMENT_DELETED'));
 }
Exemple #2
0
 /**
  * Mark a comment as deleted
  * NOTE: Does not actually delete data. Simply marks record.
  *
  * @return    void
  */
 protected function _delete()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         $this->_login();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_redirect();
     }
     // Initiate a blog comment object
     $comment = new \Hubzero\Item\Comment($this->database);
     $comment->load($id);
     if (User::get('id') != $comment->created_by && !$this->params->get('access-delete-comment')) {
         App::redirect($this->url);
         return;
     }
     // Delete the entry itself
     if (!$comment->setState($id, 2)) {
         $this->setError($comment->getError());
     }
     App::redirect($this->url, Lang::txt('PLG_COURSES_REVIEWS_REMOVED'), 'message');
 }
 /**
  * Delete a comment
  *
  * @return     string
  */
 private function _deletecomment()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Incoming
     $id = Request::getInt('comment', 0);
     if (!$id) {
         return $this->_post();
     }
     // Initiate a whiteboard comment object
     $comment = new \Hubzero\Item\Comment($this->database);
     $comment->load($id);
     $comment->state = 2;
     // Delete the entry itself
     if (!$comment->store()) {
         $this->setError($comment->getError());
     }
     // Return the topics list
     return $this->_post();
 }
Exemple #4
0
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $database = App::get('db');
     switch ($category) {
         case 'answer':
             $database->setQuery("UPDATE `#__answers_responses` SET state='2' WHERE id=" . $referenceid);
             if (!$database->query()) {
                 $this->setError($database->getErrorMsg());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_ANSWER_REMOVED', $parentid);
             break;
         case 'question':
             $upconfig = Component::params('com_members');
             $banking = $upconfig->get('bankAccounts');
             $reward = 0;
             if ($banking) {
                 $reward = $this->getReward($parentid);
             }
             $responders = array();
             // Get all the answers for this question
             $database->setQuery("SELECT r.id, r.created_by FROM `#__answers_responses` AS r WHERE r.question_id=" . $referenceid);
             $answers = $database->loadObjectList();
             if ($answers) {
                 foreach ($answers as $answer) {
                     // Delete response
                     $database->setQuery("UPDATE `#__answers_responses` SET state='2' WHERE id=" . $answer->id);
                     if (!$database->query()) {
                         $this->setError($database->getErrorMsg());
                         return false;
                     }
                     // Collect responders names
                     $responders[] = $answer->created_by;
                 }
             }
             $database->setQuery("UPDATE `#__answers_questions` SET state='2', reward='0' WHERE id=" . $referenceid);
             if (!$database->query()) {
                 $this->setError($database->getErrorMsg());
                 return false;
             }
             if ($banking && $reward) {
                 // Send email to people who answered question with reward
                 if ($responders) {
                     foreach ($responders as $r) {
                         $zuser = User::getInstance($r);
                         if (is_object($zuser)) {
                             if (\Components\Support\Helpers\Utilities::checkValidEmail($zuser->get('email')) && $email) {
                                 $admin_email = Config::get('mailfrom');
                                 $sub = Lang::txt('PLG_SUPPORT_ANSWERS_SUBJECT', Config::get('sitename'), $referenceid);
                                 $from = Lang::txt('PLG_SUPPORT_ANSWERS_TITLE', Config::get('sitename'));
                                 $hub = array('email' => $admin_email, 'name' => $from);
                                 $mes = Lang::txt('PLG_SUPPORT_ANSWERS_BODY') . "\r\n";
                                 $mes .= '----------------------------' . "\r\n\r\n";
                                 $mes .= Lang::txt('PLG_SUPPORT_ANSWERS_QUESTION', $referenceid) . "\r\n";
                                 \Components\Support\Helpers\Utilities::sendEmail($hub, $zuser->get('email'), $sub, $mes);
                             }
                         }
                     }
                 }
                 // get id of asker
                 $database->setQuery("SELECT created_by FROM `#__answers_questions` WHERE id=" . $parentid);
                 $asker = $database->loadResult();
                 if ($asker) {
                     $quser = User::getInstance($asker);
                     if (is_object($quser)) {
                         $asker_id = $quser->get('id');
                     }
                     if (isset($asker_id)) {
                         // Remove hold
                         $sql = "DELETE FROM `#__users_transactions` WHERE category='answers' AND type='hold' AND referenceid=" . $parentid . " AND uid='" . $asker_id . "'";
                         $database->setQuery($sql);
                         if (!$database->query()) {
                             $this->setError($database->getErrorMsg());
                             return false;
                         }
                         // Make credit adjustment
                         $BTL_Q = new \Hubzero\Bank\Teller($database, $asker_id);
                         $credit = $BTL_Q->credit_summary();
                         $adjusted = $credit - $reward;
                         $BTL_Q->credit_adjustment($adjusted);
                     }
                 }
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_QUESTION_REMOVED', $parentid);
             break;
         case 'answercomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_ANSWERS_NOTIFY_COMMENT_REMOVED', $parentid);
             break;
     }
     return $message;
 }
Exemple #5
0
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $this->loadLanguage();
     $database = App::get('db');
     switch ($category) {
         case 'wish':
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wishlist.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'plan.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'owner.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'ownergroup.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'rank.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'tables' . DS . 'wish' . DS . 'attachment.php';
             // Delete the wish
             $wish = new \Components\Wishlist\Tables\Wish($database);
             $wish->delete_wish($referenceid);
             // also delete all votes for this wish
             $objR = new \Components\Wishlist\Tables\Rank($database);
             $objR->remove_vote($referenceid);
             $message .= Lang::txt('PLG_SUPPORT_WISHLIST_NOTIFICATION_OF_WISH_REMOVAL', $parentid);
             break;
         case 'wishcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_WISHLIST_NOTIFICATION_OF_COMMENT_REMOVAL', $parentid);
             break;
     }
     return $message;
 }
Exemple #6
0
            $jxuser = new \Hubzero\User\Profile();
            $jxuser->load(User::get('id'));
            $anonymous = 0;
        }
        ?>
					<img src="<?php 
        echo $jxuser->getPicture($anonymous);
        ?>
" alt="" />
				</p>
				<fieldset>
				<?php 
        if (!User::isGuest()) {
            if ($replyto = Request::getInt('replyto', 0)) {
                $reply = new \Hubzero\Item\Comment($this->database);
                $reply->load($replyto);
                $name = Lang::txt('COM_KB_ANONYMOUS');
                if (!$reply->anonymous) {
                    $xuser = new \Hubzero\User\Profile();
                    $xuser->load($reply->created_by);
                    if (is_object($xuser) && $xuser->get('name')) {
                        $name = '<a href="' . Route::url($xuser->getLink()) . '">' . $this->escape(stripslashes($xuser->get('name'))) . '</a>';
                    }
                }
                ?>
					<blockquote cite="c<?php 
                echo $this->replyto->id;
                ?>
">
						<p>
							<strong><?php 
 /**
  * Retrieves a row from the database
  *
  * @param      string $refid    ID of the database table row
  * @param      string $parent   If the element has a parent element
  * @param      string $category Element type (determines table to look in)
  * @param      string $message  If the element has a parent element
  * @return     array
  */
 public function deleteReportedItem($refid, $parent, $category, $message)
 {
     if (!in_array($category, array('wishcomment', 'answercomment', 'reviewcomment', 'citations', 'citationscomment', 'collection', 'itemcomment', 'coursescomment'))) {
         return null;
     }
     $database = App::get('db');
     $this->loadLanguage();
     $msg = Lang::txt('PLG_SUPPORT_COMMENTS_CONTENT_FOUND_OBJECTIONABLE');
     $comment = new \Hubzero\Item\Comment($database);
     $comment->load($refid);
     if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $comment->content, $matches)) {
         $format = strtolower(trim($matches[1]));
         switch ($format) {
             case 'html':
                 $comment->content = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
                 break;
             case 'wiki':
             default:
                 $comment->content = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
                 break;
         }
     } else {
         $comment->content = '[[Span(' . $msg . ', class="warning")]]';
     }
     $comment->state = 1;
     $comment->store();
     return '';
 }
Exemple #8
0
 /**
  * Delete a reply
  *
  * @return     void
  */
 public function deletereply()
 {
     $database = App::get('db');
     $resource =& $this->resource;
     // Incoming
     $replyid = Request::getInt('comment', 0);
     // Do we have a review ID?
     if (!$replyid) {
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_COMMENT_ERROR_NO_REFERENCE_ID'));
         return;
     }
     // Do we have a resource ID?
     if (!$resource->id) {
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_NO_RESOURCE_ID'));
         return;
     }
     // Delete the review
     $reply = new \Hubzero\Item\Comment($database);
     $reply->load($replyid);
     // Permissions check
     if ($reply->created_by != User::get('id') && !User::authorise('core.admin')) {
         return;
     }
     $reply->setState($replyid, 2);
     App::Redirect(Route::url('index.php?option=' . $this->_option . '&id=' . $resource->id . '&active=reviews', false));
 }
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if (!$this->_canHandle($category)) {
         return null;
     }
     $this->loadLanguage();
     $database = App::get('db');
     switch ($category) {
         case 'review':
             include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'resource.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'review.php';
             // Delete the review
             $review = new \Components\Resources\Tables\Review($database);
             $review->load($referenceid);
             $review->state = 2;
             $review->store();
             // Recalculate the average rating for the parent resource
             $resource = new \Components\Resources\Tables\Resource($database);
             $resource->load($parentid);
             $resource->calculateRating();
             if (!$resource->store()) {
                 $this->setError($resource->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_RESOURCES_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
         case 'reviewcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             $comment->state = 2;
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_RESOURCES_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
     }
     return $message;
 }
 /**
  * Removes an item reported as abusive
  *
  * @param      integer $referenceid ID of the database table row
  * @param      integer $parentid    If the element has a parent element
  * @param      string  $category    Element type (determines table to look in)
  * @param      string  $message     Message to user to append to
  * @return     string
  */
 public function deleteReportedItem($referenceid, $parentid, $category, $message)
 {
     if ($category != 'pubreview' && $category != 'pubreviewcomment') {
         return null;
     }
     $this->loadLanguage();
     $msg = Lang::txt('PLG_SUPPORT_PUBLICATIONS_CONTENT_FOUND_OBJECTIONABLE');
     $database = App::get('db');
     switch ($category) {
         case 'review':
             include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'publication.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_publications' . DS . 'tables' . DS . 'review.php';
             // Delete the review
             $review = new PublicationReview($database);
             $review->load($referenceid);
             //$comment->anonymous = 1;
             if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $review->comment, $matches)) {
                 $format = strtolower(trim($matches[1]));
                 switch ($format) {
                     case 'html':
                         $review->comment = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
                         break;
                     case 'wiki':
                     default:
                         $review->comment = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
                         break;
                 }
             } else {
                 $review->comment = '[[Span(' . $msg . ', class="warning")]]';
             }
             $review->store();
             // Recalculate the average rating for the parent resource
             $pub = new Publication($database);
             $pub->load($parentid);
             $pub->calculateRating();
             $pub->updateRating();
             if (!$pub->store()) {
                 $this->setError($pub->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
         case 'reviewcomment':
             $comment = new \Hubzero\Item\Comment($database);
             $comment->load($referenceid);
             //$comment->state = 2;
             if (preg_match('/^<!-- \\{FORMAT:(.*)\\} -->/i', $comment->content, $matches)) {
                 $format = strtolower(trim($matches[1]));
                 switch ($format) {
                     case 'html':
                         $comment->content = '<!-- {FORMAT:HTML} --><span class="warning">' . $msg . '</span>';
                         break;
                     case 'wiki':
                     default:
                         $comment->content = '<!-- {FORMAT:WIKI} -->[[Span(' . $msg . ', class="warning")]]';
                         break;
                 }
             } else {
                 $comment->content = '[[Span(' . $msg . ', class="warning")]]';
             }
             if (!$comment->store()) {
                 $this->setError($comment->getError());
                 return false;
             }
             $message .= Lang::txt('PLG_SUPPORT_PUBLICATIONS_NOTIFICATION_OF_REMOVAL', $parentid);
             break;
     }
     return $message;
 }