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

PHP context_coursecat类代码示例

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

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



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

示例1: __construct

 public function __construct($actionurl, $companyid, $departmentid)
 {
     global $CFG, $USER;
     $this->selectedcompany = $companyid;
     $this->departmentid = $departmentid;
     $company = new company($this->selectedcompany);
     $parentlevel = company::get_company_parentnode($company->id);
     $this->companydepartment = $parentlevel->id;
     if (iomad::has_capability('block/iomad_company_admin:edit_all_departments', context_system::instance())) {
         $userhierarchylevel = $parentlevel->id;
     } else {
         $userlevel = company::get_userlevel($USER);
         $userhierarchylevel = $userlevel->id;
     }
     $this->subhierarchieslist = company::get_all_subdepartments($userhierarchylevel);
     if ($this->departmentid == 0) {
         $departmentid = $userhierarchylevel;
     } else {
         $departmentid = $this->departmentid;
     }
     $this->userdepartment = $userhierarchylevel;
     $options = array('context' => $this->context, 'multiselect' => true, 'companyid' => $this->selectedcompany, 'departmentid' => $departmentid, 'subdepartments' => $this->subhierarchieslist, 'parentdepartmentid' => $parentlevel, 'showopenshared' => true, 'license' => false);
     $this->currentcourses = new potential_subdepartment_course_selector('currentcourses', $options);
     $this->currentcourses->set_rows(20);
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     parent::moodleform($actionurl);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:27,代码来源:company_user_create_form.php


示例2: __construct

 public function __construct($actionurl, $invoiceid)
 {
     global $CFG;
     $this->invoiceid = $invoiceid;
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     parent::__construct($actionurl);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:7,代码来源:edit_order_form.php


示例3: __construct

 public function __construct($actionurl, $companyid, $editoroptions)
 {
     global $CFG;
     $this->selectedcompany = $companyid;
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     $this->editoroptions = $editoroptions;
     parent::__construct($actionurl);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:8,代码来源:company_course_create_form.php


示例4: test_associate_moodle_course_during_class_create

 /**
  * Validate that class instance-moodle course associations
  * can be created during a class instance create action
  *
  * @param string $link The link attribute to use in the import, or 'auto' to auto-create
  *                     from template
  * @dataProvider link_course_provider
  */
 public function test_associate_moodle_course_during_class_create($link)
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/classmoodlecourse.class.php');
     require_once elispm::lib('data/coursetemplate.class.php');
     require_once elispm::lib('data/course.class.php');
     // Make sure $USER is set up for backup/restore.
     $USER = $DB->get_record_select('user', "username != 'guest' and DELETED = 0", array(), '*', IGNORE_MULTIPLE);
     $GLOBAL['USER'] = $USER;
     // Need the moodle/backup:backupcourse capability.
     $guestroleid = create_role('guestrole', 'guestrole', 'guestrole');
     set_config('guestroleid', $guestroleid);
     set_config('siteguest', '');
     $systemcontext = context_system::instance();
     $roleid = create_role('testrole', 'testrole', 'testrole');
     assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $roleid, $systemcontext->id);
     role_assign($roleid, $USER->id, $systemcontext->id);
     set_config('siteadmins', $USER->id);
     $coursecategory = new stdClass();
     $coursecategory->name = 'testcoursecategoryname';
     $coursecategory->id = $DB->insert_record('course_categories', $coursecategory);
     context_coursecat::instance($coursecategory->id);
     $moodlecourse = new stdClass();
     $moodlecourse->category = $coursecategory->id;
     $moodlecourse->shortname = 'testcourseshortname';
     $moodlecourse->fullname = 'testcoursefullname';
     $moodlecourse = create_course($moodlecourse);
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     // Need this for the 'auto' case, at the very least.
     $coursetemplate = new coursetemplate(array('courseid' => $course->id, 'location' => $moodlecourse->id, 'templateclass' => 'moodlecourseurl'));
     $coursetemplate->save();
     // Run the class instance create action.
     $record = new stdClass();
     $record->idnumber = 'testclassidnumber';
     $record->assignment = 'testcourseidnumber';
     $record->link = $link;
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->class_create($record, 'bogus');
     $classid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => 'testclassidnumber'));
     // Validation.
     if ($record->link == 'auto') {
         $moodlecourseid = $moodlecourse->id + 1;
     } else {
         $moodlecourseid = $moodlecourse->id;
     }
     $dbautocreated = $record->link == 'auto' ? 1 : 0;
     $this->assertTrue($DB->record_exists(classmoodlecourse::TABLE, array('classid' => $classid, 'moodlecourseid' => $moodlecourseid, 'enroltype' => 0, 'enrolplugin' => 'crlm', 'autocreated' => $dbautocreated)));
     ini_set('max_execution_time', '0');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:61,代码来源:class_associate_moodle_course_test.php


