• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_context_info_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_context_info_array函数的典型用法代码示例。如果您正苦于以下问题:PHP get_context_info_array函数的具体用法?PHP get_context_info_array怎么用?PHP get_context_info_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_content

 function get_content()
 {
     global $CFG, $PAGE;
     if (!$CFG->usecomments) {
         $this->content->text = '';
         if ($this->page->user_is_editing()) {
             $this->content->text = get_string('disabledcomments');
         }
         return $this->content;
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return null;
     }
     $this->content->footer = '';
     $this->content->text = '';
     list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
     $args = new stdClass();
     $args->context = $PAGE->context;
     $args->course = $course;
     $args->area = 'page_comments';
     $args->itemid = 0;
     // set 'env' to tell moodle tweak ui for this block
     $args->env = 'block_comments';
     $args->component = 'block_comments';
     $args->linktext = get_string('showcomments');
     $comment = new comment($args);
     $comment->set_view_permission(true);
     $this->content = new stdClass();
     $this->content->text = $comment->output(true);
     $this->content->footer = '';
     return $this->content;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:35,代码来源:block_comments.php


示例2: ga_trackurl

/**
 * Local Redirect
 *
 * This local plugin that adds a 'friendly url' version of Google analytics
 * to Moodle
 *
 * @package    local
 * @subpackage local_googleanalytics
 * @copyright  2013 Bas Brands, www.basbrands.nl
 * @author 	   Bas Brands and Gavin Henrick.
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

function ga_trackurl() {
    global $CFG, $DB, $PAGE, $COURSE, $OUTPUT;

    $pageinfo = get_context_info_array($PAGE->context->id);

    $trackurl = array();

    if ($COURSE->id == 1) {
        return '';
    }

    // Adds course category name.
    if (isset($pageinfo[1]->category)) {
        if ($category = $DB->get_record('course_categories', array('id'=>$pageinfo[1]->category))) {
            $trackurl[] = urlencode($category->name);
        }
    }

    // Adds course full name.
    if (isset($pageinfo[1]->fullname)) {
        $trackurl[] = urlencode($pageinfo[1]->fullname);
    }

    // Adds activity name.
    if (isset($pageinfo[2]->name)) {
        $trackurl[] = urlencode($pageinfo[2]->name);
    }

    return implode('/', $trackurl);
}
开发者ID:anilch,项目名称:Personel,代码行数:43,代码来源:lib.php


示例3: analytics_trackurl

/**
 * Analytics
 *
 * This module provides extensive analytics on a platform of choice
 * Currently support Google Analytics and Piwik
 *
 * @package    local_analytics
 * @copyright  David Bezemer <[email protected]>, www.davidbezemer.nl
 * @author     David Bezemer <[email protected]>, Bas Brands <[email protected]>, Gavin Henrick <[email protected]>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function analytics_trackurl()
{
    global $DB, $PAGE;
    $pageinfo = get_context_info_array($PAGE->context->id);
    $trackurl = "'/";
    // Adds course category name.
    if (isset($pageinfo[1]->category)) {
        if ($category = $DB->get_record('course_categories', array('id' => $pageinfo[1]->category))) {
            $cats = explode("/", $category->path);
            foreach (array_filter($cats) as $cat) {
                if ($categorydepth = $DB->get_record("course_categories", array("id" => $cat))) {
                    $trackurl .= urlencode($categorydepth->name) . '/';
                }
            }
        }
    }
    // Adds course full name.
    if (isset($pageinfo[1]->fullname)) {
        if (isset($pageinfo[2]->name)) {
            $trackurl .= urlencode($pageinfo[1]->fullname) . '/';
        } else {
            if ($PAGE->user_is_editing()) {
                $trackurl .= urlencode($pageinfo[1]->fullname) . '/' . get_string('edit');
            } else {
                $trackurl .= urlencode($pageinfo[1]->fullname) . '/' . get_string('view');
            }
        }
    }
    // Adds activity name.
    if (isset($pageinfo[2]->name)) {
        $trackurl .= urlencode($pageinfo[2]->modname) . '/' . urlencode($pageinfo[2]->name);
    }
    $trackurl .= "'";
    return $trackurl;
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:46,代码来源:guniversal.php


示例4: get_listing

 /**
  * Get file listing
  *
  * @param string $encodedpath
  * @return mixed
  */
 public function get_listing($encodedpath = '', $page = '')
 {
     global $CFG, $USER, $OUTPUT;
     $ret = array();
     $ret['dynload'] = true;
     $ret['nosearch'] = true;
     $ret['nologin'] = true;
     $list = array();
     if (!empty($encodedpath)) {
         $params = unserialize(base64_decode($encodedpath));
         if (is_array($params)) {
             $component = is_null($params['component']) ? NULL : clean_param($params['component'], PARAM_COMPONENT);
             $filearea = is_null($params['filearea']) ? NULL : clean_param($params['filearea'], PARAM_AREA);
             $itemid = is_null($params['itemid']) ? NULL : clean_param($params['itemid'], PARAM_INT);
             $filepath = is_null($params['filepath']) ? NULL : clean_param($params['filepath'], PARAM_PATH);
             $filename = is_null($params['filename']) ? NULL : clean_param($params['filename'], PARAM_FILE);
             $context = get_context_instance_by_id(clean_param($params['contextid'], PARAM_INT));
         }
     } else {
         $itemid = null;
         $filename = null;
         $filearea = null;
         $filepath = null;
         $component = null;
         if (!empty($this->context)) {
             list($context, $course, $cm) = get_context_info_array($this->context->id);
             if (is_object($course)) {
                 $context = get_context_instance(CONTEXT_COURSE, $course->id);
             } else {
                 $context = get_system_context();
             }
         } else {
             $context = get_system_context();
         }
     }
     $browser = get_file_browser();
     $list = array();
     if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
         // build file tree
         $element = repository_local_file::retrieve_file_info($fileinfo, $this);
         $nonemptychildren = $element->get_non_empty_children();
         foreach ($nonemptychildren as $child) {
             $list[] = (array) $child->get_node();
         }
     } else {
         // if file doesn't exist, build path nodes root of current context
         $fileinfo = $browser->get_file_info($context, null, null, null, null, null);
     }
     // build path navigation
     $ret['path'] = array();
     $element = repository_local_file::retrieve_file_info($fileinfo, $this);
     for ($level = $element; $level; $level = $level->get_parent()) {
         if ($level == $element || !$level->can_skip()) {
             array_unshift($ret['path'], $level->get_node_path());
         }
     }
     $ret['list'] = array_filter($list, array($this, 'filter'));
     return $ret;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:65,代码来源:lib.php


示例5: question_pluginfile_joomdle

function question_pluginfile_joomdle($course, $context, $component, $filearea, $args, $forcedownload)
{
    global $DB, $CFG;
    list($context, $course, $cm) = get_context_info_array($context->id);
    $qubaid = (int) array_shift($args);
    $filename = array_shift($args);
    $module = $DB->get_field('question_usages', 'component', array('id' => $qubaid));
    return question_preview_question_pluginfile_joomdle($course, $context, $component, $filearea, $qubaid, $slot, $filename, $forcedownload);
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:9,代码来源:pluginfilelib.php


示例6: qformat_xhtml_questiontext_preview_pluginfile

/**
 * Serve question files when they are displayed in this export format.
 *
 * @param context $previewcontext the quiz context
 * @param int $questionid the question id.
 * @param context $filecontext the file (question) context
 * @param string $filecomponent the component the file belongs to.
 * @param string $filearea the file area.
 * @param array $args remaining file args.
 * @param bool $forcedownload.
 * @param array $options additional options affecting the file serving.
 */
function qformat_xhtml_questiontext_preview_pluginfile($context, $questionid,
        $args, $forcedownload, array $options = array()) {
    global $CFG;

    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);

    question_require_capability_on($questionid, 'view');

    question_send_questiontext_file($questionid, $args, $forcedownload, $options);
}
开发者ID:verbazend,项目名称:AWFA,代码行数:23,代码来源:lib.php


示例7: offlinequiz_statistics_questiontext_preview_pluginfile

/**
 * Serve questiontext files in the question text when they are displayed in this report.
 *
 * @package  mod_offlinequiz
 * @category files
 * @param stdClass $context the context
 * @param int $questionid the question id
 * @param array $args remaining file args
 * @param bool $forcedownload
 * @param array $options additional options affecting the file serving
 */
function offlinequiz_statistics_questiontext_preview_pluginfile($context, $questionid, $args, $forcedownload, array $options = array())
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/offlinequiz/locallib.php';
    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);
    // Assume only trusted people can see this report. There is no real way to
    // validate questionid, becuase of the complexity of random quetsions.
    require_capability('offlinequiz/statistics:view', $context);
    question_send_questiontext_file($questionid, $args, $forcedownload, $options);
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:22,代码来源:lib.php


