Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/main/admin/specific_fields_add.php

101 lines
3.3 KiB

[svn r17550] search: refactor search engine index and search interface and let learnpath follow it Search engine: - Index - use wrapper methods instead on calling xapian.php directly in most of callings - improve dokeos xapian-API - XapianIndexer - new methods: - replace_document() - remove_term_from_doc() - add_term_to_doc() - DokeosIndexer - new methods: - dokeos_preprocess_results() - Preprocess all results depending on the toolid - set_terms() - general interface for getting, comparing and set search engine terms - get_terms_on_db() - Get the terms stored at database (normal, no xapian) - more wrappers for XapianIndexer methods: dokeos_query_query(), dokeos_query_query(), dokeos_get_boolean_query(), dokeos_join_queries() - remove tags search engine feature to replace it with a new generic feature: specific fields - it let define xapian prefix terms dinamically to be included across dokeos index on each tool - move search engine document ID field from lp item table to a general man db table search_engine_ref - Search - use search_engine processor classes to change how process results depending of the dokeos tool - change interface for terms select at search: now use one multiple select foreach specific field instead of jquery thickbox plugin only for tags - search ajax suggestion feature to query terms on db - it need some work Learnpath: - refactor search engine pieces to use new tables search_engine_ref, specific_field and specific_field_values - add scorm and woogie index - remove search widget from lp list and use it from main/search - also, there are part on audios on lp items feature added
16 years ago
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
* Add form
* @package dokeos.admin
*/
$language_file[] = 'admin';
// including necessary libraries
require ('../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
include_once ($libpath.'specific_fields_manager.lib.php');
require_once ($libpath.'formvalidator/FormValidator.class.php');
// section for the tabs
$this_section=SECTION_PLATFORM_ADMIN;
// user permissions
api_protect_admin_script();
// Database table definitions
$table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
$table_uf_opt = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$table_uf_val = Database :: get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
if ($_GET['action']<>'edit')
{
$tool_name = get_lang('AddSpecificSearchField');
}
else
{
$tool_name = get_lang('EditSpecificSearchField');
}
// Create the form
$form = new FormValidator('specific_fields_add');
// Field variable name
$form->addElement('hidden','field_id',(int)$_REQUEST['field_id']);
$form->addElement('text','field_name',get_lang('FieldName'));
$form->applyFilter('field_name','html_filter');
$form->applyFilter('field_name','trim');
$form->addRule('field_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('fieldname', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
$form->addRule('fieldname', '', 'maxlength',20);
// Set default values (only not empty when editing)
$defaults = array();
if (is_numeric($_REQUEST['field_id']))
{
$form_information = get_specific_field_list(array( 'id' => (int)$_GET['field_id'] ));
$defaults['field_name'] = $form_information[0]['name'];
}
$form->setDefaults($defaults);
// Submit button
$form->addElement('submit', 'submit', get_lang('Add'));
// Validate form
if ($form->validate()) {
$field = $form->exportValues();
$field_name = $field['field_name'];
if (is_numeric($field['field_id']) && $field['field_id']<>0 && !empty($field['field_id']))
{
edit_specific_field($field['field_id'],$field['field_name']);
$message = get_lang('FieldEdited');
}
else
{
$field_id = add_specific_field($field_name);
$message = get_lang('FieldAdded');
}
header('Location: specific_fields.php?message='.$message);
//exit ();
}
// Display form
Display::display_header($tool_name);
$form->display();
Display::display_footer();