Пример #1
0
//make available wider as we need it in case of form reset (see below)
$nb_ext_auth_source_added = 0;
if (isset($extAuthSource) && count($extAuthSource) > 0) {
    $auth_sources = array();
    foreach ($extAuthSource as $key => $info) {
        // @todo : make uniform external authentification configuration (ex : cas and external_login ldap)
        // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
        // extAuthSource always on for CAS even if not activated
        // same action for file user_edit.php
        if ($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true' || $key != CAS_AUTH_SOURCE) {
            $auth_sources[$key] = $key;
            $nb_ext_auth_source_added++;
        }
    }
    if ($nb_ext_auth_source_added > 0) {
        $group[] = $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication') . ' ', 2);
        $group[] = $form->createElement('select', 'auth_source', null, $auth_sources);
        $group[] = $form->createElement('static', '', '', '<br />');
    }
}
$group[] = $form->createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword') . '<br />', 1);
$group[] = $form->createElement('radio', 'password_auto', 'id="radio_user_password"', get_lang('EnterPassword'), 0);
$group[] = $form->createElement('password', 'password', null, array('id' => 'password', 'autocomplete' => 'off', 'onkeydown' => 'javascript: password_switch_radio_button();'));
$form->addGroup($group, 'password', get_lang('Password'), '');
$form->addGroupRule('password', get_lang('EnterPassword'), 'required', null, 1);
if ($checkPass) {
    $passwordStrengthLabels = '
        <div id="password-verdict"></div>
        <div id="password-errors"></div>
        <div id="password_progress" style="display:none"></div>
    ';
     $url = api_get_self() . '?id=' . intval($_GET['id']);
 }
 $form = new FormValidator('system_announcement', 'post', $url);
 $form->addElement('header', '', $form_title);
 $form->addText('title', get_lang('Title'), true);
 $language_list = api_get_languages();
 $language_list_with_keys = array();
 $language_list_with_keys['all'] = get_lang('All');
 for ($i = 0; $i < count($language_list['name']); $i++) {
     $language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i];
 }
 $form->addElement('select', 'lang', get_lang('Language'), $language_list_with_keys);
 $form->addHtmlEditor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
 $form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range'));
 $group = array();
 $group[] = $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher'));
 $group[] = $form->createElement('checkbox', 'visible_student', null, get_lang('Student'));
 $group[] = $form->createElement('checkbox', 'visible_guest', null, get_lang('Guest'));
 $form->addGroup($group, null, get_lang('Visible'), '');
 $form->addElement('hidden', 'id');
 $userGroup = new UserGroup();
 $group_list = $userGroup->get_all();
 if (!empty($group_list)) {
     $group_list = array_column($group_list, 'name', 'id');
     $group_list[0] = get_lang('All');
     $form->addElement('select', 'group', get_lang('AnnouncementForGroup'), $group_list);
 }
 $values['group'] = isset($values['group']) ? $values['group'] : '0';
 $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
     $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
Пример #3
0
        //exit;
    }
}
Display::display_header($tool_name);
if (!empty($error_message)) {
    Display::display_error_message($error_message);
}
if (!empty($see_message_import)) {
    Display::display_normal_message($see_message_import);
}
$form = new FormValidator('user_import', 'post', 'skills_import.php');
$form->addElement('header', '', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$group = array();
$group[] = $form->createElement('radio', 'file_type', '', 'CSV (<a href="skill_example.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv');
//$group[] = $form->createElement('radio', 'file_type', null, 'XML (<a href="skill_example.xml" target="_blank">'.get_lang('ExampleXMLFile').'</a>)', 'xml');
$form->addGroup($group, '', get_lang('FileType'), '<br/>');
$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"');
$defaults['formSent'] = 1;
$defaults['sendMail'] = 0;
$defaults['file_type'] = 'csv';
$form->setDefaults($defaults);
$form->display();
$list = array();
$list_reponse = array();
$result_xml = '';
$i = 0;
$count_fields = count($extra_fields);
if ($count_fields > 0) {
    foreach ($extra_fields as $extra) {
Пример #4
0
    /**
     * @param FormValidator $form
     * @param $extra_data
     * @param $form_name
     * @param bool $admin_permissions
     * @param null $user_id
     * @deprecated
     * @return array
     */
    static function set_extra_fields_in_form($form, $extra_data, $admin_permissions = false, $user_id = null)
    {
        $user_id = intval($user_id);
        // EXTRA FIELDS
        $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
        $jquery_ready_content = null;
        foreach ($extra as $field_details) {
            if (!$admin_permissions) {
                if ($field_details[6] == 0) {
                    continue;
                }
            }
            switch ($field_details[2]) {
                case ExtraField::FIELD_TYPE_TEXT:
                    $form->addElement('text', 'extra_' . $field_details[1], $field_details[3], array('size' => 40));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    $form->applyFilter('extra_' . $field_details[1], 'html_filter');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_TEXTAREA:
                    $form->addHtmlEditor('extra_' . $field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_RADIO:
                    $group = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        $options[$option_details[1]] = $option_details[2];
                        $group[] = $form->createElement('radio', 'extra_' . $field_details[1], $option_details[1], $option_details[2] . '<br />', $option_details[1]);
                    }
                    $form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], '');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_SELECT:
                    $get_lang_variables = false;
                    if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
                        $get_lang_variables = true;
                    }
                    $options = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        if ($get_lang_variables) {
                            $options[$option_details[1]] = get_lang($option_details[2]);
                        } else {
                            $options[$option_details[1]] = $option_details[2];
                        }
                    }
                    if ($get_lang_variables) {
                        $field_details[3] = get_lang($field_details[3]);
                    }
                    $form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('id' => 'extra_' . $field_details[1]));
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
                    $options = array();
                    foreach ($field_details[9] as $option_id => $option_details) {
                        $options[$option_details[1]] = $option_details[2];
                    }
                    $form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_DATE:
                    $form->addDatePicker('extra_' . $field_details[1], $field_details[3]);
                    $defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
                    $form->setDefaults($defaults);
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    $form->applyFilter('theme', 'trim');
                    break;
                case ExtraField::FIELD_TYPE_DATETIME:
                    $form->addDateTimePicker('extra_' . $field_details[1], $field_details[3]);
                    $defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
                    $form->setDefaults($defaults);
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    $form->applyFilter('theme', 'trim');
                    break;
                case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                    foreach ($field_details[9] as $key => $element) {
                        if ($element[2][0] == '*') {
                            $values['*'][$element[0]] = str_replace('*', '', $element[2]);
                        } else {
                            $values[0][$element[0]] = $element[2];
                        }
                    }
                    $group = '';
                    $group[] = $form->createElement('select', 'extra_' . $field_details[1], '', $values[0], '');
                    $group[] = $form->createElement('select', 'extra_' . $field_details[1] . '*', '', $values['*'], '');
                    $form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], '&nbsp;');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    /* Recoding the selected values for double : if the user has
                       selected certain values, we have to assign them to the
                       correct select form */
                    if (array_key_exists('extra_' . $field_details[1], $extra_data)) {
                        // exploding all the selected values (of both select forms)
                        $selected_values = explode(';', $extra_data['extra_' . $field_details[1]]);
                        $extra_data['extra_' . $field_details[1]] = array();
                        // looping through the selected values and assigning the selected values to either the first or second select form
                        foreach ($selected_values as $key => $selected_value) {
                            if (array_key_exists($selected_value, $values[0])) {
                                $extra_data['extra_' . $field_details[1]]['extra_' . $field_details[1]] = $selected_value;
                            } else {
                                $extra_data['extra_' . $field_details[1]]['extra_' . $field_details[1] . '*'] = $selected_value;
                            }
                        }
                    }
                    break;
                case ExtraField::FIELD_TYPE_DIVIDER:
                    $form->addElement('static', $field_details[1], '<br /><strong>' . $field_details[3] . '</strong>');
                    break;
                case ExtraField::FIELD_TYPE_TAG:
                    //the magic should be here
                    $user_tags = UserManager::get_user_tags($user_id, $field_details[0]);
                    $tag_list = '';
                    if (is_array($user_tags) && count($user_tags) > 0) {
                        foreach ($user_tags as $tag) {
                            $tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>';
                        }
                    }
                    $multi_select = '<select id="extra_' . $field_details[1] . '" name="extra_' . $field_details[1] . '">
                                    ' . $tag_list . '
                                    </select>';
                    $form->addElement('label', $field_details[3], $multi_select);
                    $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php';
                    $complete_text = get_lang('StartToType');
                    //if cache is set to true the jquery will be called 1 time
                    $jquery_ready_content = <<<EOF
                    \$("#extra_{$field_details['1']}").fcbkcomplete({
                        json_url: "{$url}?a=search_tags&field_id={$field_details['0']}",
                        cache: false,
                        filter_case: true,
                        filter_hide: true,
                        complete_text:"{$complete_text}",
                        firstselected: true,
                        //onremove: "testme",
                        //onselect: "testme",
                        filter_selected: true,
                        newel: true
                    });
