本文整理汇总了PHP中rating_manager::check_item_and_owner方法的典型用法代码示例。如果您正苦于以下问题:PHP rating_manager::check_item_and_owner方法的具体用法?PHP rating_manager::check_item_and_owner怎么用?PHP rating_manager::check_item_and_owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rating_manager
的用法示例。
在下文中一共展示了rating_manager::check_item_and_owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
echo $OUTPUT->footer();
die;
}
$rm = new rating_manager();
//check the module rating permissions
//doing this check here rather than within rating_manager::get_ratings so we can return a json error response
$pluginrateallowed = true;
$pluginpermissionsarray = null;
if ($context->contextlevel == CONTEXT_MODULE) {
$plugintype = 'mod';
$pluginname = $cm->modname;
$pluginpermissionsarray = $rm->get_plugin_permissions_array($context->id, $plugintype, $pluginname);
$pluginrateallowed = $pluginpermissionsarray['rate'];
if ($pluginrateallowed) {
//check the item exists and isn't owned by the current user
$pluginrateallowed = $rm->check_item_and_owner($plugintype, $pluginname, $itemid);
}
}
if (!$pluginrateallowed || !has_capability('moodle/rating:rate', $context)) {
$result->error = get_string('ratepermissiondenied', 'rating');
echo json_encode($result);
die;
}
$PAGE->set_url('/lib/rate.php', array('contextid' => $context->id));
//rating options used to update the rating then retrieve the aggregate
$ratingoptions = new stdClass();
$ratingoptions->context = $context;
$ratingoptions->itemid = $itemid;
$ratingoptions->scaleid = $scaleid;
$ratingoptions->userid = $USER->id;
if ($userrating != RATING_UNSET_RATING) {