specific_fields.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Manage specific fields.
  5. *
  6. * @package chamilo.admin
  7. */
  8. // Resetting the course id.
  9. $cidReset = true;
  10. // Including some necessary chamilo files
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. // User permissions
  13. api_protect_admin_script();
  14. // Breadcrumb
  15. $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
  16. $interbreadcrumb[] = ['url' => 'settings.php?category=Search', 'name' => get_lang('Configuration settings')];
  17. $libpath = api_get_path(LIBRARY_PATH);
  18. include_once $libpath.'specific_fields_manager.lib.php';
  19. // Create an add-field box
  20. $form = new FormValidator('add_field', 'post', '', '', null, false);
  21. $renderer = &$form->defaultRenderer();
  22. $renderer->setCustomElementTemplate('<span>{element}</span> ');
  23. $form->addElement(
  24. 'static',
  25. 'search_advanced_link',
  26. null,
  27. '<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('Add a specific search field').'</a>'
  28. );
  29. // Create a sortable table with specific fields data
  30. $column_show = [1, 1, 1];
  31. $column_order = [3, 2, 1];
  32. $extra_fields = get_specific_field_list();
  33. $number_of_extra_fields = count($extra_fields);
  34. $table = new SortableTableFromArrayConfig(
  35. $extra_fields,
  36. 2,
  37. 50,
  38. '',
  39. $column_show,
  40. $column_order
  41. );
  42. $table->set_header(0, '&nbsp;', false, null, 'width="2%"', 'style="display:none"');
  43. $table->set_header(1, get_lang('Course code'), true, 'width="10%"');
  44. $table->set_header(2, get_lang('Name'));
  45. $table->set_header(3, get_lang('Edit'), false, 'width="10%"');
  46. $table->set_column_filter(3, 'edit_filter');
  47. function edit_filter($id, $url_params, $row)
  48. {
  49. global $charset;
  50. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.
  51. Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  52. $return .= ' <a href="'.api_get_self().'?action=delete&field_id='.$row[0].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES, $charset))."'".')) return false;">'.
  53. Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
  54. return $return;
  55. }
  56. if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
  57. delete_specific_field($_REQUEST['field_id']);
  58. header('Location: specific_fields.php?message='.get_lang('Field removed'));
  59. exit;
  60. }
  61. // Displaying the header
  62. Display::display_header(get_lang('Specific search fields'));
  63. echo Display::addFlash(Display::return_message(get_lang('Specific search fieldsIntro')));
  64. if (!empty($_GET['message'])) {
  65. Display::addFlash(Display::return_message($_GET['message'], 'confirm'));
  66. }
  67. echo '<div class="actions">';
  68. $form->display();
  69. echo '</div>';
  70. if (!empty($extra_fields)) {
  71. $table->display();
  72. }
  73. // Displaying the footer
  74. Display::display_footer();