EOF;
                    break;
                case ExtraField::FIELD_TYPE_TIMEZONE:
                    $form->addElement('select', 'extra_' . $field_details[1], $field_details[3], api_get_timezones(), '');
                    if ($field_details[7] == 0) {
                        $form->freeze('extra_' . $field_details[1]);
                    }
                    break;
                case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
                    // get the social network's favicon
                    $icon_path = UserManager::get_favicon_from_url($extra_data['extra_' . $field_details[1]], $field_details[4]);
                    // special hack for hi5
                    $leftpad = '1.7';
                    $top = '0.4';
                    $domain = parse_url($icon_path, PHP_URL_HOST);
                    if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
                        $leftpad = '3';
                        $top = '0';
                    }
                    // print the input field
                    $form->addElement('text', 'extra_' . $field_details[1], $field_details[3], array('size' => 60, 'style' => 'background-image: url(\'' . $icon_path . '\'); background-repeat: no-repeat; background-position: 0.4em ' . $top . 'em; padding-left: ' . $leftpad . 'em; '));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    if ($field_details[7] == 0) {
                        $form->freeze('extra_' . $field_details[1]);
                    }
                    break;
                case ExtraField::FIELD_TYPE_FILE:
                    $extra_field = 'extra_' . $field_details[1];
                    $form->addElement('file', $extra_field, $field_details[3], null, '');
                    if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) {
                        $form->addElement('static', $extra_field . '_list', null, $extra_file_list);
                    }
                    if ($field_details[7] == 0) {
                        $form->freeze($extra_field);
                    }
                    break;
                case ExtraField::FIELD_TYPE_MOBILE_PHONE_NUMBER:
                    $form->addElement('text', 'extra_' . $field_details[1], $field_details[3] . " (" . get_lang('CountryDialCode') . ")", array('size' => 40, 'placeholder' => '(xx)xxxxxxxxx'));
                    $form->applyFilter('extra_' . $field_details[1], 'stripslashes');
                    $form->applyFilter('extra_' . $field_details[1], 'trim');
                    $form->applyFilter('extra_' . $field_details[1], 'mobile_phone_number_filter');
                    $form->addRule('extra_' . $field_details[1], get_lang('MobilePhoneNumberWrong'), 'mobile_phone_number');
                    if (!$admin_permissions) {
                        if ($field_details[7] == 0) {
                            $form->freeze('extra_' . $field_details[1]);
                        }
                    }
                    break;
            }
        }
        $return = array();
        $return['jquery_ready_content'] = $jquery_ready_content;
        return $return;
    }
 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     // Getting the exercise list
     $obj_ex = $_SESSION['objExercise'];
     $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
     //this line defines how many questions by default appear when creating a choice question
     // The previous default value was 2. See task #1759.
     $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4;
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     /*
         Types of Feedback
         $feedback_option[0]=get_lang('Feedback');
        $feedback_option[1]=get_lang('DirectFeedback');
        $feedback_option[2]=get_lang('NoFeedback');
     */
     $feedback_title = '';
     if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
         //Scenario
         $editor_config['Width'] = '250';
         $editor_config['Height'] = '110';
         $comment_title = '<th width="500px" >' . get_lang('Comment') . '</th>';
         $feedback_title = '<th width="350px" >' . get_lang('Scenario') . '</th>';
     } else {
         $comment_title = '<th>' . get_lang('Comment') . '</th>';
     }
     $html = '<table class="data_table">
             <tr style="text-align: center;">
                 <th width="10px">
                     ' . get_lang('Number') . '
                 </th>
                 <th width="10px" >
                     ' . get_lang('True') . '
                 </th>
                 <th width="50%">
                     ' . get_lang('Answer') . '
                 </th>
                     ' . $comment_title . '
                     ' . $feedback_title . '
                 <th width="50px">
                     ' . get_lang('Weighting') . '
                 </th>
             </tr>';
     $form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
     $defaults = array();
     $correct = 0;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $form->addElement('hidden', 'nb_answers');
     //Feedback SELECT
     $question_list = $obj_ex->selectQuestionList();
     $select_question = array();
     $select_question[0] = get_lang('SelectTargetQuestion');
     require_once '../newscorm/learnpathList.class.php';
     if (is_array($question_list)) {
         foreach ($question_list as $key => $questionid) {
             //To avoid warning messages
             if (!is_numeric($questionid)) {
                 continue;
             }
             $question = Question::read($questionid);
             $select_question[$questionid] = 'Q' . $key . ' :' . cut($question->selectTitle(), 20);
         }
     }
     $select_question[-1] = get_lang('ExitTest');
     $list = new LearnpathList(api_get_user_id());
     $flat_list = $list->get_flat_list();
     $select_lp_id = array();
     $select_lp_id[0] = get_lang('SelectTargetLP');
     foreach ($flat_list as $id => $details) {
         $select_lp_id[$id] = cut($details['lp_name'], 20);
     }
     $temp_scenario = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addElement('html', '<tr>');
         if (isset($answer) && is_object($answer)) {
             if ($answer->correct[$i]) {
                 $correct = $i;
             }
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
             $item_list = explode('@@', $answer->destination[$i]);
             $try = $item_list[0];
             $lp = $item_list[1];
             $list_dest = $item_list[2];
             $url = $item_list[3];
             if ($try == 0) {
                 $try_result = 0;
             } else {
                 $try_result = 1;
             }
             if ($url == 0) {
                 $url_result = '';
             } else {
                 $url_result = $url;
             }
             $temp_scenario['url' . $i] = $url_result;
             $temp_scenario['try' . $i] = $try_result;
             $temp_scenario['lp' . $i] = $lp;
             $temp_scenario['destination' . $i] = $list_dest;
         } else {
             $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
             $defaults['weighting[1]'] = 10;
             $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
             $defaults['weighting[2]'] = 0;
             $temp_scenario['destination' . $i] = array('0');
             $temp_scenario['lp' . $i] = array('0');
         }
         $defaults['scenario'] = $temp_scenario;
         $renderer = $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']');
         $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"');
         $answer_number->freeze();
         $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
         $form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
         if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
             $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
             // Direct feedback
             //Adding extra feedback fields
             $group = array();
             $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain'));
             $group['lp' . $i] = $form->createElement('select', 'lp' . $i, get_lang('SeeTheory') . ': ', $select_lp_id);
             $group['destination' . $i] = $form->createElement('select', 'destination' . $i, get_lang('GoToQuestion') . ': ', $select_question);
             $group['url' . $i] = $form->createElement('text', 'url' . $i, get_lang('Other') . ': ', array('class' => 'span2', 'placeholder' => get_lang('Other')));
             $form->addGroup($group, 'scenario');
             $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}', 'scenario');
         } else {
             $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config);
         }
         $form->addElement('text', 'weighting[' . $i . ']', null, array('class' => "span1", 'value' => '0'));
         $form->addElement('html', '</tr>');
     }
     $form->addElement('html', '</table>');
     $form->addElement('html', '<br />');
     $navigator_info = api_get_navigator();
     global $text, $class;
     //ie6 fix
     if ($obj_ex->edit_exercise_in_lp == true) {
         if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
             $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
             $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
             $form->addElement('submit', 'submitQuestion', $text, 'class="' . $class . '"');
         } else {
             //setting the save button here and not in the question class.php
             $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"');
             $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"');
             $form->addElement('style_submit_button', 'submitQuestion', $text, 'class="' . $class . '"');
         }
     }
     $renderer->setElementTemplate('{element}&nbsp;', 'submitQuestion');
     $renderer->setElementTemplate('{element}&nbsp;', 'lessAnswers');
     $renderer->setElementTemplate('{element}&nbsp;', 'moreAnswers');
     $form->addElement('html', '</div></div>');
     // We check the first radio button to be sure a radio button will be check
     if ($correct == 0) {
         $correct = 1;
     }
     $defaults['correct'] = $correct;
     if (!empty($this->id)) {
         $form->setDefaults($defaults);
     } else {
         if ($this->isContent == 1) {
             // Default sample content.
             $form->setDefaults($defaults);
         } else {
             $form->setDefaults(array('correct' => 1));
         }
     }
     $form->setConstants(array('nb_answers' => $nb_answers));
 }
