/** * Constructor - instantiates one object of this class */ public function __construct($name, $blockid, $moduleid = null, $plan = null) { global $DB; // Check blockid exists if (!($block = $DB->get_record('block_instances', array('id' => $blockid)))) { throw new backup_task_exception('block_task_block_instance_not_found', $blockid); } $this->blockid = $blockid; $this->blockname = $block->blockname; $this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id; $this->moduleid = $moduleid; $this->modulename = null; $this->parentcontextid = null; // If moduleid passed, check exists, supports moodle2 format and save info // Check moduleid exists if (!empty($moduleid)) { if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) { throw new backup_task_exception('block_task_coursemodule_not_found', $moduleid); } // Check activity supports this moodle2 backup format if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) { throw new backup_task_exception('block_task_activity_lacks_moodle2_backup_support', $coursemodule->modname); } $this->moduleid = $moduleid; $this->modulename = $coursemodule->modname; $this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id; } parent::__construct($name, $plan); }
/** * Constructor - instantiates one object of this class */ public function __construct($name, $sectionid, $plan = null) { global $DB; // Check section exists if (!($section = $DB->get_record('course_sections', array('id' => $sectionid)))) { throw new backup_task_exception('section_task_section_not_found', $sectionid); } $this->sectionid = $sectionid; parent::__construct($name, $plan); }
/** * Constructor - instantiates one object of this class * * @param string $name the task identifier * @param int $moduleid course module id (id in course_modules table) * @param backup_plan|null $plan the backup plan instance this task is part of */ public function __construct($name, $moduleid, $plan = null) { // Check moduleid exists if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) { throw new backup_task_exception('activity_task_coursemodule_not_found', $moduleid); } // Check activity supports this moodle2 backup format if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) { throw new backup_task_exception('activity_task_activity_lacks_moodle2_backup_support', $coursemodule->modname); } $this->moduleid = $moduleid; $this->sectionid = $coursemodule->section; $this->modulename = $coursemodule->modname; $this->activityid = $coursemodule->instance; $this->contextid = context_module::instance($this->moduleid)->id; parent::__construct($name, $plan); }
/** * Constructor - instantiates one object of this class */ public function __construct($name, $courseid, $plan = null) { $this->courseid = $courseid; $this->contextid = get_context_instance(CONTEXT_COURSE, $this->courseid)->id; parent::__construct($name, $plan); }
/** * Constructor - instantiates one object of this class */ public function __construct($name, $courseid, $plan = null) { $this->courseid = $courseid; $this->contextid = context_course::instance($this->courseid)->id; parent::__construct($name, $plan); }