From 3ad9dee5e6e954dc1a70874fed0d907c227a560b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 10 Apr 2014 12:57:04 +0200 Subject: [PATCH] Adding origin parameter in api_get_cid_req() see BT#7688 --- main/inc/lib/display.lib.php | 7 ++++- main/inc/lib/main_api.lib.php | 50 ++++++++++++++++++++++++++--------- main/work/work.php | 17 +++--------- main/work/work_list.php | 2 +- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index c79549b5f2..507adb633d 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -60,7 +60,12 @@ class Display */ public static function display_header($tool_name ='', $help = null, $page_header = null) { - self::$global_template = new Template($tool_name); + $origin = api_get_origin(); + $showHeader = true; + if (isset($origin) && $origin == 'learnpath') { + $showHeader = false; + } + self::$global_template = new Template($tool_name, $showHeader, $showHeader); // Fixing tools with any help it takes xxx part of main/xxx/index.php if (empty($help)) { diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index f3bcf5ff6e..4efd749112 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -1327,18 +1327,22 @@ function api_get_anonymous_id() { * @see Uri.course_params */ function api_get_cidreq($add_session_id = true, $add_group_id = true) { - $url = empty($GLOBALS['_cid']) ? '' : 'cidReq='.htmlspecialchars($GLOBALS['_cid']); - if ($add_session_id) { - if (!empty($url)) { + $url = empty($GLOBALS['_cid']) ? '' : 'cidReq='.htmlspecialchars($GLOBALS['_cid']); + $origin = api_get_origin(); + if ($add_session_id) { + if (!empty($url)) { $url .= api_get_session_id() == 0 ? '&id_session=0' : '&id_session='.api_get_session_id(); - } - } - if ($add_group_id) { - if (!empty($url)) { + } + } + if ($add_group_id) { + if (!empty($url)) { $url .= api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq='.api_get_group_id(); - } - } - return $url; + } + } + + $url .= '&origin='.$origin; + + return $url; } /** @@ -7092,17 +7096,37 @@ function api_get_protocol() /** * Return a string where " are replaced with 2 ' - * It is usefull when you pass a PHP variable in a Javascript browser dialog + * It is useful when you pass a PHP variable in a Javascript browser dialog * e.g. : alert(""); * and message contains character " - * @param $in_text + * + * @param string $in_text + * @return string */ function convert_double_quote_to_single($in_text) { return api_preg_replace('/"/', "''", $in_text); } - +/** + * Is unoconv installed + * @return bool + */ function api_is_unoconv_installed() { return false; } + +/** + * Get origin + * + * @param string + * @return string + **/ +function api_get_origin() +{ + if (isset($_REQUEST['origin'])) { + return $_REQUEST['origin'] == 'learnpath' ? 'learnpath' : null; + } + + return null; +} diff --git a/main/work/work.php b/main/work/work.php index 6e8ed04cbb..9b5e7dd1e2 100644 --- a/main/work/work.php +++ b/main/work/work.php @@ -58,7 +58,6 @@ $link_target_parameter = ""; // e.g. "target=\"_blank\""; $display_list_users_without_publication = isset($_GET['list']) && Security::remove_XSS($_GET['list']) == 'without' ? true : false; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list'; - //Download folder if ($action == 'downloadfolder') { require 'downloadfolder.inc.php'; @@ -113,7 +112,7 @@ if (!empty($group_id)) { $interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('CreateAssignment')); } } else { - if (isset($origin) && $origin != 'learnpath') { + if ($origin != 'learnpath') { if (isset($_GET['id']) && !empty($_GET['id']) || $display_upload_form || $action == 'settings' || $action == 'create_dir') { $interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications')); @@ -272,13 +271,7 @@ switch ($action) { break; } -if (isset($origin) && $origin != 'learnpath') { - Display :: display_header(null); -} else { - // We are in the learnpath tool - Display::display_reduced_header(); -} - +Display :: display_header(null); Display::display_introduction_section(TOOL_STUDENTPUBLICATION); if ($origin == 'learnpath') { @@ -290,10 +283,6 @@ display_action_links($work_id, $curdirpath, $action); $message = Session::read('message'); echo $message; Session::erase('message'); - echo $content; -if ($origin != 'learnpath') { - //we are not in the learning path tool - Display :: display_footer(); -} +Display::display_footer(); diff --git a/main/work/work_list.php b/main/work/work_list.php index 781120e100..dcb5968c26 100644 --- a/main/work/work_list.php +++ b/main/work/work_list.php @@ -15,7 +15,7 @@ require_once 'work.lib.php'; $this_section = SECTION_COURSES; $workId = isset($_GET['id']) ? intval($_GET['id']) : null; -$origin = isset($origin) ? Security::remove_XSS($origin) : null; +$origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : ''; if (empty($workId)) { api_not_allowed(true);