1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | /** |
||
4 | * @author Julio Montoya <[email protected]> BeezNest 2011 |
||
5 | * |
||
6 | * @package chamilo.timeline |
||
7 | */ |
||
8 | require_once __DIR__.'/../inc/global.inc.php'; |
||
9 | |||
10 | $htmlHeadXtra[] = api_get_jqgrid_js(); |
||
11 | |||
12 | //$htmlHeadXtra[] = api_get_js('timeline/timeline-min.js'); |
||
13 | //$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/timeline/timeline.css'); |
||
14 | |||
15 | // setting breadcrumbs |
||
16 | //$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
||
17 | //$interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('CareersAndPromotions')); |
||
18 | |||
19 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
||
20 | |||
21 | $check = Security::check_token('request'); |
||
22 | $token = Security::get_token(); |
||
23 | $actions = ''; |
||
24 | $message = ''; |
||
25 | |||
26 | switch ($action) { |
||
27 | case 'add': |
||
28 | $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')]; |
||
29 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; |
||
30 | break; |
||
31 | case 'edit': |
||
32 | $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')]; |
||
33 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')]; |
||
34 | break; |
||
35 | case 'add_item': |
||
36 | $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Timeline')]; |
||
37 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('TimelineItem')]; |
||
38 | break; |
||
39 | default: |
||
40 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Timeline')]; |
||
41 | } |
||
42 | |||
43 | //jqgrid will use this URL to do the selects |
||
44 | $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_timelines'; |
||
45 | |||
46 | //The order is important you need to check the the $column variable in the model.ajax.php file |
||
47 | $columns = [get_lang('Name'), get_lang('Actions')]; |
||
48 | |||
49 | //Column config |
||
50 | $column_model = [ |
||
51 | ['name' => 'name', 'index' => 'name', 'width' => '120', 'align' => 'left'], |
||
52 | ['name' => 'actions', 'index' => 'actions', 'width' => '100', 'align' => 'left', 'sortable' => 'false'], |
||
53 | ]; |
||
54 | //Autowidth |
||
55 | $extra_params['autowidth'] = 'true'; |
||
56 | //height auto |
||
57 | $extra_params['height'] = 'auto'; |
||
58 | |||
59 | //With this function we can add actions to the jgrid (edit, delete, etc) |
||
60 | $htmlHeadXtra[] = ' |
||
61 | <script> |
||
62 | $(function() { |
||
63 | // grid definition see the $timeline->display() function |
||
64 | '.Display::grid_js('timelines', $url, $columns, $column_model, $extra_params, [], null, true).' |
||
65 | }); |
||
66 | </script>'; |
||
67 | $toolbarAction = ''; |
||
68 | $timeline = new Timeline(); |
||
69 | |||
70 | // Action handling: Add |
||
71 | switch ($action) { |
||
72 | case 'add': |
||
73 | if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
||
74 | api_not_allowed(); |
||
75 | } |
||
76 | $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']); |
||
77 | $form = $timeline->return_form($url, 'add'); |
||
78 | |||
79 | // The validation or display |
||
80 | if ($form->validate()) { |
||
81 | if ($check) { |
||
82 | $values = $form->exportValues(); |
||
83 | $res = $timeline->save($values); |
||
84 | if ($res) { |
||
85 | $message = Display::return_message(get_lang('ItemAdded'), 'success'); |
||
86 | } |
||
87 | } |
||
88 | $content = $timeline->listing(); |
||
89 | } else { |
||
90 | $actions .= '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
||
91 | $form->addElement('hidden', 'sec_token'); |
||
92 | $form->setConstants(['sec_token' => $token]); |
||
93 | $content = $form->return_form(); |
||
94 | } |
||
95 | break; |
||
96 | case 'edit': |
||
97 | // Action handling: Editing |
||
98 | $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']); |
||
99 | $form = $timeline->return_form($url, 'edit'); |
||
100 | |||
101 | // The validation or display |
||
102 | if ($form->validate()) { |
||
103 | if ($check) { |
||
104 | $values = $form->exportValues(); |
||
105 | //$timeline->update_all_promotion_status_by_career_id($values['id'],$values['status']); |
||
106 | $res = $timeline->update($values); |
||
107 | $message = Display::return_message(sprintf(get_lang('ItemUpdated'), $values['name']), 'confirmation'); |
||
108 | } |
||
109 | $timeline->display(); |
||
110 | } else { |
||
111 | $actions = '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
||
112 | $form->addElement('hidden', 'sec_token'); |
||
113 | $form->setConstants(['sec_token' => $token]); |
||
114 | $content = $form->return_form(); |
||
115 | } |
||
116 | break; |
||
117 | case 'add_item': |
||
118 | // Action handling: Editing |
||
119 | $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&parent_id='.intval($_GET['parent_id']); |
||
120 | $form = $timeline->return_item_form($url, 'edit'); |
||
121 | |||
122 | // The validation or display |
||
123 | if ($form->validate()) { |
||
124 | if ($check) { |
||
125 | $values = $form->exportValues(); |
||
126 | $values['type'] = ''; |
||
127 | //$timeline->update_all_promotion_status_by_career_id($values['id'],$values['status']); |
||
128 | $res = $timeline->save_item($values); |
||
129 | $message = Display::return_message(sprintf(get_lang('ItemUpdated'), $values['name']), 'confirmation'); |
||
130 | } |
||
131 | $timeline->display(); |
||
132 | } else { |
||
133 | $actions = '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
||
134 | $form->addElement('hidden', 'sec_token'); |
||
135 | $form->setConstants(['sec_token' => $token]); |
||
136 | $content = $form->return_form(); |
||
0 ignored issues
–
show
|
|||
137 | } |
||
138 | break; |
||
139 | case 'delete': |
||
140 | // Action handling: delete |
||
141 | if ($check) { |
||
142 | $res = $timeline->delete($_GET['id']); |
||
0 ignored issues
–
show
Are you sure the assignment to
$res is correct as $timeline->delete($_GET['id']) targeting Timeline::delete() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
143 | if ($res) { |
||
0 ignored issues
–
show
|
|||
144 | $message = Display::return_message(get_lang('ItemDeleted'), 'success'); |
||
145 | } |
||
146 | } |
||
147 | $content = $timeline->listing(); |
||
148 | break; |
||
149 | default: |
||
150 | $content = $timeline->listing(); |
||
151 | break; |
||
152 | } |
||
153 | |||
154 | $tpl = new Template(); |
||
155 | |||
156 | $tpl->assign('actions', $actions); |
||
157 | $tpl->assign('message', $message); |
||
158 | $tpl->assign('content', $content); |
||
159 | $tpl->display_one_col_template(); |
||
160 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.