*/
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
//api_protect_admin_script();
api_protect_global_admin_script();
if (!api_get_multiple_access_url()) {
header('Location: index.php');
exit;
}
$interbreadcrumb[] = array ("url" => 'index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = get_lang('MultipleAccessURLs');
Display :: display_header($tool_name);
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
$my_user_url_list = api_get_access_url_from_user(api_get_user_id());
$current_access_url_id = api_get_current_access_url_id();
$url_list = UrlManager::get_url_data();
// Actions
if (isset ($_GET['action'])) {
if ($_GET['action'] == 'show_message')
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
$check = Security::check_token('get');
if ($check) {
$url_id=Database::escape_string($_GET['url_id']);
switch ($_GET['action']) {
case 'delete_url' :
$result = UrlManager::delete($url_id);
if ($result) {
Display :: display_normal_message(get_lang('URLDeleted'));
} else {
Display :: display_error_message(get_lang('CannotDeleteURL'));
}
break;
case 'lock' :
UrlManager::set_url_status('lock',$url_id);
Display :: display_normal_message(get_lang('URLInactive'));
break;
case 'unlock';
UrlManager::set_url_status('unlock',$url_id);
Display :: display_normal_message(get_lang('URLActive'));
break;
case 'register';
// we are going to register the admin
if(api_is_platform_admin()) {
if($current_access_url_id!=-1) {
$url_str = '';
foreach($url_list as $my_url) {
if (!in_array($my_url['id'],$my_user_url_list)){
UrlManager::add_user_to_url(api_get_user_id(),$my_url['id']);
$url_str.=$my_url['url'].'
';
}
}
Display :: display_normal_message(get_lang('AdminUserRegisteredToThisURL').': '.$url_str.'
',false);
}
}
break;
}
}
Security::clear_token();
}
$parameters['sec_token'] = Security::get_token();
// checking if the admin is registered in all sites
$url_string='';
$my_user_url_list = api_get_access_url_from_user(api_get_user_id());
foreach($url_list as $my_url) {
if (!in_array($my_url['id'],$my_user_url_list)){
$url_string.=$my_url['url'].'
';
}
}
if(!empty($url_string)) {
Display :: display_warning_message(get_lang('AdminShouldBeRegisterInSite').'
'.$url_string,false);
}
// checking the current installation
if ($current_access_url_id==-1) {
Display :: display_warning_message(get_lang('URLNotConfiguredPleaseChangedTo').': '.api_get_path(WEB_PATH));
} elseif(api_is_platform_admin()) {
$quant= UrlManager::relation_url_user_exist(api_get_user_id(),$current_access_url_id);
if ($quant==0) {
Display :: display_warning_message(''.get_lang('ClickToRegisterAdmin').'',false);
}
}
// action menu
echo '