示例8: qformat_xhtml_question_preview_pluginfile

/**
 * Serve question files when they are displayed in this export format.
 *
 * @param context $previewcontext the quiz context
 * @param int $questionid the question id.
 * @param context $filecontext the file (question) context
 * @param string $filecomponent the component the file belongs to.
 * @param string $filearea the file area.
 * @param array $args remaining file args.
 * @param bool $forcedownload.
 * @param array $options additional options affecting the file serving.
 */
function qformat_xhtml_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
    global $CFG;
    list($context, $course, $cm) = get_context_info_array($previewcontext->id);
    require_login($course, false, $cm);
    question_require_capability_on($questionid, 'view');
    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
    if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
        send_file_not_found();
    }
    send_stored_file($file, 0, 0, $forcedownload, $options);
}
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:lib.php


示例9: quiz_statistics_question_preview_pluginfile

/**
 * Serve questiontext files in the question text when they are displayed in this report.
 *
 * @package  quiz_statistics
 * @category files
 * @param context $previewcontext the quiz context
 * @param int $questionid the question id.
 * @param context $filecontext the file (question) context
 * @param string $filecomponent the component the file belongs to.
 * @param string $filearea the file area.
 * @param array $args remaining file args.
 * @param bool $forcedownload.
 * @param array $options additional options affecting the file serving.
 */
