settings2csv.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script generates a CSV file of all settings in the order they appear
  5. * in the platform settings section, in the given language.
  6. * This is meant to speed up the redaction of the admin guide.
  7. * Note: to obtain the default values for all settings, you need to run
  8. * this script on a freshly installed Chamilo setup with all options set
  9. * by default in the installation process.
  10. * @package chamilo.tests.scripts
  11. */
  12. /**
  13. * Init
  14. */
  15. // comment exit statement before executing
  16. //exit;
  17. $language = 'french';
  18. $_GET['language'] = $language;
  19. require __DIR__ . '/../../main/inc/global.inc.php';
  20. $debug = 1;
  21. // Categories, in order of appearance in the Chamilo settings page
  22. // Check the end of main/admin/settings.php for the initial list
  23. $categories = [
  24. 'Platform',
  25. 'Course',
  26. 'Session',
  27. 'Languages',
  28. 'User',
  29. 'Tools',
  30. 'Editor',
  31. 'Security',
  32. 'Tuning',
  33. 'Gradebook',
  34. 'Timezones',
  35. 'Tracking',
  36. 'Search',
  37. 'Stylesheets',
  38. 'Templates',
  39. 'Plugins',
  40. 'LDAP',
  41. 'CAS',
  42. 'Shibboleth',
  43. 'Facebook',
  44. 'Crons',
  45. 'WebServices',
  46. ];
  47. $fileName = 'settings'; // will be appended a ".csv" extension
  48. $fileContent = [];
  49. $fileContent[] = [
  50. 'Variable',
  51. 'Subkey',
  52. 'Comment',
  53. 'Current value'
  54. ];
  55. foreach ($categories as $category) {
  56. $fileContent[] = [
  57. '***** '.get_lang('Category', null, $language).': '.$category.' ****',
  58. '',
  59. '',
  60. ''
  61. ];
  62. $settings = api_get_settings($category, 'group');
  63. foreach ($settings as $setting) {
  64. $fileContent[] = [
  65. get_lang($setting['title'], null, $language),
  66. $setting['subkey'],
  67. get_lang($setting['comment'], null, $language),
  68. $setting['selected_value']
  69. ];
  70. }
  71. }
  72. $filePath = Export::arrayToCsv($fileContent, $fileName, true);
  73. echo "File generated and stored in $filePath".PHP_EOL;