From 036ff04ac0589da14de55db916960271e7afa1fd Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 24 Oct 2013 12:17:33 +0200 Subject: [PATCH] Minor - Formatting code. --- main/admin/access_url_edit.php | 93 +++++++++++++++++----------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/main/admin/access_url_edit.php b/main/admin/access_url_edit.php index 73d3d017e3..e60ca40a74 100644 --- a/main/admin/access_url_edit.php +++ b/main/admin/access_url_edit.php @@ -8,60 +8,62 @@ $language_file = 'admin'; $cidReset = true; require_once '../inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.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; + header('Location: index.php'); + exit; } -require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; - // Create the form $form = new FormValidator('add_url'); -if( $form->validate()) { - $check = Security::check_token('post'); - if($check) { - $url_array = $form->getSubmitValues(); - $url = Security::remove_XSS($url_array['url']); - $description = Security::remove_XSS($url_array['description']); - $active = intval($url_array['active']); - $url_id = $url_array['id']; - $url_to_go='access_urls.php'; - if ($url_id!='') { - //we can't change the status of the url with id=1 - if ($url_id==1) - $active=1; - //checking url - if (substr($url,strlen($url)-1, strlen($url))=='/') { - UrlManager::udpate($url_id, $url, $description, $active); - } else { - UrlManager::udpate($url_id, $url.'/', $description, $active); - } - // URL Images - $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/'; - $image_fields = array("url_image_1", "url_image_2", "url_image_3"); - foreach ($image_fields as $image_field) { - if ($_FILES[$image_field]['error'] == 0) { - // Hardcoded: only PNG files allowed - if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') { - move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png'); - } - // else fail silently - } - // else fail silently - } - $url_to_go='access_urls.php'; - $message=get_lang('URLEdited'); +if ($form->validate()) { + $check = Security::check_token('post'); + if ($check) { + $url_array = $form->getSubmitValues(); + $url = Security::remove_XSS($url_array['url']); + $description = Security::remove_XSS($url_array['description']); + $active = intval($url_array['active']); + $url_id = $url_array['id']; + $url_to_go='access_urls.php'; + if ($url_id != '') { + //we can't change the status of the url with id=1 + if ($url_id == 1) { + $active = 1; + } + //checking url + if (substr($url, strlen($url)-1, strlen($url)) == '/') { + UrlManager::udpate($url_id, $url, $description, $active); + } else { + UrlManager::udpate($url_id, $url.'/', $description, $active); + } + // URL Images + $url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/'; + $image_fields = array("url_image_1", "url_image_2", "url_image_3"); + foreach ($image_fields as $image_field) { + if ($_FILES[$image_field]['error'] == 0) { + // Hardcoded: only PNG files allowed + if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') { + move_uploaded_file( + $_FILES[$image_field]['tmp_name'], + $url_images_dir.$url_id.'_'.$image_field.'.png' + ); + } + // else fail silently + } + // else fail silently + } + $url_to_go='access_urls.php'; + $message=get_lang('URLEdited'); } else { $num = UrlManager::url_exist($url); if ($num == 0) { - //checking url - if (substr($url,strlen($url)-1, strlen($url))=='/') { + // checking url + if (substr($url, strlen($url)-1, strlen($url))=='/') { UrlManager::add($url, $description, $active); } else { //create @@ -103,7 +105,6 @@ if( $form->validate()) { $form->setConstants(array('sec_token' => $token)); } - $form->addElement('text','url', 'URL', array('class'=>'span6')); $form->addRule('url', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('url', '', 'maxlength',254); @@ -111,11 +112,9 @@ $form->addElement('textarea','description',get_lang('Description')); //the first url with id = 1 will be always active if ($_GET['url_id'] != 1) { - $form->addElement('checkbox','active',get_lang('Active')); + $form->addElement('checkbox','active', null, get_lang('Active')); } -//$form->addRule('checkbox', get_lang('ThisFieldIsRequired'), 'required'); - $defaults['url']='http://'; $form->setDefaults($defaults); @@ -133,8 +132,10 @@ if (isset($_GET['url_id'])) { $submit_name = get_lang('AddUrl'); } -if (!$_configuration['multiple_access_urls']) +if (!$_configuration['multiple_access_urls']) { header('Location: index.php'); + exit; +} $tool_name = get_lang('AddUrl'); $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));