<td>' . GradebookUtils::build_type_icon_tag('evalnotempty') . '</td>
                <td>' . $evaluationRow['name'] . ' ' . Display::label(get_lang('Evaluation')) . '</td>';
    $output .= '<td>
                    <input type="hidden" name="eval_' . $evaluationRow['id'] . '" value="' . $evaluationRow['name'] . '" />
                    <input type="text" size="10" name="evaluation[' . $evaluationRow['id'] . ']" value="' . $item_weight . '"/>
                </td></tr>';
}
$my_api_cidreq = api_get_cidreq();
if ($my_api_cidreq == '') {
    $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
}
$currentUrl = api_get_self() . '?' . api_get_cidreq() . '&selectcat=' . $my_selectcat;
$form = new FormValidator('auto_weight', 'post', $currentUrl);
$form->addHeader(get_lang('AutoWeight'));
$form->addLabel(null, get_lang('AutoWeightExplanation'));
$form->addButtonUpdate(get_lang('AutoWeight'));
if ($form->validate()) {
    $itemCount = count($links) + count($evaluations);
    $weight = round($original_total / $itemCount, 2);
    $total = $weight * $itemCount;
    $diff = null;
    if ($original_total !== $total) {
        if ($total > $original_total) {
            $diff = $total - $original_total;
        }
    }
    $total = 0;
    $diffApplied = false;
    foreach ($links as $link) {
        $weightToApply = $weight;
        if ($diffApplied == false) {
 /**
  * Creates the form to create / edit an exercise
  * @param FormValidator $form
  */
 public function createForm($form, $type = 'full')
 {
     if (empty($type)) {
         $type = 'full';
     }
     // form title
     if (!empty($_GET['exerciseId'])) {
         $form_title = get_lang('ModifyExercise');
     } else {
         $form_title = get_lang('NewEx');
     }
     $form->addElement('header', $form_title);
     // Title.
     $form->addElement('text', 'exerciseTitle', get_lang('ExerciseName'), array('id' => 'exercise_title'));
     $form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
     $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
     $editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150');
     if (is_array($type)) {
         $editor_config = array_merge($editor_config, $type);
     }
     $form->addHtmlEditor('exerciseDescription', get_lang('ExerciseDescription'), false, false, $editor_config);
     if ($type == 'full') {
         //Can't modify a DirectFeedback question
         if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
             // feedback type
             $radios_feedback = array();
             $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
             if (api_get_setting('exercise.enable_quiz_scenario') == 'true') {
                 //Can't convert a question from one feedback to another if there is more than 1 question already added
                 if ($this->selectNbrQuestions() == 0) {
                     $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
                 }
             }
             $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
             $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')), '');
             // Type of results display on the final page
             $radios_results_disabled = array();
             $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
             $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
             $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2'));
             //$radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ExamModeWithFinalScoreShowOnlyFinalScoreWithCategoriesIfAvailable'),  '3', array('id'=>'result_disabled_3','onclick' => 'check_results_disabled()'));
             $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
             // Type of questions disposition on page
             $radios = array();
             $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
             $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
             $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
         } else {
             // if is Directfeedback but has not questions we can allow to modify the question type
             if ($this->selectNbrQuestions() == 0) {
                 // feedback type
                 $radios_feedback = array();
                 $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' => 'exerciseType_0', 'onclick' => 'check_feedback()'));
                 if (api_get_setting('exercise.enable_quiz_scenario') == 'true') {
                     $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()'));
                 }
                 $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' => 'exerciseType_2'));
                 $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')));
                 //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"');
                 $radios_results_disabled = array();
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
                 $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
                 // Type of questions disposition on page
                 $radios = array();
                 $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1');
                 $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2');
                 $form->addGroup($radios, null, get_lang('ExerciseType'));
             } else {
                 //Show options freeze
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id' => 'result_disabled_0'));
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id' => 'result_disabled_1', 'onclick' => 'check_results_disabled()'));
                 $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()'));
                 $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), '');
                 $result_disable_group->freeze();
                 //we force the options to the DirectFeedback exercisetype
                 $form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT);
                 $form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
                 // Type of questions disposition on page
                 $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id' => 'option_page_all'));
                 $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id' => 'option_page_one'));
                 $type_group = $form->addGroup($radios, null, get_lang('QuestionsPerPage'), '');
                 $type_group->freeze();
             }
         }
         // number of random question
         $max = $this->id > 0 ? $this->selectNbrQuestions() : 10;
         $option = range(0, $max);
         $option[0] = get_lang('No');
         $option[-1] = get_lang('AllQuestionsShort');
         $form->addElement('select', 'randomQuestions', array(get_lang('RandomQuestions'), get_lang('RandomQuestionsHelp')), $option, array('id' => 'randomQuestions'));
         // Random answers
         $radios_random_answers = array();
         $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('Yes'), '1');
         $radios_random_answers[] = $form->createElement('radio', 'randomAnswers', null, get_lang('No'), '0');
         $form->addGroup($radios_random_answers, null, get_lang('RandomAnswers'), '');
         // Random by category
         $form->addElement('html', '<div class="clear">&nbsp;</div>');
         $radiocat = array();
         $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesShuffled'), '1');
         $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('YesWithCategoriesSorted'), '2');
         $radiocat[] = $form->createElement('radio', 'randomByCat', null, get_lang('No'), '0');
         $radioCatGroup = $form->addGroup($radiocat, null, get_lang('RandomQuestionByCategory'), '');
         $form->addElement('html', '<div class="clear">&nbsp;</div>');
         // add the radio display the category name for student
         $radio_display_cat_name = array();
         $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('Yes'), '1');
         $radio_display_cat_name[] = $form->createElement('radio', 'display_category_name', null, get_lang('No'), '0');
         $form->addGroup($radio_display_cat_name, null, get_lang('QuestionDisplayCategoryName'), '');
         // Attempts
         $attempt_option = range(0, 10);
         $attempt_option[0] = get_lang('Infinite');
         $form->addElement('select', 'exerciseAttempts', get_lang('ExerciseAttempts'), $attempt_option, ['id' => 'exerciseAttempts']);
         // Exercise time limit
         $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
         $var = Exercise::selectTimeLimit();
         if ($this->start_time != '0000-00-00 00:00:00') {
             $form->addElement('html', '<div id="start_date_div" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="start_date_div" style="display:none;">');
         }
         $form->addElement('date_time_picker', 'start_time');
         $form->addElement('html', '</div>');
         $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()'));
         if ($this->end_time != '0000-00-00 00:00:00') {
             $form->addElement('html', '<div id="end_date_div" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="end_date_div" style="display:none;">');
         }
         $form->addElement('date_time_picker', 'end_time');
         $form->addElement('html', '</div>');
         //$check_option=$this->selectType();
         $diplay = 'block';
         $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
         $form->addElement('html', '<div class="clear">&nbsp;</div>');
         $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
         $form->addElement('html', '<div id="divtimecontrol"  style="display:' . $diplay . ';">');
         //Timer control
         //$time_hours_option = range(0,12);
         //$time_minutes_option = range(0,59);
         $form->addElement('checkbox', 'enabletimercontrol', null, get_lang('EnableTimerControl'), array('onclick' => 'option_time_expired()', 'id' => 'enabletimercontrol', 'onload' => 'check_load_time()'));
         $expired_date = (int) $this->selectExpiredTime();
         if ($expired_date != '0') {
             $form->addElement('html', '<div id="timercontrol" style="display:block;">');
         } else {
             $form->addElement('html', '<div id="timercontrol" style="display:none;">');
         }
         $form->addText('enabletimercontroltotalminutes', get_lang('ExerciseTotalDurationInMinutes'), false, ['id' => 'enabletimercontroltotalminutes', 'cols-size' => [2, 2, 8]]);
         $form->addElement('html', '</div>');
         $form->addElement('text', 'pass_percentage', array(get_lang('PassPercentage'), null, '%'), array('id' => 'pass_percentage'));
         $form->addRule('pass_percentage', get_lang('Numeric'), 'numeric');
         // add the text_when_finished textbox
         $form->addHtmlEditor('text_when_finished', get_lang('TextWhenFinished'), false, false, $editor_config);
         $defaults = array();
         if (api_get_setting('search.search_enabled') === 'true') {
             require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
             $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
             $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
             $specific_fields = get_specific_field_list();
             foreach ($specific_fields as $specific_field) {
                 $form->addElement('text', $specific_field['code'], $specific_field['name']);
                 $filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\'' . TOOL_QUIZ . '\'');
                 $values = get_specific_field_values_list($filter, array('value'));
                 if (!empty($values)) {
                     $arr_str_values = array();
                     foreach ($values as $value) {
                         $arr_str_values[] = $value['value'];
                     }
                     $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
                 }
             }
             //$form->addElement ('html','</div>');
         }
         $form->addElement('html', '</div>');
         //End advanced setting
         $form->addElement('html', '</div>');
     }
     // submit
     if (isset($_GET['exerciseId'])) {
         $form->addButtonSave(get_lang('ModifyExercise'), 'submitExercise');
     } else {
         $form->addButtonUpdate(get_lang('ProcedToQuestions'), 'submitExercise');
     }
     $form->addRule('exerciseTitle', get_lang('GiveExerciseName'), 'required');
     if ($type == 'full') {
         // rules
         $form->addRule('exerciseAttempts', get_lang('Numeric'), 'numeric');
         $form->addRule('start_time', get_lang('InvalidDate'), 'datetime');
         $form->addRule('end_time', get_lang('InvalidDate'), 'datetime');
     }
     // defaults
     if ($type == 'full') {
         if ($this->id > 0) {
             if ($this->random > $this->selectNbrQuestions()) {
                 $defaults['randomQuestions'] = $this->selectNbrQuestions();
             } else {
                 $defaults['randomQuestions'] = $this->random;
             }
             $defaults['randomAnswers'] = $this->selectRandomAnswers();
             $defaults['exerciseType'] = $this->selectType();
             $defaults['exerciseTitle'] = $this->get_formated_title();
             $defaults['exerciseDescription'] = $this->selectDescription();
             $defaults['exerciseAttempts'] = $this->selectAttempts();
             $defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
             $defaults['results_disabled'] = $this->selectResultsDisabled();
             $defaults['propagate_neg'] = $this->selectPropagateNeg();
             $defaults['review_answers'] = $this->review_answers;
             $defaults['randomByCat'] = $this->selectRandomByCat();
             $defaults['text_when_finished'] = $this->selectTextWhenFinished();
             $defaults['display_category_name'] = $this->selectDisplayCategoryName();
             $defaults['pass_percentage'] = $this->selectPassPercentage();
             if ($this->start_time != '0000-00-00 00:00:00') {
                 $defaults['activate_start_date_check'] = 1;
             }
             if ($this->end_time != '0000-00-00 00:00:00') {
                 $defaults['activate_end_date_check'] = 1;
             }
             $defaults['start_time'] = $this->start_time != '0000-00-00 00:00:00' ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00');
             $defaults['end_time'] = $this->end_time != '0000-00-00 00:00:00' ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600);
             // Get expired time
             if ($this->expired_time != '0') {
                 $defaults['enabletimercontrol'] = 1;
                 $defaults['enabletimercontroltotalminutes'] = $this->expired_time;
             } else {
                 $defaults['enabletimercontroltotalminutes'] = 0;
             }
         } else {
             $defaults['exerciseType'] = 2;
             $defaults['exerciseAttempts'] = 0;
             $defaults['randomQuestions'] = 0;
             $defaults['randomAnswers'] = 0;
             $defaults['exerciseDescription'] = '';
             $defaults['exerciseFeedbackType'] = 0;
             $defaults['results_disabled'] = 0;
             $defaults['randomByCat'] = 0;
             $defaults['text_when_finished'] = "";
             $defaults['start_time'] = date('Y-m-d 12:00:00');
             $defaults['display_category_name'] = 1;
             $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600);
             $defaults['pass_percentage'] = '';
         }
     } else {
         $defaults['exerciseTitle'] = $this->selectTitle();
         $defaults['exerciseDescription'] = $this->selectDescription();
     }
     if (api_get_setting('search.search_enabled') === 'true') {
         $defaults['index_document'] = 'checked="checked"';
     }
     $form->setDefaults($defaults);
     // Freeze some elements.
     if ($this->id != 0 && $this->edit_exercise_in_lp == false) {
         $elementsToFreeze = array('randomQuestions', 'exerciseAttempts', 'propagate_neg', 'enabletimercontrol', 'review_answers');
         foreach ($elementsToFreeze as $elementName) {
             /** @var HTML_QuickForm_element $element */
             $element = $form->getElement($elementName);
             $element->freeze();
         }
         $radioCatGroup->freeze();
     }
 }
 /**
  * Returns a Form validator Obj
  * @todo the form should be auto generated
  * @param   string  $url
  * @param   string  $action add, edit
  *
  * @return  FormValidator form validator obj
  */
 public function return_form($url, $action)
 {
     $form = new FormValidator('grades', 'post', $url);
     // Setting the form elements
     $header = get_lang('Add');
     if ($action == 'edit') {
         $header = get_lang('Modify');
     }
     $form->addElement('header', $header);
     $id = isset($_GET['id']) ? intval($_GET['id']) : '';
     $form->addElement('hidden', 'id', $id);
     $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
     $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers', 'Width' => '100%', 'Height' => '250'));
     $form->addElement('label', get_lang('Components'));
     // Get components
     $nr_items = 2;
     $max = 10;
     // Setting the defaults
     $defaults = $this->get($id);
     $components = $this->get_components($defaults['id']);
     if ($action == 'edit') {
         if (!empty($components)) {
             $nr_items = count($components) - 1;
         }
     }
     $form->addElement('hidden', 'maxvalue', '100');
     $form->addElement('hidden', 'minvalue', '0');
     $renderer =& $form->defaultRenderer();
     $component_array = array();
     for ($i = 0; $i <= $max; $i++) {
         $counter = $i;
         $form->addElement('text', 'components[' . $i . '][percentage]', null);
         $form->addElement('text', 'components[' . $i . '][acronym]', null);
         $form->addElement('text', 'components[' . $i . '][title]', null);
         $form->addElement('hidden', 'components[' . $i . '][id]', null);
         $template_percentage = '<div id=' . $i . ' style="display: ' . ($i <= $nr_items ? 'inline' : 'none') . ';" class="control-group">
             <p>
             <label class="control-label">{label}</label>
             <div class="controls">
                 <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
                 {element} <!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --> % = ';
         $template_acronym = '
         <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
         {element} {label} <!-- BEGIN error --><span class="form_error">{error}</span> <!-- END error -->';
         $template_title = '&nbsp{element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error -->
          <a href="javascript:plusItem(' . ($counter + 1) . ')">
             <img style="display: ' . ($counter >= $nr_items ? 'inline' : 'none') . ';" id="plus-' . ($counter + 1) . '" src="../img/icons/22/add.png" alt="' . get_lang('Add') . '" title="' . get_lang('Add') . '"></img>
         </a>
         <a href="javascript:minItem(' . $counter . ')">
             <img style="display: ' . ($counter >= $nr_items ? 'inline' : 'none') . ';" id="min-' . $counter . '" src="../img/delete.png" alt="' . get_lang('Delete') . '" title="' . get_lang('Delete') . '"></img>
         </a>
         </div></p></div>';
         $renderer->setElementTemplate($template_title, 'components[' . $i . '][title]');
         $renderer->setElementTemplate($template_percentage, 'components[' . $i . '][percentage]');
         $renderer->setElementTemplate($template_acronym, 'components[' . $i . '][acronym]');
         if ($i == 0) {
             $form->addRule('components[' . $i . '][percentage]', get_lang('ThisFieldIsRequired'), 'required');
             $form->addRule('components[' . $i . '][title]', get_lang('ThisFieldIsRequired'), 'required');
             $form->addRule('components[' . $i . '][acronym]', get_lang('ThisFieldIsRequired'), 'required');
         }
         $form->addRule('components[' . $i . '][percentage]', get_lang('OnlyNumbers'), 'numeric');
         $form->addRule(array('components[' . $i . '][percentage]', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
         $form->addRule(array('components[' . $i . '][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
         $component_array[] = 'components[' . $i . '][percentage]';
     }
     //New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
     $form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
     $form->addElement('label', '', get_lang('AllMustWeight100'));
     if ($action == 'edit') {
         $form->addButtonUpdate(get_lang('Modify'));
     } else {
         $form->addButtonCreate(get_lang('Add'));
     }
     if (!empty($components)) {
         $counter = 0;
         foreach ($components as $component) {
             foreach ($component as $key => $value) {
                 $defaults['components[' . $counter . '][' . $key . ']'] = $value;
             }
             $counter++;
         }
     }
     $form->setDefaults($defaults);
     // Setting the rules
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
 /**
  * @param string $url
  * @param string $action
  * @return FormValidator
  */
 public function return_form($url, $action)
 {
     $form = new FormValidator($this->type . '_field', 'post', $url);
     $form->addElement('hidden', 'type', $this->type);
     $id = isset($_GET['id']) ? intval($_GET['id']) : null;
     $form->addElement('hidden', 'id', $id);
     // Setting the form elements
     $header = get_lang('Add');
     $defaults = array();
     if ($action == 'edit') {
         $header = get_lang('Modify');
         // Setting the defaults
         $defaults = $this->get($id);
     }
     $form->addElement('header', $header);
     $form->addElement('text', 'display_text', get_lang('Name'), array('class' => 'span5'));
     // Field type
     $types = self::get_field_types();
     $form->addElement('select', 'field_type', get_lang('FieldType'), $types, array('id' => 'field_type'));
     $form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
     $form->addElement('text', 'variable', get_lang('FieldLabel'), array('class' => 'span5'));
     $form->addElement('text', 'field_options', get_lang('FieldPossibleValues'), array('id' => 'field_options', 'class' => 'span6'));
     $fieldWithOptions = array(ExtraField::FIELD_TYPE_RADIO, ExtraField::FIELD_TYPE_SELECT_MULTIPLE, ExtraField::FIELD_TYPE_SELECT, ExtraField::FIELD_TYPE_TAG, ExtraField::FIELD_TYPE_DOUBLE_SELECT);
     if ($action == 'edit') {
         if (in_array($defaults['field_type'], $fieldWithOptions)) {
             $url = Display::url(get_lang('EditExtraFieldOptions'), 'extra_field_options.php?type=' . $this->type . '&field_id=' . $id);
             $form->addElement('label', null, $url);
             if ($defaults['field_type'] == ExtraField::FIELD_TYPE_SELECT) {
                 $urlWorkFlow = Display::url(get_lang('EditExtraFieldWorkFlow'), 'extra_field_workflow.php?type=' . $this->type . '&field_id=' . $id);
                 $form->addElement('label', null, $urlWorkFlow);
             }
             $form->freeze('field_options');
         }
     }
     $form->addElement('text', 'default_value', get_lang('FieldDefaultValue'), array('id' => 'default_value'));
     $group = array();
     $group[] = $form->createElement('radio', 'visible', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'visible', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('Visible'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'changeable', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'changeable', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldChangeability'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'filter', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'filter', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldFilter'), '', false);
     /* Enable this when field_loggeable is introduced as a table field (2.0)
        $group   = array();
        $group[] = $form->createElement('radio', 'field_loggeable', null, get_lang('Yes'), 1);
        $group[] = $form->createElement('radio', 'field_loggeable', null, get_lang('No'), 0);
        $form->addGroup($group, '', get_lang('FieldLoggeable'), '', false);
        */
     $form->addElement('text', 'field_order', get_lang('FieldOrder'), array('class' => 'span1'));
     if ($action == 'edit') {
         $option = new ExtraFieldOption($this->type);
         if ($defaults['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
             $form->freeze('field_options');
         }
         $defaults['field_options'] = $option->get_field_options_by_field_to_string($id);
         $form->addButtonUpdate(get_lang('Modify'));
     } else {
         $defaults['visible'] = 0;
         $defaults['changeable'] = 0;
         $defaults['filter'] = 0;
         $form->addButtonCreate(get_lang('Add'));
     }
     /*if (!empty($defaults['created_at'])) {
           $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
       }
       if (!empty($defaults['updated_at'])) {
           $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
       }*/
     $form->setDefaults($defaults);
     // Setting the rules
     $form->addRule('display_text', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('field_type', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
Example #5
0
 */
// Resetting the course id.
$cidReset = true;
// Including some necessary dokeos files.
//require_once '../inc/global.inc.php';
// Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions.
api_protect_admin_script();
// Setting breadcrumbs.
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
// Setting the name of the tool.
$tool_name = get_lang('AddClasses');
$tool_name = get_lang('ModifyClassInfo');
$class_id = intval($_GET['idclass']);
$class = ClassManager::get_class_info($class_id);
$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass=' . $class_id);
$form->addText('name', get_lang('ClassName'));
$form->addButtonUpdate(get_lang('Ok'));
$form->setDefaults(array('name' => $class['name']));
if ($form->validate()) {
    $values = $form->exportValues();
    ClassManager::set_name($values['name'], $class_id);
    header('Location: class_list.php');
}
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
$form->display();
// Displaying the footer.
Display::display_footer();
/**
 * This function displays the form that is used to edit a forum category.
 * This is more or less a copy from the show_add_forumcategory_form function with the only difference that is uses
 * some default values. I tried to have both in one function but this gave problems with the handle_forum_and_forumcategories function
 * (storing was done twice)
 *
 * @param array
 * @return void HTML
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @version february 2006, dokeos 1.8
 */
function show_edit_forumcategory_form($inputvalues = array())
{
    $categoryId = $inputvalues['cat_id'];
    $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq() . '&id=' . $categoryId);
    // Setting the form elements.
    $form->addElement('header', '', get_lang('EditForumCategory'));
    $form->addElement('hidden', 'forum_category_id');
    $form->addElement('text', 'forum_category_title', get_lang('Title'));
    $form->addHtmlEditor('forum_category_comment', get_lang('Comment'), null, null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200'));
    $form->addButtonUpdate(get_lang('ModifyCategory'), 'SubmitEditForumCategory');
    // Setting the default values.
    $defaultvalues['forum_category_id'] = $inputvalues['cat_id'];
    $defaultvalues['forum_category_title'] = $inputvalues['cat_title'];
    $defaultvalues['forum_category_comment'] = $inputvalues['cat_comment'];
    $form->setDefaults($defaultvalues);
    // Setting the rules.
    $form->addRule('forum_category_title', get_lang('ThisFieldIsRequired'), 'required');
    // Validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            store_forumcategory($values);
        }
        Security::clear_token();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
        $table->setCellContents($row, $column, $element);
        $form->addElement('hidden', 'hidden_' . $idForm, $value, array('id' => 'hidden_' . $id));
        $column++;
    }
    $row++;
}
if (!empty($roleId)) {
    $form->addElement('html', $table->toHtml());
    $group = array();
    $group[] = $form->createElement('button', 'submit', get_lang('Save'));
    $group[] = $form->createElement('button', 'select_all', get_lang('SelectAll'), array('class' => 'btn select_all'));
    $group[] = $form->createElement('button', 'unselect_all', get_lang('UnSelectAll'), array('class' => 'btn unselect_all'));
    $form->addGroup($group, '', null, ' ');
    $form->setDefaults(array('status' => $roleId));
} else {
    $form->addButtonUpdate(get_lang('Edit'));
}
$form->display();
if ($form->validate()) {
    $values = $form->getSubmitValues();
    $result = $values['hidden_extra_field_status'];
    if (!empty($result)) {
        foreach ($result as $id => $items) {
            foreach ($items as $subItemId => $value) {
                $extraFieldOptionRelFieldOption = $app['orm.em']->getRepository('ChamiloLMS\\Entity\\ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_id, 'fieldOptionId' => $subItemId, 'roleId' => $roleId, 'relatedFieldOptionId' => $id));
                if ($value == 1) {
                    if (empty($extraFieldOptionRelFieldOption)) {
                        $extraFieldOptionRelFieldOption = new \ChamiloLMS\Entity\ExtraFieldOptionRelFieldOption();
                        $extraFieldOptionRelFieldOption->setFieldId($field_id);
                        $extraFieldOptionRelFieldOption->setFieldOptionId($subItemId);
                        $extraFieldOptionRelFieldOption->setRelatedFieldOptionId($id);
 /**
  * Returns an HTML form for the current field
  * @param string URL to send the form to (action=...)
  * @param string Type of action to offer through the form (edit, usually)
  *
  * @return FormValidator
  */
 public function return_form($url, $action)
 {
     $form_name = $this->type . '_field';
     $form = new FormValidator($form_name, 'post', $url);
     // Setting the form elements
     $header = get_lang('Add');
     if ($action == 'edit') {
         $header = get_lang('Modify');
     }
     $form->addElement('header', $header);
     $id = isset($_GET['id']) ? intval($_GET['id']) : '';
     $form->addElement('hidden', 'id', $id);
     $form->addElement('hidden', 'type', $this->type);
     $form->addElement('hidden', 'field_id', $this->field_id);
     $form->addElement('text', 'display_text', get_lang('Name'));
     $form->addElement('text', 'option_value', get_lang('Value'));
     $form->addElement('text', 'option_order', get_lang('Order'));
     $form->addElement('select', 'priority', get_lang('Priority'), $this->getPriorityOptions());
     $form->addElement('textarea', 'priority_message', get_lang('PriorityOfMessage'));
     $defaults = array();
     if ($action == 'edit') {
         // Setting the defaults
         $defaults = $this->get($id);
         $form->freeze('option_value');
         $form->addButtonUpdate(get_lang('Modify'));
     } else {
         $form->addButtonCreate(get_lang('Add'));
     }
     $form->setDefaults($defaults);
     // Setting the rules
     $form->addRule('display_text', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('option_value', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
Example #9
0
                foreach ($form_fields as &$field) {
                    $field_value = explode(':', $field);
                    if ($field_value[0] != '' && $field_value[1] != '') {
                        $defaults[$field_value[0]] = $field_value[1];
                    }
                }
            }
        }
        $form->addElement('html', '</div>');
    }
}
$form->addElement('html', '</div><br />');
if (isset($_GET['survey_id']) && $_GET['action'] == 'edit') {
    $class = 'save';
    $text = get_lang('ModifySurvey');
    $form->addButtonUpdate(get_lang('ModifySurvey'), 'submit_survey');
} else {
    $class = 'add';
    $text = get_lang('CreateSurvey');
    $form->addButtonCreate(get_lang('CreateSurvey'), 'submit_survey');
}
// Setting the rules
if ($_GET['action'] == 'add') {
    $form->addRule('survey_code', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('survey_code', '', 'maxlength', 20);
}
$form->addRule('survey_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('start_date', get_lang('InvalidDate'), 'date');
$form->addRule('end_date', get_lang('InvalidDate'), 'date');
$form->addRule(array('start_date', 'end_date'), get_lang('StartDateShouldBeBeforeEndDate'), 'date_compare', 'lte');
// Setting the default values
Example #10
0
 }
 if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
     // Updated on field
     $last_edit_date = api_get_local_time($last_edit_date);
     $display_date = date_to_str_ago($last_edit_date) . ' <span class="dropbox_date">' . api_format_date($last_edit_date) . '</span>';
     $form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
 }
 $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
 if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
     $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
     if ($readonly == 1) {
         $checked->setChecked(true);
     }
 }
 if ($is_certificate_mode) {
     $form->addButtonUpdate(get_lang('SaveCertificate'));
 } else {
     $form->addButtonUpdate(get_lang('SaveDocument'));
 }
 $defaults['filename'] = $filename;
 $defaults['extension'] = $extension;
 $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
 $defaults['commentPath'] = $file;
 $defaults['renameTo'] = $file_name;
 $defaults['comment'] = $document_data['comment'];
 $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
 $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
 $form->setDefaults($defaults);
 show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode);
 if ($is_certificate_mode) {
     $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
Example #11
0
    }
    $form->addCheckBox('send_email', null, get_lang('SendMailToStudent'));
    // Check if user to qualify has some DRHs
    $drhList = UserManager::getDrhListFromUser($work_item['user_id']);
    if (!empty($drhList)) {
        $form->addCheckBox('send_to_drh_users', null, get_lang('SendMailToHR'));
    }
}
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
$form->addElement('hidden', 'item_to_edit', $item_id);
$form->addElement('hidden', 'sec_token', $token);
$text = get_lang('UpdateWork');
$class = 'save';
// fix the Ok button when we see the tool in the learn path
$form->addButtonUpdate($text);
$form->setDefaults($defaults);
$error_message = null;
$_course = api_get_course_info();
$currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/';
$succeed = false;
if ($form->validate()) {
    if ($student_can_edit_in_session && $check) {
        /*
         * SPECIAL CASE ! For a work edited
         */
        //Get the author ID for that document from the item_property table
        $item_to_edit_id = intval($_POST['item_to_edit']);
        $is_author = user_is_author($item_to_edit_id);
        if ($is_author) {
            $work_data = get_work_data_by_id($item_to_edit_id);
Example #12
0
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_GET['notebook_id'])) {
    // Action handling: Editing a note
    if (!empty($_GET['isStudentView'])) {
        NotebookManager::display_notes();
        exit;
    }
    // Initialize the object
    $form = new FormValidator('note', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&notebook_id=' . Security::remove_XSS($_GET['notebook_id']));
    // Setting the form elements
    $form->addElement('header', '', get_lang('ModifyNote'));
    $form->addElement('hidden', 'notebook_id');
    $form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100'));
    //$form->applyFilter('note_title', 'html_filter');
    $form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit() ? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300') : array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student'));
    $form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote');
    // Setting the defaults
    $defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id']));
    $form->setDefaults($defaults);
    // Setting the rules
    $form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
    // The validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $res = NotebookManager::update_note($values);
            if ($res) {
                Display::display_confirmation_message(get_lang('NoteUpdated'));
            }
        }
Example #13
0
     $form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
 } else {
     $form->addElement('label', get_lang('Attendances'), '<strong><em>' . get_lang('ThereAreNoAttendancesInsideCourse') . '</em></strong>');
 }
 $form->addElement('html', '<div id="div_datetime_attendance">');
 if (!empty($calendar_select)) {
     $form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select, array('id' => 'start_date_select_calendar'));
 }
 $form->addElement('html', '</div>');
 $form->addElement('html', '</div>');
 $form->addText('duration_in_hours', get_lang('DurationInHours'), false, array('size' => '3', 'id' => 'duration_in_hours_element', 'autofocus' => 'autofocus'));
 $form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded' => 'false', 'ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
 if ($action == 'thematic_advance_add') {
     $form->addButtonSave(get_lang('Save'));
 } else {
     $form->addButtonUpdate(get_lang('Save'));
 }
 //$form->addElement('html', '<a href="#" id="save_button" onclick="save();">Save</a>');
 $attendance_select_item_id = null;
 if (count($attendance_select) > 1) {
     $i = 1;
     foreach ($attendance_select as $key => $attendance_select_item) {
         if ($i == 2) {
             $attendance_select_item_id = $key;
             break;
         }
         $i++;
     }
     if (!empty($attendance_select_item_id)) {
         $default['attendance_select'] = $attendance_select_item_id;
         if ($thematic_advance_id) {
Example #14
0
$group[] =& $form->createElement('password', 'password', null, array('onkeydown' => 'javascript: password_switch_radio_button(document.user_add,"password[password_auto]");'));
$form->addGroup($group, 'password', get_lang('Password'), '');
// Send email
$group = array();
$group[] =& $form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1);
$group[] =& $form->createElement('radio', 'send_mail', null, get_lang('No'), 0);
$form->addGroup($group, 'mail', get_lang('SendMailToNewUser'), '&nbsp;');
// Set default values
$defaults = array();
$defaults['username'] = $userInfo['username'];
$defaults['mail']['send_mail'] = 0;
$defaults['password']['password_auto'] = 1;
$form->setDefaults($defaults);
// Submit button
$select_level = array();
$html_results_enabled[] = $form->addButtonUpdate(get_lang('Update'), 'submit', true);
$form->addGroup($html_results_enabled);
// Validate form
if ($form->validate()) {
    $check = Security::check_token('post');
    if ($check) {
        $user = $form->exportValues();
        $email = $userInfo['email'];
        $username = $userInfo['username'];
        $send_mail = intval($user['mail']['send_mail']);
        $auth_source = PLATFORM_AUTH_SOURCE;
        $resetPassword = $user['password']['password_auto'] == '1' ? 0 : 2;
        if (count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') {
            //$auth_source = $user['password']['auth_source'];
            //$password = '******';
        } else {
Example #15
0
     break;
 case 'edit_glossary':
     if (is_numeric($_GET['glossary_id'])) {
         // initiate the object
         $form = new FormValidator('glossary', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&glossary_id=' . intval($_GET['glossary_id']) . '&' . api_get_cidreq());
         // Setting the form elements
         $form->addElement('header', '', get_lang('TermEdit'));
         $form->addElement('hidden', 'glossary_id');
         $form->addElement('text', 'glossary_title', get_lang('TermName'), array('size' => '80'));
         //$form->applyFilter('glossary_title', 'html_filter');
         $form->addHtmlEditor('glossary_comment', get_lang('TermDefinition'), false, false, array('ToolbarSet' => 'Glossary', 'Height' => '300'));
         $element = $form->addElement('text', 'insert_date', get_lang('CreationDate'), array('size' => '100'));
         $element->freeze();
         $element = $form->addElement('text', 'update_date', get_lang('UpdateDate'), array('size' => '100'));
         $element->freeze();
         $form->addButtonUpdate(get_lang('TermUpdateButton'), 'SubmitGlossary');
         // setting the defaults
         $glossary_data = GlossaryManager::get_glossary_information($_GET['glossary_id']);
         // Date treatment for timezones
         if (!empty($glossary_data['insert_date']) && $glossary_data['insert_date'] != '0000-00-00 00:00:00:') {
             $glossary_data['insert_date'] = api_get_local_time($glossary_data['insert_date']);
         } else {
             $glossary_data['insert_date'] = '';
         }
         if (!empty($glossary_data['update_date']) && $glossary_data['update_date'] != '0000-00-00 00:00:00:') {
             $glossary_data['update_date'] = api_get_local_time($glossary_data['update_date']);
         } else {
             $glossary_data['update_date'] = '';
         }
         $form->setDefaults($glossary_data);
         // setting the rules
Example #16
0
 /**
  * @param FormValidator $form
  * @param string        $type
  * @param array         $data
  */
 public function setForm($form, $type = 'add', $data = array())
 {
     switch ($type) {
         case 'add':
             $header = get_lang('Add');
             break;
         case 'edit':
             $header = get_lang('Edit');
             break;
     }
     $form->addElement('header', $header);
     //Name
     $form->addElement('text', 'name', get_lang('Name'), array('maxlength' => 255));
     $form->applyFilter('name', 'html_filter');
     $form->applyFilter('name', 'trim');
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('name', '', 'maxlength', 255);
     // Description
     $form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 58));
     $form->applyFilter('description', 'html_filter');
     $form->applyFilter('description', 'trim');
     if ($this->showGroupTypeSetting) {
         $form->addElement('checkbox', 'group_type', null, get_lang('SocialGroup'));
     }
     // url
     $form->addElement('text', 'url', get_lang('Url'));
     $form->applyFilter('url', 'html_filter');
     $form->applyFilter('url', 'trim');
     // Picture
     $allowed_picture_types = $this->getAllowedPictureExtensions();
     $form->addElement('file', 'picture', get_lang('AddPicture'));
     $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
     if (isset($data['picture']) && strlen($data['picture']) > 0) {
         $picture = $this->get_picture_group($data['id'], $data['picture'], 80);
         $img = '<img src="' . $picture['file'] . '" />';
         $form->addElement('label', null, $img);
         $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
     }
     $form->addElement('select', 'visibility', get_lang('GroupPermissions'), $this->getGroupStatusList());
     $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
     // Setting the form elements
     if ($type == 'add') {
         $form->addButtonCreate($header);
     } else {
         $form->addButtonUpdate($header);
     }
 }
Example #17
0
if (strlen($group_data['picture_uri']) > 0) {
    $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
}
// Group parent
$groups = array();
$groups = GroupPortalManager::get_groups_list($group_id);
$groups[0] = get_lang('NoParentship');
$group_data['parent_group'] = GroupPortalManager::get_parent_group($group_id);
$form->addElement('select', 'parent_group', get_lang('GroupParentship'), $groups, array());
// Status
$status = array();
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
$form->addElement('select', 'visibility', get_lang('GroupPermissions'), $status, array());
// Submit button
$form->addButtonUpdate(get_lang('ModifyInformation'));
// Set default values
$form->setDefaults($group_data);
// Validate form
if ($form->validate()) {
    $group = $form->exportValues();
    $picture_element = $form->getElement('picture');
    $picture = $picture_element->getValue();
    $picture_uri = $group_data['picture_uri'];
    if ($group['delete_picture']) {
        $picture_uri = GroupPortalManager::delete_group_picture($group_id);
    } elseif (!empty($picture['name'])) {
        $picture_uri = GroupPortalManager::update_group_picture($group_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']);
    }
    $name = $group['name'];
    $description = $group['description'];