Пример #6
0
$form->applyFilter('course_teachers', 'html_filter');
// Category code
$url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
$form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url));
// Course department
$form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
// Department URL
$form->addText('department_url', get_lang('CourseDepartmentURL'), false, array('size' => '60'));
$form->applyFilter('department_url', 'html_filter');
$form->addElement('select_language', 'course_language', get_lang('CourseLanguage'));
$form->applyFilter('select_language', 'html_filter');
$form->addElement('checkbox', 'exemplary_content', '', get_lang('FillWithExemplaryContent'));
$group = array();
$group[] = $form->createElement('radio', 'visibility', get_lang('CourseAccess'), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addGroup($group, '', get_lang('CourseAccess'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
$form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
Пример #7
0
 /**
  * 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();
     }
 }
        $value = 0;
        if (isset($includedFields[$itemCol['id']]) && in_array($item['id'], $includedFields[$itemCol['id']])) {
            $value = 1;
            $attributes['checked'] = 'checked';
        }
        $element = Display::input('checkbox', $id, null, $attributes);
        $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->addElement('button', 'submit', 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('Entity\\ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_id, 'fieldOptionId' => $subItemId, 'roleId' => $roleId, 'relatedFieldOptionId' => $id));
Пример #9
0
 /**
  * Returns an HTML form (generated by FormValidator) of the plugin settings
  * @return string FormValidator-generated form
  */
 public function get_settings_form()
 {
     $result = new FormValidator($this->get_name());
     $defaults = array();
     foreach ($this->fields as $name => $type) {
         $value = $this->get($name);
         $defaults[$name] = $value;
         $type = isset($type) ? $type : 'text';
         $help = null;
         if ($this->get_lang_plugin_exists($name . '_help')) {
             $help = $this->get_lang($name . '_help');
         }
         switch ($type) {
             case 'html':
                 $result->addElement('html', $this->get_lang($name));
                 break;
             case 'wysiwyg':
                 $result->add_html_editor($name, $this->get_lang($name));
                 break;
             case 'text':
                 $result->addElement($type, $name, array($this->get_lang($name), $help));
                 break;
             case 'boolean':
                 $group = array();
                 $group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
                 $group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
                 $result->addGroup($group, null, array($this->get_lang($name), $help));
                 break;
         }
     }
     $result->setDefaults($defaults);
     $result->addElement('style_submit_button', 'submit_button', $this->get_lang('Save'));
     return $result;
 }
Пример #10
0
/**
 * Create a group of select from a date
 * @param FormValidator $form
 * @param string $prefix
 * @return array
 */
function create_group_date_select($form, $prefix = '')
{
    $minute = range(10, 59);
    $d_year = date('Y');
    array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');

    $group_name = array(
        $form->createElement('select', $prefix.'day', '', array_combine(range(1, 31), range(1, 31))),
        $form->createElement('select', $prefix.'month', '', array_combine(range(1, 12), api_get_months_long())),
        $form->createElement('select', $prefix.'year', '', array($d_year => $d_year, $d_year + 1 => $d_year + 1)),
        $form->createElement('select', $prefix.'hour', '', array_combine(range(0, 23), range(0, 23))),
        $form->createElement('select', $prefix.'minute', '', $minute)
    );
    return $group_name;
}
Пример #11
0
function generate_settings_form($settings, $settings_by_access_list)
{
    global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list;
    $table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
    $form = new FormValidator('settings', 'post', 'settings.php?category=' . Security::remove_XSS($_GET['category']));
    $form->addElement('hidden', 'search_field', !empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null);
    $url_id = api_get_current_access_url_id();
    if (!empty($_configuration['multiple_access_urls']) && api_is_global_platform_admin() && $url_id == 1) {
        $group = array();
        $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
        $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
        $form->addGroup($group, 'buttons_in_action_right');
    }
    $default_values = array();
    $url_info = api_get_access_url($url_id);
    $i = 0;
    foreach ($settings as $row) {
        if (in_array($row['variable'], array_keys($settings_to_avoid))) {
            continue;
        }
        if (!empty($_configuration['multiple_access_urls'])) {
            if (api_is_global_platform_admin()) {
                if ($row['access_url_locked'] == 0) {
                    if ($url_id == 1) {
                        if ($row['access_url_changeable'] == '1') {
                            $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "0"  data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</a></div>');
                        } else {
                            $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "1" data_to_send = "' . $row['variable'] . '" href="javascript:void(0);">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</a></div>');
                        }
                    } else {
                        if ($row['access_url_changeable'] == '1') {
                            $form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')) . '</div>');
                        } else {
                            $form->addElement('html', '<div style="float: right;">' . Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')) . '</div>');
                        }
                    }
                }
            }
        }
        $hideme = array();
        $hide_element = false;
        if ($_configuration['access_url'] != 1) {
            if ($row['access_url_changeable'] == 0) {
                // We hide the element in other cases (checkbox, radiobutton) we 'freeze' the element.
                $hide_element = true;
                $hideme = array('disabled');
            } elseif ($url_info['active'] == 1) {
                // We show the elements.
                if (empty($row['variable'])) {
                    $row['variable'] = 0;
                }
                if (empty($row['subkey'])) {
                    $row['subkey'] = 0;
                }
                if (empty($row['category'])) {
                    $row['category'] = 0;
                }
                if (is_array($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']])) {
                    // We are sure that the other site have a selected value.
                    if ($settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'] != '') {
                        $row['selected_value'] = $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']]['selected_value'];
                    }
                }
                // There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site.
            }
        }
        switch ($row['type']) {
            case 'textfield':
                if (in_array($row['variable'], $convert_byte_to_mega_list)) {
                    $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('maxlength' => '8'));
                    $form->applyFilter($row['variable'], 'html_filter');
                    $default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1);
                } elseif ($row['variable'] == 'account_valid_duration') {
                    $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('maxlength' => '5'));
                    $form->applyFilter($row['variable'], 'html_filter');
                    $default_values[$row['variable']] = $row['selected_value'];
                    // For platform character set selection: Conversion of the textfield to a select box with valid values.
                } elseif ($row['variable'] == 'platform_charset') {
                    continue;
                } else {
                    $hideme['class'] = 'col-md-4';
                    $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme);
                    $form->applyFilter($row['variable'], 'html_filter');
                    $default_values[$row['variable']] = $row['selected_value'];
                }
                break;
            case 'textarea':
                if ($row['variable'] == 'header_extra_content') {
                    $file = api_get_path(SYS_PATH) . api_get_home_path() . 'header_extra_content.txt';
                    $value = '';
                    if (file_exists($file)) {
                        $value = file_get_contents($file);
                    }
                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme);
                    $default_values[$row['variable']] = $value;
                } elseif ($row['variable'] == 'footer_extra_content') {
                    $file = api_get_path(SYS_PATH) . api_get_home_path() . 'footer_extra_content.txt';
                    $value = '';
                    if (file_exists($file)) {
                        $value = file_get_contents($file);
                    }
                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme);
                    $default_values[$row['variable']] = $value;
                } else {
                    $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows' => '10'), $hideme);
                    $default_values[$row['variable']] = $row['selected_value'];
                }
                break;
            case 'radio':
                $values = api_get_settings_options($row['variable']);
                $group = array();
                if (is_array($values)) {
                    foreach ($values as $key => $value) {
                        $element =& $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
                        if ($hide_element) {
                            $element->freeze();
                        }
                        $group[] = $element;
                    }
                }
                $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '', false);
                $default_values[$row['variable']] = $row['selected_value'];
                break;
            case 'checkbox':
                // 1. We collect all the options of this variable.
                $sql = "SELECT * FROM {$table_settings_current}\n                        WHERE variable='" . $row['variable'] . "' AND access_url =  1";
                $result = Database::query($sql);
                $group = array();
                while ($rowkeys = Database::fetch_array($result)) {
                    // Profile tab option should be hidden when the social tool is enabled.
                    if (api_get_setting('social.allow_social_tool') == 'true') {
                        if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') {
                            continue;
                        }
                    }
                    // Hiding the gradebook option.
                    if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_gradebook') {
                        continue;
                    }
                    $element =& $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
                    if ($row['access_url_changeable'] == 1) {
                        // 2. We look into the DB if there is a setting for a specific access_url.
                        $access_url = $_configuration['access_url'];
                        if (empty($access_url)) {
                            $access_url = 1;
                        }
                        $sql = "SELECT selected_value FROM {$table_settings_current}\n                                WHERE\n                                    variable='" . $rowkeys['variable'] . "' AND\n                                    subkey='" . $rowkeys['subkey'] . "' AND\n                                    subkeytext='" . $rowkeys['subkeytext'] . "' AND\n                                    access_url =  {$access_url}";
                        $result_access = Database::query($sql);
                        $row_access = Database::fetch_array($result_access);
                        if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) {
                            $element->setChecked(true);
                        }
                    } else {
                        if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) {
                            $element->setChecked(true);
                        }
                    }
                    if ($hide_element) {
                        $element->freeze();
                    }
                    $group[] = $element;
                }
                $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '');
                break;
            case 'link':
                $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue') . ' : ' . $row['selected_value'], $hideme);
                break;
            case 'select':
                /*
                 * To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
                 * The functions being called must be added to the file settings.lib.php.
                 */
                $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_' . $row['variable']), $hideme);
                $default_values[$row['variable']] = $row['selected_value'];
                break;
            case 'custom':
                break;
        }
        switch ($row['variable']) {
            case 'pdf_export_watermark_enable':
                $url = PDF::get_watermark(null);
                if ($url != false) {
                    $delete_url = '<a href="?delete_watermark">' . get_lang('DelImage') . ' ' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>';
                    $form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="' . $url . '" style="margin-bottom:10px;" />' . $delete_url . '</div>');
                }
                $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
                $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
                $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
                break;
            case 'timezone_value':
                $timezone = $row['selected_value'];
                if (empty($timezone)) {
                    $timezone = _api_get_timezone();
                }
                $form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
                break;
        }
    }
    // end for
    if (!empty($settings)) {
        $form->setDefaults($default_values);
    }
    $form->addHtml('<div class="bottom_actions">');
    $form->addButtonSave(get_lang('SaveSettings'));
    $form->addHtml('</div>');
    return $form;
}
Пример #12
0
// Build the form
$form = new FormValidator('update_course');
$form->addElement('header', get_lang('Course') . '  #' . $course_info['real_id'] . ' ' . $course_code);
$form->addElement('hidden', 'code', $course_code);
//title
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$element = $form->addElement('text', 'real_code', array(get_lang('CourseCode'), get_lang('ThisValueCantBeChanged')));
$element->freeze();
// Visual code
$form->add_textfield('visual_code', array(get_lang('VisualCode'), get_lang('OnlyLettersAndNumbers'), get_lang('ThisValueIsUsedInTheCourseURL')), true, array('class' => 'span4'));
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$group = array($form->createElement('select', 'platform_teachers', '', $teachers, ' id="platform_teachers" multiple=multiple size="4" style="width:300px;"'), $form->createElement('select', 'course_teachers', '', $course_teachers, ' id="course_teachers" multiple=multiple size="4" style="width:300px;"'));
$element_template = <<<EOT
\t<div class="control-group">
\t\t<label>
\t\t\t<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
\t\t</label>
\t\t<div class="controls">
\t\t\t<table cellpadding="0" cellspacing="0">
\t\t\t\t<tr>
\t\t\t\t\t<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error -->\t<td>{element}</td>
\t\t\t\t</tr>
\t\t\t</table>
\t\t</div>
\t</div>
EOT;
$renderer = $form->defaultRenderer();
Пример #13
0
                if (count($certificateStudent['certificates']) > 0) {
                    $certificateStudents[] = $certificateStudent;
                }
            }
        }
    }
}
/* View */
$template = new Template(get_lang('GradebookListOfStudentsCertificates'));
if (Session::has('reportErrorMessage')) {
    $template->assign('errorMessage', Session::read('reportErrorMessage'));
}
$searchBySessionCourseDateForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php');
$searchBySessionCourseDateForm->addSelect('session', get_lang('Sessions'), $sessions, ['id' => 'session']);
$searchBySessionCourseDateForm->addSelect('course', get_lang('Courses'), $courses, ['id' => 'course']);
$searchBySessionCourseDateForm->addGroup([$searchBySessionCourseDateForm->createElement('select', 'month', null, $months, ['id' => 'month']), $searchBySessionCourseDateForm->createElement('text', 'year', null, ['id' => 'year', 'placeholder' => get_lang('Year')])], null, get_lang('Date'));
$searchBySessionCourseDateForm->addButtonSearch();
$searchBySessionCourseDateForm->setDefaults(['session' => $selectedSession, 'course' => $selectedCourse, 'month' => $selectedMonth, 'year' => $selectedYear]);
if (api_is_student_boss()) {
    foreach ($userList as $studentId) {
        $students[$studentId] = api_get_user_info($studentId)['complete_name_with_username'];
    }
    $searchByStudentForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php');
    $searchByStudentForm->addSelect('student', get_lang('Students'), $students, ['id' => 'student']);
    $searchByStudentForm->addButtonSearch();
    $searchByStudentForm->setDefaults(['student' => $selectedStudent]);
    $template->assign('searchByStudentForm', $searchByStudentForm->returnForm());
}
$template->assign('searchBySessionCourseDateForm', $searchBySessionCourseDateForm->returnForm());
$template->assign('sessions', $sessions);
$template->assign('courses', $courses);
Пример #14
0
    if (!api_is_platform_admin()) {
        $sql .= ' AND cu.status=1 ';
    }
    $sql .= ' AND target_course_code IS NULL AND cu.user_id = ' . $user_info['user_id'] . ' AND c.code != ' . "'" . $course_info['sysCode'] . "'" . ' ORDER BY title ASC';
    $res = Database::query($sql);
    if (Database::num_rows($res) == 0) {
        Display::display_normal_message(get_lang('NoDestinationCoursesAvailable'));
    } else {
        $options = array();
        while ($obj = Database::fetch_object($res)) {
            $options[$obj->code] = $obj->title;
        }
        $form = new FormValidator('copy_course', 'post', 'copy_course.php?' . api_get_cidreq());
        $form->addElement('header', '');
        $form->addElement('select', 'destination_course', get_lang('SelectDestinationCourse'), $options);
        $group = array();
        $group[] = $form->createElement('radio', 'copy_option', null, get_lang('FullCopy'), 'full_copy');
        $group[] = $form->createElement('radio', 'copy_option', null, get_lang('LetMeSelectItems'), 'select_items');
        $form->addGroup($group, '', get_lang('SelectOptionForBackup'));
        $group = array();
        $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameSkip'), FILE_SKIP);
        $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameRename'), FILE_RENAME);
        $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameOverwrite'), FILE_OVERWRITE);
        $form->addGroup($group, '', get_lang('SameFilename'));
        $form->add_progress_bar();
        $form->addElement('style_submit_button', 'submit', get_lang('CopyCourse'), 'class="save"');
        $form->setDefaults(array('copy_option' => 'select_items', 'same_file_name_option' => FILE_OVERWRITE));
        $form->display();
    }
}
Display::display_footer();
Пример #15
0
     $token = md5(uniqid(rand(), TRUE));
     $_SESSION['thematic_advance_token'] = $token;
 }
 // display form
 $form = new FormValidator('thematic_advance', 'POST', 'index.php?action=thematic_advance_list&thematic_id=' . $thematic_id . '&' . api_get_cidreq(), '', 'style="width: 100%;"');
 $form->addElement('header', $header_form);
 $form->addElement('hidden', 'thematic_advance_token', $token);
 $form->addElement('hidden', 'action', $action);
 if (!empty($thematic_advance_id)) {
     $form->addElement('hidden', 'thematic_advance_id', $thematic_advance_id);
 }
 if (!empty($thematic_id)) {
     $form->addElement('hidden', 'thematic_id', $thematic_id);
 }
 $radios = array();
 $radios[] = $form->createElement('radio', 'start_date_type', null, get_lang('StartDateFromAnAttendance'), '1', array('onclick' => 'check_per_attendance(this)', 'id' => 'from_attendance'));
 $radios[] = $form->createElement('radio', 'start_date_type', null, get_lang('StartDateCustom'), '2', array('onclick' => 'check_per_custom_date(this)', 'id' => 'custom_date'));
 $form->addGroup($radios, null, get_lang('StartDateOptions'));
 if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
     $form->addElement('html', '<div id="div_custom_datetime" style="display:block">');
 } else {
     $form->addElement('html', '<div id="div_custom_datetime" style="display:none">');
 }
 $form->addElement('datepicker', 'custom_start_date', get_lang('StartDate'), array('form_name' => 'thematic_advance'));
 $form->addElement('html', '</div>');
 if (isset($thematic_advance_data['attendance_id']) && $thematic_advance_data['attendance_id'] == 0) {
     $form->addElement('html', '<div id="div_datetime_by_attendance" style="display:none">');
 } else {
     $form->addElement('html', '<div id="div_datetime_by_attendance" style="display:block">');
 }
 if (count($attendance_select) > 1) {
Пример #16
0
 if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager::get_group_list()) > 0) {
     $base_group_options = array();
     $groups = GroupManager::get_group_list();
     foreach ($groups as $index => $group) {
         $number_of_students = GroupManager::number_of_students($group['id']);
         if ($number_of_students > 0) {
             $base_group_options[$group['id']] = $group['name'] . ' (' . $number_of_students . ' ' . get_lang('Users') . ')';
         }
     }
     if (count($base_group_options) > 0) {
         $create_subgroups_form = new FormValidator('create_subgroups');
         $create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
         $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
         $create_subgroups_form->addElement('hidden', 'action');
         $group_el = array();
         $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
         $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
         $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
         $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
         $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
         $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
         $defaults = array();
         $defaults['action'] = 'create_subgroups';
         $create_subgroups_form->setDefaults($defaults);
         $create_subgroups_form->display();
     }
 }
 /*
  * Show form to generate groups from classes subscribed to the course
  */
 $options['where'] = array(" usergroup.course_id = ? " => api_get_real_course_id());
