languages.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. // $Id: languages.php 9246 2006-09-25 13:24:53Z bmol $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004-2005 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) Bart Mollet, Hogeschool Gent
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * This page allows the platform admin to decide which languages should
  22. * be available in the language selection menu in the login page. This can be
  23. * useful for countries with more than one official language (like Belgium:
  24. * Dutch, French and German) or international organisations that are active in
  25. * a limited number of countries.
  26. *
  27. * @author Patrick Cool, main author
  28. * @author Roan EMbrechts, code cleaning
  29. * @since Dokeos 1.6
  30. * @package dokeos.admin
  31. ==============================================================================
  32. */
  33. /*
  34. ==============================================================================
  35. INIT SECTION
  36. ==============================================================================
  37. */
  38. // language file to be included
  39. $langFile = 'admin';
  40. // we are in the admin area so we do not need a course id
  41. $cidReset = true;
  42. // include global script
  43. include ('../inc/global.inc.php');
  44. $this_section = SECTION_PLATFORM_ADMIN;
  45. api_protect_admin_script();
  46. // setting the table that is needed for the styles management (there is a check if it exists later in this code)
  47. $tbl_admin_languages = Database :: get_main_table(MAIN_LANGUAGE_TABLE);
  48. $tbl_settings_current = Database :: get_main_table(MAIN_SETTINGS_CURRENT_TABLE);
  49. /*
  50. ==============================================================================
  51. STORING THE CHANGES
  52. ==============================================================================
  53. */
  54. // we change the availability
  55. if ($_GET['action'] == 'makeunavailable')
  56. {
  57. $sql_make_unavailable = "UPDATE $tbl_admin_languages SET available='0' WHERE id='{$_GET['id']}'";
  58. $result = api_sql_query($sql_make_unavailable);
  59. }
  60. if ($_GET['action'] == 'makeavailable')
  61. {
  62. $sql_make_available = "UPDATE $tbl_admin_languages SET available='1' WHERE id='{$_GET['id']}'";
  63. $result = api_sql_query($sql_make_available);
  64. }
  65. if ($_POST['Submit'])
  66. {
  67. // changing the name
  68. $sql_update = "UPDATE $tbl_admin_languages SET original_name='{$_POST['txt_name']}' WHERE id='{$_POST['edit_id']}'";
  69. $result = api_sql_query($sql_update);
  70. // changing the Platform language
  71. if ($_POST['platformlanguage'] && $_POST['platformlanguage'] <> '')
  72. {
  73. $sql_update_2 = "UPDATE $tbl_settings_current SET selected_value='{$_POST['platformlanguage']}' WHERE variable='platformLanguage'";
  74. $result_2 = api_sql_query($sql_update_2);
  75. }
  76. }
  77. elseif (isset($_POST['action']))
  78. {
  79. switch ($_POST['action'])
  80. {
  81. case 'makeavailable' :
  82. if (count($_POST['id']) > 0)
  83. {
  84. $ids = array ();
  85. foreach ($_POST['id'] as $index => $id)
  86. {
  87. $ids[] = mysql_real_escape_string($id);
  88. }
  89. $sql = "UPDATE $tbl_admin_languages SET available='1' WHERE id IN ('".implode("','", $ids)."')";
  90. api_sql_query($sql,__FILE__,__LINE__);
  91. }
  92. break;
  93. case 'makeunavailable' :
  94. if (count($_POST['id']) > 0)
  95. {
  96. $ids = array ();
  97. foreach ($_POST['id'] as $index => $id)
  98. {
  99. $ids[] = mysql_real_escape_string($id);
  100. }
  101. $sql = "UPDATE $tbl_admin_languages SET available='0' WHERE id IN ('".implode("','", $ids)."')";
  102. api_sql_query($sql,__FILE__,__LINE__);
  103. }
  104. break;
  105. }
  106. }
  107. /*
  108. ==============================================================================
  109. MAIN CODE
  110. ==============================================================================
  111. */
  112. // setting the name of the tool
  113. $tool_name = get_lang('PlatformLanguages');
  114. // setting breadcrumbs
  115. $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  116. // including the header file (which includes the banner itself)
  117. Display :: display_header($tool_name);
  118. // displaying the naam of the tool
  119. //api_display_tool_title($tool_name);
  120. // displaying the explanation for this tool
  121. echo '<p>'.get_lang('PlatformLanguagesExplanation').'</p>';
  122. // selecting all the languages
  123. $sql_select = "SELECT * FROM $tbl_admin_languages";
  124. $result_select = api_sql_query($sql_select);
  125. /*
  126. --------------------------------------
  127. DISPLAY THE TABLE
  128. --------------------------------------
  129. */
  130. // the table data
  131. $language_data = array ();
  132. while ($row = mysql_fetch_array($result_select))
  133. {
  134. $row_td = array ();
  135. $row_td[] = $row['id'];
  136. // the first column is the original name of the language OR a form containing the original name
  137. if ($_GET['action'] == 'edit' and $row['id'] == $_GET['id'])
  138. {
  139. $row_td[] = '<input type="hidden" name="edit_id" value="'.$_GET['id'].'" /><input type="text" name="txt_name" value="'.$row['original_name'].'" /> '
  140. . '<input type="checkbox" name="platformlanguage" id="platformlanguage" value="'.$row['english_name'].'" /><label for="platformlanguage">'.$row['original_name'].' '.get_lang('AsPlatformLanguage').'</label> <input type="submit" name="Submit" value="'.get_lang('Ok').'" />';
  141. }
  142. else
  143. {
  144. $row_td[] = $row['original_name'];
  145. }
  146. // the second column
  147. $row_td[] = $row['english_name'];
  148. // the third column
  149. $row_td[] = $row['dokeos_folder'];
  150. // the fourth column with the visibility icon and the edit icon
  151. if ($row['available'] == 1)
  152. {
  153. $row_td[] = "<a href='".$_SERVER['PHP_SELF']."?action=makeinavailable&id=".$row['id']."'><img src='../img/visible.gif' border='0'></a> <a href='".$_SERVER['PHP_SELF']."?action=edit&id=".$row['id']."'><img src='../img/edit.gif' border='0'></a>";
  154. }
  155. else
  156. {
  157. $row_td[] = "<a href='".$_SERVER['PHP_SELF']."?action=makeavailable&id=".$row['id']."'><img src='../img/invisible.gif' border='0'></a> <a href='".$_SERVER['PHP_SELF']."?action=edit&id=".$row['id']."'><img src='../img/edit.gif' border='0'></a>";
  158. }
  159. $language_data[] = $row_td;
  160. }
  161. $table = new SortableTableFromArray($language_data, 1, count($language_data));
  162. $table->set_header(0, '');
  163. $table->set_header(1, get_lang('OriginalName'));
  164. $table->set_header(2, get_lang('EnglishName'));
  165. $table->set_header(3, get_lang('DokeosFolder'));
  166. $table->set_header(4, get_lang('Properties'));
  167. $form_actions = array ();
  168. $form_actions['makeavailable'] = get_lang('MakeAvailable');
  169. $form_actions['makeunavailable'] = get_lang('MakeUnavailable');
  170. $table->set_form_actions($form_actions);
  171. $table->display();
  172. /*
  173. ==============================================================================
  174. FOOTER
  175. ==============================================================================
  176. */
  177. Display :: display_footer();
  178. ?>