specific_fields.php 2.7 KB

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