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. $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('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
  24. // Create a sortable table with specific fields data
  25. $column_show = array(1,1,1);
  26. $column_order = array(3,2,1);
  27. $extra_fields = get_specific_field_list();
  28. $number_of_extra_fields = count($extra_fields);
  29. $table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
  30. $table->set_header(0, '&nbsp;', false,null,'width="2%"', 'style="display:none"');
  31. $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
  32. $table->set_header(2, get_lang('Name'));
  33. $table->set_header(3, get_lang('Modify'),false,'width="10%"');
  34. $table->set_column_filter(3, 'edit_filter');
  35. function edit_filter($id,$url_params,$row) {
  36. global $charset;
  37. $return = '<a href="specific_fields_add.php?action=edit&field_id='.$row[0].'">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
  38. $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>';
  39. return $return;
  40. }
  41. if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
  42. delete_specific_field($_REQUEST['field_id']);
  43. header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
  44. exit;
  45. }
  46. // Start output
  47. // Displaying the header
  48. Display::display_header(get_lang('SpecificSearchFields'));
  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();