@@ -45,6 +45,7 @@ discard block |
||
45 | 45 | * This method is called when the stream is closed, using fclose(). |
46 | 46 | * |
47 | 47 | * You must release any resources that were locked or allocated by the stream. |
48 | + * @return boolean |
|
48 | 49 | */ |
49 | 50 | function stream_close ( ); |
50 | 51 | |
@@ -57,7 +58,7 @@ discard block |
||
57 | 58 | * You must also update the read/write position of the stream by the number of bytes that were successfully read. |
58 | 59 | * |
59 | 60 | * @param int $count |
60 | - * @return string/false up to count bytes read or false on EOF |
|
61 | + * @return string|false up to count bytes read or false on EOF |
|
61 | 62 | */ |
62 | 63 | function stream_read ( $count ); |
63 | 64 | |
@@ -114,7 +115,7 @@ discard block |
||
114 | 115 | * |
115 | 116 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
116 | 117 | * |
117 | - * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
118 | + * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
|
118 | 119 | */ |
119 | 120 | function stream_flush ( ); |
120 | 121 | |
@@ -188,7 +189,7 @@ discard block |
||
188 | 189 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
189 | 190 | * |
190 | 191 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
191 | - * @return booelan |
|
192 | + * @return boolean |
|
192 | 193 | */ |
193 | 194 | function dir_opendir ( $path, $options ); |
194 | 195 |
@@ -80,10 +80,10 @@ |
||
80 | 80 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
81 | 81 | * |
82 | 82 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
83 | - * { |
|
83 | + * { |
|
84 | 84 | * $eof = !$eof; |
85 | 85 | * } |
86 | - * |
|
86 | + * |
|
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | 89 | function stream_eof ( ); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
40 | 40 | * @return boolean true if the ressource was opened successful, otherwise false |
41 | 41 | */ |
42 | - function stream_open ( $path, $mode, $options, &$opened_path ); |
|
42 | + function stream_open($path, $mode, $options, &$opened_path); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * This method is called when the stream is closed, using fclose(). |
46 | 46 | * |
47 | 47 | * You must release any resources that were locked or allocated by the stream. |
48 | 48 | */ |
49 | - function stream_close ( ); |
|
49 | + function stream_close( ); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * This method is called in response to fread() and fgets() calls on the stream. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param int $count |
60 | 60 | * @return string/false up to count bytes read or false on EOF |
61 | 61 | */ |
62 | - function stream_read ( $count ); |
|
62 | + function stream_read($count); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * This method is called in response to fwrite() calls on the stream. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $data |
73 | 73 | * @return integer |
74 | 74 | */ |
75 | - function stream_write ( $data ); |
|
75 | + function stream_write($data); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * This method is called in response to feof() calls on the stream. |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | - function stream_eof ( ); |
|
89 | + function stream_eof( ); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * This method is called in response to ftell() calls on the stream. |
93 | 93 | * |
94 | 94 | * @return integer current read/write position of the stream |
95 | 95 | */ |
96 | - function stream_tell ( ); |
|
96 | + function stream_tell( ); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * This method is called in response to fseek() calls on the stream. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * SEEK_END - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
108 | 108 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
109 | 109 | */ |
110 | - function stream_seek ( $offset, $whence ); |
|
110 | + function stream_seek($offset, $whence); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * This method is called in response to fflush() calls on the stream. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
118 | 118 | */ |
119 | - function stream_flush ( ); |
|
119 | + function stream_flush( ); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * This method is called in response to fstat() calls on the stream. |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return array containing the same values as appropriate for the stream. |
134 | 134 | */ |
135 | - function stream_stat ( ); |
|
135 | + function stream_stat( ); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * This method is called in response to unlink() calls on URL paths associated with the wrapper. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $path |
144 | 144 | * @return boolean TRUE on success or FALSE on failure |
145 | 145 | */ |
146 | - static function unlink ( $path ); |
|
146 | + static function unlink($path); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * This method is called in response to rename() calls on URL paths associated with the wrapper. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $path_to |
158 | 158 | * @return boolean TRUE on success or FALSE on failure |
159 | 159 | */ |
160 | - static function rename ( $path_from, $path_to ); |
|
160 | + static function rename($path_from, $path_to); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * This method is called in response to mkdir() calls on URL paths associated with the wrapper. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
171 | 171 | * @return boolean TRUE on success or FALSE on failure |
172 | 172 | */ |
173 | - static function mkdir ( $path, $mode, $options ); |
|
173 | + static function mkdir($path, $mode, $options); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * This method is called in response to rmdir() calls on URL paths associated with the wrapper. |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
183 | 183 | * @return boolean TRUE on success or FALSE on failure. |
184 | 184 | */ |
185 | - static function rmdir ( $path, $options ); |
|
185 | + static function rmdir($path, $options); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
191 | 191 | * @return booelan |
192 | 192 | */ |
193 | - function dir_opendir ( $path, $options ); |
|
193 | + function dir_opendir($path, $options); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * This method is called in response to stat() calls on the URL paths associated with the wrapper. |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - static function url_stat ( $path, $flags ); |
|
221 | + static function url_stat($path, $flags); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * This method is called in response to readdir(). |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - function dir_readdir ( ); |
|
230 | + function dir_readdir( ); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * This method is called in response to rewinddir(). |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - function dir_rewinddir ( ); |
|
240 | + function dir_rewinddir( ); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * This method is called in response to closedir(). |
@@ -246,5 +246,5 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return boolean |
248 | 248 | */ |
249 | - function dir_closedir ( ); |
|
249 | + function dir_closedir( ); |
|
250 | 250 | } |
@@ -94,7 +94,6 @@ |
||
94 | 94 | /** |
95 | 95 | * imports entries according to given definition object. |
96 | 96 | * @param resource $_stream |
97 | - * @param string $_charset |
|
98 | 97 | * @param definition $_definition |
99 | 98 | */ |
100 | 99 | public function import( $_stream, definition $_definition ) { |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | private $user = null; |
83 | 83 | |
84 | 84 | /** |
85 | - * List of import errors |
|
86 | - */ |
|
87 | - protected $errors = array(); |
|
85 | + * List of import errors |
|
86 | + */ |
|
87 | + protected $errors = array(); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * List of actions, and how many times that action was taken |
@@ -305,26 +305,26 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Returns errors that were encountered during importing |
|
309 | - * Maximum of one error message per record, but you can append if you need to |
|
310 | - * |
|
311 | - * @return Array ( |
|
312 | - * record_# => error message |
|
313 | - * ) |
|
314 | - */ |
|
315 | - public function get_errors() { |
|
308 | + * Returns errors that were encountered during importing |
|
309 | + * Maximum of one error message per record, but you can append if you need to |
|
310 | + * |
|
311 | + * @return Array ( |
|
312 | + * record_# => error message |
|
313 | + * ) |
|
314 | + */ |
|
315 | + public function get_errors() { |
|
316 | 316 | return $this->errors; |
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Returns a list of actions taken, and the number of records for that action. |
|
321 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
322 | - * |
|
323 | - * @return Array ( |
|
324 | - * action => record count |
|
325 | - * ) |
|
326 | - */ |
|
327 | - public function get_results() { |
|
320 | + * Returns a list of actions taken, and the number of records for that action. |
|
321 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
322 | + * |
|
323 | + * @return Array ( |
|
324 | + * action => record count |
|
325 | + * ) |
|
326 | + */ |
|
327 | + public function get_results() { |
|
328 | 328 | return $this->results; |
329 | 329 | } |
330 | 330 | } // end of iface_export_plugin |
@@ -10,28 +10,28 @@ discard block |
||
10 | 10 | * @version $Id: $ |
11 | 11 | */ |
12 | 12 | |
13 | -require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php'); |
|
13 | +require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php'); |
|
14 | 14 | require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php'); |
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * class import_csv for addressbook |
19 | 19 | */ |
20 | -class import_events_csv implements iface_import_plugin { |
|
20 | +class import_events_csv implements iface_import_plugin { |
|
21 | 21 | |
22 | 22 | private static $plugin_options = array( |
23 | - 'fieldsep', // char |
|
24 | - 'charset', // string |
|
25 | - 'event_owner', // int account_id or -1 for leave untuched |
|
26 | - 'owner_joins_event', // bool |
|
27 | - 'update_cats', // string {override|add} overides record |
|
23 | + 'fieldsep', // char |
|
24 | + 'charset', // string |
|
25 | + 'event_owner', // int account_id or -1 for leave untuched |
|
26 | + 'owner_joins_event', // bool |
|
27 | + 'update_cats', // string {override|add} overides record |
|
28 | 28 | // with cat(s) from csv OR add the cat from |
29 | 29 | // csv file to exeisting cat(s) of record |
30 | - 'num_header_lines', // int number of header lines |
|
31 | - 'trash_users_records', // trashes all events of events owner before import |
|
32 | - 'field_conversion', // array( $csv_col_num => conversion) |
|
33 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
34 | - 'conditions', /* => array containing condition arrays: |
|
30 | + 'num_header_lines', // int number of header lines |
|
31 | + 'trash_users_records', // trashes all events of events owner before import |
|
32 | + 'field_conversion', // array( $csv_col_num => conversion) |
|
33 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
34 | + 'conditions', /* => array containing condition arrays: |
|
35 | 35 | 'type' => exists, // record['uid'] exists |
36 | 36 | 'true' => array( |
37 | 37 | 'action' => update, |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * actions wich could be done to data entries |
49 | 49 | */ |
50 | - private static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
50 | + private static $actions = array('none', 'update', 'insert', 'delete',); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * conditions for actions |
54 | 54 | * |
55 | 55 | * @var array |
56 | 56 | */ |
57 | - private static $conditions = array( 'exists', 'empty', ); |
|
57 | + private static $conditions = array('exists', 'empty',); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @var definition |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param string $_charset |
98 | 98 | * @param definition $_definition |
99 | 99 | */ |
100 | - public function import( $_stream, definition $_definition ) { |
|
101 | - $import_csv = new import_csv( $_stream, array( |
|
100 | + public function import($_stream, definition $_definition) { |
|
101 | + $import_csv = new import_csv($_stream, array( |
|
102 | 102 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
103 | 103 | 'charset' => $_definition->plugin_options['charset'], |
104 | 104 | )); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $this->definition = $_definition; |
107 | 107 | |
108 | 108 | // user, is admin ? |
109 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
109 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
110 | 110 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
111 | 111 | |
112 | 112 | // dry run? |
113 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
113 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
114 | 114 | |
115 | 115 | // fetch the calendar bo |
116 | 116 | $this->bocalupdate = new calendar_boupdate(); |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
123 | 123 | |
124 | 124 | //check if file has a header lines |
125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
126 | - $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
|
125 | + if (isset($_definition->plugin_options['num_header_lines'])) { |
|
126 | + $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // set eventOwner |
130 | - $_definition->plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ? |
|
130 | + $_definition->plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ? |
|
131 | 131 | $_definition->plugin_options['events_owner'] : $this->user; |
132 | 132 | |
133 | 133 | // trash_users_records ? |
134 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
135 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
134 | + if ($_definition->plugin_options['trash_users_records'] === true) { |
|
135 | + if (!$_definition->plugin_options['dry_run']) { |
|
136 | 136 | $socal = new calendar_socal(); |
137 | - $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
|
138 | - unset( $socal ); |
|
137 | + $this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']); |
|
138 | + unset($socal); |
|
139 | 139 | } else { |
140 | - $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
|
140 | + $lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']); |
|
141 | 141 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
142 | 142 | } |
143 | 143 | } |
@@ -145,44 +145,44 @@ discard block |
||
145 | 145 | $this->errors = array(); |
146 | 146 | $this->results = array(); |
147 | 147 | |
148 | - while ( $record = $import_csv->get_record() ) { |
|
148 | + while ($record = $import_csv->get_record()) { |
|
149 | 149 | |
150 | 150 | // don't import empty events |
151 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
151 | + if (count(array_unique($record)) < 2) continue; |
|
152 | 152 | |
153 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
153 | + if ($_definition->plugin_options['events_owner'] != -1) { |
|
154 | 154 | $record['owner'] = $_definition->plugin_options['events_owner']; |
155 | - } else unset( $record['owner'] ); |
|
155 | + } else unset($record['owner']); |
|
156 | 156 | |
157 | - if ( $_definition->plugin_options['conditions'] ) { |
|
158 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
159 | - switch ( $condition['type'] ) { |
|
157 | + if ($_definition->plugin_options['conditions']) { |
|
158 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
159 | + switch ($condition['type']) { |
|
160 | 160 | // exists |
161 | 161 | case 'exists' : |
162 | 162 | |
163 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
163 | + if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) { |
|
164 | 164 | // apply action to event matching this exists condition |
165 | 165 | $record['id'] = $event['id']; |
166 | 166 | |
167 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
168 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
169 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
170 | - $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
|
167 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
168 | + if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']); |
|
169 | + if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']); |
|
170 | + $record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id']))); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // check if entry is modiefied |
174 | - $event = array_intersect_key( $event, $record ); |
|
175 | - $diff = array_diff( $event, $record ); |
|
176 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
174 | + $event = array_intersect_key($event, $record); |
|
175 | + $diff = array_diff($event, $record); |
|
176 | + if (!empty($diff)) $record['modified'] = time(); |
|
177 | 177 | |
178 | 178 | $action = $condition['true']; |
179 | 179 | } else $action = $condition['false']; |
180 | 180 | |
181 | - $this->action( $action['action'], $record ); |
|
181 | + $this->action($action['action'], $record); |
|
182 | 182 | break; |
183 | 183 | case 'empty' : |
184 | - $action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false']; |
|
185 | - $this->action( $action['action'], $record ); |
|
184 | + $action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false']; |
|
185 | + $this->action($action['action'], $record); |
|
186 | 186 | break; |
187 | 187 | |
188 | 188 | // not supported action |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | // unconditional insert |
197 | - $this->action( 'insert', $record ); |
|
197 | + $this->action('insert', $record); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @param array $_data event data for the action |
207 | 207 | * @return bool success or not |
208 | 208 | */ |
209 | - private function action ( $_action, $_data ) { |
|
210 | - switch ( $_action ) { |
|
209 | + private function action($_action, $_data) { |
|
210 | + switch ($_action) { |
|
211 | 211 | case 'none' : |
212 | 212 | return true; |
213 | 213 | |
@@ -215,32 +215,32 @@ discard block |
||
215 | 215 | case 'insert' : |
216 | 216 | |
217 | 217 | // paticipants handling |
218 | - $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
|
218 | + $participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array(); |
|
219 | 219 | $_data['participants'] = array(); |
220 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
220 | + if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) { |
|
221 | 221 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
222 | 222 | } |
223 | - foreach( $participants as $participant ) { |
|
224 | - list( $participant, $status ) = explode( '=', $participant ); |
|
225 | - $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
|
226 | - $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
|
227 | - if ( $participant && is_numeric($participant ) ) { |
|
223 | + foreach ($participants as $participant) { |
|
224 | + list($participant, $status) = explode('=', $participant); |
|
225 | + $valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T'); |
|
226 | + $status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U'; |
|
227 | + if ($participant && is_numeric($participant)) { |
|
228 | 228 | $_data['participants'][$participant] = $status; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | // no valid participants so far --> add the importing user/owner |
232 | - if ( empty( $_data['participants'] ) ) { |
|
232 | + if (empty($_data['participants'])) { |
|
233 | 233 | $_data['participants'][$this->user] = 'A'; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // are we serious? |
237 | - if ( $this->dry_run ) { |
|
237 | + if ($this->dry_run) { |
|
238 | 238 | print_r($_data); |
239 | 239 | $this->results[$_action]++; |
240 | 240 | } else { |
241 | 241 | $messages = array(); |
242 | - $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
243 | - if(!$result) { |
|
242 | + $result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
|
243 | + if (!$result) { |
|
244 | 244 | $this->errors = implode(',', $messages); |
245 | 245 | } else { |
246 | 246 | $this->results[$_action]++; |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for addressbook |
19 | 19 | */ |
20 | -class import_events_csv implements iface_import_plugin { |
|
20 | +class import_events_csv implements iface_import_plugin |
|
21 | +{ |
|
21 | 22 | |
22 | 23 | private static $plugin_options = array( |
23 | 24 | 'fieldsep', // char |
@@ -97,7 +98,8 @@ discard block |
||
97 | 98 | * @param string $_charset |
98 | 99 | * @param definition $_definition |
99 | 100 | */ |
100 | - public function import( $_stream, definition $_definition ) { |
|
101 | + public function import( $_stream, definition $_definition ) |
|
102 | + { |
|
101 | 103 | $import_csv = new import_csv( $_stream, array( |
102 | 104 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
103 | 105 | 'charset' => $_definition->plugin_options['charset'], |
@@ -122,7 +124,8 @@ discard block |
||
122 | 124 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
123 | 125 | |
124 | 126 | //check if file has a header lines |
125 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) ) { |
|
127 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) ) |
|
128 | + { |
|
126 | 129 | $import_csv->skip_records( $_definition->plugin_options['num_header_lines'] ); |
127 | 130 | } |
128 | 131 | |
@@ -131,12 +134,16 @@ discard block |
||
131 | 134 | $_definition->plugin_options['events_owner'] : $this->user; |
132 | 135 | |
133 | 136 | // trash_users_records ? |
134 | - if ( $_definition->plugin_options['trash_users_records'] === true ) { |
|
135 | - if ( !$_definition->plugin_options['dry_run'] ) { |
|
137 | + if ( $_definition->plugin_options['trash_users_records'] === true ) |
|
138 | + { |
|
139 | + if ( !$_definition->plugin_options['dry_run'] ) |
|
140 | + { |
|
136 | 141 | $socal = new calendar_socal(); |
137 | 142 | $this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']); |
138 | 143 | unset( $socal ); |
139 | - } else { |
|
144 | + } |
|
145 | + else |
|
146 | + { |
|
140 | 147 | $lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] ); |
141 | 148 | echo "Attension: All Events of '$lid' would be deleted!\n"; |
142 | 149 | } |
@@ -145,38 +152,63 @@ discard block |
||
145 | 152 | $this->errors = array(); |
146 | 153 | $this->results = array(); |
147 | 154 | |
148 | - while ( $record = $import_csv->get_record() ) { |
|
155 | + while ( $record = $import_csv->get_record() ) |
|
156 | + { |
|
149 | 157 | |
150 | 158 | // don't import empty events |
151 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
159 | + if( count( array_unique( $record ) ) < 2 ) |
|
160 | + { |
|
161 | + continue; |
|
162 | + } |
|
152 | 163 | |
153 | - if ( $_definition->plugin_options['events_owner'] != -1 ) { |
|
164 | + if ( $_definition->plugin_options['events_owner'] != -1 ) |
|
165 | + { |
|
154 | 166 | $record['owner'] = $_definition->plugin_options['events_owner']; |
155 | - } else unset( $record['owner'] ); |
|
167 | + } |
|
168 | + else { |
|
169 | + unset( $record['owner'] ); |
|
170 | + } |
|
156 | 171 | |
157 | - if ( $_definition->plugin_options['conditions'] ) { |
|
158 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
159 | - switch ( $condition['type'] ) { |
|
172 | + if ( $_definition->plugin_options['conditions'] ) |
|
173 | + { |
|
174 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
175 | + { |
|
176 | + switch ( $condition['type'] ) |
|
177 | + { |
|
160 | 178 | // exists |
161 | 179 | case 'exists' : |
162 | 180 | |
163 | - if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) { |
|
181 | + if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) |
|
182 | + { |
|
164 | 183 | // apply action to event matching this exists condition |
165 | 184 | $record['id'] = $event['id']; |
166 | 185 | |
167 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
168 | - if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
169 | - if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
186 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
187 | + { |
|
188 | + if ( !is_array( $event['cat_id'] ) ) |
|
189 | + { |
|
190 | + $event['cat_id'] = explode( ',', $event['cat_id'] ); |
|
191 | + } |
|
192 | + if ( !is_array( $record['cat_id'] ) ) |
|
193 | + { |
|
194 | + $record['cat_id'] = explode( ',', $record['cat_id'] ); |
|
195 | + } |
|
170 | 196 | $record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) ); |
171 | 197 | } |
172 | 198 | |
173 | 199 | // check if entry is modiefied |
174 | 200 | $event = array_intersect_key( $event, $record ); |
175 | 201 | $diff = array_diff( $event, $record ); |
176 | - if( !empty( $diff ) ) $record['modified'] = time(); |
|
202 | + if( !empty( $diff ) ) |
|
203 | + { |
|
204 | + $record['modified'] = time(); |
|
205 | + } |
|
177 | 206 | |
178 | 207 | $action = $condition['true']; |
179 | - } else $action = $condition['false']; |
|
208 | + } |
|
209 | + else { |
|
210 | + $action = $condition['false']; |
|
211 | + } |
|
180 | 212 | |
181 | 213 | $this->action( $action['action'], $record ); |
182 | 214 | break; |
@@ -190,9 +222,14 @@ discard block |
||
190 | 222 | throw new Exception('condition not supported!!!'); |
191 | 223 | break; |
192 | 224 | } |
193 | - if ($action['last']) break; |
|
225 | + if ($action['last']) |
|
226 | + { |
|
227 | + break; |
|
228 | + } |
|
194 | 229 | } |
195 | - } else { |
|
230 | + } |
|
231 | + else |
|
232 | + { |
|
196 | 233 | // unconditional insert |
197 | 234 | $this->action( 'insert', $record ); |
198 | 235 | } |
@@ -206,8 +243,10 @@ discard block |
||
206 | 243 | * @param array $_data event data for the action |
207 | 244 | * @return bool success or not |
208 | 245 | */ |
209 | - private function action ( $_action, $_data ) { |
|
210 | - switch ( $_action ) { |
|
246 | + private function action ( $_action, $_data ) |
|
247 | + { |
|
248 | + switch ( $_action ) |
|
249 | + { |
|
211 | 250 | case 'none' : |
212 | 251 | return true; |
213 | 252 | |
@@ -217,32 +256,42 @@ discard block |
||
217 | 256 | // paticipants handling |
218 | 257 | $participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array(); |
219 | 258 | $_data['participants'] = array(); |
220 | - if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) { |
|
259 | + if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) |
|
260 | + { |
|
221 | 261 | $_data['participants'][$this->definition->plugin_options['events_owner']] = 'A'; |
222 | 262 | } |
223 | - foreach( $participants as $participant ) { |
|
263 | + foreach( $participants as $participant ) |
|
264 | + { |
|
224 | 265 | list( $participant, $status ) = explode( '=', $participant ); |
225 | 266 | $valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T'); |
226 | 267 | $status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U'; |
227 | - if ( $participant && is_numeric($participant ) ) { |
|
268 | + if ( $participant && is_numeric($participant ) ) |
|
269 | + { |
|
228 | 270 | $_data['participants'][$participant] = $status; |
229 | 271 | } |
230 | 272 | } |
231 | 273 | // no valid participants so far --> add the importing user/owner |
232 | - if ( empty( $_data['participants'] ) ) { |
|
274 | + if ( empty( $_data['participants'] ) ) |
|
275 | + { |
|
233 | 276 | $_data['participants'][$this->user] = 'A'; |
234 | 277 | } |
235 | 278 | |
236 | 279 | // are we serious? |
237 | - if ( $this->dry_run ) { |
|
280 | + if ( $this->dry_run ) |
|
281 | + { |
|
238 | 282 | print_r($_data); |
239 | 283 | $this->results[$_action]++; |
240 | - } else { |
|
284 | + } |
|
285 | + else |
|
286 | + { |
|
241 | 287 | $messages = array(); |
242 | 288 | $result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages); |
243 | - if(!$result) { |
|
289 | + if(!$result) |
|
290 | + { |
|
244 | 291 | $this->errors = implode(',', $messages); |
245 | - } else { |
|
292 | + } |
|
293 | + else |
|
294 | + { |
|
246 | 295 | $this->results[$_action]++; |
247 | 296 | } |
248 | 297 | return $result; |
@@ -257,7 +306,8 @@ discard block |
||
257 | 306 | * |
258 | 307 | * @return string name |
259 | 308 | */ |
260 | - public static function get_name() { |
|
309 | + public static function get_name() |
|
310 | + { |
|
261 | 311 | return lang('Calendar CSV export'); |
262 | 312 | } |
263 | 313 | |
@@ -266,7 +316,8 @@ discard block |
||
266 | 316 | * |
267 | 317 | * @return string descriprion |
268 | 318 | */ |
269 | - public static function get_description() { |
|
319 | + public static function get_description() |
|
320 | + { |
|
270 | 321 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
271 | 322 | } |
272 | 323 | |
@@ -275,7 +326,8 @@ discard block |
||
275 | 326 | * |
276 | 327 | * @return string suffix (comma seperated) |
277 | 328 | */ |
278 | - public static function get_filesuffix() { |
|
329 | + public static function get_filesuffix() |
|
330 | + { |
|
279 | 331 | return 'csv'; |
280 | 332 | } |
281 | 333 | |
@@ -291,7 +343,8 @@ discard block |
||
291 | 343 | * preserv => array, |
292 | 344 | * ) |
293 | 345 | */ |
294 | - public function get_options_etpl() { |
|
346 | + public function get_options_etpl() |
|
347 | + { |
|
295 | 348 | // lets do it! |
296 | 349 | } |
297 | 350 | |
@@ -300,7 +353,8 @@ discard block |
||
300 | 353 | * |
301 | 354 | * @return string etemplate name |
302 | 355 | */ |
303 | - public function get_selectors_etpl() { |
|
356 | + public function get_selectors_etpl() |
|
357 | + { |
|
304 | 358 | // lets do it! |
305 | 359 | } |
306 | 360 | |
@@ -312,7 +366,8 @@ discard block |
||
312 | 366 | * record_# => error message |
313 | 367 | * ) |
314 | 368 | */ |
315 | - public function get_errors() { |
|
369 | + public function get_errors() |
|
370 | + { |
|
316 | 371 | return $this->errors; |
317 | 372 | } |
318 | 373 | |
@@ -324,7 +379,8 @@ discard block |
||
324 | 379 | * action => record count |
325 | 380 | * ) |
326 | 381 | */ |
327 | - public function get_results() { |
|
382 | + public function get_results() |
|
383 | + { |
|
328 | 384 | return $this->results; |
329 | 385 | } |
330 | 386 | } // end of iface_export_plugin |
@@ -519,6 +519,7 @@ discard block |
||
519 | 519 | * @param array $new_event Event after the change |
520 | 520 | * @param string $role we treat CHAIR like event owners |
521 | 521 | * @param string $status of current user |
522 | + * @param integer $msg_type |
|
522 | 523 | * @return boolean true = update requested, false otherwise |
523 | 524 | */ |
524 | 525 | public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
@@ -594,7 +595,7 @@ discard block |
||
594 | 595 | /** |
595 | 596 | * Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified |
596 | 597 | * |
597 | - * @param int|string $user_or_email |
|
598 | + * @param string $user_or_email |
|
598 | 599 | * @param string $ical_method ='REQUEST' |
599 | 600 | * @param string $role ='REQ-PARTICIPANT' |
600 | 601 | * @return boolean true if user requested to be notified, false if not |
@@ -645,8 +646,7 @@ discard block |
||
645 | 646 | * Get iCal/iMip method from internal nummeric msg-type plus optional notification message and verbose name |
646 | 647 | * |
647 | 648 | * @param int $msg_type see MSG_* defines |
648 | - * @param string& $action=null on return verbose name |
|
649 | - * @param string& $msg=null on return notification message |
|
649 | + * @param string& $action on return verbose name |
|
650 | 650 | */ |
651 | 651 | function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
652 | 652 | { |
@@ -1011,6 +1011,9 @@ discard block |
||
1011 | 1011 | return true; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | + /** |
|
1015 | + * @param integer $added |
|
1016 | + */ |
|
1014 | 1017 | function get_update_message($event,$added) |
1015 | 1018 | { |
1016 | 1019 | $nul = null; |
@@ -1300,8 +1303,8 @@ discard block |
||
1300 | 1303 | * |
1301 | 1304 | * @param int $right self::CAT_ACL_{ADD|STATUS} |
1302 | 1305 | * @param int|array $event |
1303 | - * @return boolean true if use has the right, false if not |
|
1304 | - * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
1306 | + * @return null|boolean true if use has the right, false if not |
|
1307 | + * @return null|boolean false=access denied because of cat acl, true access granted because of cat acl, |
|
1305 | 1308 | * null = cat has no acl |
1306 | 1309 | */ |
1307 | 1310 | function check_cat_acl($right,$event) |
@@ -1386,6 +1389,8 @@ discard block |
||
1386 | 1389 | * Check if current user has a given right on a category (if it's restricted!) |
1387 | 1390 | * |
1388 | 1391 | * @param int $cat_id |
1392 | + * @param integer $right |
|
1393 | + * @param integer $user |
|
1389 | 1394 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1390 | 1395 | * null = cat has no acl |
1391 | 1396 | */ |
@@ -1647,7 +1652,7 @@ discard block |
||
1647 | 1652 | * @param string $action |
1648 | 1653 | * @param array $event_arr |
1649 | 1654 | * @param array $disinvited |
1650 | - * @return array |
|
1655 | + * @return string |
|
1651 | 1656 | */ |
1652 | 1657 | function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
1653 | 1658 | { |
@@ -1504,22 +1504,22 @@ discard block |
||
1504 | 1504 | // check the old list against the new list |
1505 | 1505 | foreach ($old_event['participants'] as $userid => $status) |
1506 | 1506 | { |
1507 | - if (!isset($new_event['participants'][$userid])){ |
|
1508 | - // Attendee will be deleted this way |
|
1509 | - $new_event['participants'][$userid] = 'G'; |
|
1510 | - } |
|
1511 | - elseif ($new_event['participants'][$userid] == $status) |
|
1512 | - { |
|
1513 | - // Same status -- nothing to do. |
|
1514 | - unset($new_event['participants'][$userid]); |
|
1515 | - } |
|
1507 | + if (!isset($new_event['participants'][$userid])){ |
|
1508 | + // Attendee will be deleted this way |
|
1509 | + $new_event['participants'][$userid] = 'G'; |
|
1510 | + } |
|
1511 | + elseif ($new_event['participants'][$userid] == $status) |
|
1512 | + { |
|
1513 | + // Same status -- nothing to do. |
|
1514 | + unset($new_event['participants'][$userid]); |
|
1515 | + } |
|
1516 | 1516 | } |
1517 | 1517 | // write the changes |
1518 | 1518 | foreach ($new_event['participants'] as $userid => $status) |
1519 | 1519 | { |
1520 | 1520 | $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
1521 | 1521 | } |
1522 | - } |
|
1522 | + } |
|
1523 | 1523 | |
1524 | 1524 | /** |
1525 | 1525 | * deletes an event |
@@ -2493,24 +2493,24 @@ discard block |
||
2493 | 2493 | /** |
2494 | 2494 | * classifies an incoming event from the eGW point-of-view |
2495 | 2495 | * |
2496 | - * exceptions: unlike other calendar apps eGW does not create an event exception |
|
2497 | - * if just the participant state changes - therefore we have to distinguish between |
|
2498 | - * real exceptions and status only exceptions |
|
2499 | - * |
|
2500 | - * @param array $event the event to check |
|
2501 | - * |
|
2502 | - * @return array |
|
2503 | - * type => |
|
2504 | - * SINGLE a single event |
|
2505 | - * SERIES-MASTER the series master |
|
2506 | - * SERIES-EXCEPTION event is a real exception |
|
2507 | - * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
2508 | - * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
2509 | - * stored_event => if event already exists in the database array with event data or false |
|
2510 | - * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
2511 | - * the corresponding series master event array |
|
2512 | - * NOTE: this param is false if event is of type SERIES-MASTER |
|
2513 | - */ |
|
2496 | + * exceptions: unlike other calendar apps eGW does not create an event exception |
|
2497 | + * if just the participant state changes - therefore we have to distinguish between |
|
2498 | + * real exceptions and status only exceptions |
|
2499 | + * |
|
2500 | + * @param array $event the event to check |
|
2501 | + * |
|
2502 | + * @return array |
|
2503 | + * type => |
|
2504 | + * SINGLE a single event |
|
2505 | + * SERIES-MASTER the series master |
|
2506 | + * SERIES-EXCEPTION event is a real exception |
|
2507 | + * SERIES-PSEUDO-EXCEPTION event is a status only exception |
|
2508 | + * SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception |
|
2509 | + * stored_event => if event already exists in the database array with event data or false |
|
2510 | + * master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE |
|
2511 | + * the corresponding series master event array |
|
2512 | + * NOTE: this param is false if event is of type SERIES-MASTER |
|
2513 | + */ |
|
2514 | 2514 | function get_event_info($event) |
2515 | 2515 | { |
2516 | 2516 | $type = 'SINGLE'; // default |
@@ -2681,16 +2681,16 @@ discard block |
||
2681 | 2681 | 'stored_event' => $stored_event, |
2682 | 2682 | 'master_event' => $master_event, |
2683 | 2683 | ); |
2684 | - } |
|
2685 | - |
|
2686 | - /** |
|
2687 | - * Translates all timestamps for a given event from server-time to user-time. |
|
2688 | - * The update() and save() methods expect timestamps in user-time. |
|
2689 | - * @param &$event the event we are working on |
|
2690 | - * |
|
2691 | - */ |
|
2692 | - function server2usertime (&$event) |
|
2693 | - { |
|
2684 | + } |
|
2685 | + |
|
2686 | + /** |
|
2687 | + * Translates all timestamps for a given event from server-time to user-time. |
|
2688 | + * The update() and save() methods expect timestamps in user-time. |
|
2689 | + * @param &$event the event we are working on |
|
2690 | + * |
|
2691 | + */ |
|
2692 | + function server2usertime (&$event) |
|
2693 | + { |
|
2694 | 2694 | // we run all dates through date2usertime, to adjust to user-time |
2695 | 2695 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
2696 | 2696 | { |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
2714 | 2714 | } |
2715 | 2715 | } |
2716 | - } |
|
2716 | + } |
|
2717 | 2717 | /** |
2718 | 2718 | * Delete events that are more than $age years old |
2719 | 2719 | * |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // types of messsages send by calendar_boupdate::send_update |
15 | -define('MSG_DELETED',0); |
|
16 | -define('MSG_MODIFIED',1); |
|
17 | -define('MSG_ADDED',2); |
|
18 | -define('MSG_REJECTED',3); |
|
19 | -define('MSG_TENTATIVE',4); |
|
20 | -define('MSG_ACCEPTED',5); |
|
21 | -define('MSG_ALARM',6); |
|
22 | -define('MSG_DISINVITE',7); |
|
23 | -define('MSG_DELEGATED',8); |
|
15 | +define('MSG_DELETED', 0); |
|
16 | +define('MSG_MODIFIED', 1); |
|
17 | +define('MSG_ADDED', 2); |
|
18 | +define('MSG_REJECTED', 3); |
|
19 | +define('MSG_TENTATIVE', 4); |
|
20 | +define('MSG_ACCEPTED', 5); |
|
21 | +define('MSG_ALARM', 6); |
|
22 | +define('MSG_DISINVITE', 7); |
|
23 | +define('MSG_DELEGATED', 8); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Class to access AND manipulate all calendar data (business object) |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function __construct() |
83 | 83 | { |
84 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
84 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
85 | 85 | |
86 | - parent::__construct(); // calling the parent constructor |
|
86 | + parent::__construct(); // calling the parent constructor |
|
87 | 87 | |
88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
88 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
113 | 113 | * ++++++++ ++++++++ |
114 | 114 | */ |
115 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
115 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
116 | 116 | { |
117 | 117 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
118 | 118 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if ($this->debug > 1 || $this->debug == 'update') |
121 | 121 | { |
122 | 122 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
123 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
123 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
124 | 124 | } |
125 | 125 | // check some minimum requirements: |
126 | 126 | // - new events need start, end and title |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // check if user has the permission to update / create the event |
151 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT,$event['id']) || |
|
152 | - $new_event && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner'])) && |
|
153 | - !$this->check_perms(EGW_ACL_ADD,0,$event['owner'])) |
|
151 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT, $event['id']) || |
|
152 | + $new_event && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner'])) && |
|
153 | + !$this->check_perms(EGW_ACL_ADD, 0, $event['owner'])) |
|
154 | 154 | { |
155 | - $messages[] = lang('Access to calendar of %1 denied!',common::grab_owner_name($event['owner'])); |
|
155 | + $messages[] = lang('Access to calendar of %1 denied!', common::grab_owner_name($event['owner'])); |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if ($new_event) |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
164 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // do we need to check, if user is allowed to invite the invited participants |
168 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
168 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
169 | 169 | { |
170 | 170 | // report removed participants back to user |
171 | - foreach($removed as $key => $account_id) |
|
171 | + foreach ($removed as $key => $account_id) |
|
172 | 172 | { |
173 | 173 | $removed[$key] = $this->participant_name($account_id); |
174 | 174 | } |
175 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
176 | - ': '.implode(', ',$removed); |
|
175 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
176 | + ': '.implode(', ', $removed); |
|
177 | 177 | } |
178 | 178 | // check category based ACL |
179 | 179 | if ($event['category']) |
180 | 180 | { |
181 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
181 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
182 | 182 | if (!$old_event || !isset($old_event['category'])) |
183 | 183 | { |
184 | 184 | $old_event['category'] = array(); |
@@ -187,38 +187,38 @@ discard block |
||
187 | 187 | { |
188 | 188 | $old_event['category'] = explode(',', $old_event['category']); |
189 | 189 | } |
190 | - foreach($event['category'] as $key => $cat_id) |
|
190 | + foreach ($event['category'] as $key => $cat_id) |
|
191 | 191 | { |
192 | 192 | // check if user is allowed to update event categories |
193 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
194 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
193 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
194 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
195 | 195 | { |
196 | 196 | unset($event['category'][$key]); |
197 | 197 | // report removed category to user |
198 | 198 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
199 | - continue; // no further check, as cat was removed |
|
199 | + continue; // no further check, as cat was removed |
|
200 | 200 | } |
201 | 201 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
202 | 202 | if (!$status_reset_to_unknown && |
203 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
203 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
204 | 204 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
205 | 205 | { |
206 | - foreach((array)$event['participants'] as $uid => $status) |
|
206 | + foreach ((array)$event['participants'] as $uid => $status) |
|
207 | 207 | { |
208 | 208 | $q = $r = null; |
209 | - calendar_so::split_status($status,$q,$r); |
|
209 | + calendar_so::split_status($status, $q, $r); |
|
210 | 210 | if ($status != 'U') |
211 | 211 | { |
212 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
212 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
213 | 213 | // todo: report reset status to user |
214 | 214 | } |
215 | 215 | } |
216 | - $status_reset_to_unknown = true; // once is enough |
|
216 | + $status_reset_to_unknown = true; // once is enough |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | if ($removed_cats) |
220 | 220 | { |
221 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
221 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
222 | 222 | } |
223 | 223 | if ($status_reset_to_unknown) |
224 | 224 | { |
@@ -229,61 +229,61 @@ discard block |
||
229 | 229 | if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end'])) |
230 | 230 | { |
231 | 231 | $types_with_quantity = array(); |
232 | - foreach($this->resources as $type => $data) |
|
232 | + foreach ($this->resources as $type => $data) |
|
233 | 233 | { |
234 | 234 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
235 | 235 | } |
236 | 236 | // get all NOT rejected participants and evtl. their quantity |
237 | 237 | $quantity = $users = array(); |
238 | - foreach($event['participants'] as $uid => $status) |
|
238 | + foreach ($event['participants'] as $uid => $status) |
|
239 | 239 | { |
240 | - calendar_so::split_status($status,$q,$r); |
|
241 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
240 | + calendar_so::split_status($status, $q, $r); |
|
241 | + if ($status[0] == 'R') continue; // ignore rejected participants |
|
242 | 242 | |
243 | 243 | if ($uid < 0) // group, check it's members too |
244 | 244 | { |
245 | - $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
|
245 | + $users += (array)$GLOBALS['egw']->accounts->members($uid, true); |
|
246 | 246 | $users = array_unique($users); |
247 | 247 | } |
248 | 248 | $users[] = $uid; |
249 | - if (in_array($uid[0],$types_with_quantity)) |
|
249 | + if (in_array($uid[0], $types_with_quantity)) |
|
250 | 250 | { |
251 | 251 | $quantity[$uid] = $q; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | //$start = microtime(true); |
255 | - $overlapping_events =& $this->search(array( |
|
255 | + $overlapping_events = & $this->search(array( |
|
256 | 256 | 'start' => $event['start'], |
257 | 257 | 'end' => $event['end'], |
258 | 258 | 'users' => $users, |
259 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
260 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
259 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
260 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
261 | 261 | 'query' => array( |
262 | 262 | 'cal_non_blocking' => 0, |
263 | 263 | ), |
264 | - 'no_integration' => true, // do NOT use integration of other apps |
|
264 | + 'no_integration' => true, // do NOT use integration of other apps |
|
265 | 265 | )); |
266 | 266 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
267 | 267 | if ($this->debug > 2 || $this->debug == 'update') |
268 | 268 | { |
269 | - $this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$event['start'],$event['end']); |
|
269 | + $this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $event['start'], $event['end']); |
|
270 | 270 | } |
271 | 271 | $max_quantity = $possible_quantity_conflicts = $conflicts = array(); |
272 | - foreach((array) $overlapping_events as $k => $overlap) |
|
272 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
273 | 273 | { |
274 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
275 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
274 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
275 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
276 | 276 | $overlap['non_blocking']) // that's a non_blocking event |
277 | 277 | { |
278 | 278 | continue; |
279 | 279 | } |
280 | 280 | if ($this->debug > 3 || $this->debug == 'update') |
281 | 281 | { |
282 | - $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
|
282 | + $this->debug_message('calendar_boupdate::update() checking overlapping event %1', false, $overlap); |
|
283 | 283 | } |
284 | 284 | // check if the overlap is with a rejected participant or within the allowed quantity |
285 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
286 | - foreach($common_parts as $n => $uid) |
|
285 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
286 | + foreach ($common_parts as $n => $uid) |
|
287 | 287 | { |
288 | 288 | $status = $overlap['participants'][$uid]; |
289 | 289 | calendar_so::split_status($status, $q, $r); |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | unset($common_parts[$n]); |
293 | 293 | continue; |
294 | 294 | } |
295 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
295 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
296 | 296 | { |
297 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
297 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
298 | 298 | } |
299 | 299 | if (!isset($max_quantity[$uid])) |
300 | 300 | { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $quantity[$uid] += $q; |
305 | 305 | if ($quantity[$uid] <= $max_quantity[$uid]) |
306 | 306 | { |
307 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
307 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
308 | 308 | unset($common_parts[$n]); |
309 | 309 | continue; |
310 | 310 | } |
@@ -314,20 +314,20 @@ discard block |
||
314 | 314 | { |
315 | 315 | if ($this->debug > 3 || $this->debug == 'update') |
316 | 316 | { |
317 | - $this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1',false,$common_parts); |
|
317 | + $this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1', false, $common_parts); |
|
318 | 318 | } |
319 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
319 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | // check if we are withing the allowed quantity and if not add all events using that resource |
323 | 323 | // seems this function is doing very strange things, it gives empty conflicts |
324 | - foreach($max_quantity as $uid => $max) |
|
324 | + foreach ($max_quantity as $uid => $max) |
|
325 | 325 | { |
326 | 326 | if ($quantity[$uid] > $max) |
327 | 327 | { |
328 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
328 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
329 | 329 | { |
330 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
330 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | } |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | |
336 | 336 | if (count($conflicts)) |
337 | 337 | { |
338 | - foreach($conflicts as $key => $conflict) |
|
338 | + foreach ($conflicts as $key => $conflict) |
|
339 | 339 | { |
340 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
341 | - if (!$this->check_perms(EGW_ACL_READ,$conflict)) |
|
340 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
341 | + if (!$this->check_perms(EGW_ACL_READ, $conflict)) |
|
342 | 342 | { |
343 | 343 | $conflicts[$key] = array( |
344 | 344 | 'id' => $conflict['id'], |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | if ($this->debug > 2 || $this->debug == 'update') |
353 | 353 | { |
354 | - $this->debug_message('calendar_boupdate::update() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
354 | + $this->debug_message('calendar_boupdate::update() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
355 | 355 | } |
356 | 356 | return $conflicts; |
357 | 357 | } |
@@ -365,33 +365,33 @@ discard block |
||
365 | 365 | return $cal_id; |
366 | 366 | } |
367 | 367 | |
368 | - $event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies |
|
368 | + $event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies |
|
369 | 369 | //echo "new $cal_id="; _debug_array($event); |
370 | 370 | |
371 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
371 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
372 | 372 | { |
373 | 373 | // Restored, bring back links |
374 | 374 | egw_link::restore('calendar', $cal_id); |
375 | 375 | } |
376 | 376 | if ($this->log_file) |
377 | 377 | { |
378 | - $this->log2file($event2save,$event,$old_event); |
|
378 | + $this->log2file($event2save, $event, $old_event); |
|
379 | 379 | } |
380 | 380 | // send notifications |
381 | - if(!$skip_notification) |
|
381 | + if (!$skip_notification) |
|
382 | 382 | { |
383 | 383 | if ($new_event) |
384 | 384 | { |
385 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
385 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
386 | 386 | } |
387 | 387 | else // update existing event |
388 | 388 | { |
389 | - $this->check4update($event,$old_event); |
|
389 | + $this->check4update($event, $old_event); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | // notify the link-class about the update, as other apps may be subscribt to it |
394 | - egw_link::notify_update('calendar',$cal_id,$event); |
|
394 | + egw_link::notify_update('calendar', $cal_id, $event); |
|
395 | 395 | |
396 | 396 | return $cal_id; |
397 | 397 | } |
@@ -403,22 +403,22 @@ discard block |
||
403 | 403 | * @param array $old_event =null old event with already invited participants |
404 | 404 | * @return array removed participants because of missing invite grants |
405 | 405 | */ |
406 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
406 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
407 | 407 | { |
408 | 408 | if (!$this->require_acl_invite) |
409 | 409 | { |
410 | - return array(); // nothing to check, everyone can invite everyone else |
|
410 | + return array(); // nothing to check, everyone can invite everyone else |
|
411 | 411 | } |
412 | 412 | if ($event['id'] && is_null($old_event)) |
413 | 413 | { |
414 | 414 | $old_event = $this->read($event['id']); |
415 | 415 | } |
416 | 416 | $removed = array(); |
417 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
417 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
418 | 418 | { |
419 | 419 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
420 | 420 | { |
421 | - unset($event['participants'][$uid]); // remove participant |
|
421 | + unset($event['participants'][$uid]); // remove participant |
|
422 | 422 | $removed[] = $uid; |
423 | 423 | } |
424 | 424 | } |
@@ -434,19 +434,19 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function check_acl_invite($uid) |
436 | 436 | { |
437 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
437 | + if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
438 | 438 | |
439 | 439 | if (!$this->require_acl_invite) |
440 | 440 | { |
441 | - $ret = true; // no grant required |
|
441 | + $ret = true; // no grant required |
|
442 | 442 | } |
443 | 443 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
444 | 444 | { |
445 | - $ret = true; // grant only required for groups |
|
445 | + $ret = true; // grant only required for groups |
|
446 | 446 | } |
447 | 447 | else |
448 | 448 | { |
449 | - $ret = $this->check_perms(EGW_ACL_INVITE,0,$uid); |
|
449 | + $ret = $this->check_perms(EGW_ACL_INVITE, 0, $uid); |
|
450 | 450 | } |
451 | 451 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
452 | 452 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param array $old_event the event before the update |
461 | 461 | * @todo check if there is a real change, not assume every save is a change |
462 | 462 | */ |
463 | - function check4update($new_event,$old_event) |
|
463 | + function check4update($new_event, $old_event) |
|
464 | 464 | { |
465 | 465 | //error_log(__METHOD__."($new_event[title])"); |
466 | 466 | $modified = $added = $deleted = array(); |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
469 | 469 | |
470 | 470 | // Find modified and deleted participants ... |
471 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
471 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
472 | 472 | { |
473 | - if(isset($new_event['participants'][$old_userid])) |
|
473 | + if (isset($new_event['participants'][$old_userid])) |
|
474 | 474 | { |
475 | 475 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
476 | 476 | } |
@@ -480,27 +480,27 @@ discard block |
||
480 | 480 | } |
481 | 481 | } |
482 | 482 | // Find new participants ... |
483 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
483 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
484 | 484 | { |
485 | - if(!isset($old_event['participants'][$new_userid])) |
|
485 | + if (!isset($old_event['participants'][$new_userid])) |
|
486 | 486 | { |
487 | 487 | $added[$new_userid] = 'U'; |
488 | 488 | } |
489 | 489 | } |
490 | 490 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
491 | - if(count($added) || count($modified) || count($deleted)) |
|
491 | + if (count($added) || count($modified) || count($deleted)) |
|
492 | 492 | { |
493 | - if(count($added)) |
|
493 | + if (count($added)) |
|
494 | 494 | { |
495 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
495 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
496 | 496 | } |
497 | - if(count($modified)) |
|
497 | + if (count($modified)) |
|
498 | 498 | { |
499 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
499 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
500 | 500 | } |
501 | - if(count($deleted)) |
|
501 | + if (count($deleted)) |
|
502 | 502 | { |
503 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
503 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
504 | 504 | } |
505 | 505 | } |
506 | 506 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | * @param string $status of current user |
518 | 518 | * @return boolean true = update requested, false otherwise |
519 | 519 | */ |
520 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
520 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
521 | 521 | { |
522 | 522 | if ($msg_type == MSG_ALARM) |
523 | 523 | { |
524 | - return True; // always True for now |
|
524 | + return True; // always True for now |
|
525 | 525 | } |
526 | 526 | $want_update = 0; |
527 | 527 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | // |
530 | 530 | $msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED; |
531 | 531 | |
532 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
532 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
533 | 533 | { |
534 | 534 | case 'responses': |
535 | 535 | ++$want_update; |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | default: |
544 | 544 | if (is_array($new_event) && is_array($old_event)) |
545 | 545 | { |
546 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
547 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
546 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
547 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
548 | 548 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
549 | 549 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
550 | 550 | { |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | if (!is_numeric($userid) && $role == 'CHAIR' && |
565 | 565 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
566 | 566 | { |
567 | - switch($msg_type) |
|
567 | + switch ($msg_type) |
|
568 | 568 | { |
569 | 569 | case MSG_DELETED: // treat deleting event as rejection to organizer |
570 | 570 | $msg_type = MSG_REJECTED; |
571 | 571 | break; |
572 | 572 | case MSG_ADDED: // new events use added, but organizer needs status |
573 | - switch($status[0]) |
|
573 | + switch ($status[0]) |
|
574 | 574 | { |
575 | 575 | case 'A': $msg_type = MSG_ACCEPTED; break; |
576 | 576 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * @param string $role ='REQ-PARTICIPANT' |
596 | 596 | * @return boolean true if user requested to be notified, false if not |
597 | 597 | */ |
598 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
598 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
599 | 599 | { |
600 | 600 | // check if email is from a user |
601 | 601 | if (is_numeric($user_or_email)) |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | ) |
620 | 620 | ); |
621 | 621 | } |
622 | - switch($ical_method) |
|
622 | + switch ($ical_method) |
|
623 | 623 | { |
624 | 624 | default: |
625 | 625 | case 'REQUEST': |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | * @param string& $action=null on return verbose name |
645 | 645 | * @param string& $msg=null on return notification message |
646 | 646 | */ |
647 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
647 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
648 | 648 | { |
649 | - switch($msg_type) |
|
649 | + switch ($msg_type) |
|
650 | 650 | { |
651 | 651 | case MSG_DELETED: |
652 | 652 | $action = 'Canceled'; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $msg = $this->cal_prefs['notify'.$pref]; |
699 | 699 | if (empty($msg)) |
700 | 700 | { |
701 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
701 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
702 | 702 | } |
703 | 703 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
704 | 704 | return $method; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param int $user =0 User who started the notify, default current user |
715 | 715 | * @return bool true/false |
716 | 716 | */ |
717 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
717 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
718 | 718 | { |
719 | 719 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
720 | 720 | if (!is_array($to_notify)) |
@@ -726,11 +726,11 @@ discard block |
||
726 | 726 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
727 | 727 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
728 | 728 | { |
729 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
729 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
733 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
733 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
734 | 734 | { |
735 | 735 | return False; |
736 | 736 | } |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $restore_tz = $tz; |
741 | 741 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
742 | 742 | } |
743 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
743 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
744 | 744 | |
745 | 745 | if (!$user) |
746 | 746 | { |
@@ -756,17 +756,17 @@ discard block |
||
756 | 756 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
757 | 757 | |
758 | 758 | // add all group-members to the notification, unless they are already participants |
759 | - foreach($to_notify as $userid => $statusid) |
|
759 | + foreach ($to_notify as $userid => $statusid) |
|
760 | 760 | { |
761 | 761 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
762 | 762 | ($members = $GLOBALS['egw']->accounts->member($userid))) |
763 | 763 | { |
764 | - foreach($members as $member) |
|
764 | + foreach ($members as $member) |
|
765 | 765 | { |
766 | 766 | $member = $member['account_id']; |
767 | 767 | if (!isset($to_notify[$member])) |
768 | 768 | { |
769 | - $to_notify[$member] = 'G'; // Group-invitation |
|
769 | + $to_notify[$member] = 'G'; // Group-invitation |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | if ($old_event) $olddate = new egw_time($old_event['start']); |
779 | 779 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
780 | 780 | $owner_prefs = $ics = null; |
781 | - foreach($to_notify as $userid => $statusid) |
|
781 | + foreach ($to_notify as $userid => $statusid) |
|
782 | 782 | { |
783 | 783 | $res_info = $quantity = $role = null; |
784 | 784 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -801,14 +801,14 @@ discard block |
||
801 | 801 | |
802 | 802 | if (!isset($userid)) |
803 | 803 | { |
804 | - if (empty($res_info['email'])) continue; // no way to notify |
|
804 | + if (empty($res_info['email'])) continue; // no way to notify |
|
805 | 805 | // check if event-owner wants non-EGroupware users notified |
806 | 806 | if (is_null($owner_prefs)) |
807 | 807 | { |
808 | 808 | $preferences = new preferences($owner); |
809 | 809 | $owner_prefs = $preferences->read_repository(); |
810 | 810 | } |
811 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
811 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
812 | 812 | (empty($owner_prefs['calendar']['notify_externals']) || |
813 | 813 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
814 | 814 | { |
@@ -820,12 +820,12 @@ discard block |
||
820 | 820 | |
821 | 821 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
822 | 822 | { |
823 | - continue; // dont notify rejected participants or groups |
|
823 | + continue; // dont notify rejected participants or groups |
|
824 | 824 | } |
825 | 825 | |
826 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
826 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
827 | 827 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
828 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
828 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
829 | 829 | $msg_type == MSG_ALARM) |
830 | 830 | { |
831 | 831 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | { |
834 | 834 | $preferences = new preferences($userid); |
835 | 835 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
836 | - $GLOBALS['egw']->accounts->get_account_name($userid,$lid,$tfn,$tln); |
|
837 | - $fullname = common::display_fullname('',$tfn,$tln); |
|
836 | + $GLOBALS['egw']->accounts->get_account_name($userid, $lid, $tfn, $tln); |
|
837 | + $fullname = common::display_fullname('', $tfn, $tln); |
|
838 | 838 | } |
839 | 839 | else // external email address: use preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
840 | 840 | { |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | } |
846 | 846 | $part_prefs = $owner_prefs; |
847 | 847 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
848 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
848 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
849 | 849 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
850 | 850 | } |
851 | 851 | $m_type = $msg_type; |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
874 | 874 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
875 | 875 | $timeformat = $part_prefs['common']['timeformat']; |
876 | - switch($timeformat) |
|
876 | + switch ($timeformat) |
|
877 | 877 | { |
878 | 878 | case '24': |
879 | 879 | $timeformat = 'H:i'; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | $timeformat = 'h:i a'; |
883 | 883 | break; |
884 | 884 | } |
885 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
885 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
886 | 886 | |
887 | 887 | $startdate->setTimezone($timezone); |
888 | 888 | $details['startdate'] = $startdate->format($timeformat); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $details['enddate'] = $enddate->format($timeformat); |
892 | 892 | |
893 | 893 | $modified->setTimezone($timezone); |
894 | - $details['updated'] = $modified->format($timeformat) . ', ' . common::grab_owner_name($event['modifier']); |
|
894 | + $details['updated'] = $modified->format($timeformat).', '.common::grab_owner_name($event['modifier']); |
|
895 | 895 | |
896 | 896 | if ($old_event != False) |
897 | 897 | { |
@@ -900,15 +900,14 @@ discard block |
||
900 | 900 | } |
901 | 901 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
902 | 902 | |
903 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
903 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
904 | 904 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
905 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
905 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
906 | 906 | { |
907 | - case 'ical': |
|
908 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
907 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
909 | 908 | { |
910 | 909 | $calendar_ical = new calendar_ical(); |
911 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
910 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
912 | 911 | // we need to pass $event[id] so iCal class reads event again, |
913 | 912 | // as event is in user TZ, but iCal class expects server TZ! |
914 | 913 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -927,11 +926,11 @@ discard block |
||
927 | 926 | case 'extended': |
928 | 927 | |
929 | 928 | $details_body = lang('Event Details follow').":\n"; |
930 | - foreach($event_arr as $key => $val) |
|
929 | + foreach ($event_arr as $key => $val) |
|
931 | 930 | { |
932 | - if(!empty($details[$key])) |
|
931 | + if (!empty($details[$key])) |
|
933 | 932 | { |
934 | - switch($key) |
|
933 | + switch ($key) |
|
935 | 934 | { |
936 | 935 | case 'access': |
937 | 936 | case 'priority': |
@@ -940,7 +939,7 @@ discard block |
||
940 | 939 | case 'title': |
941 | 940 | break; |
942 | 941 | default: |
943 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
942 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
944 | 943 | break; |
945 | 944 | } |
946 | 945 | } |
@@ -948,7 +947,7 @@ discard block |
||
948 | 947 | break; |
949 | 948 | } |
950 | 949 | // send via notification_app |
951 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
950 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
952 | 951 | { |
953 | 952 | try { |
954 | 953 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -972,7 +971,7 @@ discard block |
||
972 | 971 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
973 | 972 | $notification->set_popuplinks(array($details['link_arr'])); |
974 | 973 | |
975 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
974 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
976 | 975 | $notification->send(); |
977 | 976 | } |
978 | 977 | catch (Exception $exception) { |
@@ -1004,14 +1003,14 @@ discard block |
||
1004 | 1003 | return true; |
1005 | 1004 | } |
1006 | 1005 | |
1007 | - function get_update_message($event,$added) |
|
1006 | + function get_update_message($event, $added) |
|
1008 | 1007 | { |
1009 | 1008 | $nul = null; |
1010 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
1009 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
1011 | 1010 | |
1012 | 1011 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
1013 | 1012 | |
1014 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
1013 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
1015 | 1014 | } |
1016 | 1015 | |
1017 | 1016 | /** |
@@ -1025,37 +1024,37 @@ discard block |
||
1025 | 1024 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
1026 | 1025 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
1027 | 1026 | |
1028 | - $event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1029 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
1027 | + $event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
1028 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
1030 | 1029 | { |
1031 | - return False; // event not found |
|
1030 | + return False; // event not found |
|
1032 | 1031 | } |
1033 | 1032 | if ($alarm['all']) |
1034 | 1033 | { |
1035 | 1034 | $to_notify = $event['participants']; |
1036 | 1035 | } |
1037 | - elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1036 | + elseif ($this->check_perms(EGW_ACL_READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
1038 | 1037 | { |
1039 | 1038 | $to_notify[$alarm['owner']] = 'A'; |
1040 | 1039 | } |
1041 | 1040 | else |
1042 | 1041 | { |
1043 | - return False; // no rights |
|
1042 | + return False; // no rights |
|
1044 | 1043 | } |
1045 | 1044 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
1046 | 1045 | translation::add_app('calendar'); |
1047 | 1046 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
1048 | 1047 | |
1049 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
1048 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
1050 | 1049 | |
1051 | 1050 | // create a new alarm for recuring events for the next event, if one exists |
1052 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
1051 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
1053 | 1052 | { |
1054 | 1053 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
1055 | 1054 | unset($alarm['times']); |
1056 | 1055 | unset($alarm['next']); |
1057 | 1056 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
1058 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1057 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
1059 | 1058 | } |
1060 | 1059 | return $ret; |
1061 | 1060 | } |
@@ -1071,15 +1070,15 @@ discard block |
||
1071 | 1070 | * DEPRECATED: we allways (have to) update timestamp, as they are required for sync! |
1072 | 1071 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
1073 | 1072 | */ |
1074 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
1073 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
1075 | 1074 | { |
1076 | 1075 | unset($updateTS); |
1077 | 1076 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
1078 | 1077 | |
1079 | 1078 | // check if user has the permission to update / create the event |
1080 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT,$event['id']) || |
|
1081 | - !$event['id'] && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner']) && |
|
1082 | - !$this->check_perms(EGW_ACL_ADD,0,$event['owner']))) |
|
1079 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT, $event['id']) || |
|
1080 | + !$event['id'] && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner']) && |
|
1081 | + !$this->check_perms(EGW_ACL_ADD, 0, $event['owner']))) |
|
1083 | 1082 | { |
1084 | 1083 | return false; |
1085 | 1084 | } |
@@ -1124,19 +1123,19 @@ discard block |
||
1124 | 1123 | $time->setUser(); |
1125 | 1124 | $save_event['recur_enddate'] = egw_time::to($time, 'ts'); |
1126 | 1125 | } |
1127 | - $timestamps = array('modified','created'); |
|
1126 | + $timestamps = array('modified', 'created'); |
|
1128 | 1127 | // all-day events are handled in server time |
1129 | 1128 | $event['tzid'] = $save_event['tzid'] = egw_time::$server_timezone->getName(); |
1130 | 1129 | } |
1131 | 1130 | else |
1132 | 1131 | { |
1133 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
1132 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
1134 | 1133 | } |
1135 | 1134 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
1136 | - foreach($timestamps as $ts) |
|
1135 | + foreach ($timestamps as $ts) |
|
1137 | 1136 | { |
1138 | 1137 | // we convert here from user-time to timestamps in server-time! |
1139 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1138 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
1140 | 1139 | } |
1141 | 1140 | // convert tzid name to integer tz_id, of set user default |
1142 | 1141 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1146,7 +1145,7 @@ discard block |
||
1146 | 1145 | // same with the recur exceptions |
1147 | 1146 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
1148 | 1147 | { |
1149 | - foreach($event['recur_exception'] as &$date) |
|
1148 | + foreach ($event['recur_exception'] as &$date) |
|
1150 | 1149 | { |
1151 | 1150 | if ($event['whole_day']) |
1152 | 1151 | { |
@@ -1155,7 +1154,7 @@ discard block |
||
1155 | 1154 | } |
1156 | 1155 | else |
1157 | 1156 | { |
1158 | - $date = $this->date2ts($date,true); |
|
1157 | + $date = $this->date2ts($date, true); |
|
1159 | 1158 | } |
1160 | 1159 | } |
1161 | 1160 | unset($date); |
@@ -1163,7 +1162,7 @@ discard block |
||
1163 | 1162 | // same with the alarms |
1164 | 1163 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
1165 | 1164 | { |
1166 | - foreach($event['alarm'] as $id => &$alarm) |
|
1165 | + foreach ($event['alarm'] as $id => &$alarm) |
|
1167 | 1166 | { |
1168 | 1167 | // remove alarms belonging to not longer existing or rejected participants |
1169 | 1168 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1181,15 +1180,14 @@ discard block |
||
1181 | 1180 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
1182 | 1181 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
1183 | 1182 | { |
1184 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
1183 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
1185 | 1184 | { |
1186 | 1185 | if (!isset($event['alarm'][$id])) |
1187 | 1186 | { |
1188 | 1187 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1189 | 1188 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
1190 | 1189 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1191 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
1192 | - $old_event['participants'][$alarm['owner']]; |
|
1190 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
1193 | 1191 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
1194 | 1192 | { |
1195 | 1193 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1215,7 +1213,7 @@ discard block |
||
1215 | 1213 | } |
1216 | 1214 | $set_recurrences = false; |
1217 | 1215 | $set_recurrences_start = 0; |
1218 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1216 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
1219 | 1217 | { |
1220 | 1218 | $save_event['id'] = $cal_id; |
1221 | 1219 | // unset participants to enforce the default stati for all added recurrences |
@@ -1227,7 +1225,7 @@ discard block |
||
1227 | 1225 | // create links for new participants from addressbook, if configured |
1228 | 1226 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
1229 | 1227 | { |
1230 | - foreach($event['participants'] as $uid => $status) |
|
1228 | + foreach ($event['participants'] as $uid => $status) |
|
1231 | 1229 | { |
1232 | 1230 | $user_type = $user_id = null; |
1233 | 1231 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1240,7 +1238,7 @@ discard block |
||
1240 | 1238 | |
1241 | 1239 | // Update history |
1242 | 1240 | $tracking = new calendar_tracking($this); |
1243 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1241 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
1244 | 1242 | $tracking->track($event, $old_event); |
1245 | 1243 | |
1246 | 1244 | return $cal_id; |
@@ -1255,16 +1253,16 @@ discard block |
||
1255 | 1253 | * @param array|int $event event array or id of the event |
1256 | 1254 | * @return boolean |
1257 | 1255 | */ |
1258 | - function check_status_perms($uid,$event) |
|
1256 | + function check_status_perms($uid, $event) |
|
1259 | 1257 | { |
1260 | 1258 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
1261 | 1259 | { |
1262 | 1260 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1263 | 1261 | |
1264 | - return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']); |
|
1262 | + return $this->check_perms(EGW_ACL_EDIT, 0, $event['owner']); |
|
1265 | 1263 | } |
1266 | 1264 | // check if we have a category acl for the event or not (null) |
1267 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
1265 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
1268 | 1266 | if (!is_null($access)) |
1269 | 1267 | { |
1270 | 1268 | return $access; |
@@ -1274,17 +1272,17 @@ discard block |
||
1274 | 1272 | { |
1275 | 1273 | $resource = $this->resource_info($uid); |
1276 | 1274 | |
1277 | - return EGW_ACL_EDIT & $resource['rights']; |
|
1275 | + return EGW_ACL_EDIT&$resource['rights']; |
|
1278 | 1276 | } |
1279 | 1277 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1280 | 1278 | |
1281 | 1279 | // regular user and groups (need to check memberships too) |
1282 | 1280 | if (!isset($event['participants'][$uid])) |
1283 | 1281 | { |
1284 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
1282 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
1285 | 1283 | } |
1286 | 1284 | $memberships[] = $uid; |
1287 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT,0,$uid); |
|
1285 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT, 0, $uid); |
|
1288 | 1286 | } |
1289 | 1287 | |
1290 | 1288 | /** |
@@ -1298,16 +1296,16 @@ discard block |
||
1298 | 1296 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1299 | 1297 | * null = cat has no acl |
1300 | 1298 | */ |
1301 | - function check_cat_acl($right,$event) |
|
1299 | + function check_cat_acl($right, $event) |
|
1302 | 1300 | { |
1303 | 1301 | if (!is_array($event)) $event = $this->read($event); |
1304 | 1302 | |
1305 | 1303 | $ret = null; |
1306 | 1304 | if ($event['category']) |
1307 | 1305 | { |
1308 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
1306 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
1309 | 1307 | { |
1310 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
1308 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
1311 | 1309 | if ($access === true) |
1312 | 1310 | { |
1313 | 1311 | $ret = true; |
@@ -1315,7 +1313,7 @@ discard block |
||
1315 | 1313 | } |
1316 | 1314 | if ($access === false) |
1317 | 1315 | { |
1318 | - $ret = false; // cat denies access --> check further cats |
|
1316 | + $ret = false; // cat denies access --> check further cats |
|
1319 | 1317 | } |
1320 | 1318 | } |
1321 | 1319 | } |
@@ -1336,12 +1334,12 @@ discard block |
||
1336 | 1334 | * @param int $cat_id =null null to return array with all cats |
1337 | 1335 | * @return array with account_id => right pairs |
1338 | 1336 | */ |
1339 | - public static function get_cat_rights($cat_id=null) |
|
1337 | + public static function get_cat_rights($cat_id = null) |
|
1340 | 1338 | { |
1341 | 1339 | if (!isset(self::$cat_rights_cache)) |
1342 | 1340 | { |
1343 | - self::$cat_rights_cache = egw_cache::getSession('calendar','cat_rights', |
|
1344 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
1341 | + self::$cat_rights_cache = egw_cache::getSession('calendar', 'cat_rights', |
|
1342 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
1345 | 1343 | } |
1346 | 1344 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
1347 | 1345 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1354,7 +1352,7 @@ discard block |
||
1354 | 1352 | * @param int $user |
1355 | 1353 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
1356 | 1354 | */ |
1357 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
1355 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
1358 | 1356 | { |
1359 | 1357 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1360 | 1358 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1364,15 +1362,15 @@ discard block |
||
1364 | 1362 | if ($rights) |
1365 | 1363 | { |
1366 | 1364 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
1367 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
1365 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
1368 | 1366 | } |
1369 | 1367 | else |
1370 | 1368 | { |
1371 | 1369 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1372 | 1370 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
1373 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
1371 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
1374 | 1372 | } |
1375 | - egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
1373 | + egw_cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
1376 | 1374 | } |
1377 | 1375 | } |
1378 | 1376 | |
@@ -1383,9 +1381,9 @@ discard block |
||
1383 | 1381 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
1384 | 1382 | * null = cat has no acl |
1385 | 1383 | */ |
1386 | - public static function has_cat_right($right,$cat_id,$user) |
|
1384 | + public static function has_cat_right($right, $cat_id, $user) |
|
1387 | 1385 | { |
1388 | - static $cache=null; |
|
1386 | + static $cache = null; |
|
1389 | 1387 | |
1390 | 1388 | if (!isset($cache[$cat_id])) |
1391 | 1389 | { |
@@ -1393,21 +1391,21 @@ discard block |
||
1393 | 1391 | $cat_rights = self::get_cat_rights($cat_id); |
1394 | 1392 | if (!is_null($cat_rights)) |
1395 | 1393 | { |
1396 | - static $memberships=null; |
|
1394 | + static $memberships = null; |
|
1397 | 1395 | if (is_null($memberships)) |
1398 | 1396 | { |
1399 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
1397 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
1400 | 1398 | $memberships[] = $user; |
1401 | 1399 | } |
1402 | - foreach($cat_rights as $uid => $value) |
|
1400 | + foreach ($cat_rights as $uid => $value) |
|
1403 | 1401 | { |
1404 | 1402 | $all |= $value; |
1405 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1403 | + if (in_array($uid, $memberships)) $own |= $value; |
|
1406 | 1404 | } |
1407 | 1405 | } |
1408 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
1406 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
1409 | 1407 | { |
1410 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
1408 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
1411 | 1409 | } |
1412 | 1410 | } |
1413 | 1411 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1427,13 +1425,13 @@ discard block |
||
1427 | 1425 | * @param boolean $skip_notification =false true: do not send notification messages |
1428 | 1426 | * @return int number of changed recurrences |
1429 | 1427 | */ |
1430 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
1428 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
1431 | 1429 | { |
1432 | 1430 | unset($updateTS); |
1433 | 1431 | |
1434 | 1432 | $cal_id = is_array($event) ? $event['id'] : $event; |
1435 | 1433 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
1436 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
1434 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
1437 | 1435 | { |
1438 | 1436 | return false; |
1439 | 1437 | } |
@@ -1442,16 +1440,16 @@ discard block |
||
1442 | 1440 | if ($this->log) |
1443 | 1441 | { |
1444 | 1442 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1445 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
1443 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
1446 | 1444 | } |
1447 | 1445 | $old_event = $this->read($cal_id, $recur_date, false, 'server'); |
1448 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
1449 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
1450 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
1446 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
1447 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
1448 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
1451 | 1449 | { |
1452 | 1450 | if ($status == 'R') // remove alarms belonging to rejected participants |
1453 | 1451 | { |
1454 | - foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1452 | + foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
1455 | 1453 | { |
1456 | 1454 | if ((string)$alarm['owner'] === (string)$uid) |
1457 | 1455 | { |
@@ -1474,8 +1472,8 @@ discard block |
||
1474 | 1472 | if (isset($status2msg[$status]) && !$skip_notification) |
1475 | 1473 | { |
1476 | 1474 | if (!is_array($event)) $event = $this->read($cal_id); |
1477 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1478 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
1475 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
1476 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
1479 | 1477 | } |
1480 | 1478 | |
1481 | 1479 | // Update history |
@@ -1495,14 +1493,14 @@ discard block |
||
1495 | 1493 | * @param int $recur_date =0 date to change, or 0 = all since now |
1496 | 1494 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
1497 | 1495 | */ |
1498 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
1496 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
1499 | 1497 | { |
1500 | 1498 | if (!isset($new_event['participants'])) return; |
1501 | 1499 | |
1502 | 1500 | // check the old list against the new list |
1503 | 1501 | foreach ($old_event['participants'] as $userid => $status) |
1504 | 1502 | { |
1505 | - if (!isset($new_event['participants'][$userid])){ |
|
1503 | + if (!isset($new_event['participants'][$userid])) { |
|
1506 | 1504 | // Attendee will be deleted this way |
1507 | 1505 | $new_event['participants'][$userid] = 'G'; |
1508 | 1506 | } |
@@ -1515,7 +1513,7 @@ discard block |
||
1515 | 1513 | // write the changes |
1516 | 1514 | foreach ($new_event['participants'] as $userid => $status) |
1517 | 1515 | { |
1518 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
1516 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
1519 | 1517 | } |
1520 | 1518 | } |
1521 | 1519 | |
@@ -1530,43 +1528,43 @@ discard block |
||
1530 | 1528 | * @param int &$exceptions_kept=null on return number of kept exceptions |
1531 | 1529 | * @return boolean true on success, false on error (usually permission denied) |
1532 | 1530 | */ |
1533 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
1534 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
1531 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
1532 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
1535 | 1533 | { |
1536 | 1534 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
1537 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
1538 | - !$ignore_acl && !$this->check_perms(EGW_ACL_DELETE,$event)) |
|
1535 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
1536 | + !$ignore_acl && !$this->check_perms(EGW_ACL_DELETE, $event)) |
|
1539 | 1537 | { |
1540 | 1538 | return false; |
1541 | 1539 | } |
1542 | 1540 | |
1543 | 1541 | // Don't send notification if the event has already been deleted |
1544 | - if(!$event['deleted'] && !$skip_notification) |
|
1542 | + if (!$event['deleted'] && !$skip_notification) |
|
1545 | 1543 | { |
1546 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
1544 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
1547 | 1545 | } |
1548 | 1546 | |
1549 | 1547 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
1550 | 1548 | { |
1551 | 1549 | $config = config::read('phpgwapi'); |
1552 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
1550 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
1553 | 1551 | { |
1554 | 1552 | $this->so->delete($cal_id); |
1555 | 1553 | |
1556 | 1554 | // delete all links to the event |
1557 | - egw_link::unlink(0,'calendar',$cal_id); |
|
1555 | + egw_link::unlink(0, 'calendar', $cal_id); |
|
1558 | 1556 | } |
1559 | 1557 | elseif ($config['calendar_delete_history']) |
1560 | 1558 | { |
1561 | 1559 | // mark all links to the event as deleted, but keep them |
1562 | - egw_link::unlink(0,'calendar',$cal_id,'','','',true); |
|
1560 | + egw_link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
1563 | 1561 | |
1564 | 1562 | $event['deleted'] = $this->now; |
1565 | 1563 | $this->save($event, $ignore_acl); |
1566 | 1564 | // Actually delete alarms |
1567 | 1565 | if (isset($event['alarm']) && is_array($event['alarm'])) |
1568 | 1566 | { |
1569 | - foreach($event['alarm'] as $id => $alarm) |
|
1567 | + foreach ($event['alarm'] as $id => $alarm) |
|
1570 | 1568 | { |
1571 | 1569 | $this->delete_alarm($id); |
1572 | 1570 | } |
@@ -1589,7 +1587,7 @@ discard block |
||
1589 | 1587 | if (!($exception = $this->read($id))) continue; |
1590 | 1588 | $exception['uid'] = common::generate_uid('calendar', $id); |
1591 | 1589 | $exception['reference'] = $exception['recurrence'] = 0; |
1592 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
1590 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
1593 | 1591 | ++$exceptions_kept; |
1594 | 1592 | } |
1595 | 1593 | } |
@@ -1601,9 +1599,9 @@ discard block |
||
1601 | 1599 | if ($event['alarm']) |
1602 | 1600 | { |
1603 | 1601 | $next_recurrance = null; |
1604 | - foreach($event['alarm'] as &$alarm) |
|
1602 | + foreach ($event['alarm'] as &$alarm) |
|
1605 | 1603 | { |
1606 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
1604 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
1607 | 1605 | { |
1608 | 1606 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
1609 | 1607 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1611,12 +1609,12 @@ discard block |
||
1611 | 1609 | { |
1612 | 1610 | $checkdate = $recur_date; |
1613 | 1611 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
1614 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
1612 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
1615 | 1613 | { |
1616 | 1614 | $next_recurrance = $this->date2ts($e['start']); |
1617 | 1615 | } |
1618 | 1616 | } |
1619 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1617 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
1620 | 1618 | $alarm['cal_id'] = $cal_id; |
1621 | 1619 | unset($alarm['times']); |
1622 | 1620 | unset($alarm['next']); |
@@ -1630,7 +1628,7 @@ discard block |
||
1630 | 1628 | $event = $this->read($cal_id); |
1631 | 1629 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
1632 | 1630 | $event['recur_exception'][] = $recur_date; |
1633 | - $this->save($event);// updates the content-history |
|
1631 | + $this->save($event); // updates the content-history |
|
1634 | 1632 | } |
1635 | 1633 | if ($event['reference']) |
1636 | 1634 | { |
@@ -1648,19 +1646,19 @@ discard block |
||
1648 | 1646 | * @param array $disinvited |
1649 | 1647 | * @return array |
1650 | 1648 | */ |
1651 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
1649 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
1652 | 1650 | { |
1653 | 1651 | $details = array( // event-details for the notify-msg |
1654 | 1652 | 'id' => $event['id'], |
1655 | 1653 | 'action' => lang($action), |
1656 | 1654 | ); |
1657 | 1655 | $event_arr = $this->event2array($event); |
1658 | - foreach($event_arr as $key => $val) |
|
1656 | + foreach ($event_arr as $key => $val) |
|
1659 | 1657 | { |
1660 | 1658 | if ($key == 'recur_type') $key = 'repetition'; |
1661 | 1659 | $details[$key] = $val['data']; |
1662 | 1660 | } |
1663 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
1661 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
1664 | 1662 | |
1665 | 1663 | $event_arr['link']['field'] = lang('URL'); |
1666 | 1664 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1681,7 +1679,7 @@ discard block |
||
1681 | 1679 | */ |
1682 | 1680 | $link_arr = array(); |
1683 | 1681 | $link_arr['text'] = $event['title']; |
1684 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
1682 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
1685 | 1683 | 'cal_id' => $event['id'], |
1686 | 1684 | 'date' => $eventStart_arr['full'], |
1687 | 1685 | ); |
@@ -1689,11 +1687,11 @@ discard block |
||
1689 | 1687 | $details['link_arr'] = $link_arr; |
1690 | 1688 | |
1691 | 1689 | $dis = array(); |
1692 | - foreach($disinvited as $uid) |
|
1690 | + foreach ($disinvited as $uid) |
|
1693 | 1691 | { |
1694 | 1692 | $dis[] = $this->participant_name($uid); |
1695 | 1693 | } |
1696 | - $details['disinvited'] = implode(', ',$dis); |
|
1694 | + $details['disinvited'] = implode(', ', $dis); |
|
1697 | 1695 | return $details; |
1698 | 1696 | } |
1699 | 1697 | |
@@ -1717,14 +1715,14 @@ discard block |
||
1717 | 1715 | 'data' => $event['description'] |
1718 | 1716 | ); |
1719 | 1717 | |
1720 | - foreach(explode(',',$event['category']) as $cat_id) |
|
1718 | + foreach (explode(',', $event['category']) as $cat_id) |
|
1721 | 1719 | { |
1722 | 1720 | list($cat) = $GLOBALS['egw']->categories->return_single($cat_id); |
1723 | 1721 | $cat_string[] = stripslashes($cat['name']); |
1724 | 1722 | } |
1725 | 1723 | $var['category'] = Array( |
1726 | 1724 | 'field' => lang('Category'), |
1727 | - 'data' => implode(', ',$cat_string) |
|
1725 | + 'data' => implode(', ', $cat_string) |
|
1728 | 1726 | ); |
1729 | 1727 | |
1730 | 1728 | $var['location'] = Array( |
@@ -1770,7 +1768,7 @@ discard block |
||
1770 | 1768 | |
1771 | 1769 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
1772 | 1770 | { |
1773 | - $participants = $this->participants($event,true); |
|
1771 | + $participants = $this->participants($event, true); |
|
1774 | 1772 | } |
1775 | 1773 | $var['participants'] = Array( |
1776 | 1774 | 'field' => lang('Participants'), |
@@ -1793,26 +1791,26 @@ discard block |
||
1793 | 1791 | * @param array $old_event =null event-data in the DB before calling save |
1794 | 1792 | * @param string $type ='update' |
1795 | 1793 | */ |
1796 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
1794 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
1797 | 1795 | { |
1798 | - if (!($f = fopen($this->log_file,'a'))) |
|
1796 | + if (!($f = fopen($this->log_file, 'a'))) |
|
1799 | 1797 | { |
1800 | 1798 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
1801 | 1799 | return false; |
1802 | 1800 | } |
1803 | - fwrite($f,$type.': '.common::grab_owner_name($this->user).': '.date('r')."\n"); |
|
1804 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
1805 | - foreach(array('start','end') as $name) |
|
1801 | + fwrite($f, $type.': '.common::grab_owner_name($this->user).': '.date('r')."\n"); |
|
1802 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
1803 | + foreach (array('start', 'end') as $name) |
|
1806 | 1804 | { |
1807 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1808 | - $this->format_date($event_saved[$name]) .' / '. |
|
1805 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
1806 | + $this->format_date($event_saved[$name]).' / '. |
|
1809 | 1807 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
1810 | 1808 | } |
1811 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
1809 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
1812 | 1810 | { |
1813 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
1811 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
1814 | 1812 | } |
1815 | - fwrite($f,"\n"); |
|
1813 | + fwrite($f, "\n"); |
|
1816 | 1814 | fclose($f); |
1817 | 1815 | |
1818 | 1816 | return true; |
@@ -1833,14 +1831,14 @@ discard block |
||
1833 | 1831 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
1834 | 1832 | |
1835 | 1833 | $time = new egw_time($event['start']); |
1836 | - if(!is_array($event['alarm'])) |
|
1834 | + if (!is_array($event['alarm'])) |
|
1837 | 1835 | { |
1838 | 1836 | $event['alarm'] = $this->so->read_alarms($event['id']); |
1839 | 1837 | } |
1840 | 1838 | |
1841 | - foreach($event['alarm'] as $id => &$alarm) |
|
1839 | + foreach ($event['alarm'] as $id => &$alarm) |
|
1842 | 1840 | { |
1843 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
1841 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
1844 | 1842 | { |
1845 | 1843 | calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts')); |
1846 | 1844 | } |
@@ -1860,14 +1858,14 @@ discard block |
||
1860 | 1858 | * @param boolean $update_modified =true call update modified, default true |
1861 | 1859 | * @return string id of the alarm, or false on error (eg. no perms) |
1862 | 1860 | */ |
1863 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
1861 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
1864 | 1862 | { |
1865 | - if (!$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
1863 | + if (!$cal_id || !$this->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
1866 | 1864 | { |
1867 | 1865 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
1868 | - return false; // no rights to add the alarm |
|
1866 | + return false; // no rights to add the alarm |
|
1869 | 1867 | } |
1870 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
1868 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
1871 | 1869 | |
1872 | 1870 | $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); |
1873 | 1871 | |
@@ -1882,11 +1880,11 @@ discard block |
||
1882 | 1880 | */ |
1883 | 1881 | function delete_alarm($id) |
1884 | 1882 | { |
1885 | - list(,$cal_id) = explode(':',$id); |
|
1883 | + list(,$cal_id) = explode(':', $id); |
|
1886 | 1884 | |
1887 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
1885 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
1888 | 1886 | { |
1889 | - return false; // no rights to delete the alarm |
|
1887 | + return false; // no rights to delete the alarm |
|
1890 | 1888 | } |
1891 | 1889 | |
1892 | 1890 | $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); |
@@ -1903,13 +1901,13 @@ discard block |
||
1903 | 1901 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
1904 | 1902 | * @return array category ids (found, added and preserved categories) |
1905 | 1903 | */ |
1906 | - function find_or_add_categories($catname_list, $old_event=null) |
|
1904 | + function find_or_add_categories($catname_list, $old_event = null) |
|
1907 | 1905 | { |
1908 | 1906 | if (is_array($old_event) || $old_event > 0) |
1909 | 1907 | { |
1910 | 1908 | // preserve categories without users read access |
1911 | 1909 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
1912 | - $old_categories = explode(',',$old_event['category']); |
|
1910 | + $old_categories = explode(',', $old_event['category']); |
|
1913 | 1911 | $old_cats_preserve = array(); |
1914 | 1912 | if (is_array($old_categories) && count($old_categories) > 0) |
1915 | 1913 | { |
@@ -1963,7 +1961,7 @@ discard block |
||
1963 | 1961 | { |
1964 | 1962 | if (!is_array($cat_id_list)) |
1965 | 1963 | { |
1966 | - $cat_id_list = explode(',',$cat_id_list); |
|
1964 | + $cat_id_list = explode(',', $cat_id_list); |
|
1967 | 1965 | } |
1968 | 1966 | $cat_list = array(); |
1969 | 1967 | foreach ($cat_id_list as $cat_id) |
@@ -1988,7 +1986,7 @@ discard block |
||
1988 | 1986 | * master -> try to find a releated series master |
1989 | 1987 | * @return array calendar_ids of matching entries |
1990 | 1988 | */ |
1991 | - function find_event($event, $filter='exact') |
|
1989 | + function find_event($event, $filter = 'exact') |
|
1992 | 1990 | { |
1993 | 1991 | $matchingEvents = array(); |
1994 | 1992 | $query = array(); |
@@ -1996,14 +1994,14 @@ discard block |
||
1996 | 1994 | if ($this->log) |
1997 | 1995 | { |
1998 | 1996 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
1999 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
1997 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
2000 | 1998 | } |
2001 | 1999 | |
2002 | 2000 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
2003 | 2001 | |
2004 | 2002 | if ($filter == 'master') |
2005 | 2003 | { |
2006 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
2004 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
2007 | 2005 | $query['cal_recurrence'] = 0; |
2008 | 2006 | } |
2009 | 2007 | elseif ($filter == 'exact') |
@@ -2024,14 +2022,14 @@ discard block |
||
2024 | 2022 | if ($this->log) |
2025 | 2023 | { |
2026 | 2024 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2027 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
2025 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
2028 | 2026 | } |
2029 | 2027 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
2030 | 2028 | { |
2031 | 2029 | if ($this->log) |
2032 | 2030 | { |
2033 | 2031 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2034 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2032 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2035 | 2033 | } |
2036 | 2034 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
2037 | 2035 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2050,7 +2048,7 @@ discard block |
||
2050 | 2048 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
2051 | 2049 | if (in_array($event['recurrence'], $exceptions)) |
2052 | 2050 | { |
2053 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
2051 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
2054 | 2052 | } |
2055 | 2053 | } |
2056 | 2054 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2069,19 +2067,19 @@ discard block |
||
2069 | 2067 | |
2070 | 2068 | // only query calendars of users, we have READ-grants from |
2071 | 2069 | $users = array(); |
2072 | - foreach(array_keys($this->grants) as $user) |
|
2070 | + foreach (array_keys($this->grants) as $user) |
|
2073 | 2071 | { |
2074 | 2072 | $user = trim($user); |
2075 | - if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user)) |
|
2073 | + if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY, 0, $user)) |
|
2076 | 2074 | { |
2077 | - if ($user && !in_array($user,$users)) // already added? |
|
2075 | + if ($user && !in_array($user, $users)) // already added? |
|
2078 | 2076 | { |
2079 | 2077 | $users[] = $user; |
2080 | 2078 | } |
2081 | 2079 | } |
2082 | 2080 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2083 | 2081 | { |
2084 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2082 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
2085 | 2083 | } |
2086 | 2084 | // the further code is only for real users |
2087 | 2085 | if (!is_numeric($user)) continue; |
@@ -2092,11 +2090,11 @@ discard block |
||
2092 | 2090 | $members = $GLOBALS['egw']->accounts->member($user); |
2093 | 2091 | if (is_array($members)) |
2094 | 2092 | { |
2095 | - foreach($members as $member) |
|
2093 | + foreach ($members as $member) |
|
2096 | 2094 | { |
2097 | 2095 | // use only members which gave the user a read-grant |
2098 | - if (!in_array($member['account_id'],$users) && |
|
2099 | - $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY,0,$member['account_id'])) |
|
2096 | + if (!in_array($member['account_id'], $users) && |
|
2097 | + $this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $member['account_id'])) |
|
2100 | 2098 | { |
2101 | 2099 | $users[] = $member['account_id']; |
2102 | 2100 | } |
@@ -2108,9 +2106,9 @@ discard block |
||
2108 | 2106 | $memberships = $GLOBALS['egw']->accounts->membership($user); |
2109 | 2107 | if (is_array($memberships)) |
2110 | 2108 | { |
2111 | - foreach($memberships as $group) |
|
2109 | + foreach ($memberships as $group) |
|
2112 | 2110 | { |
2113 | - if (!in_array($group['account_id'],$users)) |
|
2111 | + if (!in_array($group['account_id'], $users)) |
|
2114 | 2112 | { |
2115 | 2113 | $users[] = $group['account_id']; |
2116 | 2114 | } |
@@ -2134,24 +2132,24 @@ discard block |
||
2134 | 2132 | |
2135 | 2133 | // check length with some tolerance |
2136 | 2134 | $length = $event['end'] - $event['start'] - $delta; |
2137 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
2135 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
2138 | 2136 | $length += 2 * $delta; |
2139 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
2140 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
2141 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
2137 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
2138 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
2139 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
2142 | 2140 | } |
2143 | 2141 | elseif (isset($event['start'])) |
2144 | 2142 | { |
2145 | 2143 | if ($filter == 'relax') |
2146 | 2144 | { |
2147 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
2148 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
2145 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
2146 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
2149 | 2147 | } |
2150 | 2148 | else |
2151 | 2149 | { |
2152 | 2150 | // we accept a tiny tolerance |
2153 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
2154 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
2151 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
2152 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
2155 | 2153 | } |
2156 | 2154 | } |
2157 | 2155 | if ($filter == 'relax') |
@@ -2174,14 +2172,14 @@ discard block |
||
2174 | 2172 | if ($this->log) |
2175 | 2173 | { |
2176 | 2174 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2177 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
2175 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
2178 | 2176 | } |
2179 | 2177 | } |
2180 | 2178 | |
2181 | 2179 | if ($this->log) |
2182 | 2180 | { |
2183 | 2181 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2184 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
2182 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
2185 | 2183 | } |
2186 | 2184 | if (!count($users) || !($foundEvents = |
2187 | 2185 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2189,19 +2187,19 @@ discard block |
||
2189 | 2187 | if ($this->log) |
2190 | 2188 | { |
2191 | 2189 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2192 | - "[NO MATCH]\n",3,$this->logfile); |
|
2190 | + "[NO MATCH]\n", 3, $this->logfile); |
|
2193 | 2191 | } |
2194 | 2192 | return $matchingEvents; |
2195 | 2193 | } |
2196 | 2194 | |
2197 | 2195 | $pseudos = array(); |
2198 | 2196 | |
2199 | - foreach($foundEvents as $egwEvent) |
|
2197 | + foreach ($foundEvents as $egwEvent) |
|
2200 | 2198 | { |
2201 | 2199 | if ($this->log) |
2202 | 2200 | { |
2203 | 2201 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2204 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
2202 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
2205 | 2203 | } |
2206 | 2204 | |
2207 | 2205 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2275,7 +2273,7 @@ discard block |
||
2275 | 2273 | if (in_array($event['recurrence'], $exceptions)) |
2276 | 2274 | { |
2277 | 2275 | // We found a pseudo exception |
2278 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
2276 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
2279 | 2277 | break; |
2280 | 2278 | } |
2281 | 2279 | } |
@@ -2293,7 +2291,7 @@ discard block |
||
2293 | 2291 | if ($this->log) |
2294 | 2292 | { |
2295 | 2293 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2296 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
2294 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
2297 | 2295 | } |
2298 | 2296 | continue; |
2299 | 2297 | } |
@@ -2305,7 +2303,7 @@ discard block |
||
2305 | 2303 | if ($this->log) |
2306 | 2304 | { |
2307 | 2305 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2308 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
2306 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
2309 | 2307 | } |
2310 | 2308 | continue; |
2311 | 2309 | } |
@@ -2326,8 +2324,8 @@ discard block |
||
2326 | 2324 | if ($this->log) |
2327 | 2325 | { |
2328 | 2326 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2329 | - "() event[$key] differ: '" . $event[$key] . |
|
2330 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
2327 | + "() event[$key] differ: '".$event[$key]. |
|
2328 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
2331 | 2329 | } |
2332 | 2330 | continue 2; // next foundEvent |
2333 | 2331 | } |
@@ -2345,7 +2343,7 @@ discard block |
||
2345 | 2343 | if ($this->log) |
2346 | 2344 | { |
2347 | 2345 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2348 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
2346 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
2349 | 2347 | } |
2350 | 2348 | continue 2; |
2351 | 2349 | } |
@@ -2357,7 +2355,7 @@ discard block |
||
2357 | 2355 | { |
2358 | 2356 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2359 | 2357 | '() event has additional categories:' |
2360 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
2358 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
2361 | 2359 | } |
2362 | 2360 | continue; |
2363 | 2361 | } |
@@ -2377,7 +2375,7 @@ discard block |
||
2377 | 2375 | if ($this->log) |
2378 | 2376 | { |
2379 | 2377 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2380 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
2378 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
2381 | 2379 | } |
2382 | 2380 | continue 2; |
2383 | 2381 | } |
@@ -2400,8 +2398,8 @@ discard block |
||
2400 | 2398 | if ($this->log) |
2401 | 2399 | { |
2402 | 2400 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2403 | - '() missing event[participants]: ' . |
|
2404 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
2401 | + '() missing event[participants]: '. |
|
2402 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
2405 | 2403 | } |
2406 | 2404 | continue; |
2407 | 2405 | } |
@@ -2413,7 +2411,7 @@ discard block |
||
2413 | 2411 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
2414 | 2412 | { |
2415 | 2413 | // We found a pseudo Exception |
2416 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
2414 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
2417 | 2415 | continue; |
2418 | 2416 | } |
2419 | 2417 | } |
@@ -2435,7 +2433,7 @@ discard block |
||
2435 | 2433 | if ($this->log) |
2436 | 2434 | { |
2437 | 2435 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2438 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
2436 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
2439 | 2437 | } |
2440 | 2438 | continue 2; |
2441 | 2439 | } |
@@ -2445,8 +2443,8 @@ discard block |
||
2445 | 2443 | if ($this->log) |
2446 | 2444 | { |
2447 | 2445 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2448 | - '() missing event[recur_exception]: ' . |
|
2449 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
2446 | + '() missing event[recur_exception]: '. |
|
2447 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
2450 | 2448 | } |
2451 | 2449 | continue; |
2452 | 2450 | } |
@@ -2461,8 +2459,8 @@ discard block |
||
2461 | 2459 | if ($this->log) |
2462 | 2460 | { |
2463 | 2461 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2464 | - "() events[$key] differ: " . $event[$key] . |
|
2465 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
2462 | + "() events[$key] differ: ".$event[$key]. |
|
2463 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
2466 | 2464 | } |
2467 | 2465 | continue 2; |
2468 | 2466 | } |
@@ -2478,7 +2476,7 @@ discard block |
||
2478 | 2476 | if ($this->log) |
2479 | 2477 | { |
2480 | 2478 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2481 | - "() new exception for series found.\n",3,$this->logfile); |
|
2479 | + "() new exception for series found.\n", 3, $this->logfile); |
|
2482 | 2480 | } |
2483 | 2481 | $matchingEvents = array(); |
2484 | 2482 | } |
@@ -2489,7 +2487,7 @@ discard block |
||
2489 | 2487 | if ($this->log) |
2490 | 2488 | { |
2491 | 2489 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2492 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
2490 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
2493 | 2491 | } |
2494 | 2492 | return $matches; |
2495 | 2493 | } |
@@ -2562,7 +2560,7 @@ discard block |
||
2562 | 2560 | if ($this->log) |
2563 | 2561 | { |
2564 | 2562 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2565 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
2563 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
2566 | 2564 | } |
2567 | 2565 | $type = 'SERIES-EXCEPTION'; |
2568 | 2566 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2583,7 +2581,7 @@ discard block |
||
2583 | 2581 | } |
2584 | 2582 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
2585 | 2583 | { |
2586 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2584 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
2587 | 2585 | $recurrence_event = $master_event; |
2588 | 2586 | $recurrence_event['start'] = $event['start']; |
2589 | 2587 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2600,8 +2598,8 @@ discard block |
||
2600 | 2598 | if ($this->log) |
2601 | 2599 | { |
2602 | 2600 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2603 | - '() try occurrence ' . $egw_rrule->current() |
|
2604 | - . " ($occurrence)\n",3,$this->logfile); |
|
2601 | + '() try occurrence '.$egw_rrule->current() |
|
2602 | + . " ($occurrence)\n", 3, $this->logfile); |
|
2605 | 2603 | } |
2606 | 2604 | if ($event['start'] == $occurrence) |
2607 | 2605 | { |
@@ -2634,8 +2632,8 @@ discard block |
||
2634 | 2632 | // default if we cannot find a proof for a fundamental change |
2635 | 2633 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
2636 | 2634 | // check for changed data |
2637 | - foreach (array('start','end','uid','title','location','description', |
|
2638 | - 'priority','public','special','non_blocking') as $key) |
|
2635 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
2636 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
2639 | 2637 | { |
2640 | 2638 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
2641 | 2639 | { |
@@ -2693,10 +2691,10 @@ discard block |
||
2693 | 2691 | * @param &$event the event we are working on |
2694 | 2692 | * |
2695 | 2693 | */ |
2696 | - function server2usertime (&$event) |
|
2694 | + function server2usertime(&$event) |
|
2697 | 2695 | { |
2698 | 2696 | // we run all dates through date2usertime, to adjust to user-time |
2699 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
2697 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
2700 | 2698 | { |
2701 | 2699 | // we convert here from server-time to timestamps in user-time! |
2702 | 2700 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2704,7 +2702,7 @@ discard block |
||
2704 | 2702 | // same with the recur exceptions |
2705 | 2703 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
2706 | 2704 | { |
2707 | - foreach($event['recur_exception'] as $n => $date) |
|
2705 | + foreach ($event['recur_exception'] as $n => $date) |
|
2708 | 2706 | { |
2709 | 2707 | $event['recur_exception'][$n] = $this->date2usertime($date); |
2710 | 2708 | } |
@@ -2712,7 +2710,7 @@ discard block |
||
2712 | 2710 | // same with the alarms |
2713 | 2711 | if (isset($event['alarm']) && is_array($event['alarm'])) |
2714 | 2712 | { |
2715 | - foreach($event['alarm'] as $id => $alarm) |
|
2713 | + foreach ($event['alarm'] as $id => $alarm) |
|
2716 | 2714 | { |
2717 | 2715 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
2718 | 2716 | } |
@@ -2729,7 +2727,7 @@ discard block |
||
2729 | 2727 | { |
2730 | 2728 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
2731 | 2729 | { |
2732 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
2730 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
2733 | 2731 | } |
2734 | 2732 | } |
2735 | 2733 | } |
@@ -81,11 +81,17 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function __construct() |
83 | 83 | { |
84 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
84 | + if ($this->debug > 0) |
|
85 | + { |
|
86 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
87 | + } |
|
85 | 88 | |
86 | 89 | parent::__construct(); // calling the parent constructor |
87 | 90 | |
88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
91 | + if ($this->debug > 0) |
|
92 | + { |
|
93 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
94 | + } |
|
89 | 95 | } |
90 | 96 | |
91 | 97 | /** |
@@ -115,7 +121,10 @@ discard block |
||
115 | 121 | function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
116 | 122 | { |
117 | 123 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
118 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
124 | + if (!is_array($messages)) |
|
125 | + { |
|
126 | + $messages = $messages ? (array)$messages : array(); |
|
127 | + } |
|
119 | 128 | |
120 | 129 | if ($this->debug > 1 || $this->debug == 'update') |
121 | 130 | { |
@@ -135,10 +144,13 @@ discard block |
||
135 | 144 | |
136 | 145 | $status_reset_to_unknown = false; |
137 | 146 | |
138 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
147 | + if (($new_event = !$event['id'])) |
|
148 | + { |
|
149 | + // some defaults for new entries |
|
139 | 150 | { |
140 | 151 | // if no owner given, set user to owner |
141 | 152 | if (!$event['owner']) $event['owner'] = $this->user; |
153 | + } |
|
142 | 154 | // set owner as participant if none is given |
143 | 155 | if (!is_array($event['participants']) || !count($event['participants'])) |
144 | 156 | { |
@@ -178,7 +190,10 @@ discard block |
||
178 | 190 | // check category based ACL |
179 | 191 | if ($event['category']) |
180 | 192 | { |
181 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
193 | + if (!is_array($event['category'])) |
|
194 | + { |
|
195 | + $event['category'] = explode(',',$event['category']); |
|
196 | + } |
|
182 | 197 | if (!$old_event || !isset($old_event['category'])) |
183 | 198 | { |
184 | 199 | $old_event['category'] = array(); |
@@ -231,18 +246,28 @@ discard block |
||
231 | 246 | $types_with_quantity = array(); |
232 | 247 | foreach($this->resources as $type => $data) |
233 | 248 | { |
234 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
249 | + if ($data['max_quantity']) |
|
250 | + { |
|
251 | + $types_with_quantity[] = $type; |
|
252 | + } |
|
235 | 253 | } |
236 | 254 | // get all NOT rejected participants and evtl. their quantity |
237 | 255 | $quantity = $users = array(); |
238 | 256 | foreach($event['participants'] as $uid => $status) |
239 | 257 | { |
240 | 258 | calendar_so::split_status($status,$q,$r); |
241 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
259 | + if ($status[0] == 'R') |
|
260 | + { |
|
261 | + continue; |
|
262 | + } |
|
263 | + // ignore rejected participants |
|
242 | 264 | |
243 | - if ($uid < 0) // group, check it's members too |
|
265 | + if ($uid < 0) |
|
266 | + { |
|
267 | + // group, check it's members too |
|
244 | 268 | { |
245 | 269 | $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
270 | + } |
|
246 | 271 | $users = array_unique($users); |
247 | 272 | } |
248 | 273 | $users[] = $uid; |
@@ -273,10 +298,13 @@ discard block |
||
273 | 298 | { |
274 | 299 | if ($overlap['id'] == $event['id'] || // that's the event itself |
275 | 300 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
276 | - $overlap['non_blocking']) // that's a non_blocking event |
|
301 | + $overlap['non_blocking']) |
|
302 | + { |
|
303 | + // that's a non_blocking event |
|
277 | 304 | { |
278 | 305 | continue; |
279 | 306 | } |
307 | + } |
|
280 | 308 | if ($this->debug > 3 || $this->debug == 'update') |
281 | 309 | { |
282 | 310 | $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
@@ -434,7 +462,11 @@ discard block |
||
434 | 462 | */ |
435 | 463 | public function check_acl_invite($uid) |
436 | 464 | { |
437 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
465 | + if (!is_numeric($uid)) |
|
466 | + { |
|
467 | + return true; |
|
468 | + } |
|
469 | + // nothing implemented for resources so far |
|
438 | 470 | |
439 | 471 | if (!$this->require_acl_invite) |
440 | 472 | { |
@@ -775,14 +807,20 @@ discard block |
||
775 | 807 | $startdate = new egw_time($event['start']); |
776 | 808 | $enddate = new egw_time($event['end']); |
777 | 809 | $modified = new egw_time($event['modified']); |
778 | - if ($old_event) $olddate = new egw_time($old_event['start']); |
|
810 | + if ($old_event) |
|
811 | + { |
|
812 | + $olddate = new egw_time($old_event['start']); |
|
813 | + } |
|
779 | 814 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
780 | 815 | $owner_prefs = $ics = null; |
781 | 816 | foreach($to_notify as $userid => $statusid) |
782 | 817 | { |
783 | 818 | $res_info = $quantity = $role = null; |
784 | 819 | calendar_so::split_status($statusid, $quantity, $role); |
785 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
820 | + if ($this->debug > 0) |
|
821 | + { |
|
822 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
823 | + } |
|
786 | 824 | |
787 | 825 | if (!is_numeric($userid)) |
788 | 826 | { |
@@ -801,7 +839,11 @@ discard block |
||
801 | 839 | |
802 | 840 | if (!isset($userid)) |
803 | 841 | { |
804 | - if (empty($res_info['email'])) continue; // no way to notify |
|
842 | + if (empty($res_info['email'])) |
|
843 | + { |
|
844 | + continue; |
|
845 | + } |
|
846 | + // no way to notify |
|
805 | 847 | // check if event-owner wants non-EGroupware users notified |
806 | 848 | if (is_null($owner_prefs)) |
807 | 849 | { |
@@ -866,11 +908,20 @@ discard block |
||
866 | 908 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
867 | 909 | $action, $event_arr, $disinvited); |
868 | 910 | $details['to-fullname'] = $fullname; |
869 | - if (isset($tfn)) $details['to-firstname'] = $tfn; |
|
870 | - if (isset($tln)) $details['to-lastname'] = $tln; |
|
911 | + if (isset($tfn)) |
|
912 | + { |
|
913 | + $details['to-firstname'] = $tfn; |
|
914 | + } |
|
915 | + if (isset($tln)) |
|
916 | + { |
|
917 | + $details['to-lastname'] = $tln; |
|
918 | + } |
|
871 | 919 | |
872 | 920 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
873 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
921 | + if (!isset($part_prefs['common']['tz'])) |
|
922 | + { |
|
923 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
924 | + } |
|
874 | 925 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
875 | 926 | $timeformat = $part_prefs['common']['timeformat']; |
876 | 927 | switch($timeformat) |
@@ -905,9 +956,12 @@ discard block |
||
905 | 956 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
906 | 957 | { |
907 | 958 | case 'ical': |
908 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
959 | + if (is_null($ics) || $m_type != $msg_type) |
|
960 | + { |
|
961 | + // need different ical for organizer notification |
|
909 | 962 | { |
910 | 963 | $calendar_ical = new calendar_ical(); |
964 | + } |
|
911 | 965 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
912 | 966 | // we need to pass $event[id] so iCal class reads event again, |
913 | 967 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -921,7 +975,10 @@ discard block |
||
921 | 975 | 'encoding' => '8bit', |
922 | 976 | 'type' => 'text/calendar; method='.$method, |
923 | 977 | ); |
924 | - if ($m_type != $msg_type) unset($ics); |
|
978 | + if ($m_type != $msg_type) |
|
979 | + { |
|
980 | + unset($ics); |
|
981 | + } |
|
925 | 982 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
926 | 983 | // fall through |
927 | 984 | case 'extended': |
@@ -972,7 +1029,9 @@ discard block |
||
972 | 1029 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
973 | 1030 | $notification->set_popuplinks(array($details['link_arr'])); |
974 | 1031 | |
975 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
1032 | + if(is_array($attachment)) |
|
1033 | + { |
|
1034 | +$notification->set_attachments(array($attachment)); } |
|
976 | 1035 | $notification->send(); |
977 | 1036 | } |
978 | 1037 | catch (Exception $exception) { |
@@ -999,7 +1058,10 @@ discard block |
||
999 | 1058 | translation::init(); |
1000 | 1059 | } |
1001 | 1060 | // restore timezone, in case we had to reset it to server-timezone |
1002 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
1061 | + if ($restore_tz) |
|
1062 | + { |
|
1063 | + date_default_timezone_set($restore_tz); |
|
1064 | + } |
|
1003 | 1065 | |
1004 | 1066 | return true; |
1005 | 1067 | } |
@@ -1034,10 +1096,13 @@ discard block |
||
1034 | 1096 | { |
1035 | 1097 | $to_notify = $event['participants']; |
1036 | 1098 | } |
1037 | - elseif ($this->check_perms(EGW_ACL_READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
1099 | + elseif ($this->check_perms(EGW_ACL_READ,$event)) |
|
1100 | + { |
|
1101 | + // checks agains $this->owner set to $alarm[owner] |
|
1038 | 1102 | { |
1039 | 1103 | $to_notify[$alarm['owner']] = 'A'; |
1040 | 1104 | } |
1105 | + } |
|
1041 | 1106 | else |
1042 | 1107 | { |
1043 | 1108 | return False; // no rights |
@@ -1087,7 +1152,10 @@ discard block |
||
1087 | 1152 | if ($event['id']) |
1088 | 1153 | { |
1089 | 1154 | // invalidate the read-cache if it contains the event we store now |
1090 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
1155 | + if ($event['id'] == self::$cached_event['id']) |
|
1156 | + { |
|
1157 | + self::$cached_event = array(); |
|
1158 | + } |
|
1091 | 1159 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
1092 | 1160 | } |
1093 | 1161 | else |
@@ -1095,7 +1163,10 @@ discard block |
||
1095 | 1163 | $old_event = null; |
1096 | 1164 | } |
1097 | 1165 | |
1098 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
1166 | + if (!isset($event['whole_day'])) |
|
1167 | + { |
|
1168 | + $event['whole_day'] = $this->isWholeDay($event); |
|
1169 | + } |
|
1099 | 1170 | $save_event = $event; |
1100 | 1171 | if ($event['whole_day']) |
1101 | 1172 | { |
@@ -1136,7 +1207,10 @@ discard block |
||
1136 | 1207 | foreach($timestamps as $ts) |
1137 | 1208 | { |
1138 | 1209 | // we convert here from user-time to timestamps in server-time! |
1139 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1210 | + if (isset($event[$ts])) |
|
1211 | + { |
|
1212 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
1213 | + } |
|
1140 | 1214 | } |
1141 | 1215 | // convert tzid name to integer tz_id, of set user default |
1142 | 1216 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1186,7 +1260,10 @@ discard block |
||
1186 | 1260 | if (!isset($event['alarm'][$id])) |
1187 | 1261 | { |
1188 | 1262 | $alarm['time'] = $event['start'] - $alarm['offset']; |
1189 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
1263 | + if ($alarm['time'] < time()) |
|
1264 | + { |
|
1265 | + calendar_so::shift_alarm($event, $alarm); |
|
1266 | + } |
|
1190 | 1267 | // remove (not store) alarms belonging to not longer existing or rejected participants |
1191 | 1268 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
1192 | 1269 | $old_event['participants'][$alarm['owner']]; |
@@ -1222,7 +1299,10 @@ discard block |
||
1222 | 1299 | unset($save_event['participants']); |
1223 | 1300 | $this->set_recurrences($save_event, $set_recurrences_start); |
1224 | 1301 | } |
1225 | - if ($updateTS) $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
1302 | + if ($updateTS) |
|
1303 | + { |
|
1304 | + $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now); |
|
1305 | + } |
|
1226 | 1306 | |
1227 | 1307 | // create links for new participants from addressbook, if configured |
1228 | 1308 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
@@ -1240,7 +1320,10 @@ discard block |
||
1240 | 1320 | |
1241 | 1321 | // Update history |
1242 | 1322 | $tracking = new calendar_tracking($this); |
1243 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
1323 | + if (empty($event['id']) && !empty($cal_id)) |
|
1324 | + { |
|
1325 | + $event['id']=$cal_id; |
|
1326 | + } |
|
1244 | 1327 | $tracking->track($event, $old_event); |
1245 | 1328 | |
1246 | 1329 | return $cal_id; |
@@ -1257,9 +1340,12 @@ discard block |
||
1257 | 1340 | */ |
1258 | 1341 | function check_status_perms($uid,$event) |
1259 | 1342 | { |
1260 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
1343 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
1344 | + { |
|
1345 | + // for contact we use the owner of the event |
|
1261 | 1346 | { |
1262 | 1347 | if (!is_array($event) && !($event = $this->read($event))) return false; |
1348 | + } |
|
1263 | 1349 | |
1264 | 1350 | return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']); |
1265 | 1351 | } |
@@ -1270,13 +1356,19 @@ discard block |
||
1270 | 1356 | return $access; |
1271 | 1357 | } |
1272 | 1358 | // no access or denied access because of category acl --> regular check |
1273 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
1359 | + if (!is_numeric($uid)) |
|
1360 | + { |
|
1361 | + // this is eg. for resources (r123) |
|
1274 | 1362 | { |
1275 | 1363 | $resource = $this->resource_info($uid); |
1364 | + } |
|
1276 | 1365 | |
1277 | 1366 | return EGW_ACL_EDIT & $resource['rights']; |
1278 | 1367 | } |
1279 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
1368 | + if (!is_array($event) && !($event = $this->read($event))) |
|
1369 | + { |
|
1370 | + return false; |
|
1371 | + } |
|
1280 | 1372 | |
1281 | 1373 | // regular user and groups (need to check memberships too) |
1282 | 1374 | if (!isset($event['participants'][$uid])) |
@@ -1300,7 +1392,10 @@ discard block |
||
1300 | 1392 | */ |
1301 | 1393 | function check_cat_acl($right,$event) |
1302 | 1394 | { |
1303 | - if (!is_array($event)) $event = $this->read($event); |
|
1395 | + if (!is_array($event)) |
|
1396 | + { |
|
1397 | + $event = $this->read($event); |
|
1398 | + } |
|
1304 | 1399 | |
1305 | 1400 | $ret = null; |
1306 | 1401 | if ($event['category']) |
@@ -1357,7 +1452,10 @@ discard block |
||
1357 | 1452 | public static function set_cat_rights($cat_id,$user,$rights) |
1358 | 1453 | { |
1359 | 1454 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
1360 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
1455 | + if (!isset(self::$cat_rights_cache)) |
|
1456 | + { |
|
1457 | + self::get_cat_rights($cat_id); |
|
1458 | + } |
|
1361 | 1459 | |
1362 | 1460 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
1363 | 1461 | { |
@@ -1369,7 +1467,10 @@ discard block |
||
1369 | 1467 | else |
1370 | 1468 | { |
1371 | 1469 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
1372 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1470 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
1471 | + { |
|
1472 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
1473 | + } |
|
1373 | 1474 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
1374 | 1475 | } |
1375 | 1476 | egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1402,7 +1503,10 @@ discard block |
||
1402 | 1503 | foreach($cat_rights as $uid => $value) |
1403 | 1504 | { |
1404 | 1505 | $all |= $value; |
1405 | - if (in_array($uid,$memberships)) $own |= $value; |
|
1506 | + if (in_array($uid,$memberships)) |
|
1507 | + { |
|
1508 | + $own |= $value; |
|
1509 | + } |
|
1406 | 1510 | } |
1407 | 1511 | } |
1408 | 1512 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1449,13 +1553,16 @@ discard block |
||
1449 | 1553 | is_numeric($uid)?$uid:substr($uid,1),$status, |
1450 | 1554 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
1451 | 1555 | { |
1452 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
1556 | + if ($status == 'R') |
|
1557 | + { |
|
1558 | + // remove alarms belonging to rejected participants |
|
1453 | 1559 | { |
1454 | 1560 | foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
1455 | 1561 | { |
1456 | 1562 | if ((string)$alarm['owner'] === (string)$uid) |
1457 | 1563 | { |
1458 | 1564 | $this->so->delete_alarm($id); |
1565 | + } |
|
1459 | 1566 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
1460 | 1567 | } |
1461 | 1568 | } |
@@ -1473,8 +1580,15 @@ discard block |
||
1473 | 1580 | ); |
1474 | 1581 | if (isset($status2msg[$status]) && !$skip_notification) |
1475 | 1582 | { |
1476 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
1477 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
1583 | + if (!is_array($event)) |
|
1584 | + { |
|
1585 | + $event = $this->read($cal_id); |
|
1586 | + } |
|
1587 | + if (isset($recur_date)) |
|
1588 | + { |
|
1589 | + $event = $this->read($event['id'],$recur_date); |
|
1590 | + } |
|
1591 | + //re-read the actually edited recurring event |
|
1478 | 1592 | $this->send_update($status2msg[$status],$event['participants'],$event); |
1479 | 1593 | } |
1480 | 1594 | |
@@ -1497,12 +1611,16 @@ discard block |
||
1497 | 1611 | */ |
1498 | 1612 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
1499 | 1613 | { |
1500 | - if (!isset($new_event['participants'])) return; |
|
1614 | + if (!isset($new_event['participants'])) |
|
1615 | + { |
|
1616 | + return; |
|
1617 | + } |
|
1501 | 1618 | |
1502 | 1619 | // check the old list against the new list |
1503 | 1620 | foreach ($old_event['participants'] as $userid => $status) |
1504 | - { |
|
1505 | - if (!isset($new_event['participants'][$userid])){ |
|
1621 | + { |
|
1622 | + if (!isset($new_event['participants'][$userid])) |
|
1623 | + { |
|
1506 | 1624 | // Attendee will be deleted this way |
1507 | 1625 | $new_event['participants'][$userid] = 'G'; |
1508 | 1626 | } |
@@ -1586,7 +1704,10 @@ discard block |
||
1586 | 1704 | } |
1587 | 1705 | else |
1588 | 1706 | { |
1589 | - if (!($exception = $this->read($id))) continue; |
|
1707 | + if (!($exception = $this->read($id))) |
|
1708 | + { |
|
1709 | + continue; |
|
1710 | + } |
|
1590 | 1711 | $exception['uid'] = common::generate_uid('calendar', $id); |
1591 | 1712 | $exception['reference'] = $exception['recurrence'] = 0; |
1592 | 1713 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1657,7 +1778,10 @@ discard block |
||
1657 | 1778 | $event_arr = $this->event2array($event); |
1658 | 1779 | foreach($event_arr as $key => $val) |
1659 | 1780 | { |
1660 | - if ($key == 'recur_type') $key = 'repetition'; |
|
1781 | + if ($key == 'recur_type') |
|
1782 | + { |
|
1783 | + $key = 'repetition'; |
|
1784 | + } |
|
1661 | 1785 | $details[$key] = $val['data']; |
1662 | 1786 | } |
1663 | 1787 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1830,7 +1954,10 @@ discard block |
||
1830 | 1954 | */ |
1831 | 1955 | function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null) |
1832 | 1956 | { |
1833 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
1957 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
1958 | + { |
|
1959 | + return; |
|
1960 | + } |
|
1834 | 1961 | |
1835 | 1962 | $time = new egw_time($event['start']); |
1836 | 1963 | if(!is_array($event['alarm'])) |
@@ -1908,7 +2035,10 @@ discard block |
||
1908 | 2035 | if (is_array($old_event) || $old_event > 0) |
1909 | 2036 | { |
1910 | 2037 | // preserve categories without users read access |
1911 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
2038 | + if (!is_array($old_event)) |
|
2039 | + { |
|
2040 | + $old_event = $this->read($old_event); |
|
2041 | + } |
|
1912 | 2042 | $old_categories = explode(',',$old_event['category']); |
1913 | 2043 | $old_cats_preserve = array(); |
1914 | 2044 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -1999,7 +2129,10 @@ discard block |
||
1999 | 2129 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
2000 | 2130 | } |
2001 | 2131 | |
2002 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
2132 | + if (!isset($event['recurrence'])) |
|
2133 | + { |
|
2134 | + $event['recurrence'] = 0; |
|
2135 | + } |
|
2003 | 2136 | |
2004 | 2137 | if ($filter == 'master') |
2005 | 2138 | { |
@@ -2053,19 +2186,26 @@ discard block |
||
2053 | 2186 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
2054 | 2187 | } |
2055 | 2188 | } |
2056 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
2189 | + } |
|
2190 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
2057 | 2191 | $event['recur_type'] == $egwEvent['recur_type'] && |
2058 | 2192 | strpos($egwEvent['title'], $event['title']) === 0)) |
2059 | 2193 | { |
2060 | 2194 | $matchingEvents[] = $egwEvent['id']; // we found the event |
2061 | 2195 | } |
2062 | 2196 | } |
2063 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
2197 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
2198 | + { |
|
2199 | + return $matchingEvents; |
|
2200 | + } |
|
2064 | 2201 | } |
2065 | 2202 | unset($event['id']); |
2066 | 2203 | |
2067 | 2204 | // No chance to find a master without [U]ID |
2068 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
2205 | + if ($filter == 'master' && empty($event['uid'])) |
|
2206 | + { |
|
2207 | + return $matchingEvents; |
|
2208 | + } |
|
2069 | 2209 | |
2070 | 2210 | // only query calendars of users, we have READ-grants from |
2071 | 2211 | $users = array(); |
@@ -2074,17 +2214,23 @@ discard block |
||
2074 | 2214 | $user = trim($user); |
2075 | 2215 | if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user)) |
2076 | 2216 | { |
2077 | - if ($user && !in_array($user,$users)) // already added? |
|
2217 | + if ($user && !in_array($user,$users)) |
|
2218 | + { |
|
2219 | + // already added? |
|
2078 | 2220 | { |
2079 | 2221 | $users[] = $user; |
2080 | 2222 | } |
2223 | + } |
|
2081 | 2224 | } |
2082 | 2225 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
2083 | 2226 | { |
2084 | 2227 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
2085 | 2228 | } |
2086 | 2229 | // the further code is only for real users |
2087 | - if (!is_numeric($user)) continue; |
|
2230 | + if (!is_numeric($user)) |
|
2231 | + { |
|
2232 | + continue; |
|
2233 | + } |
|
2088 | 2234 | |
2089 | 2235 | // for groups we have to include the members |
2090 | 2236 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2164,7 +2310,10 @@ discard block |
||
2164 | 2310 | } |
2165 | 2311 | foreach ($matchFields as $key) |
2166 | 2312 | { |
2167 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
2313 | + if (isset($event[$key])) |
|
2314 | + { |
|
2315 | + $query['cal_'.$key] = $event[$key]; |
|
2316 | + } |
|
2168 | 2317 | } |
2169 | 2318 | } |
2170 | 2319 | |
@@ -2204,7 +2353,10 @@ discard block |
||
2204 | 2353 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
2205 | 2354 | } |
2206 | 2355 | |
2207 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
2356 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
2357 | + { |
|
2358 | + continue; |
|
2359 | + } |
|
2208 | 2360 | |
2209 | 2361 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
2210 | 2362 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2371,13 +2523,16 @@ discard block |
||
2371 | 2523 | foreach ($event['participants'] as $attendee => $status) |
2372 | 2524 | { |
2373 | 2525 | if (!isset($egwEvent['participants'][$attendee]) && |
2374 | - $attendee != $egwEvent['owner']) // || |
|
2526 | + $attendee != $egwEvent['owner']) |
|
2527 | + { |
|
2528 | + // || |
|
2375 | 2529 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
2376 | 2530 | { |
2377 | 2531 | if ($this->log) |
2378 | 2532 | { |
2379 | 2533 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
2380 | 2534 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
2535 | + } |
|
2381 | 2536 | } |
2382 | 2537 | continue 2; |
2383 | 2538 | } |
@@ -2699,7 +2854,10 @@ discard block |
||
2699 | 2854 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
2700 | 2855 | { |
2701 | 2856 | // we convert here from server-time to timestamps in user-time! |
2702 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
2857 | + if (isset($event[$ts])) |
|
2858 | + { |
|
2859 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
2860 | + } |
|
2703 | 2861 | } |
2704 | 2862 | // same with the recur exceptions |
2705 | 2863 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2727,9 +2885,12 @@ discard block |
||
2727 | 2885 | */ |
2728 | 2886 | function purge($age) |
2729 | 2887 | { |
2730 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
2888 | + if (is_numeric($age) && $age > 0) |
|
2889 | + { |
|
2890 | + // just make sure bogus values dont delete everything |
|
2731 | 2891 | { |
2732 | 2892 | $this->so->purge(time() - 365*24*3600*(float)$age); |
2733 | 2893 | } |
2894 | + } |
|
2734 | 2895 | } |
2735 | 2896 | } |
@@ -1707,12 +1707,12 @@ discard block |
||
1707 | 1707 | */ |
1708 | 1708 | function event2array($event) |
1709 | 1709 | { |
1710 | - $var['title'] = Array( |
|
1710 | + $var['title'] = array( |
|
1711 | 1711 | 'field' => lang('Title'), |
1712 | 1712 | 'data' => $event['title'] |
1713 | 1713 | ); |
1714 | 1714 | |
1715 | - $var['description'] = Array( |
|
1715 | + $var['description'] = array( |
|
1716 | 1716 | 'field' => lang('Description'), |
1717 | 1717 | 'data' => $event['description'] |
1718 | 1718 | ); |
@@ -1722,48 +1722,48 @@ discard block |
||
1722 | 1722 | list($cat) = $GLOBALS['egw']->categories->return_single($cat_id); |
1723 | 1723 | $cat_string[] = stripslashes($cat['name']); |
1724 | 1724 | } |
1725 | - $var['category'] = Array( |
|
1725 | + $var['category'] = array( |
|
1726 | 1726 | 'field' => lang('Category'), |
1727 | 1727 | 'data' => implode(', ',$cat_string) |
1728 | 1728 | ); |
1729 | 1729 | |
1730 | - $var['location'] = Array( |
|
1730 | + $var['location'] = array( |
|
1731 | 1731 | 'field' => lang('Location'), |
1732 | 1732 | 'data' => $event['location'] |
1733 | 1733 | ); |
1734 | 1734 | |
1735 | - $var['startdate'] = Array( |
|
1735 | + $var['startdate'] = array( |
|
1736 | 1736 | 'field' => lang('Start Date/Time'), |
1737 | 1737 | 'data' => $this->format_date($event['start']), |
1738 | 1738 | ); |
1739 | 1739 | |
1740 | - $var['enddate'] = Array( |
|
1740 | + $var['enddate'] = array( |
|
1741 | 1741 | 'field' => lang('End Date/Time'), |
1742 | 1742 | 'data' => $this->format_date($event['end']), |
1743 | 1743 | ); |
1744 | 1744 | |
1745 | - $pri = Array( |
|
1745 | + $pri = array( |
|
1746 | 1746 | 0 => lang('None'), |
1747 | 1747 | 1 => lang('Low'), |
1748 | 1748 | 2 => lang('Normal'), |
1749 | 1749 | 3 => lang('High') |
1750 | 1750 | ); |
1751 | - $var['priority'] = Array( |
|
1751 | + $var['priority'] = array( |
|
1752 | 1752 | 'field' => lang('Priority'), |
1753 | 1753 | 'data' => $pri[$event['priority']] |
1754 | 1754 | ); |
1755 | 1755 | |
1756 | - $var['owner'] = Array( |
|
1756 | + $var['owner'] = array( |
|
1757 | 1757 | 'field' => lang('Owner'), |
1758 | 1758 | 'data' => common::grab_owner_name($event['owner']) |
1759 | 1759 | ); |
1760 | 1760 | |
1761 | - $var['updated'] = Array( |
|
1761 | + $var['updated'] = array( |
|
1762 | 1762 | 'field' => lang('Updated'), |
1763 | 1763 | 'data' => $this->format_date($event['modtime']).', '.common::grab_owner_name($event['modifier']) |
1764 | 1764 | ); |
1765 | 1765 | |
1766 | - $var['access'] = Array( |
|
1766 | + $var['access'] = array( |
|
1767 | 1767 | 'field' => lang('Access'), |
1768 | 1768 | 'data' => $event['public'] ? lang('Public') : lang('Private') |
1769 | 1769 | ); |
@@ -1772,13 +1772,13 @@ discard block |
||
1772 | 1772 | { |
1773 | 1773 | $participants = $this->participants($event,true); |
1774 | 1774 | } |
1775 | - $var['participants'] = Array( |
|
1775 | + $var['participants'] = array( |
|
1776 | 1776 | 'field' => lang('Participants'), |
1777 | 1777 | 'data' => $participants |
1778 | 1778 | ); |
1779 | 1779 | |
1780 | 1780 | // Repeated Events |
1781 | - $var['recur_type'] = Array( |
|
1781 | + $var['recur_type'] = array( |
|
1782 | 1782 | 'field' => lang('Repetition'), |
1783 | 1783 | 'data' => ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '', |
1784 | 1784 | ); |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | * @param egw_time $instance_date For recurring events, this is the date we |
1829 | 1829 | * are dealing with |
1830 | 1830 | */ |
1831 | - function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null) |
|
1831 | + function check_move_alarms(array &$event, array $old_event = null, egw_time $instance_date = null) |
|
1832 | 1832 | { |
1833 | 1833 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
1834 | 1834 |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @param string $path |
317 | 317 | * @param array $filter |
318 | - * @param array|boolean $start =false false=return all or array(start,num) |
|
318 | + * @param integer[] $start =false false=return all or array(start,num) |
|
319 | 319 | * @return array with "files" array with values for keys path and props |
320 | 320 | */ |
321 | 321 | function propfind_callback($path,array $filter,$start=false) |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @param array &$options |
621 | 621 | * @param int $id |
622 | 622 | * @param int $user =null account_id |
623 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
623 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
624 | 624 | */ |
625 | 625 | function get(&$options,$id,$user=null) |
626 | 626 | { |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | * Check if $user is a participant of given $event incl. group-invitations |
794 | 794 | * |
795 | 795 | * @param array $event |
796 | - * @param int|string $user |
|
796 | + * @param integer $user |
|
797 | 797 | * @return boolean |
798 | 798 | */ |
799 | 799 | public static function isParticipant(array $event, $user) |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @param int $id |
811 | 811 | * @param int $user =null account_id of owner, default null |
812 | 812 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
813 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
813 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
814 | 814 | */ |
815 | 815 | function put(&$options,$id,$user=null,$prefix=null) |
816 | 816 | { |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | * @param array &$options |
1039 | 1039 | * @param int $id |
1040 | 1040 | * @param int $user =null account_id of owner, default null |
1041 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1041 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1042 | 1042 | */ |
1043 | 1043 | function post(&$options,$id,$user=null) |
1044 | 1044 | { |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * @param string $charset of ical |
1113 | 1113 | * @param int $user account_id of owner |
1114 | 1114 | * @param array &$options |
1115 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1115 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1116 | 1116 | */ |
1117 | 1117 | protected function outbox_freebusy_request($ical, $charset, $user, array &$options) |
1118 | 1118 | { |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | * @param string $path |
1188 | 1188 | * @param array $options |
1189 | 1189 | * @param int $user account_id |
1190 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1190 | + * @return string|null boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1191 | 1191 | */ |
1192 | 1192 | function free_busy_report($path,$options,$user) |
1193 | 1193 | { |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | /** |
1417 | 1417 | * Query ctag for calendar |
1418 | 1418 | * |
1419 | - * @return string |
|
1419 | + * @return integer |
|
1420 | 1420 | */ |
1421 | 1421 | public function getctag($path,$user) |
1422 | 1422 | { |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | * |
1433 | 1433 | * @param array|int $entry array with event or cal_id |
1434 | 1434 | * @param string $schedule_tag =null on return schedule-tag |
1435 | - * @return string|boolean string with etag or false |
|
1435 | + * @return string string with etag or false |
|
1436 | 1436 | */ |
1437 | 1437 | function get_etag($entry, &$schedule_tag=null) |
1438 | 1438 | { |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | * |
1450 | 1450 | * @param int|array $entry id or array of new created entry |
1451 | 1451 | * @param string $path |
1452 | - * @param int|string $retval |
|
1452 | + * @param string|boolean $retval |
|
1453 | 1453 | * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header) |
1454 | 1454 | */ |
1455 | 1455 | function put_response_headers($entry, $path, $retval, $path_attr_is_name=true) |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $id ='' |
139 | 139 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
140 | 140 | */ |
141 | - function propfind($path,&$options,&$files,$user,$id='') |
|
141 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
142 | 142 | { |
143 | 143 | if ($this->debug) |
144 | 144 | { |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | 'enum_recuring' => false, |
165 | 165 | 'daywise' => false, |
166 | 166 | 'date_format' => 'server', |
167 | - 'no_total' => true, // we need no total number of rows (saves extra query) |
|
168 | - 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
167 | + 'no_total' => true, // we need no total number of rows (saves extra query) |
|
168 | + 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
169 | 169 | ); |
170 | - foreach(array( |
|
170 | + foreach (array( |
|
171 | 171 | 'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'], |
172 | 172 | 'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'], |
173 | 173 | ) as $name => $value) |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT; |
178 | 178 | } |
179 | - $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
|
179 | + $filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value); |
|
180 | 180 | } |
181 | 181 | if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
182 | 182 | { |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | $filter['filter'] = 'owner'; |
189 | 189 | } |
190 | 190 | // scheduling inbox, shows only not yet accepted or rejected events |
191 | - elseif (substr($path,-7) == '/inbox/') |
|
191 | + elseif (substr($path, -7) == '/inbox/') |
|
192 | 192 | { |
193 | 193 | $filter['filter'] = 'unknown'; |
194 | - $filter['start'] = $this->bo->now; // only return future invitations |
|
194 | + $filter['start'] = $this->bo->now; // only return future invitations |
|
195 | 195 | } |
196 | 196 | // ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now |
197 | - elseif (substr($path,-8) == '/outbox/') |
|
197 | + elseif (substr($path, -8) == '/outbox/') |
|
198 | 198 | { |
199 | 199 | return true; |
200 | 200 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // when trying to request not supported components, eg. VTODO on a calendar collection |
212 | 212 | return true; |
213 | 213 | } |
214 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
214 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
215 | 215 | |
216 | 216 | if ($this->debug > 1) |
217 | 217 | { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | $this->sync_collection_token = null; |
230 | 230 | |
231 | - $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
231 | + $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
232 | 232 | $filter['sync-collection'] = true; |
233 | 233 | // no end-date / limit into the future, as unchanged entries would never be transferted later on |
234 | 234 | unset($filter['end']); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | if (isset($nresults)) |
238 | 238 | { |
239 | - unset($filter['no_total']); // we need the total! |
|
239 | + unset($filter['no_total']); // we need the total! |
|
240 | 240 | $files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults)); |
241 | 241 | |
242 | 242 | // hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first) |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
246 | 246 | { |
247 | 247 | --$this->sync_collection_token; |
248 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
248 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | else |
252 | 252 | { |
253 | 253 | // return iterator, calling ourself to return result in chunks |
254 | - $files['files'] = new groupdav_propfind_iterator($this,$path,$filter,$files['files']); |
|
254 | + $files['files'] = new groupdav_propfind_iterator($this, $path, $filter, $files['files']); |
|
255 | 255 | } |
256 | 256 | if (isset($_GET['download'])) |
257 | 257 | { |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | html::content_header('calendar.ics', 'text/calendar'); |
272 | 272 | |
273 | 273 | $n = 0; |
274 | - foreach($files as $file) |
|
274 | + foreach ($files as $file) |
|
275 | 275 | { |
276 | - if (!$n++) continue; // first entry is collection itself |
|
276 | + if (!$n++) continue; // first entry is collection itself |
|
277 | 277 | |
278 | 278 | $icalendar = $file['props']['calendar-data']['val']; |
279 | 279 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | echo substr($icalendar, 0, $start); |
298 | 298 | } |
299 | 299 | } |
300 | - echo substr($icalendar, $start, $end-$start); |
|
300 | + echo substr($icalendar, $start, $end - $start); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | if ($icalendar && $end) |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | * @param array|boolean $start =false false=return all or array(start,num) |
316 | 316 | * @return array with "files" array with values for keys path and props |
317 | 317 | */ |
318 | - function propfind_callback($path,array $filter,$start=false) |
|
318 | + function propfind_callback($path, array $filter, $start = false) |
|
319 | 319 | { |
320 | 320 | if ($this->debug) $starttime = microtime(true); |
321 | 321 | |
322 | 322 | $calendar_data = $this->groupdav->prop_requested('calendar-data', groupdav::CALDAV, true); |
323 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
323 | + if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
324 | 324 | |
325 | 325 | $files = array(); |
326 | 326 | |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | $requested_multiget_ids = (array)$filter['query'][self::$path_attr]; |
333 | 333 | $sync_collection = $filter['sync-collection']; |
334 | 334 | |
335 | - $events =& $this->bo->search($filter); |
|
335 | + $events = & $this->bo->search($filter); |
|
336 | 336 | |
337 | 337 | if ($events) |
338 | 338 | { |
339 | - foreach($events as $event) |
|
339 | + foreach ($events as $event) |
|
340 | 340 | { |
341 | 341 | // remove event from requested multiget ids, to be able to report not found urls |
342 | 342 | if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | unset($requested_multiget_ids[$k]); |
345 | 345 | } |
346 | 346 | // sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations |
347 | - if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R','X')))) |
|
347 | + if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R', 'X')))) |
|
348 | 348 | { |
349 | 349 | $files[] = array('path' => $path.urldecode($this->get_path($event))); |
350 | 350 | continue; |
@@ -372,10 +372,9 @@ discard block |
||
372 | 372 | { |
373 | 373 | $content = $this->iCal($event, $filter['users'], |
374 | 374 | strpos($path, '/inbox/') !== false ? 'REQUEST' : null, |
375 | - !isset($calendar_data['children']['expand']) ? false : |
|
376 | - ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true)); |
|
375 | + !isset($calendar_data['children']['expand']) ? false : ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true)); |
|
377 | 376 | $props['getcontentlength'] = bytes($content); |
378 | - $props['calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data',$content); |
|
377 | + $props['calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', $content); |
|
379 | 378 | } |
380 | 379 | /* Calendarserver reports new events with schedule-changes: action: create, which iCal request |
381 | 380 | * adding it, unfortunately does not lead to showing the new event in the users inbox |
@@ -394,7 +393,7 @@ discard block |
||
394 | 393 | // report not found multiget urls |
395 | 394 | if ($requested_multiget_ids) |
396 | 395 | { |
397 | - foreach($requested_multiget_ids as $id) |
|
396 | + foreach ($requested_multiget_ids as $id) |
|
398 | 397 | { |
399 | 398 | $files[] = array('path' => $path.$id.self::$path_extension); |
400 | 399 | } |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | private function _created_updated_by_prop($user, $time) |
431 | 430 | { |
432 | 431 | $props = array(); |
433 | - foreach(array( |
|
432 | + foreach (array( |
|
434 | 433 | 'first-name' => 'account_firstname', |
435 | 434 | 'last-name' => 'account_lastname', |
436 | 435 | 'href' => 'account_email', |
@@ -473,23 +472,23 @@ discard block |
||
473 | 472 | $cal_end = $cal_filters['end']; unset($cal_filters['end']); |
474 | 473 | $num_filters = count($cal_filters); |
475 | 474 | |
476 | - foreach($options['filters'] as $filter) |
|
475 | + foreach ($options['filters'] as $filter) |
|
477 | 476 | { |
478 | - switch($filter['name']) |
|
477 | + switch ($filter['name']) |
|
479 | 478 | { |
480 | 479 | case 'comp-filter': |
481 | 480 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
482 | 481 | |
483 | - switch($filter['attrs']['name']) |
|
482 | + switch ($filter['attrs']['name']) |
|
484 | 483 | { |
485 | 484 | case 'VTODO': |
486 | - return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
485 | + return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
487 | 486 | // todos are handled by the infolog handler |
488 | 487 | //$infolog_handler = new groupdav_infolog(); |
489 | 488 | //return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method); |
490 | 489 | case 'VCALENDAR': |
491 | 490 | case 'VEVENT': |
492 | - break; // that's our default anyway |
|
491 | + break; // that's our default anyway |
|
493 | 492 | } |
494 | 493 | break; |
495 | 494 | case 'prop-filter': |
@@ -512,14 +511,14 @@ discard block |
||
512 | 511 | if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
513 | 512 | break; |
514 | 513 | case 'time-range': |
515 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
514 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
516 | 515 | if (!empty($filter['attrs']['start'])) |
517 | 516 | { |
518 | 517 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
519 | 518 | } |
520 | 519 | if (!empty($filter['attrs']['end'])) |
521 | 520 | { |
522 | - $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
521 | + $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
523 | 522 | } |
524 | 523 | break; |
525 | 524 | default: |
@@ -540,9 +539,9 @@ discard block |
||
540 | 539 | <B:nresults>10</B:nresults> |
541 | 540 | </B:limit> |
542 | 541 | */ |
543 | - foreach((array)$options['other'] as $option) |
|
542 | + foreach ((array)$options['other'] as $option) |
|
544 | 543 | { |
545 | - switch($option['name']) |
|
544 | + switch ($option['name']) |
|
546 | 545 | { |
547 | 546 | case 'nresults': |
548 | 547 | $nresults = (int)$option['data']; |
@@ -551,7 +550,7 @@ discard block |
||
551 | 550 | case 'limit': |
552 | 551 | break; |
553 | 552 | case 'href': |
554 | - break; // from addressbook-multiget, handled below |
|
553 | + break; // from addressbook-multiget, handled below |
|
555 | 554 | // rfc 6578 sync-report |
556 | 555 | case 'sync-token': |
557 | 556 | if (!empty($option['data'])) |
@@ -559,7 +558,7 @@ discard block |
||
559 | 558 | $parts = explode('/', $option['data']); |
560 | 559 | $sync_token = array_pop($parts); |
561 | 560 | $cal_filters['query'][] = 'cal_modified>'.(int)$sync_token; |
562 | - $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
561 | + $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
563 | 562 | // no standard time-range! |
564 | 563 | unset($cal_filters['start']); |
565 | 564 | } |
@@ -588,25 +587,25 @@ discard block |
||
588 | 587 | if ($id) |
589 | 588 | { |
590 | 589 | $cal_filters['query'][self::$path_attr] = groupdav_handler::$path_extension ? |
591 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
590 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
592 | 591 | } |
593 | 592 | else // fetch all given url's |
594 | 593 | { |
595 | - foreach($options['other'] as $option) |
|
594 | + foreach ($options['other'] as $option) |
|
596 | 595 | { |
597 | 596 | if ($option['name'] == 'href') |
598 | 597 | { |
599 | - $parts = explode('/',$option['data']); |
|
598 | + $parts = explode('/', $option['data']); |
|
600 | 599 | if (($id = urldecode(array_pop($parts)))) |
601 | 600 | { |
602 | 601 | $cal_filters['query'][self::$path_attr][] = groupdav_handler::$path_extension ? |
603 | - basename($id,groupdav_handler::$path_extension) : $id; |
|
602 | + basename($id, groupdav_handler::$path_extension) : $id; |
|
604 | 603 | } |
605 | 604 | } |
606 | 605 | } |
607 | 606 | } |
608 | 607 | |
609 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
608 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters)); |
|
610 | 609 | } |
611 | 610 | return true; |
612 | 611 | } |
@@ -619,9 +618,9 @@ discard block |
||
619 | 618 | * @param int $user =null account_id |
620 | 619 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
621 | 620 | */ |
622 | - function get(&$options,$id,$user=null) |
|
621 | + function get(&$options, $id, $user = null) |
|
623 | 622 | { |
624 | - if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id))) |
|
623 | + if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id))) |
|
625 | 624 | { |
626 | 625 | return $event; |
627 | 626 | } |
@@ -649,7 +648,7 @@ discard block |
||
649 | 648 | * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences |
650 | 649 | * @return string |
651 | 650 | */ |
652 | - private function iCal(array $event,$user=null, $method=null, $expand=false) |
|
651 | + private function iCal(array $event, $user = null, $method = null, $expand = false) |
|
653 | 652 | { |
654 | 653 | static $handler = null; |
655 | 654 | if (is_null($handler)) $handler = $this->_get_handler(); |
@@ -673,11 +672,11 @@ discard block |
||
673 | 672 | if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
674 | 673 | if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
675 | 674 | } |
676 | - $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
|
675 | + $events = & self::get_series($event['uid'], $this->bo, $expand, $user); |
|
677 | 676 | } |
678 | - elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
|
677 | + elseif (!$this->client_shared_uid_exceptions && $event['reference']) |
|
679 | 678 | { |
680 | - $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
679 | + $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
681 | 680 | } |
682 | 681 | return $handler->exportVCal($events, '2.0', $method); |
683 | 682 | } |
@@ -693,20 +692,20 @@ discard block |
||
693 | 692 | * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in |
694 | 693 | * @return array |
695 | 694 | */ |
696 | - private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
|
695 | + private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null) |
|
697 | 696 | { |
698 | 697 | if (is_null($bo)) $bo = new calendar_bopdate(); |
699 | 698 | |
700 | 699 | $params = array( |
701 | 700 | 'query' => array('cal_uid' => $uid), |
702 | - 'filter' => 'owner', // return all possible entries |
|
701 | + 'filter' => 'owner', // return all possible entries |
|
703 | 702 | 'daywise' => false, |
704 | 703 | 'date_format' => 'server', |
705 | - 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
704 | + 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
706 | 705 | ); |
707 | 706 | if (is_array($expand)) $params += $expand; |
708 | 707 | |
709 | - if (!($events =& $bo->search($params))) |
|
708 | + if (!($events = & $bo->search($params))) |
|
710 | 709 | { |
711 | 710 | return array(); |
712 | 711 | } |
@@ -714,12 +713,12 @@ discard block |
||
714 | 713 | // find master, which is not always first event, eg. when first event is an exception |
715 | 714 | $master = null; |
716 | 715 | $exceptions = array(); |
717 | - foreach($events as $k => &$recurrence) |
|
716 | + foreach ($events as $k => &$recurrence) |
|
718 | 717 | { |
719 | 718 | if ($recurrence['recur_type']) |
720 | 719 | { |
721 | 720 | $master = $recurrence; |
722 | - $exceptions =& $master['recur_exception']; |
|
721 | + $exceptions = & $master['recur_exception']; |
|
723 | 722 | unset($events[$k]); |
724 | 723 | break; |
725 | 724 | } |
@@ -727,7 +726,7 @@ discard block |
||
727 | 726 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
728 | 727 | if (!isset($master)) $master = $bo->read($uid); |
729 | 728 | |
730 | - foreach($events as $k => &$recurrence) |
|
729 | + foreach ($events as $k => &$recurrence) |
|
731 | 730 | { |
732 | 731 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); |
733 | 732 | if (!$master || $recurrence['id'] != $master['id']) // real exception |
@@ -749,16 +748,16 @@ discard block |
||
749 | 748 | // at least Lightning "understands" EXDATE as exception from what's included |
750 | 749 | // in the whole resource / VCALENDAR component |
751 | 750 | // not removing it causes Lightning to remove the exception itself |
752 | - if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false) |
|
751 | + if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false) |
|
753 | 752 | { |
754 | 753 | unset($exceptions[$e]); |
755 | 754 | } |
756 | - continue; // nothing to change |
|
755 | + continue; // nothing to change |
|
757 | 756 | } |
758 | 757 | // alarms are reported on recurrences --> move them to master |
759 | 758 | if ($master) |
760 | 759 | { |
761 | - foreach($recurrence['alarm'] as $alarm) |
|
760 | + foreach ($recurrence['alarm'] as $alarm) |
|
762 | 761 | { |
763 | 762 | $master['alarm'][] = $alarm; |
764 | 763 | } |
@@ -768,14 +767,14 @@ discard block |
||
768 | 767 | if (!$expand && $master && $master['participants'] == $recurrence['participants']) |
769 | 768 | { |
770 | 769 | //error_log('NO exception: '.array2string($recurrence)); |
771 | - unset($events[$k]); // no exception --> remove it |
|
770 | + unset($events[$k]); // no exception --> remove it |
|
772 | 771 | continue; |
773 | 772 | } |
774 | 773 | // this is a virtual exception now (no extra event/cal_id in DB) |
775 | 774 | //error_log('virtual exception: '.array2string($recurrence)); |
776 | 775 | $recurrence['recurrence'] = $recurrence['start']; |
777 | 776 | if ($master) $recurrence['reference'] = $master['id']; |
778 | - $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
777 | + $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
779 | 778 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
780 | 779 | } |
781 | 780 | // only add master if we are not expanding and current user participates in master (and not just some exceptions) |
@@ -809,23 +808,23 @@ discard block |
||
809 | 808 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
810 | 809 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
811 | 810 | */ |
812 | - function put(&$options,$id,$user=null,$prefix=null) |
|
811 | + function put(&$options, $id, $user = null, $prefix = null) |
|
813 | 812 | { |
814 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
813 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
815 | 814 | |
816 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
815 | + if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
817 | 816 | |
818 | 817 | // fix for iCal4OL using WinHTTP only supporting a certain header length |
819 | 818 | if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
820 | 819 | { |
821 | 820 | $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE']; |
822 | 821 | } |
823 | - $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
824 | - $oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access, |
|
825 | - isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
822 | + $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
823 | + $oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access, |
|
824 | + isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
826 | 825 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
827 | 826 | { |
828 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
827 | + if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace()); |
|
829 | 828 | return $oldEvent; |
830 | 829 | } |
831 | 830 | |
@@ -856,7 +855,7 @@ discard block |
||
856 | 855 | switch (strtolower($key)) |
857 | 856 | { |
858 | 857 | case 'charset': |
859 | - $charset = strtoupper(substr($value,1,-1)); |
|
858 | + $charset = strtoupper(substr($value, 1, -1)); |
|
860 | 859 | } |
861 | 860 | } |
862 | 861 | } |
@@ -912,7 +911,7 @@ discard block |
||
912 | 911 | if (($events = $handler->icaltoegw($vCalendar))) |
913 | 912 | { |
914 | 913 | $modified = 0; |
915 | - foreach($events as $n => $event) |
|
914 | + foreach ($events as $n => $event) |
|
916 | 915 | { |
917 | 916 | // for recurrances of event series, we need to read correct recurrence (or if series master is no first event) |
918 | 917 | if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series)) |
@@ -923,7 +922,7 @@ discard block |
||
923 | 922 | $series = self::get_series($event['uid'], $this->bo); |
924 | 923 | //foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent)); |
925 | 924 | } |
926 | - foreach($series as $oldEvent) |
|
925 | + foreach ($series as $oldEvent) |
|
927 | 926 | { |
928 | 927 | if ($oldEvent['recurrence'] == $event['recurrence']) break; |
929 | 928 | } |
@@ -988,9 +987,9 @@ discard block |
||
988 | 987 | isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']])) |
989 | 988 | { |
990 | 989 | // just update etag in database |
991 | - $GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array( |
|
990 | + $GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array( |
|
992 | 991 | 'cal_id' => $eventId, |
993 | - ),__LINE__,__FILE__,'calendar'); |
|
992 | + ), __LINE__, __FILE__, 'calendar'); |
|
994 | 993 | } |
995 | 994 | } |
996 | 995 | } |
@@ -1037,9 +1036,9 @@ discard block |
||
1037 | 1036 | * @param int $user =null account_id of owner, default null |
1038 | 1037 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1039 | 1038 | */ |
1040 | - function post(&$options,$id,$user=null) |
|
1039 | + function post(&$options, $id, $user = null) |
|
1041 | 1040 | { |
1042 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1041 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
1043 | 1042 | |
1044 | 1043 | $vCalendar = htmlspecialchars_decode($options['content']); |
1045 | 1044 | $charset = null; |
@@ -1056,13 +1055,13 @@ discard block |
||
1056 | 1055 | switch (strtolower($key)) |
1057 | 1056 | { |
1058 | 1057 | case 'charset': |
1059 | - $charset = strtoupper(substr($value,1,-1)); |
|
1058 | + $charset = strtoupper(substr($value, 1, -1)); |
|
1060 | 1059 | } |
1061 | 1060 | } |
1062 | 1061 | } |
1063 | 1062 | } |
1064 | 1063 | |
1065 | - if (substr($options['path'],-8) == '/outbox/') |
|
1064 | + if (substr($options['path'], -8) == '/outbox/') |
|
1066 | 1065 | { |
1067 | 1066 | if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar)) |
1068 | 1067 | { |
@@ -1113,7 +1112,7 @@ discard block |
||
1113 | 1112 | */ |
1114 | 1113 | protected function outbox_freebusy_request($ical, $charset, $user, array &$options) |
1115 | 1114 | { |
1116 | - unset($options); // not used, but required by function signature |
|
1115 | + unset($options); // not used, but required by function signature |
|
1117 | 1116 | |
1118 | 1117 | $vcal = new Horde_Icalendar(); |
1119 | 1118 | if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset)) |
@@ -1126,7 +1125,7 @@ discard block |
||
1126 | 1125 | |
1127 | 1126 | $handler = $this->_get_handler(); |
1128 | 1127 | $handler->setSupportedFields('groupdav'); |
1129 | - $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1128 | + $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1130 | 1129 | if (!($component = $vcal->getComponent(0)) || |
1131 | 1130 | !($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->groupdav->current_user_principal, 'Horde_Icalendar_Vfreebusy'))) |
1132 | 1131 | { |
@@ -1151,13 +1150,13 @@ discard block |
||
1151 | 1150 | $xml->startDocument('1.0', 'UTF-8'); |
1152 | 1151 | $xml->startElementNs('C', 'schedule-response', groupdav::CALDAV); |
1153 | 1152 | |
1154 | - foreach(array_keys($event['participants']) as $uid) |
|
1153 | + foreach (array_keys($event['participants']) as $uid) |
|
1155 | 1154 | { |
1156 | 1155 | $xml->startElementNs('C', 'response', null); |
1157 | 1156 | |
1158 | 1157 | $xml->startElementNs('C', 'recipient', null); |
1159 | - $xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees)); |
|
1160 | - $xml->endElement(); // recipient |
|
1158 | + $xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees)); |
|
1159 | + $xml->endElement(); // recipient |
|
1161 | 1160 | |
1162 | 1161 | $xml->writeElementNs('C', 'request-status', null, '2.0;Success'); |
1163 | 1162 | $xml->writeElementNs('C', 'calendar-data', null, |
@@ -1165,13 +1164,13 @@ discard block |
||
1165 | 1164 | 'UID' => $event['uid'], |
1166 | 1165 | 'ORGANIZER' => $organizer, |
1167 | 1166 | 'ATTENDEE' => $attendee, |
1168 | - )+(empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1167 | + ) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1169 | 1168 | 'X-CALENDARSERVER-MASK-UID' => $mask_uid, |
1170 | 1169 | )))); |
1171 | 1170 | |
1172 | - $xml->endElement(); // response |
|
1171 | + $xml->endElement(); // response |
|
1173 | 1172 | } |
1174 | - $xml->endElement(); // schedule-response |
|
1173 | + $xml->endElement(); // schedule-response |
|
1175 | 1174 | $xml->endDocument(); |
1176 | 1175 | echo $xml->outputMemory(); |
1177 | 1176 | |
@@ -1186,14 +1185,14 @@ discard block |
||
1186 | 1185 | * @param int $user account_id |
1187 | 1186 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1188 | 1187 | */ |
1189 | - function free_busy_report($path,$options,$user) |
|
1188 | + function free_busy_report($path, $options, $user) |
|
1190 | 1189 | { |
1191 | - unset($path); // unused, but required by function signature |
|
1190 | + unset($path); // unused, but required by function signature |
|
1192 | 1191 | if (!$this->bo->check_perms(EGW_ACL_FREEBUSY, 0, $user)) |
1193 | 1192 | { |
1194 | 1193 | return '403 Forbidden'; |
1195 | 1194 | } |
1196 | - foreach($options['other'] as $filter) |
|
1195 | + foreach ($options['other'] as $filter) |
|
1197 | 1196 | { |
1198 | 1197 | if ($filter['name'] == 'time-range') |
1199 | 1198 | { |
@@ -1205,7 +1204,7 @@ discard block |
||
1205 | 1204 | header('Content-Type: text/calendar'); |
1206 | 1205 | echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array()); |
1207 | 1206 | |
1208 | - common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1207 | + common::egw_exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1209 | 1208 | } |
1210 | 1209 | |
1211 | 1210 | /** |
@@ -1217,7 +1216,7 @@ discard block |
||
1217 | 1216 | * @param int $user =null owner of the collection, default current user |
1218 | 1217 | * @return array with privileges |
1219 | 1218 | */ |
1220 | - public function current_user_privileges($path, $user=null) |
|
1219 | + public function current_user_privileges($path, $user = null) |
|
1221 | 1220 | { |
1222 | 1221 | $privileges = parent::current_user_privileges($path, $user); |
1223 | 1222 | //error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges)); |
@@ -1260,7 +1259,7 @@ discard block |
||
1260 | 1259 | |
1261 | 1260 | // get array with orginal recurrences indexed by recurrence-id |
1262 | 1261 | $org_recurrences = $exceptions = array(); |
1263 | - foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
|
1262 | + foreach (self::get_series($events[0]['uid'], $bo) as $k => $event) |
|
1264 | 1263 | { |
1265 | 1264 | if (!$k) $master = $event; |
1266 | 1265 | if ($event['recurrence']) |
@@ -1270,13 +1269,13 @@ discard block |
||
1270 | 1269 | } |
1271 | 1270 | |
1272 | 1271 | // assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master |
1273 | - foreach($events as $k => &$recurrence) |
|
1272 | + foreach ($events as $k => &$recurrence) |
|
1274 | 1273 | { |
1275 | 1274 | if (!$recurrence['recurrence']) |
1276 | 1275 | { |
1277 | 1276 | // master |
1278 | 1277 | $recurrence['id'] = $master['id']; |
1279 | - $master =& $events[$k]; |
|
1278 | + $master = & $events[$k]; |
|
1280 | 1279 | continue; |
1281 | 1280 | } |
1282 | 1281 | |
@@ -1300,12 +1299,12 @@ discard block |
||
1300 | 1299 | $master['recur_exception'] = array_merge($exceptions, $master['recur_exception']); |
1301 | 1300 | |
1302 | 1301 | // delete not longer existing recurrences |
1303 | - foreach($org_recurrences as $org_recurrence) |
|
1302 | + foreach ($org_recurrences as $org_recurrence) |
|
1304 | 1303 | { |
1305 | 1304 | if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
1306 | 1305 | { |
1307 | 1306 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
1308 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1307 | + $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1309 | 1308 | } |
1310 | 1309 | else // virtual recurrence |
1311 | 1310 | { |
@@ -1326,25 +1325,25 @@ discard block |
||
1326 | 1325 | * @param int $id |
1327 | 1326 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1328 | 1327 | */ |
1329 | - function delete(&$options,$id) |
|
1328 | + function delete(&$options, $id) |
|
1330 | 1329 | { |
1331 | 1330 | if (strpos($options['path'], '/inbox/') !== false) |
1332 | 1331 | { |
1333 | - return true; // simply ignore DELETE in inbox for now |
|
1332 | + return true; // simply ignore DELETE in inbox for now |
|
1334 | 1333 | } |
1335 | - $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1336 | - if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access) |
|
1334 | + $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1335 | + if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access) |
|
1337 | 1336 | { |
1338 | 1337 | if (!$return_no_access) |
1339 | 1338 | { |
1340 | 1339 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
1341 | 1340 | $ret = '403 Forbidden'; |
1342 | 1341 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
1343 | - foreach(array_keys($event['participants']) as $uid) |
|
1342 | + foreach (array_keys($event['participants']) as $uid) |
|
1344 | 1343 | { |
1345 | 1344 | if ($this->bo->user == $uid || in_array($uid, $memberships)) |
1346 | 1345 | { |
1347 | - $this->bo->set_status($event,$this->bo->user, 'R'); |
|
1346 | + $this->bo->set_status($event, $this->bo->user, 'R'); |
|
1348 | 1347 | $ret = true; |
1349 | 1348 | break; |
1350 | 1349 | } |
@@ -1359,7 +1358,7 @@ discard block |
||
1359 | 1358 | { |
1360 | 1359 | $ret = $this->bo->delete($event['id']); |
1361 | 1360 | } |
1362 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1361 | + if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1363 | 1362 | return $ret; |
1364 | 1363 | } |
1365 | 1364 | |
@@ -1374,12 +1373,12 @@ discard block |
||
1374 | 1373 | */ |
1375 | 1374 | function read($id) |
1376 | 1375 | { |
1377 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
1376 | + if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column; |
|
1378 | 1377 | |
1379 | 1378 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
1380 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1379 | + if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1381 | 1380 | |
1382 | - if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server')) && |
|
1381 | + if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY, $event, 0, 'server')) && |
|
1383 | 1382 | // above can be true, if current user is not in master but just a recurrence |
1384 | 1383 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
1385 | 1384 | { |
@@ -1415,11 +1414,11 @@ discard block |
||
1415 | 1414 | * |
1416 | 1415 | * @return string |
1417 | 1416 | */ |
1418 | - public function getctag($path,$user) |
|
1417 | + public function getctag($path, $user) |
|
1419 | 1418 | { |
1420 | - $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1419 | + $ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1421 | 1420 | |
1422 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1421 | + if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag"); |
|
1423 | 1422 | |
1424 | 1423 | return $ctag; |
1425 | 1424 | } |
@@ -1431,7 +1430,7 @@ discard block |
||
1431 | 1430 | * @param string $schedule_tag =null on return schedule-tag |
1432 | 1431 | * @return string|boolean string with etag or false |
1433 | 1432 | */ |
1434 | - function get_etag($entry, &$schedule_tag=null) |
|
1433 | + function get_etag($entry, &$schedule_tag = null) |
|
1435 | 1434 | { |
1436 | 1435 | $etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions); |
1437 | 1436 | |
@@ -1449,7 +1448,7 @@ discard block |
||
1449 | 1448 | * @param int|string $retval |
1450 | 1449 | * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header) |
1451 | 1450 | */ |
1452 | - function put_response_headers($entry, $path, $retval, $path_attr_is_name=true) |
|
1451 | + function put_response_headers($entry, $path, $retval, $path_attr_is_name = true) |
|
1453 | 1452 | { |
1454 | 1453 | $schedule_tag = null; |
1455 | 1454 | $etag = $this->get_etag($entry, $schedule_tag); |
@@ -1468,14 +1467,14 @@ discard block |
||
1468 | 1467 | * @param array|int $event event-array or id |
1469 | 1468 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1470 | 1469 | */ |
1471 | - function check_access($acl,$event) |
|
1470 | + function check_access($acl, $event) |
|
1472 | 1471 | { |
1473 | 1472 | if ($acl == EGW_ACL_READ) |
1474 | 1473 | { |
1475 | 1474 | // we need at least EGW_ACL_FREEBUSY to get some information |
1476 | 1475 | $acl = EGW_ACL_FREEBUSY; |
1477 | 1476 | } |
1478 | - return $this->bo->check_perms($acl,$event,0,'server'); |
|
1477 | + return $this->bo->check_perms($acl, $event, 0, 'server'); |
|
1479 | 1478 | } |
1480 | 1479 | |
1481 | 1480 | /** |
@@ -1488,53 +1487,53 @@ discard block |
||
1488 | 1487 | * @param string $path =null path of the collection |
1489 | 1488 | * @return array |
1490 | 1489 | */ |
1491 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null) |
|
1490 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null) |
|
1492 | 1491 | { |
1493 | - unset($base_uri); // unused, but required by function signature |
|
1492 | + unset($base_uri); // unused, but required by function signature |
|
1494 | 1493 | if (!isset($props['calendar-description'])) |
1495 | 1494 | { |
1496 | 1495 | // default calendar description: can be overwritten via PROPPATCH, in which case it's already set |
1497 | - $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-description',$displayname); |
|
1496 | + $props['calendar-description'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-description', $displayname); |
|
1498 | 1497 | } |
1499 | 1498 | $supported_components = array( |
1500 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VCALENDAR')), |
|
1501 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VEVENT')), |
|
1499 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VCALENDAR')), |
|
1500 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VEVENT')), |
|
1502 | 1501 | ); |
1503 | 1502 | // outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations |
1504 | - if (substr($path,-8) == '/outbox/') |
|
1503 | + if (substr($path, -8) == '/outbox/') |
|
1505 | 1504 | { |
1506 | - $supported_components[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'comp',array('name' => 'VFREEBUSY')); |
|
1505 | + $supported_components[] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'comp', array('name' => 'VFREEBUSY')); |
|
1507 | 1506 | } |
1508 | 1507 | $props['supported-calendar-component-set'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, |
1509 | - 'supported-calendar-component-set',$supported_components); |
|
1508 | + 'supported-calendar-component-set', $supported_components); |
|
1510 | 1509 | // supported reports |
1511 | 1510 | $props['supported-report-set'] = array( |
1512 | - 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1513 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1514 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-query',''))))), |
|
1515 | - 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1516 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1517 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-multiget',''))))), |
|
1518 | - 'free-busy-query' => HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1519 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1520 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'free-busy-query',''))))), |
|
1511 | + 'calendar-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1512 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1513 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-query', ''))))), |
|
1514 | + 'calendar-multiget' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1515 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1516 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-multiget', ''))))), |
|
1517 | + 'free-busy-query' => HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1518 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1519 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'free-busy-query', ''))))), |
|
1521 | 1520 | ); |
1522 | 1521 | // rfc 6578 sync-collection report for everything but outbox |
1523 | 1522 | // only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
1524 | 1523 | if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history']) |
1525 | 1524 | { |
1526 | - $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report',array( |
|
1527 | - HTTP_WebDAV_Server::mkprop('report',array( |
|
1528 | - HTTP_WebDAV_Server::mkprop('sync-collection',''))))); |
|
1525 | + $props['supported-report-set']['sync-collection'] = HTTP_WebDAV_Server::mkprop('supported-report', array( |
|
1526 | + HTTP_WebDAV_Server::mkprop('report', array( |
|
1527 | + HTTP_WebDAV_Server::mkprop('sync-collection', ''))))); |
|
1529 | 1528 | } |
1530 | - $props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'supported-calendar-data',array( |
|
1531 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1532 | - HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1529 | + $props['supported-calendar-data'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'supported-calendar-data', array( |
|
1530 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1531 | + HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1533 | 1532 | |
1534 | 1533 | // get timezone of calendar |
1535 | 1534 | if ($this->groupdav->prop_requested('calendar-timezone')) |
1536 | 1535 | { |
1537 | - $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-timezone', |
|
1536 | + $props['calendar-timezone'] = HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-timezone', |
|
1538 | 1537 | calendar_timezones::user_timezone($user)); |
1539 | 1538 | } |
1540 | 1539 | return $props; |
@@ -1548,9 +1547,9 @@ discard block |
||
1548 | 1547 | private function _get_handler() |
1549 | 1548 | { |
1550 | 1549 | $handler = new calendar_ical(); |
1551 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
1552 | - $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1553 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
1550 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
1551 | + $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1552 | + if ($this->debug > 1) error_log("ical Handler called: ".$this->agent); |
|
1554 | 1553 | return $handler; |
1555 | 1554 | } |
1556 | 1555 | |
@@ -1565,7 +1564,7 @@ discard block |
||
1565 | 1564 | $pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set']; |
1566 | 1565 | $calendar_home_set = $pref ? explode(',', $pref) : array(); |
1567 | 1566 | // replace symbolic id's with real nummeric id's |
1568 | - foreach(array( |
|
1567 | + foreach (array( |
|
1569 | 1568 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
1570 | 1569 | ) as $sym => $id) |
1571 | 1570 | { |
@@ -1574,11 +1573,11 @@ discard block |
||
1574 | 1573 | $calendar_home_set[$key] = $id; |
1575 | 1574 | } |
1576 | 1575 | } |
1577 | - foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1576 | + foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1578 | 1577 | { |
1579 | 1578 | $id = $entry['grantor']; |
1580 | - if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1581 | - (in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) && |
|
1579 | + if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1580 | + (in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) && |
|
1582 | 1581 | is_numeric($id) && ($owner = $this->accounts->id2name($id))) |
1583 | 1582 | { |
1584 | 1583 | $shared[$id] = 'calendar-'.$owner; |
@@ -1587,11 +1586,11 @@ discard block |
||
1587 | 1586 | // shared locations and resources |
1588 | 1587 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
1589 | 1588 | { |
1590 | - foreach(array('locations','resources') as $res) |
|
1589 | + foreach (array('locations', 'resources') as $res) |
|
1591 | 1590 | { |
1592 | 1591 | if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res])) |
1593 | 1592 | { |
1594 | - foreach(explode(',', $pref) as $res_id) |
|
1593 | + foreach (explode(',', $pref) as $res_id) |
|
1595 | 1594 | { |
1596 | 1595 | $is_location = $res == 'locations'; |
1597 | 1596 | $shared['r'.$res_id] = str_replace('s/', '-', groupdav_principals::resource2name($res_id, $is_location)); |
@@ -1621,7 +1620,7 @@ discard block |
||
1621 | 1620 | { |
1622 | 1621 | $calendars[$entry['grantor']] = $entry['name']; |
1623 | 1622 | } |
1624 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
1623 | + if ($user > 0) unset($calendars[$user]); // skip current user |
|
1625 | 1624 | } |
1626 | 1625 | |
1627 | 1626 | $settings = array(); |
@@ -1629,7 +1628,7 @@ discard block |
||
1629 | 1628 | 'type' => 'multiselect', |
1630 | 1629 | 'label' => 'Calendars to sync in addition to personal calendar', |
1631 | 1630 | 'name' => 'calendar-home-set', |
1632 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1631 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1633 | 1632 | 'values' => $calendars, |
1634 | 1633 | 'xmlrpc' => True, |
1635 | 1634 | 'admin' => False, |
@@ -1655,7 +1654,7 @@ discard block |
||
1655 | 1654 | if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = groupdav_principals::get_resources())) |
1656 | 1655 | { |
1657 | 1656 | $resources = $locations = array(); |
1658 | - foreach($all_resources as $resource) |
|
1657 | + foreach ($all_resources as $resource) |
|
1659 | 1658 | { |
1660 | 1659 | if (groupdav_principals::resource_is_location($resource)) |
1661 | 1660 | { |
@@ -1666,7 +1665,7 @@ discard block |
||
1666 | 1665 | $resources[$resource['res_id']] = $resource['name']; |
1667 | 1666 | } |
1668 | 1667 | } |
1669 | - foreach(array( |
|
1668 | + foreach (array( |
|
1670 | 1669 | 'locations' => $locations, |
1671 | 1670 | 'resources' => $resources, |
1672 | 1671 | ) as $name => $options) |
@@ -1679,7 +1678,7 @@ discard block |
||
1679 | 1678 | 'label' => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')), |
1680 | 1679 | 'no_lang'=> true, |
1681 | 1680 | 'name' => 'calendar-home-set-'.$name, |
1682 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1681 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1683 | 1682 | 'values' => $options, |
1684 | 1683 | 'xmlrpc' => True, |
1685 | 1684 | 'admin' => False, |
@@ -117,7 +117,10 @@ discard block |
||
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | - if (!is_array($event)) $event = $this->bo->read($event); |
|
120 | + if (!is_array($event)) |
|
121 | + { |
|
122 | + $event = $this->bo->read($event); |
|
123 | + } |
|
121 | 124 | $name = $event[self::$path_attr]; |
122 | 125 | } |
123 | 126 | $name .= groupdav_handler::$path_extension; |
@@ -178,10 +181,13 @@ discard block |
||
178 | 181 | } |
179 | 182 | $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
180 | 183 | } |
181 | - if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
|
184 | + if ($this->client_shared_uid_exceptions) |
|
185 | + { |
|
186 | + // do NOT return (non-virtual) exceptions |
|
182 | 187 | { |
183 | 188 | $filter['query'] = array('cal_reference' => 0); |
184 | 189 | } |
190 | + } |
|
185 | 191 | |
186 | 192 | if ($path == '/calendar/') |
187 | 193 | { |
@@ -211,7 +217,11 @@ discard block |
||
211 | 217 | // when trying to request not supported components, eg. VTODO on a calendar collection |
212 | 218 | return true; |
213 | 219 | } |
214 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
220 | + if ($id) |
|
221 | + { |
|
222 | + $path = dirname($path).'/'; |
|
223 | + } |
|
224 | + // caldav_name get's added anyway in the callback |
|
215 | 225 | |
216 | 226 | if ($this->debug > 1) |
217 | 227 | { |
@@ -273,7 +283,11 @@ discard block |
||
273 | 283 | $n = 0; |
274 | 284 | foreach($files as $file) |
275 | 285 | { |
276 | - if (!$n++) continue; // first entry is collection itself |
|
286 | + if (!$n++) |
|
287 | + { |
|
288 | + continue; |
|
289 | + } |
|
290 | + // first entry is collection itself |
|
277 | 291 | |
278 | 292 | $icalendar = $file['props']['calendar-data']['val']; |
279 | 293 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -317,10 +331,17 @@ discard block |
||
317 | 331 | */ |
318 | 332 | function propfind_callback($path,array $filter,$start=false) |
319 | 333 | { |
320 | - if ($this->debug) $starttime = microtime(true); |
|
334 | + if ($this->debug) |
|
335 | + { |
|
336 | + $starttime = microtime(true); |
|
337 | + } |
|
321 | 338 | |
322 | 339 | $calendar_data = $this->groupdav->prop_requested('calendar-data', groupdav::CALDAV, true); |
323 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
340 | + if (!is_array($calendar_data)) |
|
341 | + { |
|
342 | + $calendar_data = false; |
|
343 | + } |
|
344 | + // not in allprop or autoindex |
|
324 | 345 | |
325 | 346 | $files = array(); |
326 | 347 | |
@@ -478,7 +499,10 @@ discard block |
||
478 | 499 | switch($filter['name']) |
479 | 500 | { |
480 | 501 | case 'comp-filter': |
481 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
502 | + if ($this->debug > 1) |
|
503 | + { |
|
504 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
505 | + } |
|
482 | 506 | |
483 | 507 | switch($filter['attrs']['name']) |
484 | 508 | { |
@@ -493,14 +517,23 @@ discard block |
||
493 | 517 | } |
494 | 518 | break; |
495 | 519 | case 'prop-filter': |
496 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
520 | + if ($this->debug > 1) |
|
521 | + { |
|
522 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
523 | + } |
|
497 | 524 | $prop_filter = $filter['attrs']['name']; |
498 | 525 | break; |
499 | 526 | case 'text-match': |
500 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
527 | + if ($this->debug > 1) |
|
528 | + { |
|
529 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
530 | + } |
|
501 | 531 | if (!isset($this->filter_prop2cal[strtoupper($prop_filter)])) |
502 | 532 | { |
503 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
533 | + if ($this->debug) |
|
534 | + { |
|
535 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
536 | + } |
|
504 | 537 | } |
505 | 538 | else |
506 | 539 | { |
@@ -509,10 +542,16 @@ discard block |
||
509 | 542 | unset($prop_filter); |
510 | 543 | break; |
511 | 544 | case 'param-filter': |
512 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
545 | + if ($this->debug) |
|
546 | + { |
|
547 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
548 | + } |
|
513 | 549 | break; |
514 | 550 | case 'time-range': |
515 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
551 | + if ($this->debug > 1) |
|
552 | + { |
|
553 | + error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
554 | + } |
|
516 | 555 | if (!empty($filter['attrs']['start'])) |
517 | 556 | { |
518 | 557 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
@@ -523,13 +562,19 @@ discard block |
||
523 | 562 | } |
524 | 563 | break; |
525 | 564 | default: |
526 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
565 | + if ($this->debug) |
|
566 | + { |
|
567 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
568 | + } |
|
527 | 569 | break; |
528 | 570 | } |
529 | 571 | } |
530 | - if (count($cal_filters) == $num_filters) // no filters set --> restore default start and end time |
|
572 | + if (count($cal_filters) == $num_filters) |
|
573 | + { |
|
574 | + // no filters set --> restore default start and end time |
|
531 | 575 | { |
532 | 576 | $cal_filters['start'] = $cal_start; |
577 | + } |
|
533 | 578 | $cal_filters['end'] = $cal_end; |
534 | 579 | } |
535 | 580 | } |
@@ -606,7 +651,10 @@ discard block |
||
606 | 651 | } |
607 | 652 | } |
608 | 653 | |
609 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
654 | + if ($this->debug > 1) |
|
655 | + { |
|
656 | + error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
657 | + } |
|
610 | 658 | } |
611 | 659 | return true; |
612 | 660 | } |
@@ -652,9 +700,15 @@ discard block |
||
652 | 700 | private function iCal(array $event,$user=null, $method=null, $expand=false) |
653 | 701 | { |
654 | 702 | static $handler = null; |
655 | - if (is_null($handler)) $handler = $this->_get_handler(); |
|
703 | + if (is_null($handler)) |
|
704 | + { |
|
705 | + $handler = $this->_get_handler(); |
|
706 | + } |
|
656 | 707 | |
657 | - if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
708 | + if (!$user) |
|
709 | + { |
|
710 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
711 | + } |
|
658 | 712 | |
659 | 713 | // only return alarms in own calendar, not other users calendars |
660 | 714 | if ($user != $GLOBALS['egw_info']['user']['account_id']) |
@@ -670,8 +724,14 @@ discard block |
||
670 | 724 | { |
671 | 725 | if (is_array($expand)) |
672 | 726 | { |
673 | - if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
674 | - if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
727 | + if (isset($expand['start'])) |
|
728 | + { |
|
729 | + $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
730 | + } |
|
731 | + if (isset($expand['end'])) |
|
732 | + { |
|
733 | + $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
734 | + } |
|
675 | 735 | } |
676 | 736 | $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
677 | 737 | } |
@@ -695,7 +755,10 @@ discard block |
||
695 | 755 | */ |
696 | 756 | private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
697 | 757 | { |
698 | - if (is_null($bo)) $bo = new calendar_bopdate(); |
|
758 | + if (is_null($bo)) |
|
759 | + { |
|
760 | + $bo = new calendar_bopdate(); |
|
761 | + } |
|
699 | 762 | |
700 | 763 | $params = array( |
701 | 764 | 'query' => array('cal_uid' => $uid), |
@@ -704,7 +767,10 @@ discard block |
||
704 | 767 | 'date_format' => 'server', |
705 | 768 | 'cfs' => array(), // read cfs as we use them to store X- attributes |
706 | 769 | ); |
707 | - if (is_array($expand)) $params += $expand; |
|
770 | + if (is_array($expand)) |
|
771 | + { |
|
772 | + $params += $expand; |
|
773 | + } |
|
708 | 774 | |
709 | 775 | if (!($events =& $bo->search($params))) |
710 | 776 | { |
@@ -725,12 +791,17 @@ discard block |
||
725 | 791 | } |
726 | 792 | } |
727 | 793 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
728 | - if (!isset($master)) $master = $bo->read($uid); |
|
794 | + if (!isset($master)) |
|
795 | + { |
|
796 | + $master = $bo->read($uid); |
|
797 | + } |
|
729 | 798 | |
730 | 799 | foreach($events as $k => &$recurrence) |
731 | 800 | { |
732 | 801 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); |
733 | - if (!$master || $recurrence['id'] != $master['id']) // real exception |
|
802 | + if (!$master || $recurrence['id'] != $master['id']) |
|
803 | + { |
|
804 | + // real exception |
|
734 | 805 | { |
735 | 806 | // user is NOT participating in this exception |
736 | 807 | if ($user && !self::isParticipant($recurrence, $user)) |
@@ -739,6 +810,7 @@ discard block |
||
739 | 810 | if (!$master || !self::isParticipant($master, $user)) |
740 | 811 | { |
741 | 812 | unset($events[$k]); |
813 | + } |
|
742 | 814 | continue; |
743 | 815 | } |
744 | 816 | // otherwise mark him in this exception as rejected |
@@ -774,7 +846,10 @@ discard block |
||
774 | 846 | // this is a virtual exception now (no extra event/cal_id in DB) |
775 | 847 | //error_log('virtual exception: '.array2string($recurrence)); |
776 | 848 | $recurrence['recurrence'] = $recurrence['start']; |
777 | - if ($master) $recurrence['reference'] = $master['id']; |
|
849 | + if ($master) |
|
850 | + { |
|
851 | + $recurrence['reference'] = $master['id']; |
|
852 | + } |
|
778 | 853 | $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
779 | 854 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
780 | 855 | } |
@@ -811,9 +886,16 @@ discard block |
||
811 | 886 | */ |
812 | 887 | function put(&$options,$id,$user=null,$prefix=null) |
813 | 888 | { |
814 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
889 | + if ($this->debug) |
|
890 | + { |
|
891 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
892 | + } |
|
815 | 893 | |
816 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
894 | + if (!$prefix) |
|
895 | + { |
|
896 | + $user = null; |
|
897 | + } |
|
898 | + // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
817 | 899 | |
818 | 900 | // fix for iCal4OL using WinHTTP only supporting a certain header length |
819 | 901 | if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
@@ -825,7 +907,10 @@ discard block |
||
825 | 907 | isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
826 | 908 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
827 | 909 | { |
828 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
910 | + if ($this->debug) |
|
911 | + { |
|
912 | + error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
913 | + } |
|
829 | 914 | return $oldEvent; |
830 | 915 | } |
831 | 916 | |
@@ -836,7 +921,10 @@ discard block |
||
836 | 921 | { |
837 | 922 | // we have no add permission on this user's calendar |
838 | 923 | // ToDo: create event in current users calendar and invite only $user |
839 | - if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
924 | + if ($this->debug) |
|
925 | + { |
|
926 | + error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
927 | + } |
|
840 | 928 | return '403 Forbidden'; |
841 | 929 | } |
842 | 930 | |
@@ -884,13 +972,19 @@ discard block |
||
884 | 972 | if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
885 | 973 | { |
886 | 974 | $schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']; |
887 | - if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
975 | + if ($schedule_tag_match[0] == '"') |
|
976 | + { |
|
977 | + $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
978 | + } |
|
888 | 979 | $schedule_tag = null; |
889 | 980 | $this->get_etag($oldEvent, $schedule_tag); |
890 | 981 | |
891 | 982 | if ($schedule_tag_match !== $schedule_tag) |
892 | 983 | { |
893 | - if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
984 | + if ($this->debug) |
|
985 | + { |
|
986 | + error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
987 | + } |
|
894 | 988 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
895 | 989 | $this->check_return_representation($options, $id, $user); |
896 | 990 | return '412 Precondition Failed'; |
@@ -905,7 +999,10 @@ discard block |
||
905 | 999 | // above can be true, if current user is not in master but just a recurrence |
906 | 1000 | (!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo)))) |
907 | 1001 | { |
908 | - if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
1002 | + if ($this->debug) |
|
1003 | + { |
|
1004 | + error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
1005 | + } |
|
909 | 1006 | return '403 Forbidden'; |
910 | 1007 | } |
911 | 1008 | // update only participant status and alarms of current user |
@@ -925,7 +1022,10 @@ discard block |
||
925 | 1022 | } |
926 | 1023 | foreach($series as $oldEvent) |
927 | 1024 | { |
928 | - if ($oldEvent['recurrence'] == $event['recurrence']) break; |
|
1025 | + if ($oldEvent['recurrence'] == $event['recurrence']) |
|
1026 | + { |
|
1027 | + break; |
|
1028 | + } |
|
929 | 1029 | } |
930 | 1030 | // if no exception found, check if it might be just a recurrence (no exception) |
931 | 1031 | if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence']) |
@@ -940,7 +1040,10 @@ discard block |
||
940 | 1040 | } |
941 | 1041 | } |
942 | 1042 | } |
943 | - if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".egw_time::to($event['recurrence']).", event=".array2string($event)); |
|
1043 | + if ($this->debug) |
|
1044 | + { |
|
1045 | + error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".egw_time::to($event['recurrence']).", event=".array2string($event)); |
|
1046 | + } |
|
944 | 1047 | if (isset($event['participants']) && isset($event['participants'][$user]) && |
945 | 1048 | $event['participants'][$user] !== $oldEvent['participants'][$user]) |
946 | 1049 | { |
@@ -948,13 +1051,19 @@ discard block |
||
948 | 1051 | // real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence! |
949 | 1052 | $recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0)) |
950 | 1053 | { |
951 | - if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".egw_time::to($recurrence).')'); |
|
1054 | + if ($this->debug) |
|
1055 | + { |
|
1056 | + error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".egw_time::to($recurrence).')'); |
|
1057 | + } |
|
952 | 1058 | return '403 Forbidden'; |
953 | 1059 | } |
954 | 1060 | else |
955 | 1061 | { |
956 | 1062 | ++$modified; |
957 | - if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".egw_time::to($recurrence).')'); |
|
1063 | + if ($this->debug) |
|
1064 | + { |
|
1065 | + error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".egw_time::to($recurrence).')'); |
|
1066 | + } |
|
958 | 1067 | } |
959 | 1068 | } |
960 | 1069 | // import alarms, if given and changed |
@@ -964,15 +1073,21 @@ discard block |
||
964 | 1073 | $modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user); |
965 | 1074 | } |
966 | 1075 | } |
967 | - if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
1076 | + if (!$modified) |
|
1077 | + { |
|
1078 | + // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
968 | 1079 | { |
969 | 1080 | $this->groupdav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent)); |
970 | 1081 | } |
1082 | + } |
|
971 | 1083 | $this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name'); |
972 | 1084 | |
973 | 1085 | return '204 No Content'; |
974 | 1086 | } |
975 | - if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
1087 | + if ($this->debug && !isset($events)) |
|
1088 | + { |
|
1089 | + error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
1090 | + } |
|
976 | 1091 | } |
977 | 1092 | if ($return_no_access) |
978 | 1093 | { |
@@ -1004,17 +1119,23 @@ discard block |
||
1004 | 1119 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, |
1005 | 1120 | self::etag2value($this->http_if_match), false, 0, $this->groupdav->current_user_principal, $user, $charset, $id))) |
1006 | 1121 | { |
1007 | - if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
1122 | + if ($this->debug) |
|
1123 | + { |
|
1124 | + error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
1125 | + } |
|
1008 | 1126 | if ($eventId && $cal_id === false) |
1009 | 1127 | { |
1010 | 1128 | // ignore import failures |
1011 | 1129 | $cal_id = $eventId; |
1012 | 1130 | $retval = true; |
1013 | 1131 | } |
1014 | - elseif ($cal_id === 0) // etag failure |
|
1132 | + elseif ($cal_id === 0) |
|
1133 | + { |
|
1134 | + // etag failure |
|
1015 | 1135 | { |
1016 | 1136 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
1017 | 1137 | $this->check_return_representation($options, $id, $user); |
1138 | + } |
|
1018 | 1139 | return '412 Precondition Failed'; |
1019 | 1140 | } |
1020 | 1141 | else |
@@ -1039,7 +1160,10 @@ discard block |
||
1039 | 1160 | */ |
1040 | 1161 | function post(&$options,$id,$user=null) |
1041 | 1162 | { |
1042 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1163 | + if ($this->debug) |
|
1164 | + { |
|
1165 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1166 | + } |
|
1043 | 1167 | |
1044 | 1168 | $vCalendar = htmlspecialchars_decode($options['content']); |
1045 | 1169 | $charset = null; |
@@ -1094,7 +1218,10 @@ discard block |
||
1094 | 1218 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null, |
1095 | 1219 | false, 0, $this->groupdav->current_user_principal, $user, $charset))) |
1096 | 1220 | { |
1097 | - if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
1221 | + if ($this->debug) |
|
1222 | + { |
|
1223 | + error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
1224 | + } |
|
1098 | 1225 | } |
1099 | 1226 | header('ETag: "'.$this->get_etag($eventId).'"'); |
1100 | 1227 | } |
@@ -1262,7 +1389,10 @@ discard block |
||
1262 | 1389 | $org_recurrences = $exceptions = array(); |
1263 | 1390 | foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
1264 | 1391 | { |
1265 | - if (!$k) $master = $event; |
|
1392 | + if (!$k) |
|
1393 | + { |
|
1394 | + $master = $event; |
|
1395 | + } |
|
1266 | 1396 | if ($event['recurrence']) |
1267 | 1397 | { |
1268 | 1398 | $org_recurrences[$event['recurrence']] = $event; |
@@ -1282,10 +1412,13 @@ discard block |
||
1282 | 1412 | |
1283 | 1413 | // from now on we deal with exceptions |
1284 | 1414 | $org_recurrence = $org_recurrences[$recurrence['recurrence']]; |
1285 | - if (isset($org_recurrence)) // already existing recurrence |
|
1415 | + if (isset($org_recurrence)) |
|
1416 | + { |
|
1417 | + // already existing recurrence |
|
1286 | 1418 | { |
1287 | 1419 | //error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); |
1288 | 1420 | $recurrence['id'] = $org_recurrence['id']; |
1421 | + } |
|
1289 | 1422 | |
1290 | 1423 | // re-add (non-virtual) exceptions to master's recur_exception |
1291 | 1424 | if ($recurrence['id'] != $master['id']) |
@@ -1302,10 +1435,14 @@ discard block |
||
1302 | 1435 | // delete not longer existing recurrences |
1303 | 1436 | foreach($org_recurrences as $org_recurrence) |
1304 | 1437 | { |
1305 | - if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
|
1438 | + if ($org_recurrence['id'] != $master['id']) |
|
1439 | + { |
|
1440 | + // non-virtual recurrence |
|
1306 | 1441 | { |
1307 | 1442 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
1308 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1443 | + $bo->delete($org_recurrence['id']); |
|
1444 | + } |
|
1445 | + // might fail because of permissions |
|
1309 | 1446 | } |
1310 | 1447 | else // virtual recurrence |
1311 | 1448 | { |
@@ -1336,7 +1473,7 @@ discard block |
||
1336 | 1473 | if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access) |
1337 | 1474 | { |
1338 | 1475 | if (!$return_no_access) |
1339 | - { |
|
1476 | + { |
|
1340 | 1477 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
1341 | 1478 | $ret = '403 Forbidden'; |
1342 | 1479 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
@@ -1359,7 +1496,10 @@ discard block |
||
1359 | 1496 | { |
1360 | 1497 | $ret = $this->bo->delete($event['id']); |
1361 | 1498 | } |
1362 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1499 | + if ($this->debug) |
|
1500 | + { |
|
1501 | + error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1502 | + } |
|
1363 | 1503 | return $ret; |
1364 | 1504 | } |
1365 | 1505 | |
@@ -1374,16 +1514,26 @@ discard block |
||
1374 | 1514 | */ |
1375 | 1515 | function read($id) |
1376 | 1516 | { |
1377 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
1517 | + if (strpos($column=self::$path_attr,'_') === false) |
|
1518 | + { |
|
1519 | + $column = 'cal_'.$column; |
|
1520 | + } |
|
1378 | 1521 | |
1379 | 1522 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
1380 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1523 | + if ($event) |
|
1524 | + { |
|
1525 | + $event = array_shift($event); |
|
1526 | + } |
|
1527 | + // read with array as 1. param, returns an array of events! |
|
1381 | 1528 | |
1382 | 1529 | if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server')) && |
1383 | 1530 | // above can be true, if current user is not in master but just a recurrence |
1384 | 1531 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
1385 | 1532 | { |
1386 | - if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
1533 | + if ($this->debug > 0) |
|
1534 | + { |
|
1535 | + error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
1536 | + } |
|
1387 | 1537 | return $retval; |
1388 | 1538 | } |
1389 | 1539 | if (!$this->bo->check_perms(EGW_ACL_READ, $event, 0, 'server')) |
@@ -1391,9 +1541,15 @@ discard block |
||
1391 | 1541 | $this->bo->clear_private_infos($event, array($this->bo->user, $event['owner'])); |
1392 | 1542 | } |
1393 | 1543 | // handle deleted events, as not existing |
1394 | - if ($event['deleted']) $event = null; |
|
1544 | + if ($event['deleted']) |
|
1545 | + { |
|
1546 | + $event = null; |
|
1547 | + } |
|
1395 | 1548 | |
1396 | - if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event)); |
|
1549 | + if ($this->debug > 1) |
|
1550 | + { |
|
1551 | + error_log(__METHOD__."($id) returning ".array2string($event)); |
|
1552 | + } |
|
1397 | 1553 | |
1398 | 1554 | return $event; |
1399 | 1555 | } |
@@ -1405,7 +1561,10 @@ discard block |
||
1405 | 1561 | */ |
1406 | 1562 | public function update_tags($entry) |
1407 | 1563 | { |
1408 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
1564 | + if (!is_array($entry)) |
|
1565 | + { |
|
1566 | + $entry = $this->read($entry); |
|
1567 | + } |
|
1409 | 1568 | |
1410 | 1569 | $this->bo->update($entry, true); |
1411 | 1570 | } |
@@ -1419,7 +1578,10 @@ discard block |
||
1419 | 1578 | { |
1420 | 1579 | $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
1421 | 1580 | |
1422 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1581 | + if ($this->debug > 1) |
|
1582 | + { |
|
1583 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1584 | + } |
|
1423 | 1585 | |
1424 | 1586 | return $ctag; |
1425 | 1587 | } |
@@ -1550,7 +1712,10 @@ discard block |
||
1550 | 1712 | $handler = new calendar_ical(); |
1551 | 1713 | $handler->setSupportedFields('GroupDAV',$this->agent); |
1552 | 1714 | $handler->supportedFields['attachments'] = true; // enabling attachments |
1553 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
1715 | + if ($this->debug > 1) |
|
1716 | + { |
|
1717 | + error_log("ical Handler called: " . $this->agent); |
|
1718 | + } |
|
1554 | 1719 | return $handler; |
1555 | 1720 | } |
1556 | 1721 | |
@@ -1621,7 +1786,11 @@ discard block |
||
1621 | 1786 | { |
1622 | 1787 | $calendars[$entry['grantor']] = $entry['name']; |
1623 | 1788 | } |
1624 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
1789 | + if ($user > 0) |
|
1790 | + { |
|
1791 | + unset($calendars[$user]); |
|
1792 | + } |
|
1793 | + // skip current user |
|
1625 | 1794 | } |
1626 | 1795 | |
1627 | 1796 | $settings = array(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param importepport_iface_egw_record record The egw_record object being imported |
75 | 75 | * @param importexport_iface_import_record import_csv Import object contains current state |
76 | 76 | * |
77 | - * @return boolean success |
|
77 | + * @return null|boolean success |
|
78 | 78 | */ |
79 | 79 | public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
80 | 80 | { |
@@ -254,7 +254,6 @@ discard block |
||
254 | 254 | * perform the required action |
255 | 255 | * |
256 | 256 | * @param int $_action one of $this->actions |
257 | - * @param array $_data record data for the action |
|
258 | 257 | * @return bool success or not |
259 | 258 | */ |
260 | 259 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
@@ -343,7 +342,7 @@ discard block |
||
343 | 342 | /** |
344 | 343 | * Alter a row for preview to show multiple participants instead of Array |
345 | 344 | * |
346 | - * @param egw_record $row_entry |
|
345 | + * @param importexport_iface_egw_record $row_entry |
|
347 | 346 | */ |
348 | 347 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
349 | 348 | { |
@@ -32,8 +32,8 @@ |
||
32 | 32 | protected static $conditions = array('exists'); |
33 | 33 | |
34 | 34 | /** |
35 | - * For figuring out if an entry has changed |
|
36 | - */ |
|
35 | + * For figuring out if an entry has changed |
|
36 | + */ |
|
37 | 37 | protected $tracking; |
38 | 38 | |
39 | 39 | /** |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for calendar |
19 | 19 | */ |
20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
20 | +class calendar_import_csv extends importexport_basic_import_csv |
|
21 | +{ |
|
21 | 22 | |
22 | 23 | /** |
23 | 24 | * actions wich could be done to data entries |
@@ -83,8 +84,10 @@ discard block |
||
83 | 84 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
84 | 85 | |
85 | 86 | // Set owner, unless it's supposed to come from CSV file |
86 | - if($options['owner_from_csv']) { |
|
87 | - if(!is_numeric($record['owner'])) { |
|
87 | + if($options['owner_from_csv']) |
|
88 | + { |
|
89 | + if(!is_numeric($record['owner'])) |
|
90 | + { |
|
88 | 91 | $this->errors[$import_csv->get_current_position()] = lang( |
89 | 92 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
90 | 93 | $record->owner, |
@@ -106,14 +109,16 @@ discard block |
||
106 | 109 | } |
107 | 110 | |
108 | 111 | // Parse particpants |
109 | - if ($record->participants && !is_array($record->participants)) { |
|
112 | + if ($record->participants && !is_array($record->participants)) |
|
113 | + { |
|
110 | 114 | // Importing participants in human friendly format: |
111 | 115 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
112 | 116 | preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
113 | 117 | $p_participants = array(); |
114 | 118 | $missing = array(); |
115 | 119 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
116 | - foreach($names as $key => $name) { |
|
120 | + foreach($names as $key => $name) |
|
121 | + { |
|
117 | 122 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
118 | 123 | |
119 | 124 | // Search for direct account name, then user in accounts first |
@@ -121,9 +126,13 @@ discard block |
||
121 | 126 | $id = importexport_helper_functions::account_name2id($name); |
122 | 127 | |
123 | 128 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
129 | + if(!$id || $names[$key] !== $this->bo->participant_name($id)) |
|
130 | + { |
|
125 | 131 | $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
132 | + if($contacts) |
|
133 | + { |
|
134 | + $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
135 | + } |
|
127 | 136 | } |
128 | 137 | if(!$id) |
129 | 138 | { |
@@ -131,7 +140,10 @@ discard block |
||
131 | 140 | foreach($this->bo->resources as $resource) |
132 | 141 | { |
133 | 142 | // Can't search for email |
134 | - if($resource['app'] == 'email') continue; |
|
143 | + if($resource['app'] == 'email') |
|
144 | + { |
|
145 | + continue; |
|
146 | + } |
|
135 | 147 | // Special resource search, since it does special stuff in link_query |
136 | 148 | if($resource['app'] == 'resources') |
137 | 149 | { |
@@ -140,7 +152,8 @@ discard block |
||
140 | 152 | $this->resource_so = new resources_so(); |
141 | 153 | } |
142 | 154 | $result = $this->resource_so->search($search,'res_id'); |
143 | - if(count($result) >= 1) { |
|
155 | + if(count($result) >= 1) |
|
156 | + { |
|
144 | 157 | $id = $resource['type'].$result[0]['res_id']; |
145 | 158 | break; |
146 | 159 | } |
@@ -158,7 +171,8 @@ discard block |
||
158 | 171 | } |
159 | 172 | } |
160 | 173 | } |
161 | - if($id) { |
|
174 | + if($id) |
|
175 | + { |
|
162 | 176 | $p_participants[$id] = calendar_so::combine_status( |
163 | 177 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
164 | 178 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -187,27 +201,38 @@ discard block |
||
187 | 201 | } |
188 | 202 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
189 | 203 | |
190 | - if ( $options['conditions'] ) { |
|
191 | - foreach ( $options['conditions'] as $condition ) { |
|
204 | + if ( $options['conditions'] ) |
|
205 | + { |
|
206 | + foreach ( $options['conditions'] as $condition ) |
|
207 | + { |
|
192 | 208 | $records = array(); |
193 | - switch ( $condition['type'] ) { |
|
209 | + switch ( $condition['type'] ) |
|
210 | + { |
|
194 | 211 | // exists |
195 | 212 | case 'exists' : |
196 | 213 | // Check for that record |
197 | 214 | $result = $this->exists($record, $condition, $records); |
198 | 215 | |
199 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
216 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
217 | + { |
|
200 | 218 | // apply action to all records matching this exists condition |
201 | 219 | $action = $condition['true']; |
202 | - foreach ( (array)$records as $event ) { |
|
220 | + foreach ( (array)$records as $event ) |
|
221 | + { |
|
203 | 222 | $record->id = $event['id']; |
204 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
205 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
223 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
224 | + { |
|
225 | + if ( !is_array( $record->category ) ) |
|
226 | + { |
|
227 | + $record->category = explode( ',', $record->category ); |
|
228 | + } |
|
206 | 229 | $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
207 | 230 | } |
208 | 231 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
209 | 232 | } |
210 | - } else { |
|
233 | + } |
|
234 | + else |
|
235 | + { |
|
211 | 236 | $action = $condition['false']; |
212 | 237 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
213 | 238 | } |
@@ -218,9 +243,14 @@ discard block |
||
218 | 243 | die('condition / action not supported!!!'); |
219 | 244 | break; |
220 | 245 | } |
221 | - if ($action['last']) break; |
|
246 | + if ($action['last']) |
|
247 | + { |
|
248 | + break; |
|
249 | + } |
|
222 | 250 | } |
223 | - } else { |
|
251 | + } |
|
252 | + else |
|
253 | + { |
|
224 | 254 | // unconditional insert |
225 | 255 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
226 | 256 | } |
@@ -239,12 +269,14 @@ discard block |
||
239 | 269 | */ |
240 | 270 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
241 | 271 | { |
242 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
272 | + if($record->__get($condition['string']) && $condition['string'] == 'id') |
|
273 | + { |
|
243 | 274 | $event = $this->bo->read($record->__get($condition['string'])); |
244 | 275 | $records = array($event); |
245 | 276 | } |
246 | 277 | |
247 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
278 | + if ( is_array( $records ) && count( $records ) >= 1) |
|
279 | + { |
|
248 | 280 | return true; |
249 | 281 | } |
250 | 282 | return false; |
@@ -260,7 +292,8 @@ discard block |
||
260 | 292 | protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
261 | 293 | { |
262 | 294 | $_data = $record->get_record_array(); |
263 | - switch ($_action) { |
|
295 | + switch ($_action) |
|
296 | + { |
|
264 | 297 | case 'none' : |
265 | 298 | return true; |
266 | 299 | case 'update' : |
@@ -268,7 +301,8 @@ discard block |
||
268 | 301 | $old = $this->bo->read($_data['id']); |
269 | 302 | |
270 | 303 | // Don't change a user account into a record |
271 | - if(!$this->definition->plugin_options['change_owner']) { |
|
304 | + if(!$this->definition->plugin_options['change_owner']) |
|
305 | + { |
|
272 | 306 | // Don't change owner of an existing record |
273 | 307 | unset($_data['owner']); |
274 | 308 | } |
@@ -276,31 +310,40 @@ discard block |
||
276 | 310 | // Merge to deal with fields not in import record |
277 | 311 | $_data = array_merge($old, $_data); |
278 | 312 | $changed = $this->tracking->changed_fields($_data, $old); |
279 | - if(count($changed) == 0) { |
|
313 | + if(count($changed) == 0) |
|
314 | + { |
|
280 | 315 | return true; |
281 | 316 | } |
282 | 317 | // Fall through |
283 | 318 | case 'insert' : |
284 | - if($_action == 'insert') { |
|
319 | + if($_action == 'insert') |
|
320 | + { |
|
285 | 321 | // Backend doesn't like inserting with ID specified, can overwrite existing |
286 | 322 | unset($_data['id']); |
287 | 323 | } |
288 | 324 | // Make sure participants are set |
289 | - if(!$_data['participants']) { |
|
325 | + if(!$_data['participants']) |
|
326 | + { |
|
290 | 327 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
291 | 328 | $_data['participants'] = array( |
292 | 329 | $user => 'U' |
293 | 330 | ); |
294 | 331 | } |
295 | - if ( $this->dry_run ) { |
|
332 | + if ( $this->dry_run ) |
|
333 | + { |
|
296 | 334 | //print_r($_data); |
297 | 335 | $this->results[$_action]++; |
298 | 336 | return true; |
299 | - } else { |
|
337 | + } |
|
338 | + else |
|
339 | + { |
|
300 | 340 | $result = $this->bo->save( $_data, $this->is_admin); |
301 | - if(!$result) { |
|
341 | + if(!$result) |
|
342 | + { |
|
302 | 343 | $this->errors[$record_num] = lang('Unable to save'); |
303 | - } else { |
|
344 | + } |
|
345 | + else |
|
346 | + { |
|
304 | 347 | $this->results[$_action]++; |
305 | 348 | // This does nothing (yet?) but update the identifier |
306 | 349 | $record->save($result); |
@@ -318,7 +361,8 @@ discard block |
||
318 | 361 | * |
319 | 362 | * @return string name |
320 | 363 | */ |
321 | - public static function get_name() { |
|
364 | + public static function get_name() |
|
365 | + { |
|
322 | 366 | return lang('Calendar CSV import'); |
323 | 367 | } |
324 | 368 | |
@@ -327,7 +371,8 @@ discard block |
||
327 | 371 | * |
328 | 372 | * @return string descriprion |
329 | 373 | */ |
330 | - public static function get_description() { |
|
374 | + public static function get_description() |
|
375 | + { |
|
331 | 376 | return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
332 | 377 | } |
333 | 378 | |
@@ -336,7 +381,8 @@ discard block |
||
336 | 381 | * |
337 | 382 | * @return string suffix (comma seperated) |
338 | 383 | */ |
339 | - public static function get_filesuffix() { |
|
384 | + public static function get_filesuffix() |
|
385 | + { |
|
340 | 386 | return 'csv'; |
341 | 387 | } |
342 | 388 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $this->role_map = array_flip($this->bo->roles); |
58 | 58 | |
59 | 59 | $this->lookups = array( |
60 | - 'priority' => Array( |
|
60 | + 'priority' => array( |
|
61 | 61 | 0 => lang('None'), |
62 | 62 | 1 => lang('Low'), |
63 | 63 | 2 => lang('Normal'), |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
240 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$records = array()) |
|
241 | 241 | { |
242 | 242 | if($record->__get($condition['string']) && $condition['string'] == 'id') { |
243 | 243 | $event = $this->bo->read($record->__get($condition['string'])); |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * class import_csv for calendar |
19 | 19 | */ |
20 | -class calendar_import_csv extends importexport_basic_import_csv { |
|
20 | +class calendar_import_csv extends importexport_basic_import_csv { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * actions wich could be done to data entries |
24 | 24 | */ |
25 | - protected static $actions = array( 'none', 'update', 'insert' ); |
|
25 | + protected static $actions = array('none', 'update', 'insert'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * conditions for actions |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Set up tracker |
46 | 46 | */ |
47 | - protected function init(importexport_definition &$definition) |
|
47 | + protected function init(importexport_definition&$definition) |
|
48 | 48 | { |
49 | 49 | // fetch the addressbook bo |
50 | - $this->bo= new calendar_boupdate(); |
|
50 | + $this->bo = new calendar_boupdate(); |
|
51 | 51 | |
52 | 52 | // Get the tracker for changes |
53 | 53 | $this->tracking = new calendar_tracking(); |
54 | 54 | |
55 | 55 | // Used for participants |
56 | - $this->status_map = array_flip(array_map('lang',$this->bo->verbose_status)); |
|
56 | + $this->status_map = array_flip(array_map('lang', $this->bo->verbose_status)); |
|
57 | 57 | $this->role_map = array_flip($this->bo->roles); |
58 | 58 | |
59 | 59 | $this->lookups = array( |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return boolean success |
78 | 78 | */ |
79 | - public function import_record(\importexport_iface_egw_record &$record, &$import_csv) |
|
79 | + public function import_record(\importexport_iface_egw_record&$record, &$import_csv) |
|
80 | 80 | { |
81 | 81 | // set eventOwner |
82 | - $options =& $this->definition->plugin_options; |
|
82 | + $options = & $this->definition->plugin_options; |
|
83 | 83 | $options['owner'] = $options['owner'] ? $options['owner'] : $this->user; |
84 | 84 | |
85 | 85 | // Set owner, unless it's supposed to come from CSV file |
86 | - if($options['owner_from_csv']) { |
|
87 | - if(!is_numeric($record['owner'])) { |
|
86 | + if ($options['owner_from_csv']) { |
|
87 | + if (!is_numeric($record['owner'])) { |
|
88 | 88 | $this->errors[$import_csv->get_current_position()] = lang( |
89 | 89 | 'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.', |
90 | 90 | $record->owner, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Handle errors in length or start/end date |
102 | - if($record->start > $record->end) |
|
102 | + if ($record->start > $record->end) |
|
103 | 103 | { |
104 | 104 | $record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60; |
105 | 105 | $this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!'); |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | if ($record->participants && !is_array($record->participants)) { |
110 | 110 | // Importing participants in human friendly format: |
111 | 111 | // Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+ |
112 | - preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants); |
|
112 | + preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants); |
|
113 | 113 | $p_participants = array(); |
114 | 114 | $missing = array(); |
115 | 115 | list($lines, $p, $names, $quantity, $status, $role) = $participants; |
116 | - foreach($names as $key => $name) { |
|
116 | + foreach ($names as $key => $name) { |
|
117 | 117 | //error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}"); |
118 | 118 | |
119 | 119 | // Search for direct account name, then user in accounts first |
@@ -121,26 +121,26 @@ discard block |
||
121 | 121 | $id = importexport_helper_functions::account_name2id($name); |
122 | 122 | |
123 | 123 | // If not found, or not an exact match to a user (account_name2id is pretty generous) |
124 | - if(!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | - $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1)); |
|
126 | - if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
124 | + if (!$id || $names[$key] !== $this->bo->participant_name($id)) { |
|
125 | + $contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1)); |
|
126 | + if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id']; |
|
127 | 127 | } |
128 | - if(!$id) |
|
128 | + if (!$id) |
|
129 | 129 | { |
130 | 130 | // Use calendar's registered resources to find participant |
131 | - foreach($this->bo->resources as $resource) |
|
131 | + foreach ($this->bo->resources as $resource) |
|
132 | 132 | { |
133 | 133 | // Can't search for email |
134 | - if($resource['app'] == 'email') continue; |
|
134 | + if ($resource['app'] == 'email') continue; |
|
135 | 135 | // Special resource search, since it does special stuff in link_query |
136 | - if($resource['app'] == 'resources') |
|
136 | + if ($resource['app'] == 'resources') |
|
137 | 137 | { |
138 | - if(!$this->resource_so) |
|
138 | + if (!$this->resource_so) |
|
139 | 139 | { |
140 | 140 | $this->resource_so = new resources_so(); |
141 | 141 | } |
142 | - $result = $this->resource_so->search($search,'res_id'); |
|
143 | - if(count($result) >= 1) { |
|
142 | + $result = $this->resource_so->search($search, 'res_id'); |
|
143 | + if (count($result) >= 1) { |
|
144 | 144 | $id = $resource['type'].$result[0]['res_id']; |
145 | 145 | break; |
146 | 146 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | // Search app via link query |
151 | 151 | $result = egw_link::query($resource['app'], $search, $options); |
152 | 152 | |
153 | - if($result) |
|
153 | + if ($result) |
|
154 | 154 | { |
155 | - $id = $resource['type'] . key($result); |
|
155 | + $id = $resource['type'].key($result); |
|
156 | 156 | break; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | - if($id) { |
|
161 | + if ($id) { |
|
162 | 162 | $p_participants[$id] = calendar_so::combine_status( |
163 | 163 | $this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0], |
164 | 164 | $quantity[$key] ? $quantity[$key] : 1, |
@@ -169,47 +169,47 @@ discard block |
||
169 | 169 | { |
170 | 170 | $missing[] = $name; |
171 | 171 | } |
172 | - if(count($missing) > 0) |
|
172 | + if (count($missing) > 0) |
|
173 | 173 | { |
174 | - $this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' . |
|
175 | - lang('Contact not found!') . '<br />'.implode(", ",$missing); |
|
174 | + $this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '. |
|
175 | + lang('Contact not found!').'<br />'.implode(", ", $missing); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | $record->participants = $p_participants; |
179 | 179 | } |
180 | 180 | |
181 | - if($record->recurrence) |
|
181 | + if ($record->recurrence) |
|
182 | 182 | { |
183 | - list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2); |
|
183 | + list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2); |
|
184 | 184 | $record->recur_interval = trim($record->recur_interval); |
185 | - $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$lookups['recurrence'])); |
|
185 | + $record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $lookups['recurrence'])); |
|
186 | 186 | unset($record->recurrence); |
187 | 187 | } |
188 | 188 | $record->tzid = calendar_timezones::id2tz($record->tz_id); |
189 | 189 | |
190 | - if ( $options['conditions'] ) { |
|
191 | - foreach ( $options['conditions'] as $condition ) { |
|
190 | + if ($options['conditions']) { |
|
191 | + foreach ($options['conditions'] as $condition) { |
|
192 | 192 | $records = array(); |
193 | - switch ( $condition['type'] ) { |
|
193 | + switch ($condition['type']) { |
|
194 | 194 | // exists |
195 | 195 | case 'exists' : |
196 | 196 | // Check for that record |
197 | 197 | $result = $this->exists($record, $condition, $records); |
198 | 198 | |
199 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
199 | + if (is_array($records) && count($records) >= 1) { |
|
200 | 200 | // apply action to all records matching this exists condition |
201 | 201 | $action = $condition['true']; |
202 | - foreach ( (array)$records as $event ) { |
|
202 | + foreach ((array)$records as $event) { |
|
203 | 203 | $record->id = $event['id']; |
204 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
205 | - if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category ); |
|
206 | - $record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) ); |
|
204 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
205 | + if (!is_array($record->category)) $record->category = explode(',', $record->category); |
|
206 | + $record->category = implode(',', array_unique(array_merge($record->category, $event['category']))); |
|
207 | 207 | } |
208 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
208 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
209 | 209 | } |
210 | 210 | } else { |
211 | 211 | $action = $condition['false']; |
212 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
212 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
213 | 213 | } |
214 | 214 | break; |
215 | 215 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | } else { |
224 | 224 | // unconditional insert |
225 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
225 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $success; |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array()) |
|
240 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array()) |
|
241 | 241 | { |
242 | - if($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
242 | + if ($record->__get($condition['string']) && $condition['string'] == 'id') { |
|
243 | 243 | $event = $this->bo->read($record->__get($condition['string'])); |
244 | 244 | $records = array($event); |
245 | 245 | } |
246 | 246 | |
247 | - if ( is_array( $records ) && count( $records ) >= 1) { |
|
247 | + if (is_array($records) && count($records) >= 1) { |
|
248 | 248 | return true; |
249 | 249 | } |
250 | 250 | return false; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param array $_data record data for the action |
258 | 258 | * @return bool success or not |
259 | 259 | */ |
260 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
260 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) |
|
261 | 261 | { |
262 | 262 | $_data = $record->get_record_array(); |
263 | 263 | switch ($_action) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $old = $this->bo->read($_data['id']); |
269 | 269 | |
270 | 270 | // Don't change a user account into a record |
271 | - if(!$this->definition->plugin_options['change_owner']) { |
|
271 | + if (!$this->definition->plugin_options['change_owner']) { |
|
272 | 272 | // Don't change owner of an existing record |
273 | 273 | unset($_data['owner']); |
274 | 274 | } |
@@ -276,29 +276,29 @@ discard block |
||
276 | 276 | // Merge to deal with fields not in import record |
277 | 277 | $_data = array_merge($old, $_data); |
278 | 278 | $changed = $this->tracking->changed_fields($_data, $old); |
279 | - if(count($changed) == 0) { |
|
279 | + if (count($changed) == 0) { |
|
280 | 280 | return true; |
281 | 281 | } |
282 | 282 | // Fall through |
283 | 283 | case 'insert' : |
284 | - if($_action == 'insert') { |
|
284 | + if ($_action == 'insert') { |
|
285 | 285 | // Backend doesn't like inserting with ID specified, can overwrite existing |
286 | 286 | unset($_data['id']); |
287 | 287 | } |
288 | 288 | // Make sure participants are set |
289 | - if(!$_data['participants']) { |
|
289 | + if (!$_data['participants']) { |
|
290 | 290 | $user = $_data['owner'] ? $_data['owner'] : $this->user; |
291 | 291 | $_data['participants'] = array( |
292 | 292 | $user => 'U' |
293 | 293 | ); |
294 | 294 | } |
295 | - if ( $this->dry_run ) { |
|
295 | + if ($this->dry_run) { |
|
296 | 296 | //print_r($_data); |
297 | 297 | $this->results[$_action]++; |
298 | 298 | return true; |
299 | 299 | } else { |
300 | - $result = $this->bo->save( $_data, $this->is_admin); |
|
301 | - if(!$result) { |
|
300 | + $result = $this->bo->save($_data, $this->is_admin); |
|
301 | + if (!$result) { |
|
302 | 302 | $this->errors[$record_num] = lang('Unable to save'); |
303 | 303 | } else { |
304 | 304 | $this->results[$_action]++; |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param egw_record $row_entry |
347 | 347 | */ |
348 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
348 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
349 | 349 | { |
350 | - $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true)); |
|
350 | + $row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true)); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | } // end of iface_export_plugin |
@@ -113,8 +113,6 @@ discard block |
||
113 | 113 | * @param array $ids array with contact id(s) |
114 | 114 | * @param string &$err error-message on error |
115 | 115 | * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf |
116 | - * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders |
|
117 | - * @param string $charset=null charset to override default set by mimetype or export charset |
|
118 | 116 | * @return string|boolean merged document or false on error |
119 | 117 | */ |
120 | 118 | function merge_string($content,$ids,$err,$mimetype,$fix) |
@@ -234,7 +232,6 @@ discard block |
||
234 | 232 | * Return replacements for the calendar |
235 | 233 | * |
236 | 234 | * @param int|array $id event-id or array with id/recur_date, or array with event info |
237 | - * @param boolean $last_event_too=false also include information about the last event |
|
238 | 235 | * @return array |
239 | 236 | */ |
240 | 237 | public function calendar_replacements($id,$prefix = '', &$content = '') |
@@ -326,20 +326,20 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
329 | - * Table plugin for event |
|
330 | - * Lists events for a certain day of the week. Only works for one week at a time, so for multiple weeks, |
|
331 | - * use multiple date ranges. |
|
332 | - * |
|
333 | - * Use: |
|
334 | - * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$ |
|
335 | - * The day of the week may be language specific (date('l')). |
|
336 | - * |
|
337 | - * @param string $plugin (Monday-Sunday) |
|
338 | - * @param int/array date or date range |
|
339 | - * @param int $n Row number |
|
340 | - * @param string $repeat Text being repeated for each entry |
|
341 | - * @return array |
|
342 | - */ |
|
329 | + * Table plugin for event |
|
330 | + * Lists events for a certain day of the week. Only works for one week at a time, so for multiple weeks, |
|
331 | + * use multiple date ranges. |
|
332 | + * |
|
333 | + * Use: |
|
334 | + * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$ |
|
335 | + * The day of the week may be language specific (date('l')). |
|
336 | + * |
|
337 | + * @param string $plugin (Monday-Sunday) |
|
338 | + * @param int/array date or date range |
|
339 | + * @param int $n Row number |
|
340 | + * @param string $repeat Text being repeated for each entry |
|
341 | + * @return array |
|
342 | + */ |
|
343 | 343 | public function day_plugin($plugin,$date,$n,$repeat) |
344 | 344 | { |
345 | 345 | static $days = null; |
@@ -414,16 +414,16 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
417 | - * Table plugin for a certain date |
|
418 | - * |
|
419 | - * Can be either a particular date (2011-02-15) or a day of the month (15) |
|
420 | - * |
|
421 | - * @param string $plugin |
|
422 | - * @param int $id ID for this record |
|
423 | - * @param int $n Repeated row number |
|
424 | - * @param string $repeat Text being repeated for each entry |
|
425 | - * @return array |
|
426 | - */ |
|
417 | + * Table plugin for a certain date |
|
418 | + * |
|
419 | + * Can be either a particular date (2011-02-15) or a day of the month (15) |
|
420 | + * |
|
421 | + * @param string $plugin |
|
422 | + * @param int $id ID for this record |
|
423 | + * @param int $n Repeated row number |
|
424 | + * @param string $repeat Text being repeated for each entry |
|
425 | + * @return array |
|
426 | + */ |
|
427 | 427 | public function day($plugin,$id,$n,$repeat) |
428 | 428 | { |
429 | 429 | static $days = null; |
@@ -515,15 +515,15 @@ discard block |
||
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
518 | - * Table plugin for participants |
|
519 | - * |
|
520 | - * Copied from eventmgr resources |
|
521 | - * |
|
522 | - * @param string $plugin |
|
523 | - * @param int $id |
|
524 | - * @param int $n |
|
525 | - * @return array |
|
526 | - */ |
|
518 | + * Table plugin for participants |
|
519 | + * |
|
520 | + * Copied from eventmgr resources |
|
521 | + * |
|
522 | + * @param string $plugin |
|
523 | + * @param int $id |
|
524 | + * @param int $n |
|
525 | + * @return array |
|
526 | + */ |
|
527 | 527 | public function participant($plugin,$id,$n) |
528 | 528 | { |
529 | 529 | unset($plugin); // not used, but required by function signature |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | { |
583 | 583 | foreach($resource as $name => $value) |
584 | 584 | { |
585 | - $replacements['$$'.$name.'$$'] = $value; |
|
585 | + $replacements['$$'.$name.'$$'] = $value; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | break; |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | |
83 | 83 | // Register table plugins |
84 | 84 | $this->table_plugins['participant'] = 'participant'; |
85 | - for($i = 0; $i < 7; $i++) |
|
85 | + for ($i = 0; $i < 7; $i++) |
|
86 | 86 | { |
87 | 87 | $this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin'; |
88 | 88 | } |
89 | - for($i = 1; $i <= 31; $i++) { |
|
89 | + for ($i = 1; $i <= 31; $i++) { |
|
90 | 90 | $this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31) |
91 | 91 | } |
92 | - foreach(self::$relative as $day) { |
|
92 | + foreach (self::$relative as $day) { |
|
93 | 93 | $this->table_plugins[$day] = 'day'; // Current day |
94 | 94 | } |
95 | - $this->query = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
95 | + $this->query = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
96 | 96 | $this->query['users'] = explode(',', $this->query['owner']); |
97 | 97 | $this->query['num_rows'] = -1; |
98 | 98 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * @param string $charset=null charset to override default set by mimetype or export charset |
114 | 114 | * @return string|boolean merged document or false on error |
115 | 115 | */ |
116 | - function merge_string($content,$ids,$err,$mimetype,$fix) |
|
116 | + function merge_string($content, $ids, $err, $mimetype, $fix) |
|
117 | 117 | { |
118 | 118 | // Handle merging a list of events into a document with range instead of pagerepeat |
119 | - if(strpos($content, '$$pagerepeat') === false && strpos($content, '{{pagerepeat') === false && count($ids) > 1) |
|
119 | + if (strpos($content, '$$pagerepeat') === false && strpos($content, '{{pagerepeat') === false && count($ids) > 1) |
|
120 | 120 | { |
121 | 121 | // Merging more than one something will fail without pagerepeat |
122 | 122 | if (is_array($ids) && $ids[0]['id']) |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | $events = $ids; |
126 | 126 | $ids = array('start' => PHP_INT_MAX, 'end' => 0); |
127 | 127 | $this->ids = array(); |
128 | - foreach($events as $event) { |
|
129 | - if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'],'ts'); |
|
130 | - if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'],'ts'); |
|
128 | + foreach ($events as $event) { |
|
129 | + if ($event['start'] && egw_time::to($event['start'], 'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'], 'ts'); |
|
130 | + if ($event['end'] && egw_time::to($event['end'], 'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'], 'ts'); |
|
131 | 131 | // Keep ids for future use |
132 | 132 | $this->ids[] = $event['id']; |
133 | 133 | } |
134 | 134 | $ids = array($ids); |
135 | 135 | } |
136 | 136 | } |
137 | - return parent::merge_string($content, $ids, $err, $mimetype,$fix); |
|
137 | + return parent::merge_string($content, $ids, $err, $mimetype, $fix); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | * @param string &$content=null content to create some replacements only if they are used |
145 | 145 | * @return array|boolean |
146 | 146 | */ |
147 | - protected function get_replacements($id,&$content=null) |
|
147 | + protected function get_replacements($id, &$content = null) |
|
148 | 148 | { |
149 | 149 | $prefix = ''; |
150 | 150 | // List events ? |
151 | - if(is_array($id) && !$id['id'] && !$id[0]['id']) |
|
151 | + if (is_array($id) && !$id['id'] && !$id[0]['id']) |
|
152 | 152 | { |
153 | 153 | $events = $this->bo->search($this->query + $id + array( |
154 | 154 | 'offset' => 0, |
155 | 155 | 'order' => 'cal_start', |
156 | 156 | 'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null |
157 | 157 | )); |
158 | - if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
158 | + if (strpos($content, '$$calendar/') !== false || strpos($content, '$$table/day') !== false) |
|
159 | 159 | { |
160 | - array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
160 | + array_unshift($events, false); unset($events[0]); // renumber the array to start with key 1, instead of 0 |
|
161 | 161 | $prefix = 'calendar/%d'; |
162 | 162 | } |
163 | 163 | } |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $events = $id; |
168 | 168 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
169 | 169 | $this->ids = array(); |
170 | - foreach($events as $event) { |
|
171 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
172 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
170 | + foreach ($events as $event) { |
|
171 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
172 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
173 | 173 | // Keep ids for future use |
174 | - $this->ids[] = $event['id']; |
|
174 | + $this->ids[] = $event['id']; |
|
175 | 175 | } |
176 | 176 | $id = array($id); |
177 | 177 | } |
@@ -183,20 +183,20 @@ discard block |
||
183 | 183 | // as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions |
184 | 184 | if (bo_merge::hasExportLimit($this->export_limit) && !bo_merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit) |
185 | 185 | { |
186 | - $err = lang('No rights to export more than %1 entries!',(int)$this->export_limit); |
|
186 | + $err = lang('No rights to export more than %1 entries!', (int)$this->export_limit); |
|
187 | 187 | throw new egw_exception_wrong_userinput($err); |
188 | 188 | } |
189 | 189 | $replacements = array(); |
190 | 190 | $n = 0; |
191 | - foreach($events as $event) |
|
191 | + foreach ($events as $event) |
|
192 | 192 | { |
193 | - $values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content); |
|
194 | - if(is_array($id) && $id['start']) |
|
193 | + $values = $this->calendar_replacements($event, sprintf($prefix, ++$n), $content); |
|
194 | + if (is_array($id) && $id['start']) |
|
195 | 195 | { |
196 | - foreach(self::$range_tags as $key => $format) |
|
196 | + foreach (self::$range_tags as $key => $format) |
|
197 | 197 | { |
198 | 198 | $value = date($format, $key == 'end' ? $id['end'] : $id['start']); |
199 | - if($key == 'month') $value = lang($value); |
|
199 | + if ($key == 'month') $value = lang($value); |
|
200 | 200 | $values["$\$range/$key$$"] = $value; |
201 | 201 | } |
202 | 202 | } |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @param boolean $last_event_too=false also include information about the last event |
213 | 213 | * @return array |
214 | 214 | */ |
215 | - public function calendar_replacements($id,$prefix = '', &$content = '') |
|
215 | + public function calendar_replacements($id, $prefix = '', &$content = '') |
|
216 | 216 | { |
217 | 217 | $replacements = array(); |
218 | - if(!is_array($id) || !$id['start']) { |
|
218 | + if (!is_array($id) || !$id['start']) { |
|
219 | 219 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
220 | 220 | } else { |
221 | 221 | $event = $id; |
@@ -228,68 +228,68 @@ discard block |
||
228 | 228 | importexport_export_csv::convert($record, $types, 'calendar'); |
229 | 229 | |
230 | 230 | $array = $record->get_record_array(); |
231 | - foreach($array as $key => $value) |
|
231 | + foreach ($array as $key => $value) |
|
232 | 232 | { |
233 | - $replacements['$$'.($prefix?$prefix.'/':'').$key.'$$'] = $value; |
|
233 | + $replacements['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
234 | 234 | } |
235 | 235 | |
236 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id']; |
|
237 | - foreach($this->bo->event2array($event) as $name => $data) |
|
236 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_id'.'$$'] = $event['id']; |
|
237 | + foreach ($this->bo->event2array($event) as $name => $data) |
|
238 | 238 | { |
239 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
240 | - $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
239 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
240 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
241 | 241 | } |
242 | 242 | // Add seperate lists of participants by type |
243 | - if(strpos($content, 'calendar_participants/')!== false) |
|
243 | + if (strpos($content, 'calendar_participants/') !== false) |
|
244 | 244 | { |
245 | 245 | $types = array(); |
246 | - foreach($this->bo->resources as $resource) |
|
246 | + foreach ($this->bo->resources as $resource) |
|
247 | 247 | { |
248 | 248 | $types[$resource['app']] = array(); |
249 | 249 | } |
250 | - foreach($event['participants'] as $uid => $status) |
|
250 | + foreach ($event['participants'] as $uid => $status) |
|
251 | 251 | { |
252 | 252 | $type = $this->bo->resources[$uid[0]]['app']; |
253 | - if($type == 'home-accounts') |
|
253 | + if ($type == 'home-accounts') |
|
254 | 254 | { |
255 | 255 | $type = ($GLOBALS['egw']->accounts->get_type($uid) == 'g' ? 'group' : 'account'); |
256 | 256 | } |
257 | 257 | $types[$type][] = $this->bo->participant_name($uid); |
258 | 258 | } |
259 | - foreach($types as $t_id => $type) |
|
259 | + foreach ($types as $t_id => $type) |
|
260 | 260 | { |
261 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type); |
|
261 | + $replacements['$$'.($prefix ? $prefix.'/' : '')."calendar_participants/{$t_id}$$"] = implode(', ', $type); |
|
262 | 262 | } |
263 | 263 | } |
264 | - if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$']) |
|
264 | + if (!$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$']) |
|
265 | 265 | { |
266 | 266 | // Need to set it to '' if not set or previous record may be used |
267 | - $replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'] = ''; |
|
267 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'] = ''; |
|
268 | 268 | } |
269 | - foreach(array('start','end') as $what) |
|
269 | + foreach (array('start', 'end') as $what) |
|
270 | 270 | { |
271 | - foreach(array( |
|
271 | + foreach (array( |
|
272 | 272 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
273 | 273 | 'day' => 'l', |
274 | - 'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
274 | + 'time' => (date('Ymd', $event['start']) != date('Ymd', $event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '').($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'), |
|
275 | 275 | ) as $name => $format) |
276 | 276 | { |
277 | - $value = egw_time::to($event[$what],$format); |
|
277 | + $value = egw_time::to($event[$what], $format); |
|
278 | 278 | if ($format == 'l') $value = lang($value); |
279 | - $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; |
|
279 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$what.$name.'$$'] = $value; |
|
280 | 280 | } |
281 | 281 | } |
282 | - $duration = ($event['end'] - $event['start'])/60; |
|
283 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
282 | + $duration = ($event['end'] - $event['start']) / 60; |
|
283 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
284 | 284 | |
285 | 285 | // Add in contact stuff for owner |
286 | - if (strpos($content,'$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'],'person_id'))) |
|
286 | + if (strpos($content, '$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'], 'person_id'))) |
|
287 | 287 | { |
288 | - $replacements += $this->contact_replacements($user,($prefix ? $prefix.'/':'').'calendar_owner'); |
|
289 | - $replacements['$$'.($prefix?$prefix.'/':'').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'],'account_primary_group')); |
|
288 | + $replacements += $this->contact_replacements($user, ($prefix ? $prefix.'/' : '').'calendar_owner'); |
|
289 | + $replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_primary_group')); |
|
290 | 290 | } |
291 | 291 | |
292 | - if($content && strpos($content, '$$#') !== FALSE) |
|
292 | + if ($content && strpos($content, '$$#') !== FALSE) |
|
293 | 293 | { |
294 | 294 | $this->cf_link_to_expand($event, $content, $replacements); |
295 | 295 | } |
@@ -315,77 +315,77 @@ discard block |
||
315 | 315 | * @param string $repeat Text being repeated for each entry |
316 | 316 | * @return array |
317 | 317 | */ |
318 | - public function day_plugin($plugin,$date,$n,$repeat) |
|
318 | + public function day_plugin($plugin, $date, $n, $repeat) |
|
319 | 319 | { |
320 | 320 | static $days = null; |
321 | - if(is_array($date) && !$date['start']) { |
|
321 | + if (is_array($date) && !$date['start']) { |
|
322 | 322 | // List of IDs |
323 | - if($date[0]['start']) { |
|
323 | + if ($date[0]['start']) { |
|
324 | 324 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
325 | - foreach($date as $event) { |
|
326 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
327 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
325 | + foreach ($date as $event) { |
|
326 | + if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
327 | + if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
328 | 328 | } |
329 | 329 | $date = $id; |
330 | 330 | } else { |
331 | 331 | $event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null); |
332 | - if(date('l',$event['start']) != $plugin) return array(); |
|
332 | + if (date('l', $event['start']) != $plugin) return array(); |
|
333 | 333 | $date = $event['start']; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | $_date = $date['start'] ? $date['start'] : $date; |
338 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
338 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
339 | 339 | |
340 | 340 | $events = $this->bo->search($this->query + array( |
341 | - 'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
342 | - 'end' => $date['end'] ? $date['end'] : mktime(23,59,59,date('m',$_date),date('d',$_date),date('Y',$_date)), |
|
341 | + 'start' => $date['end'] ? $date['start'] : mktime(0, 0, 0, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
342 | + 'end' => $date['end'] ? $date['end'] : mktime(23, 59, 59, date('m', $_date), date('d', $_date), date('Y', $_date)), |
|
343 | 343 | 'offset' => 0, |
344 | 344 | 'num_rows' => 20, |
345 | 345 | 'order' => 'cal_start', |
346 | 346 | 'daywise' => true, |
347 | - 'cfs' => array(), // read all custom-fields |
|
347 | + 'cfs' => array(), // read all custom-fields |
|
348 | 348 | )); |
349 | 349 | |
350 | 350 | if (true) $days = array(); |
351 | 351 | $replacements = array(); |
352 | 352 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
353 | - foreach($events as $day => $list) |
|
353 | + foreach ($events as $day => $list) |
|
354 | 354 | { |
355 | - foreach($list as $event) |
|
355 | + foreach ($list as $event) |
|
356 | 356 | { |
357 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
357 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
358 | 358 | $start = egw_time::to($event['start'], 'array'); |
359 | 359 | $end = egw_time::to($event['end'], 'array'); |
360 | 360 | $replacements = $this->calendar_replacements($event); |
361 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
362 | - $dow = date('l',$event['start']); |
|
361 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
362 | + $dow = date('l', $event['start']); |
|
363 | 363 | } else { |
364 | 364 | $dow = date('l', strtotime($day)); |
365 | 365 | // Fancy date+time formatting for multi-day events |
366 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
367 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
366 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
367 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
368 | 368 | } |
369 | 369 | |
370 | - $days[date('Ymd',$_date)][$dow][] = $replacements; |
|
370 | + $days[date('Ymd', $_date)][$dow][] = $replacements; |
|
371 | 371 | } |
372 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
372 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
373 | 373 | $date_marker = array( |
374 | 374 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
375 | 375 | '$$day/name$$' => lang(date('l', strtotime($day))) |
376 | 376 | ); |
377 | - if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) { |
|
377 | + if (!is_array($days[date('Ymd', $_date)][date('l', strtotime($day))])) { |
|
378 | 378 | $blank = $this->calendar_replacements(array()); |
379 | - foreach($blank as &$value) |
|
379 | + foreach ($blank as &$value) |
|
380 | 380 | { |
381 | 381 | $value = ''; |
382 | 382 | } |
383 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][] = $blank; |
|
383 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][] = $blank; |
|
384 | 384 | } |
385 | - $days[date('Ymd',$_date)][date('l',strtotime($day))][0] += $date_marker; |
|
385 | + $days[date('Ymd', $_date)][date('l', strtotime($day))][0] += $date_marker; |
|
386 | 386 | } |
387 | 387 | } |
388 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
388 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -399,27 +399,27 @@ discard block |
||
399 | 399 | * @param string $repeat Text being repeated for each entry |
400 | 400 | * @return array |
401 | 401 | */ |
402 | - public function day($plugin,$id,$n,$repeat) |
|
402 | + public function day($plugin, $id, $n, $repeat) |
|
403 | 403 | { |
404 | 404 | static $days = null; |
405 | 405 | |
406 | 406 | // Figure out which day |
407 | - list($type, $which) = explode('_',$plugin); |
|
408 | - if($type == 'day' && $which) |
|
407 | + list($type, $which) = explode('_', $plugin); |
|
408 | + if ($type == 'day' && $which) |
|
409 | 409 | { |
410 | - if($id[0]['start']) |
|
410 | + if ($id[0]['start']) |
|
411 | 411 | { |
412 | 412 | $dates = array('start' => PHP_INT_MAX, 'end' => 0); |
413 | - foreach($id as $event) { |
|
414 | - if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
415 | - if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
413 | + foreach ($id as $event) { |
|
414 | + if ($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
415 | + if ($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
416 | 416 | } |
417 | 417 | $id = $dates; |
418 | 418 | } |
419 | 419 | $arr = $this->bo->date2array($id['start']); |
420 | 420 | $arr['day'] = $which; |
421 | 421 | $date = $this->bo->date2ts($arr); |
422 | - if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
422 | + if (is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
423 | 423 | } |
424 | 424 | elseif ($plugin == 'selected') |
425 | 425 | { |
@@ -429,64 +429,64 @@ discard block |
||
429 | 429 | { |
430 | 430 | $date = strtotime($plugin); |
431 | 431 | } |
432 | - if($type == 'day' && is_array($id) && !$id['start']) { |
|
432 | + if ($type == 'day' && is_array($id) && !$id['start']) { |
|
433 | 433 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
434 | - if($which && date('d',$event['start']) != $which) return array(); |
|
435 | - if(date('Ymd',$date) != date('Ymd', $event['start'])) return array(); |
|
434 | + if ($which && date('d', $event['start']) != $which) return array(); |
|
435 | + if (date('Ymd', $date) != date('Ymd', $event['start'])) return array(); |
|
436 | 436 | return $n == 0 ? $this->calendar_replacements($event) : array(); |
437 | 437 | } |
438 | 438 | |
439 | 439 | // Use start for cache, in case of multiple months |
440 | 440 | $_date = $id['start'] ? $id['start'] : $date; |
441 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
441 | + if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n]; |
|
442 | 442 | |
443 | 443 | $events = $this->bo->search($this->query + array( |
444 | 444 | 'start' => $date, |
445 | - 'end' => mktime(23,59,59,date('m',$date),date('d',$date),date('Y',$date)), |
|
445 | + 'end' => mktime(23, 59, 59, date('m', $date), date('d', $date), date('Y', $date)), |
|
446 | 446 | 'offset' => 0, |
447 | 447 | 'num_rows' => 20, |
448 | 448 | 'order' => 'cal_start', |
449 | 449 | 'daywise' => true, |
450 | - 'cfs' => array(), // read all custom-fields |
|
450 | + 'cfs' => array(), // read all custom-fields |
|
451 | 451 | )); |
452 | 452 | |
453 | 453 | $replacements = array(); |
454 | 454 | if (true) $days = array(); |
455 | 455 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
456 | - foreach($events as $day => $list) |
|
456 | + foreach ($events as $day => $list) |
|
457 | 457 | { |
458 | - foreach($list as $event) |
|
458 | + foreach ($list as $event) |
|
459 | 459 | { |
460 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
460 | + if ($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
461 | 461 | $start = egw_time::to($event['start'], 'array'); |
462 | 462 | $end = egw_time::to($event['end'], 'array'); |
463 | 463 | $replacements = $this->calendar_replacements($event); |
464 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
464 | + if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
465 | 465 | //$dow = date('l',$event['start']); |
466 | 466 | } else { |
467 | 467 | // Fancy date+time formatting for multi-day events |
468 | - $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
|
469 | - $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
|
468 | + $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1)); |
|
469 | + $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0)); |
|
470 | 470 | } |
471 | - $days[date('Ymd',$_date)][$plugin][] = $replacements; |
|
471 | + $days[date('Ymd', $_date)][$plugin][] = $replacements; |
|
472 | 472 | } |
473 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
473 | + if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
474 | 474 | $date_marker = array( |
475 | 475 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
476 | 476 | '$$day/name$$' => lang(date('l', strtotime($day))) |
477 | 477 | ); |
478 | - if(!is_array($days[date('Ymd',$_date)][$plugin])) { |
|
478 | + if (!is_array($days[date('Ymd', $_date)][$plugin])) { |
|
479 | 479 | $blank = $this->calendar_replacements(array()); |
480 | - foreach($blank as &$value) |
|
480 | + foreach ($blank as &$value) |
|
481 | 481 | { |
482 | 482 | $value = ''; |
483 | 483 | } |
484 | - $days[date('Ymd',$_date)][$plugin][] = $blank; |
|
484 | + $days[date('Ymd', $_date)][$plugin][] = $blank; |
|
485 | 485 | } |
486 | - $days[date('Ymd',$_date)][$plugin][0] += $date_marker; |
|
486 | + $days[date('Ymd', $_date)][$plugin][0] += $date_marker; |
|
487 | 487 | } |
488 | 488 | } |
489 | - return $days[date('Ymd',$_date)][$plugin][0]; |
|
489 | + return $days[date('Ymd', $_date)][$plugin][0]; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -499,30 +499,30 @@ discard block |
||
499 | 499 | * @param int $n |
500 | 500 | * @return array |
501 | 501 | */ |
502 | - public function participant($plugin,$id,$n) |
|
502 | + public function participant($plugin, $id, $n) |
|
503 | 503 | { |
504 | - unset($plugin); // not used, but required by function signature |
|
504 | + unset($plugin); // not used, but required by function signature |
|
505 | 505 | |
506 | - if(!is_array($id) || !$id['start']) { |
|
506 | + if (!is_array($id) || !$id['start']) { |
|
507 | 507 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
508 | 508 | } else { |
509 | 509 | $event = $id; |
510 | 510 | } |
511 | 511 | |
512 | - if(!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
512 | + if (!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
513 | 513 | |
514 | 514 | $participant = null; |
515 | 515 | $status = null; |
516 | 516 | $i = -1; |
517 | - foreach($event['participants'] as $participant => $status) { |
|
518 | - if(++$i == $n) break; |
|
517 | + foreach ($event['participants'] as $participant => $status) { |
|
518 | + if (++$i == $n) break; |
|
519 | 519 | } |
520 | 520 | |
521 | - if(!$participant) return array(); |
|
521 | + if (!$participant) return array(); |
|
522 | 522 | |
523 | 523 | // Add some common information |
524 | 524 | $quantity = $role = null; |
525 | - calendar_so::split_status($status,$quantity,$role); |
|
525 | + calendar_so::split_status($status, $quantity, $role); |
|
526 | 526 | if ($role != 'REQ-PARTICIPANT') |
527 | 527 | { |
528 | 528 | if (isset($this->bo->roles[$role])) |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | $role = lang($this->bo->roles[$role]); |
531 | 531 | } |
532 | 532 | // allow to use cats as roles (beside regular iCal ones) |
533 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
533 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
534 | 534 | { |
535 | 535 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
536 | 536 | } |
537 | 537 | else |
538 | 538 | { |
539 | - $role = lang(str_replace('X-','',$role)); |
|
539 | + $role = lang(str_replace('X-', '', $role)); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | $info = array( |
@@ -549,26 +549,26 @@ discard block |
||
549 | 549 | switch ($participant[0]) |
550 | 550 | { |
551 | 551 | case 'c': |
552 | - $replacements = $this->contact_replacements(substr($participant,1),''); |
|
552 | + $replacements = $this->contact_replacements(substr($participant, 1), ''); |
|
553 | 553 | break; |
554 | 554 | case 'r': |
555 | 555 | if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo'); |
556 | - if (($resource = self::$resources->read(substr($participant,1)))) |
|
556 | + if (($resource = self::$resources->read(substr($participant, 1)))) |
|
557 | 557 | { |
558 | - foreach($resource as $name => $value) |
|
558 | + foreach ($resource as $name => $value) |
|
559 | 559 | { |
560 | 560 | $replacements['$$'.$name.'$$'] = $value; |
561 | 561 | } |
562 | 562 | } |
563 | 563 | break; |
564 | 564 | default: |
565 | - if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant,'person_id'))) |
|
565 | + if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant, 'person_id'))) |
|
566 | 566 | { |
567 | - $replacements = $this->contact_replacements($contact,''); |
|
567 | + $replacements = $this->contact_replacements($contact, ''); |
|
568 | 568 | } |
569 | 569 | break; |
570 | 570 | } |
571 | - foreach($info as $name => $value) |
|
571 | + foreach ($info as $name => $value) |
|
572 | 572 | { |
573 | 573 | $replacements['$$'.$name.'$$'] = $value; |
574 | 574 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>"; |
591 | 591 | |
592 | 592 | $n = 0; |
593 | - foreach(array( |
|
593 | + foreach (array( |
|
594 | 594 | 'calendar_id' => lang('Calendar ID'), |
595 | 595 | 'calendar_title' => lang('Title'), |
596 | 596 | 'calendar_description' => lang('Description'), |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | 'calendar_owner' => lang('Owner'), |
614 | 614 | ) as $name => $label) |
615 | 615 | { |
616 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
616 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
617 | 617 | { |
618 | 618 | echo "</tr>\n"; |
619 | 619 | $n++; |
@@ -626,13 +626,13 @@ discard block |
||
626 | 626 | |
627 | 627 | echo '<tr><td colspan="4"><h3>'.lang('Range fields').":</h3></td></tr>"; |
628 | 628 | echo '<tr><td colspan="4">'.lang('If you select a range (month, week, etc) instead of a list of entries, these extra fields are available').'</td></tr>'; |
629 | - foreach(array_keys(self::$range_tags) as $name) |
|
629 | + foreach (array_keys(self::$range_tags) as $name) |
|
630 | 630 | { |
631 | 631 | echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n"; |
632 | 632 | } |
633 | 633 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
634 | 634 | $custom = config::get_customfields('calendar'); |
635 | - foreach($custom as $name => $field) |
|
635 | + foreach ($custom as $name => $field) |
|
636 | 636 | { |
637 | 637 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
638 | 638 | } |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | echo '<tr><td colspan="4"><h3>'.lang('Participants').":</h3></td></tr>"; |
642 | 642 | echo '<tr><td>{{calendar_participants/account}}</td><td colspan="3">'.lang('Accounts')."</td></tr>\n"; |
643 | 643 | echo '<tr><td>{{calendar_participants/group}}</td><td colspan="3">'.lang('Groups')."</td></tr>\n"; |
644 | - foreach($this->bo->resources as $resource) |
|
644 | + foreach ($this->bo->resources as $resource) |
|
645 | 645 | { |
646 | - if($resource['type']) |
|
646 | + if ($resource['type']) |
|
647 | 647 | { |
648 | 648 | echo '<tr><td>{{calendar_participants/'.$resource['app'].'}}</td><td colspan="3">'.lang($resource['app'])."</td></tr>\n"; |
649 | 649 | } |
@@ -660,19 +660,19 @@ discard block |
||
660 | 660 | echo '<tr style="vertical-align:top"><td colspan="2"><table >'; |
661 | 661 | echo '<tr><td><h3>'.lang('Day of week tables').":</h3></td></tr>"; |
662 | 662 | $days = array(); |
663 | - for($i = 0; $i < 7; $i++) |
|
663 | + for ($i = 0; $i < 7; $i++) |
|
664 | 664 | { |
665 | - $days[date('N',strtotime("+$i days"))] = date('l',strtotime("+$i days")); |
|
665 | + $days[date('N', strtotime("+$i days"))] = date('l', strtotime("+$i days")); |
|
666 | 666 | } |
667 | 667 | ksort($days); |
668 | - foreach($days as $day) |
|
668 | + foreach ($days as $day) |
|
669 | 669 | { |
670 | - echo '<tr><td>{{table/'.$day. '}} ... {{endtable}}</td></tr>'; |
|
670 | + echo '<tr><td>{{table/'.$day.'}} ... {{endtable}}</td></tr>'; |
|
671 | 671 | } |
672 | 672 | echo '</table></td><td colspan="2"><table >'; |
673 | 673 | echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>"; |
674 | - foreach(self::$relative as $value) { |
|
675 | - echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>'; |
|
674 | + foreach (self::$relative as $value) { |
|
675 | + echo '<tr><td>{{table/'.$value.'}} ... {{endtable}}</td></tr>'; |
|
676 | 676 | } |
677 | 677 | echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>'; |
678 | 678 | echo '</table></td></tr>'; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>'; |
681 | 681 | |
682 | 682 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
683 | - foreach(array( |
|
683 | + foreach (array( |
|
684 | 684 | 'link' => lang('HTML link to the current record'), |
685 | 685 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
686 | 686 | 'attachments' => lang('List of files linked to the current record'), |
@@ -86,10 +86,12 @@ discard block |
||
86 | 86 | { |
87 | 87 | $this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin'; |
88 | 88 | } |
89 | - for($i = 1; $i <= 31; $i++) { |
|
89 | + for($i = 1; $i <= 31; $i++) |
|
90 | + { |
|
90 | 91 | $this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31) |
91 | 92 | } |
92 | - foreach(self::$relative as $day) { |
|
93 | + foreach(self::$relative as $day) |
|
94 | + { |
|
93 | 95 | $this->table_plugins[$day] = 'day'; // Current day |
94 | 96 | } |
95 | 97 | $this->query = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
@@ -125,9 +127,16 @@ discard block |
||
125 | 127 | $events = $ids; |
126 | 128 | $ids = array('start' => PHP_INT_MAX, 'end' => 0); |
127 | 129 | $this->ids = array(); |
128 | - foreach($events as $event) { |
|
129 | - if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'],'ts'); |
|
130 | - if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'],'ts'); |
|
130 | + foreach($events as $event) |
|
131 | + { |
|
132 | + if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) |
|
133 | + { |
|
134 | + $ids['start'] = egw_time::to($event['start'],'ts'); |
|
135 | + } |
|
136 | + if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) |
|
137 | + { |
|
138 | + $ids['end'] = egw_time::to($event['end'],'ts'); |
|
139 | + } |
|
131 | 140 | // Keep ids for future use |
132 | 141 | $this->ids[] = $event['id']; |
133 | 142 | } |
@@ -167,9 +176,16 @@ discard block |
||
167 | 176 | $events = $id; |
168 | 177 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
169 | 178 | $this->ids = array(); |
170 | - foreach($events as $event) { |
|
171 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
172 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
179 | + foreach($events as $event) |
|
180 | + { |
|
181 | + if($event['start'] && $event['start'] < $id['start']) |
|
182 | + { |
|
183 | + $id['start'] = $event['start']; |
|
184 | + } |
|
185 | + if($event['end'] && $event['end'] > $id['end']) |
|
186 | + { |
|
187 | + $id['end'] = $event['end']; |
|
188 | + } |
|
173 | 189 | // Keep ids for future use |
174 | 190 | $this->ids[] = $event['id']; |
175 | 191 | } |
@@ -196,7 +212,10 @@ discard block |
||
196 | 212 | foreach(self::$range_tags as $key => $format) |
197 | 213 | { |
198 | 214 | $value = date($format, $key == 'end' ? $id['end'] : $id['start']); |
199 | - if($key == 'month') $value = lang($value); |
|
215 | + if($key == 'month') |
|
216 | + { |
|
217 | + $value = lang($value); |
|
218 | + } |
|
200 | 219 | $values["$\$range/$key$$"] = $value; |
201 | 220 | } |
202 | 221 | } |
@@ -215,9 +234,12 @@ discard block |
||
215 | 234 | public function calendar_replacements($id,$prefix = '', &$content = '') |
216 | 235 | { |
217 | 236 | $replacements = array(); |
218 | - if(!is_array($id) || !$id['start']) { |
|
237 | + if(!is_array($id) || !$id['start']) |
|
238 | + { |
|
219 | 239 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
220 | - } else { |
|
240 | + } |
|
241 | + else |
|
242 | + { |
|
221 | 243 | $event = $id; |
222 | 244 | } |
223 | 245 | |
@@ -236,7 +258,10 @@ discard block |
||
236 | 258 | $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id']; |
237 | 259 | foreach($this->bo->event2array($event) as $name => $data) |
238 | 260 | { |
239 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
261 | + if (substr($name,-4) == 'date') |
|
262 | + { |
|
263 | + $name = substr($name,0,-4); |
|
264 | + } |
|
240 | 265 | $replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
241 | 266 | } |
242 | 267 | // Add seperate lists of participants by type |
@@ -275,7 +300,10 @@ discard block |
||
275 | 300 | ) as $name => $format) |
276 | 301 | { |
277 | 302 | $value = egw_time::to($event[$what],$format); |
278 | - if ($format == 'l') $value = lang($value); |
|
303 | + if ($format == 'l') |
|
304 | + { |
|
305 | + $value = lang($value); |
|
306 | + } |
|
279 | 307 | $replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value; |
280 | 308 | } |
281 | 309 | } |
@@ -318,24 +346,41 @@ discard block |
||
318 | 346 | public function day_plugin($plugin,$date,$n,$repeat) |
319 | 347 | { |
320 | 348 | static $days = null; |
321 | - if(is_array($date) && !$date['start']) { |
|
349 | + if(is_array($date) && !$date['start']) |
|
350 | + { |
|
322 | 351 | // List of IDs |
323 | - if($date[0]['start']) { |
|
352 | + if($date[0]['start']) |
|
353 | + { |
|
324 | 354 | $id = array('start' => PHP_INT_MAX, 'end' => 0); |
325 | - foreach($date as $event) { |
|
326 | - if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start']; |
|
327 | - if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end']; |
|
355 | + foreach($date as $event) |
|
356 | + { |
|
357 | + if($event['start'] && $event['start'] < $id['start']) |
|
358 | + { |
|
359 | + $id['start'] = $event['start']; |
|
360 | + } |
|
361 | + if($event['end'] && $event['end'] > $id['end']) |
|
362 | + { |
|
363 | + $id['end'] = $event['end']; |
|
364 | + } |
|
328 | 365 | } |
329 | 366 | $date = $id; |
330 | - } else { |
|
367 | + } |
|
368 | + else |
|
369 | + { |
|
331 | 370 | $event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null); |
332 | - if(date('l',$event['start']) != $plugin) return array(); |
|
371 | + if(date('l',$event['start']) != $plugin) |
|
372 | + { |
|
373 | + return array(); |
|
374 | + } |
|
333 | 375 | $date = $event['start']; |
334 | 376 | } |
335 | 377 | } |
336 | 378 | |
337 | 379 | $_date = $date['start'] ? $date['start'] : $date; |
338 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
380 | + if($days[date('Ymd',$_date)][$plugin]) |
|
381 | + { |
|
382 | + return $days[date('Ymd',$_date)][$plugin][$n]; |
|
383 | + } |
|
339 | 384 | |
340 | 385 | $events = $this->bo->search($this->query + array( |
341 | 386 | 'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)), |
@@ -347,20 +392,29 @@ discard block |
||
347 | 392 | 'cfs' => array(), // read all custom-fields |
348 | 393 | )); |
349 | 394 | |
350 | - if (true) $days = array(); |
|
395 | + if (true) |
|
396 | + { |
|
397 | + $days = array(); |
|
398 | + } |
|
351 | 399 | $replacements = array(); |
352 | 400 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
353 | 401 | foreach($events as $day => $list) |
354 | 402 | { |
355 | 403 | foreach($list as $event) |
356 | 404 | { |
357 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
405 | + if($this->ids && !in_array($event['id'], $this->ids)) |
|
406 | + { |
|
407 | + continue; |
|
408 | + } |
|
358 | 409 | $start = egw_time::to($event['start'], 'array'); |
359 | 410 | $end = egw_time::to($event['end'], 'array'); |
360 | 411 | $replacements = $this->calendar_replacements($event); |
361 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
412 | + if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) |
|
413 | + { |
|
362 | 414 | $dow = date('l',$event['start']); |
363 | - } else { |
|
415 | + } |
|
416 | + else |
|
417 | + { |
|
364 | 418 | $dow = date('l', strtotime($day)); |
365 | 419 | // Fancy date+time formatting for multi-day events |
366 | 420 | $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
@@ -369,12 +423,14 @@ discard block |
||
369 | 423 | |
370 | 424 | $days[date('Ymd',$_date)][$dow][] = $replacements; |
371 | 425 | } |
372 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
426 | + if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) |
|
427 | + { |
|
373 | 428 | $date_marker = array( |
374 | 429 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
375 | 430 | '$$day/name$$' => lang(date('l', strtotime($day))) |
376 | 431 | ); |
377 | - if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) { |
|
432 | + if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) |
|
433 | + { |
|
378 | 434 | $blank = $this->calendar_replacements(array()); |
379 | 435 | foreach($blank as &$value) |
380 | 436 | { |
@@ -410,16 +466,26 @@ discard block |
||
410 | 466 | if($id[0]['start']) |
411 | 467 | { |
412 | 468 | $dates = array('start' => PHP_INT_MAX, 'end' => 0); |
413 | - foreach($id as $event) { |
|
414 | - if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start']; |
|
415 | - if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end']; |
|
469 | + foreach($id as $event) |
|
470 | + { |
|
471 | + if($event['start'] && $event['start'] < $dates['start']) |
|
472 | + { |
|
473 | + $dates['start'] = $event['start']; |
|
474 | + } |
|
475 | + if($event['end'] && $event['end'] > $dates['end']) |
|
476 | + { |
|
477 | + $dates['end'] = $event['end']; |
|
478 | + } |
|
416 | 479 | } |
417 | 480 | $id = $dates; |
418 | 481 | } |
419 | 482 | $arr = $this->bo->date2array($id['start']); |
420 | 483 | $arr['day'] = $which; |
421 | 484 | $date = $this->bo->date2ts($arr); |
422 | - if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array(); |
|
485 | + if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) |
|
486 | + { |
|
487 | + return array(); |
|
488 | + } |
|
423 | 489 | } |
424 | 490 | elseif ($plugin == 'selected') |
425 | 491 | { |
@@ -429,16 +495,26 @@ discard block |
||
429 | 495 | { |
430 | 496 | $date = strtotime($plugin); |
431 | 497 | } |
432 | - if($type == 'day' && is_array($id) && !$id['start']) { |
|
498 | + if($type == 'day' && is_array($id) && !$id['start']) |
|
499 | + { |
|
433 | 500 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
434 | - if($which && date('d',$event['start']) != $which) return array(); |
|
435 | - if(date('Ymd',$date) != date('Ymd', $event['start'])) return array(); |
|
501 | + if($which && date('d',$event['start']) != $which) |
|
502 | + { |
|
503 | + return array(); |
|
504 | + } |
|
505 | + if(date('Ymd',$date) != date('Ymd', $event['start'])) |
|
506 | + { |
|
507 | + return array(); |
|
508 | + } |
|
436 | 509 | return $n == 0 ? $this->calendar_replacements($event) : array(); |
437 | 510 | } |
438 | 511 | |
439 | 512 | // Use start for cache, in case of multiple months |
440 | 513 | $_date = $id['start'] ? $id['start'] : $date; |
441 | - if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n]; |
|
514 | + if($days[date('Ymd',$_date)][$plugin]) |
|
515 | + { |
|
516 | + return $days[date('Ymd',$_date)][$plugin][$n]; |
|
517 | + } |
|
442 | 518 | |
443 | 519 | $events = $this->bo->search($this->query + array( |
444 | 520 | 'start' => $date, |
@@ -451,31 +527,42 @@ discard block |
||
451 | 527 | )); |
452 | 528 | |
453 | 529 | $replacements = array(); |
454 | - if (true) $days = array(); |
|
530 | + if (true) |
|
531 | + { |
|
532 | + $days = array(); |
|
533 | + } |
|
455 | 534 | $time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
456 | 535 | foreach($events as $day => $list) |
457 | 536 | { |
458 | 537 | foreach($list as $event) |
459 | 538 | { |
460 | - if($this->ids && !in_array($event['id'], $this->ids)) continue; |
|
539 | + if($this->ids && !in_array($event['id'], $this->ids)) |
|
540 | + { |
|
541 | + continue; |
|
542 | + } |
|
461 | 543 | $start = egw_time::to($event['start'], 'array'); |
462 | 544 | $end = egw_time::to($event['end'], 'array'); |
463 | 545 | $replacements = $this->calendar_replacements($event); |
464 | - if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) { |
|
546 | + if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) |
|
547 | + { |
|
465 | 548 | //$dow = date('l',$event['start']); |
466 | - } else { |
|
549 | + } |
|
550 | + else |
|
551 | + { |
|
467 | 552 | // Fancy date+time formatting for multi-day events |
468 | 553 | $replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1)); |
469 | 554 | $replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0)); |
470 | 555 | } |
471 | 556 | $days[date('Ymd',$_date)][$plugin][] = $replacements; |
472 | 557 | } |
473 | - if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) { |
|
558 | + if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) |
|
559 | + { |
|
474 | 560 | $date_marker = array( |
475 | 561 | '$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)), |
476 | 562 | '$$day/name$$' => lang(date('l', strtotime($day))) |
477 | 563 | ); |
478 | - if(!is_array($days[date('Ymd',$_date)][$plugin])) { |
|
564 | + if(!is_array($days[date('Ymd',$_date)][$plugin])) |
|
565 | + { |
|
479 | 566 | $blank = $this->calendar_replacements(array()); |
480 | 567 | foreach($blank as &$value) |
481 | 568 | { |
@@ -503,22 +590,35 @@ discard block |
||
503 | 590 | { |
504 | 591 | unset($plugin); // not used, but required by function signature |
505 | 592 | |
506 | - if(!is_array($id) || !$id['start']) { |
|
593 | + if(!is_array($id) || !$id['start']) |
|
594 | + { |
|
507 | 595 | $event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null); |
508 | - } else { |
|
596 | + } |
|
597 | + else |
|
598 | + { |
|
509 | 599 | $event = $id; |
510 | 600 | } |
511 | 601 | |
512 | - if(!is_array($event['participants']) || $n >= count($event['participants'])) return array(); |
|
602 | + if(!is_array($event['participants']) || $n >= count($event['participants'])) |
|
603 | + { |
|
604 | + return array(); |
|
605 | + } |
|
513 | 606 | |
514 | 607 | $participant = null; |
515 | 608 | $status = null; |
516 | 609 | $i = -1; |
517 | - foreach($event['participants'] as $participant => $status) { |
|
518 | - if(++$i == $n) break; |
|
610 | + foreach($event['participants'] as $participant => $status) |
|
611 | + { |
|
612 | + if(++$i == $n) |
|
613 | + { |
|
614 | + break; |
|
615 | + } |
|
519 | 616 | } |
520 | 617 | |
521 | - if(!$participant) return array(); |
|
618 | + if(!$participant) |
|
619 | + { |
|
620 | + return array(); |
|
621 | + } |
|
522 | 622 | |
523 | 623 | // Add some common information |
524 | 624 | $quantity = $role = null; |
@@ -552,7 +652,10 @@ discard block |
||
552 | 652 | $replacements = $this->contact_replacements(substr($participant,1),''); |
553 | 653 | break; |
554 | 654 | case 'r': |
555 | - if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo'); |
|
655 | + if (is_null(self::$resources)) |
|
656 | + { |
|
657 | + self::$resources = CreateObject('resources.resources_bo'); |
|
658 | + } |
|
556 | 659 | if (($resource = self::$resources->read(substr($participant,1)))) |
557 | 660 | { |
558 | 661 | foreach($resource as $name => $value) |
@@ -613,14 +716,23 @@ discard block |
||
613 | 716 | 'calendar_owner' => lang('Owner'), |
614 | 717 | ) as $name => $label) |
615 | 718 | { |
616 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
719 | + if (in_array($name,array('start','end')) && $n&1) |
|
720 | + { |
|
721 | + // main values, which should be in the first column |
|
617 | 722 | { |
618 | 723 | echo "</tr>\n"; |
724 | + } |
|
619 | 725 | $n++; |
620 | 726 | } |
621 | - if (!($n&1)) echo '<tr>'; |
|
727 | + if (!($n&1)) |
|
728 | + { |
|
729 | + echo '<tr>'; |
|
730 | + } |
|
622 | 731 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
623 | - if ($n&1) echo "</tr>\n"; |
|
732 | + if ($n&1) |
|
733 | + { |
|
734 | + echo "</tr>\n"; |
|
735 | + } |
|
624 | 736 | $n++; |
625 | 737 | } |
626 | 738 | |
@@ -671,7 +783,8 @@ discard block |
||
671 | 783 | } |
672 | 784 | echo '</table></td><td colspan="2"><table >'; |
673 | 785 | echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>"; |
674 | - foreach(self::$relative as $value) { |
|
786 | + foreach(self::$relative as $value) |
|
787 | + { |
|
675 | 788 | echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>'; |
676 | 789 | } |
677 | 790 | echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>'; |
@@ -204,6 +204,7 @@ |
||
204 | 204 | * |
205 | 205 | * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date |
206 | 206 | * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT |
207 | + * @param boolean $updated |
|
207 | 208 | * @return string message about update |
208 | 209 | * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version |
209 | 210 | * @throws Api\Exception\WrongUserinput if no PDO sqlite support |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function DateTimeZone($tzid) |
71 | 71 | { |
72 | - if (($id = self::tz2id($tzid,'alias'))) |
|
72 | + if (($id = self::tz2id($tzid, 'alias'))) |
|
73 | 73 | { |
74 | 74 | $tzid = self::id2tz($id); |
75 | 75 | } |
@@ -87,34 +87,34 @@ discard block |
||
87 | 87 | * @param string $what ='id' what to return, default id, null for whole array |
88 | 88 | * @return int tz_id or null if not found |
89 | 89 | */ |
90 | - public static function tz2id($tzid,$what='id') |
|
90 | + public static function tz2id($tzid, $what = 'id') |
|
91 | 91 | { |
92 | - $id =& self::$tz2id[$tzid]; |
|
92 | + $id = & self::$tz2id[$tzid]; |
|
93 | 93 | |
94 | 94 | if (!isset($id)) |
95 | 95 | { |
96 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
96 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
97 | 97 | 'tz_tzid' => $tzid, |
98 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
98 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
99 | 99 | { |
100 | 100 | $id = $data['tz_id']; |
101 | - self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_'); |
|
101 | + self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_'); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | // check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires' |
105 | 105 | if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2) |
106 | 106 | { |
107 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
107 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
108 | 108 | 'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]), |
109 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
109 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
110 | 110 | { |
111 | 111 | $id = $data['tz_id']; |
112 | - self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_'); |
|
112 | + self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | if (isset($id) && $what != 'id') |
116 | 116 | { |
117 | - return self::id2tz($id,$what); |
|
117 | + return self::id2tz($id, $what); |
|
118 | 118 | } |
119 | 119 | return $id; |
120 | 120 | } |
@@ -132,24 +132,24 @@ discard block |
||
132 | 132 | * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude' |
133 | 133 | * @return mixed false: if not found |
134 | 134 | */ |
135 | - public static function id2tz($id,$what='tzid') |
|
135 | + public static function id2tz($id, $what = 'tzid') |
|
136 | 136 | { |
137 | - $data =& self::$tz_cache[$id]; |
|
137 | + $data = & self::$tz_cache[$id]; |
|
138 | 138 | |
139 | 139 | if (!isset($data)) |
140 | 140 | { |
141 | - if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array( |
|
141 | + if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array( |
|
142 | 142 | 'tz_id' => $id, |
143 | - ),__LINE__,__FILE__,false,'','calendar')->fetch())) |
|
143 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetch())) |
|
144 | 144 | { |
145 | - $data = egw_db::strip_array_keys($data,'tz_'); |
|
145 | + $data = egw_db::strip_array_keys($data, 'tz_'); |
|
146 | 146 | self::$tz2id[$data['tzid']] = $id; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | // if not tzid queried, resolve aliases automatically |
150 | 150 | if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') |
151 | 151 | { |
152 | - $data = self::id2tz($data['alias'],null); |
|
152 | + $data = self::id2tz($data['alias'], null); |
|
153 | 153 | } |
154 | 154 | return !$data ? $data : ($what ? $data[$what] : $data); |
155 | 155 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public static function init_static() |
170 | 170 | { |
171 | - self::$tz_cache =& egw_cache::getSession(__CLASS__,'tz_cache'); |
|
172 | - self::$tz2id =& egw_cache::getSession(__CLASS__,'tz2id'); |
|
171 | + self::$tz_cache = & egw_cache::getSession(__CLASS__, 'tz_cache'); |
|
172 | + self::$tz2id = & egw_cache::getSession(__CLASS__, 'tz2id'); |
|
173 | 173 | |
174 | 174 | // init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar |
175 | 175 | if (!is_array(self::$tz2id)) |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | { |
187 | 187 | $updated = false; |
188 | 188 | $msg = self::import_zones($updated); |
189 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
189 | + if ($updated) error_log($msg); // log that timezones have been updated |
|
190 | 190 | |
191 | 191 | $alias_msg = self::import_tz_aliases($updated); |
192 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
192 | + if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
193 | 193 | |
194 | 194 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
195 | 195 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @throws egw_exception_wrong_userinput for broken sqlite extension |
209 | 209 | * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json |
210 | 210 | */ |
211 | - public static function import_zones(&$updated=null, $file='calendar/setup/zones.json') |
|
211 | + public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json') |
|
212 | 212 | { |
213 | 213 | $path = EGW_SERVER_ROOT.'/'.$file; |
214 | 214 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | { |
231 | 231 | $updated = false; |
232 | 232 | fclose($fp); |
233 | - return lang('Nothing to update, version is already %1.',$config['tz_version']); // we already have the right |
|
233 | + return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right |
|
234 | 234 | } |
235 | - $json .= fread($fp, 1024*1024); |
|
235 | + $json .= fread($fp, 1024 * 1024); |
|
236 | 236 | fclose($fp); |
237 | 237 | if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones'])) |
238 | 238 | { |
@@ -240,38 +240,38 @@ discard block |
||
240 | 240 | } |
241 | 241 | // import zones first and then aliases |
242 | 242 | $tz2id = array(); |
243 | - foreach(array('zones', 'aliases') as $type) |
|
243 | + foreach (array('zones', 'aliases') as $type) |
|
244 | 244 | { |
245 | - foreach($zones[$type] as $tzid => $data) |
|
245 | + foreach ($zones[$type] as $tzid => $data) |
|
246 | 246 | { |
247 | 247 | if ($type == 'aliases') |
248 | 248 | { |
249 | 249 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
250 | - if (!$data['alias']) continue; // there's no such tzid |
|
250 | + if (!$data['alias']) continue; // there's no such tzid |
|
251 | 251 | } |
252 | 252 | // check if already in database |
253 | - $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
|
253 | + $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array( |
|
254 | 254 | 'tz_tzid' => $tzid, |
255 | - ),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
255 | + ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
256 | 256 | |
257 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
257 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
258 | 258 | 'tz_alias' => $data['alias'], |
259 | 259 | 'tz_latitude' => $data['latitude'], |
260 | 260 | 'tz_longitude' => $data['longitude'], |
261 | 261 | 'tz_component' => $data['ics'], |
262 | - ),array( |
|
262 | + ), array( |
|
263 | 263 | 'tz_tzid' => $tzid, |
264 | - ),__LINE__,__FILE__,'calendar'); |
|
264 | + ), __LINE__, __FILE__, 'calendar'); |
|
265 | 265 | |
266 | 266 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
267 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
267 | + if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id'); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | config::save_value('tz_version', $tz_version, 'phpgwapi'); |
271 | 271 | |
272 | 272 | //_debug_array($tz2id); |
273 | 273 | $updated = true; |
274 | - return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id)); |
|
274 | + return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return string message about update |
283 | 283 | * @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version |
284 | 284 | */ |
285 | - public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php') |
|
285 | + public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php') |
|
286 | 286 | { |
287 | 287 | $path = EGW_SERVER_ROOT.'/'.$file; |
288 | 288 | |
@@ -295,27 +295,27 @@ discard block |
||
295 | 295 | if ($tz_aliases_mtime === $config['tz_aliases_mtime']) |
296 | 296 | { |
297 | 297 | $updated = false; |
298 | - return lang('Nothing to update, version is already %1.',$tz_aliases_mtime); |
|
298 | + return lang('Nothing to update, version is already %1.', $tz_aliases_mtime); |
|
299 | 299 | } |
300 | 300 | $tz_aliases = array(); |
301 | - include($path); // sets $tz_aliases |
|
301 | + include($path); // sets $tz_aliases |
|
302 | 302 | |
303 | 303 | $updates = 0; |
304 | - foreach($tz_aliases as $alias => $tzid) |
|
304 | + foreach ($tz_aliases as $alias => $tzid) |
|
305 | 305 | { |
306 | - if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
306 | + if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
|
307 | 307 | ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
308 | 308 | { |
309 | - $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
|
309 | + $GLOBALS['egw']->db->insert('egw_cal_timezones', array( |
|
310 | 310 | 'tz_alias' => $tz_id, |
311 | - ),array( |
|
311 | + ), array( |
|
312 | 312 | 'tz_tzid' => $alias, |
313 | - ),__LINE__,__FILE__,'calendar'); |
|
313 | + ), __LINE__, __FILE__, 'calendar'); |
|
314 | 314 | ++$updates; |
315 | 315 | } |
316 | 316 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
317 | 317 | } |
318 | - config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi'); |
|
318 | + config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi'); |
|
319 | 319 | |
320 | 320 | //_debug_array($tz2id); |
321 | 321 | $updated = true; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | } |
357 | 357 | // $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly |
358 | 358 | // --> we have to parse it and let Horde_Icalendar add it again |
359 | - $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false); |
|
360 | - $horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE'); |
|
359 | + $horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false); |
|
360 | + $horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE'); |
|
361 | 361 | // DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing |
362 | 362 | $standard = $horde_vtimezone->findComponent('STANDARD'); |
363 | 363 | if (is_a($standard, 'Horde_Icalendar')) |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public static function user_timezone($user=null, $type='vcalendar') |
|
391 | + public static function user_timezone($user = null, $type = 'vcalendar') |
|
392 | 392 | { |
393 | 393 | if (!$user || $user == $GLOBALS['egw_info']['user']['account_id']) |
394 | 394 | { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | case 'vcalendar': |
408 | 408 | // checking type of $val, now we included the object definition (no need to always include it!) |
409 | 409 | $vcal = new Horde_Icalendar; |
410 | - $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
410 | + $vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
|
411 | 411 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
412 | 412 | self::add_vtimezone($vcal, $tzid); |
413 | 413 | $tzid = $vcal->exportvCalendar('utf-8'); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | case 'tzid': |
416 | 416 | break; |
417 | 417 | default: |
418 | - $tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type); |
|
418 | + $tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type); |
|
419 | 419 | break; |
420 | 420 | } |
421 | 421 | return $tzid; |
@@ -186,10 +186,18 @@ discard block |
||
186 | 186 | { |
187 | 187 | $updated = false; |
188 | 188 | $msg = self::import_zones($updated); |
189 | - if ($updated) error_log($msg); // log that timezones have been updated |
|
189 | + if ($updated) |
|
190 | + { |
|
191 | + error_log($msg); |
|
192 | + } |
|
193 | + // log that timezones have been updated |
|
190 | 194 | |
191 | 195 | $alias_msg = self::import_tz_aliases($updated); |
192 | - if ($updated) error_log($alias_msg); // log that timezone aliases have been updated |
|
196 | + if ($updated) |
|
197 | + { |
|
198 | + error_log($alias_msg); |
|
199 | + } |
|
200 | + // log that timezone aliases have been updated |
|
193 | 201 | |
194 | 202 | self::$import_msg = $msg.'<br/>'.$alias_msg; |
195 | 203 | |
@@ -247,7 +255,11 @@ discard block |
||
247 | 255 | if ($type == 'aliases') |
248 | 256 | { |
249 | 257 | $data = array('alias' => $tz2id[$data['aliasTo']]); |
250 | - if (!$data['alias']) continue; // there's no such tzid |
|
258 | + if (!$data['alias']) |
|
259 | + { |
|
260 | + continue; |
|
261 | + } |
|
262 | + // there's no such tzid |
|
251 | 263 | } |
252 | 264 | // check if already in database |
253 | 265 | $tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array( |
@@ -264,7 +276,10 @@ discard block |
||
264 | 276 | ),__LINE__,__FILE__,'calendar'); |
265 | 277 | |
266 | 278 | // only query last insert id, if not already in database (gives warning for PostgreSQL) |
267 | - if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
279 | + if (!$tz2id[$tzid]) |
|
280 | + { |
|
281 | + $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id'); |
|
282 | + } |
|
268 | 283 | } |
269 | 284 | } |
270 | 285 | config::save_value('tz_version', $tz_version, 'phpgwapi'); |
@@ -304,13 +319,16 @@ discard block |
||
304 | 319 | foreach($tz_aliases as $alias => $tzid) |
305 | 320 | { |
306 | 321 | if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different |
307 | - ($tz_id = self::tz2id($tzid))) // given tzid for alias exists in DB |
|
322 | + ($tz_id = self::tz2id($tzid))) |
|
323 | + { |
|
324 | + // given tzid for alias exists in DB |
|
308 | 325 | { |
309 | 326 | $GLOBALS['egw']->db->insert('egw_cal_timezones',array( |
310 | 327 | 'tz_alias' => $tz_id, |
311 | 328 | ),array( |
312 | 329 | 'tz_tzid' => $alias, |
313 | 330 | ),__LINE__,__FILE__,'calendar'); |
331 | + } |
|
314 | 332 | ++$updates; |
315 | 333 | } |
316 | 334 | //error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).", self::tz2id('$tzid')=".array2string($tz_id)); |
@@ -400,7 +418,10 @@ discard block |
||
400 | 418 | $prefs = $prefs_obj->read(); |
401 | 419 | $tzid = $prefs['common']['tz']; |
402 | 420 | } |
403 | - if (!$tzid) $tzid = egw_time::$server_timezone->getName(); |
|
421 | + if (!$tzid) |
|
422 | + { |
|
423 | + $tzid = egw_time::$server_timezone->getName(); |
|
424 | + } |
|
404 | 425 | |
405 | 426 | switch ($type) |
406 | 427 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Fix depricated stuff in a given file |
24 | 24 | * |
25 | 25 | * @param string $file filename |
26 | - * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
|
26 | + * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created |
|
27 | 27 | * @return boolean false on error |
28 | 28 | */ |
29 | 29 | function fix_depricated($file,$replace_file=false) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Loop recursive through directory and call fix_depricated for each php file |
147 | 147 | * |
148 | 148 | * @param string $dir |
149 | - * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
|
149 | + * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created |
|
150 | 150 | * @return boolean false on error |
151 | 151 | */ |
152 | 152 | function fix_depricated_recursive($dir,$replace_file=false) |
@@ -174,7 +174,6 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * Give usage |
176 | 176 | * |
177 | - * @param string $error=null |
|
178 | 177 | */ |
179 | 178 | function usage($error=null) |
180 | 179 | { |
@@ -26,47 +26,47 @@ discard block |
||
26 | 26 | * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
27 | 27 | * @return boolean false on error |
28 | 28 | */ |
29 | -function fix_depricated($file,$replace_file=false) |
|
29 | +function fix_depricated($file, $replace_file = false) |
|
30 | 30 | { |
31 | 31 | $orig = $lines = file_get_contents($file); |
32 | 32 | if ($lines === false) return false; |
33 | 33 | global $prog; |
34 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
34 | + if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
35 | 35 | |
36 | 36 | // PHP Deprecated: Assigning the return value of new by reference is deprecated |
37 | - if (preg_match('/= *& *new /m',$lines)) |
|
37 | + if (preg_match('/= *& *new /m', $lines)) |
|
38 | 38 | { |
39 | - $lines = preg_replace('/= *& *new /','= new ',$lines); |
|
39 | + $lines = preg_replace('/= *& *new /', '= new ', $lines); |
|
40 | 40 | } |
41 | 41 | // PHP Deprecated: Function split() is deprecated |
42 | - if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m',$lines,$matches)) |
|
42 | + if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m', $lines, $matches)) |
|
43 | 43 | { |
44 | 44 | $replace = array(); |
45 | 45 | //print_r($matches); |
46 | - foreach($matches[1] as $key => $pattern) |
|
46 | + foreach ($matches[1] as $key => $pattern) |
|
47 | 47 | { |
48 | 48 | $full_pattern = $matches[0][$key]; |
49 | 49 | // single char --> just explode |
50 | - if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern,0,2) == '"\\') |
|
50 | + if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern, 0, 2) == '"\\') |
|
51 | 51 | { |
52 | - $replace[$full_pattern] = str_replace('split','explode',$full_pattern); |
|
52 | + $replace[$full_pattern] = str_replace('split', 'explode', $full_pattern); |
|
53 | 53 | } |
54 | 54 | else |
55 | 55 | { |
56 | - $preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0]; |
|
57 | - if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
58 | - $replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern); |
|
56 | + $preg_pattern = $pattern[0].'/'.str_replace('/', '\\\\/', substr($pattern, 1, -1)).'/'.$pattern[0]; |
|
57 | + if (strpos($full_pattern, 'spliti')) $preg_pattern = substr($preg_pattern, 0, -1).'i'.$pattern[0]; |
|
58 | + $replace[$full_pattern] = str_replace(array('spliti', 'split', $pattern), array('preg_split', 'preg_split', $preg_pattern), $full_pattern); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | //print_r($replace); |
62 | - $lines = strtr($lines,$replace); |
|
62 | + $lines = strtr($lines, $replace); |
|
63 | 63 | } |
64 | 64 | // PHP Deprecated: Function ereg() is deprecated |
65 | - if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m',$lines,$matches)) |
|
65 | + if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m', $lines, $matches)) |
|
66 | 66 | { |
67 | 67 | $replace = array(); |
68 | 68 | //print_r($matches); |
69 | - foreach($matches[1] as $key => $pattern) |
|
69 | + foreach ($matches[1] as $key => $pattern) |
|
70 | 70 | { |
71 | 71 | $full_pattern = $matches[0][$key]; |
72 | 72 | $what = $matches[2][$key]; |
@@ -75,25 +75,25 @@ discard block |
||
75 | 75 | if (preg_quote($pattern) == $pattern) |
76 | 76 | { |
77 | 77 | |
78 | - $replace[$full_pattern] = (strpos($full_pattern,'eregi')!==false?'strposi':'strpos').'('.$what.','.$pattern. |
|
79 | - ') '.($full_pattern[0]=='!'?'===':'!==').' false'.$matches[4][$key]; |
|
78 | + $replace[$full_pattern] = (strpos($full_pattern, 'eregi') !== false ? 'strposi' : 'strpos').'('.$what.','.$pattern. |
|
79 | + ') '.($full_pattern[0] == '!' ? '===' : '!==').' false'.$matches[4][$key]; |
|
80 | 80 | } |
81 | 81 | else |
82 | 82 | { |
83 | 83 | // full ereg regular expression --> preg_match |
84 | - $preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'"); |
|
85 | - $replace[$full_pattern] = str_replace(array('eregi','ereg',$pattern),array('preg_match','preg_match',$preg_pattern),$full_pattern); |
|
84 | + $preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'"); |
|
85 | + $replace[$full_pattern] = str_replace(array('eregi', 'ereg', $pattern), array('preg_match', 'preg_match', $preg_pattern), $full_pattern); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | //print_r($replace); |
89 | - $lines = strtr($lines,$replace); |
|
89 | + $lines = strtr($lines, $replace); |
|
90 | 90 | } |
91 | 91 | // PHP Deprecated: Function ereg_replace() is deprecated |
92 | - if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m',$lines,$matches)) |
|
92 | + if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m', $lines, $matches)) |
|
93 | 93 | { |
94 | 94 | $replace = array(); |
95 | 95 | //print_r($matches); |
96 | - foreach($matches[1] as $key => $pattern) |
|
96 | + foreach ($matches[1] as $key => $pattern) |
|
97 | 97 | { |
98 | 98 | $full_pattern = $matches[0][$key]; |
99 | 99 | $other = $matches[2][$key]; |
@@ -101,41 +101,41 @@ discard block |
||
101 | 101 | // simple replace --> use str_replace() |
102 | 102 | if (preg_quote($pattern) == $pattern) |
103 | 103 | { |
104 | - $replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace'),array('stri_replace','str_replace'),$full_pattern); |
|
104 | + $replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace'), array('stri_replace', 'str_replace'), $full_pattern); |
|
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
108 | 108 | // full ereg regular expression --> preg_replace |
109 | - $preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'"); |
|
110 | - $replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace',$pattern), |
|
111 | - array('preg_replace','preg_replace',$preg_pattern),$full_pattern); |
|
109 | + $preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'"); |
|
110 | + $replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace', $pattern), |
|
111 | + array('preg_replace', 'preg_replace', $preg_pattern), $full_pattern); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | //print_r($replace); |
115 | - $lines = strtr($lines,$replace); |
|
115 | + $lines = strtr($lines, $replace); |
|
116 | 116 | } |
117 | 117 | // remove extra '/' from regular expressions |
118 | - $lines = str_replace(array("'/'.'","'.'/'","'.'/i'"),array("'/","/'","/i'"),$lines); |
|
118 | + $lines = str_replace(array("'/'.'", "'.'/'", "'.'/i'"), array("'/", "/'", "/i'"), $lines); |
|
119 | 119 | |
120 | 120 | // fix call to not longer existing PDO method $result->fetchSingle() |
121 | - $lines = str_replace('->fetchSingle(','->fetchColumn(',$lines); |
|
121 | + $lines = str_replace('->fetchSingle(', '->fetchColumn(', $lines); |
|
122 | 122 | |
123 | 123 | // fix calls to deprecated call_user_method(_array)?(method,object[,args]) |
124 | - if (preg_match('/call_user_method(_array)?\(/',$lines,$matches)) |
|
124 | + if (preg_match('/call_user_method(_array)?\(/', $lines, $matches)) |
|
125 | 125 | { |
126 | - $lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/','call_user_func(array(\\2,\\1)\\3',$lines); |
|
127 | - $lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/','call_user_func_array(array(\\2,\\1)\\3',$lines); |
|
126 | + $lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/', 'call_user_func(array(\\2,\\1)\\3', $lines); |
|
127 | + $lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/', 'call_user_func_array(array(\\2,\\1)\\3', $lines); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($lines != $orig) |
131 | 131 | { |
132 | - file_put_contents($file.'53',$lines); |
|
133 | - system('/usr/bin/php -l '.$file.'53',$ret); |
|
132 | + file_put_contents($file.'53', $lines); |
|
133 | + system('/usr/bin/php -l '.$file.'53', $ret); |
|
134 | 134 | system('/usr/bin/diff -u '.$file.' '.$file.'53'); |
135 | 135 | if (!$ret && $replace_file) |
136 | 136 | { |
137 | 137 | unlink($file); |
138 | - rename($file.'53',$file); |
|
138 | + rename($file.'53', $file); |
|
139 | 139 | } |
140 | 140 | return !$ret; |
141 | 141 | } |
@@ -149,25 +149,25 @@ discard block |
||
149 | 149 | * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
150 | 150 | * @return boolean false on error |
151 | 151 | */ |
152 | -function fix_depricated_recursive($dir,$replace_file=false) |
|
152 | +function fix_depricated_recursive($dir, $replace_file = false) |
|
153 | 153 | { |
154 | 154 | if (!is_dir($dir)) return false; |
155 | 155 | |
156 | - foreach(scandir($dir) as $file) |
|
156 | + foreach (scandir($dir) as $file) |
|
157 | 157 | { |
158 | 158 | if ($file == '.' || $file == '..') continue; |
159 | 159 | |
160 | 160 | if (is_dir($dir.'/'.$file)) |
161 | 161 | { |
162 | - fix_depricated_recursive($dir.'/'.$file,$replace_file); |
|
162 | + fix_depricated_recursive($dir.'/'.$file, $replace_file); |
|
163 | 163 | } |
164 | - elseif(substr($file,-4) == '.php') |
|
164 | + elseif (substr($file, -4) == '.php') |
|
165 | 165 | { |
166 | - echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': '; |
|
167 | - fix_depricated($dir.'/'.$file,$replace_file); |
|
166 | + echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': '; |
|
167 | + fix_depricated($dir.'/'.$file, $replace_file); |
|
168 | 168 | } |
169 | 169 | } |
170 | - echo "\r".str_repeat(' ',100)."\r"; |
|
170 | + echo "\r".str_repeat(' ', 100)."\r"; |
|
171 | 171 | return true; |
172 | 172 | } |
173 | 173 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $error=null |
178 | 178 | */ |
179 | -function usage($error=null) |
|
179 | +function usage($error = null) |
|
180 | 180 | { |
181 | 181 | global $prog; |
182 | 182 | echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n"; |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | if (!$args) usage(); |
191 | 191 | |
192 | 192 | $replace_file = false; |
193 | -while(($arg = array_shift($args))) |
|
193 | +while (($arg = array_shift($args))) |
|
194 | 194 | { |
195 | - switch($arg) |
|
195 | + switch ($arg) |
|
196 | 196 | { |
197 | 197 | case '-h': |
198 | 198 | case '--help': |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | if (!is_dir($arg)) |
218 | 218 | { |
219 | - fix_depricated($arg,$replace_file); |
|
219 | + fix_depricated($arg, $replace_file); |
|
220 | 220 | } |
221 | 221 | else |
222 | 222 | { |
223 | - fix_depricated_recursive($arg,$replace_file); |
|
223 | + fix_depricated_recursive($arg, $replace_file); |
|
224 | 224 | } |
225 | 225 | \ No newline at end of file |
@@ -14,10 +14,13 @@ discard block |
||
14 | 14 | * @version $Id$ |
15 | 15 | */ |
16 | 16 | |
17 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
17 | +if (php_sapi_name() !== 'cli') |
|
18 | +{ |
|
19 | + // security precaution: forbit calling as web-page |
|
18 | 20 | { |
19 | 21 | die('<h1>fix_depricated.php must NOT be called as web-page --> exiting !!!</h1>'); |
20 | 22 | } |
23 | +} |
|
21 | 24 | |
22 | 25 | /** |
23 | 26 | * Fix depricated stuff in a given file |
@@ -29,9 +32,16 @@ discard block |
||
29 | 32 | function fix_depricated($file,$replace_file=false) |
30 | 33 | { |
31 | 34 | $orig = $lines = file_get_contents($file); |
32 | - if ($lines === false) return false; |
|
35 | + if ($lines === false) |
|
36 | + { |
|
37 | + return false; |
|
38 | + } |
|
33 | 39 | global $prog; |
34 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
40 | + if (basename($file) == $prog) |
|
41 | + { |
|
42 | + return true; |
|
43 | + } |
|
44 | + // dont fix ourself ;-) |
|
35 | 45 | |
36 | 46 | // PHP Deprecated: Assigning the return value of new by reference is deprecated |
37 | 47 | if (preg_match('/= *& *new /m',$lines)) |
@@ -54,7 +64,10 @@ discard block |
||
54 | 64 | else |
55 | 65 | { |
56 | 66 | $preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0]; |
57 | - if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
67 | + if (strpos($full_pattern,'spliti')) |
|
68 | + { |
|
69 | + $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
70 | + } |
|
58 | 71 | $replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern); |
59 | 72 | } |
60 | 73 | } |
@@ -151,11 +164,17 @@ discard block |
||
151 | 164 | */ |
152 | 165 | function fix_depricated_recursive($dir,$replace_file=false) |
153 | 166 | { |
154 | - if (!is_dir($dir)) return false; |
|
167 | + if (!is_dir($dir)) |
|
168 | + { |
|
169 | + return false; |
|
170 | + } |
|
155 | 171 | |
156 | 172 | foreach(scandir($dir) as $file) |
157 | 173 | { |
158 | - if ($file == '.' || $file == '..') continue; |
|
174 | + if ($file == '.' || $file == '..') |
|
175 | + { |
|
176 | + continue; |
|
177 | + } |
|
159 | 178 | |
160 | 179 | if (is_dir($dir.'/'.$file)) |
161 | 180 | { |
@@ -180,14 +199,20 @@ discard block |
||
180 | 199 | { |
181 | 200 | global $prog; |
182 | 201 | echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n"; |
183 | - if ($error) echo $error."\n\n"; |
|
202 | + if ($error) |
|
203 | + { |
|
204 | + echo $error."\n\n"; |
|
205 | + } |
|
184 | 206 | exit($error ? 1 : 0); |
185 | 207 | } |
186 | 208 | |
187 | 209 | $args = $_SERVER['argv']; |
188 | 210 | $prog = basename(array_shift($args)); |
189 | 211 | |
190 | -if (!$args) usage(); |
|
212 | +if (!$args) |
|
213 | +{ |
|
214 | + usage(); |
|
215 | +} |
|
191 | 216 | |
192 | 217 | $replace_file = false; |
193 | 218 | while(($arg = array_shift($args))) |
@@ -204,15 +229,21 @@ discard block |
||
204 | 229 | break; |
205 | 230 | |
206 | 231 | default: |
207 | - if ($args) // not last argument |
|
232 | + if ($args) |
|
233 | + { |
|
234 | + // not last argument |
|
208 | 235 | { |
209 | 236 | usage("Unknown argument '$arg'!"); |
210 | 237 | } |
238 | + } |
|
211 | 239 | break 2; |
212 | 240 | } |
213 | 241 | } |
214 | 242 | |
215 | -if (!file_exists($arg)) usage("Error: $arg not found!"); |
|
243 | +if (!file_exists($arg)) |
|
244 | +{ |
|
245 | + usage("Error: $arg not found!"); |
|
246 | +} |
|
216 | 247 | |
217 | 248 | if (!is_dir($arg)) |
218 | 249 | { |
@@ -464,6 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @param string $name |
466 | 466 | * @param string $value =null value to use, default $config[$name] |
467 | + * @return string |
|
467 | 468 | */ |
468 | 469 | function config_translate($name, $value=null) |
469 | 470 | { |
@@ -1194,7 +1195,7 @@ discard block |
||
1194 | 1195 | * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose) |
1195 | 1196 | * |
1196 | 1197 | * @param string $cmd |
1197 | - * @param array& $output=null $output of command, only if !$verbose !!! |
|
1198 | + * @param array& $output $output of command, only if !$verbose !!! |
|
1198 | 1199 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
1199 | 1200 | * @return int exit code of $cmd |
1200 | 1201 | */ |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | curl_setopt($c, CURLOPT_URL, $url); |
442 | 442 | |
443 | 443 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
444 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
444 | + if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
445 | 445 | |
446 | 446 | if (($response = curl_exec($c)) === false) |
447 | 447 | { |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false || |
675 | 675 | $pattern[0] == '/' && preg_match($pattern,$log->msg,$matches)) |
676 | 676 | { |
677 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
677 | + if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
678 | 678 | return (int)$log['revision']; |
679 | 679 | } |
680 | 680 | } |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | if ($content != $content_was) |
756 | 756 | { |
757 | 757 | file_put_contents($path,$content); |
758 | - if ($verbose) echo "Updated $path\n"; |
|
758 | + if ($verbose) echo "updated $path\n"; |
|
759 | 759 | ++$n; |
760 | 760 | } |
761 | 761 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | } |
884 | 884 | foreach($config['types'] as $type) |
885 | 885 | { |
886 | - echo "Creating $type archives\n"; |
|
886 | + echo "creating $type archives\n"; |
|
887 | 887 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
888 | 888 | |
889 | 889 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
1007 | 1007 | { |
1008 | - echo "Running $cmd\n"; |
|
1008 | + echo "running $cmd\n"; |
|
1009 | 1009 | run_cmd($cmd); |
1010 | 1010 | } |
1011 | 1011 | // fix permissions |
@@ -10,10 +10,13 @@ discard block |
||
10 | 10 | * @version $Id$ |
11 | 11 | */ |
12 | 12 | |
13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
13 | +if (php_sapi_name() !== 'cli') |
|
14 | +{ |
|
15 | + // security precaution: forbit calling setup-cli as web-page |
|
14 | 16 | { |
15 | 17 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
16 | 18 | } |
19 | +} |
|
17 | 20 | date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
18 | 21 | |
19 | 22 | $verbose = 0; |
@@ -135,7 +138,10 @@ discard block |
||
135 | 138 | case 'release': |
136 | 139 | case 'copychangelog': |
137 | 140 | $config[$name] = $value; |
138 | - if ($value) array_unshift($config['run'],$name); |
|
141 | + if ($value) |
|
142 | + { |
|
143 | + array_unshift($config['run'],$name); |
|
144 | + } |
|
139 | 145 | break; |
140 | 146 | |
141 | 147 | case 'editchangelog': |
@@ -151,7 +157,10 @@ discard block |
||
151 | 157 | { |
152 | 158 | usage("Path '$value' not found!"); |
153 | 159 | } |
154 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
160 | + if (!in_array('obs',$config['run'])) |
|
161 | + { |
|
162 | + $config['run'][] = 'obs'; |
|
163 | + } |
|
155 | 164 | // fall through |
156 | 165 | default: |
157 | 166 | $config[$name] = $value; |
@@ -209,7 +218,10 @@ discard block |
||
209 | 218 | } |
210 | 219 | |
211 | 220 | $cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD'); |
212 | - if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd; |
|
221 | + if (getcwd() != $path) |
|
222 | + { |
|
223 | + $cmd = 'cd '.$path.'; '.$cmd; |
|
224 | + } |
|
213 | 225 | $output = null; |
214 | 226 | run_cmd($cmd, $output); |
215 | 227 | |
@@ -240,7 +252,10 @@ discard block |
||
240 | 252 | { |
241 | 253 | global $config, $verbose; |
242 | 254 | |
243 | - if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
255 | + if ($verbose) |
|
256 | + { |
|
257 | + echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
258 | + } |
|
244 | 259 | |
245 | 260 | if (!is_dir($config['checkoutdir'])) |
246 | 261 | { |
@@ -271,12 +286,21 @@ discard block |
||
271 | 286 | elseif (isset($module) && preg_match('/^checkout\s*=\s*(git\s+clone\s+(-b\s+[0-9.]+\s+)?((git|http)[^ ]+)|svn\s+checkout\s+((svn|http)[^ ]+))/', $line, $matches)) |
272 | 287 | { |
273 | 288 | $repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[5] : $matches[3]; |
274 | - if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
289 | + if (substr($matches[1], 0, 3) == 'svn') |
|
290 | + { |
|
291 | + $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
292 | + } |
|
275 | 293 | $modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url; |
276 | - if ($module === '' && !isset($baseurl)) $baseurl = str_replace('/egroupware.git', '', $url); |
|
294 | + if ($module === '' && !isset($baseurl)) |
|
295 | + { |
|
296 | + $baseurl = str_replace('/egroupware.git', '', $url); |
|
297 | + } |
|
277 | 298 | } |
278 | 299 | } |
279 | - if ($verbose) print_r($modules); |
|
300 | + if ($verbose) |
|
301 | + { |
|
302 | + print_r($modules); |
|
303 | + } |
|
280 | 304 | return $modules; |
281 | 305 | } |
282 | 306 | |
@@ -343,7 +367,11 @@ discard block |
||
343 | 367 | |
344 | 368 | $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
345 | 369 | |
346 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
370 | + if (empty($config['tag'])) |
|
371 | + { |
|
372 | + return; |
|
373 | + } |
|
374 | + // otherwise we copy everything in svn root! |
|
347 | 375 | |
348 | 376 | echo "Creating tag $config[tag]\n"; |
349 | 377 | |
@@ -359,7 +387,10 @@ discard block |
||
359 | 387 | global $config,$verbose; |
360 | 388 | |
361 | 389 | // push local changes to Github incl. tags |
362 | - if ($verbose) echo "Pushing changes and tags\n"; |
|
390 | + if ($verbose) |
|
391 | + { |
|
392 | + echo "Pushing changes and tags\n"; |
|
393 | + } |
|
363 | 394 | chdir($config['checkoutdir']); |
364 | 395 | run_cmd($config['mr']. ' up'); // in case someone else pushed something |
365 | 396 | chdir($config['checkoutdir']); |
@@ -421,7 +452,10 @@ discard block |
||
421 | 452 | { |
422 | 453 | $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
423 | 454 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
424 | - if ($verbose) echo $cmd."\n"; |
|
455 | + if ($verbose) |
|
456 | + { |
|
457 | + echo $cmd."\n"; |
|
458 | + } |
|
425 | 459 | passthru($cmd); |
426 | 460 | } |
427 | 461 | } |
@@ -454,25 +488,40 @@ discard block |
||
454 | 488 | { |
455 | 489 | case 'POST': |
456 | 490 | curl_setopt($c, CURLOPT_POST, true); |
457 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
491 | + if (is_array($data)) |
|
492 | + { |
|
493 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
494 | + } |
|
458 | 495 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
459 | 496 | break; |
460 | 497 | case 'GET': |
461 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
498 | + if(count($data)) |
|
499 | + { |
|
500 | + $url .= '?' . http_build_query($data); |
|
501 | + } |
|
462 | 502 | break; |
463 | 503 | case 'FILE': |
464 | 504 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
465 | 505 | curl_setopt($c, CURLOPT_POST, true); |
466 | 506 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
467 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
507 | + if(count($data)) |
|
508 | + { |
|
509 | + $url .= '?' . http_build_query($data); |
|
510 | + } |
|
468 | 511 | break; |
469 | 512 | default: |
470 | 513 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
471 | 514 | } |
472 | 515 | curl_setopt($c, CURLOPT_URL, $url); |
473 | 516 | |
474 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
475 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
517 | + if (is_string($data)) |
|
518 | + { |
|
519 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
520 | + } |
|
521 | + if ($verbose) |
|
522 | + { |
|
523 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
524 | + } |
|
476 | 525 | |
477 | 526 | if (($response = curl_exec($c)) === false) |
478 | 527 | { |
@@ -483,7 +532,10 @@ discard block |
||
483 | 532 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
484 | 533 | } |
485 | 534 | |
486 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
535 | + if ($verbose) |
|
536 | + { |
|
537 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
538 | + } |
|
487 | 539 | |
488 | 540 | curl_close($c); |
489 | 541 | |
@@ -500,13 +552,19 @@ discard block |
||
500 | 552 | { |
501 | 553 | global $config; |
502 | 554 | |
503 | - if (!isset($value)) $value = $config[$name]; |
|
555 | + if (!isset($value)) |
|
556 | + { |
|
557 | + $value = $config[$name]; |
|
558 | + } |
|
504 | 559 | if (is_string($value) && strpos($value, '$') !== false) |
505 | 560 | { |
506 | 561 | $translate = array(); |
507 | 562 | foreach($config as $n => $val) |
508 | 563 | { |
509 | - if (is_string($val)) $translate['$'.$n] = $val; |
|
564 | + if (is_string($val)) |
|
565 | + { |
|
566 | + $translate['$'.$n] = $val; |
|
567 | + } |
|
510 | 568 | } |
511 | 569 | $value = strtr($value, $translate); |
512 | 570 | } |
@@ -608,7 +666,10 @@ discard block |
||
608 | 666 | if (is_null($revision)) |
609 | 667 | { |
610 | 668 | list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
611 | - if (empty($branch)) $branch = $config['version']; |
|
669 | + if (empty($branch)) |
|
670 | + { |
|
671 | + $branch = $config['version']; |
|
672 | + } |
|
612 | 673 | $tags_url .= '/tags'; |
613 | 674 | $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
614 | 675 | $matches = null; |
@@ -634,11 +695,18 @@ discard block |
||
634 | 695 | $message = ''; |
635 | 696 | foreach($xml as $log) |
636 | 697 | { |
637 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
698 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) |
|
699 | + { |
|
700 | + continue; |
|
701 | + } |
|
702 | + // no match --> ignore |
|
638 | 703 | |
639 | 704 | $message .= $msg."\n"; |
640 | 705 | } |
641 | - if ($verbose) echo $message; |
|
706 | + if ($verbose) |
|
707 | + { |
|
708 | + echo $message; |
|
709 | + } |
|
642 | 710 | |
643 | 711 | return $message; |
644 | 712 | } |
@@ -669,7 +737,10 @@ discard block |
||
669 | 737 | { |
670 | 738 | return null; |
671 | 739 | } |
672 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
740 | + if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) |
|
741 | + { |
|
742 | + $msg = $prefix.$msg; |
|
743 | + } |
|
673 | 744 | |
674 | 745 | return $msg; |
675 | 746 | } |
@@ -706,7 +777,10 @@ discard block |
||
706 | 777 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
707 | 778 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
708 | 779 | { |
709 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
780 | + if ($verbose) |
|
781 | + { |
|
782 | + echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
783 | + } |
|
710 | 784 | return (int)$log['revision']; |
711 | 785 | } |
712 | 786 | } |
@@ -726,7 +800,10 @@ discard block |
||
726 | 800 | { |
727 | 801 | usage("Path '$config[obs]' not found!"); |
728 | 802 | } |
729 | - if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
803 | + if ($verbose) |
|
804 | + { |
|
805 | + echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
806 | + } |
|
730 | 807 | run_cmd('osc up '.$config['obs']); |
731 | 808 | |
732 | 809 | $n = 0; |
@@ -746,10 +823,16 @@ discard block |
||
746 | 823 | if (basename($path) != basename($new_name)) |
747 | 824 | { |
748 | 825 | unlink($path); |
749 | - if ($verbose) echo "rm $path\n"; |
|
826 | + if ($verbose) |
|
827 | + { |
|
828 | + echo "rm $path\n"; |
|
829 | + } |
|
750 | 830 | } |
751 | 831 | copy($new_name,dirname($path).'/'.basename($new_name)); |
752 | - if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
|
832 | + if ($verbose) |
|
833 | + { |
|
834 | + echo "cp $new_name ".dirname($path)."/\n"; |
|
835 | + } |
|
753 | 836 | ++$n; |
754 | 837 | } |
755 | 838 | // if we have no changelog (eg. because commands run separate), try parsing it from changelog file |
@@ -787,7 +870,10 @@ discard block |
||
787 | 870 | if ($content != $content_was) |
788 | 871 | { |
789 | 872 | file_put_contents($path,$content); |
790 | - if ($verbose) echo "Updated $path\n"; |
|
873 | + if ($verbose) |
|
874 | + { |
|
875 | + echo "Updated $path\n"; |
|
876 | + } |
|
791 | 877 | ++$n; |
792 | 878 | } |
793 | 879 | } |
@@ -825,9 +911,12 @@ discard block |
||
825 | 911 | } |
826 | 912 | $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
827 | 913 | $logentry = ''; |
828 | - while($lines[$n]) // entry is terminated by empty line |
|
914 | + while($lines[$n]) |
|
915 | + { |
|
916 | + // entry is terminated by empty line |
|
829 | 917 | { |
830 | 918 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
919 | + } |
|
831 | 920 | ++$n; |
832 | 921 | } |
833 | 922 | return substr($logentry, 0, -1); // remove training "\n" |
@@ -848,7 +937,10 @@ discard block |
||
848 | 937 | |
849 | 938 | list($header) = explode("\n", $content); |
850 | 939 | $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
851 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
940 | + if (substr($config['changelog'],0,2) != ' ') |
|
941 | + { |
|
942 | + $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
943 | + } |
|
852 | 944 | $content = $new_header."\n\n".$config['changelog']. |
853 | 945 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
854 | 946 | |
@@ -862,10 +954,13 @@ discard block |
||
862 | 954 | { |
863 | 955 | global $config; |
864 | 956 | |
865 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
957 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
958 | + { |
|
959 | + // sha1_file cant deal with '~/rpm' |
|
866 | 960 | { |
867 | 961 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
868 | 962 | } |
963 | + } |
|
869 | 964 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
870 | 965 | |
871 | 966 | if (!file_exists($sumsfile)) |
@@ -876,11 +971,17 @@ discard block |
||
876 | 971 | // signing it |
877 | 972 | if (empty($config['gpg']) || !file_exists($config['gpg'])) |
878 | 973 | { |
879 | - if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
974 | + if (!empty($config['gpg'])) |
|
975 | + { |
|
976 | + echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
977 | + } |
|
880 | 978 | return; |
881 | 979 | } |
882 | 980 | echo "Signing sha1sum file:\n"; |
883 | - if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
|
981 | + if (file_exists($sumsfile.'.asc')) |
|
982 | + { |
|
983 | + unlink($sumsfile.'.asc'); |
|
984 | + } |
|
884 | 985 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
885 | 986 | run_cmd($cmd); |
886 | 987 | unlink($sumsfile); // delete the unsigned file |
@@ -893,11 +994,17 @@ discard block |
||
893 | 994 | { |
894 | 995 | global $config; |
895 | 996 | |
896 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
897 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
997 | + if (!file_exists($config['sourcedir'])) |
|
998 | + { |
|
999 | + mkdir($config['sourcedir'],0755,true); |
|
1000 | + } |
|
1001 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
1002 | + { |
|
1003 | + // sha1_file cant deal with '~/rpm' |
|
898 | 1004 | { |
899 | 1005 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
900 | 1006 | } |
1007 | + } |
|
901 | 1008 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
902 | 1009 | $sums = ''; |
903 | 1010 | |
@@ -935,12 +1042,22 @@ discard block |
||
935 | 1042 | { |
936 | 1043 | foreach((array)$config['all-add'] as $add) |
937 | 1044 | { |
938 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
939 | - if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
|
1045 | + if (substr($add, -4) != '.tar') |
|
1046 | + { |
|
1047 | + continue; |
|
1048 | + } |
|
1049 | + // probably a module |
|
1050 | + if (!($tar = realpath($add))) |
|
1051 | + { |
|
1052 | + throw new Exception("File '$add' not found!"); |
|
1053 | + } |
|
940 | 1054 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
941 | 1055 | } |
942 | 1056 | } |
943 | - if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2'; |
|
1057 | + if (file_exists($file.'.bz2')) |
|
1058 | + { |
|
1059 | + $cmd .= '; rm -f '.$file.'.bz2'; |
|
1060 | + } |
|
944 | 1061 | $cmd .= '; '.$config['bzip2'].' '.$file; |
945 | 1062 | // run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it |
946 | 1063 | run_cmd($cmd); |
@@ -961,7 +1078,10 @@ discard block |
||
961 | 1078 | |
962 | 1079 | foreach($config['extra'] as $name => $modules) |
963 | 1080 | { |
964 | - if (is_numeric($name)) $name = $modules; |
|
1081 | + if (is_numeric($name)) |
|
1082 | + { |
|
1083 | + $name = $modules; |
|
1084 | + } |
|
965 | 1085 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
966 | 1086 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
967 | 1087 | switch($type) |
@@ -1002,7 +1122,10 @@ discard block |
||
1002 | 1122 | { |
1003 | 1123 | echo "Updating virus signatures\n"; |
1004 | 1124 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
1005 | - if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
|
1125 | + if (!$verbose && function_exists('posix_getuid') && posix_getuid()) |
|
1126 | + { |
|
1127 | + echo $cmd."\n"; |
|
1128 | + } |
|
1006 | 1129 | $output = null; |
1007 | 1130 | run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
1008 | 1131 | } |
@@ -1030,7 +1153,10 @@ discard block |
||
1030 | 1153 | } |
1031 | 1154 | |
1032 | 1155 | // we need to stash uncommited changes like .mrconfig, before copying |
1033 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash"); |
|
1156 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
1157 | + { |
|
1158 | + run_cmd("cd $config[checkoutdir]; git stash"); |
|
1159 | + } |
|
1034 | 1160 | |
1035 | 1161 | try { |
1036 | 1162 | $cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/'; |
@@ -1039,8 +1165,14 @@ discard block |
||
1039 | 1165 | catch (Exception $e) { |
1040 | 1166 | // catch failures to pop stash, before throwing exception |
1041 | 1167 | } |
1042 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop"); |
|
1043 | - if (isset($e)) throw $e; |
|
1168 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
1169 | + { |
|
1170 | + run_cmd("git stash pop"); |
|
1171 | + } |
|
1172 | + if (isset($e)) |
|
1173 | + { |
|
1174 | + throw $e; |
|
1175 | + } |
|
1044 | 1176 | |
1045 | 1177 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
1046 | 1178 | { |
@@ -1125,9 +1257,12 @@ discard block |
||
1125 | 1257 | if ($ret || substr($line,0,5) == 'URL: ') |
1126 | 1258 | { |
1127 | 1259 | $url = substr($line,5); |
1128 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1260 | + if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) |
|
1261 | + { |
|
1262 | + // wrong branch (or no svn dir) |
|
1129 | 1263 | { |
1130 | 1264 | echo "Checkout is of wrong branch --> deleting it\n"; |
1265 | + } |
|
1131 | 1266 | system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
1132 | 1267 | clearstatcache(); |
1133 | 1268 | } |
@@ -1174,19 +1309,31 @@ discard block |
||
1174 | 1309 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
1175 | 1310 | $url = $svnbranch.'/'.$config['svnalias']; |
1176 | 1311 | $cmd = $svn.' propget svn:externals --strict '.$url; |
1177 | - if ($verbose) echo $cmd."\n"; |
|
1312 | + if ($verbose) |
|
1313 | + { |
|
1314 | + echo $cmd."\n"; |
|
1315 | + } |
|
1178 | 1316 | $output = $ret = null; |
1179 | 1317 | exec($cmd,$output,$ret); |
1180 | 1318 | $config['modules'] = array(); |
1181 | 1319 | foreach($output as $line) |
1182 | 1320 | { |
1183 | 1321 | $line = trim($line); |
1184 | - if (empty($line) || $line[0] == '#') continue; |
|
1322 | + if (empty($line) || $line[0] == '#') |
|
1323 | + { |
|
1324 | + continue; |
|
1325 | + } |
|
1185 | 1326 | list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
1186 | 1327 | $matches = null; |
1187 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1328 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
1329 | + { |
|
1330 | + die("Invalid SVN URL: $url\n"); |
|
1331 | + } |
|
1188 | 1332 | $repo = $matches[1]; |
1189 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1333 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
1334 | + { |
|
1335 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1336 | + } |
|
1190 | 1337 | $config['modules'][$repo][$path] = $url; |
1191 | 1338 | } |
1192 | 1339 | // process extra modules |
@@ -1195,13 +1342,25 @@ discard block |
||
1195 | 1342 | $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
1196 | 1343 | $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
1197 | 1344 | $url .= $module; |
1198 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
1199 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1345 | + if (strpos($module,'://') !== false) |
|
1346 | + { |
|
1347 | + $module = basename($module); |
|
1348 | + } |
|
1349 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
1350 | + { |
|
1351 | + die("Invalid SVN URL: $url\n"); |
|
1352 | + } |
|
1200 | 1353 | $repo = $matches[1]; |
1201 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1354 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
1355 | + { |
|
1356 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
1357 | + } |
|
1202 | 1358 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
1203 | 1359 | } |
1204 | - if ($verbose) print_r($config['modules']); |
|
1360 | + if ($verbose) |
|
1361 | + { |
|
1362 | + print_r($config['modules']); |
|
1363 | + } |
|
1205 | 1364 | return $config['modules']; |
1206 | 1365 | } |
1207 | 1366 | |
@@ -1212,7 +1371,11 @@ discard block |
||
1212 | 1371 | { |
1213 | 1372 | global $config,$svn; |
1214 | 1373 | |
1215 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1374 | + if (empty($config['svntag'])) |
|
1375 | + { |
|
1376 | + return; |
|
1377 | + } |
|
1378 | + // otherwise we copy everything in svn root! |
|
1216 | 1379 | |
1217 | 1380 | $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
1218 | 1381 | |
@@ -1251,11 +1414,17 @@ discard block |
||
1251 | 1414 | { |
1252 | 1415 | $output[] = $cmd; |
1253 | 1416 | exec($cmd,$output,$ret); |
1254 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
1417 | + if ($verbose) |
|
1418 | + { |
|
1419 | + echo implode("\n",$output)."\n"; |
|
1420 | + } |
|
1255 | 1421 | } |
1256 | 1422 | if ($ret && !in_array($ret,(array)$no_bailout)) |
1257 | 1423 | { |
1258 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
1424 | + if (!$verbose) |
|
1425 | + { |
|
1426 | + echo implode("\n",$output)."\n"; |
|
1427 | + } |
|
1259 | 1428 | throw new Exception("Error during '$cmd' --> aborting",$ret); |
1260 | 1429 | } |
1261 | 1430 | return $ret; |
@@ -1301,7 +1470,10 @@ discard block |
||
1301 | 1470 | echo "options and their defaults:\n"; |
1302 | 1471 | if ($verbose) |
1303 | 1472 | { |
1304 | - if (!isset($config['modules'])) $config['modules'] = get_modules_per_repo(); |
|
1473 | + if (!isset($config['modules'])) |
|
1474 | + { |
|
1475 | + $config['modules'] = get_modules_per_repo(); |
|
1476 | + } |
|
1305 | 1477 | } |
1306 | 1478 | else |
1307 | 1479 | { |
@@ -1309,7 +1481,10 @@ discard block |
||
1309 | 1481 | } |
1310 | 1482 | foreach($config as $name => $default) |
1311 | 1483 | { |
1312 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1484 | + if (is_array($default)) |
|
1485 | + { |
|
1486 | + $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1487 | + } |
|
1313 | 1488 | echo '--'.str_pad($name,20).$default."\n"; |
1314 | 1489 | } |
1315 | 1490 | if ($error) |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | { |
15 | 15 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
16 | 16 | } |
17 | -date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
17 | +date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
18 | 18 | |
19 | 19 | $verbose = 0; |
20 | 20 | $config = array( |
21 | 21 | 'packagename' => 'egroupware-epl', |
22 | - 'version' => '14.3', // '14.3' |
|
22 | + 'version' => '14.3', // '14.3' |
|
23 | 23 | 'packaging' => date('Ymd'), // '20160520' |
24 | - 'branch' => '14.2', // checked out branch |
|
25 | - 'tag' => '$version.$packaging', // name of tag |
|
24 | + 'branch' => '14.2', // checked out branch |
|
25 | + 'tag' => '$version.$packaging', // name of tag |
|
26 | 26 | 'checkoutdir' => realpath(__DIR__.'/../..'), |
27 | 27 | 'egw_buildroot' => '/tmp/build_root/epl_14.2_buildroot', |
28 | 28 | 'sourcedir' => '/home/download/stylite-epl/egroupware-epl-14.2', |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | 'svnalias' => 'aliases/default-ssh', // default alias |
35 | 35 | 'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'), |
36 | 36 | */ |
37 | - 'extra' => array('stylite', 'esyncpro', 'archive'), // create an extra archive for given apps |
|
37 | + 'extra' => array('stylite', 'esyncpro', 'archive'), // create an extra archive for given apps |
|
38 | 38 | // these apps are placed in egroupware-epl-contrib archive |
39 | 39 | //'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')), |
40 | - 'aliasdir' => 'egroupware', // directory created by the alias |
|
41 | - 'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'), |
|
40 | + 'aliasdir' => 'egroupware', // directory created by the alias |
|
41 | + 'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'), |
|
42 | 42 | // add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive |
43 | 43 | 'all-add' => array(/*'contrib',*/ '/home/stylite/epl-trunk/phpfreechat_data_public.tar'), |
44 | 44 | // diverse binaries we need |
@@ -55,35 +55,35 @@ discard block |
||
55 | 55 | 'gpg' => trim(`which gpg`), |
56 | 56 | 'editor' => trim(`which vi`), |
57 | 57 | 'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"', |
58 | - 'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '', |
|
58 | + 'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '', |
|
59 | 59 | 'after-checkout' => 'rm -rf */source */templates/*/source', |
60 | 60 | 'packager' => '[email protected]', |
61 | 61 | 'obs' => '/home/stylite/obs/stylite-epl', |
62 | - 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
63 | - 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
62 | + 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
63 | + 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
64 | 64 | 'changelog_packager' => 'Ralf Becker <[email protected]>', |
65 | 65 | 'editchangelog' => '* ', |
66 | 66 | //'sfuser' => 'ralfbecker', |
67 | 67 | //'release' => '$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/', |
68 | 68 | 'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README', |
69 | 69 | 'skip' => array(), |
70 | - 'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'), |
|
70 | + 'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'), |
|
71 | 71 | 'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"', |
72 | - 'github_user' => 'ralfbecker', // Github user for following token |
|
73 | - 'github_token' => '', // Github repo personal access token from above user |
|
72 | + 'github_user' => 'ralfbecker', // Github user for following token |
|
73 | + 'github_token' => '', // Github repo personal access token from above user |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | // process config from command line |
77 | 77 | $argv = $_SERVER['argv']; |
78 | 78 | $prog = array_shift($argv); |
79 | 79 | |
80 | -while(($arg = array_shift($argv))) |
|
80 | +while (($arg = array_shift($argv))) |
|
81 | 81 | { |
82 | 82 | if ($arg == '-v' || $arg == '--verbose') |
83 | 83 | { |
84 | 84 | ++$verbose; |
85 | 85 | } |
86 | - elseif($arg == '-h' || $arg == '--help') |
|
86 | + elseif ($arg == '-h' || $arg == '--help') |
|
87 | 87 | { |
88 | 88 | if (in_array('editchangelog', $config['skip']) || !in_array('editchangelog', $config['run'])) |
89 | 89 | { |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | } |
92 | 92 | usage(); |
93 | 93 | } |
94 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
94 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
95 | 95 | { |
96 | 96 | $value = array_shift($argv); |
97 | - switch($name) |
|
97 | + switch ($name) |
|
98 | 98 | { |
99 | 99 | case 'extra': // stored as array and allow to add/delete items with +/- prefix |
100 | 100 | case 'types': |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $value = array_unique(preg_split('/[ ,]+/', $value)); |
119 | 119 | } |
120 | - switch($op) |
|
120 | + switch ($op) |
|
121 | 121 | { |
122 | 122 | case '+': |
123 | 123 | $config[$name] = array_unique(array_merge($config[$name], $value)); |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | case 'release': |
136 | 136 | case 'copychangelog': |
137 | 137 | $config[$name] = $value; |
138 | - if ($value) array_unshift($config['run'],$name); |
|
138 | + if ($value) array_unshift($config['run'], $name); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case 'editchangelog': |
142 | 142 | $config[$name] = $value ? $value : true; |
143 | - if (!in_array('editchangelog',$config['run'])) |
|
143 | + if (!in_array('editchangelog', $config['run'])) |
|
144 | 144 | { |
145 | - array_unshift($config['run'],'editchangelog'); |
|
145 | + array_unshift($config['run'], 'editchangelog'); |
|
146 | 146 | } |
147 | 147 | break; |
148 | 148 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | { |
152 | 152 | usage("Path '$value' not found!"); |
153 | 153 | } |
154 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
154 | + if (!in_array('obs', $config['run'])) $config['run'][] = 'obs'; |
|
155 | 155 | // fall through |
156 | 156 | default: |
157 | 157 | $config[$name] = $value; |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | } |
170 | 170 | $svn = $config['svn']; |
171 | 171 | |
172 | -$run = array_diff($config['run'],$config['skip']); |
|
172 | +$run = array_diff($config['run'], $config['skip']); |
|
173 | 173 | |
174 | 174 | // if we dont edit the changelog, set packaging from changelog |
175 | 175 | if (!in_array('editchangelog', $run)) |
176 | 176 | { |
177 | 177 | parse_current_changelog(true); |
178 | 178 | } |
179 | -foreach($run as $func) |
|
179 | +foreach ($run as $func) |
|
180 | 180 | { |
181 | - chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
181 | + chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
182 | 182 | call_user_func('do_'.$func); |
183 | 183 | } |
184 | 184 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
194 | 194 | * @return string with changelog |
195 | 195 | */ |
196 | -function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ') |
|
196 | +function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ') |
|
197 | 197 | { |
198 | 198 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
199 | 199 | global $config; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | run_cmd($cmd, $output); |
215 | 215 | |
216 | 216 | $changelog = ''; |
217 | - foreach($output as $line) |
|
217 | + foreach ($output as $line) |
|
218 | 218 | { |
219 | 219 | if (substr($line, 0, 4) == " " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix))) |
220 | 220 | { |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | { |
247 | 247 | throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!"); |
248 | 248 | } |
249 | - if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig'))) |
|
249 | + if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig'))) |
|
250 | 250 | { |
251 | 251 | throw new Exception("$path not found!"); |
252 | 252 | } |
253 | 253 | $module = $baseurl = null; |
254 | 254 | $modules = array(); |
255 | - foreach(explode("\n", $mrconfig) as $line) |
|
255 | + foreach (explode("\n", $mrconfig) as $line) |
|
256 | 256 | { |
257 | 257 | $matches = null; |
258 | 258 | if (isset($baseurl)) |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : ''). |
318 | 318 | ' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir']; |
319 | 319 | run_cmd($cmd); |
320 | - run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
320 | + run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
321 | 321 | } |
322 | 322 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
323 | 323 | { |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | } |
342 | 342 | chdir($config['checkoutdir']); |
343 | 343 | |
344 | - $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
344 | + $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
345 | 345 | |
346 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
346 | + if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
347 | 347 | |
348 | 348 | echo "Creating tag $config[tag]\n"; |
349 | 349 | |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function do_release() |
358 | 358 | { |
359 | - global $config,$verbose; |
|
359 | + global $config, $verbose; |
|
360 | 360 | |
361 | 361 | // push local changes to Github incl. tags |
362 | 362 | if ($verbose) echo "Pushing changes and tags\n"; |
363 | 363 | chdir($config['checkoutdir']); |
364 | - run_cmd($config['mr']. ' up'); // in case someone else pushed something |
|
364 | + run_cmd($config['mr'].' up'); // in case someone else pushed something |
|
365 | 365 | chdir($config['checkoutdir']); |
366 | - run_cmd($config['git'].' push'); // regular commits like changelog |
|
366 | + run_cmd($config['git'].' push'); // regular commits like changelog |
|
367 | 367 | $tag = config_translate('tag'); |
368 | - run_cmd($config['mr']. ' push origin '.$tag); // pushing tags in all apps |
|
368 | + run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps |
|
369 | 369 | |
370 | 370 | if (empty($config['github_user']) || empty($config['github_token'])) |
371 | 371 | { |
@@ -382,26 +382,26 @@ discard block |
||
382 | 382 | 'body' => $config['changelog'], |
383 | 383 | ); |
384 | 384 | $response = github_api("/repos/EGroupware/egroupware/releases", $data); |
385 | - $upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
385 | + $upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
386 | 386 | |
387 | 387 | $archives = $config['sourcedir'].'/*egroupware-epl-'.$config['version'].'.'.$config['packaging'].'*'; |
388 | 388 | |
389 | - foreach(glob($archives) as $path) |
|
389 | + foreach (glob($archives) as $path) |
|
390 | 390 | { |
391 | 391 | $label = null; |
392 | 392 | if (substr($path, -4) == '.zip') |
393 | 393 | { |
394 | 394 | $content_type = 'application/zip'; |
395 | 395 | } |
396 | - elseif(substr($path, -7) == '.tar.gz') |
|
396 | + elseif (substr($path, -7) == '.tar.gz') |
|
397 | 397 | { |
398 | 398 | $content_type = 'application/x-gzip'; |
399 | 399 | } |
400 | - elseif(substr($path, -8) == '.tar.bz2') |
|
400 | + elseif (substr($path, -8) == '.tar.bz2') |
|
401 | 401 | { |
402 | 402 | $content_type = 'application/x-bzip2'; |
403 | 403 | } |
404 | - elseif(substr($path, -8) == '.txt.asc') |
|
404 | + elseif (substr($path, -8) == '.txt.asc') |
|
405 | 405 | { |
406 | 406 | $content_type = 'text/plain'; |
407 | 407 | $label = 'Signed hashes of downloads'; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | if (!empty($config['release'])) |
421 | 421 | { |
422 | - $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
422 | + $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
423 | 423 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
424 | 424 | if ($verbose) echo $cmd."\n"; |
425 | 425 | passthru($cmd); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @throws Exception |
438 | 438 | * @return array with response |
439 | 439 | */ |
440 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
440 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
441 | 441 | { |
442 | 442 | global $config, $verbose; |
443 | 443 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
451 | 451 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
452 | 452 | |
453 | - switch($method) |
|
453 | + switch ($method) |
|
454 | 454 | { |
455 | 455 | case 'POST': |
456 | 456 | curl_setopt($c, CURLOPT_POST, true); |
@@ -458,13 +458,13 @@ discard block |
||
458 | 458 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
459 | 459 | break; |
460 | 460 | case 'GET': |
461 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
461 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
462 | 462 | break; |
463 | 463 | case 'FILE': |
464 | 464 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
465 | 465 | curl_setopt($c, CURLOPT_POST, true); |
466 | 466 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
467 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
467 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
468 | 468 | break; |
469 | 469 | default: |
470 | 470 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | curl_setopt($c, CURLOPT_URL, $url); |
473 | 473 | |
474 | 474 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
475 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
475 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
476 | 476 | |
477 | 477 | if (($response = curl_exec($c)) === false) |
478 | 478 | { |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | curl_setopt($c, CURLOPT_HEADER, true); |
481 | 481 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
482 | 482 | curl_exec($c); |
483 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
483 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @param string $name |
497 | 497 | * @param string $value =null value to use, default $config[$name] |
498 | 498 | */ |
499 | -function config_translate($name, $value=null) |
|
499 | +function config_translate($name, $value = null) |
|
500 | 500 | { |
501 | 501 | global $config; |
502 | 502 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | if (is_string($value) && strpos($value, '$') !== false) |
505 | 505 | { |
506 | 506 | $translate = array(); |
507 | - foreach($config as $n => $val) |
|
507 | + foreach ($config as $n => $val) |
|
508 | 508 | { |
509 | 509 | if (is_string($val)) $translate['$'.$n] = $val; |
510 | 510 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | */ |
531 | 531 | function do_editchangelog() |
532 | 532 | { |
533 | - global $config,$svn; |
|
533 | + global $config, $svn; |
|
534 | 534 | |
535 | 535 | echo "Querying changelog from Git/SVN\n"; |
536 | 536 | if (!isset($config['modules'])) |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | // query changelog per repo |
541 | 541 | $changelog = ''; |
542 | 542 | $last_tag = null; |
543 | - foreach($config['modules'] as $branch_url => $modules) |
|
543 | + foreach ($config['modules'] as $branch_url => $modules) |
|
544 | 544 | { |
545 | 545 | $revision = null; |
546 | 546 | if (substr($branch_url, -4) == '.git') |
@@ -553,15 +553,15 @@ discard block |
||
553 | 553 | $changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision); |
554 | 554 | } |
555 | 555 | } |
556 | - $logfile = tempnam('/tmp','checkout-build-archives'); |
|
557 | - file_put_contents($logfile,$changelog); |
|
556 | + $logfile = tempnam('/tmp', 'checkout-build-archives'); |
|
557 | + file_put_contents($logfile, $changelog); |
|
558 | 558 | $cmd = $config['editor'].' '.escapeshellarg($logfile); |
559 | 559 | passthru($cmd); |
560 | 560 | $config['changelog'] = file_get_contents($logfile); |
561 | 561 | // remove trailing newlines |
562 | - while (substr($config['changelog'],-1) == "\n") |
|
562 | + while (substr($config['changelog'], -1) == "\n") |
|
563 | 563 | { |
564 | - $config['changelog'] = substr($config['changelog'],0,-1); |
|
564 | + $config['changelog'] = substr($config['changelog'], 0, -1); |
|
565 | 565 | } |
566 | 566 | // allow user to abort, by deleting the changelog |
567 | 567 | if (strlen($config['changelog']) <= 2) |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | run_cmd($cmd); |
587 | 587 | |
588 | 588 | // update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped) |
589 | - do_obs(true); // true: only update debian.changes in obs checkouts |
|
589 | + do_obs(true); // true: only update debian.changes in obs checkouts |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -600,41 +600,41 @@ discard block |
||
600 | 600 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
601 | 601 | * @return string with changelog |
602 | 602 | */ |
603 | -function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ') |
|
603 | +function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ') |
|
604 | 604 | { |
605 | 605 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
606 | - global $config,$verbose,$svn; |
|
606 | + global $config, $verbose, $svn; |
|
607 | 607 | |
608 | 608 | if (is_null($revision)) |
609 | 609 | { |
610 | - list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
|
610 | + list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url); |
|
611 | 611 | if (empty($branch)) $branch = $config['version']; |
612 | 612 | $tags_url .= '/tags'; |
613 | - $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
613 | + $pattern = '|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
614 | 614 | $matches = null; |
615 | - $revision = get_last_svn_tag($tags_url,$pattern,$matches); |
|
615 | + $revision = get_last_svn_tag($tags_url, $pattern, $matches); |
|
616 | 616 | $tag = $matches[1]; |
617 | 617 | } |
618 | - elseif(!is_numeric($revision)) |
|
618 | + elseif (!is_numeric($revision)) |
|
619 | 619 | { |
620 | - $revision = get_last_svn_tag($tags_url,$tag=$revision); |
|
620 | + $revision = get_last_svn_tag($tags_url, $tag = $revision); |
|
621 | 621 | } |
622 | 622 | $cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url); |
623 | 623 | if (($v = $verbose)) |
624 | 624 | { |
625 | 625 | echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n"; |
626 | - $verbose = false; // otherwise no $output! |
|
626 | + $verbose = false; // otherwise no $output! |
|
627 | 627 | } |
628 | 628 | $output = array(); |
629 | - run_cmd($cmd,$output); |
|
629 | + run_cmd($cmd, $output); |
|
630 | 630 | $verbose = $v; |
631 | - array_shift($output); // remove the command |
|
631 | + array_shift($output); // remove the command |
|
632 | 632 | |
633 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
633 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
634 | 634 | $message = ''; |
635 | - foreach($xml as $log) |
|
635 | + foreach ($xml as $log) |
|
636 | 636 | { |
637 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
637 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
638 | 638 | |
639 | 639 | $message .= $msg."\n"; |
640 | 640 | } |
@@ -651,25 +651,25 @@ discard block |
||
651 | 651 | * @param string $prefix ='* ' |
652 | 652 | * @return string |
653 | 653 | */ |
654 | -function _match_log_pattern($msg, $log_pattern, $prefix='* ') |
|
654 | +function _match_log_pattern($msg, $log_pattern, $prefix = '* ') |
|
655 | 655 | { |
656 | 656 | $pattern_len = strlen($log_pattern); |
657 | 657 | $prefix_len = strlen($prefix); |
658 | 658 | |
659 | 659 | $matches = null; |
660 | - if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches)) |
|
660 | + if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches)) |
|
661 | 661 | { |
662 | 662 | $msg = $matches[1]; |
663 | 663 | } |
664 | - elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern) |
|
664 | + elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern) |
|
665 | 665 | { |
666 | - list($msg) = explode("\n",$msg); |
|
666 | + list($msg) = explode("\n", $msg); |
|
667 | 667 | } |
668 | - elseif($log_pattern) |
|
668 | + elseif ($log_pattern) |
|
669 | 669 | { |
670 | 670 | return null; |
671 | 671 | } |
672 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
672 | + if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg; |
|
673 | 673 | |
674 | 674 | return $msg; |
675 | 675 | } |
@@ -683,30 +683,30 @@ discard block |
||
683 | 683 | * @param array &$matches=null on return matches of preg_match |
684 | 684 | * @return int revision of last svn tag matching pattern |
685 | 685 | */ |
686 | -function get_last_svn_tag($tags_url,$pattern,&$matches=null) |
|
686 | +function get_last_svn_tag($tags_url, $pattern, &$matches = null) |
|
687 | 687 | { |
688 | - global $verbose,$svn; |
|
688 | + global $verbose, $svn; |
|
689 | 689 | |
690 | 690 | $cmd = $svn.' log --xml --limit 40 -v '.escapeshellarg($tags_url); |
691 | 691 | if (($v = $verbose)) |
692 | 692 | { |
693 | 693 | echo "Querying SVN for last tags\n$cmd\n"; |
694 | - $verbose = false; // otherwise no $output! |
|
694 | + $verbose = false; // otherwise no $output! |
|
695 | 695 | } |
696 | 696 | $output = array(); |
697 | - run_cmd($cmd,$output); |
|
697 | + run_cmd($cmd, $output); |
|
698 | 698 | $verbose = $v; |
699 | - array_shift($output); // remove the command |
|
699 | + array_shift($output); // remove the command |
|
700 | 700 | |
701 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
701 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
702 | 702 | $is_regexp = $pattern[0] == substr($pattern, -1); |
703 | - foreach($xml as $log) |
|
703 | + foreach ($xml as $log) |
|
704 | 704 | { |
705 | 705 | //print_r($log); |
706 | 706 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
707 | 707 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
708 | 708 | { |
709 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
709 | + if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n"; |
|
710 | 710 | return (int)$log['revision']; |
711 | 711 | } |
712 | 712 | } |
@@ -718,9 +718,9 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it |
720 | 720 | */ |
721 | -function do_obs($only_update_changelog=false) |
|
721 | +function do_obs($only_update_changelog = false) |
|
722 | 722 | { |
723 | - global $config,$verbose; |
|
723 | + global $config, $verbose; |
|
724 | 724 | |
725 | 725 | if (!is_dir($config['obs'])) |
726 | 726 | { |
@@ -730,25 +730,25 @@ discard block |
||
730 | 730 | run_cmd('osc up '.$config['obs']); |
731 | 731 | |
732 | 732 | $n = 0; |
733 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
733 | + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
734 | 734 | { |
735 | 735 | if (basename(dirname($path)) == '.osc' || |
736 | 736 | !preg_match('/\/('.preg_quote($config['packagename']). |
737 | 737 | ($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : ''). |
738 | - ')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path)) |
|
738 | + ')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path)) |
|
739 | 739 | { |
740 | 740 | continue; |
741 | 741 | } |
742 | 742 | $matches = null; |
743 | - if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) && |
|
744 | - file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
743 | + if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) && |
|
744 | + file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
745 | 745 | { |
746 | 746 | if (basename($path) != basename($new_name)) |
747 | 747 | { |
748 | 748 | unlink($path); |
749 | 749 | if ($verbose) echo "rm $path\n"; |
750 | 750 | } |
751 | - copy($new_name,dirname($path).'/'.basename($new_name)); |
|
751 | + copy($new_name, dirname($path).'/'.basename($new_name)); |
|
752 | 752 | if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
753 | 753 | ++$n; |
754 | 754 | } |
@@ -758,35 +758,35 @@ discard block |
||
758 | 758 | $config['changelog'] = parse_current_changelog(); |
759 | 759 | } |
760 | 760 | // updating dsc, spec and changelog files |
761 | - if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') || |
|
761 | + if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') || |
|
762 | 762 | !empty($config['changelog']) && basename($path) == 'debian.changes') |
763 | 763 | { |
764 | 764 | $content = $content_was = file_get_contents($path); |
765 | 765 | |
766 | - if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') |
|
766 | + if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') |
|
767 | 767 | { |
768 | - $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content); |
|
768 | + $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content); |
|
769 | 769 | } |
770 | - if (substr($path,-4) == '.dsc') |
|
770 | + if (substr($path, -4) == '.dsc') |
|
771 | 771 | { |
772 | 772 | $content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'. |
773 | 773 | preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m', |
774 | - '\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content); |
|
774 | + '\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content); |
|
775 | 775 | } |
776 | - if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false) |
|
776 | + if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false) |
|
777 | 777 | { |
778 | 778 | $content = update_changelog($content); |
779 | 779 | } |
780 | - if (!empty($config['changelog']) && substr($path,-5) == '.spec' && |
|
781 | - ($pos_changelog = strpos($content,'%changelog')) !== false) |
|
780 | + if (!empty($config['changelog']) && substr($path, -5) == '.spec' && |
|
781 | + ($pos_changelog = strpos($content, '%changelog')) !== false) |
|
782 | 782 | { |
783 | 783 | $pos_changelog += strlen("%changelog\n"); |
784 | - $content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
785 | - $config['changelog']."\n".substr($content,$pos_changelog); |
|
784 | + $content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
785 | + $config['changelog']."\n".substr($content, $pos_changelog); |
|
786 | 786 | } |
787 | 787 | if ($content != $content_was) |
788 | 788 | { |
789 | - file_put_contents($path,$content); |
|
789 | + file_put_contents($path, $content); |
|
790 | 790 | if ($verbose) echo "Updated $path\n"; |
791 | 791 | ++$n; |
792 | 792 | } |
@@ -807,33 +807,33 @@ discard block |
||
807 | 807 | * @param boolean $set_packaging =false true: set packaging from last changelog entry |
808 | 808 | * @return string changelog entries without header and footer lines |
809 | 809 | */ |
810 | -function parse_current_changelog($set_packaging=false) |
|
810 | +function parse_current_changelog($set_packaging = false) |
|
811 | 811 | { |
812 | 812 | global $config; |
813 | 813 | |
814 | 814 | $changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes'); |
815 | 815 | $lines = explode("\n", $changelog, 100); |
816 | 816 | $matches = null; |
817 | - foreach($lines as $n => $line) |
|
817 | + foreach ($lines as $n => $line) |
|
818 | 818 | { |
819 | - if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
819 | + if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
820 | 820 | ($set_packaging ? '([0-9]+)' : preg_quote($config['packaging'])).'/', $line, $matches)) |
821 | 821 | { |
822 | 822 | if ($set_packaging) |
823 | 823 | { |
824 | 824 | $config['packaging'] = $matches[1]; |
825 | 825 | } |
826 | - $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
|
826 | + $n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header |
|
827 | 827 | $logentry = ''; |
828 | - while($lines[$n]) // entry is terminated by empty line |
|
828 | + while ($lines[$n]) // entry is terminated by empty line |
|
829 | 829 | { |
830 | 830 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
831 | 831 | ++$n; |
832 | 832 | } |
833 | - return substr($logentry, 0, -1); // remove training "\n" |
|
833 | + return substr($logentry, 0, -1); // remove training "\n" |
|
834 | 834 | } |
835 | 835 | } |
836 | - return null; // paragraph for current version NOT found |
|
836 | + return null; // paragraph for current version NOT found |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | global $config; |
848 | 848 | |
849 | 849 | list($header) = explode("\n", $content); |
850 | - $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
851 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
850 | + $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
851 | + if (substr($config['changelog'], 0, 2) != ' ') $config['changelog'] = ' '.implode("\n ", explode("\n", $config['changelog'])); |
|
852 | 852 | $content = $new_header."\n\n".$config['changelog']. |
853 | 853 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
854 | 854 | |
@@ -862,9 +862,9 @@ discard block |
||
862 | 862 | { |
863 | 863 | global $config; |
864 | 864 | |
865 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
865 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
866 | 866 | { |
867 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
867 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
868 | 868 | } |
869 | 869 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
870 | 870 | |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
884 | 884 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
885 | 885 | run_cmd($cmd); |
886 | - unlink($sumsfile); // delete the unsigned file |
|
886 | + unlink($sumsfile); // delete the unsigned file |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
@@ -893,22 +893,22 @@ discard block |
||
893 | 893 | { |
894 | 894 | global $config; |
895 | 895 | |
896 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
897 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
896 | + if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true); |
|
897 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
898 | 898 | { |
899 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
899 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
900 | 900 | } |
901 | 901 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
902 | 902 | $sums = ''; |
903 | 903 | |
904 | 904 | chdir($config['egw_buildroot']); |
905 | 905 | |
906 | - if($config['extra']) |
|
906 | + if ($config['extra']) |
|
907 | 907 | { |
908 | 908 | $exclude = $exclude_all = array(); |
909 | - foreach($config['extra'] as $name => $modules) |
|
909 | + foreach ($config['extra'] as $name => $modules) |
|
910 | 910 | { |
911 | - foreach((array)$modules as $module) |
|
911 | + foreach ((array)$modules as $module) |
|
912 | 912 | { |
913 | 913 | $exclude[] = basename($module); |
914 | 914 | if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add']))) |
@@ -918,24 +918,24 @@ discard block |
||
918 | 918 | } |
919 | 919 | } |
920 | 920 | $exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude); |
921 | - $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
921 | + $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
922 | 922 | } |
923 | - foreach($config['types'] as $type) |
|
923 | + foreach ($config['types'] as $type) |
|
924 | 924 | { |
925 | 925 | echo "Creating $type archives\n"; |
926 | 926 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
927 | 927 | |
928 | 928 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
929 | - switch($type) |
|
929 | + switch ($type) |
|
930 | 930 | { |
931 | 931 | case 'all.tar.bz2': // single tar-ball for debian builds not easily supporting to use multiple |
932 | 932 | $file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar'; |
933 | 933 | $cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware'; |
934 | 934 | if (!empty($config['all-add'])) |
935 | 935 | { |
936 | - foreach((array)$config['all-add'] as $add) |
|
936 | + foreach ((array)$config['all-add'] as $add) |
|
937 | 937 | { |
938 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
938 | + if (substr($add, -4) != '.tar') continue; // probably a module |
|
939 | 939 | if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
940 | 940 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
941 | 941 | } |
@@ -959,15 +959,15 @@ discard block |
||
959 | 959 | run_cmd($cmd); |
960 | 960 | $sums .= sha1_file($file)."\t".basename($file)."\n"; |
961 | 961 | |
962 | - foreach($config['extra'] as $name => $modules) |
|
962 | + foreach ($config['extra'] as $name => $modules) |
|
963 | 963 | { |
964 | 964 | if (is_numeric($name)) $name = $modules; |
965 | 965 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
966 | 966 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
967 | - switch($type) |
|
967 | + switch ($type) |
|
968 | 968 | { |
969 | 969 | case 'all.tar.bz2': |
970 | - break; // nothing to do |
|
970 | + break; // nothing to do |
|
971 | 971 | case 'tar.bz2': |
972 | 972 | case 'tar.gz': |
973 | 973 | $cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | } |
983 | 983 | } |
984 | 984 | // writing sha1sum file |
985 | - file_put_contents($sumsfile,$sums); |
|
985 | + file_put_contents($sumsfile, $sums); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | /** |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | */ |
991 | 991 | function do_virusscan() |
992 | 992 | { |
993 | - global $config,$verbose; |
|
993 | + global $config, $verbose; |
|
994 | 994 | |
995 | 995 | if (!file_exists($config['clamscan']) || !is_executable($config['clamscan'])) |
996 | 996 | { |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
1005 | 1005 | if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
1006 | 1006 | $output = null; |
1007 | - run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
|
1007 | + run_cmd($cmd, $output, 1); // 1 = ignore already up to date database |
|
1008 | 1008 | } |
1009 | 1009 | echo "Starting virusscan\n"; |
1010 | 1010 | $cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot']; |
@@ -1061,12 +1061,12 @@ discard block |
||
1061 | 1061 | */ |
1062 | 1062 | function do_svncheckout() |
1063 | 1063 | { |
1064 | - global $config,$svn; |
|
1064 | + global $config, $svn; |
|
1065 | 1065 | |
1066 | 1066 | echo "Starting svn checkout/update\n"; |
1067 | 1067 | if (!file_exists($config['checkoutdir'])) |
1068 | 1068 | { |
1069 | - mkdir($config['checkoutdir'],0755,true); |
|
1069 | + mkdir($config['checkoutdir'], 0755, true); |
|
1070 | 1070 | } |
1071 | 1071 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
1072 | 1072 | { |
@@ -1081,17 +1081,17 @@ discard block |
||
1081 | 1081 | { |
1082 | 1082 | get_modules_per_repo(); |
1083 | 1083 | } |
1084 | - $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
1084 | + $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
1085 | 1085 | |
1086 | 1086 | if (file_exists($config['aliasdir'])) |
1087 | 1087 | { |
1088 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
1088 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
1089 | 1089 | clearstatcache(); |
1090 | 1090 | } |
1091 | - foreach($config['modules'] as $repo => $modules) |
|
1091 | + foreach ($config['modules'] as $repo => $modules) |
|
1092 | 1092 | { |
1093 | 1093 | $cmd = $svn.' co '; |
1094 | - foreach($modules as $path => $url) |
|
1094 | + foreach ($modules as $path => $url) |
|
1095 | 1095 | { |
1096 | 1096 | if ($path == $config['aliasdir']) |
1097 | 1097 | { |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | $cmd = $svn.' co '; |
1102 | 1102 | continue; |
1103 | 1103 | } |
1104 | - if(file_exists($config['aliasdir'])) |
|
1104 | + if (file_exists($config['aliasdir'])) |
|
1105 | 1105 | { |
1106 | 1106 | die("'egroupware' applications must be first one in externals!\n"); |
1107 | 1107 | } |
@@ -1119,16 +1119,16 @@ discard block |
||
1119 | 1119 | // check if correct branch |
1120 | 1120 | $cmd = 'LANG=C '.$svn.' info'; |
1121 | 1121 | $output = $ret = null; |
1122 | - exec($cmd,$output,$ret); |
|
1123 | - foreach($output as $line) |
|
1122 | + exec($cmd, $output, $ret); |
|
1123 | + foreach ($output as $line) |
|
1124 | 1124 | { |
1125 | - if ($ret || substr($line,0,5) == 'URL: ') |
|
1125 | + if ($ret || substr($line, 0, 5) == 'URL: ') |
|
1126 | 1126 | { |
1127 | - $url = substr($line,5); |
|
1128 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1127 | + $url = substr($line, 5); |
|
1128 | + if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
1129 | 1129 | { |
1130 | 1130 | echo "Checkout is of wrong branch --> deleting it\n"; |
1131 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
1131 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
1132 | 1132 | clearstatcache(); |
1133 | 1133 | } |
1134 | 1134 | break; |
@@ -1140,10 +1140,10 @@ discard block |
||
1140 | 1140 | run_cmd($cmd); |
1141 | 1141 | |
1142 | 1142 | chdir($config['aliasdir']); |
1143 | - foreach($config['extra'] as $module) |
|
1143 | + foreach ($config['extra'] as $module) |
|
1144 | 1144 | { |
1145 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1146 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
1145 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1146 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
1147 | 1147 | $url .= $module; |
1148 | 1148 | $cmd = $svn.' co '.$url; |
1149 | 1149 | run_cmd($cmd); |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | function get_modules_per_svn_repo() |
1170 | 1170 | { |
1171 | - global $config,$svn,$verbose; |
|
1171 | + global $config, $svn, $verbose; |
|
1172 | 1172 | |
1173 | 1173 | // process alias/externals |
1174 | 1174 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
@@ -1176,27 +1176,27 @@ discard block |
||
1176 | 1176 | $cmd = $svn.' propget svn:externals --strict '.$url; |
1177 | 1177 | if ($verbose) echo $cmd."\n"; |
1178 | 1178 | $output = $ret = null; |
1179 | - exec($cmd,$output,$ret); |
|
1179 | + exec($cmd, $output, $ret); |
|
1180 | 1180 | $config['modules'] = array(); |
1181 | - foreach($output as $line) |
|
1181 | + foreach ($output as $line) |
|
1182 | 1182 | { |
1183 | 1183 | $line = trim($line); |
1184 | 1184 | if (empty($line) || $line[0] == '#') continue; |
1185 | - list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
|
1185 | + list($path, $url) = preg_split('/[ \t\r\n]+/', $line); |
|
1186 | 1186 | $matches = null; |
1187 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1187 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
1188 | 1188 | $repo = $matches[1]; |
1189 | 1189 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
1190 | 1190 | $config['modules'][$repo][$path] = $url; |
1191 | 1191 | } |
1192 | 1192 | // process extra modules |
1193 | - foreach($config['extra'] as $module) |
|
1193 | + foreach ($config['extra'] as $module) |
|
1194 | 1194 | { |
1195 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1196 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
1195 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
1196 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
1197 | 1197 | $url .= $module; |
1198 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
1199 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
1198 | + if (strpos($module, '://') !== false) $module = basename($module); |
|
1199 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
1200 | 1200 | $repo = $matches[1]; |
1201 | 1201 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
1202 | 1202 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
@@ -1210,11 +1210,11 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | function do_svntag() |
1212 | 1212 | { |
1213 | - global $config,$svn; |
|
1213 | + global $config, $svn; |
|
1214 | 1214 | |
1215 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1215 | + if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
1216 | 1216 | |
1217 | - $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
1217 | + $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
1218 | 1218 | |
1219 | 1219 | echo "Creating SVN tag $config[svntag]\n"; |
1220 | 1220 | if (!isset($config['modules'])) |
@@ -1222,9 +1222,9 @@ discard block |
||
1222 | 1222 | get_modules_per_repo(); |
1223 | 1223 | } |
1224 | 1224 | // create tags (per repo) |
1225 | - foreach($config['modules'] as $repo => $modules) |
|
1225 | + foreach ($config['modules'] as $repo => $modules) |
|
1226 | 1226 | { |
1227 | - $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
1227 | + $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
1228 | 1228 | run_cmd($cmd); |
1229 | 1229 | } |
1230 | 1230 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
1238 | 1238 | * @return int exit code of $cmd |
1239 | 1239 | */ |
1240 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
1240 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
1241 | 1241 | { |
1242 | 1242 | global $verbose; |
1243 | 1243 | |
@@ -1245,18 +1245,18 @@ discard block |
||
1245 | 1245 | { |
1246 | 1246 | echo $cmd."\n"; |
1247 | 1247 | $ret = null; |
1248 | - system($cmd,$ret); |
|
1248 | + system($cmd, $ret); |
|
1249 | 1249 | } |
1250 | 1250 | else |
1251 | 1251 | { |
1252 | 1252 | $output[] = $cmd; |
1253 | - exec($cmd,$output,$ret); |
|
1254 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
1253 | + exec($cmd, $output, $ret); |
|
1254 | + if ($verbose) echo implode("\n", $output)."\n"; |
|
1255 | 1255 | } |
1256 | - if ($ret && !in_array($ret,(array)$no_bailout)) |
|
1256 | + if ($ret && !in_array($ret, (array)$no_bailout)) |
|
1257 | 1257 | { |
1258 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
1259 | - throw new Exception("Error during '$cmd' --> aborting",$ret); |
|
1258 | + if (!$verbose) echo implode("\n", $output)."\n"; |
|
1259 | + throw new Exception("Error during '$cmd' --> aborting", $ret); |
|
1260 | 1260 | } |
1261 | 1261 | return $ret; |
1262 | 1262 | } |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | return 'NULL'; |
1284 | 1284 | case 'object': |
1285 | 1285 | case 'array': |
1286 | - return str_replace(array("\n",' '/*,'Array'*/),'',print_r($var,true)); |
|
1286 | + return str_replace(array("\n", ' '/*,'Array'*/), '', print_r($var, true)); |
|
1287 | 1287 | } |
1288 | 1288 | return 'UNKNOWN TYPE!'; |
1289 | 1289 | } |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | * |
1294 | 1294 | * @param string $error =null optional error-message |
1295 | 1295 | */ |
1296 | -function usage($error=null) |
|
1296 | +function usage($error = null) |
|
1297 | 1297 | { |
1298 | - global $prog,$config,$verbose; |
|
1298 | + global $prog, $config, $verbose; |
|
1299 | 1299 | |
1300 | 1300 | echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n"; |
1301 | 1301 | echo "options and their defaults:\n"; |
@@ -1305,12 +1305,12 @@ discard block |
||
1305 | 1305 | } |
1306 | 1306 | else |
1307 | 1307 | { |
1308 | - unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
1308 | + unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
1309 | 1309 | } |
1310 | - foreach($config as $name => $default) |
|
1310 | + foreach ($config as $name => $default) |
|
1311 | 1311 | { |
1312 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
1313 | - echo '--'.str_pad($name,20).$default."\n"; |
|
1312 | + if (is_array($default)) $default = json_encode($default, JSON_UNESCAPED_SLASHES); |
|
1313 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
1314 | 1314 | } |
1315 | 1315 | if ($error) |
1316 | 1316 | { |