public function add_dependency(backup_setting $dependentsetting, $type = setting_dependency::DISABLED_VALUE, $options = array())
 {
     // Check the dependency level is >= current level
     if ($dependentsetting->get_level() < $this->level) {
         throw new backup_setting_exception('cannot_add_upper_level_dependency');
     }
     parent::add_dependency($dependentsetting, $type, $options);
 }
예제 #2
0
 /**
  * Adds HTML formatting for the given backup setting, needed to group/segment
  * correctly.
  * @param backup_setting $setting
  */
 protected function add_html_formatting(backup_setting $setting)
 {
     $mform = $this->_form;
     $isincludesetting = strpos($setting->get_name(), '_include') !== false;
     if ($isincludesetting && $setting->get_level() != backup_setting::ROOT_LEVEL) {
         switch ($setting->get_level()) {
             case backup_setting::COURSE_LEVEL:
                 if ($this->activitydiv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                     $this->activitydiv = false;
                 }
                 if ($this->sectiondiv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                     $this->sectiondiv = false;
                 }
                 if ($this->coursediv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                 }
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'grouped_settings course_level')));
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'include_setting course_level')));
                 $this->coursediv = true;
                 break;
             case backup_setting::SECTION_LEVEL:
                 if ($this->activitydiv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                     $this->activitydiv = false;
                 }
                 if ($this->sectiondiv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                 }
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'grouped_settings section_level')));
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'include_setting section_level')));
                 $this->sectiondiv = true;
                 break;
             case backup_setting::ACTIVITY_LEVEL:
                 if ($this->activitydiv) {
                     $this->_form->addElement('html', html_writer::end_tag('div'));
                 }
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'grouped_settings activity_level')));
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'include_setting activity_level')));
                 $this->activitydiv = true;
                 break;
             default:
                 $mform->addElement('html', html_writer::start_tag('div', array('class' => 'normal_setting')));
                 break;
         }
     } else {
         if ($setting->get_level() == backup_setting::ROOT_LEVEL) {
             $mform->addElement('html', html_writer::start_tag('div', array('class' => 'root_setting')));
         } else {
             $mform->addElement('html', html_writer::start_tag('div', array('class' => 'normal_setting')));
         }
     }
 }