~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to backup/controller/backup_controller.class.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 *
41
41
 * TODO: Finish phpdocs
42
42
 */
43
 
class backup_controller extends backup implements loggable {
 
43
class backup_controller extends base_controller {
44
44
 
45
45
    protected $backupid; // Unique identificator for this backup
46
46
 
56
56
    protected $status; // Current status of the controller (created, planned, configured...)
57
57
 
58
58
    protected $plan;   // Backup execution plan
 
59
    protected $includefiles; // Whether this backup includes files or not.
59
60
 
60
61
    protected $execution;     // inmediate/delayed
61
62
    protected $executiontime; // epoch time when we want the backup to be executed (requires cron to run)
62
63
 
63
64
    protected $destination; // Destination chain object (fs_moodle, fs_os, db, email...)
64
 
    protected $logger;      // Logging chain object (moodle, inline, fs, db, syslog)
65
65
 
66
66
    protected $checksum; // Cache @checksumable results for lighter @is_checksum_correct() uses
67
67
 
108
108
        // Default logger chain (based on interactive/execution)
109
109
        $this->logger = backup_factory::get_logger_chain($this->interactive, $this->execution, $this->backupid);
110
110
 
 
111
        // By default there is no progress reporter. Interfaces that wish to
 
112
        // display progress must set it.
 
113
        $this->progress = new core_backup_null_progress();
 
114
 
111
115
        // Instantiate the output_controller singleton and active it if interactive and inmediate
112
116
        $oc = output_controller::get_instance();
113
117
        if ($this->interactive == backup::INTERACTIVE_YES && $this->execution == backup::EXECUTION_INMEDIATE) {
239
243
        return $this->type;
240
244
    }
241
245
 
 
246
    /**
 
247
     * Returns the current value of the include_files setting.
 
248
     * This setting is intended to ensure that files are not included in
 
249
     * generated backups.
 
250
     *
 
251
     * @return int Indicates whether files should be included in backups.
 
252
     */
 
253
    public function get_include_files() {
 
254
        return $this->includefiles;
 
255
    }
 
256
 
242
257
    public function get_operation() {
243
258
        return $this->operation;
244
259
    }
286
301
        return $this->plan;
287
302
    }
288
303
 
289
 
    public function get_logger() {
290
 
        return $this->logger;
291
 
    }
292
 
 
293
304
    /**
294
305
     * Executes the backup
295
306
     * @return void Throws and exception of completes
313
324
        return $this->plan->get_results();
314
325
    }
315
326
 
316
 
    public function log($message, $level, $a = null, $depth = null, $display = false) {
317
 
        backup_helper::log($message, $level, $a, $depth, $display, $this->logger);
318
 
    }
319
 
 
320
327
    /**
321
328
     * Save controller information
322
329
     *
362
369
        $this->log('applying plan defaults', backup::LOG_DEBUG);
363
370
        backup_controller_dbops::apply_config_defaults($this);
364
371
        $this->set_status(backup::STATUS_CONFIGURED);
 
372
        $this->set_include_files();
 
373
    }
 
374
 
 
375
    /**
 
376
     * Set the initial value for the include_files setting.
 
377
     *
 
378
     * @see backup_controller::get_include_files for further information on the purpose of this setting.
 
379
     * @return int Indicates whether files should be included in backups.
 
380
     */
 
381
    protected function set_include_files() {
 
382
        // We normally include files.
 
383
        $includefiles = true;
 
384
 
 
385
        // In an import, we don't need to include files.
 
386
        if ($this->get_mode() === backup::MODE_IMPORT) {
 
387
            $includefiles = false;
 
388
        }
 
389
 
 
390
        // When a backup is intended for the same site, we don't need to include the files.
 
391
        // Note, this setting is only used for duplication of an entire course.
 
392
        if ($this->get_mode() === backup::MODE_SAMESITE) {
 
393
            $includefiles = false;
 
394
        }
 
395
 
 
396
        $this->includefiles = (int) $includefiles;
 
397
        $this->log("setting file inclusion to {$this->includefiles}", backup::LOG_DEBUG);
 
398
        return $this->includefiles;
365
399
    }
366
400
}
367
401