function quiz_statistics_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/quiz/locallib.php';
    list($context, $course, $cm) = get_context_info_array($previewcontext->id);
    require_login($course, false, $cm);
    // Assume only trusted people can see this report. There is no real way to
    // validate questionid, becuase of the complexity of random quetsions.
    require_capability('quiz/statistics:view', $context);
    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
    if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
        send_file_not_found();
    }
    send_stored_file($file, 0, 0, $forcedownload, $options);
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:lib.php


示例10: __construct

 public function __construct($context, $itemid, $filearea = 'submission')
 {
     global $USER, $CFG;
     require_once $CFG->libdir . '/portfoliolib.php';
     $this->context = $context;
     list($context, $course, $cm) = get_context_info_array($context->id);
     $this->cm = $cm;
     $this->course = $course;
     $fs = get_file_storage();
     $this->dir = $fs->get_area_tree($this->context->id, 'mod_assignment', $filearea, $itemid);
     $files = $fs->get_area_files($this->context->id, 'mod_assignment', $filearea, $itemid, "timemodified", false);
     if (count($files) >= 1 && has_capability('mod/assignment:exportownsubmission', $this->context)) {
         $button = new portfolio_add_button();
         $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/locallib.php');
         $button->reset_formats();
         $this->portfolioform = $button->to_html();
     }
     $this->preprocess($this->dir, $filearea);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:19,代码来源:renderer.php


示例11: get_content

 function get_content()
 {
     global $CFG, $PAGE;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!$CFG->usecomments) {
         $this->content = new stdClass();
         $this->content->text = '';
         if ($this->page->user_is_editing()) {
             $this->content->text = get_string('disabledcomments');
         }
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
     $args = new stdClass();
     $args->context = $PAGE->context;
     $args->course = $course;
     $args->area = 'page_comments';
     $args->itemid = 0;
     $args->component = 'block_comments';
     $args->linktext = get_string('showcomments');
     $args->notoggle = true;
     $args->autostart = true;
     $args->displaycancel = false;
     $comment = new comment($args);
     $comment->set_view_permission(true);
     $comment->set_fullwidth();
     $this->content = new stdClass();
     $this->content->text = $comment->output(true);
     $this->content->footer = '';
     return $this->content;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:39,代码来源:block_comments.php


示例12: get_grading_manager

    // get manager by id
    $manager = get_grading_manager($areaid);
} else {
    // get manager by context and component
    if (is_null($contextid) or is_null($component) or is_null($area)) {
        throw new coding_exception('The caller script must identify the gradable area.');
    }
    $context = context::instance_by_id($contextid, MUST_EXIST);
    $manager = get_grading_manager($context, $component, $area);
}
if ($manager->get_context()->contextlevel < CONTEXT_COURSE) {
    throw new coding_exception('Unsupported gradable area context level');
}
// get the currently active method
$method = $manager->get_active_method();
list($context, $course, $cm) = get_context_info_array($manager->get_context()->id);
require_login($course, true, $cm);
require_capability('moodle/grade:managegradingforms', $context);
if (!empty($returnurl)) {
    $returnurl = new moodle_url($returnurl);
} else {
    $returnurl = null;
}
$PAGE->set_url($manager->get_management_url($returnurl));
navigation_node::override_active_url($manager->get_management_url());
$PAGE->set_title(get_string('gradingmanagement', 'core_grading'));
$PAGE->set_heading(get_string('gradingmanagement', 'core_grading'));
$output = $PAGE->get_renderer('core_grading');
// process the eventual change of the active grading method
if (!empty($setmethod)) {
    require_sesskey();
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:manage.php


示例13: initialise_filepicker

/**
 * Generate all options needed by filepicker
 *
 * @param array $args including following keys
 *          context
 *          accepted_types
 *          return_types
 *
 * @return array the list of repository instances, including meta infomation, containing the following keys
 *          externallink
 *          repositories
 *          accepted_types
 */
function initialise_filepicker($args)
{
    global $CFG, $USER, $PAGE, $OUTPUT;
    static $templatesinitialized = array();
    require_once $CFG->libdir . '/licenselib.php';
    $return = new stdClass();
    $licenses = array();
    if (!empty($CFG->licenses)) {
        $array = explode(',', $CFG->licenses);
        foreach ($array as $license) {
            $l = new stdClass();
            $l->shortname = $license;
            $l->fullname = get_string($license, 'license');
            $licenses[] = $l;
        }
    }
    if (!empty($CFG->sitedefaultlicense)) {
        $return->defaultlicense = $CFG->sitedefaultlicense;
    }
    $return->licenses = $licenses;
    $return->author = fullname($USER);
    if (empty($args->context)) {
        $context = $PAGE->context;
    } else {
        $context = $args->context;
    }
    $disable_types = array();
    if (!empty($args->disable_types)) {
        $disable_types = $args->disable_types;
    }
    $user_context = context_user::instance($USER->id);
    list($context, $course, $cm) = get_context_info_array($context->id);
    $contexts = array($user_context, context_system::instance());
    if (!empty($course)) {
        // adding course context
        $contexts[] = context_course::instance($course->id);
    }
    $externallink = (int) get_config(null, 'repositoryallowexternallinks');
    $repositories = repository::get_instances(array('context' => $contexts, 'currentcontext' => $context, 'accepted_types' => $args->accepted_types, 'return_types' => $args->return_types, 'disable_types' => $disable_types));
    $return->repositories = array();
    if (empty($externallink)) {
        $return->externallink = false;
    } else {
        $return->externallink = true;
    }
    $return->userprefs = array();
    $return->userprefs['recentrepository'] = get_user_preferences('filepicker_recentrepository', '');
    $return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
    $return->userprefs['recentviewmode'] = get_user_preferences('filepicker_recentviewmode', '');
    user_preference_allow_ajax_update('filepicker_recentrepository', PARAM_INT);
    user_preference_allow_ajax_update('filepicker_recentlicense', PARAM_SAFEDIR);
    user_preference_allow_ajax_update('filepicker_recentviewmode', PARAM_INT);
    // provided by form element
    $return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
    $return->return_types = $args->return_types;
    $templates = array();
    foreach ($repositories as $repository) {
        $meta = $repository->get_meta();
        // Please note that the array keys for repositories are used within
        // JavaScript a lot, the key NEEDS to be the repository id.
        $return->repositories[$repository->id] = $meta;
        // Register custom repository template if it has one
        if (method_exists($repository, 'get_upload_template') && !array_key_exists('uploadform_' . $meta->type, $templatesinitialized)) {
            $templates['uploadform_' . $meta->type] = $repository->get_upload_template();
            $templatesinitialized['uploadform_' . $meta->type] = true;
        }
    }
    if (!array_key_exists('core', $templatesinitialized)) {
        // we need to send each filepicker template to the browser just once
        $fprenderer = $PAGE->get_renderer('core', 'files');
        $templates = array_merge($templates, $fprenderer->filepicker_js_templates());
        $templatesinitialized['core'] = true;
    }
    if (sizeof($templates)) {
        $PAGE->requires->js_init_call('M.core_filepicker.set_templates', array($templates), true);
    }
    return $return;
}
开发者ID:isuruAb,项目名称:moodle,代码行数:91,代码来源:lib.php


示例14: course_page_type_list

/**
 * Return a list of page types
 * @param string $pagetype current page type
 * @param stdClass $parentcontext Block's parent context
 * @param stdClass $currentcontext Current context of block
 */
function course_page_type_list($pagetype, $parentcontext, $currentcontext)
{
    // if above course context ,display all course fomats
    list($currentcontext, $course, $cm) = get_context_info_array($currentcontext->id);
    if ($course->id == SITEID) {
        return array('*' => get_string('page-x', 'pagetype'));
    } else {
        return array('*' => get_string('page-x', 'pagetype'), 'course-*' => get_string('page-course-x', 'pagetype'), 'course-view-*' => get_string('page-course-view-x', 'pagetype'));
    }
}
开发者ID:numbas,项目名称:moodle,代码行数:16,代码来源:lib.php


示例15: data_print_template


//.........这里部分代码省略.........
            $moreurl .= '&amp;filter=1';
        }
        $patterns[]='##more##';
        $replacement[] = '<a href="' . $moreurl . '"><img src="' . $OUTPUT->pix_url('i/search') . '" class="iconsmall" alt="' . get_string('more', 'data') . '" title="' . get_string('more', 'data') . '" /></a>';

        $patterns[]='##moreurl##';
        $replacement[] = $moreurl;

        $patterns[]='##user##';
        $replacement[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$record->userid.
                               '&amp;course='.$data->course.'">'.fullname($record).'</a>';

        $patterns[]='##export##';

        if (!empty($CFG->enableportfolios) && ($template == 'singletemplate' || $template == 'listtemplate')
            && ((has_capability('mod/data:exportentry', $context)
                || (data_isowner($record->id) && has_capability('mod/data:exportownentry', $context))))) {
            require_once($CFG->libdir . '/portfoliolib.php');
            $button = new portfolio_add_button();
            $button->set_callback_options('data_portfolio_caller', array('id' => $cm->id, 'recordid' => $record->id), '/mod/data/locallib.php');
            list($formats, $files) = data_portfolio_caller::formats($fields, $record);
            $button->set_formats($formats);
            $replacement[] = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
        } else {
            $replacement[] = '';
        }

        $patterns[] = '##timeadded##';
        $replacement[] = userdate($record->timecreated);

        $patterns[] = '##timemodified##';
        $replacement [] = userdate($record->timemodified);

        $patterns[]='##approve##';
        if (has_capability('mod/data:approve', $context) && ($data->approval) && (!$record->approved)){
            $replacement[] = '<span class="approve"><a href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;approve='.$record->id.'&amp;sesskey='.sesskey().'"><img src="'.$OUTPUT->pix_url('i/approve') . '" class="icon" alt="'.get_string('approve').'" /></a></span>';
        } else {
            $replacement[] = '';
        }

        $patterns[]='##comments##';
        if (($template == 'listtemplate') && ($data->comments)) {

            if (!empty($CFG->usecomments)) {
                require_once($CFG->dirroot  . '/comment/lib.php');
                list($context, $course, $cm) = get_context_info_array($context->id);
                $cmt = new stdClass();
                $cmt->context = $context;
                $cmt->course  = $course;
                $cmt->cm      = $cm;
                $cmt->area    = 'database_entry';
                $cmt->itemid  = $record->id;
                $cmt->showcount = true;
                $cmt->component = 'mod_data';
                $comment = new comment($cmt);
                $replacement[] = $comment->output(true);
            }
        } else {
            $replacement[] = '';
        }

        // actual replacement of the tags
        $newtext = str_ireplace($patterns, $replacement, $data->{$template});

        // no more html formatting and filtering - see MDL-6635
        if ($return) {
            return $newtext;
        } else {
            echo $newtext;

            // hack alert - return is always false in singletemplate anyway ;-)
            /**********************************
             *    Printing Ratings Form       *
             *********************************/
            if ($template == 'singletemplate') {    //prints ratings options
                data_print_ratings($data, $record);
            }

            /**********************************
             *    Printing Comments Form       *
             *********************************/
            if (($template == 'singletemplate') && ($data->comments)) {
                if (!empty($CFG->usecomments)) {
                    require_once($CFG->dirroot . '/comment/lib.php');
                    list($context, $course, $cm) = get_context_info_array($context->id);
                    $cmt = new stdClass();
                    $cmt->context = $context;
                    $cmt->course  = $course;
                    $cmt->cm      = $cm;
                    $cmt->area    = 'database_entry';
                    $cmt->itemid  = $record->id;
                    $cmt->showcount = true;
                    $cmt->component = 'mod_data';
                    $comment = new comment($cmt);
                    $comment->output(false);
                }
            }
        }
    }
}
开发者ID:nottmoo,项目名称:moodle,代码行数:101,代码来源:lib.php


