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


PHP context_system::instance方法代码示例

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


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

示例1: execute

 public function execute()
 {
     global $CFG, $DB;
     $roleid = $this->arguments[0];
     $filearg = $this->arguments[1];
     if (substr($filearg, 0, 1) == '/') {
         // Absolute file.
         $filename = $filearg;
     } else {
         // Relative to current directory.
         $filename = $this->cwd . DIRECTORY_SEPARATOR . $filearg;
     }
     $fh = fopen($filename, 'r');
     $roledefinition = fread($fh, filesize($filename));
     if ($roledefinition) {
         $systemcontext = \context_system::instance();
         $options = array('shortname' => 1, 'name' => 1, 'description' => 1, 'permissions' => 1, 'archetype' => 1, 'contextlevels' => 1, 'allowassign' => 1, 'allowoverride' => 1, 'allowswitch' => 1, 'permissions' => 1);
         $definitiontable = new \core_role_define_role_table_advanced($systemcontext, $roleid);
         // Add all permissions from definition file to $_POST, otherwise, they won't be applied.
         $info = \core_role_preset::parse_preset($roledefinition);
         $_POST = $info['permissions'];
         $definitiontable->read_submitted_permissions();
         $definitiontable->force_preset($roledefinition, $options);
         $definitiontable->save_changes();
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:26,代码来源:RoleReset.php

示例2: xmldb_block_calendar_month_upgrade

/**
 * Upgrade the calendar_month block
 * @param int $oldversion
 * @param object $block
 */
function xmldb_block_calendar_month_upgrade($oldversion, $block)
{
    global $DB;
    if ($oldversion < 2014062600) {
        // Add this block the default blocks on /my.
        $blockname = 'calendar_month';
        // Do not try to add the block if we cannot find the default my_pages entry.
        // Private => 1 refers to MY_PAGE_PRIVATE.
        if ($systempage = $DB->get_record('my_pages', array('userid' => null, 'private' => 1))) {
            $page = new moodle_page();
            $page->set_context(context_system::instance());
            // Check to see if this block is already on the default /my page.
            $criteria = array('blockname' => $blockname, 'parentcontextid' => $page->context->id, 'pagetypepattern' => 'my-index', 'subpagepattern' => $systempage->id);
            if (!$DB->record_exists('block_instances', $criteria)) {
                // Add the block to the default /my.
                $page->blocks->add_region(BLOCK_POS_RIGHT);
                $page->blocks->add_block($blockname, BLOCK_POS_RIGHT, 0, false, 'my-index', $systempage->id);
            }
        }
        upgrade_block_savepoint(true, 2014062600, $blockname);
    }
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.9.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.0.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:evltuma,项目名称:moodle,代码行数:36,代码来源:upgrade.php

示例3: load_settings

 public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig)
 {
     global $CFG, $USER, $DB, $OUTPUT, $PAGE;
     // In case settings.php wants to refer to them.
     $ADMIN = $adminroot;
     // May be used in settings.php.
     $plugininfo = $this;
     // Also can be used inside settings.php.
     $qtype = $this;
     // Also can be used inside settings.php.
     if (!$this->is_installed_and_upgraded()) {
         return;
     }
     $section = $this->get_settings_section_name();
     $settings = null;
     $systemcontext = \context_system::instance();
     if ($hassiteconfig && file_exists($this->full_path('settings.php'))) {
         $settings = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
         include $this->full_path('settings.php');
         // This may also set $settings to null.
     }
     if ($settings) {
         $ADMIN->add($parentnodename, $settings);
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:25,代码来源:calendartype.php

示例4: get_csswww

 public function get_csswww()
 {
     global $CFG;
     if (!$this->theme_essential_lte_ie9()) {
         if (right_to_left()) {
             $moodlecss = 'essential-rtl.css';
         } else {
             $moodlecss = 'essential.css';
         }
         $syscontext = context_system::instance();
         $itemid = theme_get_revision();
         $url = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecss}");
         $url = preg_replace('|^https?://|i', '//', $url->out(false));
         return '<link rel="stylesheet" href="' . $url . '">';
     } else {
         if (right_to_left()) {
             $moodlecssone = 'essential-rtl_ie9-blessed1.css';
             $moodlecsstwo = 'essential-rtl_ie9.css';
         } else {
             $moodlecssone = 'essential_ie9-blessed1.css';
             $moodlecsstwo = 'essential_ie9.css';
         }
         $syscontext = context_system::instance();
         $itemid = theme_get_revision();
         $urlone = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecssone}");
         $urlone = preg_replace('|^https?://|i', '//', $urlone->out(false));
         $urltwo = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecsstwo}");
         $urltwo = preg_replace('|^https?://|i', '//', $urltwo->out(false));
         return '<link rel="stylesheet" href="' . $urlone . '"><link rel="stylesheet" href="' . $urltwo . '">';
     }
 }
开发者ID:blionut,项目名称:elearning,代码行数:31,代码来源:core_renderer_maintenance.php

示例5: xmldb_assignfeedback_editpdf_upgrade

/**
 * EditPDF upgrade code
 * @param int $oldversion
 * @return bool
 */
function xmldb_assignfeedback_editpdf_upgrade($oldversion)
{
    global $CFG;
    if ($oldversion < 2013110800) {
        // Check that no stamps where uploaded.
        $fs = get_file_storage();
        $stamps = $fs->get_area_files(context_system::instance()->id, 'assignfeedback_editpdf', 'stamps', 0, "filename", false);
        // Add default stamps.
        if (empty($stamps)) {
            // List of default stamps.
            $defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png');
            // Stamp file object.
            $filerecord = new stdClass();
            $filerecord->component = 'assignfeedback_editpdf';
            $filerecord->contextid = context_system::instance()->id;
            $filerecord->userid = get_admin()->id;
            $filerecord->filearea = 'stamps';
            $filerecord->filepath = '/';
            $filerecord->itemid = 0;
            // Add all default stamps.
            foreach ($defaultstamps as $stamp) {
                $filerecord->filename = $stamp;
                $fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename);
            }
        }
        upgrade_plugin_savepoint(true, 2013110800, 'assignfeedback', 'editpdf');
    }
    // Moodle v2.6.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.7.0 release upgrade line.
    // Put any upgrade step following this.
    // Moodle v2.8.0 release upgrade line.
    // Put any upgrade step following this.
    return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:40,代码来源:upgrade.php

示例6: MoodleQuickForm_editor

 /**
  * Constructor
  *
  * @param string $elementName (optional) name of the editor
  * @param string $elementLabel (optional) editor label
  * @param array $attributes (optional) Either a typical HTML attribute string
  *              or an associative array
  * @param array $options set of options to initalize filepicker
  */
 function MoodleQuickForm_editor($elementName = null, $elementLabel = null, $attributes = null, $options = null)
 {
     global $CFG, $PAGE;
     $options = (array) $options;
     foreach ($options as $name => $value) {
         if (array_key_exists($name, $this->_options)) {
             $this->_options[$name] = $value;
         }
     }
     if (!empty($options['maxbytes'])) {
         $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
     }
     if (!$this->_options['context']) {
         // trying to set context to the current page context to make legacy files show in filepicker (e.g. forum post)
         if (!empty($PAGE->context->id)) {
             $this->_options['context'] = $PAGE->context;
         } else {
             $this->_options['context'] = context_system::instance();
         }
     }
     $this->_options['trusted'] = trusttext_trusted($this->_options['context']);
     parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
     // Note: for some reason the code using this setting does not like bools.
     $this->_options['subdirs'] = (int) ($this->_options['subdirs'] == 1);
     editors_head_setup();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:35,代码来源:editor.php

示例7: init

 /**
  * Initialise required event data properties.
  */
 protected function init()
 {
     $this->context = \context_system::instance();
     $this->data['objecttable'] = 'user';
     $this->data['crud'] = 'r';
     $this->data['edulevel'] = self::LEVEL_OTHER;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:10,代码来源:user_loggedout.php

示例8: get_content

 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     $context = context_system::instance();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     $content = array();
     $canview = has_capability('block/enrol_token_manager:viewtokens', $context) === true;
     $cancreate = has_capability('block/enrol_token_manager:createtokens', $context) === true;
     $canrevoke = has_capability('block/enrol_token_manager:revoketokens', $context) === true;
     // view tokens link
     if ($canview) {
         $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextViewTokens', 'block_enrol_token_manager'));
     }
     // create tokens link
     if ($cancreate) {
         $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/create_tokens.php'), get_string('linkTextCreateTokens', 'block_enrol_token_manager'));
     }
     // revoke tokens link
     if ($canrevoke) {
         $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextRevokeTokens', 'block_enrol_token_manager'));
     }
     if ($cancreate || $canrevoke || $canview) {
         $this->content->text = html_writer::alist($content);
     }
     return $this->content;
 }
开发者ID:frumbert,项目名称:moodle-token-enrolment,代码行数:30,代码来源:block_enrol_token_manager.php

示例9: specific_definition

 protected function specific_definition($mform)
 {
     global $CFG;
     // Fields for editing HTML block title and contents.
     $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
     $mform->addElement('text', 'config_title', get_string('configtitle', 'block_tags'));
     $mform->setType('config_title', PARAM_TEXT);
     $mform->setDefault('config_title', get_string('pluginname', 'block_tags'));
     $this->add_collection_selector($mform);
     $numberoftags = array();
     for ($i = 1; $i <= 200; $i++) {
         $numberoftags[$i] = $i;
     }
     $mform->addElement('select', 'config_numberoftags', get_string('numberoftags', 'blog'), $numberoftags);
     $mform->setDefault('config_numberoftags', 80);
     $defaults = array('official' => get_string('officialonly', 'block_tags'), '' => get_string('anytype', 'block_tags'));
     $mform->addElement('select', 'config_tagtype', get_string('defaultdisplay', 'block_tags'), $defaults);
     $mform->setDefault('config_tagtype', '');
     $defaults = array(0 => context_system::instance()->get_context_name());
     $parentcontext = context::instance_by_id($this->block->instance->parentcontextid);
     if ($parentcontext->contextlevel > CONTEXT_COURSE) {
         $coursecontext = $parentcontext->get_course_context();
         $defaults[$coursecontext->id] = $coursecontext->get_context_name();
     }
     if ($parentcontext->contextlevel != CONTEXT_SYSTEM) {
         $defaults[$parentcontext->id] = $parentcontext->get_context_name();
     }
     $mform->addElement('select', 'config_ctx', get_string('taggeditemscontext', 'block_tags'), $defaults);
     $mform->addHelpButton('config_ctx', 'taggeditemscontext', 'block_tags');
     $mform->setDefault('config_ctx', 0);
     $mform->addElement('advcheckbox', 'config_rec', get_string('recursivecontext', 'block_tags'));
     $mform->addHelpButton('config_rec', 'recursivecontext', 'block_tags');
     $mform->setDefault('config_rec', 1);
 }
开发者ID:bewanyk,项目名称:moodle,代码行数:34,代码来源:edit_form.php

示例10: definition

 public function definition()
 {
     global $CFG, $PAGE, $DB;
     $context = context_system::instance();
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'id', $this->classroomid);
     $mform->addElement('hidden', 'companyid', $this->companyid);
     $mform->setType('id', PARAM_INT);
     $mform->setType('companyid', PARAM_INT);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'header', get_string('classroom', 'block_iomad_company_admin'));
     $mform->addElement('text', 'name', get_string('classroom_name', 'block_iomad_company_admin'), 'maxlength="100" size="50"');
     $mform->setType('name', PARAM_NOTAGS);
     $mform->addRule('name', $strrequired, 'required', null, 'client');
     $mform->addElement('text', 'address', get_string('address'), 'maxlength="70" size="50"');
     $mform->addRule('address', $strrequired, 'required', null, 'client');
     $mform->setType('address', PARAM_NOTAGS);
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="50"');
     $mform->addRule('city', $strrequired, 'required', null, 'client');
     $mform->setType('city', PARAM_NOTAGS);
     $mform->addElement('text', 'postcode', get_string('postcode', 'block_iomad_commerce'), 'maxlength="20" size="20"');
     $mform->addRule('postcode', $strrequired, 'required', null, 'client');
     $mform->setType('postcode', PARAM_NOTAGS);
     $choices = get_string_manager()->get_list_of_countries();
     $choices = array('' => get_string('selectacountry') . '...') + $choices;
     $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
     $mform->addRule('country', $strrequired, 'required', null, 'client');
     $mform->addElement('text', 'capacity', get_string('classroom_capacity', 'block_iomad_company_admin'));
     $mform->addRule('capacity', $strrequired, 'required', null, 'client');
     $mform->setType('capacity', PARAM_INTEGER);
     $this->add_action_buttons();
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:33,代码来源:classroom_edit_form.php

示例11: init

 /**
  * Init method.
  */
 protected function init()
 {
     $this->data['objecttable'] = 'lti';
     $this->data['crud'] = 'r';
     $this->data['level'] = self::LEVEL_OTHER;
     $this->data['context'] = \context_system::instance();
 }
开发者ID:helenagarcia90,项目名称:moodle,代码行数:10,代码来源:unknown_service_api_called.php

示例12: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $syscontext = context_system::instance();
     $actions = array(0 => get_string('choose') . '...');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[1] = get_string('confirm');
     }
     if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
         $actions[2] = get_string('messageselectadd');
     }
     if (has_capability('moodle/user:delete', $syscontext)) {
         $actions[3] = get_string('delete');
     }
     $actions[4] = get_string('displayonpage');
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[5] = get_string('download', 'admin');
     }
     if (has_capability('moodle/role:assign', $syscontext)) {
         //TODO: MDL-24064
         //$actions[6] = get_string('enrolmultipleusers', 'admin');
     }
     if (has_capability('moodle/user:update', $syscontext)) {
         $actions[7] = get_string('forcepasswordchange');
     }
     if (has_capability('moodle/cohort:assign', $syscontext)) {
         $actions[8] = get_string('bulkadd', 'core_cohort');
     }
     $objs = array();
     $objs[] =& $mform->createElement('select', 'action', null, $actions);
     $objs[] =& $mform->createElement('submit', 'doaction', get_string('go'));
     $mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:34,代码来源:user_bulk_forms.php

