From 84b0a23480e8a271ab4fc832a63beae0f4b33de2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 2 Jun 2021 11:08:34 +0200 Subject: [PATCH] Careers: Add career_diagram_legend and career_diagram_disclaimer config In order to show a legend and a disclaimer below the career diagram BT#18720 --- main/auth/my_progress.php | 2 -- main/inc/lib/career.lib.php | 18 +++++++++++++++++- main/inc/lib/sessionmanager.lib.php | 4 ++++ main/install/configuration.dist.php | 7 +++++++ main/user/career_diagram.php | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/main/auth/my_progress.php b/main/auth/my_progress.php index 4eb308d34d..d220aace85 100755 --- a/main/auth/my_progress.php +++ b/main/auth/my_progress.php @@ -39,8 +39,6 @@ $courseUserList = CourseManager::get_courses_list_by_user_id($user_id); $dates = $issues = ''; $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0; $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; -$allowCareerUser = api_get_configuration_value('allow_career_users'); - $showGraph = false === api_get_configuration_value('hide_session_graph_in_my_progress'); $isAllowedToEdit = api_is_allowed_to_edit(); diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index ed0ffb7f2b..0364d739ab 100755 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -500,7 +500,7 @@ class Career extends Model * * @return string */ - public static function renderDiagramByColumn($careerInfo, $tpl, $loadUserIdData = 0) + public static function renderDiagramByColumn($careerInfo, $tpl, $loadUserIdData = 0, $showFooter = true) { $careerId = isset($careerInfo['id']) ? $careerInfo['id'] : 0; if (empty($careerId)) { @@ -792,6 +792,9 @@ class Career extends Model $tpl->assign('vertex_list', $graph->elementList); $graphHtml .= '
'; + if ($showFooter) { + $graphHtml .= self::renderDiagramFooter(); + } return $graphHtml; } @@ -1411,4 +1414,17 @@ class Career extends Model return $html; } + + public static function renderDiagramFooter(): string + { + $footer = ''; + if (api_get_configuration_value('career_diagram_legend')) { + $footer .= get_lang('CareerDiagramLegend'); + } + if (api_get_configuration_value('career_diagram_disclaimer')) { + $footer .= get_lang('CareerDiagramDisclaimer'); + } + + return $footer; + } } diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 496ee7ba37..0f12edbde9 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -9740,6 +9740,10 @@ class SessionManager } } + if (!empty($content)) { + $content .= Career::renderDiagramFooter(); + } + return $content; } diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 31976ac1e2..57bad03631 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1935,6 +1935,13 @@ ALTER TABLE gradebook_comment ADD CONSTRAINT FK_C3B70763AD3ED51C FOREIGN KEY (gr // Allows the use of the external id instead of the internal id. //$_configuration['use_career_external_id_as_identifier_in_diagrams'] = true; +// Add a career legend below the diagram, a variable will be called +// get_lang('CareerDiagramLegend') and printed below a diagram +// $_configuration['career_diagram_legend'] = true; + +// If true then a variable will be called get_lang('CareerDiagramDisclaimer') and printed below a diagram; +//$_configuration['career_diagram_disclaimer'] = true; + // KEEP THIS AT THE END // -------- Custom DB changes // Add user activation by confirmation email diff --git a/main/user/career_diagram.php b/main/user/career_diagram.php index a4e8817f42..82fdbe858b 100644 --- a/main/user/career_diagram.php +++ b/main/user/career_diagram.php @@ -85,7 +85,7 @@ if (!empty($itemUrls) && !empty($itemUrls['value'])) { $showFullPage = isset($_REQUEST['iframe']) && 1 === (int) $_REQUEST['iframe'] ? false : true; $tpl = new Template(get_lang('Diagram'), $showFullPage, $showFullPage, !$showFullPage); $html = Display::page_subheader2($careerInfo['name'].$urlToString); -$diagram = Career::renderDiagramByColumn($careerInfo, $tpl, $userId); +$diagram = Career::renderDiagramByColumn($careerInfo, $tpl, $userId, !$showFullPage); if (!empty($diagram)) { $html .= $diagram;