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


PHP restore_dbops::send_files_to_pool方法代码示例

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


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

示例1: 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

示例2: send_qtype_files

 /**
  * Send the question type specific files to a new context.
  *
  * @param text            $qtype The qtype name to send.
  * @param int             $oldctxid Old context id.
  * @param int             $newctxid New context id.
  * @param \core\progress  $progress Progress object to use.
  */
 private function send_qtype_files($qtype, $oldctxid, $newctxid, $progress)
 {
     if (!isset($this->qtypecomponentscache[$qtype])) {
         $this->qtypecomponentscache[$qtype] = backup_qtype_plugin::get_components_and_fileareas($qtype);
     }
     $components = $this->qtypecomponentscache[$qtype];
     foreach ($components as $component => $fileareas) {
         foreach ($fileareas as $filearea => $mapping) {
             restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea, $oldctxid, $this->task->get_userid(), $mapping, null, $newctxid, true, $progress);
         }
     }
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:20,代码来源:restore_stepslib.php

示例3: add_related_files

 /**
  * Add all the existing file, given their component and filearea and one backup_ids itemname to match with
  */
 public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null)
 {
     // If the current progress object is set up and ready to receive
     // indeterminate progress, then use it, otherwise don't. (This check is
     // just in case this function is ever called from somewhere not within
     // the execute() method here, which does set up progress like this.)
     $progress = $this->get_task()->get_progress();
     if (!$progress->is_in_progress_section() || $progress->get_current_max() !== \core\progress\base::INDETERMINATE) {
         $progress = null;
     }
     $filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid;
     $results = restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid, null, false, $progress);
     $resultstoadd = array();
     foreach ($results as $result) {
         $this->log($result->message, $result->level);
         $resultstoadd[$result->code] = true;
     }
     $this->task->add_result($resultstoadd);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:22,代码来源:restore_structure_step.class.php

示例4: define_execution

    protected function define_execution() {
        global $DB;

        // Let's process only created questions
        $questionsrs = $DB->get_recordset_sql("SELECT bi.itemid, bi.newitemid, bi.parentitemid, q.qtype
                                               FROM {backup_ids_temp} bi
                                               JOIN {question} q ON q.id = bi.newitemid
                                              WHERE bi.backupid = ?
                                                AND bi.itemname = 'question_created'", array($this->get_restoreid()));
        foreach ($questionsrs as $question) {
            // Get question_category mapping, it contains the target context for the question
            if (!$qcatmapping = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'question_category', $question->parentitemid)) {
                // Something went really wrong, cannot find the question_category for the question
                debugging('Error fetching target context for question', DEBUG_DEVELOPER);
                continue;
            }
            // Calculate source and target contexts
            $oldctxid = $qcatmapping->info->contextid;
            $newctxid = $qcatmapping->parentitemid;

            // Add common question files (question and question_answer ones)
            restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'questiontext',
                                              $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true);
            restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'generalfeedback',
                                              $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true);
            restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answer',
                                              $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true);
            restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'answerfeedback',
                                              $oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true);
            restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'hint',
                                              $oldctxid, $this->task->get_userid(), 'question_hint', null, $newctxid, true);
            // Add qtype dependent files
            $components = backup_qtype_plugin::get_components_and_fileareas($question->qtype);
            foreach ($components as $component => $fileareas) {
                foreach ($fileareas as $filearea => $mapping) {
                    // Use itemid only if mapping is question_created
                    $itemid = ($mapping == 'question_created') ? $question->itemid : null;
                    restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea,
                                                      $oldctxid, $this->task->get_userid(), $mapping, $itemid, $newctxid, true);
                }
            }
        }
        $questionsrs->close();
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:44,代码来源:restore_stepslib.php

示例5: create_included_users


