@@ -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) |
@@ -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 |
@@ -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' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/view.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,7 +1131,7 @@ 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 | if (($entry = $this->read($id)) && |
1137 | 1136 | ($entry['cat_id'] = $settings) && |
1138 | 1137 | $this->save($entry) == 0) |
@@ -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 | } |
@@ -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 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | 'name' => 'Ralf Becker', |
21 | 21 | 'email' => '[email protected]' |
22 | 22 | ); |
23 | -$setup_info['filemanager']['license'] = 'GPL'; |
|
23 | +$setup_info['filemanager']['license'] = 'GPL'; |
|
24 | 24 | |
25 | 25 | /* The hooks this app includes, needed for hooks registration */ |
26 | 26 | $setup_info['filemanager']['hooks']['settings'] = 'filemanager_hooks::settings'; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @param array $content=null |
79 | 79 | * @param string $msg='' |
80 | 80 | */ |
81 | - public function index(array $content=null, $msg='', $msg_type=null) |
|
81 | + public function index(array $content = null, $msg = '', $msg_type = null) |
|
82 | 82 | { |
83 | 83 | if (is_array($content)) |
84 | 84 | { |
85 | 85 | //_debug_array($content); |
86 | 86 | if ($content['sudo']) |
87 | 87 | { |
88 | - $msg = $this->sudo($content['user'],$content['password'],self::$is_setup) ? |
|
88 | + $msg = $this->sudo($content['user'], $content['password'], self::$is_setup) ? |
|
89 | 89 | lang('Root access granted.') : lang('Wrong username or password!'); |
90 | 90 | $msg_type = Vfs::$is_root ? 'success' : 'error'; |
91 | 91 | } |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | $backup = Vfs::$is_root; |
97 | 97 | Vfs::$is_root = true; |
98 | 98 | $msg = Vfs::mount($url, $path) ? |
99 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
99 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
100 | 100 | Vfs::$is_root = $backup; |
101 | 101 | } |
102 | 102 | elseif (Vfs::$is_root) |
103 | 103 | { |
104 | 104 | if ($content['logout']) |
105 | 105 | { |
106 | - $msg = $this->sudo('','',self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
106 | + $msg = $this->sudo('', '', self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
107 | 107 | $msg_type = !Vfs::$is_root ? 'success' : 'error'; |
108 | 108 | } |
109 | 109 | if ($content['mounts']['disable'] || self::$is_setup && $content['mounts']['umount']) |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | if (!in_array($path, self::$protected_path) && $path != '/') |
120 | 120 | { |
121 | 121 | $msg = Vfs::umount($path) ? |
122 | - lang('%1 successful unmounted.',$path) : lang('Error unmounting %1!',$path); |
|
122 | + lang('%1 successful unmounted.', $path) : lang('Error unmounting %1!', $path); |
|
123 | 123 | } |
124 | 124 | else // re-mount / with sqlFS, to disable versioning |
125 | 125 | { |
126 | - $msg = Vfs::mount($url=Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path,$path) ? |
|
127 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
126 | + $msg = Vfs::mount($url = Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path, $path) ? |
|
127 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | if (($path = $content['mounts']['path']) && |
131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
132 | 132 | { |
133 | - $url = str_replace('$path',$path,$content['mounts']['url']); |
|
133 | + $url = str_replace('$path', $path, $content['mounts']['url']); |
|
134 | 134 | if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
135 | 135 | |
136 | 136 | if ($content['mounts']['enable'] && !$this->versioning) |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | elseif (!Vfs::file_exists($path) || !Vfs::is_dir($path)) |
142 | 142 | { |
143 | - $msg = lang('Path %1 not found or not a directory!',$path); |
|
143 | + $msg = lang('Path %1 not found or not a directory!', $path); |
|
144 | 144 | $msg_type = 'error'; |
145 | 145 | } |
146 | 146 | // dont allow to change mount of /apps or /templates (eg. switching on versioning) |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - $msg = Vfs::mount($url,$path) ? |
|
155 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
154 | + $msg = Vfs::mount($url, $path) ? |
|
155 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | if ($content['allow_delete_versions'] != $GLOBALS['egw_info']['server']['allow_delete_versions']) |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | 'hidden' => true, |
198 | 198 | 'depth' => true, |
199 | 199 | 'path_preg' => '#/\.(attic|versions)/#', |
200 | - )+(!(int)$content['mtime'] ? array() : array( |
|
201 | - 'mtime' => ($content['mtime']<0?'-':'+').(int)$content['mtime'], |
|
200 | + ) + (!(int)$content['mtime'] ? array() : array( |
|
201 | + 'mtime' => ($content['mtime'] < 0 ? '-' : '+').(int)$content['mtime'], |
|
202 | 202 | )), function($path) use (&$deleted, &$errors) |
203 | 203 | { |
204 | 204 | if (($is_dir = Vfs::is_dir($path)) && Vfs::rmdir($path) || |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | }); |
214 | 214 | } |
215 | - $time = number_format(microtime(true)-$starttime, 1); |
|
215 | + $time = number_format(microtime(true) - $starttime, 1); |
|
216 | 216 | $msg = ($errors ? lang('%1 errors deleting!', $errors)."\n\n" : ''). |
217 | 217 | lang('%1 files or directories deleted in %2 seconds.', $deleted, $time); |
218 | 218 | $msg_type = $errors ? 'error' : 'info'; |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | { |
236 | 236 | // statistical information |
237 | 237 | $content += Versioning\StreamWrapper::summary(); |
238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
238 | + if ($content['total_files']) $content['percent_files'] = number_format(100.0 * $content['version_files'] / $content['total_files'], 1).'%'; |
|
239 | + if ($content['total_size']) $content['percent_size'] = number_format(100.0 * $content['version_size'] / $content['total_size'], 1).'%'; |
|
240 | 240 | } |
241 | - if (!($content['is_root']=Vfs::$is_root)) |
|
241 | + if (!($content['is_root'] = Vfs::$is_root)) |
|
242 | 242 | { |
243 | 243 | if (empty($msg)) |
244 | 244 | { |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | |
255 | 255 | $n = 2; |
256 | 256 | $content['mounts'] = array(); |
257 | - foreach(Vfs::mount() as $path => $url) |
|
257 | + foreach (Vfs::mount() as $path => $url) |
|
258 | 258 | { |
259 | 259 | $content['mounts'][$n++] = array( |
260 | 260 | 'path' => $path, |
261 | 261 | 'url' => $url, |
262 | 262 | ); |
263 | 263 | $readonlys["disable[$path]"] = !$this->versioning || !Vfs::$is_root || |
264 | - Vfs::parse_url($url,PHP_URL_SCHEME) != $this->versioning; |
|
264 | + Vfs::parse_url($url, PHP_URL_SCHEME) != $this->versioning; |
|
265 | 265 | } |
266 | - $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
266 | + $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
267 | 267 | $readonlys['url'] = !self::$is_setup; |
268 | 268 | |
269 | 269 | $sel_options['allow_delete_versions'] = array( |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | ); |
275 | 275 | // show [Mount /etemplates] button for admin, if not already mounted and available |
276 | 276 | $readonlys['etemplates'] = !class_exists('\EGroupware\Stylite\Vfs\Merge\StreamWrapper') || |
277 | - ($fs_tab=Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
277 | + ($fs_tab = Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
278 | 278 | !isset($GLOBALS['egw_info']['user']['apps']['admin']); |
279 | 279 | //_debug_array($content); |
280 | 280 | |
281 | 281 | $tpl = new Etemplate('filemanager.admin'); |
282 | 282 | $GLOBALS['egw_info']['flags']['app_header'] = lang('VFS mounts and versioning'); |
283 | - $tpl->exec('filemanager.filemanager_admin.index',$content,$sel_options,$readonlys); |
|
283 | + $tpl->exec('filemanager.filemanager_admin.index', $content, $sel_options, $readonlys); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | } |
301 | 301 | $content = '<p>'.implode("</p>\n<p>", (array)$msgs)."</p>\n"; |
302 | 302 | |
303 | - $content .= Api\Html::form('<p>'.($check_only&&is_array($msgs) ? |
|
303 | + $content .= Api\Html::form('<p>'.($check_only && is_array($msgs) ? |
|
304 | 304 | Api\Html::submit_button('fix', lang('Fix reported problems')) : ''). |
305 | 305 | Api\Html::submit_button('cancel', lang('Cancel')).'</p>', |
306 | - '','/index.php',array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
306 | + '', '/index.php', array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
307 | 307 | |
308 | 308 | $GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true); |
309 | 309 | } |
@@ -127,8 +127,7 @@ |
||
127 | 127 | /** |
128 | 128 | * Show files shared |
129 | 129 | * |
130 | - * @param array $content=null |
|
131 | - * @param string $msg='' |
|
130 | + * @param array $content |
|
132 | 131 | */ |
133 | 132 | public function index(array $content=null) |
134 | 133 | { |
@@ -131,7 +131,10 @@ discard block |
||
131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
132 | 132 | { |
133 | 133 | $url = str_replace('$path',$path,$content['mounts']['url']); |
134 | - if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
|
134 | + if (empty($url) && $this->versioning) |
|
135 | + { |
|
136 | + $url = Versioning\StreamWrapper::PREFIX.$path; |
|
137 | + } |
|
135 | 138 | |
136 | 139 | if ($content['mounts']['enable'] && !$this->versioning) |
137 | 140 | { |
@@ -227,16 +230,25 @@ discard block |
||
227 | 230 | $content['versionedpath'] = '/'; |
228 | 231 | $content['mtime'] = 100; |
229 | 232 | } |
230 | - if (true) $content = array( |
|
233 | + if (true) |
|
234 | + { |
|
235 | + $content = array( |
|
231 | 236 | 'versionedpath' => $content['versionedpath'], |
232 | 237 | 'mtime' => $content['mtime'], |
233 | 238 | ); |
239 | + } |
|
234 | 240 | if ($this->versioning) |
235 | 241 | { |
236 | 242 | // statistical information |
237 | 243 | $content += Versioning\StreamWrapper::summary(); |
238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
244 | + if ($content['total_files']) |
|
245 | + { |
|
246 | + $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
247 | + } |
|
248 | + if ($content['total_size']) |
|
249 | + { |
|
250 | + $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | if (!($content['is_root']=Vfs::$is_root)) |
242 | 254 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param array $content |
67 | 67 | */ |
68 | - function select(array $content=null) |
|
68 | + function select(array $content = null) |
|
69 | 69 | { |
70 | 70 | if (!is_array($content)) |
71 | 71 | { |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | $content['msg'] = $_GET['msg']; |
77 | 77 | $_GET['mode'] = 'open'; |
78 | 78 | $_GET['method'] = 'ckeditor_return'; |
79 | - $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager','ckeditorfuncnum'); |
|
79 | + $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager', 'ckeditorfuncnum'); |
|
80 | 80 | } |
81 | 81 | $content['mode'] = $_GET['mode']; |
82 | - if (!in_array($content['mode'],array('open','open-multiple','saveas','select-dir'))) |
|
82 | + if (!in_array($content['mode'], array('open', 'open-multiple', 'saveas', 'select-dir'))) |
|
83 | 83 | { |
84 | 84 | throw new Api\Exception\WrongParameter("Wrong or unset required mode parameter!"); |
85 | 85 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | if (isset($_GET['CKEditorFuncNum']) && is_numeric($_GET['CKEditorFuncNum'])) |
96 | 96 | { |
97 | - Api\Cache::setSession('filemanager','ckeditorfuncnum', |
|
97 | + Api\Cache::setSession('filemanager', 'ckeditorfuncnum', |
|
98 | 98 | $content['ckeditorfuncnum'] = $_GET['CKEditorFuncNum']); |
99 | 99 | } |
100 | 100 | else |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | throw new Api\Exception\WrongParameter("chkeditor_return has been specified as a method but some parameters are missing or invalid."); |
103 | 103 | } |
104 | 104 | } |
105 | - $content['id'] = $_GET['id']; |
|
105 | + $content['id'] = $_GET['id']; |
|
106 | 106 | $content['label'] = isset($_GET['label']) ? $_GET['label'] : lang('Open'); |
107 | 107 | if (($content['options-mime'] = isset($_GET['mime']))) |
108 | 108 | { |
109 | 109 | $sel_options['mime'] = array(); |
110 | - foreach((array)$_GET['mime'] as $key => $value) |
|
110 | + foreach ((array)$_GET['mime'] as $key => $value) |
|
111 | 111 | { |
112 | 112 | if (is_numeric($key)) |
113 | 113 | { |
114 | - $sel_options['mime'][$value] = lang('%1 files',strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
114 | + $sel_options['mime'][$value] = lang('%1 files', strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
118 | - $sel_options['mime'][$key] = lang('%1 files',strtoupper($value)).' ('.$key.')'; |
|
118 | + $sel_options['mime'][$key] = lang('%1 files', strtoupper($value)).' ('.$key.')'; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | error_log(array2string($content['options-mime'])); |
124 | 124 | } |
125 | 125 | } |
126 | - elseif(isset($content['button'])) |
|
126 | + elseif (isset($content['button'])) |
|
127 | 127 | { |
128 | 128 | list($button) = each($content['button']); |
129 | 129 | unset($content['button']); |
130 | - switch($button) |
|
130 | + switch ($button) |
|
131 | 131 | { |
132 | 132 | case 'home': |
133 | 133 | $content['path'] = filemanager_ui::get_home_dir(); |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | //Set the "content" name filed accordingly to the uploaded file |
140 | 140 | // encode chars which special meaning in url/vfs (some like / get removed!) |
141 | 141 | $content['name'] = Vfs::encodePathComponent($content['file_upload']['name']); |
142 | - $to_path = Vfs::concat($content['path'],$content['name']); |
|
142 | + $to_path = Vfs::concat($content['path'], $content['name']); |
|
143 | 143 | |
144 | 144 | $copy_result = (Vfs::is_writable($content['path']) || Vfs::is_writable($to_path)) && |
145 | - copy($content['file_upload']['tmp_name'],Vfs::PREFIX.$to_path); |
|
145 | + copy($content['file_upload']['tmp_name'], Vfs::PREFIX.$to_path); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //Break on an error condition |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | - switch($content['mode']) |
|
164 | + switch ($content['mode']) |
|
165 | 165 | { |
166 | 166 | case 'open-multiple': |
167 | - foreach((array)$content['dir']['selected'] as $name) |
|
167 | + foreach ((array)$content['dir']['selected'] as $name) |
|
168 | 168 | { |
169 | - $files[] = Vfs::concat($content['path'],$name); |
|
169 | + $files[] = Vfs::concat($content['path'], $name); |
|
170 | 170 | } |
171 | 171 | //Add an uploaded file to the files result array2string |
172 | 172 | if ($copy_result === true) $files[] = $to_path; |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | // Fall through |
183 | 183 | |
184 | 184 | default: |
185 | - $files = Vfs::concat($content['path'],$content['name']); |
|
185 | + $files = Vfs::concat($content['path'], $content['name']); |
|
186 | 186 | break; |
187 | 187 | } |
188 | 188 | |
189 | 189 | if ($content['method'] && $content['method'] != 'ckeditor_return') |
190 | 190 | { |
191 | - $js = ExecMethod2($content['method'],$content['id'],$files); |
|
191 | + $js = ExecMethod2($content['method'], $content['id'], $files); |
|
192 | 192 | } |
193 | 193 | else if ($content['method'] == 'ckeditor_return') |
194 | 194 | { |
195 | - $download_url = Vfs::download_url(Vfs::concat($content['path'],$content['name'])); |
|
195 | + $download_url = Vfs::download_url(Vfs::concat($content['path'], $content['name'])); |
|
196 | 196 | if ($download_url[0] == '/') $download_url = Egw::link($download_url); |
197 | 197 | $js = "window.opener.CKEDITOR.tools.callFunction(". |
198 | 198 | $content['ckeditorfuncnum'].",'". |
199 | 199 | htmlspecialchars($download_url)."',". |
200 | 200 | "'');\negw(window).close();"; |
201 | 201 | } |
202 | - if(Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
202 | + if (Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
203 | 203 | { |
204 | 204 | $response = Api\Json\Response::get(); |
205 | - if($js) |
|
205 | + if ($js) |
|
206 | 206 | { |
207 | 207 | $response->script($js); |
208 | 208 | } |
209 | 209 | // Ahh! |
210 | 210 | // The vfs-select widget looks for this |
211 | - $response->script('this.selected_files = '.json_encode($files) . '; egw(this).close();'); |
|
211 | + $response->script('this.selected_files = '.json_encode($files).'; egw(this).close();'); |
|
212 | 212 | } |
213 | 213 | else |
214 | 214 | { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | $sel_options['mime'] = $content['options-mime']; |
222 | 222 | } |
223 | - elseif(isset($content['apps'])) |
|
223 | + elseif (isset($content['apps'])) |
|
224 | 224 | { |
225 | 225 | list($app) = each($content['apps']); |
226 | 226 | if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir(); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | //Deactivate the opload field if the current directory is not writeable or |
230 | 230 | //we're currently not in the single file open mode. |
231 | 231 | $content['no_upload'] = !Vfs::is_writable($content['path']) || |
232 | - !in_array($content['mode'],array('open')); |
|
232 | + !in_array($content['mode'], array('open')); |
|
233 | 233 | |
234 | 234 | $content['apps'] = array_keys(self::get_apps()); |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | // Set a flag for easy detection as we go |
242 | - $favorites_flag = substr($content['path'],0,strlen('/apps/favorites')) == '/apps/favorites'; |
|
242 | + $favorites_flag = substr($content['path'], 0, strlen('/apps/favorites')) == '/apps/favorites'; |
|
243 | 243 | |
244 | 244 | if (!$favorites_flag && (!$content['path'] || !Vfs::is_dir($content['path']))) |
245 | 245 | { |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | $files = array(); |
254 | 254 | $favorites = Framework\Favorites::get_favorites('filemanager'); |
255 | 255 | $n = 0; |
256 | - foreach($favorites as $favorite) |
|
256 | + foreach ($favorites as $favorite) |
|
257 | 257 | { |
258 | 258 | $path = $favorite['state']['path']; |
259 | 259 | // Just directories |
260 | - if(!$path) continue; |
|
261 | - if ($path == $content['path']) continue; // remove directory itself |
|
260 | + if (!$path) continue; |
|
261 | + if ($path == $content['path']) continue; // remove directory itself |
|
262 | 262 | |
263 | 263 | $mime = Vfs::mime_content_type($path); |
264 | 264 | $content['dir'][$n] = array( |
@@ -274,29 +274,29 @@ discard block |
||
274 | 274 | ++$n; |
275 | 275 | } |
276 | 276 | } |
277 | - else if (!($files = Vfs::find($content['path'],array( |
|
277 | + else if (!($files = Vfs::find($content['path'], array( |
|
278 | 278 | 'dirsontop' => true, |
279 | 279 | 'order' => 'name', |
280 | 280 | 'sort' => 'ASC', |
281 | 281 | 'maxdepth' => 1, |
282 | 282 | )))) |
283 | 283 | { |
284 | - $content['msg'] = lang("Can't open directory %1!",$content['path']); |
|
284 | + $content['msg'] = lang("Can't open directory %1!", $content['path']); |
|
285 | 285 | } |
286 | 286 | else |
287 | 287 | { |
288 | 288 | $n = 0; |
289 | 289 | $content['dir'] = array('mode' => $content['mode']); |
290 | - foreach($files as $path) |
|
290 | + foreach ($files as $path) |
|
291 | 291 | { |
292 | - if ($path == $content['path']) continue; // remove directory itself |
|
292 | + if ($path == $content['path']) continue; // remove directory itself |
|
293 | 293 | |
294 | 294 | $name = Vfs::basename($path); |
295 | 295 | $is_dir = Vfs::is_dir($path); |
296 | 296 | $mime = Vfs::mime_content_type($path); |
297 | 297 | if ($content['mime'] && !$is_dir && $mime != $content['mime']) |
298 | 298 | { |
299 | - continue; // does not match mime-filter --> ignore |
|
299 | + continue; // does not match mime-filter --> ignore |
|
300 | 300 | } |
301 | 301 | $content['dir'][$n] = array( |
302 | 302 | 'name' => $name, |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | ++$n; |
312 | 312 | } |
313 | - if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
313 | + if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
314 | 314 | } |
315 | 315 | $readonlys['button[createdir]'] = !Vfs::is_writable($content['path']); |
316 | 316 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | { |
338 | 338 | Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline'); |
339 | 339 | } |
340 | - $tpl->exec('filemanager.filemanager_select.select',$content,$sel_options,$readonlys,$preserve,2); |
|
340 | + $tpl->exec('filemanager.filemanager_select.select', $content, $sel_options, $readonlys, $preserve, 2); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | */ |
348 | 348 | static function get_apps() |
349 | 349 | { |
350 | - $apps = array(false); // index starting from 1 |
|
350 | + $apps = array(false); // index starting from 1 |
|
351 | 351 | if (isset($GLOBALS['egw_info']['apps']['stylite'])) $apps = array('favorites' => lang('Favorites')); |
352 | 352 | $apps += Link::app_list('query'); |
353 | 353 | |
354 | - unset($apps['mydms']); // they do NOT support adding files to VFS |
|
354 | + unset($apps['mydms']); // they do NOT support adding files to VFS |
|
355 | 355 | unset($apps['wiki']); |
356 | 356 | unset($apps['api-accounts']); |
357 | 357 | unset($apps['addressbook-email']); |
@@ -169,7 +169,10 @@ discard block |
||
169 | 169 | $files[] = Vfs::concat($content['path'],$name); |
170 | 170 | } |
171 | 171 | //Add an uploaded file to the files result array2string |
172 | - if ($copy_result === true) $files[] = $to_path; |
|
172 | + if ($copy_result === true) |
|
173 | + { |
|
174 | + $files[] = $to_path; |
|
175 | + } |
|
173 | 176 | break; |
174 | 177 | |
175 | 178 | case 'select-dir': |
@@ -193,7 +196,10 @@ discard block |
||
193 | 196 | else if ($content['method'] == 'ckeditor_return') |
194 | 197 | { |
195 | 198 | $download_url = Vfs::download_url(Vfs::concat($content['path'],$content['name'])); |
196 | - if ($download_url[0] == '/') $download_url = Egw::link($download_url); |
|
199 | + if ($download_url[0] == '/') |
|
200 | + { |
|
201 | + $download_url = Egw::link($download_url); |
|
202 | + } |
|
197 | 203 | $js = "window.opener.CKEDITOR.tools.callFunction(". |
198 | 204 | $content['ckeditorfuncnum'].",'". |
199 | 205 | htmlspecialchars($download_url)."',". |
@@ -223,7 +229,10 @@ discard block |
||
223 | 229 | elseif(isset($content['apps'])) |
224 | 230 | { |
225 | 231 | list($app) = each($content['apps']); |
226 | - if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir(); |
|
232 | + if ($app == 'home') |
|
233 | + { |
|
234 | + $content['path'] = filemanager_ui::get_home_dir(); |
|
235 | + } |
|
227 | 236 | } |
228 | 237 | |
229 | 238 | //Deactivate the opload field if the current directory is not writeable or |
@@ -257,8 +266,15 @@ discard block |
||
257 | 266 | { |
258 | 267 | $path = $favorite['state']['path']; |
259 | 268 | // Just directories |
260 | - if(!$path) continue; |
|
261 | - if ($path == $content['path']) continue; // remove directory itself |
|
269 | + if(!$path) |
|
270 | + { |
|
271 | + continue; |
|
272 | + } |
|
273 | + if ($path == $content['path']) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
277 | + // remove directory itself |
|
262 | 278 | |
263 | 279 | $mime = Vfs::mime_content_type($path); |
264 | 280 | $content['dir'][$n] = array( |
@@ -289,7 +305,11 @@ discard block |
||
289 | 305 | $content['dir'] = array('mode' => $content['mode']); |
290 | 306 | foreach($files as $path) |
291 | 307 | { |
292 | - if ($path == $content['path']) continue; // remove directory itself |
|
308 | + if ($path == $content['path']) |
|
309 | + { |
|
310 | + continue; |
|
311 | + } |
|
312 | + // remove directory itself |
|
293 | 313 | |
294 | 314 | $name = Vfs::basename($path); |
295 | 315 | $is_dir = Vfs::is_dir($path); |
@@ -310,7 +330,11 @@ discard block |
||
310 | 330 | } |
311 | 331 | ++$n; |
312 | 332 | } |
313 | - if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
333 | + if (!$n) |
|
334 | + { |
|
335 | + $readonlys['selected[]'] = true; |
|
336 | + } |
|
337 | + // remove checkbox from empty line |
|
314 | 338 | } |
315 | 339 | $readonlys['button[createdir]'] = !Vfs::is_writable($content['path']); |
316 | 340 | |
@@ -348,7 +372,10 @@ discard block |
||
348 | 372 | static function get_apps() |
349 | 373 | { |
350 | 374 | $apps = array(false); // index starting from 1 |
351 | - if (isset($GLOBALS['egw_info']['apps']['stylite'])) $apps = array('favorites' => lang('Favorites')); |
|
375 | + if (isset($GLOBALS['egw_info']['apps']['stylite'])) |
|
376 | + { |
|
377 | + $apps = array('favorites' => lang('Favorites')); |
|
378 | + } |
|
352 | 379 | $apps += Link::app_list('query'); |
353 | 380 | |
354 | 381 | unset($apps['mydms']); // they do NOT support adding files to VFS |
@@ -123,7 +123,7 @@ |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | parent::__construct(); |
62 | 62 | |
63 | - if($_dir) |
|
63 | + if ($_dir) |
|
64 | 64 | { |
65 | 65 | $this->dir = $_dir; |
66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string &$content=null content to create some replacements only if they are use |
77 | 77 | * @return array|boolean |
78 | 78 | */ |
79 | - protected function get_replacements($id,&$content=null) |
|
79 | + protected function get_replacements($id, &$content = null) |
|
80 | 80 | { |
81 | 81 | if (!($replacements = $this->filemanager_replacements($id, '', $content))) |
82 | 82 | { |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | * @param string $prefix='' prefix like eg. 'erole' |
93 | 93 | * @return array|boolean |
94 | 94 | */ |
95 | - public function filemanager_replacements($id,$prefix='', &$content = null) |
|
95 | + public function filemanager_replacements($id, $prefix = '', &$content = null) |
|
96 | 96 | { |
97 | 97 | $info = array(); |
98 | - $file = Vfs::lstat($id,true); |
|
98 | + $file = Vfs::lstat($id, true); |
|
99 | 99 | |
100 | 100 | $file['mtime'] = Api\DateTime::to($file['mtime']); |
101 | 101 | $file['ctime'] = Api\DateTime::to($file['ctime']); |
102 | 102 | |
103 | 103 | $file['name'] = Vfs::basename($id); |
104 | 104 | $file['dir'] = Vfs::decodePath(Vfs::dirname($id)); |
105 | - $dirlist = explode('/',$file['dir']); |
|
105 | + $dirlist = explode('/', $file['dir']); |
|
106 | 106 | $file['folder'] = array_pop($dirlist); |
107 | - $file['folder_file'] = $file['folder'] . '/'.$file['name']; |
|
107 | + $file['folder_file'] = $file['folder'].'/'.$file['name']; |
|
108 | 108 | $file['path'] = $id; |
109 | 109 | $file['rel_path'] = str_replace($this->dir.'/', '', $id); |
110 | 110 | $file['hsize'] = Vfs::hsize($file['size']); |
111 | 111 | $file['mime'] = Vfs::mime_content_type($id); |
112 | - $file['gid'] *= -1; // our widgets use negative gid's |
|
112 | + $file['gid'] *= -1; // our widgets use negative gid's |
|
113 | 113 | if (($props = Vfs::propfind($id))) |
114 | 114 | { |
115 | - foreach($props as $prop) |
|
115 | + foreach ($props as $prop) |
|
116 | 116 | { |
117 | 117 | $file[$prop['name']] = $prop['val']; |
118 | 118 | } |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $file['symlink'] = Vfs::readlink($id); |
123 | 123 | } |
124 | 124 | // Custom fields |
125 | - if($content && strpos($content, '#') !== 0) |
|
125 | + if ($content && strpos($content, '#') !== 0) |
|
126 | 126 | { |
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
130 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
130 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
131 | 131 | { |
132 | 132 | // Set any missing custom fields, or the marker will stay |
133 | - if(!$file['#'.$name]) |
|
133 | + if (!$file['#'.$name]) |
|
134 | 134 | { |
135 | 135 | $file['#'.$name] = ''; |
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Format date cfs per user Api\Preferences |
140 | - if($field['type'] == 'date' || $field['type'] == 'date-time') |
|
140 | + if ($field['type'] == 'date' || $field['type'] == 'date-time') |
|
141 | 141 | { |
142 | 142 | $this->date_fields[] = '#'.$name; |
143 | 143 | $file['#'.$name] = Api\DateTime::to($file['#'.$name], $field['type'] == 'date' ? true : ''); |
@@ -146,51 +146,51 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // If in apps folder, try for app-specific placeholders |
149 | - if($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
149 | + if ($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
150 | 150 | { |
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | - list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
|
152 | + list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5)); |
|
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
155 | 155 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | - $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
|
157 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
156 | + $resolved = Vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4))); |
|
157 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
158 | 158 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
159 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | 160 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 161 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
162 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
163 | 163 | } |
164 | 164 | } |
165 | - if($app && $app_id) |
|
165 | + if ($app && $app_id) |
|
166 | 166 | { |
167 | - if($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
167 | + if ($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
168 | 168 | { |
169 | 169 | $app_merge = null; |
170 | 170 | try |
171 | 171 | { |
172 | - $classname = $app .'_merge'; |
|
173 | - if(class_exists($classname)) |
|
172 | + $classname = $app.'_merge'; |
|
173 | + if (class_exists($classname)) |
|
174 | 174 | { |
175 | 175 | $app_merge = new $classname(); |
176 | - if($app_merge && method_exists($app_merge, 'get_replacements')) |
|
176 | + if ($app_merge && method_exists($app_merge, 'get_replacements')) |
|
177 | 177 | { |
178 | 178 | $app_placeholders = $app_merge->get_replacements($app_id, $content); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | 182 | // Silently discard & continue |
183 | - catch(Exception $e) { |
|
184 | - unset($e); // not used |
|
183 | + catch (Exception $e) { |
|
184 | + unset($e); // not used |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
189 | 189 | $link = Link::mime_open($file['url'], $file['mime']); |
190 | - if(is_array($link)) |
|
190 | + if (is_array($link)) |
|
191 | 191 | { |
192 | 192 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
193 | + if ($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
194 | 194 | $link = Api\Session::link('/index.php', $link); |
195 | 195 | } |
196 | 196 | else |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | $file['url'] = $link; |
210 | 210 | |
211 | 211 | // Add markers |
212 | - foreach($file as $key => &$value) |
|
212 | + foreach ($file as $key => &$value) |
|
213 | 213 | { |
214 | - if(!$value) $value = ''; |
|
215 | - $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
|
214 | + if (!$value) $value = ''; |
|
215 | + $info['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
216 | 216 | } |
217 | - if($app_placeholders) |
|
217 | + if ($app_placeholders) |
|
218 | 218 | { |
219 | 219 | $info = array_merge($app_placeholders, $info); |
220 | 220 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'hsize' => 'Size', |
251 | 251 | 'size' => 'Size (in bytes)', |
252 | 252 | ); |
253 | - foreach($fields as $name => $label) |
|
253 | + foreach ($fields as $name => $label) |
|
254 | 254 | { |
255 | 255 | if (!($n&1)) echo '<tr>'; |
256 | 256 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
262 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
262 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
263 | 263 | { |
264 | 264 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
265 | 265 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | echo '<tr><td colspan="4">'.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of available placeholders.').'</td></tr>'; |
269 | 269 | |
270 | 270 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
271 | - foreach(array( |
|
271 | + foreach (array( |
|
272 | 272 | 'date' => lang('Date'), |
273 | 273 | 'user/n_fn' => lang('Name of current user, all other contact fields are valid too'), |
274 | 274 | 'user/account_lid' => lang('Username'), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
@@ -151,12 +151,14 @@ discard block |
||
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | 152 | list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
155 | + { |
|
155 | 156 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | 157 | $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
157 | 158 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
158 | 159 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
161 | + { |
|
160 | 162 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 163 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | 164 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
@@ -190,7 +192,10 @@ discard block |
||
190 | 192 | if(is_array($link)) |
191 | 193 | { |
192 | 194 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
195 | + if($link['path'] && strpos($link['path'], '://') !== false) |
|
196 | + { |
|
197 | + $link['path'] = $file['path']; |
|
198 | + } |
|
194 | 199 | $link = Api\Session::link('/index.php', $link); |
195 | 200 | } |
196 | 201 | else |
@@ -211,7 +216,10 @@ discard block |
||
211 | 216 | // Add markers |
212 | 217 | foreach($file as $key => &$value) |
213 | 218 | { |
214 | - if(!$value) $value = ''; |
|
219 | + if(!$value) |
|
220 | + { |
|
221 | + $value = ''; |
|
222 | + } |
|
215 | 223 | $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
216 | 224 | } |
217 | 225 | if($app_placeholders) |
@@ -252,9 +260,15 @@ discard block |
||
252 | 260 | ); |
253 | 261 | foreach($fields as $name => $label) |
254 | 262 | { |
255 | - if (!($n&1)) echo '<tr>'; |
|
263 | + if (!($n&1)) |
|
264 | + { |
|
265 | + echo '<tr>'; |
|
266 | + } |
|
256 | 267 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
257 | - if ($n&1) echo "</tr>\n"; |
|
268 | + if ($n&1) |
|
269 | + { |
|
270 | + echo "</tr>\n"; |
|
271 | + } |
|
258 | 272 | $n++; |
259 | 273 | } |
260 | 274 |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | $context['appname'] = 'filemanager'; |
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->nm_settings += array( |
34 | 34 | 'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows', |
35 | 35 | 'csv_export' => true, |
36 | 36 | // Use a different template so it can be accessed from client side |
37 | - 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows' ), |
|
37 | + 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows'), |
|
38 | 38 | // Filemanager needs this header, it's an important component for actions, but we reduce it to the minimum |
39 | 39 | 'header_left' => 'filemanager.home.header_left', |
40 | 40 | // Use a reduced column set for home, user can change if needed |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | 'parent_id' => 'dir', |
47 | 47 | 'is_parent' => 'mime', |
48 | 48 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
49 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
49 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
53 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
54 | 54 | { |
55 | 55 | |
56 | 56 | $this->context['sel_options']['filter'] = array( |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $ui = new filemanager_ui(); |
81 | 81 | $total = $ui->get_rows($query, $rows, $readonlys); |
82 | 82 | // Change template to match selected view |
83 | - if($query['view']) |
|
83 | + if ($query['view']) |
|
84 | 84 | { |
85 | 85 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.home.rows' : 'filemanager.tile'); |
86 | 86 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | // the etemplate exec to fire again. |
104 | 104 | if ($content['nm']['action']) |
105 | 105 | { |
106 | - $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
107 | - if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
108 | - foreach($content['nm']['selected'] as &$id) |
|
106 | + $msg = filemanager_ui::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
107 | + if ($msg) Api\Json\Response::get()->apply('egw.message', array($msg)); |
|
108 | + foreach ($content['nm']['selected'] as &$id) |
|
109 | 109 | { |
110 | 110 | $id = 'filemanager::'.$id; |
111 | 111 | } |
112 | 112 | // Directly request an update - this will get filemanager tab too |
113 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); |
|
113 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected'])); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | 117 | \ No newline at end of file |
@@ -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 | { |
@@ -104,7 +104,10 @@ |
||
104 | 104 | if ($content['nm']['action']) |
105 | 105 | { |
106 | 106 | $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
107 | - if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
107 | + if($msg) |
|
108 | + { |
|
109 | + Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
110 | + } |
|
108 | 111 | foreach($content['nm']['selected'] as &$id) |
109 | 112 | { |
110 | 113 | $id = 'filemanager::'.$id; |
@@ -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 |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | ); |
19 | 19 | include('../header.inc.php'); |
20 | 20 | |
21 | -if (!($path = Api\Cache::getSession('filemanger','test'))) |
|
21 | +if (!($path = Api\Cache::getSession('filemanger', 'test'))) |
|
22 | 22 | { |
23 | 23 | $path = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
24 | 24 | } |
25 | 25 | if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; |
26 | -echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"'). |
|
27 | - Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET'); |
|
26 | +echo Api\Html::form("<p>Path: ".Api\Html::input('path', $path, 'text', 'size="40"'). |
|
27 | + Api\Html::submit_button('', lang('Submit'))."</p>\n", array(), '', '', '', '', 'GET'); |
|
28 | 28 | |
29 | 29 | if (isset($path) && !empty($path)) |
30 | 30 | { |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | { |
33 | 33 | throw new Api\Exception\WrongUserinput('Not an absolute path!'); |
34 | 34 | } |
35 | - Api\Cache::setSession('filemanger','test',$path); |
|
35 | + Api\Cache::setSession('filemanger', 'test', $path); |
|
36 | 36 | |
37 | 37 | echo "<h2>"; |
38 | - foreach(explode('/',$path) as $n => $part) |
|
38 | + foreach (explode('/', $path) as $n => $part) |
|
39 | 39 | { |
40 | 40 | $p .= ($p != '/' ? '/' : '').$part; |
41 | - echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ','/filemanager/test.php',array('path'=>$p)); |
|
41 | + echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ', '/filemanager/test.php', array('path'=>$p)); |
|
42 | 42 | } |
43 | 43 | echo "</h2>\n"; |
44 | 44 | |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | |
51 | 51 | $time = microtime(true); |
52 | 52 | $stat = Vfs::stat($path); |
53 | - $stime = number_format(1000*(microtime(true)-$time),1); |
|
53 | + $stime = number_format(1000 * (microtime(true) - $time), 1); |
|
54 | 54 | |
55 | 55 | $time2 = microtime(true); |
56 | 56 | if ($is_dir)// && ($d = Vfs::opendir($path))) |
57 | 57 | { |
58 | 58 | $files = array(); |
59 | 59 | //while(($file = readdir($d))) |
60 | - foreach(Vfs::scandir($path) as $file) |
|
60 | + foreach (Vfs::scandir($path) as $file) |
|
61 | 61 | { |
62 | - if (Vfs::is_readable($fpath=Vfs::concat($path,$file))) |
|
62 | + if (Vfs::is_readable($fpath = Vfs::concat($path, $file))) |
|
63 | 63 | { |
64 | - $file = Api\Html::a_href($file,'/filemanager/test.php',array('path'=>$fpath)); |
|
64 | + $file = Api\Html::a_href($file, '/filemanager/test.php', array('path'=>$fpath)); |
|
65 | 65 | } |
66 | 66 | $file .= ' ('.Vfs::mime_content_type($fpath).')'; |
67 | 67 | $files[] = $file; |
68 | 68 | } |
69 | 69 | //closedir($d); |
70 | - $time2f = number_format(1000*(microtime(true)-$time2),1); |
|
70 | + $time2f = number_format(1000 * (microtime(true) - $time2), 1); |
|
71 | 71 | echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n"; |
72 | - if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
72 | + if ($files) echo '<ol><li>'.implode("</li>\n<li>", $files).'</ol>'."\n"; |
|
73 | 73 | } |
74 | 74 | |
75 | - echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')'; |
|
75 | + echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode']) ? sprintf('%o', $stat['mode']).' = '.Vfs::int2mode($stat['mode']) : 'NULL').')'; |
|
76 | 76 | if (is_array($stat)) |
77 | 77 | { |
78 | 78 | _debug_array($stat); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | echo "<p><b>readlink('$path')</b>=".array2string(Vfs::readlink($path))."</p>\n"; |
90 | 90 | $time3 = microtime(true); |
91 | 91 | $lstat = Vfs::lstat($path); |
92 | - $time3f = number_format(1000*(microtime(true)-$time3),1); |
|
93 | - echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode'])?sprintf('%o',$lstat['mode']).' = '.Vfs::int2mode($lstat['mode']):'NULL').')'; |
|
92 | + $time3f = number_format(1000 * (microtime(true) - $time3), 1); |
|
93 | + echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode']) ? sprintf('%o', $lstat['mode']).' = '.Vfs::int2mode($lstat['mode']) : 'NULL').')'; |
|
94 | 94 | if (is_array($lstat)) |
95 | 95 | { |
96 | 96 | _debug_array($lstat); |
@@ -22,7 +22,10 @@ discard block |
||
22 | 22 | { |
23 | 23 | $path = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
24 | 24 | } |
25 | -if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; |
|
25 | +if (isset($_REQUEST['path'])) |
|
26 | +{ |
|
27 | + $path = $_REQUEST['path']; |
|
28 | +} |
|
26 | 29 | echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"'). |
27 | 30 | Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET'); |
28 | 31 | |
@@ -53,9 +56,12 @@ discard block |
||
53 | 56 | $stime = number_format(1000*(microtime(true)-$time),1); |
54 | 57 | |
55 | 58 | $time2 = microtime(true); |
56 | - if ($is_dir)// && ($d = Vfs::opendir($path))) |
|
59 | + if ($is_dir) |
|
60 | + { |
|
61 | + // && ($d = Vfs::opendir($path))) |
|
57 | 62 | { |
58 | 63 | $files = array(); |
64 | + } |
|
59 | 65 | //while(($file = readdir($d))) |
60 | 66 | foreach(Vfs::scandir($path) as $file) |
61 | 67 | { |
@@ -69,7 +75,10 @@ discard block |
||
69 | 75 | //closedir($d); |
70 | 76 | $time2f = number_format(1000*(microtime(true)-$time2),1); |
71 | 77 | echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n"; |
72 | - if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
78 | + if($files) |
|
79 | + { |
|
80 | + echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
81 | + } |
|
73 | 82 | } |
74 | 83 | |
75 | 84 | echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')'; |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | //print_r($config); exit; |
38 | 38 | |
39 | -$uglify =& $config['uglify']; |
|
39 | +$uglify = & $config['uglify']; |
|
40 | 40 | |
41 | -foreach(Bundle::all() as $name => $files) |
|
41 | +foreach (Bundle::all() as $name => $files) |
|
42 | 42 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
43 | + if ($name == '.ts') continue; // ignore timestamp |
|
44 | 44 | |
45 | 45 | // remove leading / from file-names |
46 | 46 | array_walk($files, function(&$path) |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | // add css for all templates and themes |
82 | -$cssmin =& $config['cssmin']; |
|
83 | -$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | -$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | -foreach(array('pixelegg','jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
82 | +$cssmin = & $config['cssmin']; |
|
83 | +$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | +$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | +foreach (array('pixelegg', 'jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
86 | 86 | { |
87 | 87 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 88 | $tpl = Framework::factory(); |
89 | 89 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | - foreach($themes as $theme) |
|
90 | + if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | + foreach ($themes as $theme) |
|
92 | 92 | { |
93 | 93 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | 94 | if ($template == 'pixelegg' && $theme == 'traditional') continue; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $new_json = str_replace("\n", "\n\t", |
115 | 115 | preg_replace_callback('/^( *)/m', function($matches) |
116 | 116 | { |
117 | - return str_repeat("\t", strlen($matches[1])/4); |
|
117 | + return str_repeat("\t", strlen($matches[1]) / 4); |
|
118 | 118 | }, json_encode($config, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES))); |
119 | 119 | |
120 | 120 | $new_content = preg_replace('/^(\s*)"([a-z0-9]+)":/mi', '$1$2:', $new_json); |
@@ -13,7 +13,10 @@ discard block |
||
13 | 13 | use EGroupware\Api\Framework; |
14 | 14 | use EGroupware\Api\Framework\Bundle; |
15 | 15 | |
16 | -if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n"); |
|
16 | +if (php_sapi_name() !== 'cli') |
|
17 | +{ |
|
18 | + die("This is a commandline ONLY tool!\n"); |
|
19 | +} |
|
17 | 20 | |
18 | 21 | $GLOBALS['egw_info'] = array( |
19 | 22 | 'flags' => array( |
@@ -40,12 +43,19 @@ discard block |
||
40 | 43 | |
41 | 44 | foreach(Bundle::all() as $name => $files) |
42 | 45 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
46 | + if ($name == '.ts') |
|
47 | + { |
|
48 | + continue; |
|
49 | + } |
|
50 | + // ignore timestamp |
|
44 | 51 | |
45 | 52 | // remove leading / from file-names |
46 | 53 | array_walk($files, function(&$path) |
47 | 54 | { |
48 | - if ($path[0] == '/') $path = substr($path, 1); |
|
55 | + if ($path[0] == '/') |
|
56 | + { |
|
57 | + $path = substr($path, 1); |
|
58 | + } |
|
49 | 59 | }); |
50 | 60 | |
51 | 61 | // api/js/jsapi/egw.js loaded via own tag, and we must not load it twice! |
@@ -87,11 +97,18 @@ discard block |
||
87 | 97 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 98 | $tpl = Framework::factory(); |
89 | 99 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
100 | + if ($template == 'pixelegg') |
|
101 | + { |
|
102 | + $themes[] = 'fw_mobile'; |
|
103 | + } |
|
104 | + // this is for mobile devices |
|
91 | 105 | foreach($themes as $theme) |
92 | 106 | { |
93 | 107 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | - if ($template == 'pixelegg' && $theme == 'traditional') continue; |
|
108 | + if ($template == 'pixelegg' && $theme == 'traditional') |
|
109 | + { |
|
110 | + continue; |
|
111 | + } |
|
95 | 112 | $GLOBALS['egw_info']['user']['preferences']['common']['theme'] = $theme; |
96 | 113 | // empty include list by not-existing file plus last true |
97 | 114 | Framework\CssIncludes::add('*grunt*', null, true, true); |