specific_fields.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2008 Dokeos SPRL
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
  14. ==============================================================================
  15. */
  16. /**
  17. * Manage specific fields
  18. *
  19. * @package dokeos.admin
  20. */
  21. $language_file[] = 'admin';
  22. // Including some necessary chamilo files
  23. require '../inc/global.inc.php';
  24. // User permissions
  25. api_protect_admin_script();
  26. // Breadcrumb
  27. $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  28. $interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
  29. $libpath = api_get_path(LIBRARY_PATH);
  30. require_once $libpath.'sortabletable.class.php';
  31. include_once $libpath.'specific_fields_manager.lib.php';
  32. require_once $libpath.'formvalidator/FormValidator.class.php';
  33. // Create an add-field box
  34. $form = new FormValidator('add_field','post','','',null,false);
  35. $renderer =& $form->defaultRenderer();
  36. $renderer->setElementTemplate('<span>{element}</span> ');
  37. $form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
  38. // Create a sortable table with specific fields data
  39. $column_show = array(1,1,1,1);
  40. $column_order = array(3,2,1,4);
  41. $extra_fields = get_specific_field_list();
  42. $number_of_extra_fields = count($extra_fields);
  43. $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
  44. $table->set_header(0, '', false,null,'width="2%"', 'style="display:none"');
  45. $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
  46. $table->set_header(2, get_lang('Name'));
  47. $table->set_header(3, get_lang('Modify'),true,'width="10%"');
  48. $table->set_column_filter(3, 'edit_filter');
  49. function edit_filter($id,$url_params,$row)
  50. {
  51. global $charset;
  52. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
  53. $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>';
  54. return $return;
  55. }
  56. if ($_REQUEST['action'] == 'delete') {
  57. delete_specific_field($_REQUEST['field_id']);
  58. header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
  59. }
  60. // Start output
  61. // Displaying the header
  62. Display::display_header($nameTools);
  63. echo '<div class="admin-tool-intro">'.get_lang('SpecificSearchFieldsIntro').'</div>';
  64. if(!empty($_GET['message']))
  65. {
  66. Display::display_confirmation_message($_GET['message']);
  67. }
  68. echo '<div class="actions">';
  69. $form->display();
  70. echo '</div>';
  71. $table->display();
  72. // Displaying the footer
  73. Display::display_footer();