Adding some love (cleaning files, avoiding warning messages )

skala
Julio Montoya 14 years ago
parent f39f25ae01
commit acea9becbe
  1. 41
      main/admin/specific_fields.php
  2. 70
      main/admin/specific_fields_add.php

@ -1,31 +1,13 @@
<?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
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
* Manage specific fields
*
* @package dokeos.admin
* @package chamilo.admin
*/
$language_file[] = 'admin';
// Including some necessary chamilo files
require '../inc/global.inc.php';
require_once '../inc/global.inc.php';
// User permissions
api_protect_admin_script();
@ -45,8 +27,6 @@ $renderer =& $form->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span> ');
$form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
// Create a sortable table with specific fields data
$column_show = array(1,1,1,1);
$column_order = array(3,2,1,4);
@ -60,8 +40,7 @@ $table->set_header(2, get_lang('Name'));
$table->set_header(3, get_lang('Modify'),true,'width="10%"');
$table->set_column_filter(3, 'edit_filter');
function edit_filter($id,$url_params,$row)
{
function edit_filter($id,$url_params,$row) {
global $charset;
$return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
$return .= ' <a href="'.api_get_self().'?action=delete&field_id='.$row[0].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a>';
@ -77,18 +56,18 @@ if ($_REQUEST['action'] == 'delete') {
// Displaying the header
Display::display_header($nameTools);
echo '<div class="admin-tool-intro">'.get_lang('SpecificSearchFieldsIntro').'</div>';
echo Display::display_normal_message(get_lang('SpecificSearchFieldsIntro'));
if(!empty($_GET['message']))
{
if(!empty($_GET['message'])) {
Display::display_confirmation_message($_GET['message']);
}
echo '<div class="actions">';
$form->display();
echo '</div>';
$table->display();
if (!empty($extra_fields)) {
$table->display();
}
// Displaying the footer
Display::display_footer();
Display::display_footer();

@ -1,31 +1,13 @@
<?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
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
* Add form
* @package dokeos.admin
* @package chamilo.admin
*/
$language_file[] = 'admin';
// including necessary libraries
require ('../inc/global.inc.php');
require_once '../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');
@ -40,17 +22,14 @@ api_protect_admin_script();
$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);
$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')
{
if ($_GET['action']<>'edit') {
$tool_name = get_lang('AddSpecificSearchField');
}
else
{
} else {
$tool_name = get_lang('EditSpecificSearchField');
}
// Create the form
@ -66,10 +45,9 @@ $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'];
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
@ -77,25 +55,19 @@ $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 ();
$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();
Loading…
Cancel
Save