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


PHP backup_controller::get_logger方法代码示例

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


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

示例1: backup

 /**
  * Takes the original course object as an argument, backs up the
  * course and returns a backupid which can be used for restoring the course.
  *
  * @param object $course Original course object
  * @param array $activityids all cm ids to backup
  * @param array $activityids all section ids to backup
  * @throws coding_exception Moodle coding_exception
  * @retun string backupid Backupid
  */
 private function backup($course, $activityids, $sectionids)
 {
     global $CFG, $DB, $USER;
     // MODE_IMPORT option is required to prevent it from zipping up the
     // result at the end. Unfortunately this breaks the system in some
     // other ways (see other comments).
     // NOTE: We cannot use MODE_SAMESITE here because that option will
     // zip the result and anyway, MODE_IMPORT already turns off the files.
     $bc = new \backup_controller(\backup::TYPE_1COURSE, $course->id, \backup::FORMAT_MOODLE, \backup::INTERACTIVE_NO, \backup::MODE_IMPORT, $USER->id);
     // Setup custom logger that prints dots.
     $logger = new logger(\backup::LOG_INFO, false, true);
     self::$currentlogger = $logger;
     $logger->potential_dot();
     $bc->get_logger()->set_next($logger);
     $bc->set_progress(new progress());
     foreach ($bc->get_plan()->get_tasks() as $taskindex => $task) {
         $settings = $task->get_settings();
         foreach ($settings as $settingindex => $setting) {
             $setting->set_status(\backup_setting::NOT_LOCKED);
             // Modify the values of the intial backup settings.
             if ($taskindex == 0) {
                 if (isset($this->backupsettings[$setting->get_name()])) {
                     $setting->set_value($this->backupsettings[$setting->get_name()]);
                 }
             } else {
                 list($name, $id, $type) = $this->parse_backup_course_module($setting->get_name());
                 // Include user data on glossary if the role 'contributingstudent'
                 // does not have the capability mod/glossary:write on that glossary.
                 // This is so that we include course-team glossary data but not
                 // glossaries that are written by students.
                 if ($name === 'glossary' && $type === 'userinfo') {
                     // Find the contributing student role id. If there
                     // isn't one, use the student role id, for dev servers etc.
                     $roles = $DB->get_records_select('role', "shortname IN ('contributingstudent', 'student')", null, 'shortname', 'id');
                     if (!$roles) {
                         continue;
                     }
                     $roleid = reset($roles)->id;
                     // Get the list of roles which have the capability in the context
                     // of the glossary.
                     $context = \context_module::instance($id);
                     list($allowed, $forbidden) = get_roles_with_cap_in_context($context, 'mod/glossary:write');
                     // If student has this capability then the user data is false.
                     if (!empty($allowed[$roleid]) && empty($forbidden[$roleid])) {
                         $setting->set_value(false);
                     } else {
                         $setting->set_value(true);
                     }
                 }
                 // Ignone any sections not in subpage.
                 if ($name === 'section' && $type === 'included' && !in_array($id, $sectionids)) {
                     $setting->set_value(false);
                 }
                 // Ignone any activities not in subpage.
                 if ($name !== 'section' && $type === 'included' && !in_array($id, $activityids)) {
                     $setting->set_value(false);
                 }
             }
         }
     }
     $logger->potential_dot();
     $bc->save_controller();
     $backupid = $bc->get_backupid();
     $this->backupbasepath = $bc->get_plan()->get_basepath();
     $bc->execute_plan();
     $bc->destroy();
     return $backupid;
 }
开发者ID:ninelanterns,项目名称:moodle-mod_subpage,代码行数:78,代码来源:lib.php


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