Example #1
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');
 }
Example #2
0
 /**
  * Delete a review
  *
  * @return     void
  */
 public function deletereview()
 {
     $database = App::get('db');
     $publication =& $this->publication;
     // Incoming
     $reviewid = Request::getInt('comment', 0);
     // Do we have a review ID?
     if (!$reviewid) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_ID'));
         return;
     }
     // Do we have a publication ID?
     if (!$publication->exists()) {
         $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_NO_RESOURCE_ID'));
         return;
     }
     $review = new \Components\Publications\Tables\Review($database);
     $review->load($reviewid);
     // Permissions check
     if ($review->created_by != User::get('id')) {
         return;
     }
     $review->state = 2;
     $review->store();
     // Delete the review's comments
     $reply = new \Hubzero\Item\Comment($database);
     $comments1 = $reply->find(array('parent' => $reviewid, 'item_type' => 'pubreview', 'item_id' => $publication->get('id')));
     if (count($comments1) > 0) {
         foreach ($comments1 as $comment1) {
             $reply->setState($comment1->id, 2);
         }
     }
     // Recalculate the average rating for the parent publication
     $publication->table()->calculateRating();
     $publication->table()->updateRating();
     App::redirect(Route::url($publication->link('reviews')), Lang::txt('PLG_PUBLICATIONS_REVIEWS_REVIEW_DELETED'));
     return;
 }
Example #3
0
 /**
  * Delete a review
  *
  * @return     void
  */
 public function deletereview()
 {
     $database = App::get('db');
     $resource =& $this->resource;
     // Incoming
     $reviewid = Request::getInt('comment', 0);
     // Do we have a review ID?
     if (!$reviewid) {
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_NO_ID'));
         return;
     }
     // Do we have a resource ID?
     if (!$resource->id) {
         $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_NO_RESOURCE_ID'));
         return;
     }
     $review = new \Components\Resources\Tables\Review($database);
     $review->load($reviewid);
     // Permissions check
     if ($review->user_id != User::get('id') && !User::authorise('core.admin')) {
         return;
     }
     $review->state = 2;
     $review->store();
     // Delete the review's comments
     $reply = new \Hubzero\Item\Comment($database);
     $comments1 = $reply->find(array('parent' => $reviewid, 'item_type' => 'review', 'item_id' => $resource->id));
     if (count($comments1) > 0) {
         foreach ($comments1 as $comment1) {
             $reply->setState($comment1->id, 2);
         }
     }
     // Recalculate the average rating for the parent resource
     $resource->calculateRating();
     $resource->updateRating();
     App::redirect(Route::url('index.php?option=' . $this->_option . '&id=' . $resource->id . '&active=reviews', false));
 }