} else {
         $form->display();
     }
     break;
 case 'edit':
     $item = Rsys::get_item($_GET['id']);
     $cats = Rsys::get_category();
     foreach ($cats as $cat) {
         $catOptions[$cat['id']] = $cat['name'];
     }
     $interbreadcrumb[] = array("url" => "m_item.php", "name" => $tool_name);
     Display::display_header(str_replace('#ITEM#', $item['name'], get_lang('EditItem')));
     api_display_tool_title(get_lang('EditItem2'));
     $form = new FormValidator('item', 'post', 'm_item.php?action=edit');
     $form->addElement('select', 'category_id', get_lang('Category'), $catOptions);
     $form->add_textfield('name', get_lang('ItemName'), array('maxlength' => '128'));
     $form->addElement('textarea', 'description', get_lang('ItemDescription'), array('rows' => '3', 'cols' => '40'));
     $form->addRule('category_id', get_lang('ThisFieldIsRequired'), 'required');
     $form->addElement('hidden', 'id', $item['id']);
     $form->addElement('submit', 'submit', get_lang('Ok'));
     $form->setDefaults($item);
     if ($form->validate()) {
         $values = $form->exportValues();
         if (Rsys::edit_item($values['id'], $values['name'], $values['description'], $values['category_id'], $values['course_id'])) {
             Display::display_normal_message(Rsys::get_return_msg(get_lang('ItemEdited'), "m_item.php", $tool_name), false);
         } else {
             Display::display_normal_message(Rsys::get_return_msg(get_lang('ItemExist'), "m_item.php?action=edit&id=" . $values['id'], get_lang('EditItem2')), false);
         }
     } else {
         $form->display();
     }
        $values['lang'] = $announcement->lang;
        $values['action'] = 'edit';
        $groups = SystemAnnouncementManager::get_announcement_groups($announcement->id);
        $values['group'] = isset($groups[0]['group_id']) ? $groups[0]['group_id'] : 0;
        $action_todo = true;
        break;
}
if ($action_todo) {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
        $form_title = get_lang('AddNews');
    } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
        $form_title = get_lang('EditNews');
    }
    $form = new FormValidator('system_announcement');
    $form->addElement('header', '', $form_title);
    $form->add_textfield('title', get_lang('Title'), true, array('class' => 'span4'));
    $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);
    if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
        $form->addElement('textarea', 'content', get_lang('Content'));
    } else {
        $form->add_html_editor('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'));
Example #3
0
    Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
}
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
    $param_gradebook = '&gradebook=' . Security::remove_XSS($_SESSION['gradebook']);
}
if (!$error) {
    $token = Security::get_token();
}
$attendance_weight = floatval($attendance_weight);
// display form
$form = new FormValidator('attendance_edit', 'POST', 'index.php?action=attendance_edit&' . api_get_cidreq() . '&attendance_id=' . $attendance_id . $param_gradebook);
$form->addElement('header', '', get_lang('Edit'));
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'attendance_id', $attendance_id);
$form->add_textfield('title', get_lang('Title'), true, array('size' => '50'));
$form->applyFilter('title', 'html_filter');
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
// Adavanced Parameters
if (Gradebook::is_active()) {
    if (!empty($attendance_qualify_title) || !empty($attendance_weight)) {
        $form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
        $form->addElement('html', '<div id="id_qualify_options" style="display:block">');
        $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}'));
        $form->addElement('html', '<div id="options_field" style="display:block">');
    } else {
        $form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters'));
        $form->addElement('html', '<div id="id_qualify_options" style="display:none">');
        $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
        $form->addElement('html', '<div id="options_field" style="display:none">');
    }
Example #4
0
		$form->addElement('style_submit_button', 'submit', get_lang('CreateResourceType'),'class="add"');
		if ($form->validate()) {
			$values = $form->exportValues();
			if (Rsys :: add_category($values['name']))
				Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeAdded'), "m_category.php", $tool_name),false);
			else
				Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeExist'), "m_category.php?action=add", get_lang('AddNewResourceType')),false);
		} else
			$form->display();
		break;
	case 'edit' :
		$interbreadcrumb[] = array ("url" => "m_category.php", "name" => $tool_name);
		Display :: display_header(get_lang('EditResourceType'));
		api_display_tool_title(get_lang('EditResourceType'));
		$form = new FormValidator('category', 'post', 'm_category.php?action=edit');
		$form->add_textfield('name', get_lang('ResourceTypeName'), true, array ('maxlength' => '128'));
		$form->addElement('hidden', 'id', intval($_GET['id']));
		$form->addElement('style_submit_button', 'submit', get_lang('ModifyResourceType'),'class="save"');
		$form->setDefaults(Rsys :: get_category($_GET['id']));
		if ($form->validate()) {
			$values = $form->exportValues();
			if (Rsys :: edit_category($values['id'], $values['name']))
				Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeEdited'), "m_category.php", $tool_name),false);
			else
				Display :: display_normal_message(Rsys :: get_return_msg(get_lang('ResourceTypeExist'), "m_category.php?action=edit&id=".$values['id'], get_lang('EditRight')),false);
		} else
			$form->display();
		break;
	case 'delete' :
		$result = Rsys :: delete_category($_GET['id']);
		ob_start();
