specific_fields.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Manage specific fields
  5. *
  6. * @package chamilo.admin
  7. */
  8. $language_file[] = 'admin';
  9. // Resetting the course id.
  10. $cidReset = true;
  11. // Including some necessary chamilo files
  12. require_once '../inc/global.inc.php';
  13. // User permissions
  14. api_protect_admin_script();
  15. // Breadcrumb
  16. $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  17. $interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
  18. $interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
  19. $libpath = api_get_path(LIBRARY_PATH);
  20. require_once $libpath.'sortable_table.class.php';
  21. include_once $libpath.'specific_fields_manager.lib.php';
  22. // Create an add-field box
  23. $form = new FormValidator('add_field','post','','',null,false);
  24. $renderer =& $form->defaultRenderer();
  25. $renderer->setElementTemplate('<span>{element}</span> ');
  26. $form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
  27. // Create a sortable table with specific fields data
  28. $column_show = array(1,1,1,1);
  29. $column_order = array(3,2,1,4);
  30. $extra_fields = get_specific_field_list();
  31. $number_of_extra_fields = count($extra_fields);
  32. $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
  33. $table->set_header(0, '', false,null,'width="2%"', 'style="display:none"');
  34. $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
  35. $table->set_header(2, get_lang('Name'));
  36. $table->set_header(3, get_lang('Modify'),true,'width="10%"');
  37. $table->set_column_filter(3, 'edit_filter');
  38. function edit_filter($id,$url_params,$row) {
  39. global $charset;
  40. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
  41. $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>';
  42. return $return;
  43. }
  44. if ($_REQUEST['action'] == 'delete') {
  45. delete_specific_field($_REQUEST['field_id']);
  46. header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
  47. }
  48. // Start output
  49. // Displaying the header
  50. Display::display_header($nameTools);
  51. echo Display::display_normal_message(get_lang('SpecificSearchFieldsIntro'));
  52. if(!empty($_GET['message'])) {
  53. Display::display_confirmation_message($_GET['message']);
  54. }
  55. echo '<div class="actions">';
  56. $form->display();
  57. echo '</div>';
  58. if (!empty($extra_fields)) {
  59. $table->display();
  60. }
  61. // Displaying the footer
  62. Display::display_footer();