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


PHP repository::check_context方法代码示例

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


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

示例1: optional_param

$ctx_id = optional_param('ctx_id', SITEID, PARAM_INT);
// context ID
$repo_id = optional_param('repo_id', 1, PARAM_INT);
// repository ID
$req_path = optional_param('p', '', PARAM_RAW);
// path
$save_path = optional_param('savepath', '/', PARAM_PATH);
$callback = optional_param('callback', '', PARAM_CLEANHTML);
$search_text = optional_param('s', '', PARAM_CLEANHTML);
/// Headers to make it not cacheable
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$err = new stdclass();
$err->client_id = $client_id;
/// Check permissions
if (!(isloggedin() && repository::check_context($ctx_id))) {
    $err->e = get_string('nopermissiontoaccess', 'repository');
    die(json_encode($err));
}
/// Wait as long as it takes for this script to finish
set_time_limit(0);
/// Check for actions that do not need repository ID
switch ($action) {
    // delete a file from filemanger
    case 'delete':
        try {
            if (!($context = get_context_instance(CONTEXT_USER, $USER->id))) {
            }
            $contextid = $context->id;
            $fs = get_file_storage();
            if ($file = $fs->get_file($contextid, 'user_draft', $itemid, '/', $title)) {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:ws.php

示例2: optional_param

$imgurl = optional_param('url', '', PARAM_URL);
if (empty($imgurl)) {
    $imgurl = '-';
}
$imgdataurl = required_param('dataURL', PARAM_RAW);
$draftitemid = optional_param('draftitemid', '', PARAM_INT);
if (empty($draftitemid)) {
    $draftitemid = (int) substr(hexdec(uniqid()), 0, 9) + rand(1, 100);
}
$context = get_context_instance(CONTEXT_USER, $USER->id);
$contextid = optional_param('contextid', SITEID, PARAM_INT);
$imgurlnew = null;
if (empty($contextid)) {
    $contextid = $context->id;
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isloggedin() || !repository::check_context($contextid)) {
    paintweb_send_result($imgurl, $imgurlnew, false, get_string('moodleServer:permissionDenied', 'paintweb'));
}
if (empty($imgdataurl)) {
    paintweb_send_result($imgurl, $imgurlnew, false, get_string('moodleServer:saveEmptyDataUrl', 'paintweb'));
}
// A data URL starts like this:
// data:[<MIME-type>][;charset="<encoding>"][;base64],<data>
// See details at:
// http://en.wikipedia.org/wiki/Data_URI_scheme
$mimetype = 'text/plain';
$base64data = '';
$regex = '/^data:([^;,]+);base64,(.+)$/';
$matches = array();
if (preg_match($regex, $imgdataurl, $matches)) {
    $mimetype = $matches[1];
开发者ID:randycasburn,项目名称:paintweb,代码行数:31,代码来源:imagesave20.php


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