public function process_nested_element(base_nested_element $nested) { // Proceed with all the file annotations for this element $fileannotations = $nested->get_file_annotations(); if ($fileannotations) { // If there are areas to search $backupid = $this->get_var(backup::VAR_BACKUPID); foreach ($fileannotations as $component => $area) { foreach ($area as $filearea => $info) { $contextid = !is_null($info->contextid) ? $info->contextid : $this->get_var(backup::VAR_CONTEXTID); $itemid = !is_null($info->element) ? $info->element->get_value() : null; backup_structure_dbops::annotate_files($backupid, $contextid, $component, $filearea, $itemid); } } } }
protected function define_execution() { global $DB; // List of fileareas we are going to annotate $fileareas = array('profile', 'icon'); if ($this->get_setting_value('user_files')) { // private files only if enabled in settings $fileareas[] = 'private'; } // Fetch all annotated (final) users $rs = $DB->get_recordset('backup_ids_temp', array('backupid' => $this->get_backupid(), 'itemname' => 'userfinal')); foreach ($rs as $record) { $userid = $record->itemid; $userctx = get_context_instance(CONTEXT_USER, $userid); if (!$userctx) { continue; // User has not context, sure it's a deleted user, so cannot have files } // Proceed with every user filearea foreach ($fileareas as $filearea) { // We don't need to specify itemid ($userid - 5th param) as far as by // context we can get all the associated files. See MDL-22092 backup_structure_dbops::annotate_files($this->get_backupid(), $userctx->id, 'user', $filearea, null); } } $rs->close(); }
protected function define_execution() { global $DB; // List of fileareas we are going to annotate $fileareas = array('profile', 'icon'); // Fetch all annotated (final) users $rs = $DB->get_recordset('backup_ids_temp', array('backupid' => $this->get_backupid(), 'itemname' => 'userfinal')); $progress = $this->task->get_progress(); $progress->start_progress($this->get_name()); foreach ($rs as $record) { $userid = $record->itemid; $userctx = context_user::instance($userid, IGNORE_MISSING); if (!$userctx) { continue; // User has not context, sure it's a deleted user, so cannot have files } // Proceed with every user filearea foreach ($fileareas as $filearea) { // We don't need to specify itemid ($userid - 5th param) as far as by // context we can get all the associated files. See MDL-22092 backup_structure_dbops::annotate_files($this->get_backupid(), $userctx->id, 'user', $filearea, null); $progress->progress(); } } $progress->end_progress(); $rs->close(); }
protected function define_execution() { global $DB; // List of fileareas we are going to annotate $fileareas = array('profile', 'icon'); // Fetch all annotated (final) users $rs = $DB->get_recordset('backup_ids_temp', array('backupid' => $this->get_backupid(), 'itemname' => 'userfinal')); foreach ($rs as $record) { $userid = $record->itemid; $userctxid = get_context_instance(CONTEXT_USER, $userid)->id; // Proceed with every user filearea foreach ($fileareas as $filearea) { // We don't need to specify itemid ($userid - 5th param) as far as by // context we can get all the associated files. See MDL-22092 backup_structure_dbops::annotate_files($this->get_backupid(), $userctxid, 'user', $filearea, null); } } $rs->close(); }