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);
 }
 /**
  * Define the common setting that any restore type will have
  */
 protected function define_settings()
 {
     // Load all the root settings found in backup file from controller
     $rootsettings = $this->get_info()->root_settings;
     // Define users setting (keeping it on hand to define dependencies)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['users']) && $rootsettings['users']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $users = new restore_users_setting('users', base_setting::IS_BOOLEAN, $defaultvalue);
     $users->set_ui(new backup_setting_ui_checkbox($users, get_string('rootsettingusers', 'backup')));
     $users->get_ui()->set_changeable($changeable);
     $this->add_setting($users);
     $rootenrolmanual = new restore_users_setting('enrol_migratetomanual', base_setting::IS_BOOLEAN, false);
     $rootenrolmanual->set_ui(new backup_setting_ui_checkbox($rootenrolmanual, get_string('rootenrolmanual', 'backup')));
     $rootenrolmanual->get_ui()->set_changeable(enrol_is_enabled('manual'));
     $rootenrolmanual->get_ui()->set_changeable($changeable);
     $this->add_setting($rootenrolmanual);
     $users->add_dependency($rootenrolmanual);
     // Define role_assignments (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['role_assignments']) && $rootsettings['role_assignments']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $roleassignments = new restore_role_assignments_setting('role_assignments', base_setting::IS_BOOLEAN, $defaultvalue);
     $roleassignments->set_ui(new backup_setting_ui_checkbox($roleassignments, get_string('rootsettingroleassignments', 'backup')));
     $roleassignments->get_ui()->set_changeable($changeable);
     $this->add_setting($roleassignments);
     $users->add_dependency($roleassignments);
     // Define activitites
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['activities']) && $rootsettings['activities']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $activities = new restore_activities_setting('activities', base_setting::IS_BOOLEAN, $defaultvalue);
     $activities->set_ui(new backup_setting_ui_checkbox($activities, get_string('rootsettingactivities', 'backup')));
     $activities->get_ui()->set_changeable($changeable);
     $this->add_setting($activities);
     // Define blocks
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['blocks']) && $rootsettings['blocks']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $blocks = new restore_generic_setting('blocks', base_setting::IS_BOOLEAN, $defaultvalue);
     $blocks->set_ui(new backup_setting_ui_checkbox($blocks, get_string('rootsettingblocks', 'backup')));
     $blocks->get_ui()->set_changeable($changeable);
     $this->add_setting($blocks);
     // Define filters
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['filters']) && $rootsettings['filters']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $filters = new restore_generic_setting('filters', base_setting::IS_BOOLEAN, $defaultvalue);
     $filters->set_ui(new backup_setting_ui_checkbox($filters, get_string('rootsettingfilters', 'backup')));
     $filters->get_ui()->set_changeable($changeable);
     $this->add_setting($filters);
     // Define comments (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['comments']) && $rootsettings['comments']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $comments = new restore_comments_setting('comments', base_setting::IS_BOOLEAN, $defaultvalue);
     $comments->set_ui(new backup_setting_ui_checkbox($comments, get_string('rootsettingcomments', 'backup')));
     $comments->get_ui()->set_changeable($changeable);
     $this->add_setting($comments);
     $users->add_dependency($comments);
     // Define badges (dependent of activities).
     $defaultvalue = false;
     // Safer default.
     $changeable = false;
     if (isset($rootsettings['badges']) && $rootsettings['badges']) {
         // Only enabled when available.
         $defaultvalue = true;
         $changeable = true;
     }
     $badges = new restore_badges_setting('badges', base_setting::IS_BOOLEAN, $defaultvalue);
     $badges->set_ui(new backup_setting_ui_checkbox($badges, get_string('rootsettingbadges', 'backup')));
     $badges->get_ui()->set_changeable($changeable);
     $this->add_setting($badges);
     $activities->add_dependency($badges);
     $users->add_dependency($badges);
     // Define Calendar events.
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['calendarevents']) && $rootsettings['calendarevents']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $events = new restore_calendarevents_setting('calendarevents', base_setting::IS_BOOLEAN, $defaultvalue);
     $events->set_ui(new backup_setting_ui_checkbox($events, get_string('rootsettingcalendarevents', 'backup')));
     $events->get_ui()->set_changeable($changeable);
     $this->add_setting($events);
     // Define completion (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['userscompletion']) && $rootsettings['userscompletion']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $completion = new restore_userscompletion_setting('userscompletion', base_setting::IS_BOOLEAN, $defaultvalue);
     $completion->set_ui(new backup_setting_ui_checkbox($completion, get_string('rootsettinguserscompletion', 'backup')));
     $completion->get_ui()->set_changeable($changeable);
     $this->add_setting($completion);
     $users->add_dependency($completion);
     // Define logs (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['logs']) && $rootsettings['logs']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $logs = new restore_logs_setting('logs', base_setting::IS_BOOLEAN, $defaultvalue);
     $logs->set_ui(new backup_setting_ui_checkbox($logs, get_string('rootsettinglogs', 'backup')));
     $logs->get_ui()->set_changeable($changeable);
     $this->add_setting($logs);
     $users->add_dependency($logs);
     // Define grade_histories (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['grade_histories']) && $rootsettings['grade_histories']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $gradehistories = new restore_grade_histories_setting('grade_histories', base_setting::IS_BOOLEAN, $defaultvalue);
     $gradehistories->set_ui(new backup_setting_ui_checkbox($gradehistories, get_string('rootsettinggradehistories', 'backup')));
     $gradehistories->get_ui()->set_changeable($changeable);
     $this->add_setting($gradehistories);
     $users->add_dependency($gradehistories);
     // The restore does not process the grade histories when some activities are ignored.
     // So let's define a dependency to prevent false expectations from our users.
     $activities->add_dependency($gradehistories);
 }
 /**
  * Define the common setting that any restore type will have
  */
 protected function define_settings()
 {
     // Load all the root settings found in backup file from controller
     $rootsettings = $this->get_info()->root_settings;
     // Define users setting (keeping it on hand to define dependencies)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['users']) && $rootsettings['users']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $users = new restore_users_setting('users', base_setting::IS_BOOLEAN, $defaultvalue);
     $users->set_ui(new backup_setting_ui_checkbox($users, get_string('rootsettingusers', 'backup')));
     $users->get_ui()->set_changeable($changeable);
     $this->add_setting($users);
     // Define role_assignments (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['role_assignments']) && $rootsettings['role_assignments']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $roleassignments = new restore_role_assignments_setting('role_assignments', base_setting::IS_BOOLEAN, $defaultvalue);
     $roleassignments->set_ui(new backup_setting_ui_checkbox($roleassignments, get_string('rootsettingroleassignments', 'backup')));
     $roleassignments->get_ui()->set_changeable($changeable);
     $this->add_setting($roleassignments);
     $users->add_dependency($roleassignments);
     // Define user_files (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['user_files']) && $rootsettings['user_files']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $userfiles = new restore_user_files_setting('user_files', base_setting::IS_BOOLEAN, $defaultvalue);
     $userfiles->set_ui(new backup_setting_ui_checkbox($userfiles, get_string('rootsettinguserfiles', 'backup')));
     $userfiles->get_ui()->set_changeable($changeable);
     $this->add_setting($userfiles);
     $users->add_dependency($userfiles);
     // Define activitites
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['activities']) && $rootsettings['activities']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $activities = new restore_activities_setting('activities', base_setting::IS_BOOLEAN, $defaultvalue);
     $activities->set_ui(new backup_setting_ui_checkbox($activities, get_string('rootsettingactivities', 'backup')));
     $activities->get_ui()->set_changeable($changeable);
     $this->add_setting($activities);
     // Define blocks
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['blocks']) && $rootsettings['blocks']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $blocks = new restore_generic_setting('blocks', base_setting::IS_BOOLEAN, $defaultvalue);
     $blocks->set_ui(new backup_setting_ui_checkbox($blocks, get_string('rootsettingblocks', 'backup')));
     $blocks->get_ui()->set_changeable($changeable);
     $this->add_setting($blocks);
     // Define filters
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['filters']) && $rootsettings['filters']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $filters = new restore_generic_setting('filters', base_setting::IS_BOOLEAN, $defaultvalue);
     $filters->set_ui(new backup_setting_ui_checkbox($filters, get_string('rootsettingfilters', 'backup')));
     $filters->get_ui()->set_changeable($changeable);
     $this->add_setting($filters);
     // Define comments (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['comments']) && $rootsettings['comments']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $comments = new restore_comments_setting('comments', base_setting::IS_BOOLEAN, $defaultvalue);
     $comments->set_ui(new backup_setting_ui_checkbox($comments, get_string('rootsettingcomments', 'backup')));
     $comments->get_ui()->set_changeable($changeable);
     $this->add_setting($comments);
     $users->add_dependency($comments);
     // Define completion (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['userscompletion']) && $rootsettings['userscompletion']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $completion = new restore_userscompletion_setting('userscompletion', base_setting::IS_BOOLEAN, $defaultvalue);
     $completion->set_ui(new backup_setting_ui_checkbox($completion, get_string('rootsettinguserscompletion', 'backup')));
     $completion->get_ui()->set_changeable($changeable);
     $this->add_setting($completion);
     $users->add_dependency($completion);
     // Define logs (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['logs']) && $rootsettings['logs']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $logs = new restore_logs_setting('logs', base_setting::IS_BOOLEAN, $defaultvalue);
     $logs->set_ui(new backup_setting_ui_checkbox($logs, get_string('rootsettinglogs', 'backup')));
     $logs->get_ui()->set_changeable($changeable);
     $this->add_setting($logs);
     $users->add_dependency($logs);
     // Define grade_histories (dependent of users)
     $defaultvalue = false;
     // Safer default
     $changeable = false;
     if (isset($rootsettings['grade_histories']) && $rootsettings['grade_histories']) {
         // Only enabled when available
         $defaultvalue = true;
         $changeable = true;
     }
     $gradehistories = new restore_grade_histories_setting('grade_histories', base_setting::IS_BOOLEAN, $defaultvalue);
     $gradehistories->set_ui(new backup_setting_ui_checkbox($gradehistories, get_string('rootsettinggradehistories', 'backup')));
     $gradehistories->get_ui()->set_changeable($changeable);
     $this->add_setting($gradehistories);
     $users->add_dependency($gradehistories);
 }
Beispiel #4
0
 /**
  * restore_competencies_setting constructor.
  * @param bool $hascompetencies Flag whether to set the restore setting as checked and unlocked.
  */
 public function __construct($hascompetencies)
 {
     $defaultvalue = false;
     $visibility = base_setting::HIDDEN;
     $status = base_setting::LOCKED_BY_CONFIG;
     if (\core_competency\api::is_enabled()) {
         $visibility = base_setting::VISIBLE;
         if ($hascompetencies) {
             $defaultvalue = true;
             $status = base_setting::NOT_LOCKED;
         }
     }
     parent::__construct('competencies', base_setting::IS_BOOLEAN, $defaultvalue, $visibility, $status);
 }