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

PHP restore_dbops类代码示例

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

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



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

示例1: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target glossary for the block. This must be done here
  * and not in normal execution steps because the glossary
  * may be restored after the block.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid
     $blockid = $this->get_blockid();
     // Extract block configdata and update it to point to the new glossary
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->glossary)) {
             if ($glossarymap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'glossary', $config->glossary)) {
                 // Get glossary mapping and replace it in config
                 $config->glossary = $glossarymap->newitemid;
             } else {
                 if ($this->is_samesite()) {
                     // We are restoring on the same site, check if glossary can be used in the block in this course.
                     $glossaryid = $DB->get_field_sql("SELECT id FROM {glossary} " . "WHERE id = ? AND (course = ? OR globalglossary = 1)", [$config->glossary, $this->get_courseid()]);
                     if (!$glossaryid) {
                         unset($config->glossary);
                     }
                 } else {
                     // The block refers to a glossary not present in the backup file.
                     unset($config->glossary);
                 }
             }
             // Unset config variables that are no longer used.
             unset($config->globalglossary);
             unset($config->courseid);
             // Save updated config.
             $configdata = base64_encode(serialize($config));
             $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:40,代码来源:restore_glossary_random_block_task.class.php


示例2: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will remove tag collection reference in case block was restored into another site.
  * Also get mapping of contextid.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid.
     $blockid = $this->get_blockid();
     // Extract block configdata and remove tag collection reference if this is another site. Also map contextid.
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         $changed = false;
         if (!empty($config->tagcoll) && $config->tagcoll > 1 && !$this->is_samesite()) {
             $config->tagcoll = 0;
             $changed = true;
         }
         if (!empty($config->ctx)) {
             if ($ctxmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'context', $config->ctx)) {
                 $config->ctx = $ctxmap->newitemid;
             } else {
                 $config->ctx = 0;
             }
             $changed = true;
         }
         if ($changed) {
             $configdata = base64_encode(serialize($config));
             $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:restore_tags_block_task.class.php


示例3: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target activity for the block. This must be done here
  * and not in normal execution so we are sure everything is
  * at its finale place.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid.
     $blockid = $this->get_blockid();
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->section_id)) {
             // Get the mapping and replace it in config.
             if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'course_section', $config->section_id)) {
                 // Update the parent module id (the id from mdl_quiz etc...)
                 $config->section_id = $mapping->newitemid;
                 // Encode and save the config.
                 $configdata = base64_encode(serialize($config));
                 $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
                 // Arrange the replace link in the course_sections summary.
                 $newsection = $DB->get_record('course_sections', array('id' => $mapping->newitemid));
                 // Update the Side Bar section with the required values to make it work.
                 $reseturl = new moodle_url('/blocks/side_bar/reset.php?cid=' . $newsection->course);
                 $newsection->name = get_string('sidebar', 'block_side_bar');
                 $newsection->summary = get_string('sectionsummary', 'block_side_bar', (string) html_writer::link($reseturl, $reseturl));
                 $newsection->summaryformat = FORMAT_HTML;
                 $newsection->visible = true;
                 $DB->update_record('course_sections', $newsection);
             }
         }
     }
 }
开发者ID:fernandooliveira,项目名称:moodle-block_sidebar,代码行数:35,代码来源:restore_ned_sidebar_block_task.class.php


示例4: after_restore

 public function after_restore()
 {
     global $DB;
     $course_id = $this->get_courseid();
     $records = $DB->get_records("block_lockdownbrowser_sett", array("course" => $course_id));
     if ($records === FALSE) {
         return;
     }
     $missing_ids = 0;
     foreach ($records as $settings) {
         $old_quizid = $settings->quizid;
         if (empty($old_quizid)) {
             continue;
         }
         $quizmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), "quiz", $old_quizid);
         if (empty($quizmap)) {
             $missing_ids++;
             continue;
         }
         $settings->quizid = $quizmap->newitemid;
         $DB->update_record('block_lockdownbrowser_sett', $settings);
     }
     if ($missing_ids > 0) {
         $this->get_logger()->process("Failed to restore dependency in block 'lockdownbrowser'. " . "Backup and restore will not work correctly unless you " . "include the dependent 'quiz' modules.", backup::LOG_ERROR);
     }
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:26,代码来源:restore_lockdownbrowser_block_task.class.php


示例5: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target quiz for the block. This must be done here
  * and not in normal execution steps because the quiz
  * can be restored after the block.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid.
     $blockid = $this->get_blockid();
     // Extract block configdata and update it to point to the new quiz.
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->quizid)) {
             // Get quiz mapping and replace it in config.
             if ($quizmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'quiz', $config->quizid)) {
                 $config->activityparent = 'quiz';
                 $config->activityparentid = $quizmap->newitemid;
                 // Set the decimal valuue as appropriate.
                 if ($config->gradeformat == 1) {
                     // This block is using percentages, do not display any decimal places.
                     $config->decimalpoints = 0;
                 } else {
                     // Get the decimal value from the corresponding quiz.
                     $config->decimalpoints = $DB->get_field('quiz', 'decimalpoints', array('id' => $config->activityparentid));
                 }
                 // Get the grade_items record to set the activitygradeitemid.
                 $info = $DB->get_record('grade_items', array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));
                 $config->activitygradeitemid = $info->id;
                 unset($config->quizid);
                 // Save the new configuration and update the record.
                 $DB->set_field('block_instances', 'configdata', base64_encode(serialize($config)), array('id' => $blockid));
                 $DB->set_field('block_instances', 'blockname', 'activity_results', array('id' => $blockid));
             }
         }
     }
 }
开发者ID:grug,项目名称:moodle,代码行数:39,代码来源:restore_quiz_results_block_task.class.php


示例6: process_log

 protected function process_log($log, $oldctx, $context)
 {
     global $DB;
     $log = (object) $log;
     $oldid = $log->id;
     $mailedusers = explode(',', $log->mailto);
     $validusers = array();
     foreach ($mailedusers as $userid) {
         $validusers[] = $this->get_mappingid('user', $userid);
     }
     $log->courseid = $this->get_courseid();
     $log->userid = $this->get_mappingid('user', $log->userid);
     $log->mailto = implode(',', $validusers);
     $log->time = $this->apply_date_offset($log->time);
     // TODO: correctly convert alternate ids
     $log->alternateid = null;
     $newid = $DB->insert_record('block_quickmail_log', $log);
     $this->set_mapping('log', $oldid, $newid);
     foreach (array('log', 'attachment_log') as $filearea) {
         restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'block_quickmail', $filearea, $oldctx, $log->userid);
         $sql = 'UPDATE {files} SET
             itemid = :newid WHERE contextid = :ctxt AND itemid = :oldid';
         $params = array('newid' => $newid, 'oldid' => $oldid, 'ctxt' => $context->id);
         $DB->execute($sql, $params);
     }
 }
开发者ID:amunguia,项目名称:block_quickmail,代码行数:26,代码来源:restore_quickmail_stepslib.php