示例13: get_rol

/**
 * Obtiene el rol del usuario logeado.
 * @return string Rol {'Alumno', 'Profesor', 'Decano', 'Rector'}
 */
function get_rol()
{
    global $USER, $DB, $SESSION;
    if (isset($SESSION->rol)) {
        return $SESSION->rol;
        exit;
    }
    $context = context_system::instance();
    $rolesportada = get_user_roles($context, false);
    foreach ($rolesportada as $rol) {
        if ($rol->name == 'Rector') {
            $SESSION->rol = 'Rector';
            return 'Rector';
        }
    }
    $facultades = $DB->get_records_sql("SELECT DISTINCT {course}.category\n\t\t\t\t\t\t\t\t\t\tFROM {course} INNER JOIN {context} ON ({course}.category = {context}.instanceid)\n\t\t\t\t\t\t\t\t\t\tINNER JOIN {role_assignments} ON ({context}.id = {role_assignments}.contextid)\n\t\t\t\t\t\t\t\t\t\tINNER JOIN {role} ON ({role_assignments}.roleid = {role}.id)\n\t\t\t\t\t\t\t\t\t\tWHERE {role}.name = 'Decano' AND {role_assignments}.userid = " . $USER->id);
    if (!empty($facultades)) {
        $SESSION->rol = 'Decano';
        $SESSION->facultades = array_keys($facultades);
        return 'Decano';
    }
    $profesores = $DB->get_records_sql("SELECT DISTINCT id_profesor FROM {local_toolbox_score}");
    if (array_key_exists($USER->id, $profesores)) {
        $SESSION->rol = 'Profesor';
        return 'Profesor';
    }
    $SESSION->rol = 'Alumno';
    return 'Alumno';
}
开发者ID:edmiranda,项目名称:toolbox,代码行数:33,代码来源:lib.php

示例14: get_content

 function get_content()
 {
     global $CFG, $OUTPUT;
     if (empty($this->instance)) {
         $this->content = '';
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     // user/index.php expect course context, so get one if page has module context.
     $currentcontext = $this->page->context->get_course_context(false);
     if (empty($currentcontext)) {
         $this->content = '';
         return $this->content;
     } else {
         if ($this->page->course->id == SITEID) {
             if (!has_capability('moodle/site:viewparticipants', context_system::instance())) {
                 $this->content = '';
                 return $this->content;
             }
         } else {
             if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
                 $this->content = '';
                 return $this->content;
             }
         }
     }
     $icon = '<img src="' . $OUTPUT->pix_url('i/users') . '" class="icon" alt="" />&nbsp;';
     $this->content->items[] = '<a title="' . get_string('listofallpeople') . '" href="' . $CFG->wwwroot . '/user/index.php?contextid=' . $currentcontext->id . '">' . $icon . get_string('participants') . '</a>';
     return $this->content;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:33,代码来源:block_participants.php

示例15: __DisplayBadges

 public function __DisplayBadges($uid, $callFor, $bid)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     $param_total = array('user_id' => $uid);
     $params = array('user_badge_id' => $bid, 'user_id' => $uid);
     if ($callFor == 'getBadges') {
         $badgedetails = array_values($DB->get_records_sql('SELECT id,badge_name,badge_value FROM {badge} ORDER BY badge_value'));
         //  $users_badges = array_values($DB->get_records_sql('SELECT ub.user_badge_id,ub.user_badge_value,b.badge_name FROM {badge_user} ub,{badge} b WHERE ub.user_id=? AND ub.user_badge_id=b.id', $param_total));
         $users_badges = array_values($DB->get_records_sql('SELECT ub.id,ub.user_badge_id,b.badge_value,b.badge_name FROM {badge_user} ub INNER JOIN {badge} b WHERE ub.user_id=? AND ub.user_badge_id=b.id;', $param_total));
         if (!empty($uid) && !empty($bid)) {
             //$userbadgecnt = count($badge_userdetails);
             // if ($userbadgecnt == 0) {
             $DB->insert_record('badge_user', $params);
             //}
         }
         $badges = @array_merge(array("badges" => $badgedetails, "userbadges" => $users_badges));
         if (!empty($badges)) {
             $response->response(false, 'done', $badges);
         } else {
             $response->response(true, 'no_records', $badges);
         }
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:25,代码来源:clinique_badges_bag.php


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