示例5: init_category_and_course

 /**
  * Initialize a test category and course, including their context records.
  *
  * @return object the course's context object
  * @uses $DB
  */
 private function init_category_and_course()
 {
     global $DB;
     // Category.
     $category = new stdClass();
     $category->name = 'category';
     $category->id = $DB->insert_record('course_categories', $category);
     context_coursecat::instance($category->id);
     // Course.
     $coursedata = new stdClass();
     $coursedata->category = $category->id;
     $coursedata->fullname = 'fullname';
     $course = create_course($coursedata);
     return context_course::instance($course->id);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:21,代码来源:custom_field_permissions_test.php


示例6: __construct

 public function __construct($actionurl, $isadding, $shopsettingsid, $course, $priceblocks, $editoroptions)
 {
     global $CFG;
     $this->isadding = $isadding;
     $this->shopsettingsid = $shopsettingsid;
     $this->course = $course;
     $this->priceblocks = $priceblocks;
     $this->context = context_coursecat::instance($CFG->defaultrequestcategory);
     $this->editoroptions = $editoroptions;
     if ($isadding) {
         $options = array('context' => $this->context, 'multiselect' => false, 'selectedid' => $shopsettingsid, 'searchanywhere' => true, 'file' => '/blocks/iomad_commerce/lib/course_selectors.php');
         $this->currentcourses = new nonshopcourse_selector('currentcourses', $options);
         $this->currentcourses->set_rows(1);
     }
     parent::__construct($actionurl);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:16,代码来源:edit_course_shopsettings_form.php


示例7: test_user_sync_on_pm_user_create

 /**
  * Validate that appropriate fields are synched over to Moodle when PM user is enrolled in a class instance during an import.
  */
 public function test_user_sync_on_pm_user_create()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/classmoodlecourse.class.php');
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/pmclass.class.php');
     require_once elispm::lib('data/user.class.php');
     // Configure the elis enrolment plugin.
     $roleid = $DB->get_field('role', 'id', array(), IGNORE_MULTIPLE);
     set_config('roleid', $roleid, 'enrol_elis');
     $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '[email protected]', 'country' => 'CA'));
     $user->save();
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     $class = new pmclass(array('courseid' => $course->id, 'idnumber' => 'testclassidnumber'));
     $class->save();
     $category = new stdClass();
     $category->name = 'testcategoryname';
     $category->id = $DB->insert_record('course_categories', $category);
     // Create the associated context.
     context_coursecat::instance($category->id);
     $mdlcourse = new stdClass();
     $mdlcourse->category = $category->id;
     $mdlcourse->fullname = 'testcoursefullname';
     $mdlcourse = create_course($mdlcourse);
     // Associate class instance to Moodle course.
     $classmoodlecourse = new classmoodlecourse(array('classid' => $class->id, 'moodlecourseid' => $mdlcourse->id));
     $classmoodlecourse->save();
     // Run the enrolment create action.
     $record = new stdClass();
     $record->context = 'class_testclassidnumber';
     $record->user_username = 'testuserusername';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->class_enrolment_create($record, 'bogus', 'testclassidnumber');
     // Validate the enrolment.
     $enrolid = $DB->get_field('enrol', 'id', array('enrol' => 'elis', 'courseid' => $mdlcourse->id));
     $this->assertNotEquals(false, $enrolid);
     $mdluserid = $DB->get_field('user', 'id', array('username' => 'testuserusername'));
     $this->assertNotEquals(false, $mdluserid);
     $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $enrolid, 'userid' => $mdluserid)));
     // Validate the role assignment.
     $mdlcoursecontext = context_course::instance($mdlcourse->id);
     $this->assertTrue($DB->record_exists('role_assignments', array('roleid' => $roleid, 'contextid' => $mdlcoursecontext->id, 'userid' => $mdluserid)));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:50,代码来源:elis_enrolment_sync_test.php


