/** * Delete a reply * * @return void */ public function deletereply() { // Is the user logged in? if (User::isGuest()) { $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_LOGIN_NOTICE')); return; } $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 = \Hubzero\Item\Comment::oneOrFail($replyid); // Permissions check if ($reply->get('created_by') != User::get('id') && !User::authorise('core.admin')) { return; } $reply->set('state', \Hubzero\Item\Comment::STATE_DELETED); $reply->save(); App::Redirect(Route::url('index.php?option=' . $this->_option . '&id=' . $resource->id . '&active=reviews', false)); }
/** * 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)); }