示例16: question_preview_question_pluginfile

/**
 * Called via pluginfile.php -> question_pluginfile to serve files belonging to
 * a question in a question_attempt when that attempt is a preview.
 *
 * @package  core_question
 * @category files
 * @param stdClass $course course settings object
 * @param stdClass $context context object
 * @param string $component the name of the component we are serving files for.
 * @param string $filearea the name of the file area.
 * @param int $qubaid the question_usage this image belongs to.
 * @param int $slot the relevant slot within the usage.
 * @param array $args the remaining bits of the file path.
 * @param bool $forcedownload whether the user must be forced to download the file.
 * @param array $options additional options affecting the file serving
 * @return bool false if file not found, does not return if found - justsend the file
 */
function question_preview_question_pluginfile($course, $context, $component, $filearea, $qubaid, $slot, $args, $forcedownload, $fileoptions)
{
    global $USER, $DB, $CFG;
    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);
    $quba = question_engine::load_questions_usage_by_activity($qubaid);
    if (!question_has_capability_on($quba->get_question($slot), 'use')) {
        send_file_not_found();
    }
    $options = new question_display_options();
    $options->feedback = question_display_options::VISIBLE;
    $options->numpartscorrect = question_display_options::VISIBLE;
    $options->generalfeedback = question_display_options::VISIBLE;
    $options->rightanswer = question_display_options::VISIBLE;
    $options->manualcomment = question_display_options::VISIBLE;
    $options->history = question_display_options::VISIBLE;
    if (!$quba->check_file_access($slot, $options, $component, $filearea, $args, $forcedownload)) {
        send_file_not_found();
    }
    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/{$context->id}/{$component}/{$filearea}/{$relativepath}";
    if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
        send_file_not_found();
    }
    send_stored_file($file, 0, 0, $forcedownload, $fileoptions);
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:44,代码来源:previewlib.php