示例7: dispatch_chunk

 protected function dispatch_chunk($data)
 {
     // Prepare question_category record
     if ($data['path'] == '/question_categories/question_category') {
         $info = (object) $data['tags'];
         $itemname = 'question_category';
         $itemid = $info->id;
         $parentitemid = $info->contextid;
         $this->lastcatid = $itemid;
         // Prepare question record
     } else {
         if ($data['path'] == '/question_categories/question_category/questions/question') {
             $info = (object) $data['tags'];
             $itemname = 'question';
             $itemid = $info->id;
             $parentitemid = $this->lastcatid;
             // Not question_category nor question, impossible. Throw exception.
         } else {
             throw new progressive_parser_exception('restore_questions_parser_processor_unexpected_path', $data['path']);
         }
     }
     // Only load it if needed (exist same question_categoryref itemid in table)
     if (restore_dbops::get_backup_ids_record($this->restoreid, 'question_categoryref', $this->lastcatid)) {
         restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid, 0, $parentitemid, $info);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:restore_questions_parser_processor.class.php


示例8: dispatch_chunk

 protected function dispatch_chunk($data)
 {
     // Received one inforef chunck, we are going to store it into backup_ids
     // table, with name = itemname + "ref" for later use
     $itemname = basename($data['path']) . 'ref';
     $itemid = $data['tags']['id'];
     restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:restore_inforef_parser_processor.class.php


示例9: dispatch_chunk

 protected function dispatch_chunk($data)
 {
     // Received one role chunck, we are going to store it into backup_ids
     // table, with name = role
     $itemname = 'role';
     $itemid = $data['tags']['id'];
     $info = $data['tags'];
     // Only load it if needed (exist same roleref itemid in table)
     if (restore_dbops::get_backup_ids_record($this->restoreid, 'roleref', $itemid)) {
         restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid, 0, null, $info);
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:12,代码来源:restore_roles_parser_processor.class.php


示例10: dispatch_chunk

 protected function dispatch_chunk($data)
 {
     // Received one user chunck, we are going to store it into backup_ids
     // table, with name = user and parentid = contextid for later use
     $itemname = 'user';
     $itemid = $data['tags']['id'];
     $parentitemid = $data['tags']['contextid'];
     $info = $data['tags'];
     // Only load it if needed (exist same userref itemid in table)
     if (restore_dbops::get_backup_ids_record($this->restoreid, 'userref', $itemid)) {
         restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid, 0, $parentitemid, $info);
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:restore_users_parser_processor.class.php


示例11: define_execution

 /**
  *  Checks if mapped questions are exact valid, or marks them to be created
  *  
  *  @global $DB
  *  @throws moodle_exception
  */
 protected function define_execution()
 {
     global $DB;
     $restoreid = $this->get_restoreid();
     $courseid = $this->get_courseid();
     $userid = $this->task->get_userid();
     $workaround_qtypes = explode(',', get_config('block_sharing_cart', 'workaround_qtypes'));
     // @see /backup/util/dbops/restore_dbops.class.php#prechek_precheck_qbanks_by_level
     $contexts = restore_dbops::restore_get_question_banks($restoreid);
     foreach ($contexts as $contextid => $contextlevel) {
         $categories = restore_dbops::restore_get_question_categories($restoreid, $contextid);
         $canadd = false;
         if ($targetcontext = restore_dbops::restore_find_best_target_context($categories, $courseid, $contextlevel)) {
             $canadd = has_capability('moodle/question:add', $targetcontext, $userid);
         }
         foreach ($categories as $category) {
             $questions = restore_dbops::restore_get_questions($restoreid, $category->id);
             foreach ($questions as $question) {
                 if (!in_array($question->qtype, $workaround_qtypes)) {
                     continue;
                 }
                 $mapping = restore_dbops::get_backup_ids_record($restoreid, 'question', $question->id);
                 if ($mapping && $mapping->newitemid && !self::is_question_valid($question->qtype, $mapping->newitemid)) {
                     if (!$canadd) {
                         throw new moodle_exception('questioncannotberestored', 'backup', '', $question);
                     }
                     $catmapping = restore_dbops::get_backup_ids_record($restoreid, 'question_category', $category->id);
                     $matchquestions = $DB->get_records('question', array('category' => $catmapping->newitemid, 'qtype' => $question->qtype, 'stamp' => $question->stamp, 'version' => $question->version));
                     $newitemid = 0;
                     // to be created if no valid duplicate exists
                     foreach ($matchquestions as $q) {
                         if ($q->id == $mapping->newitemid) {
                             continue;
                         }
                         if (self::is_question_valid($question->qtype, $q->id)) {
                             $newitemid = $q->id;
                             // updates mapping if a valid one found
                             break;
                         }
                     }
                     $this->update_mapping($mapping, $newitemid);
                 }
             }
         }
     }
 }
开发者ID:edurenye,项目名称:sharing_cart,代码行数:52,代码来源:restore_fix_missing_questions.php


示例12: after_restore

 public function after_restore()
 {
     global $DB;
     // Find all the items that have a 'moduleid' but are not headings and match them up to the newly-restored activities.
     $items = $DB->get_records_select('checklist_item', 'checklist = ? AND moduleid > 0 AND itemoptional <> 2', array($this->get_activityid()));
     foreach ($items as $item) {
         $moduleid = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'course_module', $item->moduleid);
         if ($moduleid) {
             // Match up the moduleid to the restored activity module.
             $DB->set_field('checklist_item', 'moduleid', $moduleid->newitemid, array('id' => $item->id));
         } else {
             // Does not match up to a restored activity module => delete the item + associated user data.
             $DB->delete_records('checklist_check', array('item' => $item->id));
             $DB->delete_records('checklist_comment', array('itemid' => $item->id));
             $DB->delete_records('checklist_item', array('id' => $item->id));
         }
     }
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:18,代码来源:restore_checklist_activity_task.class.php


示例13: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target quiz for the block. This must be done here
  * and not in normal execution steps because the quiz
  * can be restored after the block.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid
     $blockid = $this->get_blockid();
     // Extract block configdata and update it to point to the new quiz
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->quizid)) {
             // Get quiz mapping and replace it in config
             if ($quizmap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'quiz', $config->quizid)) {
                 $config->quizid = $quizmap->newitemid;
                 $configdata = base64_encode(serialize($config));
                 $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
             }
         }
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:25,代码来源:restore_quiz_results_block_task.class.php


示例14: test_mod_jclic_backup_restore

 public function test_mod_jclic_backup_restore()
 {
     global $USER, $DB, $CFG;
     require_once $CFG->dirroot . '/backup/util/includes/backup_includes.php';
     require_once $CFG->dirroot . '/backup/util/includes/restore_includes.php';
     $this->resetAfterTest(true);
     $this->setUser(2);
     // Admin user.
     // Create a course with some availability data set.
     $generator = $this->getDataGenerator();
     $course = $generator->create_course(array('format' => 'topics', 'numsections' => 3, 'enablecompletion' => COMPLETION_ENABLED), array('createsections' => true));
     $jclic = $generator->create_module('jclic', array('course' => $course->id));
     // Turn off file logging, otherwise it can't delete the file (Windows).
     $CFG->backup_file_logger_level = backup::LOG_NONE;
     // Do backup with default settings. MODE_IMPORT means it will just
     // create the directory and not zip it.
     $bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id);
     $backupid = $bc->get_backupid();
     $bc->execute_plan();
     $bc->destroy();
     // Do restore to new course with default settings.
     $newcourseid = restore_dbops::create_new_course($course->fullname, $course->shortname . '_2', $course->category);
     $rc = new restore_controller($backupid, $newcourseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id, backup::TARGET_NEW_COURSE);
     $this->assertTrue($rc->execute_precheck());
     $rc->execute_plan();
     $rc->destroy();
     // Check settings in new course.
     $modinfo = get_fast_modinfo($newcourseid);
     $jclics = array_values($modinfo->get_instances_of('jclic'));
     $newjclic = new jclic(context_module::instance($jclics[0]->id), false, false);
     $newjclicmodule = $newjclic->get_instance();
     $this->assertNotEmpty($newjclic);
     $jclic = new jclic(context_module::instance($jclic->cmid), false, false);
     $jclicmodule = $jclic->get_instance();
     $fields = (array) $jclicmodule;
     unset($fields['id']);
     unset($fields['course']);
     foreach ($fields as $key => $unused) {
         $this->assertEquals($newjclicmodule->{$key}, $jclicmodule->{$key}, "Failed on field {$key}");
     }
     // Avoid errors...
     ini_set('max_execution_time', 0);
 }
开发者ID:danielvdml,项目名称:moodleyarcho,代码行数:43,代码来源:lib_test.php


示例15: after_restore

 /**
  * Translates the backed up configuration data for the target course modules.
  *
  * @global type $DB
  */
 public function after_restore()
 {
     global $DB;
     $prefixes = array('monitor_', 'date_time_', 'action_', 'locked_');
     // Get the blockid.
     $id = $this->get_blockid();
     // Get restored course id.
     $courseid = $this->get_courseid();
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $id))) {
         $config = (array) unserialize(base64_decode($configdata));
         $newconfig = $config;
         // Filter module related config information.
         foreach ($newconfig as $key => $value) {
             foreach ($prefixes as $prefix) {
                 if (substr($key, 0, strlen($prefix)) === $prefix) {
                     unset($newconfig[$key]);
                 }
             }
         }
         // Translate the old config information to the target course values.
         foreach ($config as $key => $value) {
             $matches = array();
             preg_match('/monitor_(\\D+)(\\d+)/', $key, $matches);
             if (!empty($matches)) {
                 $module = $matches[1];
                 $instance = $matches[2];
                 // Find the mapped instance ID.
                 if ($newinstance = restore_dbops::get_backup_ids_record($this->get_restoreid(), $module, $instance)) {
                     $newinstanceid = $newinstance->newitemid;
                     // Translate new instance values from old IDs.
                     foreach ($prefixes as $prefix) {
                         if (isset($config["{$prefix}{$module}{$instance}"])) {
                             $newconfig["{$prefix}{$module}{$newinstanceid}"] = $config["{$prefix}{$module}{$instance}"];
                         }
                     }
                 }
             }
         }
         // Save everything back to DB.
         $configdata = base64_encode(serialize((object) $newconfig));
         $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $id));
     }
 }
开发者ID:nwp90,项目名称:Moodle-block_progress,代码行数:48,代码来源:restore_progress_block_task.class.php


示例16: course_rollover

/**
 * Roll over an existing Moodle course into a new one using a customized backup
 * and restore routine
 *
 * @param int $courseid Id of the course we are copying
 * @param int $categoryid
 * @return int|boolean Id of the newly created course
 */
function course_rollover($courseid, $categoryid = null)
{
    global $DB;
    if ($course = $DB->get_record('course', array('id' => $courseid))) {
        //figure out the category
        if ($categoryid === null) {
            $categoryid = $course->category;
        }
        //make sure the category is valid
        if (!$DB->record_exists('course_categories', array('id' => $categoryid))) {
            //invalid category
            return false;
        }
        //perform backup without including user info
        $controller = new rollover_backup_controller($courseid);
        $controller->get_plan()->get_setting('users')->set_value(false);
        $controller->execute_plan();
        //get directory name for use in restore
        $backupid = $controller->get_backupid();
        //start a database transaction to make sure restore is atomic, etc
        $transaction = $DB->start_delegated_transaction();
        //create the new course
        $result = restore_dbops::create_new_course($course->fullname, $course->shortname, $categoryid);
        //restore the content into it within the current transaction without including user information
        $controller = new rollover_restore_controller($backupid, $result);
        $controller->get_plan()->get_setting('users')->set_value(false);
        $controller->execute_precheck();
        $controller->execute_plan();
        //make sure the sort order is defined as expected
        fix_course_sortorder();
        try {
            //try to finalize
            $transaction->allow_commit();
        } catch (dml_transaction_exception $e) {
            //failure
            $result = false;
        }
        return $result;
    } else {
        //invalid course specified
        return false;
    }
}
开发者ID:jamesmcq,项目名称:elis,代码行数:51,代码来源:lib.php


