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


PHP restore_dbops::set_course_role_names方法代码示例

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


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

示例1: process_course

 /**
  * Processing functions go here
  *
  * @global moodledatabase $DB
  * @param stdClass $data
  */
 public function process_course($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $fullname = $this->get_setting_value('course_fullname');
     $shortname = $this->get_setting_value('course_shortname');
     $startdate = $this->get_setting_value('course_startdate');
     // Calculate final course names, to avoid dupes
     list($fullname, $shortname) = restore_dbops::calculate_course_names($this->get_courseid(), $fullname, $shortname);
     // Need to change some fields before updating the course record
     $data->id = $this->get_courseid();
     $data->fullname = $fullname;
     $data->shortname = $shortname;
     // Only allow the idnumber to be set if the user has permission and the idnumber is not already in use by
     // another course on this site.
     $context = context::instance_by_id($this->task->get_contextid());
     if (!empty($data->idnumber) && has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid()) && $this->task->is_samesite() && !$DB->record_exists('course', array('idnumber' => $data->idnumber))) {
         // Do not reset idnumber.
     } else {
         $data->idnumber = '';
     }
     // Any empty value for course->hiddensections will lead to 0 (default, show collapsed).
     // It has been reported that some old 1.9 courses may have it null leading to DB error. MDL-31532
     if (empty($data->hiddensections)) {
         $data->hiddensections = 0;
     }
     // Set legacyrestrictmodules to true if the course was resticting modules. If so
     // then we will need to process restricted modules after execution.
     $this->legacyrestrictmodules = !empty($data->restrictmodules);
     $data->startdate = $this->apply_date_offset($data->startdate);
     if ($data->defaultgroupingid) {
         $data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
     }
     if (empty($CFG->enablecompletion)) {
         $data->enablecompletion = 0;
         $data->completionstartonenrol = 0;
         $data->completionnotify = 0;
     }
     $languages = get_string_manager()->get_list_of_translations();
     // Get languages for quick search
     if (!array_key_exists($data->lang, $languages)) {
         $data->lang = '';
     }
     $themes = get_list_of_themes();
     // Get themes for quick search later
     if (!array_key_exists($data->theme, $themes) || empty($CFG->allowcoursethemes)) {
         $data->theme = '';
     }
     // Check if this is an old SCORM course format.
     if ($data->format == 'scorm') {
         $data->format = 'singleactivity';
         $data->activitytype = 'scorm';
     }
     // Course record ready, update it
     $DB->update_record('course', $data);
     course_get_format($data)->update_course_format_options($data);
     // Role name aliases
     restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:65,代码来源:restore_stepslib.php

示例2: process_course

 /**
  * Processing functions go here
  *
  * @global moodledatabase $DB
  * @param stdClass $data
  */
 public function process_course($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $fullname = $this->get_setting_value('course_fullname');
     $shortname = $this->get_setting_value('course_shortname');
     $startdate = $this->get_setting_value('course_startdate');
     // Calculate final course names, to avoid dupes
     list($fullname, $shortname) = restore_dbops::calculate_course_names($this->get_courseid(), $fullname, $shortname);
     // Need to change some fields before updating the course record
     $data->id = $this->get_courseid();
     $data->fullname = $fullname;
     $data->shortname = $shortname;
     $context = get_context_instance_by_id($this->task->get_contextid());
     if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
         $data->idnumber = '';
     } else {
         unset($data->idnumber);
     }
     // Any empty value for course->hiddensections will lead to 0 (default, show collapsed).
     // It has been reported that some old 1.9 courses may have it null leading to DB error. MDL-31532
     if (empty($data->hiddensections)) {
         $data->hiddensections = 0;
     }
     // Only restrict modules if original course was and target site too for new courses
     $data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
     $data->startdate = $this->apply_date_offset($data->startdate);
     if ($data->defaultgroupingid) {
         $data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
     }
     if (empty($CFG->enablecompletion)) {
         $data->enablecompletion = 0;
         $data->completionstartonenrol = 0;
         $data->completionnotify = 0;
     }
     $languages = get_string_manager()->get_list_of_translations();
     // Get languages for quick search
     if (!array_key_exists($data->lang, $languages)) {
         $data->lang = '';
     }
     $themes = get_list_of_themes();
     // Get themes for quick search later
     if (!array_key_exists($data->theme, $themes) || empty($CFG->allowcoursethemes)) {
         $data->theme = '';
     }
     // Course record ready, update it
     $DB->update_record('course', $data);
     // Role name aliases
     restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
 }
开发者ID:renatosousafilho,项目名称:moodle-restore,代码行数:56,代码来源:restore_stepslib.php

