本文整理汇总了PHP中Rating::permRate方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::permRate方法的具体用法?PHP Rating::permRate怎么用?PHP Rating::permRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::permRate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
require_once 'include/course_settings.php';
$is_link = false;
if ($_GET['rtype'] == 'blogpost') {
$setting_id = SETTING_BLOG_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'course') {
$setting_id = SETTING_COURSE_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'forum_post') {
$setting_id = SETTING_FORUM_RATING_ENABLE;
} elseif ($_GET['rtype'] == 'link') {
$is_link = true; //there is no rating setting for social bookmarks, rating is always enabled
}
if ($is_link || setting_get($setting_id, $course_id) == 1) {
if (Rating::permRate($is_editor, $uid, $course_id, $_GET['rtype'])) {
$widget = $_GET['widget'];
$rtype = $_GET['rtype'];
$rid = intval($_GET['rid']);
$value = intval($_GET['value']);
//response array
$response = array();
$rating = new Rating($widget, $rtype, $rid);
$had_rated = $rating->userHasRated($uid);
$action = $rating->castRating($value, $uid);
if ($widget == 'up_down') {
$up_value = $rating->getUpRating();
$down_value = $rating->getDownRating();
示例2: put
public function put($isEditor, $uid, $courseId)
{
global $langUserHasRated, $langRatingVote, $langRatingVotes, $langRatingAverage, $langRateIt, $urlServer;
$this->rating_add_js();
if ($this->widget == 'up_down') {
$out = "<div class=\"rating\">";
$onclick_up = $onclick_down = "";
//disable icons when user hasn't permission to vote
if (Rating::permRate($isEditor, $uid, $courseId, $this->rtype)) {
$onclick_up = "onclick=\"Rate('" . $this->widget . "'," . $this->rid . ",'" . $this->rtype . "',1,'" . $urlServer . "modules/rating/rate.php')\"";
$onclick_down = "onclick=\"Rate('" . $this->widget . "'," . $this->rid . ",'" . $this->rtype . "',-1,'" . $urlServer . "modules/rating/rate.php')\"";
}
$has_rated = $this->userHasRated($uid);
if ($has_rated !== false) {
$value = $has_rated;
$has_rated = true;
if ($value == 1) {
$img_up = 'thumbs_up_active.png';
$img_down = 'thumbs_down_inactive.png';
} elseif ($value == -1) {
$img_up = 'thumbs_up_inactive.png';
$img_down = 'thumbs_down_active.png';
}
} else {
$has_rated = false;
$img_up = 'thumbs_up_inactive.png';
$img_down = 'thumbs_down_inactive.png';
}
$out .= "<img id=\"rate_" . $this->rid . "_img_up\" src=\"" . $urlServer . "modules/rating/" . $img_up . "\" " . $onclick_up . "/> ";
$out .= "<span id=\"rate_" . $this->rid . "_up\">" . $this->getUpRating() . "</span> ";
$out .= "<img id=\"rate_" . $this->rid . "_img_down\" src=\"" . $urlServer . "modules/rating/" . $img_down . "\" " . $onclick_down . "/> ";
$out .= "<span id=\"rate_" . $this->rid . "_down\">" . $this->getDownRating() . "</span>";
$out .= "<div class=\"smaller\" id=\"rate_msg_" . $this->rid . "\">";
if ($has_rated) {
$out .= $langUserHasRated;
}
$out .= "</div>";
$out .= "</div>";
} elseif ($this->widget == 'thumbs_up') {
$out = "<div class=\"rating\">";
$onclick_up = "";
//disable icons when user hasn't permission to vote
if (Rating::permRate($isEditor, $uid, $courseId, $this->rtype)) {
$onclick_up = "onclick=\"Rate('" . $this->widget . "'," . $this->rid . ",'" . $this->rtype . "',1,'" . $urlServer . "modules/rating/rate.php')\"";
}
$has_rated = $this->userHasRated($uid);
if ($has_rated !== false) {
$has_rated = true;
$img_up = 'thumbs_up_active.png';
} else {
$has_rated = false;
$img_up = 'thumbs_up_inactive.png';
}
$out .= "<img id=\"rate_" . $this->rid . "_img\" src=\"" . $urlServer . "modules/rating/" . $img_up . "\" " . $onclick_up . "/> ";
$out .= "<span id=\"rate_" . $this->rid . "_up\">" . $this->getThumbsUpRating() . "</span>";
$out .= "<div class=\"smaller\" id=\"rate_msg_" . $this->rid . "\">";
if ($has_rated) {
$out .= $langUserHasRated;
}
$out .= "</div>";
$out .= "</div>";
} elseif ($this->widget == 'fivestar') {
$out = "<div class=\"rating\">";
$num_ratings = $this->getRatingsNum();
if (Rating::permRate($isEditor, $uid, $courseId, $this->rtype)) {
$avg = $this->getFivestarRating();
$avg_datavalue = 'data-rateit-value="' . $avg . '" data-rateit-ispreset="true" data-rateit-readonly="true"';
$out .= '<div class="rateit" id="rateit-avg-' . $this->rtype . '-' . $this->rid . '" ' . $avg_datavalue . '></div>';
$out .= '<div id="rateit-info-' . $this->rtype . '-' . $this->rid . '">';
if ($num_ratings['fivestar'] != 0) {
$out .= $langRatingAverage . $avg . ', ';
}
if ($num_ratings['fivestar'] == 1) {
$out .= $num_ratings['fivestar'] . $langRatingVote . '</div>';
} else {
$out .= $num_ratings['fivestar'] . $langRatingVotes . '</div>';
}
$out .= '<div id="rateitwrapdiv-' . $this->rtype . '-' . $this->rid . '" ><a href="javascript:void(0)">' . $langRateIt . '</a></div>';
$userRating = "";
if ($this->userHasRated($uid) !== false) {
$userRating = 'data-rateit-value="' . $this->getFivestarUserRating($uid) . '"';
}
$out .= '<div class="hideratewidget" id="rateitwidgetdiv-' . $this->rtype . '-' . $this->rid . '">';
$out .= '<div class="rateit" id="rateit-' . $this->rtype . '-' . $this->rid . '" ' . $userRating . '></div>';
$out .= '</div>';
$out .= '<script type="text/javascript">';
$out .= ' $("#rateitwrapdiv-' . $this->rtype . '-' . $this->rid . '").click(function() {$("#rateitwidgetdiv-' . $this->rtype . '-' . $this->rid . '").toggle()});';
$out .= ' $("#rateit-' . $this->rtype . '-' . $this->rid . '").bind(\'rated\', function (event, value) {
$.ajax({
url: \'' . $urlServer . 'modules/rating/rate.php\',
data: { rtype: "' . $this->rtype . '", rid: ' . $this->rid . ', widget: "' . $this->widget . '",value: value },
type: \'GET\',
success: function (data) {
response = JSON.parse(data);
$("#rateit-info-' . $this->rtype . '-' . $this->rid . '").text(response[0]);
$("#rateit-avg-' . $this->rtype . '-' . $this->rid . '").rateit("value",response[1]);
},
});
});';
$out .= ' $("#rateit-' . $this->rtype . '-' . $this->rid . '").bind(\'reset\', function (event, value) {
//.........这里部分代码省略.........