dokeos-admin
[ class tree: dokeos-admin ] [ index: dokeos-admin ] [ all elements ]

Source for file languages.php

Documentation is available at languages.php

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

Documentation generated on Thu, 12 Jun 2008 13:54:04 -0500 by phpDocumentor 1.4.1