Пример #17
0
 /**
  * @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', 'field_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', 'class' => 'chzn-select', 'data-placeholder' => get_lang('Select')));
     $form->addElement('label', get_lang('Example'), '<div id="example">-</div>');
     $form->addElement('text', 'field_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_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', 'field_default_value', get_lang('FieldDefaultValue'), array('id' => 'field_default_value', 'class' => 'span5'));
     $group = array();
     $group[] = $form->createElement('radio', 'field_visible', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_visible', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('Visible'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'field_changeable', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_changeable', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldChangeability'), '', false);
     $group = array();
     $group[] = $form->createElement('radio', 'field_filter', null, get_lang('Yes'), 1);
     $group[] = $form->createElement('radio', 'field_filter', null, get_lang('No'), 0);
     $form->addGroup($group, '', get_lang('FieldFilter'), '', false);
     $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->addElement('button', 'submit', get_lang('Modify'), 'class="save"');
     } else {
         $defaults['field_visible'] = 0;
         $defaults['field_changeable'] = 0;
         $defaults['field_filter'] = 0;
         $form->addElement('button', 'submit', get_lang('Add'), 'class="save"');
     }
     /*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('field_display_text', get_lang('ThisFieldIsRequired'), 'required');
     //$form->addRule('field_variable', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('field_type', get_lang('ThisFieldIsRequired'), 'required');
     return $form;
 }
Пример #18
0
		}

		//$form->addElement('html', "timestart:".$time_start."-".Rsys :: mysql_datetime_to_timestamp($res_start_at));
		$form->addElement('html', "<p>".str_replace('#start_end',$start_end,str_replace('#from_till', $from_till,str_replace('#name#', "<b>".$item[3]."</b>",str_replace('#start#', "<b>".$reservation[0][5]."</b>", str_replace('#end#', "<b>".$reservation[0][6]."</b>", get_lang("SubscribeTimePickerInformation"))))))." </p>");
		$form->add_timewindow('startpicker', 'endpicker', get_lang('StartDate'), get_lang('EndDate'));
		$form->addElement('hidden', 'min', $reservation[0][12]);
		$form->addElement('hidden', 'max', $reservation[0][13]);
		$datum = $_GET['timestart'];
		$defaultvalues['startpicker'] = Rsys :: timestamp_to_datetime($datum);
		//$defaultvalues['endpicker'] = Rsys :: timestamp_to_datetime($datum +900);
		$defaultvalues['endpicker'] = Rsys :: timestamp_to_datetime($datum +($min_timepicker*60));
		$form->setDefaults($defaultvalues);
	} else {
		$form->addElement('html', "<p> * ".str_replace('#name#', "<b>".$item[3]."</b>",str_replace('#start#', "<b>".$reservation[0][5]."</b>", str_replace('#end#', "<b>".$reservation[0][6]."</b>", get_lang('SubscribeInformation'))))." *</p>");
	}
	$buttons[] = $form->createElement('submit', 'submit', get_lang('Ok'));
	$buttons[] = $form->createElement('button', 'cancel', get_lang('Cancel'), array ('onclick' => 'location.href="reservation.php?cat='.$item[1].'&item='.$item[0].'"'));
	$form->addGroup($buttons, null, '', '', false);

	$buffer = ob_get_contents();
	ob_end_clean();

	if ($form->validate()) {
		$values = $form->exportValues();
		if ($values['timepicker'] == 0) {
			$result = Rsys :: add_subscription($_GET['rid'], api_get_user_id(),$values['accepted']);
			switch ($result) {
				case 0 :
					Display :: display_normal_message(Rsys :: get_return_msg2(get_lang('ReservationAdded'), "javascript:history.go(-2)", get_lang('BookingView')),false);
					break;
				case 1 :
Пример #19
0
 /**
  * @param FormValidator $form
  */
 public function add_course_settings_form($form)
 {
     $pluginList = $this->getInstalledPluginListObject();
     /** @var Plugin $obj */
     foreach ($pluginList as $obj) {
         $plugin_name = $obj->get_name();
         $pluginTitle = $obj->get_title();
         if (!empty($obj->course_settings)) {
             if (is_file(api_get_path(SYS_CODE_PATH) . 'img/icons/' . ICON_SIZE_SMALL . '/' . $plugin_name . '.png')) {
                 $icon = Display::return_icon($plugin_name . '.png', Security::remove_XSS($pluginTitle), '', ICON_SIZE_SMALL);
             } else {
                 $icon = Display::return_icon('plugins.png', Security::remove_XSS($pluginTitle), '', ICON_SIZE_SMALL);
             }
             $form->addElement('html', '<div><h3>' . $icon . ' ' . Security::remove_XSS($pluginTitle) . '</h3><div>');
             $groups = array();
             foreach ($obj->course_settings as $setting) {
                 if ($setting['type'] != 'checkbox') {
                     $form->addElement($setting['type'], $setting['name'], $obj->get_lang($setting['name']));
                 } else {
                     $element =& $form->createElement($setting['type'], $setting['name'], '', $obj->get_lang($setting['name']));
                     if (isset($setting['init_value']) && $setting['init_value'] == 1) {
                         $element->setChecked(true);
                     }
                     if (isset($setting['group'])) {
                         $groups[$setting['group']][] = $element;
                     }
                 }
             }
             foreach ($groups as $k => $v) {
                 $form->addGroup($groups[$k], $k, array($obj->get_lang($k)));
             }
             $form->addButtonSave(get_lang('SaveSettings'));
             $form->addElement('html', '</div></div>');
         }
     }
 }