Example #5
0
            }
            break;
    }
}
$content = '';
$message = '';
$actions = '';
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
    // Get all course categories
    $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
    $interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
    $tool_name = get_lang('SearchACourse');
    //api_display_tool_title($tool_name);
    $form = new FormValidator('advanced_course_search', 'get');
    $form->addElement('header', $tool_name);
    $form->add_textfield('keyword_code', get_lang('CourseCode'), false);
    $form->add_textfield('keyword_title', get_lang('Title'), false);
    // Category code
    $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
    $form->addElement('select_ajax', 'keyword_category', get_lang('CourseFaculty'), null, array('url' => $url));
    $el = $form->addElement('select_language', 'keyword_language', get_lang('CourseLanguage'));
    $el->addOption(get_lang('All'), '%');
    $form->addElement('radio', 'keyword_visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
    $form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
    $form->addElement('radio', 'keyword_visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
    $form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
    $form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
    $form->addElement('radio', 'keyword_visibility', null, get_lang('All'), '%');
    $form->addElement('radio', 'keyword_subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
    $form->addElement('radio', 'keyword_subscribe', null, get_lang('Denied'), 0);
    $form->addElement('radio', 'keyword_subscribe', null, get_lang('All'), '%');
    $form->addElement('hidden', 'id');
} else {
    // Checks if the field was created in the table Category. It creates it if is neccesary
    $table_category = Database::get_course_table(TABLE_GROUP_CATEGORY);
    if (!Database::query("SELECT wiki_state FROM {$table_category} WHERE c_id = {$course_id}")) {
        Database::query("ALTER TABLE {$table_category} ADD wiki_state tinyint(3) UNSIGNED NOT NULL default '1' WHERE c_id = {$course_id}");
    }
    // Create a new category
    $action = 'add_category';
    $form = new FormValidator('group_category');
}
$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');
Example #7
0
}
/*	MAIN CODE */
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
    $("#max_member").on("focus", function() {
        $("#max_member_selected").attr("checked", true);
    });
});
 </script>';
// Build form
$form = new FormValidator('group_edit', 'post', api_get_self() . '?' . api_get_cidreq());
$form->addElement('header', $nameTools);
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'referer');
// Group name
$form->add_textfield('name', get_lang('GroupName'));
// Description
$form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => 6));
// Getting course info
$course = $app['orm.em']->getRepository('Entity\\Course')->find(api_get_course_int_id());
//Getting subscribed students
$subscribedUsers = $app['orm.em']->getRepository('Entity\\Course')->getSubscribedStudents($course);
$subscribedUsers = $subscribedUsers->getQuery();
$subscribedUsers = $subscribedUsers->execute();
// Getting all users
$complete_user_list = array();
foreach ($subscribedUsers as $user) {
    $complete_user_list[$user->getUserId()] = $user->getCompleteNameWithClasses();
}
$possible_users = array();
foreach ($complete_user_list as $userId => $user) {
function manage_form($default, $select_from_user_list = null, $sent_to = null)
{
    $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
    $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
    $param_f = isset($_GET['f']) ? Security::remove_XSS($_GET['f']) : '';
    $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data'));
    if (empty($group_id)) {
        if (isset($select_from_user_list)) {
            $form->add_textfield('id_text_name', get_lang('SendMessageTo'), true, array('class' => 'span4', 'id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off'));
            $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required');
            $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
            $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list'));
        } else {
            if (!empty($sent_to)) {
                $form->addElement('html', $sent_to);
            }
            if (empty($default['users'])) {
                //fb select
                $form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => 'users'));
            } else {
                $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user'));
            }
        }
    } else {
        $usergroup = new UserGroup();
        $group_info = $usergroup->get($group_id);
        $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name']));
        $form->addElement('hidden', 'group_id', $group_id);
        $form->addElement('hidden', 'parent_id', $message_id);
    }
    $form->add_textfield('title', get_lang('Subject'), true, array('class' => 'span4'));
    $form->add_html_editor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250'));
    if (isset($_GET['re_id'])) {
        $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']);
        $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title'];
        $form->addElement('hidden', 're_id', intval($_GET['re_id']));
        $form->addElement('hidden', 'save_form', 'save_form');
        //adding reply mail
        $user_reply_info = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']);
        $default['content'] = '<br />' . sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content']));
    }
    if (empty($group_id)) {
        $form->addElement('advanced_settings', get_lang('FilesAttachment') . '<span id="filepaths">
                    <div id="filepath_1">
                        <input type="file" name="attach_1"/><br />
                        ' . get_lang('Description') . '&nbsp;&nbsp;<input type="text" name="legend[]" /><br /><br />
                    </div>
                </span>');
        $form->addElement('advanced_settings', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp;(' . sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
    }
    $form->addElement('style_submit_button', 'compose', api_xml_http_response_encode(get_lang('SendMessage')), 'class="save"');
    $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
    if (!empty($group_id) && !empty($message_id)) {
        $message_info = MessageManager::get_message_by_id($message_id);
        $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title'];
    }
    $form->setDefaults($default);
    $html = '';
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $user_list = $default['users'];
            $file_comments = $_POST['legend'];
            $title = $default['title'];
            $content = $default['content'];
            $group_id = isset($default['group_id']) ? $default['group_id'] : null;
            $parent_id = $default['parent_id'];
            if (is_array($user_list) && count($user_list) > 0) {
                //all is well, send the message
                foreach ($user_list as $user) {
                    $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id, null, null, api_get_user_id());
                    if ($res) {
                        if (is_string($res)) {
                            $html .= Display::return_message($res, 'error');
                        } else {
                            $user_info = api_get_user_info($user);
                            $html .= Display::return_message(get_lang('MessageSentTo') . " &nbsp;<b>" . $user_info['complete_name'] . "</b>", 'confirmation', false);
                        }
                    }
                }
            } else {
                Display::display_error_message('ErrorSendingMessage');
            }
        }
        Security::clear_token();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $html .= $form->return_form();
    }
    return $html;
}
 // Form title.
 $form->addElement('header', $tool_name);
 // Title.
 $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
 $form->applyFilter('title', 'html_filter');
 $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
 // Course category.
 $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
 $categoryList = array();
 if (!empty($course_request_info['category_code'])) {
     $data = getCategory($course_request_info['category_code']);
     $categoryList[] = array('id' => $data['code'], 'text' => $data['name']);
 }
 $form->addElement('select_ajax', 'category_code', get_lang('CourseFaculty'), null, array('url' => $url, 'defaults' => $categoryList));
 // Course code.
 $form->add_textfield('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength));
 $form->applyFilter('wanted_code', 'html_filter');
 $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength);
 $form->addRule('wanted_code', get_lang('ThisFieldIsRequired'), 'required');
 // The teacher.
 $titular = $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled'));
 // Description of the requested course.
 $form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
 $form->addRule('description', get_lang('ThisFieldIsRequired'), 'required');
 // Objectives of the requested course.
 $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
 $form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required');
 // Target audience of the requested course.
 $form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
 $form->addRule('target_audience', get_lang('ThisFieldIsRequired'), 'required');
 // Course language.