//.........这里部分代码省略.........
         if (!is_enabled_auth($user->auth)) {
             if ($CFG->registerauth == 'email') {
                 $user->auth = 'email';
             } else {
                 $user->auth = 'manual';
             }
         }
         if (!is_enabled_auth($user->auth)) {
             // Final auth check verify, default to manual if not enabled
             $user->auth = 'manual';
         }
         // Now that we know the auth method, for users to be created without pass
         // if password handling is internal and reset password is available
         // we set the password to "restored" (plain text), so the login process
         // will know how to handle that situation in order to allow the user to
         // recover the password. MDL-20846
         if (empty($user->password)) {
             // Only if restore comes without password
             if (!array_key_exists($user->auth, $authcache)) {
                 // Not in cache
                 $userauth = new stdClass();
                 $authplugin = get_auth_plugin($user->auth);
                 $userauth->preventpassindb = $authplugin->prevent_local_passwords();
                 $userauth->isinternal = $authplugin->is_internal();
                 $userauth->canresetpwd = $authplugin->can_reset_password();
                 $authcache[$user->auth] = $userauth;
             } else {
                 $userauth = $authcache[$user->auth];
                 // Get from cache
             }
             // Most external plugins do not store passwords locally
             if (!empty($userauth->preventpassindb)) {
                 $user->password = 'not cached';
                 // If Moodle is responsible for storing/validating pwd and reset functionality is available, mark
             } else {
                 if ($userauth->isinternal and $userauth->canresetpwd) {
                     $user->password = 'restored';
                 }
             }
         }
         // Creating new user, we must reset the policyagreed always
         $user->policyagreed = 0;
         // Set time created if empty
         if (empty($user->timecreated)) {
             $user->timecreated = time();
         }
         // Done, let's create the user and annotate its id
         $newuserid = $DB->insert_record('user', $user);
         self::set_backup_ids_record($restoreid, 'user', $recuser->itemid, $newuserid);
         // Let's create the user context and annotate it (we need it for sure at least for files)
         // but for deleted users that don't have a context anymore (MDL-30192). We are done for them
         // and nothing else (custom fields, prefs, tags, files...) will be created.
         if (empty($user->deleted)) {
             $newuserctxid = $user->deleted ? 0 : get_context_instance(CONTEXT_USER, $newuserid)->id;
             self::set_backup_ids_record($restoreid, 'context', $recuser->parentitemid, $newuserctxid);
             // Process custom fields
             if (isset($user->custom_fields)) {
                 // if present in backup
                 foreach ($user->custom_fields['custom_field'] as $udata) {
                     $udata = (object) $udata;
                     // If the profile field has data and the profile shortname-datatype is defined in server
                     if ($udata->field_data) {
                         if ($field = $DB->get_record('user_info_field', array('shortname' => $udata->field_name, 'datatype' => $udata->field_type))) {
                             /// Insert the user_custom_profile_field
                             $rec = new stdClass();
                             $rec->userid = $newuserid;
                             $rec->fieldid = $field->id;
                             $rec->data = $udata->field_data;
                             $DB->insert_record('user_info_data', $rec);
                         }
                     }
                 }
             }
             // Process tags
             if (!empty($CFG->usetags) && isset($user->tags)) {
                 // if enabled in server and present in backup
                 $tags = array();
                 foreach ($user->tags['tag'] as $usertag) {
                     $usertag = (object) $usertag;
                     $tags[] = $usertag->rawname;
                 }
                 tag_set('user', $newuserid, $tags);
             }
             // Process preferences
             if (isset($user->preferences)) {
                 // if present in backup
                 foreach ($user->preferences['preference'] as $preference) {
                     $preference = (object) $preference;
                     // Prepare the record and insert it
                     $preference->userid = $newuserid;
                     $status = $DB->insert_record('user_preferences', $preference);
                 }
             }
             // Create user files in pool (profile, icon, private) by context
             restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
             restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'profile', $recuser->parentitemid, $userid);
         }
     }
     $rs->close();
 }
开发者ID:numbas,项目名称:moodle,代码行数:101,代码来源:restore_dbops.class.php

示例6: add_related_files

 /**
  * Add all the existing file, given their component and filearea and one backup_ids itemname to match with
  */
 public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null)
 {
     $filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid;
     $results = restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid);
     $resultstoadd = array();
     foreach ($results as $result) {
         $this->log($result->message, $result->level);
         $resultstoadd[$result->code] = true;
     }
     $this->task->add_result($resultstoadd);
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:14,代码来源:restore_structure_step.class.php

示例7: add_related_files

 /**
  * Add all the existing file, given their component and filearea and one backup_ids itemname to match with
  */
 public function add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null)
 {
     $filesctxid = is_null($filesctxid) ? $this->task->get_old_contextid() : $filesctxid;
     restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), $component, $filearea, $filesctxid, $this->task->get_userid(), $mappingitemname, $olditemid);
 }
开发者ID:nigeli,项目名称:moodle,代码行数:8,代码来源:restore_structure_step.class.php


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