Skip to content

Commit 5fac7f1

Browse files
committed
Add setting 'allow_career_diagram' see BT#12861
Allow careers to have a diagram based in a CSV file. Requires DB change: alter table extra_field_values modify column value longtext null;
1 parent e8aba6f commit 5fac7f1

File tree

9 files changed

+551
-13
lines changed

9 files changed

+551
-13
lines changed

main/admin/career_diagram.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/* For licensing terms, see /license.txt */
3+
4+
use ChamiloSession as Session;
5+
6+
/**
7+
* @package chamilo.admin
8+
*/
9+
10+
/*
11+
*
12+
* Requires extra_field_values.value to be longtext to save diagram:
13+
*
14+
update extra_field_values set created_at = null where created_at = '0000-00-00 00:00:00';
15+
update extra_field_values set updated_at = null where updated_at = '0000-00-00 00:00:00';
16+
17+
UPDATE extra_field_values SET created_at = NULL WHERE CAST(created_at AS CHAR(20)) = '0000-00-00 00:00:00';
18+
UPDATE extra_field_values SET updated_at = NULL WHERE CAST(updated_at AS CHAR(20)) = '0000-00-00 00:00:00';
19+
20+
alter table extra_field_values modify column value longtext null;
21+
22+
*/
23+
24+
$cidReset = true;
25+
require_once __DIR__.'/../inc/global.inc.php';
26+
27+
if (api_get_configuration_value('allow_career_diagram') == false) {
28+
api_not_allowed(true);
29+
}
30+
31+
$this_section = SECTION_PLATFORM_ADMIN;
32+
33+
api_protect_admin_script();
34+
35+
$htmlHeadXtra[] = api_get_js('jsplumb2.js');
36+
37+
$careerId = isset($_GET['id']) ? $_GET['id'] : 0;
38+
if (empty($careerId)) {
39+
api_not_allowed(true);
40+
}
41+
42+
// setting breadcrumbs
43+
$interbreadcrumb[] = array(
44+
'url' => 'index.php',
45+
'name' => get_lang('PlatformAdmin'),
46+
);
47+
$interbreadcrumb[] = array(
48+
'url' => 'career_dashboard.php',
49+
'name' => get_lang('CareersAndPromotions'),
50+
);
51+
52+
$interbreadcrumb[] = array(
53+
'url' => 'careers.php',
54+
'name' => get_lang('Careers'),
55+
);
56+
57+
$action = isset($_GET['action']) ? $_GET['action'] : null;
58+
59+
$check = Security::check_token('request');
60+
$token = Security::get_token();
61+
62+
if ($action == 'add') {
63+
$interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
64+
$tool_name = get_lang('Add');
65+
} elseif ($action == 'edit') {
66+
$interbreadcrumb[] = array('url' => 'careers.php', 'name' => get_lang('Careers'));
67+
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
68+
$tool_name = get_lang('Edit');
69+
} else {
70+
$tool_name = get_lang('Careers');
71+
}
72+
73+
$career = new Career();
74+
$careerInfo = $career->get($careerId);
75+
if (empty($careerInfo)) {
76+
api_not_allowed(true);
77+
}
78+
79+
$extraFieldValue = new ExtraFieldValue('career');
80+
$item = $extraFieldValue->get_values_by_handler_and_field_variable(
81+
$careerId,
82+
'career_diagram',
83+
false,
84+
false,
85+
false
86+
);
87+
88+
if (!empty($item) && isset($item['value']) && !empty($item['value'])) {
89+
$graph = unserialize($item['value']);
90+
$html = Display::page_header($careerInfo['name']);
91+
$html .= Career::renderDiagram($graph);
92+
$tpl = new Template('');
93+
$tpl->assign('content', $html);
94+
$tpl->display_one_col_template();
95+
}

main/admin/careers.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,16 @@
8181
//height auto
8282
$extra_params['height'] = 'auto';
8383

84+
$diagramLink = '';
85+
$allow = api_get_configuration_value('allow_career_diagram');
86+
if ($allow) {
87+
$diagramLink = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/career_diagram.php?id=\'+options.rowId+\'">'.get_lang('Diagram').'</a>';
88+
}
89+
8490
//With this function we can add actions to the jgrid (edit, delete, etc)
8591
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
8692
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
93+
$diagramLink.
8794
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>'.
8895
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
8996
'\';

0 commit comments

Comments
 (0)