Skip to content

Commit

Permalink
MDL-21432 backup 2.0 - initial commit. controller
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Apr 21, 2010
1 parent 77547b4 commit c6cc972
Show file tree
Hide file tree
Showing 3 changed files with 580 additions and 0 deletions.
106 changes: 106 additions & 0 deletions backup/backup.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @package moodlecore
* @subpackage backup
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Abstract class defining common stuff to be used by the backup stuff
*
* This class defines various constants and methods that will be used
* by different classes, all related with the backup process. Just provides
* the top hierarchy of the backup controller/worker stuff.
*
* TODO: Finish phpdocs
*/
abstract class backup implements checksumable {

// Backup type
const TYPE_1ACTIVITY = '1act';
const TYPE_1SECTION = '1sec';
const TYPE_1COURSE = '1cou';

// Backup format
const FORMAT_MOODLE = 'moodle2';
const FORMAT_IMSCC = 'imscc';

// Interactive
const INTERACTIVE_YES = true;
const INTERACTIVE_NO = false;

// Predefined modes (purposes) of the backup
const MODE_GENERAL = 10;
const MODE_IMPORT = 20;
const MODE_HUB = 30;
const MODE_SAMESITE = 40;

// Execution mode
const EXECUTION_INMEDIATE = 1;
const EXECUTION_DELAYED = 2;

// Status of the backup_controller
const STATUS_CREATED = 100;
const STATUS_PLANNED = 200;
const STATUS_CONFIGURED = 300;
const STATUS_SETTING_UI = 400;
const STATUS_AWAITING = 500;
const STATUS_EXECUTING = 600;
const STATUS_FINISHED_OK = 700;
const STATUS_FINISHED_ERR= 800;

// Logging levels
const LOG_DEBUG = 50;
const LOG_INFO = 40;
const LOG_WARNING = 30;
const LOG_ERROR = 20;
const LOG_NONE = 10;

// Some constants used to identify some helpfull processor variables
// (using negative numbers to avoid any collision posibility
// To be used when defining backup structures
const VAR_COURSEID = -1; // To reference id of course in a processor
const VAR_SECTIONID = -11; // To reference id of section in a processor
const VAR_ACTIVITYID = -21; // To reference id of activity in a processor
const VAR_MODID = -31; // To reference id of course_module in a processor
const VAR_MODNAME = -41; // To reference name of module in a processor
const VAR_BLOCKID = -51; // To reference id of block in a processor
const VAR_BLOCKNAME = -61; // To reference name of block in a processor
const VAR_CONTEXTID = -71; // To reference context id in a processor
const VAR_PARENTID = -81; // To reference the first parent->id in a backup structure

// Used internally by the backup process
const VAR_BACKUPID = -1001; // To reference the backupid being processed
const VAR_BASEPATH = -1011; // To reference the dir where the file is generated

// Version (to keep CFG->backup_version (and release) updated automatically)
const VERSION = 2010022500;
const RELEASE = '2.0 dev';
}

/*
* Exception class used by all the @backup stuff
*/
class backup_exception extends moodle_exception {

public function __construct($errorcode, $a=NULL, $debuginfo=null) {
parent::__construct($errorcode, 'error', '', $a, null, $debuginfo);
}
}
Loading

0 comments on commit c6cc972

Please sign in to comment.