示例8: create_cohorts

 /**
  * Create one or more cohorts
  *
  * @param array $cohorts An array of cohorts to create.
  * @return array An array of arrays
  * @since Moodle 2.5
  */
 public static function create_cohorts($cohorts)
 {
     global $CFG, $DB;
     require_once "{$CFG->dirroot}/cohort/lib.php";
     $params = self::validate_parameters(self::create_cohorts_parameters(), array('cohorts' => $cohorts));
     $transaction = $DB->start_delegated_transaction();
     $syscontext = context_system::instance();
     $cohortids = array();
     foreach ($params['cohorts'] as $cohort) {
         $cohort = (object) $cohort;
         // Category type (context id).
         $categorytype = $cohort->categorytype;
         if (!in_array($categorytype['type'], array('idnumber', 'id', 'system'))) {
             throw new invalid_parameter_exception('category type must be id, idnumber or system:' . $categorytype['type']);
         }
         if ($categorytype['type'] === 'system') {
             $cohort->contextid = $syscontext->id;
         } else {
             if ($catid = $DB->get_field('course_categories', 'id', array($categorytype['type'] => $categorytype['value']))) {
                 $catcontext = context_coursecat::instance($catid);
                 $cohort->contextid = $catcontext->id;
             } else {
                 throw new invalid_parameter_exception('category not exists: category ' . $categorytype['type'] . ' = ' . $categorytype['value']);
             }
         }
         // Make sure that the idnumber doesn't already exist.
         if ($DB->record_exists('cohort', array('idnumber' => $cohort->idnumber))) {
             throw new invalid_parameter_exception('record already exists: idnumber=' . $cohort->idnumber);
         }
         $context = context::instance_by_id($cohort->contextid, MUST_EXIST);
         if ($context->contextlevel != CONTEXT_COURSECAT and $context->contextlevel != CONTEXT_SYSTEM) {
             throw new invalid_parameter_exception('Invalid context');
         }
         self::validate_context($context);
         require_capability('moodle/cohort:manage', $context);
         // Validate format.
         $cohort->descriptionformat = external_validate_format($cohort->descriptionformat);
         $cohort->id = cohort_add_cohort($cohort);
         list($cohort->description, $cohort->descriptionformat) = external_format_text($cohort->description, $cohort->descriptionformat, $context->id, 'cohort', 'description', $cohort->id);
         $cohortids[] = (array) $cohort;
     }
     $transaction->allow_commit();
     return $cohortids;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:51,代码来源:externallib.php


示例9: block_jmail_get_context

/**
 * Returns the jmail context
 *
 * @param  int $context The context
 * @param  int $id      The context id
 * @param  int $flags   The flags to be used
 * @return stdClass     An object instance
 */
function block_jmail_get_context($context, $id = null, $flags = null)
{
    if ($context == CONTEXT_SYSTEM) {
        if (class_exists('context_system')) {
            return context_system::instance();
        } else {
            return get_context_instance(CONTEXT_SYSTEM);
        }
    } else {
        if ($context == CONTEXT_COURSE) {
            if (class_exists('context_course')) {
                return context_course::instance($id, $flags);
            } else {
                return get_context_instance($context, $id, $flags);
            }
        } else {
            if ($context == CONTEXT_COURSECAT) {
                if (class_exists('context_coursecat')) {
                    return context_coursecat::instance($id, $flags);
                } else {
                    return get_context_instance($context, $id, $flags);
                }
            } else {
                if ($context == CONTEXT_BLOCK) {
                    if (class_exists('context_block')) {
                        return context_block::instance($id, $flags);
                    } else {
                        return get_context_instance($context, $id, $flags);
                    }
                } else {
                    if ($context == CONTEXT_USER) {
                        if (class_exists('context_user')) {
                            return context_user::instance($id, $flags);
                        } else {
                            return get_context_instance($context, $id, $flags);
                        }
                    }
                }
            }
        }
    }
}
开发者ID:borrown,项目名称:moodle-block_jmail,代码行数:50,代码来源:locallib.php


示例10: equella_getssotoken

/**
 * Create EQUELLA single sign on token for current user
 *
 * @return string
 */
function equella_getssotoken($course = null)
{
    global $USER, $CFG, $COURSE;
    if (empty($course)) {
        $course = $COURSE;
    }
    $context_sys = context_system::instance();
    $context_cc = null;
    if (!empty($course->category) && is_int($course->category)) {
        $context_cc = context_coursecat::instance($course->category);
    }
    $context_c = context_course::instance($course->id);
    // roles are ordered by shortname
    $editingroles = get_all_editing_roles();
    foreach ($editingroles as $role) {
        $hassystemrole = false;
        if (!empty($context_sys)) {
            $hassystemrole = user_has_role_assignment($USER->id, $role->id, $context_sys->id);
        }
        $hascategoryrole = false;
        if (!empty($context_cc)) {
            $hascategoryrole = user_has_role_assignment($USER->id, $role->id, $context_cc->id);
        }
        $hascourserole = false;
        if (!empty($context_c)) {
            $hascourserole = user_has_role_assignment($USER->id, $role->id, $context_c->id);
        }
        if ($hassystemrole || $hascategoryrole || $hascourserole) {
            // see if the user has a role that is linked to an equella role
            $shareid = $CFG->{"equella_{$role->shortname}_shareid"};
            if (!empty($shareid)) {
                return equella_getssotoken_raw($USER->username, $shareid, $CFG->{"equella_{$role->shortname}_sharedsecret"});
            }
        }
    }
    // no roles found, use the default shareid and secret
    $shareid = $CFG->equella_shareid;
    if (!empty($shareid)) {
        return equella_getssotoken_raw($USER->username, $shareid, $CFG->equella_sharedsecret);
    }
}
开发者ID:CTANZ,项目名称:moodle-mod_equella,代码行数:46,代码来源:lib.php


示例11: get_category_options

 protected function get_category_options($currentcontextid)
 {
     $displaylist = array();
     $parentlist = array();
     make_categories_list($displaylist, $parentlist, 'moodle/cohort:manage');
     $options = array();
     $syscontext = context_system::instance();
     if (has_capability('moodle/cohort:manage', $syscontext)) {
         $options[$syscontext->id] = $syscontext->get_context_name();
     }
     foreach ($displaylist as $cid => $name) {
         $context = context_coursecat::instance($cid);
         $options[$context->id] = $name;
     }
     // Always add current - this is not likely, but if the logic gets changed it might be a problem.
     if (!isset($options[$currentcontextid])) {
         $context = context::instance_by_id($currentcontextid, MUST_EXIST);
         $options[$context->id] = $syscontext->get_context_name();
     }
     return $options;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:21,代码来源:edit_form.php


示例12: test_enrol_cohort_create_new_group

 /**
  * Test that a new group with the name of the cohort is created.
  */
 public function test_enrol_cohort_create_new_group()
 {
     global $DB;
     $this->resetAfterTest();
     // Create a category.
     $category = $this->getDataGenerator()->create_category();
     // Create two courses.
     $course = $this->getDataGenerator()->create_course(array('category' => $category->id));
     $course2 = $this->getDataGenerator()->create_course(array('category' => $category->id));
     // Create a cohort.
     $cohort = $this->getDataGenerator()->create_cohort(array('context' => context_coursecat::instance($category->id)->id));
     // Run the function.
     $groupid = enrol_cohort_create_new_group($course->id, $cohort->id);
     // Check the results.
     $group = $DB->get_record('groups', array('id' => $groupid));
     // The group name should match the cohort name.
     $this->assertEquals($cohort->name . ' cohort', $group->name);
     // Group course id should match the course id.
     $this->assertEquals($course->id, $group->courseid);
     // Create a group that will have the same name as the cohort.
     $groupdata = new stdClass();
     $groupdata->courseid = $course2->id;
     $groupdata->name = $cohort->name . ' cohort';
     groups_create_group($groupdata);
     // Create a group for the cohort in course 2.
     $groupid = enrol_cohort_create_new_group($course2->id, $cohort->id);
     $groupinfo = $DB->get_record('groups', array('id' => $groupid));
     // Check that the group name has been changed.
     $this->assertEquals($cohort->name . ' cohort (2)', $groupinfo->name);
     // Create another group that will have the same name as a generated cohort.
     $groupdata = new stdClass();
     $groupdata->courseid = $course2->id;
     $groupdata->name = $cohort->name . ' cohort (2)';
     groups_create_group($groupdata);
     // Create a group for the cohort in course 2.
     $groupid = enrol_cohort_create_new_group($course2->id, $cohort->id);
     $groupinfo = $DB->get_record('groups', array('id' => $groupid));
     // Check that the group name has been changed.
     $this->assertEquals($cohort->name . ' cohort (3)', $groupinfo->name);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:43,代码来源:cohortlib_test.php


示例13: xmldb_main_install

/**
 * Main post-install tasks to be executed after the BD schema is available
 *
 * This function is automatically executed after Moodle core DB has been
 * created at initial install. It's in charge of perform the initial tasks
 * not covered by the {@link install.xml} file, like create initial users,
 * roles, templates, moving stuff from other plugins...
 *
 * Note that the function is only invoked once, at install time, so if new tasks
 * are needed in the future, they will need to be added both here (for new sites)
 * and in the corresponding {@link upgrade.php} file (for existing sites).
 *
 * All plugins within Moodle (modules, blocks, reports...) support the existence of
 * their own install.php file, using the "Frankenstyle" component name as
 * defined at {@link http://docs.moodle.org/dev/Frankenstyle}, for example:
 *     - {@link xmldb_page_install()}. (modules don't require the plugintype ("mod_") to be used.
 *     - {@link xmldb_enrol_meta_install()}.
 *     - {@link xmldb_workshopform_accumulative_install()}.
 *     - ....
 *
 * Finally, note that it's also supported to have one uninstall.php file that is
 * executed also once, each time one plugin is uninstalled (before the DB schema is
 * deleted). Those uninstall files will contain one function, using the "Frankenstyle"
 * naming conventions, like {@link xmldb_enrol_meta_uninstall()} or {@link xmldb_workshop_uninstall()}.
 */
function xmldb_main_install()
{
    global $CFG, $DB, $SITE, $OUTPUT;
    // Make sure system context exists
    $syscontext = context_system::instance(0, MUST_EXIST, false);
    if ($syscontext->id != SYSCONTEXTID) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new system context id!');
    }
    // Create site course
    if ($DB->record_exists('course', array())) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create frontpage course, courses already exist.');
    }
    $newsite = new stdClass();
    $newsite->fullname = '';
    $newsite->shortname = '';
    $newsite->summary = NULL;
    $newsite->newsitems = 3;
    $newsite->numsections = 1;
    $newsite->category = 0;
    $newsite->format = 'site';
    // Only for this course
    $newsite->timecreated = time();
    $newsite->timemodified = $newsite->timecreated;
    if (defined('SITEID')) {
        $newsite->id = SITEID;
        $DB->import_record('course', $newsite);
        $DB->get_manager()->reset_sequence('course');
    } else {
        $newsite->id = $DB->insert_record('course', $newsite);
        define('SITEID', $newsite->id);
    }
    // set the field 'numsections'. We can not use format_site::update_format_options() because
    // the file is not loaded
    $DB->insert_record('course_format_options', array('courseid' => SITEID, 'format' => 'site', 'sectionid' => 0, 'name' => 'numsections', 'value' => $newsite->numsections));
    $SITE = get_site();
    if ($newsite->id != $SITE->id) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Unexpected new site course id!');
    }
    // Make sure site course context exists
    context_course::instance($SITE->id);
    // Update the global frontpage cache
    $SITE = $DB->get_record('course', array('id' => $newsite->id), '*', MUST_EXIST);
    // Create default course category
    if ($DB->record_exists('course_categories', array())) {
        throw new moodle_exception('generalexceptionmessage', 'error', '', 'Can not create default course category, categories already exist.');
    }
    $cat = new stdClass();
    $cat->name = get_string('miscellaneous');
    $cat->depth = 1;
    $cat->sortorder = MAX_COURSES_IN_CATEGORY;
    $cat->timemodified = time();
    $catid = $DB->insert_record('course_categories', $cat);
    $DB->set_field('course_categories', 'path', '/' . $catid, array('id' => $catid));
    // Make sure category context exists
    context_coursecat::instance($catid);
    $defaults = array('rolesactive' => '0', 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'enrol_plugins_enabled' => 'manual,guest,self,cohort', 'theme' => theme_config::DEFAULT_THEME, 'filter_multilang_converted' => 1, 'siteidentifier' => random_string(32) . get_host_from_url($CFG->wwwroot), 'backup_version' => 2008111700, 'backup_release' => '2.0 dev', 'mnet_dispatcher_mode' => 'off', 'sessiontimeout' => 7200, 'stringfilters' => '', 'filterall' => 0, 'texteditors' => 'atto,tinymce,textarea', 'upgrade_minmaxgradestepignored' => 1, 'upgrade_extracreditweightsstepignored' => 1, 'upgrade_calculatedgradeitemsignored' => 1);
    foreach ($defaults as $key => $value) {
        set_config($key, $value);
    }
    // Bootstrap mnet
    $mnethost = new stdClass();
    $mnethost->wwwroot = $CFG->wwwroot;
    $mnethost->name = '';
    $mnethost->name = '';
    $mnethost->public_key = '';
    if (empty($_SERVER['SERVER_ADDR'])) {
        // SERVER_ADDR is only returned by Apache-like webservers
        preg_match("@^(?:http[s]?://)?([A-Z0-9\\-\\.]+).*@i", $CFG->wwwroot, $matches);
        $my_hostname = $matches[1];
        $my_ip = gethostbyname($my_hostname);
        // Returns unmodified hostname on failure. DOH!
        if ($my_ip == $my_hostname) {
            $mnethost->ip_address = 'UNKNOWN';
        } else {
            $mnethost->ip_address = $my_ip;
//.........这里部分代码省略.........
开发者ID:alanaipe2015,项目名称:moodle,代码行数:101,代码来源:install.php


示例14: add_category

 /**
  * Adds a structured category to the navigation in the correct order/place
  *
  * @param stdClass $category
  * @param navigation_node $parent
  */
 protected function add_category(stdClass $category, navigation_node $parent)
 {
     if (array_key_exists($category->id, $this->addedcategories)) {
         return;
     }
     $url = new moodle_url('/course/category.php', array('id' => $category->id));
     $context = context_coursecat::instance($category->id);
     $categoryname = format_string($category->name, true, array('context' => $context));
     $categorynode = $parent->add($categoryname, $url, self::TYPE_CATEGORY, $categoryname, $category->id);
     if (empty($category->visible)) {
         if (has_capability('moodle/category:viewhiddencategories', get_system_context())) {
             $categorynode->hidden = true;
         } else {
             $categorynode->display = false;
         }
     }
     $this->addedcategories[$category->id] = $categorynode;
 }
开发者ID:nigeli,项目名称:moodle,代码行数:24,代码来源:navigationlib.php


示例15: delete_categories

    /**
     * Delete categories
     *
     * @param array $categories A list of category ids
     * @return array
     * @since Moodle 2.3
     */
    public static function delete_categories($categories) {
        global $CFG, $DB;
        require_once($CFG->dirroot . "/course/lib.php");
        require_once($CFG->libdir . "/coursecatlib.php");

        // Validate parameters.
        $params = self::validate_parameters(self::delete_categories_parameters(), array('categories' => $categories));

        $transaction = $DB->start_delegated_transaction();

        foreach ($params['categories'] as $category) {
            $deletecat = coursecat::get($category['id'], MUST_EXIST);
            $context = context_coursecat::instance($deletecat->id);
            require_capability('moodle/category:manage', $context);
            self::validate_context($context);
            self::validate_context(get_category_or_system_context($deletecat->parent));

            if ($category['recursive']) {
                // If recursive was specified, then we recursively delete the category's contents.
                if ($deletecat->can_delete_full()) {
                    $deletecat->delete_full(false);
                } else {
                    throw new moodle_exception('youcannotdeletecategory', '', '', $deletecat->get_formatted_name());
                }
            } else {
                // In this situation, we don't delete the category's contents, we either move it to newparent or parent.
                // If the parent is the root, moving is not supported (because a course must always be inside a category).
                // We must move to an existing category.
                if (!empty($category['newparent'])) {
                    $newparentcat = coursecat::get($category['newparent']);
                } else {
                    $newparentcat = coursecat::get($deletecat->parent);
                }

                // This operation is not allowed. We must move contents to an existing category.
                if (!$newparentcat->id) {
                    throw new moodle_exception('movecatcontentstoroot');
                }

                self::validate_context(context_coursecat::instance($newparentcat->id));
                if ($deletecat->can_move_content_to($newparentcat->id)) {
                    $deletecat->delete_move($newparentcat->id, false);
                } else {
                    throw new moodle_exception('youcannotdeletecategory', '', '', $deletecat->get_formatted_name());
                }
            }
        }

        $transaction->allow_commit();
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:57,代码来源:externallib.php


示例16: delete_categories

 /**
  * Delete categories
  *
  * @param array $categories A list of category ids
  * @return array
  * @since Moodle 2.3
  */
 public static function delete_categories($categories)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/course/lib.php";
     // Validate parameters.
     $params = self::validate_parameters(self::delete_categories_parameters(), array('categories' => $categories));
     $transaction = $DB->start_delegated_transaction();
     foreach ($params['categories'] as $category) {
         if (!($deletecat = $DB->get_record('course_categories', array('id' => $category['id'])))) {
             throw new moodle_exception('unknowcategory');
         }
         $context = context_coursecat::instance($deletecat->id);
         require_capability('moodle/category:manage', $context);
         self::validate_context($context);
         self::validate_context(get_category_or_system_context($deletecat->parent));
         if ($category['recursive']) {
             // If recursive was specified, then we recursively delete the category's contents.
             category_delete_full($deletecat, false);
         } else {
             // In this situation, we don't delete the category's contents, we either move it to newparent or parent.
             // If the parent is the root, moving is not supported (because a course must always be inside a category).
             // We must move to an existing category.
             if (!empty($category['newparent'])) {
                 if (!$DB->record_exists('course_categories', array('id' => $category['newparent']))) {
                     throw new moodle_exception('unknowcategory');
                 }
                 $newparent = $category['newparent'];
             } else {
                 $newparent = $deletecat->parent;
             }
             // This operation is not allowed. We must move contents to an existing category.
             if ($newparent == 0) {
                 throw new moodle_exception('movecatcontentstoroot');
             }
             $parentcontext = get_category_or_system_context($newparent);
             require_capability('moodle/category:manage', $parentcontext);
             self::validate_context($parentcontext);
             category_delete_move($deletecat, $newparent, false);
         }
     }
     $transaction->allow_commit();
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:49,代码来源:externallib.php


示例17: user_can_create_courses

/**
 * @global object
 * @uses CONTEXT_COURSECAT
 * @return boolean Whether the user can create courses in any category in the system.
 */
function user_can_create_courses()
{
    global $DB;
    $catsrs = $DB->get_recordset('course_categories');
    foreach ($catsrs as $cat) {
        if (has_capability('moodle/course:create', context_coursecat::instance($cat->id))) {
            $catsrs->close();
            return true;
        }
    }
    $catsrs->close();
    return false;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:18,代码来源:datalib.php


示例18: initialise


//.........这里部分代码省略.........
             $addedcategories = array();
             while (($category = array_shift($categories)) !== null) {
                 if ($category->parent == '0') {
                     $categoryparent = $this->rootnodes['mycourses'];
                 } else {
                     if (array_key_exists($category->parent, $addedcategories)) {
                         $categoryparent = $addedcategories[$category->parent];
                     } else {
                         // Prepare to count iterations. We don't want to loop forever
                         // accidentally if for some reason a category can't be placed.
                         if (!isset($category->loopcount)) {
                             $category->loopcount = 0;
                         }
                         $category->loopcount++;
                         if ($category->loopcount > 5) {
                             // This is a pretty serious problem and this should never happen.
                             // If it does then for some reason a category has been loaded but
                             // its parents have now. It could be data corruption.
                             debugging('Category ' . $category->id . ' could not be placed within the navigation', DEBUG_DEVELOPER);
                         } else {
                             // Add it back to the end of the categories array
                             array_push($categories, $category);
                         }
                         continue;
                     }
                 }
                 $url = new moodle_url('/course/category.php', array('id' => $category->id));
                 $addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id);
                 if (!$category->visible) {
                     // Let's decide the context where viewhidden cap checks will happen.
                     if ($category->parent == '0') {
                         $contexttocheck = context_system::instance();
                     } else {
                         $contexttocheck = context_coursecat::instance($category->parent);
                     }
                     if (!has_capability('moodle/category:viewhiddencategories', $contexttocheck)) {
                         $addedcategories[$category->id]->display = false;
                     } else {
                         $addedcategories[$category->id]->hidden = true;
                     }
                 }
             }
         }
         // Add all of the users courses to the navigation.
         // First up we need to add to the mycourses section.
         foreach ($mycourses as $course) {
             $course->coursenode = $this->add_course($course, false, true);
         }
         if (!empty($CFG->navshowallcourses)) {
             // Load all courses
             $this->load_all_courses();
         }
         // Next if nasvshowallcourses is enabled then we need to add courses
         // to the courses branch as well.
         if (!empty($CFG->navshowallcourses)) {
             foreach ($mycourses as $course) {
                 if (!empty($course->category) && !$this->can_add_more_courses_to_category($course->category)) {
                     continue;
                 }
                 $genericcoursenode = $this->add_course($course, true);
                 if ($genericcoursenode->isactive) {
                     // We don't want this node to be active because we want the
                     // node in the mycourses branch to be active.
                     $genericcoursenode->make_inactive();
                     $genericcoursenode->collapse = true;
                     if ($genericcoursenode->parent && $genericcoursenode->parent->type == self::TYPE_CATEGORY) {
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:67,代码来源:navigationlib.php


示例19: require_login

 * @package eclass-local-contextadmin
 * @author joshstagg
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/coursecatlib.php';
require_once 'categoryroles_form.php';
require_login();
$id = required_param('id', PARAM_INT);
$forum = optional_param('rolerenaming', 0, PARAM_INT);
$itemid = 0;
// Initalise itemid, as all files in category description has item id 0.
$PAGE->set_url('/local/contextadmin/categoryroles.php', array('id' => $id));
$categorycontext = context_coursecat::instance($id);
$PAGE->set_context($categorycontext);
require_capability('moodle/category:manage', $categorycontext);
if (!($category = $DB->get_record('course_categories', array('id' => $id)))) {
    print_error('unknowcategory');
}
$strtitle = get_string('roleedit_title', 'local_contextadmin');
$editorcontext = $categorycontext;
$title = $strtitle;
$fullname = $category->name;
$PAGE->set_pagelayout('admin');
$mform = new categoryroles_form('categoryroles.php', array('category' => $category));
if ($mform->is_cancelled()) {
    if ($id) {
        redirect($CFG->wwwroot . '/course/index.php?categoryid=' . $id . '&categoryedit=on');
    } else {
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:31,代码来源:categoryroles.php


示例20: get_context


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP context_helper类代码示例发布时间:2022-05-23
下一篇:
PHP context_course类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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