@@ -29,7 +29,7 @@ |
||
29 | 29 | * of elements as $to_lines. |
30 | 30 | */ |
31 | 31 | function Text_Diff_Mapped($from_lines, $to_lines, |
32 | - $mapped_from_lines, $mapped_to_lines) |
|
32 | + $mapped_from_lines, $mapped_to_lines) |
|
33 | 33 | { |
34 | 34 | assert(count($from_lines) == count($mapped_from_lines)); |
35 | 35 | assert(count($to_lines) == count($mapped_to_lines)); |
@@ -124,9 +124,9 @@ |
||
124 | 124 | array_push($edits, |
125 | 125 | new Text_Diff_Op_copy( |
126 | 126 | $this->_getLines($from_lines, $from_line_no, |
127 | - $from_line_no + count($from_lines) - 1), |
|
127 | + $from_line_no + count($from_lines) - 1), |
|
128 | 128 | $this->_getLines($to_lines, $to_line_no, |
129 | - $to_line_no + count($to_lines) - 1))); |
|
129 | + $to_line_no + count($to_lines) - 1))); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $edits; |
@@ -6,17 +6,17 @@ |
||
6 | 6 | class PEAR5 |
7 | 7 | { |
8 | 8 | /** |
9 | - * If you have a class that's mostly/entirely static, and you need static |
|
10 | - * properties, you can use this method to simulate them. Eg. in your method(s) |
|
11 | - * do this: $myVar = &PEAR5::getStaticProperty('myclass', 'myVar'); |
|
12 | - * You MUST use a reference, or they will not persist! |
|
13 | - * |
|
14 | - * @access public |
|
15 | - * @param string $class The calling classname, to prevent clashes |
|
16 | - * @param string $var The variable to retrieve. |
|
17 | - * @return mixed A reference to the variable. If not set it will be |
|
18 | - * auto initialised to NULL. |
|
19 | - */ |
|
9 | + * If you have a class that's mostly/entirely static, and you need static |
|
10 | + * properties, you can use this method to simulate them. Eg. in your method(s) |
|
11 | + * do this: $myVar = &PEAR5::getStaticProperty('myclass', 'myVar'); |
|
12 | + * You MUST use a reference, or they will not persist! |
|
13 | + * |
|
14 | + * @access public |
|
15 | + * @param string $class The calling classname, to prevent clashes |
|
16 | + * @param string $var The variable to retrieve. |
|
17 | + * @return mixed A reference to the variable. If not set it will be |
|
18 | + * auto initialised to NULL. |
|
19 | + */ |
|
20 | 20 | static function &getStaticProperty($class, $var) |
21 | 21 | { |
22 | 22 | static $properties; |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | { |
235 | 235 | $trace = $this->getTraceSafe(); |
236 | 236 | $cause = array('class' => get_class($this), |
237 | - 'message' => $this->message, |
|
238 | - 'file' => 'unknown', |
|
239 | - 'line' => 'unknown'); |
|
237 | + 'message' => $this->message, |
|
238 | + 'file' => 'unknown', |
|
239 | + 'line' => 'unknown'); |
|
240 | 240 | if (isset($trace[0])) { |
241 | 241 | if (isset($trace[0]['file'])) { |
242 | 242 | $cause['file'] = $trace[0]['file']; |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | $this->cause->getCauseMessage($causes); |
249 | 249 | } elseif ($this->cause instanceof Exception) { |
250 | 250 | $causes[] = array('class' => get_class($this->cause), |
251 | - 'message' => $this->cause->getMessage(), |
|
252 | - 'file' => $this->cause->getFile(), |
|
253 | - 'line' => $this->cause->getLine()); |
|
251 | + 'message' => $this->cause->getMessage(), |
|
252 | + 'file' => $this->cause->getFile(), |
|
253 | + 'line' => $this->cause->getLine()); |
|
254 | 254 | } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) { |
255 | 255 | $causes[] = array('class' => get_class($this->cause), |
256 | - 'message' => $this->cause->getMessage(), |
|
257 | - 'file' => 'unknown', |
|
258 | - 'line' => 'unknown'); |
|
256 | + 'message' => $this->cause->getMessage(), |
|
257 | + 'file' => 'unknown', |
|
258 | + 'line' => 'unknown'); |
|
259 | 259 | } elseif (is_array($this->cause)) { |
260 | 260 | foreach ($this->cause as $cause) { |
261 | 261 | if ($cause instanceof PEAR_Exception) { |
262 | 262 | $cause->getCauseMessage($causes); |
263 | 263 | } elseif ($cause instanceof Exception) { |
264 | 264 | $causes[] = array('class' => get_class($cause), |
265 | - 'message' => $cause->getMessage(), |
|
266 | - 'file' => $cause->getFile(), |
|
267 | - 'line' => $cause->getLine()); |
|
265 | + 'message' => $cause->getMessage(), |
|
266 | + 'file' => $cause->getFile(), |
|
267 | + 'line' => $cause->getLine()); |
|
268 | 268 | } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) { |
269 | 269 | $causes[] = array('class' => get_class($cause), |
270 | - 'message' => $cause->getMessage(), |
|
271 | - 'file' => 'unknown', |
|
272 | - 'line' => 'unknown'); |
|
270 | + 'message' => $cause->getMessage(), |
|
271 | + 'file' => 'unknown', |
|
272 | + 'line' => 'unknown'); |
|
273 | 273 | } elseif (is_array($cause) && isset($cause['message'])) { |
274 | 274 | // PEAR_ErrorStack warning |
275 | 275 | $causes[] = array( |
@@ -327,19 +327,19 @@ discard block |
||
327 | 327 | $html = '<table style="border: 1px" cellspacing="0">' . "\n"; |
328 | 328 | foreach ($causes as $i => $cause) { |
329 | 329 | $html .= '<tr><td colspan="3" style="background: #ff9999">' |
330 | - . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: ' |
|
331 | - . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> ' |
|
332 | - . 'on line <b>' . $cause['line'] . '</b>' |
|
333 | - . "</td></tr>\n"; |
|
330 | + . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: ' |
|
331 | + . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> ' |
|
332 | + . 'on line <b>' . $cause['line'] . '</b>' |
|
333 | + . "</td></tr>\n"; |
|
334 | 334 | } |
335 | 335 | $html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n" |
336 | - . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>' |
|
337 | - . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>' |
|
338 | - . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n"; |
|
336 | + . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>' |
|
337 | + . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>' |
|
338 | + . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n"; |
|
339 | 339 | |
340 | 340 | foreach ($trace as $k => $v) { |
341 | 341 | $html .= '<tr><td style="text-align: center;">' . $k . '</td>' |
342 | - . '<td>'; |
|
342 | + . '<td>'; |
|
343 | 343 | if (!empty($v['class'])) { |
344 | 344 | $html .= $v['class'] . $v['type']; |
345 | 345 | } |
@@ -361,15 +361,15 @@ discard block |
||
361 | 361 | } |
362 | 362 | } |
363 | 363 | $html .= '(' . implode(', ',$args) . ')' |
364 | - . '</td>' |
|
365 | - . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') |
|
366 | - . ':' . (isset($v['line']) ? $v['line'] : 'unknown') |
|
367 | - . '</td></tr>' . "\n"; |
|
364 | + . '</td>' |
|
365 | + . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown') |
|
366 | + . ':' . (isset($v['line']) ? $v['line'] : 'unknown') |
|
367 | + . '</td></tr>' . "\n"; |
|
368 | 368 | } |
369 | 369 | $html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>' |
370 | - . '<td>{main}</td>' |
|
371 | - . '<td> </td></tr>' . "\n" |
|
372 | - . '</table>'; |
|
370 | + . '<td>{main}</td>' |
|
371 | + . '<td> </td></tr>' . "\n" |
|
372 | + . '</table>'; |
|
373 | 373 | return $html; |
374 | 374 | } |
375 | 375 | |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | $causeMsg = ''; |
381 | 381 | foreach ($causes as $i => $cause) { |
382 | 382 | $causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': ' |
383 | - . $cause['message'] . ' in ' . $cause['file'] |
|
384 | - . ' on line ' . $cause['line'] . "\n"; |
|
383 | + . $cause['message'] . ' in ' . $cause['file'] |
|
384 | + . ' on line ' . $cause['line'] . "\n"; |
|
385 | 385 | } |
386 | 386 | return $causeMsg . $this->getTraceAsString(); |
387 | 387 | } |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | $href = htmlentities($this->pager->_url . str_replace('%d', $selector, $this->pager->_fileName), ENT_COMPAT, 'UTF-8'); |
154 | 154 | } |
155 | 155 | $tmp .= ' onchange="document.location.href=\'' |
156 | - . $href .'\'' |
|
157 | - . '"'; |
|
156 | + . $href .'\'' |
|
157 | + . '"'; |
|
158 | 158 | } elseif ($this->pager->_httpMethod == 'POST') { |
159 | 159 | $tmp .= " onchange='" |
160 | - . $this->pager->_generateFormOnClick($this->pager->_url, $this->pager->_linkData) |
|
161 | - . "'"; |
|
160 | + . $this->pager->_generateFormOnClick($this->pager->_url, $this->pager->_linkData) |
|
161 | + . "'"; |
|
162 | 162 | $tmp = preg_replace( |
163 | 163 | '/(input\.name = \"'.$this->pager->_sessionVar.'\"; input\.value =) \"(\d+)\";/', |
164 | 164 | '\\1 this.options[this.selectedIndex].value;', |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | // |
260 | 260 | } |
261 | 261 | $tmp .= ' onchange="javascript: document.location.href=\'' |
262 | - . $href .'\'' |
|
263 | - . '"'; |
|
262 | + . $href .'\'' |
|
263 | + . '"'; |
|
264 | 264 | } elseif ($this->pager->_httpMethod == 'POST') { |
265 | 265 | $tmp .= " onchange='" |
266 | - . $this->pager->_generateFormOnClick($this->pager->_url, $this->pager->_linkData) |
|
267 | - . "'"; |
|
266 | + . $this->pager->_generateFormOnClick($this->pager->_url, $this->pager->_linkData) |
|
267 | + . "'"; |
|
268 | 268 | $tmp = preg_replace( |
269 | 269 | '/(input\.name = \"'.$this->pager->_urlVar.'\"; input\.value =) \"(\d+)\";/', |
270 | 270 | '\\1 this.options[this.selectedIndex].value;', |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | $this->range[$i] = false; |
235 | 235 | $this->_linkData[$this->_urlVar] = $i; |
236 | 236 | $links .= $this->_renderLink(str_replace('%d', $i, $this->_altPage), $i) |
237 | - . $this->_spacesBefore |
|
238 | - . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : ''); |
|
237 | + . $this->_spacesBefore |
|
238 | + . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : ''); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $this->range[$i] = false; |
269 | 269 | $this->_linkData[$this->_urlVar] = $i; |
270 | 270 | $links .= $this->_renderLink(str_replace('%d', $i, $this->_altPage), $i) |
271 | - . $this->_spacesBefore |
|
272 | - . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : ''); |
|
271 | + . $this->_spacesBefore |
|
272 | + . ($print_separator_flag ? $this->_separator.$this->_spacesAfter : ''); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $links .= $this->_curPageSpanPre . $i . $this->_curPageSpanPost; |
286 | 286 | } |
287 | 287 | $links .= $this->_spacesBefore |
288 | - . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : ''); |
|
288 | + . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : ''); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | return $links; |
@@ -250,7 +250,7 @@ |
||
250 | 250 | $links .= $this->_curPageSpanPre . $i . $this->_curPageSpanPost; |
251 | 251 | } |
252 | 252 | $links .= $this->_spacesBefore |
253 | - . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : ''); |
|
253 | + . (($i != $this->_totalPages) ? $this->_separator.$this->_spacesAfter : ''); |
|
254 | 254 | } |
255 | 255 | return $links; |
256 | 256 | } |
@@ -249,282 +249,282 @@ |
||
249 | 249 | return $affected_rows; |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Get all plugins path inside dashboard directory |
|
254 | - * @return array name plugins directories |
|
255 | - */ |
|
256 | - public static function getPossibleDashboardPluginsPath() |
|
252 | + /** |
|
253 | + * Get all plugins path inside dashboard directory |
|
254 | + * @return array name plugins directories |
|
255 | + */ |
|
256 | + public static function getPossibleDashboardPluginsPath() |
|
257 | 257 | { |
258 | - // get all plugins path inside plugin directory |
|
259 | - /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | - $possiblePlugins = array(); |
|
261 | - $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | - $handle = @opendir($dashboard_pluginpath); |
|
263 | - while (false !== ($file = readdir($handle))) { |
|
264 | - if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | - $possiblePlugins[] = $file; |
|
266 | - } |
|
267 | - } |
|
268 | - @closedir($handle); |
|
269 | - |
|
270 | - return $possiblePlugins; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Get all blocks data without plugin directory |
|
275 | - * @return array Block data |
|
276 | - */ |
|
277 | - public static function get_block_data_without_plugin() |
|
258 | + // get all plugins path inside plugin directory |
|
259 | + /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | + $possiblePlugins = array(); |
|
261 | + $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | + $handle = @opendir($dashboard_pluginpath); |
|
263 | + while (false !== ($file = readdir($handle))) { |
|
264 | + if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | + $possiblePlugins[] = $file; |
|
266 | + } |
|
267 | + } |
|
268 | + @closedir($handle); |
|
269 | + |
|
270 | + return $possiblePlugins; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Get all blocks data without plugin directory |
|
275 | + * @return array Block data |
|
276 | + */ |
|
277 | + public static function get_block_data_without_plugin() |
|
278 | 278 | { |
279 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | - $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | - |
|
282 | - // We check if plugin exists inside directory for updating active field |
|
283 | - $sql = "SELECT * FROM $tbl_block"; |
|
284 | - $rs = Database::query($sql); |
|
285 | - if (Database::num_rows($rs) > 0){ |
|
286 | - while ($row = Database::fetch_array($rs)) { |
|
287 | - $path = $row['path']; |
|
288 | - if (!in_array($row['path'],$possibleplugins)) { |
|
289 | - $active = 0; |
|
290 | - } else { |
|
291 | - $active = 1; |
|
292 | - } |
|
293 | - // update active |
|
294 | - $upd = "UPDATE $tbl_block SET active = '$active' |
|
279 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | + $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | + |
|
282 | + // We check if plugin exists inside directory for updating active field |
|
283 | + $sql = "SELECT * FROM $tbl_block"; |
|
284 | + $rs = Database::query($sql); |
|
285 | + if (Database::num_rows($rs) > 0){ |
|
286 | + while ($row = Database::fetch_array($rs)) { |
|
287 | + $path = $row['path']; |
|
288 | + if (!in_array($row['path'],$possibleplugins)) { |
|
289 | + $active = 0; |
|
290 | + } else { |
|
291 | + $active = 1; |
|
292 | + } |
|
293 | + // update active |
|
294 | + $upd = "UPDATE $tbl_block SET active = '$active' |
|
295 | 295 | WHERE path = '".$row['path']."'"; |
296 | - Database::query($upd); |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - // get disabled block data |
|
301 | - $block_data = array(); |
|
302 | - $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | - $rs_block = Database::query($sql); |
|
304 | - if (Database::num_rows($rs_block) > 0) { |
|
305 | - while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | - $block_data[] = $row_block; |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - return $block_data; |
|
311 | - |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * get data about enabled dashboard block (stored insise block table) |
|
316 | - * @param string plugin path |
|
317 | - * @return array data |
|
318 | - */ |
|
319 | - public static function get_enabled_dashboard_blocks($path = '') |
|
296 | + Database::query($upd); |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + // get disabled block data |
|
301 | + $block_data = array(); |
|
302 | + $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | + $rs_block = Database::query($sql); |
|
304 | + if (Database::num_rows($rs_block) > 0) { |
|
305 | + while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | + $block_data[] = $row_block; |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + return $block_data; |
|
311 | + |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * get data about enabled dashboard block (stored insise block table) |
|
316 | + * @param string plugin path |
|
317 | + * @return array data |
|
318 | + */ |
|
319 | + public static function get_enabled_dashboard_blocks($path = '') |
|
320 | 320 | { |
321 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | - $condition_path = ''; |
|
323 | - if (!empty($path)) { |
|
324 | - $path = Database::escape_string($path); |
|
325 | - $condition_path = ' AND path = "'.$path.'" '; |
|
326 | - } |
|
327 | - |
|
328 | - $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | - $rs = Database::query($sql); |
|
330 | - $block_data = array(); |
|
331 | - if (Database::num_rows($rs) > 0) { |
|
332 | - while ($row = Database::fetch_array($rs)) { |
|
333 | - $block_data[$row['path']] = $row; |
|
334 | - } |
|
335 | - } |
|
336 | - return $block_data; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * display user dashboard list |
|
341 | - * @param int User id |
|
342 | - * @return void |
|
343 | - */ |
|
344 | - public static function display_user_dashboard_list($user_id) |
|
321 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | + $condition_path = ''; |
|
323 | + if (!empty($path)) { |
|
324 | + $path = Database::escape_string($path); |
|
325 | + $condition_path = ' AND path = "'.$path.'" '; |
|
326 | + } |
|
327 | + |
|
328 | + $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | + $rs = Database::query($sql); |
|
330 | + $block_data = array(); |
|
331 | + if (Database::num_rows($rs) > 0) { |
|
332 | + while ($row = Database::fetch_array($rs)) { |
|
333 | + $block_data[$row['path']] = $row; |
|
334 | + } |
|
335 | + } |
|
336 | + return $block_data; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * display user dashboard list |
|
341 | + * @param int User id |
|
342 | + * @return void |
|
343 | + */ |
|
344 | + public static function display_user_dashboard_list($user_id) |
|
345 | 345 | { |
346 | - $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | - $user_block_data = self::get_user_block_data($user_id); |
|
348 | - |
|
349 | - if (count($enabled_dashboard_plugins) > 0) { |
|
350 | - echo '<div style="margin-top:20px">'; |
|
351 | - echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | - echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | - echo '<table class="data_table">'; |
|
354 | - echo '<tr>'; |
|
355 | - echo '<th width="5%">'; |
|
356 | - echo get_lang('Enabled'); |
|
357 | - echo '</th>'; |
|
358 | - echo '<th width="30%">'; |
|
359 | - echo get_lang('Name'); |
|
360 | - echo '</th>'; |
|
361 | - echo '<th width="40%">'; |
|
362 | - echo get_lang('Description'); |
|
363 | - echo '</th>'; |
|
364 | - echo '<th>'; |
|
365 | - echo get_lang('ColumnPosition'); |
|
366 | - echo '</th>'; |
|
367 | - echo '</tr>'; |
|
368 | - |
|
369 | - // We display all enabled plugins and the checkboxes |
|
370 | - foreach ($enabled_dashboard_plugins as $block) { |
|
371 | - |
|
372 | - $path = $block['path']; |
|
373 | - $controller_class = $block['controller']; |
|
374 | - $filename_controller = $path.'.class.php'; |
|
375 | - $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | - require_once $dashboard_plugin_path.$filename_controller; |
|
377 | - if (class_exists($controller_class)) { |
|
378 | - $obj_block = new $controller_class($user_id); |
|
379 | - |
|
380 | - // check if user is allowed to see the block |
|
381 | - if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | - $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | - if (!$is_block_visible_for_user) continue; |
|
384 | - } |
|
385 | - |
|
386 | - echo '<tr>'; |
|
387 | - // checkboxes |
|
388 | - self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | - echo '<td>'.$block['name'].'</td>'; |
|
390 | - echo '<td>'.$block['description'].'</td>'; |
|
391 | - echo '<td> |
|
346 | + $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | + $user_block_data = self::get_user_block_data($user_id); |
|
348 | + |
|
349 | + if (count($enabled_dashboard_plugins) > 0) { |
|
350 | + echo '<div style="margin-top:20px">'; |
|
351 | + echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | + echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | + echo '<table class="data_table">'; |
|
354 | + echo '<tr>'; |
|
355 | + echo '<th width="5%">'; |
|
356 | + echo get_lang('Enabled'); |
|
357 | + echo '</th>'; |
|
358 | + echo '<th width="30%">'; |
|
359 | + echo get_lang('Name'); |
|
360 | + echo '</th>'; |
|
361 | + echo '<th width="40%">'; |
|
362 | + echo get_lang('Description'); |
|
363 | + echo '</th>'; |
|
364 | + echo '<th>'; |
|
365 | + echo get_lang('ColumnPosition'); |
|
366 | + echo '</th>'; |
|
367 | + echo '</tr>'; |
|
368 | + |
|
369 | + // We display all enabled plugins and the checkboxes |
|
370 | + foreach ($enabled_dashboard_plugins as $block) { |
|
371 | + |
|
372 | + $path = $block['path']; |
|
373 | + $controller_class = $block['controller']; |
|
374 | + $filename_controller = $path.'.class.php'; |
|
375 | + $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | + require_once $dashboard_plugin_path.$filename_controller; |
|
377 | + if (class_exists($controller_class)) { |
|
378 | + $obj_block = new $controller_class($user_id); |
|
379 | + |
|
380 | + // check if user is allowed to see the block |
|
381 | + if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | + $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | + if (!$is_block_visible_for_user) continue; |
|
384 | + } |
|
385 | + |
|
386 | + echo '<tr>'; |
|
387 | + // checkboxes |
|
388 | + self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | + echo '<td>'.$block['name'].'</td>'; |
|
390 | + echo '<td>'.$block['description'].'</td>'; |
|
391 | + echo '<td> |
|
392 | 392 | <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']"> |
393 | 393 | <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option> |
394 | 394 | <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option> |
395 | 395 | </select> |
396 | 396 | </td>'; |
397 | - echo '</tr>'; |
|
398 | - } else { |
|
399 | - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - echo '</table>'; |
|
404 | - echo '<div class="row"><div class="col-md-12">'; |
|
405 | - echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
397 | + echo '</tr>'; |
|
398 | + } else { |
|
399 | + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + echo '</table>'; |
|
404 | + echo '<div class="row"><div class="col-md-12">'; |
|
405 | + echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
406 | 406 | get_lang('EnableDashboardBlock').'</button></form>'; |
407 | - echo '</div></div>'; |
|
408 | - } else { |
|
409 | - echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | - if (api_is_platform_admin()) { |
|
411 | - echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
407 | + echo '</div></div>'; |
|
408 | + } else { |
|
409 | + echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | + if (api_is_platform_admin()) { |
|
411 | + echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
412 | 412 | get_lang('ConfigureDashboardPlugin').'</a>'; |
413 | - } |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * display checkboxes for user dashboard list |
|
419 | - * @param int User id |
|
420 | - * @param int Block id |
|
421 | - * @return void |
|
422 | - */ |
|
423 | - public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | - |
|
425 | - $user_id = intval($user_id); |
|
426 | - $user_block_data = self::get_user_block_data($user_id); |
|
427 | - $enabled_blocks_id = array_keys($user_block_data); |
|
428 | - |
|
429 | - $checked = ''; |
|
430 | - if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | - $checked = "checked"; |
|
432 | - } |
|
433 | - |
|
434 | - echo "<td align=\"center\">"; |
|
435 | - echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | - echo "</td>"; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | - * @param int User id |
|
442 | - * @param array selected blocks |
|
443 | - * @param array columns position |
|
444 | - * @return bool |
|
445 | - */ |
|
446 | - public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | - $selected_blocks_id = array(); |
|
448 | - if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | - $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | - } |
|
451 | - |
|
452 | - // build data for storing inside extra user field |
|
453 | - $fname = 'dashboard'; |
|
454 | - $fvalue = array(); |
|
455 | - foreach ($selected_blocks_id as $block_id) { |
|
456 | - $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | - } |
|
413 | + } |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * display checkboxes for user dashboard list |
|
419 | + * @param int User id |
|
420 | + * @param int Block id |
|
421 | + * @return void |
|
422 | + */ |
|
423 | + public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | + |
|
425 | + $user_id = intval($user_id); |
|
426 | + $user_block_data = self::get_user_block_data($user_id); |
|
427 | + $enabled_blocks_id = array_keys($user_block_data); |
|
428 | + |
|
429 | + $checked = ''; |
|
430 | + if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | + $checked = "checked"; |
|
432 | + } |
|
433 | + |
|
434 | + echo "<td align=\"center\">"; |
|
435 | + echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | + echo "</td>"; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | + * @param int User id |
|
442 | + * @param array selected blocks |
|
443 | + * @param array columns position |
|
444 | + * @return bool |
|
445 | + */ |
|
446 | + public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | + $selected_blocks_id = array(); |
|
448 | + if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | + $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | + } |
|
451 | + |
|
452 | + // build data for storing inside extra user field |
|
453 | + $fname = 'dashboard'; |
|
454 | + $fvalue = array(); |
|
455 | + foreach ($selected_blocks_id as $block_id) { |
|
456 | + $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | + } |
|
458 | 458 | $upd_extra_field = UserManager::update_extra_field_value( |
459 | 459 | $user_id, |
460 | 460 | $fname, |
461 | 461 | $fvalue |
462 | 462 | ); |
463 | 463 | |
464 | - return $upd_extra_field; |
|
464 | + return $upd_extra_field; |
|
465 | 465 | |
466 | - } |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * This function get user block data (block id with its number of column) from extra user data |
|
470 | - * @param int User id |
|
471 | - * @return array data (block_id,column) |
|
472 | - */ |
|
473 | - public static function get_user_block_data($user_id) |
|
468 | + /** |
|
469 | + * This function get user block data (block id with its number of column) from extra user data |
|
470 | + * @param int User id |
|
471 | + * @return array data (block_id,column) |
|
472 | + */ |
|
473 | + public static function get_user_block_data($user_id) |
|
474 | 474 | { |
475 | - $user_id = intval($user_id); |
|
476 | - $field_variable = 'dashboard'; |
|
477 | - $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
478 | - $extra_user_data = explode(';',$extra_user_data[$field_variable]); |
|
479 | - $data = array(); |
|
480 | - foreach ($extra_user_data as $extra) { |
|
481 | - $split_extra = explode(':',$extra); |
|
482 | - if (!empty($split_extra)) { |
|
483 | - $block_id = $split_extra[0]; |
|
484 | - $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
485 | - $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - return $data; |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * This function update extra user blocks data after closing a dashboard block |
|
494 | - * @param int User id |
|
495 | - * @param string plugin path |
|
496 | - * @return bool |
|
497 | - */ |
|
498 | - public static function close_user_block($user_id, $path) |
|
475 | + $user_id = intval($user_id); |
|
476 | + $field_variable = 'dashboard'; |
|
477 | + $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
478 | + $extra_user_data = explode(';',$extra_user_data[$field_variable]); |
|
479 | + $data = array(); |
|
480 | + foreach ($extra_user_data as $extra) { |
|
481 | + $split_extra = explode(':',$extra); |
|
482 | + if (!empty($split_extra)) { |
|
483 | + $block_id = $split_extra[0]; |
|
484 | + $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
485 | + $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + return $data; |
|
490 | + } |
|
491 | + |
|
492 | + /** |
|
493 | + * This function update extra user blocks data after closing a dashboard block |
|
494 | + * @param int User id |
|
495 | + * @param string plugin path |
|
496 | + * @return bool |
|
497 | + */ |
|
498 | + public static function close_user_block($user_id, $path) |
|
499 | 499 | { |
500 | - $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
501 | - $user_block_data = self::get_user_block_data($user_id); |
|
502 | - |
|
503 | - foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
504 | - unset($user_block_data[$enabled_block['id']]); |
|
505 | - } |
|
506 | - |
|
507 | - // get columns and blocks id for updating extra user data |
|
508 | - $columns = array(); |
|
509 | - $user_blocks_id = array(); |
|
510 | - foreach ($user_block_data as $data) { |
|
511 | - $user_blocks_id[$data['block_id']] = true; |
|
512 | - $columns[$data['block_id']] = $data['column']; |
|
513 | - } |
|
514 | - |
|
515 | - // update extra user blocks data |
|
516 | - $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
517 | - |
|
518 | - return $upd_extra_field; |
|
519 | - } |
|
520 | - |
|
521 | - /** |
|
522 | - * get links for styles from dashboard plugins |
|
523 | - * @return string links |
|
524 | - */ |
|
525 | - public static function get_links_for_styles_from_dashboard_plugins() { |
|
526 | - |
|
527 | - return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
528 | - } |
|
500 | + $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
501 | + $user_block_data = self::get_user_block_data($user_id); |
|
502 | + |
|
503 | + foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
504 | + unset($user_block_data[$enabled_block['id']]); |
|
505 | + } |
|
506 | + |
|
507 | + // get columns and blocks id for updating extra user data |
|
508 | + $columns = array(); |
|
509 | + $user_blocks_id = array(); |
|
510 | + foreach ($user_block_data as $data) { |
|
511 | + $user_blocks_id[$data['block_id']] = true; |
|
512 | + $columns[$data['block_id']] = $data['column']; |
|
513 | + } |
|
514 | + |
|
515 | + // update extra user blocks data |
|
516 | + $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
517 | + |
|
518 | + return $upd_extra_field; |
|
519 | + } |
|
520 | + |
|
521 | + /** |
|
522 | + * get links for styles from dashboard plugins |
|
523 | + * @return string links |
|
524 | + */ |
|
525 | + public static function get_links_for_styles_from_dashboard_plugins() { |
|
526 | + |
|
527 | + return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
528 | + } |
|
529 | 529 | |
530 | 530 | } |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Constructor |
14 | 14 | */ |
15 | - public function __construct() |
|
15 | + public function __construct() |
|
16 | 16 | { |
17 | 17 | $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function get_all($where_conditions = array()) |
21 | 21 | { |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * Displays the title + grid |
31 | 31 | */ |
32 | - public function display() |
|
32 | + public function display() |
|
33 | 33 | { |
34 | - // action links |
|
35 | - $content = Display::actions(array( |
|
34 | + // action links |
|
35 | + $content = Display::actions(array( |
|
36 | 36 | array( |
37 | 37 | 'url' => 'event_type.php' , |
38 | 38 | 'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM) |
39 | - ) |
|
39 | + ) |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | $content .= Display::grid_html('event_email_template'); |
43 | 43 | return $content; |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public function get_status_list() |
47 | 47 | { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'Height' => '250', |
83 | 83 | ) |
84 | 84 | ); |
85 | - $status_list = $this->get_status_list(); |
|
85 | + $status_list = $this->get_status_list(); |
|
86 | 86 | $form->addElement('select', 'status', get_lang('Status'), $status_list); |
87 | 87 | if ($action == 'edit') { |
88 | 88 | $form->addElement('text', 'created_at', get_lang('CreatedAt')); |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | $defaults = $this->get($id); |
100 | 100 | |
101 | 101 | if (!empty($defaults['created_at'])) { |
102 | - $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
|
102 | + $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']); |
|
103 | 103 | } |
104 | 104 | if (!empty($defaults['updated_at'])) { |
105 | - $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
|
105 | + $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']); |
|
106 | 106 | } |
107 | 107 | $form->setDefaults($defaults); |
108 | 108 | |
109 | 109 | // Setting the rules |
110 | 110 | $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
111 | 111 | |
112 | - return $form; |
|
112 | + return $form; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public function get_count() |