/** * 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 comment object $comment = \Components\Courses\Models\Comment::oneOrFail($id); if (User::get('id') != $comment->get('created_by') && !$this->params->get('access-delete-comment')) { App::redirect($this->url); } $comment->set('state', $comment::STATE_DELETED); // Delete the entry itself if (!$comment->save()) { $this->setError($comment->getError()); } App::redirect($this->url, Lang::txt('PLG_COURSES_REVIEWS_REMOVED'), 'message'); }
* THE SOFTWARE. * * HUBzero is a registered trademark of Purdue University. * * @package hubzero-cms * @author Shawn Rice <*****@*****.**> * @copyright Copyright 2005-2015 HUBzero Foundation, LLC. * @license http://opensource.org/licenses/MIT MIT */ // No direct access defined('_HZEXEC_') or die; $this->css(); $total = 0; $avg = 0; $distribution = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0); $ratings = \Components\Courses\Models\Comment::all()->whereEquals('item_id', $this->course->get('id'))->whereEquals('item_type', 'courses')->whereEquals('parent', 0)->whereEquals('state', array(Components\Courses\Models\Comment::STATE_PUBLISHED))->rows(); if ($ratings) { $sum = 0; $total = count($ratings); foreach ($ratings as $item) { $distribution[$item->rating]++; $sum += $item->rating; } // Find the average of all ratings $avg = $total > 0 ? $sum / $total : 0; // Round to the nearest half $avg = $avg > 0 ? round($avg * 2) / 2 : 0; } switch ($avg) { case 0.5: $cls = ' half-stars';
?> "><?php echo $reply->created('date'); ?> </time></span> </p> <p><?php echo \Hubzero\Utility\String::truncate(stripslashes($reply->get('content')), 300); ?> </p> </blockquote> <?php } } if ($edit) { $comment = \Components\Courses\Models\Comment::oneOrNew($edit); ?> <p class="warning"> <?php echo Lang::txt('PLG_COURSES_REVIEWS_NOTE_EDITING_COMMENT_POSTED'); ?> <br /> <span class="comment-date-at"><?php echo Lang::txt('PLG_COURSES_REVIEWS_AT'); ?> </span> <span class="time"><time datetime="<?php echo $comment->created(); ?> "><?php echo $comment->created('time');