Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 46... Línea 46...
46
     * progress reports.
46
     * progress reports.
47
     *
47
     *
48
     * @param string $backupid Backup id
48
     * @param string $backupid Backup id
49
     * @param \core\progress\base $progress Optional progress reporting object
49
     * @param \core\progress\base $progress Optional progress reporting object
50
     */
50
     */
51
    public static function clear_backup_dir($backupid, \core\progress\base $progress = null) {
51
    public static function clear_backup_dir($backupid, ?\core\progress\base $progress = null) {
52
        $backupiddir = make_backup_temp_directory($backupid, false);
52
        $backupiddir = make_backup_temp_directory($backupid, false);
53
        if (!self::delete_dir_contents($backupiddir, '', $progress)) {
53
        if (!self::delete_dir_contents($backupiddir, '', $progress)) {
54
            throw new backup_helper_exception('cannot_empty_backup_temp_dir');
54
            throw new backup_helper_exception('cannot_empty_backup_temp_dir');
55
        }
55
        }
56
        return true;
56
        return true;
Línea 63... Línea 63...
63
     * progress reports.
63
     * progress reports.
64
     *
64
     *
65
     * @param string $backupid Backup id
65
     * @param string $backupid Backup id
66
     * @param \core\progress\base $progress Optional progress reporting object
66
     * @param \core\progress\base $progress Optional progress reporting object
67
     */
67
     */
68
     public static function delete_backup_dir($backupid, \core\progress\base $progress = null) {
68
     public static function delete_backup_dir($backupid, ?\core\progress\base $progress = null) {
69
         $backupiddir = make_backup_temp_directory($backupid, false);
69
         $backupiddir = make_backup_temp_directory($backupid, false);
70
         self::clear_backup_dir($backupid, $progress);
70
         self::clear_backup_dir($backupid, $progress);
71
         return rmdir($backupiddir);
71
         return rmdir($backupiddir);
72
     }
72
     }
Línea 81... Línea 81...
81
     *
81
     *
82
     * @param string $dir Directory to delete
82
     * @param string $dir Directory to delete
83
     * @param string $excludedir Exclude this directory
83
     * @param string $excludedir Exclude this directory
84
     * @param \core\progress\base $progress Optional progress reporting object
84
     * @param \core\progress\base $progress Optional progress reporting object
85
     */
85
     */
86
    public static function delete_dir_contents($dir, $excludeddir='', \core\progress\base $progress = null) {
86
    public static function delete_dir_contents($dir, $excludeddir='', ?\core\progress\base $progress = null) {
87
        global $CFG;
87
        global $CFG;
Línea 88... Línea 88...
88
 
88
 
89
        if ($progress) {
89
        if ($progress) {
90
            $progress->progress();
90
            $progress->progress();
Línea 154... Línea 154...
154
     * progress reports.
154
     * progress reports.
155
     *
155
     *
156
     * @param int $deletebefore Delete files and directories older than this time
156
     * @param int $deletebefore Delete files and directories older than this time
157
     * @param \core\progress\base $progress Optional progress reporting object
157
     * @param \core\progress\base $progress Optional progress reporting object
158
     */
158
     */
159
    public static function delete_old_backup_dirs($deletebefore, \core\progress\base $progress = null) {
159
    public static function delete_old_backup_dirs($deletebefore, ?\core\progress\base $progress = null) {
160
        $status = true;
160
        $status = true;
161
        // Get files and directories in the backup temp dir.
161
        // Get files and directories in the backup temp dir.
162
        $backuptempdir = make_backup_temp_directory('');
162
        $backuptempdir = make_backup_temp_directory('');
163
        $items = new DirectoryIterator($backuptempdir);
163
        $items = new DirectoryIterator($backuptempdir);
164
        foreach ($items as $item) {
164
        foreach ($items as $item) {
Línea 217... Línea 217...
217
     * @param \core\progress\base $progress Optional progress monitor
217
     * @param \core\progress\base $progress Optional progress monitor
218
     * @return stored_file if created, null otherwise
218
     * @return stored_file if created, null otherwise
219
     *
219
     *
220
     * @throws moodle_exception in case of any problems
220
     * @throws moodle_exception in case of any problems
221
     */
221
     */
222
    public static function store_backup_file($backupid, $filepath, \core\progress\base $progress = null) {
222
    public static function store_backup_file($backupid, $filepath, ?\core\progress\base $progress = null) {
223
        global $CFG;
223
        global $CFG;
Línea 224... Línea 224...
224
 
224
 
225
        // First of all, get some information from the backup_controller to help us decide
225
        // First of all, get some information from the backup_controller to help us decide
226
        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
226
        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
Línea 315... Línea 315...
315
                }
315
                }
316
                // bad luck, try to deal with the file the old way - keep backup in file area if we can not copy to ext system
316
                // bad luck, try to deal with the file the old way - keep backup in file area if we can not copy to ext system
317
            }
317
            }
318
        }
318
        }
Línea 319... Línea -...
319
 
-
 
320
        // Backups of type HUB (by definition never have user info)
-
 
321
        // are sent to user's "user_tohub" file area. The upload process
-
 
322
        // will be responsible for cleaning that filearea once finished
-
 
323
        if ($backupmode == backup::MODE_HUB) {
-
 
324
            $ctxid     = context_user::instance($userid)->id;
-
 
325
            $component = 'user';
-
 
326
            $filearea  = 'tohub';
-
 
327
            $itemid    = 0;
-
 
328
        }
-
 
329
 
319
 
330
        // Backups without user info or with the anonymise functionality
320
        // Backups without user info or with the anonymise functionality
331
        // enabled are sent to user's "user_backup"
321
        // enabled are sent to user's "user_backup"
332
        // file area. Maintenance of such area is responsibility of
322
        // file area. Maintenance of such area is responsibility of
333
        // the user via corresponding file manager frontend
323
        // the user via corresponding file manager frontend
Línea 420... Línea 410...
420
                }
410
                }
Línea 421... Línea 411...
421
 
411
 
Línea 422... Línea 412...
422
            }
412
            }
423
 
413
 
424
            $selectmenu = new \core\output\select_menu('coursereusetype', $menuarray, $activeurl);
414
            $selectmenu = new \core\output\select_menu('coursereusetype', $menuarray, $activeurl);
425
            $selectmenu->set_label(get_string('coursereusenavigationmenu'), ['class' => 'sr-only']);
415
            $selectmenu->set_label(get_string('coursereusenavigationmenu'), ['class' => 'visually-hidden']);
426
            $options = \html_writer::tag(
416
            $options = \html_writer::tag(
427
                'div',
417
                'div',
428
                $OUTPUT->render_from_template('core/tertiary_navigation_selector', $selectmenu->export_for_template($OUTPUT)),
418
                $OUTPUT->render_from_template('core/tertiary_navigation_selector', $selectmenu->export_for_template($OUTPUT)),