示例3: process_course

    /**
     * Processing functions go here
     *
     * @global moodledatabase $DB
     * @param stdClass $data
     */
    public function process_course($data) {
        global $CFG, $DB;

        $data = (object)$data;
        $oldid = $data->id; // We'll need this later

        $fullname  = $this->get_setting_value('course_fullname');
        $shortname = $this->get_setting_value('course_shortname');
        $startdate = $this->get_setting_value('course_startdate');

        // Calculate final course names, to avoid dupes
        list($fullname, $shortname) = restore_dbops::calculate_course_names($this->get_courseid(), $fullname, $shortname);

        // Need to change some fields before updating the course record
        $data->id = $this->get_courseid();
        $data->fullname = $fullname;
        $data->shortname= $shortname;
        $data->idnumber = '';

        // Only restrict modules if original course was and target site too for new courses
        $data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';

        $data->startdate= $this->apply_date_offset($data->startdate);
        if ($data->defaultgroupingid) {
            $data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
        }
        if (empty($CFG->enablecompletion)) {
            $data->enablecompletion = 0;
            $data->completionstartonenrol = 0;
            $data->completionnotify = 0;
        }
        $languages = get_string_manager()->get_list_of_translations(); // Get languages for quick search
        if (!array_key_exists($data->lang, $languages)) {
            $data->lang = '';
        }

        $themes = get_list_of_themes(); // Get themes for quick search later
        if (!array_key_exists($data->theme, $themes) || empty($CFG->allowcoursethemes)) {
            $data->theme = '';
        }

        // Course record ready, update it
        $DB->update_record('course', $data);

        // Role name aliases
        restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:53,代码来源:restore_stepslib.php

示例4: process_course

 /**
  * Processing functions go here
  *
  * @global moodledatabase $DB
  * @param stdClass $data
  */
 public function process_course($data)
 {
     global $CFG, $DB;
     $data = (object) $data;
     $coursetags = isset($data->tags['tag']) ? $data->tags['tag'] : array();
     $coursemodules = isset($data->allowed_modules['module']) ? $data->allowed_modules['module'] : array();
     $oldid = $data->id;
     // We'll need this later
     $fullname = $this->get_setting_value('course_fullname');
     $shortname = $this->get_setting_value('course_shortname');
     $startdate = $this->get_setting_value('course_startdate');
     // Calculate final course names, to avoid dupes
     list($fullname, $shortname) = restore_dbops::calculate_course_names($this->get_courseid(), $fullname, $shortname);
     // Need to change some fields before updating the course record
     $data->id = $this->get_courseid();
     $data->fullname = $fullname;
     $data->shortname = $shortname;
     $data->idnumber = '';
     // Category is set by UI when choosing the destination
     unset($data->category);
     $data->startdate = $this->apply_date_offset($data->startdate);
     if ($data->defaultgroupingid) {
         $data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
     }
     if (empty($CFG->enablecompletion)) {
         $data->enablecompletion = 0;
         $data->completionstartonenrol = 0;
         $data->completionnotify = 0;
     }
     $languages = get_string_manager()->get_list_of_translations();
     // Get languages for quick search
     if (!array_key_exists($data->lang, $languages)) {
         $data->lang = '';
     }
     $themes = get_list_of_themes();
     // Get themes for quick search later
     if (!in_array($data->theme, $themes) || empty($CFG->allowcoursethemes)) {
         $data->theme = '';
     }
     // Course record ready, update it
     $DB->update_record('course', $data);
     // Course tags
     if (!empty($CFG->usetags) && isset($coursetags)) {
         // if enabled in server and present in backup
         $tags = array();
         foreach ($coursetags as $coursetag) {
             $coursetag = (object) $coursetag;
             $tags[] = $coursetag->rawname;
         }
         tag_set('course', $this->get_courseid(), $tags);
     }
     // Course allowed modules
     if (!empty($data->restrictmodules) && !empty($coursemodules)) {
         $available = get_plugin_list('mod');
         foreach ($coursemodules as $coursemodule) {
             $mname = $coursemodule['modulename'];
             if (array_key_exists($mname, $available)) {
                 if ($module = $DB->get_record('modules', array('name' => $mname, 'visible' => 1))) {
                     $rec = new stdclass();
                     $rec->course = $this->get_courseid();
                     $rec->module = $module->id;
                     if (!$DB->record_exists('course_allowed_modules', (array) $rec)) {
                         $DB->insert_record('course_allowed_modules', $rec);
                     }
                 }
             }
         }
     }
     // Role name aliases
     restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:77,代码来源:restore_stepslib.php


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