/** * 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; }
/** * 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 $comments1 = \Hubzero\Item\Comment::all()->whereEquals('parent', $reviewid)->whereEquals('item_id', $publication->get('id'))->whereEquals('item_type', 'pubreview')->ordered()->rows(); foreach ($comments1 as $comment1) { $comment1->set('state', $comment1::STATE_DELETED); $comment1->save(); } // 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; }
<?php foreach ($this->related as $line) { if ($line->section == 'Topic') { if ($line->group != '' && $line->scope != '') { $sef = Route::url('index.php?option=com_groups&scope=' . $line->scope . '&pagename=' . $line->alias); } else { $sef = Route::url('index.php?option=com_topics&scope=' . $line->scope . '&pagename=' . $line->alias); } } else { $class = \Components\Publications\Helpers\Html::getRatingClass($line->rating); // Get version authors $authors = $pa->getAuthors($line->version); $authorlist = \Components\Publications\Helpers\Html::showContributors($authors, false, true); // If the user is logged in, get their rating for this publication if (!User::isGuest()) { $mr = new \Components\Publications\Tables\Review($database); $myrating = $mr->loadUserRating($line->id, User::get('id'), $line->version); } else { $myrating = 0; } $myclass = \Components\Publications\Helpers\Html::getRatingClass($myrating); // Get the SEF for the publication if ($line->alias) { $sef = Route::url('index.php?option=' . $this->option . '&alias=' . $line->alias); } else { $sef = Route::url('index.php?option=' . $this->option . '&id=' . $line->id); } } // Make sure we have an SEF, otherwise it's a querystring if (strstr($sef, 'option=')) { $d = '&';