示例17: after_restore

 /**
  * Translates the backed up configuration data for the target course modules
  *
  * @global type $DB
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid
     $id = $this->get_blockid();
     //Restored course id
     $courseid = $this->get_courseid();
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $id))) {
         $config = (array) unserialize(base64_decode($configdata));
         // Translate the old config information to the target course values
         foreach ($config as $key => $value) {
             $matches = array();
             preg_match('/monitor_(\\D+)(\\d+)/', $key, $matches);
             if ($value == 1 && !empty($matches)) {
                 $module = $matches[1];
                 $instance = $matches[2];
                 // Find a matching module in the target course
                 if ($cm = get_coursemodule_from_instance($module, $instance)) {
                     // Get new cm and instance
                     $newitem = restore_dbops::get_backup_ids_record($this->get_restoreid(), "course_module", $cm->id);
                     $newcm = get_coursemodule_from_id($module, $newitem->newitemid);
                     $newinstance = $newcm->instance;
                     // Set new config
                     $config["monitor_{$module}{$newinstance}"] = $config["monitor_{$module}{$instance}"];
                     $config["locked_{$module}{$newinstance}"] = $config["locked_{$module}{$instance}"];
                     $config["date_time_{$module}{$newinstance}"] = $config["date_time_{$module}{$instance}"];
                     $config["action_{$module}{$newinstance}"] = $config["action_{$module}{$instance}"];
                     // Unset old config
                     unset($config["monitor_{$module}{$instance}"]);
                     unset($config["locked_{$module}{$instance}"]);
                     unset($config["date_time_{$module}{$instance}"]);
                     unset($config["action_{$module}{$instance}"]);
                 }
             }
         }
         // Save everything back to DB
         $configdata = base64_encode(serialize((object) $config));
         $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $id));
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:45,代码来源:restore_progress_block_task.class.php


示例18: update_after_restore

 public function update_after_restore($restoreid, $courseid, \base_logger $logger, $name)
 {
     global $DB;
     if (!$this->roleid) {
         // If using 'same as activity' option, no need to change it.
         return false;
     }
     $rec = \restore_dbops::get_backup_ids_record($restoreid, 'role', $this->roleid);
     if (!$rec || !$rec->newitemid) {
         // If we are on the same course (e.g. duplicate) then we can just
         // use the existing one.
         if ($DB->record_exists('roles', array('id' => $this->roleid, 'courseid' => $courseid))) {
             return false;
         }
         // Otherwise it's a warning.
         $this->roleid = -1;
         $logger->process('Restored item (' . $name . ') has availability condition on grouping that was not restored', \backup::LOG_WARNING);
     } else {
         $this->roleid = (int) $rec->newitemid;
     }
     return true;
 }
开发者ID:moodleuulm,项目名称:moodle-availability_role,代码行数:22,代码来源:condition.php


示例19: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target activity for the block. This must be done here
  * and not in normal execution steps because the activity
  * can be restored after the block.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid.
     $blockid = $this->get_blockid();
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->activityparentid)) {
             // Get the mapping and replace it in config.
             if ($mapping = restore_dbops::get_backup_ids_record($this->get_restoreid(), $config->activityparent, $config->activityparentid)) {
                 // Update the parent module id (the id from mdl_quiz etc...)
                 $config->activityparentid = $mapping->newitemid;
                 // Get the grade_items record to update the activitygradeitemid.
                 $info = $DB->get_record('grade_items', array('iteminstance' => $config->activityparentid, 'itemmodule' => $config->activityparent));
                 // Update the activitygradeitemid the id from the grade_items table.
                 $config->activitygradeitemid = $info->id;
                 // Encode and save the config.
                 $configdata = base64_encode(serialize($config));
                 $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:restore_activity_results_block_task.class.php


示例20: after_restore

 /**
  * This function, executed after all the tasks in the plan
  * have been executed, will perform the recode of the
  * target glossary for the block. This must be done here
  * and not in normal execution steps because the glossary
  * may be restored after the block.
  */
 public function after_restore()
 {
     global $DB;
     // Get the blockid
     $blockid = $this->get_blockid();
     // Extract block configdata and update it to point to the new glossary
     if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) {
         $config = unserialize(base64_decode($configdata));
         if (!empty($config->glossary)) {
             // Get glossary mapping and replace it in config
             if ($glossarymap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'glossary', $config->glossary)) {
                 $mappedglossary = $DB->get_record('glossary', array('id' => $glossarymap->newitemid), 'id,course,globalglossary', MUST_EXIST);
                 $config->glossary = $mappedglossary->id;
                 $config->courseid = $mappedglossary->course;
                 $config->globalglossary = $mappedglossary->globalglossary;
                 $configdata = base64_encode(serialize($config));
                 $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid));
             } else {
                 // The block refers to a glossary not present in the backup file.
                 $DB->set_field('block_instances', 'configdata', '', array('id' => $blockid));
             }
         }
     }
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:31,代码来源:restore_glossary_random_block_task.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP restore_enrolments_structure_step类代码示例发布时间:2022-05-23
下一篇:
PHP restore_controller类代码示例发布时间: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