コード例 #1
0
 protected function define_my_settings()
 {
     // Nothing to do
     if (!$this->history_exists()) {
         return;
     }
     $rootsettings = $this->get_info()->root_settings;
     $defaultvalue = false;
     $changeable = false;
     $is_blocks = isset($rootsettings['blocks']) && $rootsettings['blocks'];
     $is_users = isset($rootsettings['users']) && $rootsettings['users'];
     if ($is_blocks and $is_users) {
         $defaultvalue = true;
         $changeable = true;
     }
     $restore_history = new restore_generic_setting('restore_quickmail_history', base_setting::IS_BOOLEAN, $defaultvalue);
     $restore_history->set_ui(new backup_setting_ui_select($restore_history, get_string('restore_history', 'block_quickmail'), array(1 => get_string('yes'), 0 => get_string('no'))));
     if (!$changeable) {
         $restore_history->set_value($defaultvalue);
         $restore_history->set_status(backup_setting::LOCKED_BY_CONFIG);
         $restore_history->set_visibility(backup_setting::HIDDEN);
     }
     $this->add_setting($restore_history);
     $this->get_setting('users')->add_dependency($restore_history);
     $this->get_setting('blocks')->add_dependency($restore_history);
     $overwrite_history = new restore_course_generic_setting('overwrite_quickmail_history', base_setting::IS_BOOLEAN, false);
     $overwrite_history->set_ui(new backup_setting_ui_select($overwrite_history, get_string('overwrite_history', 'block_quickmail'), array(1 => get_string('yes'), 0 => get_string('no'))));
     if ($this->get_target() != backup::TARGET_CURRENT_DELETING and $this->get_target() != backup::TARGET_EXISTING_DELETING) {
         $overwrite_history->set_value(false);
         $overwrite_history->set_status(backup_setting::LOCKED_BY_CONFIG);
     }
     $this->add_setting($overwrite_history);
     $restore_history->add_dependency($overwrite_history);
 }
コード例 #2
0
 public function __construct($name, $vtype, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED)
 {
     parent::__construct($name, $vtype, $value, $visibility, $status);
     $this->set_ui(new backup_setting_ui_text($this, $name));
 }
コード例 #3
0
 /**
  * Define the common setting that any restore course will have
  */
 protected function define_settings()
 {
     //$name, $vtype, $value = null, $visibility = self::VISIBLE, $status = self::NOT_LOCKED
     $fullname = new restore_course_generic_text_setting('course_fullname', base_setting::IS_TEXT, $this->get_info()->original_course_fullname);
     $fullname->get_ui()->set_label(get_string('setting_course_fullname', 'backup'));
     $this->add_setting($fullname);
     $shortname = new restore_course_generic_text_setting('course_shortname', base_setting::IS_TEXT, $this->get_info()->original_course_shortname);
     $shortname->get_ui()->set_label(get_string('setting_course_shortname', 'backup'));
     $this->add_setting($shortname);
     $startdate = new restore_course_generic_text_setting('course_startdate', base_setting::IS_INTEGER, $this->get_info()->original_course_startdate);
     $startdate->set_ui(new backup_setting_ui_dateselector($startdate, get_string('setting_course_startdate', 'backup')));
     $this->add_setting($startdate);
     $keep_enrols = new restore_course_generic_setting('keep_roles_and_enrolments', base_setting::IS_BOOLEAN, false);
     $keep_enrols->set_ui(new backup_setting_ui_select($keep_enrols, $keep_enrols->get_name(), array(1 => get_string('yes'), 0 => get_string('no'))));
     $keep_enrols->get_ui()->set_label(get_string('setting_keep_roles_and_enrolments', 'backup'));
     if ($this->get_target() != backup::TARGET_CURRENT_DELETING and $this->get_target() != backup::TARGET_EXISTING_DELETING) {
         $keep_enrols->set_value(false);
         $keep_enrols->set_status(backup_setting::LOCKED_BY_CONFIG);
         $keep_enrols->set_visibility(backup_setting::HIDDEN);
     }
     $this->add_setting($keep_enrols);
     $keep_groups = new restore_course_generic_setting('keep_groups_and_groupings', base_setting::IS_BOOLEAN, false);
     $keep_groups->set_ui(new backup_setting_ui_select($keep_groups, $keep_groups->get_name(), array(1 => get_string('yes'), 0 => get_string('no'))));
     $keep_groups->get_ui()->set_label(get_string('setting_keep_groups_and_groupings', 'backup'));
     if ($this->get_target() != backup::TARGET_CURRENT_DELETING and $this->get_target() != backup::TARGET_EXISTING_DELETING) {
         $keep_groups->set_value(false);
         $keep_groups->set_status(backup_setting::LOCKED_BY_CONFIG);
         $keep_groups->set_visibility(backup_setting::HIDDEN);
     }
     $this->add_setting($keep_groups);
     // Define overwrite_conf to decide if course configuration will be restored over existing one
     $overwrite = new restore_course_overwrite_conf_setting('overwrite_conf', base_setting::IS_BOOLEAN, false);
     $overwrite->set_ui(new backup_setting_ui_select($overwrite, $overwrite->get_name(), array(1 => get_string('yes'), 0 => get_string('no'))));
     $overwrite->get_ui()->set_label(get_string('setting_overwriteconf', 'backup'));
     if ($this->get_target() == backup::TARGET_NEW_COURSE) {
         $overwrite->set_value(true);
         $overwrite->set_status(backup_setting::LOCKED_BY_CONFIG);
         $overwrite->set_visibility(backup_setting::HIDDEN);
     }
     $this->add_setting($overwrite);
 }