original_string: public function add_settings(array $settingstasks) {
          global $OUTPUT;
  
          // Determine highest setting level, which is displayed in this stage. This is relevant for considering only
          // locks of dependency settings for parent settings, which are not displayed in this stage.
          $highestlevel = backup_setting::ACTIVITY_LEVEL;
          foreach ($settingstasks as $st) {
              list($setting, $task) = $st;
              if ($setting->get_level() < $highestlevel) {
                  $highestlevel = $setting->get_level();
              }
          }
  
          $defaults = array();
          foreach ($settingstasks as $st) {
              list($setting, $task) = $st;
              // If the setting cant be changed or isn't visible then add it as a fixed setting.
              if (!$setting->get_ui()->is_changeable($highestlevel) ||
                  $setting->get_visibility() != backup_setting::VISIBLE) {
                  $this->add_fixed_setting($setting, $task);
                  continue;
              }
  
              // First add the formatting for this setting.
              $this->add_html_formatting($setting);
  
              // Then call the add method with the get_element_properties array.
              call_user_func_array(array($this->_form, 'addElement'), $setting->get_ui()->get_element_properties($task, $OUTPUT));
              $this->_form->setType($setting->get_ui_name(), $setting->get_param_validation());
              $defaults[$setting->get_ui_name()] = $setting->get_value();
              if ($setting->has_help()) {
                  list($identifier, $component) = $setting->get_help();
                  $this->_form->addHelpButton($setting->get_ui_name(), $identifier, $component);
              }
              $this->_form->addElement('html', html_writer::end_tag('div'));
          }
          $this->_form->setDefaults($defaults);
          return true;
      }
code: public function add_settings(array $settingstasks) {
          global $OUTPUT;
  
          // Determine highest setting level, which is displayed in this stage. This is relevant for considering only
          // locks of dependency settings for parent settings, which are not displayed in this stage.
          $highestlevel = backup_setting::ACTIVITY_LEVEL;
          foreach ($settingstasks as $st) {
              list($setting, $task) = $st;
              if ($setting->get_level() < $highestlevel) {
                  $highestlevel = $setting->get_level();
              }
          }
  
          $defaults = array();
          foreach ($settingstasks as $st) {
              list($setting, $task) = $st;
              // If the setting cant be changed or isn't visible then add it as a fixed setting.
              if (!$setting->get_ui()->is_changeable($highestlevel) ||
                  $setting->get_visibility() != backup_setting::VISIBLE) {
                  $this->add_fixed_setting($setting, $task);
                  continue;
              }
  
              // First add the formatting for this setting.
              $this->add_html_formatting($setting);
  
              // Then call the add method with the get_element_properties array.
              call_user_func_array(array($this->_form, 'addElement'), $setting->get_ui()->get_element_properties($task, $OUTPUT));
              $this->_form->setType($setting->get_ui_name(), $setting->get_param_validation());
              $defaults[$setting->get_ui_name()] = $setting->get_value();
              if ($setting->has_help()) {
                  list($identifier, $component) = $setting->get_help();
                  $this->_form->addHelpButton($setting->get_ui_name(), $identifier, $component);
              }
              $this->_form->addElement('html', html_writer::end_tag('div'));
          }
          $this->_form->setDefaults($defaults);
          return true;
      }
code_tokens: public function add_settings ( array $ settingstasks ) { global $ OUTPUT ; // Determine highest setting level, which is displayed in this stage. This is relevant for considering only // locks of dependency settings for parent settings, which are not displayed in this stage. $ highestlevel = backup_setting :: ACTIVITY_LEVEL ; foreach ( $ settingstasks as $ st ) { list ( $ setting , $ task ) = $ st ; if ( $ setting -> get_level ( ) < $ highestlevel ) { $ highestlevel = $ setting -> get_level ( ) ; } } $ defaults = array ( ) ; foreach ( $ settingstasks as $ st ) { list ( $ setting , $ task ) = $ st ; // If the setting cant be changed or isn't visible then add it as a fixed setting. if ( ! $ setting -> get_ui ( ) -> is_changeable ( $ highestlevel ) || $ setting -> get_visibility ( ) != backup_setting :: VISIBLE ) { $ this -> add_fixed_setting ( $ setting , $ task ) ; continue ; } // First add the formatting for this setting. $ this -> add_html_formatting ( $ setting ) ; // Then call the add method with the get_element_properties array. call_user_func_array ( array ( $ this -> _form , 'addElement' ) , $ setting -> get_ui ( ) -> get_element_properties ( $ task , $ OUTPUT ) ) ; $ this -> _form -> setType ( $ setting -> get_ui_name ( ) , $ setting -> get_param_validation ( ) ) ; $ defaults [ $ setting -> get_ui_name ( ) ] = $ setting -> get_value ( ) ; if ( $ setting -> has_help ( ) ) { list ( $ identifier , $ component ) = $ setting -> get_help ( ) ; $ this -> _form -> addHelpButton ( $ setting -> get_ui_name ( ) , $ identifier , $ component ) ; } $ this -> _form -> addElement ( 'html' , html_writer :: end_tag ( 'div' ) ) ; } $ this -> _form -> setDefaults ( $ defaults ) ; return true ; }
docstring: Adds multiple backup_settings as elements to the form
  @param array $settingstasks Consists of array($setting, $task) elements
  @return bool
docstring_tokens: Adds multiple backup_settings as elements to the form