/**
 * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
 * @version August 2008
 * @since Dokeos 1.8.6
 */
function add_edit_template()
{
    // initiate the object
    $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . $_GET['action'] . '&id=' . $_GET['id']);
    // settting the form elements: the header
    if ($_GET['action'] == 'add') {
        $title = get_lang('AddTemplate');
    } else {
        $title = get_lang('EditTemplate');
    }
    $form->addElement('header', '', $title);
    // settting the form elements: the title of the template
    $form->add_textfield('title', get_lang('Title'), false);
    // settting the form elements: the content of the template (wysiwyg editor)
    $form->addElement('html_editor', 'template_text', get_lang('Text'));
    // settting the form elements: the form to upload an image to be used with the template
    $form->addElement('file', 'template_image', get_lang('Image'), '');
    // settting the form elements: a little bit information about the template image
    $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
    // getting all the information of the template when editing a template
    if ($_GET['action'] == 'edit') {
        // Database table definition
        $table_system_template = Database::get_main_table('system_template');
        $sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'";
        $result = api_sql_query($sql, __FILE__, __LINE__);
        $row = Database::fetch_array($result);
        $defaults['template_id'] = $_GET['id'];
        $defaults['template_text'] = $row['content'];
        $defaults['title'] = $row['title'];
        // adding an extra field: a hidden field with the id of the template we are editing
        $form->addElement('hidden', 'template_id');
        // adding an extrra field: a preview of the image that is currently used
        if (!empty($row['image'])) {
            $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
        } else {
            $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
        }
        // setting the information of the template that we are editing
        $form->setDefaults($defaults);
    }
    // settting the form elements: the submit button
    $form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
    // setting the rules: the required fields
    $form->addRule('title', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('template_text', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required');
    // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
    if ($form->validate()) {
        // exporting the values
        $values = $form->exportValues();
        // upload the file
        if (!empty($_FILES['template_image']['name'])) {
            include_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
            $upload_ok = process_uploaded_file($_FILES['template_image']);
            if ($upload_ok) {
                // Try to add an extension to the file if it hasn't one
                $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
                // upload dir
                $upload_dir = api_get_path(SYS_PATH) . 'home/default_platform_document/';
                // create dir if not exists
                if (!is_dir($upload_dir)) {
                    $perm = api_get_setting('permissions_for_new_directories');
                    $perm = octdec(!empty($perm) ? $perm : '0770');
                    $res = @mkdir($upload_dir, $perm);
                }
                // resize image to max default and upload
                require_once api_get_path(LIBRARY_PATH) . 'image.lib.php';
                $temp = new image($_FILES['template_image']['tmp_name']);
                $picture_infos = @getimagesize($_FILES['template_image']['tmp_name']);
                $max_width_for_picture = 100;
                if ($picture_infos[0] > $max_width_for_picture) {
                    $thumbwidth = $max_width_for_picture;
                    if (empty($thumbwidth) or $thumbwidth == 0) {
                        $thumbwidth = $max_width_for_picture;
                    }
                    $new_height = round($thumbwidth / $picture_infos[0] * $picture_infos[1]);
                    $temp->resize($thumbwidth, $new_height, 0);
                }
                $type = $picture_infos[2];
                switch (!empty($type)) {
                    case 2:
                        $temp->send_image('JPG', $upload_dir . $new_file_name);
                        break;
                    case 3:
                        $temp->send_image('PNG', $upload_dir . $new_file_name);
                        break;
                    case 1:
                        $temp->send_image('GIF', $upload_dir . $new_file_name);
                        break;
                }
            }
        }
        // store the information in the database (as insert or as update)
        $table_system_template = Database::get_main_table('system_template');
        if ($_GET['action'] == 'add') {
            $sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . Database::escape_string($values['template_text']) . "','" . Database::escape_string($new_file_name) . "')";
            $result = api_sql_query($sql, __FILE__, __LINE__);
            // display a feedback message
            Display::display_confirmation_message('TemplateAdded');
            echo '<a href="settings.php?category=Templates&amp;action=add">' . Display::return_icon('add_template.gif', get_lang('AddTemplate')) . get_lang('AddTemplate') . '</a>';
        } else {
            $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "',\n\t\t\t\t\t\t\t\t\t\t\t   \t\t  content = '" . Database::escape_string($values['template_text']) . "'";
            if (!empty($new_file_name)) {
                $sql .= ", image = '" . Database::escape_string($new_file_name) . "'";
            }
            $sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'";
            $result = api_sql_query($sql, __FILE__, __LINE__);
            // display a feedback message
            Display::display_confirmation_message('TemplateEdited');
        }
        display_templates();
    } else {
        // display the form
        $form->display();
    }
}
Example #11
0
    if (!empty($picture['name'])) {
        $picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
    }
}
// Display course picture
$course_path = api_get_path(SYS_COURSE_PATH) . $currentCourseRepository;
// course path
if (file_exists($course_path . '/course-pic85x85.png')) {
    $course_web_path = api_get_path(WEB_COURSE_PATH) . $currentCourseRepository;
    // course web path
    $course_medium_image = $course_web_path . '/course-pic85x85.png?' . rand(1, 1000);
    // redimensioned image 85x85
    $image_html = '<div class="row"><div class="formw"><img src="' . $course_medium_image . '" /></div></div>';
}
$form->addElement('html', $image_html);
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
$form->addElement('select', 'category_code', get_lang('Fac'), $categories, array('style' => 'width:350px', 'class' => 'chzn-select', 'id' => 'category_code'));
$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
$form->add_textfield('department_name', get_lang('Department'), false, array('class' => 'span5'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
$form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array('class' => 'span5'));
$form->applyFilter('department_url', 'html_filter');
// Picture
$form->addElement('file', 'picture', get_lang('AddPicture'));
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
    $url = PDF::get_watermark($course_code);
Example #12
0
$form = new FormValidator('add_course');
// Form title
$form->addElement('header', $tool_name);
// Title
$form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex')), array('class' => 'span6', 'id' => 'title'));
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('advanced_settings', 'advanced_params', get_lang('AdvancedParameters'));
$form->addElement('html', '<div id="advanced_params_options">');
// Course category.
$categories_select = $form->addElement('select', 'category_code', array(get_lang('Fac'), get_lang('TargetFac')), array(), array('id' => 'category_code', 'class' => 'chzn-select', 'style' => 'width:350px'));
$form->applyFilter('category_code', 'html_filter');
$categories_select->addOption('-', '');
CourseManager::select_and_sort_categories($categories_select);
// Course code
$form->add_textfield('wanted_code', array(get_lang('Code'), get_lang('OnlyLettersAndNumbers')), '', array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
// The teacher
//get_lang('ExplicationTrainers')
$titular =& $form->addElement('hidden', 'tutor_name', '');
//array(get_lang('Professor'), null), null, array('size' => '60', 'disabled' => 'disabled'));
//$form->applyFilter('tutor_name', 'html_filter');
if ($course_validation_feature) {
    // Description of the requested course.
    $form->addElement('textarea', 'description', get_lang('Description'), array('class' => 'span6', 'rows' => '3'));
    //$form->addRule('description', get_lang('ThisFieldIsRequired'), 'required');
    // Objectives of the requested course.
    $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('class' => 'span6', 'rows' => '3'));
    //$form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required');
    // Target audience of the requested course.
Example #13
0
function status_filter($status)
{
    $statusname = api_get_status_langvars();
    return $statusname[$status];
}
// INIT SECTION
$action = isset($_GET["action"]) ? $_GET["action"] : null;
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
    $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
    $interbreadcrumb[] = array("url" => 'group_list.php', "name" => get_lang('GroupList'));
    $tool_name = get_lang('SearchAUser');
    Display::display_header($tool_name);
    //api_display_tool_title($tool_name);
    $form = new FormValidator('advanced_search', 'get');
    $form->addElement('header', '', $tool_name);
    $form->add_textfield('keyword_firstname', get_lang('FirstName'), false);
    $form->add_textfield('keyword_lastname', get_lang('LastName'), false);
    $form->add_textfield('keyword_username', get_lang('LoginName'), false);
    $form->add_textfield('keyword_email', get_lang('Email'), false);
    $form->add_textfield('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[SESSIONADMIN] = get_lang('Administrator');
    //
    $form->addElement('select', 'keyword_status', get_lang('Status'), $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);
Example #14
0
// Resetting the course id.
$cidReset = true;
// Including some necessary dokeos files.
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'classmanager.lib.php';
// Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions.
api_protect_admin_script();
// Setting breadcrumbs.
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
// Setting the name of the tool.
$tool_name = get_lang('AddClasses');
$tool_name = get_lang('ModifyClassInfo');
$class_id = intval($_GET['idclass']);
$class = ClassManager::get_class_info($class_id);
$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass=' . $class_id);
$form->add_textfield('name', get_lang('ClassName'));
$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"');
$form->setDefaults(array('name' => $class['name']));
if ($form->validate()) {
    $values = $form->exportValues();
    ClassManager::set_name($values['name'], $class_id);
    header('Location: class_list.php');
}
Display::display_header($tool_name);
//api_display_tool_title($tool_name);
$form->display();
// Displaying the footer.
Display::display_footer();
/**
 * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium
 * @version August 2008
 * @since Dokeos 1.8.6
 */
function add_edit_template()
{
    // Initialize the object.
    $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . Security::remove_XSS($_GET['action']) . '&id=' . Security::remove_XSS($_GET['id']));
    // Settting the form elements: the header.
    if ($_GET['action'] == 'add') {
        $title = get_lang('AddTemplate');
    } else {
        $title = get_lang('EditTemplate');
    }
    $form->addElement('header', $title);
    // Settting the form elements: the title of the template.
    $form->add_textfield('title', get_lang('Title'), false);
    // Settting the form elements: the content of the template (wysiwyg editor).
    $form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
    // Settting the form elements: the form to upload an image to be used with the template.
    $form->addElement('file', 'template_image', get_lang('Image'), '');
    // Settting the form elements: a little bit information about the template image.
    $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
    // Getting all the information of the template when editing a template.
    if ($_GET['action'] == 'edit') {
        // Database table definition.
        $table_system_template = Database::get_main_table('system_template');
        $sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'";
        $result = Database::query($sql);
        $row = Database::fetch_array($result);
        $defaults['template_id'] = intval($_GET['id']);
        $defaults['template_text'] = $row['content'];
        // Forcing get_lang().
        $defaults['title'] = get_lang($row['title']);
        // Adding an extra field: a hidden field with the id of the template we are editing.
        $form->addElement('hidden', 'template_id');
        // Adding an extra field: a preview of the image that is currently used.
        if (!empty($row['image'])) {
            $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_DATA_PATH) . 'document_templates/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>');
        } else {
            $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_DATA_PATH) . 'document_templates/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>');
        }
        // Setting the information of the template that we are editing.
        $form->setDefaults($defaults);
    }
    // Setting the form elements: the submit button.
    $form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"');
    // Setting the rules: the required fields.
    $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('template_text', get_lang('ThisFieldIsRequired'), 'required');
    // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            // Exporting the values.
            $values = $form->exportValues();
            // Upload the file.
            if (!empty($_FILES['template_image']['name'])) {
                $upload_ok = FileManager::process_uploaded_file($_FILES['template_image']);
                if ($upload_ok) {
                    // Try to add an extension to the file if it hasn't one.
                    $new_file_name = FileManager::add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
                    // The upload directory.
                    $upload_dir = api_get_path(SYS_DATA_PATH) . 'document_templates/';
                    // Resize the preview image to max default and upload.
                    $temp = new Image($_FILES['template_image']['tmp_name']);
                    $picture_info = $temp->get_image_info();
                    $max_width_for_picture = 100;
                    if ($picture_info['width'] > $max_width_for_picture) {
                        $thumbwidth = $max_width_for_picture;
                        if (empty($thumbwidth) || $thumbwidth == 0) {
                            $thumbwidth = $max_width_for_picture;
                        }
                        $new_height = round($thumbwidth / $picture_info['width'] * $picture_info['height']);
                        $temp->resize($thumbwidth, $new_height, 0);
                    }
                    $temp->send_image($upload_dir . $new_file_name);
                }
            }
            // Store the information in the database (as insert or as update).
            $table_system_template = Database::get_main_table('system_template');
            if ($_GET['action'] == 'add') {
                $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>';
                $sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . $content_template . "','" . Database::escape_string($new_file_name) . "')";
                Database::query($sql);
                // Display a feedback message.
                Display::display_confirmation_message(get_lang('TemplateAdded'));
                echo '<a href="settings.php?category=Templates&amp;action=add">' . Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM) . '</a>';
            } else {
                $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>';
                $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "', content = '" . $content_template . "'";
                if (!empty($new_file_name)) {
                    $sql .= ", image = '" . Database::escape_string($new_file_name) . "'";
                }
                $sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'";
                Database::query($sql);
                // Display a feedback message.
                Display::display_confirmation_message(get_lang('TemplateEdited'));
            }
        }
        Security::clear_token();
        display_templates();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        // Display the form.
        $form->display();
    }
}
Example #16
0
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'course_list.php', 'name' => get_lang('CourseList'));
/* MAIN CODE */
global $_configuration;
$group = Container::getGroupManager()->findGroupByName('teachers');
$teachers = array();
$users = $group->getUsers();
/** @var Chamilo\UserBundle\Entity\User $user */
foreach ($users as $user) {
    $teachers[$user->getId()] = $user->getCompleteName();
}
// Build the form.
$form = new FormValidator('update_course');
$form->addElement('header', $tool_name);
// Title
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
// Code
$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')), false, array('class' => 'span3', 'maxlength' => CourseManager::MAX_COURSE_LENGTH_CODE));
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addRule('visual_code', get_lang('Max'), 'maxlength', CourseManager::MAX_COURSE_LENGTH_CODE);
$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select"  style="width:350px" multiple="multiple" ');
$form->applyFilter('course_teachers', 'html_filter');
//This function fills the category_code select ...
$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->add_textfield('department_name', get_lang('CourseDepartment'), false, array('size' => '60'));
$form->applyFilter('department_name', 'html_filter');
Example #17
0
            echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=downloadfolder&amp;id=' . $document_id . '">' . Display::return_icon('save_pack.png', get_lang('Save') . ' (ZIP)', '', ICON_SIZE_MEDIUM) . '</a>';
        }
    }
}
// Slideshow by Patrick Cool, May 2004
require 'document_slideshow.inc.php';
if ($image_present && !isset($_GET['keyword'])) {
    echo '<a href="slideshow.php?' . api_get_cidreq() . '&amp;curdirpath=' . $curdirpathurl . '">' . Display::return_icon('slideshow.png', get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM) . '</a>';
}
if (api_is_allowed_to_edit(null, true)) {
    echo '<a href="document_quota.php?' . api_get_cidreq() . '">' . Display::return_icon('percentage.png', get_lang('DocumentQuota'), '', ICON_SIZE_MEDIUM) . '</a>';
}
if (!$is_certificate_mode) {
    /* Search form */
    $form = new FormValidator('search_document', 'get', '', '', array('class' => 'form-inline'), false);
    $form->add_textfield('keyword', '', false, array('class' => 'span2'));
    $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"');
    $form->display();
}
echo '</div>';
//end actions
if (isset($message)) {
    echo $message;
}
if (isset($_POST['move_to'])) {
    $document_id = DocumentManager::get_document_id($course_info, $_POST['move_to']);
}
if (isset($_GET['createdir']) && isset($_POST['dirname']) && $_POST['dirname'] != '') {
    $post_dir_name = $_POST['dirname'];
    $document_id = DocumentManager::get_document_id($course_info, $_POST['dirname']);
}
     $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) {
     $form->addElement('select', 'attendance_select', get_lang('Attendances'), $attendance_select, array('id' => 'id_attendance_select', 'onchange' => 'datetime_by_attendance(this.value)'));
 } else {
     $form->addElement('label', get_lang('Attendances'), '<strong><em>' . get_lang('ThereAreNoAttendancesInsideCourse') . '</em></strong>');
 }
 $form->addElement('html', '<div id="div_datetime_attendance">');
 if (!empty($calendar_select)) {
     $form->addElement('select', 'start_date_by_attendance', get_lang('StartDate'), $calendar_select, array('id' => 'start_date_select_calendar'));
 }
 $form->addElement('html', '</div>');
 $form->addElement('html', '</div>');
 $form->add_textfield('duration_in_hours', get_lang('DurationInHours'), false, array('size' => '3', 'id' => 'duration_in_hours_element', 'autofocus' => 'autofocus'));
 $form->add_html_editor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded' => 'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
 //$form->addElement('textarea', 'content', get_lang('Content'));
 if ($action == 'thematic_advance_add') {
     $form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_button" class="save"');
 } else {
     $form->addElement('style_submit_button', null, get_lang('Save'), 'id="update_button" class="save"');
 }
 //$form->addElement('html', '<a href="#" id="save_button" onclick="save();">Save</a>');
 $attendance_select_item_id = null;
 if (count($attendance_select) > 1) {
     $i = 1;
     foreach ($attendance_select as $key => $attendance_select_item) {
         if ($i == 2) {
             $attendance_select_item_id = $key;
             break;
Example #19
0
    // We add in the array platform teachers
    $platform_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
}
// Case where there is no teacher in the course
if (count($course_teachers) == 0) {
    $sql = 'SELECT tutor_name FROM ' . $course_table . ' WHERE code="' . $course_code . '"';
    $res = Database::query($sql);
    $tutor_name = Database::result($res, 0, 0);
    $course['tutor_name'] = array_search($tutor_name, $platform_teachers);
}
// 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>
Example #20
0
    $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&amp;type=csv">' . Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM) . '</a> ';
    $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&amp;type=xls">' . Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM) . '</a> ';
    if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
        $actions .= '<a href="user_import.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM) . '</a> ';
    }
    $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&type=pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a> ';
    $actions .= "<a href=\"../group/group.php?" . api_get_cidreq() . "\">" . Display::return_icon('group.png', get_lang("GroupUserManagement"), '', ICON_SIZE_MEDIUM) . "</a>";
    if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
        $actions .= ' <a class="btn" href="class.php?' . api_get_cidreq() . '">' . get_lang('Classes') . '</a>';
    }
    //$actions .= ' <a class="btn" href="social_groups.php?'.api_get_cidreq().'">'.get_lang('SocialGroups').'</a>';
    // Build search-form
    $form = new FormValidator('search_user', 'get', '', '', null, false);
    $renderer = $form->defaultRenderer();
    $renderer->setElementTemplate('<span>{element}</span> ');
    $form->add_textfield('keyword', '', false);
    $form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
    $form->addElement('static', 'additionalactions', null, $actions);
    $form->display();
    echo '</div>';
}
if (isset($message)) {
    Display::display_confirmation_message($message);
}
/* 		DISPLAY LIST OF USERS */
/**
 *  * Get the users to display on the current page.
 */