示例17: file_pluginfile

/**
 * This function delegates file serving to individual plugins
 *
 * @param string $relativepath
 * @param bool $forcedownload
 * @param null|string $preview the preview mode, defaults to serving the original file
 * @todo MDL-31088 file serving improments
 */
function file_pluginfile($relativepath, $forcedownload, $preview = null)
{
    global $DB, $CFG, $USER;
    // relative path must start with '/'
    if (!$relativepath) {
        print_error('invalidargorconf');
    } else {
        if ($relativepath[0] != '/') {
            print_error('pathdoesnotstartslash');
        }
    }
    // extract relative path components
    $args = explode('/', ltrim($relativepath, '/'));
    if (count($args) < 3) {
        // always at least context, component and filearea
        print_error('invalidarguments');
    }
    $contextid = (int) array_shift($args);
    $component = clean_param(array_shift($args), PARAM_COMPONENT);
    $filearea = clean_param(array_shift($args), PARAM_AREA);
    list($context, $course, $cm) = get_context_info_array($contextid);
    $fs = get_file_storage();
    // ========================================================================================================================
    if ($component === 'blog') {
        // Blog file serving
        if ($context->contextlevel != CONTEXT_SYSTEM) {
            send_file_not_found();
        }
        if ($filearea !== 'attachment' and $filearea !== 'post') {
            send_file_not_found();
        }
        if (empty($CFG->enableblogs)) {
            print_error('siteblogdisable', 'blog');
        }
        $entryid = (int) array_shift($args);
        if (!($entry = $DB->get_record('post', array('module' => 'blog', 'id' => $entryid)))) {
            send_file_not_found();
        }
        if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
            require_login();
            if (isguestuser()) {
                print_error('noguest');
            }
            if ($CFG->bloglevel == BLOG_USER_LEVEL) {
                if ($USER->id != $entry->userid) {
                    send_file_not_found();
                }
            }
        }
        if ($entry->publishstate === 'public') {
            if ($CFG->forcelogin) {
                require_login();
            }
        } else {
            if ($entry->publishstate === 'site') {
                require_login();
                //ok
            } else {
                if ($entry->publishstate === 'draft') {
                    require_login();
                    if ($USER->id != $entry->userid) {
                        send_file_not_found();
                    }
                }
            }
        }
        $filename = array_pop($args);
        $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
        if (!($file = $fs->get_file($context->id, $component, $filearea, $entryid, $filepath, $filename)) or $file->is_directory()) {
            send_file_not_found();
        }
        send_stored_file($file, 10 * 60, 0, true, array('preview' => $preview));
        // download MUST be forced - security!
        // ========================================================================================================================
    } else {
        if ($component === 'grade') {
            if (($filearea === 'outcome' or $filearea === 'scale') and $context->contextlevel == CONTEXT_SYSTEM) {
                // Global gradebook files
                if ($CFG->forcelogin) {
                    require_login();
                }
                $fullpath = "/{$context->id}/{$component}/{$filearea}/" . implode('/', $args);
                if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
                    send_file_not_found();
                }
                \core\session\manager::write_close();
                // Unlock session during file serving.
                send_stored_file($file, 60 * 60, 0, $forcedownload, array('preview' => $preview));
            } else {
                if ($filearea === 'feedback' and $context->contextlevel == CONTEXT_COURSE) {
                    //TODO: nobody implemented this yet in grade edit form!!
                    send_file_not_found();
//.........这里部分代码省略.........
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:101,代码来源:filelib.php


示例18: core_question_question_preview_pluginfile

/**
 * Serve questiontext files in the question text when they are displayed in this report.
 *
 * @package  core_files
 * @category files
 * @param context $previewcontext the context in which the preview is happening.
 * @param int $questionid the question id.
 * @param context $filecontext the file (question) context.
 * @param string $filecomponent the component the file belongs to.
 * @param string $filearea the file area.
 * @param array $args remaining file args.
 * @param bool $forcedownload.
 * @param array $options additional options affecting the file serving.
 */
function core_question_question_preview_pluginfile($previewcontext, $questionid, $filecontext, $filecomponent, $filearea, $args, $forcedownload, $options = array())
{
    global $DB;
    // Verify that contextid matches the question.
    $question = $DB->get_record_sql('
            SELECT q.*, qc.contextid
              FROM {question} q
              JOIN {question_categories} qc ON qc.id = q.category
             WHERE q.id = :id AND qc.contextid = :contextid', array('id' => $questionid, 'contextid' => $filecontext->id), MUST_EXIST);
    // Check the capability.
    list($context, $course, $cm) = get_context_info_array($previewcontext->id);
    require_login($course, false, $cm);
    question_require_capability_on($question, 'use');
    $fs = get_file_storage();
    $relativepath = implode('/', $args);
    $fullpath = "/{$filecontext->id}/{$filecomponent}/{$filearea}/{$relativepath}";
    if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
        send_file_not_found();
    }
    send_stored_file($file, 0, 0, $forcedownload, $options);
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:35,代码来源:questionlib.php


示例19: __construct

 /**
  * Constructor
  *
  * @param stdClass $options options for filemanager
  *   default options are:
  *       maxbytes=>-1,
  *       maxfiles=>-1,
  *       itemid=>0,
  *       subdirs=>false,
  *       client_id=>uniqid(),
  *       acepted_types=>'*',
  *       return_types=>FILE_INTERNAL,
  *       context=>$PAGE->context,
  *       author=>fullname($USER),
  *       licenses=>array build from $CFG->licenses,
  *       defaultlicense=>$CFG->sitedefaultlicense
  */
 public function __construct(stdClass $options)
 {
     global $CFG, $USER, $PAGE;
     require_once $CFG->dirroot . '/repository/lib.php';
     $defaults = array('maxbytes' => -1, 'maxfiles' => -1, 'itemid' => 0, 'subdirs' => 0, 'client_id' => uniqid(), 'accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'context' => $PAGE->context, 'author' => fullname($USER), 'licenses' => array());
     if (!empty($CFG->licenses)) {
         $array = explode(',', $CFG->licenses);
         foreach ($array as $license) {
             $l = new stdClass();
             $l->shortname = $license;
             $l->fullname = get_string($license, 'license');
             $defaults['licenses'][] = $l;
         }
     }
     if (!empty($CFG->sitedefaultlicense)) {
         $defaults['defaultlicense'] = $CFG->sitedefaultlicense;
     }
     foreach ($defaults as $key => $value) {
         if (empty($options->{$key})) {
             $options->{$key} = $value;
         }
     }
     $fs = get_file_storage();
     // initilise options, getting files in root path
     $this->options = file_get_drafarea_files($options->itemid, '/');
     // calculate file count
     $usercontext = context_user::instance($USER->id);
     $files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id', false);
     $filecount = count($files);
     $this->options->filecount = $filecount;
     // copying other options
     foreach ($options as $name => $value) {
         $this->options->{$name} = $value;
     }
     // calculate the maximum file size as minimum from what is specified in filepicker options,
     // course options, global configuration and php settings
     $coursebytes = $maxbytes = 0;
     list($context, $course, $cm) = get_context_info_array($this->options->context->id);
     if (is_object($course)) {
         $coursebytes = $course->maxbytes;
     }
     if (!empty($this->options->maxbytes) && $this->options->maxbytes > 0) {
         $maxbytes = $this->options->maxbytes;
     }
     $this->options->maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursebytes, $maxbytes);
     // building file picker options
     $params = new stdClass();
     $params->accepted_types = $options->accepted_types;
     $params->return_types = $options->return_types;
     $params->context = $options->context;
     $params->env = 'filemanager';
     $params->disable_types = !empty($options->disable_types) ? $options->disable_types : array();
     $filepicker_options = initialise_filepicker($params);
     $this->options->filepicker = $filepicker_options;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:72,代码来源:filemanager.php


示例20: get_name

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_context_info_list函数代码示例发布时间:2022-05-15
下一篇:
PHP get_context函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap