@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) || |
382 | 382 | ($owner < 0) != ($cmd == 'chgrp')) |
383 | 383 | { |
384 | - die("Unknown $type '$owner_was'!"); |
|
384 | + die("unknown $type '$owner_was'!"); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
388 | 388 | ($owner < 0) != ($cmd == 'chgrp'))) |
389 | 389 | { |
390 | - die("Unknown $type '$owner_was'!"); |
|
390 | + die("unknown $type '$owner_was'!"); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | $params = array($url,$owner); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | { |
446 | 446 | if (!($f = fopen($url,'r'))) |
447 | 447 | { |
448 | - echo "File $url not found !!!\n\n"; |
|
448 | + echo "file $url not found !!!\n\n"; |
|
449 | 449 | } |
450 | 450 | else |
451 | 451 | { |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | } |
762 | 762 | if (!($from_fp = fopen($from,'r'))) |
763 | 763 | { |
764 | - die("File $from not found!\n"); |
|
764 | + die("file $from not found!\n"); |
|
765 | 765 | } |
766 | 766 | if (!($to_fp = fopen($to,'w'))) |
767 | 767 | { |
@@ -20,10 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED); |
22 | 22 | |
23 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling filemanager/cli.php as web-page |
|
23 | +if (php_sapi_name() !== 'cli') |
|
24 | +{ |
|
25 | + // security precaution: forbit calling filemanager/cli.php as web-page |
|
24 | 26 | { |
25 | 27 | die('<h1>'.basename(__FILE__).' must NOT be called as web-page --> exiting !!!</h1>'); |
26 | 28 | } |
29 | +} |
|
27 | 30 | |
28 | 31 | /** |
29 | 32 | * callback if the session-check fails, creates session from user/passwd in $GLOBALS['egw_login_data'] |
@@ -87,17 +90,23 @@ discard block |
||
87 | 90 | $cmd = array_shift($args); |
88 | 91 | } |
89 | 92 | |
90 | -if (!$args) $args = array('-h'); |
|
93 | +if (!$args) |
|
94 | +{ |
|
95 | + $args = array('-h'); |
|
96 | +} |
|
91 | 97 | |
92 | 98 | $argv = $find_options = array(); |
93 | 99 | while(!is_null($option = array_shift($args))) |
94 | 100 | { |
95 | - if ($option == '-' || $option[0] != '-') // no option --> argument |
|
101 | + if ($option == '-' || $option[0] != '-') |
|
102 | + { |
|
103 | + // no option --> argument |
|
96 | 104 | { |
97 | 105 | // remove quotes from arguments |
98 | 106 | if (in_array($option[0], array('"', "'")) && $option[0] == substr($option, -1)) |
99 | 107 | { |
100 | 108 | $option = substr($option, 1, -1); |
109 | + } |
|
101 | 110 | } |
102 | 111 | $argv[] = $option; |
103 | 112 | continue; |
@@ -197,7 +206,10 @@ discard block |
||
197 | 206 | { |
198 | 207 | usage('Wrong number of parameters!'); |
199 | 208 | } |
200 | - if (($url = $argv[0])) load_wrapper($url); |
|
209 | + if (($url = $argv[0])) |
|
210 | + { |
|
211 | + load_wrapper($url); |
|
212 | + } |
|
201 | 213 | if(!Vfs::$is_root) |
202 | 214 | { |
203 | 215 | die("You need to be root to do that!\n"); |
@@ -262,7 +274,10 @@ discard block |
||
262 | 274 | break; |
263 | 275 | |
264 | 276 | case 'rename': |
265 | - if (count($argv) != 2) usage('Wrong number of parameters!'); |
|
277 | + if (count($argv) != 2) |
|
278 | + { |
|
279 | + usage('Wrong number of parameters!'); |
|
280 | + } |
|
266 | 281 | load_wrapper($argv[0]); |
267 | 282 | load_wrapper($argv[1]); |
268 | 283 | rename($argv[0],$argv[1]); |
@@ -273,7 +288,11 @@ discard block |
||
273 | 288 | { |
274 | 289 | die("\nYou need to be root to do that!\n\n"); |
275 | 290 | } |
276 | - if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
291 | + if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
292 | + { |
|
293 | + exit; |
|
294 | + } |
|
295 | + // we need write access, error msg already given |
|
277 | 296 | $fstab = Vfs::mount(); |
278 | 297 | if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false) |
279 | 298 | { |
@@ -286,7 +305,10 @@ discard block |
||
286 | 305 | $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
287 | 306 | echo "\n$num_files files migrated from DB to filesystem.\n"; |
288 | 307 | $new_url = preg_replace('/storage=db&?/','',$fstab['/']); |
289 | - if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1); |
|
308 | + if (substr($new_url,-1) == '?') |
|
309 | + { |
|
310 | + $new_url = substr($new_url,0,-1); |
|
311 | + } |
|
290 | 312 | if (Vfs::mount($new_url,'/')) |
291 | 313 | { |
292 | 314 | echo "/ successful re-mounted on $new_url\n"; |
@@ -302,7 +324,10 @@ discard block |
||
302 | 324 | { |
303 | 325 | $url = array_shift($argv); |
304 | 326 | |
305 | - if (strpos($url, '://')) load_wrapper($url); |
|
327 | + if (strpos($url, '://')) |
|
328 | + { |
|
329 | + load_wrapper($url); |
|
330 | + } |
|
306 | 331 | echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.", recursive=".(int)$recursive.") ".implode(' ', $argv)."\n"; |
307 | 332 | |
308 | 333 | switch($cmd) |
@@ -329,7 +354,10 @@ discard block |
||
329 | 354 | break; |
330 | 355 | |
331 | 356 | case 'mkdir': |
332 | - if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n"; |
|
357 | + if (!mkdir($url,null,$recursive)) |
|
358 | + { |
|
359 | + echo "Can't create directory, permission denied!\n"; |
|
360 | + } |
|
333 | 361 | break; |
334 | 362 | |
335 | 363 | case 'touch': |
@@ -428,13 +456,19 @@ discard block |
||
428 | 456 | { |
429 | 457 | if ($argc) |
430 | 458 | { |
431 | - if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/'; |
|
459 | + if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) |
|
460 | + { |
|
461 | + $name = '/'; |
|
462 | + } |
|
432 | 463 | echo "\n$name:\n"; |
433 | 464 | } |
434 | 465 | // separate evtl. query part, to re-add it after the file-name |
435 | 466 | unset($query); |
436 | 467 | list($url,$query) = explode('?',$url,2); |
437 | - if ($query) $query = '?'.$query; |
|
468 | + if ($query) |
|
469 | + { |
|
470 | + $query = '?'.$query; |
|
471 | + } |
|
438 | 472 | |
439 | 473 | if (substr($url,-1) == '/') |
440 | 474 | { |
@@ -466,7 +500,10 @@ discard block |
||
466 | 500 | { |
467 | 501 | do_stat($url,$long,$numeric,false,$inode); |
468 | 502 | } |
469 | - if (!$long && $cmd == 'ls') echo "\n"; |
|
503 | + if (!$long && $cmd == 'ls') |
|
504 | + { |
|
505 | + echo "\n"; |
|
506 | + } |
|
470 | 507 | break; |
471 | 508 | } |
472 | 509 | } |
@@ -669,18 +706,36 @@ discard block |
||
669 | 706 | { |
670 | 707 | $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : |
671 | 708 | (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
672 | - if (is_array($uid)) $uid = $uid['name']; |
|
673 | - if (empty($uid)) $uid = $stat['uid']; |
|
709 | + if (is_array($uid)) |
|
710 | + { |
|
711 | + $uid = $uid['name']; |
|
712 | + } |
|
713 | + if (empty($uid)) |
|
714 | + { |
|
715 | + $uid = $stat['uid']; |
|
716 | + } |
|
717 | + } |
|
718 | + if (!isset($uid)) |
|
719 | + { |
|
720 | + $uid = 'root'; |
|
674 | 721 | } |
675 | - if (!isset($uid)) $uid = 'root'; |
|
676 | 722 | if ($stat['gid']) |
677 | 723 | { |
678 | 724 | $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : |
679 | 725 | (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
680 | - if (is_array($gid)) $gid = $gid['name']; |
|
681 | - if (empty($gid)) $gid = $stat['gid']; |
|
726 | + if (is_array($gid)) |
|
727 | + { |
|
728 | + $gid = $gid['name']; |
|
729 | + } |
|
730 | + if (empty($gid)) |
|
731 | + { |
|
732 | + $gid = $stat['gid']; |
|
733 | + } |
|
734 | + } |
|
735 | + if (!isset($gid)) |
|
736 | + { |
|
737 | + $gid = 'root'; |
|
682 | 738 | } |
683 | - if (!isset($gid)) $gid = 'root'; |
|
684 | 739 | } |
685 | 740 | $size = hsize($stat['size']); |
686 | 741 | $mtime = date('Y-m-d H:i:s',$stat['mtime']); |
@@ -703,8 +758,14 @@ discard block |
||
703 | 758 | |
704 | 759 | function hsize($size) |
705 | 760 | { |
706 | - if ($size < 1024) return $size; |
|
707 | - if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024); |
|
761 | + if ($size < 1024) |
|
762 | + { |
|
763 | + return $size; |
|
764 | + } |
|
765 | + if ($size < 1024*1024) |
|
766 | + { |
|
767 | + return sprintf('%3.1lfk',(float)$size/1024); |
|
768 | + } |
|
708 | 769 | return sprintf('%3.1lfM',(float)$size/(1024*1024)); |
709 | 770 | } |
710 | 771 | |
@@ -738,14 +799,20 @@ discard block |
||
738 | 799 | ++$anz_files; |
739 | 800 | _cp($f,$t); |
740 | 801 | } |
741 | - if ($perms) _cp_perms($f,$t); |
|
802 | + if ($perms) |
|
803 | + { |
|
804 | + _cp_perms($f,$t); |
|
805 | + } |
|
742 | 806 | } |
743 | 807 | echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n"; |
744 | 808 | } |
745 | 809 | else |
746 | 810 | { |
747 | 811 | _cp($from,$to,true); |
748 | - if ($perms) _cp_perms($from,$to); |
|
812 | + if ($perms) |
|
813 | + { |
|
814 | + _cp_perms($from,$to); |
|
815 | + } |
|
749 | 816 | } |
750 | 817 | } |
751 | 818 | } |
@@ -774,7 +841,10 @@ discard block |
||
774 | 841 | //stream_filter_append($from_fp,'convert.base64-decode'); |
775 | 842 | $count = stream_copy_to_stream($from_fp,$to_fp); |
776 | 843 | |
777 | - if ($verbose) echo hsize($count)." bytes written to $to\n"; |
|
844 | + if ($verbose) |
|
845 | + { |
|
846 | + echo hsize($count)." bytes written to $to\n"; |
|
847 | + } |
|
778 | 848 | |
779 | 849 | fclose($from_fp); |
780 | 850 | |
@@ -821,7 +891,10 @@ discard block |
||
821 | 891 | function do_lntree($from,$to) |
822 | 892 | { |
823 | 893 | echo "lntree $from $to\n"; |
824 | - if ($from[0] == '/') $from = 'sqlfs://default'.$from; |
|
894 | + if ($from[0] == '/') |
|
895 | + { |
|
896 | + $from = 'sqlfs://default'.$from; |
|
897 | + } |
|
825 | 898 | load_wrapper($from); |
826 | 899 | |
827 | 900 | if (!file_exists($from)) |
@@ -883,34 +956,55 @@ discard block |
||
883 | 956 | */ |
884 | 957 | function int2mode( $mode ) |
885 | 958 | { |
886 | - if(($mode & 0xA000) == 0xA000) // Symbolic Link |
|
959 | + if(($mode & 0xA000) == 0xA000) |
|
960 | + { |
|
961 | + // Symbolic Link |
|
887 | 962 | { |
888 | 963 | $sP = 'l'; |
889 | 964 | } |
890 | - elseif(($mode & 0xC000) == 0xC000) // Socket |
|
965 | + } |
|
966 | + elseif(($mode & 0xC000) == 0xC000) |
|
967 | + { |
|
968 | + // Socket |
|
891 | 969 | { |
892 | 970 | $sP = 's'; |
893 | 971 | } |
894 | - elseif($mode & 0x1000) // FIFO pipe |
|
972 | + } |
|
973 | + elseif($mode & 0x1000) |
|
974 | + { |
|
975 | + // FIFO pipe |
|
895 | 976 | { |
896 | 977 | $sP = 'p'; |
897 | 978 | } |
898 | - elseif($mode & 0x2000) // Character special |
|
979 | + } |
|
980 | + elseif($mode & 0x2000) |
|
981 | + { |
|
982 | + // Character special |
|
899 | 983 | { |
900 | 984 | $sP = 'c'; |
901 | 985 | } |
902 | - elseif($mode & 0x4000) // Directory |
|
986 | + } |
|
987 | + elseif($mode & 0x4000) |
|
988 | + { |
|
989 | + // Directory |
|
903 | 990 | { |
904 | 991 | $sP = 'd'; |
905 | 992 | } |
906 | - elseif($mode & 0x6000) // Block special |
|
993 | + } |
|
994 | + elseif($mode & 0x6000) |
|
995 | + { |
|
996 | + // Block special |
|
907 | 997 | { |
908 | 998 | $sP = 'b'; |
909 | 999 | } |
910 | - elseif($mode & 0x8000) // Regular |
|
1000 | + } |
|
1001 | + elseif($mode & 0x8000) |
|
1002 | + { |
|
1003 | + // Regular |
|
911 | 1004 | { |
912 | 1005 | $sP = '-'; |
913 | 1006 | } |
1007 | + } |
|
914 | 1008 | else // UNKNOWN |
915 | 1009 | { |
916 | 1010 | $sP = 'u'; |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | use EGroupware\Api; |
17 | 17 | use EGroupware\Api\Vfs; |
18 | 18 | |
19 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
19 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
20 | 20 | |
21 | -error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED); |
|
21 | +error_reporting(error_reporting()&~E_NOTICE & ~E_DEPRECATED); |
|
22 | 22 | |
23 | 23 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling filemanager/cli.php as web-page |
24 | 24 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $error_msg ='' error-message to be printed in front of usage |
49 | 49 | */ |
50 | -function usage($error_msg='') |
|
50 | +function usage($error_msg = '') |
|
51 | 51 | { |
52 | 52 | if ($error_msg) |
53 | 53 | { |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | } |
82 | 82 | $long = $numeric = $recursive = $perms = $all = $inode = false; |
83 | 83 | $args = $_SERVER['argv']; |
84 | -$cmd = basename(array_shift($args),'.php'); |
|
85 | -if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0],'://') === false) |
|
84 | +$cmd = basename(array_shift($args), '.php'); |
|
85 | +if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0], '://') === false) |
|
86 | 86 | { |
87 | 87 | $cmd = array_shift($args); |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if (!$args) $args = array('-h'); |
91 | 91 | |
92 | 92 | $argv = $find_options = array(); |
93 | -while(!is_null($option = array_shift($args))) |
|
93 | +while (!is_null($option = array_shift($args))) |
|
94 | 94 | { |
95 | 95 | if ($option == '-' || $option[0] != '-') // no option --> argument |
96 | 96 | { |
@@ -103,34 +103,34 @@ discard block |
||
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
106 | - switch($option) |
|
106 | + switch ($option) |
|
107 | 107 | { |
108 | 108 | default: |
109 | 109 | if ($cmd == 'find') |
110 | 110 | { |
111 | - if (!in_array($option,array('-type','-depth','-mindepth','-maxdepth','-name','-path', |
|
112 | - '-uid','-user','-nouser','-gid','-group','-nogroup','-mime', |
|
113 | - '-empty','-size','-cmin','-ctime','-mmin','-mtime','-limit','-order','-sort', |
|
114 | - '-hidden','-show-deleted','-name-preg','-path','-path-preg'))) |
|
111 | + if (!in_array($option, array('-type', '-depth', '-mindepth', '-maxdepth', '-name', '-path', |
|
112 | + '-uid', '-user', '-nouser', '-gid', '-group', '-nogroup', '-mime', |
|
113 | + '-empty', '-size', '-cmin', '-ctime', '-mmin', '-mtime', '-limit', '-order', '-sort', |
|
114 | + '-hidden', '-show-deleted', '-name-preg', '-path', '-path-preg'))) |
|
115 | 115 | { |
116 | 116 | usage("Unknown find option '$option'!"); |
117 | 117 | } |
118 | - if (in_array($option,array('-empty','-depth','-nouser','-nogroup','-hidden','-show-deleted'))) |
|
118 | + if (in_array($option, array('-empty', '-depth', '-nouser', '-nogroup', '-hidden', '-show-deleted'))) |
|
119 | 119 | { |
120 | - $find_options[substr($option,1)] = true; |
|
120 | + $find_options[substr($option, 1)] = true; |
|
121 | 121 | } |
122 | 122 | else |
123 | 123 | { |
124 | - $find_options[str_replace('-','_',substr($option,1))] = array_shift($args); |
|
124 | + $find_options[str_replace('-', '_', substr($option, 1))] = array_shift($args); |
|
125 | 125 | } |
126 | 126 | break; |
127 | 127 | } |
128 | 128 | // multiple options, eg. -rp --> -r -p |
129 | - elseif($option[0] == '-' && $option[1] != '-' && strlen($option) > 2) |
|
129 | + elseif ($option[0] == '-' && $option[1] != '-' && strlen($option) > 2) |
|
130 | 130 | { |
131 | - for($i = 1; $i < strlen($option); ++$i) |
|
131 | + for ($i = 1; $i < strlen($option); ++$i) |
|
132 | 132 | { |
133 | - array_unshift($args,'-'.$option[$i]); |
|
133 | + array_unshift($args, '-'.$option[$i]); |
|
134 | 134 | } |
135 | 135 | break; |
136 | 136 | } |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | } |
187 | 187 | if ($user && $passwd) |
188 | 188 | { |
189 | - load_egw($user,$passwd,$domain ? $domain : 'default'); |
|
189 | + load_egw($user, $passwd, $domain ? $domain : 'default'); |
|
190 | 190 | } |
191 | 191 | $argc = count($argv); |
192 | 192 | |
193 | -switch($cmd) |
|
193 | +switch ($cmd) |
|
194 | 194 | { |
195 | 195 | case 'umount': |
196 | 196 | if ($argc != 1 && !$all) |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | usage('Wrong number of parameters!'); |
199 | 199 | } |
200 | 200 | if (($url = $argv[0])) load_wrapper($url); |
201 | - if(!Vfs::$is_root) |
|
201 | + if (!Vfs::$is_root) |
|
202 | 202 | { |
203 | 203 | die("You need to be root to do that!\n"); |
204 | 204 | } |
205 | 205 | if ($all) |
206 | 206 | { |
207 | - Api\Config::save_value('vfs_fstab',$GLOBALS['egw_info']['server']['vfs_fstab']='','phpgwapi'); |
|
207 | + Api\Config::save_value('vfs_fstab', $GLOBALS['egw_info']['server']['vfs_fstab'] = '', 'phpgwapi'); |
|
208 | 208 | echo "Restored default mounts:\n"; |
209 | 209 | } |
210 | 210 | elseif (!Vfs::umount($url)) |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | { |
222 | 222 | usage('Wrong number of parameters!'); |
223 | 223 | } |
224 | - load_wrapper($url=$argv[0]); |
|
224 | + load_wrapper($url = $argv[0]); |
|
225 | 225 | |
226 | - if($argc > 1 && !Vfs::$is_root) |
|
226 | + if ($argc > 1 && !Vfs::$is_root) |
|
227 | 227 | { |
228 | 228 | die("You need to be root to do that!\n"); |
229 | 229 | } |
230 | - $fstab = Vfs::mount($url,$path=$argv[1]); |
|
230 | + $fstab = Vfs::mount($url, $path = $argv[1]); |
|
231 | 231 | if (is_array($fstab)) |
232 | 232 | { |
233 | - foreach($fstab as $path => $url) |
|
233 | + foreach ($fstab as $path => $url) |
|
234 | 234 | { |
235 | 235 | echo "$url\t$path\n"; |
236 | 236 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | break; |
251 | 251 | |
252 | 252 | case 'find': |
253 | - do_find($argv,$find_options); |
|
253 | + do_find($argv, $find_options); |
|
254 | 254 | break; |
255 | 255 | |
256 | 256 | case 'lntree': |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | break; |
259 | 259 | |
260 | 260 | case 'cp': |
261 | - do_cp($argv,$recursive,$perms); |
|
261 | + do_cp($argv, $recursive, $perms); |
|
262 | 262 | break; |
263 | 263 | |
264 | 264 | case 'rename': |
265 | 265 | if (count($argv) != 2) usage('Wrong number of parameters!'); |
266 | 266 | load_wrapper($argv[0]); |
267 | 267 | load_wrapper($argv[1]); |
268 | - rename($argv[0],$argv[1]); |
|
268 | + rename($argv[0], $argv[1]); |
|
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'migrate-db2fs': |
@@ -273,21 +273,21 @@ discard block |
||
273 | 273 | { |
274 | 274 | die("\nYou need to be root to do that!\n\n"); |
275 | 275 | } |
276 | - if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
276 | + if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
277 | 277 | $fstab = Vfs::mount(); |
278 | - if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false) |
|
278 | + if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'], 'storage=db') === false) |
|
279 | 279 | { |
280 | - foreach($fstab as $path => $url) |
|
280 | + foreach ($fstab as $path => $url) |
|
281 | 281 | { |
282 | 282 | echo "$url\t$path\n"; |
283 | 283 | } |
284 | 284 | die("\n/ NOT mounted with 'storage=db' --> no need to convert!\n\n"); |
285 | 285 | } |
286 | - $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
|
286 | + $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
|
287 | 287 | echo "\n$num_files files migrated from DB to filesystem.\n"; |
288 | - $new_url = preg_replace('/storage=db&?/','',$fstab['/']); |
|
289 | - if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1); |
|
290 | - if (Vfs::mount($new_url,'/')) |
|
288 | + $new_url = preg_replace('/storage=db&?/', '', $fstab['/']); |
|
289 | + if (substr($new_url, -1) == '?') $new_url = substr($new_url, 0, -1); |
|
290 | + if (Vfs::mount($new_url, '/')) |
|
291 | 291 | { |
292 | 292 | echo "/ successful re-mounted on $new_url\n"; |
293 | 293 | } |
@@ -298,24 +298,24 @@ discard block |
||
298 | 298 | break; |
299 | 299 | |
300 | 300 | default: |
301 | - while($argv) |
|
301 | + while ($argv) |
|
302 | 302 | { |
303 | 303 | $url = array_shift($argv); |
304 | 304 | |
305 | 305 | if (strpos($url, '://')) load_wrapper($url); |
306 | 306 | echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.", recursive=".(int)$recursive.") ".implode(' ', $argv)."\n"; |
307 | 307 | |
308 | - switch($cmd) |
|
308 | + switch ($cmd) |
|
309 | 309 | { |
310 | 310 | case 'rm': |
311 | 311 | if ($recursive) |
312 | 312 | { |
313 | 313 | if (!class_exists('EGroupware\\Api\\Vfs')) |
314 | 314 | { |
315 | - die("rm -r only implemented for eGW streams!"); // dont want to repeat the code here |
|
315 | + die("rm -r only implemented for eGW streams!"); // dont want to repeat the code here |
|
316 | 316 | } |
317 | - array_unshift($argv,$url); |
|
318 | - Vfs::remove($argv,true); |
|
317 | + array_unshift($argv, $url); |
|
318 | + Vfs::remove($argv, true); |
|
319 | 319 | $argv = array(); |
320 | 320 | } |
321 | 321 | else |
@@ -329,27 +329,27 @@ discard block |
||
329 | 329 | break; |
330 | 330 | |
331 | 331 | case 'mkdir': |
332 | - if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n"; |
|
332 | + if (!mkdir($url, null, $recursive)) echo "Can't create directory, permission denied!\n"; |
|
333 | 333 | break; |
334 | 334 | |
335 | 335 | case 'touch': |
336 | 336 | case 'chmod': |
337 | 337 | case 'chown': |
338 | 338 | case 'chgrp': |
339 | - switch($cmd) |
|
339 | + switch ($cmd) |
|
340 | 340 | { |
341 | 341 | case 'touch': |
342 | - $params = array($url,$time); |
|
342 | + $params = array($url, $time); |
|
343 | 343 | break; |
344 | 344 | case 'chmod': |
345 | 345 | if (!isset($mode)) |
346 | 346 | { |
347 | - $mode = $url; // first param is mode |
|
347 | + $mode = $url; // first param is mode |
|
348 | 348 | $url = array_shift($argv); |
349 | - load_wrapper($url); // not loaded because mode was in url |
|
349 | + load_wrapper($url); // not loaded because mode was in url |
|
350 | 350 | } |
351 | 351 | |
352 | - if (strpos($mode,'+') !== false || strpos($mode,'-') !== false) |
|
352 | + if (strpos($mode, '+') !== false || strpos($mode, '-') !== false) |
|
353 | 353 | { |
354 | 354 | $stat = stat($url); |
355 | 355 | $set = $stat['mode']; |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | } |
361 | 361 | if (!class_exists('EGroupware\\Api\\Vfs')) |
362 | 362 | { |
363 | - die("chmod only implemented for eGW streams!"); // dont want to repeat the code here |
|
363 | + die("chmod only implemented for eGW streams!"); // dont want to repeat the code here |
|
364 | 364 | } |
365 | - $set = Vfs::mode2int($mode,$set); |
|
366 | - $params = array($url,$set); |
|
365 | + $set = Vfs::mode2int($mode, $set); |
|
366 | + $params = array($url, $set); |
|
367 | 367 | break; |
368 | 368 | case 'chown': |
369 | 369 | case 'chgrp': |
370 | 370 | $type = $cmd == 'chgrp' ? 'group' : 'user'; |
371 | 371 | if (!isset($owner)) |
372 | 372 | { |
373 | - $owner = $url; // first param is owner/group |
|
373 | + $owner = $url; // first param is owner/group |
|
374 | 374 | $url = array_shift($argv); |
375 | - load_wrapper($url); // not loaded because owner/group was in url |
|
375 | + load_wrapper($url); // not loaded because owner/group was in url |
|
376 | 376 | if ($owner == 'root') |
377 | 377 | { |
378 | 378 | $owner = 0; |
@@ -383,34 +383,34 @@ discard block |
||
383 | 383 | { |
384 | 384 | die("only numeric user/group-id's allowed for non eGW streams!"); |
385 | 385 | } |
386 | - if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) || |
|
386 | + if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was = $owner, 'account_lid', $type[0])) || |
|
387 | 387 | ($owner < 0) != ($cmd == 'chgrp')) |
388 | 388 | { |
389 | 389 | die("Unknown $type '$owner_was'!"); |
390 | 390 | } |
391 | 391 | } |
392 | - elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
|
392 | + elseif ($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
|
393 | 393 | ($owner < 0) != ($cmd == 'chgrp'))) |
394 | 394 | { |
395 | 395 | die("Unknown $type '$owner_was'!"); |
396 | 396 | } |
397 | 397 | } |
398 | - $params = array($url,$owner); |
|
398 | + $params = array($url, $owner); |
|
399 | 399 | break; |
400 | 400 | } |
401 | - if (($scheme = Vfs::parse_url($url,PHP_URL_SCHEME))) |
|
401 | + if (($scheme = Vfs::parse_url($url, PHP_URL_SCHEME))) |
|
402 | 402 | { |
403 | 403 | load_wrapper($url); |
404 | 404 | } |
405 | 405 | if ($recursive && class_exists('EGroupware\\Api\\Vfs')) |
406 | 406 | { |
407 | - array_unshift($argv,$url); |
|
408 | - $params = array($argv,null,$cmd,$params[1]); |
|
409 | - $cmd = array('EGroupware\\Api\\Vfs','find'); |
|
410 | - $argv = array(); // we processed all url's |
|
407 | + array_unshift($argv, $url); |
|
408 | + $params = array($argv, null, $cmd, $params[1]); |
|
409 | + $cmd = array('EGroupware\\Api\\Vfs', 'find'); |
|
410 | + $argv = array(); // we processed all url's |
|
411 | 411 | } |
412 | 412 | //echo "calling cmd=".print_r($cmd,true).", params=".print_r($params,true)."\n"; |
413 | - call_user_func_array($cmd,$params); |
|
413 | + call_user_func_array($cmd, $params); |
|
414 | 414 | break; |
415 | 415 | |
416 | 416 | case 'cat': |
@@ -420,35 +420,35 @@ discard block |
||
420 | 420 | if ($cmd != 'cat' && $recursive && class_exists('EGroupware\\Api\\Vfs')) |
421 | 421 | { |
422 | 422 | load_wrapper($url); |
423 | - array_unshift($argv,$url); |
|
424 | - Vfs::find($argv,array('url'=>true,),'do_stat',array($long,$numeric,true,$inode)); |
|
423 | + array_unshift($argv, $url); |
|
424 | + Vfs::find($argv, array('url'=>true,), 'do_stat', array($long, $numeric, true, $inode)); |
|
425 | 425 | $argv = array(); |
426 | 426 | } |
427 | 427 | elseif (is_dir($url) && ($dir = opendir($url))) |
428 | 428 | { |
429 | 429 | if ($argc) |
430 | 430 | { |
431 | - if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/'; |
|
431 | + if (!($name = basename(Vfs::parse_url($url, PHP_URL_PATH)))) $name = '/'; |
|
432 | 432 | echo "\n$name:\n"; |
433 | 433 | } |
434 | 434 | // separate evtl. query part, to re-add it after the file-name |
435 | 435 | unset($query); |
436 | - list($url,$query) = explode('?',$url,2); |
|
436 | + list($url, $query) = explode('?', $url, 2); |
|
437 | 437 | if ($query) $query = '?'.$query; |
438 | 438 | |
439 | - if (substr($url,-1) == '/') |
|
439 | + if (substr($url, -1) == '/') |
|
440 | 440 | { |
441 | - $url = substr($url,0,-1); |
|
441 | + $url = substr($url, 0, -1); |
|
442 | 442 | } |
443 | - while(($file = readdir($dir)) !== false) |
|
443 | + while (($file = readdir($dir)) !== false) |
|
444 | 444 | { |
445 | - do_stat($url.'/'.$file.$query,$long,$numeric,false,$inode); |
|
445 | + do_stat($url.'/'.$file.$query, $long, $numeric, false, $inode); |
|
446 | 446 | } |
447 | 447 | closedir($dir); |
448 | 448 | } |
449 | 449 | elseif ($cmd == 'cat') |
450 | 450 | { |
451 | - if (!($f = fopen($url,'r'))) |
|
451 | + if (!($f = fopen($url, 'r'))) |
|
452 | 452 | { |
453 | 453 | echo "File $url not found !!!\n\n"; |
454 | 454 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | { |
457 | 457 | if ($argc) |
458 | 458 | { |
459 | - echo "\n".basename(Vfs::parse_url($url,PHP_URL_PATH)).":\n"; |
|
459 | + echo "\n".basename(Vfs::parse_url($url, PHP_URL_PATH)).":\n"; |
|
460 | 460 | } |
461 | 461 | fpassthru($f); |
462 | 462 | fclose($f); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | } |
465 | 465 | else |
466 | 466 | { |
467 | - do_stat($url,$long,$numeric,false,$inode); |
|
467 | + do_stat($url, $long, $numeric, false, $inode); |
|
468 | 468 | } |
469 | 469 | if (!$long && $cmd == 'ls') echo "\n"; |
470 | 470 | break; |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | */ |
480 | 480 | function load_wrapper($url) |
481 | 481 | { |
482 | - if (($scheme = parse_url($url,PHP_URL_SCHEME)) && |
|
482 | + if (($scheme = parse_url($url, PHP_URL_SCHEME)) && |
|
483 | 483 | !in_array($scheme, stream_get_wrappers())) |
484 | 484 | { |
485 | - switch($scheme) |
|
485 | + switch ($scheme) |
|
486 | 486 | { |
487 | 487 | case 'webdav': |
488 | 488 | case 'webdavs': |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | break; |
491 | 491 | |
492 | 492 | default: |
493 | - if (!isset($GLOBALS['egw']) && !in_array($scheme,array('smb','imap')) && |
|
494 | - ($user = parse_url($url,PHP_URL_USER)) && ($pass = parse_url($url,PHP_URL_PASS))) |
|
493 | + if (!isset($GLOBALS['egw']) && !in_array($scheme, array('smb', 'imap')) && |
|
494 | + ($user = parse_url($url, PHP_URL_USER)) && ($pass = parse_url($url, PHP_URL_PASS))) |
|
495 | 495 | { |
496 | - load_egw($user, $pass, ($host = parse_url($url,PHP_URL_HOST)) ? $host : 'default'); |
|
496 | + load_egw($user, $pass, ($host = parse_url($url, PHP_URL_HOST)) ? $host : 'default'); |
|
497 | 497 | } |
498 | 498 | // get eGW's __autoload() function |
499 | 499 | include_once(EGW_SERVER_ROOT.'/api/src/loader/common.php'); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param string $passwd |
515 | 515 | * @param string $domain |
516 | 516 | */ |
517 | -function load_egw($user,$passwd,$domain='default') |
|
517 | +function load_egw($user, $passwd, $domain = 'default') |
|
518 | 518 | { |
519 | 519 | //echo "load_egw($user,$passwd,$domain)\n"; |
520 | 520 | $_REQUEST['domain'] = $domain; |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
528 | 528 | { |
529 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
529 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | $GLOBALS['egw_info'] = array( |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | ) |
539 | 539 | ); |
540 | 540 | |
541 | - if (substr($user,0,5) != 'root_') |
|
541 | + if (substr($user, 0, 5) != 'root_') |
|
542 | 542 | { |
543 | 543 | include('../header.inc.php'); |
544 | 544 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | $cmd = $GLOBALS['cmd']; |
567 | - if (!in_array($cmd,array('ls','find','mount','umount','eacl','touch','chmod','chown','chgrp')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
567 | + if (!in_array($cmd, array('ls', 'find', 'mount', 'umount', 'eacl', 'touch', 'chmod', 'chown', 'chgrp')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
568 | 568 | { |
569 | 569 | echo "\nError: eGroupWare's files directory {$GLOBALS['egw_info']['server']['files_dir']} is NOT writable by the user running ".basename(__FILE__)."!\n". |
570 | 570 | "--> Please run it as the same user the webserver uses or root, otherwise the $cmd command will fail!\n\n"; |
@@ -595,22 +595,22 @@ discard block |
||
595 | 595 | } |
596 | 596 | if ($argc == 1) |
597 | 597 | { |
598 | - foreach(Vfs::get_eacl($url) as $acl) |
|
598 | + foreach (Vfs::get_eacl($url) as $acl) |
|
599 | 599 | { |
600 | - $mode = ($acl['rights'] & Vfs::READABLE ? 'r' : '-'). |
|
601 | - ($acl['rights'] & Vfs::WRITABLE ? 'w' : '-'). |
|
602 | - ($acl['rights'] & Vfs::EXECUTABLE ? 'x' : '-'); |
|
600 | + $mode = ($acl['rights']&Vfs::READABLE ? 'r' : '-'). |
|
601 | + ($acl['rights']&Vfs::WRITABLE ? 'w' : '-'). |
|
602 | + ($acl['rights']&Vfs::EXECUTABLE ? 'x' : '-'); |
|
603 | 603 | echo $acl['path']."\t$mode\t".$GLOBALS['egw']->accounts->id2name($acl['owner'])."\n"; |
604 | 604 | } |
605 | 605 | return; |
606 | 606 | } |
607 | 607 | if ($argc > 1 && !is_numeric($argv[1])) |
608 | 608 | { |
609 | - $mode=$argv[1]; |
|
609 | + $mode = $argv[1]; |
|
610 | 610 | $argv[1] = null; |
611 | - for($i = 0; $mode[$i]; ++$i) |
|
611 | + for ($i = 0; $mode[$i]; ++$i) |
|
612 | 612 | { |
613 | - switch($mode[$i]) |
|
613 | + switch ($mode[$i]) |
|
614 | 614 | { |
615 | 615 | case 'x': $argv[1] |= Vfs::EXECUTABLE; break; |
616 | 616 | case 'w': $argv[1] |= Vfs::WRITABLE; break; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | - if (!Vfs::eacl($url,$argv[1],$argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2])) |
|
621 | + if (!Vfs::eacl($url, $argv[1], $argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2])) |
|
622 | 622 | { |
623 | 623 | echo "Error setting extended Acl for $argv[0]!\n"; |
624 | 624 | } |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | * @param boolean $full_path =false true=give full path instead of just filename |
634 | 634 | * @param boolean $inode =false true=display inode (sqlfs id) |
635 | 635 | */ |
636 | -function do_stat($url,$long=false,$numeric=false,$full_path=false,$inode=false) |
|
636 | +function do_stat($url, $long = false, $numeric = false, $full_path = false, $inode = false) |
|
637 | 637 | { |
638 | 638 | //echo "do_stat($url,$long,$numeric,$full_path)\n"; |
639 | - $bname = Vfs::parse_url($url,PHP_URL_PATH); |
|
639 | + $bname = Vfs::parse_url($url, PHP_URL_PATH); |
|
640 | 640 | |
641 | 641 | if (!$full_path) |
642 | 642 | { |
@@ -667,25 +667,23 @@ discard block |
||
667 | 667 | { |
668 | 668 | if ($stat['uid']) |
669 | 669 | { |
670 | - $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : |
|
671 | - (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
|
670 | + $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
|
672 | 671 | if (is_array($uid)) $uid = $uid['name']; |
673 | 672 | if (empty($uid)) $uid = $stat['uid']; |
674 | 673 | } |
675 | 674 | if (!isset($uid)) $uid = 'root'; |
676 | 675 | if ($stat['gid']) |
677 | 676 | { |
678 | - $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : |
|
679 | - (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
|
677 | + $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
|
680 | 678 | if (is_array($gid)) $gid = $gid['name']; |
681 | 679 | if (empty($gid)) $gid = $stat['gid']; |
682 | 680 | } |
683 | 681 | if (!isset($gid)) $gid = 'root'; |
684 | 682 | } |
685 | 683 | $size = hsize($stat['size']); |
686 | - $mtime = date('Y-m-d H:i:s',$stat['mtime']); |
|
684 | + $mtime = date('Y-m-d H:i:s', $stat['mtime']); |
|
687 | 685 | $nlink = $stat['nlink']; |
688 | - if (($stat['mode'] & 0xA000) == 0xA000) |
|
686 | + if (($stat['mode']&0xA000) == 0xA000) |
|
689 | 687 | { |
690 | 688 | $symlink = " -> ".(class_exists('EGroupware\\Api\\Vfs') ? Vfs::readlink($url) : readlink($url)); |
691 | 689 | } |
@@ -704,12 +702,12 @@ discard block |
||
704 | 702 | function hsize($size) |
705 | 703 | { |
706 | 704 | if ($size < 1024) return $size; |
707 | - if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024); |
|
708 | - return sprintf('%3.1lfM',(float)$size/(1024*1024)); |
|
705 | + if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024); |
|
706 | + return sprintf('%3.1lfM', (float)$size / (1024 * 1024)); |
|
709 | 707 | } |
710 | 708 | |
711 | 709 | |
712 | -function do_cp($argv,$recursive=false,$perms=false) |
|
710 | +function do_cp($argv, $recursive = false, $perms = false) |
|
713 | 711 | { |
714 | 712 | $to = array_pop($argv); |
715 | 713 | load_wrapper($to); |
@@ -721,13 +719,13 @@ discard block |
||
721 | 719 | usage("No such directory '$to'!"); |
722 | 720 | } |
723 | 721 | $anz_dirs = $anz_files = 0; |
724 | - foreach($argv as $from) |
|
722 | + foreach ($argv as $from) |
|
725 | 723 | { |
726 | 724 | if (is_dir($from) && (!file_exists($to) || is_dir($to)) && $recursive && class_exists('EGroupware\\Api\\Vfs')) |
727 | 725 | { |
728 | - foreach(Vfs::find($from,array('url' => true)) as $f) |
|
726 | + foreach (Vfs::find($from, array('url' => true)) as $f) |
|
729 | 727 | { |
730 | - $t = $to.substr($f,strlen($from)); |
|
728 | + $t = $to.substr($f, strlen($from)); |
|
731 | 729 | if (is_dir($f)) |
732 | 730 | { |
733 | 731 | ++$anz_dirs; |
@@ -736,43 +734,43 @@ discard block |
||
736 | 734 | else |
737 | 735 | { |
738 | 736 | ++$anz_files; |
739 | - _cp($f,$t); |
|
737 | + _cp($f, $t); |
|
740 | 738 | } |
741 | - if ($perms) _cp_perms($f,$t); |
|
739 | + if ($perms) _cp_perms($f, $t); |
|
742 | 740 | } |
743 | - echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n"; |
|
741 | + echo ($anz_dirs ? "$anz_dirs dir(s) created and " : '')."$anz_files file(s) copied.\n"; |
|
744 | 742 | } |
745 | 743 | else |
746 | 744 | { |
747 | - _cp($from,$to,true); |
|
748 | - if ($perms) _cp_perms($from,$to); |
|
745 | + _cp($from, $to, true); |
|
746 | + if ($perms) _cp_perms($from, $to); |
|
749 | 747 | } |
750 | 748 | } |
751 | 749 | } |
752 | 750 | |
753 | -function _cp($from,$to,$verbose=false) |
|
751 | +function _cp($from, $to, $verbose = false) |
|
754 | 752 | { |
755 | 753 | load_wrapper($from); |
756 | 754 | |
757 | 755 | if (is_dir($to)) |
758 | 756 | { |
759 | - $path = Vfs::parse_url($from,PHP_URL_PATH); |
|
757 | + $path = Vfs::parse_url($from, PHP_URL_PATH); |
|
760 | 758 | if (is_dir($to)) |
761 | 759 | { |
762 | - list($to,$query) = explode('?',$to,2); |
|
760 | + list($to, $query) = explode('?', $to, 2); |
|
763 | 761 | $to .= '/'.basename($path).($query ? '?'.$query : ''); |
764 | 762 | } |
765 | 763 | } |
766 | - if (!($from_fp = fopen($from,'r'))) |
|
764 | + if (!($from_fp = fopen($from, 'r'))) |
|
767 | 765 | { |
768 | 766 | die("File $from not found!\n"); |
769 | 767 | } |
770 | - if (!($to_fp = fopen($to,'w'))) |
|
768 | + if (!($to_fp = fopen($to, 'w'))) |
|
771 | 769 | { |
772 | 770 | die("Can't open $to for writing!\n"); |
773 | 771 | } |
774 | 772 | //stream_filter_append($from_fp,'convert.base64-decode'); |
775 | - $count = stream_copy_to_stream($from_fp,$to_fp); |
|
773 | + $count = stream_copy_to_stream($from_fp, $to_fp); |
|
776 | 774 | |
777 | 775 | if ($verbose) echo hsize($count)." bytes written to $to\n"; |
778 | 776 | |
@@ -785,11 +783,11 @@ discard block |
||
785 | 783 | } |
786 | 784 | |
787 | 785 | |
788 | -function _cp_perms($from,$to) |
|
786 | +function _cp_perms($from, $to) |
|
789 | 787 | { |
790 | 788 | if (($from_stat = stat($from)) && ($to_stat = stat($to))) |
791 | 789 | { |
792 | - foreach(array( |
|
790 | + foreach (array( |
|
793 | 791 | 'mode' => 'chmod', |
794 | 792 | 'uid' => 'chown', |
795 | 793 | 'gid' => 'chgrp', |
@@ -798,27 +796,27 @@ discard block |
||
798 | 796 | if ($from_stat[$perm] != $to_stat[$perm]) |
799 | 797 | { |
800 | 798 | //echo "Vfs::$cmd($to,{$from_stat[$perm]}\n"; |
801 | - call_user_func(array('EGroupware\\Api\\Vfs',$cmd),$to,$from_stat[$perm]); |
|
799 | + call_user_func(array('EGroupware\\Api\\Vfs', $cmd), $to, $from_stat[$perm]); |
|
802 | 800 | } |
803 | 801 | } |
804 | 802 | } |
805 | 803 | } |
806 | 804 | |
807 | -function do_find($bases,$options) |
|
805 | +function do_find($bases, $options) |
|
808 | 806 | { |
809 | - foreach($bases as $url) |
|
807 | + foreach ($bases as $url) |
|
810 | 808 | { |
811 | 809 | load_wrapper($url); |
812 | 810 | } |
813 | - $options['url'] = true; // we use url's not vfs pathes in filemanager/cli.php |
|
811 | + $options['url'] = true; // we use url's not vfs pathes in filemanager/cli.php |
|
814 | 812 | |
815 | - foreach(Vfs::find($bases,$options) as $path) |
|
813 | + foreach (Vfs::find($bases, $options) as $path) |
|
816 | 814 | { |
817 | 815 | echo "$path\n"; |
818 | 816 | } |
819 | 817 | } |
820 | 818 | |
821 | -function do_lntree($from,$to) |
|
819 | +function do_lntree($from, $to) |
|
822 | 820 | { |
823 | 821 | echo "lntree $from $to\n"; |
824 | 822 | if ($from[0] == '/') $from = 'sqlfs://default'.$from; |
@@ -881,33 +879,33 @@ discard block |
||
881 | 879 | * @param int $mode |
882 | 880 | * @return string |
883 | 881 | */ |
884 | -function int2mode( $mode ) |
|
882 | +function int2mode($mode) |
|
885 | 883 | { |
886 | - if(($mode & 0xA000) == 0xA000) // Symbolic Link |
|
884 | + if (($mode&0xA000) == 0xA000) // Symbolic Link |
|
887 | 885 | { |
888 | 886 | $sP = 'l'; |
889 | 887 | } |
890 | - elseif(($mode & 0xC000) == 0xC000) // Socket |
|
888 | + elseif (($mode&0xC000) == 0xC000) // Socket |
|
891 | 889 | { |
892 | 890 | $sP = 's'; |
893 | 891 | } |
894 | - elseif($mode & 0x1000) // FIFO pipe |
|
892 | + elseif ($mode&0x1000) // FIFO pipe |
|
895 | 893 | { |
896 | 894 | $sP = 'p'; |
897 | 895 | } |
898 | - elseif($mode & 0x2000) // Character special |
|
896 | + elseif ($mode&0x2000) // Character special |
|
899 | 897 | { |
900 | 898 | $sP = 'c'; |
901 | 899 | } |
902 | - elseif($mode & 0x4000) // Directory |
|
900 | + elseif ($mode&0x4000) // Directory |
|
903 | 901 | { |
904 | 902 | $sP = 'd'; |
905 | 903 | } |
906 | - elseif($mode & 0x6000) // Block special |
|
904 | + elseif ($mode&0x6000) // Block special |
|
907 | 905 | { |
908 | 906 | $sP = 'b'; |
909 | 907 | } |
910 | - elseif($mode & 0x8000) // Regular |
|
908 | + elseif ($mode&0x8000) // Regular |
|
911 | 909 | { |
912 | 910 | $sP = '-'; |
913 | 911 | } |
@@ -917,22 +915,19 @@ discard block |
||
917 | 915 | } |
918 | 916 | |
919 | 917 | // owner |
920 | - $sP .= (($mode & 0x0100) ? 'r' : '-') . |
|
921 | - (($mode & 0x0080) ? 'w' : '-') . |
|
922 | - (($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) : |
|
923 | - (($mode & 0x0800) ? 'S' : '-')); |
|
918 | + $sP .= (($mode&0x0100) ? 'r' : '-'). |
|
919 | + (($mode&0x0080) ? 'w' : '-'). |
|
920 | + (($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-')); |
|
924 | 921 | |
925 | 922 | // group |
926 | - $sP .= (($mode & 0x0020) ? 'r' : '-') . |
|
927 | - (($mode & 0x0010) ? 'w' : '-') . |
|
928 | - (($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) : |
|
929 | - (($mode & 0x0400) ? 'S' : '-')); |
|
923 | + $sP .= (($mode&0x0020) ? 'r' : '-'). |
|
924 | + (($mode&0x0010) ? 'w' : '-'). |
|
925 | + (($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-')); |
|
930 | 926 | |
931 | 927 | // world |
932 | - $sP .= (($mode & 0x0004) ? 'r' : '-') . |
|
933 | - (($mode & 0x0002) ? 'w' : '-') . |
|
934 | - (($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) : |
|
935 | - (($mode & 0x0200) ? 'T' : '-')); |
|
928 | + $sP .= (($mode&0x0004) ? 'r' : '-'). |
|
929 | + (($mode&0x0002) ? 'w' : '-'). |
|
930 | + (($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-')); |
|
936 | 931 | |
937 | 932 | return $sP; |
938 | 933 | } |
@@ -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').')'; |
@@ -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,'cd'=>'no')); |
|
41 | + echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ', '/filemanager/test.php', array('path'=>$p, 'cd'=>'no')); |
|
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,'cd'=>'no')); |
|
64 | + $file = Api\Html::a_href($file, '/filemanager/test.php', array('path'=>$fpath, 'cd'=>'no')); |
|
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); |
@@ -178,15 +178,17 @@ discard block |
||
178 | 178 | $acl = new Acl($anon_user); |
179 | 179 | $acl->read_repository(); |
180 | 180 | foreach ($calendar_bo->resources as $type => $data) |
181 | - { |
|
181 | + { |
|
182 | 182 | // Check anon user's permissions - must have at least run for the hook to be available |
183 | 183 | if($acl->check('run',EGW_ACL_READ, $data['app']) && |
184 | 184 | $type != '' && $data['app'] && Link::get_registry($data['app'], 'query') |
185 | - ) |
|
186 | - { |
|
185 | + ) { |
|
187 | 186 | $_results = Link::query($data['app'], $query,$options); |
188 | 187 | } |
189 | - if(!$_results) continue; |
|
188 | + if(!$_results) |
|
189 | + { |
|
190 | + continue; |
|
191 | + } |
|
190 | 192 | $_results = array_unique($_results); |
191 | 193 | foreach ($_results as $key => $value) |
192 | 194 | { |
@@ -223,8 +225,14 @@ discard block |
||
223 | 225 | $arguments['sortby'] = 'month'; |
224 | 226 | $arguments['date'] = substr($arguments['date'],0,4).'0101'; |
225 | 227 | } |
226 | - if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
|
227 | - if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
|
228 | + if (isset($_GET['date'])) |
|
229 | + { |
|
230 | + $arguments['date'] = $_GET['date']; |
|
231 | + } |
|
232 | + if (empty($arguments['cat_id'])) |
|
233 | + { |
|
234 | + $arguments['cat_id'] = ''; |
|
235 | + } |
|
228 | 236 | if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
229 | 237 | { |
230 | 238 | foreach($arguments['resources'] as $index => $value) |
@@ -259,7 +267,8 @@ discard block |
||
259 | 267 | if (is_array($params['owner'])) |
260 | 268 | { |
261 | 269 | // Buffer, and add anything that gets cleared to the content |
262 | - ob_start(function($buffer) use(&$html) { |
|
270 | + ob_start(function($buffer) use(&$html) |
|
271 | + { |
|
263 | 272 | $html .= $buffer; |
264 | 273 | return ''; |
265 | 274 | }); |
@@ -268,20 +277,26 @@ discard block |
||
268 | 277 | $ui->sortby = $arguments['sortby']; |
269 | 278 | $ui->owner = $params['owner']; |
270 | 279 | |
271 | - if (!$ui->planner_view || $ui->planner_view == 'month') // planner monthview |
|
280 | + if (!$ui->planner_view || $ui->planner_view == 'month') |
|
281 | + { |
|
282 | + // planner monthview |
|
272 | 283 | { |
273 | 284 | if ($ui->day < 15) // show one complete month |
274 | 285 | { |
275 | 286 | $ui->_week_align_month($ui->first,$ui->last); |
287 | + } |
|
276 | 288 | } |
277 | 289 | else // show 2 half month |
278 | 290 | { |
279 | 291 | $ui->_week_align_month($ui->first,$ui->last,15); |
280 | 292 | } |
281 | 293 | } |
282 | - elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') // weeekview |
|
294 | + elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') |
|
295 | + { |
|
296 | + // weeekview |
|
283 | 297 | { |
284 | 298 | $start = new Api\DateTime($ui->date); |
299 | + } |
|
285 | 300 | $start->setWeekstart(); |
286 | 301 | $ui->first = $start->format('ts'); |
287 | 302 | $ui->last = $ui->bo->date2array($this->first); |
@@ -327,7 +327,7 @@ |
||
327 | 327 | // rest of the calendar app is probably missing. |
328 | 328 | foreach($search_params['owner'] as $owner) |
329 | 329 | { |
330 | - $sel_options['owner'][] = Array( |
|
330 | + $sel_options['owner'][] = array( |
|
331 | 331 | 'id' => $owner, |
332 | 332 | 'value' => $owner, |
333 | 333 | 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'cat_id' => array( |
49 | 49 | 'type' => 'select', |
50 | 50 | 'label' => lang('Choose a category'), |
51 | - 'options' => array(), // done by get_user_interface() |
|
51 | + 'options' => array(), // done by get_user_interface() |
|
52 | 52 | 'multiple' => true, |
53 | 53 | ), |
54 | 54 | 'owner' => array( |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function get_user_interface() |
95 | 95 | { |
96 | - $cats = new Api\Categories('','calendar'); |
|
97 | - foreach($cats->return_array('all',0,False,'','cat_name','',True) as $cat) |
|
96 | + $cats = new Api\Categories('', 'calendar'); |
|
97 | + foreach ($cats->return_array('all', 0, False, '', 'cat_name', '', True) as $cat) |
|
98 | 98 | { |
99 | - $this->arguments['cat_id']['options'][$cat['id']] = str_repeat(' ',$cat['level']).$cat['name']; |
|
99 | + $this->arguments['cat_id']['options'][$cat['id']] = str_repeat(' ', $cat['level']).$cat['name']; |
|
100 | 100 | } |
101 | 101 | if (count($this->arguments['cat_id']['options']) > 5) |
102 | 102 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
109 | 109 | } |
110 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
110 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
111 | 111 | $search_params = array( |
112 | 112 | 'type' => 'both', |
113 | 113 | 'app' => 'calendar', |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $users = array(); |
118 | 118 | $groups = array(); |
119 | 119 | // sort users and groups separately. |
120 | - $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u'); |
|
121 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
120 | + $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'], 'account_lid', 'u'); |
|
121 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
122 | 122 | foreach ($accounts as $entry) |
123 | 123 | { |
124 | 124 | $is_group = false; |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | $acl = new Acl($entry['account_id']); |
127 | 127 | $acl->read_repository(); |
128 | 128 | // get the rights for each account to check whether the anon user has read permissions. |
129 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
129 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
130 | 130 | // also add the anon user if it's his own calendar. |
131 | - if ($calendar_bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$entry['account_id'],'ts',null,$anon_user) || ($entry['account_id'] == $anon_user)) |
|
131 | + if ($calendar_bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $entry['account_id'], 'ts', null, $anon_user) || ($entry['account_id'] == $anon_user)) |
|
132 | 132 | { |
133 | 133 | $has_read_permissions = true; |
134 | 134 | } |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | // or ass permissions if this is the anon group's calendar. |
139 | 139 | foreach ($anon_groups as $parent_group) |
140 | 140 | { |
141 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
142 | - if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
141 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
142 | + if (($rights&Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
143 | 143 | { |
144 | 144 | $has_read_permissions = true; |
145 | 145 | break; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | else |
157 | 157 | { |
158 | - $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
158 | + $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | foreach ($calendar_bo->resources as $type => $data) |
181 | 181 | { |
182 | 182 | // Check anon user's permissions - must have at least run for the hook to be available |
183 | - if($acl->check('run',EGW_ACL_READ, $data['app']) && |
|
183 | + if ($acl->check('run', EGW_ACL_READ, $data['app']) && |
|
184 | 184 | $type != '' && $data['app'] && Link::get_registry($data['app'], 'query') |
185 | 185 | ) |
186 | 186 | { |
187 | - $_results = Link::query($data['app'], $query,$options); |
|
187 | + $_results = Link::query($data['app'], $query, $options); |
|
188 | 188 | } |
189 | - if(!$_results) continue; |
|
189 | + if (!$_results) continue; |
|
190 | 190 | $_results = array_unique($_results); |
191 | 191 | foreach ($_results as $key => $value) |
192 | 192 | { |
193 | - if($calendar_bo->check_perms(Acl::READ,0,$type.$key,'ts',null,$anon_user)) |
|
193 | + if ($calendar_bo->check_perms(Acl::READ, 0, $type.$key, 'ts', null, $anon_user)) |
|
194 | 194 | { |
195 | 195 | $this->arguments['resources']['options'][$type.$key] = $value; |
196 | 196 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param $arguments |
210 | 210 | * @param $properties |
211 | 211 | */ |
212 | - function get_content(&$arguments,$properties) |
|
212 | + function get_content(&$arguments, $properties) |
|
213 | 213 | { |
214 | 214 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
215 | 215 | |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | if ($arguments['sortby'] == 'yearly') |
222 | 222 | { |
223 | 223 | $arguments['sortby'] = 'month'; |
224 | - $arguments['date'] = substr($arguments['date'],0,4).'0101'; |
|
224 | + $arguments['date'] = substr($arguments['date'], 0, 4).'0101'; |
|
225 | 225 | } |
226 | 226 | if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
227 | 227 | if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
228 | - if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
|
228 | + if (isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
|
229 | 229 | { |
230 | - foreach($arguments['resources'] as $index => $value) |
|
230 | + foreach ($arguments['resources'] as $index => $value) |
|
231 | 231 | { |
232 | - if($value == 'r0') |
|
232 | + if ($value == 'r0') |
|
233 | 233 | { |
234 | 234 | unset($arguments['resources'][$index]); |
235 | 235 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | { |
273 | 273 | if ($ui->day < 15) // show one complete month |
274 | 274 | { |
275 | - $ui->_week_align_month($ui->first,$ui->last); |
|
275 | + $ui->_week_align_month($ui->first, $ui->last); |
|
276 | 276 | } |
277 | 277 | else // show 2 half month |
278 | 278 | { |
279 | - $ui->_week_align_month($ui->first,$ui->last,15); |
|
279 | + $ui->_week_align_month($ui->first, $ui->last, 15); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') // weeekview |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $start->setWeekstart(); |
286 | 286 | $ui->first = $start->format('ts'); |
287 | 287 | $ui->last = $ui->bo->date2array($this->first); |
288 | - $ui->last['day'] += ($ui->planner_view == 'week' ? 7 : 7 * $ui->cal_prefs['multiple_weeks'])-1; |
|
288 | + $ui->last['day'] += ($ui->planner_view == 'week' ? 7 : 7 * $ui->cal_prefs['multiple_weeks']) - 1; |
|
289 | 289 | $ui->last['hour'] = 23; $ui->last['minute'] = $ui->last['sec'] = 59; |
290 | 290 | unset($ui->last['raw']); |
291 | 291 | $ui->last = $ui->bo->date2ts($ui->last); |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | $content = array(); |
311 | 311 | $sel_options = array(); |
312 | 312 | $content['planner'] = $ui->bo->search($search_params); |
313 | - foreach($content['planner'] as &$event) |
|
313 | + foreach ($content['planner'] as &$event) |
|
314 | 314 | { |
315 | 315 | $ui->to_client($event); |
316 | 316 | } |
317 | 317 | |
318 | 318 | $tmpl = new Etemplate('calendar.planner'); |
319 | 319 | |
320 | - $tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($ui->first, Api\DateTime::ET2)); |
|
321 | - $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); |
|
322 | - $tmpl->setElementAttribute('planner','owner', $search_params['owner']); |
|
323 | - $tmpl->setElementAttribute('planner','group_by', $ui->sortby); |
|
320 | + $tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($ui->first, Api\DateTime::ET2)); |
|
321 | + $tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); |
|
322 | + $tmpl->setElementAttribute('planner', 'owner', $search_params['owner']); |
|
323 | + $tmpl->setElementAttribute('planner', 'group_by', $ui->sortby); |
|
324 | 324 | |
325 | 325 | // Make sure all used owners are there, faking |
326 | 326 | // calendar_owner_etemplate_widget::beforeSendToClient() since the |
327 | 327 | // rest of the calendar app is probably missing. |
328 | - foreach($search_params['owner'] as $owner) |
|
328 | + foreach ($search_params['owner'] as $owner) |
|
329 | 329 | { |
330 | 330 | $sel_options['owner'][] = Array( |
331 | 331 | 'id' => $owner, |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) |
334 | 334 | ); |
335 | 335 | } |
336 | - $tmpl->exec(__METHOD__, $content,$sel_options, array('__ALL__' => true),array(),2); |
|
336 | + $tmpl->exec(__METHOD__, $content, $sel_options, array('__ALL__' => true), array(), 2); |
|
337 | 337 | $html .= ob_get_contents(); |
338 | 338 | $html .= '<script>' |
339 | 339 | . '(function() {jQuery("#calendar-planner").on("load",function() {' |
340 | - . 'app.calendar.update_state(' . json_encode(array( |
|
340 | + . 'app.calendar.update_state('.json_encode(array( |
|
341 | 341 | 'view' => 'planner', |
342 | 342 | 'planner_view' => 'month', |
343 | 343 | 'date' => Api\DateTime::to($ui->first, Api\DateTime::ET2), |
@@ -115,7 +115,8 @@ |
||
115 | 115 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
116 | 116 | } |
117 | 117 | $this->arguments['category']['options'] = $cat_ids; |
118 | - if (count($cat_ids) > 5) { |
|
118 | + if (count($cat_ids) > 5) |
|
119 | + { |
|
119 | 120 | $this->arguments['category']['multiple'] = 5; |
120 | 121 | } |
121 | 122 |
@@ -252,7 +252,7 @@ |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | // set the search parameters |
255 | - $search_params = Array |
|
255 | + $search_params = array |
|
256 | 256 | ( |
257 | 257 | 'offset' => false, |
258 | 258 | 'order' => 'cal_start ASC', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'category' => array( |
56 | 56 | 'type' => 'select', |
57 | 57 | 'label' => lang('Choose a category'), |
58 | - 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
58 | + 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
59 | 59 | 'multiple' => true, |
60 | 60 | ), |
61 | 61 | 'numWeeks' => array( |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | function get_user_interface() |
108 | 108 | { |
109 | 109 | // copied from bookmarks module. |
110 | - $cat = createobject('phpgwapi.categories','','calendar'); |
|
111 | - $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
|
110 | + $cat = createobject('phpgwapi.categories', '', 'calendar'); |
|
111 | + $cats = $cat->return_array('all', 0, False, '', 'cat_name', '', True); |
|
112 | 112 | $cat_ids = array(); |
113 | - foreach($cats as $category) |
|
113 | + foreach ($cats as $category) |
|
114 | 114 | { |
115 | 115 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
116 | 116 | } |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | $this->arguments['category']['multiple'] = 5; |
120 | 120 | } |
121 | 121 | |
122 | - if (! isset($GLOBALS['egw']->accounts)) |
|
122 | + if (!isset($GLOBALS['egw']->accounts)) |
|
123 | 123 | { |
124 | 124 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
125 | 125 | } |
126 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
127 | - $search_params=array( |
|
126 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
127 | + $search_params = array( |
|
128 | 128 | 'type' => 'both', |
129 | 129 | 'app' => 'calendar', |
130 | 130 | ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // sort users and groups separately. |
135 | 135 | if (isset($GLOBALS['sitemgr_info']['anonymous_user'])) |
136 | 136 | { |
137 | - $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u'); |
|
137 | + $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'], 'account_lid', 'u'); |
|
138 | 138 | } |
139 | 139 | else |
140 | 140 | { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the |
144 | 144 | * anonymous user for the correct site. |
145 | 145 | */ |
146 | - $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']); |
|
146 | + $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/', "/\${1}", $_SERVER['HTTP_REFERER']); |
|
147 | 147 | // Remove the trailing file- / pathname if any |
148 | 148 | $sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path); |
149 | 149 | // Add leading slash if it has been lost. |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | // Code adapted from sitemgr-site/index.php |
156 | 156 | $site_urls = array(); |
157 | 157 | $site_urls[] = $sitemgr_path; |
158 | - $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path; |
|
159 | - $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path; |
|
158 | + $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$sitemgr_path; |
|
159 | + $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$sitemgr_path; |
|
160 | 160 | |
161 | - $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id', |
|
162 | - array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr')->fetchColumn(),'account_lid','u'); |
|
161 | + $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->select('egw_sitemgr_sites', 'anonymous_user,anonymous_passwd,site_id', |
|
162 | + array('site_url' => $site_urls), __LINE__, __FILE__, false, '', 'sitemgr')->fetchColumn(), 'account_lid', 'u'); |
|
163 | 163 | } |
164 | 164 | |
165 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
165 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
166 | 166 | foreach ($accounts as $entry) |
167 | 167 | { |
168 | 168 | $is_group = false; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | $acl = new Acl($entry['account_id']); |
171 | 171 | $acl->read_repository(); |
172 | 172 | // get the rights for each account to check whether the anon user has read permissions. |
173 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
173 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
174 | 174 | // also add the anon user if it's his own calendar. |
175 | - if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
175 | + if (($rights&Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
176 | 176 | { |
177 | 177 | $has_read_permissions = true; |
178 | 178 | } |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | // or ass permissions if this is the anon group's calendar. |
183 | 183 | foreach ($anon_groups as $parent_group) |
184 | 184 | { |
185 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
186 | - if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
185 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
186 | + if (($rights&Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
187 | 187 | { |
188 | 188 | $has_read_permissions = true; |
189 | 189 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | else |
201 | 201 | { |
202 | - $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
202 | + $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | return parent::get_user_interface(); |
220 | 220 | } |
221 | 221 | |
222 | - function get_content(&$arguments,$properties) |
|
222 | + function get_content(&$arguments, $properties) |
|
223 | 223 | { |
224 | 224 | $html = ""; |
225 | 225 | Api\Translation::add_app('calendar'); |
@@ -227,33 +227,32 @@ discard block |
||
227 | 227 | $this->ui->allowEdit = false; |
228 | 228 | $this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false; |
229 | 229 | |
230 | - $weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 2; |
|
230 | + $weeks = $arguments['numWeeks'] ? (int)$arguments['numWeeks'] : 2; |
|
231 | 231 | |
232 | - if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET')))) |
|
232 | + if (($arguments['acceptDateParam']) && (get_var('date', array('POST', 'GET')))) |
|
233 | 233 | { |
234 | - $start = (int) (strtotime(get_var('date',array('POST','GET'))) + |
|
234 | + $start = (int)(strtotime(get_var('date', array('POST', 'GET'))) + |
|
235 | 235 | (60 * 60 * 24 * 7 * $dateOffset)); |
236 | 236 | } |
237 | 237 | else |
238 | 238 | { |
239 | - $start = (int) ($this->bo->now_su + |
|
239 | + $start = (int)($this->bo->now_su + |
|
240 | 240 | (60 * 60 * 24 * 7 * $dateOffset)); |
241 | 241 | } |
242 | 242 | $start = new Api\DateTime($start); |
243 | 243 | $start->setWeekstart(); |
244 | 244 | $first = $start->format('ts'); |
245 | - $last = strtotime("+$weeks weeks",$first) - 1; |
|
245 | + $last = strtotime("+$weeks weeks", $first) - 1; |
|
246 | 246 | |
247 | 247 | if ($arguments['showTitle']) |
248 | 248 | { |
249 | 249 | $html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Weekview').": "; |
250 | - $html .= lang('After %1',$this->bo->long_date($first)); |
|
250 | + $html .= lang('After %1', $this->bo->long_date($first)); |
|
251 | 251 | $html .= "</div>"; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // set the search parameters |
255 | - $search_params = Array |
|
256 | - ( |
|
255 | + $search_params = Array( |
|
257 | 256 | 'offset' => false, |
258 | 257 | 'order' => 'cal_start ASC', |
259 | 258 | 'start' => $first, |
@@ -288,19 +287,19 @@ discard block |
||
288 | 287 | $html .= '<!-- END Calendar info -->'."\n"; |
289 | 288 | unset($css_file); |
290 | 289 | // we add DAY_s/2 to $this->first (using 12h), to deal with daylight saving changes |
291 | - for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week",$week_start)) |
|
290 | + for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week", $week_start)) |
|
292 | 291 | { |
293 | 292 | $week = array(); |
294 | 293 | for ($i = 0; $i < 7; ++$i) |
295 | 294 | { |
296 | - $day_ymd = $this->bo->date2string($i ? strtotime("+$i days",$week_start) : $week_start); |
|
295 | + $day_ymd = $this->bo->date2string($i ? strtotime("+$i days", $week_start) : $week_start); |
|
297 | 296 | $week[$day_ymd] = array_shift($rows); |
298 | 297 | } |
299 | 298 | $week_view = array( |
300 | 299 | 'menuaction' => false, |
301 | 300 | 'date' => $this->bo->date2string($week_start), |
302 | 301 | ); |
303 | - $title = lang('Wk').' '.adodb_date('W',$week_start); |
|
302 | + $title = lang('Wk').' '.adodb_date('W', $week_start); |
|
304 | 303 | if (!isset($GLOBALS['egw']->template)) |
305 | 304 | { |
306 | 305 | $GLOBALS['egw']->template = new Framework\Template; |
@@ -165,7 +165,8 @@ discard block |
||
165 | 165 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
166 | 166 | } |
167 | 167 | $this->arguments['category']['options'] = $cat_ids; |
168 | - if (count($cat_ids) > 5) { |
|
168 | + if (count($cat_ids) > 5) |
|
169 | + { |
|
169 | 170 | $this->arguments['category']['multiple'] = 5; |
170 | 171 | } |
171 | 172 | |
@@ -310,8 +311,16 @@ discard block |
||
310 | 311 | foreach((array) $this->bo->search($search_params) as $event) |
311 | 312 | { |
312 | 313 | $event['date'] = $this->bo->date2string($event['start']); |
313 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
314 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
314 | + if (empty($event['description'])) |
|
315 | + { |
|
316 | + $event['description'] = ' '; |
|
317 | + } |
|
318 | + // no description screws the titles horz. alignment |
|
319 | + if (empty($event['location'])) |
|
320 | + { |
|
321 | + $event['location'] = ' '; |
|
322 | + } |
|
323 | + // no location screws the owner horz. alignment |
|
315 | 324 | $rows[] = $event; |
316 | 325 | } |
317 | 326 | if (($arguments['showWeeks']) && ((int)$arguments['offset'] == 0)) |
@@ -337,7 +346,8 @@ discard block |
||
337 | 346 | } |
338 | 347 | $last_week = adodb_date('W-Y',$event['start']); |
339 | 348 | $html .= " <!-- Event -->\n"; |
340 | - if ($event_count % 2 == 0) { |
|
349 | + if ($event_count % 2 == 0) |
|
350 | + { |
|
341 | 351 | $html .= ' <div class="cal_list_event cal_event_even">'."\n"; |
342 | 352 | } |
343 | 353 | else |
@@ -353,7 +363,8 @@ discard block |
||
353 | 363 | $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
354 | 364 | $html .= $this->bo->format_date($event['end'])."</span></div>\n"; |
355 | 365 | $descr = trim($event['description']); |
356 | - if (! empty($descr)) { |
|
366 | + if (! empty($descr)) |
|
367 | + { |
|
357 | 368 | $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/',"<br>\n",$event['description'])."</div>\n"; |
358 | 369 | } |
359 | 370 | $html .= " </div><!-- cal_list_event -->\n"; |
@@ -280,7 +280,7 @@ |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | // set the search parameters |
283 | - $search_params = Array |
|
283 | + $search_params = array |
|
284 | 284 | ( |
285 | 285 | 'offset' => $arguments['entryOffset'] ? (int) $arguments['entryOffset'] : false, |
286 | 286 | 'order' => 'cal_start ASC', |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'category' => array( |
92 | 92 | 'type' => 'select', |
93 | 93 | 'label' => lang('Choose a category'), |
94 | - 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
94 | + 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
95 | 95 | 'multiple' => true, |
96 | 96 | ), |
97 | 97 | 'numWeeks' => array( |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | { |
158 | 158 | //_debug_array($GLOBALS['Common_BO']->sites->current_site); |
159 | 159 | // copied from bookmarks module. |
160 | - $cat = new Api\Categories('','calendar'); |
|
161 | - $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
|
160 | + $cat = new Api\Categories('', 'calendar'); |
|
161 | + $cats = $cat->return_array('all', 0, False, '', 'cat_name', '', True); |
|
162 | 162 | $cat_ids = array(); |
163 | - foreach($cats as $category) |
|
163 | + foreach ($cats as $category) |
|
164 | 164 | { |
165 | 165 | $cat_ids[$category['id']] = $GLOBALS['egw']->strip_html($category['name']); |
166 | 166 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | { |
174 | 174 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
175 | 175 | } |
176 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
176 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
177 | 177 | $search_params = array( |
178 | 178 | 'type' => 'both', |
179 | 179 | 'app' => 'calendar', |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | $users = array(); |
183 | 183 | $groups = array(); |
184 | 184 | // sort users and groups separately. |
185 | - $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u'); |
|
186 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
185 | + $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'], 'account_lid', 'u'); |
|
186 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
187 | 187 | foreach ($accounts as $entry) |
188 | 188 | { |
189 | 189 | $is_group = false; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | $acl = new Acl($entry['account_id']); |
192 | 192 | $acl->read_repository(); |
193 | 193 | // get the rights for each account to check whether the anon user has read permissions. |
194 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
194 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
195 | 195 | // also add the anon user if it's his own calendar. |
196 | - if (($rights & Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
196 | + if (($rights&Acl::READ) || ($entry['account_id'] == $anon_user)) |
|
197 | 197 | { |
198 | 198 | $has_read_permissions = true; |
199 | 199 | } |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | // or ass permissions if this is the anon group's calendar. |
204 | 204 | foreach ($anon_groups as $parent_group) |
205 | 205 | { |
206 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
207 | - if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
206 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
207 | + if (($rights&Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
208 | 208 | { |
209 | 209 | $has_read_permissions = true; |
210 | 210 | break; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | else |
222 | 222 | { |
223 | - $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
223 | + $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | return parent::get_user_interface(); |
241 | 241 | } |
242 | 242 | |
243 | - function get_content(&$arguments,$properties) |
|
243 | + function get_content(&$arguments, $properties) |
|
244 | 244 | { |
245 | 245 | $html = ""; |
246 | 246 | Api\Translation::add_app('calendar'); |
@@ -249,17 +249,17 @@ discard block |
||
249 | 249 | $this->ui->allowEdit = false; |
250 | 250 | $this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false; |
251 | 251 | |
252 | - $weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 4; |
|
253 | - $dateOffset = $arguments['offset'] ? (int) $arguments['offset'] : 0; |
|
252 | + $weeks = $arguments['numWeeks'] ? (int)$arguments['numWeeks'] : 4; |
|
253 | + $dateOffset = $arguments['offset'] ? (int)$arguments['offset'] : 0; |
|
254 | 254 | |
255 | - if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET')))) |
|
255 | + if (($arguments['acceptDateParam']) && (get_var('date', array('POST', 'GET')))) |
|
256 | 256 | { |
257 | - $first = (int) (strtotime(get_var('date',array('POST','GET'))) + |
|
257 | + $first = (int)(strtotime(get_var('date', array('POST', 'GET'))) + |
|
258 | 258 | (60 * 60 * 24 * 7 * $dateOffset)); |
259 | 259 | } |
260 | 260 | else |
261 | 261 | { |
262 | - $first = (int) ($this->bo->now_su + |
|
262 | + $first = (int)($this->bo->now_su + |
|
263 | 263 | (60 * 60 * 24 * 7 * $dateOffset)); |
264 | 264 | } |
265 | 265 | if ($arguments['useWeekStart']) |
@@ -269,20 +269,19 @@ discard block |
||
269 | 269 | $first = $start->format('ts'); |
270 | 270 | } |
271 | 271 | |
272 | - $last = (int) ($first + |
|
272 | + $last = (int)($first + |
|
273 | 273 | (60 * 60 * 24 * 7 * $weeks)); |
274 | 274 | |
275 | 275 | if ($arguments['showTitle']) |
276 | 276 | { |
277 | 277 | $html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '; |
278 | - $html .= lang('After %1',$this->bo->long_date($first)); |
|
278 | + $html .= lang('After %1', $this->bo->long_date($first)); |
|
279 | 279 | $html .= "</div>"; |
280 | 280 | } |
281 | 281 | |
282 | 282 | // set the search parameters |
283 | - $search_params = Array |
|
284 | - ( |
|
285 | - 'offset' => $arguments['entryOffset'] ? (int) $arguments['entryOffset'] : false, |
|
283 | + $search_params = Array( |
|
284 | + 'offset' => $arguments['entryOffset'] ? (int)$arguments['entryOffset'] : false, |
|
286 | 285 | 'order' => 'cal_start ASC', |
287 | 286 | 'start' => $first, |
288 | 287 | 'end' => $last, |
@@ -302,23 +301,23 @@ discard block |
||
302 | 301 | } |
303 | 302 | if ($arguments['numEntries']) |
304 | 303 | { |
305 | - $search_params['num_rows'] = (int) $arguments['numEntries']; |
|
306 | - $search_params['offset'] = $arguments['entryOffset'] ? (int) $arguments['entryOffset'] :0; |
|
304 | + $search_params['num_rows'] = (int)$arguments['numEntries']; |
|
305 | + $search_params['offset'] = $arguments['entryOffset'] ? (int)$arguments['entryOffset'] : 0; |
|
307 | 306 | } |
308 | 307 | $rows = array(); |
309 | 308 | |
310 | - foreach((array) $this->bo->search($search_params) as $event) |
|
309 | + foreach ((array)$this->bo->search($search_params) as $event) |
|
311 | 310 | { |
312 | 311 | $event['date'] = $this->bo->date2string($event['start']); |
313 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
314 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
312 | + if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
313 | + if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
315 | 314 | $rows[] = $event; |
316 | 315 | } |
317 | 316 | if (($arguments['showWeeks']) && ((int)$arguments['offset'] == 0)) |
318 | 317 | { |
319 | 318 | $html .= "<div>".lang('Next')." ".lang('%1 weeks', $weeks).":</div>\n"; |
320 | 319 | } |
321 | - if (($search_params['offset'] && $this->bo->total == 0) || count($rows)==0) |
|
320 | + if (($search_params['offset'] && $this->bo->total == 0) || count($rows) == 0) |
|
322 | 321 | { |
323 | 322 | $html .= "<div>".lang("no events found")."</div>"; |
324 | 323 | } |
@@ -331,11 +330,11 @@ discard block |
||
331 | 330 | $html .= ' <div class="cal_list_weektop"></div>'."\n"; |
332 | 331 | foreach ($rows as $event) |
333 | 332 | { |
334 | - if (($last_week != 0) && (adodb_date('W-Y',$event['start']) != $last_week)) |
|
333 | + if (($last_week != 0) && (adodb_date('W-Y', $event['start']) != $last_week)) |
|
335 | 334 | { |
336 | 335 | $html .= ' <div class="cal_list_weeksplit"></div>'."\n"; |
337 | 336 | } |
338 | - $last_week = adodb_date('W-Y',$event['start']); |
|
337 | + $last_week = adodb_date('W-Y', $event['start']); |
|
339 | 338 | $html .= " <!-- Event -->\n"; |
340 | 339 | if ($event_count % 2 == 0) { |
341 | 340 | $html .= ' <div class="cal_list_event cal_event_even">'."\n"; |
@@ -347,17 +346,17 @@ discard block |
||
347 | 346 | $html .= ' <div class="cal_list_title">'.$event['title']."</div>\n"; |
348 | 347 | $html .= ' <div class="cal_list_date">'; |
349 | 348 | $html .= '<span class="cal_list_start">'; |
350 | - $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['start'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
349 | + $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D', $event['start'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
351 | 350 | $html .= $this->bo->format_date($event['start'])."</span>"; |
352 | 351 | $html .= '<span class="cal_list_end"> - '; |
353 | - $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
352 | + $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D', $event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
354 | 353 | $html .= $this->bo->format_date($event['end'])."</span></div>\n"; |
355 | 354 | $descr = trim($event['description']); |
356 | - if (! empty($descr)) { |
|
357 | - $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/',"<br>\n",$event['description'])."</div>\n"; |
|
355 | + if (!empty($descr)) { |
|
356 | + $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/', "<br>\n", $event['description'])."</div>\n"; |
|
358 | 357 | } |
359 | 358 | $html .= " </div><!-- cal_list_event -->\n"; |
360 | - $event_count ++; |
|
359 | + $event_count++; |
|
361 | 360 | } |
362 | 361 | $html .= ' <div class="cal_list_weekbottom"></div>'."\n"; |
363 | 362 | $html .= "<!-- End module -->\n"; |
@@ -44,15 +44,23 @@ |
||
44 | 44 | if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D') |
45 | 45 | { |
46 | 46 | $_GET['user'] = substr($_GET['user'],2); |
47 | - if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2); |
|
48 | - if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2); |
|
49 | -} |
|
47 | + if (isset($_GET['password'])) |
|
48 | + { |
|
49 | + $_GET['password'] = substr($_GET['password'],2); |
|
50 | + } |
|
51 | + if (isset($_GET['cred'])) |
|
52 | + { |
|
53 | + $_GET['cred'] = substr($_GET['cred'],2); |
|
54 | + } |
|
55 | + } |
|
50 | 56 | if (!is_numeric($user = $_GET['user'])) |
51 | 57 | { |
52 | 58 | // check if user contains the current domain --> remove it |
53 | 59 | list(,$domain) = explode('@',$user); |
54 | 60 | if ($domain === $GLOBALS['egw_info']['user']['domain']) |
55 | - list($user) = explode('@',$user); |
|
61 | + { |
|
62 | + list($user) = explode('@',$user); |
|
63 | + } |
|
56 | 64 | $user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u'); |
57 | 65 | } |
58 | 66 | if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user))) |
@@ -41,23 +41,23 @@ discard block |
||
41 | 41 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
42 | 42 | } |
43 | 43 | // fix for SOGo connector, which does not decode the = in our f/b url |
44 | -if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D') |
|
44 | +if (strpos($_SERVER['QUERY_STRING'], '=3D') !== false && substr($_GET['user'], 0, 2) == '3D') |
|
45 | 45 | { |
46 | - $_GET['user'] = substr($_GET['user'],2); |
|
47 | - if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2); |
|
48 | - if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2); |
|
46 | + $_GET['user'] = substr($_GET['user'], 2); |
|
47 | + if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'], 2); |
|
48 | + if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'], 2); |
|
49 | 49 | } |
50 | 50 | if (!is_numeric($user = $_GET['user'])) |
51 | 51 | { |
52 | 52 | // check if user contains the current domain --> remove it |
53 | - list(,$domain) = explode('@',$user); |
|
53 | + list(,$domain) = explode('@', $user); |
|
54 | 54 | if ($domain === $GLOBALS['egw_info']['user']['domain']) |
55 | - list($user) = explode('@',$user); |
|
56 | - $user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u'); |
|
55 | + list($user) = explode('@', $user); |
|
56 | + $user = $GLOBALS['egw']->accounts->name2id($user, 'account_lid', 'u'); |
|
57 | 57 | } |
58 | 58 | if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user))) |
59 | 59 | { |
60 | - fail_exit(lang("freebusy: unknown user '%1', wrong password or not available to not logged in users !!!"." $username($user)",$_GET['user'])); |
|
60 | + fail_exit(lang("freebusy: unknown user '%1', wrong password or not available to not logged in users !!!"." $username($user)", $_GET['user'])); |
|
61 | 61 | } |
62 | 62 | if (!$loged_in) |
63 | 63 | { |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | if (strpos($authuser, '@') === false) |
79 | 79 | { |
80 | 80 | $domain = $GLOBALS['egw_info']['server']['default_domain']; |
81 | - $authuser .= '@' . $domain; |
|
81 | + $authuser .= '@'.$domain; |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - list(, $domain) = explode('@',$authuser, 2); |
|
85 | + list(, $domain) = explode('@', $authuser, 2); |
|
86 | 86 | } |
87 | 87 | if (array_key_exists($domain, $GLOBALS['egw_domain'])) |
88 | 88 | { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $GLOBALS['egw_info']['user']['domain'] = $domain; |
93 | 93 | $GLOBALS['egw_info']['flags']['currentapp'] = 'login'; |
94 | 94 | $GLOBALS['egw_info']['flags']['noapi'] = false; |
95 | - $loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text'); |
|
95 | + $loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text'); |
|
96 | 96 | session_unset(); |
97 | 97 | session_destroy(); |
98 | 98 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | - Api\Header\Content::type('freebusy.ifb','text/calendar'); |
|
111 | + Api\Header\Content::type('freebusy.ifb', 'text/calendar'); |
|
112 | 112 | } |
113 | 113 | $ical = new calendar_ical(); |
114 | 114 | echo $ical->freebusy($user, $_GET['end']); |
@@ -111,7 +111,7 @@ |
||
111 | 111 | $value = $value_in =& self::get_array($content, $form_name); |
112 | 112 | if(!is_array($value)) |
113 | 113 | { |
114 | - $value = Array($value); |
|
114 | + $value = array($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $valid =& self::get_array($validated, $form_name, true); |
@@ -30,33 +30,33 @@ discard block |
||
30 | 30 | * @param string $cname |
31 | 31 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
32 | 32 | */ |
33 | - public function beforeSendToClient($cname, array $expand=null) |
|
33 | + public function beforeSendToClient($cname, array $expand = null) |
|
34 | 34 | { |
35 | 35 | |
36 | - Framework::includeJS('.','et2_widget_owner','calendar'); |
|
37 | - Framework::includeCSS('calendar','calendar'); |
|
36 | + Framework::includeJS('.', 'et2_widget_owner', 'calendar'); |
|
37 | + Framework::includeCSS('calendar', 'calendar'); |
|
38 | 38 | |
39 | 39 | $bo = new calendar_bo(); |
40 | 40 | |
41 | 41 | $form_name = self::form_name($cname, $this->id, $expand); |
42 | 42 | |
43 | - $value =& self::get_array(self::$request->content, $form_name); |
|
43 | + $value = & self::get_array(self::$request->content, $form_name); |
|
44 | 44 | |
45 | 45 | if (!is_array(self::$request->sel_options[$form_name])) |
46 | 46 | { |
47 | 47 | self::$request->sel_options[$form_name] = array(); |
48 | 48 | } |
49 | - $sel_options =& self::$request->sel_options[$form_name]; |
|
49 | + $sel_options = & self::$request->sel_options[$form_name]; |
|
50 | 50 | |
51 | 51 | // Get user accounts, formatted nicely for grouping and matching |
52 | 52 | // the ajax call calendar_uiforms->ajax_owner() - users first |
53 | 53 | $accounts = array(); |
54 | 54 | $list = array('accounts', 'owngroups'); |
55 | - foreach($list as $type) |
|
55 | + foreach ($list as $type) |
|
56 | 56 | { |
57 | 57 | $account_options = array('account_type' => $type); |
58 | - $accounts_type = Api\Accounts::link_query('',$account_options); |
|
59 | - if($type == 'accounts') |
|
58 | + $accounts_type = Api\Accounts::link_query('', $account_options); |
|
59 | + if ($type == 'accounts') |
|
60 | 60 | { |
61 | 61 | $accounts_type = array_intersect_key($accounts_type, $GLOBALS['egw']->acl->get_grants('calendar')); |
62 | 62 | } |
@@ -84,47 +84,47 @@ discard block |
||
84 | 84 | else |
85 | 85 | { |
86 | 86 | // Add in group memberships as strings |
87 | - $data['resources'] = array_map(function($a) { return ''.$a;},$GLOBALS['egw']->accounts->members($account_id, true)); |
|
87 | + $data['resources'] = array_map(function($a) { return ''.$a; },$GLOBALS['egw']->accounts->members($account_id, true)); |
|
88 | 88 | } |
89 | 89 | return $data; |
90 | 90 | }, |
91 | 91 | array_keys($accounts), $accounts |
92 | 92 | ); |
93 | 93 | |
94 | - if(!is_array($value)) |
|
94 | + if (!is_array($value)) |
|
95 | 95 | { |
96 | 96 | // set value with an empty string only if sel options are not |
97 | 97 | // loaded, for example: setting calendar owner via URL when |
98 | 98 | // calendar app is not yet loaded. |
99 | - $value = !empty($sel_options) ? array(): explode(',', $value); |
|
99 | + $value = !empty($sel_options) ? array() : explode(',', $value); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // Add external owners that a select account widget will not find |
103 | - foreach($value as &$owner) |
|
103 | + foreach ($value as &$owner) |
|
104 | 104 | { |
105 | 105 | $label = self::get_owner_label($owner); |
106 | 106 | $info = array(); |
107 | - if(!is_numeric($owner)) |
|
107 | + if (!is_numeric($owner)) |
|
108 | 108 | { |
109 | - $resource = $bo->resources[substr($owner, 0,1)]; |
|
110 | - if($resource['info'] && !($info = $bo->resource_info($owner))) |
|
109 | + $resource = $bo->resources[substr($owner, 0, 1)]; |
|
110 | + if ($resource['info'] && !($info = $bo->resource_info($owner))) |
|
111 | 111 | { |
112 | - continue; // ignore that resource, we would get a PHP Fatal: Unsupported operand types |
|
112 | + continue; // ignore that resource, we would get a PHP Fatal: Unsupported operand types |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | else if (!in_array($owner, array_keys($accounts))) |
116 | 116 | { |
117 | 117 | $resource = array('app'=> 'api-accounts'); |
118 | 118 | } |
119 | - if ($resource && is_numeric ($owner) && (int)$owner < 0) |
|
119 | + if ($resource && is_numeric($owner) && (int)$owner < 0) |
|
120 | 120 | { |
121 | 121 | // Add in group memberships as strings |
122 | - $info['resources'] = array_map(function($a) { return ''.$a;},$GLOBALS['egw']->accounts->members($owner, true)); |
|
122 | + $info['resources'] = array_map(function($a) { return ''.$a; },$GLOBALS['egw']->accounts->members($owner, true)); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $option = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app'])) + $info; |
126 | 126 | $sel_option_index = $this->get_index($sel_options, 'value', $owner); |
127 | - if($sel_option_index === false) |
|
127 | + if ($sel_option_index === false) |
|
128 | 128 | { |
129 | 129 | $sel_options[] = $option; |
130 | 130 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | */ |
146 | 146 | private function get_index(&$array, $key, $value) |
147 | 147 | { |
148 | - foreach($array as $_key => $_value) |
|
148 | + foreach ($array as $_key => $_value) |
|
149 | 149 | { |
150 | - if($_value[$key] === $value) return $_key; |
|
150 | + if ($_value[$key] === $value) return $_key; |
|
151 | 151 | } |
152 | 152 | return false; |
153 | 153 | } |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | * @param array $content |
160 | 160 | * @param array &$validated=array() validated content |
161 | 161 | */ |
162 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
162 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
163 | 163 | { |
164 | 164 | $form_name = self::form_name($cname, $this->id, $expand); |
165 | 165 | |
166 | 166 | if (!$this->is_readonly($cname, $form_name)) |
167 | 167 | { |
168 | - $value = $value_in =& self::get_array($content, $form_name); |
|
169 | - if(!is_array($value)) |
|
168 | + $value = $value_in = & self::get_array($content, $form_name); |
|
169 | + if (!is_array($value)) |
|
170 | 170 | { |
171 | 171 | $value = Array($value); |
172 | 172 | } |
173 | 173 | |
174 | - $valid =& self::get_array($validated, $form_name, true); |
|
174 | + $valid = & self::get_array($validated, $form_name, true); |
|
175 | 175 | if (true) $valid = $value; |
176 | 176 | } |
177 | 177 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | public static function ajax_owner($id = null) |
184 | 184 | { |
185 | 185 | // Handle a request for a single ID |
186 | - if($id) |
|
186 | + if ($id) |
|
187 | 187 | { |
188 | 188 | $label = self::get_owner_label($id); |
189 | 189 | Api\Json\Response::get()->data($label); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $options = array('start' => 0, 'num_rows' => 50, |
198 | 198 | // Filter accounts out of addressbook |
199 | 199 | 'filter' => array('account_id' => null)) + |
200 | - array_diff_key($_REQUEST, array_flip(array('menuaction','query'))); |
|
200 | + array_diff_key($_REQUEST, array_flip(array('menuaction', 'query'))); |
|
201 | 201 | $results = array(); |
202 | 202 | |
203 | 203 | // Contacts matching accounts the user does not have permission for cause |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | // we remove those contacts |
206 | 206 | $remove_contacts = array(); |
207 | 207 | |
208 | - $resources = array_merge(array('' => $bo->resources['']),$bo->resources); |
|
208 | + $resources = array_merge(array('' => $bo->resources['']), $bo->resources); |
|
209 | 209 | $contacts_obj = new Api\Contacts(); |
210 | - foreach($resources as $type => $data) |
|
210 | + foreach ($resources as $type => $data) |
|
211 | 211 | { |
212 | 212 | $mapped = array(); |
213 | 213 | $_results = array(); |
214 | 214 | |
215 | 215 | // Handle Api\Accounts seperately |
216 | - if($type == '') |
|
216 | + if ($type == '') |
|
217 | 217 | { |
218 | 218 | $account_options = $options + array('account_type' => 'both'); |
219 | 219 | $_results += $remove_contacts = Api\Accounts::link_query($query, $account_options); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // Use standard link registry |
232 | 232 | else if ($data['app'] && Link::get_registry($data['app'], 'query')) |
233 | 233 | { |
234 | - $_results = Link::query($data['app'], $query,$options); |
|
234 | + $_results = Link::query($data['app'], $query, $options); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // There are always special cases |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | return (stripos($element, $query) !== false); |
246 | 246 | } |
247 | 247 | ); |
248 | - foreach($lists as $list_id => $list) |
|
248 | + foreach ($lists as $list_id => $list) |
|
249 | 249 | { |
250 | 250 | $_results[$list_id] = array( |
251 | 251 | 'label' => $list, |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | } |
255 | 255 | break; |
256 | 256 | } |
257 | - if(!$_results) |
|
257 | + if (!$_results) |
|
258 | 258 | { |
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | |
262 | - foreach(array_unique($_results, SORT_REGULAR) as $id => $title) |
|
262 | + foreach (array_unique($_results, SORT_REGULAR) as $id => $title) |
|
263 | 263 | { |
264 | - if($id && $title) |
|
264 | + if ($id && $title) |
|
265 | 265 | { |
266 | 266 | // Magicsuggest uses id, not value. |
267 | 267 | $value = array( |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | 'label' => $title, |
271 | 271 | 'app' => lang($data['app']) |
272 | 272 | ); |
273 | - if(is_array($value['label'])) |
|
273 | + if (is_array($value['label'])) |
|
274 | 274 | { |
275 | 275 | $value = array_merge($value, $value['label']); |
276 | 276 | } |
277 | - switch($type) |
|
277 | + switch ($type) |
|
278 | 278 | { |
279 | 279 | case 'r': |
280 | 280 | // TODO: fetch resources photo |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | 'contact_id' => $contact['id'], |
287 | 287 | 'etag' => $contact['etag'] ? $contact['etag'] : 1 |
288 | 288 | )); |
289 | - if($id < 0) |
|
289 | + if ($id < 0) |
|
290 | 290 | { |
291 | 291 | $value['resources'] = $GLOBALS['egw']->accounts->members($id, true); |
292 | 292 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $mapped[] = $value; |
298 | 298 | } |
299 | 299 | } |
300 | - if(count($mapped)) |
|
300 | + if (count($mapped)) |
|
301 | 301 | { |
302 | 302 | $results = array_merge($results, $mapped); |
303 | 303 | } |
@@ -317,25 +317,25 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public static function get_owner_label($id) |
319 | 319 | { |
320 | - static $bo=null; |
|
321 | - if(!$bo) $bo = new calendar_bo(); |
|
320 | + static $bo = null; |
|
321 | + if (!$bo) $bo = new calendar_bo(); |
|
322 | 322 | |
323 | 323 | $id = ''.$id; |
324 | - if(!is_numeric($id)) |
|
324 | + if (!is_numeric($id)) |
|
325 | 325 | { |
326 | - $resource = $bo->resources[substr($id, 0,1)]; |
|
327 | - $label = Link::title($resource['app'], substr($id,1)); |
|
326 | + $resource = $bo->resources[substr($id, 0, 1)]; |
|
327 | + $label = Link::title($resource['app'], substr($id, 1)); |
|
328 | 328 | |
329 | 329 | // Could not get via link, try via resources info |
330 | - if($label === false) |
|
330 | + if ($label === false) |
|
331 | 331 | { |
332 | - $info = ExecMethod($resource['info'], substr($id,1)); |
|
332 | + $info = ExecMethod($resource['info'], substr($id, 1)); |
|
333 | 333 | $label = $info[0]['name']; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | else |
337 | 337 | { |
338 | - $label = Link::title('api-accounts',$id) ?: Api\Accounts::username($id); |
|
338 | + $label = Link::title('api-accounts', $id) ?: Api\Accounts::username($id); |
|
339 | 339 | } |
340 | 340 | return $label; |
341 | 341 | } |
@@ -84,7 +84,9 @@ discard block |
||
84 | 84 | else |
85 | 85 | { |
86 | 86 | // Add in group memberships as strings |
87 | - $data['resources'] = array_map(function($a) { return ''.$a;},$GLOBALS['egw']->accounts->members($account_id, true)); |
|
87 | + $data['resources'] = array_map(function($a) |
|
88 | + { |
|
89 | +return ''.$a;},$GLOBALS['egw']->accounts->members($account_id, true)); |
|
88 | 90 | } |
89 | 91 | return $data; |
90 | 92 | }, |
@@ -119,7 +121,9 @@ discard block |
||
119 | 121 | if ($resource && is_numeric ($owner) && (int)$owner < 0) |
120 | 122 | { |
121 | 123 | // Add in group memberships as strings |
122 | - $info['resources'] = array_map(function($a) { return ''.$a;},$GLOBALS['egw']->accounts->members($owner, true)); |
|
124 | + $info['resources'] = array_map(function($a) |
|
125 | + { |
|
126 | +return ''.$a;},$GLOBALS['egw']->accounts->members($owner, true)); |
|
123 | 127 | } |
124 | 128 | |
125 | 129 | $option = array('value' => $owner, 'label' => $label, 'app' => lang($resource['app'])) + $info; |
@@ -147,7 +151,10 @@ discard block |
||
147 | 151 | { |
148 | 152 | foreach($array as $_key => $_value) |
149 | 153 | { |
150 | - if($_value[$key] === $value) return $_key; |
|
154 | + if($_value[$key] === $value) |
|
155 | + { |
|
156 | + return $_key; |
|
157 | + } |
|
151 | 158 | } |
152 | 159 | return false; |
153 | 160 | } |
@@ -172,7 +179,10 @@ discard block |
||
172 | 179 | } |
173 | 180 | |
174 | 181 | $valid =& self::get_array($validated, $form_name, true); |
175 | - if (true) $valid = $value; |
|
182 | + if (true) |
|
183 | + { |
|
184 | + $valid = $value; |
|
185 | + } |
|
176 | 186 | } |
177 | 187 | } |
178 | 188 | /** |
@@ -241,7 +251,8 @@ discard block |
||
241 | 251 | // Include mailing lists |
242 | 252 | $lists = array_filter( |
243 | 253 | $contacts_obj->get_lists(Api\Acl::READ), |
244 | - function($element) use($query) { |
|
254 | + function($element) use($query) |
|
255 | + { |
|
245 | 256 | return (stripos($element, $query) !== false); |
246 | 257 | } |
247 | 258 | ); |
@@ -282,10 +293,13 @@ discard block |
||
282 | 293 | case 'c': |
283 | 294 | case '': |
284 | 295 | $contact = $contacts_obj->read($type === '' ? 'account:'.$id : $id, true); |
285 | - if (is_array($contact)) $value['icon'] = Api\Framework::link('/api/avatar.php', array( |
|
296 | + if (is_array($contact)) |
|
297 | + { |
|
298 | + $value['icon'] = Api\Framework::link('/api/avatar.php', array( |
|
286 | 299 | 'contact_id' => $contact['id'], |
287 | 300 | 'etag' => $contact['etag'] ? $contact['etag'] : 1 |
288 | 301 | )); |
302 | + } |
|
289 | 303 | if($id < 0) |
290 | 304 | { |
291 | 305 | $value['resources'] = $GLOBALS['egw']->accounts->members($id, true); |
@@ -318,7 +332,10 @@ discard block |
||
318 | 332 | public static function get_owner_label($id) |
319 | 333 | { |
320 | 334 | static $bo=null; |
321 | - if(!$bo) $bo = new calendar_bo(); |
|
335 | + if(!$bo) |
|
336 | + { |
|
337 | + $bo = new calendar_bo(); |
|
338 | + } |
|
322 | 339 | |
323 | 340 | $id = ''.$id; |
324 | 341 | if(!is_numeric($id)) |
@@ -2890,11 +2890,11 @@ |
||
2890 | 2890 | { |
2891 | 2891 | $msg = lang('Event deleted'); |
2892 | 2892 | } |
2893 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
2893 | + $response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete')); |
|
2894 | 2894 | } |
2895 | 2895 | else |
2896 | 2896 | { |
2897 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
2897 | + $response->apply('egw.message', array(lang('Error')),'error'); |
|
2898 | 2898 | } |
2899 | 2899 | } |
2900 | 2900 |
@@ -2693,14 +2693,14 @@ discard block |
||
2693 | 2693 | } |
2694 | 2694 | |
2695 | 2695 | /** |
2696 | - * Export events as vCalendar version 2.0 files (iCal) |
|
2697 | - * |
|
2698 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
2699 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
2700 | - * @return string error-msg if $return_error |
|
2701 | - */ |
|
2702 | - function export($content=0,$return_error=false) |
|
2703 | - { |
|
2696 | + * Export events as vCalendar version 2.0 files (iCal) |
|
2697 | + * |
|
2698 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
2699 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
2700 | + * @return string error-msg if $return_error |
|
2701 | + */ |
|
2702 | + function export($content=0,$return_error=false) |
|
2703 | + { |
|
2704 | 2704 | $boical = new calendar_ical(); |
2705 | 2705 | #error_log(__METHOD__.print_r($content,true)); |
2706 | 2706 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2754,7 +2754,7 @@ discard block |
||
2754 | 2754 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
2755 | 2755 | $etpl = new Etemplate('calendar.export'); |
2756 | 2756 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
2757 | - } |
|
2757 | + } |
|
2758 | 2758 | |
2759 | 2759 | /** |
2760 | 2760 | * Edit category ACL (admin only) |
@@ -2826,8 +2826,8 @@ discard block |
||
2826 | 2826 | } |
2827 | 2827 | |
2828 | 2828 | /** |
2829 | - * Set up the required fields to get the history tab |
|
2830 | - */ |
|
2829 | + * Set up the required fields to get the history tab |
|
2830 | + */ |
|
2831 | 2831 | public function setup_history(&$content, &$sel_options) |
2832 | 2832 | { |
2833 | 2833 | $status = 'history_status'; |
@@ -644,436 +644,436 @@ |
||
644 | 644 | |
645 | 645 | switch((string)$button) |
646 | 646 | { |
647 | - case 'exception': // create an exception in a recuring event |
|
648 | - $msg = $this->_create_exception($event,$preserv); |
|
649 | - break; |
|
650 | - case 'edit': |
|
651 | - // Going from add dialog to full edit dialog |
|
652 | - unset($preserv['template']); |
|
653 | - unset($event['template']); |
|
654 | - break; |
|
655 | - |
|
656 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
657 | - unset($event['id']); |
|
658 | - unset($event['uid']); |
|
659 | - unset($event['reference']); |
|
660 | - unset($preserv['reference']); |
|
661 | - unset($event['recurrence']); |
|
662 | - unset($preserv['recurrence']); |
|
663 | - unset($event['recur_exception']); |
|
664 | - unset($event['edit_single']); // in case it has been set |
|
665 | - unset($event['modified']); |
|
666 | - unset($event['modifier']); |
|
667 | - unset($event['caldav_name']); |
|
668 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
647 | + case 'exception': // create an exception in a recuring event |
|
648 | + $msg = $this->_create_exception($event,$preserv); |
|
649 | + break; |
|
650 | + case 'edit': |
|
651 | + // Going from add dialog to full edit dialog |
|
652 | + unset($preserv['template']); |
|
653 | + unset($event['template']); |
|
654 | + break; |
|
669 | 655 | |
670 | - // Clear participant stati |
|
671 | - foreach($event['participant_types'] as $type => &$participants) |
|
672 | - { |
|
673 | - foreach($participants as $id => &$p_response) |
|
656 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
657 | + unset($event['id']); |
|
658 | + unset($event['uid']); |
|
659 | + unset($event['reference']); |
|
660 | + unset($preserv['reference']); |
|
661 | + unset($event['recurrence']); |
|
662 | + unset($preserv['recurrence']); |
|
663 | + unset($event['recur_exception']); |
|
664 | + unset($event['edit_single']); // in case it has been set |
|
665 | + unset($event['modified']); |
|
666 | + unset($event['modifier']); |
|
667 | + unset($event['caldav_name']); |
|
668 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
669 | + |
|
670 | + // Clear participant stati |
|
671 | + foreach($event['participant_types'] as $type => &$participants) |
|
672 | + { |
|
673 | + foreach($participants as $id => &$p_response) |
|
674 | + { |
|
675 | + if($type == 'u' && $id == $event['owner']) continue; |
|
676 | + calendar_so::split_status($p_response, $quantity, $role); |
|
677 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
678 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
679 | + $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
680 | + } |
|
681 | + } |
|
682 | + |
|
683 | + // Copy alarms |
|
684 | + if (is_array($event['alarm'])) |
|
674 | 685 | { |
675 | - if($type == 'u' && $id == $event['owner']) continue; |
|
676 | - calendar_so::split_status($p_response, $quantity, $role); |
|
677 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
678 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
679 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
686 | + foreach($event['alarm'] as $n => &$alarm) |
|
687 | + { |
|
688 | + unset($alarm['id']); |
|
689 | + unset($alarm['cal_id']); |
|
690 | + } |
|
680 | 691 | } |
681 | - } |
|
682 | 692 | |
683 | - // Copy alarms |
|
684 | - if (is_array($event['alarm'])) |
|
685 | - { |
|
686 | - foreach($event['alarm'] as $n => &$alarm) |
|
693 | + // Get links to be copied |
|
694 | + // With no ID, $content['link_to']['to_id'] is used |
|
695 | + $content['link_to'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
696 | + foreach(Link::get_links('calendar', $content['id']) as $link) |
|
687 | 697 | { |
688 | - unset($alarm['id']); |
|
689 | - unset($alarm['cal_id']); |
|
698 | + if ($link['app'] != Link::VFS_APPNAME) |
|
699 | + { |
|
700 | + Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
701 | + } |
|
702 | + elseif ($link['app'] == Link::VFS_APPNAME) |
|
703 | + { |
|
704 | + Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
705 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
706 | + 'name' => $link['id'], |
|
707 | + ), $link['remark']); |
|
708 | + } |
|
690 | 709 | } |
691 | - } |
|
710 | + unset($link); |
|
711 | + $preserv['view'] = $preserv['edit_single'] = false; |
|
712 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
713 | + $event['title'] = lang('Copy of:').' '.$event['title']; |
|
714 | + break; |
|
692 | 715 | |
693 | - // Get links to be copied |
|
694 | - // With no ID, $content['link_to']['to_id'] is used |
|
695 | - $content['link_to'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
696 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
697 | - { |
|
698 | - if ($link['app'] != Link::VFS_APPNAME) |
|
716 | + case 'mail': |
|
717 | + case 'sendrequest': |
|
718 | + case 'save': |
|
719 | + case 'print': |
|
720 | + case 'apply': |
|
721 | + case 'infolog': |
|
722 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
699 | 723 | { |
700 | - Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
724 | + $msg = lang('Permission denied'); |
|
725 | + $button = ''; |
|
726 | + break; |
|
701 | 727 | } |
702 | - elseif ($link['app'] == Link::VFS_APPNAME) |
|
728 | + if ($event['start'] > $event['end']) |
|
703 | 729 | { |
704 | - Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
705 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
706 | - 'name' => $link['id'], |
|
707 | - ), $link['remark']); |
|
730 | + $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
731 | + $button = ''; |
|
732 | + break; |
|
708 | 733 | } |
709 | - } |
|
710 | - unset($link); |
|
711 | - $preserv['view'] = $preserv['edit_single'] = false; |
|
712 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
713 | - $event['title'] = lang('Copy of:').' '.$event['title']; |
|
714 | - break; |
|
715 | - |
|
716 | - case 'mail': |
|
717 | - case 'sendrequest': |
|
718 | - case 'save': |
|
719 | - case 'print': |
|
720 | - case 'apply': |
|
721 | - case 'infolog': |
|
722 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
723 | - { |
|
724 | - $msg = lang('Permission denied'); |
|
725 | - $button = ''; |
|
726 | - break; |
|
727 | - } |
|
728 | - if ($event['start'] > $event['end']) |
|
729 | - { |
|
730 | - $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
731 | - $button = ''; |
|
732 | - break; |
|
733 | - } |
|
734 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
735 | - { |
|
736 | - $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
737 | - $button = ''; |
|
738 | - break; |
|
739 | - } |
|
740 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
741 | - { |
|
742 | - $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
743 | - $button = ''; |
|
744 | - break; |
|
745 | - } |
|
746 | - if (!$event['participants']) |
|
747 | - { |
|
748 | - $msg = lang('Error: no participants selected !!!'); |
|
749 | - $button = ''; |
|
750 | - break; |
|
751 | - } |
|
752 | - // if private event with ressource reservation is forbidden |
|
753 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
754 | - { |
|
755 | - foreach (array_keys($event['participants']) as $uid) |
|
734 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
735 | + { |
|
736 | + $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
737 | + $button = ''; |
|
738 | + break; |
|
739 | + } |
|
740 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
741 | + { |
|
742 | + $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
743 | + $button = ''; |
|
744 | + break; |
|
745 | + } |
|
746 | + if (!$event['participants']) |
|
747 | + { |
|
748 | + $msg = lang('Error: no participants selected !!!'); |
|
749 | + $button = ''; |
|
750 | + break; |
|
751 | + } |
|
752 | + // if private event with ressource reservation is forbidden |
|
753 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
756 | 754 | { |
757 | - if ($uid[0] == 'r') //ressource detection |
|
755 | + foreach (array_keys($event['participants']) as $uid) |
|
758 | 756 | { |
759 | - $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
760 | - $button = ''; |
|
761 | - break 2; //break foreach and case |
|
757 | + if ($uid[0] == 'r') //ressource detection |
|
758 | + { |
|
759 | + $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
760 | + $button = ''; |
|
761 | + break 2; //break foreach and case |
|
762 | + } |
|
762 | 763 | } |
763 | 764 | } |
764 | - } |
|
765 | - if ($content['edit_single']) // we edited a single event from a series |
|
766 | - { |
|
767 | - $event['reference'] = $event['id']; |
|
768 | - $event['recurrence'] = $content['edit_single']; |
|
769 | - unset($event['id']); |
|
770 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
771 | - if (!is_array($conflicts) && $conflicts) |
|
772 | - { |
|
773 | - // now we need to add the original start as recur-execption to the series |
|
774 | - $recur_event = $this->bo->read($event['reference']); |
|
775 | - $recur_event['recur_exception'][] = $content['edit_single']; |
|
776 | - // check if we need to move the alarms, because they are next on that exception |
|
777 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
765 | + if ($content['edit_single']) // we edited a single event from a series |
|
766 | + { |
|
767 | + $event['reference'] = $event['id']; |
|
768 | + $event['recurrence'] = $content['edit_single']; |
|
769 | + unset($event['id']); |
|
770 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
771 | + if (!is_array($conflicts) && $conflicts) |
|
778 | 772 | { |
779 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
773 | + // now we need to add the original start as recur-execption to the series |
|
774 | + $recur_event = $this->bo->read($event['reference']); |
|
775 | + $recur_event['recur_exception'][] = $content['edit_single']; |
|
776 | + // check if we need to move the alarms, because they are next on that exception |
|
777 | + foreach($recur_event['alarm'] as $id => $alarm) |
|
780 | 778 | { |
781 | - $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
782 | - foreach ($rrule as $time) |
|
779 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
783 | 780 | { |
784 | - if ($content['edit_single'] < $time->format('ts')) |
|
781 | + $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
782 | + foreach ($rrule as $time) |
|
785 | 783 | { |
786 | - $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
787 | - $this->bo->save_alarm($event['reference'], $alarm); |
|
788 | - break; |
|
784 | + if ($content['edit_single'] < $time->format('ts')) |
|
785 | + { |
|
786 | + $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
787 | + $this->bo->save_alarm($event['reference'], $alarm); |
|
788 | + break; |
|
789 | + } |
|
789 | 790 | } |
790 | 791 | } |
791 | 792 | } |
792 | - } |
|
793 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
794 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
795 | - $this->bo->update($recur_event,true); // no conflict check here |
|
793 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
794 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
795 | + $this->bo->update($recur_event,true); // no conflict check here |
|
796 | 796 | |
797 | - // Save links |
|
798 | - if($content['links']) |
|
799 | - { |
|
800 | - Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
801 | - } |
|
797 | + // Save links |
|
798 | + if($content['links']) |
|
799 | + { |
|
800 | + Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
801 | + } |
|
802 | + |
|
803 | + if(Api\Json\Response::isJSONResponse()) |
|
804 | + { |
|
805 | + // Sending null will trigger a removal of the original |
|
806 | + // for that date |
|
807 | + Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
808 | + } |
|
802 | 809 | |
803 | - if(Api\Json\Response::isJSONResponse()) |
|
810 | + unset($recur_event); |
|
811 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
812 | + unset($preserv['edit_single']); |
|
813 | + } |
|
814 | + else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
804 | 815 | { |
805 | - // Sending null will trigger a removal of the original |
|
806 | - // for that date |
|
807 | - Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
816 | + $event['id'] = $event['reference']; |
|
817 | + $event['reference'] = $event['recurrence'] = 0; |
|
818 | + $event['uid'] = $content['uid']; |
|
808 | 819 | } |
809 | - |
|
810 | - unset($recur_event); |
|
811 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
812 | - unset($preserv['edit_single']); |
|
813 | - } |
|
814 | - else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
815 | - { |
|
816 | - $event['id'] = $event['reference']; |
|
817 | - $event['reference'] = $event['recurrence'] = 0; |
|
818 | - $event['uid'] = $content['uid']; |
|
820 | + $update_type = 'edit'; |
|
819 | 821 | } |
820 | - $update_type = 'edit'; |
|
821 | - } |
|
822 | - else // we edited a non-reccuring event or the whole series |
|
823 | - { |
|
824 | - if (($old_event = $this->bo->read($event['id']))) |
|
822 | + else // we edited a non-reccuring event or the whole series |
|
825 | 823 | { |
826 | - if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
824 | + if (($old_event = $this->bo->read($event['id']))) |
|
827 | 825 | { |
828 | - $update_type = 'edit'; |
|
829 | - |
|
830 | - // we edit a existing series event |
|
831 | - if ($event['start'] != $old_event['start'] || |
|
832 | - $event['whole_day'] != $old_event['whole_day'] || |
|
833 | - $event['end'] != $old_event['end']) |
|
826 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
834 | 827 | { |
835 | - // calculate offset against old series start or clicked recurrance, |
|
836 | - // depending on which is smaller |
|
837 | - $offset = $event['start'] - $old_event['start']; |
|
838 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
828 | + $update_type = 'edit'; |
|
829 | + |
|
830 | + // we edit a existing series event |
|
831 | + if ($event['start'] != $old_event['start'] || |
|
832 | + $event['whole_day'] != $old_event['whole_day'] || |
|
833 | + $event['end'] != $old_event['end']) |
|
839 | 834 | { |
840 | - $offset = $off2; |
|
835 | + // calculate offset against old series start or clicked recurrance, |
|
836 | + // depending on which is smaller |
|
837 | + $offset = $event['start'] - $old_event['start']; |
|
838 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
839 | + { |
|
840 | + $offset = $off2; |
|
841 | + } |
|
842 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
843 | + if($msg) |
|
844 | + { |
|
845 | + $noerror = false; |
|
846 | + } |
|
841 | 847 | } |
842 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
843 | - if($msg) |
|
848 | + } |
|
849 | + else |
|
850 | + { |
|
851 | + if ($old_event['start'] != $event['start'] || |
|
852 | + $old_event['end'] != $event['end'] || |
|
853 | + $event['whole_day'] != $old_event['whole_day']) |
|
844 | 854 | { |
845 | - $noerror = false; |
|
855 | + // check if we need to move the alarms, because they are relative |
|
856 | + $this->bo->check_move_alarms($event, $old_event); |
|
846 | 857 | } |
847 | 858 | } |
848 | 859 | } |
849 | - else |
|
860 | + // Update alarm (default alarm or set alarm before change start date) |
|
861 | + // for new event. |
|
862 | + elseif (is_array($event['alarm']) && ($event['alarm'][1]['time'] + $event['alarm'][1]['offset'] != $event['start'])) |
|
850 | 863 | { |
851 | - if ($old_event['start'] != $event['start'] || |
|
852 | - $old_event['end'] != $event['end'] || |
|
853 | - $event['whole_day'] != $old_event['whole_day']) |
|
854 | - { |
|
855 | - // check if we need to move the alarms, because they are relative |
|
856 | - $this->bo->check_move_alarms($event, $old_event); |
|
857 | - } |
|
864 | + $this->bo->check_move_alarms($event); |
|
865 | + } |
|
866 | + // Adding participants needs to be done as an edit, in case we |
|
867 | + // have participants visible in seperate calendars |
|
868 | + if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
869 | + { |
|
870 | + $update_type = 'edit'; |
|
858 | 871 | } |
872 | + // Changing category may affect event filtering |
|
873 | + if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
874 | + { |
|
875 | + $update_type = 'edit'; |
|
876 | + } |
|
877 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
878 | + unset($event['ignore']); |
|
859 | 879 | } |
860 | - // Update alarm (default alarm or set alarm before change start date) |
|
861 | - // for new event. |
|
862 | - elseif (is_array($event['alarm']) && ($event['alarm'][1]['time'] + $event['alarm'][1]['offset'] != $event['start'])) |
|
880 | + if (is_array($conflicts)) |
|
863 | 881 | { |
864 | - $this->bo->check_move_alarms($event); |
|
882 | + $event['button_was'] = $button; // remember for ignore |
|
883 | + return $this->conflicts($event,$conflicts,$preserv); |
|
865 | 884 | } |
866 | - // Adding participants needs to be done as an edit, in case we |
|
867 | - // have participants visible in seperate calendars |
|
868 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
885 | + |
|
886 | + // Event spans multiple days, need an edit to make sure they all get updated |
|
887 | + // We could check old date, as removing from days could still be an update |
|
888 | + if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
869 | 889 | { |
870 | 890 | $update_type = 'edit'; |
871 | 891 | } |
872 | - // Changing category may affect event filtering |
|
873 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
892 | + // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
|
893 | + if ($messages) |
|
874 | 894 | { |
875 | - $update_type = 'edit'; |
|
895 | + $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
876 | 896 | } |
877 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
878 | - unset($event['ignore']); |
|
879 | - } |
|
880 | - if (is_array($conflicts)) |
|
881 | - { |
|
882 | - $event['button_was'] = $button; // remember for ignore |
|
883 | - return $this->conflicts($event,$conflicts,$preserv); |
|
884 | - } |
|
885 | - |
|
886 | - // Event spans multiple days, need an edit to make sure they all get updated |
|
887 | - // We could check old date, as removing from days could still be an update |
|
888 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
889 | - { |
|
890 | - $update_type = 'edit'; |
|
891 | - } |
|
892 | - // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
|
893 | - if ($messages) |
|
894 | - { |
|
895 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
896 | - } |
|
897 | - if ($conflicts === 0) |
|
898 | - { |
|
899 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
900 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
901 | - htmlspecialchars(Egw::link('/index.php',array( |
|
902 | - 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
903 | - 'cal_id' => $content['id'], |
|
904 | - ))).'">','</a>'); |
|
905 | - $noerror = false; |
|
906 | - } |
|
907 | - elseif ($conflicts > 0) |
|
908 | - { |
|
909 | - // series moved by splitting in two --> move alarms and exceptions |
|
910 | - if ($old_event && $old_event['id'] != $event['id']) |
|
897 | + if ($conflicts === 0) |
|
911 | 898 | { |
912 | - $update_type = 'edit'; |
|
913 | - foreach ((array)$old_event['alarms'] as $alarm) |
|
899 | + $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
900 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
901 | + htmlspecialchars(Egw::link('/index.php',array( |
|
902 | + 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
903 | + 'cal_id' => $content['id'], |
|
904 | + ))).'">','</a>'); |
|
905 | + $noerror = false; |
|
906 | + } |
|
907 | + elseif ($conflicts > 0) |
|
908 | + { |
|
909 | + // series moved by splitting in two --> move alarms and exceptions |
|
910 | + if ($old_event && $old_event['id'] != $event['id']) |
|
914 | 911 | { |
915 | - // check if alarms still needed in old event, if not delete it |
|
916 | - $event_time = $alarm['time'] + $alarm['offset']; |
|
917 | - if ($event_time >= $this->bo->now_su) |
|
918 | - { |
|
919 | - $this->bo->delete_alarm($alarm['id']); |
|
920 | - } |
|
921 | - $alarm['time'] += $offset; |
|
922 | - unset($alarm['id']); |
|
923 | - // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
|
924 | - if ($alarm['time'] < $this->bo->now_su) |
|
912 | + $update_type = 'edit'; |
|
913 | + foreach ((array)$old_event['alarms'] as $alarm) |
|
925 | 914 | { |
926 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
915 | + // check if alarms still needed in old event, if not delete it |
|
916 | + $event_time = $alarm['time'] + $alarm['offset']; |
|
917 | + if ($event_time >= $this->bo->now_su) |
|
927 | 918 | { |
928 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
919 | + $this->bo->delete_alarm($alarm['id']); |
|
929 | 920 | } |
930 | - else |
|
921 | + $alarm['time'] += $offset; |
|
922 | + unset($alarm['id']); |
|
923 | + // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
|
924 | + if ($alarm['time'] < $this->bo->now_su) |
|
925 | + { |
|
926 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
927 | + { |
|
928 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
929 | + } |
|
930 | + else |
|
931 | + { |
|
932 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
933 | + } |
|
934 | + } |
|
935 | + // alarm is currently on a previous recurrence --> set for first recurrence of new series |
|
936 | + elseif ($event_time < $event['start']) |
|
931 | 937 | { |
932 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
938 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
939 | + } |
|
940 | + if ($alarm) |
|
941 | + { |
|
942 | + $alarm['id'] = $this->bo->save_alarm($event['id'], $alarm); |
|
943 | + $event['alarm'][$alarm['id']] = $alarm; |
|
933 | 944 | } |
934 | 945 | } |
935 | - // alarm is currently on a previous recurrence --> set for first recurrence of new series |
|
936 | - elseif ($event_time < $event['start']) |
|
937 | - { |
|
938 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
939 | - } |
|
940 | - if ($alarm) |
|
946 | + // attach all future exceptions to the new series |
|
947 | + $events =& $this->bo->search(array( |
|
948 | + 'query' => array('cal_uid' => $old_event['uid']), |
|
949 | + 'filter' => 'owner', // return all possible entries |
|
950 | + 'daywise' => false, |
|
951 | + 'date_format' => 'ts', |
|
952 | + )); |
|
953 | + foreach ((array)$events as $exception) |
|
941 | 954 | { |
942 | - $alarm['id'] = $this->bo->save_alarm($event['id'], $alarm); |
|
943 | - $event['alarm'][$alarm['id']] = $alarm; |
|
955 | + if ($exception['recurrence'] > $this->bo->now_su) |
|
956 | + { |
|
957 | + $exception['recurrence'] += $offset; |
|
958 | + $exception['reference'] = $event['id']; |
|
959 | + $exception['uid'] = $event['uid']; |
|
960 | + $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
961 | + } |
|
944 | 962 | } |
945 | 963 | } |
946 | - // attach all future exceptions to the new series |
|
947 | - $events =& $this->bo->search(array( |
|
948 | - 'query' => array('cal_uid' => $old_event['uid']), |
|
949 | - 'filter' => 'owner', // return all possible entries |
|
950 | - 'daywise' => false, |
|
951 | - 'date_format' => 'ts', |
|
952 | - )); |
|
953 | - foreach ((array)$events as $exception) |
|
964 | + |
|
965 | + $message = lang('Event saved'); |
|
966 | + if ($status_reset_to_unknown) |
|
954 | 967 | { |
955 | - if ($exception['recurrence'] > $this->bo->now_su) |
|
968 | + foreach((array)$event['participants'] as $uid => $status) |
|
956 | 969 | { |
957 | - $exception['recurrence'] += $offset; |
|
958 | - $exception['reference'] = $event['id']; |
|
959 | - $exception['uid'] = $event['uid']; |
|
960 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
970 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
|
971 | + { |
|
972 | + calendar_so::split_status($status,$q,$r); |
|
973 | + $status = calendar_so::combine_status('U',$q,$r); |
|
974 | + $this->bo->set_status($event['id'], $uid, $status, 0, true); |
|
975 | + } |
|
961 | 976 | } |
977 | + $message .= lang(', stati of participants reset'); |
|
962 | 978 | } |
963 | - } |
|
964 | 979 | |
965 | - $message = lang('Event saved'); |
|
966 | - if ($status_reset_to_unknown) |
|
967 | - { |
|
968 | - foreach((array)$event['participants'] as $uid => $status) |
|
980 | + $response = Api\Json\Response::get(); |
|
981 | + if($response && $update_type != 'delete') |
|
969 | 982 | { |
970 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
|
971 | - { |
|
972 | - calendar_so::split_status($status,$q,$r); |
|
973 | - $status = calendar_so::combine_status('U',$q,$r); |
|
974 | - $this->bo->set_status($event['id'], $uid, $status, 0, true); |
|
975 | - } |
|
983 | + $client_updated = $this->update_client($event['id']); |
|
976 | 984 | } |
977 | - $message .= lang(', stati of participants reset'); |
|
978 | - } |
|
979 | 985 | |
980 | - $response = Api\Json\Response::get(); |
|
981 | - if($response && $update_type != 'delete') |
|
982 | - { |
|
983 | - $client_updated = $this->update_client($event['id']); |
|
986 | + $msg = $message . ($msg ? ', ' . $msg : ''); |
|
987 | + Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
|
988 | + // writing links for new entry, existing ones are handled by the widget itself |
|
989 | + if (!$content['id'] && is_array($content['link_to']['to_id'])) |
|
990 | + { |
|
991 | + Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
992 | + } |
|
984 | 993 | } |
985 | - |
|
986 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
987 | - Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
|
988 | - // writing links for new entry, existing ones are handled by the widget itself |
|
989 | - if (!$content['id'] && is_array($content['link_to']['to_id'])) |
|
994 | + else |
|
990 | 995 | { |
991 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
996 | + $msg = lang('Error: saving the event !!!'); |
|
992 | 997 | } |
993 | - } |
|
994 | - else |
|
995 | - { |
|
996 | - $msg = lang('Error: saving the event !!!'); |
|
997 | - } |
|
998 | - break; |
|
999 | - |
|
1000 | - case 'cancel': |
|
1001 | - if($content['cancel_needs_refresh']) |
|
1002 | - { |
|
1003 | - Framework::refresh_opener($msg, 'calendar'); |
|
1004 | - } |
|
1005 | - break; |
|
998 | + break; |
|
1006 | 999 | |
1007 | - case 'delete': // delete of event (regular or series) |
|
1008 | - $exceptions_kept = null; |
|
1009 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
1010 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
1011 | - { |
|
1012 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
1000 | + case 'cancel': |
|
1001 | + if($content['cancel_needs_refresh']) |
|
1013 | 1002 | { |
1014 | - $msg = lang('Series deleted'); |
|
1015 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
1003 | + Framework::refresh_opener($msg, 'calendar'); |
|
1016 | 1004 | } |
1017 | - else |
|
1005 | + break; |
|
1006 | + |
|
1007 | + case 'delete': // delete of event (regular or series) |
|
1008 | + $exceptions_kept = null; |
|
1009 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
1010 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
1018 | 1011 | { |
1019 | - $msg = lang('Event deleted'); |
|
1020 | - } |
|
1012 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
1013 | + { |
|
1014 | + $msg = lang('Series deleted'); |
|
1015 | + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
1016 | + } |
|
1017 | + else |
|
1018 | + { |
|
1019 | + $msg = lang('Event deleted'); |
|
1020 | + } |
|
1021 | 1021 | |
1022 | - } |
|
1023 | - break; |
|
1022 | + } |
|
1023 | + break; |
|
1024 | 1024 | |
1025 | - case 'freetime': |
|
1026 | - // the "click" has to be in onload, to make sure the button is already created |
|
1027 | - $event['button_was'] = $button; |
|
1028 | - break; |
|
1025 | + case 'freetime': |
|
1026 | + // the "click" has to be in onload, to make sure the button is already created |
|
1027 | + $event['button_was'] = $button; |
|
1028 | + break; |
|
1029 | 1029 | |
1030 | - case 'add_alarm': |
|
1031 | - $time = $content['start']; |
|
1032 | - $offset = $time - $content['new_alarm']['date']; |
|
1033 | - if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
1034 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
1035 | - $time < $next_occurrence['start']) |
|
1036 | - { |
|
1037 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
1038 | - } |
|
1039 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1040 | - { |
|
1041 | - $alarm = array( |
|
1042 | - 'offset' => $offset, |
|
1043 | - 'time' => $content['new_alarm']['date'], |
|
1044 | - 'all' => !$content['new_alarm']['owner'], |
|
1045 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
1046 | - ); |
|
1047 | - if ($alarm['time'] < $this->bo->now_su) |
|
1030 | + case 'add_alarm': |
|
1031 | + $time = $content['start']; |
|
1032 | + $offset = $time - $content['new_alarm']['date']; |
|
1033 | + if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
1034 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
1035 | + $time < $next_occurrence['start']) |
|
1048 | 1036 | { |
1049 | - $msg = lang("Can't add alarms in the past !!!"); |
|
1037 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
1050 | 1038 | } |
1051 | - elseif ($event['id']) // save the alarm immediatly |
|
1039 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1052 | 1040 | { |
1053 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1041 | + $alarm = array( |
|
1042 | + 'offset' => $offset, |
|
1043 | + 'time' => $content['new_alarm']['date'], |
|
1044 | + 'all' => !$content['new_alarm']['owner'], |
|
1045 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
1046 | + ); |
|
1047 | + if ($alarm['time'] < $this->bo->now_su) |
|
1054 | 1048 | { |
1055 | - $alarm['id'] = $alarm_id; |
|
1056 | - $event['alarm'][$alarm_id] = $alarm; |
|
1049 | + $msg = lang("Can't add alarms in the past !!!"); |
|
1050 | + } |
|
1051 | + elseif ($event['id']) // save the alarm immediatly |
|
1052 | + { |
|
1053 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1054 | + { |
|
1055 | + $alarm['id'] = $alarm_id; |
|
1056 | + $event['alarm'][$alarm_id] = $alarm; |
|
1057 | 1057 | |
1058 | - $msg = lang('Alarm added'); |
|
1059 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1058 | + $msg = lang('Alarm added'); |
|
1059 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1060 | + } |
|
1061 | + else |
|
1062 | + { |
|
1063 | + $msg = lang('Error adding the alarm'); |
|
1064 | + } |
|
1060 | 1065 | } |
1061 | 1066 | else |
1062 | 1067 | { |
1063 | - $msg = lang('Error adding the alarm'); |
|
1068 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1069 | + $event['alarm'][$alarm['id']] = $alarm; |
|
1064 | 1070 | } |
1065 | 1071 | } |
1066 | 1072 | else |
1067 | 1073 | { |
1068 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1069 | - $event['alarm'][$alarm['id']] = $alarm; |
|
1074 | + $msg = lang('Permission denied'); |
|
1070 | 1075 | } |
1071 | - } |
|
1072 | - else |
|
1073 | - { |
|
1074 | - $msg = lang('Permission denied'); |
|
1075 | - } |
|
1076 | - break; |
|
1076 | + break; |
|
1077 | 1077 | } |
1078 | 1078 | // add notification-errors, if we have some |
1079 | 1079 | if (($notification_errors = notifications::errors(true))) |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var locktime in seconds |
58 | 58 | */ |
59 | - var $locktime_default=1; |
|
59 | + var $locktime_default = 1; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Constructor |
63 | 63 | */ |
64 | 64 | function __construct() |
65 | 65 | { |
66 | - parent::__construct(true); // call the parent's constructor |
|
66 | + parent::__construct(true); // call the parent's constructor |
|
67 | 67 | |
68 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
68 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
69 | 69 | { |
70 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
70 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -79,11 +79,10 @@ discard block |
||
79 | 79 | function &default_add_event() |
80 | 80 | { |
81 | 81 | $extra_participants = $_GET['participants'] ? |
82 | - (!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) : |
|
83 | - array(); |
|
82 | + (!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array(); |
|
84 | 83 | |
85 | 84 | // if participant is a contact, add its link title as title |
86 | - foreach($extra_participants as $uid) |
|
85 | + foreach ($extra_participants as $uid) |
|
87 | 86 | { |
88 | 87 | if ($uid[0] == 'c') |
89 | 88 | { |
@@ -92,21 +91,21 @@ discard block |
||
92 | 91 | } |
93 | 92 | } |
94 | 93 | |
95 | - if($_GET['title']) |
|
94 | + if ($_GET['title']) |
|
96 | 95 | { |
97 | 96 | $title = $_GET['title']; |
98 | 97 | } |
99 | 98 | if (isset($_GET['owner'])) |
100 | 99 | { |
101 | 100 | $owner = $_GET['owner']; |
102 | - if(!is_array($owner) && strpos($owner, ',')) |
|
101 | + if (!is_array($owner) && strpos($owner, ',')) |
|
103 | 102 | { |
104 | - $owner = explode(',',$owner); |
|
103 | + $owner = explode(',', $owner); |
|
105 | 104 | } |
106 | - if(is_array($owner)) |
|
105 | + if (is_array($owner)) |
|
107 | 106 | { |
108 | 107 | // old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0' |
109 | - if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
108 | + if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
110 | 109 | { |
111 | 110 | $extra_participants += $owner; |
112 | 111 | } |
@@ -124,18 +123,18 @@ discard block |
||
124 | 123 | } |
125 | 124 | |
126 | 125 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
127 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
126 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
128 | 127 | { |
129 | 128 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
130 | 129 | { |
131 | - if(!is_array($owner)) |
|
130 | + if (!is_array($owner)) |
|
132 | 131 | { |
133 | - $owner = explode(',',$owner); |
|
132 | + $owner = explode(',', $owner); |
|
134 | 133 | } |
135 | 134 | // if we come from ressources we don't need any users selected in calendar |
136 | 135 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
137 | 136 | { |
138 | - foreach($owner as $uid) |
|
137 | + foreach ($owner as $uid) |
|
139 | 138 | { |
140 | 139 | $extra_participants[] = $uid; |
141 | 140 | } |
@@ -145,7 +144,7 @@ discard block |
||
145 | 144 | } |
146 | 145 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
147 | 146 | |
148 | - if(isset($_GET['start'])) |
|
147 | + if (isset($_GET['start'])) |
|
149 | 148 | { |
150 | 149 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
151 | 150 | } |
@@ -154,64 +153,64 @@ discard block |
||
154 | 153 | $ts = new Api\DateTime(); |
155 | 154 | $ts->setUser(); |
156 | 155 | $start = $this->bo->date2ts(array( |
157 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
158 | - 'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : ($ts->format('H')+1)), |
|
159 | - 'minute' => (int) $_GET['minute'], |
|
156 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
157 | + 'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : ($ts->format('H') + 1)), |
|
158 | + 'minute' => (int)$_GET['minute'], |
|
160 | 159 | )); |
161 | 160 | } |
162 | 161 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
163 | 162 | |
164 | 163 | $participant_types['u'] = $participant_types = $participants = array(); |
165 | - foreach($extra_participants as $uid) |
|
164 | + foreach ($extra_participants as $uid) |
|
166 | 165 | { |
167 | - if (isset($participants[$uid])) continue; // already included |
|
166 | + if (isset($participants[$uid])) continue; // already included |
|
168 | 167 | |
169 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
168 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
170 | 169 | |
171 | 170 | if (is_numeric($uid)) |
172 | 171 | { |
173 | 172 | $participants[$uid] = $participant_types['u'][$uid] = |
174 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
175 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
173 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
174 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
176 | 175 | } |
177 | 176 | elseif (is_array($this->bo->resources[$uid[0]])) |
178 | 177 | { |
179 | 178 | // Expand mailing lists |
180 | - if($uid[0] == 'l') |
|
179 | + if ($uid[0] == 'l') |
|
181 | 180 | { |
182 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
181 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
183 | 182 | { |
184 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
185 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
183 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
184 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
186 | 185 | } |
187 | 186 | continue; |
188 | 187 | } |
189 | 188 | // if contact is a user, use the user instead (as the GUI) |
190 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
189 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
191 | 190 | { |
192 | 191 | $uid = $account_id; |
193 | 192 | $participants[$uid] = $participant_types['u'][$uid] = |
194 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
195 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
193 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
194 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
196 | 195 | continue; |
197 | 196 | } |
198 | 197 | $res_data = $this->bo->resources[$uid[0]]; |
199 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
200 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
198 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
199 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
201 | 200 | { |
202 | 201 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
203 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
202 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
204 | 203 | } |
205 | 204 | } |
206 | 205 | } |
207 | 206 | if (!$participants) // if all participants got removed, include current user |
208 | 207 | { |
209 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
208 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
210 | 209 | } |
211 | - if(isset($_GET['cat_id'])) |
|
210 | + if (isset($_GET['cat_id'])) |
|
212 | 211 | { |
213 | - $cat_id = explode(',',$_GET['cat_id']); |
|
214 | - foreach($cat_id as &$cat) |
|
212 | + $cat_id = explode(',', $_GET['cat_id']); |
|
213 | + foreach ($cat_id as &$cat) |
|
215 | 214 | { |
216 | 215 | $cat = (int)$cat; |
217 | 216 | } |
@@ -220,8 +219,8 @@ discard block |
||
220 | 219 | { |
221 | 220 | $cat_id = $this->cal_prefs['default_category']; |
222 | 221 | } |
223 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
224 | - if(isset($_GET['end'])) |
|
222 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
223 | + if (isset($_GET['end'])) |
|
225 | 224 | { |
226 | 225 | $end = Api\DateTime::to($_GET['end'], 'ts'); |
227 | 226 | $duration = $end - $start; |
@@ -239,9 +238,9 @@ discard block |
||
239 | 238 | if ((string)$this->cal_prefs[$alarm_pref] !== '') |
240 | 239 | { |
241 | 240 | $offset = 60 * $this->cal_prefs[$alarm_pref]; |
242 | - $alarms[1] = array( |
|
241 | + $alarms[1] = array( |
|
243 | 242 | 'default' => 1, |
244 | - 'offset' => $offset , |
|
243 | + 'offset' => $offset, |
|
245 | 244 | 'time' => $start - $offset, |
246 | 245 | 'all' => false, |
247 | 246 | 'owner' => $owner, |
@@ -256,7 +255,7 @@ discard block |
||
256 | 255 | 'start' => $start, |
257 | 256 | 'end' => $end, |
258 | 257 | 'tzid' => $this->bo->common_prefs['tz'], |
259 | - 'priority' => 2, // normal |
|
258 | + 'priority' => 2, // normal |
|
260 | 259 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
261 | 260 | 'alarm' => $alarms, |
262 | 261 | 'recur_exception' => array(), |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | { |
276 | 275 | if (!is_array($content)) // redirect from etemplate, if POST empty |
277 | 276 | { |
278 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
277 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
279 | 278 | } |
280 | 279 | // clear notification errors |
281 | 280 | notifications::errors(true); |
@@ -289,22 +288,22 @@ discard block |
||
289 | 288 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
290 | 289 | |
291 | 290 | $button = @key($content['button']); |
292 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
291 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
293 | 292 | unset($content['button']); unset($content['action']); |
294 | 293 | |
295 | 294 | $view = $content['view']; |
296 | 295 | if ($button == 'ical') |
297 | 296 | { |
298 | - $msg = $this->export($content['id'],true); |
|
297 | + $msg = $this->export($content['id'], true); |
|
299 | 298 | } |
300 | 299 | // delete a recur-exception |
301 | 300 | if ($content['recur_exception']['delete_exception']) |
302 | 301 | { |
303 | 302 | $date = key($content['recur_exception']['delete_exception']); |
304 | 303 | // eT2 converts time to |
305 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
304 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
306 | 305 | unset($content['recur_exception']['delete_exception']); |
307 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
306 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
308 | 307 | { |
309 | 308 | // propagate the exception to a single event |
310 | 309 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -314,7 +313,7 @@ discard block |
||
314 | 313 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
315 | 314 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
316 | 315 | $exception['reference'] = $exception['recurrence'] = 0; |
317 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
316 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
318 | 317 | break; |
319 | 318 | } |
320 | 319 | unset($content['recur_exception'][$key]); |
@@ -355,7 +354,7 @@ discard block |
||
355 | 354 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
356 | 355 | if ((string)$def_alarm === '') |
357 | 356 | { |
358 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
357 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
359 | 358 | } |
360 | 359 | else |
361 | 360 | { |
@@ -377,7 +376,7 @@ discard block |
||
377 | 376 | $offset = 60 * $def_alarm; |
378 | 377 | array_unshift($content['alarm'], array( |
379 | 378 | 'default' => 1, |
380 | - 'offset' => $offset , |
|
379 | + 'offset' => $offset, |
|
381 | 380 | 'time' => $content['start'] - $offset, |
382 | 381 | 'all' => false, |
383 | 382 | 'owner' => 0, |
@@ -390,7 +389,7 @@ discard block |
||
390 | 389 | unset($event['alarm']['delete_alarm']); |
391 | 390 | unset($event['duration']); |
392 | 391 | |
393 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
392 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
394 | 393 | { |
395 | 394 | // no conversation necessary, event is already in the right format |
396 | 395 | } |
@@ -410,7 +409,7 @@ discard block |
||
410 | 409 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
411 | 410 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
412 | 411 | { |
413 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
412 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
414 | 413 | } |
415 | 414 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
416 | 415 | { |
@@ -422,9 +421,9 @@ discard block |
||
422 | 421 | |
423 | 422 | $event['participants'] = $event['participant_types'] = array(); |
424 | 423 | |
425 | - foreach($content['participants'] as $key => $data) |
|
424 | + foreach ($content['participants'] as $key => $data) |
|
426 | 425 | { |
427 | - switch($key) |
|
426 | + switch ($key) |
|
428 | 427 | { |
429 | 428 | case 'delete': // handled in default |
430 | 429 | case 'quantity': // handled in new_resource |
@@ -433,7 +432,7 @@ discard block |
||
433 | 432 | case 'status_date': |
434 | 433 | break; |
435 | 434 | case 'participant': |
436 | - foreach($data as $participant) |
|
435 | + foreach ($data as $participant) |
|
437 | 436 | { |
438 | 437 | if (is_null($participant)) |
439 | 438 | { |
@@ -442,17 +441,17 @@ discard block |
||
442 | 441 | |
443 | 442 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
444 | 443 | $email = array(); |
445 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
444 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
446 | 445 | { |
447 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
448 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
446 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
447 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
449 | 448 | { |
450 | 449 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
451 | 450 | } |
452 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
451 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
453 | 452 | 'email' => $email[2], |
454 | 453 | 'email_home' => $email[2], |
455 | - ),true,'','','',false,'OR'))) |
|
454 | + ), true, '', '', '', false, 'OR'))) |
|
456 | 455 | { |
457 | 456 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
458 | 457 | } |
@@ -463,7 +462,7 @@ discard block |
||
463 | 462 | } |
464 | 463 | else |
465 | 464 | { |
466 | - if(is_numeric($participant)) |
|
465 | + if (is_numeric($participant)) |
|
467 | 466 | { |
468 | 467 | $uid = $participant; |
469 | 468 | $id = $participant; |
@@ -472,12 +471,12 @@ discard block |
||
472 | 471 | else |
473 | 472 | { |
474 | 473 | $uid = $participant; |
475 | - $id = substr($participant,1); |
|
474 | + $id = substr($participant, 1); |
|
476 | 475 | $resource = $this->bo->resources[$participant[0]]; |
477 | 476 | } |
478 | - if(!$this->bo->check_acl_invite($uid)) |
|
477 | + if (!$this->bo->check_acl_invite($uid)) |
|
479 | 478 | { |
480 | - if(!$msg_permission_denied_added) |
|
479 | + if (!$msg_permission_denied_added) |
|
481 | 480 | { |
482 | 481 | $msg .= lang('Permission denied!'); |
483 | 482 | $msg_permission_denied_added = true; |
@@ -487,20 +486,19 @@ discard block |
||
487 | 486 | |
488 | 487 | $type = $resource['type']; |
489 | 488 | $status = isset($this->bo->resources[$type]['new_status']) ? |
490 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
491 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
489 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
492 | 490 | |
493 | 491 | // Expand mailing lists |
494 | - if($type == 'l') |
|
492 | + if ($type == 'l') |
|
495 | 493 | { |
496 | 494 | // Ignore ACL here, allow inviting anyone in the list |
497 | - foreach($this->bo->enum_mailing_list($participant, true) as $contact) |
|
495 | + foreach ($this->bo->enum_mailing_list($participant, true) as $contact) |
|
498 | 496 | { |
499 | 497 | // Mailing lists can contain users, so allow for that possibility |
500 | 498 | $_type = is_numeric($contact) ? '' : $contact[0]; |
501 | - $_uid = is_numeric($contact) ? $contact : substr($contact,1); |
|
499 | + $_uid = is_numeric($contact) ? $contact : substr($contact, 1); |
|
502 | 500 | $event['participants'][$contact] = $event['participant_types'][$_type][$_uid] = |
503 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
501 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
504 | 502 | } |
505 | 503 | continue; |
506 | 504 | } |
@@ -510,8 +508,8 @@ discard block |
||
510 | 508 | // todo check real availability = maximum - already booked quantity |
511 | 509 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
512 | 510 | { |
513 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
514 | - foreach(array('quantity','resource','role') as $n) |
|
511 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
512 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
515 | 513 | { |
516 | 514 | $event['participants'][$n] = $content['participants'][$n]; |
517 | 515 | } |
@@ -520,7 +518,7 @@ discard block |
||
520 | 518 | else |
521 | 519 | { |
522 | 520 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
523 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
521 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
524 | 522 | } |
525 | 523 | } |
526 | 524 | } |
@@ -534,15 +532,15 @@ discard block |
||
534 | 532 | break; |
535 | 533 | |
536 | 534 | default: // existing participant row |
537 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
535 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
538 | 536 | $quantity = $status = $role = null; |
539 | - foreach(array('uid','status','quantity','role') as $name) |
|
537 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
540 | 538 | { |
541 | 539 | $$name = $data[$name]; |
542 | 540 | } |
543 | 541 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
544 | 542 | { |
545 | - $uid = false; // entry has been deleted |
|
543 | + $uid = false; // entry has been deleted |
|
546 | 544 | } |
547 | 545 | elseif ($uid) |
548 | 546 | { |
@@ -553,27 +551,27 @@ discard block |
||
553 | 551 | } |
554 | 552 | else |
555 | 553 | { |
556 | - $id = substr($uid,1); |
|
554 | + $id = substr($uid, 1); |
|
557 | 555 | $type = $uid[0]; |
558 | 556 | } |
559 | 557 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
560 | 558 | { |
561 | 559 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
562 | 560 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
563 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
561 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
564 | 562 | { |
565 | 563 | // Update main window |
566 | 564 | $d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone); |
567 | 565 | $client_updated = $this->update_client($event['id'], $d); |
568 | 566 | |
569 | 567 | // refreshing the calendar-view with the changed participant-status |
570 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
568 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
571 | 569 | { |
572 | 570 | $msg = lang('Status for all future scheduled days changed'); |
573 | 571 | } |
574 | 572 | else |
575 | 573 | { |
576 | - if(isset($content['edit_single'])) |
|
574 | + if (isset($content['edit_single'])) |
|
577 | 575 | { |
578 | 576 | $msg = lang('Status for this particular day changed'); |
579 | 577 | // prevent accidentally creating a real exception afterwards |
@@ -594,7 +592,7 @@ discard block |
||
594 | 592 | if ($status == 'R' && $event['alarm']) |
595 | 593 | { |
596 | 594 | // remove from bo->set_status deleted alarms of rejected users from UI too |
597 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
595 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
598 | 596 | { |
599 | 597 | if ((string)$alarm['owner'] === (string)$uid) |
600 | 598 | { |
@@ -607,7 +605,7 @@ discard block |
||
607 | 605 | if ($uid && $status != 'G') |
608 | 606 | { |
609 | 607 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
610 | - calendar_so::combine_status($status,$quantity,$role); |
|
608 | + calendar_so::combine_status($status, $quantity, $role); |
|
611 | 609 | } |
612 | 610 | } |
613 | 611 | break; |
@@ -626,26 +624,26 @@ discard block |
||
626 | 624 | 'tabs' => $content['tabs'], |
627 | 625 | 'template' => $content['template'], |
628 | 626 | ); |
629 | - $noerror=true; |
|
627 | + $noerror = true; |
|
630 | 628 | |
631 | 629 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
632 | 630 | |
633 | 631 | $ignore_conflicts = $status_reset_to_unknown = false; |
634 | 632 | |
635 | - switch((string)$button) |
|
633 | + switch ((string)$button) |
|
636 | 634 | { |
637 | 635 | case 'ignore': |
638 | 636 | $ignore_conflicts = true; |
639 | - $button = $event['button_was']; // save or apply |
|
637 | + $button = $event['button_was']; // save or apply |
|
640 | 638 | unset($event['button_was']); |
641 | 639 | break; |
642 | 640 | |
643 | 641 | } |
644 | 642 | |
645 | - switch((string)$button) |
|
643 | + switch ((string)$button) |
|
646 | 644 | { |
647 | 645 | case 'exception': // create an exception in a recuring event |
648 | - $msg = $this->_create_exception($event,$preserv); |
|
646 | + $msg = $this->_create_exception($event, $preserv); |
|
649 | 647 | break; |
650 | 648 | case 'edit': |
651 | 649 | // Going from add dialog to full edit dialog |
@@ -661,29 +659,29 @@ discard block |
||
661 | 659 | unset($event['recurrence']); |
662 | 660 | unset($preserv['recurrence']); |
663 | 661 | unset($event['recur_exception']); |
664 | - unset($event['edit_single']); // in case it has been set |
|
662 | + unset($event['edit_single']); // in case it has been set |
|
665 | 663 | unset($event['modified']); |
666 | 664 | unset($event['modifier']); |
667 | 665 | unset($event['caldav_name']); |
668 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
666 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner']; |
|
669 | 667 | |
670 | 668 | // Clear participant stati |
671 | - foreach($event['participant_types'] as $type => &$participants) |
|
669 | + foreach ($event['participant_types'] as $type => &$participants) |
|
672 | 670 | { |
673 | - foreach($participants as $id => &$p_response) |
|
671 | + foreach ($participants as $id => &$p_response) |
|
674 | 672 | { |
675 | - if($type == 'u' && $id == $event['owner']) continue; |
|
673 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
676 | 674 | calendar_so::split_status($p_response, $quantity, $role); |
677 | 675 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
678 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
679 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
676 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
677 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
680 | 678 | } |
681 | 679 | } |
682 | 680 | |
683 | 681 | // Copy alarms |
684 | 682 | if (is_array($event['alarm'])) |
685 | 683 | { |
686 | - foreach($event['alarm'] as $n => &$alarm) |
|
684 | + foreach ($event['alarm'] as $n => &$alarm) |
|
687 | 685 | { |
688 | 686 | unset($alarm['id']); |
689 | 687 | unset($alarm['cal_id']); |
@@ -693,7 +691,7 @@ discard block |
||
693 | 691 | // Get links to be copied |
694 | 692 | // With no ID, $content['link_to']['to_id'] is used |
695 | 693 | $content['link_to'] = array('to_app' => 'calendar', 'to_id' => 0); |
696 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
694 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
697 | 695 | { |
698 | 696 | if ($link['app'] != Link::VFS_APPNAME) |
699 | 697 | { |
@@ -709,7 +707,7 @@ discard block |
||
709 | 707 | } |
710 | 708 | unset($link); |
711 | 709 | $preserv['view'] = $preserv['edit_single'] = false; |
712 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
710 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry'))); |
|
713 | 711 | $event['title'] = lang('Copy of:').' '.$event['title']; |
714 | 712 | break; |
715 | 713 | |
@@ -719,7 +717,7 @@ discard block |
||
719 | 717 | case 'print': |
720 | 718 | case 'apply': |
721 | 719 | case 'infolog': |
722 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
720 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
723 | 721 | { |
724 | 722 | $msg = lang('Permission denied'); |
725 | 723 | $button = ''; |
@@ -737,7 +735,7 @@ discard block |
||
737 | 735 | $button = ''; |
738 | 736 | break; |
739 | 737 | } |
740 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
738 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
741 | 739 | { |
742 | 740 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
743 | 741 | $button = ''; |
@@ -767,14 +765,14 @@ discard block |
||
767 | 765 | $event['reference'] = $event['id']; |
768 | 766 | $event['recurrence'] = $content['edit_single']; |
769 | 767 | unset($event['id']); |
770 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
768 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
771 | 769 | if (!is_array($conflicts) && $conflicts) |
772 | 770 | { |
773 | 771 | // now we need to add the original start as recur-execption to the series |
774 | 772 | $recur_event = $this->bo->read($event['reference']); |
775 | 773 | $recur_event['recur_exception'][] = $content['edit_single']; |
776 | 774 | // check if we need to move the alarms, because they are next on that exception |
777 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
775 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
778 | 776 | { |
779 | 777 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
780 | 778 | { |
@@ -790,17 +788,17 @@ discard block |
||
790 | 788 | } |
791 | 789 | } |
792 | 790 | } |
793 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
794 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
795 | - $this->bo->update($recur_event,true); // no conflict check here |
|
791 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
792 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
793 | + $this->bo->update($recur_event, true); // no conflict check here |
|
796 | 794 | |
797 | 795 | // Save links |
798 | - if($content['links']) |
|
796 | + if ($content['links']) |
|
799 | 797 | { |
800 | 798 | Link::link('calendar', $event['id'], $content['links']['to_id']); |
801 | 799 | } |
802 | 800 | |
803 | - if(Api\Json\Response::isJSONResponse()) |
|
801 | + if (Api\Json\Response::isJSONResponse()) |
|
804 | 802 | { |
805 | 803 | // Sending null will trigger a removal of the original |
806 | 804 | // for that date |
@@ -808,7 +806,7 @@ discard block |
||
808 | 806 | } |
809 | 807 | |
810 | 808 | unset($recur_event); |
811 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
809 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
812 | 810 | unset($preserv['edit_single']); |
813 | 811 | } |
814 | 812 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -839,8 +837,8 @@ discard block |
||
839 | 837 | { |
840 | 838 | $offset = $off2; |
841 | 839 | } |
842 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
843 | - if($msg) |
|
840 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
841 | + if ($msg) |
|
844 | 842 | { |
845 | 843 | $noerror = false; |
846 | 844 | } |
@@ -865,43 +863,43 @@ discard block |
||
865 | 863 | } |
866 | 864 | // Adding participants needs to be done as an edit, in case we |
867 | 865 | // have participants visible in seperate calendars |
868 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
866 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
869 | 867 | { |
870 | 868 | $update_type = 'edit'; |
871 | 869 | } |
872 | 870 | // Changing category may affect event filtering |
873 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
871 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
874 | 872 | { |
875 | 873 | $update_type = 'edit'; |
876 | 874 | } |
877 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
875 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
878 | 876 | unset($event['ignore']); |
879 | 877 | } |
880 | 878 | if (is_array($conflicts)) |
881 | 879 | { |
882 | - $event['button_was'] = $button; // remember for ignore |
|
883 | - return $this->conflicts($event,$conflicts,$preserv); |
|
880 | + $event['button_was'] = $button; // remember for ignore |
|
881 | + return $this->conflicts($event, $conflicts, $preserv); |
|
884 | 882 | } |
885 | 883 | |
886 | 884 | // Event spans multiple days, need an edit to make sure they all get updated |
887 | 885 | // We could check old date, as removing from days could still be an update |
888 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
886 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
889 | 887 | { |
890 | 888 | $update_type = 'edit'; |
891 | 889 | } |
892 | 890 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
893 | 891 | if ($messages) |
894 | 892 | { |
895 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
893 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
896 | 894 | } |
897 | 895 | if ($conflicts === 0) |
898 | 896 | { |
899 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
900 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
901 | - htmlspecialchars(Egw::link('/index.php',array( |
|
897 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
898 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
899 | + htmlspecialchars(Egw::link('/index.php', array( |
|
902 | 900 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
903 | 901 | 'cal_id' => $content['id'], |
904 | - ))).'">','</a>'); |
|
902 | + ))).'">', '</a>'); |
|
905 | 903 | $noerror = false; |
906 | 904 | } |
907 | 905 | elseif ($conflicts > 0) |
@@ -923,19 +921,19 @@ discard block |
||
923 | 921 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
924 | 922 | if ($alarm['time'] < $this->bo->now_su) |
925 | 923 | { |
926 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
924 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
927 | 925 | { |
928 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
926 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
929 | 927 | } |
930 | 928 | else |
931 | 929 | { |
932 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
930 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
933 | 931 | } |
934 | 932 | } |
935 | 933 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
936 | 934 | elseif ($event_time < $event['start']) |
937 | 935 | { |
938 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
936 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
939 | 937 | } |
940 | 938 | if ($alarm) |
941 | 939 | { |
@@ -944,9 +942,9 @@ discard block |
||
944 | 942 | } |
945 | 943 | } |
946 | 944 | // attach all future exceptions to the new series |
947 | - $events =& $this->bo->search(array( |
|
945 | + $events = & $this->bo->search(array( |
|
948 | 946 | 'query' => array('cal_uid' => $old_event['uid']), |
949 | - 'filter' => 'owner', // return all possible entries |
|
947 | + 'filter' => 'owner', // return all possible entries |
|
950 | 948 | 'daywise' => false, |
951 | 949 | 'date_format' => 'ts', |
952 | 950 | )); |
@@ -957,7 +955,7 @@ discard block |
||
957 | 955 | $exception['recurrence'] += $offset; |
958 | 956 | $exception['reference'] = $event['id']; |
959 | 957 | $exception['uid'] = $event['uid']; |
960 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
958 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
961 | 959 | } |
962 | 960 | } |
963 | 961 | } |
@@ -965,12 +963,12 @@ discard block |
||
965 | 963 | $message = lang('Event saved'); |
966 | 964 | if ($status_reset_to_unknown) |
967 | 965 | { |
968 | - foreach((array)$event['participants'] as $uid => $status) |
|
966 | + foreach ((array)$event['participants'] as $uid => $status) |
|
969 | 967 | { |
970 | 968 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
971 | 969 | { |
972 | - calendar_so::split_status($status,$q,$r); |
|
973 | - $status = calendar_so::combine_status('U',$q,$r); |
|
970 | + calendar_so::split_status($status, $q, $r); |
|
971 | + $status = calendar_so::combine_status('U', $q, $r); |
|
974 | 972 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
975 | 973 | } |
976 | 974 | } |
@@ -978,17 +976,17 @@ discard block |
||
978 | 976 | } |
979 | 977 | |
980 | 978 | $response = Api\Json\Response::get(); |
981 | - if($response && $update_type != 'delete') |
|
979 | + if ($response && $update_type != 'delete') |
|
982 | 980 | { |
983 | 981 | $client_updated = $this->update_client($event['id']); |
984 | 982 | } |
985 | 983 | |
986 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
984 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
987 | 985 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
988 | 986 | // writing links for new entry, existing ones are handled by the widget itself |
989 | 987 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
990 | 988 | { |
991 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
989 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
992 | 990 | } |
993 | 991 | } |
994 | 992 | else |
@@ -998,7 +996,7 @@ discard block |
||
998 | 996 | break; |
999 | 997 | |
1000 | 998 | case 'cancel': |
1001 | - if($content['cancel_needs_refresh']) |
|
999 | + if ($content['cancel_needs_refresh']) |
|
1002 | 1000 | { |
1003 | 1001 | Framework::refresh_opener($msg, 'calendar'); |
1004 | 1002 | } |
@@ -1036,7 +1034,7 @@ discard block |
||
1036 | 1034 | { |
1037 | 1035 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
1038 | 1036 | } |
1039 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
1037 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
1040 | 1038 | { |
1041 | 1039 | $alarm = array( |
1042 | 1040 | 'offset' => $offset, |
@@ -1050,13 +1048,13 @@ discard block |
||
1050 | 1048 | } |
1051 | 1049 | elseif ($event['id']) // save the alarm immediatly |
1052 | 1050 | { |
1053 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
1051 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
1054 | 1052 | { |
1055 | 1053 | $alarm['id'] = $alarm_id; |
1056 | 1054 | $event['alarm'][$alarm_id] = $alarm; |
1057 | 1055 | |
1058 | 1056 | $msg = lang('Alarm added'); |
1059 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
1057 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
1060 | 1058 | } |
1061 | 1059 | else |
1062 | 1060 | { |
@@ -1065,7 +1063,7 @@ discard block |
||
1065 | 1063 | } |
1066 | 1064 | else |
1067 | 1065 | { |
1068 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1066 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1069 | 1067 | $event['alarm'][$alarm['id']] = $alarm; |
1070 | 1068 | } |
1071 | 1069 | } |
@@ -1082,32 +1080,32 @@ discard block |
||
1082 | 1080 | } |
1083 | 1081 | // New event, send data before updating so it's there |
1084 | 1082 | $response = Api\Json\Response::get(); |
1085 | - if($response && !$content['id'] && $event['id']) |
|
1083 | + if ($response && !$content['id'] && $event['id']) |
|
1086 | 1084 | { |
1087 | 1085 | $client_updated = $this->update_client($event['id']); |
1088 | 1086 | } |
1089 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
1087 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
1090 | 1088 | { |
1091 | 1089 | if ($content['lock_token']) // remove an existing lock |
1092 | 1090 | { |
1093 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
1091 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
1094 | 1092 | } |
1095 | 1093 | if ($content['no_popup']) |
1096 | 1094 | { |
1097 | - Egw::redirect_link('/index.php',array( |
|
1095 | + Egw::redirect_link('/index.php', array( |
|
1098 | 1096 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1099 | 1097 | 'msg' => $msg, |
1100 | 1098 | 'ajax' => 'true' |
1101 | 1099 | )); |
1102 | 1100 | } |
1103 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1101 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
1104 | 1102 | { |
1105 | - Framework::refresh_opener($msg,'calendar'); |
|
1103 | + Framework::refresh_opener($msg, 'calendar'); |
|
1106 | 1104 | } |
1107 | 1105 | else |
1108 | 1106 | { |
1109 | 1107 | Framework::refresh_opener($msg, 'calendar', |
1110 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
1108 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
1111 | 1109 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
1112 | 1110 | ); |
1113 | 1111 | } |
@@ -1115,7 +1113,7 @@ discard block |
||
1115 | 1113 | exit(); |
1116 | 1114 | } |
1117 | 1115 | unset($event['no_notifications']); |
1118 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1116 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
1119 | 1117 | } |
1120 | 1118 | |
1121 | 1119 | /** |
@@ -1127,7 +1125,7 @@ discard block |
||
1127 | 1125 | * @param array &$preserv |
1128 | 1126 | * @return string message that exception was created |
1129 | 1127 | */ |
1130 | - function _create_exception(&$event,&$preserv) |
|
1128 | + function _create_exception(&$event, &$preserv) |
|
1131 | 1129 | { |
1132 | 1130 | // In some cases where the user makes the first day an exception, actual_date may be missing |
1133 | 1131 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1137,25 +1135,25 @@ discard block |
||
1137 | 1135 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
1138 | 1136 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
1139 | 1137 | $event['recur_type'] = MCAL_RECUR_NONE; |
1140 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
1138 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
1141 | 1139 | { |
1142 | 1140 | unset($event[$name]); |
1143 | 1141 | } |
1144 | 1142 | // add all alarms as new alarms to execption |
1145 | 1143 | $event['alarm'] = array_values((array)$event['alarm']); |
1146 | - foreach($event['alarm'] as &$alarm) |
|
1144 | + foreach ($event['alarm'] as &$alarm) |
|
1147 | 1145 | { |
1148 | 1146 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
1149 | 1147 | } |
1150 | 1148 | |
1151 | 1149 | // Copy links |
1152 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1150 | + if (!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1153 | 1151 | $event['link_to']['to_app'] = 'calendar'; |
1154 | 1152 | $event['link_to']['to_id'] = 0; |
1155 | 1153 | |
1156 | - foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1154 | + foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
1157 | 1155 | { |
1158 | - if(!$link['id']) continue; |
|
1156 | + if (!$link['id']) continue; |
|
1159 | 1157 | if ($link['app'] != Link::VFS_APPNAME) |
1160 | 1158 | { |
1161 | 1159 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1171,7 +1169,7 @@ discard block |
||
1171 | 1169 | |
1172 | 1170 | $event['links'] = $event['link_to']; |
1173 | 1171 | |
1174 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
1172 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
1175 | 1173 | { |
1176 | 1174 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
1177 | 1175 | } |
@@ -1198,14 +1196,14 @@ discard block |
||
1198 | 1196 | { |
1199 | 1197 | $msg = false; |
1200 | 1198 | |
1201 | - if(!$as_of_date ) |
|
1199 | + if (!$as_of_date) |
|
1202 | 1200 | { |
1203 | 1201 | $as_of_date = time(); |
1204 | 1202 | } |
1205 | 1203 | |
1206 | 1204 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
1207 | 1205 | |
1208 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1206 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
1209 | 1207 | { |
1210 | 1208 | $msg = lang("Error: You can't shift a series from the past!"); |
1211 | 1209 | return $msg; |
@@ -1218,11 +1216,11 @@ discard block |
||
1218 | 1216 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
1219 | 1217 | |
1220 | 1218 | // base start-date of new series on actual / clicked date |
1221 | - $event['start'] = $as_of_date ; |
|
1219 | + $event['start'] = $as_of_date; |
|
1222 | 1220 | |
1223 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
1221 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
1224 | 1222 | // Adjust for requested date in the past |
1225 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
1223 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
1226 | 1224 | ) |
1227 | 1225 | { |
1228 | 1226 | |
@@ -1242,17 +1240,17 @@ discard block |
||
1242 | 1240 | $rriter->next_no_exception(); |
1243 | 1241 | $occurrence = $rriter->current(); |
1244 | 1242 | } |
1245 | - while ($rriter->valid() && ( |
|
1243 | + while ($rriter->valid() && ( |
|
1246 | 1244 | Api\DateTime::to($occurrence, 'ts') <= time() || |
1247 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
1245 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
1248 | 1246 | ) && ($last = $occurrence)); |
1249 | 1247 | |
1250 | 1248 | |
1251 | 1249 | // Make sure as_of_date is still valid, may have to move forward |
1252 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
1250 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
1253 | 1251 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
1254 | 1252 | { |
1255 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
1253 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
1256 | 1254 | } |
1257 | 1255 | |
1258 | 1256 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1260,7 +1258,7 @@ discard block |
||
1260 | 1258 | { |
1261 | 1259 | $event['end'] = $event['start'] + $duration; |
1262 | 1260 | } |
1263 | - elseif($event['end'] < $event['start']) |
|
1261 | + elseif ($event['end'] < $event['start']) |
|
1264 | 1262 | { |
1265 | 1263 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
1266 | 1264 | } |
@@ -1269,7 +1267,7 @@ discard block |
||
1269 | 1267 | $event['participants'] = $old_event['participants']; |
1270 | 1268 | foreach ($old_event['recur_exception'] as $key => $exdate) |
1271 | 1269 | { |
1272 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
1270 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
1273 | 1271 | { |
1274 | 1272 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
1275 | 1273 | unset($old_event['recur_exception'][$key]); |
@@ -1283,18 +1281,18 @@ discard block |
||
1283 | 1281 | } |
1284 | 1282 | $last->setTime(0, 0, 0); |
1285 | 1283 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
1286 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
1284 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
1287 | 1285 | { |
1288 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1289 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
1290 | - htmlspecialchars(Egw::link('/index.php',array( |
|
1286 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
1287 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
1288 | + htmlspecialchars(Egw::link('/index.php', array( |
|
1291 | 1289 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1292 | 1290 | 'cal_id' => $event['id'], |
1293 | - ))).'">','</a>'); |
|
1291 | + ))).'">', '</a>'); |
|
1294 | 1292 | $event = $orig_event; |
1295 | 1293 | } |
1296 | 1294 | } |
1297 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
1295 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
1298 | 1296 | return $msg; |
1299 | 1297 | } |
1300 | 1298 | |
@@ -1305,18 +1303,18 @@ discard block |
||
1305 | 1303 | * @param boolean $added |
1306 | 1304 | * @return string javascript window.open command |
1307 | 1305 | */ |
1308 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
1306 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
1309 | 1307 | { |
1310 | 1308 | $to = array(); |
1311 | 1309 | |
1312 | - foreach($event['participants'] as $uid => $status) |
|
1310 | + foreach ($event['participants'] as $uid => $status) |
|
1313 | 1311 | { |
1314 | 1312 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1315 | 1313 | if (empty($status)) continue; |
1316 | - if(!is_array($status)) |
|
1314 | + if (!is_array($status)) |
|
1317 | 1315 | { |
1318 | 1316 | $quantity = $role = null; |
1319 | - calendar_so::split_status($status,$quantity,$role); |
|
1317 | + calendar_so::split_status($status, $quantity, $role); |
|
1320 | 1318 | $status = array( |
1321 | 1319 | 'status' => $status, |
1322 | 1320 | 'uid' => $uid, |
@@ -1327,32 +1325,32 @@ discard block |
||
1327 | 1325 | |
1328 | 1326 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1329 | 1327 | { |
1330 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1328 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
1331 | 1329 | |
1332 | 1330 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
1333 | 1331 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
1334 | 1332 | |
1335 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1333 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
1336 | 1334 | } |
1337 | 1335 | elseif ($uid < 0) |
1338 | 1336 | { |
1339 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
1337 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
1340 | 1338 | { |
1341 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1339 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
1342 | 1340 | |
1343 | 1341 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
1344 | 1342 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
1345 | 1343 | |
1346 | 1344 | // dont add groupmembers if they already rejected the event, or are the current user |
1347 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1345 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1348 | 1346 | } |
1349 | 1347 | } |
1350 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1348 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
1351 | 1349 | { |
1352 | 1350 | $to[] = $info['email']; |
1353 | 1351 | //error_log(__METHOD__.__LINE__.array2string($to)); |
1354 | 1352 | } |
1355 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
1353 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
1356 | 1354 | { |
1357 | 1355 | $to[] = $info['email']; |
1358 | 1356 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1361,7 +1359,7 @@ discard block |
||
1361 | 1359 | // prefer event description over standard notification text |
1362 | 1360 | if (empty($event['description'])) |
1363 | 1361 | { |
1364 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1362 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
1365 | 1363 | } |
1366 | 1364 | else |
1367 | 1365 | { |
@@ -1376,12 +1374,12 @@ discard block |
||
1376 | 1374 | $boical = new calendar_ical(); |
1377 | 1375 | // we need to pass $event[id] so iCal class reads event again, |
1378 | 1376 | // as event is in user TZ, but iCal class expects server TZ! |
1379 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
1377 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
1380 | 1378 | |
1381 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
1382 | - if(($f = fopen($ics_file,'w'))) |
|
1379 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
1380 | + if (($f = fopen($ics_file, 'w'))) |
|
1383 | 1381 | { |
1384 | - fwrite($f,$ics); |
|
1382 | + fwrite($f, $ics); |
|
1385 | 1383 | fclose($f); |
1386 | 1384 | } |
1387 | 1385 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1392,10 +1390,10 @@ discard block |
||
1392 | 1390 | 'preset[body]' => $body, |
1393 | 1391 | 'preset[name]' => 'event.ics', |
1394 | 1392 | 'preset[file]' => $ics_file, |
1395 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
1393 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
1396 | 1394 | 'preset[size]' => filesize($ics_file), |
1397 | 1395 | ); |
1398 | - $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
|
1396 | + $vars[$asrequest ? 'preset[to]' : 'preset[bcc]'] = $to; |
|
1399 | 1397 | if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
1400 | 1398 | $response = Api\Json\Response::get(); |
1401 | 1399 | $response->call('app.calendar.custom_mail', $vars); |
@@ -1440,7 +1438,7 @@ discard block |
||
1440 | 1438 | { |
1441 | 1439 | // This tells etemplate to send as JSON response, not full |
1442 | 1440 | // This avoids errors from trying to send header again |
1443 | - if(Api\Json\Request::isJSONRequest()) |
|
1441 | + if (Api\Json\Request::isJSONRequest()) |
|
1444 | 1442 | { |
1445 | 1443 | $GLOBALS['egw']->framework->response = Api\Json\Response::get(); |
1446 | 1444 | } |
@@ -1454,7 +1452,7 @@ discard block |
||
1454 | 1452 | */ |
1455 | 1453 | public function ajax_conflicts() |
1456 | 1454 | { |
1457 | - $participants = json_decode($_GET['participants'],true); |
|
1455 | + $participants = json_decode($_GET['participants'], true); |
|
1458 | 1456 | unset($_GET['participants']); |
1459 | 1457 | |
1460 | 1458 | $content = $this->default_add_event(); |
@@ -1462,10 +1460,10 @@ discard block |
||
1462 | 1460 | // Process edit wants to see input values |
1463 | 1461 | $participants = array(1=> false); |
1464 | 1462 | $participants['cal_resources'] = ''; |
1465 | - foreach($content['participants'] as $id => $status) |
|
1463 | + foreach ($content['participants'] as $id => $status) |
|
1466 | 1464 | { |
1467 | 1465 | $quantity = $role = ''; |
1468 | - calendar_so::split_status($status,$quantity,$role); |
|
1466 | + calendar_so::split_status($status, $quantity, $role); |
|
1469 | 1467 | $participants[] = array( |
1470 | 1468 | 'uid' => $id, |
1471 | 1469 | 'status' => $status, |
@@ -1491,7 +1489,7 @@ discard block |
||
1491 | 1489 | * @param mixed $link_to_id ='' from or for the link-widget |
1492 | 1490 | * @param string $msg_type =null default automatic detect, if it contains "error" |
1493 | 1491 | */ |
1494 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
1492 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
1495 | 1493 | { |
1496 | 1494 | $sel_options = array( |
1497 | 1495 | 'recur_type' => &$this->bo->recur_types, |
@@ -1515,13 +1513,13 @@ discard block |
||
1515 | 1513 | 'no_popup' => isset($_GET['no_popup']), |
1516 | 1514 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
1517 | 1515 | ); |
1518 | - if(!isset($_REQUEST['print']) && !empty($preserv['template']) && $this->cal_prefs['new_event_dialog'] == 'edit') |
|
1516 | + if (!isset($_REQUEST['print']) && !empty($preserv['template']) && $this->cal_prefs['new_event_dialog'] == 'edit') |
|
1519 | 1517 | { |
1520 | 1518 | // User wants full thing |
1521 | 1519 | unset($preserv['template']); |
1522 | 1520 | } |
1523 | - $cal_id = (int) $_GET['cal_id']; |
|
1524 | - if($_GET['action']) |
|
1521 | + $cal_id = (int)$_GET['cal_id']; |
|
1522 | + if ($_GET['action']) |
|
1525 | 1523 | { |
1526 | 1524 | $event = $this->bo->read($cal_id); |
1527 | 1525 | $event['action'] = $_GET['action']; |
@@ -1539,14 +1537,14 @@ discard block |
||
1539 | 1537 | { |
1540 | 1538 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
1541 | 1539 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
1542 | - $event =& $this->default_add_event(); |
|
1540 | + $event = & $this->default_add_event(); |
|
1543 | 1541 | } |
1544 | 1542 | if (!empty($_GET['ical_data']) && |
1545 | 1543 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
1546 | 1544 | { |
1547 | 1545 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
1548 | 1546 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
1549 | - $event =& $this->default_add_event(); |
|
1547 | + $event = & $this->default_add_event(); |
|
1550 | 1548 | } |
1551 | 1549 | if (!empty($_GET['ical'])) |
1552 | 1550 | { |
@@ -1555,14 +1553,14 @@ discard block |
||
1555 | 1553 | { |
1556 | 1554 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
1557 | 1555 | $msg = lang('Error: importing the iCal'); |
1558 | - $event =& $this->default_add_event(); |
|
1556 | + $event = & $this->default_add_event(); |
|
1559 | 1557 | } |
1560 | 1558 | else |
1561 | 1559 | { |
1562 | 1560 | if (count($events) > 1) |
1563 | 1561 | { |
1564 | 1562 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
1565 | - $msg_type = 'notice'; // no not hide automatic |
|
1563 | + $msg_type = 'notice'; // no not hide automatic |
|
1566 | 1564 | } |
1567 | 1565 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
1568 | 1566 | $this->bo->db2data($events, 'ts'); |
@@ -1575,7 +1573,7 @@ discard block |
||
1575 | 1573 | else |
1576 | 1574 | { |
1577 | 1575 | $event['participant_types'] = array(); |
1578 | - foreach($event['participants'] as $uid => $status) |
|
1576 | + foreach ($event['participants'] as $uid => $status) |
|
1579 | 1577 | { |
1580 | 1578 | $user_type = $user_id = null; |
1581 | 1579 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1596,15 +1594,15 @@ discard block |
||
1596 | 1594 | } |
1597 | 1595 | else |
1598 | 1596 | { |
1599 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
1597 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
1600 | 1598 | exit(); |
1601 | 1599 | } |
1602 | 1600 | } |
1603 | - $event =& $this->default_add_event(); |
|
1601 | + $event = & $this->default_add_event(); |
|
1604 | 1602 | } |
1605 | 1603 | else |
1606 | 1604 | { |
1607 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1605 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1608 | 1606 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1609 | 1607 | { |
1610 | 1608 | if (empty($event['whole_day'])) |
@@ -1617,10 +1615,10 @@ discard block |
||
1617 | 1615 | $date->setUser(); |
1618 | 1616 | } |
1619 | 1617 | $event = $this->bo->read($cal_id, $date, true); |
1620 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1618 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
1621 | 1619 | if ($_GET['exception']) |
1622 | 1620 | { |
1623 | - $msg = $this->_create_exception($event,$preserv); |
|
1621 | + $msg = $this->_create_exception($event, $preserv); |
|
1624 | 1622 | } |
1625 | 1623 | else |
1626 | 1624 | { |
@@ -1629,9 +1627,9 @@ discard block |
||
1629 | 1627 | } |
1630 | 1628 | } |
1631 | 1629 | // set new start and end if given by $_GET |
1632 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1633 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1634 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1630 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
1631 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
1632 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1635 | 1633 | // check if the event is the whole day |
1636 | 1634 | $start = $this->bo->date2array($event['start']); |
1637 | 1635 | $end = $this->bo->date2array($event['end']); |
@@ -1641,30 +1639,30 @@ discard block |
||
1641 | 1639 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
1642 | 1640 | { |
1643 | 1641 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
1644 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1642 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
1645 | 1643 | { |
1646 | 1644 | $link_id = $link_ids[$n]; |
1647 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1645 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
1648 | 1646 | { |
1649 | 1647 | continue; |
1650 | 1648 | } |
1651 | - if(!$n) |
|
1649 | + if (!$n) |
|
1652 | 1650 | { |
1653 | - $event['title'] = Link::title($link_app,$link_id); |
|
1651 | + $event['title'] = Link::title($link_app, $link_id); |
|
1654 | 1652 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
1655 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
1653 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
1656 | 1654 | { |
1657 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
1655 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
1658 | 1656 | { |
1659 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1657 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
1660 | 1658 | } |
1661 | 1659 | unset($set['link_app']); |
1662 | 1660 | unset($set['link_id']); |
1663 | 1661 | |
1664 | - $event = array_merge($event,$set); |
|
1662 | + $event = array_merge($event, $set); |
|
1665 | 1663 | } |
1666 | 1664 | } |
1667 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
1665 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
1668 | 1666 | } |
1669 | 1667 | } |
1670 | 1668 | } |
@@ -1674,45 +1672,45 @@ discard block |
||
1674 | 1672 | { |
1675 | 1673 | $etpl->read($preserv['template'] = 'calendar.edit'); |
1676 | 1674 | } |
1677 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
1675 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
1678 | 1676 | //echo "view=$view, event="; _debug_array($event); |
1679 | 1677 | // shared locking of entries to edit |
1680 | 1678 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
1681 | 1679 | { |
1682 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
1680 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
1683 | 1681 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1684 | 1682 | |
1685 | 1683 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
1686 | 1684 | { |
1687 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
1685 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
1688 | 1686 | } |
1689 | 1687 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1690 | 1688 | { |
1691 | 1689 | $msg .= ' '.lang('This entry is currently opened by %1!', |
1692 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
1690 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
1693 | 1691 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
1694 | 1692 | } |
1695 | - elseif($lock) |
|
1693 | + elseif ($lock) |
|
1696 | 1694 | { |
1697 | 1695 | $preserv['lock_token'] = $lock['token']; |
1698 | 1696 | } |
1699 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
1697 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
1700 | 1698 | { |
1701 | 1699 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
1702 | 1700 | } |
1703 | 1701 | else |
1704 | 1702 | { |
1705 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1703 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
1706 | 1704 | $view = true; |
1707 | 1705 | } |
1708 | 1706 | } |
1709 | - $content = array_merge($event,array( |
|
1707 | + $content = array_merge($event, array( |
|
1710 | 1708 | 'cal_id' => $event['id'], |
1711 | 1709 | 'link_to' => array( |
1712 | 1710 | 'to_id' => $link_to_id, |
1713 | 1711 | 'to_app' => 'calendar', |
1714 | 1712 | ), |
1715 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1713 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
1716 | 1714 | 'tabs' => $preserv['tabs'], |
1717 | 1715 | 'view' => $view, |
1718 | 1716 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1724,11 +1722,11 @@ discard block |
||
1724 | 1722 | $row = 3; |
1725 | 1723 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1726 | 1724 | // preserve some ui elements, if set eg. under error-conditions |
1727 | - foreach(array('quantity','resource','role') as $n) |
|
1725 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
1728 | 1726 | { |
1729 | 1727 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
1730 | 1728 | } |
1731 | - foreach($event['participant_types'] as $type => $participants) |
|
1729 | + foreach ($event['participant_types'] as $type => $participants) |
|
1732 | 1730 | { |
1733 | 1731 | $name = 'accounts'; |
1734 | 1732 | if (isset($this->bo->resources[$type])) |
@@ -1737,17 +1735,17 @@ discard block |
||
1737 | 1735 | } |
1738 | 1736 | // sort participants (in there group/app) by title |
1739 | 1737 | uksort($participants, array($this, 'uid_title_cmp')); |
1740 | - foreach($participants as $id => $status) |
|
1738 | + foreach ($participants as $id => $status) |
|
1741 | 1739 | { |
1742 | 1740 | $uid = $type == 'u' ? $id : $type.$id; |
1743 | 1741 | $quantity = $role = null; |
1744 | - calendar_so::split_status($status,$quantity,$role); |
|
1742 | + calendar_so::split_status($status, $quantity, $role); |
|
1745 | 1743 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1746 | 1744 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
1747 | 1745 | 'uid' => $uid, |
1748 | 1746 | 'status' => $status, |
1749 | 1747 | 'old_status' => $status, |
1750 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1748 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
1751 | 1749 | 'role' => $role, |
1752 | 1750 | ); |
1753 | 1751 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1756,33 +1754,33 @@ discard block |
||
1756 | 1754 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
1757 | 1755 | } |
1758 | 1756 | // allow third party apps to use categories for roles |
1759 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
1757 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
1760 | 1758 | { |
1761 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
1759 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
1762 | 1760 | } |
1763 | 1761 | else |
1764 | 1762 | { |
1765 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
1763 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
1766 | 1764 | } |
1767 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
1765 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
1768 | 1766 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1769 | 1767 | |
1770 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
1768 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
1771 | 1769 | $readonlys['participants'][$row]['status'] = $no_status; |
1772 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
1770 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
1773 | 1771 | $readonlys['participants']['delete'][$uid] = true; |
1774 | 1772 | // todo: make the participants available as links with email as title |
1775 | 1773 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1776 | 1774 | // enumerate group-invitations, so people can accept/reject them |
1777 | 1775 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
1778 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
1776 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
1779 | 1777 | { |
1780 | 1778 | $sel_options['status']['G'] = lang('Select one'); |
1781 | 1779 | // sort members by title |
1782 | 1780 | usort($members, array($this, 'uid_title_cmp')); |
1783 | - foreach($members as $member) |
|
1781 | + foreach ($members as $member) |
|
1784 | 1782 | { |
1785 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
1783 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
1786 | 1784 | { |
1787 | 1785 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
1788 | 1786 | 'app' => 'Group invitation', |
@@ -1791,7 +1789,7 @@ discard block |
||
1791 | 1789 | ); |
1792 | 1790 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
1793 | 1791 | // read access is enough to invite participants, but you need edit rights to change status |
1794 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
1792 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
1795 | 1793 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
1796 | 1794 | } |
1797 | 1795 | } |
@@ -1799,37 +1797,37 @@ discard block |
||
1799 | 1797 | } |
1800 | 1798 | // resouces / apps we shedule, atm. resources and addressbook |
1801 | 1799 | $content['participants']['cal_resources'] = ''; |
1802 | - foreach($this->bo->resources as $data) |
|
1800 | + foreach ($this->bo->resources as $data) |
|
1803 | 1801 | { |
1804 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1802 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1805 | 1803 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1806 | 1804 | } |
1807 | 1805 | } |
1808 | 1806 | $content['participants']['status_date'] = $preserv['actual_date']; |
1809 | - $preserved = array_merge($preserv,$content); |
|
1807 | + $preserved = array_merge($preserv, $content); |
|
1810 | 1808 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
1811 | 1809 | if ($event['alarm']) |
1812 | 1810 | { |
1813 | 1811 | // makes keys of the alarm-array starting with 1 |
1814 | 1812 | $content['alarm'] = array(false); |
1815 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
1813 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
1816 | 1814 | { |
1817 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
1815 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
1818 | 1816 | { |
1819 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1817 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
1820 | 1818 | } |
1821 | - $alarm['all'] = (int) $alarm['all']; |
|
1819 | + $alarm['all'] = (int)$alarm['all']; |
|
1822 | 1820 | // fix alarm time in case of alread run alarms, where the time will be their keep_time / when they will be cleaned up otherwise |
1823 | 1821 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1824 | 1822 | $after = false; |
1825 | - if($alarm['offset'] < 0) |
|
1823 | + if ($alarm['offset'] < 0) |
|
1826 | 1824 | { |
1827 | 1825 | $after = true; |
1828 | 1826 | $alarm['offset'] = -1 * $alarm['offset']; |
1829 | 1827 | } |
1830 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
1831 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
1832 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
1828 | + $days = (int)($alarm['offset'] / DAY_s); |
|
1829 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
1830 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
1833 | 1831 | $label = array(); |
1834 | 1832 | if ($days) $label[] = $days.' '.lang('days'); |
1835 | 1833 | if ($hours) $label[] = $hours.' '.lang('hours'); |
@@ -1840,11 +1838,11 @@ discard block |
||
1840 | 1838 | } |
1841 | 1839 | else |
1842 | 1840 | { |
1843 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
1841 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
1844 | 1842 | } |
1845 | 1843 | $content['alarm'][] = $alarm; |
1846 | 1844 | |
1847 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
1845 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
1848 | 1846 | } |
1849 | 1847 | if (count($content['alarm']) == 1) |
1850 | 1848 | { |
@@ -1859,20 +1857,20 @@ discard block |
||
1859 | 1857 | |
1860 | 1858 | if ($view) |
1861 | 1859 | { |
1862 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1860 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
1863 | 1861 | $readonlys['button[cancel]'] = $readonlys['action'] = |
1864 | 1862 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
1865 | 1863 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
1866 | 1864 | |
1867 | 1865 | $content['participants']['no_add'] = true; |
1868 | 1866 | |
1869 | - if(!$event['whole_day']) |
|
1867 | + if (!$event['whole_day']) |
|
1870 | 1868 | { |
1871 | 1869 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
1872 | 1870 | } |
1873 | 1871 | |
1874 | 1872 | // respect category permissions |
1875 | - if(!empty($event['category'])) |
|
1873 | + if (!empty($event['category'])) |
|
1876 | 1874 | { |
1877 | 1875 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
1878 | 1876 | } |
@@ -1883,7 +1881,7 @@ discard block |
||
1883 | 1881 | |
1884 | 1882 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
1885 | 1883 | { |
1886 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1884 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
1887 | 1885 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
1888 | 1886 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
1889 | 1887 | } |
@@ -1893,9 +1891,9 @@ discard block |
||
1893 | 1891 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
1894 | 1892 | } |
1895 | 1893 | } |
1896 | - if($content['category'] && !is_array($content['category'])) |
|
1894 | + if ($content['category'] && !is_array($content['category'])) |
|
1897 | 1895 | { |
1898 | - $content['category'] = explode(',',$event['category']); |
|
1896 | + $content['category'] = explode(',', $event['category']); |
|
1899 | 1897 | } |
1900 | 1898 | // disabling the custom fields tab, if there are none |
1901 | 1899 | $readonlys['tabs'] = array( |
@@ -1912,13 +1910,13 @@ discard block |
||
1912 | 1910 | { |
1913 | 1911 | $readonlys['action'] = true; |
1914 | 1912 | } |
1915 | - if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
|
1913 | + if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate']))) |
|
1916 | 1914 | { |
1917 | 1915 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1918 | 1916 | } |
1919 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
1917 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
1920 | 1918 | |
1921 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1919 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
1922 | 1920 | { |
1923 | 1921 | $sel_options['owner'][0] = lang('All participants'); |
1924 | 1922 | } |
@@ -1926,26 +1924,26 @@ discard block |
||
1926 | 1924 | { |
1927 | 1925 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
1928 | 1926 | } |
1929 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
1927 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
1930 | 1928 | { |
1931 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
1929 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
1932 | 1930 | { |
1933 | 1931 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
1934 | 1932 | } |
1935 | 1933 | } |
1936 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1934 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
1937 | 1935 | if (!$event['id']) |
1938 | 1936 | { |
1939 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
1937 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
1940 | 1938 | } |
1941 | 1939 | if ($preserved['no_popup']) |
1942 | 1940 | { |
1943 | 1941 | // If not a popup, load the normal calendar interface on cancel |
1944 | - $etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1942 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index&ajax=true\')'); |
|
1945 | 1943 | } |
1946 | 1944 | |
1947 | 1945 | // Allow admins to restore deleted events |
1948 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
1946 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
1949 | 1947 | { |
1950 | 1948 | $content['deleted'] = $preserved['deleted'] = null; |
1951 | 1949 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1957,7 +1955,7 @@ discard block |
||
1957 | 1955 | // Setup history tab |
1958 | 1956 | $this->setup_history($content, $sel_options); |
1959 | 1957 | |
1960 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
1958 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
1961 | 1959 | . (!$event['id'] ? lang('Add') |
1962 | 1960 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
1963 | 1961 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1967,15 +1965,15 @@ discard block |
||
1967 | 1965 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
1968 | 1966 | |
1969 | 1967 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1970 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1968 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
1971 | 1969 | { |
1972 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1970 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
1973 | 1971 | $content['button']['save'] = true; |
1974 | - $this->process_edit(array_merge($content,$preserved)); |
|
1972 | + $this->process_edit(array_merge($content, $preserved)); |
|
1975 | 1973 | } |
1976 | 1974 | else |
1977 | 1975 | { |
1978 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
1976 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
1979 | 1977 | } |
1980 | 1978 | } |
1981 | 1979 | |
@@ -1985,14 +1983,14 @@ discard block |
||
1985 | 1983 | * @param int $id |
1986 | 1984 | * @param string $token |
1987 | 1985 | */ |
1988 | - function ajax_unlock($id,$token) |
|
1986 | + function ajax_unlock($id, $token) |
|
1989 | 1987 | { |
1990 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
1988 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
1991 | 1989 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1992 | 1990 | |
1993 | 1991 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
1994 | 1992 | { |
1995 | - Vfs::unlock($lock_path,$token,false); |
|
1993 | + Vfs::unlock($lock_path, $token, false); |
|
1996 | 1994 | } |
1997 | 1995 | } |
1998 | 1996 | |
@@ -2004,17 +2002,17 @@ discard block |
||
2004 | 2002 | * are called by new mail-app; and we intend to use the stuff passed on by session |
2005 | 2003 | * @param string $msg = null |
2006 | 2004 | */ |
2007 | - function meeting(array $event=null, $msg=null) |
|
2005 | + function meeting(array $event = null, $msg = null) |
|
2008 | 2006 | { |
2009 | 2007 | $user = $GLOBALS['egw_info']['user']['account_id']; |
2010 | 2008 | $readonlys['button[apply]'] = true; |
2011 | - $_usesession=!is_array($event); |
|
2009 | + $_usesession = !is_array($event); |
|
2012 | 2010 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
2013 | 2011 | //are called by new mail-app; and we intend to use the stuff passed on by session |
2014 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
2012 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
2015 | 2013 | { |
2016 | - $event=null; // set to null |
|
2017 | - $_usesession=true; // trigger session read |
|
2014 | + $event = null; // set to null |
|
2015 | + $_usesession = true; // trigger session read |
|
2018 | 2016 | } |
2019 | 2017 | if (!is_array($event)) |
2020 | 2018 | { |
@@ -2044,7 +2042,7 @@ discard block |
||
2044 | 2042 | if (($existing_event = $this->bo->read($event['uid'], $event['recurrence'], false, 'ts', null, true)) && // true = read the exception |
2045 | 2043 | !$existing_event['deleted']) |
2046 | 2044 | { |
2047 | - switch(strtolower($ical_method)) |
|
2045 | + switch (strtolower($ical_method)) |
|
2048 | 2046 | { |
2049 | 2047 | case 'reply': |
2050 | 2048 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -2099,25 +2097,25 @@ discard block |
||
2099 | 2097 | } |
2100 | 2098 | else // event not in calendar |
2101 | 2099 | { |
2102 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2100 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
2103 | 2101 | } |
2104 | 2102 | $event['participant_types'] = array(); |
2105 | - foreach($event['participants'] as $uid => $status) |
|
2103 | + foreach ($event['participants'] as $uid => $status) |
|
2106 | 2104 | { |
2107 | 2105 | $user_type = $user_id = null; |
2108 | 2106 | calendar_so::split_user($uid, $user_type, $user_id); |
2109 | 2107 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
2110 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2108 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
2111 | 2109 | } |
2112 | 2110 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
2113 | 2111 | $event['recure'] = $this->bo->recure2string($event); |
2114 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
2112 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
2115 | 2113 | |
2116 | 2114 | // EGroupware event has been deleted, dont let user resurect it by accepting again |
2117 | 2115 | if ($existing_event && $existing_event['deleted'] && strtolower($ical_method) !== 'cancel') |
2118 | 2116 | { |
2119 | 2117 | // check if this is an EGroupware event or has an external organizer |
2120 | - foreach($existing_event['participants'] as $uid => $status) |
|
2118 | + foreach ($existing_event['participants'] as $uid => $status) |
|
2121 | 2119 | { |
2122 | 2120 | $quantity = $role = null; |
2123 | 2121 | calendar_so::split_status($status, $quantity, $role); |
@@ -2148,23 +2146,23 @@ discard block |
||
2148 | 2146 | // clear notification errors |
2149 | 2147 | notifications::errors(true); |
2150 | 2148 | |
2151 | - switch($button) |
|
2149 | + switch ($button) |
|
2152 | 2150 | { |
2153 | 2151 | case 'reject': |
2154 | 2152 | if (!$event['id']) |
2155 | 2153 | { |
2156 | 2154 | // send reply to organizer |
2157 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
2158 | - break; // no need to store rejected event |
|
2155 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
2156 | + break; // no need to store rejected event |
|
2159 | 2157 | } |
2160 | 2158 | // fall-through |
2161 | 2159 | case 'accept': |
2162 | 2160 | case 'tentativ': |
2163 | - $status = strtoupper($button[0]); // A, R or T |
|
2161 | + $status = strtoupper($button[0]); // A, R or T |
|
2164 | 2162 | if (!$event['id']) |
2165 | 2163 | { |
2166 | 2164 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
2167 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
2165 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
2168 | 2166 | { |
2169 | 2167 | // --> make organize a participant with role chair and current user the owner |
2170 | 2168 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2172,7 +2170,7 @@ discard block |
||
2172 | 2170 | $event['owner'] = $this->user; |
2173 | 2171 | } |
2174 | 2172 | // store event without notifications! |
2175 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2173 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2176 | 2174 | { |
2177 | 2175 | $msg[] = lang('Event saved'); |
2178 | 2176 | } |
@@ -2186,7 +2184,7 @@ discard block |
||
2186 | 2184 | elseif (self::event_changed($event, $event['old'])) |
2187 | 2185 | { |
2188 | 2186 | // check if we are allowed to update the event |
2189 | - if($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2187 | + if ($this->bo->check_perms(Acl::EDIT, $event['old'])) |
|
2190 | 2188 | { |
2191 | 2189 | if ($event['recurrence'] && !$event['old']['reference'] && ($recur_event = $this->bo->read($event['id']))) |
2192 | 2190 | { |
@@ -2194,9 +2192,9 @@ discard block |
||
2194 | 2192 | $recur_event['recur_exception'][] = $event['recurrence']; |
2195 | 2193 | // check if we need to move the alarms, because they are next on that exception |
2196 | 2194 | $this->bo->check_move_alarms($recur_event, null, $event['recurrence']); |
2197 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2198 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2199 | - $this->bo->update($recur_event, $ignore_conflicts=true, true, false, true, $msg, true); |
|
2195 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2196 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2197 | + $this->bo->update($recur_event, $ignore_conflicts = true, true, false, true, $msg, true); |
|
2200 | 2198 | |
2201 | 2199 | // then we need to create the exception as new event |
2202 | 2200 | unset($event['id']); |
@@ -2211,7 +2209,7 @@ discard block |
||
2211 | 2209 | } |
2212 | 2210 | unset($event['old']); |
2213 | 2211 | |
2214 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
2212 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
2215 | 2213 | { |
2216 | 2214 | $msg[] = lang('Event saved'); |
2217 | 2215 | } |
@@ -2261,7 +2259,7 @@ discard block |
||
2261 | 2259 | Framework::message(implode("\n", (array)$msg)); |
2262 | 2260 | $readonlys['button[edit]'] = !$event['id']; |
2263 | 2261 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
2264 | - switch(strtolower($ical_method)) |
|
2262 | + switch (strtolower($ical_method)) |
|
2265 | 2263 | { |
2266 | 2264 | case 'reply': |
2267 | 2265 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2275,7 +2273,7 @@ discard block |
||
2275 | 2273 | break; |
2276 | 2274 | } |
2277 | 2275 | $tpl = new Etemplate('calendar.meeting'); |
2278 | - $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event+array( |
|
2276 | + $tpl->exec('calendar.calendar_uiforms.meeting', $event, array(), $readonlys, $event + array( |
|
2279 | 2277 | 'old' => $existing_event, |
2280 | 2278 | ), 2); |
2281 | 2279 | } |
@@ -2295,11 +2293,11 @@ discard block |
||
2295 | 2293 | 'recur_type', 'recur_data', 'recur_interval', 'recur_exception'); |
2296 | 2294 | |
2297 | 2295 | // only compare certain fields, taking account unset, null or '' values |
2298 | - $event = array_intersect_key($_event+array('recur_exception'=>array()), array_flip($keys_to_check)); |
|
2296 | + $event = array_intersect_key($_event + array('recur_exception'=>array()), array_flip($keys_to_check)); |
|
2299 | 2297 | $old = array_intersect_key(array_diff($_old, array(null, '')), array_flip($keys_to_check)); |
2300 | 2298 | |
2301 | 2299 | // keep the status of existing participants (users) |
2302 | - foreach($old['participants'] as $uid => $status) |
|
2300 | + foreach ($old['participants'] as $uid => $status) |
|
2303 | 2301 | { |
2304 | 2302 | if (is_numeric($uid) && $uid > 0) |
2305 | 2303 | { |
@@ -2319,37 +2317,37 @@ discard block |
||
2319 | 2317 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
2320 | 2318 | * @param array $preserv data to preserv |
2321 | 2319 | */ |
2322 | - function conflicts($event,$conflicts,$preserv) |
|
2320 | + function conflicts($event, $conflicts, $preserv) |
|
2323 | 2321 | { |
2324 | 2322 | $etpl = new Etemplate('calendar.conflicts'); |
2325 | 2323 | $allConflicts = array(); |
2326 | 2324 | |
2327 | - foreach($conflicts as $k => $conflict) |
|
2325 | + foreach ($conflicts as $k => $conflict) |
|
2328 | 2326 | { |
2329 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
2327 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
2330 | 2328 | |
2331 | 2329 | $conflicts[$k] += array( |
2332 | 2330 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
2333 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
2334 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
2335 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
2336 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
2337 | - ),true,true)), // show group invitations too |
|
2331 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
2332 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
2333 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
2334 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
2335 | + ), true, true)), // show group invitations too |
|
2338 | 2336 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
2339 | 2337 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
2340 | 2338 | ); |
2341 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
2339 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
2342 | 2340 | } |
2343 | 2341 | $content = $event + array( |
2344 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2342 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
2345 | 2343 | ); |
2346 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
2344 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
2347 | 2345 | $resources_config = Api\Config::read('resources'); |
2348 | 2346 | $readonlys = array(); |
2349 | 2347 | |
2350 | 2348 | foreach (array_keys($allConflicts) as $pId) |
2351 | 2349 | { |
2352 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2350 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
2353 | 2351 | { |
2354 | 2352 | |
2355 | 2353 | switch ($resources_config['ignoreconflicts']) |
@@ -2369,7 +2367,7 @@ discard block |
||
2369 | 2367 | } |
2370 | 2368 | } |
2371 | 2369 | } |
2372 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
2370 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
2373 | 2371 | } |
2374 | 2372 | |
2375 | 2373 | /** |
@@ -2387,7 +2385,7 @@ discard block |
||
2387 | 2385 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
2388 | 2386 | |
2389 | 2387 | // convert start/end date-time values to timestamps |
2390 | - foreach(array('start', 'end') as $name) |
|
2388 | + foreach (array('start', 'end') as $name) |
|
2391 | 2389 | { |
2392 | 2390 | if (!empty($edit_content[$name])) |
2393 | 2391 | { |
@@ -2417,7 +2415,7 @@ discard block |
||
2417 | 2415 | 'recur_type' => $edit_content['recur_type'], |
2418 | 2416 | 'participants' => array(), |
2419 | 2417 | ); |
2420 | - foreach($edit_content['participants'] as $key => $data) |
|
2418 | + foreach ($edit_content['participants'] as $key => $data) |
|
2421 | 2419 | { |
2422 | 2420 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
2423 | 2421 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2432,21 +2430,21 @@ discard block |
||
2432 | 2430 | // default search parameters |
2433 | 2431 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
2434 | 2432 | $content['end_time'] = $this->cal_prefs['workdayends']; |
2435 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
2433 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
2436 | 2434 | { |
2437 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2435 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
2438 | 2436 | } |
2439 | 2437 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
2440 | 2438 | |
2441 | 2439 | $content['search_window'] = 7 * DAY_s; |
2442 | 2440 | |
2443 | 2441 | // store content in session |
2444 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
2442 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
2445 | 2443 | |
2446 | 2444 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
2447 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
2445 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
2448 | 2446 | |
2449 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
2447 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
2450 | 2448 | |
2451 | 2449 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
2452 | 2450 | |
@@ -2469,26 +2467,26 @@ discard block |
||
2469 | 2467 | { |
2470 | 2468 | $etpl = new Etemplate('calendar.freetimesearch'); |
2471 | 2469 | $sel_options['search_window'] = array( |
2472 | - 7*DAY_s => lang('one week'), |
|
2473 | - 14*DAY_s => lang('two weeks'), |
|
2474 | - 31*DAY_s => lang('one month'), |
|
2475 | - 92*DAY_s => lang('three month'), |
|
2476 | - 365*DAY_s => lang('one year'), |
|
2470 | + 7 * DAY_s => lang('one week'), |
|
2471 | + 14 * DAY_s => lang('two weeks'), |
|
2472 | + 31 * DAY_s => lang('one month'), |
|
2473 | + 92 * DAY_s => lang('three month'), |
|
2474 | + 365 * DAY_s => lang('one year'), |
|
2477 | 2475 | ); |
2478 | 2476 | if (!is_array($content)) |
2479 | 2477 | { |
2480 | 2478 | // get content from session (and delete it immediatly) |
2481 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2482 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2479 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2480 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
2483 | 2481 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
2484 | 2482 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
2485 | 2483 | $sTime = $content['start_time']; |
2486 | 2484 | $eTime = $content['end_time']; |
2487 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
2488 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
2485 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
2486 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
2489 | 2487 | |
2490 | 2488 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
2491 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
2489 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
2492 | 2490 | { |
2493 | 2491 | if ($window > $content['duration']) |
2494 | 2492 | { |
@@ -2515,19 +2513,19 @@ discard block |
||
2515 | 2513 | { |
2516 | 2514 | $content['msg'] .= lang('Only the initial date of that recurring event is checked!'); |
2517 | 2515 | } |
2518 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
2519 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
2516 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
2517 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
2520 | 2518 | |
2521 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
2519 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
2522 | 2520 | |
2523 | 2521 | $sel_options['duration'] = $this->durations; |
2524 | 2522 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
2525 | 2523 | |
2526 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
2524 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
2527 | 2525 | 'participants' => $content['participants'], |
2528 | 2526 | 'cal_id' => $content['cal_id'], |
2529 | 2527 | 'recur_type' => $content['recur_type'], |
2530 | - ),2); |
|
2528 | + ), 2); |
|
2531 | 2529 | } |
2532 | 2530 | |
2533 | 2531 | /** |
@@ -2540,15 +2538,15 @@ discard block |
||
2540 | 2538 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
2541 | 2539 | * @return array of free time-slots: array with start and end values |
2542 | 2540 | */ |
2543 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
2541 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
2544 | 2542 | { |
2545 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2543 | + if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id); |
|
2546 | 2544 | |
2547 | 2545 | $busy = $this->bo->search(array( |
2548 | 2546 | 'start' => $start, |
2549 | 2547 | 'end' => $end, |
2550 | 2548 | 'users' => $participants, |
2551 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2549 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
2552 | 2550 | )); |
2553 | 2551 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
2554 | 2552 | 'start' => $end, |
@@ -2557,15 +2555,15 @@ discard block |
||
2557 | 2555 | $ft_start = $start; |
2558 | 2556 | $freetime = array(); |
2559 | 2557 | $n = 0; |
2560 | - foreach($busy as $event) |
|
2558 | + foreach ($busy as $event) |
|
2561 | 2559 | { |
2562 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2560 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2563 | 2561 | |
2564 | 2562 | if ($event['non_blocking']) continue; // ignore non_blocking events |
2565 | 2563 | |
2566 | 2564 | // check if from all wanted participants at least one has a not rejected status in found event |
2567 | 2565 | $non_rejected_found = false; |
2568 | - foreach($participants as $uid) |
|
2566 | + foreach ($participants as $uid) |
|
2569 | 2567 | { |
2570 | 2568 | $status = $event['participants'][$uid]; |
2571 | 2569 | $quantity = $role = null; |
@@ -2584,10 +2582,10 @@ discard block |
||
2584 | 2582 | |
2585 | 2583 | if ($this->debug) |
2586 | 2584 | { |
2587 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
2585 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
2588 | 2586 | echo "event[title]=$event[title]<br>\n"; |
2589 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
2590 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
2587 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
2588 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
2591 | 2589 | } |
2592 | 2590 | // $events ends before our actual position ==> ignore it |
2593 | 2591 | if ($event['end'] < $ft_start) |
@@ -2611,11 +2609,11 @@ discard block |
||
2611 | 2609 | 'start' => $ft_start, |
2612 | 2610 | 'end' => $ft_end, |
2613 | 2611 | ); |
2614 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2612 | + if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n"; |
|
2615 | 2613 | } |
2616 | 2614 | $ft_start = $event['end']; |
2617 | 2615 | } |
2618 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2616 | + if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime); |
|
2619 | 2617 | |
2620 | 2618 | return $freetime; |
2621 | 2619 | } |
@@ -2635,46 +2633,46 @@ discard block |
||
2635 | 2633 | */ |
2636 | 2634 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2637 | 2635 | { |
2638 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2636 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time); |
|
2639 | 2637 | |
2640 | 2638 | $freetime_daywise = array(); |
2641 | 2639 | if (!is_array($sel_options)) $sel_options = array(); |
2642 | 2640 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2643 | 2641 | |
2644 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
2645 | - $end_time = (int) $_end_time; |
|
2642 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
2643 | + $end_time = (int)$_end_time; |
|
2646 | 2644 | |
2647 | 2645 | // ignore the end_time, if duration would never fit |
2648 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
2646 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
2649 | 2647 | { |
2650 | 2648 | $end_time = 0; |
2651 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2649 | + if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time); |
|
2652 | 2650 | } |
2653 | 2651 | $n = 0; |
2654 | - foreach($freetime as $ft) |
|
2652 | + foreach ($freetime as $ft) |
|
2655 | 2653 | { |
2656 | 2654 | $adaybegin = $this->bo->date2array($ft['start']); |
2657 | 2655 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
2658 | 2656 | unset($adaybegin['raw']); |
2659 | 2657 | $daybegin = $this->bo->date2ts($adaybegin); |
2660 | 2658 | |
2661 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
2659 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
2662 | 2660 | { |
2663 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
2664 | - $mcal_dow = pow(2,$dow); |
|
2665 | - if (!($weekdays & $mcal_dow)) |
|
2661 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
2662 | + $mcal_dow = pow(2, $dow); |
|
2663 | + if (!($weekdays&$mcal_dow)) |
|
2666 | 2664 | { |
2667 | 2665 | //echo "wrong day of week $dow<br>\n"; |
2668 | - continue; // wrong day of week |
|
2666 | + continue; // wrong day of week |
|
2669 | 2667 | } |
2670 | 2668 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2671 | 2669 | |
2672 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2670 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
2673 | 2671 | { |
2674 | - $start = $daybegin + $start_time*HOUR_s; |
|
2672 | + $start = $daybegin + $start_time * HOUR_s; |
|
2675 | 2673 | } |
2676 | 2674 | // if end_time given use it, else the original slot's end |
2677 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
2675 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
2678 | 2676 | if ($end > $ft['end']) $end = $ft['end']; |
2679 | 2677 | |
2680 | 2678 | // slot to small for duration |
@@ -2688,11 +2686,11 @@ discard block |
||
2688 | 2686 | 'end' => $end, |
2689 | 2687 | ); |
2690 | 2688 | $times = array(); |
2691 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
2689 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
2692 | 2690 | { |
2693 | 2691 | $e = $s + $duration; |
2694 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
2695 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
2692 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
2693 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
2696 | 2694 | } |
2697 | 2695 | $sel_options[$n.'start'] = $times; |
2698 | 2696 | } |
@@ -2707,13 +2705,13 @@ discard block |
||
2707 | 2705 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
2708 | 2706 | * @return string error-msg if $return_error |
2709 | 2707 | */ |
2710 | - function export($content=0,$return_error=false) |
|
2708 | + function export($content = 0, $return_error = false) |
|
2711 | 2709 | { |
2712 | 2710 | $boical = new calendar_ical(); |
2713 | 2711 | #error_log(__METHOD__.print_r($content,true)); |
2714 | 2712 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
2715 | 2713 | { |
2716 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
2714 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
2717 | 2715 | { |
2718 | 2716 | $msg = lang('Permission denied'); |
2719 | 2717 | |
@@ -2721,20 +2719,20 @@ discard block |
||
2721 | 2719 | } |
2722 | 2720 | else |
2723 | 2721 | { |
2724 | - Api\Header\Content::type('event.ics','text/calendar',bytes($ical)); |
|
2722 | + Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical)); |
|
2725 | 2723 | echo $ical; |
2726 | 2724 | exit(); |
2727 | 2725 | } |
2728 | 2726 | } |
2729 | 2727 | if (is_array($content)) |
2730 | 2728 | { |
2731 | - $events =& $this->bo->search(array( |
|
2729 | + $events = & $this->bo->search(array( |
|
2732 | 2730 | 'start' => $content['start'], |
2733 | 2731 | 'end' => $content['end'], |
2734 | 2732 | 'enum_recuring' => false, |
2735 | 2733 | 'daywise' => false, |
2736 | 2734 | 'owner' => $this->owner, |
2737 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
2735 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
2738 | 2736 | )); |
2739 | 2737 | if (!$events) |
2740 | 2738 | { |
@@ -2742,8 +2740,8 @@ discard block |
||
2742 | 2740 | } |
2743 | 2741 | else |
2744 | 2742 | { |
2745 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
2746 | - Api\Header\Content::type($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
2743 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
2744 | + Api\Header\Content::type($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
2747 | 2745 | echo $ical; |
2748 | 2746 | exit(); |
2749 | 2747 | } |
@@ -2759,9 +2757,9 @@ discard block |
||
2759 | 2757 | } |
2760 | 2758 | $content['msg'] = $msg; |
2761 | 2759 | |
2762 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
2760 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
2763 | 2761 | $etpl = new Etemplate('calendar.export'); |
2764 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
2762 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
2765 | 2763 | } |
2766 | 2764 | |
2767 | 2765 | /** |
@@ -2769,7 +2767,7 @@ discard block |
||
2769 | 2767 | * |
2770 | 2768 | * @param array $_content |
2771 | 2769 | */ |
2772 | - function cat_acl(array $_content=null) |
|
2770 | + function cat_acl(array $_content = null) |
|
2773 | 2771 | { |
2774 | 2772 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
2775 | 2773 | { |
@@ -2781,15 +2779,15 @@ discard block |
||
2781 | 2779 | unset($_content['button']); |
2782 | 2780 | if ($button != 'cancel') // store changed Acl |
2783 | 2781 | { |
2784 | - foreach($_content as $data) |
|
2782 | + foreach ($_content as $data) |
|
2785 | 2783 | { |
2786 | 2784 | if (!($cat_id = $data['cat_id'])) continue; |
2787 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
2785 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
2788 | 2786 | { |
2789 | 2787 | $rights = 0; |
2790 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2791 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2792 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2788 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2789 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2790 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
2793 | 2791 | } |
2794 | 2792 | } |
2795 | 2793 | } |
@@ -2801,20 +2799,20 @@ discard block |
||
2801 | 2799 | ), 'admin'); |
2802 | 2800 | } |
2803 | 2801 | } |
2804 | - $content= $preserv = array(); |
|
2802 | + $content = $preserv = array(); |
|
2805 | 2803 | $n = 1; |
2806 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2804 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
2807 | 2805 | { |
2808 | - $cat_id = substr($Lcat_id,1); |
|
2806 | + $cat_id = substr($Lcat_id, 1); |
|
2809 | 2807 | $row = array( |
2810 | 2808 | 'cat_id' => $cat_id, |
2811 | 2809 | 'add' => array(), |
2812 | 2810 | 'status' => array(), |
2813 | 2811 | ); |
2814 | - foreach($data as $account_id => $rights) |
|
2812 | + foreach ($data as $account_id => $rights) |
|
2815 | 2813 | { |
2816 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2817 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2814 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2815 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
2818 | 2816 | } |
2819 | 2817 | $content[$n] = $row; |
2820 | 2818 | $preserv[$n] = array( |
@@ -2830,7 +2828,7 @@ discard block |
||
2830 | 2828 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
2831 | 2829 | $tmp = new Etemplate('calendar.cat_acl'); |
2832 | 2830 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
2833 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
2831 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
2834 | 2832 | } |
2835 | 2833 | |
2836 | 2834 | /** |
@@ -2880,18 +2878,18 @@ discard block |
||
2880 | 2878 | |
2881 | 2879 | |
2882 | 2880 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
2883 | - if($content['recur_type'] || $content['recurrence']) |
|
2881 | + if ($content['recur_type'] || $content['recurrence']) |
|
2884 | 2882 | { |
2885 | 2883 | $content['history']['filter'] = array( |
2886 | 2884 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
2887 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
2888 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
2885 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
2886 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
2889 | 2887 | ); |
2890 | 2888 | } |
2891 | 2889 | |
2892 | 2890 | // Translate labels |
2893 | 2891 | $tracking = new calendar_tracking(); |
2894 | - foreach($tracking->field2label as $field => $label) |
|
2892 | + foreach ($tracking->field2label as $field => $label) |
|
2895 | 2893 | { |
2896 | 2894 | $sel_options[$status][$field] = lang($label); |
2897 | 2895 | } |
@@ -2910,44 +2908,44 @@ discard block |
||
2910 | 2908 | * which particular instance was dragged |
2911 | 2909 | * @return string XML response if no error occurs |
2912 | 2910 | */ |
2913 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
2911 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
2914 | 2912 | { |
2915 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
2913 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
2916 | 2914 | $ignore_conflicts = false; |
2917 | 2915 | |
2918 | 2916 | // we do not allow dragging into another users calendar ATM |
2919 | - if($targetOwner < 0) |
|
2917 | + if ($targetOwner < 0) |
|
2920 | 2918 | { |
2921 | 2919 | $targetOwner = array($targetOwner); |
2922 | 2920 | } |
2923 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2921 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
2924 | 2922 | { |
2925 | 2923 | $targetOwner = $calendarOwner; |
2926 | 2924 | } |
2927 | 2925 | // But you may be viewing multiple users, or a group calendar and |
2928 | 2926 | // dragging your event - dragging across calendars does not change owner |
2929 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2927 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
2930 | 2928 | { |
2931 | 2929 | $return = true; |
2932 | - foreach($targetOwner as $owner) |
|
2930 | + foreach ($targetOwner as $owner) |
|
2933 | 2931 | { |
2934 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
2932 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
2935 | 2933 | { |
2936 | 2934 | $return = false; |
2937 | 2935 | break; |
2938 | 2936 | } |
2939 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
2937 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
2940 | 2938 | { |
2941 | 2939 | $return = false; |
2942 | 2940 | break; |
2943 | 2941 | } |
2944 | 2942 | } |
2945 | - if($return) return; |
|
2943 | + if ($return) return; |
|
2946 | 2944 | } |
2947 | - $old_event=$event=$this->bo->read($eventId); |
|
2945 | + $old_event = $event = $this->bo->read($eventId); |
|
2948 | 2946 | if (!$durationT) |
2949 | 2947 | { |
2950 | - $duration=$event['end']-$event['start']; |
|
2948 | + $duration = $event['end'] - $event['start']; |
|
2951 | 2949 | } |
2952 | 2950 | // Drag a normal event to whole day non-blocking |
2953 | 2951 | else if ($durationT == 'whole_day') |
@@ -2955,7 +2953,7 @@ discard block |
||
2955 | 2953 | $event['whole_day'] = true; |
2956 | 2954 | $event['non_blocking'] = true; |
2957 | 2955 | // Make duration whole days, less 1 second |
2958 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
2956 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
2959 | 2957 | } |
2960 | 2958 | else |
2961 | 2959 | { |
@@ -2968,19 +2966,19 @@ discard block |
||
2968 | 2966 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
2969 | 2967 | if (!empty($event['whole_day'])) |
2970 | 2968 | { |
2971 | - $d =& $this->bo->so->startOfDay($d); |
|
2969 | + $d = & $this->bo->so->startOfDay($d); |
|
2972 | 2970 | $d->setUser(); |
2973 | 2971 | } |
2974 | 2972 | $event = $this->bo->read($eventId, $d, true); |
2975 | 2973 | |
2976 | 2974 | // For DnD, create an exception if they gave the date |
2977 | 2975 | $preserv = null; |
2978 | - $this->_create_exception($event,$preserv); |
|
2976 | + $this->_create_exception($event, $preserv); |
|
2979 | 2977 | unset($event['id']); |
2980 | 2978 | $links = $event['link_to']['to_id']; |
2981 | 2979 | |
2982 | 2980 | $messages = null; |
2983 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
2981 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
2984 | 2982 | if (!is_array($conflicts) && $conflicts) |
2985 | 2983 | { |
2986 | 2984 | // now we need to add the original start as recur-execption to the series |
@@ -2988,28 +2986,28 @@ discard block |
||
2988 | 2986 | $recur_event['recur_exception'][] = $d->format('ts'); |
2989 | 2987 | // check if we need to move the alarms, because they are next on that exception |
2990 | 2988 | $this->bo->check_move_alarms($recur_event, null, $d); |
2991 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2992 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2993 | - $this->bo->update($recur_event,true); // no conflict check here |
|
2989 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
2990 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
2991 | + $this->bo->update($recur_event, true); // no conflict check here |
|
2994 | 2992 | |
2995 | 2993 | // Sending null will trigger a removal of the original for that date |
2996 | 2994 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
2997 | 2995 | |
2998 | 2996 | unset($recur_event); |
2999 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
2997 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3000 | 2998 | unset($preserv['edit_single']); |
3001 | 2999 | } |
3002 | 3000 | } |
3003 | 3001 | |
3004 | 3002 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
3005 | 3003 | $event['start'] = $d->format('ts'); |
3006 | - $event['end'] = $event['start']+$duration; |
|
3004 | + $event['end'] = $event['start'] + $duration; |
|
3007 | 3005 | |
3008 | 3006 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
3009 | 3007 | { |
3010 | 3008 | // calculate offset against clicked recurrance, |
3011 | 3009 | // depending on which is smaller |
3012 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
3010 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
3013 | 3011 | $event['start'] = $old_event['start'] + $offset; |
3014 | 3012 | $event['duration'] = $duration; |
3015 | 3013 | |
@@ -3020,45 +3018,45 @@ discard block |
||
3020 | 3018 | // Can't handle conflict. Just ignore it. |
3021 | 3019 | $ignore_conflicts = true; |
3022 | 3020 | } |
3023 | - if(!$event['recur_type']) |
|
3021 | + if (!$event['recur_type']) |
|
3024 | 3022 | { |
3025 | 3023 | $this->bo->check_move_alarms($event, $old_event); |
3026 | 3024 | } |
3027 | 3025 | |
3028 | 3026 | // Drag a whole day to a time |
3029 | - if($durationT && $durationT != 'whole_day') |
|
3027 | + if ($durationT && $durationT != 'whole_day') |
|
3030 | 3028 | { |
3031 | 3029 | $event['whole_day'] = ($duration == DAY_s); |
3032 | 3030 | $event['non_blocking'] = false; |
3033 | 3031 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
3034 | 3032 | // so save the change now, and then let the conflict check happen. |
3035 | 3033 | $message = null; |
3036 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
3034 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
3037 | 3035 | |
3038 | 3036 | // Whole day non blocking with DAY_s would add a day |
3039 | - if($duration==DAY_s) $duration=0; |
|
3037 | + if ($duration == DAY_s) $duration = 0; |
|
3040 | 3038 | } |
3041 | 3039 | |
3042 | 3040 | $status_reset_to_unknown = false; |
3043 | 3041 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
3044 | 3042 | |
3045 | 3043 | $message = false; |
3046 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
3044 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
3047 | 3045 | |
3048 | 3046 | // Save links |
3049 | - if($links) |
|
3047 | + if ($links) |
|
3050 | 3048 | { |
3051 | 3049 | Link::link('calendar', $event['id'], $links); |
3052 | 3050 | } |
3053 | 3051 | |
3054 | - $this->update_client($event['id'],$d); |
|
3052 | + $this->update_client($event['id'], $d); |
|
3055 | 3053 | $response = Api\Json\Response::get(); |
3056 | - if(!is_array($conflicts) && $conflicts) |
|
3054 | + if (!is_array($conflicts) && $conflicts) |
|
3057 | 3055 | { |
3058 | - if(is_int($conflicts)) |
|
3056 | + if (is_int($conflicts)) |
|
3059 | 3057 | { |
3060 | 3058 | $event['id'] = $conflicts; |
3061 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3059 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3062 | 3060 | } |
3063 | 3061 | } |
3064 | 3062 | else if ($conflicts) |
@@ -3071,21 +3069,21 @@ discard block |
||
3071 | 3069 | .'&end='.$event['end'] |
3072 | 3070 | .'&non_interactive=true' |
3073 | 3071 | .'&cancel_needs_refresh=true', |
3074 | - '',750,410); |
|
3072 | + '', 750, 410); |
|
3075 | 3073 | } |
3076 | 3074 | else if ($message) |
3077 | 3075 | { |
3078 | - $response->call('egw.message', implode('<br />', $message)); |
|
3076 | + $response->call('egw.message', implode('<br />', $message)); |
|
3079 | 3077 | } |
3080 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
3078 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
3081 | 3079 | if ($status_reset_to_unknown) |
3082 | 3080 | { |
3083 | - foreach((array)$event['participants'] as $uid => $status) |
|
3081 | + foreach ((array)$event['participants'] as $uid => $status) |
|
3084 | 3082 | { |
3085 | 3083 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
3086 | 3084 | { |
3087 | - calendar_so::split_status($status,$q,$r); |
|
3088 | - $status = calendar_so::combine_status('U',$q,$r); |
|
3085 | + calendar_so::split_status($status, $q, $r); |
|
3086 | + $status = calendar_so::combine_status('U', $q, $r); |
|
3089 | 3087 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
3090 | 3088 | } |
3091 | 3089 | } |
@@ -3102,7 +3100,7 @@ discard block |
||
3102 | 3100 | { |
3103 | 3101 | list($eventId, $date) = explode(':', $_eventId); |
3104 | 3102 | $event = $this->bo->read($eventId); |
3105 | - if($date) |
|
3103 | + if ($date) |
|
3106 | 3104 | { |
3107 | 3105 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3108 | 3106 | } |
@@ -3112,29 +3110,29 @@ discard block |
||
3112 | 3110 | { |
3113 | 3111 | if (!empty($event['whole_day'])) |
3114 | 3112 | { |
3115 | - $d =& $this->bo->so->startOfDay($date); |
|
3113 | + $d = & $this->bo->so->startOfDay($date); |
|
3116 | 3114 | $d->setUser(); |
3117 | 3115 | } |
3118 | 3116 | $event = $this->bo->read($eventId, $d, true); |
3119 | 3117 | $date = $d->format('ts'); |
3120 | 3118 | } |
3121 | - if($event['participants'][$uid]) |
|
3119 | + if ($event['participants'][$uid]) |
|
3122 | 3120 | { |
3123 | 3121 | $q = $r = null; |
3124 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3125 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3126 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3122 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3123 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3124 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3127 | 3125 | } |
3128 | 3126 | else |
3129 | 3127 | { |
3130 | 3128 | // Group membership |
3131 | - foreach(array_keys($event['participants']) as $id) |
|
3129 | + foreach (array_keys($event['participants']) as $id) |
|
3132 | 3130 | { |
3133 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
3131 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
3134 | 3132 | { |
3135 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
3136 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
3137 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
3133 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
3134 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
3135 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
3138 | 3136 | break; |
3139 | 3137 | } |
3140 | 3138 | } |
@@ -3142,7 +3140,7 @@ discard block |
||
3142 | 3140 | |
3143 | 3141 | // Directly update stored data. If event is still visible, it will |
3144 | 3142 | // be notified & update itself. |
3145 | - $this->update_client($eventId,$d); |
|
3143 | + $this->update_client($eventId, $d); |
|
3146 | 3144 | } |
3147 | 3145 | |
3148 | 3146 | /** |
@@ -3150,8 +3148,8 @@ discard block |
||
3150 | 3148 | */ |
3151 | 3149 | public function ajax_delete($eventId) |
3152 | 3150 | { |
3153 | - list($id, $date) = explode(':',$eventId); |
|
3154 | - $event=$this->bo->read($id); |
|
3151 | + list($id, $date) = explode(':', $eventId); |
|
3152 | + $event = $this->bo->read($id); |
|
3155 | 3153 | $response = Api\Json\Response::get(); |
3156 | 3154 | |
3157 | 3155 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -3164,11 +3162,11 @@ discard block |
||
3164 | 3162 | { |
3165 | 3163 | $msg = lang('Event deleted'); |
3166 | 3164 | } |
3167 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
3165 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
3168 | 3166 | } |
3169 | 3167 | else |
3170 | 3168 | { |
3171 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
3169 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
3172 | 3170 | } |
3173 | 3171 | } |
3174 | 3172 | |
@@ -3181,10 +3179,10 @@ discard block |
||
3181 | 3179 | */ |
3182 | 3180 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
3183 | 3181 | { |
3184 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
3182 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
3185 | 3183 | |
3186 | 3184 | $event = $this->bo->read($eventId); |
3187 | - if($date) |
|
3185 | + if ($date) |
|
3188 | 3186 | { |
3189 | 3187 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
3190 | 3188 | } |
@@ -3194,17 +3192,17 @@ discard block |
||
3194 | 3192 | { |
3195 | 3193 | if (!empty($event['whole_day'])) |
3196 | 3194 | { |
3197 | - $d =& $this->bo->so->startOfDay($date); |
|
3195 | + $d = & $this->bo->so->startOfDay($date); |
|
3198 | 3196 | $d->setUser(); |
3199 | 3197 | } |
3200 | 3198 | $event = $this->bo->read($eventId, $d, true); |
3201 | 3199 | // For DnD, create an exception if they gave the date |
3202 | 3200 | $preserv = null; |
3203 | - $this->_create_exception($event,$preserv); |
|
3201 | + $this->_create_exception($event, $preserv); |
|
3204 | 3202 | unset($event['id']); |
3205 | 3203 | |
3206 | 3204 | $messages = null; |
3207 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
3205 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
3208 | 3206 | if (!is_array($conflicts) && $conflicts) |
3209 | 3207 | { |
3210 | 3208 | // now we need to add the original start as recur-execption to the series |
@@ -3212,28 +3210,28 @@ discard block |
||
3212 | 3210 | $recur_event['recur_exception'][] = $d->format('ts'); |
3213 | 3211 | // check if we need to move the alarms, because they are next on that exception |
3214 | 3212 | $this->bo->check_move_alarms($recur_event, null, $d); |
3215 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3216 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3217 | - $this->bo->update($recur_event,true); // no conflict check here |
|
3213 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
3214 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
3215 | + $this->bo->update($recur_event, true); // no conflict check here |
|
3218 | 3216 | |
3219 | 3217 | // Sending null will trigger a removal of the original for that date |
3220 | 3218 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
3221 | 3219 | |
3222 | 3220 | unset($recur_event); |
3223 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3221 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
3224 | 3222 | unset($preserv['edit_single']); |
3225 | 3223 | } |
3226 | 3224 | } |
3227 | - foreach($remove as $participant) |
|
3225 | + foreach ($remove as $participant) |
|
3228 | 3226 | { |
3229 | 3227 | unset($event['participants'][$participant]); |
3230 | 3228 | } |
3231 | - foreach($invite as $participant) |
|
3229 | + foreach ($invite as $participant) |
|
3232 | 3230 | { |
3233 | 3231 | $event['participants'][$participant] = 'U'; |
3234 | 3232 | } |
3235 | 3233 | $message = null; |
3236 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
3234 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
3237 | 3235 | |
3238 | 3236 | $response = Api\Json\Response::get(); |
3239 | 3237 | |
@@ -3241,8 +3239,8 @@ discard block |
||
3241 | 3239 | { |
3242 | 3240 | // Save it anyway, was done with explicit user interaction, |
3243 | 3241 | // and if we don't we lose the invite |
3244 | - $this->bo->update($event,true); // no conflict check here |
|
3245 | - $this->update_client($event['id'],$d); |
|
3242 | + $this->bo->update($event, true); // no conflict check here |
|
3243 | + $this->update_client($event['id'], $d); |
|
3246 | 3244 | $response->call( |
3247 | 3245 | 'egw_openWindowCentered2', |
3248 | 3246 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3251,22 +3249,22 @@ discard block |
||
3251 | 3249 | .'&end='.$event['end'] |
3252 | 3250 | .'&non_interactive=true' |
3253 | 3251 | .'&cancel_needs_refresh=true', |
3254 | - '',750,410); |
|
3252 | + '', 750, 410); |
|
3255 | 3253 | } |
3256 | 3254 | else if ($message) |
3257 | 3255 | { |
3258 | - $response->call('egw.message', implode('<br />', $message)); |
|
3256 | + $response->call('egw.message', implode('<br />', $message)); |
|
3259 | 3257 | } |
3260 | - if($conflicts) |
|
3258 | + if ($conflicts) |
|
3261 | 3259 | { |
3262 | - $this->update_client($event['id'],$d); |
|
3263 | - if(is_int($conflicts)) |
|
3260 | + $this->update_client($event['id'], $d); |
|
3261 | + if (is_int($conflicts)) |
|
3264 | 3262 | { |
3265 | 3263 | $event['id'] = $conflicts; |
3266 | 3264 | } |
3267 | - if($event['id']) |
|
3265 | + if ($event['id']) |
|
3268 | 3266 | { |
3269 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
3267 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
3270 | 3268 | } |
3271 | 3269 | } |
3272 | 3270 | } |
@@ -3277,13 +3275,13 @@ discard block |
||
3277 | 3275 | * @param array $mailContent = null mail content |
3278 | 3276 | * @return array |
3279 | 3277 | */ |
3280 | - function mail_import(array $mailContent=null) |
|
3278 | + function mail_import(array $mailContent = null) |
|
3281 | 3279 | { |
3282 | 3280 | // It would get called from compose as a popup with egw_data |
3283 | 3281 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
3284 | 3282 | { |
3285 | 3283 | // get raw mail data |
3286 | - Link::get_data ($_GET['egw_data']); |
|
3284 | + Link::get_data($_GET['egw_data']); |
|
3287 | 3285 | return false; |
3288 | 3286 | } |
3289 | 3287 | |
@@ -3293,7 +3291,7 @@ discard block |
||
3293 | 3291 | $AB = new Api\Contacts(); |
3294 | 3292 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
3295 | 3293 | |
3296 | - $participants[0] = array ( |
|
3294 | + $participants[0] = array( |
|
3297 | 3295 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
3298 | 3296 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
3299 | 3297 | 'status' => 'A', |
@@ -3301,23 +3299,23 @@ discard block |
||
3301 | 3299 | 'app' => 'User', |
3302 | 3300 | 'role' => 'REQ-PARTICIPANT' |
3303 | 3301 | ); |
3304 | - foreach($mailContent['addresses'] as $address) |
|
3302 | + foreach ($mailContent['addresses'] as $address) |
|
3305 | 3303 | { |
3306 | 3304 | // Get available contacts from the email |
3307 | 3305 | $contacts = $AB->search(array( |
3308 | 3306 | 'email' => $address['email'], |
3309 | 3307 | 'email_home' => $address['email'] |
3310 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
3308 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
3311 | 3309 | if (is_array($contacts)) |
3312 | 3310 | { |
3313 | - foreach($contacts as $account) |
|
3311 | + foreach ($contacts as $account) |
|
3314 | 3312 | { |
3315 | 3313 | $accounts[] = $account['account_id']; |
3316 | 3314 | } |
3317 | 3315 | } |
3318 | 3316 | else |
3319 | 3317 | { |
3320 | - $participants []= array ( |
|
3318 | + $participants [] = array( |
|
3321 | 3319 | 'app' => 'email', |
3322 | 3320 | 'uid' => 'e'.$address['email'], |
3323 | 3321 | 'status' => 'U', |
@@ -3325,7 +3323,7 @@ discard block |
||
3325 | 3323 | ); |
3326 | 3324 | } |
3327 | 3325 | } |
3328 | - $participants = array_merge($participants , array( |
|
3326 | + $participants = array_merge($participants, array( |
|
3329 | 3327 | "participant" => $accounts, |
3330 | 3328 | "role" => "REQ-PARTICIPANT", |
3331 | 3329 | "add" => "pressed" |
@@ -3349,14 +3347,14 @@ discard block |
||
3349 | 3347 | { |
3350 | 3348 | foreach ($mailContent['attachments'] as $attachment) |
3351 | 3349 | { |
3352 | - if($attachment['egw_data']) |
|
3350 | + if ($attachment['egw_data']) |
|
3353 | 3351 | { |
3354 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
3352 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
3355 | 3353 | } |
3356 | - else if(is_readable($attachment['tmp_name']) || |
|
3354 | + else if (is_readable($attachment['tmp_name']) || |
|
3357 | 3355 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
3358 | 3356 | { |
3359 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
3357 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
3360 | 3358 | } |
3361 | 3359 | } |
3362 | 3360 | } |
@@ -126,11 +126,14 @@ discard block |
||
126 | 126 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
127 | 127 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
128 | 128 | { |
129 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
129 | + if ($owner) |
|
130 | + { |
|
131 | + // make an owner who is no user or we have no add-rights a participant |
|
130 | 132 | { |
131 | 133 | if(!is_array($owner)) |
132 | 134 | { |
133 | 135 | $owner = explode(',',$owner); |
136 | + } |
|
134 | 137 | } |
135 | 138 | // if we come from ressources we don't need any users selected in calendar |
136 | 139 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -164,9 +167,17 @@ discard block |
||
164 | 167 | $participant_types['u'] = $participant_types = $participants = array(); |
165 | 168 | foreach($extra_participants as $uid) |
166 | 169 | { |
167 | - if (isset($participants[$uid])) continue; // already included |
|
170 | + if (isset($participants[$uid])) |
|
171 | + { |
|
172 | + continue; |
|
173 | + } |
|
174 | + // already included |
|
168 | 175 | |
169 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
176 | + if (!$this->bo->check_acl_invite($uid)) |
|
177 | + { |
|
178 | + continue; |
|
179 | + } |
|
180 | + // no right to invite --> ignored |
|
170 | 181 | |
171 | 182 | if (is_numeric($uid)) |
172 | 183 | { |
@@ -204,10 +215,13 @@ discard block |
||
204 | 215 | } |
205 | 216 | } |
206 | 217 | } |
207 | - if (!$participants) // if all participants got removed, include current user |
|
218 | + if (!$participants) |
|
219 | + { |
|
220 | + // if all participants got removed, include current user |
|
208 | 221 | { |
209 | 222 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
210 | 223 | } |
224 | + } |
|
211 | 225 | if(isset($_GET['cat_id'])) |
212 | 226 | { |
213 | 227 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -273,10 +287,13 @@ discard block |
||
273 | 287 | */ |
274 | 288 | function process_edit($content) |
275 | 289 | { |
276 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
290 | + if (!is_array($content)) |
|
291 | + { |
|
292 | + // redirect from etemplate, if POST empty |
|
277 | 293 | { |
278 | 294 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
279 | 295 | } |
296 | + } |
|
280 | 297 | // clear notification errors |
281 | 298 | notifications::errors(true); |
282 | 299 | $messages = null; |
@@ -289,7 +306,11 @@ discard block |
||
289 | 306 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
290 | 307 | |
291 | 308 | $button = @key($content['button']); |
292 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
309 | + if (!$button && $content['action']) |
|
310 | + { |
|
311 | + $button = $content['action']; |
|
312 | + } |
|
313 | + // action selectbox |
|
293 | 314 | unset($content['button']); unset($content['action']); |
294 | 315 | |
295 | 316 | $view = $content['view']; |
@@ -302,7 +323,10 @@ discard block |
||
302 | 323 | { |
303 | 324 | $date = key($content['recur_exception']['delete_exception']); |
304 | 325 | // eT2 converts time to |
305 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
326 | + if (!is_numeric($date)) |
|
327 | + { |
|
328 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
329 | + } |
|
306 | 330 | unset($content['recur_exception']['delete_exception']); |
307 | 331 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
308 | 332 | { |
@@ -311,7 +335,10 @@ discard block |
||
311 | 335 | foreach ($recur_exceptions as $id) |
312 | 336 | { |
313 | 337 | if (!($exception = $this->bo->read($id)) || |
314 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
338 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
339 | + { |
|
340 | + continue; |
|
341 | + } |
|
315 | 342 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
316 | 343 | $exception['reference'] = $exception['recurrence'] = 0; |
317 | 344 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -369,8 +396,7 @@ discard block |
||
369 | 396 | // Existing event, check for change from/to whole day |
370 | 397 | ($old = $this->bo->read($content['cal_id'])) && $old['whole_day'] !== $content['whole_day'] && |
371 | 398 | ($def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]) |
372 | - ) |
|
373 | - { |
|
399 | + ) { |
|
374 | 400 | // Reset default alarm |
375 | 401 | $old_default = array_shift($content['alarm']); |
376 | 402 | $this->bo->delete_alarm($old_default['id']); |
@@ -407,7 +433,10 @@ discard block |
||
407 | 433 | $event['end'] = $this->bo->date2ts($event['end']); |
408 | 434 | } |
409 | 435 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
410 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
436 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
437 | + { |
|
438 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
439 | + } |
|
411 | 440 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
412 | 441 | { |
413 | 442 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -534,7 +563,11 @@ discard block |
||
534 | 563 | break; |
535 | 564 | |
536 | 565 | default: // existing participant row |
537 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
566 | + if (!is_array($data)) |
|
567 | + { |
|
568 | + continue; |
|
569 | + } |
|
570 | + // widgets in participant tab, above participant list |
|
538 | 571 | $quantity = $status = $role = null; |
539 | 572 | foreach(array('uid','status','quantity','role') as $name) |
540 | 573 | { |
@@ -672,7 +705,10 @@ discard block |
||
672 | 705 | { |
673 | 706 | foreach($participants as $id => &$p_response) |
674 | 707 | { |
675 | - if($type == 'u' && $id == $event['owner']) continue; |
|
708 | + if($type == 'u' && $id == $event['owner']) |
|
709 | + { |
|
710 | + continue; |
|
711 | + } |
|
676 | 712 | calendar_so::split_status($p_response, $quantity, $role); |
677 | 713 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
678 | 714 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -754,17 +790,23 @@ discard block |
||
754 | 790 | { |
755 | 791 | foreach (array_keys($event['participants']) as $uid) |
756 | 792 | { |
757 | - if ($uid[0] == 'r') //ressource detection |
|
793 | + if ($uid[0] == 'r') |
|
794 | + { |
|
795 | + //ressource detection |
|
758 | 796 | { |
759 | 797 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
798 | + } |
|
760 | 799 | $button = ''; |
761 | 800 | break 2; //break foreach and case |
762 | 801 | } |
763 | 802 | } |
764 | 803 | } |
765 | - if ($content['edit_single']) // we edited a single event from a series |
|
804 | + if ($content['edit_single']) |
|
805 | + { |
|
806 | + // we edited a single event from a series |
|
766 | 807 | { |
767 | 808 | $event['reference'] = $event['id']; |
809 | + } |
|
768 | 810 | $event['recurrence'] = $content['edit_single']; |
769 | 811 | unset($event['id']); |
770 | 812 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -1012,7 +1054,10 @@ discard block |
||
1012 | 1054 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
1013 | 1055 | { |
1014 | 1056 | $msg = lang('Series deleted'); |
1015 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
1057 | + if ($exceptions_kept) |
|
1058 | + { |
|
1059 | + $msg .= lang(', exceptions preserved'); |
|
1060 | + } |
|
1016 | 1061 | } |
1017 | 1062 | else |
1018 | 1063 | { |
@@ -1048,11 +1093,14 @@ discard block |
||
1048 | 1093 | { |
1049 | 1094 | $msg = lang("Can't add alarms in the past !!!"); |
1050 | 1095 | } |
1051 | - elseif ($event['id']) // save the alarm immediatly |
|
1096 | + elseif ($event['id']) |
|
1097 | + { |
|
1098 | + // save the alarm immediatly |
|
1052 | 1099 | { |
1053 | 1100 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
1054 | 1101 | { |
1055 | 1102 | $alarm['id'] = $alarm_id; |
1103 | + } |
|
1056 | 1104 | $event['alarm'][$alarm_id] = $alarm; |
1057 | 1105 | |
1058 | 1106 | $msg = lang('Alarm added'); |
@@ -1065,7 +1113,9 @@ discard block |
||
1065 | 1113 | } |
1066 | 1114 | else |
1067 | 1115 | { |
1068 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
1116 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
1117 | + { |
|
1118 | +} // get a temporary non-conflicting, numeric id |
|
1069 | 1119 | $event['alarm'][$alarm['id']] = $alarm; |
1070 | 1120 | } |
1071 | 1121 | } |
@@ -1088,10 +1138,13 @@ discard block |
||
1088 | 1138 | } |
1089 | 1139 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
1090 | 1140 | { |
1091 | - if ($content['lock_token']) // remove an existing lock |
|
1141 | + if ($content['lock_token']) |
|
1142 | + { |
|
1143 | + // remove an existing lock |
|
1092 | 1144 | { |
1093 | 1145 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
1094 | 1146 | } |
1147 | + } |
|
1095 | 1148 | if ($content['no_popup']) |
1096 | 1149 | { |
1097 | 1150 | Egw::redirect_link('/index.php',array( |
@@ -1149,13 +1202,19 @@ discard block |
||
1149 | 1202 | } |
1150 | 1203 | |
1151 | 1204 | // Copy links |
1152 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
1205 | + if(!is_array($event['link_to'])) |
|
1206 | + { |
|
1207 | + $event['link_to'] = array(); |
|
1208 | + } |
|
1153 | 1209 | $event['link_to']['to_app'] = 'calendar'; |
1154 | 1210 | $event['link_to']['to_id'] = 0; |
1155 | 1211 | |
1156 | 1212 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
1157 | 1213 | { |
1158 | - if(!$link['id']) continue; |
|
1214 | + if(!$link['id']) |
|
1215 | + { |
|
1216 | + continue; |
|
1217 | + } |
|
1159 | 1218 | if ($link['app'] != Link::VFS_APPNAME) |
1160 | 1219 | { |
1161 | 1220 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1223,8 +1282,7 @@ discard block |
||
1223 | 1282 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
1224 | 1283 | // Adjust for requested date in the past |
1225 | 1284 | Api\DateTime::to($as_of_date,'ts') < time() |
1226 | - ) |
|
1227 | - { |
|
1285 | + ) { |
|
1228 | 1286 | |
1229 | 1287 | unset($orig_event); |
1230 | 1288 | // copy event by unsetting the id(s) |
@@ -1312,7 +1370,10 @@ discard block |
||
1312 | 1370 | foreach($event['participants'] as $uid => $status) |
1313 | 1371 | { |
1314 | 1372 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
1315 | - if (empty($status)) continue; |
|
1373 | + if (empty($status)) |
|
1374 | + { |
|
1375 | + continue; |
|
1376 | + } |
|
1316 | 1377 | if(!is_array($status)) |
1317 | 1378 | { |
1318 | 1379 | $quantity = $role = null; |
@@ -1323,28 +1384,43 @@ discard block |
||
1323 | 1384 | ); |
1324 | 1385 | } |
1325 | 1386 | $toadd = ''; |
1326 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
1387 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
1388 | + { |
|
1389 | + continue; |
|
1390 | + } |
|
1327 | 1391 | |
1328 | 1392 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
1329 | 1393 | { |
1330 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
1394 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
1395 | + { |
|
1396 | + continue; |
|
1397 | + } |
|
1331 | 1398 | |
1332 | 1399 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
1333 | 1400 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
1334 | 1401 | |
1335 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
1402 | + if (!in_array($toadd,$to)) |
|
1403 | + { |
|
1404 | + $to[] = $toadd; |
|
1405 | + } |
|
1336 | 1406 | } |
1337 | 1407 | elseif ($uid < 0) |
1338 | 1408 | { |
1339 | 1409 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
1340 | 1410 | { |
1341 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
1411 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
1412 | + { |
|
1413 | + continue; |
|
1414 | + } |
|
1342 | 1415 | |
1343 | 1416 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
1344 | 1417 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
1345 | 1418 | |
1346 | 1419 | // dont add groupmembers if they already rejected the event, or are the current user |
1347 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
1420 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
1421 | + { |
|
1422 | + $to[] = $toadd; |
|
1423 | + } |
|
1348 | 1424 | } |
1349 | 1425 | } |
1350 | 1426 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1396,7 +1472,10 @@ discard block |
||
1396 | 1472 | 'preset[size]' => filesize($ics_file), |
1397 | 1473 | ); |
1398 | 1474 | $vars[$asrequest?'preset[to]': 'preset[bcc]'] = $to; |
1399 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
1475 | + if ($asrequest) |
|
1476 | + { |
|
1477 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
1478 | + } |
|
1400 | 1479 | $response = Api\Json\Response::get(); |
1401 | 1480 | $response->call('app.calendar.custom_mail', $vars); |
1402 | 1481 | } |
@@ -1629,9 +1708,15 @@ discard block |
||
1629 | 1708 | } |
1630 | 1709 | } |
1631 | 1710 | // set new start and end if given by $_GET |
1632 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1633 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1634 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1711 | + if(isset($_GET['start'])) |
|
1712 | + { |
|
1713 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
1714 | + if(isset($_GET['end'])) |
|
1715 | + { |
|
1716 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
1717 | + if(isset($_GET['non_blocking'])) |
|
1718 | + { |
|
1719 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
1635 | 1720 | // check if the event is the whole day |
1636 | 1721 | $start = $this->bo->date2array($event['start']); |
1637 | 1722 | $end = $this->bo->date2array($event['end']); |
@@ -1644,10 +1729,13 @@ discard block |
||
1644 | 1729 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
1645 | 1730 | { |
1646 | 1731 | $link_id = $link_ids[$n]; |
1647 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
1732 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
1733 | + { |
|
1734 | + // guard against XSS |
|
1648 | 1735 | { |
1649 | 1736 | continue; |
1650 | 1737 | } |
1738 | + } |
|
1651 | 1739 | if(!$n) |
1652 | 1740 | { |
1653 | 1741 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1656,7 +1744,10 @@ discard block |
||
1656 | 1744 | { |
1657 | 1745 | foreach((array)$set['link_app'] as $i => $l_app) |
1658 | 1746 | { |
1659 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1747 | + if (($l_id=$set['link_id'][$i])) |
|
1748 | + { |
|
1749 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
1750 | + } |
|
1660 | 1751 | } |
1661 | 1752 | unset($set['link_app']); |
1662 | 1753 | unset($set['link_id']); |
@@ -1682,10 +1773,13 @@ discard block |
||
1682 | 1773 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
1683 | 1774 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
1684 | 1775 | |
1685 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
1776 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
1777 | + { |
|
1778 | + // already locked --> refresh the lock |
|
1686 | 1779 | { |
1687 | 1780 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
1688 | 1781 | } |
1782 | + } |
|
1689 | 1783 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
1690 | 1784 | { |
1691 | 1785 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1719,14 +1813,20 @@ discard block |
||
1719 | 1813 | )); |
1720 | 1814 | Framework::message($msg, $msg_type); |
1721 | 1815 | $content['duration'] = $content['end'] - $content['start']; |
1722 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
1816 | + if (isset($this->durations[$content['duration']])) |
|
1817 | + { |
|
1818 | + $content['end'] = ''; |
|
1819 | + } |
|
1723 | 1820 | |
1724 | 1821 | $row = 3; |
1725 | 1822 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
1726 | 1823 | // preserve some ui elements, if set eg. under error-conditions |
1727 | 1824 | foreach(array('quantity','resource','role') as $n) |
1728 | 1825 | { |
1729 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
1826 | + if (isset($event['participants'][$n])) |
|
1827 | + { |
|
1828 | + $content['participants'][$n] = $event['participants'][$n]; |
|
1829 | + } |
|
1730 | 1830 | } |
1731 | 1831 | foreach($event['participant_types'] as $type => $participants) |
1732 | 1832 | { |
@@ -1768,9 +1868,13 @@ discard block |
||
1768 | 1868 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
1769 | 1869 | |
1770 | 1870 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
1771 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
1871 | + { |
|
1872 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
1873 | + } |
|
1772 | 1874 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
1773 | - $readonlys['participants']['delete'][$uid] = true; |
|
1875 | + { |
|
1876 | + $readonlys['participants']['delete'][$uid] = true; |
|
1877 | + } |
|
1774 | 1878 | // todo: make the participants available as links with email as title |
1775 | 1879 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
1776 | 1880 | // enumerate group-invitations, so people can accept/reject them |
@@ -1801,7 +1905,11 @@ discard block |
||
1801 | 1905 | $content['participants']['cal_resources'] = ''; |
1802 | 1906 | foreach($this->bo->resources as $data) |
1803 | 1907 | { |
1804 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
1908 | + if ($data['app'] == 'email') |
|
1909 | + { |
|
1910 | + continue; |
|
1911 | + } |
|
1912 | + // make no sense, as we cant search for email |
|
1805 | 1913 | $content['participants']['cal_resources'] .= ','.$data['app']; |
1806 | 1914 | } |
1807 | 1915 | } |
@@ -1831,9 +1939,18 @@ discard block |
||
1831 | 1939 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
1832 | 1940 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
1833 | 1941 | $label = array(); |
1834 | - if ($days) $label[] = $days.' '.lang('days'); |
|
1835 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
1836 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
1942 | + if ($days) |
|
1943 | + { |
|
1944 | + $label[] = $days.' '.lang('days'); |
|
1945 | + } |
|
1946 | + if ($hours) |
|
1947 | + { |
|
1948 | + $label[] = $hours.' '.lang('hours'); |
|
1949 | + } |
|
1950 | + if ($minutes) |
|
1951 | + { |
|
1952 | + $label[] = $minutes.' '.lang('Minutes'); |
|
1953 | + } |
|
1837 | 1954 | if (!$label) |
1838 | 1955 | { |
1839 | 1956 | $alarm['offset'] = lang('at start of the event'); |
@@ -1903,25 +2020,34 @@ discard block |
||
1903 | 2020 | 'participants' => $this->accountsel->account_selection == 'none', |
1904 | 2021 | 'history' => !$event['id'], |
1905 | 2022 | ); |
1906 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
2023 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
2024 | + { |
|
2025 | + // no mail without mail-app |
|
1907 | 2026 | { |
1908 | 2027 | unset($sel_options['action']['mail']); |
2028 | + } |
|
1909 | 2029 | unset($sel_options['action']['sendmeetingrequest']); |
1910 | 2030 | } |
1911 | - if (!$event['id']) // no ical export for new (not saved) events |
|
2031 | + if (!$event['id']) |
|
2032 | + { |
|
2033 | + // no ical export for new (not saved) events |
|
1912 | 2034 | { |
1913 | 2035 | $readonlys['action'] = true; |
1914 | 2036 | } |
2037 | + } |
|
1915 | 2038 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
1916 | 2039 | { |
1917 | 2040 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
1918 | 2041 | } |
1919 | 2042 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
1920 | 2043 | |
1921 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
2044 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
2045 | + { |
|
2046 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
1922 | 2047 | { |
1923 | 2048 | $sel_options['owner'][0] = lang('All participants'); |
1924 | 2049 | } |
2050 | + } |
|
1925 | 2051 | if (isset($event['participant_types']['u'][$this->user])) |
1926 | 2052 | { |
1927 | 2053 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1964,7 +2090,10 @@ discard block |
||
1964 | 2090 | |
1965 | 2091 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
1966 | 2092 | |
1967 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
2093 | + if (!empty($preserved['lock_token'])) |
|
2094 | + { |
|
2095 | + $content['lock_token'] = $preserved['lock_token']; |
|
2096 | + } |
|
1968 | 2097 | |
1969 | 2098 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
1970 | 2099 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2121,7 +2250,10 @@ discard block |
||
2121 | 2250 | { |
2122 | 2251 | $quantity = $role = null; |
2123 | 2252 | calendar_so::split_status($status, $quantity, $role); |
2124 | - if (!is_numeric($uid) && $role == 'CHAIR') break; |
|
2253 | + if (!is_numeric($uid) && $role == 'CHAIR') |
|
2254 | + { |
|
2255 | + break; |
|
2256 | + } |
|
2125 | 2257 | } |
2126 | 2258 | if (!(!is_numeric($uid) && $role == 'CHAIR')) |
2127 | 2259 | { |
@@ -2349,13 +2481,16 @@ discard block |
||
2349 | 2481 | |
2350 | 2482 | foreach (array_keys($allConflicts) as $pId) |
2351 | 2483 | { |
2352 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
2484 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
2485 | + { |
|
2486 | + // resources Allow ignore conflicts |
|
2353 | 2487 | { |
2354 | 2488 | |
2355 | 2489 | switch ($resources_config['ignoreconflicts']) |
2356 | 2490 | { |
2357 | 2491 | case 'no': |
2358 | 2492 | $readonlys['button[ignore]'] = true; |
2493 | + } |
|
2359 | 2494 | break; |
2360 | 2495 | case 'allusers': |
2361 | 2496 | $readonlys['button[ignore]'] = false; |
@@ -2499,7 +2634,10 @@ discard block |
||
2499 | 2634 | } |
2500 | 2635 | else |
2501 | 2636 | { |
2502 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
2637 | + if (!$content['duration']) |
|
2638 | + { |
|
2639 | + $content['duration'] = $content['end'] - $content['start']; |
|
2640 | + } |
|
2503 | 2641 | $weekds = 0; |
2504 | 2642 | foreach ($content['weekdays'] as &$wdays) |
2505 | 2643 | { |
@@ -2521,7 +2659,10 @@ discard block |
||
2521 | 2659 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
2522 | 2660 | |
2523 | 2661 | $sel_options['duration'] = $this->durations; |
2524 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
2662 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
2663 | + { |
|
2664 | + $content['end'] = ''; |
|
2665 | + } |
|
2525 | 2666 | |
2526 | 2667 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
2527 | 2668 | 'participants' => $content['participants'], |
@@ -2542,7 +2683,10 @@ discard block |
||
2542 | 2683 | */ |
2543 | 2684 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
2544 | 2685 | { |
2545 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2686 | + if ($this->debug > 2) |
|
2687 | + { |
|
2688 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
2689 | + } |
|
2546 | 2690 | |
2547 | 2691 | $busy = $this->bo->search(array( |
2548 | 2692 | 'start' => $start, |
@@ -2559,9 +2703,17 @@ discard block |
||
2559 | 2703 | $n = 0; |
2560 | 2704 | foreach($busy as $event) |
2561 | 2705 | { |
2562 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
2706 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
2707 | + { |
|
2708 | + continue; |
|
2709 | + } |
|
2710 | + // ignore our own event |
|
2563 | 2711 | |
2564 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
2712 | + if ($event['non_blocking']) |
|
2713 | + { |
|
2714 | + continue; |
|
2715 | + } |
|
2716 | + // ignore non_blocking events |
|
2565 | 2717 | |
2566 | 2718 | // check if from all wanted participants at least one has a not rejected status in found event |
2567 | 2719 | $non_rejected_found = false; |
@@ -2570,7 +2722,10 @@ discard block |
||
2570 | 2722 | $status = $event['participants'][$uid]; |
2571 | 2723 | $quantity = $role = null; |
2572 | 2724 | calendar_so::split_status($status, $quantity, $role); |
2573 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
2725 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
2726 | + { |
|
2727 | + continue; |
|
2728 | + } |
|
2574 | 2729 | |
2575 | 2730 | if (isset($event['participants'][$uid]) || |
2576 | 2731 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2580,7 +2735,10 @@ discard block |
||
2580 | 2735 | break; |
2581 | 2736 | } |
2582 | 2737 | } |
2583 | - if (!$non_rejected_found) continue; |
|
2738 | + if (!$non_rejected_found) |
|
2739 | + { |
|
2740 | + continue; |
|
2741 | + } |
|
2584 | 2742 | |
2585 | 2743 | if ($this->debug) |
2586 | 2744 | { |
@@ -2611,11 +2769,17 @@ discard block |
||
2611 | 2769 | 'start' => $ft_start, |
2612 | 2770 | 'end' => $ft_end, |
2613 | 2771 | ); |
2614 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2772 | + if ($this->debug > 1) |
|
2773 | + { |
|
2774 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
2775 | + } |
|
2615 | 2776 | } |
2616 | 2777 | $ft_start = $event['end']; |
2617 | 2778 | } |
2618 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2779 | + if ($this->debug > 0) |
|
2780 | + { |
|
2781 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
2782 | + } |
|
2619 | 2783 | |
2620 | 2784 | return $freetime; |
2621 | 2785 | } |
@@ -2635,10 +2799,16 @@ discard block |
||
2635 | 2799 | */ |
2636 | 2800 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
2637 | 2801 | { |
2638 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2802 | + if ($this->debug > 1) |
|
2803 | + { |
|
2804 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
2805 | + } |
|
2639 | 2806 | |
2640 | 2807 | $freetime_daywise = array(); |
2641 | - if (!is_array($sel_options)) $sel_options = array(); |
|
2808 | + if (!is_array($sel_options)) |
|
2809 | + { |
|
2810 | + $sel_options = array(); |
|
2811 | + } |
|
2642 | 2812 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
2643 | 2813 | |
2644 | 2814 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2648,7 +2818,10 @@ discard block |
||
2648 | 2818 | if (($end_time - $start_time)*HOUR_s < $duration) |
2649 | 2819 | { |
2650 | 2820 | $end_time = 0; |
2651 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2821 | + if ($this->debug > 1) |
|
2822 | + { |
|
2823 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
2824 | + } |
|
2652 | 2825 | } |
2653 | 2826 | $n = 0; |
2654 | 2827 | foreach($freetime as $ft) |
@@ -2669,13 +2842,19 @@ discard block |
||
2669 | 2842 | } |
2670 | 2843 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
2671 | 2844 | |
2672 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
2845 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
2846 | + { |
|
2847 | + // start earlier then start_time |
|
2673 | 2848 | { |
2674 | 2849 | $start = $daybegin + $start_time*HOUR_s; |
2675 | 2850 | } |
2851 | + } |
|
2676 | 2852 | // if end_time given use it, else the original slot's end |
2677 | 2853 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
2678 | - if ($end > $ft['end']) $end = $ft['end']; |
|
2854 | + if ($end > $ft['end']) |
|
2855 | + { |
|
2856 | + $end = $ft['end']; |
|
2857 | + } |
|
2679 | 2858 | |
2680 | 2859 | // slot to small for duration |
2681 | 2860 | if ($end - $start < $duration) |
@@ -2717,7 +2896,10 @@ discard block |
||
2717 | 2896 | { |
2718 | 2897 | $msg = lang('Permission denied'); |
2719 | 2898 | |
2720 | - if ($return_error) return $msg; |
|
2899 | + if ($return_error) |
|
2900 | + { |
|
2901 | + return $msg; |
|
2902 | + } |
|
2721 | 2903 | } |
2722 | 2904 | else |
2723 | 2905 | { |
@@ -2779,27 +2961,42 @@ discard block |
||
2779 | 2961 | { |
2780 | 2962 | $button = key($_content['button']); |
2781 | 2963 | unset($_content['button']); |
2782 | - if ($button != 'cancel') // store changed Acl |
|
2964 | + if ($button != 'cancel') |
|
2965 | + { |
|
2966 | + // store changed Acl |
|
2783 | 2967 | { |
2784 | 2968 | foreach($_content as $data) |
2785 | 2969 | { |
2786 | 2970 | if (!($cat_id = $data['cat_id'])) continue; |
2971 | + } |
|
2787 | 2972 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
2788 | 2973 | { |
2789 | 2974 | $rights = 0; |
2790 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2791 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2792 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2975 | + if (in_array($account_id,(array)$data['add'])) |
|
2976 | + { |
|
2977 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
2978 | + } |
|
2979 | + if (in_array($account_id,(array)$data['status'])) |
|
2980 | + { |
|
2981 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
2982 | + } |
|
2983 | + if ($account_id) |
|
2984 | + { |
|
2985 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
2986 | + } |
|
2793 | 2987 | } |
2794 | 2988 | } |
2795 | 2989 | } |
2796 | - if ($button != 'apply') // end dialog |
|
2990 | + if ($button != 'apply') |
|
2991 | + { |
|
2992 | + // end dialog |
|
2797 | 2993 | { |
2798 | 2994 | Egw::redirect_link('/index.php', array( |
2799 | 2995 | 'menuaction' => 'admin.admin_ui.index', |
2800 | 2996 | 'ajax' => 'true' |
2801 | 2997 | ), 'admin'); |
2802 | 2998 | } |
2999 | + } |
|
2803 | 3000 | } |
2804 | 3001 | $content= $preserv = array(); |
2805 | 3002 | $n = 1; |
@@ -2813,8 +3010,14 @@ discard block |
||
2813 | 3010 | ); |
2814 | 3011 | foreach($data as $account_id => $rights) |
2815 | 3012 | { |
2816 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
2817 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
3013 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
3014 | + { |
|
3015 | + $row['add'][] = $account_id; |
|
3016 | + } |
|
3017 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
3018 | + { |
|
3019 | + $row['status'][] = $account_id; |
|
3020 | + } |
|
2818 | 3021 | } |
2819 | 3022 | $content[$n] = $row; |
2820 | 3023 | $preserv[$n] = array( |
@@ -2942,7 +3145,10 @@ discard block |
||
2942 | 3145 | break; |
2943 | 3146 | } |
2944 | 3147 | } |
2945 | - if($return) return; |
|
3148 | + if($return) |
|
3149 | + { |
|
3150 | + return; |
|
3151 | + } |
|
2946 | 3152 | } |
2947 | 3153 | $old_event=$event=$this->bo->read($eventId); |
2948 | 3154 | if (!$durationT) |
@@ -3036,7 +3242,10 @@ discard block |
||
3036 | 3242 | $this->bo->update($event,true, true, false, true, $message,true); |
3037 | 3243 | |
3038 | 3244 | // Whole day non blocking with DAY_s would add a day |
3039 | - if($duration==DAY_s) $duration=0; |
|
3245 | + if($duration==DAY_s) |
|
3246 | + { |
|
3247 | + $duration=0; |
|
3248 | + } |
|
3040 | 3249 | } |
3041 | 3250 | |
3042 | 3251 | $status_reset_to_unknown = false; |
@@ -3077,7 +3286,10 @@ discard block |
||
3077 | 3286 | { |
3078 | 3287 | $response->call('egw.message', implode('<br />', $message)); |
3079 | 3288 | } |
3080 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
3289 | + if($event['id'] != $eventId ) |
|
3290 | + { |
|
3291 | + $this->update_client($_eventId); |
|
3292 | + } |
|
3081 | 3293 | if ($status_reset_to_unknown) |
3082 | 3294 | { |
3083 | 3295 | foreach((array)$event['participants'] as $uid => $status) |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * |
62 | 62 | * @var array |
63 | 63 | */ |
64 | - static public $types = Array( |
|
64 | + static public $types = array( |
|
65 | 65 | self::NONE => 'None', |
66 | 66 | self::DAILY => 'Daily', |
67 | 67 | self::WEEKLY => 'Weekly', |
@@ -962,14 +962,14 @@ |
||
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
965 | - * Parses a DateTime field and returns a unix timestamp. If the |
|
966 | - * field cannot be parsed then the original text is returned |
|
967 | - * unmodified. |
|
968 | - * |
|
969 | - * @param string $text The Icalendar datetime field value. |
|
970 | - * @param string $tzid =null A timezone identifier. |
|
971 | - * |
|
972 | - * @return integer A unix timestamp. |
|
965 | + * Parses a DateTime field and returns a unix timestamp. If the |
|
966 | + * field cannot be parsed then the original text is returned |
|
967 | + * unmodified. |
|
968 | + * |
|
969 | + * @param string $text The Icalendar datetime field value. |
|
970 | + * @param string $tzid =null A timezone identifier. |
|
971 | + * |
|
972 | + * @return integer A unix timestamp. |
|
973 | 973 | */ |
974 | 974 | private static function parseIcalDateTime($text, $tzid=null) |
975 | 975 | { |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | static private $recur_egw2ical_2_0 = array( |
86 | 86 | self::DAILY => 'DAILY', |
87 | 87 | self::WEEKLY => 'WEEKLY', |
88 | - self::MONTHLY_WDAY => 'MONTHLY', // BYDAY={1..7, -1}{MO..SO, last workday} |
|
89 | - self::MONTHLY_MDAY => 'MONTHLY', // BYMONHTDAY={1..31, -1 for last day of month} |
|
88 | + self::MONTHLY_WDAY => 'MONTHLY', // BYDAY={1..7, -1}{MO..SO, last workday} |
|
89 | + self::MONTHLY_MDAY => 'MONTHLY', // BYMONHTDAY={1..31, -1 for last day of month} |
|
90 | 90 | self::YEARLY => 'YEARLY', |
91 | 91 | self::HOURLY => 'HOURLY', |
92 | 92 | self::MINUTELY => 'MINUTELY', |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | static private $recur_egw2ical_1_0 = array( |
99 | 99 | self::DAILY => 'D', |
100 | 100 | self::WEEKLY => 'W', |
101 | - self::MONTHLY_WDAY => 'MP', // BYDAY={1..7,-1}{MO..SO, last workday} |
|
102 | - self::MONTHLY_MDAY => 'MD', // BYMONHTDAY={1..31,-1} |
|
101 | + self::MONTHLY_WDAY => 'MP', // BYDAY={1..7,-1}{MO..SO, last workday} |
|
102 | + self::MONTHLY_MDAY => 'MD', // BYMONHTDAY={1..31,-1} |
|
103 | 103 | self::YEARLY => 'YM', |
104 | 104 | ); |
105 | 105 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | const THURSDAY = 16; |
168 | 168 | const FRIDAY = 32; |
169 | 169 | const SATURDAY = 64; |
170 | - const WORKDAYS = 62; // Mo, ..., Fr |
|
170 | + const WORKDAYS = 62; // Mo, ..., Fr |
|
171 | 171 | const ALLDAYS = 127; |
172 | 172 | /** |
173 | 173 | * Translate weekday bitmasks to labels |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @var array |
197 | 197 | */ |
198 | - public $exceptions=array(); |
|
198 | + public $exceptions = array(); |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Array of exceptions as DateTime/egw_time objects |
202 | 202 | * |
203 | 203 | * @var array |
204 | 204 | */ |
205 | - public $exceptions_objs=array(); |
|
205 | + public $exceptions_objs = array(); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Starttime of series |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | * @param int $weekdays =0 self::SUNDAY=1|self::MONDAY=2|...|self::SATURDAY=64 |
246 | 246 | * @param array $exceptions =null DateTime objects with exceptions |
247 | 247 | */ |
248 | - public function __construct(DateTime $time,$type,$interval=1,DateTime $enddate=null,$weekdays=0,array $exceptions=null) |
|
248 | + public function __construct(DateTime $time, $type, $interval = 1, DateTime $enddate = null, $weekdays = 0, array $exceptions = null) |
|
249 | 249 | { |
250 | - switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
250 | + switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
251 | 251 | { |
252 | 252 | case 'Sunday': |
253 | 253 | $this->lastdayofweek = self::SATURDAY; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $this->time = $time instanceof Api\DateTime ? $time : new Api\DateTime($time); |
263 | 263 | |
264 | - if (!in_array($type,array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY, self::HOURLY, self::MINUTELY))) |
|
264 | + if (!in_array($type, array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY, self::HOURLY, self::MINUTELY))) |
|
265 | 265 | { |
266 | 266 | throw new Api\Exception\WrongParameter(__METHOD__."($time,$type,$interval,$enddate,$weekdays,...) type $type is NOT valid!"); |
267 | 267 | } |
@@ -271,16 +271,16 @@ discard block |
||
271 | 271 | if ($type == self::MONTHLY_WDAY) |
272 | 272 | { |
273 | 273 | // check for last week of month |
274 | - if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time)-7) |
|
274 | + if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time) - 7) |
|
275 | 275 | { |
276 | 276 | $this->monthly_byday_num = -1; |
277 | 277 | } |
278 | 278 | else |
279 | 279 | { |
280 | - $this->monthly_byday_num = 1 + floor(($this->time->format('d')-1) / 7); |
|
280 | + $this->monthly_byday_num = 1 + floor(($this->time->format('d') - 1) / 7); |
|
281 | 281 | } |
282 | 282 | } |
283 | - elseif($type == self::MONTHLY_MDAY) |
|
283 | + elseif ($type == self::MONTHLY_MDAY) |
|
284 | 284 | { |
285 | 285 | $this->monthly_bymonthday = (int)$this->time->format('d'); |
286 | 286 | // check for last day of month |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | if ((int)$interval < 1) |
299 | 299 | { |
300 | - $interval = 1; // calendar stores no (extra) interval as null, so using default 1 here |
|
300 | + $interval = 1; // calendar stores no (extra) interval as null, so using default 1 here |
|
301 | 301 | } |
302 | 302 | $this->interval = (int)$interval; |
303 | 303 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | if ($exceptions) |
330 | 330 | { |
331 | - foreach($exceptions as $exception) |
|
331 | + foreach ($exceptions as $exception) |
|
332 | 332 | { |
333 | 333 | $exception->setTimezone($this->time->getTimezone()); |
334 | 334 | $this->exceptions[] = $exception->format('Ymd'); |
@@ -344,22 +344,22 @@ discard block |
||
344 | 344 | * @param int $interval =1 |
345 | 345 | * @return int |
346 | 346 | */ |
347 | - public static function recurrence_interval($type, $interval=1) |
|
347 | + public static function recurrence_interval($type, $interval = 1) |
|
348 | 348 | { |
349 | - switch($type) |
|
349 | + switch ($type) |
|
350 | 350 | { |
351 | 351 | case self::DAILY: |
352 | - $duration = 24*3600; |
|
352 | + $duration = 24 * 3600; |
|
353 | 353 | break; |
354 | 354 | case self::WEEKLY: |
355 | - $duration = 7*24*3600; |
|
355 | + $duration = 7 * 24 * 3600; |
|
356 | 356 | break; |
357 | 357 | case self::MONTHLY_MDAY: |
358 | 358 | case self::MONTHLY_WDAY: |
359 | - $duration = 31*24*3600; |
|
359 | + $duration = 31 * 24 * 3600; |
|
360 | 360 | break; |
361 | 361 | case self::YEARLY: |
362 | - $duration = 366*24*3600; |
|
362 | + $duration = 366 * 24 * 3600; |
|
363 | 363 | break; |
364 | 364 | } |
365 | 365 | if ($interval > 1) $duration *= $interval; |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | */ |
376 | 376 | private static function daysInMonth(DateTime $time) |
377 | 377 | { |
378 | - list($year,$month) = explode('-',$time->format('Y-m')); |
|
378 | + list($year, $month) = explode('-', $time->format('Y-m')); |
|
379 | 379 | $last_day = new Api\DateTime(); |
380 | - $last_day->setDate($year,$month+1,0); |
|
380 | + $last_day->setDate($year, $month + 1, 0); |
|
381 | 381 | |
382 | 382 | return (int)$last_day->format('d'); |
383 | 383 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | */ |
408 | 408 | public function next_no_exception() |
409 | 409 | { |
410 | - switch($this->type) |
|
410 | + switch ($this->type) |
|
411 | 411 | { |
412 | 412 | case self::NONE: // need to add at least one day, to end "series", as enddate == current date |
413 | 413 | case self::DAILY: |
@@ -422,28 +422,28 @@ discard block |
||
422 | 422 | // --> on the last day of the week we have to additionally advance interval-1 weeks |
423 | 423 | if ($this->interval > 1 && self::getWeekday($this->current) == $this->lastdayofweek) |
424 | 424 | { |
425 | - $this->current->modify(($this->interval-1).' week'); |
|
425 | + $this->current->modify(($this->interval - 1).' week'); |
|
426 | 426 | } |
427 | 427 | $this->current->modify('1 day'); |
428 | 428 | //echo __METHOD__.'() '.$this->current->format('l').', '.$this->current.": $this->weekdays & ".self::getWeekday($this->current)."<br />\n"; |
429 | 429 | } |
430 | - while(!($this->weekdays & self::getWeekday($this->current))); |
|
430 | + while (!($this->weekdays & self::getWeekday($this->current))); |
|
431 | 431 | break; |
432 | 432 | |
433 | 433 | case self::MONTHLY_WDAY: // iCal: BYDAY={1, ..., 5, -1}{MO..SO} |
434 | 434 | // advance to start of next month |
435 | - list($year,$month) = explode('-',$this->current->format('Y-m')); |
|
436 | - $month += $this->interval+($this->monthly_byday_num < 0 ? 1 : 0); |
|
437 | - $this->current->setDate($year,$month,$this->monthly_byday_num < 0 ? 0 : 1); |
|
435 | + list($year, $month) = explode('-', $this->current->format('Y-m')); |
|
436 | + $month += $this->interval + ($this->monthly_byday_num < 0 ? 1 : 0); |
|
437 | + $this->current->setDate($year, $month, $this->monthly_byday_num < 0 ? 0 : 1); |
|
438 | 438 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).": setDate($year,$month,1): ".$this->current->format('l').', '.$this->current."<br />\n"; |
439 | 439 | // now advance to n-th week |
440 | 440 | if ($this->monthly_byday_num > 1) |
441 | 441 | { |
442 | - $this->current->modify(($this->monthly_byday_num-1).' week'); |
|
442 | + $this->current->modify(($this->monthly_byday_num - 1).' week'); |
|
443 | 443 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify('.($this->monthly_byday_num-1).' week): '.$this->current->format('l').', '.$this->current."<br />\n"; |
444 | 444 | } |
445 | 445 | // advance to given weekday |
446 | - while(!($this->weekdays & self::getWeekday($this->current))) |
|
446 | + while (!($this->weekdays & self::getWeekday($this->current))) |
|
447 | 447 | { |
448 | 448 | $this->current->modify(($this->monthly_byday_num < 0 ? -1 : 1).' day'); |
449 | 449 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify(1 day): '.$this->current->format('l').', '.$this->current."<br />\n"; |
@@ -451,10 +451,10 @@ discard block |
||
451 | 451 | break; |
452 | 452 | |
453 | 453 | case self::MONTHLY_MDAY: // iCal: monthly_bymonthday={1, ..., 31, -1} |
454 | - list($year,$month) = explode('-',$this->current->format('Y-m')); |
|
455 | - $day = $this->monthly_bymonthday+($this->monthly_bymonthday < 0 ? 1 : 0); |
|
456 | - $month += $this->interval+($this->monthly_bymonthday < 0 ? 1 : 0); |
|
457 | - $this->current->setDate($year,$month,$day); |
|
454 | + list($year, $month) = explode('-', $this->current->format('Y-m')); |
|
455 | + $day = $this->monthly_bymonthday + ($this->monthly_bymonthday < 0 ? 1 : 0); |
|
456 | + $month += $this->interval + ($this->monthly_bymonthday < 0 ? 1 : 0); |
|
457 | + $this->current->setDate($year, $month, $day); |
|
458 | 458 | //echo __METHOD__."() setDate($year,$month,$day): ".$this->current->format('l').', '.$this->current."<br />\n"; |
459 | 459 | break; |
460 | 460 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | { |
485 | 485 | $this->next_no_exception(); |
486 | 486 | } |
487 | - while($this->exceptions && in_array($this->current->format('Ymd'),$this->exceptions)); |
|
487 | + while ($this->exceptions && in_array($this->current->format('Ymd'), $this->exceptions)); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | if (isset($this->current)) $backup = $this->current; |
517 | 517 | $this->rewind(); |
518 | 518 | |
519 | - while(--$count > 0) |
|
519 | + while (--$count > 0) |
|
520 | 520 | { |
521 | 521 | $this->next_no_exception(); |
522 | 522 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | // if enddate is now before next acurrence, but not on same day, we use previous recurrence |
542 | 542 | // this can happen if client gives an enddate which is NOT a recurrence date |
543 | 543 | // eg. for a on Monday recurring weekly event a Tuesday as enddate |
544 | - if ($this->enddate < $this->current && $this->current->format('Ymd') != $this->enddate->format('Ymd')) |
|
544 | + if ($this->enddate < $this->current && $this->current->format('Ymd') != $this->enddate->format('Ymd')) |
|
545 | 545 | { |
546 | 546 | $last = $previous; |
547 | 547 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | $this->current = clone $this->time; |
561 | 561 | while ($this->valid() && |
562 | 562 | $this->exceptions && |
563 | - in_array($this->current->format('Ymd'),$this->exceptions)) |
|
563 | + in_array($this->current->format('Ymd'), $this->exceptions)) |
|
564 | 564 | { |
565 | 565 | $this->next_no_exception(); |
566 | 566 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @param boolean $use_just_date =false default use also time |
573 | 573 | * @return boolean |
574 | 574 | */ |
575 | - public function valid($use_just_date=false) |
|
575 | + public function valid($use_just_date = false) |
|
576 | 576 | { |
577 | 577 | if ($use_just_date) |
578 | 578 | { |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | { |
591 | 591 | $str = ''; |
592 | 592 | // Repeated Events |
593 | - if($this->type != self::NONE) |
|
593 | + if ($this->type != self::NONE) |
|
594 | 594 | { |
595 | 595 | $str = lang(self::$types[$this->type]); |
596 | 596 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | { |
609 | 609 | $repeat_days[] = $this->type == self::WEEKLY ? lang('all') : lang('day'); |
610 | 610 | } |
611 | - elseif($this->weekdays == self::WORKDAYS) |
|
611 | + elseif ($this->weekdays == self::WORKDAYS) |
|
612 | 612 | { |
613 | 613 | $repeat_days[] = $this->type == self::WEEKLY ? lang('workdays') : lang('workday'); |
614 | 614 | } |
@@ -622,18 +622,18 @@ discard block |
||
622 | 622 | } |
623 | 623 | } |
624 | 624 | } |
625 | - if($this->type == self::WEEKLY && count($repeat_days)) |
|
625 | + if ($this->type == self::WEEKLY && count($repeat_days)) |
|
626 | 626 | { |
627 | - $str_extra[] = lang('days repeated').': '.implode(', ',$repeat_days); |
|
627 | + $str_extra[] = lang('days repeated').': '.implode(', ', $repeat_days); |
|
628 | 628 | } |
629 | - elseif($this->type == self::MONTHLY_WDAY) |
|
629 | + elseif ($this->type == self::MONTHLY_WDAY) |
|
630 | 630 | { |
631 | - $str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ',$repeat_days); |
|
631 | + $str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ', $repeat_days); |
|
632 | 632 | } |
633 | 633 | break; |
634 | 634 | |
635 | 635 | } |
636 | - if($this->interval > 1) |
|
636 | + if ($this->interval > 1) |
|
637 | 637 | { |
638 | 638 | $str_extra[] = lang('Interval').': '.$this->interval; |
639 | 639 | } |
@@ -649,9 +649,9 @@ discard block |
||
649 | 649 | { |
650 | 650 | $str_extra[] = $this->time->getTimezone()->getName(); |
651 | 651 | } |
652 | - if(count($str_extra)) |
|
652 | + if (count($str_extra)) |
|
653 | 653 | { |
654 | - $str .= ' ('.implode(', ',$str_extra).')'; |
|
654 | + $str .= ' ('.implode(', ', $str_extra).')'; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | return $str; |
@@ -663,16 +663,16 @@ discard block |
||
663 | 663 | * |
664 | 664 | * $return array vCalendar RRULE |
665 | 665 | */ |
666 | - public function generate_rrule($version='2.0') |
|
666 | + public function generate_rrule($version = '2.0') |
|
667 | 667 | { |
668 | 668 | $repeat_days = array(); |
669 | 669 | $rrule = array(); |
670 | 670 | |
671 | - if ($this->type == self::NONE) return false; // no recuring event |
|
671 | + if ($this->type == self::NONE) return false; // no recuring event |
|
672 | 672 | |
673 | 673 | if ($version == '1.0') |
674 | 674 | { |
675 | - $rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type] . $this->interval; |
|
675 | + $rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type].$this->interval; |
|
676 | 676 | switch ($this->type) |
677 | 677 | { |
678 | 678 | case self::WEEKLY: |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | { |
681 | 681 | if ($this->weekdays & $mask) |
682 | 682 | { |
683 | - $repeat_days[] = strtoupper(substr($label,0,2)); |
|
683 | + $repeat_days[] = strtoupper(substr($label, 0, 2)); |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | $rrule['BYDAY'] = implode(' ', $repeat_days); |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | case self::MONTHLY_WDAY: // weekday of the month: BDAY={1..5}+ {MO..SO} |
694 | 694 | $rrule['BYDAY'] = abs($this->monthly_byday_num); |
695 | 695 | $rrule['BYDAY'] .= ($this->monthly_byday_num < 0) ? '- ' : '+ '; |
696 | - $rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'),0,2)); |
|
696 | + $rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'), 0, 2)); |
|
697 | 697 | $rrule['FREQ'] = $rrule['FREQ'].' '.$rrule['BYDAY']; |
698 | 698 | break; |
699 | 699 | } |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | { |
714 | 714 | if ($this->weekdays & $mask) |
715 | 715 | { |
716 | - $repeat_days[] = strtoupper(substr($label,0,2)); |
|
716 | + $repeat_days[] = strtoupper(substr($label, 0, 2)); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | $rrule['BYDAY'] = implode(',', $repeat_days); |
@@ -724,8 +724,8 @@ discard block |
||
724 | 724 | break; |
725 | 725 | |
726 | 726 | case self::MONTHLY_WDAY: // weekday of the month: BDAY={1..5}{MO..SO} |
727 | - $rrule['BYDAY'] = $this->monthly_byday_num . |
|
728 | - strtoupper(substr($this->time->format('l'),0,2)); |
|
727 | + $rrule['BYDAY'] = $this->monthly_byday_num. |
|
728 | + strtoupper(substr($this->time->format('l'), 0, 2)); |
|
729 | 729 | break; |
730 | 730 | } |
731 | 731 | if ($this->interval > 1) |
@@ -760,12 +760,12 @@ discard block |
||
760 | 760 | * |
761 | 761 | * @return calendar_rrule false on error |
762 | 762 | */ |
763 | - public static function event2rrule(array $event,$usertime=true,$to_tz=null) |
|
763 | + public static function event2rrule(array $event, $usertime = true, $to_tz = null) |
|
764 | 764 | { |
765 | - if (!is_array($event) || !isset($event['tzid'])) return false; |
|
765 | + if (!is_array($event) || !isset($event['tzid'])) return false; |
|
766 | 766 | if (!$to_tz) $to_tz = $event['tzid']; |
767 | 767 | $timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone; |
768 | - $time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz); |
|
768 | + $time = is_a($event['start'], 'DateTime') ? $event['start'] : new Api\DateTime($event['start'], $timestamp_tz); |
|
769 | 769 | |
770 | 770 | if (!isset(self::$tz_cache[$to_tz])) |
771 | 771 | { |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | |
779 | 779 | if ($event['recur_enddate']) |
780 | 780 | { |
781 | - $enddate = is_a($event['recur_enddate'],'DateTime') ? clone $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],$timestamp_tz); |
|
781 | + $enddate = is_a($event['recur_enddate'], 'DateTime') ? clone $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], $timestamp_tz); |
|
782 | 782 | |
783 | 783 | // Check to see if switching timezones changes the date, we'll need to adjust for that |
784 | 784 | $enddate_event_timezone = clone $enddate; |
@@ -786,22 +786,22 @@ discard block |
||
786 | 786 | $delta = (int)$enddate_event_timezone->format('z') - (int)$enddate->format('z'); |
787 | 787 | $enddate->add("$delta days"); |
788 | 788 | |
789 | - $end = is_a($event['end'],'DateTime') ? clone $event['end'] : new Api\DateTime($event['end'],$timestamp_tz); |
|
789 | + $end = is_a($event['end'], 'DateTime') ? clone $event['end'] : new Api\DateTime($event['end'], $timestamp_tz); |
|
790 | 790 | $end->setTimezone($enddate->getTimezone()); |
791 | - $enddate->setTime($end->format('H'),$end->format('i'),0); |
|
792 | - if($event['whole_day']) |
|
791 | + $enddate->setTime($end->format('H'), $end->format('i'), 0); |
|
792 | + if ($event['whole_day']) |
|
793 | 793 | { |
794 | - $enddate->setTime(23,59,59); |
|
794 | + $enddate->setTime(23, 59, 59); |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | if (is_array($event['recur_exception'])) |
798 | 798 | { |
799 | - foreach($event['recur_exception'] as $exception) |
|
799 | + foreach ($event['recur_exception'] as $exception) |
|
800 | 800 | { |
801 | - $exceptions[] = is_a($exception,'DateTime') ? $exception : new Api\DateTime($exception,$timestamp_tz); |
|
801 | + $exceptions[] = is_a($exception, 'DateTime') ? $exception : new Api\DateTime($exception, $timestamp_tz); |
|
802 | 802 | } |
803 | 803 | } |
804 | - return new calendar_rrule($time,$event['recur_type'],$event['recur_interval'],$enddate,$event['recur_data'],$exceptions); |
|
804 | + return new calendar_rrule($time, $event['recur_type'], $event['recur_interval'], $enddate, $event['recur_data'], $exceptions); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $exceptions = array(); |
821 | 821 | |
822 | 822 | list($type, $sub, $conds) = explode(' (', $rrule); |
823 | - if(!$conds) |
|
823 | + if (!$conds) |
|
824 | 824 | { |
825 | 825 | $conds = $sub; |
826 | 826 | } |
@@ -830,10 +830,10 @@ discard block |
||
830 | 830 | } |
831 | 831 | $conditions = explode(', ', substr($conds, 0, -1)); |
832 | 832 | |
833 | - foreach(static::$types as $id => $type_name) |
|
833 | + foreach (static::$types as $id => $type_name) |
|
834 | 834 | { |
835 | 835 | $str = lang($type_name); |
836 | - if($str == $type) |
|
836 | + if ($str == $type) |
|
837 | 837 | { |
838 | 838 | $type_id = $id; |
839 | 839 | break; |
@@ -841,25 +841,25 @@ discard block |
||
841 | 841 | } |
842 | 842 | |
843 | 843 | // Rejoin some extra splits for conditions with multiple values |
844 | - foreach($conditions as $condition_index => $condition) |
|
844 | + foreach ($conditions as $condition_index => $condition) |
|
845 | 845 | { |
846 | - if(((int)$condition || strpos($condition, lang('last')) === 0) && |
|
847 | - substr_compare( $condition, lang('day'), -strlen( lang('day') ) ) === 0) |
|
846 | + if (((int)$condition || strpos($condition, lang('last')) === 0) && |
|
847 | + substr_compare($condition, lang('day'), -strlen(lang('day'))) === 0) |
|
848 | 848 | { |
849 | 849 | $time->setDate($time->format('Y'), $time->format('m'), (int)($condition) ? (int)$condition : $time->format('t')); |
850 | 850 | unset($conditions[$condition_index]); |
851 | 851 | continue; |
852 | 852 | } |
853 | - if(!strpos($condition, ':') && strpos($conditions[$condition_index-1], ':')) |
|
853 | + if (!strpos($condition, ':') && strpos($conditions[$condition_index - 1], ':')) |
|
854 | 854 | { |
855 | - $conditions[$condition_index-1] .= ', ' . $condition; |
|
855 | + $conditions[$condition_index - 1] .= ', '.$condition; |
|
856 | 856 | unset($conditions[$condition_index]); |
857 | 857 | } |
858 | 858 | } |
859 | - foreach($conditions as $condition_index => $condition) |
|
859 | + foreach ($conditions as $condition_index => $condition) |
|
860 | 860 | { |
861 | 861 | list($condition_name, $value) = explode(': ', $condition); |
862 | - if($condition_name == lang('days repeated')) |
|
862 | + if ($condition_name == lang('days repeated')) |
|
863 | 863 | { |
864 | 864 | foreach (self::$days as $mask => $label) |
865 | 865 | { |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | $weekdays += $mask; |
869 | 869 | } |
870 | 870 | } |
871 | - if(stripos($condition, lang('all')) !== false) |
|
871 | + if (stripos($condition, lang('all')) !== false) |
|
872 | 872 | { |
873 | 873 | $weekdays = self::ALLDAYS; |
874 | 874 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | } |
885 | 885 | } |
886 | 886 | |
887 | - return new calendar_rrule($time,$type_id,$interval,$enddate,$weekdays,$exceptions); |
|
887 | + return new calendar_rrule($time, $type_id, $interval, $enddate, $weekdays, $exceptions); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | * @param DateTime/string starttime of the event (in servertime) |
911 | 911 | * @param string $to_tz new timezone |
912 | 912 | */ |
913 | - public static function rrule2tz(array &$event,$starttime,$to_tz) |
|
913 | + public static function rrule2tz(array &$event, $starttime, $to_tz) |
|
914 | 914 | { |
915 | 915 | // We assume that the difference between timezones can result |
916 | 916 | // in a maximum of one day |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | self::$tz_cache[$to_tz] = calendar_timezones::DateTimeZone($to_tz); |
932 | 932 | } |
933 | 933 | |
934 | - $time = is_a($starttime,'DateTime') ? |
|
934 | + $time = is_a($starttime, 'DateTime') ? |
|
935 | 935 | $starttime : new Api\DateTime($starttime, Api\DateTime::$server_timezone); |
936 | 936 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
937 | 937 | $remote = clone $time; |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | if ($delta == 1 || $delta == -6) |
950 | 950 | { |
951 | 951 | $mask = $mask << 1; |
952 | - if ($mask & 128) $mask = $mask - 127; // overflow |
|
952 | + if ($mask&128) $mask = $mask - 127; // overflow |
|
953 | 953 | } |
954 | 954 | else |
955 | 955 | { |
956 | - if ($mask & 1) $mask = $mask + 128; // underflow |
|
956 | + if ($mask&1) $mask = $mask + 128; // underflow |
|
957 | 957 | $mask = $mask >> 1; |
958 | 958 | } |
959 | 959 | $event['recur_data'] = $mask; |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @return integer A unix timestamp. |
973 | 973 | */ |
974 | - private static function parseIcalDateTime($text, $tzid=null) |
|
974 | + private static function parseIcalDateTime($text, $tzid = null) |
|
975 | 975 | { |
976 | 976 | static $vcal = null; |
977 | 977 | if (!isset($vcal)) $vcal = new Horde_Icalendar; |
@@ -986,32 +986,32 @@ discard block |
||
986 | 986 | * @param bool $support_below_daily =false true: support FREQ=HOURLY|MINUTELY |
987 | 987 | * @return type |
988 | 988 | */ |
989 | - public static function parseRrule($recurence, $support_below_daily=false) |
|
989 | + public static function parseRrule($recurence, $support_below_daily = false) |
|
990 | 990 | { |
991 | 991 | $vcardData = array(); |
992 | 992 | $vcardData['recur_interval'] = 1; |
993 | 993 | $matches = null; |
994 | - $type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0]; |
|
994 | + $type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0]; |
|
995 | 995 | // vCard 2.0 values for all types |
996 | - if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches)) |
|
996 | + if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches)) |
|
997 | 997 | { |
998 | 998 | $vcardData['recur_enddate'] = self::parseIcalDateTime($matches[1]); |
999 | 999 | // If it couldn't be parsed, treat it as not set |
1000 | - if(is_string($vcardData['recur_enddate'])) |
|
1000 | + if (is_string($vcardData['recur_enddate'])) |
|
1001 | 1001 | { |
1002 | 1002 | unset($vcardData['recur_enddate']); |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | - elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches)) |
|
1005 | + elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches)) |
|
1006 | 1006 | { |
1007 | 1007 | $vcardData['recur_count'] = (int)$matches[1]; |
1008 | 1008 | } |
1009 | - if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches)) |
|
1009 | + if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches)) |
|
1010 | 1010 | { |
1011 | - $vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1; |
|
1011 | + $vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1; |
|
1012 | 1012 | } |
1013 | 1013 | $vcardData['recur_data'] = 0; |
1014 | - switch($type) |
|
1014 | + switch ($type) |
|
1015 | 1015 | { |
1016 | 1016 | case 'D': // 1.0 |
1017 | 1017 | $recurenceMatches = null; |
@@ -1035,20 +1035,20 @@ discard block |
||
1035 | 1035 | case 'W': |
1036 | 1036 | case 'WEEKLY': |
1037 | 1037 | $days = array(); |
1038 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
1038 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches)) // 1.0 |
|
1039 | 1039 | { |
1040 | 1040 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1041 | 1041 | if (empty($recurenceMatches[2])) |
1042 | 1042 | { |
1043 | - $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
|
1043 | + $days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2)); |
|
1044 | 1044 | } |
1045 | 1045 | else |
1046 | 1046 | { |
1047 | - $days = explode(' ',trim($recurenceMatches[2])); |
|
1047 | + $days = explode(' ', trim($recurenceMatches[2])); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | $repeatMatches = null; |
1051 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
|
1051 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches)) |
|
1052 | 1052 | { |
1053 | 1053 | if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
1054 | 1054 | } |
@@ -1057,20 +1057,20 @@ discard block |
||
1057 | 1057 | $vcardData['recur_enddate'] = self::parseIcalDateTime($recurenceMatches[4]); |
1058 | 1058 | } |
1059 | 1059 | } |
1060 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
1060 | + elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches)) // 2.0 |
|
1061 | 1061 | { |
1062 | - $days = explode(',',$recurenceMatches[1]); |
|
1062 | + $days = explode(',', $recurenceMatches[1]); |
|
1063 | 1063 | } |
1064 | 1064 | else // no day given, use the day of dtstart |
1065 | 1065 | { |
1066 | - $vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']); |
|
1066 | + $vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']); |
|
1067 | 1067 | $vcardData['recur_type'] = self::WEEKLY; |
1068 | 1068 | } |
1069 | 1069 | if ($days) |
1070 | 1070 | { |
1071 | 1071 | foreach (self::$days as $id => $day) |
1072 | 1072 | { |
1073 | - if (in_array(strtoupper(substr($day,0,2)),$days)) |
|
1073 | + if (in_array(strtoupper(substr($day, 0, 2)), $days)) |
|
1074 | 1074 | { |
1075 | 1075 | $vcardData['recur_data'] |= $id; |
1076 | 1076 | } |
@@ -1086,17 +1086,17 @@ discard block |
||
1086 | 1086 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1087 | 1087 | $vcardData['recur_count'] = $recurenceMatches[2]; |
1088 | 1088 | } |
1089 | - elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
1089 | + elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
1090 | 1090 | { |
1091 | 1091 | $vcardData['recur_type'] = self::MONTHLY_MDAY; |
1092 | 1092 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1093 | 1093 | $vcardData['recur_enddate'] = self::parseIcalDateTime($recurenceMatches[2]); |
1094 | 1094 | } |
1095 | - elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches)) |
|
1095 | + elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches)) |
|
1096 | 1096 | { |
1097 | 1097 | $vcardData['recur_type'] = self::MONTHLY_WDAY; |
1098 | 1098 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1099 | - if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches)) |
|
1099 | + if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches)) |
|
1100 | 1100 | { |
1101 | 1101 | $vcardData['recur_count'] = $recurenceMatches[1]; |
1102 | 1102 | } |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1114 | 1114 | $vcardData['recur_count'] = $recurenceMatches[2]; |
1115 | 1115 | } |
1116 | - elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches)) |
|
1116 | + elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches)) |
|
1117 | 1117 | { |
1118 | 1118 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1119 | 1119 | $vcardData['recur_enddate'] = self::parseIcalDateTime($recurenceMatches[2]); |
@@ -1127,11 +1127,11 @@ discard block |
||
1127 | 1127 | } |
1128 | 1128 | // handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL |
1129 | 1129 | $vcardData['recur_interval'] = $vcardData['recur_interval'] ? |
1130 | - 12*$vcardData['recur_interval'] : 12; |
|
1130 | + 12 * $vcardData['recur_interval'] : 12; |
|
1131 | 1131 | // fall-through |
1132 | 1132 | case 'MONTHLY': |
1133 | 1133 | // does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART |
1134 | - $vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ? |
|
1134 | + $vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ? |
|
1135 | 1135 | self::MONTHLY_WDAY : self::MONTHLY_MDAY; |
1136 | 1136 | break; |
1137 | 1137 | case 'HOURLY': |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
1149 | 1149 | { |
1150 | - ini_set('display_errors',1); |
|
1150 | + ini_set('display_errors', 1); |
|
1151 | 1151 | error_reporting(E_ALL & ~E_NOTICE); |
1152 | 1152 | function lang($str) { return $str; } |
1153 | 1153 | $GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin'; |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | |
1156 | 1156 | if (!isset($_REQUEST['time'])) |
1157 | 1157 | { |
1158 | - $now = new Api\DateTime('now',new DateTimeZone($_REQUEST['tz'] = 'UTC')); |
|
1158 | + $now = new Api\DateTime('now', new DateTimeZone($_REQUEST['tz'] = 'UTC')); |
|
1159 | 1159 | $_REQUEST['time'] = $now->format(); |
1160 | 1160 | $_REQUEST['type'] = calendar_rrule::WEEKLY; |
1161 | 1161 | $_REQUEST['interval'] = 2; |
@@ -1164,29 +1164,29 @@ discard block |
||
1164 | 1164 | $_REQUEST['user-tz'] = 'Europe/Berlin'; |
1165 | 1165 | } |
1166 | 1166 | echo "<html>\n<head>\n\t<title>Test calendar_rrule class</title>\n</head>\n<body>\n<form method='GET'>\n"; |
1167 | - echo "<p>Date+Time: ".Api\Html::input('time',$_REQUEST['time']). |
|
1168 | - Api\Html::select('tz',$_REQUEST['tz'],Api\DateTime::getTimezones())."</p>\n"; |
|
1169 | - echo "<p>Type: ".Api\Html::select('type',$_REQUEST['type'],calendar_rrule::$types)."\n". |
|
1170 | - "Interval: ".Api\Html::input('interval',$_REQUEST['interval'])."</p>\n"; |
|
1167 | + echo "<p>Date+Time: ".Api\Html::input('time', $_REQUEST['time']). |
|
1168 | + Api\Html::select('tz', $_REQUEST['tz'], Api\DateTime::getTimezones())."</p>\n"; |
|
1169 | + echo "<p>Type: ".Api\Html::select('type', $_REQUEST['type'], calendar_rrule::$types)."\n". |
|
1170 | + "Interval: ".Api\Html::input('interval', $_REQUEST['interval'])."</p>\n"; |
|
1171 | 1171 | echo "<table><tr><td>\n"; |
1172 | - echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays',$_REQUEST['weekdays'],calendar_rrule::$days,false,'','7',false,'height: 150px;')."\n"; |
|
1172 | + echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays', $_REQUEST['weekdays'], calendar_rrule::$days, false, '', '7', false, 'height: 150px;')."\n"; |
|
1173 | 1173 | echo "</td><td>\n"; |
1174 | - echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions',$_REQUEST['exceptions'],'style="height: 150px;"')."\n"; |
|
1174 | + echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions', $_REQUEST['exceptions'], 'style="height: 150px;"')."\n"; |
|
1175 | 1175 | echo "</td></tr></table>\n"; |
1176 | - echo "<p>Enddate: ".Api\Html::input('enddate',$_REQUEST['enddate'])."</p>\n"; |
|
1177 | - echo "<p>Display recurances in ".Api\Html::select('user-tz',$_REQUEST['user-tz'],Api\DateTime::getTimezones())."</p>\n"; |
|
1178 | - echo "<p>".Api\Html::submit_button('calc','Calculate')."</p>\n"; |
|
1176 | + echo "<p>Enddate: ".Api\Html::input('enddate', $_REQUEST['enddate'])."</p>\n"; |
|
1177 | + echo "<p>Display recurances in ".Api\Html::select('user-tz', $_REQUEST['user-tz'], Api\DateTime::getTimezones())."</p>\n"; |
|
1178 | + echo "<p>".Api\Html::submit_button('calc', 'Calculate')."</p>\n"; |
|
1179 | 1179 | echo "</form>\n"; |
1180 | 1180 | |
1181 | 1181 | $tz = new DateTimeZone($_REQUEST['tz']); |
1182 | - $time = new Api\DateTime($_REQUEST['time'],$tz); |
|
1183 | - if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
1184 | - $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
1185 | - if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
1182 | + $time = new Api\DateTime($_REQUEST['time'], $tz); |
|
1183 | + if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'], $tz); |
|
1184 | + $weekdays = 0; foreach ((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
1185 | + if ($_REQUEST['exceptions']) foreach (preg_split("/[,\r\n]+ ?/", $_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
1186 | 1186 | |
1187 | - $rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions); |
|
1187 | + $rrule = new calendar_rrule($time, $_REQUEST['type'], $_REQUEST['interval'], $enddate, $weekdays, $exceptions); |
|
1188 | 1188 | echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n"; |
1189 | - foreach($rrule as $rtime) |
|
1189 | + foreach ($rrule as $rtime) |
|
1190 | 1190 | { |
1191 | 1191 | $rtime->setTimezone(Api\DateTime::$user_timezone); |
1192 | 1192 | echo ++$n.': '.$rtime->format('l').', '.$rtime."<br />\n"; |
@@ -362,7 +362,10 @@ discard block |
||
362 | 362 | $duration = 366*24*3600; |
363 | 363 | break; |
364 | 364 | } |
365 | - if ($interval > 1) $duration *= $interval; |
|
365 | + if ($interval > 1) |
|
366 | + { |
|
367 | + $duration *= $interval; |
|
368 | + } |
|
366 | 369 | |
367 | 370 | return $duration; |
368 | 371 | } |
@@ -513,7 +516,10 @@ discard block |
||
513 | 516 | { |
514 | 517 | return clone $this->time; |
515 | 518 | } |
516 | - if (isset($this->current)) $backup = $this->current; |
|
519 | + if (isset($this->current)) |
|
520 | + { |
|
521 | + $backup = $this->current; |
|
522 | + } |
|
517 | 523 | $this->rewind(); |
518 | 524 | |
519 | 525 | while(--$count > 0) |
@@ -521,7 +527,10 @@ discard block |
||
521 | 527 | $this->next_no_exception(); |
522 | 528 | } |
523 | 529 | $ret = clone $this->current; |
524 | - if ($backup) $this->current = $backup; |
|
530 | + if ($backup) |
|
531 | + { |
|
532 | + $this->current = $backup; |
|
533 | + } |
|
525 | 534 | return $ret; |
526 | 535 | } |
527 | 536 | |
@@ -668,7 +677,11 @@ discard block |
||
668 | 677 | $repeat_days = array(); |
669 | 678 | $rrule = array(); |
670 | 679 | |
671 | - if ($this->type == self::NONE) return false; // no recuring event |
|
680 | + if ($this->type == self::NONE) |
|
681 | + { |
|
682 | + return false; |
|
683 | + } |
|
684 | + // no recuring event |
|
672 | 685 | |
673 | 686 | if ($version == '1.0') |
674 | 687 | { |
@@ -762,8 +775,14 @@ discard block |
||
762 | 775 | */ |
763 | 776 | public static function event2rrule(array $event,$usertime=true,$to_tz=null) |
764 | 777 | { |
765 | - if (!is_array($event) || !isset($event['tzid'])) return false; |
|
766 | - if (!$to_tz) $to_tz = $event['tzid']; |
|
778 | + if (!is_array($event) || !isset($event['tzid'])) |
|
779 | + { |
|
780 | + return false; |
|
781 | + } |
|
782 | + if (!$to_tz) |
|
783 | + { |
|
784 | + $to_tz = $event['tzid']; |
|
785 | + } |
|
767 | 786 | $timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone; |
768 | 787 | $time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz); |
769 | 788 | |
@@ -920,7 +939,10 @@ discard block |
||
920 | 939 | $event['recur_type'] == self::NONE || |
921 | 940 | empty($event['recur_data']) || $event['recur_data'] == self::ALLDAYS || |
922 | 941 | empty($event['tzid']) || empty($to_tz) || |
923 | - $event['tzid'] == $to_tz) return; |
|
942 | + $event['tzid'] == $to_tz) |
|
943 | + { |
|
944 | + return; |
|
945 | + } |
|
924 | 946 | |
925 | 947 | if (!isset(self::$tz_cache[$event['tzid']])) |
926 | 948 | { |
@@ -949,11 +971,19 @@ discard block |
||
949 | 971 | if ($delta == 1 || $delta == -6) |
950 | 972 | { |
951 | 973 | $mask = $mask << 1; |
952 | - if ($mask & 128) $mask = $mask - 127; // overflow |
|
974 | + if ($mask & 128) |
|
975 | + { |
|
976 | + $mask = $mask - 127; |
|
977 | + } |
|
978 | + // overflow |
|
953 | 979 | } |
954 | 980 | else |
955 | 981 | { |
956 | - if ($mask & 1) $mask = $mask + 128; // underflow |
|
982 | + if ($mask & 1) |
|
983 | + { |
|
984 | + $mask = $mask + 128; |
|
985 | + } |
|
986 | + // underflow |
|
957 | 987 | $mask = $mask >> 1; |
958 | 988 | } |
959 | 989 | $event['recur_data'] = $mask; |
@@ -974,7 +1004,10 @@ discard block |
||
974 | 1004 | private static function parseIcalDateTime($text, $tzid=null) |
975 | 1005 | { |
976 | 1006 | static $vcal = null; |
977 | - if (!isset($vcal)) $vcal = new Horde_Icalendar; |
|
1007 | + if (!isset($vcal)) |
|
1008 | + { |
|
1009 | + $vcal = new Horde_Icalendar; |
|
1010 | + } |
|
978 | 1011 | |
979 | 1012 | return $vcal->_parseDateTime($text, $tzid); |
980 | 1013 | } |
@@ -1025,19 +1058,27 @@ discard block |
||
1025 | 1058 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1026 | 1059 | $vcardData['recur_enddate'] = self::parseIcalDateTime(trim($recurenceMatches[2])); |
1027 | 1060 | } |
1028 | - else break; |
|
1061 | + else { |
|
1062 | + break; |
|
1063 | + } |
|
1029 | 1064 | // fall-through |
1030 | 1065 | case 'DAILY': // 2.0 |
1031 | 1066 | $vcardData['recur_type'] = self::DAILY; |
1032 | - if (stripos($recurence, 'BYDAY') === false) break; |
|
1067 | + if (stripos($recurence, 'BYDAY') === false) |
|
1068 | + { |
|
1069 | + break; |
|
1070 | + } |
|
1033 | 1071 | // hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval |
1034 | 1072 | // fall-through |
1035 | 1073 | case 'W': |
1036 | 1074 | case 'WEEKLY': |
1037 | 1075 | $days = array(); |
1038 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
1076 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) |
|
1077 | + { |
|
1078 | + // 1.0 |
|
1039 | 1079 | { |
1040 | 1080 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1081 | + } |
|
1041 | 1082 | if (empty($recurenceMatches[2])) |
1042 | 1083 | { |
1043 | 1084 | $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
@@ -1050,17 +1091,23 @@ discard block |
||
1050 | 1091 | $repeatMatches = null; |
1051 | 1092 | if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
1052 | 1093 | { |
1053 | - if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
|
1094 | + if ($repeatMatches[1]) |
|
1095 | + { |
|
1096 | + $vcardData['recur_count'] = $repeatMatches[1]; |
|
1097 | + } |
|
1054 | 1098 | } |
1055 | 1099 | else |
1056 | 1100 | { |
1057 | 1101 | $vcardData['recur_enddate'] = self::parseIcalDateTime($recurenceMatches[4]); |
1058 | 1102 | } |
1059 | 1103 | } |
1060 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
1104 | + elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) |
|
1105 | + { |
|
1106 | + // 2.0 |
|
1061 | 1107 | { |
1062 | 1108 | $days = explode(',',$recurenceMatches[1]); |
1063 | 1109 | } |
1110 | + } |
|
1064 | 1111 | else // no day given, use the day of dtstart |
1065 | 1112 | { |
1066 | 1113 | $vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']); |
@@ -1117,7 +1164,10 @@ discard block |
||
1117 | 1164 | { |
1118 | 1165 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
1119 | 1166 | $vcardData['recur_enddate'] = self::parseIcalDateTime($recurenceMatches[2]); |
1120 | - } else break; |
|
1167 | + } |
|
1168 | + else { |
|
1169 | + break; |
|
1170 | + } |
|
1121 | 1171 | // fall-through |
1122 | 1172 | case 'YEARLY': // 2.0 |
1123 | 1173 | if (strpos($recurence, 'BYDAY') === false) |
@@ -1135,21 +1185,32 @@ discard block |
||
1135 | 1185 | self::MONTHLY_WDAY : self::MONTHLY_MDAY; |
1136 | 1186 | break; |
1137 | 1187 | case 'HOURLY': |
1138 | - if ($support_below_daily) $vcardData['recur_type'] = self::HOURLY; |
|
1188 | + if ($support_below_daily) |
|
1189 | + { |
|
1190 | + $vcardData['recur_type'] = self::HOURLY; |
|
1191 | + } |
|
1139 | 1192 | break; |
1140 | 1193 | case 'MINUTELY': |
1141 | - if ($support_below_daily) $vcardData['recur_type'] = self::MINUTELY; |
|
1194 | + if ($support_below_daily) |
|
1195 | + { |
|
1196 | + $vcardData['recur_type'] = self::MINUTELY; |
|
1197 | + } |
|
1142 | 1198 | break; |
1143 | 1199 | } |
1144 | 1200 | return $vcardData; |
1145 | 1201 | } |
1146 | 1202 | } |
1147 | 1203 | |
1148 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
1204 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
1205 | +{ |
|
1206 | + // some tests |
|
1149 | 1207 | { |
1150 | 1208 | ini_set('display_errors',1); |
1209 | +} |
|
1151 | 1210 | error_reporting(E_ALL & ~E_NOTICE); |
1152 | - function lang($str) { return $str; } |
|
1211 | + function lang($str) |
|
1212 | + { |
|
1213 | +return $str; } |
|
1153 | 1214 | $GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin'; |
1154 | 1215 | require_once('../../api/src/autoload.php'); |
1155 | 1216 | |
@@ -1180,9 +1241,18 @@ discard block |
||
1180 | 1241 | |
1181 | 1242 | $tz = new DateTimeZone($_REQUEST['tz']); |
1182 | 1243 | $time = new Api\DateTime($_REQUEST['time'],$tz); |
1183 | - if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
1184 | - $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
1185 | - if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
1244 | + if ($_REQUEST['enddate']) |
|
1245 | + { |
|
1246 | + $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
1247 | + } |
|
1248 | + $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) |
|
1249 | + { |
|
1250 | +$weekdays |= $mask; } |
|
1251 | + if ($_REQUEST['exceptions']) |
|
1252 | + { |
|
1253 | + foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); |
|
1254 | + } |
|
1255 | + } |
|
1186 | 1256 | |
1187 | 1257 | $rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions); |
1188 | 1258 | echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n"; |