function get_number_of_users()
{
    $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
                }
                if (isset($_GET['id_session']) && trim($_GET['id_session']) != "") {
                    addUserToSession($UserList, $_GET['id_session']);
                }
                if (count($UserList) > 0) {
                    Display::display_normal_message(count($UserList) . " " . get_lang('LDAPUsersAdded'));
                } else {
                    Display::display_normal_message(get_lang('NoUserAdded'));
                }
                break;
        }
        Security::clear_token();
    }
}
$form = new FormValidator('advanced_search', 'get');
$form->add_textfield('keyword_username', get_lang('LoginName'), false);
if (api_is_western_name_order()) {
    $form->add_textfield('keyword_firstname', get_lang('FirstName'), false);
    $form->add_textfield('keyword_lastname', get_lang('LastName'), false);
} else {
    $form->add_textfield('keyword_lastname', get_lang('LastName'), false);
    $form->add_textfield('keyword_firstname', get_lang('FirstName'), false);
}
if (isset($_GET['id_session'])) {
    $form->addElement('hidden', 'id_session', $_GET['id_session']);
}
$type = array();
$type["all"] = get_lang('All');
$type["employee"] = get_lang('Teacher');
$type["student"] = get_lang('Student');
$form->addElement('select', 'keyword_type', get_lang('Status'), $type);
Example #22
0
}
echo '</div>';
// error messages
if (isset($error) && intval($error) == 1) {
    Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
}
// default header title form
$header = '';
$description_type = intval($description_type);
if ($description_type >= ADD_BLOCK) {
    $header = $default_description_titles[ADD_BLOCK];
}
if (!$error) {
    $token = Security::get_token();
}
// display form
$form = new FormValidator('course_description', 'POST', 'index.php?action=add&' . api_get_cidreq());
$form->addElement('header', '', $header);
$form->addElement('hidden', 'description_type', $description_type);
$form->addElement('hidden', 'sec_token', $token);
$form->add_textfield('title', get_lang('Title'), true, array('size' => 'width: 350px;'));
$form->applyFilter('title', 'html_filter');
$form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
// display default questions
if (isset($question[$description_type])) {
    $message = '<strong>' . get_lang('QuestionPlan') . '</strong><br />';
    $message .= $question[$description_type];
    Display::display_normal_message($message, false);
}
$form->display();
Example #23
0
$parameters['sec_token'] = Security::get_token();
// get the list of all admins to mark them in the users list
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$sql_admin = "SELECT user_id FROM {$admin_table}";
$res_admin = Database::query($sql_admin);
$_admins_list = array();
while ($row_admin = Database::fetch_row($res_admin)) {
    $_admins_list[] = $row_admin[0];
}
// Display Advanced search form.
$form = new FormValidator('advanced_search', 'get');
$form->addElement('html', '<div id="advanced_search_form" style="display:none;">');
$form->addElement('header', get_lang('AdvancedSearch'));
$form->addElement('html', '<table>');
$form->addElement('html', '<tr><td>');
$form->add_textfield('keyword_firstname', get_lang('FirstName'), false, array('style' => 'margin-left:17px'));
$form->addElement('html', '</td><td width="200px;">');
$form->add_textfield('keyword_lastname', get_lang('LastName'), false, array('style' => 'margin-left:17px'));
$form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>');
$form->add_textfield('keyword_username', get_lang('LoginName'), false, array('style' => 'margin-left:17px'));
$form->addElement('html', '</td>');
$form->addElement('html', '<td>');
$form->add_textfield('keyword_email', get_lang('Email'), false, array('style' => 'margin-left:17px'));
$form->addElement('html', '</td></tr>');
$form->addElement('html', '<tr><td>');
$form->add_textfield('keyword_officialcode', get_lang('OfficialCode'), false, array('style' => 'margin-left:17px'));
$form->addElement('html', '</td><td>');
$status_options = array();
$status_options['%'] = get_lang('All');
$status_options[STUDENT] = get_lang('Student');
 /**
  * Shows statistics about the time of last visit to each course.
  */
 static function print_course_last_visit()
 {
     $access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     $current_url_id = api_get_current_access_url_id();
     $columns[0] = 'c_id';
     $columns[1] = 'access_date';
     $sql_order[SORT_ASC] = 'ASC';
     $sql_order[SORT_DESC] = 'DESC';
     $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
     $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1;
     $column = isset($_GET['column']) ? intval($_GET['column']) : 0;
     $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60;
     if (!in_array($_GET['direction'], array(SORT_ASC, SORT_DESC))) {
         $direction = SORT_ASC;
     } else {
         $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC;
     }
     $form = new FormValidator('courselastvisit', 'get');
     $form->addElement('hidden', 'report', 'courselastvisit');
     $form->add_textfield('date_diff', get_lang('Days'), true);
     $form->addRule('date_diff', 'InvalidNumber', 'numeric');
     $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"');
     if (!isset($_GET['date_diff'])) {
         $defaults['date_diff'] = 60;
     } else {
         $defaults['date_diff'] = Security::remove_XSS($_GET['date_diff']);
     }
     $form->setDefaults($defaults);
     $form->display();
     $values = $form->exportValues();
     $date_diff = $values['date_diff'];
     $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
     $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
     if (api_is_multiple_url_enabled()) {
         $sql = "SELECT access_date, c.code FROM {$table} s , {$access_url_rel_course_table} u, {$tableCourse} c\n                    WHERE c.id = u.c_id AND c.id = s.c_id AND access_url_id='" . $current_url_id . "' " . "GROUP BY access_cours_code " . "HAVING s.c_id <> '' " . "AND DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff;
     } else {
         $sql = "SELECT access_date, c.code FROM {$table} , {$tableCourse} c\n                    WHERE c_id = c.id\n                    GROUP BY c_id\n                    HAVING c_id <> ''AND\n                    DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff;
     }
     $res = Database::query($sql);
     $number_of_courses = Database::num_rows($res);
     $sql .= ' ORDER BY ' . $columns[$column] . ' ' . $sql_order[$direction];
     $from = ($page_nr - 1) * $per_page;
     $sql .= ' LIMIT ' . $from . ',' . $per_page;
     echo '<p>' . get_lang('LastAccess') . ' &gt;= ' . $date_diff . ' ' . get_lang('Days') . '</p>';
     $res = Database::query($sql);
     if (Database::num_rows($res) > 0) {
         $courses = array();
         while ($obj = Database::fetch_object($res)) {
             $course = array();
             $course[] = '<a href="' . api_get_path(WEB_PATH) . 'courses/' . $obj->code . '">' . $obj->code . ' <a>';
             //Allow sort by date hiding the numerical date
             $course[] = '<span style="display:none;">' . $obj->access_date . '</span>' . api_convert_and_format_date($obj->access_date);
             $courses[] = $course;
         }
         $parameters['date_diff'] = $date_diff;
         $parameters['report'] = 'courselastvisit';
         $table_header[] = array(get_lang("CourseCode"), true);
         $table_header[] = array(get_lang("LastAccess"), true);
         Display::display_sortable_table($table_header, $courses, array('column' => $column, 'direction' => $direction), array(), $parameters);
     } else {
         echo get_lang('NoSearchResults');
     }
 }
