This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * Copyright (c) STMicroelectronics, 2006. All Rights Reserved. |
||
4 | * |
||
5 | * Originally written by Mahmoud MAALEJ, 2006. STMicroelectronics. |
||
6 | * |
||
7 | * This file is a part of Codendi. |
||
8 | * |
||
9 | * Codendi is free software; you can redistribute it and/or modify |
||
10 | * it under the terms of the GNU General Public License as published by |
||
11 | * the Free Software Foundation; either version 2 of the License, or |
||
12 | * (at your option) any later version. |
||
13 | * |
||
14 | * Codendi is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with Codendi. If not, see <http://www.gnu.org/licenses/>. |
||
21 | */ |
||
22 | |||
23 | class GraphOnTrackersPlugin extends Plugin { |
||
24 | |||
25 | |||
26 | var $report_id; |
||
27 | var $chunksz; |
||
28 | var $offset; |
||
29 | var $advsrch; |
||
30 | var $morder; |
||
31 | var $prefs; |
||
32 | var $group_id; |
||
33 | var $atid; |
||
34 | var $set; |
||
35 | var $report_graphic_id; |
||
36 | var $allowedForProject; |
||
37 | |||
38 | /** |
||
39 | * Class constructor |
||
40 | * |
||
41 | * @param integer $id plugin id |
||
42 | */ |
||
43 | function GraphOnTrackersPlugin($id) { |
||
44 | $this->Plugin($id); |
||
45 | $this->setScope(Plugin::SCOPE_PROJECT); |
||
46 | |||
47 | $this->_addHook('cssfile', 'cssFile', false); |
||
48 | $this->_addHook('tracker_collapsable_sections', 'tracker_collapsable_sections', false); |
||
49 | $this->_addHook('tracker_urlparam_processing','tracker_urlparam_processing',false); |
||
50 | $this->_addHook('tracker_user_pref','tracker_user_pref',false); |
||
51 | $this->_addHook('tracker_form_browse_add_in','tracker_form_browse_add_in',false); |
||
52 | $this->_addHook('tracker_after_report','tracker_after_report',false); |
||
53 | $this->_addHook('tracker_graphic_report_admin','tracker_graphic_report_admin',false); |
||
54 | $this->_addHook('tracker_graphic_report_add_link','tracker_graphic_report_add_link',false); |
||
55 | $this->_addHook('tracker_graphic_report_admin_header','tracker_graphic_report_admin_header',false); |
||
56 | $this->_addHook('graphontrackers_load_chart_factories', 'graphontrackers_load_chart_factories', false); |
||
57 | $this->_addHook('artifactType_created', 'copy_graphical_reports', false); |
||
58 | $this->_addHook('artifactType_deleted', 'delete_graphical_reports', false); |
||
59 | $this->allowedForProject = array(); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * function to get plugin info |
||
64 | * |
||
65 | */ |
||
66 | function &getPluginInfo() { |
||
67 | if (!is_a($this->pluginInfo, 'GraphOnTrackersPluginInfo')) { |
||
68 | require_once('GraphOnTrackersPluginInfo.class.php'); |
||
69 | $this->pluginInfo = new GraphOnTrackersPluginInfo($this); |
||
70 | } |
||
71 | return $this->pluginInfo; |
||
72 | } |
||
73 | |||
74 | function tracker_collapsable_sections($params) { |
||
75 | $params['sections'][] = 'charts'; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Return true if current project has the right to use this plugin. |
||
80 | */ |
||
81 | function isAllowed() { |
||
82 | $request =& HTTPRequest::instance(); |
||
83 | $group_id = (int) $request->get('group_id'); |
||
84 | if(!isset($this->allowedForProject[$group_id])) { |
||
85 | $pM =& PluginManager::instance(); |
||
86 | $this->allowedForProject[$group_id] = $pM->isPluginAllowedForProject($this, $group_id); |
||
87 | } |
||
88 | return $this->allowedForProject[$group_id]; |
||
89 | } |
||
90 | |||
91 | function cssFile($params) { |
||
92 | // Only show the stylesheet if we're actually in the Docman pages. |
||
93 | // This stops styles inadvertently clashing with the main site. |
||
94 | if (strpos($_SERVER['REQUEST_URI'], '/tracker/admin/') === 0) { |
||
95 | echo '<link rel="stylesheet" type="text/css" href="'.$this->getThemePath().'/css/style.css" />'."\n"; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | function graphontrackers_load_chart_factories($params) { |
||
100 | require_once('data-access/GraphOnTrackers_Chart_Bar.class.php'); |
||
101 | require_once('data-access/GraphOnTrackers_Chart_Pie.class.php'); |
||
102 | require_once('data-access/GraphOnTrackers_Chart_Gantt.class.php'); |
||
103 | $params['factories']['pie'] = array( |
||
104 | 'chart_type' => 'pie', |
||
105 | 'chart_classname' => 'GraphOnTrackers_Chart_Pie', |
||
106 | 'icon' => $this->getThemePath().'/images/chart_pie.png', |
||
107 | 'title' => $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','pie'), |
||
108 | ); |
||
109 | $params['factories']['bar'] = array( |
||
110 | 'chart_type' => 'bar', |
||
111 | 'chart_classname' => 'GraphOnTrackers_Chart_Bar', |
||
112 | 'icon' => $this->getThemePath().'/images/chart_bar.png', |
||
113 | 'title' => $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','bar'), |
||
114 | ); |
||
115 | $params['factories']['gantt'] = array( |
||
116 | 'chart_type' => 'gantt', |
||
117 | 'chart_classname' => 'GraphOnTrackers_Chart_Gantt', |
||
118 | 'icon' => $this->getThemePath().'/images/chart_gantt.png', |
||
119 | 'title' => $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','gantt'), |
||
120 | ); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Hook to add watch and ganttscale preferences to variable url who |
||
125 | * belong to displayReport method . |
||
126 | * Used in www/tracker/include/ArtifactReportHtml.class.php |
||
127 | * |
||
128 | * @param params:hook parameters |
||
129 | */ |
||
130 | function tracker_urlparam_processing($params){ |
||
131 | if($this->isAllowed()) { |
||
132 | if ($this->report_graphic_id!="0"){ |
||
133 | $params['url'] .= "&report_graphic_id=".$this->report_graphic_id; |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * Hook to set all user preferences . |
||
140 | * |
||
141 | * @param params:hook parameters |
||
142 | */ |
||
143 | function tracker_user_pref($params){ |
||
144 | if($this->isAllowed()) { |
||
145 | $this->group_id = $params['group_id']; |
||
146 | $this->atid = $params['atid']; |
||
147 | $this->report_id = $params['report_id']; |
||
148 | $this->prefs = $params['prefs']; |
||
149 | $this->morder = $params['morder']; |
||
150 | $this->chunksz = $params['chunksz']; |
||
151 | $this->advsrch = $params['advsrch']; |
||
152 | $this->msort = $params['msort']; |
||
153 | $this->offset = $params['offset']; |
||
154 | $this->set = $params['set']; |
||
155 | $request = & HTTPRequest::instance(); |
||
156 | |||
157 | $func = $request->get('func'); |
||
158 | $set = $request->get('set'); |
||
159 | if ($request->get('report_graphic_id') !== false && $request->valid(new Valid_UInt('report_graphic_id'))) { |
||
160 | $this->report_graphic_id = $request->get('report_graphic_id'); |
||
161 | $trackerGraphsPrefs = "&report_graphic_id=".$this->report_graphic_id; |
||
162 | if ($trackerGraphsPrefs != user_get_preference('tracker_graph_brow_cust'.$request->get('atid'))){ |
||
163 | user_set_preference('tracker_graph_brow_cust'.$request->get('atid'),$trackerGraphsPrefs); |
||
164 | } |
||
165 | } else { |
||
166 | if (user_isloggedin()) { |
||
167 | $custom_pref=user_get_preference('tracker_graph_brow_cust'.$this->atid); |
||
168 | if ($custom_pref) { |
||
169 | $pref_arr = explode('&',substr($custom_pref,1)); |
||
170 | while (list(,$expr) = each($pref_arr)) { |
||
171 | list($field,$value_id) = explode('=',$expr); |
||
172 | $field = str_replace('[]','',$field); |
||
173 | if($field == 'report_graphic_id') { |
||
174 | $this->report_graphic_id = $value_id; |
||
175 | } |
||
176 | } |
||
177 | } |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * Hook to display the charts. |
||
185 | * Used in www/tracker/browse.php |
||
186 | * |
||
187 | * @param params:hook parameters |
||
188 | */ |
||
189 | function tracker_after_report($params){ |
||
190 | if($this->isAllowed()) { |
||
191 | require_once('html-generators/GraphicEngineHtml.class.php'); |
||
192 | $eng = new graphicEngineHtml($this->atid,user_getid(),$this->getThemePath()); |
||
193 | $eng->displayReportGraphic($this->report_graphic_id, $params['group_id'], $params['atid'], $params['url']); |
||
194 | } |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * Hook to admin graphic reports |
||
199 | * Used in www/tracker/admin/index.php |
||
200 | * |
||
201 | * @param params:hook parameters |
||
202 | */ |
||
203 | function tracker_graphic_report_admin($params){ |
||
204 | |||
205 | $request = HTTPRequest::instance(); |
||
206 | if ($request->valid(new Valid_WhiteList('func', array('reportgraphic'))) && $request->valid(new Valid_UInt('atid'))) { |
||
207 | $func = $request->get('func'); |
||
208 | $atid = $request->get('atid'); |
||
209 | if ($func == 'reportgraphic') { |
||
210 | require_once('html-generators/GraphicEngineHtml.class.php'); |
||
211 | require_once('data-access/GraphOnTrackers_Report.class.php'); |
||
212 | |||
213 | if ( !user_isloggedin() ) { |
||
214 | exit_not_logged_in(); |
||
215 | return; |
||
216 | } |
||
217 | |||
218 | $user_id = UserManager::instance()->getCurrentUser()->getId(); |
||
219 | $geh = new graphicEngineHtml($atid, $user_id, $this->getThemePath()); |
||
220 | if ($request->exist('create_report_graphic') && $request->get('rep_name')) { |
||
221 | if ($GLOBALS['ath']->userIsAdmin() && $request->valid(new Valid_WhiteList('rep_scope', array('P', 'I')))) { |
||
222 | $rep_scope = $request->get('rep_scope'); |
||
223 | } else { |
||
224 | $rep_scope = 'I'; |
||
225 | } |
||
226 | if ($report = GraphOnTrackers_Report::create($atid, |
||
227 | $user_id, |
||
228 | $request->get('rep_name'), |
||
229 | $request->get('rep_desc'), |
||
230 | $rep_scope)) { |
||
231 | $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','new_created_report')); |
||
232 | $GLOBALS['Response']->redirect('/tracker/admin/?func=reportgraphic&group_id='.$report->getGroupId().'&atid='.$report->getAtid().'&report_graphic_id='.$report->getId()); |
||
233 | } |
||
234 | } else { |
||
235 | $report_graphic_id = $request->getValidated('report_graphic_id', 'uint', 0); |
||
236 | |||
237 | $gr = new GraphOnTrackers_Report($report_graphic_id); |
||
238 | |||
239 | if ($gr->getScope() != 'P' || $GLOBALS['ath']->userIsAdmin()) { |
||
240 | if ($request->exist('update_report')) { |
||
241 | if ($request->valid(new Valid_String('rep_name')) |
||
242 | && $request->valid(new Valid_String('rep_desc')) |
||
243 | && $request->valid(new Valid_WhiteList('rep_scope', array('I', 'P'))) |
||
244 | ) { |
||
245 | $rep_name = $request->get('rep_name'); |
||
246 | $rep_desc = $request->get('rep_desc'); |
||
247 | $rep_scope = $request->get('rep_scope'); |
||
248 | |||
249 | if ($rep_name != $gr->getName() || $rep_desc != $gr->getDescription() || $rep_scope != $gr->getScope()) { |
||
250 | $gr->setName($rep_name); |
||
251 | $gr->setDescription($rep_desc); |
||
252 | $gr->setScope($rep_scope); |
||
253 | $gr->setUserId(UserManager::instance()->getCurrentUser()->getId()); |
||
254 | if ($gr->update()) { |
||
255 | $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','updated_report')); |
||
256 | } else { |
||
257 | $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','not_updated_report').': '.$gr->getErrorMessage()); |
||
258 | } |
||
259 | } |
||
260 | } |
||
261 | } else if (is_array($request->get('delete_chart'))) { |
||
262 | $chart_id_to_delete = (int)key($request->get('delete_chart')); |
||
263 | $gr->deleteChart($chart_id_to_delete); |
||
264 | $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','updated_report')); |
||
265 | $GLOBALS['Response']->redirect('/tracker/admin/?func=reportgraphic&group_id='.$gr->getGroupId().'&atid='.$gr->getAtid().'&report_graphic_id='.$gr->getId()); |
||
266 | } else if ($request->exist('update_chart') && is_array($request->get('chart'))) { |
||
267 | $row = $request->get('chart'); |
||
268 | if (isset($row['id'])) { |
||
269 | $chart_to_edit = $gr->getChart($row['id']); |
||
270 | if ($chart_to_edit->update($row)) { |
||
271 | $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','updated_report')); |
||
272 | } |
||
273 | } |
||
274 | } else if ($request->exist('edit_chart')) { |
||
275 | $chart_to_edit = $gr->getChart((int)($request->get('edit_chart'))); |
||
276 | } else if ($request->exist('add_chart')) { |
||
277 | if ($chart = $gr->createChart($request->get('add_chart'))) { |
||
278 | $GLOBALS['Response']->redirect('/tracker/admin/?func=reportgraphic&group_id='.$gr->getGroupId().'&atid='.$gr->getAtid().'&report_graphic_id='.$gr->getId().'&edit_chart='. (int)$chart->getId()); |
||
279 | } |
||
280 | } else if ($request->exist('delete_report_graphic')) { |
||
281 | $gr->delete(); |
||
282 | $report_graphic_id = null; |
||
283 | $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','report_deleted')); |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | |||
288 | $GLOBALS['ath']->adminHeader(array ('title'=> $GLOBALS['Language']->getText('plugin_graphontrackers_include_report','report_mgmt'), |
||
289 | 'help' => 'tracker-v3.html#tracker-graphical-report-setting')); |
||
290 | |||
291 | if ($request->exist('new_report_graphic')) { |
||
292 | $geh->createReportForm(); |
||
293 | } else if ($report_graphic_id) { |
||
294 | if (isset($chart_to_edit)){ |
||
295 | $geh->showChartForm($chart_to_edit); |
||
296 | } else { |
||
297 | $geh->showReportForm($report_graphic_id); |
||
298 | } |
||
299 | } else { |
||
300 | // Front page |
||
301 | $reports = $geh->grf->getReportsAvailable($atid, user_getid()); |
||
0 ignored issues
–
show
|
|||
302 | $geh->showAvailableReports($reports); |
||
303 | } |
||
304 | $GLOBALS['ath']->footer(null); |
||
305 | exit; |
||
0 ignored issues
–
show
The method
tracker_graphic_report_admin() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
306 | } |
||
307 | } |
||
308 | } |
||
309 | |||
310 | /** |
||
311 | * Hook to add graphic reports administration link |
||
312 | * Used in www/tracker/admin/index.php |
||
313 | * |
||
314 | * @param params:hook parameters |
||
315 | */ |
||
316 | function tracker_graphic_report_add_link($params) { |
||
317 | $request =& HTTPRequest::instance(); |
||
318 | if ($request->valid(new Valid_GroupId())) { |
||
319 | echo '<H3><A href="/tracker/admin/?func=reportgraphic&group_id='.$request->get('group_id').'&atid='.$request->get('atid').'">'.$GLOBALS['Language']->getText('plugin_graphontrackers_admin_menu','manage_graphic').'</A></H3>'; |
||
320 | echo $GLOBALS['Language']->getText('plugin_graphontrackers_admin_menu','manage_graphic_desc'); |
||
321 | } |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * Hook to add graphic reports administration administration |
||
326 | * Used in www/tracker/include/ArtifactTypeHtml.class.php |
||
327 | * |
||
328 | * @param params:hook parameters |
||
329 | */ |
||
330 | function tracker_graphic_report_admin_header($params) { |
||
331 | $request =& HTTPRequest::instance(); |
||
332 | if ($request->valid(new Valid_GroupId())) { |
||
333 | echo ' | <a href="/tracker/admin/?func=reportgraphic&group_id='.$request->get('group_id').'&atid='.$request->get('atid').'">'.$GLOBALS['Language']->getText('plugin_graphontrackers_admin_menu','graphic_report').'</a>'; |
||
334 | } |
||
335 | } |
||
336 | /** |
||
337 | * Hook to copy graphic reports afer trackers reports are copied, when trackers are created. |
||
338 | * Used in src/common/tracker/ArtifactTypeFactory.class.php |
||
339 | * |
||
340 | * @param params:hook parameters |
||
341 | */ |
||
342 | function copy_graphical_reports($params){ |
||
343 | require_once('data-access/GraphOnTrackers_ReportFactory.class.php'); |
||
344 | |||
345 | $atid_source=$params['atid_source']; |
||
346 | $atid_dest=$params['atid_dest']; |
||
347 | |||
348 | $rf = new GraphOnTrackers_ReportFactory(); |
||
349 | $rf->copyReports($atid_source, $atid_dest); |
||
350 | } |
||
351 | |||
352 | /** |
||
353 | * Hook to delete graphic reports afer tracker reports are deleted, when trackers are deleted. |
||
354 | * Used in src/common/tracker/ArtifactTypeFactory.class.php |
||
355 | * |
||
356 | * @param params:hook parameters |
||
357 | */ |
||
358 | function delete_graphical_reports($params){ |
||
359 | require_once('data-access/GraphOnTrackers_Report.class.php'); |
||
360 | $atid=$params['atid']; |
||
361 | $sql = "SELECT report_graphic_id FROM plugin_graphontrackers_report_graphic WHERE group_artifact_id='".db_ei($atid)."'"; |
||
362 | $res = db_query($sql); |
||
363 | while ($report_array = db_fetch_array($res)) { |
||
364 | $report_graphic_id = db_ei($report_array["report_graphic_id"]); |
||
365 | $gr = new GraphOnTrackers_Report($report_graphic_id); |
||
366 | $gr->delete(); |
||
367 | } |
||
368 | } |
||
369 | } |
||
370 | |||
371 | ?> |
||
372 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.