Пример #20
0
 /**
  * @param FormValidator $form
  *
  * @return array
  */
 public static function setForm(FormValidator &$form, $sessionId = 0)
 {
     $categoriesList = SessionManager::get_all_session_category();
     $userInfo = api_get_user_info();
     $categoriesOptions = array('0' => get_lang('None'));
     if ($categoriesList != false) {
         foreach ($categoriesList as $categoryItem) {
             $categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
         }
     }
     // Database Table Definitions
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $form->addElement('text', 'name', get_lang('SessionName'), array('maxlength' => 50));
     $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');
     if (!api_is_platform_admin() && api_is_teacher()) {
         $form->addElement('select', 'coach_username', get_lang('CoachName'), [api_get_user_id() => $userInfo['complete_name']], array('id' => 'coach_username', 'class' => 'chzn-select', 'style' => 'width:370px;'));
     } else {
         $sql = "SELECT COUNT(1) FROM {$tbl_user} WHERE status = 1";
         $rs = Database::query($sql);
         $countUsers = Database::result($rs, 0, 0);
         if (intval($countUsers) < 50) {
             $orderClause = "ORDER BY ";
             $orderClause .= api_sort_by_first_name() ? "firstname, lastname, username" : "lastname, firstname, username";
             $sql = "SELECT user_id, lastname, firstname, username\n                        FROM {$tbl_user}\n                        WHERE status = '1' " . $orderClause;
             if (api_is_multiple_url_enabled()) {
                 $userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
                 $accessUrlId = api_get_current_access_url_id();
                 if ($accessUrlId != -1) {
                     $sql = "SELECT user.user_id, username, lastname, firstname\n                        FROM {$tbl_user} user\n                        INNER JOIN {$userRelAccessUrlTable} url_user\n                        ON (url_user.user_id = user.user_id)\n                        WHERE\n                            access_url_id = {$accessUrlId} AND\n                            status = 1 " . $orderClause;
                 }
             }
             $result = Database::query($sql);
             $coachesList = Database::store_result($result);
             $coachesOptions = array();
             foreach ($coachesList as $coachItem) {
                 $coachesOptions[$coachItem['user_id']] = api_get_person_name($coachItem['firstname'], $coachItem['lastname']) . ' (' . $coachItem['username'] . ')';
             }
             $form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions);
         } else {
             $form->addElement('select_ajax', 'coach_username', get_lang('CoachName'), null, ['url' => api_get_path(WEB_AJAX_PATH) . 'session.ajax.php?a=search_general_coach', 'width' => '100%']);
         }
     }
     $form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required');
     $form->addHtml('<div id="ajax_list_coachs"></div>');
     $form->addButtonAdvancedSettings('advanced_params');
     $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
     $form->addSelect('session_category', get_lang('SessionCategory'), $categoriesOptions, array('id' => 'session_category', 'class' => 'chzn-select', 'style' => 'width:370px;'));
     $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Minimal'));
     $form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'));
     $visibilityGroup = array();
     $visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'), SESSION_VISIBLE => get_lang('SessionAccessible'), SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))));
     $form->addGroup($visibilityGroup, 'visibility_group', get_lang('SessionVisibility'), null, false);
     $options = [0 => get_lang('ByDuration'), 1 => get_lang('ByDates')];
     $form->addSelect('access', get_lang('Access'), $options, array('onchange' => 'accessSwitcher()', 'id' => 'access'));
     $form->addElement('html', '<div id="duration" style="display:none">');
     $form->addElement('number', 'duration', array(get_lang('SessionDurationTitle'), get_lang('SessionDurationDescription')), array('maxlength' => 50));
     $form->addElement('html', '</div>');
     $form->addElement('html', '<div id="date_fields" style="display:none">');
     // Dates
     $form->addDateTimePicker('access_start_date', array(get_lang('SessionStartDate'), get_lang('SessionStartDateComment')), array('id' => 'access_start_date'));
     $form->addDateTimePicker('access_end_date', array(get_lang('SessionEndDate'), get_lang('SessionEndDateComment')), array('id' => 'access_end_date'));
     $form->addRule(array('access_start_date', 'access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addDateTimePicker('display_start_date', array(get_lang('SessionDisplayStartDate'), get_lang('SessionDisplayStartDateComment')), array('id' => 'display_start_date'));
     $form->addDateTimePicker('display_end_date', array(get_lang('SessionDisplayEndDate'), get_lang('SessionDisplayEndDateComment')), array('id' => 'display_end_date'));
     $form->addRule(array('display_start_date', 'display_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addDateTimePicker('coach_access_start_date', array(get_lang('SessionCoachStartDate'), get_lang('SessionCoachStartDateComment')), array('id' => 'coach_access_start_date'));
     $form->addDateTimePicker('coach_access_end_date', array(get_lang('SessionCoachEndDate'), get_lang('SessionCoachEndDateComment')), array('id' => 'coach_access_end_date'));
     $form->addRule(array('coach_access_start_date', 'coach_access_end_date'), get_lang('StartDateMustBeBeforeTheEndDate'), 'compare_datetime_text', '< allow_empty');
     $form->addElement('html', '</div>');
     $form->addCheckBox('send_subscription_notification', [get_lang('SendSubscriptionNotification'), get_lang('SendAnEmailWhenAUserBeingSubscribed')]);
     // Extra fields
     $extra_field = new ExtraField('session');
     $extra = $extra_field->addElements($form, $sessionId);
     $form->addElement('html', '</div>');
     $js = $extra['jquery_ready_content'];
     return ['js' => $js];
 }
Пример #21
0
    /**
     * Uses new functions (php 5.2) for displaying real upload progress.
     * @param string $upload_id							The value of the field UPLOAD_IDENTIFIER, the second parameter (XXX) of the $form->addElement('file', XXX) sentence
     * @param string $element_after						The first element of the form (to place at first UPLOAD_IDENTIFIER)
     * @param int $delay (optional)						The frequency of the xajax call
     * @param bool $wait_after_upload (optional)
     */
    public function add_real_progress_bar($upload_id, $element_after, $delay = 2, $wait_after_upload = false)
    {
        if (!function_exists('uploadprogress_get_info')) {
            $this->add_progress_bar($delay);
            return;
        }
        $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php');
        $xajax_upload->registerFunction('updateProgress');
        // IMPORTANT : must be the first element of the form
        $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after);
        $this->addElement('html', '<br />');
        // Add div-element where the progress bar is to be displayed
        $this->addElement('html', '
                		<div id="dynamic_div_container" style="display:none">
                			<div id="dynamic_div_label">' . get_lang('UploadFile') . '</div>
                			<div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . api_get_path(WEB_IMG_PATH) . 'real_upload_frame.gif);">
                				<div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . api_get_path(WEB_IMG_PATH) . 'real_upload_step.gif);background-repeat:repeat-x;background-position:center;"></div>
                			</div>
                		</div>');
        if ($wait_after_upload) {
            $this->addElement('html', '
			<div id="dynamic_div_waiter_container" style="display:none">
				<div id="dynamic_div_waiter_label">
					' . get_lang('SlideshowConversion') . '
				</div>
				<div id="dynamic_div_waiter_frame">
					<img src="' . api_get_path(WEB_IMG_PATH) . 'real_upload_frame.gif" />
				</div>
			</div>
		');
        }
        // Get the xajax code
        $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax'));
        // Get the upload code
        $this->addElement('html', api_get_js('js/upload.js'));
        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . abs(intval($delay)) * 1000 . ');</script>');
        if (!$wait_after_upload) {
            $wait_after_upload = 0;
        }
        // Add the upload event
        $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\"");
    }
Пример #22
0
/**
 * This function displays the form that is used to add a forum category.
 *
 * @param array $inputvalues
 * @param int $lp_id
 * @return void HTML
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Juan Carlos Raña Trabado (return to lp_id)
 *
 * @version may 2011, Chamilo 1.8.8
 */
function show_add_forum_form($inputvalues = array(), $lp_id)
{
    $_course = api_get_course_info();
    // Initialize the object.
    $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq());
    // The header for the form
    if (!empty($inputvalues)) {
        $form_title = get_lang('EditForum');
    } else {
        $form_title = get_lang('AddForum');
    }
    $session_header = Session::read('session_name');
    $form->addElement('header', $form_title . $session_header);
    // We have a hidden field if we are editing.
    if (!empty($inputvalues) && is_array($inputvalues)) {
        $my_forum_id = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
        $form->addElement('hidden', 'forum_id', $my_forum_id);
    }
    $lp_id = intval($lp_id);
    // hidden field if from learning path
    $form->addElement('hidden', 'lp_id', $lp_id);
    // The title of the forum
    $form->addElement('text', 'forum_title', get_lang('Title'), array('autofocus'));
    // The comment of the forum.
    $form->addHtmlEditor('forum_comment', get_lang('Description'), null, null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200'));
    // Dropdown list: Forum categories
    $forum_categories = get_forum_categories();
    foreach ($forum_categories as $key => $value) {
        $forum_categories_titles[$value['cat_id']] = $value['cat_title'];
    }
    $form->addElement('select', 'forum_category', get_lang('InForumCategory'), $forum_categories_titles);
    $form->applyFilter('forum_category', 'html_filter');
    if ($_course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
        // This is for horizontal
        $group = array();
        $group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1);
        $group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('No'), 0);
        $form->addGroup($group, 'allow_anonymous_group', get_lang('AllowAnonymousPosts'), ' ');
    }
    $form->addButtonAdvancedSettings('advanced_params');
    $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
    $group = array();
    $group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('No'), 0);
    $form->addGroup($group, 'students_can_edit_group', get_lang('StudentsCanEdit'), ' ');
    $group = array();
    $group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Approval'), 1);
    $group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Direct'), 0);
    $group = array();
    $group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('No'), 0);
    $group = array();
    $group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('No'), 0);
    $form->addGroup($group, 'allow_new_threads_group', get_lang('AllowNewThreads'), ' ');
    $group = array();
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
    $form->addGroup($group, 'default_view_type_group', get_lang('DefaultViewType'), ' ');
    // Drop down list: Groups
    $groups = GroupManager::get_group_list();
    $groups_titles[0] = get_lang('NotAGroupForum');
    foreach ($groups as $key => $value) {
        $groups_titles[$value['id']] = $value['name'];
    }
    $form->addElement('select', 'group_forum', get_lang('ForGroup'), $groups_titles);
    // Public or private group forum
    $group = array();
    $group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
    $group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
    $form->addGroup($group, 'public_private_group_forum_group', get_lang('PublicPrivateGroupForum'), '');
    // Forum image
    $form->add_progress_bar();
    if (isset($inputvalues['forum_image']) && strlen($inputvalues['forum_image']) > 0) {
        $image_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/forum/images/' . $inputvalues['forum_image'];
        $image_size = api_getimagesize($image_path);
        $img_attributes = '';
        if (!empty($image_size)) {
            if ($image_size['width'] > 100 || $image_size['height'] > 100) {
                //limit display width and height to 100px
                $img_attributes = 'width="100" height="100"';
            }
            $show_preview_image = '<img src="' . $image_path . '" ' . $img_attributes . '>';
            $form->addElement('label', get_lang('PreviewImage'), $show_preview_image);
            $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
        }
    }
    $forum_image = isset($inputvalues['forum_image']) ? $inputvalues['forum_image'] : '';
    $form->addElement('file', 'picture', $forum_image != '' ? get_lang('UpdateImage') : get_lang('AddImage'));
    $form->addRule('picture', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif'));
    $form->addElement('html', '</div>');
    // The OK button
    if (isset($_GET['id']) && $_GET['action'] == 'edit') {
        $form->addButtonUpdate(get_lang('ModifyForum'), 'SubmitForum');
    } else {
        $form->addButtonCreate(get_lang('CreateForum'), 'SubmitForum');
    }
    // setting the rules
    $form->addRule('forum_title', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('forum_category', get_lang('ThisFieldIsRequired'), 'required');
    $defaultSettingAllowNewThreads = api_get_default_tool_setting('forum', 'allow_new_threads', 0);
    // Settings the defaults
    if (empty($inputvalues) || !is_array($inputvalues)) {
        $defaults['allow_anonymous_group']['allow_anonymous'] = 0;
        $defaults['students_can_edit_group']['students_can_edit'] = 0;
        $defaults['approval_direct_group']['approval_direct'] = 0;
        $defaults['allow_attachments_group']['allow_attachments'] = 1;
        $defaults['allow_new_threads_group']['allow_new_threads'] = $defaultSettingAllowNewThreads;
        $defaults['default_view_type_group']['default_view_type'] = api_get_setting('forum.default_forum_view');
        $defaults['public_private_group_forum_group']['public_private_group_forum'] = 'public';
        if (isset($_GET['forumcategory'])) {
            $defaults['forum_category'] = Security::remove_XSS($_GET['forumcategory']);
        }
    } else {
        // the default values when editing = the data in the table
        $defaults['forum_id'] = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
        $defaults['forum_title'] = prepare4display(isset($inputvalues['forum_title']) ? $inputvalues['forum_title'] : null);
        $defaults['forum_comment'] = prepare4display(isset($inputvalues['forum_comment']) ? $inputvalues['forum_comment'] : null);
        $defaults['forum_category'] = isset($inputvalues['forum_category']) ? $inputvalues['forum_category'] : null;
        $defaults['allow_anonymous_group']['allow_anonymous'] = isset($inputvalues['allow_anonymous']) ? $inputvalues['allow_anonymous'] : null;
        $defaults['students_can_edit_group']['students_can_edit'] = isset($inputvalues['allow_edit']) ? $inputvalues['allow_edit'] : null;
        $defaults['approval_direct_group']['approval_direct'] = isset($inputvalues['approval_direct_post']) ? $inputvalues['approval_direct_post'] : null;
        $defaults['allow_attachments_group']['allow_attachments'] = isset($inputvalues['allow_attachments']) ? $inputvalues['allow_attachments'] : null;
        $defaults['allow_new_threads_group']['allow_new_threads'] = isset($inputvalues['allow_new_threads']) ? $inputvalues['allow_new_threads'] : $defaultSettingAllowNewThreads;
        $defaults['default_view_type_group']['default_view_type'] = isset($inputvalues['default_view']) ? $inputvalues['default_view'] : null;
        $defaults['public_private_group_forum_group']['public_private_group_forum'] = isset($inputvalues['forum_group_public_private']) ? $inputvalues['forum_group_public_private'] : null;
        $defaults['group_forum'] = isset($inputvalues['forum_of_group']) ? $inputvalues['forum_of_group'] : null;
    }
    $form->setDefaults($defaults);
    // Validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $return_message = store_forum($values);
            Display::display_confirmation_message($return_message);
        }
        Security::clear_token();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
Пример #23
0
     echo '<div class="actions">';
     echo Display::url(Display::return_icon('folder_up.png', get_lang("Back"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . Security::remove_XSS($category));
     echo '</div>';
     $form_title = $action == 'add' ? get_lang('AddACategory') : get_lang('EditNode');
     if (!empty($category)) {
         $form_title .= ' ' . get_lang('Into') . ' ' . Security::remove_XSS($category);
     }
     $url = api_get_self() . '?action=' . Security::remove_XSS($action) . '&category=' . Security::remove_XSS($category) . '&id=' . Security::remove_XSS($categoryId);
     $form = new FormValidator('course_category', 'post', $url);
     $form->addElement('header', '', $form_title);
     $form->addElement('hidden', 'formSent', 1);
     $form->addElement('text', 'code', get_lang("CategoryCode"));
     $form->addElement('text', 'name', get_lang("CategoryName"));
     $form->addRule('name', get_lang('PleaseEnterCategoryInfo'), 'required');
     $form->addRule('code', get_lang('PleaseEnterCategoryInfo'), 'required');
     $group = array($form->createElement('radio', 'auth_course_child', get_lang("AllowCoursesInCategory"), get_lang('Yes'), 'TRUE'), $form->createElement('radio', 'auth_course_child', null, get_lang('No'), 'FALSE'));
     $form->addGroup($group, null, get_lang("AllowCoursesInCategory"));
     if (!empty($categoryInfo)) {
         $class = "save";
         $text = get_lang('Save');
         $form->setDefaults($categoryInfo);
         $form->addButtonSave($text);
     } else {
         $class = "add";
         $text = get_lang('AddCategory');
         $form->setDefaults(array('auth_course_child' => 'TRUE'));
         $form->addButtonCreate($text);
     }
     $form->display();
 } elseif (api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
     // If multiple URLs and not main URL, prevent edition and inform user
Пример #24
0
$form->addElement('header', get_lang('AdvancedSearch'));
$form->addText('keyword_firstname', get_lang('FirstName'), false);
$form->addText('keyword_lastname', get_lang('LastName'), false);
$form->addText('keyword_username', get_lang('LoginName'), false);
$form->addText('keyword_email', get_lang('Email'), false);
$form->addText('keyword_officialcode', get_lang('OfficialCode'), false);
$status_options = array();
$status_options['%'] = get_lang('All');
$status_options[STUDENT] = get_lang('Student');
$status_options[COURSEMANAGER] = get_lang('Teacher');
$status_options[DRH] = get_lang('Drh');
$status_options[SESSIONADMIN] = get_lang('SessionsAdmin');
$status_options[PLATFORM_ADMIN] = get_lang('Administrator');
$form->addElement('select', 'keyword_status', get_lang('Profile'), $status_options);
$active_group = array();
$active_group[] = $form->createElement('checkbox', 'keyword_active', '', get_lang('Active'));
$active_group[] = $form->createElement('checkbox', 'keyword_inactive', '', get_lang('Inactive'));
$form->addGroup($active_group, '', get_lang('ActiveAccount'), '<br/>', false);
$form->addElement('checkbox', 'check_easy_passwords', null, get_lang('CheckEasyPasswords'));
$form->addButtonSearch(get_lang('SearchUsers'));
$defaults = array();
$defaults['keyword_active'] = 1;
$defaults['keyword_inactive'] = 1;
$form->setDefaults($defaults);
$form->addElement('html', '</div>');
$form = $form->returnForm();
$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, 'width="18px"');
$table->set_header(1, get_lang('Photo'), false);
$table->set_header(2, get_lang('OfficialCode'));
Пример #25
0
$usernameInput = $form->addElement('text', 'username', get_lang('LoginName'));
$usernameInput->freeze();
// Password
$group = array();
$auth_sources = 0;
//make available wider as we need it in case of form reset (see below)
/*if (count($extAuthSource) > 0) {
	$group[] =& $form->createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2);
	$auth_sources = array();
	foreach ($extAuthSource as $key => $info) {
		$auth_sources[$key] = $key;
	}
	$group[] =& $form->createElement('select', 'auth_source', null, $auth_sources);
	$group[] =& $form->createElement('static', '', '', '<br />');
}*/
$group[] =& $form->createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword') . '<br />', 1);
$group[] =& $form->createElement('radio', 'password_auto', 'id="radio_user_password"', null, 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
Пример #26
0
        Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'warning'));
    } else {
        Display::addFlash(Display::return_message($warning_message));
        header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?sec_token=' . $tok);
        exit;
    }
}
Display::display_header($tool_name);
if (!empty($error_message)) {
    Display::display_error_message($error_message);
}
$form = new FormValidator('user_import', 'post', 'user_import.php');
$form->addElement('header', '', $tool_name);
$form->addElement('hidden', 'formSent');
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$group = array($form->createElement('radio', 'file_type', '', 'CSV (<a href="example.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'), $form->createElement('radio', 'file_type', null, 'XML (<a href="example.xml" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml'));
$form->addGroup($group, '', get_lang('FileType'), '<br/>');
$group = array($form->createElement('radio', 'sendMail', '', get_lang('Yes'), 1), $form->createElement('radio', 'sendMail', null, get_lang('No'), 0));
$form->addGroup($group, '', get_lang('SendMailToUsers'), '<br/>');
$form->addElement('checkbox', 'check_unique_email', '', get_lang('CheckUniqueEmail'));
$form->addButtonImport(get_lang('Import'));
$defaults['formSent'] = 1;
$defaults['sendMail'] = 0;
$defaults['file_type'] = 'csv';
$form->setDefaults($defaults);
$form->display();
$list = array();
$list_reponse = array();
$result_xml = '';
$i = 0;
$count_fields = count($extra_fields);
Пример #27
0
}
$form->addElement('html', '<div class="sectiontitle" >' . $nameTools);
$form->addElement('html', '</div>');
// If categories allowed, show title & description field
if (api_get_setting('allow_group_categories') == 'true') {
    $form->add_textfield('title', get_lang('Title'));
    $form->addElement('textarea', 'description', get_lang('Description'), array('cols' => 50, 'rows' => 6));
} else {
    $form->addElement('hidden', 'title');
    $form->addElement('hidden', 'description');
}
// Action
$form->addElement('hidden', 'action');
// Groups per user
$group = array();
$group[] = $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartBeforeNumber'));
$possible_values = array();
for ($i = 1; $i <= 10; $i++) {
    $possible_values[$i] = $i;
}
$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
$group[] = $form->createElement('select', 'groups_per_user', null, $possible_values);
$group[] = $form->createElement('static', null, null, get_lang('QtyOfUserCanSubscribe_PartAfterNumber'));
$form->addGroup($group, 'limit_group', get_lang('GroupLimit'), ' ', false);
$form->addRule('limit_group', get_lang('MaxGroupsPerUserInvalid'), 'callback', 'check_groups_per_user');
$form->addElement('html', '<br /><br /><div class="sectiontitle" >' . get_lang('DefaultSettingsForNewGroups'));
$form->addElement('html', '</div>');
// Members per group
$form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), GroupManager::MEMBER_PER_GROUP_NO_LIMIT);
$group = array();
$group[] = $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1, array('id' => 'max_member_selected'));
Пример #28
0
$nb_ext_auth_source_added = 0;
if (isset($extAuthSource) && !empty($extAuthSource) && count($extAuthSource) > 0) {
    $auth_sources = array();
    foreach ($extAuthSource as $key => $info) {
        // @todo : make uniform external authentification configuration (ex : cas and external_login ldap)
        // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
        // extAuthSource always on for CAS even if not activated
        // same action for file user_add.php
        if ($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true' || $key != CAS_AUTH_SOURCE) {
            $auth_sources[$key] = $key;
            $nb_ext_auth_source_added++;
        }
    }
    if ($nb_ext_auth_source_added > 0) {
        // @todo check the radio button for external authentification and select the external authentification in the menu
        $group[] = $form->createElement('radio', 'reset_password', null, get_lang('ExternalAuthentication') . ' ', 3);
        $group[] = $form->createElement('select', 'auth_source', null, $auth_sources);
        $group[] = $form->createElement('static', '', '', '<br />');
        $form->addGroup($group, 'password', null, '', false);
    }
}
$form->addElement('radio', 'reset_password', null, get_lang('AutoGeneratePassword'), 1);
$group = array();
$group[] = $form->createElement('radio', 'reset_password', null, null, 2);
$group[] = $form->createElement('password', 'password', null, array('onkeydown' => 'javascript: password_switch_radio_button();'));
$form->addGroup($group, 'password', null, '', false);
// Status
$status = array();
$status[COURSEMANAGER] = get_lang('Teacher');
$status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
Пример #29
0
    global $filepath;
    $filename = addslashes(trim($filename));
    $filename = Security::remove_XSS($filename);
    $filename = api_replace_dangerous_char($filename);
    $filename = FileManager::disable_dangerous_file($filename);
    return !file_exists($filepath . $filename . '.html');
}
// Add group to the form
if ($is_certificate_mode) {
    $form->addElement('text', 'title', get_lang('CertificateName'), array('id' => 'document_title'));
} else {
    $form->addElement('text', 'title', get_lang('Title'), array('id' => 'document_title'));
}
// Show read-only box only in groups
if (!empty($groupId)) {
    $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists');
$current_session_id = api_get_session_id();
$form->add_html_editor('content', '', false, false, $html_editor_config);
// Comment-field
$folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
// If we are not in the certificates creation, display a folder chooser for the
// new document created
if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'], $dir, $current_session_id)) {
    $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit);
    $parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory')));
    // Following two conditions copied from document.inc.php::build_directory_selector()
    $folder_titles = array();
    if (is_array($folders)) {
Пример #30
0
 /**
  * Returns an HTML form (generated by FormValidator) of the plugin settings
  * @return string FormValidator-generated form
  */
 public function get_settings_form()
 {
     $result = new FormValidator($this->get_name());
     $defaults = array();
     $checkboxGroup = array();
     $checkboxCollection = array();
     if ($checkboxNames = array_keys($this->fields, 'checkbox')) {
         $pluginInfoCollection = api_get_settings('Plugins');
         foreach ($pluginInfoCollection as $pluginInfo) {
             if (array_search($pluginInfo['title'], $checkboxNames) !== false) {
                 $checkboxCollection[$pluginInfo['title']] = $pluginInfo;
             }
         }
     }
     foreach ($this->fields as $name => $type) {
         $options = null;
         if (is_array($type) && isset($type['type']) && $type['type'] === "select") {
             $options = $type['options'];
             $type = $type['type'];
         }
         $value = $this->get($name);
         $defaults[$name] = $value;
         $type = isset($type) ? $type : 'text';
         $help = null;
         if ($this->get_lang_plugin_exists($name . '_help')) {
             $help = $this->get_lang($name . '_help');
             if ($name === "show_main_menu_tab") {
                 $pluginName = strtolower(str_replace('Plugin', '', get_class($this)));
                 $pluginUrl = api_get_path(WEB_PATH) . "plugin/{$pluginName}/index.php";
                 $pluginUrl = "<a href={$pluginUrl}>{$pluginUrl}</a>";
                 $help = sprintf($help, $pluginUrl);
             }
         }
         switch ($type) {
             case 'html':
                 $result->addElement('html', $this->get_lang($name));
                 break;
             case 'wysiwyg':
                 $result->addHtmlEditor($name, $this->get_lang($name), false);
                 break;
             case 'text':
                 $result->addElement($type, $name, array($this->get_lang($name), $help));
                 break;
             case 'boolean':
                 $group = array();
                 $group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
                 $group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
                 $result->addGroup($group, null, array($this->get_lang($name), $help));
                 break;
             case 'checkbox':
                 $selectedValue = null;
                 if (isset($checkboxCollection[$name])) {
                     if ($checkboxCollection[$name]['selected_value'] === 'true') {
                         $selectedValue = 'checked';
                     }
                 }
                 $element = $result->createElement($type, $name, '', $this->get_lang($name), $selectedValue);
                 $element->_attributes['value'] = 'true';
                 $checkboxGroup[] = $element;
                 break;
             case 'select':
                 $result->addElement($type, $name, array($this->get_lang($name), $help), $options);
                 break;
         }
     }
     if (!empty($checkboxGroup)) {
         $result->addGroup($checkboxGroup, null, array($this->get_lang('sms_types'), $help));
     }
     $result->setDefaults($defaults);
     $result->addButtonSave($this->get_lang('Save'), 'submit_button');
     return $result;
 }