/** * 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, $courseid, $plan = null) { $this->courseid = $courseid; $this->contextid = get_context_instance(CONTEXT_COURSE, $this->courseid)->id; parent::__construct($name, $plan); }
/** * Tries to look for the instance specific setting value, task specific setting value or the * common plan setting value - in that order * * @param string $name the name of the setting * @return mixed|null the value of the setting or null if not found */ public function get_setting($name) { $namewithprefix = $this->modulename . '_' . $this->moduleid . '_' . $name; $result = null; foreach ($this->settings as $key => $setting) { if ($setting->get_name() == $namewithprefix) { if ($result != null) { throw new base_task_exception('multiple_settings_by_name_found', $namewithprefix); } else { $result = $setting; } } } if ($result) { return $result; } else { // Fallback to parent return parent::get_setting($name); } }
/** * 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); }