@@ -252,7 +252,7 @@ |
||
252 | 252 | /** |
253 | 253 | * Check if header exists and is up to date |
254 | 254 | * |
255 | - * @return int 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
255 | + * @return string 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
256 | 256 | */ |
257 | 257 | function check_header() |
258 | 258 | { |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | { |
28 | 28 | $setup_info = array(); |
29 | 29 | $d = dir(EGW_SERVER_ROOT); |
30 | - while($entry=$d->read()) |
|
30 | + while ($entry = $d->read()) |
|
31 | 31 | { |
32 | - if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry)) |
|
32 | + if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry)) |
|
33 | 33 | { |
34 | - $f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php'; |
|
35 | - if (@file_exists ($f)) |
|
34 | + $f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'; |
|
35 | + if (@file_exists($f)) |
|
36 | 36 | { |
37 | 37 | include($f); |
38 | 38 | $setup_info[$entry]['filename'] = $f; |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | * @param array $setup_info |
53 | 53 | * @return array $setup_info |
54 | 54 | */ |
55 | - function get_db_versions($setup_info=null) |
|
55 | + function get_db_versions($setup_info = null) |
|
56 | 56 | { |
57 | 57 | try { // catch DB errors |
58 | 58 | $GLOBALS['egw_setup']->set_table_names(); |
59 | 59 | |
60 | - if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true)) |
|
60 | + if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true)) |
|
61 | 61 | { |
62 | 62 | /* one of these tables exists. checking for post/pre beta version */ |
63 | - if($GLOBALS['egw_setup']->applications_table != 'applications') |
|
63 | + if ($GLOBALS['egw_setup']->applications_table != 'applications') |
|
64 | 64 | { |
65 | - foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row) |
|
65 | + foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table, '*', false, __LINE__, __FILE__) as $row) |
|
66 | 66 | { |
67 | 67 | $app = $row['app_name']; |
68 | 68 | if (!isset($setup_info[$app])) // app source no longer there |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | // new api, dont care about old pre egroupware stuff |
84 | 84 | } |
85 | - elseif(!@$setup_info['phpgwapi']['currentver']) |
|
85 | + elseif (!@$setup_info['phpgwapi']['currentver']) |
|
86 | 86 | { |
87 | 87 | $setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver']; |
88 | 88 | $setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver']; |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - foreach($GLOBALS['egw_setup']->db->query('select * from applications') as $row) |
|
104 | + foreach ($GLOBALS['egw_setup']->db->query('select * from applications') as $row) |
|
105 | 105 | { |
106 | - if($row['app_name'] == 'admin') |
|
106 | + if ($row['app_name'] == 'admin') |
|
107 | 107 | { |
108 | 108 | $setup_info['phpgwapi']['currentver'] = $row['app_version']; |
109 | 109 | } |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | * V Version mismatch at end of upgrade (Not used, proposed only) |
132 | 132 | * M Missing files at start of upgrade (Not used, proposed only) |
133 | 133 | */ |
134 | - function compare_versions($setup_info,$try_downgrade=false) |
|
134 | + function compare_versions($setup_info, $try_downgrade = false) |
|
135 | 135 | { |
136 | - foreach($setup_info as $key => $value) |
|
136 | + foreach ($setup_info as $key => $value) |
|
137 | 137 | { |
138 | 138 | //echo '<br>'.$value['name'].'STATUS: '.$value['status']; |
139 | 139 | /* Only set this if it has not already failed to upgrade - Milosch */ |
140 | - if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') )) |
|
140 | + if (!((@$value['status'] == 'F') || (@$value['status'] == 'C'))) |
|
141 | 141 | { |
142 | 142 | //if ($setup_info[$key]['currentver'] > $setup_info[$key]['version']) |
143 | - if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) || |
|
143 | + if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) || |
|
144 | 144 | $value['version'] == 'deleted') |
145 | 145 | { |
146 | 146 | $setup_info[$key]['status'] = 'V'; |
147 | 147 | } |
148 | - elseif(@$value['currentver'] == @$value['version']) |
|
148 | + elseif (@$value['currentver'] == @$value['version']) |
|
149 | 149 | { |
150 | 150 | $setup_info[$key]['status'] = 'C'; |
151 | 151 | } |
152 | - elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version'])) |
|
152 | + elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version'])) |
|
153 | 153 | { |
154 | 154 | $setup_info[$key]['status'] = 'U'; |
155 | 155 | } |
@@ -166,35 +166,35 @@ discard block |
||
166 | 166 | function check_depends($setup_info) |
167 | 167 | { |
168 | 168 | /* Run the list of apps */ |
169 | - foreach($setup_info as $key => $value) |
|
169 | + foreach ($setup_info as $key => $value) |
|
170 | 170 | { |
171 | 171 | /* Does this app have any depends */ |
172 | - if(isset($value['depends'])) |
|
172 | + if (isset($value['depends'])) |
|
173 | 173 | { |
174 | 174 | /* If so find out which apps it depends on */ |
175 | - foreach($value['depends'] as $depkey => $depvalue) |
|
175 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
176 | 176 | { |
177 | 177 | /* I set this to False until we find a compatible version of this app */ |
178 | 178 | $setup_info['depends'][$depkey]['status'] = False; |
179 | 179 | /* Now we loop thru the versions looking for a compatible version */ |
180 | 180 | |
181 | - foreach($depvalue['versions'] as $depsvalue) |
|
181 | + foreach ($depvalue['versions'] as $depsvalue) |
|
182 | 182 | { |
183 | 183 | $currentver = $setup_info[$depvalue['appname']]['currentver']; |
184 | - if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99') |
|
184 | + if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99') |
|
185 | 185 | { |
186 | 186 | $currentver = '0.9.14.508'; |
187 | 187 | } |
188 | 188 | $major = $GLOBALS['egw_setup']->get_major($currentver); |
189 | - if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.') |
|
189 | + if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.') |
|
190 | 190 | { |
191 | 191 | $setup_info['depends'][$depkey]['status'] = True; |
192 | 192 | } |
193 | 193 | else // check if majors are equal and minors greater or equal |
194 | 194 | { |
195 | 195 | $major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue); |
196 | - $tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp); |
|
197 | - $tmp2 = explode('.',$currentver); $minor = array_pop($tmp2); |
|
196 | + $tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp); |
|
197 | + $tmp2 = explode('.', $currentver); $minor = array_pop($tmp2); |
|
198 | 198 | if ($major == $major_depsvalue && $minor <= $minor_depsvalue) |
199 | 199 | { |
200 | 200 | $setup_info['depends'][$depkey]['status'] = True; |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | Finally, we loop through the dependencies again to look for apps that still have a failure status |
208 | 208 | If we find one, we set the apps overall status as a dependency failure. |
209 | 209 | */ |
210 | - foreach($value['depends'] as $depkey => $depvalue) |
|
210 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
211 | 211 | { |
212 | 212 | if ($setup_info['depends'][$depkey]['status'] == False) |
213 | 213 | { |
214 | 214 | /* Only set this if it has not already failed to upgrade - Milosch */ |
215 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
215 | + if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
216 | 216 | { |
217 | 217 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
218 | 218 | * This should fix apps showing post-install dep failure when they are not yet installed. |
219 | 219 | */ |
220 | - if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
220 | + if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
221 | 221 | { |
222 | 222 | $setup_info[$key]['status'] = 'D'; |
223 | 223 | } |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function upgrade_exclude($setup_info) |
241 | 241 | { |
242 | - foreach($setup_info as $key => $value) |
|
242 | + foreach ($setup_info as $key => $value) |
|
243 | 243 | { |
244 | - if(isset($value['no_mass_update'])) |
|
244 | + if (isset($value['no_mass_update'])) |
|
245 | 245 | { |
246 | 246 | unset($setup_info[$key]); |
247 | 247 | } |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | */ |
257 | 257 | function check_header() |
258 | 258 | { |
259 | - if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
259 | + if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
260 | 260 | { |
261 | 261 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One'; |
262 | 262 | return '1'; |
263 | 263 | } |
264 | 264 | else |
265 | 265 | { |
266 | - if(!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
266 | + if (!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
267 | 267 | { |
268 | 268 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)'; |
269 | 269 | return '2'; |
270 | 270 | } |
271 | - elseif(!@isset($GLOBALS['egw_domain'])) |
|
271 | + elseif (!@isset($GLOBALS['egw_domain'])) |
|
272 | 272 | { |
273 | 273 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)'; |
274 | 274 | return '3'; |
275 | 275 | } |
276 | - elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
276 | + elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
277 | 277 | { |
278 | 278 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)'; |
279 | 279 | return '4'; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
291 | 291 | * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete |
292 | 292 | */ |
293 | - function check_db($setup_info=null) |
|
293 | + function check_db($setup_info = null) |
|
294 | 294 | { |
295 | 295 | if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
296 | 296 | |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
299 | 299 | { |
300 | 300 | $old = error_reporting(); |
301 | - error_reporting($old & ~E_WARNING); // no warnings |
|
301 | + error_reporting($old&~E_WARNING); // no warnings |
|
302 | 302 | $GLOBALS['egw_setup']->db->connect(); |
303 | 303 | error_reporting($old); |
304 | 304 | |
305 | 305 | $GLOBALS['egw_setup']->set_table_names(); |
306 | 306 | } |
307 | 307 | } |
308 | - catch(Api\Db\Exception $e) { |
|
308 | + catch (Api\Db\Exception $e) { |
|
309 | 309 | // ignore error |
310 | 310 | } |
311 | 311 | |
@@ -314,14 +314,14 @@ discard block |
||
314 | 314 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)'; |
315 | 315 | return 1; |
316 | 316 | } |
317 | - if(!isset($setup_info['api']['currentver'])) |
|
317 | + if (!isset($setup_info['api']['currentver'])) |
|
318 | 318 | { |
319 | 319 | $setup_info = $this->get_db_versions($setup_info); |
320 | 320 | } |
321 | 321 | // first check new api installed and up to date |
322 | 322 | if (isset($setup_info['api']['currentver'])) |
323 | 323 | { |
324 | - if($setup_info['api']['currentver'] == $setup_info['api']['version']) |
|
324 | + if ($setup_info['api']['currentver'] == $setup_info['api']['version']) |
|
325 | 325 | { |
326 | 326 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)'; |
327 | 327 | return 10; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | // then check old phpgwapi |
336 | 336 | elseif (isset($setup_info['phpgwapi']['currentver'])) |
337 | 337 | { |
338 | - if($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version']) |
|
338 | + if ($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version']) |
|
339 | 339 | { |
340 | 340 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)'; |
341 | 341 | return 10; |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | */ |
371 | 371 | function check_config() |
372 | 372 | { |
373 | - if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
373 | + if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
374 | 374 | { |
375 | 375 | return ''; |
376 | 376 | } |
377 | 377 | |
378 | 378 | try { // catch db errors |
379 | - foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, |
|
380 | - 'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row) |
|
379 | + foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, |
|
380 | + 'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__) as $row) |
|
381 | 381 | { |
382 | 382 | $config[$row['config_name']] = $row['config_value']; |
383 | 383 | } |
@@ -387,23 +387,23 @@ discard block |
||
387 | 387 | // ignore db errors |
388 | 388 | } |
389 | 389 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)'; |
390 | - if(!count($config)) |
|
390 | + if (!count($config)) |
|
391 | 391 | { |
392 | 392 | return 1; |
393 | 393 | } |
394 | - $config_errors =& $GLOBALS['egw_info']['setup']['config_errors']; |
|
394 | + $config_errors = & $GLOBALS['egw_info']['setup']['config_errors']; |
|
395 | 395 | $GLOBALS['egw_info']['setup']['config_errors'] = array(); |
396 | 396 | $error_msg = null; |
397 | - if (!$this->check_dir($config['temp_dir'],$error_msg)) |
|
397 | + if (!$this->check_dir($config['temp_dir'], $error_msg)) |
|
398 | 398 | { |
399 | - $config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg); |
|
399 | + $config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | if ((!isset($config['file_repository']) || $config['file_repository'] == 'sql') && |
403 | 403 | (!isset($config['file_store_contents']) || $config['file_store_contents'] == 'filesystem') && |
404 | - !$this->check_dir($config['files_dir'],$error_msg,true)) |
|
404 | + !$this->check_dir($config['files_dir'], $error_msg, true)) |
|
405 | 405 | { |
406 | - $config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg); |
|
406 | + $config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg); |
|
407 | 407 | } |
408 | 408 | // set and create the default backup_dir |
409 | 409 | if (@is_writeable($config['files_dir']) && !$config['backup_dir'] && $config['file_store_contents'] == 'filesystem') |
@@ -411,35 +411,35 @@ discard block |
||
411 | 411 | $config['backup_dir'] = $config['files_dir'].'/db_backup'; |
412 | 412 | if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir'])) |
413 | 413 | { |
414 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
414 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
415 | 415 | 'config_value' => $config['backup_dir'], |
416 | - ),array( |
|
416 | + ), array( |
|
417 | 417 | 'config_app' => 'phpgwapi', |
418 | 418 | 'config_name' => 'backup_dir', |
419 | - ),__LINE__,__FILE__); |
|
419 | + ), __LINE__, __FILE__); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | if (isset($config['backup_mincount'])) |
423 | 423 | { |
424 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
424 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
425 | 425 | 'config_value' => $config['backup_mincount'], |
426 | - ),array( |
|
426 | + ), array( |
|
427 | 427 | 'config_app' => 'phpgwapi', |
428 | 428 | 'config_name' => 'backup_mincount', |
429 | - ),__LINE__,__FILE__); |
|
429 | + ), __LINE__, __FILE__); |
|
430 | 430 | } |
431 | 431 | if (isset($config['backup_files'])) |
432 | 432 | { |
433 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
433 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
434 | 434 | 'config_value' => (int)$config['backup_files'], |
435 | - ),array( |
|
435 | + ), array( |
|
436 | 436 | 'config_app' => 'phpgwapi', |
437 | 437 | 'config_name' => 'backup_files', |
438 | - ),__LINE__,__FILE__); |
|
438 | + ), __LINE__, __FILE__); |
|
439 | 439 | } |
440 | - if (!$this->check_dir($config['backup_dir'],$error_msg,true)) |
|
440 | + if (!$this->check_dir($config['backup_dir'], $error_msg, true)) |
|
441 | 441 | { |
442 | - $config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg); |
|
442 | + $config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg); |
|
443 | 443 | } |
444 | 444 | if ($config_errors) |
445 | 445 | { |
@@ -455,19 +455,19 @@ discard block |
||
455 | 455 | * @param $appname |
456 | 456 | * @param $any optional, set to True to see if any of the apps tables are installed |
457 | 457 | */ |
458 | - function check_app_tables($appname,$any=False) |
|
458 | + function check_app_tables($appname, $any = False) |
|
459 | 459 | { |
460 | 460 | $none = 0; |
461 | 461 | $setup_info = $GLOBALS['setup_info']; |
462 | 462 | |
463 | - if(@$setup_info[$appname]['tables']) |
|
463 | + if (@$setup_info[$appname]['tables']) |
|
464 | 464 | { |
465 | 465 | /* Make a copy, else we send some callers into an infinite loop */ |
466 | 466 | $copy = $setup_info; |
467 | 467 | $tables = Array(); |
468 | 468 | try { |
469 | 469 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
470 | - foreach($table_names as $key => $val) |
|
470 | + foreach ($table_names as $key => $val) |
|
471 | 471 | { |
472 | 472 | $tables[] = $val['table_name']; |
473 | 473 | } |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | unset($e); |
477 | 477 | // ignore db error |
478 | 478 | } |
479 | - foreach($copy[$appname]['tables'] as $key => $val) |
|
479 | + foreach ($copy[$appname]['tables'] as $key => $val) |
|
480 | 480 | { |
481 | - if($GLOBALS['DEBUG']) |
|
481 | + if ($GLOBALS['DEBUG']) |
|
482 | 482 | { |
483 | - echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
|
483 | + echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val; |
|
484 | 484 | } |
485 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
485 | + if (!in_array($val, $tables) && !in_array(strtolower($val), $tables)) // names in tables might be lowercase |
|
486 | 486 | { |
487 | - if($GLOBALS['DEBUG']) |
|
487 | + if ($GLOBALS['DEBUG']) |
|
488 | 488 | { |
489 | - echo '<br>check_app_tables(): ' . $val . ' missing!'; |
|
489 | + echo '<br>check_app_tables(): '.$val.' missing!'; |
|
490 | 490 | } |
491 | - if(!$any) |
|
491 | + if (!$any) |
|
492 | 492 | { |
493 | 493 | return False; |
494 | 494 | } |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | } |
500 | 500 | else |
501 | 501 | { |
502 | - if($any) |
|
502 | + if ($any) |
|
503 | 503 | { |
504 | - if($GLOBALS['DEBUG']) |
|
504 | + if ($GLOBALS['DEBUG']) |
|
505 | 505 | { |
506 | 506 | echo '<br>check_app_tables(): Some tables installed'; |
507 | 507 | } |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
513 | - if($none && $any) |
|
513 | + if ($none && $any) |
|
514 | 514 | { |
515 | - if($GLOBALS['DEBUG']) |
|
515 | + if ($GLOBALS['DEBUG']) |
|
516 | 516 | { |
517 | 517 | echo '<br>check_app_tables(): No tables installed'; |
518 | 518 | } |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | else |
522 | 522 | { |
523 | - if($GLOBALS['DEBUG']) |
|
523 | + if ($GLOBALS['DEBUG']) |
|
524 | 524 | { |
525 | 525 | echo '<br>check_app_tables(): All tables installed'; |
526 | 526 | } |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | * @param boolean $check_in_docroot =false run an optional in docroot check |
537 | 537 | * @return boolean |
538 | 538 | */ |
539 | - static function check_dir($dir,&$msg,$check_in_docroot=false) |
|
539 | + static function check_dir($dir, &$msg, $check_in_docroot = false) |
|
540 | 540 | { |
541 | - if (!@is_dir($dir) && !@mkdir($dir,0700,true)) |
|
541 | + if (!@is_dir($dir) && !@mkdir($dir, 0700, true)) |
|
542 | 542 | { |
543 | 543 | $msg = lang('does not exist'); |
544 | 544 | return false; |
@@ -550,16 +550,16 @@ discard block |
||
550 | 550 | } |
551 | 551 | if ($check_in_docroot) |
552 | 552 | { |
553 | - $docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT'])); |
|
553 | + $docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT'])); |
|
554 | 554 | $dir = realpath($dir); |
555 | 555 | |
556 | 556 | foreach ($docroots as $docroot) |
557 | 557 | { |
558 | 558 | $len = strlen($docroot); |
559 | 559 | |
560 | - if ($docroot == substr($dir,0,$len) && $len>0) |
|
560 | + if ($docroot == substr($dir, 0, $len) && $len > 0) |
|
561 | 561 | { |
562 | - $rest = substr($dir,$len); |
|
562 | + $rest = substr($dir, $len); |
|
563 | 563 | |
564 | 564 | if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) |
565 | 565 | { |
@@ -65,7 +65,9 @@ discard block |
||
65 | 65 | foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row) |
66 | 66 | { |
67 | 67 | $app = $row['app_name']; |
68 | - if (!isset($setup_info[$app])) // app source no longer there |
|
68 | + if (!isset($setup_info[$app])) |
|
69 | + { |
|
70 | + // app source no longer there |
|
69 | 71 | { |
70 | 72 | $setup_info[$app] = array( |
71 | 73 | 'name' => $app, |
@@ -73,6 +75,7 @@ discard block |
||
73 | 75 | 'version' => 'deleted', |
74 | 76 | ); |
75 | 77 | } |
78 | + } |
|
76 | 79 | $setup_info[$app]['currentver'] = $row['app_version']; |
77 | 80 | $setup_info[$app]['enabled'] = $row['app_enabled']; |
78 | 81 | } |
@@ -212,7 +215,9 @@ discard block |
||
212 | 215 | if ($setup_info['depends'][$depkey]['status'] == False) |
213 | 216 | { |
214 | 217 | /* Only set this if it has not already failed to upgrade - Milosch */ |
215 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
218 | + if($setup_info[$key]['status'] != 'F') |
|
219 | + { |
|
220 | + //&& $setup_info[$key]['status'] != 'C') |
|
216 | 221 | { |
217 | 222 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
218 | 223 | * This should fix apps showing post-install dep failure when they are not yet installed. |
@@ -220,6 +225,7 @@ discard block |
||
220 | 225 | if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
221 | 226 | { |
222 | 227 | $setup_info[$key]['status'] = 'D'; |
228 | + } |
|
223 | 229 | } |
224 | 230 | else |
225 | 231 | { |
@@ -292,7 +298,10 @@ discard block |
||
292 | 298 | */ |
293 | 299 | function check_db($setup_info=null) |
294 | 300 | { |
295 | - if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
|
301 | + if (!$setup_info) |
|
302 | + { |
|
303 | + $setup_info = $GLOBALS['setup_info']; |
|
304 | + } |
|
296 | 305 | |
297 | 306 | try { // catch DB errors |
298 | 307 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
@@ -482,11 +491,14 @@ discard block |
||
482 | 491 | { |
483 | 492 | echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
484 | 493 | } |
485 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
494 | + if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) |
|
495 | + { |
|
496 | + // names in tables might be lowercase |
|
486 | 497 | { |
487 | 498 | if($GLOBALS['DEBUG']) |
488 | 499 | { |
489 | 500 | echo '<br>check_app_tables(): ' . $val . ' missing!'; |
501 | + } |
|
490 | 502 | } |
491 | 503 | if(!$any) |
492 | 504 | { |
@@ -543,9 +555,12 @@ discard block |
||
543 | 555 | $msg = lang('does not exist'); |
544 | 556 | return false; |
545 | 557 | } |
546 | - if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver |
|
558 | + if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) |
|
559 | + { |
|
560 | + // only do the check if we run by the webserver |
|
547 | 561 | { |
548 | 562 | $msg = lang('is not writeable by the webserver'); |
563 | + } |
|
549 | 564 | return false; |
550 | 565 | } |
551 | 566 | if ($check_in_docroot) |
@@ -464,7 +464,7 @@ |
||
464 | 464 | { |
465 | 465 | /* Make a copy, else we send some callers into an infinite loop */ |
466 | 466 | $copy = $setup_info; |
467 | - $tables = Array(); |
|
467 | + $tables = array(); |
|
468 | 468 | try { |
469 | 469 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
470 | 470 | foreach($table_names as $key => $val) |
@@ -53,10 +53,7 @@ |
||
53 | 53 | * the mother of all multipass upgrade parental loop functions |
54 | 54 | * |
55 | 55 | * @param array $setup_info array of application info from setup.inc.php files |
56 | - * @param string $type='new' defaults to new(install), could also be 'upgrade' |
|
57 | - * @param boolean $DEBUG=false print debugging info |
|
58 | - * @param boolean $force_en=false install english language files, not used anymore |
|
59 | - * @param string $system_charset=null charset to use |
|
56 | + * @param boolean $force_en install english language files, not used anymore |
|
60 | 57 | * @param array $preset_config=array() |
61 | 58 | */ |
62 | 59 | function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array()) |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * @param string $system_charset=null charset to use |
60 | 60 | * @param array $preset_config=array() |
61 | 61 | */ |
62 | - function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array()) |
|
62 | + function pass(array $setup_info, $method = 'new', $DEBUG = False, $force_en = False, $preset_config = array()) |
|
63 | 63 | { |
64 | - unset($force_en); // no longer used |
|
64 | + unset($force_en); // no longer used |
|
65 | 65 | |
66 | - if(!$method) |
|
66 | + if (!$method) |
|
67 | 67 | { |
68 | 68 | return False; |
69 | 69 | } |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | $pass['phpgwapi'] = $setup_info['phpgwapi']; |
93 | 93 | } |
94 | 94 | } |
95 | - $pass['admin'] = $setup_info['admin']; |
|
95 | + $pass['admin'] = $setup_info['admin']; |
|
96 | 96 | $pass['preferences'] = $setup_info['preferences']; |
97 | 97 | if (file_exists(EGW_SERVER_ROOT.'/etemplate')) |
98 | 98 | { |
99 | - $pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it |
|
99 | + $pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it |
|
100 | 100 | } |
101 | 101 | $this->api_version_target = $setup_info['api']['version']; |
102 | 102 | |
103 | 103 | $i = 1; |
104 | 104 | $passed = array(); |
105 | 105 | $passing = array(); |
106 | - $pass_string = implode (':', $pass); |
|
107 | - $passing_string = implode (':', $passing); |
|
108 | - while($pass_string != $passing_string) |
|
106 | + $pass_string = implode(':', $pass); |
|
107 | + $passing_string = implode(':', $passing); |
|
108 | + while ($pass_string != $passing_string) |
|
109 | 109 | { |
110 | 110 | $passing = array(); |
111 | - if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
111 | + if ($DEBUG) { echo '<br>process->pass(): #'.$i.' for '.$method.' processing'."\n"; } |
|
112 | 112 | |
113 | 113 | // Check current versions and dependencies |
114 | 114 | $setup_info = $GLOBALS['egw_setup']->detection->check_depends( |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | $GLOBALS['egw_setup']->detection->get_db_versions($setup_info), true)); |
117 | 117 | |
118 | 118 | // stuff the rest of the apps, but only those with available upgrades |
119 | - foreach($setup_info as $key => $value) |
|
119 | + foreach ($setup_info as $key => $value) |
|
120 | 120 | { |
121 | 121 | // check if app is either installed or supports the used database |
122 | 122 | if (!isset($value['currentver']) && isset($value['only_db']) && ( |
123 | - is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type,$value['only_db']) || |
|
123 | + is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type, $value['only_db']) || |
|
124 | 124 | !is_array($value['only_db']) && $GLOBALS['egw_setup']->db->Type != $value['only_db'])) |
125 | 125 | { |
126 | - continue; // app does not support this db-type, dont try installing it |
|
126 | + continue; // app does not support this db-type, dont try installing it |
|
127 | 127 | } |
128 | - if(/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U') |
|
128 | + if (/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U') |
|
129 | 129 | { |
130 | - if($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C') |
|
130 | + if ($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C') |
|
131 | 131 | { |
132 | 132 | $pass[$value['name']] = $setup_info[$value['name']]; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - switch($method) |
|
137 | + switch ($method) |
|
138 | 138 | { |
139 | 139 | case 'new': |
140 | 140 | if (empty($GLOBALS['egw_info']['server']['temp_dir'])) |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | $GLOBALS['egw_info']['server']['temp_dir'] = sys_get_temp_dir(); |
143 | 143 | } |
144 | 144 | /* Create tables and insert new records for each app in this list */ |
145 | - $passing_c = $this->current($pass,$DEBUG); |
|
145 | + $passing_c = $this->current($pass, $DEBUG); |
|
146 | 146 | if (isset($pass['api'])) $this->save_minimal_config($preset_config); |
147 | - $passing = $this->default_records($passing_c,$DEBUG); |
|
147 | + $passing = $this->default_records($passing_c, $DEBUG); |
|
148 | 148 | break; |
149 | 149 | case 'upgrade': |
150 | 150 | /* Run upgrade scripts on each app in the list */ |
151 | - $passing = $this->upgrade($pass,$DEBUG); |
|
151 | + $passing = $this->upgrade($pass, $DEBUG); |
|
152 | 152 | //_debug_array($pass);exit; |
153 | 153 | break; |
154 | 154 | default: |
@@ -157,32 +157,32 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | $pass = array(); |
160 | - foreach($passing as $key => $value) |
|
160 | + foreach ($passing as $key => $value) |
|
161 | 161 | { |
162 | - if($value['status'] == 'C') |
|
162 | + if ($value['status'] == 'C') |
|
163 | 163 | { |
164 | 164 | $passed[$value['name']] = $passing[$value['name']]; |
165 | - if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
165 | + if ($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'].' install completed'."\n"; } |
|
166 | 166 | } |
167 | - elseif($value['status'] == 'F') |
|
167 | + elseif ($value['status'] == 'F') |
|
168 | 168 | { |
169 | 169 | $setup_info[$value['name']] = $passing[$value['name']]; |
170 | - if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
170 | + if ($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'].' install failed'."\n"; } |
|
171 | 171 | } |
172 | - elseif($value['status'] == 'D') |
|
172 | + elseif ($value['status'] == 'D') |
|
173 | 173 | { |
174 | 174 | $pass[$value['name']] = $setup_info[$value['name']]; |
175 | - if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
175 | + if ($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'].' fails dependency check on this pass'."\n"; } |
|
176 | 176 | } |
177 | 177 | else |
178 | 178 | { |
179 | 179 | $tmp = $passing[$value['name']]['name']; |
180 | - if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
180 | + if ($DEBUG) { echo '<br>process->pass(): '.$tmp.' skipped on this pass'."\n"; } |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | $i++; |
185 | - if($i == 20) /* Then oops it broke */ |
|
185 | + if ($i == 20) /* Then oops it broke */ |
|
186 | 186 | { |
187 | 187 | echo '<br>Setup failure: excess looping in process->pass():'."\n"; |
188 | 188 | echo '<br>Pass:<br>'."\n"; |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | _debug_array($passed); |
192 | 192 | exit; |
193 | 193 | } |
194 | - $pass_string = implode (':', $pass); |
|
195 | - $passing_string = implode (':', $passing); |
|
194 | + $pass_string = implode(':', $pass); |
|
195 | + $passing_string = implode(':', $passing); |
|
196 | 196 | } |
197 | 197 | try { |
198 | 198 | // flush instance cache: also registers hooks and flushes image cache |
199 | 199 | Api\Cache::flush(Api\Cache::INSTANCE); |
200 | 200 | } |
201 | - catch(Exception $e) { |
|
201 | + catch (Exception $e) { |
|
202 | 202 | unset($e); |
203 | 203 | // ignore exception, as during a new install, there's no cache configured and therefore no need to unset |
204 | 204 | } |
205 | 205 | /* now return the list */ |
206 | - return array_merge($setup_info,$passed); |
|
206 | + return array_merge($setup_info, $passed); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param array $preset_config =array() |
213 | 213 | */ |
214 | - function save_minimal_config(array $preset_config=array()) |
|
214 | + function save_minimal_config(array $preset_config = array()) |
|
215 | 215 | { |
216 | - $is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN'; |
|
216 | + $is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; |
|
217 | 217 | |
218 | 218 | $current_config['site_title'] = 'EGroupware'; |
219 | - $current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; |
|
219 | + $current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; |
|
220 | 220 | |
221 | 221 | // guessing the eGW url |
222 | 222 | if (isset($_SERVER['HTTP_HOST'])) |
223 | 223 | { |
224 | - $parts = explode('/',$_SERVER['PHP_SELF']); |
|
225 | - array_pop($parts); // remove config.php |
|
226 | - array_pop($parts); // remove setup |
|
227 | - $current_config['webserver_url'] = implode('/',$parts); |
|
224 | + $parts = explode('/', $_SERVER['PHP_SELF']); |
|
225 | + array_pop($parts); // remove config.php |
|
226 | + array_pop($parts); // remove setup |
|
227 | + $current_config['webserver_url'] = implode('/', $parts); |
|
228 | 228 | $egroupwareDirName = end($parts); |
229 | 229 | } |
230 | 230 | else // eg. cli install --> use defaults |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | $current_config['webserver_url'] = '/egroupware'; |
233 | 233 | $egroupwareDirName = 'egroupware'; |
234 | 234 | } |
235 | - if(!$is_windows) |
|
235 | + if (!$is_windows) |
|
236 | 236 | { |
237 | - if(@is_dir('/tmp')) |
|
237 | + if (@is_dir('/tmp')) |
|
238 | 238 | { |
239 | 239 | $current_config['temp_dir'] = '/tmp'; |
240 | 240 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - if(@is_dir('c:\\windows\\temp')) |
|
251 | + if (@is_dir('c:\\windows\\temp')) |
|
252 | 252 | { |
253 | 253 | $current_config['temp_dir'] = 'c:\\windows\\temp'; |
254 | 254 | } |
@@ -269,15 +269,15 @@ discard block |
||
269 | 269 | $current_config['enabled_spellcheck'] = 'YesBrowserBased'; |
270 | 270 | |
271 | 271 | // always enable history logging for calendar, addressbook and infolog |
272 | - $current_config['history'] = 'history'; // addressbook: only admin |
|
273 | - $current_config['calendar_delete_history'] = 'history'; // only admins |
|
272 | + $current_config['history'] = 'history'; // addressbook: only admin |
|
273 | + $current_config['calendar_delete_history'] = 'history'; // only admins |
|
274 | 274 | // infolog does NOT use config_app='phpgwapi', but 'infolog' |
275 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
276 | - 'config_value' => 'history_admin_delete', // only admins |
|
277 | - ),array( |
|
275 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
276 | + 'config_value' => 'history_admin_delete', // only admins |
|
277 | + ), array( |
|
278 | 278 | 'config_app' => 'infolog', |
279 | 279 | 'config_name' => 'history', |
280 | - ),__FILE__,__LINE__); |
|
280 | + ), __FILE__, __LINE__); |
|
281 | 281 | |
282 | 282 | |
283 | 283 | // RalfBecker: php.net recommend this for security reasons, it should be our default too |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $tz = new DateTimeZone(date_default_timezone_get()); |
294 | 294 | $current_config['server_timezone'] = $tz->getName(); |
295 | 295 | } |
296 | - catch(Exception $e) |
|
296 | + catch (Exception $e) |
|
297 | 297 | { |
298 | 298 | unset($e); |
299 | 299 | // do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it! |
@@ -301,42 +301,42 @@ discard block |
||
301 | 301 | } |
302 | 302 | $current_config['install_id'] = md5($_SERVER['HTTP_HOST'].microtime(true).$GLOBALS['egw_setup']->ConfigDomain); |
303 | 303 | |
304 | - $current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report |
|
304 | + $current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report |
|
305 | 305 | |
306 | 306 | // use securest password hash by default |
307 | - require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash |
|
307 | + require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash |
|
308 | 308 | $securest = null; |
309 | 309 | sql_passwdhashes(array(), true, $securest); |
310 | 310 | $current_config['sql_encryption_type'] = $current_config['ldap_encryption_type'] = $securest; |
311 | 311 | |
312 | 312 | if ($preset_config) |
313 | 313 | { |
314 | - $current_config = array_merge($current_config,$preset_config); |
|
314 | + $current_config = array_merge($current_config, $preset_config); |
|
315 | 315 | } |
316 | 316 | |
317 | - foreach($current_config as $name => $value) |
|
317 | + foreach ($current_config as $name => $value) |
|
318 | 318 | { |
319 | 319 | $app = 'phpgwapi'; |
320 | 320 | if ($name == 'postpone_statistics_submit') |
321 | 321 | { |
322 | 322 | $app = 'admin'; |
323 | 323 | } |
324 | - elseif(strpos($name, '/') !== false) |
|
324 | + elseif (strpos($name, '/') !== false) |
|
325 | 325 | { |
326 | 326 | list($app, $name) = explode('/', $name); |
327 | 327 | } |
328 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
328 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
329 | 329 | 'config_value' => $value, |
330 | - ),array( |
|
330 | + ), array( |
|
331 | 331 | 'config_app' => $app, |
332 | 332 | 'config_name' => $name, |
333 | - ),__FILE__,__LINE__); |
|
333 | + ), __FILE__, __LINE__); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // so the default_records use the current data |
337 | 337 | $GLOBALS['egw_info']['server'] = array_merge((array)$GLOBALS['egw_info']['server'], $current_config); |
338 | - Api\Cache::flush(); // flush whole instance cache |
|
339 | - Api\Config::init_static(); // flush internal cache of Api\Config class |
|
338 | + Api\Cache::flush(); // flush whole instance cache |
|
339 | + Api\Config::init_static(); // flush internal cache of Api\Config class |
|
340 | 340 | $GLOBALS['egw_setup']->setup_account_object($current_config); |
341 | 341 | } |
342 | 342 | |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param $setup_info array of application info from setup.inc.php files, etc. |
347 | 347 | */ |
348 | - function droptables(array $setup_info,$DEBUG=False) |
|
348 | + function droptables(array $setup_info, $DEBUG = False) |
|
349 | 349 | { |
350 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
350 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
351 | 351 | { |
352 | 352 | $this->init_process(); |
353 | 353 | } |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | $tablenames = $GLOBALS['egw_setup']->db->table_names(); |
356 | 356 | if (!is_array($setup_info) || !is_array($tablenames)) |
357 | 357 | { |
358 | - return $setup_info; // nothing to do |
|
358 | + return $setup_info; // nothing to do |
|
359 | 359 | } |
360 | 360 | $tables = array(); |
361 | - foreach($tablenames as $data) |
|
361 | + foreach ($tablenames as $data) |
|
362 | 362 | { |
363 | 363 | $tables[] = $data['table_name']; |
364 | 364 | } |
@@ -367,16 +367,16 @@ discard block |
||
367 | 367 | { |
368 | 368 | return $setup_info; |
369 | 369 | } |
370 | - foreach($setup_info as $app_name => $data) |
|
370 | + foreach ($setup_info as $app_name => $data) |
|
371 | 371 | { |
372 | - if(is_array($data['tables'])) |
|
372 | + if (is_array($data['tables'])) |
|
373 | 373 | { |
374 | - foreach($data['tables'] as $table) |
|
374 | + foreach ($data['tables'] as $table) |
|
375 | 375 | { |
376 | 376 | //echo $table; |
377 | - if(in_array($table,$tables)) |
|
377 | + if (in_array($table, $tables)) |
|
378 | 378 | { |
379 | - if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
379 | + if ($DEBUG) { echo '<br>process->droptables(): Dropping :'.$app_name.' table: '.$table; } |
|
380 | 380 | $GLOBALS['egw_setup']->oProc->DropTable($table); |
381 | 381 | // Update the array values for return below |
382 | 382 | $setup_info[$app_name]['status'] = 'U'; |
@@ -396,31 +396,31 @@ discard block |
||
396 | 396 | * @param boolean $DEBUG =false output further diagnostics |
397 | 397 | * @return array $setup_info |
398 | 398 | */ |
399 | - function current(array $setup_info,$DEBUG=False) |
|
399 | + function current(array $setup_info, $DEBUG = False) |
|
400 | 400 | { |
401 | 401 | //echo __METHOD__; _debug_array($setup_info); |
402 | - if(!isset($GLOBALS['egw_setup']->oProc)) |
|
402 | + if (!isset($GLOBALS['egw_setup']->oProc)) |
|
403 | 403 | { |
404 | 404 | $this->init_process(); |
405 | 405 | } |
406 | - foreach($setup_info as $appname => &$appdata) |
|
406 | + foreach ($setup_info as $appname => &$appdata) |
|
407 | 407 | { |
408 | 408 | $enabled = False; |
409 | 409 | $apptitle = $appdata['title']; |
410 | 410 | |
411 | - if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
411 | + if ($DEBUG) { echo '<br>process->current(): Incoming status: '.$appname.',status: '.$appdata['status']; } |
|
412 | 412 | |
413 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
413 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
414 | 414 | |
415 | - if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
|
415 | + if ($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
|
416 | 416 | { |
417 | - if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
417 | + if ($DEBUG) { echo '<br>process->current(): Including: '.$appdir.'tables_current.inc.php'; } |
|
418 | 418 | $phpgw_baseline = null; |
419 | 419 | include ($appdir.'tables_current.inc.php'); |
420 | - $ret = $this->post_process($phpgw_baseline,$DEBUG); |
|
421 | - if($ret) |
|
420 | + $ret = $this->post_process($phpgw_baseline, $DEBUG); |
|
421 | + if ($ret) |
|
422 | 422 | { |
423 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
423 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
424 | 424 | { |
425 | 425 | $GLOBALS['egw_setup']->update_app($appname); |
426 | 426 | } |
@@ -435,34 +435,34 @@ discard block |
||
435 | 435 | else |
436 | 436 | { |
437 | 437 | /* script processing failed */ |
438 | - if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
438 | + if ($DEBUG) { echo '<br>process->current(): Failed for '.$appname.',status: '.$appdata['status']; } |
|
439 | 439 | $appdata['status'] = 'F'; |
440 | 440 | } |
441 | 441 | } |
442 | 442 | else |
443 | 443 | { |
444 | - if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
444 | + if ($DEBUG) { echo '<br>process->current(): No current tables for '.$apptitle."\n"; } |
|
445 | 445 | /* |
446 | 446 | Add the app, but disable it if it has tables defined. |
447 | 447 | A manual sql script install is needed, but we do add the hooks |
448 | 448 | */ |
449 | 449 | $enabled = 99; |
450 | - if($appdata['tables'][0] != '') |
|
450 | + if ($appdata['tables'][0] != '') |
|
451 | 451 | { |
452 | 452 | $enabled = False; |
453 | 453 | } |
454 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
454 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
455 | 455 | { |
456 | 456 | $GLOBALS['egw_setup']->update_app($appname); |
457 | 457 | } |
458 | 458 | else |
459 | 459 | { |
460 | - $GLOBALS['egw_setup']->register_app($appname,$enabled); |
|
460 | + $GLOBALS['egw_setup']->register_app($appname, $enabled); |
|
461 | 461 | $GLOBALS['egw_setup']->set_default_preferences($appname); |
462 | 462 | } |
463 | 463 | $appdata['status'] = 'C'; |
464 | 464 | } |
465 | - if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
465 | + if ($DEBUG) { echo '<br>process->current(): Outgoing status: '.$appname.',status: '.$appdata['status']; } |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | // update hooks |
@@ -479,25 +479,25 @@ discard block |
||
479 | 479 | * @param boolean $DEBUG =false output further diagnostics |
480 | 480 | * @return array $setup_info |
481 | 481 | */ |
482 | - function default_records(array $setup_info,$DEBUG=False) |
|
482 | + function default_records(array $setup_info, $DEBUG = False) |
|
483 | 483 | { |
484 | 484 | //echo __METHOD__; _debug_array($setup_info); |
485 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
485 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
486 | 486 | { |
487 | 487 | $this->init_process(); |
488 | 488 | } |
489 | - foreach($setup_info as $appname => &$appdata) |
|
489 | + foreach ($setup_info as $appname => &$appdata) |
|
490 | 490 | { |
491 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
491 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
492 | 492 | |
493 | - if(file_exists($appdir.'default_records.inc.php')) |
|
493 | + if (file_exists($appdir.'default_records.inc.php')) |
|
494 | 494 | { |
495 | - if($DEBUG) |
|
495 | + if ($DEBUG) |
|
496 | 496 | { |
497 | - echo '<br>process->default_records(): Including default records for ' . $appname . "\n"; |
|
497 | + echo '<br>process->default_records(): Including default records for '.$appname."\n"; |
|
498 | 498 | } |
499 | 499 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_begin(); |
500 | - $oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps |
|
500 | + $oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps |
|
501 | 501 | include ($appdir.'default_records.inc.php'); |
502 | 502 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_commit(); |
503 | 503 | } |
@@ -521,21 +521,21 @@ discard block |
||
521 | 521 | * @param boolean $DEBUG =false output further diagnostics |
522 | 522 | * @return array $setup_info |
523 | 523 | */ |
524 | - function test_data(array $setup_info,$DEBUG=False) |
|
524 | + function test_data(array $setup_info, $DEBUG = False) |
|
525 | 525 | { |
526 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
526 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
527 | 527 | { |
528 | 528 | $this->init_process(); |
529 | 529 | } |
530 | - foreach($setup_info as $appname => &$appdata) |
|
530 | + foreach ($setup_info as $appname => &$appdata) |
|
531 | 531 | { |
532 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
532 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
533 | 533 | |
534 | - if(file_exists($appdir.'test_data.inc.php')) |
|
534 | + if (file_exists($appdir.'test_data.inc.php')) |
|
535 | 535 | { |
536 | - if($DEBUG) |
|
536 | + if ($DEBUG) |
|
537 | 537 | { |
538 | - echo '<br>process->test_data(): Including baseline test data for ' . $appname . "\n"; |
|
538 | + echo '<br>process->test_data(): Including baseline test data for '.$appname."\n"; |
|
539 | 539 | } |
540 | 540 | $GLOBALS['egw_setup']->oProc->m_odb->transaction_begin(); |
541 | 541 | include ($appdir.'test_data.inc.php'); |
@@ -555,35 +555,35 @@ discard block |
||
555 | 555 | * @param boolean $DEBUG =false output further diagnostics |
556 | 556 | * @return array $setup_info |
557 | 557 | */ |
558 | - function baseline(array $setup_info,$DEBUG=False) |
|
558 | + function baseline(array $setup_info, $DEBUG = False) |
|
559 | 559 | { |
560 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
560 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
561 | 561 | { |
562 | 562 | $this->init_process(); |
563 | 563 | } |
564 | - foreach($setup_info as $appname => &$appdata) |
|
564 | + foreach ($setup_info as $appname => &$appdata) |
|
565 | 565 | { |
566 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
566 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
567 | 567 | |
568 | - if(file_exists($appdir.'tables_baseline.inc.php')) |
|
568 | + if (file_exists($appdir.'tables_baseline.inc.php')) |
|
569 | 569 | { |
570 | - if($DEBUG) |
|
570 | + if ($DEBUG) |
|
571 | 571 | { |
572 | - echo '<br>process->baseline(): Including baseline tables for ' . $appname . "\n"; |
|
572 | + echo '<br>process->baseline(): Including baseline tables for '.$appname."\n"; |
|
573 | 573 | } |
574 | 574 | $phpgw_baseline = null; |
575 | 575 | include ($appdir.'tables_baseline.inc.php'); |
576 | 576 | $GLOBALS['egw_setup']->oProc->GenerateScripts($phpgw_baseline, $DEBUG); |
577 | - $this->post_process($phpgw_baseline,$DEBUG); |
|
577 | + $this->post_process($phpgw_baseline, $DEBUG); |
|
578 | 578 | |
579 | 579 | /* Update the array values for return below */ |
580 | 580 | /* $setup_info[$key]['status'] = 'R'; */ |
581 | 581 | } |
582 | 582 | else |
583 | 583 | { |
584 | - if($DEBUG) |
|
584 | + if ($DEBUG) |
|
585 | 585 | { |
586 | - echo '<br>process->baseline(): No baseline tables for ' . $appname . "\n"; |
|
586 | + echo '<br>process->baseline(): No baseline tables for '.$appname."\n"; |
|
587 | 587 | } |
588 | 588 | //$setup_info[$key]['status'] = 'C'; |
589 | 589 | } |
@@ -601,19 +601,19 @@ discard block |
||
601 | 601 | * @param boolean $DEBUG =false output further diagnostics |
602 | 602 | * @return array $setup_info |
603 | 603 | */ |
604 | - function upgrade($setup_info,$DEBUG=False) |
|
604 | + function upgrade($setup_info, $DEBUG = False) |
|
605 | 605 | { |
606 | 606 | //echo __METHOD__; _debug_array($setup_info); |
607 | - if(!@$GLOBALS['egw_setup']->oProc) |
|
607 | + if (!@$GLOBALS['egw_setup']->oProc) |
|
608 | 608 | { |
609 | 609 | $this->init_process(); |
610 | 610 | } |
611 | 611 | $GLOBALS['egw_setup']->oProc->m_odb->HaltOnError = 'yes'; |
612 | 612 | |
613 | - foreach($setup_info as $appname => &$appdata) |
|
613 | + foreach ($setup_info as $appname => &$appdata) |
|
614 | 614 | { |
615 | 615 | // check if app is NOT installed |
616 | - if(!$GLOBALS['egw_setup']->app_registered($appname)) |
|
616 | + if (!$GLOBALS['egw_setup']->app_registered($appname)) |
|
617 | 617 | { |
618 | 618 | // check if app wants to be automatically installed on update to version x or allways |
619 | 619 | if (isset($appdata['autoinstall']) && ($appdata['autoinstall'] === true || |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | continue; |
626 | 626 | } |
627 | 627 | /* Don't try to upgrade an app that is not installed */ |
628 | - if($DEBUG) |
|
628 | + if ($DEBUG) |
|
629 | 629 | { |
630 | 630 | echo "<p>process->upgrade(): Application not installed: $appname</p>\n"; |
631 | 631 | } |
@@ -634,41 +634,41 @@ discard block |
||
634 | 634 | } |
635 | 635 | |
636 | 636 | /* if upgrade required, or if we are running again after an upgrade or dependency failure */ |
637 | - if($DEBUG) |
|
637 | + if ($DEBUG) |
|
638 | 638 | { |
639 | 639 | echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n"; |
640 | 640 | } |
641 | - if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
641 | + if ($appdata['status'] == 'U' || $appdata['status'] == 'D' || $appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
642 | 642 | { |
643 | 643 | $currentver = $appdata['currentver']; |
644 | - $targetver = $appdata['version']; // The version we need to match when done |
|
645 | - $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
|
644 | + $targetver = $appdata['version']; // The version we need to match when done |
|
645 | + $appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/'; |
|
646 | 646 | |
647 | - if(file_exists($appdir . 'tables_update.inc.php')) |
|
647 | + if (file_exists($appdir.'tables_update.inc.php')) |
|
648 | 648 | { |
649 | 649 | if (!@$this->updateincluded[$appname]) |
650 | 650 | { |
651 | - include ($appdir . 'tables_update.inc.php'); |
|
651 | + include ($appdir.'tables_update.inc.php'); |
|
652 | 652 | $this->updateincluded[$appname] = True; |
653 | 653 | } |
654 | 654 | while ($currentver && $currentver != $targetver && |
655 | - function_exists($function = $appname . '_upgrade' . str_replace('.','_',$currentver))) |
|
655 | + function_exists($function = $appname.'_upgrade'.str_replace('.', '_', $currentver))) |
|
656 | 656 | { |
657 | - if($DEBUG) |
|
657 | + if ($DEBUG) |
|
658 | 658 | { |
659 | 659 | echo "<br>process->upgrade(): $appname($currentver --> $targetver): running $function()\n"; |
660 | 660 | } |
661 | 661 | if (!($currentver = $function())) |
662 | 662 | { |
663 | - if($DEBUG) |
|
663 | + if ($DEBUG) |
|
664 | 664 | { |
665 | 665 | echo "<b>failed!!!</b>\n"; |
666 | 666 | } |
667 | - $appstatus = 'F'; |
|
667 | + $appstatus = 'F'; |
|
668 | 668 | } |
669 | 669 | else |
670 | 670 | { |
671 | - if($DEBUG) |
|
671 | + if ($DEBUG) |
|
672 | 672 | { |
673 | 673 | echo "--> $currentver\n"; |
674 | 674 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | } |
677 | 677 | if ($currentver == $targetver) // upgrades succesful |
678 | 678 | { |
679 | - if($DEBUG) |
|
679 | + if ($DEBUG) |
|
680 | 680 | { |
681 | 681 | echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n"; |
682 | 682 | } |
@@ -684,27 +684,27 @@ discard block |
||
684 | 684 | } |
685 | 685 | elseif ($currentver) |
686 | 686 | { |
687 | - if($DEBUG) |
|
687 | + if ($DEBUG) |
|
688 | 688 | { |
689 | 689 | echo "<br><b>process->upgrade(): No table upgrade available for appname: $appname, version: $currentver</b>\n"; |
690 | 690 | } |
691 | 691 | $appdate['currentver'] = $targetver; |
692 | - $appstatus = 'F'; |
|
692 | + $appstatus = 'F'; |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | else |
696 | 696 | { |
697 | - if($DEBUG) |
|
697 | + if ($DEBUG) |
|
698 | 698 | { |
699 | 699 | echo "<br>process->upgrade(): No table upgrade required/availible for $appname\n"; |
700 | 700 | } |
701 | - $appstatus = 'C'; |
|
701 | + $appstatus = 'C'; |
|
702 | 702 | } |
703 | 703 | if ($appstatus == 'C') // update successful completed |
704 | 704 | { |
705 | 705 | $appdata['currentver'] = $targetver; |
706 | 706 | |
707 | - if($GLOBALS['egw_setup']->app_registered($appname)) |
|
707 | + if ($GLOBALS['egw_setup']->app_registered($appname)) |
|
708 | 708 | { |
709 | 709 | $GLOBALS['egw_setup']->update_app($appname); |
710 | 710 | } |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | } |
718 | 718 | else |
719 | 719 | { |
720 | - if($DEBUG) |
|
720 | + if ($DEBUG) |
|
721 | 721 | { |
722 | 722 | echo "<br>process->upgrade(): No upgrade required for $appname\n"; |
723 | 723 | } |
724 | - $appstatus = 'C'; |
|
724 | + $appstatus = 'C'; |
|
725 | 725 | } |
726 | 726 | /* Done with this app, update status */ |
727 | - if($DEBUG) |
|
727 | + if ($DEBUG) |
|
728 | 728 | { |
729 | 729 | echo "<br>process->upgrade(): Outgoing : appname: $appname, status: $appstatus</div>\n"; |
730 | 730 | } |
@@ -742,13 +742,13 @@ discard block |
||
742 | 742 | * commit above processing to the db |
743 | 743 | * |
744 | 744 | */ |
745 | - function post_process($tables,$DEBUG=False) |
|
745 | + function post_process($tables, $DEBUG = False) |
|
746 | 746 | { |
747 | - if(!$tables) |
|
747 | + if (!$tables) |
|
748 | 748 | { |
749 | 749 | return False; |
750 | 750 | } |
751 | - return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG); |
|
751 | + return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables, $DEBUG); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -756,14 +756,14 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @param $tablename table whose array you want to see |
758 | 758 | */ |
759 | - function sql_to_array($tablename='') |
|
759 | + function sql_to_array($tablename = '') |
|
760 | 760 | { |
761 | - if(!$tablename) |
|
761 | + if (!$tablename) |
|
762 | 762 | { |
763 | 763 | return False; |
764 | 764 | } |
765 | 765 | |
766 | - if(!$GLOBALS['egw_setup']->oProc) |
|
766 | + if (!$GLOBALS['egw_setup']->oProc) |
|
767 | 767 | { |
768 | 768 | $this->init_process(); |
769 | 769 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $sColumns = null; |
772 | 772 | $GLOBALS['egw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['egw_setup']->oProc, $tablename, $sColumns); |
773 | 773 | |
774 | - while(list($key,$tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol)) |
|
774 | + while (list($key, $tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol)) |
|
775 | 775 | { |
776 | 776 | $arr .= $tbldata; |
777 | 777 | } |
@@ -780,6 +780,6 @@ discard block |
||
780 | 780 | $ix = $GLOBALS['egw_setup']->oProc->m_oTranslator->ix; |
781 | 781 | $uc = $GLOBALS['egw_setup']->oProc->m_oTranslator->uc; |
782 | 782 | |
783 | - return array($arr,$pk,$fk,$ix,$uc); |
|
783 | + return array($arr, $pk, $fk, $ix, $uc); |
|
784 | 784 | } |
785 | 785 | } |
@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | while($pass_string != $passing_string) |
109 | 109 | { |
110 | 110 | $passing = array(); |
111 | - if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
111 | + if($DEBUG) |
|
112 | + { |
|
113 | +echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; } |
|
112 | 114 | |
113 | 115 | // Check current versions and dependencies |
114 | 116 | $setup_info = $GLOBALS['egw_setup']->detection->check_depends( |
@@ -143,7 +145,10 @@ discard block |
||
143 | 145 | } |
144 | 146 | /* Create tables and insert new records for each app in this list */ |
145 | 147 | $passing_c = $this->current($pass,$DEBUG); |
146 | - if (isset($pass['api'])) $this->save_minimal_config($preset_config); |
|
148 | + if (isset($pass['api'])) |
|
149 | + { |
|
150 | + $this->save_minimal_config($preset_config); |
|
151 | + } |
|
147 | 152 | $passing = $this->default_records($passing_c,$DEBUG); |
148 | 153 | break; |
149 | 154 | case 'upgrade': |
@@ -162,29 +167,40 @@ discard block |
||
162 | 167 | if($value['status'] == 'C') |
163 | 168 | { |
164 | 169 | $passed[$value['name']] = $passing[$value['name']]; |
165 | - if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
170 | + if($DEBUG) |
|
171 | + { |
|
172 | +echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; } |
|
166 | 173 | } |
167 | 174 | elseif($value['status'] == 'F') |
168 | 175 | { |
169 | 176 | $setup_info[$value['name']] = $passing[$value['name']]; |
170 | - if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
177 | + if($DEBUG) |
|
178 | + { |
|
179 | +echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; } |
|
171 | 180 | } |
172 | 181 | elseif($value['status'] == 'D') |
173 | 182 | { |
174 | 183 | $pass[$value['name']] = $setup_info[$value['name']]; |
175 | - if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
184 | + if($DEBUG) |
|
185 | + { |
|
186 | +echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; } |
|
176 | 187 | } |
177 | 188 | else |
178 | 189 | { |
179 | 190 | $tmp = $passing[$value['name']]['name']; |
180 | - if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
191 | + if($DEBUG) |
|
192 | + { |
|
193 | +echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; } |
|
181 | 194 | } |
182 | 195 | } |
183 | 196 | |
184 | 197 | $i++; |
185 | - if($i == 20) /* Then oops it broke */ |
|
198 | + if($i == 20) |
|
199 | + { |
|
200 | + /* Then oops it broke */ |
|
186 | 201 | { |
187 | 202 | echo '<br>Setup failure: excess looping in process->pass():'."\n"; |
203 | + } |
|
188 | 204 | echo '<br>Pass:<br>'."\n"; |
189 | 205 | _debug_array($pass); |
190 | 206 | echo '<br>Passed:<br>'."\n"; |
@@ -376,7 +392,9 @@ discard block |
||
376 | 392 | //echo $table; |
377 | 393 | if(in_array($table,$tables)) |
378 | 394 | { |
379 | - if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
395 | + if($DEBUG) |
|
396 | + { |
|
397 | +echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; } |
|
380 | 398 | $GLOBALS['egw_setup']->oProc->DropTable($table); |
381 | 399 | // Update the array values for return below |
382 | 400 | $setup_info[$app_name]['status'] = 'U'; |
@@ -408,13 +426,17 @@ discard block |
||
408 | 426 | $enabled = False; |
409 | 427 | $apptitle = $appdata['title']; |
410 | 428 | |
411 | - if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
429 | + if($DEBUG) |
|
430 | + { |
|
431 | +echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; } |
|
412 | 432 | |
413 | 433 | $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
414 | 434 | |
415 | 435 | if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php')) |
416 | 436 | { |
417 | - if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
437 | + if($DEBUG) |
|
438 | + { |
|
439 | +echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; } |
|
418 | 440 | $phpgw_baseline = null; |
419 | 441 | include ($appdir.'tables_current.inc.php'); |
420 | 442 | $ret = $this->post_process($phpgw_baseline,$DEBUG); |
@@ -435,13 +457,17 @@ discard block |
||
435 | 457 | else |
436 | 458 | { |
437 | 459 | /* script processing failed */ |
438 | - if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
460 | + if($DEBUG) |
|
461 | + { |
|
462 | +echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; } |
|
439 | 463 | $appdata['status'] = 'F'; |
440 | 464 | } |
441 | 465 | } |
442 | 466 | else |
443 | 467 | { |
444 | - if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
468 | + if($DEBUG) |
|
469 | + { |
|
470 | +echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; } |
|
445 | 471 | /* |
446 | 472 | Add the app, but disable it if it has tables defined. |
447 | 473 | A manual sql script install is needed, but we do add the hooks |
@@ -462,7 +488,9 @@ discard block |
||
462 | 488 | } |
463 | 489 | $appdata['status'] = 'C'; |
464 | 490 | } |
465 | - if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
491 | + if($DEBUG) |
|
492 | + { |
|
493 | +echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; } |
|
466 | 494 | } |
467 | 495 | |
468 | 496 | // update hooks |
@@ -638,9 +666,12 @@ discard block |
||
638 | 666 | { |
639 | 667 | echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n"; |
640 | 668 | } |
641 | - if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ??? |
|
669 | + if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') |
|
670 | + { |
|
671 | + // TODO this is not getting set for api upgrade, sometimes ??? |
|
642 | 672 | { |
643 | 673 | $currentver = $appdata['currentver']; |
674 | + } |
|
644 | 675 | $targetver = $appdata['version']; // The version we need to match when done |
645 | 676 | $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
646 | 677 | |
@@ -674,11 +705,14 @@ discard block |
||
674 | 705 | } |
675 | 706 | } |
676 | 707 | } |
677 | - if ($currentver == $targetver) // upgrades succesful |
|
708 | + if ($currentver == $targetver) |
|
709 | + { |
|
710 | + // upgrades succesful |
|
678 | 711 | { |
679 | 712 | if($DEBUG) |
680 | 713 | { |
681 | 714 | echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n"; |
715 | + } |
|
682 | 716 | } |
683 | 717 | $appstatus = 'C'; |
684 | 718 | } |
@@ -700,9 +734,12 @@ discard block |
||
700 | 734 | } |
701 | 735 | $appstatus = 'C'; |
702 | 736 | } |
703 | - if ($appstatus == 'C') // update successful completed |
|
737 | + if ($appstatus == 'C') |
|
738 | + { |
|
739 | + // update successful completed |
|
704 | 740 | { |
705 | 741 | $appdata['currentver'] = $targetver; |
742 | + } |
|
706 | 743 | |
707 | 744 | if($GLOBALS['egw_setup']->app_registered($appname)) |
708 | 745 | { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @param statuses List of statuses to process, with sub-statuses in a 'substatus' array |
263 | 263 | * @param labels Array of labels, pass array() and labels will be built in it |
264 | - * @param depth Current depth |
|
264 | + * @param depth integer depth |
|
265 | 265 | * |
266 | 266 | * @return None, labels are built in labels parameter |
267 | 267 | */ |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param array|int $data =null use $this->data or $this->data['ts_id'] (to fetch the data) |
307 | 307 | * @param int $user =null for which user to check, default current user |
308 | - * @return boolean true if the rights are ok, false if no rights |
|
308 | + * @return null|boolean true if the rights are ok, false if no rights |
|
309 | 309 | */ |
310 | 310 | function check_statusForEditRights($data=null,$user=null) |
311 | 311 | { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @param int $required Acl::READ, EGW_ACL_WRITE, Acl::ADD, Acl::DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET |
341 | 341 | * @param array|int $data =null project or project-id to use, default the project in $this->data |
342 | 342 | * @param int $user =null for which user to check, default current user |
343 | - * @return boolean true if the rights are ok, null if not found, false if no rights |
|
343 | + * @return null|boolean true if the rights are ok, null if not found, false if no rights |
|
344 | 344 | */ |
345 | 345 | function check_acl($required,$data=null,$user=null) |
346 | 346 | { |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
398 | 398 | * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return |
399 | 399 | * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
400 | - * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
400 | + * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
401 | 401 | * @param string $wildcard ='' appended befor and after each criteria |
402 | 402 | * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row |
403 | 403 | * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
404 | - * @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
404 | + * @param boolean $start =false if != false, return only maxmatch rows begining with start, or array($start,$num) |
|
405 | 405 | * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
406 | 406 | * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or |
407 | 407 | * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! |
@@ -658,8 +658,6 @@ discard block |
||
658 | 658 | * delete / move all timesheets of a given user |
659 | 659 | * |
660 | 660 | * @param array $data |
661 | - * @param int $data['account_id'] owner to change |
|
662 | - * @param int $data['new_owner'] new owner or 0 for delete |
|
663 | 661 | */ |
664 | 662 | function deleteaccount($data) |
665 | 663 | { |
@@ -686,7 +684,7 @@ discard block |
||
686 | 684 | * |
687 | 685 | * @param array $keys =null if given array with col => value pairs to characterise single timesheet or null for $this->data |
688 | 686 | * @param int $status =0 |
689 | - * @return int affected rows, should be 1 if ok, 0 if an error |
|
687 | + * @return boolean affected rows, should be 1 if ok, 0 if an error |
|
690 | 688 | */ |
691 | 689 | function set_status($keys=null, $status=0) |
692 | 690 | { |
@@ -816,7 +814,7 @@ discard block |
||
816 | 814 | * @param int $check Acl::READ for read and Acl::EDIT for write or delete access |
817 | 815 | * @param string $rel_path =null currently not used in InfoLog |
818 | 816 | * @param int $user =null for which user to check, default current user |
819 | - * @return boolean true if access is granted or false otherwise |
|
817 | + * @return null|boolean true if access is granted or false otherwise |
|
820 | 818 | */ |
821 | 819 | function file_access($id,$check,$rel_path=null,$user=null) |
822 | 820 | { |
@@ -152,8 +152,8 @@ |
||
152 | 152 | const EXTRA_TABLE = 'egw_timesheet_extra'; |
153 | 153 | |
154 | 154 | /** |
155 | - * Columns to search when user does a text search |
|
156 | - */ |
|
155 | + * Columns to search when user does a text search |
|
156 | + */ |
|
157 | 157 | var $columns_to_search = array('egw_timesheet.ts_id', 'ts_project', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_unitprice'); |
158 | 158 | |
159 | 159 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | if (!defined('TIMESHEET_APP')) |
18 | 18 | { |
19 | - define('TIMESHEET_APP','timesheet'); |
|
19 | + define('TIMESHEET_APP', 'timesheet'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @var boolean |
45 | 45 | */ |
46 | - var $quantity_sum=false; |
|
46 | + var $quantity_sum = false; |
|
47 | 47 | /** |
48 | 48 | * current user |
49 | 49 | * |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @var array |
57 | 57 | */ |
58 | 58 | var $timestamps = array( |
59 | - 'ts_start','ts_modified' |
|
59 | + 'ts_start', 'ts_modified' |
|
60 | 60 | ); |
61 | 61 | /** |
62 | 62 | * Start of today in user-time |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | * @var array |
71 | 71 | */ |
72 | 72 | var $date_filters = array( // Start: year,month,day,week, End: year,month,day,week |
73 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
74 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
75 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
76 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
77 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
78 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
79 | - '2 month ago' => array(0,-2,0,0, 0,-1,0,0), |
|
80 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
81 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
82 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
83 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
73 | + 'Today' => array(0, 0, 0, 0, 0, 0, 1, 0), |
|
74 | + 'Yesterday' => array(0, 0, -1, 0, 0, 0, 0, 0), |
|
75 | + 'This week' => array(0, 0, 0, 0, 0, 0, 0, 1), |
|
76 | + 'Last week' => array(0, 0, 0, -1, 0, 0, 0, 0), |
|
77 | + 'This month' => array(0, 0, 0, 0, 0, 1, 0, 0), |
|
78 | + 'Last month' => array(0, -1, 0, 0, 0, 0, 0, 0), |
|
79 | + '2 month ago' => array(0, -2, 0, 0, 0, -1, 0, 0), |
|
80 | + 'This year' => array(0, 0, 0, 0, 1, 0, 0, 0), |
|
81 | + 'Last year' => array(-1, 0, 0, 0, 0, 0, 0, 0), |
|
82 | + '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0), |
|
83 | + '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0), |
|
84 | 84 | ); |
85 | 85 | /** |
86 | 86 | * Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @var array |
107 | 107 | */ |
108 | - var $customfields=array(); |
|
108 | + var $customfields = array(); |
|
109 | 109 | /** |
110 | 110 | * Array with status label |
111 | 111 | * |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | |
166 | 166 | function __construct() |
167 | 167 | { |
168 | - parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id'); |
|
168 | + parent::__construct(TIMESHEET_APP, 'egw_timesheet', self::EXTRA_TABLE, '', 'ts_extra_name', 'ts_extra_value', 'ts_id'); |
|
169 | 169 | |
170 | 170 | if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
171 | 171 | $this->config_data = Api\Config::read(TIMESHEET_APP); |
172 | 172 | $this->quantity_sum = $this->config_data['quantity_sum'] == 'true'; |
173 | 173 | |
174 | 174 | // Load & process statuses |
175 | - if($this->config_data['status_labels']) $this->load_statuses(); |
|
175 | + if ($this->config_data['status_labels']) $this->load_statuses(); |
|
176 | 176 | |
177 | - $this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now)); |
|
177 | + $this->today = mktime(0, 0, 0, date('m', $this->now), date('d', $this->now), date('Y', $this->now)); |
|
178 | 178 | |
179 | 179 | // save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks |
180 | 180 | if (!is_object($GLOBALS['timesheet_bo'])) |
181 | 181 | { |
182 | - $GLOBALS['timesheet_bo'] =& $this; |
|
182 | + $GLOBALS['timesheet_bo'] = & $this; |
|
183 | 183 | } |
184 | 184 | $this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); |
185 | 185 | } |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function load_statuses() |
191 | 191 | { |
192 | - $this->status_labels =& $this->config_data['status_labels']; |
|
193 | - if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels); |
|
192 | + $this->status_labels = & $this->config_data['status_labels']; |
|
193 | + if (!is_array($this->status_labels)) $this->status_labels = array($this->status_labels); |
|
194 | 194 | |
195 | 195 | foreach ($this->status_labels as $status_id => $label) |
196 | 196 | { |
197 | 197 | if (!is_array($label)) |
198 | 198 | { //old values, before parent status |
199 | 199 | $name = $label; |
200 | - $label=array(); |
|
200 | + $label = array(); |
|
201 | 201 | $label['name'] = $name; |
202 | 202 | $label['parent'] = ''; |
203 | 203 | } |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | $map = array( |
210 | 210 | '' => array('substatus' => array()) |
211 | 211 | ); |
212 | - foreach($this->status_labels_config as $id => &$status) |
|
212 | + foreach ($this->status_labels_config as $id => &$status) |
|
213 | 213 | { |
214 | 214 | $status['substatus'] = array(); |
215 | 215 | $map[$id] = &$status; |
216 | 216 | } |
217 | - foreach($this->status_labels_config as &$status) |
|
217 | + foreach ($this->status_labels_config as &$status) |
|
218 | 218 | { |
219 | 219 | $map[$status['parent']]['substatus'][] = &$status; |
220 | 220 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | // Sort Api\Config based on tree |
228 | 228 | $sorted = array(); |
229 | - foreach($this->status_labels as $status_id => $label) |
|
229 | + foreach ($this->status_labels as $status_id => $label) |
|
230 | 230 | { |
231 | 231 | $sorted[$status_id] = $this->status_labels_config[$status_id]; |
232 | 232 | //$sorted[$status_id]['name'] = $label; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | if (!isset($this->status_labels_config)) $this->load_statuses(); |
247 | 247 | $stati = array($status); |
248 | - foreach($this->status_labels_config as $stat) |
|
248 | + foreach ($this->status_labels_config as $stat) |
|
249 | 249 | { |
250 | 250 | if ($stat['parent'] && in_array($stat['parent'], $stati)) |
251 | 251 | { |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return None, labels are built in labels parameter |
267 | 267 | */ |
268 | - protected function make_status_labels($statuses, &$labels, $depth=0) |
|
268 | + protected function make_status_labels($statuses, &$labels, $depth = 0) |
|
269 | 269 | { |
270 | - foreach($statuses as $status) |
|
270 | + foreach ($statuses as $status) |
|
271 | 271 | { |
272 | - $labels[$status['id']] = str_pad('',$depth*12, " ",STR_PAD_LEFT).trim(str_replace(' ','',$status['name'])); |
|
273 | - if(count($status['substatus']) > 0) |
|
272 | + $labels[$status['id']] = str_pad('', $depth * 12, " ", STR_PAD_LEFT).trim(str_replace(' ', '', $status['name'])); |
|
273 | + if (count($status['substatus']) > 0) |
|
274 | 274 | { |
275 | - $this->make_status_labels($status['substatus'], $labels, $depth+1); |
|
275 | + $this->make_status_labels($status['substatus'], $labels, $depth + 1); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | * @param int $required =EGW_ACL_READ |
284 | 284 | * @return array with uid => Username pairs |
285 | 285 | */ |
286 | - function grant_list($required=EGW_ACL_READ) |
|
286 | + function grant_list($required = EGW_ACL_READ) |
|
287 | 287 | { |
288 | 288 | $result = array(); |
289 | - foreach($this->grants as $uid => $grant) |
|
289 | + foreach ($this->grants as $uid => $grant) |
|
290 | 290 | { |
291 | - if ($grant & $required) |
|
291 | + if ($grant&$required) |
|
292 | 292 | { |
293 | 293 | $result[$uid] = Api\Accounts::username($uid); |
294 | 294 | } |
@@ -307,19 +307,19 @@ discard block |
||
307 | 307 | * @param int $user =null for which user to check, default current user |
308 | 308 | * @return boolean true if the rights are ok, false if no rights |
309 | 309 | */ |
310 | - function check_statusForEditRights($data=null,$user=null) |
|
310 | + function check_statusForEditRights($data = null, $user = null) |
|
311 | 311 | { |
312 | 312 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
313 | 313 | { |
314 | - $data =& $this->data; |
|
314 | + $data = & $this->data; |
|
315 | 315 | } |
316 | 316 | if (!is_array($data)) |
317 | 317 | { |
318 | 318 | $save_data = $this->data; |
319 | - $data = $this->read($data,true); |
|
319 | + $data = $this->read($data, true); |
|
320 | 320 | $this->data = $save_data; |
321 | 321 | |
322 | - if (!$data) return null; // entry not found |
|
322 | + if (!$data) return null; // entry not found |
|
323 | 323 | } |
324 | 324 | if (!$user) $user = $this->user; |
325 | 325 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
@@ -342,19 +342,19 @@ discard block |
||
342 | 342 | * @param int $user =null for which user to check, default current user |
343 | 343 | * @return boolean true if the rights are ok, null if not found, false if no rights |
344 | 344 | */ |
345 | - function check_acl($required,$data=null,$user=null) |
|
345 | + function check_acl($required, $data = null, $user = null) |
|
346 | 346 | { |
347 | 347 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
348 | 348 | { |
349 | - $data =& $this->data; |
|
349 | + $data = & $this->data; |
|
350 | 350 | } |
351 | 351 | if (!is_array($data)) |
352 | 352 | { |
353 | 353 | $save_data = $this->data; |
354 | - $data = $this->read($data,true); |
|
354 | + $data = $this->read($data, true); |
|
355 | 355 | $this->data = $save_data; |
356 | 356 | |
357 | - if (!$data) return null; // entry not found |
|
357 | + if (!$data) return null; // entry not found |
|
358 | 358 | } |
359 | 359 | if (!$user) $user = $this->user; |
360 | 360 | if ($user == $this->user) |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | } |
364 | 364 | else |
365 | 365 | { |
366 | - $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user); |
|
366 | + $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user); |
|
367 | 367 | } |
368 | - $ret = $data && !!($grants[$data['ts_owner']] & $required); |
|
368 | + $ret = $data && !!($grants[$data['ts_owner']]&$required); |
|
369 | 369 | |
370 | - if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
370 | + if (($required&Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
371 | 371 | $data['ts_status'] == self::DELETED_STATUS) |
372 | 372 | { |
373 | 373 | $ret = !!($GLOBALS['egw_info']['user']['apps']['admin']); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param int &$end |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - function date_filter($name,&$start,&$end) |
|
387 | + function date_filter($name, &$start, &$end) |
|
388 | 388 | { |
389 | 389 | return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters); |
390 | 390 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false |
410 | 410 | * @return array of matching rows (the row is an array of the cols) or False |
411 | 411 | */ |
412 | - function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false,$only_summary=false) |
|
412 | + function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false, $only_summary = false) |
|
413 | 413 | { |
414 | 414 | //error_log(__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')"); |
415 | 415 | //echo "<p>".__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n"; |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | |
419 | 419 | if (!is_array($extra_cols)) |
420 | 420 | { |
421 | - $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); |
|
421 | + $extra_cols = $extra_cols ? explode(',', $extra_cols) : array(); |
|
422 | 422 | } |
423 | - if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false) |
|
423 | + if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false) |
|
424 | 424 | { |
425 | 425 | $extra_cols[] = $total_sql.' AS ts_total'; |
426 | 426 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | { |
433 | 433 | if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
434 | 434 | |
435 | - foreach($filter['ts_owner'] as $key => $owner) |
|
435 | + foreach ($filter['ts_owner'] as $key => $owner) |
|
436 | 436 | { |
437 | 437 | if (!isset($this->grants[$owner])) |
438 | 438 | { |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | } |
447 | 447 | else |
448 | 448 | { |
449 | - $filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS . |
|
450 | - ($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')'; |
|
449 | + $filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS. |
|
450 | + ($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')'; |
|
451 | 451 | } |
452 | 452 | if (!count($filter['ts_owner'])) |
453 | 453 | { |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | $this->summary = array(); |
456 | 456 | return array(); |
457 | 457 | } |
458 | - if ($only_summary==false && $criteria && $this->show_sums) |
|
458 | + if ($only_summary == false && $criteria && $this->show_sums) |
|
459 | 459 | { |
460 | 460 | // if we have a criteria AND intend to show the sums we first query the affected ids, |
461 | 461 | // then we throw away criteria and filter, and replace the filter with the list of ids |
462 | - $ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join); |
|
462 | + $ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join); |
|
463 | 463 | //_debug_array($ids); |
464 | 464 | if (empty($ids)) |
465 | 465 | { |
466 | - $this->summary = array('duration'=>0,'price'=>null,'quantity'=>0); |
|
466 | + $this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0); |
|
467 | 467 | return array(); |
468 | 468 | } |
469 | 469 | unset($criteria); |
@@ -487,45 +487,45 @@ discard block |
||
487 | 487 | |
488 | 488 | if ($only_summary) return $this->summary; |
489 | 489 | |
490 | - if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
490 | + if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
491 | 491 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
492 | 492 | { |
493 | 493 | $sum_sql = array( |
494 | - 'year' => $this->db->date_format($from_unixtime_ts_start,'%Y'), |
|
495 | - 'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'), |
|
496 | - 'week' => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
497 | - 'day' => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'), |
|
494 | + 'year' => $this->db->date_format($from_unixtime_ts_start, '%Y'), |
|
495 | + 'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'), |
|
496 | + 'week' => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
497 | + 'day' => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'), |
|
498 | 498 | ); |
499 | - foreach($this->show_sums as $type) |
|
499 | + foreach ($this->show_sums as $type) |
|
500 | 500 | { |
501 | 501 | $extra_cols[] = $sum_sql[$type].' AS ts_'.$type; |
502 | 502 | $extra_cols[] = '0 AS is_sum_'.$type; |
503 | - $sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]); // as we dont group by ts_start |
|
503 | + $sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start |
|
504 | 504 | $sum_extra_cols[$type] = '0 AS is_sum_'.$type; |
505 | 505 | } |
506 | 506 | // regular entries |
507 | - parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
507 | + parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
508 | 508 | |
509 | - $sort = substr($order_by,8); |
|
509 | + $sort = substr($order_by, 8); |
|
510 | 510 | $union_order = array(); |
511 | - $sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0); |
|
512 | - foreach($this->show_sums as $type) |
|
511 | + $sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0); |
|
512 | + foreach ($this->show_sums as $type) |
|
513 | 513 | { |
514 | - $union_order[] = 'ts_'.$type . ' ' . $sort; |
|
514 | + $union_order[] = 'ts_'.$type.' '.$sort; |
|
515 | 515 | $union_order[] = 'is_sum_'.$type; |
516 | 516 | $sum_extra_cols[$type]{0} = '1'; |
517 | 517 | // the $type sum |
518 | - parent::search($criteria,array( |
|
519 | - (string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', |
|
518 | + parent::search($criteria, array( |
|
519 | + (string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration', |
|
520 | 520 | ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'), |
521 | - '0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total" |
|
522 | - ),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
521 | + '0', 'NULL', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total" |
|
522 | + ), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
523 | 523 | $sum_extra_cols[$type]{0} = '0'; |
524 | 524 | } |
525 | 525 | $union_order[] = 'ts_start '.$sort; |
526 | - return parent::search('','',implode(',',$union_order),'','',false,'',$start); |
|
526 | + return parent::search('', '', implode(',', $union_order), '', '', false, '', $start); |
|
527 | 527 | } |
528 | - return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count); |
|
528 | + return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,16 +535,16 @@ discard block |
||
535 | 535 | * @param boolean $ignore_acl =false should the Acl be checked |
536 | 536 | * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights |
537 | 537 | */ |
538 | - function read($ts_id,$ignore_acl=false) |
|
538 | + function read($ts_id, $ignore_acl = false) |
|
539 | 539 | { |
540 | 540 | //error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace()); |
541 | 541 | if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id)) |
542 | 542 | { |
543 | - return null; // entry not found |
|
543 | + return null; // entry not found |
|
544 | 544 | } |
545 | 545 | if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ))) |
546 | 546 | { |
547 | - return false; // no read rights |
|
547 | + return false; // no read rights |
|
548 | 548 | } |
549 | 549 | return $this->data; |
550 | 550 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts |
560 | 560 | * @return int 0 on success and errno != 0 else |
561 | 561 | */ |
562 | - function save($keys=null,$touch_modified=true,$ignore_acl=false) |
|
562 | + function save($keys = null, $touch_modified = true, $ignore_acl = false) |
|
563 | 563 | { |
564 | 564 | if ($keys) $this->data_merge($keys); |
565 | 565 | |
@@ -577,13 +577,13 @@ discard block |
||
577 | 577 | // check if we have a real modification of an existing record |
578 | 578 | if ($this->data['ts_id']) |
579 | 579 | { |
580 | - $new =& $this->data; |
|
580 | + $new = & $this->data; |
|
581 | 581 | unset($this->data); |
582 | 582 | $this->read($new['ts_id']); |
583 | - $old =& $this->data; |
|
584 | - $this->data =& $new; |
|
583 | + $old = & $this->data; |
|
584 | + $this->data = & $new; |
|
585 | 585 | $changed = array(); |
586 | - if (isset($old)) foreach($old as $name => $value) |
|
586 | + if (isset($old)) foreach ($old as $name => $value) |
|
587 | 587 | { |
588 | 588 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
589 | 589 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | } |
595 | 595 | |
596 | 596 | // Check for restore of deleted contact, restore held links |
597 | - if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
597 | + if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
598 | 598 | { |
599 | 599 | Link::restore(TIMESHEET_APP, $new['ts_id']); |
600 | 600 | } |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | |
606 | 606 | $this->tracking->html_content_allow = true; |
607 | 607 | } |
608 | - if ($this->tracking->track($this->data,$old,$this->user) === false) |
|
608 | + if ($this->tracking->track($this->data, $old, $this->user) === false) |
|
609 | 609 | { |
610 | - return implode(', ',$this->tracking->errors); |
|
610 | + return implode(', ', $this->tracking->errors); |
|
611 | 611 | } |
612 | 612 | if (!($err = parent::save())) |
613 | 613 | { |
614 | 614 | // notify the link-class about the update, as other apps may be subscribt to it |
615 | - Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data); |
|
615 | + Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | return $err; |
@@ -625,15 +625,15 @@ discard block |
||
625 | 625 | * @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts |
626 | 626 | * @return int affected rows, should be 1 if ok, 0 if an error |
627 | 627 | */ |
628 | - function delete($keys=null,$ignore_acl=false) |
|
628 | + function delete($keys = null, $ignore_acl = false) |
|
629 | 629 | { |
630 | - if (!is_array($keys) && (int) $keys) |
|
630 | + if (!is_array($keys) && (int)$keys) |
|
631 | 631 | { |
632 | - $keys = array('ts_id' => (int) $keys); |
|
632 | + $keys = array('ts_id' => (int)$keys); |
|
633 | 633 | } |
634 | 634 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
635 | 635 | |
636 | - if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id))) |
|
636 | + if (!$ignore_acl && !$this->check_acl(Acl::DELETE, $ts_id) || !($old = $this->read($ts_id))) |
|
637 | 637 | { |
638 | 638 | return false; |
639 | 639 | } |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | $delete = $old; |
645 | 645 | $delete['ts_status'] = self::DELETED_STATUS; |
646 | 646 | $ret = !($this->save($delete)); |
647 | - Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true); |
|
647 | + Link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true); |
|
648 | 648 | } |
649 | 649 | elseif (($ret = parent::delete($keys)) && $ts_id) |
650 | 650 | { |
651 | 651 | // delete all links to timesheet entry $ts_id |
652 | - Link::unlink(0,TIMESHEET_APP,$ts_id); |
|
652 | + Link::unlink(0, TIMESHEET_APP, $ts_id); |
|
653 | 653 | } |
654 | 654 | return $ret; |
655 | 655 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | function deleteaccount($data) |
665 | 665 | { |
666 | 666 | $account_id = $data['account_id']; |
667 | - $new_owner = $data['new_owner']; |
|
667 | + $new_owner = $data['new_owner']; |
|
668 | 668 | |
669 | 669 | if (!$new_owner) |
670 | 670 | { |
@@ -688,22 +688,22 @@ discard block |
||
688 | 688 | * @param int $status =0 |
689 | 689 | * @return int affected rows, should be 1 if ok, 0 if an error |
690 | 690 | */ |
691 | - function set_status($keys=null, $status=0) |
|
691 | + function set_status($keys = null, $status = 0) |
|
692 | 692 | { |
693 | 693 | $ret = true; |
694 | - if (!is_array($keys) && (int) $keys) |
|
694 | + if (!is_array($keys) && (int)$keys) |
|
695 | 695 | { |
696 | - $keys = array('ts_id' => (int) $keys); |
|
696 | + $keys = array('ts_id' => (int)$keys); |
|
697 | 697 | } |
698 | 698 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
699 | 699 | |
700 | - if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true)) |
|
700 | + if (!$this->check_acl(Acl::EDIT, $ts_id) || !$this->read($ts_id, true)) |
|
701 | 701 | { |
702 | 702 | return false; |
703 | 703 | } |
704 | 704 | |
705 | 705 | $this->data['ts_status'] = $status; |
706 | - if ($this->save($ts_id)!=0) $ret = false; |
|
706 | + if ($this->save($ts_id) != 0) $ret = false; |
|
707 | 707 | |
708 | 708 | return $ret; |
709 | 709 | } |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | { |
721 | 721 | return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null); |
722 | 722 | } |
723 | - return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true); |
|
723 | + return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -731,27 +731,27 @@ discard block |
||
731 | 731 | * @param int|array $entry int ts_id or array with timesheet entry |
732 | 732 | * @return string/boolean string with title, null if timesheet not found, false if no perms to view it |
733 | 733 | */ |
734 | - function link_title( $entry ) |
|
734 | + function link_title($entry) |
|
735 | 735 | { |
736 | 736 | if (!is_array($entry)) |
737 | 737 | { |
738 | 738 | // need to preserve the $this->data |
739 | - $backup =& $this->data; |
|
739 | + $backup = & $this->data; |
|
740 | 740 | unset($this->data); |
741 | - $entry = $this->read( $entry,false,false); |
|
741 | + $entry = $this->read($entry, false, false); |
|
742 | 742 | // restore the data again |
743 | - $this->data =& $backup; |
|
743 | + $this->data = & $backup; |
|
744 | 744 | } |
745 | 745 | if (!$entry) |
746 | 746 | { |
747 | 747 | return $entry; |
748 | 748 | } |
749 | 749 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
750 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
750 | + if (date('H:i', $entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
751 | 751 | { |
752 | 752 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
753 | 753 | } |
754 | - return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
|
754 | + return date($format, $entry['ts_start']).': '.$entry['ts_title']; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -762,18 +762,18 @@ discard block |
||
762 | 762 | * @param array $ids array with ts_id's |
763 | 763 | * @return array with titles, see link_title |
764 | 764 | */ |
765 | - function link_titles( array $ids ) |
|
765 | + function link_titles(array $ids) |
|
766 | 766 | { |
767 | 767 | $titles = array(); |
768 | - if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start'))) |
|
768 | + if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start'))) |
|
769 | 769 | { |
770 | - foreach($entries as $entry) |
|
770 | + foreach ($entries as $entry) |
|
771 | 771 | { |
772 | 772 | $titles[$entry['ts_id']] = $this->link_title($entry); |
773 | 773 | } |
774 | 774 | } |
775 | 775 | // we assume all not returned entries are not readable by the user, as we notify Link about all deletes |
776 | - foreach($ids as $id) |
|
776 | + foreach ($ids as $id) |
|
777 | 777 | { |
778 | 778 | if (!isset($titles[$id])) |
779 | 779 | { |
@@ -792,16 +792,16 @@ discard block |
||
792 | 792 | * @param array $options Array of options for the search |
793 | 793 | * @return array with ts_id - title pairs of the matching entries |
794 | 794 | */ |
795 | - function link_query( $pattern, Array &$options = array() ) |
|
795 | + function link_query($pattern, Array &$options = array()) |
|
796 | 796 | { |
797 | 797 | $limit = false; |
798 | 798 | $need_count = false; |
799 | - if($options['start'] || $options['num_rows']) { |
|
799 | + if ($options['start'] || $options['num_rows']) { |
|
800 | 800 | $limit = array($options['start'], $options['num_rows']); |
801 | 801 | $need_count = true; |
802 | 802 | } |
803 | 803 | $result = array(); |
804 | - foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
|
804 | + foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts) |
|
805 | 805 | { |
806 | 806 | if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
807 | 807 | } |
@@ -818,11 +818,11 @@ discard block |
||
818 | 818 | * @param int $user =null for which user to check, default current user |
819 | 819 | * @return boolean true if access is granted or false otherwise |
820 | 820 | */ |
821 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
821 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
822 | 822 | { |
823 | - unset($rel_path); // not used, but required by function signature |
|
823 | + unset($rel_path); // not used, but required by function signature |
|
824 | 824 | |
825 | - return $this->check_acl($check,$id,$user); |
|
825 | + return $this->check_acl($check, $id, $user); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -834,16 +834,16 @@ discard block |
||
834 | 834 | * @param string $newtitle => the new title of the project |
835 | 835 | * @return boolean true for success, false for invalid parameters |
836 | 836 | */ |
837 | - function update_ts_project($oldtitle='', $newtitle='') |
|
837 | + function update_ts_project($oldtitle = '', $newtitle = '') |
|
838 | 838 | { |
839 | - if(strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
839 | + if (strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
840 | 840 | { |
841 | - $this->db->update('egw_timesheet',array( |
|
841 | + $this->db->update('egw_timesheet', array( |
|
842 | 842 | 'ts_project' => $newtitle, |
843 | 843 | 'ts_title' => $newtitle, |
844 | - ),array( |
|
844 | + ), array( |
|
845 | 845 | 'ts_project' => $oldtitle, |
846 | - ),__LINE__,__FILE__,TIMESHEET_APP); |
|
846 | + ), __LINE__, __FILE__, TIMESHEET_APP); |
|
847 | 847 | |
848 | 848 | return true; |
849 | 849 | } |
@@ -856,16 +856,16 @@ discard block |
||
856 | 856 | * @param int $pm_id ID of selected project |
857 | 857 | * @return array containing link_id and ts_id |
858 | 858 | */ |
859 | - function get_ts_links($pm_id=0) |
|
859 | + function get_ts_links($pm_id = 0) |
|
860 | 860 | { |
861 | - if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
861 | + if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
862 | 862 | { |
863 | - $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id); |
|
863 | + $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id); |
|
864 | 864 | $pm_ids[] = $pm_id; |
865 | - $links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
865 | + $links = Link\Storage::get_links('projectmanager', $pm_ids, 'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
866 | 866 | if ($links) |
867 | 867 | { |
868 | - $links = array_unique(call_user_func_array('array_merge',$links)); |
|
868 | + $links = array_unique(call_user_func_array('array_merge', $links)); |
|
869 | 869 | } |
870 | 870 | return $links; |
871 | 871 | } |
@@ -883,17 +883,17 @@ discard block |
||
883 | 883 | function notify($data) |
884 | 884 | { |
885 | 885 | //error_log(__METHOD__.'('.array2string($data).')'); |
886 | - $backup =& $this->data; // backup internal data in case class got re-used by ExecMethod |
|
886 | + $backup = & $this->data; // backup internal data in case class got re-used by ExecMethod |
|
887 | 887 | unset($this->data); |
888 | 888 | |
889 | 889 | if ($data['target_app'] == 'projectmanager' && $this->read($data['id'])) |
890 | 890 | { |
891 | 891 | $old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null; |
892 | - switch($data['type']) |
|
892 | + switch ($data['type']) |
|
893 | 893 | { |
894 | 894 | case 'link': |
895 | 895 | case 'update': |
896 | - if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
896 | + if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
897 | 897 | isset($old_title) && $this->data['ts_project'] === $old_title) |
898 | 898 | { |
899 | 899 | $pm_id = $data['target_id']; |
@@ -935,17 +935,17 @@ discard block |
||
935 | 935 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
936 | 936 | * @return array |
937 | 937 | */ |
938 | - function db2data($data=null) |
|
938 | + function db2data($data = null) |
|
939 | 939 | { |
940 | 940 | if (($intern = !is_array($data))) |
941 | 941 | { |
942 | - $data =& $this->data; |
|
942 | + $data = & $this->data; |
|
943 | 943 | } |
944 | 944 | // get pm_id from links and ts_project: either project matching ts_project or first found project |
945 | 945 | if (!isset($data['pm_id']) && $data['ts_id']) |
946 | 946 | { |
947 | 947 | $first_pm_id = null; |
948 | - foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
948 | + foreach (Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
949 | 949 | { |
950 | 950 | if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
951 | 951 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | $data['ts_project_blur'] = $data['ts_project']; |
964 | 964 | $data['ts_project'] = ''; |
965 | 965 | } |
966 | - return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
966 | + return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
976 | 976 | * @return array |
977 | 977 | */ |
978 | - function data2db($data=null) |
|
978 | + function data2db($data = null) |
|
979 | 979 | { |
980 | 980 | if (($intern = !is_array($data))) |
981 | 981 | { |
982 | - $data =& $this->data; |
|
982 | + $data = & $this->data; |
|
983 | 983 | } |
984 | 984 | // allways store ts_project to be able to search for it, even if no custom project is set |
985 | 985 | if (empty($data['ts_project']) && !is_null($data['ts_project'])) |
986 | 986 | { |
987 | 987 | $data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : ''; |
988 | 988 | } |
989 | - return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
989 | + return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
990 | 990 | } |
991 | 991 | } |
@@ -167,12 +167,18 @@ discard block |
||
167 | 167 | { |
168 | 168 | parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id'); |
169 | 169 | |
170 | - if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
|
170 | + if ($this->customfields) |
|
171 | + { |
|
172 | + $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value'; |
|
173 | + } |
|
171 | 174 | $this->config_data = Api\Config::read(TIMESHEET_APP); |
172 | 175 | $this->quantity_sum = $this->config_data['quantity_sum'] == 'true'; |
173 | 176 | |
174 | 177 | // Load & process statuses |
175 | - if($this->config_data['status_labels']) $this->load_statuses(); |
|
178 | + if($this->config_data['status_labels']) |
|
179 | + { |
|
180 | + $this->load_statuses(); |
|
181 | + } |
|
176 | 182 | |
177 | 183 | $this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now)); |
178 | 184 | |
@@ -190,12 +196,16 @@ discard block |
||
190 | 196 | protected function load_statuses() |
191 | 197 | { |
192 | 198 | $this->status_labels =& $this->config_data['status_labels']; |
193 | - if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels); |
|
199 | + if (!is_array($this->status_labels)) |
|
200 | + { |
|
201 | + $this->status_labels= array($this->status_labels); |
|
202 | + } |
|
194 | 203 | |
195 | 204 | foreach ($this->status_labels as $status_id => $label) |
196 | 205 | { |
197 | 206 | if (!is_array($label)) |
198 | - { //old values, before parent status |
|
207 | + { |
|
208 | +//old values, before parent status |
|
199 | 209 | $name = $label; |
200 | 210 | $label=array(); |
201 | 211 | $label['name'] = $name; |
@@ -243,7 +253,10 @@ discard block |
||
243 | 253 | */ |
244 | 254 | function get_sub_status($status) |
245 | 255 | { |
246 | - if (!isset($this->status_labels_config)) $this->load_statuses(); |
|
256 | + if (!isset($this->status_labels_config)) |
|
257 | + { |
|
258 | + $this->load_statuses(); |
|
259 | + } |
|
247 | 260 | $stati = array($status); |
248 | 261 | foreach($this->status_labels_config as $stat) |
249 | 262 | { |
@@ -319,9 +332,16 @@ discard block |
||
319 | 332 | $data = $this->read($data,true); |
320 | 333 | $this->data = $save_data; |
321 | 334 | |
322 | - if (!$data) return null; // entry not found |
|
335 | + if (!$data) |
|
336 | + { |
|
337 | + return null; |
|
338 | + } |
|
339 | + // entry not found |
|
340 | + } |
|
341 | + if (!$user) |
|
342 | + { |
|
343 | + $user = $this->user; |
|
323 | 344 | } |
324 | - if (!$user) $user = $this->user; |
|
325 | 345 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
326 | 346 | { |
327 | 347 | if ($this->status_labels_config[$data['ts_status']]['admin']) |
@@ -354,9 +374,16 @@ discard block |
||
354 | 374 | $data = $this->read($data,true); |
355 | 375 | $this->data = $save_data; |
356 | 376 | |
357 | - if (!$data) return null; // entry not found |
|
377 | + if (!$data) |
|
378 | + { |
|
379 | + return null; |
|
380 | + } |
|
381 | + // entry not found |
|
382 | + } |
|
383 | + if (!$user) |
|
384 | + { |
|
385 | + $user = $this->user; |
|
358 | 386 | } |
359 | - if (!$user) $user = $this->user; |
|
360 | 387 | if ($user == $this->user) |
361 | 388 | { |
362 | 389 | $grants = $this->grants; |
@@ -430,7 +457,10 @@ discard block |
||
430 | 457 | } |
431 | 458 | else |
432 | 459 | { |
433 | - if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
|
460 | + if (!is_array($filter['ts_owner'])) |
|
461 | + { |
|
462 | + $filter['ts_owner'] = array($filter['ts_owner']); |
|
463 | + } |
|
434 | 464 | |
435 | 465 | foreach($filter['ts_owner'] as $key => $owner) |
436 | 466 | { |
@@ -485,7 +515,10 @@ discard block |
||
485 | 515 | $this->summary = $this->summary[0]; |
486 | 516 | $this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']); |
487 | 517 | |
488 | - if ($only_summary) return $this->summary; |
|
518 | + if ($only_summary) |
|
519 | + { |
|
520 | + return $this->summary; |
|
521 | + } |
|
489 | 522 | |
490 | 523 | if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
491 | 524 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
@@ -561,7 +594,10 @@ discard block |
||
561 | 594 | */ |
562 | 595 | function save($keys=null,$touch_modified=true,$ignore_acl=false) |
563 | 596 | { |
564 | - if ($keys) $this->data_merge($keys); |
|
597 | + if ($keys) |
|
598 | + { |
|
599 | + $this->data_merge($keys); |
|
600 | + } |
|
565 | 601 | |
566 | 602 | if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT)) |
567 | 603 | { |
@@ -583,10 +619,13 @@ discard block |
||
583 | 619 | $old =& $this->data; |
584 | 620 | $this->data =& $new; |
585 | 621 | $changed = array(); |
586 | - if (isset($old)) foreach($old as $name => $value) |
|
622 | + if (isset($old)) |
|
623 | + { |
|
624 | + foreach($old as $name => $value) |
|
587 | 625 | { |
588 | 626 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
589 | 627 | } |
628 | + } |
|
590 | 629 | } |
591 | 630 | if (isset($old) && !$changed) |
592 | 631 | { |
@@ -703,7 +742,10 @@ discard block |
||
703 | 742 | } |
704 | 743 | |
705 | 744 | $this->data['ts_status'] = $status; |
706 | - if ($this->save($ts_id)!=0) $ret = false; |
|
745 | + if ($this->save($ts_id)!=0) |
|
746 | + { |
|
747 | + $ret = false; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | return $ret; |
709 | 751 | } |
@@ -747,10 +789,13 @@ discard block |
||
747 | 789 | return $entry; |
748 | 790 | } |
749 | 791 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
750 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
792 | + if (date('H:i',$entry['ts_start']) != '00:00') |
|
793 | + { |
|
794 | + // dont show 00:00 time, as it means date only |
|
751 | 795 | { |
752 | 796 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
753 | 797 | } |
798 | + } |
|
754 | 799 | return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
755 | 800 | } |
756 | 801 | |
@@ -796,14 +841,18 @@ discard block |
||
796 | 841 | { |
797 | 842 | $limit = false; |
798 | 843 | $need_count = false; |
799 | - if($options['start'] || $options['num_rows']) { |
|
844 | + if($options['start'] || $options['num_rows']) |
|
845 | + { |
|
800 | 846 | $limit = array($options['start'], $options['num_rows']); |
801 | 847 | $need_count = true; |
802 | 848 | } |
803 | 849 | $result = array(); |
804 | 850 | foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
805 | 851 | { |
806 | - if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
|
852 | + if ($ts) |
|
853 | + { |
|
854 | + $result[$ts['ts_id']] = $this->link_title($ts); |
|
855 | + } |
|
807 | 856 | } |
808 | 857 | $options['total'] = $need_count ? $this->total : count($result); |
809 | 858 | return $result; |
@@ -922,7 +971,10 @@ discard block |
||
922 | 971 | //error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update)); |
923 | 972 | } |
924 | 973 | } |
925 | - if ($backup) $this->data = $backup; |
|
974 | + if ($backup) |
|
975 | + { |
|
976 | + $this->data = $backup; |
|
977 | + } |
|
926 | 978 | } |
927 | 979 | |
928 | 980 | |
@@ -947,7 +999,10 @@ discard block |
||
947 | 999 | $first_pm_id = null; |
948 | 1000 | foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
949 | 1001 | { |
950 | - if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
|
1002 | + if (!isset($first_pm_id)) |
|
1003 | + { |
|
1004 | + $first_pm_id = $pm_id; |
|
1005 | + } |
|
951 | 1006 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
952 | 1007 | { |
953 | 1008 | $data['pm_id'] = $pm_id; |
@@ -956,7 +1011,10 @@ discard block |
||
956 | 1011 | break; |
957 | 1012 | } |
958 | 1013 | } |
959 | - if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id; |
|
1014 | + if (!isset($data['pm_id']) && isset($first_pm_id)) |
|
1015 | + { |
|
1016 | + $data['pm_id'] = $first_pm_id; |
|
1017 | + } |
|
960 | 1018 | } |
961 | 1019 | elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project']) |
962 | 1020 | { |
@@ -572,7 +572,7 @@ |
||
572 | 572 | * @param array $options Array of options for the search |
573 | 573 | * |
574 | 574 | */ |
575 | - function link_query( $pattern, Array &$options = array() ) |
|
575 | + function link_query( $pattern, array &$options = array() ) |
|
576 | 576 | { |
577 | 577 | if (is_array($pattern)) |
578 | 578 | { |
@@ -83,7 +83,7 @@ |
||
83 | 83 | * @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id |
84 | 84 | * @param int $target target project id |
85 | 85 | * @param array $extra =null data of target-project, atm not used by the infolog datasource |
86 | - * @return array|boolean array(info_id,link_id) on success, false otherwise |
|
86 | + * @return boolean array(info_id,link_id) on success, false otherwise |
|
87 | 87 | */ |
88 | 88 | function copy($element,$target,$extra=null) |
89 | 89 | { |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | } |
44 | 44 | if (!is_array($data_id)) |
45 | 45 | { |
46 | - if (!(int) $data_id || !($data = $GLOBALS['timesheet_bo']->read((int) $data_id))) |
|
46 | + if (!(int)$data_id || !($data = $GLOBALS['timesheet_bo']->read((int)$data_id))) |
|
47 | 47 | { |
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | else |
52 | 52 | { |
53 | - $data =& $data_id; |
|
53 | + $data = & $data_id; |
|
54 | 54 | } |
55 | 55 | $ds = array( |
56 | 56 | 'pe_title' => $GLOBALS['timesheet_bo']->link_title($data), |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | if ($data['ts_duration']) |
68 | 68 | { |
69 | - $ds['pe_real_end'] = $data['ts_start'] + 60*$data['ts_duration']; |
|
69 | + $ds['pe_real_end'] = $data['ts_start'] + 60 * $data['ts_duration']; |
|
70 | 70 | $ds['pe_used_time'] = $data['ts_duration']; |
71 | 71 | } |
72 | 72 | if ($this->debug) |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param array $extra =null data of target-project, atm not used by the infolog datasource |
86 | 86 | * @return array|boolean array(info_id,link_id) on success, false otherwise |
87 | 87 | */ |
88 | - function copy($element,$target,$extra=null) |
|
88 | + function copy($element, $target, $extra = null) |
|
89 | 89 | { |
90 | - unset($element,$target,$extra); // not used, but required by function signature |
|
90 | + unset($element, $target, $extra); // not used, but required by function signature |
|
91 | 91 | |
92 | 92 | return false; |
93 | 93 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Exports records as defined in $_definition |
27 | 27 | * |
28 | - * @param egw_record $_definition |
|
28 | + * @param importexport_definition $_definition |
|
29 | 29 | */ |
30 | 30 | public function export( $_stream, importexport_definition $_definition) { |
31 | 31 | $options = $_definition->plugin_options; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * return html for options. |
133 | 133 | * this way the plugin has all opportunities for options tab |
134 | 134 | * |
135 | - * @return string html |
|
135 | + * @return boolean html |
|
136 | 136 | */ |
137 | 137 | public function get_options_etpl() { |
138 | 138 | return false; |
@@ -125,8 +125,8 @@ |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | public static function get_mimetype() { |
128 | - return 'text/csv'; |
|
129 | - } |
|
128 | + return 'text/csv'; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * return html for options. |
@@ -27,51 +27,51 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param egw_record $_definition |
29 | 29 | */ |
30 | - public function export( $_stream, importexport_definition $_definition) { |
|
30 | + public function export($_stream, importexport_definition $_definition) { |
|
31 | 31 | $options = $_definition->plugin_options; |
32 | 32 | |
33 | 33 | $this->ui = new timesheet_ui(); |
34 | 34 | $selection = array(); |
35 | 35 | |
36 | - if($options['selection'] == 'search') { |
|
37 | - $query = $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP); |
|
38 | - $query['num_rows'] = -1; // all records |
|
39 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
40 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
41 | - } elseif($options['selection'] == 'all') { |
|
36 | + if ($options['selection'] == 'search') { |
|
37 | + $query = $GLOBALS['egw']->session->appsession('index', TIMESHEET_APP); |
|
38 | + $query['num_rows'] = -1; // all records |
|
39 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
40 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
41 | + } elseif ($options['selection'] == 'all') { |
|
42 | 42 | $query = array( |
43 | 43 | 'num_rows' => -1, |
44 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
44 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
45 | 45 | ); |
46 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
46 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
47 | 47 | } |
48 | - else if($options['selection'] == 'filter') |
|
48 | + else if ($options['selection'] == 'filter') |
|
49 | 49 | { |
50 | 50 | $fields = importexport_helper_functions::get_filter_fields($_definition->application, $this); |
51 | 51 | $filter = $_definition->filter; |
52 | 52 | $query = array( |
53 | 53 | 'num_rows' => -1, |
54 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
54 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
55 | 55 | 'col_filter' => array() |
56 | 56 | ); |
57 | 57 | |
58 | 58 | // Handle ranges |
59 | - foreach($filter as $field => $value) |
|
59 | + foreach ($filter as $field => $value) |
|
60 | 60 | { |
61 | - if($field == 'cat_id') |
|
61 | + if ($field == 'cat_id') |
|
62 | 62 | { |
63 | 63 | $query['cat_id'] = $value; |
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | $query['col_filter'][$field] = $value; |
67 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
67 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
68 | 68 | |
69 | 69 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
70 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
71 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
70 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
71 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
72 | 72 | unset($query['col_filter'][$field]); |
73 | 73 | } |
74 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
74 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | // support other selectors atm. |
84 | 84 | foreach ($selection as $identifier) { |
85 | 85 | $record = new timesheet_egw_record($identifier); |
86 | - if($options['convert']) { |
|
86 | + if ($options['convert']) { |
|
87 | 87 | importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects); |
88 | 88 | } else { |
89 | 89 | // Implode arrays, so they don't say 'Array' |
90 | - foreach($record->get_record_array() as $key => $value) { |
|
91 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
90 | + foreach ($record->get_record_array() as $key => $value) { |
|
91 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | $export_object->export_record($record); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | public function get_selects() |
152 | 152 | { |
153 | 153 | $this->selects = array( |
154 | - 'ts_status' => $this->ui->status_labels+array(lang('No status')) |
|
154 | + 'ts_status' => $this->ui->status_labels + array(lang('No status')) |
|
155 | 155 | ); |
156 | - foreach($this->selects['ts_status'] as &$status) { |
|
157 | - $status = str_replace(' ','',$status); // Remove |
|
156 | + foreach ($this->selects['ts_status'] as &$status) { |
|
157 | + $status = str_replace(' ', '', $status); // Remove |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function get_filter_fields(Array &$filters) |
165 | 165 | { |
166 | - foreach($filters as $field_name => &$settings) |
|
166 | + foreach ($filters as $field_name => &$settings) |
|
167 | 167 | { |
168 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
168 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * export plugin of addressbook |
16 | 16 | */ |
17 | -class timesheet_export_csv implements importexport_iface_export_plugin { |
|
17 | +class timesheet_export_csv implements importexport_iface_export_plugin |
|
18 | +{ |
|
18 | 19 | |
19 | 20 | public function __construct() |
20 | 21 | { |
@@ -27,18 +28,22 @@ discard block |
||
27 | 28 | * |
28 | 29 | * @param egw_record $_definition |
29 | 30 | */ |
30 | - public function export( $_stream, importexport_definition $_definition) { |
|
31 | + public function export( $_stream, importexport_definition $_definition) |
|
32 | + { |
|
31 | 33 | $options = $_definition->plugin_options; |
32 | 34 | |
33 | 35 | $this->ui = new timesheet_ui(); |
34 | 36 | $selection = array(); |
35 | 37 | |
36 | - if($options['selection'] == 'search') { |
|
38 | + if($options['selection'] == 'search') |
|
39 | + { |
|
37 | 40 | $query = $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP); |
38 | 41 | $query['num_rows'] = -1; // all records |
39 | 42 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
40 | 43 | $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
41 | - } elseif($options['selection'] == 'all') { |
|
44 | + } |
|
45 | + elseif($options['selection'] == 'all') |
|
46 | + { |
|
42 | 47 | $query = array( |
43 | 48 | 'num_rows' => -1, |
44 | 49 | 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
@@ -64,11 +69,20 @@ discard block |
||
64 | 69 | continue; |
65 | 70 | } |
66 | 71 | $query['col_filter'][$field] = $value; |
67 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
72 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
73 | + { |
|
74 | + continue; |
|
75 | + } |
|
68 | 76 | |
69 | 77 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
70 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
71 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
78 | + if($value['from']) |
|
79 | + { |
|
80 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
81 | + } |
|
82 | + if($value['to']) |
|
83 | + { |
|
84 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
85 | + } |
|
72 | 86 | unset($query['col_filter'][$field]); |
73 | 87 | } |
74 | 88 | $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
@@ -81,14 +95,22 @@ discard block |
||
81 | 95 | |
82 | 96 | // $options['selection'] is array of identifiers as this plugin doesn't |
83 | 97 | // support other selectors atm. |
84 | - foreach ($selection as $identifier) { |
|
98 | + foreach ($selection as $identifier) |
|
99 | + { |
|
85 | 100 | $record = new timesheet_egw_record($identifier); |
86 | - if($options['convert']) { |
|
101 | + if($options['convert']) |
|
102 | + { |
|
87 | 103 | importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects); |
88 | - } else { |
|
104 | + } |
|
105 | + else |
|
106 | + { |
|
89 | 107 | // Implode arrays, so they don't say 'Array' |
90 | - foreach($record->get_record_array() as $key => $value) { |
|
91 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
108 | + foreach($record->get_record_array() as $key => $value) |
|
109 | + { |
|
110 | + if(is_array($value)) |
|
111 | + { |
|
112 | + $record->$key = implode(',', $value); |
|
113 | + } |
|
92 | 114 | } |
93 | 115 | } |
94 | 116 | $export_object->export_record($record); |
@@ -102,7 +124,8 @@ discard block |
||
102 | 124 | * |
103 | 125 | * @return string name |
104 | 126 | */ |
105 | - public static function get_name() { |
|
127 | + public static function get_name() |
|
128 | + { |
|
106 | 129 | return lang('Timesheet CSV export'); |
107 | 130 | } |
108 | 131 | |
@@ -111,7 +134,8 @@ discard block |
||
111 | 134 | * |
112 | 135 | * @return string descriprion |
113 | 136 | */ |
114 | - public static function get_description() { |
|
137 | + public static function get_description() |
|
138 | + { |
|
115 | 139 | return lang("Exports entries from your Timesheet into a CSV File. "); |
116 | 140 | } |
117 | 141 | |
@@ -120,11 +144,13 @@ discard block |
||
120 | 144 | * |
121 | 145 | * @return string suffix |
122 | 146 | */ |
123 | - public static function get_filesuffix() { |
|
147 | + public static function get_filesuffix() |
|
148 | + { |
|
124 | 149 | return 'csv'; |
125 | 150 | } |
126 | 151 | |
127 | - public static function get_mimetype() { |
|
152 | + public static function get_mimetype() |
|
153 | + { |
|
128 | 154 | return 'text/csv'; |
129 | 155 | } |
130 | 156 | |
@@ -134,7 +160,8 @@ discard block |
||
134 | 160 | * |
135 | 161 | * @return string html |
136 | 162 | */ |
137 | - public function get_options_etpl() { |
|
163 | + public function get_options_etpl() |
|
164 | + { |
|
138 | 165 | return false; |
139 | 166 | } |
140 | 167 | |
@@ -142,7 +169,8 @@ discard block |
||
142 | 169 | * returns slectors of this plugin via xajax |
143 | 170 | * |
144 | 171 | */ |
145 | - public function get_selectors_etpl() { |
|
172 | + public function get_selectors_etpl() |
|
173 | + { |
|
146 | 174 | return array( |
147 | 175 | 'name' => 'importexport.export_csv_selectors', |
148 | 176 | ); |
@@ -153,7 +181,8 @@ discard block |
||
153 | 181 | $this->selects = array( |
154 | 182 | 'ts_status' => $this->ui->status_labels+array(lang('No status')) |
155 | 183 | ); |
156 | - foreach($this->selects['ts_status'] as &$status) { |
|
184 | + foreach($this->selects['ts_status'] as &$status) |
|
185 | + { |
|
157 | 186 | $status = str_replace(' ','',$status); // Remove |
158 | 187 | } |
159 | 188 | |
@@ -165,7 +194,10 @@ discard block |
||
165 | 194 | { |
166 | 195 | foreach($filters as $field_name => &$settings) |
167 | 196 | { |
168 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
197 | + if($this->selects[$field_name]) |
|
198 | + { |
|
199 | + $settings['values'] = $this->selects[$field_name]; |
|
200 | + } |
|
169 | 201 | } |
170 | 202 | } |
171 | 203 |
@@ -247,7 +247,7 @@ |
||
247 | 247 | $this->selects['info_status'] = $this->bo->get_status(); |
248 | 248 | } |
249 | 249 | |
250 | - public function get_filter_fields(Array &$filters) |
|
250 | + public function get_filter_fields(array &$filters) |
|
251 | 251 | { |
252 | 252 | foreach($filters as $field_name => &$settings) |
253 | 253 | { |
@@ -86,8 +86,6 @@ |
||
86 | 86 | * Here we need to handle any incoming data. Setup is done in the constructor, |
87 | 87 | * output is handled by parent. |
88 | 88 | * |
89 | - * @param type $id |
|
90 | - * @param Etemplate $etemplate |
|
91 | 89 | */ |
92 | 90 | public static function process($content = array()) |
93 | 91 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $context['appname'] = 'timesheet'; |
29 | 29 | |
30 | 30 | // Let parent handle the basic stuff |
31 | - parent::__construct($context,$need_reload); |
|
31 | + parent::__construct($context, $need_reload); |
|
32 | 32 | |
33 | 33 | $this->context['template'] = 'timesheet.index.rows'; |
34 | 34 | $this->nm_settings += array( |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
45 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
45 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
46 | 46 | { |
47 | 47 | $ui = new timesheet_ui(); |
48 | 48 | |
49 | 49 | $date_filters = array('All'); |
50 | - foreach(array_keys($ui->date_filters) as $name) |
|
50 | + foreach (array_keys($ui->date_filters) as $name) |
|
51 | 51 | { |
52 | 52 | $date_filters[$name] = $name; |
53 | 53 | } |
54 | 54 | $date_filters['custom'] = 'custom'; |
55 | 55 | $this->context['sel_options']['filter'] = $date_filters; |
56 | - $this->context['sel_options']['filter2'] = array('No details','Details'); |
|
56 | + $this->context['sel_options']['filter2'] = array('No details', 'Details'); |
|
57 | 57 | $read_grants = $ui->grant_list(Acl::READ); |
58 | 58 | $this->context['sel_options'] += array( |
59 | 59 | 'ts_owner' => $read_grants, |
60 | 60 | 'pm_id' => array(lang('No project')), |
61 | 61 | 'cat_id' => array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))), |
62 | - 'ts_status' => $ui->status_labels+array(lang('No status')), |
|
62 | + 'ts_status' => $ui->status_labels + array(lang('No status')), |
|
63 | 63 | ); |
64 | 64 | $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings); |
65 | 65 | |
@@ -112,29 +112,29 @@ discard block |
||
112 | 112 | if (!count($content['nm']['selected']) && !$content['nm']['select_all']) |
113 | 113 | { |
114 | 114 | $msg = lang('You need to select some entries first!'); |
115 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
115 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
116 | 116 | } |
117 | 117 | else |
118 | 118 | { |
119 | 119 | $success = $failed = $action_msg = null; |
120 | - if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
121 | - $success,$failed,$action_msg,'index',$msg)) |
|
120 | + if ($ui->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
121 | + $success, $failed, $action_msg, 'index', $msg)) |
|
122 | 122 | { |
123 | - $msg .= lang('%1 timesheets(s) %2',$success,$action_msg); |
|
123 | + $msg .= lang('%1 timesheets(s) %2', $success, $action_msg); |
|
124 | 124 | |
125 | - Api\Json\Response::get()->apply('egw.message',array($msg,'success')); |
|
126 | - foreach($content['nm']['selected'] as &$id) |
|
125 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'success')); |
|
126 | + foreach ($content['nm']['selected'] as &$id) |
|
127 | 127 | { |
128 | 128 | $id = 'timesheet::'.$id; |
129 | 129 | } |
130 | 130 | // Directly request an update - this will get timesheet tab too |
131 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); |
|
131 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected'])); |
|
132 | 132 | } |
133 | - elseif(empty($msg)) |
|
133 | + elseif (empty($msg)) |
|
134 | 134 | { |
135 | - $msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
135 | + $msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
136 | 136 | } |
137 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
137 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | } |
@@ -76,9 +76,12 @@ |
||
76 | 76 | |
77 | 77 | // This is just copy+pasted from resources_ui line 816, but we don't want |
78 | 78 | // the etemplate exec to fire again. |
79 | - if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
79 | + if (is_array($content) && isset($content['nm']['rows']['document'])) |
|
80 | + { |
|
81 | + // handle insert in default document button like an action |
|
80 | 82 | { |
81 | 83 | list($id) = @each($content['nm']['rows']['document']); |
84 | + } |
|
82 | 85 | $content['nm']['action'] = 'document'; |
83 | 86 | $content['nm']['selected'] = array($id); |
84 | 87 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) |
51 | 51 | */ |
52 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
52 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
53 | 53 | { |
54 | 54 | if (false) parent::__construct(); |
55 | 55 |
@@ -104,8 +104,7 @@ |
||
104 | 104 | /** |
105 | 105 | * imports entries according to given definition object. |
106 | 106 | * @param resource $_stream |
107 | - * @param string $_charset |
|
108 | - * @param definition $_definition |
|
107 | + * @param importexport_definition $_definition |
|
109 | 108 | */ |
110 | 109 | public function import( $_stream, importexport_definition $_definition ) { |
111 | 110 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | private $bo; |
73 | 73 | |
74 | 74 | /** |
75 | - * For figuring out if a record has changed |
|
76 | - */ |
|
75 | + * For figuring out if a record has changed |
|
76 | + */ |
|
77 | 77 | protected $tracking; |
78 | 78 | |
79 | 79 | /** |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | protected $errors = array(); |
98 | 98 | |
99 | 99 | /** |
100 | - * List of actions, and how many times that action was taken |
|
101 | - */ |
|
102 | - protected $results = array(); |
|
100 | + * List of actions, and how many times that action was taken |
|
101 | + */ |
|
102 | + protected $results = array(); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * imports entries according to given definition object. |
@@ -458,40 +458,40 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
461 | - * Returns warnings that were encountered during importing |
|
462 | - * Maximum of one warning message per record, but you can append if you need to |
|
463 | - * |
|
464 | - * @return Array ( |
|
465 | - * record_# => warning message |
|
466 | - * ) |
|
467 | - */ |
|
468 | - public function get_warnings() { |
|
461 | + * Returns warnings that were encountered during importing |
|
462 | + * Maximum of one warning message per record, but you can append if you need to |
|
463 | + * |
|
464 | + * @return Array ( |
|
465 | + * record_# => warning message |
|
466 | + * ) |
|
467 | + */ |
|
468 | + public function get_warnings() { |
|
469 | 469 | return $this->warnings; |
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
473 | - * Returns errors that were encountered during importing |
|
474 | - * Maximum of one error message per record, but you can append if you need to |
|
475 | - * |
|
476 | - * @return Array ( |
|
477 | - * record_# => error message |
|
478 | - * ) |
|
479 | - */ |
|
480 | - public function get_errors() { |
|
473 | + * Returns errors that were encountered during importing |
|
474 | + * Maximum of one error message per record, but you can append if you need to |
|
475 | + * |
|
476 | + * @return Array ( |
|
477 | + * record_# => error message |
|
478 | + * ) |
|
479 | + */ |
|
480 | + public function get_errors() { |
|
481 | 481 | return $this->errors; |
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
485 | - * Returns a list of actions taken, and the number of records for that action. |
|
486 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
487 | - * |
|
488 | - * @return Array ( |
|
489 | - * action => record count |
|
490 | - * ) |
|
491 | - */ |
|
492 | - public function get_results() { |
|
493 | - return $this->results; |
|
494 | - } |
|
485 | + * Returns a list of actions taken, and the number of records for that action. |
|
486 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
487 | + * |
|
488 | + * @return Array ( |
|
489 | + * action => record count |
|
490 | + * ) |
|
491 | + */ |
|
492 | + public function get_results() { |
|
493 | + return $this->results; |
|
494 | + } |
|
495 | 495 | // end of iface_export_plugin |
496 | 496 | |
497 | 497 | // Extra conversion functions - must be static |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | class timesheet_import_csv implements importexport_iface_import_plugin |
21 | 21 | { |
22 | 22 | private static $plugin_options = array( |
23 | - 'fieldsep', // char |
|
24 | - 'charset', // string |
|
25 | - 'update_cats', // string {override|add} overides record |
|
23 | + 'fieldsep', // char |
|
24 | + 'charset', // string |
|
25 | + 'update_cats', // string {override|add} overides record |
|
26 | 26 | // with cat(s) from csv OR add the cat from |
27 | 27 | // csv file to exeisting cat(s) of record |
28 | 28 | 'num_header_lines', // int number of header lines |
29 | 29 | 'field_conversion', // array( $csv_col_num => conversion) |
30 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
31 | - 'conditions', /* => array containing condition arrays: |
|
30 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
31 | + 'conditions', /* => array containing condition arrays: |
|
32 | 32 | 'type' => exists, // exists |
33 | 33 | 'string' => '#kundennummer', |
34 | 34 | 'true' => array( |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * actions wich could be done to data entries |
54 | 54 | */ |
55 | - protected static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
55 | + protected static $actions = array('none', 'update', 'insert', 'delete',); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * conditions for actions |
59 | 59 | * |
60 | 60 | * @var array |
61 | 61 | */ |
62 | - protected static $conditions = array( 'exists' ); |
|
62 | + protected static $conditions = array('exists'); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var definition |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @param string $_charset |
108 | 108 | * @param definition $_definition |
109 | 109 | */ |
110 | - public function import( $_stream, importexport_definition $_definition ) { |
|
111 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
110 | + public function import($_stream, importexport_definition $_definition) { |
|
111 | + $import_csv = new importexport_import_csv($_stream, array( |
|
112 | 112 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
113 | 113 | 'charset' => $_definition->plugin_options['charset'], |
114 | 114 | )); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
119 | 119 | |
120 | 120 | // dry run? |
121 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
121 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
122 | 122 | |
123 | 123 | // fetch the bo |
124 | 124 | $this->bo = new timesheet_bo(); |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $import_csv->conversion_class = $this; |
137 | 137 | |
138 | 138 | //check if file has a header lines |
139 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
139 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
140 | 140 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
141 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
141 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
142 | 142 | // First method is preferred |
143 | 143 | $import_csv->skip_records(1); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // set Owner |
147 | - $_definition->plugin_options['record_owner'] = isset( $_definition->plugin_options['record_owner'] ) ? |
|
147 | + $_definition->plugin_options['record_owner'] = isset($_definition->plugin_options['record_owner']) ? |
|
148 | 148 | $_definition->plugin_options['record_owner'] : $this->user; |
149 | 149 | |
150 | 150 | // Used to try to automatically match names to account IDs |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | ); |
159 | 159 | |
160 | 160 | // Status need leading spaces removed |
161 | - foreach($lookups['ts_status'] as $id => &$label) { |
|
162 | - $label = str_replace(' ', '',trim($label)); |
|
163 | - if($label == '') unset($lookups['ts_status'][$id]); |
|
161 | + foreach ($lookups['ts_status'] as $id => &$label) { |
|
162 | + $label = str_replace(' ', '', trim($label)); |
|
163 | + if ($label == '') unset($lookups['ts_status'][$id]); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | // Start counting successes |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | // Failures |
171 | 171 | $this->errors = array(); |
172 | 172 | |
173 | - while ( $record = $import_csv->get_record() ) { |
|
173 | + while ($record = $import_csv->get_record()) { |
|
174 | 174 | $success = false; |
175 | 175 | |
176 | 176 | // don't import empty records |
177 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
177 | + if (count(array_unique($record)) < 2) continue; |
|
178 | 178 | |
179 | 179 | $result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']); |
180 | - if($result) $this->warnings[$import_csv->get_current_position()] = $result; |
|
180 | + if ($result) $this->warnings[$import_csv->get_current_position()] = $result; |
|
181 | 181 | |
182 | 182 | // Automatically handle text Api\Categories without explicit Api\Translation |
183 | - foreach(array('ts_status','cat_id') as $field) { |
|
184 | - if(!is_numeric($record[$field])) { |
|
185 | - $translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id'); |
|
186 | - if(($key = array_search($record[$field], $lookups[$field]))) { |
|
183 | + foreach (array('ts_status', 'cat_id') as $field) { |
|
184 | + if (!is_numeric($record[$field])) { |
|
185 | + $translate_key = 'translate'.(substr($field, 0, 2) == 'ts' ? substr($field, 2) : '_cat_id'); |
|
186 | + if (($key = array_search($record[$field], $lookups[$field]))) { |
|
187 | 187 | $record[$field] = $key; |
188 | - } elseif(array_key_exists($translate_key, $_definition->plugin_options)) { |
|
188 | + } elseif (array_key_exists($translate_key, $_definition->plugin_options)) { |
|
189 | 189 | $t_field = $_definition->plugin_options[$translate_key]; |
190 | 190 | switch ($t_field) { |
191 | 191 | case '': |
@@ -196,29 +196,29 @@ discard block |
||
196 | 196 | case '~skip~': |
197 | 197 | continue 2; |
198 | 198 | default: |
199 | - if(strpos($t_field, 'add') === 0) { |
|
199 | + if (strpos($t_field, 'add') === 0) { |
|
200 | 200 | // Check for a parent |
201 | - list($name, $parent_name) = explode('~',$t_field); |
|
202 | - if($parent_name) { |
|
201 | + list($name, $parent_name) = explode('~', $t_field); |
|
202 | + if ($parent_name) { |
|
203 | 203 | $parent = importexport_helper_functions::cat_name2id($parent_name); |
204 | 204 | } |
205 | 205 | |
206 | - if($field == 'cat_id') { |
|
206 | + if ($field == 'cat_id') { |
|
207 | 207 | $record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent); |
208 | 208 | } elseif ($field == 'ts_status') { |
209 | 209 | end($this->bo->status_labels); |
210 | - $id = key($this->bo->status_labels)+1; |
|
210 | + $id = key($this->bo->status_labels) + 1; |
|
211 | 211 | $this->bo->status_labels[$id] = $record[$field]; |
212 | 212 | $this->bo->status_labels_config[$id] = array( |
213 | 213 | 'name' => $record[$field], |
214 | 214 | 'parent' => $parent, |
215 | 215 | 'admin' => false |
216 | 216 | ); |
217 | - Api\Config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP); |
|
217 | + Api\Config::save_value('status_labels', $this->bo->status_labels_config, TIMESHEET_APP); |
|
218 | 218 | $lookups[$field][$id] = $name; |
219 | 219 | $record[$field] = $id; |
220 | 220 | } |
221 | - } elseif(($key = array_search($t_field, $lookups[$field]))) { |
|
221 | + } elseif (($key = array_search($t_field, $lookups[$field]))) { |
|
222 | 222 | $record[$field] = $key; |
223 | 223 | } else { |
224 | 224 | $record[$field] = $t_field; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | // Set creator, unless it's supposed to come from CSV file |
233 | - if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) { |
|
234 | - if(!is_numeric($record['ts_owner'])) { |
|
233 | + if ($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) { |
|
234 | + if (!is_numeric($record['ts_owner'])) { |
|
235 | 235 | // Automatically handle text owner without explicit Api\Translation |
236 | 236 | $new_owner = importexport_helper_functions::account_name2id($record['ts_owner']); |
237 | - if($new_owner == '') { |
|
237 | + if ($new_owner == '') { |
|
238 | 238 | $this->errors[$import_csv->get_current_position()] = lang( |
239 | 239 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for %3.', |
240 | 240 | $record['ts_owner'], |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | // Check account IDs |
254 | - foreach(array('ts_modifier') as $field) { |
|
255 | - if($record[$field] && !is_numeric($record[$field])) { |
|
254 | + foreach (array('ts_modifier') as $field) { |
|
255 | + if ($record[$field] && !is_numeric($record[$field])) { |
|
256 | 256 | // Try an automatic conversion |
257 | 257 | $account_id = importexport_helper_functions::account_name2id($record[$field]); |
258 | - if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field])) { |
|
258 | + if ($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field])) { |
|
259 | 259 | $record[$field] = $account_id; |
260 | 260 | } else { |
261 | 261 | $this->errors[$import_csv->get_current_position()] = lang( |
@@ -271,35 +271,35 @@ discard block |
||
271 | 271 | // Special values |
272 | 272 | if ($record['addressbook'] && !is_numeric($record['addressbook'])) |
273 | 273 | { |
274 | - list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']); |
|
275 | - $record['addressbook'] = self::addr_id($lastname,$firstname,$org_name); |
|
274 | + list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']); |
|
275 | + $record['addressbook'] = self::addr_id($lastname, $firstname, $org_name); |
|
276 | 276 | } |
277 | 277 | |
278 | - if ( $_definition->plugin_options['conditions'] ) { |
|
279 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
278 | + if ($_definition->plugin_options['conditions']) { |
|
279 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
280 | 280 | $results = array(); |
281 | - switch ( $condition['type'] ) { |
|
281 | + switch ($condition['type']) { |
|
282 | 282 | // exists |
283 | 283 | case 'exists' : |
284 | - if($record[$condition['string']]) { |
|
284 | + if ($record[$condition['string']]) { |
|
285 | 285 | $results = $this->bo->search(array($condition['string'] => $record[$condition['string']])); |
286 | 286 | } |
287 | 287 | |
288 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1 ) { |
|
288 | + if (is_array($results) && count(array_keys($results)) >= 1) { |
|
289 | 289 | // apply action to all records matching this exists condition |
290 | 290 | $action = $condition['true']; |
291 | - foreach ( (array)$results as $result ) { |
|
291 | + foreach ((array)$results as $result) { |
|
292 | 292 | $record['ts_id'] = $result['ts_id']; |
293 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
294 | - if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] ); |
|
295 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
296 | - $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) ); |
|
293 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
294 | + if (!is_array($result['cat_id'])) $result['cat_id'] = explode(',', $result['cat_id']); |
|
295 | + if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']); |
|
296 | + $record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $result['cat_id']))); |
|
297 | 297 | } |
298 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
298 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
299 | 299 | } |
300 | 300 | } else { |
301 | 301 | $action = $condition['false']; |
302 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
302 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
303 | 303 | } |
304 | 304 | break; |
305 | 305 | |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | } |
313 | 313 | } else { |
314 | 314 | // unconditional insert |
315 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
315 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
316 | 316 | } |
317 | - if($success) $count++; |
|
317 | + if ($success) $count++; |
|
318 | 318 | } |
319 | 319 | return $count; |
320 | 320 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param array $_data tracker data for the action |
327 | 327 | * @return bool success or not |
328 | 328 | */ |
329 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
329 | + private function action($_action, $_data, $record_num = 0) { |
|
330 | 330 | $result = true; |
331 | 331 | switch ($_action) { |
332 | 332 | case 'none' : |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $old_record = new timesheet_egw_record($_data['ts_id']); |
337 | 337 | $old = $old_record->get_record_array(); |
338 | 338 | |
339 | - if(!$this->definition->plugin_options['change_owner']) { |
|
339 | + if (!$this->definition->plugin_options['change_owner']) { |
|
340 | 340 | // Don't change creator of an existing ticket |
341 | 341 | unset($_data['ts_owner']); |
342 | 342 | } |
@@ -344,35 +344,35 @@ discard block |
||
344 | 344 | // Merge to deal with fields not in import record |
345 | 345 | $_data = array_merge($old, $_data); |
346 | 346 | $changed = $this->tracking->changed_fields($_data, $old); |
347 | - if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) { |
|
347 | + if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) { |
|
348 | 348 | break; |
349 | 349 | } |
350 | 350 | |
351 | 351 | // Clear old link, if different |
352 | 352 | if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) { |
353 | - Link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']); |
|
353 | + Link::unlink2(0, TIMESHEET_APP, $_data['ts_id'], 0, 'projectmanager', $old['pm_id']); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Fall through |
357 | 357 | case 'insert' : |
358 | - if ( $this->dry_run ) { |
|
358 | + if ($this->dry_run) { |
|
359 | 359 | //print_r($_data); |
360 | 360 | $this->results[$_action]++; |
361 | 361 | break; |
362 | 362 | } else { |
363 | - $result = $this->bo->save( $_data); |
|
363 | + $result = $this->bo->save($_data); |
|
364 | 364 | $_data['ts_id'] = $this->bo->data['ts_id']; |
365 | 365 | |
366 | 366 | // Set projectmanager link |
367 | 367 | if ($_data['pm_id']) { |
368 | - Link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']); |
|
368 | + Link::link(TIMESHEET_APP, $_data['ts_id'], 'projectmanager', $_data['pm_id']); |
|
369 | 369 | } |
370 | 370 | |
371 | - if($result) { |
|
371 | + if ($result) { |
|
372 | 372 | $this->errors[$record_num] = lang('Permissions error - %1 could not %2', |
373 | 373 | $GLOBALS['egw']->accounts->id2name($_data['owner']), |
374 | 374 | lang($_action) |
375 | - ) . ' ' . $result; |
|
375 | + ).' '.$result; |
|
376 | 376 | } else { |
377 | 377 | $this->results[$_action]++; |
378 | 378 | $result = $this->bo->data['ts_id']; |
@@ -384,22 +384,22 @@ discard block |
||
384 | 384 | } |
385 | 385 | |
386 | 386 | // Process some additional fields |
387 | - if(!is_numeric($result)) { |
|
387 | + if (!is_numeric($result)) { |
|
388 | 388 | return $result; |
389 | 389 | } |
390 | 390 | $_link_id = false; |
391 | - foreach(self::$special_fields as $field => $desc) { |
|
392 | - if(!$_data[$field]) continue; |
|
391 | + foreach (self::$special_fields as $field => $desc) { |
|
392 | + if (!$_data[$field]) continue; |
|
393 | 393 | |
394 | 394 | // Links |
395 | - if(strpos('link', $field) === 0) { |
|
395 | + if (strpos('link', $field) === 0) { |
|
396 | 396 | list($app, $id) = explode(':', $_data[$field]); |
397 | 397 | } else { |
398 | 398 | $app = $field; |
399 | 399 | $id = $_data[$field]; |
400 | 400 | } |
401 | 401 | if ($app && $app_id) { |
402 | - $link_id = Link::link('timesheet',$id,$app,$app_id); |
|
402 | + $link_id = Link::link('timesheet', $id, $app, $app_id); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | return $result; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | // end of iface_export_plugin |
496 | 496 | |
497 | 497 | // Extra conversion functions - must be static |
498 | - public static function addr_id( $n_family,$n_given=null,$org_name=null ) { |
|
498 | + public static function addr_id($n_family, $n_given = null, $org_name = null) { |
|
499 | 499 | |
500 | 500 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
501 | 501 | static $contacts; |
@@ -505,18 +505,18 @@ discard block |
||
505 | 505 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
506 | 506 | } |
507 | 507 | $n_family = trim($n_family); |
508 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
508 | + if (!is_null($n_given)) $n_given = trim($n_given); |
|
509 | 509 | if (!is_object($contacts)) |
510 | 510 | { |
511 | - $contacts =& CreateObject('phpgwapi.contacts'); |
|
511 | + $contacts = & CreateObject('phpgwapi.contacts'); |
|
512 | 512 | } |
513 | 513 | if (!is_null($org_name)) // org_name given? |
514 | 514 | { |
515 | 515 | $org_name = trim($org_name); |
516 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
|
516 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name"); |
|
517 | 517 | if (!count($addrs)) |
518 | 518 | { |
519 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
|
519 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name'); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } |
526 | 526 | if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
527 | 527 | { |
528 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
|
528 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn'); |
|
529 | 529 | } |
530 | 530 | if (count($addrs)) |
531 | 531 | { |
@@ -107,7 +107,8 @@ discard block |
||
107 | 107 | * @param string $_charset |
108 | 108 | * @param definition $_definition |
109 | 109 | */ |
110 | - public function import( $_stream, importexport_definition $_definition ) { |
|
110 | + public function import( $_stream, importexport_definition $_definition ) |
|
111 | + { |
|
111 | 112 | $import_csv = new importexport_import_csv( $_stream, array( |
112 | 113 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
113 | 114 | 'charset' => $_definition->plugin_options['charset'], |
@@ -136,9 +137,12 @@ discard block |
||
136 | 137 | $import_csv->conversion_class = $this; |
137 | 138 | |
138 | 139 | //check if file has a header lines |
139 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
140 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
141 | + { |
|
140 | 142 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
141 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
143 | + } |
|
144 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
145 | + { |
|
142 | 146 | // First method is preferred |
143 | 147 | $import_csv->skip_records(1); |
144 | 148 | } |
@@ -158,9 +162,13 @@ discard block |
||
158 | 162 | ); |
159 | 163 | |
160 | 164 | // Status need leading spaces removed |
161 | - foreach($lookups['ts_status'] as $id => &$label) { |
|
165 | + foreach($lookups['ts_status'] as $id => &$label) |
|
166 | + { |
|
162 | 167 | $label = str_replace(' ', '',trim($label)); |
163 | - if($label == '') unset($lookups['ts_status'][$id]); |
|
168 | + if($label == '') |
|
169 | + { |
|
170 | + unset($lookups['ts_status'][$id]); |
|
171 | + } |
|
164 | 172 | } |
165 | 173 | |
166 | 174 | // Start counting successes |
@@ -170,24 +178,37 @@ discard block |
||
170 | 178 | // Failures |
171 | 179 | $this->errors = array(); |
172 | 180 | |
173 | - while ( $record = $import_csv->get_record() ) { |
|
181 | + while ( $record = $import_csv->get_record() ) |
|
182 | + { |
|
174 | 183 | $success = false; |
175 | 184 | |
176 | 185 | // don't import empty records |
177 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
186 | + if( count( array_unique( $record ) ) < 2 ) |
|
187 | + { |
|
188 | + continue; |
|
189 | + } |
|
178 | 190 | |
179 | 191 | $result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']); |
180 | - if($result) $this->warnings[$import_csv->get_current_position()] = $result; |
|
192 | + if($result) |
|
193 | + { |
|
194 | + $this->warnings[$import_csv->get_current_position()] = $result; |
|
195 | + } |
|
181 | 196 | |
182 | 197 | // Automatically handle text Api\Categories without explicit Api\Translation |
183 | - foreach(array('ts_status','cat_id') as $field) { |
|
184 | - if(!is_numeric($record[$field])) { |
|
198 | + foreach(array('ts_status','cat_id') as $field) |
|
199 | + { |
|
200 | + if(!is_numeric($record[$field])) |
|
201 | + { |
|
185 | 202 | $translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id'); |
186 | - if(($key = array_search($record[$field], $lookups[$field]))) { |
|
203 | + if(($key = array_search($record[$field], $lookups[$field]))) |
|
204 | + { |
|
187 | 205 | $record[$field] = $key; |
188 | - } elseif(array_key_exists($translate_key, $_definition->plugin_options)) { |
|
206 | + } |
|
207 | + elseif(array_key_exists($translate_key, $_definition->plugin_options)) |
|
208 | + { |
|
189 | 209 | $t_field = $_definition->plugin_options[$translate_key]; |
190 | - switch ($t_field) { |
|
210 | + switch ($t_field) |
|
211 | + { |
|
191 | 212 | case '': |
192 | 213 | case '0': |
193 | 214 | // Skip that field |
@@ -196,16 +217,21 @@ discard block |
||
196 | 217 | case '~skip~': |
197 | 218 | continue 2; |
198 | 219 | default: |
199 | - if(strpos($t_field, 'add') === 0) { |
|
220 | + if(strpos($t_field, 'add') === 0) |
|
221 | + { |
|
200 | 222 | // Check for a parent |
201 | 223 | list($name, $parent_name) = explode('~',$t_field); |
202 | - if($parent_name) { |
|
224 | + if($parent_name) |
|
225 | + { |
|
203 | 226 | $parent = importexport_helper_functions::cat_name2id($parent_name); |
204 | 227 | } |
205 | 228 | |
206 | - if($field == 'cat_id') { |
|
229 | + if($field == 'cat_id') |
|
230 | + { |
|
207 | 231 | $record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent); |
208 | - } elseif ($field == 'ts_status') { |
|
232 | + } |
|
233 | + elseif ($field == 'ts_status') |
|
234 | + { |
|
209 | 235 | end($this->bo->status_labels); |
210 | 236 | $id = key($this->bo->status_labels)+1; |
211 | 237 | $this->bo->status_labels[$id] = $record[$field]; |
@@ -218,9 +244,13 @@ discard block |
||
218 | 244 | $lookups[$field][$id] = $name; |
219 | 245 | $record[$field] = $id; |
220 | 246 | } |
221 | - } elseif(($key = array_search($t_field, $lookups[$field]))) { |
|
247 | + } |
|
248 | + elseif(($key = array_search($t_field, $lookups[$field]))) |
|
249 | + { |
|
222 | 250 | $record[$field] = $key; |
223 | - } else { |
|
251 | + } |
|
252 | + else |
|
253 | + { |
|
224 | 254 | $record[$field] = $t_field; |
225 | 255 | } |
226 | 256 | break; |
@@ -230,11 +260,14 @@ discard block |
||
230 | 260 | } |
231 | 261 | |
232 | 262 | // Set creator, unless it's supposed to come from CSV file |
233 | - if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) { |
|
234 | - if(!is_numeric($record['ts_owner'])) { |
|
263 | + if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) |
|
264 | + { |
|
265 | + if(!is_numeric($record['ts_owner'])) |
|
266 | + { |
|
235 | 267 | // Automatically handle text owner without explicit Api\Translation |
236 | 268 | $new_owner = importexport_helper_functions::account_name2id($record['ts_owner']); |
237 | - if($new_owner == '') { |
|
269 | + if($new_owner == '') |
|
270 | + { |
|
238 | 271 | $this->errors[$import_csv->get_current_position()] = lang( |
239 | 272 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for %3.', |
240 | 273 | $record['ts_owner'], |
@@ -242,22 +275,31 @@ discard block |
||
242 | 275 | lang($this->bo->field2label['ts_owner']) |
243 | 276 | ); |
244 | 277 | $record['ts_owner'] = $_definition->plugin_options['record_owner']; |
245 | - } else { |
|
278 | + } |
|
279 | + else |
|
280 | + { |
|
246 | 281 | $record['ts_owner'] = $new_owner; |
247 | 282 | } |
248 | 283 | } |
249 | - } elseif ($_definition->plugin_options['record_owner']) { |
|
284 | + } |
|
285 | + elseif ($_definition->plugin_options['record_owner']) |
|
286 | + { |
|
250 | 287 | $record['ts_owner'] = $_definition->plugin_options['record_owner']; |
251 | 288 | } |
252 | 289 | |
253 | 290 | // Check account IDs |
254 | - foreach(array('ts_modifier') as $field) { |
|
255 | - if($record[$field] && !is_numeric($record[$field])) { |
|
291 | + foreach(array('ts_modifier') as $field) |
|
292 | + { |
|
293 | + if($record[$field] && !is_numeric($record[$field])) |
|
294 | + { |
|
256 | 295 | // Try an automatic conversion |
257 | 296 | $account_id = importexport_helper_functions::account_name2id($record[$field]); |
258 | - if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field])) { |
|
297 | + if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field])) |
|
298 | + { |
|
259 | 299 | $record[$field] = $account_id; |
260 | - } else { |
|
300 | + } |
|
301 | + else |
|
302 | + { |
|
261 | 303 | $this->errors[$import_csv->get_current_position()] = lang( |
262 | 304 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for %3.', |
263 | 305 | $record[$field], |
@@ -275,29 +317,44 @@ discard block |
||
275 | 317 | $record['addressbook'] = self::addr_id($lastname,$firstname,$org_name); |
276 | 318 | } |
277 | 319 | |
278 | - if ( $_definition->plugin_options['conditions'] ) { |
|
279 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
320 | + if ( $_definition->plugin_options['conditions'] ) |
|
321 | + { |
|
322 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
323 | + { |
|
280 | 324 | $results = array(); |
281 | - switch ( $condition['type'] ) { |
|
325 | + switch ( $condition['type'] ) |
|
326 | + { |
|
282 | 327 | // exists |
283 | 328 | case 'exists' : |
284 | - if($record[$condition['string']]) { |
|
329 | + if($record[$condition['string']]) |
|
330 | + { |
|
285 | 331 | $results = $this->bo->search(array($condition['string'] => $record[$condition['string']])); |
286 | 332 | } |
287 | 333 | |
288 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1 ) { |
|
334 | + if ( is_array( $results ) && count( array_keys( $results )) >= 1 ) |
|
335 | + { |
|
289 | 336 | // apply action to all records matching this exists condition |
290 | 337 | $action = $condition['true']; |
291 | - foreach ( (array)$results as $result ) { |
|
338 | + foreach ( (array)$results as $result ) |
|
339 | + { |
|
292 | 340 | $record['ts_id'] = $result['ts_id']; |
293 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
294 | - if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] ); |
|
295 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
341 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
342 | + { |
|
343 | + if ( !is_array( $result['cat_id'] ) ) |
|
344 | + { |
|
345 | + $result['cat_id'] = explode( ',', $result['cat_id'] ); |
|
346 | + } |
|
347 | + if ( !is_array( $record['cat_id'] ) ) |
|
348 | + { |
|
349 | + $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
350 | + } |
|
296 | 351 | $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) ); |
297 | 352 | } |
298 | 353 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
299 | 354 | } |
300 | - } else { |
|
355 | + } |
|
356 | + else |
|
357 | + { |
|
301 | 358 | $action = $condition['false']; |
302 | 359 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
303 | 360 | } |
@@ -308,13 +365,21 @@ discard block |
||
308 | 365 | die('condition / action not supported!!!'); |
309 | 366 | break; |
310 | 367 | } |
311 | - if ($action['last']) break; |
|
368 | + if ($action['last']) |
|
369 | + { |
|
370 | + break; |
|
371 | + } |
|
312 | 372 | } |
313 | - } else { |
|
373 | + } |
|
374 | + else |
|
375 | + { |
|
314 | 376 | // unconditional insert |
315 | 377 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
316 | 378 | } |
317 | - if($success) $count++; |
|
379 | + if($success) |
|
380 | + { |
|
381 | + $count++; |
|
382 | + } |
|
318 | 383 | } |
319 | 384 | return $count; |
320 | 385 | } |
@@ -326,9 +391,11 @@ discard block |
||
326 | 391 | * @param array $_data tracker data for the action |
327 | 392 | * @return bool success or not |
328 | 393 | */ |
329 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
394 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
395 | + { |
|
330 | 396 | $result = true; |
331 | - switch ($_action) { |
|
397 | + switch ($_action) |
|
398 | + { |
|
332 | 399 | case 'none' : |
333 | 400 | return true; |
334 | 401 | case 'update' : |
@@ -336,7 +403,8 @@ discard block |
||
336 | 403 | $old_record = new timesheet_egw_record($_data['ts_id']); |
337 | 404 | $old = $old_record->get_record_array(); |
338 | 405 | |
339 | - if(!$this->definition->plugin_options['change_owner']) { |
|
406 | + if(!$this->definition->plugin_options['change_owner']) |
|
407 | + { |
|
340 | 408 | // Don't change creator of an existing ticket |
341 | 409 | unset($_data['ts_owner']); |
342 | 410 | } |
@@ -344,36 +412,45 @@ discard block |
||
344 | 412 | // Merge to deal with fields not in import record |
345 | 413 | $_data = array_merge($old, $_data); |
346 | 414 | $changed = $this->tracking->changed_fields($_data, $old); |
347 | - if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) { |
|
415 | + if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) |
|
416 | + { |
|
348 | 417 | break; |
349 | 418 | } |
350 | 419 | |
351 | 420 | // Clear old link, if different |
352 | - if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) { |
|
421 | + if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) |
|
422 | + { |
|
353 | 423 | Link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']); |
354 | 424 | } |
355 | 425 | |
356 | 426 | // Fall through |
357 | 427 | case 'insert' : |
358 | - if ( $this->dry_run ) { |
|
428 | + if ( $this->dry_run ) |
|
429 | + { |
|
359 | 430 | //print_r($_data); |
360 | 431 | $this->results[$_action]++; |
361 | 432 | break; |
362 | - } else { |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
363 | 436 | $result = $this->bo->save( $_data); |
364 | 437 | $_data['ts_id'] = $this->bo->data['ts_id']; |
365 | 438 | |
366 | 439 | // Set projectmanager link |
367 | - if ($_data['pm_id']) { |
|
440 | + if ($_data['pm_id']) |
|
441 | + { |
|
368 | 442 | Link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']); |
369 | 443 | } |
370 | 444 | |
371 | - if($result) { |
|
445 | + if($result) |
|
446 | + { |
|
372 | 447 | $this->errors[$record_num] = lang('Permissions error - %1 could not %2', |
373 | 448 | $GLOBALS['egw']->accounts->id2name($_data['owner']), |
374 | 449 | lang($_action) |
375 | 450 | ) . ' ' . $result; |
376 | - } else { |
|
451 | + } |
|
452 | + else |
|
453 | + { |
|
377 | 454 | $this->results[$_action]++; |
378 | 455 | $result = $this->bo->data['ts_id']; |
379 | 456 | } |
@@ -384,21 +461,30 @@ discard block |
||
384 | 461 | } |
385 | 462 | |
386 | 463 | // Process some additional fields |
387 | - if(!is_numeric($result)) { |
|
464 | + if(!is_numeric($result)) |
|
465 | + { |
|
388 | 466 | return $result; |
389 | 467 | } |
390 | 468 | $_link_id = false; |
391 | - foreach(self::$special_fields as $field => $desc) { |
|
392 | - if(!$_data[$field]) continue; |
|
469 | + foreach(self::$special_fields as $field => $desc) |
|
470 | + { |
|
471 | + if(!$_data[$field]) |
|
472 | + { |
|
473 | + continue; |
|
474 | + } |
|
393 | 475 | |
394 | 476 | // Links |
395 | - if(strpos('link', $field) === 0) { |
|
477 | + if(strpos('link', $field) === 0) |
|
478 | + { |
|
396 | 479 | list($app, $id) = explode(':', $_data[$field]); |
397 | - } else { |
|
480 | + } |
|
481 | + else |
|
482 | + { |
|
398 | 483 | $app = $field; |
399 | 484 | $id = $_data[$field]; |
400 | 485 | } |
401 | - if ($app && $app_id) { |
|
486 | + if ($app && $app_id) |
|
487 | + { |
|
402 | 488 | $link_id = Link::link('timesheet',$id,$app,$app_id); |
403 | 489 | } |
404 | 490 | } |
@@ -410,7 +496,8 @@ discard block |
||
410 | 496 | * |
411 | 497 | * @return string name |
412 | 498 | */ |
413 | - public static function get_name() { |
|
499 | + public static function get_name() |
|
500 | + { |
|
414 | 501 | return lang('Timesheet CSV import'); |
415 | 502 | } |
416 | 503 | |
@@ -419,7 +506,8 @@ discard block |
||
419 | 506 | * |
420 | 507 | * @return string descriprion |
421 | 508 | */ |
422 | - public static function get_description() { |
|
509 | + public static function get_description() |
|
510 | + { |
|
423 | 511 | return lang("Imports entries into the timesheet from a CSV File. "); |
424 | 512 | } |
425 | 513 | |
@@ -428,7 +516,8 @@ discard block |
||
428 | 516 | * |
429 | 517 | * @return string suffix (comma seperated) |
430 | 518 | */ |
431 | - public static function get_filesuffix() { |
|
519 | + public static function get_filesuffix() |
|
520 | + { |
|
432 | 521 | return 'csv'; |
433 | 522 | } |
434 | 523 | |
@@ -444,7 +533,8 @@ discard block |
||
444 | 533 | * preserv => array, |
445 | 534 | * ) |
446 | 535 | */ |
447 | - public function get_options_etpl() { |
|
536 | + public function get_options_etpl() |
|
537 | + { |
|
448 | 538 | // lets do it! |
449 | 539 | } |
450 | 540 | |
@@ -453,7 +543,8 @@ discard block |
||
453 | 543 | * |
454 | 544 | * @return string etemplate name |
455 | 545 | */ |
456 | - public function get_selectors_etpl() { |
|
546 | + public function get_selectors_etpl() |
|
547 | + { |
|
457 | 548 | // lets do it! |
458 | 549 | } |
459 | 550 | |
@@ -465,7 +556,8 @@ discard block |
||
465 | 556 | * record_# => warning message |
466 | 557 | * ) |
467 | 558 | */ |
468 | - public function get_warnings() { |
|
559 | + public function get_warnings() |
|
560 | + { |
|
469 | 561 | return $this->warnings; |
470 | 562 | } |
471 | 563 | |
@@ -477,7 +569,8 @@ discard block |
||
477 | 569 | * record_# => error message |
478 | 570 | * ) |
479 | 571 | */ |
480 | - public function get_errors() { |
|
572 | + public function get_errors() |
|
573 | + { |
|
481 | 574 | return $this->errors; |
482 | 575 | } |
483 | 576 | |
@@ -489,13 +582,15 @@ discard block |
||
489 | 582 | * action => record count |
490 | 583 | * ) |
491 | 584 | */ |
492 | - public function get_results() { |
|
585 | + public function get_results() |
|
586 | + { |
|
493 | 587 | return $this->results; |
494 | 588 | } |
495 | 589 | // end of iface_export_plugin |
496 | 590 | |
497 | 591 | // Extra conversion functions - must be static |
498 | - public static function addr_id( $n_family,$n_given=null,$org_name=null ) { |
|
592 | + public static function addr_id( $n_family,$n_given=null,$org_name=null ) |
|
593 | + { |
|
499 | 594 | |
500 | 595 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
501 | 596 | static $contacts; |
@@ -505,28 +600,40 @@ discard block |
||
505 | 600 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
506 | 601 | } |
507 | 602 | $n_family = trim($n_family); |
508 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
603 | + if(!is_null($n_given)) |
|
604 | + { |
|
605 | + $n_given = trim($n_given); |
|
606 | + } |
|
509 | 607 | if (!is_object($contacts)) |
510 | 608 | { |
511 | 609 | $contacts =& CreateObject('phpgwapi.contacts'); |
512 | 610 | } |
513 | - if (!is_null($org_name)) // org_name given? |
|
611 | + if (!is_null($org_name)) |
|
612 | + { |
|
613 | + // org_name given? |
|
514 | 614 | { |
515 | 615 | $org_name = trim($org_name); |
616 | + } |
|
516 | 617 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
517 | 618 | if (!count($addrs)) |
518 | 619 | { |
519 | 620 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
520 | 621 | } |
521 | 622 | } |
522 | - if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
|
623 | + if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) |
|
624 | + { |
|
625 | + // first name given and no result so far |
|
523 | 626 | { |
524 | 627 | $addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given)); |
525 | 628 | } |
526 | - if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
|
629 | + } |
|
630 | + if (is_null($n_given) && is_null($org_name)) |
|
631 | + { |
|
632 | + // just one name given, check against fn (= full name) |
|
527 | 633 | { |
528 | 634 | $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
529 | 635 | } |
636 | + } |
|
530 | 637 | if (count($addrs)) |
531 | 638 | { |
532 | 639 | return $addrs[0]['id']; |
@@ -1053,7 +1053,7 @@ |
||
1053 | 1053 | * @param int &$success number of succeded actions |
1054 | 1054 | * @param int &$failed number of failed actions (not enought permissions) |
1055 | 1055 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 timesheets 'deleted' |
1056 | - * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
1056 | + * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
1057 | 1057 | * @return boolean true if all actions succeded, false otherwise |
1058 | 1058 | */ |
1059 | 1059 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | function view() |
57 | 57 | { |
58 | - $this->edit(null,true); |
|
58 | + $this->edit(null, true); |
|
59 | 59 | } |
60 | 60 | |
61 | - function edit($content = null,$view = false) |
|
61 | + function edit($content = null, $view = false) |
|
62 | 62 | { |
63 | 63 | $etpl = new Etemplate('timesheet.edit'); |
64 | 64 | if (!is_array($content)) |
@@ -80,20 +80,19 @@ discard block |
||
80 | 80 | { |
81 | 81 | $this->data = array( |
82 | 82 | 'ts_start' => $this->today, |
83 | - 'start_time' => '', // force empty start-time |
|
84 | - 'end_time' => Api\DateTime::to($this->now,'H:i'), |
|
83 | + 'start_time' => '', // force empty start-time |
|
84 | + 'end_time' => Api\DateTime::to($this->now, 'H:i'), |
|
85 | 85 | 'ts_owner' => $GLOBALS['egw_info']['user']['account_id'], |
86 | - 'cat_id' => (int) $_REQUEST['cat_id'], |
|
86 | + 'cat_id' => (int)$_REQUEST['cat_id'], |
|
87 | 87 | 'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'], |
88 | 88 | ); |
89 | 89 | } |
90 | 90 | $matches = null; |
91 | - $referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] : |
|
92 | - (strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index'); |
|
91 | + $referer = preg_match('/menuaction=([^&]+)/', $_SERVER['HTTP_REFERER'], $matches) ? $matches[1] : (strpos($_SERVER['HTTP_REFERER'], '/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index'); |
|
93 | 92 | |
94 | 93 | if (!$this->check_statusForEditRights($this->data)) |
95 | 94 | { |
96 | - $view = true; //only admin can edit with this status |
|
95 | + $view = true; //only admin can edit with this status |
|
97 | 96 | $only_admin_edit = true; |
98 | 97 | $msg = lang('only Admin can edit this status'); |
99 | 98 | } |
@@ -106,7 +105,7 @@ discard block |
||
106 | 105 | { |
107 | 106 | if ($this->status_labels_config[$content['ts_status']]['admin']) |
108 | 107 | { |
109 | - $view = true; //only admin can edit with this status |
|
108 | + $view = true; //only admin can edit with this status |
|
110 | 109 | $only_admin_edit = true; |
111 | 110 | $msg = lang('only Admin can edit this status'); |
112 | 111 | } |
@@ -120,29 +119,29 @@ discard block |
||
120 | 119 | { |
121 | 120 | //$content['ts_start'] += $content['start_time']; |
122 | 121 | $start = new Api\DateTime($content['ts_start']); |
123 | - $start_time = explode(':',$content['start_time']); |
|
124 | - $start->setTime($start_time[0],$start_time[1]); |
|
122 | + $start_time = explode(':', $content['start_time']); |
|
123 | + $start->setTime($start_time[0], $start_time[1]); |
|
125 | 124 | $content['ts_start'] = $start->format('ts'); |
126 | 125 | } |
127 | 126 | if (isset($content['end_time'])) // end-time specified |
128 | 127 | { |
129 | 128 | $end = new Api\DateTime($content['ts_start']); |
130 | - $end_time = explode(':',$content['end_time']); |
|
131 | - $end->setTime($end_time[0],$end_time[1]); |
|
129 | + $end_time = explode(':', $content['end_time']); |
|
130 | + $end->setTime($end_time[0], $end_time[1]); |
|
132 | 131 | } |
133 | 132 | if ($end && $start) // start- & end-time --> calculate the duration |
134 | 133 | { |
135 | 134 | $content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60; |
136 | 135 | // check if negative duration is caused by wrap over midnight |
137 | - if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60) |
|
136 | + if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24 * 60) |
|
138 | 137 | { |
139 | - $content['ts_duration'] += 24*60; |
|
138 | + $content['ts_duration'] += 24 * 60; |
|
140 | 139 | } |
141 | 140 | //echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n"; |
142 | 141 | } |
143 | 142 | elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration |
144 | 143 | { |
145 | - $content['ts_start'] = $end->format('ts') - 60*$content['ts_duration']; |
|
144 | + $content['ts_start'] = $end->format('ts') - 60 * $content['ts_duration']; |
|
146 | 145 | //echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n"; |
147 | 146 | } |
148 | 147 | if ($content['ts_duration'] > 0) unset($content['end_time']); |
@@ -152,18 +151,18 @@ discard block |
||
152 | 151 | $referer = $content['referer']; |
153 | 152 | $content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : ''; |
154 | 153 | $this->data = $content; |
155 | - foreach(array('button','view','referer','tabs','start_time') as $key) |
|
154 | + foreach (array('button', 'view', 'referer', 'tabs', 'start_time') as $key) |
|
156 | 155 | { |
157 | 156 | unset($this->data[$key]); |
158 | 157 | } |
159 | - switch($button) |
|
158 | + switch ($button) |
|
160 | 159 | { |
161 | 160 | case 'edit': |
162 | 161 | if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false; |
163 | 162 | break; |
164 | 163 | |
165 | 164 | case 'undelete': |
166 | - if($content['ts_status'] == self::DELETED_STATUS) |
|
165 | + if ($content['ts_status'] == self::DELETED_STATUS) |
|
167 | 166 | { |
168 | 167 | unset($content['ts_status']); |
169 | 168 | $this->data['ts_status'] = ''; |
@@ -181,14 +180,14 @@ discard block |
||
181 | 180 | } |
182 | 181 | if (!$this->data['ts_quantity']) |
183 | 182 | { |
184 | - $etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!')); |
|
183 | + $etpl->set_validation_error('ts_quantity', lang('Field must not be empty !!!')); |
|
185 | 184 | } |
186 | 185 | if ($this->data['ts_duration'] < 0) |
187 | 186 | { |
188 | - $etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!')); |
|
187 | + $etpl->set_validation_error('start_time', lang('Starttime has to be before endtime !!!')); |
|
189 | 188 | } |
190 | 189 | // set ts_title to ts_project if short viewtype (title is not editable) |
191 | - if($this->ts_viewtype == 'short') |
|
190 | + if ($this->ts_viewtype == 'short') |
|
192 | 191 | { |
193 | 192 | $this->data['ts_title'] = $this->data['ts_project']; |
194 | 193 | } |
@@ -199,9 +198,9 @@ discard block |
||
199 | 198 | |
200 | 199 | if (!$this->data['ts_title']) |
201 | 200 | { |
202 | - $etpl->set_validation_error('ts_title',lang('Field must not be empty !!!')); |
|
201 | + $etpl->set_validation_error('ts_title', lang('Field must not be empty !!!')); |
|
203 | 202 | } |
204 | - elseif($button != 'save_new') |
|
203 | + elseif ($button != 'save_new') |
|
205 | 204 | { |
206 | 205 | // remove title-blur for same behavior after apply, as for opening the saved entry again |
207 | 206 | unset($this->data['ts_title_blur']); |
@@ -210,26 +209,26 @@ discard block |
||
210 | 209 | unset($content['ts_project_blur']); |
211 | 210 | } |
212 | 211 | } |
213 | - if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry |
|
212 | + if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry |
|
214 | 213 | |
215 | 214 | // account for changed project --> remove old one from links and add new one |
216 | - if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id']) |
|
215 | + if ((int)$this->data['pm_id'] != (int)$this->data['old_pm_id']) |
|
217 | 216 | { |
218 | 217 | // update links accordingly |
219 | 218 | if ($this->data['pm_id']) |
220 | 219 | { |
221 | - Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']); |
|
220 | + Link::link(TIMESHEET_APP, $content['link_to']['to_id'], 'projectmanager', $this->data['pm_id']); |
|
222 | 221 | } |
223 | 222 | if ($this->data['old_pm_id']) |
224 | 223 | { |
225 | - Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']); |
|
224 | + Link::unlink2(0, TIMESHEET_APP, $content['link_to']['to_id'], 0, 'projectmanager', $this->data['old_pm_id']); |
|
226 | 225 | unset($this->data['old_pm_id']); |
227 | 226 | } |
228 | 227 | } |
229 | 228 | // check if we are linked to a project, but that is NOT set as project |
230 | 229 | if (!$this->data['pm_id'] && is_array($content['link_to']['to_id'])) |
231 | 230 | { |
232 | - foreach($content['link_to']['to_id'] as $data) |
|
231 | + foreach ($content['link_to']['to_id'] as $data) |
|
233 | 232 | { |
234 | 233 | if ($data['app'] == 'projectmanager') |
235 | 234 | { |
@@ -250,26 +249,26 @@ discard block |
||
250 | 249 | $msg = lang('Entry saved'); |
251 | 250 | if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id'])) |
252 | 251 | { |
253 | - Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']); |
|
252 | + Link::link(TIMESHEET_APP, $this->data['ts_id'], $content['link_to']['to_id']); |
|
254 | 253 | } |
255 | 254 | } |
256 | 255 | Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add'); |
257 | 256 | if ($button == 'apply') break; |
258 | 257 | if ($button == 'save_new') |
259 | 258 | { |
260 | - $msg .= ', '.lang('creating new entry'); // giving some feedback to the user |
|
259 | + $msg .= ', '.lang('creating new entry'); // giving some feedback to the user |
|
261 | 260 | |
262 | 261 | if (!is_array($content['link_to']['to_id'])) // set links again, so new entry gets the same links as the existing one |
263 | 262 | { |
264 | 263 | $content['link_to']['to_id'] = 0; |
265 | - foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link) |
|
264 | + foreach (Link::get_links(TIMESHEET_APP, $this->data['ts_id'], '!'.Link::VFS_APPNAME) as $link) |
|
266 | 265 | { |
267 | - Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']); |
|
266 | + Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
268 | 267 | } |
269 | 268 | } |
270 | 269 | // create a new entry |
271 | 270 | $this->data['ts_start'] += 60 * $this->data['ts_duration']; |
272 | - foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier') as $name) |
|
271 | + foreach (array('ts_id', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_modified', 'ts_modifier') as $name) |
|
273 | 272 | { |
274 | 273 | unset($this->data[$name]); |
275 | 274 | } |
@@ -289,7 +288,7 @@ discard block |
||
289 | 288 | else |
290 | 289 | { |
291 | 290 | $msg = lang('Error deleting the entry!!!'); |
292 | - break; // dont close window |
|
291 | + break; // dont close window |
|
293 | 292 | } |
294 | 293 | } |
295 | 294 | // fall-through for save |
@@ -302,7 +301,7 @@ discard block |
||
302 | 301 | 'referer' => $referer, |
303 | 302 | 'ts_title_blur' => $content['ts_title_blur'], |
304 | 303 | ); |
305 | - $content = array_merge($this->data,array( |
|
304 | + $content = array_merge($this->data, array( |
|
306 | 305 | 'msg' => $msg, |
307 | 306 | 'view' => $view, |
308 | 307 | 'tabs' => $content['tabs'], |
@@ -310,8 +309,8 @@ discard block |
||
310 | 309 | 'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] : $content['link_to']['to_id'], |
311 | 310 | 'to_app' => TIMESHEET_APP, |
312 | 311 | ), |
313 | - 'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '', |
|
314 | - 'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'], |
|
312 | + 'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '', |
|
313 | + 'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'], |
|
315 | 314 | 'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'], |
316 | 315 | 'pm_integration' => $this->pm_integration, |
317 | 316 | 'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS), |
@@ -321,10 +320,10 @@ discard block |
||
321 | 320 | if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
322 | 321 | { |
323 | 322 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
324 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
323 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
325 | 324 | { |
326 | 325 | $link_id = $link_ids[$n]; |
327 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
326 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // gard against XSS |
|
328 | 327 | { |
329 | 328 | switch ($link_app) |
330 | 329 | { |
@@ -332,33 +331,33 @@ discard block |
||
332 | 331 | $links[] = $link_id; |
333 | 332 | // fall-through; |
334 | 333 | default: |
335 | - if(!$n) |
|
334 | + if (!$n) |
|
336 | 335 | { |
337 | 336 | // get title from first linked app |
338 | - $preserv['ts_title_blur'] = Link::title($link_app,$link_id); |
|
337 | + $preserv['ts_title_blur'] = Link::title($link_app, $link_id); |
|
339 | 338 | // ask first linked app via "timesheet_set" hook, for further data to set, incl. links |
340 | - if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app))) |
|
339 | + if (($set = Api\Hooks::single(array('location'=>'timesheet_set', 'id'=>$link_id), $link_app))) |
|
341 | 340 | { |
342 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
341 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
343 | 342 | { |
344 | - if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id); |
|
343 | + if (($l_id = $set['link_id'][$i])) Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $l_app, $l_id); |
|
345 | 344 | if ($l_app == 'projectmanager') $links[] = $l_id; |
346 | 345 | } |
347 | 346 | unset($set['link_app']); |
348 | 347 | unset($set['link_id']); |
349 | 348 | |
350 | - $content = array_merge($content,$set); |
|
349 | + $content = array_merge($content, $set); |
|
351 | 350 | } |
352 | 351 | } |
353 | 352 | break; |
354 | 353 | } |
355 | - Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id); |
|
354 | + Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link_app, $link_id); |
|
356 | 355 | } |
357 | 356 | } |
358 | 357 | } |
359 | 358 | elseif ($this->data['ts_id']) |
360 | 359 | { |
361 | - $links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager'); |
|
360 | + $links = Link::get_links(TIMESHEET_APP, $this->data['ts_id'], 'projectmanager'); |
|
362 | 361 | } |
363 | 362 | // make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all |
364 | 363 | $content['all_pm_ids'] = array_values($links); |
@@ -401,7 +400,7 @@ discard block |
||
401 | 400 | |
402 | 401 | if ($view) |
403 | 402 | { |
404 | - foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key) |
|
403 | + foreach (array_merge(array_keys($this->data), array('pm_id', 'pl_id', 'link_to')) as $key) |
|
405 | 404 | { |
406 | 405 | $readonlys[$key] = true; |
407 | 406 | } |
@@ -417,9 +416,9 @@ discard block |
||
417 | 416 | { |
418 | 417 | $edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']); |
419 | 418 | } |
420 | - $sel_options['ts_owner'] = $edit_grants; |
|
421 | - $sel_options['ts_status'] = $this->status_labels; |
|
422 | - if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS) |
|
419 | + $sel_options['ts_owner'] = $edit_grants; |
|
420 | + $sel_options['ts_status'] = $this->status_labels; |
|
421 | + if ($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS) |
|
423 | 422 | { |
424 | 423 | $sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted'; |
425 | 424 | } |
@@ -429,19 +428,19 @@ discard block |
||
429 | 428 | // supress unknow widget 'projectmanager-*', if projectmanager is not installed or old |
430 | 429 | if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php')) |
431 | 430 | { |
432 | - $etpl->set_cell_attribute('pm_id','disabled',true); |
|
433 | - $etpl->set_cell_attribute('pl_id','disabled',true); |
|
431 | + $etpl->set_cell_attribute('pm_id', 'disabled', true); |
|
432 | + $etpl->set_cell_attribute('pl_id', 'disabled', true); |
|
434 | 433 | } |
435 | 434 | |
436 | - if($this->ts_viewtype == 'short') |
|
435 | + if ($this->ts_viewtype == 'short') |
|
437 | 436 | { |
438 | 437 | $content['ts_viewtype'] = $readonlys['tabs']['notes'] = true; |
439 | 438 | $content['ts_description_short'] = $content['ts_description']; |
440 | 439 | } |
441 | - if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields |
|
442 | - if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID |
|
440 | + if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields |
|
441 | + if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID |
|
443 | 442 | |
444 | - return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2); |
|
443 | + return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit', $content, $sel_options, $readonlys, $preserv, 2); |
|
445 | 444 | } |
446 | 445 | |
447 | 446 | /** |
@@ -454,7 +453,7 @@ discard block |
||
454 | 453 | { |
455 | 454 | if (!$datetime) return 0; |
456 | 455 | |
457 | - return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime)); |
|
456 | + return $datetime - mktime(0, 0, 0, date('m', $datetime), date('d', $datetime), date('Y', $datetime)); |
|
458 | 457 | } |
459 | 458 | |
460 | 459 | /** |
@@ -468,22 +467,22 @@ discard block |
||
468 | 467 | * @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session |
469 | 468 | * @return int total number of contacts matching the selection |
470 | 469 | */ |
471 | - function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false) |
|
470 | + function get_rows(&$query_in, &$rows, &$readonlys, $id_only = false) |
|
472 | 471 | { |
473 | 472 | $this->show_sums = false; |
474 | 473 | |
475 | 474 | // Date filter |
476 | 475 | $end_date = $query_in['enddate'] ? $query_in['enddate'] : false; |
477 | - if($end_date || $query_in['filter'] === 'custom') |
|
476 | + if ($end_date || $query_in['filter'] === 'custom') |
|
478 | 477 | { |
479 | 478 | $query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1; |
480 | 479 | } |
481 | - $date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date); |
|
480 | + $date_filter = $this->date_filter($query_in['filter'], $query_in['startdate'], $end_date); |
|
482 | 481 | |
483 | 482 | if ($query_in['startdate']) |
484 | 483 | { |
485 | - $start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60)); |
|
486 | - $end = explode('-',date('Y-m-d',$end_date ? $end_date : $query_in['startdate']+7.5*24*60*60)); |
|
484 | + $start = explode('-', date('Y-m-d', $query_in['startdate'] + 12 * 60 * 60)); |
|
485 | + $end = explode('-', date('Y-m-d', $end_date ? $end_date : $query_in['startdate'] + 7.5 * 24 * 60 * 60)); |
|
487 | 486 | |
488 | 487 | // show year-sums, if we are year-aligned (show full years)? |
489 | 488 | if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12) |
@@ -491,28 +490,28 @@ discard block |
||
491 | 490 | $this->show_sums[] = 'year'; |
492 | 491 | } |
493 | 492 | // show month-sums, if we are month-aligned (show full monthes)? |
494 | - if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0]))) |
|
493 | + if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d', mktime(12, 0, 0, $end[1] + 1, 0, $end[0]))) |
|
495 | 494 | { |
496 | 495 | $this->show_sums[] = 'month'; |
497 | 496 | } |
498 | 497 | // show week-sums, if we are week-aligned (show full weeks)? |
499 | 498 | $week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']; |
500 | 499 | if (!$week_start_day) $week_start_day = 'Sunday'; |
501 | - switch($week_start_day) |
|
500 | + switch ($week_start_day) |
|
502 | 501 | { |
503 | 502 | case 'Sunday': $week_end_day = 'Saturday'; break; |
504 | 503 | case 'Monday': $week_end_day = 'Sunday'; break; |
505 | 504 | case 'Saturday': $week_end_day = 'Friday'; break; |
506 | 505 | } |
507 | - $filter_start_day = date('l',$query_in['startdate']+12*60*60); |
|
508 | - $filter_end_day = $query_in['enddate'] ? date('l',$query_in['enddate']+12*60*60) : false; |
|
506 | + $filter_start_day = date('l', $query_in['startdate'] + 12 * 60 * 60); |
|
507 | + $filter_end_day = $query_in['enddate'] ? date('l', $query_in['enddate'] + 12 * 60 * 60) : false; |
|
509 | 508 | //echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n"; |
510 | 509 | if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day)) |
511 | 510 | { |
512 | 511 | $this->show_sums[] = 'week'; |
513 | 512 | } |
514 | 513 | // show day-sums, if range <= 5 weeks |
515 | - if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36*24*60*60) |
|
514 | + if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36 * 24 * 60 * 60) |
|
516 | 515 | { |
517 | 516 | $this->show_sums[] = 'day'; |
518 | 517 | } |
@@ -523,10 +522,10 @@ discard block |
||
523 | 522 | // Refresh actions (undelete needs this) |
524 | 523 | $query_in['actions'] = $this->get_actions($query_in); |
525 | 524 | |
526 | - $query = $query_in; // keep the original query |
|
525 | + $query = $query_in; // keep the original query |
|
527 | 526 | $query['enddate'] = $end_date; |
528 | 527 | |
529 | - if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false); |
|
528 | + if ($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false, 'ts_unitprice'=>false, 'ts_total'=>false); |
|
530 | 529 | if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false; |
531 | 530 | |
532 | 531 | //_debug_array($query['col_filter']); |
@@ -553,10 +552,10 @@ discard block |
||
553 | 552 | // handle linked filter (show only entries linked to a certain other entry) |
554 | 553 | if ($query['col_filter']['linked']) |
555 | 554 | { |
556 | - list($app,$id) = explode(':',$query['col_filter']['linked']); |
|
557 | - if (!($links = Link::get_links($app,$id,'timesheet'))) |
|
555 | + list($app, $id) = explode(':', $query['col_filter']['linked']); |
|
556 | + if (!($links = Link::get_links($app, $id, 'timesheet'))) |
|
558 | 557 | { |
559 | - $rows = array(); // no infologs linked to project --> no rows to return |
|
558 | + $rows = array(); // no infologs linked to project --> no rows to return |
|
560 | 559 | return 0; |
561 | 560 | } |
562 | 561 | if (!$query['col_filter']['ts_id']) |
@@ -564,9 +563,9 @@ discard block |
||
564 | 563 | $query['col_filter']['ts_id'] = array_values(array_unique($links)); |
565 | 564 | } |
566 | 565 | // allow to combine with other filters using ts_id --> intersect ids |
567 | - elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links))))) |
|
566 | + elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'], array_values(array_unique($links))))) |
|
568 | 567 | { |
569 | - $rows = array(); // no infologs linked to project --> no rows to return |
|
568 | + $rows = array(); // no infologs linked to project --> no rows to return |
|
570 | 569 | return 0; |
571 | 570 | } |
572 | 571 | } |
@@ -590,13 +589,13 @@ discard block |
||
590 | 589 | { |
591 | 590 | if (isset($this->status_labels_substatus['2level'][$status_id])) |
592 | 591 | { |
593 | - $query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]); |
|
592 | + $query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'], $this->status_labels_substatus[$status_id]); |
|
594 | 593 | } |
595 | 594 | } |
596 | 595 | } |
597 | 596 | if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details']) |
598 | 597 | { |
599 | - $GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']); |
|
598 | + $GLOBALS['egw']->preferences->add(TIMESHEET_APP, 'show_details', (int)$query['filter2']); |
|
600 | 599 | $GLOBALS['egw']->preferences->save_repository(true); |
601 | 600 | } |
602 | 601 | // category filter: cat_id or ''=All cats or 0=No cat |
@@ -619,7 +618,7 @@ discard block |
||
619 | 618 | $GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']); |
620 | 619 | #if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members"); |
621 | 620 | #_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true)); |
622 | - if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true)); |
|
621 | + if ($query['col_filter']['ts_owner'] < 0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']), $GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'], true)); |
|
623 | 622 | } |
624 | 623 | else |
625 | 624 | { |
@@ -632,60 +631,60 @@ discard block |
||
632 | 631 | // generate a meaningful app-header / report title |
633 | 632 | if ($this->show_sums['month']) |
634 | 633 | { |
635 | - if ((int)$start[1] == 1 && (int) $end[1] == 12) // whole year(s) |
|
634 | + if ((int)$start[1] == 1 && (int)$end[1] == 12) // whole year(s) |
|
636 | 635 | { |
637 | - $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : ''); |
|
636 | + $GLOBALS['egw_info']['flags']['app_header'] .= ': '.$start[0].($start[0] != $end[0] ? ' - '.$end[0] : ''); |
|
638 | 637 | } |
639 | 638 | else |
640 | 639 | { |
641 | - $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0]; |
|
640 | + $GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(date('F', $query['startdate'] + 12 * 60 * 60)).' '.$start[0]; |
|
642 | 641 | if ($start[0] != $end[0] || $start[1] != $end[1]) |
643 | 642 | { |
644 | - $GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0]; |
|
643 | + $GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang(date('F', $query['enddate'] + 12 * 60 * 60)).' '.$end[0]; |
|
645 | 644 | } |
646 | 645 | } |
647 | 646 | } |
648 | 647 | elseif ($this->show_sums['week']) |
649 | 648 | { |
650 | - $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0]; |
|
651 | - if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60) |
|
649 | + $GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('week').' '.date('W', $query['startdate'] + 36 * 60 * 60).'/'.$start[0]; |
|
650 | + if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10 * 24 * 60 * 60) |
|
652 | 651 | { |
653 | - $GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0]; |
|
652 | + $GLOBALS['egw_info']['flags']['app_header'] .= ' - '.date('W', $query['enddate'] - 36 * 60 * 60).'/'.$end[0]; |
|
654 | 653 | } |
655 | 654 | } |
656 | 655 | elseif ($query['startdate']) |
657 | 656 | { |
658 | 657 | $df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
659 | - $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df); |
|
658 | + $GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\DateTime::to($query['startdate'] + 12 * 60 * 60, $df); |
|
660 | 659 | if ($start != $end) |
661 | 660 | { |
662 | - $GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate']+12*60*60:'now', $df); |
|
661 | + $GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate'] + 12 * 60 * 60 : 'now', $df); |
|
663 | 662 | } |
664 | 663 | } |
665 | 664 | } |
666 | 665 | // Update start / end dates for custom |
667 | - if($query_in['filter'] != 'custom') |
|
666 | + if ($query_in['filter'] != 'custom') |
|
668 | 667 | { |
669 | 668 | Api\Json\Response::get()->call( |
670 | 669 | 'app.timesheet.update_timespan', |
671 | - Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2), |
|
670 | + Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now', Api\DateTime::ET2), |
|
672 | 671 | $query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null |
673 | 672 | ); |
674 | 673 | } |
675 | - $total = parent::get_rows($query,$rows,$readonlys); |
|
674 | + $total = parent::get_rows($query, $rows, $readonlys); |
|
676 | 675 | |
677 | 676 | $ids = array(); |
678 | - foreach($rows as &$row) |
|
677 | + foreach ($rows as &$row) |
|
679 | 678 | { |
680 | 679 | if ($row['ts_id'] > 0) $ids[] = $row['ts_id']; |
681 | 680 | } |
682 | 681 | if ($id_only) |
683 | 682 | { |
684 | 683 | $rows = $ids; |
685 | - return $this->total; // no need to set other fields or $readonlys |
|
684 | + return $this->total; // no need to set other fields or $readonlys |
|
686 | 685 | } |
687 | 686 | $links = array(); |
688 | - $links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager'); // only check for pm links! |
|
687 | + $links3 = Link::get_links_multiple(TIMESHEET_APP, $ids, true, 'projectmanager'); // only check for pm links! |
|
689 | 688 | //as the full array is expected, we must supply the missing but needed (since expected further down) information |
690 | 689 | if (is_array($links3)) |
691 | 690 | { |
@@ -705,14 +704,14 @@ discard block |
||
705 | 704 | |
706 | 705 | $readonlys = array(); |
707 | 706 | $have_cats = false; |
708 | - foreach($rows as &$row) |
|
707 | + foreach ($rows as &$row) |
|
709 | 708 | { |
710 | 709 | if ($row['cat_id']) $have_cats = true; |
711 | 710 | |
712 | 711 | $row['class'] = 'row'; |
713 | 712 | if ($row['ts_id'] <= 0) // sums |
714 | 713 | { |
715 | - if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change |
|
714 | + if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change |
|
716 | 715 | |
717 | 716 | // Remove fake modified date, it breaks nextmatch checks |
718 | 717 | unset($row['ts_modified']); |
@@ -720,22 +719,22 @@ discard block |
||
720 | 719 | // Set flag to avoid actions on these rows |
721 | 720 | $row['no_actions'] = true; |
722 | 721 | |
723 | - switch($row['ts_id']) |
|
722 | + switch ($row['ts_id']) |
|
724 | 723 | { |
725 | 724 | case 0: // day-sum |
726 | - $row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'])); |
|
725 | + $row['ts_title'] = lang('Sum %1:', lang(date('l', $row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'])); |
|
727 | 726 | $row['ts_id'] = 'sum-day-'.$row['ts_start']; |
728 | 727 | break; |
729 | 728 | case -1: // week-sum |
730 | - $row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4)); |
|
729 | + $row['ts_title'] = lang('Sum %1:', lang('week').' '.substr($row['ts_week'], 4).'/'.substr($row['ts_week'], 0, 4)); |
|
731 | 730 | $row['ts_id'] = 'sum-week-'.$row['ts_week']; |
732 | 731 | break; |
733 | 732 | case -2: // month-sum |
734 | - $row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4)); |
|
733 | + $row['ts_title'] = lang('Sum %1:', lang(date('F', $row['ts_start'])).' '.substr($row['ts_month'], 0, 4)); |
|
735 | 734 | $row['ts_id'] = 'sum-month-'.$row['ts_month']; |
736 | 735 | break; |
737 | 736 | case -3: // year-sum |
738 | - $row['ts_title'] = lang('Sum %1:',$row['ts_year']); |
|
737 | + $row['ts_title'] = lang('Sum %1:', $row['ts_year']); |
|
739 | 738 | $row['ts_id'] = 'sum-year-'.$row['ts_year']; |
740 | 739 | break; |
741 | 740 | } |
@@ -745,11 +744,11 @@ discard block |
||
745 | 744 | $row['titleClass'] = 'timesheet_titleSum'; |
746 | 745 | continue; |
747 | 746 | } |
748 | - if($row['ts_quantity']) |
|
747 | + if ($row['ts_quantity']) |
|
749 | 748 | { |
750 | 749 | $row['ts_quantity'] = round($row['ts_quantity'], 2); |
751 | 750 | } |
752 | - if (!$this->check_acl(Acl::EDIT,$row)) |
|
751 | + if (!$this->check_acl(Acl::EDIT, $row)) |
|
753 | 752 | { |
754 | 753 | $row['class'] .= ' rowNoEdit '; |
755 | 754 | } |
@@ -757,21 +756,21 @@ discard block |
||
757 | 756 | { |
758 | 757 | $row['class'] .= ' rowNoEdit '; |
759 | 758 | } |
760 | - if (!$this->check_acl(Acl::DELETE,$row)) |
|
759 | + if (!$this->check_acl(Acl::DELETE, $row)) |
|
761 | 760 | { |
762 | 761 | $row['class'] .= ' rowNoDelete '; |
763 | 762 | } |
764 | - if($row['ts_status'] != self::DELETED_STATUS) |
|
763 | + if ($row['ts_status'] != self::DELETED_STATUS) |
|
765 | 764 | { |
766 | 765 | $row['class'] .= ' rowNoUndelete '; |
767 | 766 | } |
768 | 767 | if ($query['col_filter']['ts_project']) |
769 | 768 | { |
770 | - unset($row['ts_project']); // dont need or want to show it |
|
769 | + unset($row['ts_project']); // dont need or want to show it |
|
771 | 770 | } |
772 | 771 | elseif ($links[$row['ts_id']]) |
773 | 772 | { |
774 | - foreach($links[$row['ts_id']] as $link) |
|
773 | + foreach ($links[$row['ts_id']] as $link) |
|
775 | 774 | { |
776 | 775 | if ($link['app'] == 'projectmanager') |
777 | 776 | { |
@@ -782,28 +781,28 @@ discard block |
||
782 | 781 | } |
783 | 782 | } |
784 | 783 | |
785 | - if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails'; |
|
784 | + if (!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails'; |
|
786 | 785 | |
787 | 786 | } |
788 | 787 | $rows['no_cat_id'] = (!$have_cats || $query['cat_id']); |
789 | 788 | if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint'; |
790 | 789 | $rows['no_owner_col'] = $query['no_owner_col']; |
791 | - if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1; |
|
790 | + if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'], 'ts_owner')) $rows['no_owner_col'] = 1; |
|
792 | 791 | |
793 | 792 | $rows += $this->summary; |
794 | 793 | |
795 | 794 | $rows['pm_integration'] = $this->pm_integration; |
796 | - $rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short'; |
|
795 | + $rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short'; |
|
797 | 796 | if (!$rows['ts_viewtype']) |
798 | 797 | { |
799 | 798 | #_debug_array($query['selectcols']); |
800 | - if(!is_array($query['selectcols'])){ |
|
801 | - $query['selectcols'] = explode(',',$query['selectcols']); |
|
799 | + if (!is_array($query['selectcols'])) { |
|
800 | + $query['selectcols'] = explode(',', $query['selectcols']); |
|
802 | 801 | } |
803 | 802 | #ts_quantity,ts_unitprice,ts_total |
804 | - if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1; |
|
805 | - if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1; |
|
806 | - if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1; |
|
803 | + if ($query['selectcols'] && in_array('ts_quantity_quantity', $query['selectcols']) === false) $rows['no_ts_quantity'] = 1; |
|
804 | + if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols']) === false) $rows['no_ts_unitprice'] = 1; |
|
805 | + if ($query['selectcols'] && in_array('ts_total_price', $query['selectcols']) === false) $rows['no_ts_total'] = 1; |
|
807 | 806 | } |
808 | 807 | $rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] || |
809 | 808 | $query['no_status']; |
@@ -822,7 +821,7 @@ discard block |
||
822 | 821 | * @param array $content |
823 | 822 | * @param string $msg |
824 | 823 | */ |
825 | - function index($content = null,$msg='') |
|
824 | + function index($content = null, $msg = '') |
|
826 | 825 | { |
827 | 826 | $etpl = new Etemplate('timesheet.index'); |
828 | 827 | |
@@ -859,14 +858,14 @@ discard block |
||
859 | 858 | else |
860 | 859 | { |
861 | 860 | $success = $failed = $action_msg = null; |
862 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
863 | - $success,$failed,$action_msg,'index',$msg)) |
|
861 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
862 | + $success, $failed, $action_msg, 'index', $msg)) |
|
864 | 863 | { |
865 | - $msg .= lang('%1 timesheets(s) %2',$success,$action_msg); |
|
864 | + $msg .= lang('%1 timesheets(s) %2', $success, $action_msg); |
|
866 | 865 | } |
867 | - elseif(empty($msg)) |
|
866 | + elseif (empty($msg)) |
|
868 | 867 | { |
869 | - $msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
868 | + $msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
870 | 869 | } |
871 | 870 | } |
872 | 871 | } |
@@ -878,7 +877,7 @@ discard block |
||
878 | 877 | if (!is_array($content['nm'])) |
879 | 878 | { |
880 | 879 | $date_filters = array('All'); |
881 | - foreach(array_keys($this->date_filters) as $name) |
|
880 | + foreach (array_keys($this->date_filters) as $name) |
|
882 | 881 | { |
883 | 882 | $date_filters[$name] = $name; |
884 | 883 | } |
@@ -887,23 +886,23 @@ discard block |
||
887 | 886 | $content['nm'] = array( |
888 | 887 | 'get_rows' => TIMESHEET_APP.'.timesheet_ui.get_rows', |
889 | 888 | 'options-filter' => $date_filters, |
890 | - 'options-filter2' => array('No details','Details'), |
|
891 | - 'order' => 'ts_start',// IO name of the column to sort after (optional for the sortheaders) |
|
892 | - 'sort' => 'DESC',// IO direction of the sort: 'ASC' or 'DESC' |
|
889 | + 'options-filter2' => array('No details', 'Details'), |
|
890 | + 'order' => 'ts_start', // IO name of the column to sort after (optional for the sortheaders) |
|
891 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
893 | 892 | 'filter_onchange' => "app.timesheet.filter_change();", |
894 | 893 | 'filter2_onchange' => "app.timesheet.filter2_change();", |
895 | 894 | 'filter2' => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'], |
896 | 895 | 'row_id' => 'ts_id', |
897 | 896 | 'row_modified' => 'ts_modified', |
898 | 897 | //'actions' => $this->get_actions(), |
899 | - 'default_cols' => '!legacy_actions', // switch legacy actions column and row off by default |
|
898 | + 'default_cols' => '!legacy_actions', // switch legacy actions column and row off by default |
|
900 | 899 | 'pm_integration' => $this->pm_integration, |
901 | 900 | 'placeholder_actions' => array('add') |
902 | 901 | ); |
903 | 902 | } |
904 | 903 | $content['nm']['actions'] = $this->get_actions($content['nm']); |
905 | 904 | |
906 | - if($_GET['search']) |
|
905 | + if ($_GET['search']) |
|
907 | 906 | { |
908 | 907 | $content['nm']['search'] = $_GET['search']; |
909 | 908 | } |
@@ -914,25 +913,25 @@ discard block |
||
914 | 913 | 'ts_owner' => $read_grants, |
915 | 914 | 'pm_id' => array(lang('No project')), |
916 | 915 | 'cat_id' => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label'=>lang('None'))), |
917 | - 'ts_status' => $this->status_labels+array(lang('No status')), |
|
916 | + 'ts_status' => $this->status_labels + array(lang('No status')), |
|
918 | 917 | ); |
919 | - if($this->config_data['history']) |
|
918 | + if ($this->config_data['history']) |
|
920 | 919 | { |
921 | 920 | $sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted'; |
922 | 921 | } |
923 | - $content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status' |
|
924 | - $content['nm']['favorites'] = true; //Enable favorite |
|
922 | + $content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status' |
|
923 | + $content['nm']['favorites'] = true; //Enable favorite |
|
925 | 924 | |
926 | 925 | if ($this->pm_integration != 'full') |
927 | 926 | { |
928 | - $projects =& $this->query_list('ts_project'); |
|
927 | + $projects = & $this->query_list('ts_project'); |
|
929 | 928 | if (!is_array($projects)) $projects = array(); |
930 | 929 | $sel_options['ts_project'] = $projects + array(lang('No project')); |
931 | 930 | } |
932 | 931 | |
933 | 932 | // dont show [Export] button if app is not availible to the user or we are on php4 |
934 | - $readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5; |
|
935 | - return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys); |
|
933 | + $readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int)phpversion() < 5; |
|
934 | + return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index', $content, $sel_options, $readonlys); |
|
936 | 935 | } |
937 | 936 | |
938 | 937 | /** |
@@ -951,9 +950,9 @@ discard block |
||
951 | 950 | 'allowOnMultiple' => false, |
952 | 951 | 'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id', |
953 | 952 | 'popup' => Link::get_registry('timesheet', 'add_popup'), |
954 | - 'group' => $group=1, |
|
953 | + 'group' => $group = 1, |
|
955 | 954 | 'disableClass' => 'th', |
956 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':'', |
|
955 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.timesheet.viewEntry' : '', |
|
957 | 956 | 'mobileViewTemplate' => 'edit?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/edit.xet')) |
958 | 957 | ), |
959 | 958 | /* |
@@ -981,7 +980,7 @@ discard block |
||
981 | 980 | 'group' => $group, |
982 | 981 | ), |
983 | 982 | 'cat' => Etemplate\Widget\Nextmatch::category_action( |
984 | - 'timesheet',++$group,'Change category','cat_' |
|
983 | + 'timesheet', ++$group, 'Change category', 'cat_' |
|
985 | 984 | ), |
986 | 985 | 'status' => array( |
987 | 986 | 'icon' => 'apply', |
@@ -1033,7 +1032,7 @@ discard block |
||
1033 | 1032 | ); |
1034 | 1033 | } |
1035 | 1034 | // enable additonal edit check for following actions, if they are generally available |
1036 | - foreach(array('cat','status') as $action) |
|
1035 | + foreach (array('cat', 'status') as $action) |
|
1037 | 1036 | { |
1038 | 1037 | if ($actions[$action]['enabled']) |
1039 | 1038 | { |
@@ -1056,7 +1055,7 @@ discard block |
||
1056 | 1055 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
1057 | 1056 | * @return boolean true if all actions succeded, false otherwise |
1058 | 1057 | */ |
1059 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
1058 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
1060 | 1059 | { |
1061 | 1060 | $success = $failed = 0; |
1062 | 1061 | if ($use_all) |
@@ -1066,17 +1065,17 @@ discard block |
||
1066 | 1065 | |
1067 | 1066 | if ($use_all) |
1068 | 1067 | { |
1069 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1070 | - $query['num_rows'] = -1; // all |
|
1068 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1069 | + $query['num_rows'] = -1; // all |
|
1071 | 1070 | $readonlys = null; |
1072 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
1071 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
1073 | 1072 | } |
1074 | 1073 | } |
1075 | 1074 | //error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')"); |
1076 | 1075 | |
1077 | - if (substr($action,0,9) == 'to_status') |
|
1076 | + if (substr($action, 0, 9) == 'to_status') |
|
1078 | 1077 | { |
1079 | - $to_status = (int)substr($action,10); |
|
1078 | + $to_status = (int)substr($action, 10); |
|
1080 | 1079 | $action = 'to_status'; |
1081 | 1080 | } |
1082 | 1081 | else |
@@ -1085,11 +1084,11 @@ discard block |
||
1085 | 1084 | list($action, $settings) = explode('_', $action, 2); |
1086 | 1085 | } |
1087 | 1086 | |
1088 | - switch($action) |
|
1087 | + switch ($action) |
|
1089 | 1088 | { |
1090 | 1089 | case 'delete': |
1091 | 1090 | $action_msg = lang('deleted'); |
1092 | - foreach((array)$checked as $n => $id) |
|
1091 | + foreach ((array)$checked as $n => $id) |
|
1093 | 1092 | { |
1094 | 1093 | if ($this->delete($id)) |
1095 | 1094 | { |
@@ -1102,10 +1101,10 @@ discard block |
||
1102 | 1101 | } |
1103 | 1102 | break; |
1104 | 1103 | case 'undelete': |
1105 | - $action_msg =lang('recovered'); |
|
1106 | - foreach((array)$checked as $n => $id) |
|
1104 | + $action_msg = lang('recovered'); |
|
1105 | + foreach ((array)$checked as $n => $id) |
|
1107 | 1106 | { |
1108 | - if ($this->set_status($id,'')) |
|
1107 | + if ($this->set_status($id, '')) |
|
1109 | 1108 | { |
1110 | 1109 | $success++; |
1111 | 1110 | } |
@@ -1116,10 +1115,10 @@ discard block |
||
1116 | 1115 | } |
1117 | 1116 | break; |
1118 | 1117 | case 'to_status': |
1119 | - $action_msg =lang('changed status'); |
|
1120 | - foreach((array)$checked as $n => $id) |
|
1118 | + $action_msg = lang('changed status'); |
|
1119 | + foreach ((array)$checked as $n => $id) |
|
1121 | 1120 | { |
1122 | - if ($this->set_status($id,$to_status)) |
|
1121 | + if ($this->set_status($id, $to_status)) |
|
1123 | 1122 | { |
1124 | 1123 | $success++; |
1125 | 1124 | } |
@@ -1132,10 +1131,10 @@ discard block |
||
1132 | 1131 | case 'cat': |
1133 | 1132 | $cat_name = Api\Categories::id2name($settings); |
1134 | 1133 | $action_msg = lang('changed category to %1', $cat_name); |
1135 | - foreach((array)$checked as $n => $id) { |
|
1134 | + foreach ((array)$checked as $n => $id) { |
|
1136 | 1135 | $entry = $this->read($id); |
1137 | 1136 | $entry['cat_id'] = $settings; |
1138 | - if($this->save($entry) == 0) |
|
1137 | + if ($this->save($entry) == 0) |
|
1139 | 1138 | { |
1140 | 1139 | $success++; |
1141 | 1140 | } |
@@ -1163,7 +1162,7 @@ discard block |
||
1163 | 1162 | * @param conetnt |
1164 | 1163 | * @param view |
1165 | 1164 | */ |
1166 | - function editstatus($content = null,$msg='') |
|
1165 | + function editstatus($content = null, $msg = '') |
|
1167 | 1166 | { |
1168 | 1167 | // this function requires admin rights |
1169 | 1168 | $GLOBALS['egw_info']['flags']['admin_only'] = true; |
@@ -1174,13 +1173,13 @@ discard block |
||
1174 | 1173 | list($button) = @each($content['button']); |
1175 | 1174 | unset ($content['button']); |
1176 | 1175 | |
1177 | - switch($button) |
|
1176 | + switch ($button) |
|
1178 | 1177 | { |
1179 | 1178 | case 'delete': |
1180 | 1179 | break; |
1181 | 1180 | case 'apply': |
1182 | 1181 | case 'save': |
1183 | - foreach($content['statis'] as &$cat) |
|
1182 | + foreach ($content['statis'] as &$cat) |
|
1184 | 1183 | { |
1185 | 1184 | $id = $cat['id']; |
1186 | 1185 | if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== '')) |
@@ -1194,7 +1193,7 @@ discard block |
||
1194 | 1193 | } |
1195 | 1194 | if ($need_update) |
1196 | 1195 | { |
1197 | - Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP); |
|
1196 | + Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP); |
|
1198 | 1197 | $this->config_data = Api\Config::read(TIMESHEET_APP); |
1199 | 1198 | $this->load_statuses(); |
1200 | 1199 | $msg .= lang('Status updated.'); |
@@ -1211,7 +1210,7 @@ discard block |
||
1211 | 1210 | if (isset($this->status_labels_config[$id])) |
1212 | 1211 | { |
1213 | 1212 | unset($this->status_labels_config[$id]); |
1214 | - Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP); |
|
1213 | + Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP); |
|
1215 | 1214 | unset($this->status_labels[$id]); |
1216 | 1215 | $msg .= lang('Status deleted.'); |
1217 | 1216 | } |
@@ -1220,12 +1219,12 @@ discard block |
||
1220 | 1219 | $i = 1; |
1221 | 1220 | $max_id = 0; |
1222 | 1221 | unset($content['statis']); |
1223 | - foreach($this->status_labels_config as $id => $label) |
|
1222 | + foreach ($this->status_labels_config as $id => $label) |
|
1224 | 1223 | { |
1225 | - $content['statis'][$i]['name']= $label['name']; |
|
1226 | - $content['statis'][$i]['id']= $id; |
|
1227 | - $content['statis'][$i]['parent']= $label['parent']; |
|
1228 | - $content['statis'][$i]['admin']= $label['admin']; |
|
1224 | + $content['statis'][$i]['name'] = $label['name']; |
|
1225 | + $content['statis'][$i]['id'] = $id; |
|
1226 | + $content['statis'][$i]['parent'] = $label['parent']; |
|
1227 | + $content['statis'][$i]['admin'] = $label['admin']; |
|
1229 | 1228 | $i++; |
1230 | 1229 | $max_id = max($id, $max_id); |
1231 | 1230 | } |
@@ -1237,6 +1236,6 @@ discard block |
||
1237 | 1236 | $preserv = $content; |
1238 | 1237 | $sel_options['parent'] = $this->status_labels; |
1239 | 1238 | $etpl = new Etemplate('timesheet.editstatus'); |
1240 | - $etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv); |
|
1239 | + $etpl->exec('timesheet.timesheet_ui.editstatus', $content, $sel_options, array(), $preserv); |
|
1241 | 1240 | } |
1242 | 1241 | } |
@@ -63,7 +63,10 @@ discard block |
||
63 | 63 | $etpl = new Etemplate('timesheet.edit'); |
64 | 64 | if (!is_array($content)) |
65 | 65 | { |
66 | - if ($_GET['msg']) $msg = strip_tags($_GET['msg']); |
|
66 | + if ($_GET['msg']) |
|
67 | + { |
|
68 | + $msg = strip_tags($_GET['msg']); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | if ($view || (int)$_GET['ts_id']) |
69 | 72 | { |
@@ -116,23 +119,32 @@ discard block |
||
116 | 119 | $content['ts_description'] = $content['ts_description_short']; |
117 | 120 | } |
118 | 121 | // we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!) |
119 | - if (isset($content['start_time'])) // start-time specified |
|
122 | + if (isset($content['start_time'])) |
|
123 | + { |
|
124 | + // start-time specified |
|
120 | 125 | { |
121 | 126 | //$content['ts_start'] += $content['start_time']; |
122 | 127 | $start = new Api\DateTime($content['ts_start']); |
128 | + } |
|
123 | 129 | $start_time = explode(':',$content['start_time']); |
124 | 130 | $start->setTime($start_time[0],$start_time[1]); |
125 | 131 | $content['ts_start'] = $start->format('ts'); |
126 | 132 | } |
127 | - if (isset($content['end_time'])) // end-time specified |
|
133 | + if (isset($content['end_time'])) |
|
134 | + { |
|
135 | + // end-time specified |
|
128 | 136 | { |
129 | 137 | $end = new Api\DateTime($content['ts_start']); |
138 | + } |
|
130 | 139 | $end_time = explode(':',$content['end_time']); |
131 | 140 | $end->setTime($end_time[0],$end_time[1]); |
132 | 141 | } |
133 | - if ($end && $start) // start- & end-time --> calculate the duration |
|
142 | + if ($end && $start) |
|
143 | + { |
|
144 | + // start- & end-time --> calculate the duration |
|
134 | 145 | { |
135 | 146 | $content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60; |
147 | + } |
|
136 | 148 | // check if negative duration is caused by wrap over midnight |
137 | 149 | if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60) |
138 | 150 | { |
@@ -140,12 +152,18 @@ discard block |
||
140 | 152 | } |
141 | 153 | //echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n"; |
142 | 154 | } |
143 | - elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration |
|
155 | + elseif ($content['ts_duration'] && $end) |
|
156 | + { |
|
157 | + // no start, calculate from end and duration |
|
144 | 158 | { |
145 | 159 | $content['ts_start'] = $end->format('ts') - 60*$content['ts_duration']; |
160 | + } |
|
146 | 161 | //echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n"; |
147 | 162 | } |
148 | - if ($content['ts_duration'] > 0) unset($content['end_time']); |
|
163 | + if ($content['ts_duration'] > 0) |
|
164 | + { |
|
165 | + unset($content['end_time']); |
|
166 | + } |
|
149 | 167 | // now we only deal with start (date+time) and duration |
150 | 168 | list($button) = @each($content['button']); |
151 | 169 | $view = $content['view']; |
@@ -159,7 +177,10 @@ discard block |
||
159 | 177 | switch($button) |
160 | 178 | { |
161 | 179 | case 'edit': |
162 | - if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false; |
|
180 | + if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) |
|
181 | + { |
|
182 | + $view = false; |
|
183 | + } |
|
163 | 184 | break; |
164 | 185 | |
165 | 186 | case 'undelete': |
@@ -173,12 +194,15 @@ discard block |
||
173 | 194 | case 'save': |
174 | 195 | case 'save_new': |
175 | 196 | case 'apply': |
176 | - if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration']) // set the quantity (in h) from the duration (in min) |
|
197 | + if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration']) |
|
198 | + { |
|
199 | + // set the quantity (in h) from the duration (in min) |
|
177 | 200 | { |
178 | 201 | // We need to keep the actual value of ts_quantity when we are storing it, as it is used in price calculation |
179 | 202 | // and rounding it causes miscalculation on prices |
180 | 203 | $this->data['ts_quantity'] = $this->data['ts_duration'] / 60.0; |
181 | 204 | } |
205 | + } |
|
182 | 206 | if (!$this->data['ts_quantity']) |
183 | 207 | { |
184 | 208 | $etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!')); |
@@ -210,7 +234,11 @@ discard block |
||
210 | 234 | unset($content['ts_project_blur']); |
211 | 235 | } |
212 | 236 | } |
213 | - if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry |
|
237 | + if ($etpl->validation_errors()) |
|
238 | + { |
|
239 | + break; |
|
240 | + } |
|
241 | + // the user need to fix the error, before we can save the entry |
|
214 | 242 | |
215 | 243 | // account for changed project --> remove old one from links and add new one |
216 | 244 | if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id']) |
@@ -254,14 +282,20 @@ discard block |
||
254 | 282 | } |
255 | 283 | } |
256 | 284 | Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add'); |
257 | - if ($button == 'apply') break; |
|
285 | + if ($button == 'apply') |
|
286 | + { |
|
287 | + break; |
|
288 | + } |
|
258 | 289 | if ($button == 'save_new') |
259 | 290 | { |
260 | 291 | $msg .= ', '.lang('creating new entry'); // giving some feedback to the user |
261 | 292 | |
262 | - if (!is_array($content['link_to']['to_id'])) // set links again, so new entry gets the same links as the existing one |
|
293 | + if (!is_array($content['link_to']['to_id'])) |
|
294 | + { |
|
295 | + // set links again, so new entry gets the same links as the existing one |
|
263 | 296 | { |
264 | 297 | $content['link_to']['to_id'] = 0; |
298 | + } |
|
265 | 299 | foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link) |
266 | 300 | { |
267 | 301 | Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']); |
@@ -324,12 +358,15 @@ discard block |
||
324 | 358 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
325 | 359 | { |
326 | 360 | $link_id = $link_ids[$n]; |
327 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
361 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
362 | + { |
|
363 | + // gard against XSS |
|
328 | 364 | { |
329 | 365 | switch ($link_app) |
330 | 366 | { |
331 | 367 | case 'projectmanager': |
332 | 368 | $links[] = $link_id; |
369 | + } |
|
333 | 370 | // fall-through; |
334 | 371 | default: |
335 | 372 | if(!$n) |
@@ -341,8 +378,14 @@ discard block |
||
341 | 378 | { |
342 | 379 | foreach((array)$set['link_app'] as $i => $l_app) |
343 | 380 | { |
344 | - if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id); |
|
345 | - if ($l_app == 'projectmanager') $links[] = $l_id; |
|
381 | + if (($l_id=$set['link_id'][$i])) |
|
382 | + { |
|
383 | + Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id); |
|
384 | + } |
|
385 | + if ($l_app == 'projectmanager') |
|
386 | + { |
|
387 | + $links[] = $l_id; |
|
388 | + } |
|
346 | 389 | } |
347 | 390 | unset($set['link_app']); |
348 | 391 | unset($set['link_id']); |
@@ -438,8 +481,16 @@ discard block |
||
438 | 481 | $content['ts_viewtype'] = $readonlys['tabs']['notes'] = true; |
439 | 482 | $content['ts_description_short'] = $content['ts_description']; |
440 | 483 | } |
441 | - if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields |
|
442 | - if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID |
|
484 | + if (!$this->customfields) |
|
485 | + { |
|
486 | + $readonlys['tabs']['customfields'] = true; |
|
487 | + } |
|
488 | + // suppress tab if there are not customfields |
|
489 | + if (!$this->data['ts_id']) |
|
490 | + { |
|
491 | + $readonlys['tabs']['history'] = true; |
|
492 | + } |
|
493 | + //suppress history for the first loading without ID |
|
443 | 494 | |
444 | 495 | return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2); |
445 | 496 | } |
@@ -452,7 +503,10 @@ discard block |
||
452 | 503 | */ |
453 | 504 | function datetime2time($datetime) |
454 | 505 | { |
455 | - if (!$datetime) return 0; |
|
506 | + if (!$datetime) |
|
507 | + { |
|
508 | + return 0; |
|
509 | + } |
|
456 | 510 | |
457 | 511 | return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime)); |
458 | 512 | } |
@@ -497,7 +551,10 @@ discard block |
||
497 | 551 | } |
498 | 552 | // show week-sums, if we are week-aligned (show full weeks)? |
499 | 553 | $week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']; |
500 | - if (!$week_start_day) $week_start_day = 'Sunday'; |
|
554 | + if (!$week_start_day) |
|
555 | + { |
|
556 | + $week_start_day = 'Sunday'; |
|
557 | + } |
|
501 | 558 | switch($week_start_day) |
502 | 559 | { |
503 | 560 | case 'Sunday': $week_end_day = 'Saturday'; break; |
@@ -518,7 +575,10 @@ discard block |
||
518 | 575 | } |
519 | 576 | } |
520 | 577 | //echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n"; |
521 | - if (!$id_only && !$query_in['csv_export']) Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in); |
|
578 | + if (!$id_only && !$query_in['csv_export']) |
|
579 | + { |
|
580 | + Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in); |
|
581 | + } |
|
522 | 582 | |
523 | 583 | // Refresh actions (undelete needs this) |
524 | 584 | $query_in['actions'] = $this->get_actions($query_in); |
@@ -526,8 +586,14 @@ discard block |
||
526 | 586 | $query = $query_in; // keep the original query |
527 | 587 | $query['enddate'] = $end_date; |
528 | 588 | |
529 | - if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false); |
|
530 | - if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false; |
|
589 | + if($this->ts_viewtype == 'short') |
|
590 | + { |
|
591 | + $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false); |
|
592 | + } |
|
593 | + if ($query['no_status']) |
|
594 | + { |
|
595 | + $query_in['options-selectcols']['ts_status'] = false; |
|
596 | + } |
|
531 | 597 | |
532 | 598 | //_debug_array($query['col_filter']); |
533 | 599 | //echo "PM Integration:".$this->pm_integration.'<br>'; |
@@ -540,8 +606,14 @@ discard block |
||
540 | 606 | { |
541 | 607 | //$query['col_filter']['ts_id'] = Link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet'); |
542 | 608 | $query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']); |
543 | - if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1; |
|
544 | - if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0; |
|
609 | + if (empty($query['col_filter']['ts_id'])) |
|
610 | + { |
|
611 | + $query['col_filter']['ts_id'] = -1; |
|
612 | + } |
|
613 | + if (!$query['col_filter']['ts_id']) |
|
614 | + { |
|
615 | + $query['col_filter']['ts_id'] = 0; |
|
616 | + } |
|
545 | 617 | } |
546 | 618 | if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] == '0') |
547 | 619 | { |
@@ -605,10 +677,13 @@ discard block |
||
605 | 677 | $cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']); |
606 | 678 | $query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id']; |
607 | 679 | } |
608 | - elseif ((string)$query['cat_id'] == '0') // no category |
|
680 | + elseif ((string)$query['cat_id'] == '0') |
|
681 | + { |
|
682 | + // no category |
|
609 | 683 | { |
610 | 684 | $query['col_filter']['cat_id'] = null; |
611 | 685 | } |
686 | + } |
|
612 | 687 | else // all cats --> no filter |
613 | 688 | { |
614 | 689 | unset($query['col_filter']['cat_id']); |
@@ -619,7 +694,10 @@ discard block |
||
619 | 694 | $GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']); |
620 | 695 | #if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members"); |
621 | 696 | #_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true)); |
622 | - if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true)); |
|
697 | + if ($query['col_filter']['ts_owner']<0) |
|
698 | + { |
|
699 | + $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true)); |
|
700 | + } |
|
623 | 701 | } |
624 | 702 | else |
625 | 703 | { |
@@ -632,10 +710,13 @@ discard block |
||
632 | 710 | // generate a meaningful app-header / report title |
633 | 711 | if ($this->show_sums['month']) |
634 | 712 | { |
635 | - if ((int)$start[1] == 1 && (int) $end[1] == 12) // whole year(s) |
|
713 | + if ((int)$start[1] == 1 && (int) $end[1] == 12) |
|
714 | + { |
|
715 | + // whole year(s) |
|
636 | 716 | { |
637 | 717 | $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : ''); |
638 | 718 | } |
719 | + } |
|
639 | 720 | else |
640 | 721 | { |
641 | 722 | $GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0]; |
@@ -677,7 +758,10 @@ discard block |
||
677 | 758 | $ids = array(); |
678 | 759 | foreach($rows as &$row) |
679 | 760 | { |
680 | - if ($row['ts_id'] > 0) $ids[] = $row['ts_id']; |
|
761 | + if ($row['ts_id'] > 0) |
|
762 | + { |
|
763 | + $ids[] = $row['ts_id']; |
|
764 | + } |
|
681 | 765 | } |
682 | 766 | if ($id_only) |
683 | 767 | { |
@@ -707,12 +791,19 @@ discard block |
||
707 | 791 | $have_cats = false; |
708 | 792 | foreach($rows as &$row) |
709 | 793 | { |
710 | - if ($row['cat_id']) $have_cats = true; |
|
794 | + if ($row['cat_id']) |
|
795 | + { |
|
796 | + $have_cats = true; |
|
797 | + } |
|
711 | 798 | |
712 | 799 | $row['class'] = 'row'; |
713 | - if ($row['ts_id'] <= 0) // sums |
|
800 | + if ($row['ts_id'] <= 0) |
|
714 | 801 | { |
715 | - if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change |
|
802 | + // sums |
|
803 | + { |
|
804 | + if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; |
|
805 | + } |
|
806 | + // fix for DSL change |
|
716 | 807 | |
717 | 808 | // Remove fake modified date, it breaks nextmatch checks |
718 | 809 | unset($row['ts_modified']); |
@@ -740,7 +831,10 @@ discard block |
||
740 | 831 | break; |
741 | 832 | } |
742 | 833 | $row['ts_start'] = $row['ts_unitprice'] = ''; |
743 | - if (!$this->quantity_sum) $row['ts_quantity'] = ''; |
|
834 | + if (!$this->quantity_sum) |
|
835 | + { |
|
836 | + $row['ts_quantity'] = ''; |
|
837 | + } |
|
744 | 838 | $row['class'] = 'th rowNoEdit rowNoDelete rowNoUndelete'; |
745 | 839 | $row['titleClass'] = 'timesheet_titleSum'; |
746 | 840 | continue; |
@@ -782,13 +876,22 @@ discard block |
||
782 | 876 | } |
783 | 877 | } |
784 | 878 | |
785 | - if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails'; |
|
879 | + if(!$row['titleClass']) |
|
880 | + { |
|
881 | + $row['titleClass'] = 'timesheet_titleDetails'; |
|
882 | + } |
|
786 | 883 | |
787 | 884 | } |
788 | 885 | $rows['no_cat_id'] = (!$have_cats || $query['cat_id']); |
789 | - if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint'; |
|
886 | + if ($query['col_filter']['ts_owner']) |
|
887 | + { |
|
888 | + $rows['ownerClass'] = 'noPrint'; |
|
889 | + } |
|
790 | 890 | $rows['no_owner_col'] = $query['no_owner_col']; |
791 | - if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1; |
|
891 | + if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) |
|
892 | + { |
|
893 | + $rows['no_owner_col'] = 1; |
|
894 | + } |
|
792 | 895 | |
793 | 896 | $rows += $this->summary; |
794 | 897 | |
@@ -797,13 +900,23 @@ discard block |
||
797 | 900 | if (!$rows['ts_viewtype']) |
798 | 901 | { |
799 | 902 | #_debug_array($query['selectcols']); |
800 | - if(!is_array($query['selectcols'])){ |
|
903 | + if(!is_array($query['selectcols'])) |
|
904 | + { |
|
801 | 905 | $query['selectcols'] = explode(',',$query['selectcols']); |
802 | 906 | } |
803 | 907 | #ts_quantity,ts_unitprice,ts_total |
804 | - if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1; |
|
805 | - if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1; |
|
806 | - if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1; |
|
908 | + if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) |
|
909 | + { |
|
910 | + $rows['no_ts_quantity'] = 1; |
|
911 | + } |
|
912 | + if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) |
|
913 | + { |
|
914 | + $rows['no_ts_unitprice'] = 1; |
|
915 | + } |
|
916 | + if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) |
|
917 | + { |
|
918 | + $rows['no_ts_total'] = 1; |
|
919 | + } |
|
807 | 920 | } |
808 | 921 | $rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] || |
809 | 922 | $query['no_status']; |
@@ -826,7 +939,10 @@ discard block |
||
826 | 939 | { |
827 | 940 | $etpl = new Etemplate('timesheet.index'); |
828 | 941 | |
829 | - if ($_GET['msg']) $msg = $_GET['msg']; |
|
942 | + if ($_GET['msg']) |
|
943 | + { |
|
944 | + $msg = $_GET['msg']; |
|
945 | + } |
|
830 | 946 | if ($content['nm']['rows']['delete']) |
831 | 947 | { |
832 | 948 | list($ts_id) = each($content['nm']['rows']['delete']); |
@@ -839,9 +955,12 @@ discard block |
||
839 | 955 | $msg = lang('Error deleting the entry!!!'); |
840 | 956 | } |
841 | 957 | } |
842 | - if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
958 | + if (is_array($content) && isset($content['nm']['rows']['document'])) |
|
959 | + { |
|
960 | + // handle insert in default document button like an action |
|
843 | 961 | { |
844 | 962 | list($id) = @each($content['nm']['rows']['document']); |
963 | + } |
|
845 | 964 | $content['nm']['action'] = 'document'; |
846 | 965 | $content['nm']['selected'] = array($id); |
847 | 966 | } |
@@ -909,7 +1028,10 @@ discard block |
||
909 | 1028 | } |
910 | 1029 | $read_grants = $this->grant_list(Acl::READ); |
911 | 1030 | $content['nm']['no_owner_col'] = count($read_grants) == 1; |
912 | - if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']; |
|
1031 | + if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) |
|
1032 | + { |
|
1033 | + $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']; |
|
1034 | + } |
|
913 | 1035 | $sel_options = array( |
914 | 1036 | 'ts_owner' => $read_grants, |
915 | 1037 | 'pm_id' => array(lang('No project')), |
@@ -926,7 +1048,10 @@ discard block |
||
926 | 1048 | if ($this->pm_integration != 'full') |
927 | 1049 | { |
928 | 1050 | $projects =& $this->query_list('ts_project'); |
929 | - if (!is_array($projects)) $projects = array(); |
|
1051 | + if (!is_array($projects)) |
|
1052 | + { |
|
1053 | + $projects = array(); |
|
1054 | + } |
|
930 | 1055 | $sel_options['ts_project'] = $projects + array(lang('No project')); |
931 | 1056 | } |
932 | 1057 | |
@@ -1132,7 +1257,8 @@ discard block |
||
1132 | 1257 | case 'cat': |
1133 | 1258 | $cat_name = Api\Categories::id2name($settings); |
1134 | 1259 | $action_msg = lang('changed category to %1', $cat_name); |
1135 | - foreach((array)$checked as $n => $id) { |
|
1260 | + foreach((array)$checked as $n => $id) |
|
1261 | + { |
|
1136 | 1262 | $entry = $this->read($id); |
1137 | 1263 | $entry['cat_id'] = $settings; |
1138 | 1264 | if($this->save($entry) == 0) |
@@ -1147,7 +1273,10 @@ discard block |
||
1147 | 1273 | break; |
1148 | 1274 | |
1149 | 1275 | case 'document': |
1150 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document']; |
|
1276 | + if (!$settings) |
|
1277 | + { |
|
1278 | + $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document']; |
|
1279 | + } |
|
1151 | 1280 | $document_merge = new timesheet_merge(); |
1152 | 1281 | $msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']); |
1153 | 1282 | $failed = count($checked); |
@@ -1199,7 +1328,10 @@ discard block |
||
1199 | 1328 | $this->load_statuses(); |
1200 | 1329 | $msg .= lang('Status updated.'); |
1201 | 1330 | } |
1202 | - if ($button == 'apply') break; |
|
1331 | + if ($button == 'apply') |
|
1332 | + { |
|
1333 | + break; |
|
1334 | + } |
|
1203 | 1335 | // fall-through |
1204 | 1336 | case 'cancel': |
1205 | 1337 | $GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin'); |
@@ -942,7 +942,7 @@ |
||
942 | 942 | * |
943 | 943 | * @return array see nextmatch_widget::egw_actions() |
944 | 944 | */ |
945 | - public function get_actions(Array $query) |
|
945 | + public function get_actions(array $query) |
|
946 | 946 | { |
947 | 947 | $actions = array( |
948 | 948 | 'open' => array( // does edit if allowed, otherwise view |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * Create a session or if the user has no account return authenticate header and 401 Unauthorized |
32 | 32 | * |
33 | 33 | * @param array &$account |
34 | - * @return int session-id |
|
34 | + * @return string session-id |
|
35 | 35 | */ |
36 | 36 | function check_access(&$account) |
37 | 37 | { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | if (isset($_GET['auth'])) |
39 | 39 | { |
40 | - list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2); |
|
40 | + list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2); |
|
41 | 41 | } |
42 | 42 | return Api\Header\Authenticate::autocreate_session_callback($account); |
43 | 43 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | 'noheader' => True, |
49 | 49 | 'currentapp' => preg_match('|/webdav.php/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager', |
50 | 50 | 'autocreate_session_callback' => 'check_access', |
51 | - 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
52 | - 'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup! |
|
51 | + 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
52 | + 'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup! |
|
53 | 53 | ) |
54 | 54 | ); |
55 | 55 |