当前位置: 首页>>代码示例>>PHP>>正文


PHP rating_manager::get_plugin_permissions_array方法代码示例

本文整理汇总了PHP中rating_manager::get_plugin_permissions_array方法的典型用法代码示例。如果您正苦于以下问题:PHP rating_manager::get_plugin_permissions_array方法的具体用法?PHP rating_manager::get_plugin_permissions_array怎么用?PHP rating_manager::get_plugin_permissions_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rating_manager的用法示例。


在下文中一共展示了rating_manager::get_plugin_permissions_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course, false, $cm);
$contextid = null;
//now we have a context object throw away the id from the user
$PAGE->set_context($context);
$PAGE->set_url('/rating/rate.php', array('contextid' => $context->id));
if (!confirm_sesskey() || !has_capability('moodle/rating:rate', $context)) {
    echo $OUTPUT->header();
    echo get_string('ratepermissiondenied', 'rating');
    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
$pluginpermissionsarray = $rm->get_plugin_permissions_array($context->id, $component, $ratingarea);
if (!$pluginpermissionsarray['rate']) {
    $result->error = get_string('ratepermissiondenied', 'rating');
    echo json_encode($result);
    die;
} else {
    $params = array('context' => $context, 'component' => $component, 'ratingarea' => $ratingarea, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $userrating, 'rateduserid' => $rateduserid);
    if (!$rm->check_rating_is_valid($params)) {
        echo $OUTPUT->header();
        echo get_string('ratinginvalid', 'rating');
        echo $OUTPUT->footer();
        die;
    }
}
if ($userrating != RATING_UNSET_RATING) {
    $ratingoptions = new stdClass();
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:rate.php

示例2: array

//now we have a context object throw away the id from the user
if (!confirm_sesskey() || $USER->id == $rateduserid) {
    echo $OUTPUT->header();
    echo get_string('ratepermissiondenied', 'rating');
    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;
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:rate_ajax.php

示例3: array

list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course, false, $cm);
$contextid = null;
//now we have a context object throw away the id from the user
$PAGE->set_context($context);
$PAGE->set_url('/rating/rate.php', array('contextid' => $context->id));
if (!confirm_sesskey() || !has_capability('moodle/rating:rate', $context)) {
    echo $OUTPUT->header();
    echo get_string('ratepermissiondenied', 'rating');
    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
$pluginpermissionsarray = $rm->get_plugin_permissions_array($context->id, $component);
if (!$pluginpermissionsarray['rate']) {
    $result->error = get_string('ratepermissiondenied', 'rating');
    echo json_encode($result);
    die;
} else {
    $params = array('context' => $context, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $userrating, 'rateduserid' => $rateduserid);
    if (!$rm->check_rating_is_valid($component, $params)) {
        echo $OUTPUT->header();
        echo get_string('ratinginvalid', 'rating');
        echo $OUTPUT->footer();
        die;
    }
}
if ($userrating != RATING_UNSET_RATING) {
    $ratingoptions = new stdClass();
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:31,代码来源:rate.php

示例4: get_component_ratings_since

 /**
  * Get ratings created since a given time.
  *
  * @param  stdClass $context   context object
  * @param  string $component  component name
  * @param  int $since         the time to check
  * @return array list of ratings db records since the given timelimit
  * @since Moodle 3.2
  */
 public function get_component_ratings_since($context, $component, $since)
 {
     global $DB, $USER;
     $ratingssince = array();
     $where = 'contextid = ? AND component = ? AND (timecreated > ? OR timemodified > ?)';
     $ratings = $DB->get_records_select('rating', $where, array($context->id, $component, $since, $since));
     // Check area by area if we have permissions.
     $permissions = array();
     $rm = new rating_manager();
     foreach ($ratings as $rating) {
         // Check if the permission array for the area is cached.
         if (!isset($permissions[$rating->ratingarea])) {
             $permissions[$rating->ratingarea] = $rm->get_plugin_permissions_array($context->id, $component, $rating->ratingarea);
         }
         if ($permissions[$rating->ratingarea]['view'] and $rating->userid == $USER->id or ($permissions[$rating->ratingarea]['viewany'] or $permissions[$rating->ratingarea]['viewall'])) {
             $ratingssince[$rating->id] = $rating;
         }
     }
     return $ratingssince;
 }
开发者ID:dg711,项目名称:moodle,代码行数:29,代码来源:lib.php


注:本文中的rating_manager::get_plugin_permissions_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。