Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/util/factories/restore_factory.class.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00033 abstract class restore_factory {
00034 
00035     public static function get_restore_activity_task($info) {
00036 
00037         $classname = 'restore_' . $info->modulename . '_activity_task';
00038         if (class_exists($classname)) {
00039             return new $classname($info->title, $info);
00040         }
00041     }
00042 
00043     public static function get_restore_block_task($blockname, $basepath) {
00044 
00045         $classname = 'restore_default_block_task';
00046         $testname  = 'restore_' . $blockname . '_block_task';
00047         // If the block has custom backup/restore task class (testname), use it
00048         if (class_exists($testname)) {
00049             $classname = $testname;
00050         }
00051         return new $classname($blockname, $basepath);
00052     }
00053 
00054     public static function get_restore_section_task($info) {
00055 
00056         return new restore_section_task($info->title, $info);
00057     }
00058 
00059     public static function get_restore_course_task($info, $courseid) {
00060         global $DB;
00061 
00062         // Check course exists
00063         if (!$course = $DB->get_record('course', array('id' => $courseid))) {
00064             throw new restore_task_exception('course_task_course_not_found', $courseid);
00065         }
00066 
00067         return new restore_course_task($info->title, $info);
00068     }
00069 }
 All Data Structures Namespaces Files Functions Variables Enumerations