Skip to content

Commit

Permalink
Careers: Add career_diagram_legend and career_diagram_disclaimer config
Browse files Browse the repository at this point in the history
In order to show a legend and a disclaimer below the career diagram

BT#18720
  • Loading branch information
jmontoyaa committed Jun 2, 2021
1 parent 74cfb85 commit 84b0a23
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
2 changes: 0 additions & 2 deletions main/auth/my_progress.php
Expand Up @@ -39,8 +39,6 @@
$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();
Expand Down
18 changes: 17 additions & 1 deletion main/inc/lib/career.lib.php
Expand Up @@ -500,7 +500,7 @@ public static function renderDiagram($careerInfo, $graph)
*
* @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)) {
Expand Down Expand Up @@ -792,6 +792,9 @@ public static function renderDiagramByColumn($careerInfo, $tpl, $loadUserIdData
$tpl->assign('vertex_list', $graph->elementList);

$graphHtml .= '<div id="graphContainer"></div>';
if ($showFooter) {
$graphHtml .= self::renderDiagramFooter();
}

return $graphHtml;
}
Expand Down Expand Up @@ -1411,4 +1414,17 @@ public static function createConnection($source, $target, $anchor = [])

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;
}
}
4 changes: 4 additions & 0 deletions main/inc/lib/sessionmanager.lib.php
Expand Up @@ -9740,6 +9740,10 @@ public static function getCareerDiagramPerSessionList($sessionList, $userId)
}
}

if (!empty($content)) {
$content .= Career::renderDiagramFooter();
}

return $content;
}

Expand Down
7 changes: 7 additions & 0 deletions main/install/configuration.dist.php
Expand Up @@ -1935,6 +1935,13 @@
// 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
Expand Down
2 changes: 1 addition & 1 deletion main/user/career_diagram.php
Expand Up @@ -85,7 +85,7 @@
$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;
Expand Down

0 comments on commit 84b0a23

Please sign in to comment.