Example #25
0
        }
        echo '</div>';
    }
}

// get information about user id viewed
$user_info_viewed = api_get_user_info($userIdViewed);
$is_session_course_coach = UserManager::is_session_course_coach($userIdViewed, $_course['sysCode'], $current_session_id);

if ($displayMode == "viewDefEdit") {
    /* CATEGORIES DEFINITIONS : EDIT */

    $catToEdit = get_cat_def($_GET['editDef']);
    $edit_heading_form = new FormValidator('edit_heading_form');
    $edit_heading_form->addElement('hidden', 'id');
    $edit_heading_form->add_textfield('title', get_lang('Title'));
    $edit_heading_form->addElement('textarea', 'comment', get_lang('Comment'), array ('cols' => 60, 'rows' => 4));
    $possible_line_nrs[1] = '1 '.get_lang('Line');
    $possible_line_nrs[3] = '3 '.get_lang('Lines');
    $possible_line_nrs[5] = '5 '.get_lang('Lines');
    $possible_line_nrs[10] = '10 '.get_lang('Lines');
    $possible_line_nrs[15] = '15 '.get_lang('Lines');
    $edit_heading_form->addElement('select', 'nbline', get_lang('LineNumber'), $possible_line_nrs);
    $edit_heading_form->addElement('submit', 'submitDef', get_lang('Ok'));
    $edit_heading_form->setDefaults($catToEdit);
    $edit_heading_form->display();

} elseif ($displayMode == "viewDefList") {
    /*CATEGORIES DEFINITIONS : LIST */

    $catList = get_cat_def_list();