@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This page allows the platform admin to decide which languages should
@ -23,7 +24,6 @@ $cidReset = true;
// include global script
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php';
require_once 'sub_language.class.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -33,8 +33,12 @@ api_protect_admin_script();
if (isset($_POST['sent_http_request'])) {
if (isset($_POST['visibility']) & & $_POST['visibility'] == strval(intval($_POST['visibility'])) & & $_POST['visibility'] == 0) {
if (isset($_POST['id']) & & $_POST['id'] == strval(intval($_POST['id']))) {
if (SubLanguageManager::check_if_language_is_used($_POST['id']) == false) {
SubLanguageManager::make_unavailable_language($_POST['id']);
echo 'set_hidden';
} else {
echo 'confirm:' . intval($_POST['id']);
}
}
}
if (isset($_POST['visibility']) & & $_POST['visibility'] == strval(intval($_POST['visibility'])) & & $_POST['visibility'] == 1) {
@ -45,7 +49,9 @@ if (isset($_POST['sent_http_request'])) {
}
exit;
}
$htmlHeadXtra[] ='< script type = "text/javascript" >
$htmlHeadXtra[] = '< script >
$(document).ready(function() {
//$(window).load(function () {
@ -76,14 +82,14 @@ $htmlHeadXtra[] ='<script type="text/javascript">
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("#id_content_message").html("< div class = \"normal-message\" > < img src = '.api_get_path(WEB_PATH).' main / inc / lib / javascript / indicator . gif \ ' / > < / div > ");
$("#id_content_message").html("< div class = \"normal-message\" > < img src = \"' . api_get_path ( WEB_PATH ) . ' main / img / loading1 . gif \ " / > < / div > ");
},
type: "POST",
url: "../admin/languages.php",
data: "id="+link_id+"& visibility="+my_visibility+"& sent_http_request=1",
success: function(datos) {
if (datos=="set_visible" || datos=="set_hidden") {
$("#"+id_img_link_tool).attr("src",path_name_of_imglinktool);
if (my_image_tool=="visible.png") {
@ -96,12 +102,20 @@ $htmlHeadXtra[] ='<script type="text/javascript">
if (datos=="set_visible") {
$("#id_content_message").html("< div class = \"confirmation-message\" > ' . get_lang('LanguageIsNowVisible', '') . '< / div > ");
} else {
}
if (datos=="set_hidden") {
$("#id_content_message").html("< div class = \"confirmation-message\" > ' . get_lang('LanguageIsNowHidden', '') . '< / div > ");
}
}
var action = datos.split(":")[0];
if (action & & action == "confirm") {
var id = datos.split(":")[1];
var sure = "< div class = \"warning-message\" > '.get_lang('ThereAreUsersUsingThisLanguageYouWantToDisableThisLanguageAndSetTheUserWithTheDefaultPortalLanguage').'< / div > < a href = \"languages.php?action=make_unavailable_confirmed&id="+id+"\" class = \"btn\" > ' . get_lang('MakeUnavailable') . '< / a > ";
$("#id_content_message").html(sure);
}
} });
});
});
@ -118,49 +132,38 @@ $tbl_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT)
// we change the availability
if ($_GET['action'] == 'makeunavailable') {
if (isset($_GET['id']) & & $_GET['id'] == strval(intval($_GET['id']))) {
SubLanguageManager::make_unavailable_language($_GET['id']);
}
}
if ($_GET['action'] == 'makeavailable') {
if (isset($_GET['id']) & & $_GET['id'] == strval(intval($_GET['id']))) {
SubLanguageManager::make_available_language($_GET['id']);
}
}
if ($_GET['action'] == 'setplatformlanguage') {
if (isset($_GET['id']) & & $_GET['id'] == strval(intval($_GET['id']))) {
SubLanguageManager::set_platform_language($_GET['id']);
}
}
if ($_POST['Submit'])
{
if ($_POST['Submit']) {
// changing the name
$sql_update = "UPDATE $tbl_admin_languages SET original_name='{$_POST['txt_name']}' WHERE id='{$_POST['edit_id']}'";
$result = Database::query($sql_update);
// changing the Platform language
if ($_POST['platformlanguage'] & & $_POST['platformlanguage'] < > '')
{
if ($_POST['platformlanguage'] & & $_POST['platformlanguage'] < > '') {
//$sql_update_2 = "UPDATE $tbl_settings_current SET selected_value='{$_POST['platformlanguage']}' WHERE variable='platformLanguage'";
//$result_2 = Database::query($sql_update_2);
api_set_setting('platformLanguage', $_POST['platformlanguage'], null, null, $_configuration['access_url']);
}
}
elseif (isset($_POST['action']))
{
switch ($_POST['action'])
{
} elseif (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'makeavailable' :
if (count($_POST['id']) > 0)
{
if (count($_POST['id']) > 0) {
$ids = array();
foreach ($_POST['id'] as $index => $id)
{
foreach ($_POST['id'] as $index => $id) {
$ids[] = Database::escape_string($id);
}
$sql = "UPDATE $tbl_admin_languages SET available='1' WHERE id IN ('" . implode("','", $ids) . "')";
@ -168,11 +171,9 @@ elseif (isset($_POST['action']))
}
break;
case 'makeunavailable' :
if (count($_POST['id']) > 0)
{
if (count($_POST['id']) > 0) {
$ids = array();
foreach ($_POST['id'] as $index => $id)
{
foreach ($_POST['id'] as $index => $id) {
$ids[] = Database::escape_string($id);
}
$sql = "UPDATE $tbl_admin_languages SET available='0' WHERE id IN ('" . implode("','", $ids) . "')";
@ -197,11 +198,18 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
// including the header file (which includes the banner itself)
Display :: display_header($tool_name);
// displaying the naam of the tool
//api_display_tool_title($tool_name);
if (isset($_GET['action']) & & $_GET['action'] == 'make_unavailable_confirmed') {
$language_info = SubLanguageManager::get_all_information_of_language($_GET['id']);
if ($language_info['available'] == 1) {
SubLanguageManager::make_unavailable_language($_GET['id']);
$platform_language = api_get_setting('platformLanguage');
UserManager::update_all_user_languages($language_info['english_name'], $platform_language);
Display::display_confirmation_message(get_lang('LanguageIsNowHidden'));
}
}
// displaying the explanation for this tool
echo '< p > '.get_lang('PlatformLanguagesExplanation').'< / p > ';
Display::display_normal_message(get_lang('PlatformLanguagesExplanation')) ;
// selecting all the languages
$sql_select = "SELECT * FROM $tbl_admin_languages";
@ -234,8 +242,10 @@ while ($row = Database::fetch_array($result_select)) {
} else {
$row_td[] = $row['original_name'];
}
// the second column
$row_td[] = $row['english_name'];
// the third column
$row_td[] = $row['dokeos_folder'];
@ -244,6 +254,7 @@ while ($row = Database::fetch_array($result_select)) {
} else {
$setplatformlanguage = "< a href = \"javascript:if ( confirm ( ' " . addslashes ( get_lang ( ' AreYouSureYouWantToSetThisLanguageAsThePortalDefault ' ) ) . " ' ) ) { location . href = '" . api_get_self() . "?action=setplatformlanguage&id=" . $row[' id ' ] . " ' ; } \ " > " . Display::return_icon('languages_na.png', get_lang('SetLanguageAsDefault'), '', ICON_SIZE_SMALL) . "< / a > ";
}
if (api_get_setting('allow_use_sub_language') == 'true') {
$verified_if_is_sub_language = SubLanguageManager::check_if_language_is_sub_language($row['id']);
@ -263,19 +274,21 @@ while ($row = Database::fetch_array($result_select)) {
$allow_add_term_sub_language = " < a href = 'sub_language.php?action=registersublanguage&id=" . Security::remove_XSS($all_information_of_sub_language[' parent_id ' ] ) . " & sub_language_id = " . Security::remove_XSS($row['id']) . " ' > " . Display::return_icon('2rightarrow.gif', get_lang('AddWordForTheSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "< / a > ";
$allow_delete_sub_language = " < a href = 'sub_language_add.php?action=deletesublanguage&id=" . Security::remove_XSS($all_information_of_sub_language[' parent_id ' ] ) . " & sub_language_id = " . Security::remove_XSS($row['id']) . " ' > " . Display::return_icon('delete.png', get_lang('DeleteSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "< / a > ";
}
} else {
$allow_use_sub_language = '';
$allow_add_term_sub_language = '';
}
if ($row['english_name'] == $row_lang['selected_value']) {
$row_td[] = Display::return_icon('visible.png', get_lang('Visible'))."< a href = '" . api_get_self() . "?action=edit&id=" . $row[' id ' ] . " # value ' > " . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "< / a >
" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
} else {
if ($row['available'] == 1) {
$row_td[] = "< a class = \"make_visible_and_invisible\" id = \"linktool_" . $ row [ ' id ' ] . " \ " href = '" . api_get_self() . "?action=makeunavailable&id=" . $row[' id ' ] . " ' > " . Display::return_icon('visible.png', get_lang('MakeUnavailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "< / a > < a href = '" . api_get_self() . "?action=edit&id=" . $row[' id ' ] . " # value ' > " . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "< / a > " . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
//$row_td[] = "< a class = \"make_visible_and_invisible\" id = \"linktool_".$row['id']."\" href = 'javascript:void(0)' > ".Display::return_icon('visible.gif', get_lang('MakeUnavailable'),array('id'=>'imglinktool_'.$row['id']))."< / a > < a href = '".api_get_self()."?action=edit&id=".$row[' id ' ] . " # value ' > ".Display::return_icon('edit.gif', get_lang('Edit'))."< / a > ".$setplatformlanguage.$allow_use_sub_language.$allow_add_term_sub_language;
} else {
$row_td[] = "< a class = \"make_visible_and_invisible\" id = \"linktool_" . $ row [ ' id ' ] . " \ " href = '" . api_get_self() . "?action=makeavailable&id=" . $row[' id ' ] . " ' > " . Display::return_icon('invisible.png', get_lang('MakeAvailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "< / a > < a href = '" . api_get_self() . "?action=edit&id=" . $row[' id ' ] . " # value ' > " . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "< / a > " . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
//$row_td[] = "< a class = \"make_visible_and_invisible\" id = \"linktool_".$row['id']."\" href = 'javascript:void(0)' > ".Display::return_icon('invisible.gif', get_lang('MakeAvailable'),array('id'=>'imglinktool_'.$row['id']))."< / a > < a href = '".api_get_self()."?action=edit&id=".$row[' id ' ] . " # value ' > ".Display::return_icon('edit.gif', get_lang('Edit'))."< / a > ".$setplatformlanguage.$allow_use_sub_language.$allow_add_term_sub_language;
}
}
$language_data[] = $row_td;
}