@@ -381,38 +381,38 @@ |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | - * Returns warnings that were encountered during importing |
|
385 | - * Maximum of one warning message per record, but you can append if you need to |
|
386 | - * |
|
387 | - * @return Array ( |
|
388 | - * record_# => warning message |
|
389 | - * ) |
|
390 | - */ |
|
391 | - public function get_warnings() { |
|
384 | + * Returns warnings that were encountered during importing |
|
385 | + * Maximum of one warning message per record, but you can append if you need to |
|
386 | + * |
|
387 | + * @return Array ( |
|
388 | + * record_# => warning message |
|
389 | + * ) |
|
390 | + */ |
|
391 | + public function get_warnings() { |
|
392 | 392 | return $this->warnings; |
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
396 | - * Returns errors that were encountered during importing |
|
397 | - * Maximum of one error message per record, but you can append if you need to |
|
398 | - * |
|
399 | - * @return Array ( |
|
400 | - * record_# => error message |
|
401 | - * ) |
|
402 | - */ |
|
403 | - public function get_errors() { |
|
396 | + * Returns errors that were encountered during importing |
|
397 | + * Maximum of one error message per record, but you can append if you need to |
|
398 | + * |
|
399 | + * @return Array ( |
|
400 | + * record_# => error message |
|
401 | + * ) |
|
402 | + */ |
|
403 | + public function get_errors() { |
|
404 | 404 | return $this->errors; |
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Returns a list of actions taken, and the number of records for that action. |
|
409 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
410 | - * |
|
411 | - * @return Array ( |
|
412 | - * action => record count |
|
413 | - * ) |
|
414 | - */ |
|
415 | - public function get_results() { |
|
416 | - return $this->results; |
|
417 | - } |
|
408 | + * Returns a list of actions taken, and the number of records for that action. |
|
409 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
410 | + * |
|
411 | + * @return Array ( |
|
412 | + * action => record count |
|
413 | + * ) |
|
414 | + */ |
|
415 | + public function get_results() { |
|
416 | + return $this->results; |
|
417 | + } |
|
418 | 418 | } |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * imports entries according to given definition object. |
55 | 55 | * @param resource $_stream |
56 | - * @param string $_charset |
|
57 | - * @param definition $_definition |
|
56 | + * @param importexport_definition $_definition |
|
58 | 57 | */ |
59 | 58 | public function import( $_stream, importexport_definition $_definition ) { |
60 | 59 | parent::import($_stream, $_definition); |
@@ -67,9 +66,7 @@ discard block |
||
67 | 66 | |
68 | 67 | /** |
69 | 68 | * imports entries according to given definition object. |
70 | - * @param resource $_stream |
|
71 | - * @param string $_charset |
|
72 | - * @param definition $_definition |
|
69 | + * @param importexport_definition $_definition |
|
73 | 70 | */ |
74 | 71 | public function init(importexport_definition &$_definition ) { |
75 | 72 |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for addressbook |
17 | 17 | */ |
18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * conditions for actions |
22 | 22 | * |
23 | 23 | * @var array |
24 | 24 | */ |
25 | - protected static $conditions = array( 'exists', 'equal' ); |
|
25 | + protected static $conditions = array('exists', 'equal'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var addressbook_bo |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param string $_charset |
57 | 57 | * @param definition $_definition |
58 | 58 | */ |
59 | - public function import( $_stream, importexport_definition $_definition ) { |
|
59 | + public function import($_stream, importexport_definition $_definition) { |
|
60 | 60 | parent::import($_stream, $_definition); |
61 | 61 | |
62 | - if($_definition->plugin_options['empty_addressbook']) |
|
62 | + if ($_definition->plugin_options['empty_addressbook']) |
|
63 | 63 | { |
64 | 64 | $this->empty_addressbook($this->user, $this->ids); |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $_charset |
72 | 72 | * @param definition $_definition |
73 | 73 | */ |
74 | - public function init(importexport_definition &$_definition ) { |
|
74 | + public function init(importexport_definition &$_definition) { |
|
75 | 75 | |
76 | 76 | // fetch the addressbook bo |
77 | 77 | $this->bocontacts = new addressbook_bo(); |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | $this->lookups = array( |
83 | 83 | 'tid' => array('n'=>'contact') |
84 | 84 | ); |
85 | - foreach($this->bocontacts->content_types as $tid => $data) |
|
85 | + foreach ($this->bocontacts->content_types as $tid => $data) |
|
86 | 86 | { |
87 | 87 | $this->lookups['tid'][$tid] = $data['name']; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Try and set a default type, for use if file does not specify |
91 | - if(!$this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 1 || |
|
91 | + if (!$this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 1 || |
|
92 | 92 | $this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 2) |
93 | 93 | { |
94 | 94 | reset($this->lookups['tid']); |
@@ -97,21 +97,21 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | // set contact owner |
100 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
100 | + $contact_owner = isset($_definition->plugin_options['contact_owner']) ? |
|
101 | 101 | $_definition->plugin_options['contact_owner'] : $this->user; |
102 | 102 | |
103 | 103 | // Check to make sure target addressbook is valid |
104 | - if(!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD)))) |
|
104 | + if (!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD)))) |
|
105 | 105 | { |
106 | 106 | $this->warnings[0] = lang("Unable to import into %1, using %2", |
107 | - $contact_owner . ' ('.Api\Accounts::username($record->owner) . ')', |
|
107 | + $contact_owner.' ('.Api\Accounts::username($record->owner).')', |
|
108 | 108 | Api\Accounts::username($this->user) |
109 | 109 | ); |
110 | 110 | $contact_owner = 'personal'; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Import into importer's personal addressbook |
114 | - if($contact_owner == 'personal') |
|
114 | + if ($contact_owner == 'personal') |
|
115 | 115 | { |
116 | 116 | $contact_owner = $this->user; |
117 | 117 | } |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | { |
133 | 133 | |
134 | 134 | // Set owner, unless it's supposed to come from CSV file |
135 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
136 | - if(!is_numeric($record->owner)) { |
|
135 | + if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
136 | + if (!is_numeric($record->owner)) { |
|
137 | 137 | // Automatically handle text owner without explicit translation |
138 | 138 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
139 | - if($new_owner == '') { |
|
139 | + if ($new_owner == '') { |
|
140 | 140 | $this->errors[$import_csv->get_current_position()] = lang( |
141 | 141 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
142 | 142 | $record->owner, |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | // Check that owner (addressbook) is allowed |
155 | - if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
155 | + if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
156 | 156 | { |
157 | 157 | $this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2", |
158 | 158 | Api\Accounts::username($record->owner), |
@@ -163,18 +163,18 @@ discard block |
||
163 | 163 | |
164 | 164 | // Do not allow owner == 0 (accounts) without an account_id |
165 | 165 | // It causes the contact to be filed as an account, and can't delete |
166 | - if(!$record->owner && !$record->account_id) |
|
166 | + if (!$record->owner && !$record->account_id) |
|
167 | 167 | { |
168 | 168 | $record->owner = $GLOBALS['egw_info']['user']['account_id']; |
169 | 169 | } |
170 | 170 | |
171 | 171 | // Do not import into non-existing type, warn and change |
172 | - if(!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
172 | + if (!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
173 | 173 | { |
174 | 174 | // Avoid lots of warnings about type (2 types are contact and deleted) |
175 | - if($record->tid && !$this->type_warned[$record->tid] && !$this->lookups['tid'][$record->tid] ) |
|
175 | + if ($record->tid && !$this->type_warned[$record->tid] && !$this->lookups['tid'][$record->tid]) |
|
176 | 176 | { |
177 | - $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n'])); |
|
177 | + $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n'])); |
|
178 | 178 | $this->type_warned[$record->tid] = true; |
179 | 179 | } |
180 | 180 | $record->tid = $this->default_type; |
@@ -183,45 +183,45 @@ discard block |
||
183 | 183 | // Also handle categories in their own field |
184 | 184 | $record_array = $record->get_record_array(); |
185 | 185 | $more_categories = array(); |
186 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
187 | - if(!array_key_exists($field_name, $record_array) || |
|
188 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
186 | + foreach ($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
187 | + if (!array_key_exists($field_name, $record_array) || |
|
188 | + substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
189 | 189 | list(, $cat_id) = explode('-', $field_name); |
190 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
190 | + if (is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
191 | 191 | // Column has a single category ID |
192 | 192 | $more_categories[] = $record->$field_name; |
193 | - } elseif($record->$field_name == '1' || |
|
193 | + } elseif ($record->$field_name == '1' || |
|
194 | 194 | (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
195 | 195 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
196 | 196 | $more_categories[] = $cat_id; |
197 | 197 | } else { |
198 | 198 | // Text categories |
199 | - $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
|
199 | + $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id)); |
|
200 | 200 | } |
201 | 201 | } |
202 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
202 | + if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories); |
|
203 | 203 | |
204 | 204 | // Private set but missing causes hidden entries |
205 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
205 | + if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
206 | 206 | |
207 | 207 | // Format birthday as backend requires - converter should give timestamp |
208 | - if($record->bday && is_numeric($record->bday)) |
|
208 | + if ($record->bday && is_numeric($record->bday)) |
|
209 | 209 | { |
210 | 210 | $time = new Api\DateTime($record->bday); |
211 | 211 | $record->bday = $time->format('Y-m-d'); |
212 | 212 | } |
213 | 213 | |
214 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
215 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
214 | + if ($this->definition->plugin_options['conditions']) { |
|
215 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
216 | 216 | $contacts = array(); |
217 | - switch ( $condition['type'] ) { |
|
217 | + switch ($condition['type']) { |
|
218 | 218 | // exists |
219 | 219 | case 'exists' : |
220 | - if($record_array[$condition['string']]) { |
|
221 | - $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
|
220 | + if ($record_array[$condition['string']]) { |
|
221 | + $searchcondition = array($condition['string'] => $record_array[$condition['string']]); |
|
222 | 222 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
223 | 223 | // enables Api\Contacts\Storage to decide what backend is to be used |
224 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
224 | + if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0; |
|
225 | 225 | $contacts = $this->bocontacts->search( |
226 | 226 | //array( $condition['string'] => $record[$condition['string']],), |
227 | 227 | '', |
@@ -230,37 +230,37 @@ discard block |
||
230 | 230 | $searchcondition |
231 | 231 | ); |
232 | 232 | } |
233 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
233 | + if (is_array($contacts) && count(array_keys($contacts)) >= 1) { |
|
234 | 234 | // apply action to all contacts matching this exists condition |
235 | 235 | $action = $condition['true']; |
236 | - foreach ( (array)$contacts as $contact ) { |
|
236 | + foreach ((array)$contacts as $contact) { |
|
237 | 237 | $record->id = $contact['id']; |
238 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
239 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
240 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
241 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
|
238 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
239 | + if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']); |
|
240 | + if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id); |
|
241 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id']))); |
|
242 | 242 | } |
243 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
243 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
244 | 244 | } |
245 | 245 | } else { |
246 | 246 | $action = $condition['false']; |
247 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
247 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
248 | 248 | } |
249 | 249 | break; |
250 | 250 | case 'equal': |
251 | 251 | // Match on field |
252 | 252 | $result = $this->equal($record, $condition); |
253 | - if($result) |
|
253 | + if ($result) |
|
254 | 254 | { |
255 | 255 | // Apply true action to any matching records found |
256 | 256 | $action = $condition['true']; |
257 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
257 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | 261 | // Apply false action if no matching records found |
262 | 262 | $action = $condition['false']; |
263 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
263 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
264 | 264 | } |
265 | 265 | break; |
266 | 266 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | } else { |
274 | 274 | // unconditional insert |
275 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
275 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
276 | 276 | } |
277 | 277 | return $success; |
278 | 278 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param importexport_iface_egw_record $record contact data for the action |
285 | 285 | * @return bool success or not |
286 | 286 | */ |
287 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
287 | + protected function action($_action, importexport_iface_egw_record &$record, $record_num = 0) { |
|
288 | 288 | $_data = $record->get_record_array(); |
289 | 289 | |
290 | 290 | // Make sure picture is loaded/updated |
291 | - if($_data['jpegphoto']) |
|
291 | + if ($_data['jpegphoto']) |
|
292 | 292 | { |
293 | 293 | $_data['photo_unchanged'] = false; |
294 | 294 | } |
@@ -297,15 +297,15 @@ discard block |
||
297 | 297 | case 'none' : |
298 | 298 | return true; |
299 | 299 | case 'delete': |
300 | - if($_data['id']) |
|
300 | + if ($_data['id']) |
|
301 | 301 | { |
302 | - if ( $this->dry_run ) { |
|
302 | + if ($this->dry_run) { |
|
303 | 303 | //print_r($_data); |
304 | 304 | $this->results[$_action]++; |
305 | 305 | return true; |
306 | 306 | } |
307 | 307 | $result = $this->bocontacts->delete($_data); |
308 | - if($result && $result === true) |
|
308 | + if ($result && $result === true) |
|
309 | 309 | { |
310 | 310 | $this->results[$_action]++; |
311 | 311 | } |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | // Only update if there are changes |
321 | 321 | $old = $this->bocontacts->read($_data['id']); |
322 | 322 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
323 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
324 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
|
323 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
324 | + if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) |
|
325 | 325 | $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
326 | 326 | } |
327 | 327 | // Don't change a user account into a contact |
328 | - if($old['owner'] == 0) { |
|
328 | + if ($old['owner'] == 0) { |
|
329 | 329 | unset($_data['owner']); |
330 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
330 | + } elseif (!$this->definition->plugin_options['change_owner']) { |
|
331 | 331 | // Don't change addressbook of an existing contact |
332 | 332 | unset($_data['owner']); |
333 | 333 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | // Merge to deal with fields not in import record |
338 | 338 | $_data = array_merge($old, $_data); |
339 | 339 | $changed = $this->tracking->changed_fields($_data, $old); |
340 | - if(count($changed) == 0) { |
|
340 | + if (count($changed) == 0) { |
|
341 | 341 | return true; |
342 | 342 | } else { |
343 | 343 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
@@ -348,22 +348,22 @@ discard block |
||
348 | 348 | |
349 | 349 | // Fall through |
350 | 350 | case 'insert' : |
351 | - if($_action == 'insert') { |
|
351 | + if ($_action == 'insert') { |
|
352 | 352 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
353 | 353 | unset($_data['id']); |
354 | 354 | } |
355 | - if(!isset($_data['org_name'])) { |
|
355 | + if (!isset($_data['org_name'])) { |
|
356 | 356 | // org_name is a trigger to update n_fileas |
357 | 357 | $_data['org_name'] = ''; |
358 | 358 | } |
359 | 359 | |
360 | - if ( $this->dry_run ) { |
|
360 | + if ($this->dry_run) { |
|
361 | 361 | //print_r($_data); |
362 | 362 | $this->results[$_action]++; |
363 | 363 | return true; |
364 | 364 | } else { |
365 | - $result = $this->bocontacts->save( $_data, $this->is_admin); |
|
366 | - if(!$result) { |
|
365 | + $result = $this->bocontacts->save($_data, $this->is_admin); |
|
366 | + if (!$result) { |
|
367 | 367 | $this->errors[$record_num] = $this->bocontacts->error; |
368 | 368 | } else { |
369 | 369 | $this->ids[] = $result; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | return $result; |
375 | 375 | } |
376 | 376 | default: |
377 | - throw new Api\Exception('Unsupported action: '. $_action); |
|
377 | + throw new Api\Exception('Unsupported action: '.$_action); |
|
378 | 378 | |
379 | 379 | } |
380 | 380 | } |
@@ -394,15 +394,15 @@ discard block |
||
394 | 394 | |
395 | 395 | $delete = array_diff($contacts, $ids); |
396 | 396 | |
397 | - foreach($delete as $id) |
|
397 | + foreach ($delete as $id) |
|
398 | 398 | { |
399 | - if($this->dry_run || $this->bocontacts->delete($id)) |
|
399 | + if ($this->dry_run || $this->bocontacts->delete($id)) |
|
400 | 400 | { |
401 | 401 | $this->results['deleted']++; |
402 | 402 | } |
403 | 403 | else |
404 | 404 | { |
405 | - $this->warnings[] = lang('Unable to delete') . ': ' . Api\Link::title('addressbook', $id); |
|
405 | + $this->warnings[] = lang('Unable to delete').': '.Api\Link::title('addressbook', $id); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * preserv => array, |
447 | 447 | * ) |
448 | 448 | */ |
449 | - public function get_options_etpl(importexport_definition &$definition=null) |
|
449 | + public function get_options_etpl(importexport_definition &$definition = null) |
|
450 | 450 | { |
451 | 451 | // lets do it! |
452 | 452 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for addressbook |
17 | 17 | */ |
18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * conditions for actions |
@@ -56,7 +57,8 @@ discard block |
||
56 | 57 | * @param string $_charset |
57 | 58 | * @param definition $_definition |
58 | 59 | */ |
59 | - public function import( $_stream, importexport_definition $_definition ) { |
|
60 | + public function import( $_stream, importexport_definition $_definition ) |
|
61 | + { |
|
60 | 62 | parent::import($_stream, $_definition); |
61 | 63 | |
62 | 64 | if($_definition->plugin_options['empty_addressbook']) |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | * @param string $_charset |
72 | 74 | * @param definition $_definition |
73 | 75 | */ |
74 | - public function init(importexport_definition &$_definition ) { |
|
76 | + public function init(importexport_definition &$_definition ) |
|
77 | + { |
|
75 | 78 | |
76 | 79 | // fetch the addressbook bo |
77 | 80 | $this->bocontacts = new addressbook_bo(); |
@@ -132,22 +135,29 @@ discard block |
||
132 | 135 | { |
133 | 136 | |
134 | 137 | // Set owner, unless it's supposed to come from CSV file |
135 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
136 | - if(!is_numeric($record->owner)) { |
|
138 | + if($this->definition->plugin_options['owner_from_csv'] && $record->owner) |
|
139 | + { |
|
140 | + if(!is_numeric($record->owner)) |
|
141 | + { |
|
137 | 142 | // Automatically handle text owner without explicit translation |
138 | 143 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
139 | - if($new_owner == '') { |
|
144 | + if($new_owner == '') |
|
145 | + { |
|
140 | 146 | $this->errors[$import_csv->get_current_position()] = lang( |
141 | 147 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
142 | 148 | $record->owner, |
143 | 149 | Api\Accounts::username($this->user) |
144 | 150 | ); |
145 | 151 | $record->owner = $this->user; |
146 | - } else { |
|
152 | + } |
|
153 | + else |
|
154 | + { |
|
147 | 155 | $record->owner = $new_owner; |
148 | 156 | } |
149 | 157 | } |
150 | - } else { |
|
158 | + } |
|
159 | + else |
|
160 | + { |
|
151 | 161 | $record->owner = $this->user; |
152 | 162 | } |
153 | 163 | |
@@ -183,26 +193,41 @@ discard block |
||
183 | 193 | // Also handle categories in their own field |
184 | 194 | $record_array = $record->get_record_array(); |
185 | 195 | $more_categories = array(); |
186 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
196 | + foreach($this->definition->plugin_options['field_mapping'] as $field_name) |
|
197 | + { |
|
187 | 198 | if(!array_key_exists($field_name, $record_array) || |
188 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
199 | + substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') |
|
200 | + { |
|
201 | + continue; |
|
202 | + } |
|
189 | 203 | list(, $cat_id) = explode('-', $field_name); |
190 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
204 | + if(is_numeric($record->$field_name) && $record->$field_name != 1) |
|
205 | + { |
|
191 | 206 | // Column has a single category ID |
192 | 207 | $more_categories[] = $record->$field_name; |
193 | - } elseif($record->$field_name == '1' || |
|
194 | - (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
|
208 | + } |
|
209 | + elseif($record->$field_name == '1' || |
|
210 | + (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) |
|
211 | + { |
|
195 | 212 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
196 | 213 | $more_categories[] = $cat_id; |
197 | - } else { |
|
214 | + } |
|
215 | + else |
|
216 | + { |
|
198 | 217 | // Text categories |
199 | 218 | $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
200 | 219 | } |
201 | 220 | } |
202 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
221 | + if(count($more_categories) > 0) |
|
222 | + { |
|
223 | + $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
224 | + } |
|
203 | 225 | |
204 | 226 | // Private set but missing causes hidden entries |
205 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
227 | + if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) |
|
228 | + { |
|
229 | + unset($record->private); |
|
230 | + } |
|
206 | 231 | |
207 | 232 | // Format birthday as backend requires - converter should give timestamp |
208 | 233 | if($record->bday && is_numeric($record->bday)) |
@@ -211,17 +236,24 @@ discard block |
||
211 | 236 | $record->bday = $time->format('Y-m-d'); |
212 | 237 | } |
213 | 238 | |
214 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
215 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
239 | + if ( $this->definition->plugin_options['conditions'] ) |
|
240 | + { |
|
241 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
242 | + { |
|
216 | 243 | $contacts = array(); |
217 | - switch ( $condition['type'] ) { |
|
244 | + switch ( $condition['type'] ) |
|
245 | + { |
|
218 | 246 | // exists |
219 | 247 | case 'exists' : |
220 | - if($record_array[$condition['string']]) { |
|
248 | + if($record_array[$condition['string']]) |
|
249 | + { |
|
221 | 250 | $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
222 | 251 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
223 | 252 | // enables Api\Contacts\Storage to decide what backend is to be used |
224 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
253 | + if ($condition['string']=='account_id') |
|
254 | + { |
|
255 | + $searchcondition['owner']=0; |
|
256 | + } |
|
225 | 257 | $contacts = $this->bocontacts->search( |
226 | 258 | //array( $condition['string'] => $record[$condition['string']],), |
227 | 259 | '', |
@@ -230,19 +262,30 @@ discard block |
||
230 | 262 | $searchcondition |
231 | 263 | ); |
232 | 264 | } |
233 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
265 | + if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) |
|
266 | + { |
|
234 | 267 | // apply action to all contacts matching this exists condition |
235 | 268 | $action = $condition['true']; |
236 | - foreach ( (array)$contacts as $contact ) { |
|
269 | + foreach ( (array)$contacts as $contact ) |
|
270 | + { |
|
237 | 271 | $record->id = $contact['id']; |
238 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
239 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
240 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
272 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
273 | + { |
|
274 | + if ( !is_array( $contact['cat_id'] ) ) |
|
275 | + { |
|
276 | + $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
277 | + } |
|
278 | + if ( !is_array( $record_array['cat_id'] ) ) |
|
279 | + { |
|
280 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
281 | + } |
|
241 | 282 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
242 | 283 | } |
243 | 284 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
244 | 285 | } |
245 | - } else { |
|
286 | + } |
|
287 | + else |
|
288 | + { |
|
246 | 289 | $action = $condition['false']; |
247 | 290 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
248 | 291 | } |
@@ -268,9 +311,14 @@ discard block |
||
268 | 311 | default : |
269 | 312 | die('condition / action not supported!!!'); |
270 | 313 | } |
271 | - if ($action['stop']) break; |
|
314 | + if ($action['stop']) |
|
315 | + { |
|
316 | + break; |
|
317 | + } |
|
272 | 318 | } |
273 | - } else { |
|
319 | + } |
|
320 | + else |
|
321 | + { |
|
274 | 322 | // unconditional insert |
275 | 323 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
276 | 324 | } |
@@ -284,7 +332,8 @@ discard block |
||
284 | 332 | * @param importexport_iface_egw_record $record contact data for the action |
285 | 333 | * @return bool success or not |
286 | 334 | */ |
287 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
335 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
336 | + { |
|
288 | 337 | $_data = $record->get_record_array(); |
289 | 338 | |
290 | 339 | // Make sure picture is loaded/updated |
@@ -293,13 +342,15 @@ discard block |
||
293 | 342 | $_data['photo_unchanged'] = false; |
294 | 343 | } |
295 | 344 | |
296 | - switch ($_action) { |
|
345 | + switch ($_action) |
|
346 | + { |
|
297 | 347 | case 'none' : |
298 | 348 | return true; |
299 | 349 | case 'delete': |
300 | 350 | if($_data['id']) |
301 | 351 | { |
302 | - if ( $this->dry_run ) { |
|
352 | + if ( $this->dry_run ) |
|
353 | + { |
|
303 | 354 | //print_r($_data); |
304 | 355 | $this->results[$_action]++; |
305 | 356 | return true; |
@@ -320,14 +371,20 @@ discard block |
||
320 | 371 | // Only update if there are changes |
321 | 372 | $old = $this->bocontacts->read($_data['id']); |
322 | 373 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
323 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
374 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
375 | + { |
|
324 | 376 | if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
325 | - $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
377 | + { |
|
378 | + $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
379 | + } |
|
326 | 380 | } |
327 | 381 | // Don't change a user account into a contact |
328 | - if($old['owner'] == 0) { |
|
382 | + if($old['owner'] == 0) |
|
383 | + { |
|
329 | 384 | unset($_data['owner']); |
330 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
385 | + } |
|
386 | + elseif(!$this->definition->plugin_options['change_owner']) |
|
387 | + { |
|
331 | 388 | // Don't change addressbook of an existing contact |
332 | 389 | unset($_data['owner']); |
333 | 390 | } |
@@ -337,9 +394,12 @@ discard block |
||
337 | 394 | // Merge to deal with fields not in import record |
338 | 395 | $_data = array_merge($old, $_data); |
339 | 396 | $changed = $this->tracking->changed_fields($_data, $old); |
340 | - if(count($changed) == 0) { |
|
397 | + if(count($changed) == 0) |
|
398 | + { |
|
341 | 399 | return true; |
342 | - } else { |
|
400 | + } |
|
401 | + else |
|
402 | + { |
|
343 | 403 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
344 | 404 | } |
345 | 405 | |
@@ -348,24 +408,32 @@ discard block |
||
348 | 408 | |
349 | 409 | // Fall through |
350 | 410 | case 'insert' : |
351 | - if($_action == 'insert') { |
|
411 | + if($_action == 'insert') |
|
412 | + { |
|
352 | 413 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
353 | 414 | unset($_data['id']); |
354 | 415 | } |
355 | - if(!isset($_data['org_name'])) { |
|
416 | + if(!isset($_data['org_name'])) |
|
417 | + { |
|
356 | 418 | // org_name is a trigger to update n_fileas |
357 | 419 | $_data['org_name'] = ''; |
358 | 420 | } |
359 | 421 | |
360 | - if ( $this->dry_run ) { |
|
422 | + if ( $this->dry_run ) |
|
423 | + { |
|
361 | 424 | //print_r($_data); |
362 | 425 | $this->results[$_action]++; |
363 | 426 | return true; |
364 | - } else { |
|
427 | + } |
|
428 | + else |
|
429 | + { |
|
365 | 430 | $result = $this->bocontacts->save( $_data, $this->is_admin); |
366 | - if(!$result) { |
|
431 | + if(!$result) |
|
432 | + { |
|
367 | 433 | $this->errors[$record_num] = $this->bocontacts->error; |
368 | - } else { |
|
434 | + } |
|
435 | + else |
|
436 | + { |
|
369 | 437 | $this->ids[] = $result; |
370 | 438 | $this->results[$_action]++; |
371 | 439 | // This does nothing (yet?) but update the identifier |
@@ -412,7 +480,8 @@ discard block |
||
412 | 480 | * |
413 | 481 | * @return string name |
414 | 482 | */ |
415 | - public static function get_name() { |
|
483 | + public static function get_name() |
|
484 | + { |
|
416 | 485 | return lang('Addressbook CSV import'); |
417 | 486 | } |
418 | 487 | |
@@ -421,7 +490,8 @@ discard block |
||
421 | 490 | * |
422 | 491 | * @return string descriprion |
423 | 492 | */ |
424 | - public static function get_description() { |
|
493 | + public static function get_description() |
|
494 | + { |
|
425 | 495 | return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators."); |
426 | 496 | } |
427 | 497 | |
@@ -430,7 +500,8 @@ discard block |
||
430 | 500 | * |
431 | 501 | * @return string suffix (comma seperated) |
432 | 502 | */ |
433 | - public static function get_filesuffix() { |
|
503 | + public static function get_filesuffix() |
|
504 | + { |
|
434 | 505 | return 'csv'; |
435 | 506 | } |
436 | 507 | |
@@ -456,7 +527,8 @@ discard block |
||
456 | 527 | * |
457 | 528 | * @return string etemplate name |
458 | 529 | */ |
459 | - public function get_selectors_etpl() { |
|
530 | + public function get_selectors_etpl() |
|
531 | + { |
|
460 | 532 | // lets do it! |
461 | 533 | } |
462 | 534 | |
@@ -468,7 +540,8 @@ discard block |
||
468 | 540 | * record_# => warning message |
469 | 541 | * ) |
470 | 542 | */ |
471 | - public function get_warnings() { |
|
543 | + public function get_warnings() |
|
544 | + { |
|
472 | 545 | return $this->warnings; |
473 | 546 | } |
474 | 547 | |
@@ -480,7 +553,8 @@ discard block |
||
480 | 553 | * record_# => error message |
481 | 554 | * ) |
482 | 555 | */ |
483 | - public function get_errors() { |
|
556 | + public function get_errors() |
|
557 | + { |
|
484 | 558 | return $this->errors; |
485 | 559 | } |
486 | 560 | |
@@ -492,7 +566,8 @@ discard block |
||
492 | 566 | * action => record count |
493 | 567 | * ) |
494 | 568 | */ |
495 | - public function get_results() { |
|
569 | + public function get_results() |
|
570 | + { |
|
496 | 571 | return $this->results; |
497 | 572 | } |
498 | 573 | } |
@@ -90,20 +90,20 @@ discard block |
||
90 | 90 | */ |
91 | 91 | var $clientProperties; |
92 | 92 | /** |
93 | - * Set Logging |
|
94 | - * |
|
95 | - * @var string |
|
96 | - * off = false; |
|
97 | - */ |
|
93 | + * Set Logging |
|
94 | + * |
|
95 | + * @var string |
|
96 | + * off = false; |
|
97 | + */ |
|
98 | 98 | var $log = false; |
99 | 99 | var $logfile="/tmp/log-vcard"; |
100 | 100 | /** |
101 | - * Constructor |
|
102 | - * |
|
103 | - * @param string $contact_app the current application |
|
104 | - * @param string $_contentType the content type (version) |
|
105 | - * @param array $_clientProperties client properties |
|
106 | - */ |
|
101 | + * Constructor |
|
102 | + * |
|
103 | + * @param string $contact_app the current application |
|
104 | + * @param string $_contentType the content type (version) |
|
105 | + * @param array $_clientProperties client properties |
|
106 | + */ |
|
107 | 107 | function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array()) |
108 | 108 | { |
109 | 109 | parent::__construct($contact_app); |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | $this->supportedFields = $this->databaseFields; |
127 | 127 | } |
128 | 128 | /** |
129 | - * import a vard into addressbook |
|
130 | - * |
|
131 | - * @param string $_vcard the vcard |
|
132 | - * @param int/string $_abID =null the internal addressbook id or !$_abID for a new enty |
|
133 | - * @param boolean $merge =false merge data with existing entry |
|
134 | - * @param string $charset The encoding charset for $text. Defaults to |
|
135 | - * utf-8 for new format, iso-8859-1 for old format. |
|
136 | - * @return int contact id |
|
137 | - */ |
|
129 | + * import a vard into addressbook |
|
130 | + * |
|
131 | + * @param string $_vcard the vcard |
|
132 | + * @param int/string $_abID =null the internal addressbook id or !$_abID for a new enty |
|
133 | + * @param boolean $merge =false merge data with existing entry |
|
134 | + * @param string $charset The encoding charset for $text. Defaults to |
|
135 | + * utf-8 for new format, iso-8859-1 for old format. |
|
136 | + * @return int contact id |
|
137 | + */ |
|
138 | 138 | function addVCard($_vcard, $_abID=null, $merge=false, $charset=null) |
139 | 139 | { |
140 | 140 | if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false; |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | $contact['id'] = $_abID; |
175 | 175 | } |
176 | 176 | else |
177 | - { |
|
178 | - if (is_array($contact['cat_id'])) |
|
177 | + { |
|
178 | + if (is_array($contact['cat_id'])) |
|
179 | 179 | { |
180 | 180 | $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
181 | 181 | } |
182 | - } |
|
183 | - if (isset($contact['owner']) && $contact['owner'] != $this->user) |
|
184 | - { |
|
185 | - $contact['private'] = 0; // foreign contacts are never private! |
|
186 | - } |
|
187 | - if ($this->log) |
|
182 | + } |
|
183 | + if (isset($contact['owner']) && $contact['owner'] != $this->user) |
|
184 | + { |
|
185 | + $contact['private'] = 0; // foreign contacts are never private! |
|
186 | + } |
|
187 | + if ($this->log) |
|
188 | 188 | { |
189 | 189 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
190 | 190 | array2string($contact)."\n",3,$this->logfile); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * return a vcard |
|
197 | - * |
|
198 | - * @param int/string $_id the id of the contact |
|
199 | - * @param string $_charset ='UTF-8' encoding of the vcard, default UTF-8 |
|
200 | - * @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it |
|
201 | - * @return string containing the vcard |
|
202 | - */ |
|
196 | + * return a vcard |
|
197 | + * |
|
198 | + * @param int/string $_id the id of the contact |
|
199 | + * @param string $_charset ='UTF-8' encoding of the vcard, default UTF-8 |
|
200 | + * @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it |
|
201 | + * @return string containing the vcard |
|
202 | + */ |
|
203 | 203 | function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true) |
204 | 204 | { |
205 | 205 | $vCard = new Horde_Icalendar_Vcard($this->version); |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
536 | - * Parses a string containing vCard data. |
|
537 | - * |
|
538 | - * @param string $_vcard The data to parse. |
|
539 | - * @param string $charset The encoding charset for $text. Defaults to |
|
540 | - * utf-8 for new format, iso-8859-1 for old format. |
|
541 | - * |
|
542 | - * @return array|boolean The contact data or false on errors. |
|
543 | - */ |
|
536 | + * Parses a string containing vCard data. |
|
537 | + * |
|
538 | + * @param string $_vcard The data to parse. |
|
539 | + * @param string $charset The encoding charset for $text. Defaults to |
|
540 | + * utf-8 for new format, iso-8859-1 for old format. |
|
541 | + * |
|
542 | + * @return array|boolean The contact data or false on errors. |
|
543 | + */ |
|
544 | 544 | function vcardtoegw($_vcard, $charset=null) |
545 | 545 | { |
546 | 546 | // the horde class does the charset conversion. DO NOT CONVERT HERE. |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | } |
800 | 800 | break; |
801 | 801 | case 'TEL;OTHER;VOICE': |
802 | - if (!in_array('TEL;OTHER', $rowNames) |
|
802 | + if (!in_array('TEL;OTHER', $rowNames) |
|
803 | 803 | && !isset($finalRowNames['TEL;OTHER'])) |
804 | 804 | { |
805 | 805 | $finalRowNames['TEL;OTHER'] = $vcardKey; |
@@ -137,7 +137,10 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function addVCard($_vcard, $_abID=null, $merge=false, $charset=null) |
139 | 139 | { |
140 | - if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false; |
|
140 | + if (!($contact = $this->vcardtoegw($_vcard, $charset))) |
|
141 | + { |
|
142 | + return false; |
|
143 | + } |
|
141 | 144 | |
142 | 145 | if ($_abID) |
143 | 146 | { |
@@ -174,9 +177,9 @@ discard block |
||
174 | 177 | $contact['id'] = $_abID; |
175 | 178 | } |
176 | 179 | else |
177 | - { |
|
180 | + { |
|
178 | 181 | if (is_array($contact['cat_id'])) |
179 | - { |
|
182 | + { |
|
180 | 183 | $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
181 | 184 | } |
182 | 185 | } |
@@ -185,7 +188,7 @@ discard block |
||
185 | 188 | $contact['private'] = 0; // foreign contacts are never private! |
186 | 189 | } |
187 | 190 | if ($this->log) |
188 | - { |
|
191 | + { |
|
189 | 192 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
190 | 193 | array2string($contact)."\n",3,$this->logfile); |
191 | 194 | } |
@@ -331,9 +334,12 @@ discard block |
||
331 | 334 | break; |
332 | 335 | |
333 | 336 | case 'cat_id': |
334 | - if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//) |
|
337 | + if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value))) |
|
338 | + { |
|
339 | + //) |
|
335 | 340 | { |
336 | 341 | $values = (array) Api\Translation::convert($values, $sysCharSet, $_charset); |
342 | + } |
|
337 | 343 | $value = implode(',', $values); // just for the CHARSET recognition |
338 | 344 | if (($size > 0) && strlen($value) > $size) |
339 | 345 | { |
@@ -386,8 +392,14 @@ discard block |
||
386 | 392 | if (isset($this->supportedFields['X-ABSHOWAS']) && |
387 | 393 | $entry['org_name'] == $entry['n_fileas'] && $entry['fileas_type'] == 'org_name') |
388 | 394 | { |
389 | - if ($vcardField == 'X-ABSHOWAS') $value = 'COMPANY'; |
|
390 | - if ($databaseField == 'n_fn') $value = $entry['org_name']; |
|
395 | + if ($vcardField == 'X-ABSHOWAS') |
|
396 | + { |
|
397 | + $value = 'COMPANY'; |
|
398 | + } |
|
399 | + if ($databaseField == 'n_fn') |
|
400 | + { |
|
401 | + $value = $entry['org_name']; |
|
402 | + } |
|
391 | 403 | } |
392 | 404 | //error_log("vcardField='$vcardField', databaseField='$databaseField', this->supportedFields['X-ABSHOWAS']=".array2string($this->supportedFields['X-ABSHOWAS'])." --> value='$value'"); |
393 | 405 | // fall-through |
@@ -524,12 +536,18 @@ discard block |
||
524 | 536 | $this->productManufacturer = strtolower($_productManufacturer); |
525 | 537 | $this->productName = strtolower($_productName); |
526 | 538 | |
527 | - if (is_array($_supportedFields)) $this->supportedFields = $_supportedFields; |
|
539 | + if (is_array($_supportedFields)) |
|
540 | + { |
|
541 | + $this->supportedFields = $_supportedFields; |
|
542 | + } |
|
528 | 543 | } |
529 | 544 | |
530 | 545 | function setDatabaseFields($_databaseFields) |
531 | 546 | { |
532 | - if (is_array($_databaseFields)) $this->databaseFields = $_databaseFields; |
|
547 | + if (is_array($_databaseFields)) |
|
548 | + { |
|
549 | + $this->databaseFields = $_databaseFields; |
|
550 | + } |
|
533 | 551 | } |
534 | 552 | |
535 | 553 | /** |
@@ -681,7 +699,10 @@ discard block |
||
681 | 699 | case 'VOICE': |
682 | 700 | case 'OTHER': |
683 | 701 | case 'CELL': |
684 | - if ($rowName != 'TEL') break; |
|
702 | + if ($rowName != 'TEL') |
|
703 | + { |
|
704 | + break; |
|
705 | + } |
|
685 | 706 | case 'WORK': |
686 | 707 | case 'HOME': |
687 | 708 | $rowName .= ';' . $pname; |
@@ -801,7 +822,7 @@ discard block |
||
801 | 822 | case 'TEL;OTHER;VOICE': |
802 | 823 | if (!in_array('TEL;OTHER', $rowNames) |
803 | 824 | && !isset($finalRowNames['TEL;OTHER'])) |
804 | - { |
|
825 | + { |
|
805 | 826 | $finalRowNames['TEL;OTHER'] = $vcardKey; |
806 | 827 | } |
807 | 828 | break; |
@@ -924,7 +945,10 @@ discard block |
||
924 | 945 | { |
925 | 946 | foreach($fields as $field) |
926 | 947 | { |
927 | - if ($field != 'fileas_type') $contact[$field] = null; |
|
948 | + if ($field != 'fileas_type') |
|
949 | + { |
|
950 | + $contact[$field] = null; |
|
951 | + } |
|
928 | 952 | } |
929 | 953 | } |
930 | 954 | |
@@ -982,7 +1006,8 @@ discard block |
||
982 | 1006 | break; |
983 | 1007 | |
984 | 1008 | case 'uid': |
985 | - if (strlen($value) < $minimum_uid_length) { |
|
1009 | + if (strlen($value) < $minimum_uid_length) |
|
1010 | + { |
|
986 | 1011 | // we don't use it |
987 | 1012 | break; |
988 | 1013 | } |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @var array |
39 | 39 | */ |
40 | 40 | var $databaseFields = array( // all entries e.g. for CardDAV |
41 | - 'ADR;WORK' => array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region', |
|
42 | - 'adr_one_postalcode','adr_one_countryname'), |
|
43 | - 'ADR;HOME' => array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region', |
|
44 | - 'adr_two_postalcode','adr_two_countryname'), |
|
41 | + 'ADR;WORK' => array('', 'adr_one_street2', 'adr_one_street', 'adr_one_locality', 'adr_one_region', |
|
42 | + 'adr_one_postalcode', 'adr_one_countryname'), |
|
43 | + 'ADR;HOME' => array('', 'adr_two_street2', 'adr_two_street', 'adr_two_locality', 'adr_two_region', |
|
44 | + 'adr_two_postalcode', 'adr_two_countryname'), |
|
45 | 45 | 'BDAY' => array('bday'), |
46 | 46 | 'CLASS' => array('private'), |
47 | 47 | 'CATEGORIES' => array('cat_id'), |
48 | 48 | 'EMAIL;WORK' => array('email'), |
49 | 49 | 'EMAIL;HOME' => array('email_home'), |
50 | - 'N' => array('n_family','n_given','n_middle', |
|
51 | - 'n_prefix','n_suffix'), |
|
50 | + 'N' => array('n_family', 'n_given', 'n_middle', |
|
51 | + 'n_prefix', 'n_suffix'), |
|
52 | 52 | 'FN' => array('n_fn'), |
53 | 53 | 'NOTE' => array('note'), |
54 | - 'ORG' => array('org_name','org_unit','room'), |
|
54 | + 'ORG' => array('org_name', 'org_unit', 'room'), |
|
55 | 55 | 'TEL;CELL;WORK' => array('tel_cell'), |
56 | 56 | 'TEL;CELL;HOME' => array('tel_cell_private'), |
57 | 57 | 'TEL;CAR' => array('tel_car'), |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * off = false; |
99 | 99 | */ |
100 | 100 | var $log = false; |
101 | - var $logfile="/tmp/log-vcard"; |
|
101 | + var $logfile = "/tmp/log-vcard"; |
|
102 | 102 | /** |
103 | 103 | * Constructor |
104 | 104 | * |
@@ -106,16 +106,16 @@ discard block |
||
106 | 106 | * @param string $_contentType the content type (version) |
107 | 107 | * @param array $_clientProperties client properties |
108 | 108 | */ |
109 | - function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array()) |
|
109 | + function __construct($contact_app = 'addressbook', $_contentType = 'text/x-vcard', &$_clientProperties = array()) |
|
110 | 110 | { |
111 | 111 | parent::__construct($contact_app); |
112 | 112 | if ($this->log) |
113 | 113 | { |
114 | 114 | $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcard"; |
115 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
116 | - array2string($_contentType)."\n",3,$this->logfile); |
|
115 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
116 | + array2string($_contentType)."\n", 3, $this->logfile); |
|
117 | 117 | } |
118 | - switch($_contentType) |
|
118 | + switch ($_contentType) |
|
119 | 119 | { |
120 | 120 | case 'text/vcard': |
121 | 121 | $this->version = '3.0'; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * utf-8 for new format, iso-8859-1 for old format. |
138 | 138 | * @return int contact id |
139 | 139 | */ |
140 | - function addVCard($_vcard, $_abID=null, $merge=false, $charset=null) |
|
140 | + function addVCard($_vcard, $_abID = null, $merge = false, $charset = null) |
|
141 | 141 | { |
142 | 142 | if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false; |
143 | 143 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | if (is_array($contact['cat_id'])) |
165 | 165 | { |
166 | - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID)); |
|
166 | + $contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], $_abID)); |
|
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | { |
180 | 180 | if (is_array($contact['cat_id'])) |
181 | 181 | { |
182 | - $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1)); |
|
182 | + $contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], -1)); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | if (isset($contact['owner']) && $contact['owner'] != $this->user) |
186 | 186 | { |
187 | - $contact['private'] = 0; // foreign contacts are never private! |
|
187 | + $contact['private'] = 0; // foreign contacts are never private! |
|
188 | 188 | } |
189 | 189 | if ($this->log) |
190 | 190 | { |
191 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
192 | - array2string($contact)."\n",3,$this->logfile); |
|
191 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
192 | + array2string($contact)."\n", 3, $this->logfile); |
|
193 | 193 | } |
194 | 194 | return $this->save($contact); |
195 | 195 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it |
203 | 203 | * @return string containing the vcard |
204 | 204 | */ |
205 | - function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true) |
|
205 | + function getVCard($_id, $_charset = 'UTF-8', $extra_charset_attribute = true) |
|
206 | 206 | { |
207 | 207 | $vCard = new Horde_Icalendar_Vcard($this->version); |
208 | - $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'. |
|
208 | + $vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'. |
|
209 | 209 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
210 | 210 | |
211 | 211 | $sysCharSet = Api\Translation::charset(); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | if (!$oval && ($this->version == '3.0')) |
240 | 240 | { |
241 | 241 | // declare OPTION as TYPE=OPTION |
242 | - $options['TYPE'][] = $oname ; |
|
242 | + $options['TYPE'][] = $oname; |
|
243 | 243 | } |
244 | 244 | else |
245 | 245 | { |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $noTruncate = $this->clientProperties[$vcardField]['NoTruncate']; |
260 | 260 | if ($this->log && $size > 0) |
261 | 261 | { |
262 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
263 | - "() $vcardField Size: $size, NoTruncate: " . |
|
264 | - ($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile); |
|
262 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
263 | + "() $vcardField Size: $size, NoTruncate: ". |
|
264 | + ($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile); |
|
265 | 265 | } |
266 | 266 | //Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " . |
267 | 267 | // ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | switch ($databaseField) |
284 | 284 | { |
285 | 285 | case 'modified': |
286 | - $value = gmdate("Y-m-d\TH:i:s\Z",Api\DateTime::user2server($value)); |
|
286 | + $value = gmdate("Y-m-d\TH:i:s\Z", Api\DateTime::user2server($value)); |
|
287 | 287 | $hasdata++; |
288 | 288 | break; |
289 | 289 | |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | { |
298 | 298 | if ($size == 8) |
299 | 299 | { |
300 | - $value = str_replace('-','',$value); |
|
300 | + $value = str_replace('-', '', $value); |
|
301 | 301 | } |
302 | 302 | elseif (isset($options['TYPE']) && ( |
303 | 303 | $options['TYPE'] == 'BASIC')) |
304 | 304 | { |
305 | 305 | unset($options['TYPE']); |
306 | 306 | // used by old SyncML implementations |
307 | - $value = str_replace('-','',$value).'T000000Z'; |
|
307 | + $value = str_replace('-', '', $value).'T000000Z'; |
|
308 | 308 | } |
309 | 309 | $hasdata++; |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | |
313 | 313 | case 'jpegphoto': |
314 | - if (empty($value) && ($entry['files'] & Api\Contacts::FILES_BIT_PHOTO)) |
|
314 | + if (empty($value) && ($entry['files']&Api\Contacts::FILES_BIT_PHOTO)) |
|
315 | 315 | { |
316 | 316 | $value = file_get_contents(Api\Link::vfs_path('addressbook', $entry['id'], Api\Contacts::FILES_PHOTO)); |
317 | 317 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | case 'cat_id': |
352 | 352 | if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//) |
353 | 353 | { |
354 | - $values = (array) Api\Translation::convert($values, $sysCharSet, $_charset); |
|
354 | + $values = (array)Api\Translation::convert($values, $sysCharSet, $_charset); |
|
355 | 355 | $value = implode(',', $values); // just for the CHARSET recognition |
356 | 356 | if (($size > 0) && strlen($value) > $size) |
357 | 357 | { |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | { |
362 | 362 | if ($this->log) |
363 | 363 | { |
364 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
365 | - "() $vcardField omitted due to maximum size $size\n",3,$this->logfile); |
|
364 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
365 | + "() $vcardField omitted due to maximum size $size\n", 3, $this->logfile); |
|
366 | 366 | } |
367 | 367 | // Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size", |
368 | 368 | // __FILE__, __LINE__, PEAR_LOG_WARNING); |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | // fall-through |
412 | 412 | |
413 | 413 | default: |
414 | - if (($size > 0) && strlen(implode(',', $values) . $value) > $size) |
|
414 | + if (($size > 0) && strlen(implode(',', $values).$value) > $size) |
|
415 | 415 | { |
416 | 416 | if ($noTruncate) |
417 | 417 | { |
418 | 418 | if ($this->log) |
419 | 419 | { |
420 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
421 | - "() $vcardField omitted due to maximum size $size\n",3,$this->logfile); |
|
420 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
421 | + "() $vcardField omitted due to maximum size $size\n", 3, $this->logfile); |
|
422 | 422 | } |
423 | 423 | // Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size", |
424 | 424 | // __FILE__, __LINE__, PEAR_LOG_WARNING); |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | } |
438 | 438 | if ($this->log) |
439 | 439 | { |
440 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
441 | - "() $vcardField truncated to maximum size $size\n",3,$this->logfile); |
|
440 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
441 | + "() $vcardField truncated to maximum size $size\n", 3, $this->logfile); |
|
442 | 442 | } |
443 | 443 | //Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size", |
444 | 444 | // __FILE__, __LINE__, PEAR_LOG_INFO); |
445 | 445 | } |
446 | 446 | if (!empty($value) // required field |
447 | - || in_array($vcardField,array('FN','ORG','N')) |
|
447 | + || in_array($vcardField, array('FN', 'ORG', 'N')) |
|
448 | 448 | || ($size >= 0 && !$noTruncate)) |
449 | 449 | { |
450 | 450 | $value = Api\Translation::convert(trim($value), $sysCharSet, $_charset); |
@@ -509,15 +509,15 @@ discard block |
||
509 | 509 | |
510 | 510 | if ($this->log) |
511 | 511 | { |
512 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
513 | - "() '$this->productManufacturer','$this->productName'\n",3,$this->logfile); |
|
514 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
515 | - array2string($result)."\n",3,$this->logfile); |
|
512 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
513 | + "() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile); |
|
514 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
515 | + array2string($result)."\n", 3, $this->logfile); |
|
516 | 516 | } |
517 | 517 | return $result; |
518 | 518 | } |
519 | 519 | |
520 | - function search($_vcard, $contentID=null, $relax=false, $charset=null) |
|
520 | + function search($_vcard, $contentID = null, $relax = false, $charset = null) |
|
521 | 521 | { |
522 | 522 | $result = array(); |
523 | 523 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | { |
526 | 526 | if (is_array($contact['category'])) |
527 | 527 | { |
528 | - $contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], |
|
528 | + $contact['category'] = implode(',', $this->find_or_add_categories($contact['category'], |
|
529 | 529 | $contentID ? $contentID : -1)); |
530 | 530 | } |
531 | 531 | if ($contentID) |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | return $result; |
538 | 538 | } |
539 | 539 | |
540 | - function setSupportedFields($_productManufacturer='file', $_productName='', $_supportedFields = null) |
|
540 | + function setSupportedFields($_productManufacturer = 'file', $_productName = '', $_supportedFields = null) |
|
541 | 541 | { |
542 | 542 | $this->productManufacturer = strtolower($_productManufacturer); |
543 | 543 | $this->productName = strtolower($_productName); |
@@ -559,18 +559,18 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return array|boolean The contact data or false on errors. |
561 | 561 | */ |
562 | - function vcardtoegw($_vcard, $charset=null) |
|
562 | + function vcardtoegw($_vcard, $charset = null) |
|
563 | 563 | { |
564 | 564 | // the horde class does the charset conversion. DO NOT CONVERT HERE. |
565 | 565 | // be as flexible as possible |
566 | 566 | |
567 | 567 | if ($this->log) |
568 | 568 | { |
569 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
570 | - array2string($_vcard)."\n",3,$this->logfile); |
|
569 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
570 | + array2string($_vcard)."\n", 3, $this->logfile); |
|
571 | 571 | } |
572 | 572 | |
573 | - if(!($_vcard instanceof Horde_Icalendar)) |
|
573 | + if (!($_vcard instanceof Horde_Icalendar)) |
|
574 | 574 | { |
575 | 575 | $container = false; |
576 | 576 | $vCard = Horde_Icalendar::newComponent('vcard', $container); |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | $pref_tel = false; |
612 | 612 | |
613 | 613 | $rowNames = array(); |
614 | - foreach($vcardValues as $key => $vcardRow) |
|
614 | + foreach ($vcardValues as $key => $vcardRow) |
|
615 | 615 | { |
616 | - $rowName = strtoupper($vcardRow['name']); |
|
617 | - if ($vcardRow['value'] == '' && implode('', $vcardRow['values']) == '') |
|
616 | + $rowName = strtoupper($vcardRow['name']); |
|
617 | + if ($vcardRow['value'] == '' && implode('', $vcardRow['values']) == '') |
|
618 | 618 | { |
619 | 619 | unset($vcardRow); |
620 | 620 | continue; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | switch ($pname) |
690 | 690 | { |
691 | 691 | case 'PREF': |
692 | - if (substr($rowName,0,3) == 'TEL' && !$pref_tel) |
|
692 | + if (substr($rowName, 0, 3) == 'TEL' && !$pref_tel) |
|
693 | 693 | { |
694 | 694 | $pref_tel = $key; |
695 | 695 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | if ($rowName != 'TEL') break; |
703 | 703 | case 'WORK': |
704 | 704 | case 'HOME': |
705 | - $rowName .= ';' . $pname; |
|
705 | + $rowName .= ';'.$pname; |
|
706 | 706 | break; |
707 | 707 | case 'CAR': |
708 | 708 | case 'X-CUSTOMLABEL-CAR': |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | if (strpos($pname, 'X-FUNAMBOL-') === 0) |
723 | 723 | { |
724 | 724 | // Propriatary Funambol extension will be ignored |
725 | - $rowName .= ';' . $pname; |
|
725 | + $rowName .= ';'.$pname; |
|
726 | 726 | } |
727 | 727 | break; |
728 | 728 | } |
@@ -730,39 +730,39 @@ discard block |
||
730 | 730 | |
731 | 731 | if ($rowName == 'EMAIL') |
732 | 732 | { |
733 | - $rowName .= ';X-egw-Ref' . $email++; |
|
733 | + $rowName .= ';X-egw-Ref'.$email++; |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | if (($rowName == 'TEL;CELL') || |
737 | 737 | ($rowName == 'TEL;CELL;VOICE')) |
738 | 738 | { |
739 | - $rowName = 'TEL;CELL;X-egw-Ref' . $cell++; |
|
739 | + $rowName = 'TEL;CELL;X-egw-Ref'.$cell++; |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | if (($rowName == 'TEL') || |
743 | 743 | ($rowName == 'TEL;VOICE')) |
744 | 744 | { |
745 | - $rowName = 'TEL;X-egw-Ref' . $tel++; |
|
745 | + $rowName = 'TEL;X-egw-Ref'.$tel++; |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | if ($rowName == 'URL') |
749 | 749 | { |
750 | - $rowName = 'URL;X-egw-Ref' . $url++; |
|
750 | + $rowName = 'URL;X-egw-Ref'.$url++; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | // current algorithm cant cope with multiple attributes of same name |
754 | 754 | // --> cumulate them in values, so they can be used later (works only for values, not for parameters!) |
755 | 755 | if (($k = array_search($rowName, $rowNames)) != false) |
756 | 756 | { |
757 | - $vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'],$vcardValues[$key]['values']); |
|
757 | + $vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'], $vcardValues[$key]['values']); |
|
758 | 758 | } |
759 | 759 | $rowNames[$key] = $rowName; |
760 | 760 | } |
761 | 761 | |
762 | 762 | if ($this->log) |
763 | 763 | { |
764 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
765 | - array2string($rowNames)."\n",3,$this->logfile); |
|
764 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
765 | + array2string($rowNames)."\n", 3, $this->logfile); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | // All rowNames of the vCard are now concatenated with their qualifiers. |
@@ -932,15 +932,15 @@ discard block |
||
932 | 932 | |
933 | 933 | if ($this->log) |
934 | 934 | { |
935 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
936 | - array2string($finalRowNames)."\n",3,$this->logfile); |
|
935 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
936 | + array2string($finalRowNames)."\n", 3, $this->logfile); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | $contact = array(); |
940 | 940 | // to be able to delete fields, we have to set all supported fields to at least null |
941 | - foreach($this->supportedFields as $fields) |
|
941 | + foreach ($this->supportedFields as $fields) |
|
942 | 942 | { |
943 | - foreach($fields as $field) |
|
943 | + foreach ($fields as $field) |
|
944 | 944 | { |
945 | 945 | if ($field != 'fileas_type') $contact[$field] = null; |
946 | 946 | } |
@@ -963,16 +963,16 @@ discard block |
||
963 | 963 | { |
964 | 964 | $contact['tel_prefer'] = $fieldName; |
965 | 965 | } |
966 | - switch($fieldName) |
|
966 | + switch ($fieldName) |
|
967 | 967 | { |
968 | 968 | case 'bday': |
969 | - $contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'] . |
|
970 | - '-' . $vcardValues[$vcardKey]['value']['month'] . |
|
971 | - '-' . $vcardValues[$vcardKey]['value']['mday']; |
|
969 | + $contact[$fieldName] = $vcardValues[$vcardKey]['value']['year']. |
|
970 | + '-'.$vcardValues[$vcardKey]['value']['month']. |
|
971 | + '-'.$vcardValues[$vcardKey]['value']['mday']; |
|
972 | 972 | break; |
973 | 973 | |
974 | 974 | case 'private': |
975 | - $contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE'); |
|
975 | + $contact[$fieldName] = (int)(strtoupper($value) == 'PRIVATE'); |
|
976 | 976 | break; |
977 | 977 | |
978 | 978 | case 'cat_id': |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | |
982 | 982 | case 'jpegphoto': |
983 | 983 | $contact[$fieldName] = $vcardValues[$vcardKey]['value']; |
984 | - if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64'))) |
|
984 | + if (in_array($vcardValues[$vcardKey]['params']['ENCODING'], array('b', 'B', 'BASE64'))) |
|
985 | 985 | { |
986 | 986 | $contact[$fieldName] = base64_decode($contact[$fieldName]); |
987 | 987 | } |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | |
990 | 990 | case 'pubkey': |
991 | 991 | $content = $vcardValues[$vcardKey]['value']; |
992 | - if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64'))) |
|
992 | + if (in_array($vcardValues[$vcardKey]['params']['ENCODING'], array('b', 'B', 'BASE64'))) |
|
993 | 993 | { |
994 | 994 | $content = base64_decode($content); |
995 | 995 | } |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | // add unsupported attributes as with '##' prefix |
1028 | - elseif(($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'],array('PRODID','REV'))) |
|
1028 | + elseif (($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'], array('PRODID', 'REV'))) |
|
1029 | 1029 | { |
1030 | 1030 | // for attributes with multiple values in multiple lines, merge the values |
1031 | 1031 | if (isset($contact['##'.$attribute['name']])) |
@@ -1044,10 +1044,10 @@ discard block |
||
1044 | 1044 | |
1045 | 1045 | if ($this->log) |
1046 | 1046 | { |
1047 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . |
|
1048 | - "() '$this->productManufacturer','$this->productName'\n",3,$this->logfile); |
|
1049 | - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . |
|
1050 | - array2string($contact)."\n",3,$this->logfile); |
|
1047 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
|
1048 | + "() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile); |
|
1049 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n". |
|
1050 | + array2string($contact)."\n", 3, $this->logfile); |
|
1051 | 1051 | } |
1052 | 1052 | return $contact; |
1053 | 1053 | } |
@@ -1058,14 +1058,14 @@ discard block |
||
1058 | 1058 | * @param array $ids contact-ids |
1059 | 1059 | * @param string $file filename or null for download |
1060 | 1060 | */ |
1061 | - function export($ids, $file=null) |
|
1061 | + function export($ids, $file = null) |
|
1062 | 1062 | { |
1063 | 1063 | if (!$file) |
1064 | 1064 | { |
1065 | - $filename = count($ids) == 1 ? Link::title('addressbook',$ids[0]): 'egw_addressbook_'.date('Y-m-d'); |
|
1066 | - Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf','text/x-vcard'); |
|
1065 | + $filename = count($ids) == 1 ? Link::title('addressbook', $ids[0]) : 'egw_addressbook_'.date('Y-m-d'); |
|
1066 | + Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf', 'text/x-vcard'); |
|
1067 | 1067 | } |
1068 | - if (!($fp = fopen($file ? $file : 'php://output','w'))) |
|
1068 | + if (!($fp = fopen($file ? $file : 'php://output', 'w'))) |
|
1069 | 1069 | { |
1070 | 1070 | return false; |
1071 | 1071 | } |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | } |
1080 | 1080 | foreach ($ids as $id) |
1081 | 1081 | { |
1082 | - fwrite($fp,$this->getVCard($id, $charset)); |
|
1082 | + fwrite($fp, $this->getVCard($id, $charset)); |
|
1083 | 1083 | } |
1084 | 1084 | fclose($fp); |
1085 | 1085 | |
@@ -1097,22 +1097,22 @@ discard block |
||
1097 | 1097 | * @param string $version ='3.0' vcard version |
1098 | 1098 | * @return string containing the vcard |
1099 | 1099 | */ |
1100 | - function getGroupVCard(array $list,$version='3.0') |
|
1100 | + function getGroupVCard(array $list, $version = '3.0') |
|
1101 | 1101 | { |
1102 | 1102 | $vCard = new Horde_Icalendar_Vcard($version); |
1103 | - $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'. |
|
1103 | + $vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'. |
|
1104 | 1104 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
1105 | 1105 | |
1106 | - $vCard->setAttribute('N',$list['list_name'],array(),true,array($list['list_name'],'','','','')); |
|
1107 | - $vCard->setAttribute('FN',$list['list_name']); |
|
1106 | + $vCard->setAttribute('N', $list['list_name'], array(), true, array($list['list_name'], '', '', '', '')); |
|
1107 | + $vCard->setAttribute('FN', $list['list_name']); |
|
1108 | 1108 | |
1109 | - $vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND','group'); |
|
1110 | - foreach($list['members'] as $uid) |
|
1109 | + $vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND', 'group'); |
|
1110 | + foreach ($list['members'] as $uid) |
|
1111 | 1111 | { |
1112 | - $vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER','urn:uuid:'.$uid); |
|
1112 | + $vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER', 'urn:uuid:'.$uid); |
|
1113 | 1113 | } |
1114 | - $vCard->setAttribute('REV',Api\DateTime::to($list['list_modified'],'Y-m-d\TH:i:s\Z')); |
|
1115 | - $vCard->setAttribute('UID',$list['list_uid']); |
|
1114 | + $vCard->setAttribute('REV', Api\DateTime::to($list['list_modified'], 'Y-m-d\TH:i:s\Z')); |
|
1115 | + $vCard->setAttribute('UID', $list['list_uid']); |
|
1116 | 1116 | |
1117 | 1117 | return $vCard->exportvCalendar(); |
1118 | 1118 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param string $id folder id |
278 | 278 | * @param int $cutoffdate =null |
279 | 279 | * @return array |
280 | - */ |
|
280 | + */ |
|
281 | 281 | function GetMessageList($id, $cutoffdate=NULL) |
282 | 282 | { |
283 | 283 | unset($cutoffdate); // not used, but required by function signature |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
379 | 379 | if (!empty($contact[$attr])) |
380 | 380 | { |
381 | - $tz = date_default_timezone_get(); |
|
382 | - date_default_timezone_set('UTC'); |
|
383 | - $message->birthday = strtotime($contact[$attr]); |
|
384 | - date_default_timezone_set($tz); |
|
381 | + $tz = date_default_timezone_get(); |
|
382 | + date_default_timezone_set('UTC'); |
|
383 | + $message->birthday = strtotime($contact[$attr]); |
|
384 | + date_default_timezone_set($tz); |
|
385 | 385 | } |
386 | 386 | break; |
387 | 387 | |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * @param $folderid of the current folder |
635 | 635 | * @param $id of the message |
636 | 636 | * @param $newfolderid |
637 | - * @param ContentParameters $contentParameters |
|
637 | + * @param ContentParameters $contentParameters |
|
638 | 638 | * |
639 | 639 | * @return $newid as a string | boolean false on error |
640 | 640 | * |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @param $folderid |
664 | 664 | * @param $id |
665 | - * @param ContentParameters $contentParameters |
|
665 | + * @param ContentParameters $contentParameters |
|
666 | 666 | * |
667 | 667 | * @return boolean true on success, false on error, diffbackend does NOT use the returnvalue |
668 | 668 | * |
@@ -681,23 +681,23 @@ discard block |
||
681 | 681 | return $ret; |
682 | 682 | } |
683 | 683 | |
684 | - /** |
|
685 | - * Changes the 'read' flag of a message on disk. The $flags |
|
686 | - * parameter can only be '1' (read) or '0' (unread). After a call to |
|
687 | - * SetReadFlag(), GetMessageList() should return the message with the |
|
688 | - * new 'flags' but should not modify the 'mod' parameter. If you do |
|
689 | - * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
690 | - * a full resync of the item from the server. |
|
691 | - * |
|
692 | - * @param string $folderid id of the folder |
|
693 | - * @param string $id id of the message |
|
694 | - * @param int $flags read flag of the message |
|
695 | - * @param ContentParameters $contentParameters |
|
696 | - * |
|
697 | - * @access public |
|
698 | - * @return boolean status of the operation |
|
699 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
700 | - */ |
|
684 | + /** |
|
685 | + * Changes the 'read' flag of a message on disk. The $flags |
|
686 | + * parameter can only be '1' (read) or '0' (unread). After a call to |
|
687 | + * SetReadFlag(), GetMessageList() should return the message with the |
|
688 | + * new 'flags' but should not modify the 'mod' parameter. If you do |
|
689 | + * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
690 | + * a full resync of the item from the server. |
|
691 | + * |
|
692 | + * @param string $folderid id of the folder |
|
693 | + * @param string $id id of the message |
|
694 | + * @param int $flags read flag of the message |
|
695 | + * @param ContentParameters $contentParameters |
|
696 | + * |
|
697 | + * @access public |
|
698 | + * @return boolean status of the operation |
|
699 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
700 | + */ |
|
701 | 701 | function SetReadFlag($folderid, $id, $flags, $contentParameters) |
702 | 702 | { |
703 | 703 | unset($folderid, $id, $flags, $contentParameters); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * |
714 | 714 | * |
715 | 715 | * @DESC The $flags parameter must contains the poommailflag Object |
716 | - */ |
|
716 | + */ |
|
717 | 717 | function ChangeMessageFlag($folderid, $id, $flags) |
718 | 718 | { |
719 | 719 | unset($folderid, $id, $flags); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'homestreet' => 'adr_two_street', |
72 | 72 | 'homefaxnumber' => 'tel_fax_home', |
73 | 73 | 'homephonenumber' => 'tel_home', |
74 | - 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
74 | + 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
75 | 75 | 'lastname' => 'n_family', |
76 | 76 | 'middlename' => 'n_middle', |
77 | 77 | 'mobilephonenumber' => 'tel_cell', |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param booelan $ab_prefix =false prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
124 | 124 | * @return string|array addressbook name of array with int account_id => label pairs |
125 | 125 | */ |
126 | - private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false) |
|
126 | + private function get_addressbooks($account = null, $return_all_in_one = true, $ab_prefix = false) |
|
127 | 127 | { |
128 | - static $abs=null; |
|
128 | + static $abs = null; |
|
129 | 129 | |
130 | 130 | if (!isset($abs) || !$return_all_in_one) |
131 | 131 | { |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
140 | + Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
141 | 141 | |
142 | 142 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
143 | 143 | |
144 | 144 | // error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true)); |
145 | 145 | $pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
146 | - $pref_abs = (string)$pref !== '' ? explode(',',$pref) : array(); |
|
146 | + $pref_abs = (string)$pref !== '' ? explode(',', $pref) : array(); |
|
147 | 147 | |
148 | 148 | foreach ($this->addressbook->get_addressbooks() as $account_id => $label) |
149 | 149 | { |
@@ -151,18 +151,17 @@ discard block |
||
151 | 151 | { |
152 | 152 | $account_id = self::PRIVATE_AB; |
153 | 153 | } |
154 | - if ($account_id && in_array($account_id,$pref_abs) || in_array('A',$pref_abs) || |
|
155 | - $account_id == 0 && in_array('U',$pref_abs) || |
|
156 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
157 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$pref_abs)) |
|
154 | + if ($account_id && in_array($account_id, $pref_abs) || in_array('A', $pref_abs) || |
|
155 | + $account_id == 0 && in_array('U', $pref_abs) || |
|
156 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
157 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $pref_abs)) |
|
158 | 158 | { |
159 | 159 | $abs[$account_id] = $label; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | - $ret = is_null($account) ? $abs : |
|
165 | - ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
164 | + $ret = is_null($account) ? $abs : ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
166 | 165 | lang('Addressbook').' ' : '').$abs[$account]; |
167 | 166 | //error_log(__METHOD__."($account, $return_all_in_one, $ab_prefix) returning ".array2string($ret)); |
168 | 167 | return $ret; |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | foreach ($this->get_addressbooks() as $account => $label) |
181 | 180 | { |
182 | 181 | $folderlist[] = array( |
183 | - 'id' => $this->backend->createID('addressbook',$account), |
|
182 | + 'id' => $this->backend->createID('addressbook', $account), |
|
184 | 183 | 'mod' => $label, |
185 | 184 | 'parent'=> '0', |
186 | 185 | ); |
@@ -278,20 +277,20 @@ discard block |
||
278 | 277 | * @param int $cutoffdate =null |
279 | 278 | * @return array |
280 | 279 | */ |
281 | - function GetMessageList($id, $cutoffdate=NULL) |
|
280 | + function GetMessageList($id, $cutoffdate = NULL) |
|
282 | 281 | { |
283 | - unset($cutoffdate); // not used, but required by function signature |
|
282 | + unset($cutoffdate); // not used, but required by function signature |
|
284 | 283 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
285 | 284 | |
286 | 285 | $type = $user = null; |
287 | - $this->backend->splitID($id,$type,$user); |
|
286 | + $this->backend->splitID($id, $type, $user); |
|
288 | 287 | $filter = array('owner' => $user); |
289 | 288 | |
290 | 289 | // handle all-in-one addressbook |
291 | 290 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
292 | 291 | $user == $GLOBALS['egw_info']['user']['account_id']) |
293 | 292 | { |
294 | - $filter['owner'] = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
293 | + $filter['owner'] = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
295 | 294 | // translate AS private AB ID to EGroupware one |
296 | 295 | if (($key = array_search(self::PRIVATE_AB, $filter['owner'])) !== false) |
297 | 296 | { |
@@ -308,10 +307,10 @@ discard block |
||
308 | 307 | |
309 | 308 | $messagelist = array(); |
310 | 309 | $criteria = null; |
311 | - if (($contacts =& $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
312 | - false, 'AND', false,$filter))) |
|
310 | + if (($contacts = & $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
311 | + false, 'AND', false, $filter))) |
|
313 | 312 | { |
314 | - foreach($contacts as $contact) |
|
313 | + foreach ($contacts as $contact) |
|
315 | 314 | { |
316 | 315 | $messagelist[] = $this->StatMessage($id, $contact); |
317 | 316 | } |
@@ -348,9 +347,9 @@ discard block |
||
348 | 347 | } |
349 | 348 | $emailname = isset($contact['n_given']) ? $contact['n_given'].' ' : ''; |
350 | 349 | $emailname .= isset($contact['n_middle']) ? $contact['n_middle'].' ' : ''; |
351 | - $emailname .= isset($contact['n_family']) ? $contact['n_family']: ''; |
|
350 | + $emailname .= isset($contact['n_family']) ? $contact['n_family'] : ''; |
|
352 | 351 | $message = new SyncContact(); |
353 | - foreach(self::$mapping as $key => $attr) |
|
352 | + foreach (self::$mapping as $key => $attr) |
|
354 | 353 | { |
355 | 354 | switch ($attr) |
356 | 355 | { |
@@ -363,7 +362,7 @@ discard block |
||
363 | 362 | } |
364 | 363 | else |
365 | 364 | { |
366 | - if (strlen ($contact[$attr]) > 0) |
|
365 | + if (strlen($contact[$attr]) > 0) |
|
367 | 366 | { |
368 | 367 | $message->asbody = new SyncBaseBody(); |
369 | 368 | $this->backend->note2messagenote($contact[$attr], $bodypreference, $message->asbody); |
@@ -372,7 +371,7 @@ discard block |
||
372 | 371 | break; |
373 | 372 | |
374 | 373 | case 'jpegphoto': |
375 | - if (empty($contact[$attr]) && ($contact['files'] & Api\Contacts::FILES_BIT_PHOTO)) |
|
374 | + if (empty($contact[$attr]) && ($contact['files']&Api\Contacts::FILES_BIT_PHOTO)) |
|
376 | 375 | { |
377 | 376 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
378 | 377 | } |
@@ -391,14 +390,14 @@ discard block |
||
391 | 390 | |
392 | 391 | case 'cat_id': |
393 | 392 | $message->$key = array(); |
394 | - foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id) |
|
393 | + foreach ($contact[$attr] ? explode(',', $contact[$attr]) : array() as $cat_id) |
|
395 | 394 | { |
396 | 395 | $message->categories[] = Api\Categories::id2name($cat_id); |
397 | 396 | } |
398 | 397 | // for all addressbooks in one, add addressbook name itself as category |
399 | 398 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
400 | 399 | { |
401 | - $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true); |
|
400 | + $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true); |
|
402 | 401 | } |
403 | 402 | break; |
404 | 403 | // HTC Desire needs at least one telefon number, otherwise sync of contact fails without error, |
@@ -410,7 +409,7 @@ discard block |
||
410 | 409 | case 'n_fileas': |
411 | 410 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']) |
412 | 411 | { |
413 | - $message->$key = $this->addressbook->fileas($contact,$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
412 | + $message->$key = $this->addressbook->fileas($contact, $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
414 | 413 | break; |
415 | 414 | } |
416 | 415 | // fall through |
@@ -436,7 +435,7 @@ discard block |
||
436 | 435 | */ |
437 | 436 | public function StatMessage($folderid, $contact) |
438 | 437 | { |
439 | - unset($folderid); // not used (contact_id is global), but required by function signaure |
|
438 | + unset($folderid); // not used (contact_id is global), but required by function signaure |
|
440 | 439 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
441 | 440 | |
442 | 441 | if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
@@ -471,7 +470,7 @@ discard block |
||
471 | 470 | */ |
472 | 471 | public function ChangeFolder($id, $oldid, $displayname, $type) |
473 | 472 | { |
474 | - unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
473 | + unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
475 | 474 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." not implemented"); |
476 | 475 | } |
477 | 476 | |
@@ -510,7 +509,7 @@ discard block |
||
510 | 509 | */ |
511 | 510 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
512 | 511 | { |
513 | - unset($contentParameters); // not used, but required by function signature |
|
512 | + unset($contentParameters); // not used, but required by function signature |
|
514 | 513 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
515 | 514 | |
516 | 515 | $type = $account = null; |
@@ -531,10 +530,10 @@ discard block |
||
531 | 530 | if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
532 | 531 | { |
533 | 532 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
534 | - return false; //no changing of Api\Accounts |
|
533 | + return false; //no changing of Api\Accounts |
|
535 | 534 | } |
536 | 535 | $contact = array(); |
537 | - if (empty($id) && ($this->addressbook->grants[$account] & Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
536 | + if (empty($id) && ($this->addressbook->grants[$account]&Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
538 | 537 | { |
539 | 538 | // remove all fields supported by AS, leaving all unsupported fields unchanged |
540 | 539 | $contact = array_diff_key($contact, array_flip(self::$mapping)); |
@@ -547,7 +546,7 @@ discard block |
||
547 | 546 | break; |
548 | 547 | |
549 | 548 | case 'bday': // zpush uses timestamp in servertime |
550 | - $contact[$attr] = $message->$key ? date('Y-m-d',$message->$key) : null; |
|
549 | + $contact[$attr] = $message->$key ? date('Y-m-d', $message->$key) : null; |
|
551 | 550 | break; |
552 | 551 | |
553 | 552 | case 'jpegphoto': |
@@ -557,20 +556,20 @@ discard block |
||
557 | 556 | case 'cat_id': |
558 | 557 | // for existing entries in all-in-one addressbook, remove addressbook name as category |
559 | 558 | if ($contact && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
560 | - ($k=array_search($this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true),$message->$key))) |
|
559 | + ($k = array_search($this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true), $message->$key))) |
|
561 | 560 | { |
562 | 561 | unset($message->categories[$k]); |
563 | 562 | } |
564 | 563 | if (is_array($message->$key)) |
565 | 564 | { |
566 | - $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id),'strlen')); |
|
565 | + $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id), 'strlen')); |
|
567 | 566 | } |
568 | 567 | break; |
569 | 568 | case 'email': |
570 | 569 | case 'email_home': |
571 | - if (function_exists ('imap_rfc822_parse_adrlist')) |
|
570 | + if (function_exists('imap_rfc822_parse_adrlist')) |
|
572 | 571 | { |
573 | - $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,"")); |
|
572 | + $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key, "")); |
|
574 | 573 | if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host)) |
575 | 574 | { |
576 | 575 | $contact[$attr] = $email_array->mailbox.'@'.$email_array->host; |
@@ -582,7 +581,7 @@ discard block |
||
582 | 581 | } |
583 | 582 | else |
584 | 583 | { |
585 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__. " Warning : php-imap not available"); |
|
584 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Warning : php-imap not available"); |
|
586 | 585 | $contact[$attr] = $message->$key; |
587 | 586 | } |
588 | 587 | break; |
@@ -609,9 +608,9 @@ discard block |
||
609 | 608 | $contact['private'] = (int)$is_private; |
610 | 609 | } |
611 | 610 | // if default addressbook for new contacts is NOT synced --> use personal addressbook |
612 | - elseif($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
611 | + elseif ($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
613 | 612 | !in_array($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], |
614 | - array_keys($this->get_addressbooks(null,false)))) |
|
613 | + array_keys($this->get_addressbooks(null, false)))) |
|
615 | 614 | { |
616 | 615 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
617 | 616 | } |
@@ -643,7 +642,7 @@ discard block |
||
643 | 642 | */ |
644 | 643 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
645 | 644 | { |
646 | - unset($contentParameters); // not used, but required by function signature |
|
645 | + unset($contentParameters); // not used, but required by function signature |
|
647 | 646 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
648 | 647 | { |
649 | 648 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, $newfolderid) NOT allowed for an all-in-one addressbook --> returning false"); |
@@ -670,7 +669,7 @@ discard block |
||
670 | 669 | */ |
671 | 670 | public function DeleteMessage($folderid, $id, $contentParameters) |
672 | 671 | { |
673 | - unset($contentParameters); // not used, but required by function signature |
|
672 | + unset($contentParameters); // not used, but required by function signature |
|
674 | 673 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
675 | 674 | |
676 | 675 | $ret = $this->addressbook->delete($id); |
@@ -739,18 +738,18 @@ discard block |
||
739 | 738 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
740 | 739 | $owner == $GLOBALS['egw_info']['user']['account_id']) |
741 | 740 | { |
742 | - if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'],'A') !== false) |
|
741 | + if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'], 'A') !== false) |
|
743 | 742 | { |
744 | - $owner = null; // all AB's |
|
743 | + $owner = null; // all AB's |
|
745 | 744 | } |
746 | 745 | else |
747 | 746 | { |
748 | - $owner = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
747 | + $owner = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
749 | 748 | // translate AS private AB ID to current user |
750 | 749 | if (($key = array_search(self::PRIVATE_AB, $owner)) !== false) |
751 | 750 | { |
752 | 751 | unset($owner[$key]); |
753 | - if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner)) |
|
752 | + if (!in_array($GLOBALS['egw_info']['user']['account_id'], $owner)) |
|
754 | 753 | { |
755 | 754 | $owner[] = $GLOBALS['egw_info']['user']['account_id']; |
756 | 755 | } |
@@ -763,7 +762,7 @@ discard block |
||
763 | 762 | } |
764 | 763 | $ctag = $this->addressbook->get_ctag($owner); |
765 | 764 | |
766 | - $changes = array(); // no change |
|
765 | + $changes = array(); // no change |
|
767 | 766 | //$syncstate_was = $syncstate; |
768 | 767 | |
769 | 768 | if ($ctag !== $syncstate) |
@@ -791,32 +790,32 @@ discard block |
||
791 | 790 | $range = false; |
792 | 791 | if (isset($searchquery['range']) && preg_match('/^\d+-\d+$/', $searchquery['range'])) |
793 | 792 | { |
794 | - list($start,$end) = explode('-', $searchquery['range']); |
|
795 | - $range = array($start, $end-$start+1); // array(start, num_entries) |
|
793 | + list($start, $end) = explode('-', $searchquery['range']); |
|
794 | + $range = array($start, $end - $start + 1); // array(start, num_entries) |
|
796 | 795 | } |
797 | 796 | //error_log(__METHOD__.'('.array2string($searchquery).') range='.array2string($range)); |
798 | 797 | |
799 | 798 | $items = $filter = array(); |
800 | 799 | $filter['cols_to_search'] = array('n_fn', 'n_family', 'n_given', |
801 | - 'room','org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
800 | + 'room', 'org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
802 | 801 | 'email', 'email_home'); |
803 | - if (($contacts =& $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
802 | + if (($contacts = & $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
804 | 803 | { |
805 | - foreach($contacts as $contact) |
|
804 | + foreach ($contacts as $contact) |
|
806 | 805 | { |
807 | 806 | //$item[SYNC_GAL_ALIAS] = $contact['contact_id']; |
808 | - $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
807 | + $item[SYNC_GAL_LASTNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
809 | 808 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
810 | 809 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
811 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
812 | - $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
|
810 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
811 | + $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private']; |
|
813 | 812 | //$item['nameid'] = $searchquery; |
814 | 813 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
815 | 814 | $item[SYNC_GAL_HOMEPHONE] = (string)$contact['tel_home']; |
816 | 815 | $item[SYNC_GAL_MOBILEPHONE] = (string)$contact['tel_cell']; |
817 | 816 | $item[SYNC_GAL_COMPANY] = (string)$contact['org_name']; |
818 | 817 | $item[SYNC_GAL_OFFICE] = $contact['room']; |
819 | - $item[SYNC_GAL_TITLE ] = $contact['title']; |
|
818 | + $item[SYNC_GAL_TITLE] = $contact['title']; |
|
820 | 819 | |
821 | 820 | //do not return users without email |
822 | 821 | if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
@@ -824,8 +823,8 @@ discard block |
||
824 | 823 | $items[] = $item; |
825 | 824 | } |
826 | 825 | } |
827 | - $items['searchtotal']=count($items); |
|
828 | - $items['range']=$searchquery['range']; |
|
826 | + $items['searchtotal'] = count($items); |
|
827 | + $items['range'] = $searchquery['range']; |
|
829 | 828 | return $items; |
830 | 829 | } |
831 | 830 | |
@@ -846,14 +845,14 @@ discard block |
||
846 | 845 | $addressbooks = $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
847 | 846 | if ($user > 0) |
848 | 847 | { |
849 | - unset($addressbooks[$user]); // personal addressbook is allways synced |
|
848 | + unset($addressbooks[$user]); // personal addressbook is allways synced |
|
850 | 849 | if (isset($addressbooks[$user.'p'])) |
851 | 850 | { |
852 | 851 | $addressbooks[self::PRIVATE_AB] = lang('Private'); |
853 | 852 | } |
854 | 853 | } |
855 | - unset($addressbooks[$user.'p']);// private addressbook uses ID self::PRIVATE_AB |
|
856 | - $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute'))+$addressbook_bo->fileas_options(); |
|
854 | + unset($addressbooks[$user.'p']); // private addressbook uses ID self::PRIVATE_AB |
|
855 | + $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute')) + $addressbook_bo->fileas_options(); |
|
857 | 856 | } |
858 | 857 | $addressbooks += array( |
859 | 858 | 'G' => lang('Primary Group'), |
@@ -139,7 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | Api\Translation::add_app('addressbook'); // we need the addressbook translations |
141 | 141 | |
142 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
142 | + if (!isset($this->addressbook)) |
|
143 | + { |
|
144 | + $this->addressbook = new Api\Contacts(); |
|
145 | + } |
|
143 | 146 | |
144 | 147 | // error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true)); |
145 | 148 | $pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
@@ -281,7 +284,10 @@ discard block |
||
281 | 284 | function GetMessageList($id, $cutoffdate=NULL) |
282 | 285 | { |
283 | 286 | unset($cutoffdate); // not used, but required by function signature |
284 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
287 | + if (!isset($this->addressbook)) |
|
288 | + { |
|
289 | + $this->addressbook = new Api\Contacts(); |
|
290 | + } |
|
285 | 291 | |
286 | 292 | $type = $user = null; |
287 | 293 | $this->backend->splitID($id,$type,$user); |
@@ -332,7 +338,10 @@ discard block |
||
332 | 338 | */ |
333 | 339 | public function GetMessage($folderid, $id, $contentparameters) |
334 | 340 | { |
335 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
341 | + if (!isset($this->addressbook)) |
|
342 | + { |
|
343 | + $this->addressbook = new Api\Contacts(); |
|
344 | + } |
|
336 | 345 | |
337 | 346 | //$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
338 | 347 | //$mimesupport = $contentparameters->GetMimeSupport(); |
@@ -376,7 +385,10 @@ discard block |
||
376 | 385 | { |
377 | 386 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
378 | 387 | } |
379 | - if (!empty($contact[$attr])) $message->$key = base64_encode($contact[$attr]); |
|
388 | + if (!empty($contact[$attr])) |
|
389 | + { |
|
390 | + $message->$key = base64_encode($contact[$attr]); |
|
391 | + } |
|
380 | 392 | break; |
381 | 393 | |
382 | 394 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
@@ -415,7 +427,10 @@ discard block |
||
415 | 427 | } |
416 | 428 | // fall through |
417 | 429 | default: |
418 | - if (!empty($contact[$attr])) $message->$key = $contact[$attr]; |
|
430 | + if (!empty($contact[$attr])) |
|
431 | + { |
|
432 | + $message->$key = $contact[$attr]; |
|
433 | + } |
|
419 | 434 | } |
420 | 435 | } |
421 | 436 | //error_log(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message)); |
@@ -437,9 +452,15 @@ discard block |
||
437 | 452 | public function StatMessage($folderid, $contact) |
438 | 453 | { |
439 | 454 | unset($folderid); // not used (contact_id is global), but required by function signaure |
440 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
455 | + if (!isset($this->addressbook)) |
|
456 | + { |
|
457 | + $this->addressbook = new Api\Contacts(); |
|
458 | + } |
|
441 | 459 | |
442 | - if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
|
460 | + if (!is_array($contact)) |
|
461 | + { |
|
462 | + $contact = $this->addressbook->read($contact); |
|
463 | + } |
|
443 | 464 | |
444 | 465 | if (!$contact) |
445 | 466 | { |
@@ -511,7 +532,10 @@ discard block |
||
511 | 532 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
512 | 533 | { |
513 | 534 | unset($contentParameters); // not used, but required by function signature |
514 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
535 | + if (!isset($this->addressbook)) |
|
536 | + { |
|
537 | + $this->addressbook = new Api\Contacts(); |
|
538 | + } |
|
515 | 539 | |
516 | 540 | $type = $account = null; |
517 | 541 | $this->backend->splitID($folderid, $type, $account); |
@@ -523,14 +547,20 @@ discard block |
||
523 | 547 | |
524 | 548 | } |
525 | 549 | // error_log(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); |
526 | - if ($type != 'addressbook') // || !($contact = $this->addressbook->read($id))) |
|
550 | + if ($type != 'addressbook') |
|
551 | + { |
|
552 | + // || !($contact = $this->addressbook->read($id))) |
|
527 | 553 | { |
528 | 554 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Folder wrong or contact not existing"); |
555 | + } |
|
529 | 556 | return false; |
530 | 557 | } |
531 | - if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
|
558 | + if ($account == 0) |
|
559 | + { |
|
560 | + // as a precausion, we currently do NOT allow to change Api\Accounts |
|
532 | 561 | { |
533 | 562 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
563 | + } |
|
534 | 564 | return false; //no changing of Api\Accounts |
535 | 565 | } |
536 | 566 | $contact = array(); |
@@ -593,7 +623,10 @@ discard block |
||
593 | 623 | } |
594 | 624 | break; |
595 | 625 | case 'title': // as ol jobtitle mapping changed in egw from role to title, do NOT overwrite title with value of role |
596 | - if ($id && $message->$key == $contact['role']) break; |
|
626 | + if ($id && $message->$key == $contact['role']) |
|
627 | + { |
|
628 | + break; |
|
629 | + } |
|
597 | 630 | // fall throught |
598 | 631 | default: |
599 | 632 | $contact[$attr] = $message->$key; |
@@ -602,7 +635,10 @@ discard block |
||
602 | 635 | } |
603 | 636 | // for all-in-one addressbook, account is meaningless and wrong! |
604 | 637 | // Api\Contacts::save() keeps the owner or sets an appropriate one if none given |
605 | - if (!isset($contact['private'])) $contact['private'] = (int)$is_private; |
|
638 | + if (!isset($contact['private'])) |
|
639 | + { |
|
640 | + $contact['private'] = (int)$is_private; |
|
641 | + } |
|
606 | 642 | if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
607 | 643 | { |
608 | 644 | $contact['owner'] = $account; |
@@ -615,7 +651,10 @@ discard block |
||
615 | 651 | { |
616 | 652 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
617 | 653 | } |
618 | - if (!empty($id)) $contact['id'] = $id; |
|
654 | + if (!empty($id)) |
|
655 | + { |
|
656 | + $contact['id'] = $id; |
|
657 | + } |
|
619 | 658 | $this->addressbook->fixup_contact($contact); |
620 | 659 | $newid = $this->addressbook->save($contact); |
621 | 660 | //error_log(__METHOD__."($folderid,$id) contact=".array2string($contact)." returning ".array2string($newid)); |
@@ -671,7 +710,10 @@ discard block |
||
671 | 710 | public function DeleteMessage($folderid, $id, $contentParameters) |
672 | 711 | { |
673 | 712 | unset($contentParameters); // not used, but required by function signature |
674 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
713 | + if (!isset($this->addressbook)) |
|
714 | + { |
|
715 | + $this->addressbook = new Api\Contacts(); |
|
716 | + } |
|
675 | 717 | |
676 | 718 | $ret = $this->addressbook->delete($id); |
677 | 719 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -731,9 +773,15 @@ discard block |
||
731 | 773 | $type = $owner = null; |
732 | 774 | $this->backend->splitID($folderid, $type, $owner); |
733 | 775 | |
734 | - if ($type != 'addressbook') return false; |
|
776 | + if ($type != 'addressbook') |
|
777 | + { |
|
778 | + return false; |
|
779 | + } |
|
735 | 780 | |
736 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
781 | + if (!isset($this->addressbook)) |
|
782 | + { |
|
783 | + $this->addressbook = new Api\Contacts(); |
|
784 | + } |
|
737 | 785 | |
738 | 786 | // handle all-in-one addressbook |
739 | 787 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
@@ -784,7 +832,10 @@ discard block |
||
784 | 832 | */ |
785 | 833 | function getSearchResultsGAL($searchquery) |
786 | 834 | { |
787 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
835 | + if (!isset($this->addressbook)) |
|
836 | + { |
|
837 | + $this->addressbook = new Api\Contacts(); |
|
838 | + } |
|
788 | 839 | //error_log(__METHOD__.'('.array2string($searchquery).')'); |
789 | 840 | |
790 | 841 | // only return items in given range, eg. "0-50" |
@@ -808,7 +859,10 @@ discard block |
||
808 | 859 | $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
809 | 860 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
810 | 861 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
811 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
862 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) |
|
863 | + { |
|
864 | + $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
865 | + } |
|
812 | 866 | $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
813 | 867 | //$item['nameid'] = $searchquery; |
814 | 868 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
@@ -819,7 +873,10 @@ discard block |
||
819 | 873 | $item[SYNC_GAL_TITLE ] = $contact['title']; |
820 | 874 | |
821 | 875 | //do not return users without email |
822 | - if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
|
876 | + if (!trim($item[SYNC_GAL_EMAILADDRESS])) |
|
877 | + { |
|
878 | + continue; |
|
879 | + } |
|
823 | 880 | |
824 | 881 | $items[] = $item; |
825 | 882 | } |
@@ -1885,12 +1885,12 @@ discard block |
||
1885 | 1885 | } |
1886 | 1886 | |
1887 | 1887 | /** |
1888 | - * Edit a contact |
|
1889 | - * |
|
1890 | - * @param array $content=null submitted content |
|
1891 | - * @param int $_GET['contact_id'] contact_id mainly for popup use |
|
1892 | - * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
|
1893 | - */ |
|
1888 | + * Edit a contact |
|
1889 | + * |
|
1890 | + * @param array $content=null submitted content |
|
1891 | + * @param int $_GET['contact_id'] contact_id mainly for popup use |
|
1892 | + * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
|
1893 | + */ |
|
1894 | 1894 | function edit($content=null) |
1895 | 1895 | { |
1896 | 1896 | if (is_array($content)) |
@@ -3069,8 +3069,8 @@ discard block |
||
3069 | 3069 | } |
3070 | 3070 | |
3071 | 3071 | /** |
3072 | - * Set up history log widget |
|
3073 | - */ |
|
3072 | + * Set up history log widget |
|
3073 | + */ |
|
3074 | 3074 | protected function setup_history(&$content, &$sel_options) |
3075 | 3075 | { |
3076 | 3076 | if ($this->contact_repository == 'ldap' || !$content['id'] || |
@@ -2594,7 +2594,7 @@ |
||
2594 | 2594 | case 'infolog': |
2595 | 2595 | case 'tracker': |
2596 | 2596 | default: |
2597 | - Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2597 | + Api\Json\Response::get()->apply('app.addressbook.view_set_list',array(array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2598 | 2598 | break; |
2599 | 2599 | } |
2600 | 2600 |
@@ -1127,6 +1127,8 @@ discard block |
||
1127 | 1127 | * @param int &$failed number of failed actions (not enought permissions) |
1128 | 1128 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 contacts 'deleted' |
1129 | 1129 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
1130 | + * @param null|integer $success |
|
1131 | + * @param null|integer $failed |
|
1130 | 1132 | * @return boolean true if all actions succeded, false otherwise |
1131 | 1133 | */ |
1132 | 1134 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL) |
@@ -1433,6 +1435,8 @@ discard block |
||
1433 | 1435 | * @param int &$failed number of failed actions (not enought permissions) |
1434 | 1436 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 contacts 'deleted' |
1435 | 1437 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
1438 | + * @param integer $success |
|
1439 | + * @param integer $failed |
|
1436 | 1440 | * |
1437 | 1441 | * @return array List of contact IDs in the provided groups |
1438 | 1442 | */ |
@@ -1985,9 +1989,7 @@ discard block |
||
1985 | 1989 | /** |
1986 | 1990 | * Edit a contact |
1987 | 1991 | * |
1988 | - * @param array $content=null submitted content |
|
1989 | - * @param int $_GET['contact_id'] contact_id mainly for popup use |
|
1990 | - * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
|
1992 | + * @param array $content submitted content |
|
1991 | 1993 | */ |
1992 | 1994 | function edit($content=null) |
1993 | 1995 | { |
@@ -93,7 +93,10 @@ discard block |
||
93 | 93 | ); |
94 | 94 | |
95 | 95 | // make sure the hook for export_limit is registered |
96 | - if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true); |
|
96 | + if (!Api\Hooks::exists('export_limit','addressbook')) |
|
97 | + { |
|
98 | + Api\Hooks::read(true); |
|
99 | + } |
|
97 | 100 | |
98 | 101 | $this->config =& $GLOBALS['egw_info']['server']; |
99 | 102 | |
@@ -132,15 +135,21 @@ discard block |
||
132 | 135 | { |
133 | 136 | $do_email = $_content['do_email']; |
134 | 137 | |
135 | - if (isset($_content['nm']['rows']['delete'])) // handle a single delete like delete with the checkboxes |
|
138 | + if (isset($_content['nm']['rows']['delete'])) |
|
139 | + { |
|
140 | + // handle a single delete like delete with the checkboxes |
|
136 | 141 | { |
137 | 142 | list($id) = @each($_content['nm']['rows']['delete']); |
143 | + } |
|
138 | 144 | $_content['nm']['action'] = 'delete'; |
139 | 145 | $_content['nm']['selected'] = array($id); |
140 | 146 | } |
141 | - if (isset($_content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
147 | + if (isset($_content['nm']['rows']['document'])) |
|
148 | + { |
|
149 | + // handle insert in default document button like an action |
|
142 | 150 | { |
143 | 151 | list($id) = @each($_content['nm']['rows']['document']); |
152 | + } |
|
144 | 153 | $_content['nm']['action'] = 'document'; |
145 | 154 | $_content['nm']['selected'] = array($id); |
146 | 155 | } |
@@ -177,10 +186,13 @@ discard block |
||
177 | 186 | list($org) = each($_content['nm']['rows']['infolog']); |
178 | 187 | return $this->infolog_org_view($org); |
179 | 188 | } |
180 | - if ($_content['nm']['rows']['view']) // show all contacts of an organisation |
|
189 | + if ($_content['nm']['rows']['view']) |
|
190 | + { |
|
191 | + // show all contacts of an organisation |
|
181 | 192 | { |
182 | 193 | list($grouped_view) = each($_content['nm']['rows']['view']); |
183 | 194 | } |
195 | + } |
|
184 | 196 | else |
185 | 197 | { |
186 | 198 | $grouped_view = $_content['nm']['grouped_view']; |
@@ -274,10 +286,14 @@ discard block |
||
274 | 286 | } |
275 | 287 | |
276 | 288 | // Search parameter passed in |
277 | - if ($_GET['search']) { |
|
289 | + if ($_GET['search']) |
|
290 | + { |
|
278 | 291 | $content['nm']['search'] = $_GET['search']; |
279 | 292 | } |
280 | - if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; |
|
293 | + if (isset($typeselection)) |
|
294 | + { |
|
295 | + $content['nm']['col_filter']['tid'] = $typeselection; |
|
296 | + } |
|
281 | 297 | // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys |
282 | 298 | //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); |
283 | 299 | Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); |
@@ -315,7 +331,10 @@ discard block |
||
315 | 331 | $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); |
316 | 332 | |
317 | 333 | // if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export |
318 | - if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
334 | + if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) |
|
335 | + { |
|
336 | + $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
337 | + } |
|
319 | 338 | |
320 | 339 | // Merge to email dialog needs the infolog types |
321 | 340 | $infolog = new infolog_bo(); |
@@ -329,7 +348,10 @@ discard block |
||
329 | 348 | //_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter')); |
330 | 349 | unset($content['nm']['col_filter']['tid']); |
331 | 350 | } |
332 | - if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
351 | + if (!isset($content['nm']['col_filter']['tid'])) |
|
352 | + { |
|
353 | + $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
354 | + } |
|
333 | 355 | if (count($this->content_types) > 1) |
334 | 356 | { |
335 | 357 | foreach($this->content_types as $tid => $data) |
@@ -426,7 +448,10 @@ discard block |
||
426 | 448 | $crm_apps = array('infolog','tracker'); |
427 | 449 | foreach($crm_apps as $app) |
428 | 450 | { |
429 | - if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; |
|
451 | + if ($GLOBALS['egw_info']['user']['apps'][$app]) |
|
452 | + { |
|
453 | + $crm_count++; |
|
454 | + } |
|
430 | 455 | } |
431 | 456 | if($crm_count > 1) |
432 | 457 | { |
@@ -494,7 +519,10 @@ discard block |
||
494 | 519 | ), |
495 | 520 | ), |
496 | 521 | ); |
497 | - if (!$GLOBALS['egw_info']['user']['apps']['preferences']) unset($actions['cats']['children']['cat_edit']); |
|
522 | + if (!$GLOBALS['egw_info']['user']['apps']['preferences']) |
|
523 | + { |
|
524 | + unset($actions['cats']['children']['cat_edit']); |
|
525 | + } |
|
498 | 526 | // Submenu for all distributionlist stuff |
499 | 527 | $actions['lists'] = array( |
500 | 528 | 'caption' => 'Distribution lists', |
@@ -507,7 +535,9 @@ discard block |
||
507 | 535 | ), |
508 | 536 | 'group' => $group, |
509 | 537 | ); |
510 | - if (($add_lists = $this->get_lists(Acl::EDIT))) // do we have distribution lists?, and are we allowed to edit them |
|
538 | + if (($add_lists = $this->get_lists(Acl::EDIT))) |
|
539 | + { |
|
540 | + // do we have distribution lists?, and are we allowed to edit them |
|
511 | 541 | { |
512 | 542 | $actions['lists']['children'] += array( |
513 | 543 | 'to_list' => array( |
@@ -543,6 +573,7 @@ discard block |
||
543 | 573 | 'fieldValue' => '!', // enable if list != '' |
544 | 574 | ), |
545 | 575 | ); |
576 | + } |
|
546 | 577 | if(is_subclass_of('etemplate', 'etemplate_new')) |
547 | 578 | { |
548 | 579 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
@@ -551,9 +582,13 @@ discard block |
||
551 | 582 | } |
552 | 583 | } |
553 | 584 | // move to AB |
554 | - if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
|
585 | + if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) |
|
586 | + { |
|
587 | + // do we have addressbooks, we should |
|
555 | 588 | { |
556 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
589 | + unset($move2addressbooks[0]); |
|
590 | + } |
|
591 | + // do not offer action to move contact to an account, as we dont support that currrently |
|
557 | 592 | foreach($move2addressbooks as $owner => $label) |
558 | 593 | { |
559 | 594 | $icon = $type_label = null; |
@@ -695,7 +730,9 @@ discard block |
||
695 | 730 | |
696 | 731 | ); |
697 | 732 | if (!$this->prefs['preferredMail']) |
698 | - $actions['email']['children']['email_business']['checked'] = true; |
|
733 | + { |
|
734 | + $actions['email']['children']['email_business']['checked'] = true; |
|
735 | + } |
|
699 | 736 | |
700 | 737 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
701 | 738 | { |
@@ -843,11 +880,17 @@ discard block |
||
843 | 880 | protected function _get_grouped_name($view_id) |
844 | 881 | { |
845 | 882 | $group_name = array(); |
846 | - if (strpos($view_id,'*AND*')!== false) $view_id = str_replace('*AND*','&',$view_id); |
|
883 | + if (strpos($view_id,'*AND*')!== false) |
|
884 | + { |
|
885 | + $view_id = str_replace('*AND*','&',$view_id); |
|
886 | + } |
|
847 | 887 | foreach(explode('|||',$view_id) as $part) |
848 | 888 | { |
849 | 889 | list(,$name) = explode(':',$part,2); |
850 | - if ($name) $group_name[] = $name; |
|
890 | + if ($name) |
|
891 | + { |
|
892 | + $group_name[] = $name; |
|
893 | + } |
|
851 | 894 | } |
852 | 895 | $name = implode(': ',$group_name); |
853 | 896 | return $name ? array($view_id => $name) : array(); |
@@ -993,9 +1036,15 @@ discard block |
||
993 | 1036 | $org_contacts = array(); |
994 | 1037 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
995 | 1038 | $query['num_rows'] = -1; // all |
996 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
1039 | + if(!is_array($query['col_filter'])) |
|
1040 | + { |
|
1041 | + $query['col_filter'] = array(); |
|
1042 | + } |
|
997 | 1043 | |
998 | - if(!is_array($org)) $org = array($org); |
|
1044 | + if(!is_array($org)) |
|
1045 | + { |
|
1046 | + $org = array($org); |
|
1047 | + } |
|
999 | 1048 | foreach($org as $org_name) |
1000 | 1049 | { |
1001 | 1050 | $query['grouped_view'] = $org_name; |
@@ -1024,14 +1073,23 @@ discard block |
||
1024 | 1073 | $checked = $readonlys = null; |
1025 | 1074 | $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
1026 | 1075 | |
1027 | - if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
|
1076 | + if (count($checked) > 1) |
|
1077 | + { |
|
1078 | + // use a nicely formatted org-name as title in infolog |
|
1028 | 1079 | { |
1029 | 1080 | $parts = array(); |
1030 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
1081 | + } |
|
1082 | + if (strpos($org,'*AND*')!== false) |
|
1083 | + { |
|
1084 | + $org = str_replace('*AND*','&',$org); |
|
1085 | + } |
|
1031 | 1086 | foreach(explode('|||',$org) as $part) |
1032 | 1087 | { |
1033 | 1088 | list(,$part) = explode(':',$part,2); |
1034 | - if ($part) $parts[] = $part; |
|
1089 | + if ($part) |
|
1090 | + { |
|
1091 | + $parts[] = $part; |
|
1092 | + } |
|
1035 | 1093 | } |
1036 | 1094 | $org = implode(', ',$parts); |
1037 | 1095 | } |
@@ -1160,7 +1218,10 @@ discard block |
||
1160 | 1218 | } |
1161 | 1219 | // replace org_name:* id's with all id's of that org |
1162 | 1220 | $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success,$failed,$action_msg,$session_name, $msg); |
1163 | - if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1221 | + if ($grouped_contacts) |
|
1222 | + { |
|
1223 | + $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1224 | + } |
|
1164 | 1225 | //_debug_array($checked); exit; |
1165 | 1226 | |
1166 | 1227 | if (substr($action,0,8) == 'move_to_') |
@@ -1177,9 +1238,12 @@ discard block |
||
1177 | 1238 | $document = substr($action,9); |
1178 | 1239 | $action = 'document'; |
1179 | 1240 | } |
1180 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1241 | + elseif(substr($action,0,4) == 'cat_') |
|
1242 | + { |
|
1243 | + // cat_add_123 or cat_del_456 |
|
1181 | 1244 | { |
1182 | 1245 | $cat_id = (int)substr($action, 8); |
1246 | + } |
|
1183 | 1247 | $action = substr($action,0,7); |
1184 | 1248 | } |
1185 | 1249 | // Security: stop non-admins to export more then the configured number of contacts |
@@ -1226,7 +1290,10 @@ discard block |
||
1226 | 1290 | return false; |
1227 | 1291 | |
1228 | 1292 | case 'document': |
1229 | - if (!$document) $document = $this->prefs['default_document']; |
|
1293 | + if (!$document) |
|
1294 | + { |
|
1295 | + $document = $this->prefs['default_document']; |
|
1296 | + } |
|
1230 | 1297 | $document_merge = new Api\Contacts\Merge(); |
1231 | 1298 | $msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']); |
1232 | 1299 | $failed = count($checked); |
@@ -1378,19 +1445,25 @@ discard block |
||
1378 | 1445 | break; |
1379 | 1446 | |
1380 | 1447 | default: // move to an other addressbook |
1381 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
1448 | + if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) |
|
1449 | + { |
|
1450 | + // might be ADD in the future |
|
1382 | 1451 | { |
1383 | 1452 | return false; |
1384 | 1453 | } |
1454 | + } |
|
1385 | 1455 | if (!$checkboxes['move_to_copy']) |
1386 | 1456 | { |
1387 | 1457 | $action_msg = lang('moved'); |
1388 | 1458 | if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
1389 | 1459 | { |
1390 | - if (!$contact['owner']) // no (mass-)move of Api\Accounts |
|
1460 | + if (!$contact['owner']) |
|
1461 | + { |
|
1462 | + // no (mass-)move of Api\Accounts |
|
1391 | 1463 | { |
1392 | 1464 | $Ok = false; |
1393 | 1465 | } |
1466 | + } |
|
1394 | 1467 | elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
1395 | 1468 | { |
1396 | 1469 | $contact['owner'] = (int) $action; |
@@ -1533,9 +1606,12 @@ discard block |
||
1533 | 1606 | $do_email = $query['do_email']; |
1534 | 1607 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index'); |
1535 | 1608 | |
1536 | - if (!$id_only && !$query['csv_export']) // do NOT store state for csv_export or querying id's (no regular view) |
|
1609 | + if (!$id_only && !$query['csv_export']) |
|
1610 | + { |
|
1611 | + // do NOT store state for csv_export or querying id's (no regular view) |
|
1537 | 1612 | { |
1538 | 1613 | $store_query = $query; |
1614 | + } |
|
1539 | 1615 | // Do not store these |
1540 | 1616 | foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
1541 | 1617 | { |
@@ -1557,21 +1633,29 @@ discard block |
||
1557 | 1633 | if (isset($this->grouped_views[(string) $query['grouped_view']])) |
1558 | 1634 | { |
1559 | 1635 | // we have a grouped view, reset the advanced search |
1560 | - if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1636 | + if(!$query['search'] && $old_state['advanced_search']) |
|
1637 | + { |
|
1638 | + $query['advanced_search'] = $old_state['advanced_search']; |
|
1639 | + } |
|
1561 | 1640 | } |
1562 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
1641 | + elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) |
|
1642 | + { |
|
1643 | + // eg. paging in an advanced search |
|
1563 | 1644 | { |
1564 | 1645 | $query['advanced_search'] = $old_state['advanced_search']; |
1565 | 1646 | } |
1647 | + } |
|
1566 | 1648 | |
1567 | 1649 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
1568 | 1650 | foreach($query['col_filter'] as $key => $col_filter) |
1569 | 1651 | { |
1570 | - if(!is_numeric($key)) continue; |
|
1652 | + if(!is_numeric($key)) |
|
1653 | + { |
|
1654 | + continue; |
|
1655 | + } |
|
1571 | 1656 | if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
1572 | 1657 | ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i',$col_filter) == 1 |
1573 | - ) |
|
1574 | - { |
|
1658 | + ) { |
|
1575 | 1659 | unset($query['col_filter'][$key]); |
1576 | 1660 | } |
1577 | 1661 | } |
@@ -1582,9 +1666,13 @@ discard block |
||
1582 | 1666 | // check if accounts are stored in ldap, which does NOT yet support the org-views |
1583 | 1667 | if ($this->so_accounts && $query['filter'] === '0' && $query['grouped_view']) |
1584 | 1668 | { |
1585 | - if ($old_state['filter'] === '0') // user changed to org_view |
|
1669 | + if ($old_state['filter'] === '0') |
|
1586 | 1670 | { |
1587 | - $query['filter'] = ''; // --> change filter to all contacts |
|
1671 | + // user changed to org_view |
|
1672 | + { |
|
1673 | + $query['filter'] = ''; |
|
1674 | + } |
|
1675 | + // --> change filter to all contacts |
|
1588 | 1676 | } |
1589 | 1677 | else // user changed to accounts |
1590 | 1678 | { |
@@ -1621,9 +1709,12 @@ discard block |
||
1621 | 1709 | { |
1622 | 1710 | unset($query['col_filter']['cat_id']); |
1623 | 1711 | } |
1624 | - if ($query['filter'] !== '') // not all addressbooks |
|
1712 | + if ($query['filter'] !== '') |
|
1713 | + { |
|
1714 | + // not all addressbooks |
|
1625 | 1715 | { |
1626 | 1716 | $query['col_filter']['owner'] = (string) (int) $query['filter']; |
1717 | + } |
|
1627 | 1718 | |
1628 | 1719 | if ($this->private_addressbook) |
1629 | 1720 | { |
@@ -1635,10 +1726,13 @@ discard block |
||
1635 | 1726 | unset($query['col_filter']['owner']); |
1636 | 1727 | unset($query['col_filter']['private']); |
1637 | 1728 | } |
1638 | - if ((int)$query['filter2']) // not no distribution list |
|
1729 | + if ((int)$query['filter2']) |
|
1730 | + { |
|
1731 | + // not no distribution list |
|
1639 | 1732 | { |
1640 | 1733 | $query['col_filter']['list'] = (string) (int) $query['filter2']; |
1641 | 1734 | } |
1735 | + } |
|
1642 | 1736 | else |
1643 | 1737 | { |
1644 | 1738 | unset($query['col_filter']['list']); |
@@ -1679,9 +1773,12 @@ discard block |
||
1679 | 1773 | } |
1680 | 1774 | // Query doesn't like parent_id |
1681 | 1775 | unset($query['col_filter']['parent_id']); |
1682 | - if ($query['grouped_view']) // view the contacts of one organisation only |
|
1776 | + if ($query['grouped_view']) |
|
1777 | + { |
|
1778 | + // view the contacts of one organisation only |
|
1683 | 1779 | { |
1684 | 1780 | if (strpos($query['grouped_view'],'*AND*') !== false) $query['grouped_view'] = str_replace('*AND*','&',$query['grouped_view']); |
1781 | + } |
|
1685 | 1782 | $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
1686 | 1783 | foreach(explode('|||',$query['grouped_view']) as $part) |
1687 | 1784 | { |
@@ -1704,14 +1801,18 @@ discard block |
||
1704 | 1801 | // translate the select order to the really used over all 3 columns |
1705 | 1802 | $sort = $query['sort']; |
1706 | 1803 | switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
1707 | - { // we don't exclude them, as the total would otherwise depend on the order-criteria |
|
1804 | + { |
|
1805 | +// we don't exclude them, as the total would otherwise depend on the order-criteria |
|
1708 | 1806 | case 'org_name': |
1709 | 1807 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
1710 | 1808 | break; |
1711 | 1809 | default: |
1712 | - if ($query['order'][0] == '#') // we order by a custom field |
|
1810 | + if ($query['order'][0] == '#') |
|
1811 | + { |
|
1812 | + // we order by a custom field |
|
1713 | 1813 | { |
1714 | 1814 | $order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort"; |
1815 | + } |
|
1715 | 1816 | break; |
1716 | 1817 | } |
1717 | 1818 | $query['order'] = 'n_family'; |
@@ -1735,9 +1836,12 @@ discard block |
||
1735 | 1836 | case 'contact_id': |
1736 | 1837 | $order = "egw_addressbook.$query[order] $sort"; |
1737 | 1838 | } |
1738 | - if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
|
1839 | + if ($query['searchletter']) |
|
1840 | + { |
|
1841 | + // only show contacts if the order-criteria starts with the given letter |
|
1739 | 1842 | { |
1740 | 1843 | $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
1844 | + } |
|
1741 | 1845 | $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
1742 | 1846 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); |
1743 | 1847 | } |
@@ -1777,13 +1881,19 @@ discard block |
||
1777 | 1881 | { |
1778 | 1882 | foreach($columselection as $col) |
1779 | 1883 | { |
1780 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
1884 | + if ($col[0] == '#') |
|
1885 | + { |
|
1886 | + $selected_cfs[] = substr($col,1); |
|
1887 | + } |
|
1781 | 1888 | } |
1782 | 1889 | $customfields = $this->read_customfields($ids,$selected_cfs); |
1783 | 1890 | } |
1784 | 1891 | // TODO: we need to find out where the csv_export query has been used and try to clean up |
1785 | 1892 | // this columnselection condition statements. |
1786 | - if ($columselection && $show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); |
|
1893 | + if ($columselection && $show_calendar && !empty($ids)) |
|
1894 | + { |
|
1895 | + $calendar = $this->read_calendar($calendar_participants); |
|
1896 | + } |
|
1787 | 1897 | // distributionlist memership for the entrys |
1788 | 1898 | //_debug_array($this->get_lists(Acl::EDIT)); |
1789 | 1899 | if ($show_distributionlist && $available_distib_lists) |
@@ -1793,7 +1903,10 @@ discard block |
||
1793 | 1903 | } |
1794 | 1904 | } |
1795 | 1905 | } |
1796 | - if (!$rows) $rows = array(); |
|
1906 | + if (!$rows) |
|
1907 | + { |
|
1908 | + $rows = array(); |
|
1909 | + } |
|
1797 | 1910 | |
1798 | 1911 | if ($id_only) |
1799 | 1912 | { |
@@ -1826,7 +1939,10 @@ discard block |
||
1826 | 1939 | $row['line2'] = $row['org_name']; |
1827 | 1940 | break; |
1828 | 1941 | case 'n_fileas': |
1829 | - if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
|
1942 | + if (!$row['n_fileas']) |
|
1943 | + { |
|
1944 | + $row['n_fileas'] = $this->fileas($row); |
|
1945 | + } |
|
1830 | 1946 | list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
1831 | 1947 | break; |
1832 | 1948 | } |
@@ -1905,8 +2021,14 @@ discard block |
||
1905 | 2021 | } |
1906 | 2022 | |
1907 | 2023 | // hide region for address format 'postcode_city' |
1908 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
1909 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
2024 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') |
|
2025 | + { |
|
2026 | + unset($row['adr_one_region']); |
|
2027 | + } |
|
2028 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') |
|
2029 | + { |
|
2030 | + unset($row['adr_two_region']); |
|
2031 | + } |
|
1910 | 2032 | |
1911 | 2033 | // respect category permissions |
1912 | 2034 | if(!empty($row['cat_id'])) |
@@ -1965,10 +2087,13 @@ discard block |
||
1965 | 2087 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
1966 | 2088 | $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
1967 | 2089 | } |
1968 | - if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
|
2090 | + if ($query['search'] && !$query['advanced_search']) |
|
2091 | + { |
|
2092 | + // do not add that, if we have advanced search active |
|
1969 | 2093 | { |
1970 | 2094 | $header[] = lang("Search for '%1'",$query['search']); |
1971 | 2095 | } |
2096 | + } |
|
1972 | 2097 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
1973 | 2098 | |
1974 | 2099 | return $this->total; |
@@ -2035,7 +2160,10 @@ discard block |
||
2035 | 2160 | $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
2036 | 2161 | $content['owner'] = (string) (int) $content['owner']; |
2037 | 2162 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
2038 | - if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
|
2163 | + if ($this->config['private_cf_tab']) |
|
2164 | + { |
|
2165 | + $content = (array)$content['private_cfs'] + $content; |
|
2166 | + } |
|
2039 | 2167 | unset($content['private_cfs']); |
2040 | 2168 | |
2041 | 2169 | switch($button) |
@@ -2226,7 +2354,10 @@ discard block |
||
2226 | 2354 | { |
2227 | 2355 | // arguments containing a comma get quoted by etemplate/js/nextmatch_action.js |
2228 | 2356 | // leading to error in Api\Db::column_data_implode, if not unquoted |
2229 | - if ($org[0] == '"') $org = substr($org, 1, -1); |
|
2357 | + if ($org[0] == '"') |
|
2358 | + { |
|
2359 | + $org = substr($org, 1, -1); |
|
2360 | + } |
|
2230 | 2361 | $content = $this->read_org($org); |
2231 | 2362 | } |
2232 | 2363 | elseif ($state['grouped_view'] && !isset($this->grouped_views[$state['grouped_view']])) |
@@ -2246,7 +2377,10 @@ discard block |
||
2246 | 2377 | $content['adr_two_countryname'] = |
2247 | 2378 | $GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']); |
2248 | 2379 | } |
2249 | - if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default']; |
|
2380 | + if ($this->prefs['fileas_default']) |
|
2381 | + { |
|
2382 | + $content['fileas_type'] = $this->prefs['fileas_default']; |
|
2383 | + } |
|
2250 | 2384 | } |
2251 | 2385 | if (isset($_GET['owner']) && $_GET['owner'] !== '') |
2252 | 2386 | { |
@@ -2271,7 +2405,10 @@ discard block |
||
2271 | 2405 | $new_type = array_keys($this->content_types); |
2272 | 2406 | // fetch active type to preset the type, if param typeid is not passed |
2273 | 2407 | $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
2274 | - if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
|
2408 | + if ($active_tid && strtoupper($active_tid) === 'D') |
|
2409 | + { |
|
2410 | + unset($active_tid); |
|
2411 | + } |
|
2275 | 2412 | $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
2276 | 2413 | foreach($this->get_contact_columns() as $field) |
2277 | 2414 | { |
@@ -2289,19 +2426,37 @@ discard block |
||
2289 | 2426 | if (strpos($singleAddress[0]->personal,',')===false) |
2290 | 2427 | { |
2291 | 2428 | list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
2292 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2293 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2294 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2429 | + if (strlen(trim($P_n_given))>0) |
|
2430 | + { |
|
2431 | + $content['n_given'] = trim($P_n_given); |
|
2432 | + } |
|
2433 | + if (strlen(trim($P_n_family))>0) |
|
2434 | + { |
|
2435 | + $content['n_family'] = trim($P_n_family); |
|
2436 | + } |
|
2437 | + if (strlen(trim($P_org_name))>0) |
|
2438 | + { |
|
2439 | + $content['org_name'] = trim($P_org_name); |
|
2440 | + } |
|
2295 | 2441 | } |
2296 | 2442 | else |
2297 | 2443 | { |
2298 | 2444 | list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
2299 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2445 | + if (strlen(trim($P_n_family))>0) |
|
2446 | + { |
|
2447 | + $content['n_family'] = trim($P_n_family); |
|
2448 | + } |
|
2300 | 2449 | if (strlen(trim($P_other))>0) |
2301 | 2450 | { |
2302 | 2451 | list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
2303 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2304 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2452 | + if (strlen(trim($P_n_given))>0) |
|
2453 | + { |
|
2454 | + $content['n_given'] = trim($P_n_given); |
|
2455 | + } |
|
2456 | + if (strlen(trim($P_org_name))>0) |
|
2457 | + { |
|
2458 | + $content['org_name'] = trim($P_org_name); |
|
2459 | + } |
|
2305 | 2460 | } |
2306 | 2461 | } |
2307 | 2462 | } |
@@ -2329,7 +2484,10 @@ discard block |
||
2329 | 2484 | break; |
2330 | 2485 | } |
2331 | 2486 | } |
2332 | - if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content); |
|
2487 | + if (empty($content['n_fn'])) |
|
2488 | + { |
|
2489 | + $content['n_fn'] = $this->fullname($content); |
|
2490 | + } |
|
2333 | 2491 | } |
2334 | 2492 | $content['creator'] = $this->user; |
2335 | 2493 | $content['created'] = $this->now_su; |
@@ -2337,17 +2495,27 @@ discard block |
||
2337 | 2495 | //_debug_array($content); |
2338 | 2496 | } |
2339 | 2497 | |
2340 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2498 | + if ($_GET['msg']) |
|
2499 | + { |
|
2500 | + $content['msg'] = strip_tags($_GET['msg']); |
|
2501 | + } |
|
2502 | + // dont allow HTML! |
|
2341 | 2503 | |
2342 | - if($content && $_GET['makecp']) // copy the contact |
|
2504 | + if($content && $_GET['makecp']) |
|
2505 | + { |
|
2506 | + // copy the contact |
|
2343 | 2507 | { |
2344 | 2508 | $this->copy_contact($content); |
2509 | + } |
|
2345 | 2510 | $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
2346 | 2511 | $view = false; |
2347 | 2512 | } |
2348 | 2513 | else |
2349 | 2514 | { |
2350 | - if (is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id; |
|
2515 | + if (is_numeric($contact_id)) |
|
2516 | + { |
|
2517 | + $content['link_to']['to_id'] = $contact_id; |
|
2518 | + } |
|
2351 | 2519 | } |
2352 | 2520 | // automatic link new entries to entries specified in the url |
2353 | 2521 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
@@ -2356,10 +2524,13 @@ discard block |
||
2356 | 2524 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
2357 | 2525 | { |
2358 | 2526 | $link_id = $link_ids[$n]; |
2359 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
2527 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
2528 | + { |
|
2529 | + // gard against XSS |
|
2360 | 2530 | { |
2361 | 2531 | Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
2362 | 2532 | } |
2533 | + } |
|
2363 | 2534 | } |
2364 | 2535 | } |
2365 | 2536 | } |
@@ -2367,7 +2538,10 @@ discard block |
||
2367 | 2538 | { |
2368 | 2539 | // last and next calendar date |
2369 | 2540 | list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
2370 | - if(is_array($dates)) $content += $dates; |
|
2541 | + if(is_array($dates)) |
|
2542 | + { |
|
2543 | + $content += $dates; |
|
2544 | + } |
|
2371 | 2545 | } |
2372 | 2546 | |
2373 | 2547 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2403,7 +2577,11 @@ discard block |
||
2403 | 2577 | $sel_options['fileas_type'] = $this->fileas_options($content); |
2404 | 2578 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
2405 | 2579 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
2406 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2580 | + if ($content['owner']) |
|
2581 | + { |
|
2582 | + unset($sel_options['owner'][0]); |
|
2583 | + } |
|
2584 | + // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2407 | 2585 | if ((string) $content['owner'] !== '') |
2408 | 2586 | { |
2409 | 2587 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
@@ -2444,7 +2622,10 @@ discard block |
||
2444 | 2622 | } |
2445 | 2623 | } |
2446 | 2624 | |
2447 | - if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
2625 | + if (isset($readonlys['n_fileas'])) |
|
2626 | + { |
|
2627 | + $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
2628 | + } |
|
2448 | 2629 | // disable not needed tabs |
2449 | 2630 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2450 | 2631 | $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
@@ -2452,8 +2633,14 @@ discard block |
||
2452 | 2633 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
2453 | 2634 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2454 | 2635 | $this->account_repository != 'sql' && $content['account_id']; |
2455 | - if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
|
2456 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
2636 | + if (!$content['id']) |
|
2637 | + { |
|
2638 | + $readonlys['button[delete]'] = !$content['id']; |
|
2639 | + } |
|
2640 | + if ($this->config['private_cf_tab']) |
|
2641 | + { |
|
2642 | + $content['no_private_cfs'] = 0; |
|
2643 | + } |
|
2457 | 2644 | $readonlys['change_org'] = empty($content['org_name']) || $view; |
2458 | 2645 | |
2459 | 2646 | // for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl" |
@@ -2501,7 +2688,10 @@ discard block |
||
2501 | 2688 | |
2502 | 2689 | $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']); |
2503 | 2690 | |
2504 | - if ($content['private']) $content['owner'] .= 'p'; |
|
2691 | + if ($content['private']) |
|
2692 | + { |
|
2693 | + $content['owner'] .= 'p'; |
|
2694 | + } |
|
2505 | 2695 | |
2506 | 2696 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
2507 | 2697 | if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
@@ -2524,7 +2714,10 @@ discard block |
||
2524 | 2714 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
2525 | 2715 | foreach($hook_data as $extra_tabs) |
2526 | 2716 | { |
2527 | - if (!$extra_tabs) continue; |
|
2717 | + if (!$extra_tabs) |
|
2718 | + { |
|
2719 | + continue; |
|
2720 | + } |
|
2528 | 2721 | |
2529 | 2722 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
2530 | 2723 | { |
@@ -2541,7 +2734,10 @@ discard block |
||
2541 | 2734 | $readonlys = array_merge($readonlys, $extra_tab['readonlys']); |
2542 | 2735 | } |
2543 | 2736 | // we must NOT add tabs and callbacks more then once! |
2544 | - if (!$first_call) continue; |
|
2737 | + if (!$first_call) |
|
2738 | + { |
|
2739 | + continue; |
|
2740 | + } |
|
2545 | 2741 | |
2546 | 2742 | if (!empty($extra_tab['pre_save_callback'])) |
2547 | 2743 | { |
@@ -2632,13 +2828,16 @@ discard block |
||
2632 | 2828 | // if email changed, check for doublicates |
2633 | 2829 | if (in_array($name, array('email', 'email_home')) && in_array('contact_'.$name, $fields)) |
2634 | 2830 | { |
2635 | - if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) // only search for real email addresses, to not return to many contacts |
|
2831 | + if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) |
|
2832 | + { |
|
2833 | + // only search for real email addresses, to not return to many contacts |
|
2636 | 2834 | { |
2637 | 2835 | $contacts = parent::search(array( |
2638 | 2836 | 'email' => $values[$name], |
2639 | 2837 | 'email_home' => $values[$name], |
2640 | 2838 | ), false, '', '', '', false, 'OR'); |
2641 | 2839 | } |
2840 | + } |
|
2642 | 2841 | } |
2643 | 2842 | else |
2644 | 2843 | { |
@@ -2659,10 +2858,13 @@ discard block |
||
2659 | 2858 | if (in_array($name,$fields) && $specified_count >= 2) |
2660 | 2859 | { |
2661 | 2860 | $filter = array(); |
2662 | - foreach($fields as $n) // use email too, to exclude obvious false positives |
|
2861 | + foreach($fields as $n) |
|
2862 | + { |
|
2863 | + // use email too, to exclude obvious false positives |
|
2663 | 2864 | { |
2664 | 2865 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
2665 | 2866 | } |
2867 | + } |
|
2666 | 2868 | $contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter); |
2667 | 2869 | } |
2668 | 2870 | } |
@@ -2670,7 +2872,10 @@ discard block |
||
2670 | 2872 | { |
2671 | 2873 | foreach($contacts as $contact) |
2672 | 2874 | { |
2673 | - if ($own_id && $contact['id'] == $own_id) continue; |
|
2875 | + if ($own_id && $contact['id'] == $own_id) |
|
2876 | + { |
|
2877 | + continue; |
|
2878 | + } |
|
2674 | 2879 | |
2675 | 2880 | $ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('. |
2676 | 2881 | (!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ? |
@@ -2697,7 +2902,10 @@ discard block |
||
2697 | 2902 | // CRM list comes from content, request, or preference |
2698 | 2903 | $crm_list = $content['crm_list'] ? $content['crm_list'] : |
2699 | 2904 | ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
2700 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2905 | + if(!$crm_list || $crm_list == '~edit~') |
|
2906 | + { |
|
2907 | + $crm_list = 'infolog'; |
|
2908 | + } |
|
2701 | 2909 | |
2702 | 2910 | if(is_array($content)) |
2703 | 2911 | { |
@@ -2720,7 +2928,10 @@ discard block |
||
2720 | 2928 | $inc = 1; |
2721 | 2929 | // fall through |
2722 | 2930 | case 'back': |
2723 | - if (!isset($inc)) $inc = -1; |
|
2931 | + if (!isset($inc)) |
|
2932 | + { |
|
2933 | + $inc = -1; |
|
2934 | + } |
|
2724 | 2935 | // get next/previous contact in selection |
2725 | 2936 | $query = Api\Cache::getSession('addressbook', 'index'); |
2726 | 2937 | $query['start'] = $content['index'] + $inc; |
@@ -2883,11 +3094,20 @@ discard block |
||
2883 | 3094 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
2884 | 3095 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2885 | 3096 | $this->account_repository != 'sql' && $content['account_id']; |
2886 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
3097 | + if ($this->config['private_cf_tab']) |
|
3098 | + { |
|
3099 | + $content['no_private_cfs'] = 0; |
|
3100 | + } |
|
2887 | 3101 | |
2888 | 3102 | // last and next calendar date |
2889 | - if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2890 | - if(is_array($dates)) $content += $dates; |
|
3103 | + if (!empty($content['id'])) |
|
3104 | + { |
|
3105 | + list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
3106 | + } |
|
3107 | + if(is_array($dates)) |
|
3108 | + { |
|
3109 | + $content += $dates; |
|
3110 | + } |
|
2891 | 3111 | |
2892 | 3112 | // Disable importexport |
2893 | 3113 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2966,7 +3186,10 @@ discard block |
||
2966 | 3186 | */ |
2967 | 3187 | function email2link($email) |
2968 | 3188 | { |
2969 | - if (strpos($email,'@') == false) return ''; |
|
3189 | + if (strpos($email,'@') == false) |
|
3190 | + { |
|
3191 | + return ''; |
|
3192 | + } |
|
2970 | 3193 | |
2971 | 3194 | if($GLOBALS['egw_info']['user']['apps']['mail']) |
2972 | 3195 | { |
@@ -3018,7 +3241,10 @@ discard block |
||
3018 | 3241 | $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
3019 | 3242 | foreach ($query['advanced_search'] as $key => $value) |
3020 | 3243 | { |
3021 | - if(!$value) unset($query['advanced_search'][$key]); |
|
3244 | + if(!$value) |
|
3245 | + { |
|
3246 | + unset($query['advanced_search'][$key]); |
|
3247 | + } |
|
3022 | 3248 | } |
3023 | 3249 | // Skip n_fn, it causes problems in sql |
3024 | 3250 | unset($query['advanced_search']['n_fn']); |
@@ -3075,8 +3301,14 @@ discard block |
||
3075 | 3301 | { |
3076 | 3302 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
3077 | 3303 | { |
3078 | - if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
|
3079 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3304 | + if (!isset($content['#'.$name])) |
|
3305 | + { |
|
3306 | + $content['#'.$name] = ''; |
|
3307 | + } |
|
3308 | + if(!isset($data['values'][''])) |
|
3309 | + { |
|
3310 | + $sel_options['#'.$name][''] = lang('Select one'); |
|
3311 | + } |
|
3080 | 3312 | } |
3081 | 3313 | // Make them not required, otherwise you can't search |
3082 | 3314 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -3100,7 +3332,10 @@ discard block |
||
3100 | 3332 | $content['no_tid'] = true; |
3101 | 3333 | $content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default |
3102 | 3334 | |
3103 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
3335 | + if ($this->config['private_cf_tab']) |
|
3336 | + { |
|
3337 | + $content['no_private_cfs'] = 0; |
|
3338 | + } |
|
3104 | 3339 | |
3105 | 3340 | $this->tmpl->set_cell_attribute('change_org','disabled',true); |
3106 | 3341 | return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param string $contact_app |
81 | 81 | */ |
82 | - function __construct($contact_app='addressbook') |
|
82 | + function __construct($contact_app = 'addressbook') |
|
83 | 83 | { |
84 | 84 | parent::__construct($contact_app); |
85 | 85 | |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | ); |
94 | 94 | |
95 | 95 | // make sure the hook for export_limit is registered |
96 | - if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true); |
|
96 | + if (!Api\Hooks::exists('export_limit', 'addressbook')) Api\Hooks::read(true); |
|
97 | 97 | |
98 | - $this->config =& $GLOBALS['egw_info']['server']; |
|
98 | + $this->config = & $GLOBALS['egw_info']['server']; |
|
99 | 99 | |
100 | 100 | // check if a contact specific export limit is set, if yes use it also for etemplate's csv export |
101 | - $this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app='addressbook'); |
|
101 | + $this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app = 'addressbook'); |
|
102 | 102 | |
103 | 103 | if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ? |
104 | 104 | $this->config['copy_fields'] : unserialize($this->config['copy_fields']))) |
105 | 105 | { |
106 | 106 | // Set country code if country name is selected |
107 | - $supported_fields = $this->get_fields('supported',null,0); |
|
108 | - if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$fields)) |
|
107 | + $supported_fields = $this->get_fields('supported', null, 0); |
|
108 | + if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $fields)) |
|
109 | 109 | { |
110 | 110 | $fields[] = 'adr_one_countrycode'; |
111 | 111 | } |
112 | - if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$fields)) |
|
112 | + if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $fields)) |
|
113 | 113 | { |
114 | 114 | $fields[] = 'adr_two_countrycode'; |
115 | 115 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string $msg =null message to show |
126 | 126 | * @param boolean $do_email =false do an email-selection popup or the regular index-page |
127 | 127 | */ |
128 | - function index($_content=null,$msg=null,$do_email=false) |
|
128 | + function index($_content = null, $msg = null, $do_email = false) |
|
129 | 129 | { |
130 | 130 | //echo "<p>uicontacts::index(".print_r($_content,true).",'$msg')</p>\n"; |
131 | 131 | if (($re_submit = is_array($_content))) |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | else |
159 | 159 | { |
160 | 160 | $success = $failed = $action_msg = null; |
161 | - if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], |
|
162 | - $success,$failed,$action_msg,$_content['do_email'] ? 'email' : 'index',$msg,$_content['nm']['checkboxes'])) |
|
161 | + if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'], |
|
162 | + $success, $failed, $action_msg, $_content['do_email'] ? 'email' : 'index', $msg, $_content['nm']['checkboxes'])) |
|
163 | 163 | { |
164 | - $msg .= lang('%1 contact(s) %2',$success,$action_msg); |
|
164 | + $msg .= lang('%1 contact(s) %2', $success, $action_msg); |
|
165 | 165 | Framework::message($msg); |
166 | 166 | } |
167 | - elseif(is_null($msg)) |
|
167 | + elseif (is_null($msg)) |
|
168 | 168 | { |
169 | - $msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
170 | - Framework::message($msg,'error'); |
|
169 | + $msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
170 | + Framework::message($msg, 'error'); |
|
171 | 171 | } |
172 | 172 | $msg = ''; |
173 | 173 | } |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | } |
188 | 188 | $typeselection = $_content['nm']['col_filter']['tid']; |
189 | 189 | } |
190 | - elseif($_GET['add_list']) |
|
190 | + elseif ($_GET['add_list']) |
|
191 | 191 | { |
192 | - $list = $this->add_list($_GET['add_list'],$_GET['owner']?$_GET['owner']:$this->user); |
|
192 | + $list = $this->add_list($_GET['add_list'], $_GET['owner'] ? $_GET['owner'] : $this->user); |
|
193 | 193 | if ($list === true) |
194 | 194 | { |
195 | 195 | $msg = lang('List already exists!'); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ); |
209 | 209 | $to = $_content['nm']['to']; |
210 | 210 | $content = array(); |
211 | - if($msg || $_GET['msg']) |
|
211 | + if ($msg || $_GET['msg']) |
|
212 | 212 | { |
213 | 213 | Framework::message($msg ? $msg : $_GET['msg']); |
214 | 214 | } |
@@ -217,23 +217,23 @@ discard block |
||
217 | 217 | if (!is_array($content['nm'])) |
218 | 218 | { |
219 | 219 | $content['nm'] = array( |
220 | - 'get_rows' => 'addressbook.addressbook_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
221 | - 'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows |
|
222 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie |
|
223 | - 'start' => 0, // IO position in list |
|
224 | - 'cat_id' => '', // IO category, if not 'no_cat' => True |
|
225 | - 'search' => '', // IO search pattern |
|
226 | - 'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders) |
|
227 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
228 | - 'col_filter' => array(), // IO array of column-name value pairs (optional for the filterheaders) |
|
220 | + 'get_rows' => 'addressbook.addressbook_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
221 | + 'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows |
|
222 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie |
|
223 | + 'start' => 0, // IO position in list |
|
224 | + 'cat_id' => '', // IO category, if not 'no_cat' => True |
|
225 | + 'search' => '', // IO search pattern |
|
226 | + 'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders) |
|
227 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
228 | + 'col_filter' => array(), // IO array of column-name value pairs (optional for the filterheaders) |
|
229 | 229 | //'cat_id_label' => lang('Categories'), |
230 | 230 | //'filter_label' => lang('Addressbook'), // I label for filter (optional) |
231 | - 'filter' => '', // =All // IO filter, if not 'no_filter' => True |
|
232 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
233 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
231 | + 'filter' => '', // =All // IO filter, if not 'no_filter' => True |
|
232 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
233 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
234 | 234 | //'filter2_label'=> lang('Distribution lists'), // IO filter2, if not 'no_filter2' => True |
235 | - 'filter2' => '', // IO filter2, if not 'no_filter2' => True |
|
236 | - 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options) |
|
235 | + 'filter2' => '', // IO filter2, if not 'no_filter2' => True |
|
236 | + 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options) |
|
237 | 237 | 'lettersearch' => true, |
238 | 238 | 'do_email' => $do_email ? 1 : 0, |
239 | 239 | // using a positiv list now, as we constantly adding new columns in addressbook, but not removing them from default |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | 'default_cols' => '!cat_id,contact_created_contact_modified,distribution_list,contact_id,owner,room',*/ |
245 | 245 | 'filter2_onchange' => "return app.addressbook.filter2_onchange();", |
246 | 246 | 'filter2_tags' => true, |
247 | - 'manual' => $do_email ? ' ' : false, // space for the manual icon |
|
247 | + 'manual' => $do_email ? ' ' : false, // space for the manual icon |
|
248 | 248 | //'actions' => $this->get_actions(), // set on each request, as it depends on some filters |
249 | 249 | 'row_id' => 'id', |
250 | 250 | 'row_modified' => 'modified', |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | // use the state of the last session stored in the user prefs |
261 | 261 | if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state']))) |
262 | 262 | { |
263 | - $content['nm'] = array_merge($content['nm'],$state); |
|
263 | + $content['nm'] = array_merge($content['nm'], $state); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | $sel_options['cat_id'] = array('' => lang('All categories'), '0' => lang('None')); |
267 | 267 | |
268 | 268 | $content['nm']['placeholder_actions'] = array('add'); |
269 | 269 | // Edit and delete list actions depends on permissions |
270 | - if($this->get_lists(Acl::EDIT)) |
|
270 | + if ($this->get_lists(Acl::EDIT)) |
|
271 | 271 | { |
272 | 272 | $content['nm']['placeholder_actions'][] = 'rename_list'; |
273 | 273 | $content['nm']['placeholder_actions'][] = 'delete_list'; |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; |
281 | 281 | // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys |
282 | 282 | //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); |
283 | - Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); |
|
283 | + Api\Cache::setSession('addressbook', 'active_tid', $content['nm']['col_filter']['tid']); |
|
284 | 284 | if ($this->lists_available()) |
285 | 285 | { |
286 | - $sel_options['filter2'] = $this->get_lists(Acl::READ,array('' => lang('No distribution list'))); |
|
287 | - $sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end |
|
286 | + $sel_options['filter2'] = $this->get_lists(Acl::READ, array('' => lang('No distribution list'))); |
|
287 | + $sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end |
|
288 | 288 | } |
289 | 289 | if ($do_email) |
290 | 290 | { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $content['nm']['header_left'] = 'addressbook.email.left'; |
303 | 303 | } |
304 | 304 | // Organisation stuff is not (yet) availible with ldap |
305 | - elseif($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
|
305 | + elseif ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
|
306 | 306 | { |
307 | 307 | $content['nm']['header_left'] = 'addressbook.index.left'; |
308 | 308 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); |
316 | 316 | |
317 | 317 | // if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export |
318 | - if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
318 | + if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit'] = $this->config['contact_export_limit']; |
|
319 | 319 | |
320 | 320 | // Merge to email dialog needs the infolog types |
321 | 321 | $infolog = new infolog_bo(); |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | // dont show tid-selection if we have only one content_type |
325 | 325 | // be a bit more sophisticated about it |
326 | 326 | $availabletypes = array_keys($this->content_types); |
327 | - if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'],$availabletypes)) |
|
327 | + if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'], $availabletypes)) |
|
328 | 328 | { |
329 | 329 | //_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter')); |
330 | 330 | unset($content['nm']['col_filter']['tid']); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
333 | 333 | if (count($this->content_types) > 1) |
334 | 334 | { |
335 | - foreach($this->content_types as $tid => $data) |
|
335 | + foreach ($this->content_types as $tid => $data) |
|
336 | 336 | { |
337 | 337 | $sel_options['tid'][$tid] = $data['name']; |
338 | 338 | } |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | |
351 | 351 | $content['nm']['actions'] = $this->get_actions($content['nm']['col_filter']['tid']); |
352 | 352 | |
353 | - if (!isset($sel_options['grouped_view'][(string) $content['nm']['grouped_view']])) |
|
353 | + if (!isset($sel_options['grouped_view'][(string)$content['nm']['grouped_view']])) |
|
354 | 354 | { |
355 | 355 | $sel_options['grouped_view'] += $this->_get_grouped_name((string)$content['nm']['grouped_view']); |
356 | 356 | } |
357 | 357 | // unset the filters regarding grouped views, when there is no group selected |
358 | - if (empty($sel_options['grouped_view'][(string) $content['nm']['grouped_view']]) || stripos($grouped_view,":") === false ) |
|
358 | + if (empty($sel_options['grouped_view'][(string)$content['nm']['grouped_view']]) || stripos($grouped_view, ":") === false) |
|
359 | 359 | { |
360 | 360 | $this->unset_grouped_filters($content['nm']); |
361 | 361 | } |
362 | - $content['nm']['grouped_view_label'] = $sel_options['grouped_view'][(string) $content['nm']['grouped_view']]; |
|
362 | + $content['nm']['grouped_view_label'] = $sel_options['grouped_view'][(string)$content['nm']['grouped_view']]; |
|
363 | 363 | |
364 | 364 | $this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index'); |
365 | 365 | return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index', |
366 | - $content,$sel_options,array(),$preserv,$do_email ? 2 : 0); |
|
366 | + $content, $sel_options, array(), $preserv, $do_email ? 2 : 0); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param string $tid_filter =null |
373 | 373 | * @return array see Etemplate\Widget\Nextmatch::get_actions() |
374 | 374 | */ |
375 | - public function get_actions($tid_filter=null) |
|
375 | + public function get_actions($tid_filter = null) |
|
376 | 376 | { |
377 | 377 | // Contact view |
378 | 378 | $actions = array( |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'caption' => 'CRM-View', |
381 | 381 | 'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~', |
382 | 382 | 'allowOnMultiple' => false, |
383 | - 'group' => $group=1, |
|
383 | + 'group' => $group = 1, |
|
384 | 384 | 'onExecute' => 'javaScript:app.addressbook.view', |
385 | 385 | 'enableClass' => 'contact_contact', |
386 | 386 | 'hideOnDisabled' => true, |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | ); |
424 | 424 | // CRM view options |
425 | 425 | $crm_count = 0; |
426 | - $crm_apps = array('infolog','tracker'); |
|
427 | - foreach($crm_apps as $app) |
|
426 | + $crm_apps = array('infolog', 'tracker'); |
|
427 | + foreach ($crm_apps as $app) |
|
428 | 428 | { |
429 | 429 | if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; |
430 | 430 | } |
431 | - if($crm_count > 1) |
|
431 | + if ($crm_count > 1) |
|
432 | 432 | { |
433 | - foreach($crm_apps as $app) |
|
433 | + foreach ($crm_apps as $app) |
|
434 | 434 | { |
435 | 435 | $actions['view']['children']["view-$app"] = array( |
436 | 436 | 'caption' => $app, |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | 'caption' => 'View', |
446 | 446 | 'default' => true, |
447 | 447 | 'allowOnMultiple' => false, |
448 | - 'group' => $group=1, |
|
448 | + 'group' => $group = 1, |
|
449 | 449 | 'enableClass' => 'contact_organisation', |
450 | 450 | 'hideOnDisabled' => true |
451 | 451 | ), |
@@ -466,29 +466,29 @@ discard block |
||
466 | 466 | 'caption' => 'View', |
467 | 467 | 'default' => true, |
468 | 468 | 'allowOnMultiple' => false, |
469 | - 'group' => $group=1, |
|
469 | + 'group' => $group = 1, |
|
470 | 470 | 'enableClass' => 'contact_duplicate', |
471 | 471 | 'hideOnDisabled' => true |
472 | 472 | ) |
473 | 473 | ); |
474 | 474 | |
475 | - ++$group; // other AB related stuff group: lists, AB's, categories |
|
475 | + ++$group; // other AB related stuff group: lists, AB's, categories |
|
476 | 476 | // categories submenu |
477 | 477 | $actions['cat'] = array( |
478 | 478 | 'caption' => 'Categories', |
479 | 479 | 'group' => $group, |
480 | 480 | 'children' => array( |
481 | 481 | 'cat_add' => Etemplate\Widget\Nextmatch::category_action( |
482 | - 'addressbook',$group,'Add category', 'cat_add_', |
|
483 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
484 | - )+array( |
|
482 | + 'addressbook', $group, 'Add category', 'cat_add_', |
|
483 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
484 | + ) + array( |
|
485 | 485 | 'icon' => 'foldertree_nolines_plus', |
486 | 486 | 'disableClass' => 'rowNoEdit', |
487 | 487 | ), |
488 | 488 | 'cat_del' => Etemplate\Widget\Nextmatch::category_action( |
489 | - 'addressbook',$group,'Delete category', 'cat_del_', |
|
490 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
491 | - )+array( |
|
489 | + 'addressbook', $group, 'Delete category', 'cat_del_', |
|
490 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
491 | + ) + array( |
|
492 | 492 | 'icon' => 'foldertree_nolines_minus', |
493 | 493 | 'disableClass' => 'rowNoEdit', |
494 | 494 | ), |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | 'children' => $add_lists, |
516 | 516 | 'prefix' => 'to_list_', |
517 | 517 | 'icon' => 'foldertree_nolines_plus', |
518 | - 'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
518 | + 'enabled' => ($add_lists ?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
519 | 519 | //'disableClass' => 'rowNoEdit', // wether you are allowed to edit the contact or not, as you alter a list, not the contact |
520 | 520 | ), |
521 | 521 | 'remove_from_list' => array( |
@@ -524,14 +524,14 @@ discard block |
||
524 | 524 | 'icon' => 'foldertree_nolines_minus', |
525 | 525 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
526 | 526 | 'fieldId' => 'exec[nm][filter2]', |
527 | - 'fieldValue' => '!', // enable if list != '' |
|
527 | + 'fieldValue' => '!', // enable if list != '' |
|
528 | 528 | ), |
529 | 529 | 'rename_list' => array( |
530 | 530 | 'caption' => 'Rename selected distribution list', |
531 | 531 | 'icon' => 'edit', |
532 | 532 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
533 | 533 | 'fieldId' => 'exec[nm][filter2]', |
534 | - 'fieldValue' => '!', // enable if list != '' |
|
534 | + 'fieldValue' => '!', // enable if list != '' |
|
535 | 535 | 'onExecute' => 'javaScript:app.addressbook.rename_list' |
536 | 536 | ), |
537 | 537 | 'delete_list' => array( |
@@ -540,10 +540,10 @@ discard block |
||
540 | 540 | 'icon' => 'delete', |
541 | 541 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
542 | 542 | 'fieldId' => 'exec[nm][filter2]', |
543 | - 'fieldValue' => '!', // enable if list != '' |
|
543 | + 'fieldValue' => '!', // enable if list != '' |
|
544 | 544 | ), |
545 | 545 | ); |
546 | - if(is_subclass_of('etemplate', 'etemplate_new')) |
|
546 | + if (is_subclass_of('etemplate', 'etemplate_new')) |
|
547 | 547 | { |
548 | 548 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
549 | 549 | $actions['lists']['children']['rename_list']['fieldId'] = 'filter2'; |
@@ -553,18 +553,18 @@ discard block |
||
553 | 553 | // move to AB |
554 | 554 | if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
555 | 555 | { |
556 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
557 | - foreach($move2addressbooks as $owner => $label) |
|
556 | + unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
557 | + foreach ($move2addressbooks as $owner => $label) |
|
558 | 558 | { |
559 | 559 | $icon = $type_label = null; |
560 | - $this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label); |
|
560 | + $this->type_icon((int)$owner, substr($owner, -1) == 'p', 'n', $icon, $type_label); |
|
561 | 561 | $move2addressbooks[$owner] = array( |
562 | 562 | 'icon' => $icon, |
563 | 563 | 'caption' => $label, |
564 | 564 | ); |
565 | 565 | } |
566 | 566 | // copy checkbox |
567 | - $move2addressbooks= array( |
|
567 | + $move2addressbooks = array( |
|
568 | 568 | 'copy' =>array( |
569 | 569 | 'id' => 'move_to_copy', |
570 | 570 | 'caption' => 'Copy instead of move', |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | 'hideOnDisabled' => true |
598 | 598 | ); |
599 | 599 | |
600 | - ++$group; // integration with other apps: infolog, calendar, filemanager |
|
600 | + ++$group; // integration with other apps: infolog, calendar, filemanager |
|
601 | 601 | if ($GLOBALS['egw_info']['user']['apps']['infolog']) |
602 | 602 | { |
603 | 603 | $actions['infolog_app'] = array( |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | 'icon' => 'new', |
619 | 619 | 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id', |
620 | 620 | 'popup' => Link::get_registry('infolog', 'add_popup'), |
621 | - 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
621 | + 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
622 | 622 | ), |
623 | 623 | ), |
624 | 624 | 'hideOnMobile' => true |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | 'caption' => 'Show', |
637 | 637 | 'icon' => 'view', |
638 | 638 | 'onExecute' => 'javaScript:app.addressbook.view_calendar', |
639 | - 'targetapp' => 'calendar', // open in calendar tab, |
|
639 | + 'targetapp' => 'calendar', // open in calendar tab, |
|
640 | 640 | 'hideOnDisabled' => true, |
641 | 641 | ), |
642 | 642 | 'calendar_add' => array( |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | 'icon' => 'map', |
717 | 717 | 'group' => ++$group, |
718 | 718 | 'enableClass' => 'contact_contact', |
719 | - 'children' => array ( |
|
719 | + 'children' => array( |
|
720 | 720 | 'private' => array( |
721 | 721 | 'caption' => 'Private Address', |
722 | 722 | 'enabled' => 'javaScript:app.addressbook.geoLocation_enabled', |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | ); |
734 | 734 | // check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no) |
735 | 735 | $exception = Api\Storage\Merge::is_export_limit_excepted(); |
736 | - if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
736 | + if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
737 | 737 | { |
738 | 738 | $actions['export'] = array( |
739 | 739 | 'caption' => 'Export', |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | ), |
750 | 750 | 'vcard' => array( |
751 | 751 | 'caption' => 'Export as VCard', |
752 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
752 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
753 | 753 | 'icon' => Vfs::mime_icon('text/vcard'), |
754 | 754 | ), |
755 | 755 | ), |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $this->prefs['document_dir'], $group, 'Insert in document', 'document_', |
762 | 762 | $this->prefs['default_document'], $this->config['contact_export_limit'] |
763 | 763 | ); |
764 | - if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail']||$GLOBALS['egw_info']['user']['apps']['mail'])) |
|
764 | + if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail'])) |
|
765 | 765 | { |
766 | 766 | $actions['mail'] = array( |
767 | 767 | 'caption' => lang('Mail VCard'), |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | 'disableClass' => 'rowNoDelete', |
785 | 785 | ); |
786 | 786 | } |
787 | - if ($this->grants[0] & Acl::DELETE) |
|
787 | + if ($this->grants[0]&Acl::DELETE) |
|
788 | 788 | { |
789 | 789 | $actions['delete_account'] = array( |
790 | 790 | 'caption' => 'Delete', |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | ); |
798 | 798 | $actions['delete']['hideOnDisabled'] = true; |
799 | 799 | } |
800 | - if($tid_filter == 'D') |
|
800 | + if ($tid_filter == 'D') |
|
801 | 801 | { |
802 | 802 | $actions['undelete'] = array( |
803 | 803 | 'caption' => 'Un-delete', |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | } |
809 | 809 | if (isset($actions['export']['children']['csv']) && |
810 | 810 | (!isset($GLOBALS['egw_info']['user']['apps']['importexport']) || |
811 | - !importexport_helper_functions::has_definitions('addressbook','export'))) |
|
811 | + !importexport_helper_functions::has_definitions('addressbook', 'export'))) |
|
812 | 812 | { |
813 | 813 | unset($actions['export']['children']['csv']); |
814 | 814 | } |
@@ -843,13 +843,13 @@ discard block |
||
843 | 843 | protected function _get_grouped_name($view_id) |
844 | 844 | { |
845 | 845 | $group_name = array(); |
846 | - if (strpos($view_id,'*AND*')!== false) $view_id = str_replace('*AND*','&',$view_id); |
|
847 | - foreach(explode('|||',$view_id) as $part) |
|
846 | + if (strpos($view_id, '*AND*') !== false) $view_id = str_replace('*AND*', '&', $view_id); |
|
847 | + foreach (explode('|||', $view_id) as $part) |
|
848 | 848 | { |
849 | - list(,$name) = explode(':',$part,2); |
|
849 | + list(,$name) = explode(':', $part, 2); |
|
850 | 850 | if ($name) $group_name[] = $name; |
851 | 851 | } |
852 | - $name = implode(': ',$group_name); |
|
852 | + $name = implode(': ', $group_name); |
|
853 | 853 | return $name ? array($view_id => $name) : array(); |
854 | 854 | } |
855 | 855 | |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | unset($query['col_filter']['org_name']); |
864 | 864 | unset($query['col_filter']['org_unit']); |
865 | 865 | unset($query['col_filter']['adr_one_locality']); |
866 | - foreach(array_keys(static::$duplicate_fields) as $field) |
|
866 | + foreach (array_keys(static::$duplicate_fields) as $field) |
|
867 | 867 | { |
868 | 868 | unset($query['col_filter'][$field]); |
869 | 869 | } |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | // Query doesn't like empties |
882 | 882 | unset($query['col_filter']['parent_id']); |
883 | 883 | |
884 | - if($query['actions'] && $query['actions']['open']) |
|
884 | + if ($query['actions'] && $query['actions']['open']) |
|
885 | 885 | { |
886 | 886 | // Just switched from contact view, update actions |
887 | 887 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
@@ -909,10 +909,10 @@ discard block |
||
909 | 909 | } |
910 | 910 | $query['org_view'] = $query['grouped_view']; |
911 | 911 | // switch the distribution list selection off for ldap |
912 | - if($this->contact_repository != 'sql') |
|
912 | + if ($this->contact_repository != 'sql') |
|
913 | 913 | { |
914 | 914 | $query['no_filter2'] = true; |
915 | - unset($query['col_filter']['list']); // does not work here |
|
915 | + unset($query['col_filter']['list']); // does not work here |
|
916 | 916 | } |
917 | 917 | else |
918 | 918 | { |
@@ -920,8 +920,8 @@ discard block |
||
920 | 920 | } |
921 | 921 | break; |
922 | 922 | case 'addressbook.index.duplicate_rows': |
923 | - $query['no_filter2'] = true; // switch the distribution list selection off |
|
924 | - unset($query['col_filter']['list']); // does not work for duplicates |
|
923 | + $query['no_filter2'] = true; // switch the distribution list selection off |
|
924 | + unset($query['col_filter']['list']); // does not work for duplicates |
|
925 | 925 | $rows = parent::duplicates($query); |
926 | 926 | break; |
927 | 927 | } |
@@ -943,12 +943,12 @@ discard block |
||
943 | 943 | * @param array $content =null submitted content |
944 | 944 | * @param string $msg =null message to show |
945 | 945 | */ |
946 | - function emailpopup($content=null,$msg=null) |
|
946 | + function emailpopup($content = null, $msg = null) |
|
947 | 947 | { |
948 | - if (strpos($GLOBALS['egw_info']['flags']['java_script'],'addEmail') === false) |
|
948 | + if (strpos($GLOBALS['egw_info']['flags']['java_script'], 'addEmail') === false) |
|
949 | 949 | { |
950 | 950 | $handler = 'opener.addEmail(to,email)'; |
951 | - $GLOBALS['egw_info']['flags']['java_script'].= " |
|
951 | + $GLOBALS['egw_info']['flags']['java_script'] .= " |
|
952 | 952 | <script> |
953 | 953 | window.egw_LAB.wait(function() { |
954 | 954 | window.focus(); |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | </script> |
979 | 979 | "; |
980 | 980 | } |
981 | - return $this->index($content,$msg,true); |
|
981 | + return $this->index($content, $msg, true); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -992,19 +992,19 @@ discard block |
||
992 | 992 | { |
993 | 993 | $org_contacts = array(); |
994 | 994 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
995 | - $query['num_rows'] = -1; // all |
|
996 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
995 | + $query['num_rows'] = -1; // all |
|
996 | + if (!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
997 | 997 | |
998 | - if(!is_array($org)) $org = array($org); |
|
999 | - foreach($org as $org_name) |
|
998 | + if (!is_array($org)) $org = array($org); |
|
999 | + foreach ($org as $org_name) |
|
1000 | 1000 | { |
1001 | 1001 | $query['grouped_view'] = $org_name; |
1002 | 1002 | $checked = array(); |
1003 | 1003 | $readonlys = null; |
1004 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
1005 | - if($checked[0]) |
|
1004 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
1005 | + if ($checked[0]) |
|
1006 | 1006 | { |
1007 | - $org_contacts = array_merge($org_contacts,$checked); |
|
1007 | + $org_contacts = array_merge($org_contacts, $checked); |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | Api\Json\Response::get()->data(array_unique($org_contacts)); |
@@ -1018,33 +1018,33 @@ discard block |
||
1018 | 1018 | function infolog_org_view($org) |
1019 | 1019 | { |
1020 | 1020 | $query = Api\Cache::getSession('addressbook', 'index'); |
1021 | - $query['num_rows'] = -1; // all |
|
1021 | + $query['num_rows'] = -1; // all |
|
1022 | 1022 | $query['grouped_view'] = $org; |
1023 | 1023 | $query['searchletter'] = ''; |
1024 | 1024 | $checked = $readonlys = null; |
1025 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
1025 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
1026 | 1026 | |
1027 | 1027 | if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
1028 | 1028 | { |
1029 | 1029 | $parts = array(); |
1030 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
1031 | - foreach(explode('|||',$org) as $part) |
|
1030 | + if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org); |
|
1031 | + foreach (explode('|||', $org) as $part) |
|
1032 | 1032 | { |
1033 | - list(,$part) = explode(':',$part,2); |
|
1033 | + list(,$part) = explode(':', $part, 2); |
|
1034 | 1034 | if ($part) $parts[] = $part; |
1035 | 1035 | } |
1036 | - $org = implode(', ',$parts); |
|
1036 | + $org = implode(', ', $parts); |
|
1037 | 1037 | } |
1038 | 1038 | else |
1039 | 1039 | { |
1040 | - $org = ''; // use infolog default of link-title |
|
1040 | + $org = ''; // use infolog default of link-title |
|
1041 | 1041 | } |
1042 | - Egw::redirect_link('/index.php',array( |
|
1042 | + Egw::redirect_link('/index.php', array( |
|
1043 | 1043 | 'menuaction' => 'infolog.infolog_ui.index', |
1044 | 1044 | 'action' => 'addressbook', |
1045 | - 'action_id' => implode(',',$checked), |
|
1045 | + 'action_id' => implode(',', $checked), |
|
1046 | 1046 | 'action_title' => $org, |
1047 | - ),'infolog'); |
|
1047 | + ), 'infolog'); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | /** |
@@ -1069,31 +1069,31 @@ discard block |
||
1069 | 1069 | $owner = $this->default_addressbook; |
1070 | 1070 | } |
1071 | 1071 | // Check for valid list & permissions |
1072 | - if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) |
|
1072 | + if (!(int)$list_id && !$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner)) |
|
1073 | 1073 | { |
1074 | - Api\Json\Response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error')); |
|
1074 | + Api\Json\Response::get()->apply('egw.message', array(lang('List creation failed, no rights!'), 'error')); |
|
1075 | 1075 | return; |
1076 | 1076 | } |
1077 | 1077 | if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner)) |
1078 | 1078 | { |
1079 | - Api\Json\Response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error')); |
|
1079 | + Api\Json\Response::get()->apply('egw.message', array(lang('Insufficent rights to edit this list!'), 'error')); |
|
1080 | 1080 | return; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | $list = array('list_owner' => $owner); |
1084 | 1084 | |
1085 | 1085 | // Rename |
1086 | - if($list_id) |
|
1086 | + if ($list_id) |
|
1087 | 1087 | { |
1088 | 1088 | $list = $this->read_list((int)$list_id); |
1089 | 1089 | } |
1090 | 1090 | $list['list_name'] = $new_name; |
1091 | 1091 | |
1092 | - $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list); |
|
1092 | + $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'], array(), $list); |
|
1093 | 1093 | |
1094 | - if($contacts) |
|
1094 | + if ($contacts) |
|
1095 | 1095 | { |
1096 | - $this->add2list($contacts,$new_id); |
|
1096 | + $this->add2list($contacts, $new_id); |
|
1097 | 1097 | } |
1098 | 1098 | Api\Json\Response::get()->apply('egw.message', array( |
1099 | 1099 | $new_id == $list_id ? lang('Distribution list renamed') : lang('List created'), |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | * |
1109 | 1109 | * @param string $account_id |
1110 | 1110 | */ |
1111 | - function ajax_get_contact ($account_id) |
|
1111 | + function ajax_get_contact($account_id) |
|
1112 | 1112 | { |
1113 | 1113 | $bo = new Api\Contacts(); |
1114 | 1114 | $contact = $bo->read('account:'.$account_id); |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | { |
1126 | 1126 | $query = Api\Cache::getSession('addressbook', 'index'); |
1127 | 1127 | unset($query['advanced_search']); |
1128 | - Api\Cache::setSession('addressbook','index',$query); |
|
1128 | + Api\Cache::setSession('addressbook', 'index', $query); |
|
1129 | 1129 | Api\Cache::setSession('addressbook', 'advanced_search', false); |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1141,60 +1141,60 @@ discard block |
||
1141 | 1141 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
1142 | 1142 | * @return boolean true if all actions succeded, false otherwise |
1143 | 1143 | */ |
1144 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL) |
|
1144 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $checkboxes = NULL) |
|
1145 | 1145 | { |
1146 | 1146 | //echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n"; |
1147 | 1147 | $success = $failed = 0; |
1148 | - if ($use_all || in_array($action,array('remove_from_list','delete_list'))) |
|
1148 | + if ($use_all || in_array($action, array('remove_from_list', 'delete_list'))) |
|
1149 | 1149 | { |
1150 | 1150 | // get the whole selection |
1151 | 1151 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); |
1152 | 1152 | |
1153 | 1153 | if ($use_all) |
1154 | 1154 | { |
1155 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1156 | - $query['num_rows'] = -1; // all |
|
1155 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1156 | + $query['num_rows'] = -1; // all |
|
1157 | 1157 | $readonlys = null; |
1158 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
1158 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
1159 | 1159 | } |
1160 | 1160 | } |
1161 | 1161 | // replace org_name:* id's with all id's of that org |
1162 | - $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success,$failed,$action_msg,$session_name, $msg); |
|
1163 | - if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1162 | + $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success, $failed, $action_msg, $session_name, $msg); |
|
1163 | + if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked, $grouped_contacts) : $grouped_contacts); |
|
1164 | 1164 | //_debug_array($checked); exit; |
1165 | 1165 | |
1166 | - if (substr($action,0,8) == 'move_to_') |
|
1166 | + if (substr($action, 0, 8) == 'move_to_') |
|
1167 | 1167 | { |
1168 | - $action = (int)substr($action,8).(substr($action,-1) == 'p' ? 'p' : ''); |
|
1168 | + $action = (int)substr($action, 8).(substr($action, -1) == 'p' ? 'p' : ''); |
|
1169 | 1169 | } |
1170 | - elseif (substr($action,0,8) == 'to_list_') |
|
1170 | + elseif (substr($action, 0, 8) == 'to_list_') |
|
1171 | 1171 | { |
1172 | - $to_list = (int)substr($action,8); |
|
1172 | + $to_list = (int)substr($action, 8); |
|
1173 | 1173 | $action = 'to_list'; |
1174 | 1174 | } |
1175 | - elseif (substr($action,0,9) == 'document_') |
|
1175 | + elseif (substr($action, 0, 9) == 'document_') |
|
1176 | 1176 | { |
1177 | - $document = substr($action,9); |
|
1177 | + $document = substr($action, 9); |
|
1178 | 1178 | $action = 'document'; |
1179 | 1179 | } |
1180 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1180 | + elseif (substr($action, 0, 4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1181 | 1181 | { |
1182 | 1182 | $cat_id = (int)substr($action, 8); |
1183 | - $action = substr($action,0,7); |
|
1183 | + $action = substr($action, 0, 7); |
|
1184 | 1184 | } |
1185 | 1185 | // Security: stop non-admins to export more then the configured number of contacts |
1186 | - if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
1186 | + if (in_array($action, array('csv', 'vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
1187 | 1187 | (!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit'])) |
1188 | 1188 | { |
1189 | 1189 | $action_msg = lang('exported'); |
1190 | 1190 | $failed = count($checked); |
1191 | 1191 | return false; |
1192 | 1192 | } |
1193 | - switch($action) |
|
1193 | + switch ($action) |
|
1194 | 1194 | { |
1195 | 1195 | case 'vcard': |
1196 | 1196 | $action_msg = lang('exported'); |
1197 | - $vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
1197 | + $vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
1198 | 1198 | $vcard->export($checked); |
1199 | 1199 | // does not return! |
1200 | 1200 | $Ok = false; |
@@ -1202,10 +1202,10 @@ discard block |
||
1202 | 1202 | |
1203 | 1203 | case 'merge': |
1204 | 1204 | $error_msg = null; |
1205 | - $success = $this->merge($checked,$error_msg); |
|
1205 | + $success = $this->merge($checked, $error_msg); |
|
1206 | 1206 | $failed = count($checked) - (int)$success; |
1207 | 1207 | $action_msg = lang('merged'); |
1208 | - $checked = array(); // to not start the single actions |
|
1208 | + $checked = array(); // to not start the single actions |
|
1209 | 1209 | break; |
1210 | 1210 | |
1211 | 1211 | case 'delete_list': |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | { |
1214 | 1214 | $msg = lang('You need to select a distribution list'); |
1215 | 1215 | } |
1216 | - elseif($this->delete_list($query['filter2']) === false) |
|
1216 | + elseif ($this->delete_list($query['filter2']) === false) |
|
1217 | 1217 | { |
1218 | 1218 | $msg = lang('Insufficent rights to delete this list!'); |
1219 | 1219 | } |
@@ -1233,49 +1233,49 @@ discard block |
||
1233 | 1233 | return false; |
1234 | 1234 | |
1235 | 1235 | case 'infolog_add': |
1236 | - Framework::popup(Egw::link('/index.php',array( |
|
1236 | + Framework::popup(Egw::link('/index.php', array( |
|
1237 | 1237 | 'menuaction' => 'infolog.infolog_ui.edit', |
1238 | 1238 | 'type' => 'task', |
1239 | 1239 | 'action' => 'addressbook', |
1240 | - 'action_id' => implode(',',$checked), |
|
1241 | - )),'_blank',Link::get_registry('infolog', 'add_popup')); |
|
1242 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1240 | + 'action_id' => implode(',', $checked), |
|
1241 | + )), '_blank', Link::get_registry('infolog', 'add_popup')); |
|
1242 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1243 | 1243 | return false; |
1244 | 1244 | |
1245 | 1245 | case 'calendar_add': // add appointment for org-views, other views are handled directly in javascript |
1246 | - Framework::popup(Egw::link('/index.php',array( |
|
1246 | + Framework::popup(Egw::link('/index.php', array( |
|
1247 | 1247 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1248 | - 'participants' => 'c'.implode(',c',$checked), |
|
1249 | - )),'_blank',Link::get_registry('calendar', 'add_popup')); |
|
1250 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1248 | + 'participants' => 'c'.implode(',c', $checked), |
|
1249 | + )), '_blank', Link::get_registry('calendar', 'add_popup')); |
|
1250 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1251 | 1251 | return false; |
1252 | 1252 | |
1253 | 1253 | case 'calendar_view': // show calendar for org-views, although all views are handled directly in javascript |
1254 | - Egw::redirect_link('/index.php',array( |
|
1254 | + Egw::redirect_link('/index.php', array( |
|
1255 | 1255 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1256 | - 'owner' => 'c'.implode(',c',$checked), |
|
1256 | + 'owner' => 'c'.implode(',c', $checked), |
|
1257 | 1257 | )); |
1258 | 1258 | } |
1259 | - foreach($checked as $id) |
|
1259 | + foreach ($checked as $id) |
|
1260 | 1260 | { |
1261 | - switch($action) |
|
1261 | + switch ($action) |
|
1262 | 1262 | { |
1263 | 1263 | case 'cat_add': |
1264 | 1264 | case 'cat_del': |
1265 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact))) |
|
1265 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT, $contact))) |
|
1266 | 1266 | { |
1267 | 1267 | $action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete'); |
1268 | - $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
1268 | + $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
1269 | 1269 | if ($action == 'cat_add') |
1270 | 1270 | { |
1271 | 1271 | $cat_ids[] = $cat_id; |
1272 | 1272 | $cat_ids = array_unique($cat_ids); |
1273 | 1273 | } |
1274 | - elseif ((($key = array_search($cat_id,$cat_ids))) !== false) |
|
1274 | + elseif ((($key = array_search($cat_id, $cat_ids))) !== false) |
|
1275 | 1275 | { |
1276 | 1276 | unset($cat_ids[$key]); |
1277 | 1277 | } |
1278 | - $ids = $cat_ids ? implode(',',$cat_ids) : null; |
|
1278 | + $ids = $cat_ids ? implode(',', $cat_ids) : null; |
|
1279 | 1279 | if ($ids !== $contact['cat_id']) |
1280 | 1280 | { |
1281 | 1281 | $contact['cat_id'] = $ids; |
@@ -1286,10 +1286,10 @@ discard block |
||
1286 | 1286 | |
1287 | 1287 | case 'delete': |
1288 | 1288 | $action_msg = lang('deleted'); |
1289 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
1289 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
1290 | 1290 | { |
1291 | - if ($contact['owner'] || // regular contact or |
|
1292 | - empty($contact['account_id']) || // accounts without account_id |
|
1291 | + if ($contact['owner'] || // regular contact or |
|
1292 | + empty($contact['account_id']) || // accounts without account_id |
|
1293 | 1293 | // already deleted account (should no longer happen, but needed to allow for cleanup) |
1294 | 1294 | $contact['tid'] == self::DELETED_TYPE) |
1295 | 1295 | { |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | // delete single account --> redirect to admin |
1299 | 1299 | elseif (count($checked) == 1 && $contact['account_id']) |
1300 | 1300 | { |
1301 | - Egw::redirect_link('/index.php',array( |
|
1301 | + Egw::redirect_link('/index.php', array( |
|
1302 | 1302 | 'menuaction' => 'admin.admin_account.delete', |
1303 | 1303 | 'account_id' => $contact['account_id'], |
1304 | 1304 | )); |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | } |
1361 | 1361 | else |
1362 | 1362 | { |
1363 | - $Ok = $this->remove_from_list($id,$query['filter2']) !== false; |
|
1363 | + $Ok = $this->remove_from_list($id, $query['filter2']) !== false; |
|
1364 | 1364 | } |
1365 | 1365 | break; |
1366 | 1366 | |
@@ -1373,28 +1373,28 @@ discard block |
||
1373 | 1373 | } |
1374 | 1374 | else |
1375 | 1375 | { |
1376 | - $Ok = $this->add2list($id,$to_list) !== false; |
|
1376 | + $Ok = $this->add2list($id, $to_list) !== false; |
|
1377 | 1377 | } |
1378 | 1378 | break; |
1379 | 1379 | |
1380 | 1380 | default: // move to an other addressbook |
1381 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
1381 | + if (!(int)$action || !($this->grants[(string)(int)$action]&Acl::EDIT)) // might be ADD in the future |
|
1382 | 1382 | { |
1383 | 1383 | return false; |
1384 | 1384 | } |
1385 | 1385 | if (!$checkboxes['move_to_copy']) |
1386 | 1386 | { |
1387 | 1387 | $action_msg = lang('moved'); |
1388 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
1388 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
1389 | 1389 | { |
1390 | 1390 | if (!$contact['owner']) // no (mass-)move of Api\Accounts |
1391 | 1391 | { |
1392 | 1392 | $Ok = false; |
1393 | 1393 | } |
1394 | - elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
1394 | + elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
1395 | 1395 | { |
1396 | - $contact['owner'] = (int) $action; |
|
1397 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
1396 | + $contact['owner'] = (int)$action; |
|
1397 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
1398 | 1398 | $Ok = $this->save($contact); |
1399 | 1399 | } |
1400 | 1400 | } |
@@ -1402,14 +1402,14 @@ discard block |
||
1402 | 1402 | else |
1403 | 1403 | { |
1404 | 1404 | $action_msg = lang('copied'); |
1405 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact))) |
|
1405 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ, $contact))) |
|
1406 | 1406 | { |
1407 | - if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
1407 | + if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
1408 | 1408 | { |
1409 | - $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
1409 | + $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
1410 | 1410 | $links = $contact['link_to']['to_id']; |
1411 | - $contact['owner'] = (int) $action; |
|
1412 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
1411 | + $contact['owner'] = (int)$action; |
|
1412 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
1413 | 1413 | $Ok = $this->save($contact); |
1414 | 1414 | if ($Ok && is_array($links)) |
1415 | 1415 | { |
@@ -1448,38 +1448,38 @@ discard block |
||
1448 | 1448 | * |
1449 | 1449 | * @return array List of contact IDs in the provided groups |
1450 | 1450 | */ |
1451 | - protected function find_grouped_ids($action,&$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
1451 | + protected function find_grouped_ids($action, &$checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
1452 | 1452 | { |
1453 | 1453 | unset($use_all); |
1454 | 1454 | $grouped_contacts = array(); |
1455 | - foreach((array)$checked as $n => $id) |
|
1455 | + foreach ((array)$checked as $n => $id) |
|
1456 | 1456 | { |
1457 | - if (substr($id,0,9) == 'org_name:' || substr($id, 0,10) == 'duplicate:') |
|
1457 | + if (substr($id, 0, 9) == 'org_name:' || substr($id, 0, 10) == 'duplicate:') |
|
1458 | 1458 | { |
1459 | 1459 | if (count($checked) == 1 && !count($grouped_contacts) && $action == 'infolog') |
1460 | 1460 | { |
1461 | - return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
1461 | + return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
1462 | 1462 | } |
1463 | 1463 | unset($checked[$n]); |
1464 | 1464 | $query = Api\Cache::getSession('addressbook', $session_name); |
1465 | - $query['num_rows'] = -1; // all |
|
1465 | + $query['num_rows'] = -1; // all |
|
1466 | 1466 | $query['grouped_view'] = $id; |
1467 | 1467 | unset($query['filter2']); |
1468 | 1468 | $extra = $readonlys = null; |
1469 | - $this->get_rows($query,$extra,$readonlys,true); // true = only return the id's |
|
1469 | + $this->get_rows($query, $extra, $readonlys, true); // true = only return the id's |
|
1470 | 1470 | |
1471 | 1471 | // Merge them here, so we only merge the ones that are duplicates, |
1472 | 1472 | // not merge all selected together |
1473 | - if($action == 'merge_duplicates') |
|
1473 | + if ($action == 'merge_duplicates') |
|
1474 | 1474 | { |
1475 | 1475 | $loop_success = $loop_fail = 0; |
1476 | - $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg,$session_name,$msg); |
|
1476 | + $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg, $session_name, $msg); |
|
1477 | 1477 | $success += $loop_success; |
1478 | 1478 | $failed += $loop_fail; |
1479 | 1479 | } |
1480 | 1480 | if ($extra[0]) |
1481 | 1481 | { |
1482 | - $grouped_contacts = array_merge($grouped_contacts,$extra); |
|
1482 | + $grouped_contacts = array_merge($grouped_contacts, $extra); |
|
1483 | 1483 | } |
1484 | 1484 | } |
1485 | 1485 | } |
@@ -1495,22 +1495,22 @@ discard block |
||
1495 | 1495 | * @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name), |
1496 | 1496 | * false: copy everything, but never to copy fields |
1497 | 1497 | */ |
1498 | - function copy_contact(array &$content, $only_copy_fields=true) |
|
1498 | + function copy_contact(array &$content, $only_copy_fields = true) |
|
1499 | 1499 | { |
1500 | 1500 | $content['link_to']['to_id'] = 0; |
1501 | - Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'], |
|
1502 | - lang('Copied by %1, from record #%2.',Api\Accounts::format_username('', |
|
1503 | - $GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']), |
|
1501 | + Link::link('addressbook', $content['link_to']['to_id'], 'addressbook', $content['id'], |
|
1502 | + lang('Copied by %1, from record #%2.', Api\Accounts::format_username('', |
|
1503 | + $GLOBALS['egw_info']['user']['account_firstname'], $GLOBALS['egw_info']['user']['account_lastname']), |
|
1504 | 1504 | $content['id'])); |
1505 | 1505 | // create a new contact with the content of the old |
1506 | - foreach(array_keys($content) as $key) |
|
1506 | + foreach (array_keys($content) as $key) |
|
1507 | 1507 | { |
1508 | - if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid'))) |
|
1508 | + if ($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id', 'etag', 'carddav_name', 'uid'))) |
|
1509 | 1509 | { |
1510 | 1510 | unset($content[$key]); |
1511 | 1511 | } |
1512 | 1512 | } |
1513 | - if(!isset($content['owner'])) |
|
1513 | + if (!isset($content['owner'])) |
|
1514 | 1514 | { |
1515 | 1515 | $content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook; |
1516 | 1516 | } |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session |
1529 | 1529 | * @return int total number of contacts matching the selection |
1530 | 1530 | */ |
1531 | - function get_rows(&$query,&$rows,&$readonlys,$id_only=false) |
|
1531 | + function get_rows(&$query, &$rows, &$readonlys, $id_only = false) |
|
1532 | 1532 | { |
1533 | 1533 | $do_email = $query['do_email']; |
1534 | 1534 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index'); |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | { |
1538 | 1538 | $store_query = $query; |
1539 | 1539 | // Do not store these |
1540 | - foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
|
1540 | + foreach (array('options-cat_id', 'actions', 'action_links', 'placeholder_actions') as $key) |
|
1541 | 1541 | { |
1542 | 1542 | unset($store_query[$key]); |
1543 | 1543 | } |
@@ -1548,28 +1548,28 @@ discard block |
||
1548 | 1548 | { |
1549 | 1549 | $old_state = Api\Cache::getSession('addressbook', $what); |
1550 | 1550 | } |
1551 | - if (!isset($this->grouped_views[(string) $query['grouped_view']]) || strpos($query['grouped_view'],':') === false) |
|
1551 | + if (!isset($this->grouped_views[(string)$query['grouped_view']]) || strpos($query['grouped_view'], ':') === false) |
|
1552 | 1552 | { |
1553 | 1553 | // we don't have a grouped view, unset the according col_filters |
1554 | 1554 | $this->unset_grouped_filters($query); |
1555 | 1555 | } |
1556 | 1556 | |
1557 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
1557 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
1558 | 1558 | { |
1559 | 1559 | // we have a grouped view, reset the advanced search |
1560 | - if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1560 | + if (!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1561 | 1561 | } |
1562 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
1562 | + elseif (!$query['search'] && array_key_exists('advanced_search', $old_state)) // eg. paging in an advanced search |
|
1563 | 1563 | { |
1564 | 1564 | $query['advanced_search'] = $old_state['advanced_search']; |
1565 | 1565 | } |
1566 | 1566 | |
1567 | 1567 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
1568 | - foreach($query['col_filter'] as $key => $col_filter) |
|
1568 | + foreach ($query['col_filter'] as $key => $col_filter) |
|
1569 | 1569 | { |
1570 | - if(!is_numeric($key)) continue; |
|
1571 | - if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
1572 | - ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i',$col_filter) == 1 |
|
1570 | + if (!is_numeric($key)) continue; |
|
1571 | + if (preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
1572 | + ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i', $col_filter) == 1 |
|
1573 | 1573 | ) |
1574 | 1574 | { |
1575 | 1575 | unset($query['col_filter'][$key]); |
@@ -1584,16 +1584,16 @@ discard block |
||
1584 | 1584 | { |
1585 | 1585 | if ($old_state['filter'] === '0') // user changed to org_view |
1586 | 1586 | { |
1587 | - $query['filter'] = ''; // --> change filter to all contacts |
|
1587 | + $query['filter'] = ''; // --> change filter to all contacts |
|
1588 | 1588 | } |
1589 | 1589 | else // user changed to accounts |
1590 | 1590 | { |
1591 | - $query['grouped_view'] = ''; // --> change to regular contacts view |
|
1591 | + $query['grouped_view'] = ''; // --> change to regular contacts view |
|
1592 | 1592 | } |
1593 | 1593 | } |
1594 | 1594 | if ($query['grouped_view'] && isset($this->grouped_views[$old_state['grouped_view']]) && !isset($this->grouped_views[$query['grouped_view']])) |
1595 | 1595 | { |
1596 | - $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
1596 | + $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
1597 | 1597 | } |
1598 | 1598 | // save the state of the index in the user prefs |
1599 | 1599 | $state = serialize(array( |
@@ -1606,9 +1606,9 @@ discard block |
||
1606 | 1606 | )); |
1607 | 1607 | if ($state != $this->prefs[$what.'_state'] && !$query['csv_export']) |
1608 | 1608 | { |
1609 | - $GLOBALS['egw']->preferences->add('addressbook',$what.'_state',$state); |
|
1609 | + $GLOBALS['egw']->preferences->add('addressbook', $what.'_state', $state); |
|
1610 | 1610 | // save prefs, but do NOT invalid the cache (unnecessary) |
1611 | - $GLOBALS['egw']->preferences->save_repository(false,'user',false); |
|
1611 | + $GLOBALS['egw']->preferences->save_repository(false, 'user', false); |
|
1612 | 1612 | } |
1613 | 1613 | } |
1614 | 1614 | unset($old_state); |
@@ -1623,11 +1623,11 @@ discard block |
||
1623 | 1623 | } |
1624 | 1624 | if ($query['filter'] !== '') // not all addressbooks |
1625 | 1625 | { |
1626 | - $query['col_filter']['owner'] = (string) (int) $query['filter']; |
|
1626 | + $query['col_filter']['owner'] = (string)(int)$query['filter']; |
|
1627 | 1627 | |
1628 | 1628 | if ($this->private_addressbook) |
1629 | 1629 | { |
1630 | - $query['col_filter']['private'] = substr($query['filter'],-1) == 'p' ? 1 : 0; |
|
1630 | + $query['col_filter']['private'] = substr($query['filter'], -1) == 'p' ? 1 : 0; |
|
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | else |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | } |
1638 | 1638 | if ((int)$query['filter2']) // not no distribution list |
1639 | 1639 | { |
1640 | - $query['col_filter']['list'] = (string) (int) $query['filter2']; |
|
1640 | + $query['col_filter']['list'] = (string)(int)$query['filter2']; |
|
1641 | 1641 | } |
1642 | 1642 | else |
1643 | 1643 | { |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | $query['no_filter2'] = false; |
1657 | 1657 | |
1658 | 1658 | // Grouped view |
1659 | - if (isset($this->grouped_views[(string) $query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
1659 | + if (isset($this->grouped_views[(string)$query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
1660 | 1660 | { |
1661 | 1661 | $query['grouped_view_label'] = ''; |
1662 | 1662 | $rows = $this->get_grouped_rows($query); |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | { |
1672 | 1672 | $query['template'] = $do_email ? 'addressbook.email.rows' : 'addressbook.index.rows'; |
1673 | 1673 | } |
1674 | - if($query['col_filter']['parent_id']) |
|
1674 | + if ($query['col_filter']['parent_id']) |
|
1675 | 1675 | { |
1676 | 1676 | $query['grouped_view'] = $query['col_filter']['parent_id']; |
1677 | 1677 | $query['template'] = strpos($query['grouped_view'], 'duplicate') === 0 ? |
@@ -1681,11 +1681,11 @@ discard block |
||
1681 | 1681 | unset($query['col_filter']['parent_id']); |
1682 | 1682 | if ($query['grouped_view']) // view the contacts of one organisation only |
1683 | 1683 | { |
1684 | - if (strpos($query['grouped_view'],'*AND*') !== false) $query['grouped_view'] = str_replace('*AND*','&',$query['grouped_view']); |
|
1685 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
1686 | - foreach(explode('|||',$query['grouped_view']) as $part) |
|
1684 | + if (strpos($query['grouped_view'], '*AND*') !== false) $query['grouped_view'] = str_replace('*AND*', '&', $query['grouped_view']); |
|
1685 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
1686 | + foreach (explode('|||', $query['grouped_view']) as $part) |
|
1687 | 1687 | { |
1688 | - list($name,$value) = explode(':',$part,2); |
|
1688 | + list($name, $value) = explode(':', $part, 2); |
|
1689 | 1689 | // do NOT set invalid column, as this gives an SQL error ("AND AND" in sql) |
1690 | 1690 | if (static::$duplicate_fields[$name] && $value && ( |
1691 | 1691 | strpos($query['grouped_view'], 'duplicate:') === 0 && in_array($name, $fields) || |
@@ -1696,14 +1696,14 @@ discard block |
||
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | } |
1699 | - else if($query['actions'] && !$query['actions']['edit']) |
|
1699 | + else if ($query['actions'] && !$query['actions']['edit']) |
|
1700 | 1700 | { |
1701 | 1701 | // Just switched from grouped view, update actions |
1702 | 1702 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
1703 | 1703 | } |
1704 | 1704 | // translate the select order to the really used over all 3 columns |
1705 | 1705 | $sort = $query['sort']; |
1706 | - switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
1706 | + switch ($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
1707 | 1707 | { // we don't exclude them, as the total would otherwise depend on the order-criteria |
1708 | 1708 | case 'org_name': |
1709 | 1709 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
@@ -1737,8 +1737,8 @@ discard block |
||
1737 | 1737 | } |
1738 | 1738 | if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
1739 | 1739 | { |
1740 | - $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
|
1741 | - $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
|
1740 | + $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created', 'contact_modified'); |
|
1741 | + $query['col_filter'][] = (in_array($query['order'], $no_letter_search) ? 'org_name' : (substr($query['order'], 0, 1) == '#' ? '' : 'egw_addressbook.').$query['order']).' '. |
|
1742 | 1742 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); |
1743 | 1743 | } |
1744 | 1744 | $wildcard = '%'; |
@@ -1752,34 +1752,34 @@ discard block |
||
1752 | 1752 | unset($query['advanced_search']['meth_select']); |
1753 | 1753 | } |
1754 | 1754 | //if ($do_email ) $email_only = array('id','owner','tid','n_fn','n_family','n_given','org_name','email','email_home'); |
1755 | - $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only, |
|
1756 | - $order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']); |
|
1755 | + $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'], $id_only, |
|
1756 | + $order, '', $wildcard, false, $op, array((int)$query['start'], (int)$query['num_rows']), $query['col_filter']); |
|
1757 | 1757 | |
1758 | 1758 | // do we need to read the custom fields, depends on the column is enabled and customfields exist |
1759 | 1759 | // $query['csv_export'] allways needs to read ALL cf's |
1760 | 1760 | $columsel = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows']; |
1761 | - $available_distib_lists=$this->get_lists(Acl::READ); |
|
1762 | - $columselection = $columsel && !$query['csv_export'] ? explode(',',$columsel) : array(); |
|
1761 | + $available_distib_lists = $this->get_lists(Acl::READ); |
|
1762 | + $columselection = $columsel && !$query['csv_export'] ? explode(',', $columsel) : array(); |
|
1763 | 1763 | $ids = $calendar_participants = array(); |
1764 | 1764 | if (!$id_only && $rows) |
1765 | 1765 | { |
1766 | - $show_custom_fields = (in_array('customfields',$columselection)) && $this->customfields; |
|
1767 | - $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection); |
|
1768 | - $show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists); |
|
1766 | + $show_custom_fields = (in_array('customfields', $columselection)) && $this->customfields; |
|
1767 | + $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar', $columselection); |
|
1768 | + $show_distributionlist = in_array('distrib_lists', $columselection) || count($available_distib_lists); |
|
1769 | 1769 | if ($show_calendar || $show_custom_fields || $show_distributionlist) |
1770 | 1770 | { |
1771 | - foreach($rows as $val) |
|
1771 | + foreach ($rows as $val) |
|
1772 | 1772 | { |
1773 | 1773 | $ids[] = $val['id']; |
1774 | 1774 | $calendar_participants[$val['id']] = $val['account_id'] ? $val['account_id'] : 'c'.$val['id']; |
1775 | 1775 | } |
1776 | 1776 | if ($show_custom_fields) |
1777 | 1777 | { |
1778 | - foreach($columselection as $col) |
|
1778 | + foreach ($columselection as $col) |
|
1779 | 1779 | { |
1780 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
1780 | + if ($col[0] == '#') $selected_cfs[] = substr($col, 1); |
|
1781 | 1781 | } |
1782 | - $customfields = $this->read_customfields($ids,$selected_cfs); |
|
1782 | + $customfields = $this->read_customfields($ids, $selected_cfs); |
|
1783 | 1783 | } |
1784 | 1784 | // TODO: we need to find out where the csv_export query has been used and try to clean up |
1785 | 1785 | // this columnselection condition statements. |
@@ -1788,7 +1788,7 @@ discard block |
||
1788 | 1788 | //_debug_array($this->get_lists(Acl::EDIT)); |
1789 | 1789 | if ($show_distributionlist && $available_distib_lists) |
1790 | 1790 | { |
1791 | - $distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists)); |
|
1791 | + $distributionlist = $this->read_distributionlist($ids, array_keys($available_distib_lists)); |
|
1792 | 1792 | } |
1793 | 1793 | } |
1794 | 1794 | } |
@@ -1797,20 +1797,20 @@ discard block |
||
1797 | 1797 | |
1798 | 1798 | if ($id_only) |
1799 | 1799 | { |
1800 | - foreach($rows as $n => $row) |
|
1800 | + foreach ($rows as $n => $row) |
|
1801 | 1801 | { |
1802 | 1802 | $rows[$n] = $row['id']; |
1803 | 1803 | } |
1804 | - return $this->total; // no need to set other fields or $readonlys |
|
1804 | + return $this->total; // no need to set other fields or $readonlys |
|
1805 | 1805 | } |
1806 | 1806 | $order = $query['order']; |
1807 | 1807 | |
1808 | 1808 | $readonlys = array(); |
1809 | - foreach($rows as $n => &$row) |
|
1809 | + foreach ($rows as $n => &$row) |
|
1810 | 1810 | { |
1811 | 1811 | $given = $row['n_given'] ? $row['n_given'] : ($row['n_prefix'] ? $row['n_prefix'] : ''); |
1812 | 1812 | |
1813 | - switch($order) |
|
1813 | + switch ($order) |
|
1814 | 1814 | { |
1815 | 1815 | default: // postalcode, created, modified, ... |
1816 | 1816 | case 'org_name': |
@@ -1827,43 +1827,43 @@ discard block |
||
1827 | 1827 | break; |
1828 | 1828 | case 'n_fileas': |
1829 | 1829 | if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
1830 | - list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
|
1830 | + list($row['line1'], $row['line2']) = explode(': ', $row['n_fileas']); |
|
1831 | 1831 | break; |
1832 | 1832 | } |
1833 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
1833 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
1834 | 1834 | { |
1835 | 1835 | $row['type'] = 'home'; |
1836 | 1836 | $row['type_label'] = $query['grouped_view'] == 'duplicate' ? lang('Duplicates') : lang('Organisation'); |
1837 | 1837 | |
1838 | - if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE)) |
|
1838 | + if ($query['filter'] && !($this->grants[(int)$query['filter']]&Acl::DELETE)) |
|
1839 | 1839 | { |
1840 | 1840 | $row['class'] .= 'rowNoDelete '; |
1841 | 1841 | } |
1842 | - $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
1842 | + $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
1843 | 1843 | $row['class'] .= $query['grouped_view'] == 'duplicates' ? 'contact_duplicate' : 'contact_organisation '; |
1844 | 1844 | } |
1845 | 1845 | else |
1846 | 1846 | { |
1847 | - $this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']); |
|
1847 | + $this->type_icon($row['owner'], $row['private'], $row['tid'], $row['type'], $row['type_label']); |
|
1848 | 1848 | |
1849 | - static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax'); |
|
1849 | + static $tel2show = array('tel_work', 'tel_cell', 'tel_home', 'tel_fax'); |
|
1850 | 1850 | static $prefer_marker = null; |
1851 | 1851 | if (is_null($prefer_marker)) |
1852 | 1852 | { |
1853 | 1853 | // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 |
1854 | 1854 | $prefer_marker = html_entity_decode(' ☆', ENT_NOQUOTES, 'utf-8'); |
1855 | 1855 | } |
1856 | - foreach($tel2show as $name) |
|
1856 | + foreach ($tel2show as $name) |
|
1857 | 1857 | { |
1858 | - $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
1858 | + $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
1859 | 1859 | } |
1860 | 1860 | // allways show the prefered phone, if not already shown |
1861 | - if (!in_array($row['tel_prefer'],$tel2show) && $row[$row['tel_prefer']]) |
|
1861 | + if (!in_array($row['tel_prefer'], $tel2show) && $row[$row['tel_prefer']]) |
|
1862 | 1862 | { |
1863 | 1863 | $row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker; |
1864 | 1864 | } |
1865 | 1865 | // Show nice name as status text |
1866 | - if($row['tel_prefer']) |
|
1866 | + if ($row['tel_prefer']) |
|
1867 | 1867 | { |
1868 | 1868 | $row['tel_prefer_label'] = $this->contact_fields[$row['tel_prefer']]; |
1869 | 1869 | } |
@@ -1871,33 +1871,33 @@ discard block |
||
1871 | 1871 | { |
1872 | 1872 | $row['class'] .= 'rowAccount rowNoDelete '; |
1873 | 1873 | } |
1874 | - elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
1874 | + elseif (!$this->check_perms(Acl::DELETE, $row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
1875 | 1875 | { |
1876 | 1876 | $row['class'] .= 'rowNoDelete '; |
1877 | 1877 | } |
1878 | - if (!$this->check_perms(Acl::EDIT,$row)) |
|
1878 | + if (!$this->check_perms(Acl::EDIT, $row)) |
|
1879 | 1879 | { |
1880 | 1880 | $row['class'] .= 'rowNoEdit '; |
1881 | 1881 | } |
1882 | 1882 | $row['class'] .= 'contact_contact '; |
1883 | 1883 | |
1884 | - unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
1884 | + unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
1885 | 1885 | |
1886 | 1886 | if (isset($customfields[$row['id']])) |
1887 | 1887 | { |
1888 | - foreach($this->customfields as $name => $data) |
|
1888 | + foreach ($this->customfields as $name => $data) |
|
1889 | 1889 | { |
1890 | 1890 | $row['#'.$name] = $customfields[$row['id']]['#'.$name]; |
1891 | 1891 | } |
1892 | 1892 | } |
1893 | 1893 | if (isset($distributionlist[$row['id']])) |
1894 | 1894 | { |
1895 | - $row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']])); |
|
1895 | + $row['distrib_lists'] = implode("\n", array_values($distributionlist[$row['id']])); |
|
1896 | 1896 | //if ($show_distributionlist) $readonlys['distrib_lists'] =true; |
1897 | 1897 | } |
1898 | 1898 | if (isset($calendar[$calendar_participants[$row['id']]])) |
1899 | 1899 | { |
1900 | - foreach($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
1900 | + foreach ($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
1901 | 1901 | { |
1902 | 1902 | $row[$name] = $data; |
1903 | 1903 | } |
@@ -1905,13 +1905,13 @@ discard block |
||
1905 | 1905 | } |
1906 | 1906 | |
1907 | 1907 | // hide region for address format 'postcode_city' |
1908 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
1909 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
1908 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname'])) == 'postcode_city') unset($row['adr_one_region']); |
|
1909 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname'])) == 'postcode_city') unset($row['adr_two_region']); |
|
1910 | 1910 | |
1911 | 1911 | // respect category permissions |
1912 | - if(!empty($row['cat_id'])) |
|
1912 | + if (!empty($row['cat_id'])) |
|
1913 | 1913 | { |
1914 | - $row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']); |
|
1914 | + $row['cat_id'] = $this->categories->check_list(Acl::READ, $row['cat_id']); |
|
1915 | 1915 | } |
1916 | 1916 | } |
1917 | 1917 | $rows['no_distribution_list'] = (bool)$query['filter2']; |
@@ -1923,7 +1923,7 @@ discard block |
||
1923 | 1923 | } |
1924 | 1924 | |
1925 | 1925 | // Disable next/last date if so configured |
1926 | - if($this->config['disable_event_column'] == 'True') |
|
1926 | + if ($this->config['disable_event_column'] == 'True') |
|
1927 | 1927 | { |
1928 | 1928 | $rows['no_event_column'] = true; |
1929 | 1929 | } |
@@ -1936,23 +1936,21 @@ discard block |
||
1936 | 1936 | $header = array(); |
1937 | 1937 | if ($query['filter'] !== '' && !isset($this->grouped_views[$query['grouped_view']])) |
1938 | 1938 | { |
1939 | - $header[] = ($query['filter'] == '0' ? lang('accounts') : |
|
1940 | - ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
1941 | - lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) : |
|
1942 | - Api\Accounts::username((int)$query['filter']). |
|
1943 | - (substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
1939 | + $header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
1940 | + lang('Group %1', $GLOBALS['egw']->accounts->id2name($query['filter'])) : Api\Accounts::username((int)$query['filter']). |
|
1941 | + (substr($query['filter'], -1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
1944 | 1942 | } |
1945 | 1943 | if ($query['grouped_view']) |
1946 | 1944 | { |
1947 | 1945 | $header[] = $query['grouped_view_label']; |
1948 | 1946 | // Make sure option is there |
1949 | - if(!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
1947 | + if (!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
1950 | 1948 | { |
1951 | 1949 | $this->grouped_views += $this->_get_grouped_name($query['grouped_view']); |
1952 | 1950 | $rows['sel_options']['grouped_view'] = $this->grouped_views; |
1953 | 1951 | } |
1954 | 1952 | } |
1955 | - if($query['advanced_search']) |
|
1953 | + if ($query['advanced_search']) |
|
1956 | 1954 | { |
1957 | 1955 | $header[] = lang('Advanced search'); |
1958 | 1956 | } |
@@ -1963,11 +1961,11 @@ discard block |
||
1963 | 1961 | if ($query['searchletter']) |
1964 | 1962 | { |
1965 | 1963 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
1966 | - $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
|
1964 | + $header[] = lang("%1 starts with '%2'", $order, $query['searchletter']); |
|
1967 | 1965 | } |
1968 | 1966 | if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
1969 | 1967 | { |
1970 | - $header[] = lang("Search for '%1'",$query['search']); |
|
1968 | + $header[] = lang("Search for '%1'", $query['search']); |
|
1971 | 1969 | } |
1972 | 1970 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
1973 | 1971 | |
@@ -1983,7 +1981,7 @@ discard block |
||
1983 | 1981 | * @param string &$icon icon-name |
1984 | 1982 | * @param string &$label translated label |
1985 | 1983 | */ |
1986 | - function type_icon($owner,$private,$tid,&$icon,&$label) |
|
1984 | + function type_icon($owner, $private, $tid, &$icon, &$label) |
|
1987 | 1985 | { |
1988 | 1986 | if (!$owner) |
1989 | 1987 | { |
@@ -1998,7 +1996,7 @@ discard block |
||
1998 | 1996 | elseif ($GLOBALS['egw']->accounts->get_type($owner) == 'g') |
1999 | 1997 | { |
2000 | 1998 | $icon = 'group'; |
2001 | - $label = lang('group %1',$GLOBALS['egw']->accounts->id2name($owner)); |
|
1999 | + $label = lang('group %1', $GLOBALS['egw']->accounts->id2name($owner)); |
|
2002 | 2000 | } |
2003 | 2001 | else |
2004 | 2002 | { |
@@ -2006,9 +2004,9 @@ discard block |
||
2006 | 2004 | $label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner); |
2007 | 2005 | } |
2008 | 2006 | // show tid icon for tid!='n' AND only if one is defined |
2009 | - if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name'])) |
|
2007 | + if ($tid != 'n' && Api\Image::find('addressbook', $this->content_types[$tid]['name'])) |
|
2010 | 2008 | { |
2011 | - $icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']); |
|
2009 | + $icon = Api\Image::find('addressbook', $this->content_types[$tid]['name']); |
|
2012 | 2010 | } |
2013 | 2011 | |
2014 | 2012 | // Legacy - from when icons could be anywhere |
@@ -2026,19 +2024,19 @@ discard block |
||
2026 | 2024 | * @param int $_GET['contact_id'] contact_id mainly for popup use |
2027 | 2025 | * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
2028 | 2026 | */ |
2029 | - function edit($content=null) |
|
2027 | + function edit($content = null) |
|
2030 | 2028 | { |
2031 | 2029 | if (is_array($content)) |
2032 | 2030 | { |
2033 | 2031 | list($button) = @each($content['button']); |
2034 | 2032 | unset($content['button']); |
2035 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
2036 | - $content['owner'] = (string) (int) $content['owner']; |
|
2033 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
2034 | + $content['owner'] = (string)(int)$content['owner']; |
|
2037 | 2035 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
2038 | 2036 | if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
2039 | 2037 | unset($content['private_cfs']); |
2040 | 2038 | |
2041 | - switch($button) |
|
2039 | + switch ($button) |
|
2042 | 2040 | { |
2043 | 2041 | case 'save': |
2044 | 2042 | case 'apply': |
@@ -2050,7 +2048,7 @@ discard block |
||
2050 | 2048 | // photo might be changed by ajax_upload_photo |
2051 | 2049 | if (!array_key_exists('jpegphoto', $content)) |
2052 | 2050 | { |
2053 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
2051 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
2054 | 2052 | } |
2055 | 2053 | $links = false; |
2056 | 2054 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
@@ -2063,12 +2061,12 @@ discard block |
||
2063 | 2061 | $old_org_entry = $this->read($content['id']); |
2064 | 2062 | $old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry)); |
2065 | 2063 | } |
2066 | - if ( $content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
2064 | + if ($content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
2067 | 2065 | { |
2068 | 2066 | unset($content['n_fn']); |
2069 | 2067 | } |
2070 | 2068 | // Country codes |
2071 | - foreach(array('adr_one', 'adr_two') as $c_prefix) |
|
2069 | + foreach (array('adr_one', 'adr_two') as $c_prefix) |
|
2072 | 2070 | { |
2073 | 2071 | if ($content[$c_prefix.'_countrycode'] == '-custom-') |
2074 | 2072 | { |
@@ -2077,7 +2075,7 @@ discard block |
||
2077 | 2075 | } |
2078 | 2076 | $content['msg'] = ''; |
2079 | 2077 | $this->error = false; |
2080 | - foreach((array)$content['pre_save_callbacks'] as $callback) |
|
2078 | + foreach ((array)$content['pre_save_callbacks'] as $callback) |
|
2081 | 2079 | { |
2082 | 2080 | try { |
2083 | 2081 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2087,7 +2085,7 @@ discard block |
||
2087 | 2085 | } |
2088 | 2086 | catch (Exception $ex) { |
2089 | 2087 | $content['msg'] .= ($content['msg'] ? ', ' : '').$ex->getMessage(); |
2090 | - $button = 'apply'; // do not close dialog |
|
2088 | + $button = 'apply'; // do not close dialog |
|
2091 | 2089 | $this->error = true; |
2092 | 2090 | break; |
2093 | 2091 | } |
@@ -2102,7 +2100,7 @@ discard block |
||
2102 | 2100 | |
2103 | 2101 | unset($content['jpegphoto'], $content['photo_unchanged']); |
2104 | 2102 | |
2105 | - foreach((array)$content['post_save_callbacks'] as $callback) |
|
2103 | + foreach ((array)$content['post_save_callbacks'] as $callback) |
|
2106 | 2104 | { |
2107 | 2105 | try { |
2108 | 2106 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2110,58 +2108,58 @@ discard block |
||
2110 | 2108 | $content['msg'] .= ', '.$success_msg; |
2111 | 2109 | } |
2112 | 2110 | } |
2113 | - catch(Api\Exception\Redirect $r) |
|
2111 | + catch (Api\Exception\Redirect $r) |
|
2114 | 2112 | { |
2115 | 2113 | // catch it to continue execution and rethrow it later |
2116 | 2114 | } |
2117 | 2115 | catch (Exception $ex) { |
2118 | 2116 | $content['msg'] .= ', '.$ex->getMessage(); |
2119 | - $button = 'apply'; // do not close dialog |
|
2117 | + $button = 'apply'; // do not close dialog |
|
2120 | 2118 | $this->error = true; |
2121 | 2119 | break; |
2122 | 2120 | } |
2123 | 2121 | } |
2124 | 2122 | |
2125 | - if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry,$content,true)) && |
|
2126 | - ($members = $this->org_similar($old_org_entry['org_name'],$changed))) |
|
2123 | + if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry, $content, true)) && |
|
2124 | + ($members = $this->org_similar($old_org_entry['org_name'], $changed))) |
|
2127 | 2125 | { |
2128 | 2126 | //foreach($changed as $name => $old_value) echo "<p>$name: '$old_value' --> '{$content[$name]}'</p>\n"; |
2129 | - list($changed_members,$changed_fields,$failed_members) = $this->change_org($old_org_entry['org_name'],$changed,$content,$members); |
|
2127 | + list($changed_members, $changed_fields, $failed_members) = $this->change_org($old_org_entry['org_name'], $changed, $content, $members); |
|
2130 | 2128 | if ($changed_members) |
2131 | 2129 | { |
2132 | - $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed',$changed_fields,$changed_members); |
|
2130 | + $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed', $changed_fields, $changed_members); |
|
2133 | 2131 | } |
2134 | 2132 | if ($failed_members) |
2135 | 2133 | { |
2136 | - $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!',$failed_members); |
|
2134 | + $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!', $failed_members); |
|
2137 | 2135 | } |
2138 | 2136 | } |
2139 | 2137 | } |
2140 | - elseif($this->error === true) |
|
2138 | + elseif ($this->error === true) |
|
2141 | 2139 | { |
2142 | 2140 | $content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
2143 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
2144 | - htmlspecialchars(Egw::link('/index.php',array( |
|
2141 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
2142 | + htmlspecialchars(Egw::link('/index.php', array( |
|
2145 | 2143 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
2146 | 2144 | 'contact_id' => $content['id'], |
2147 | - ))).'">','</a>'); |
|
2148 | - break; // dont refresh the list |
|
2145 | + ))).'">', '</a>'); |
|
2146 | + break; // dont refresh the list |
|
2149 | 2147 | } |
2150 | 2148 | else |
2151 | 2149 | { |
2152 | 2150 | $content['msg'] = lang('Error saving the contact !!!'). |
2153 | 2151 | ($this->error ? ' '.$this->error : ''); |
2154 | - $button = 'apply'; // to not leave the dialog |
|
2152 | + $button = 'apply'; // to not leave the dialog |
|
2155 | 2153 | } |
2156 | 2154 | // writing links for new entry, existing ones are handled by the widget itself |
2157 | 2155 | if ($links && $content['id']) |
2158 | 2156 | { |
2159 | - Link::link('addressbook',$content['id'],$links); |
|
2157 | + Link::link('addressbook', $content['id'], $links); |
|
2160 | 2158 | } |
2161 | 2159 | // Update client side global datastore |
2162 | 2160 | $response = Api\Json\Response::get(); |
2163 | 2161 | $response->generic('data', array('uid' => 'addressbook::'.$content['id'], 'data' => $content)); |
2164 | - Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
2162 | + Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
2165 | 2163 | null, null, null, $this->error ? 'error' : 'success'); |
2166 | 2164 | |
2167 | 2165 | // re-throw redirect exception, if there's no error |
@@ -2183,11 +2181,11 @@ discard block |
||
2183 | 2181 | |
2184 | 2182 | case 'delete': |
2185 | 2183 | $success = $failed = $action_msg = null; |
2186 | - if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg'])) |
|
2184 | + if ($this->action('delete', array($content['id']), false, $success, $failed, $action_msg, '', $content['msg'])) |
|
2187 | 2185 | { |
2188 | 2186 | if ($GLOBALS['egw']->currentapp == 'addressbook') |
2189 | 2187 | { |
2190 | - Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' ); |
|
2188 | + Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete'); |
|
2191 | 2189 | Framework::window_close(); |
2192 | 2190 | } |
2193 | 2191 | else |
@@ -2212,7 +2210,7 @@ discard block |
||
2212 | 2210 | // new contact --> set some defaults |
2213 | 2211 | if ($contact_id && is_array($content = $this->read($contact_id))) |
2214 | 2212 | { |
2215 | - $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
2213 | + $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
2216 | 2214 | if (!$this->check_perms(Acl::EDIT, $content)) |
2217 | 2215 | { |
2218 | 2216 | $view = true; |
@@ -2256,52 +2254,52 @@ discard block |
||
2256 | 2254 | { |
2257 | 2255 | $content['owner'] = (string)($state['filter'] == 0 ? '' : $state['filter']); |
2258 | 2256 | } |
2259 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
2260 | - if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
2257 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
2258 | + if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
2261 | 2259 | { |
2262 | 2260 | $content['owner'] = $this->default_addressbook; |
2263 | 2261 | $content['private'] = (int)$this->default_private; |
2264 | 2262 | |
2265 | - if (!($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
2263 | + if (!($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
2266 | 2264 | { |
2267 | - $content['owner'] = (string) $this->user; |
|
2265 | + $content['owner'] = (string)$this->user; |
|
2268 | 2266 | $content['private'] = 0; |
2269 | 2267 | } |
2270 | 2268 | } |
2271 | 2269 | $new_type = array_keys($this->content_types); |
2272 | 2270 | // fetch active type to preset the type, if param typeid is not passed |
2273 | - $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
|
2271 | + $active_tid = Api\Cache::getSession('addressbook', 'active_tid'); |
|
2274 | 2272 | if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
2275 | - $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
|
2276 | - foreach($this->get_contact_columns() as $field) |
|
2273 | + $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid ? $active_tid : $new_type[0]); |
|
2274 | + foreach ($this->get_contact_columns() as $field) |
|
2277 | 2275 | { |
2278 | 2276 | if ($_GET['presets'][$field]) |
2279 | 2277 | { |
2280 | - if ($field=='email'||$field=='email_home') |
|
2278 | + if ($field == 'email' || $field == 'email_home') |
|
2281 | 2279 | { |
2282 | - $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field],''); |
|
2280 | + $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field], ''); |
|
2283 | 2281 | //error_log(__METHOD__.__LINE__.' Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal); |
2284 | - if (!(!is_array($singleAddress) || count($singleAddress)<1)) |
|
2282 | + if (!(!is_array($singleAddress) || count($singleAddress) < 1)) |
|
2285 | 2283 | { |
2286 | 2284 | $content[$field] = $singleAddress[0]->mailbox."@".$singleAddress[0]->host; |
2287 | 2285 | if (!empty($singleAddress[0]->personal)) |
2288 | 2286 | { |
2289 | - if (strpos($singleAddress[0]->personal,',')===false) |
|
2287 | + if (strpos($singleAddress[0]->personal, ',') === false) |
|
2290 | 2288 | { |
2291 | - list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
|
2292 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2293 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2294 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2289 | + list($P_n_given, $P_n_family, $P_org_name) = explode(' ', $singleAddress[0]->personal, 3); |
|
2290 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
2291 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
2292 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
2295 | 2293 | } |
2296 | 2294 | else |
2297 | 2295 | { |
2298 | - list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
|
2299 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2300 | - if (strlen(trim($P_other))>0) |
|
2296 | + list($P_n_family, $P_other) = explode(',', $singleAddress[0]->personal, 2); |
|
2297 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
2298 | + if (strlen(trim($P_other)) > 0) |
|
2301 | 2299 | { |
2302 | - list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
|
2303 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2304 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2300 | + list($P_n_given, $P_org_name) = explode(',', $P_other, 2); |
|
2301 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
2302 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
2305 | 2303 | } |
2306 | 2304 | } |
2307 | 2305 | } |
@@ -2319,13 +2317,13 @@ discard block |
||
2319 | 2317 | } |
2320 | 2318 | if (isset($_GET['presets'])) |
2321 | 2319 | { |
2322 | - foreach(array('email','email_home','n_family','n_given','org_name') as $field) |
|
2320 | + foreach (array('email', 'email_home', 'n_family', 'n_given', 'org_name') as $field) |
|
2323 | 2321 | { |
2324 | 2322 | if (!empty($content[$field])) |
2325 | 2323 | { |
2326 | 2324 | //Set the presets fields in content in order to be able to use them later in client side for checking duplication only on first time load |
2327 | 2325 | // after save/apply we unset them |
2328 | - $content['presets_fields'][]= $field; |
|
2326 | + $content['presets_fields'][] = $field; |
|
2329 | 2327 | break; |
2330 | 2328 | } |
2331 | 2329 | } |
@@ -2337,12 +2335,12 @@ discard block |
||
2337 | 2335 | //_debug_array($content); |
2338 | 2336 | } |
2339 | 2337 | |
2340 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2338 | + if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2341 | 2339 | |
2342 | - if($content && $_GET['makecp']) // copy the contact |
|
2340 | + if ($content && $_GET['makecp']) // copy the contact |
|
2343 | 2341 | { |
2344 | 2342 | $this->copy_contact($content); |
2345 | - $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
|
2343 | + $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook', 'entry'))); |
|
2346 | 2344 | $view = false; |
2347 | 2345 | } |
2348 | 2346 | else |
@@ -2353,12 +2351,12 @@ discard block |
||
2353 | 2351 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
2354 | 2352 | { |
2355 | 2353 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
2356 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
2354 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
2357 | 2355 | { |
2358 | 2356 | $link_id = $link_ids[$n]; |
2359 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
2357 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // gard against XSS |
|
2360 | 2358 | { |
2361 | - Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
|
2359 | + Link::link('addressbook', $content['link_to']['to_id'], $link_app, $link_id); |
|
2362 | 2360 | } |
2363 | 2361 | } |
2364 | 2362 | } |
@@ -2366,8 +2364,8 @@ discard block |
||
2366 | 2364 | if ($content['id']) |
2367 | 2365 | { |
2368 | 2366 | // last and next calendar date |
2369 | - list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2370 | - if(is_array($dates)) $content += $dates; |
|
2367 | + list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
2368 | + if (is_array($dates)) $content += $dates; |
|
2371 | 2369 | } |
2372 | 2370 | |
2373 | 2371 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2378,7 +2376,7 @@ discard block |
||
2378 | 2376 | |
2379 | 2377 | // Avoid setting conflicts with private custom fields |
2380 | 2378 | $content['private_cfs'] = array(); |
2381 | - foreach(Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
2379 | + foreach (Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
2382 | 2380 | { |
2383 | 2381 | if ($this->config['private_cf_tab'] && $cf['private'] && isset($content['#'.$name])) |
2384 | 2382 | { |
@@ -2391,7 +2389,7 @@ discard block |
||
2391 | 2389 | $content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']); |
2392 | 2390 | |
2393 | 2391 | //_debug_array($content); |
2394 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
2392 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
2395 | 2393 | $readonlys['button[copy]'] = $readonlys['button[edit]'] = $readonlys['button[vcard]'] = true; |
2396 | 2394 | $readonlys['button[save]'] = $readonlys['button[apply]'] = $view; |
2397 | 2395 | if ($view) |
@@ -2403,19 +2401,18 @@ discard block |
||
2403 | 2401 | $sel_options['fileas_type'] = $this->fileas_options($content); |
2404 | 2402 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
2405 | 2403 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
2406 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2407 | - if ((string) $content['owner'] !== '') |
|
2404 | + if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2405 | + if ((string)$content['owner'] !== '') |
|
2408 | 2406 | { |
2409 | 2407 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
2410 | 2408 | { |
2411 | - $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : |
|
2412 | - Api\Accounts::username($content['owner']); |
|
2409 | + $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : Api\Accounts::username($content['owner']); |
|
2413 | 2410 | } |
2414 | - $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
2415 | - $content['id'] && !$this->check_perms(Acl::DELETE,$content); // you need delete rights to move an existing contact into an other addressbook |
|
2411 | + $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
2412 | + $content['id'] && !$this->check_perms(Acl::DELETE, $content); // you need delete rights to move an existing contact into an other addressbook |
|
2416 | 2413 | } |
2417 | 2414 | // set the unsupported fields from the backend to readonly |
2418 | - foreach($this->get_fields('unsupported',$content['id'],$content['owner']) as $field) |
|
2415 | + foreach ($this->get_fields('unsupported', $content['id'], $content['owner']) as $field) |
|
2419 | 2416 | { |
2420 | 2417 | $readonlys[$field] = true; |
2421 | 2418 | } |
@@ -2425,7 +2422,7 @@ discard block |
||
2425 | 2422 | $readonlys['__ALL__'] = true; |
2426 | 2423 | $readonlys['button[cancel]'] = false; |
2427 | 2424 | |
2428 | - foreach($this->own_account_acl as $field) |
|
2425 | + foreach ($this->own_account_acl as $field) |
|
2429 | 2426 | { |
2430 | 2427 | $readonlys[$field] = false; |
2431 | 2428 | } |
@@ -2447,9 +2444,9 @@ discard block |
||
2447 | 2444 | if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
2448 | 2445 | // disable not needed tabs |
2449 | 2446 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2450 | - $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
|
2447 | + $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'], $content['owner']) == $this->so_accounts; |
|
2451 | 2448 | $readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab']; |
2452 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
2449 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
2453 | 2450 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2454 | 2451 | $this->account_repository != 'sql' && $content['account_id']; |
2455 | 2452 | if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
@@ -2461,7 +2458,7 @@ discard block |
||
2461 | 2458 | { |
2462 | 2459 | $this->_set_readonlys_for_own_account_acl($readonlys, $content['id']); |
2463 | 2460 | } |
2464 | - for($i = -23; $i<=23; $i++) |
|
2461 | + for ($i = -23; $i <= 23; $i++) |
|
2465 | 2462 | { |
2466 | 2463 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
2467 | 2464 | } |
@@ -2469,11 +2466,11 @@ discard block |
||
2469 | 2466 | $content['tz'] = $content['tz'] ? $content['tz'] : '0'; |
2470 | 2467 | if (count($this->content_types) > 1) |
2471 | 2468 | { |
2472 | - foreach($this->content_types as $type => $data) |
|
2469 | + foreach ($this->content_types as $type => $data) |
|
2473 | 2470 | { |
2474 | 2471 | $sel_options['tid'][$type] = $data['name']; |
2475 | 2472 | } |
2476 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
2473 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
2477 | 2474 | } |
2478 | 2475 | else |
2479 | 2476 | { |
@@ -2487,10 +2484,10 @@ discard block |
||
2487 | 2484 | ); |
2488 | 2485 | |
2489 | 2486 | // Links for deleted entries |
2490 | - if($content['tid'] == self::DELETED_TYPE) |
|
2487 | + if ($content['tid'] == self::DELETED_TYPE) |
|
2491 | 2488 | { |
2492 | 2489 | $content['link_to']['show_deleted'] = true; |
2493 | - if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
2490 | + if (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
2494 | 2491 | { |
2495 | 2492 | $readonlys['button[delete]'] = true; |
2496 | 2493 | } |
@@ -2499,33 +2496,33 @@ discard block |
||
2499 | 2496 | // Enable history |
2500 | 2497 | $this->setup_history($content, $sel_options); |
2501 | 2498 | |
2502 | - $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']); |
|
2499 | + $content['photo'] = $this->photo_src($content['id'], $content['jpegphoto'], 'photo', $content['etag']); |
|
2503 | 2500 | |
2504 | 2501 | if ($content['private']) $content['owner'] .= 'p'; |
2505 | 2502 | |
2506 | 2503 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
2507 | - if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
2504 | + if (in_array($content['tid'], array('n', self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
2508 | 2505 | { |
2509 | 2506 | $this->tmpl->read('addressbook.edit'); |
2510 | 2507 | } |
2511 | 2508 | |
2512 | 2509 | // allow other apps to add tabs to addressbook edit |
2513 | 2510 | $preserve = $content; |
2514 | - unset($preserve['jpegphoto'], $content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2511 | + unset($preserve['jpegphoto'], $content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2515 | 2512 | $this->tmpl->setElementAttribute('tabs', 'add_tabs', true); |
2516 | - $tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
2513 | + $tabs = & $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
2517 | 2514 | if (($first_call = !isset($tabs))) |
2518 | 2515 | { |
2519 | 2516 | $tabs = array(); |
2520 | 2517 | } |
2521 | 2518 | //error_log(__LINE__.': '.__METHOD__."() first_call=$first_call"); |
2522 | - $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit')+$content); |
|
2519 | + $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit') + $content); |
|
2523 | 2520 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
2524 | - foreach($hook_data as $extra_tabs) |
|
2521 | + foreach ($hook_data as $extra_tabs) |
|
2525 | 2522 | { |
2526 | 2523 | if (!$extra_tabs) continue; |
2527 | 2524 | |
2528 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
2525 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
2529 | 2526 | { |
2530 | 2527 | if ($extra_tab['data'] && is_array($extra_tab['data'])) |
2531 | 2528 | { |
@@ -2570,15 +2567,15 @@ discard block |
||
2570 | 2567 | * @param array &$readonlys |
2571 | 2568 | * @param int $id |
2572 | 2569 | */ |
2573 | - function _set_readonlys_for_own_account_acl(&$readonlys,$id) |
|
2570 | + function _set_readonlys_for_own_account_acl(&$readonlys, $id) |
|
2574 | 2571 | { |
2575 | 2572 | // regular fields depending on the backend |
2576 | - foreach($this->get_fields('supported',$id,0) as $field) |
|
2573 | + foreach ($this->get_fields('supported', $id, 0) as $field) |
|
2577 | 2574 | { |
2578 | - if (!$this->own_account_acl || !in_array($field,$this->own_account_acl)) |
|
2575 | + if (!$this->own_account_acl || !in_array($field, $this->own_account_acl)) |
|
2579 | 2576 | { |
2580 | 2577 | $readonlys[$field] = true; |
2581 | - switch($field) |
|
2578 | + switch ($field) |
|
2582 | 2579 | { |
2583 | 2580 | case 'tel_work': |
2584 | 2581 | case 'tel_cell': |
@@ -2594,16 +2591,16 @@ discard block |
||
2594 | 2591 | // custom fields |
2595 | 2592 | if ($this->customfields) |
2596 | 2593 | { |
2597 | - foreach(array_keys($this->customfields) as $name) |
|
2594 | + foreach (array_keys($this->customfields) as $name) |
|
2598 | 2595 | { |
2599 | - if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl)) |
|
2596 | + if (!$this->own_account_acl || !in_array('#'.$name, $this->own_account_acl)) |
|
2600 | 2597 | { |
2601 | 2598 | $readonlys['#'.$name] = true; |
2602 | 2599 | } |
2603 | 2600 | } |
2604 | 2601 | } |
2605 | 2602 | // links |
2606 | - if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl)) |
|
2603 | + if (!$this->own_account_acl || !in_array('link_to', $this->own_account_acl)) |
|
2607 | 2604 | { |
2608 | 2605 | $readonlys['link_to'] = true; |
2609 | 2606 | } |
@@ -2621,10 +2618,10 @@ discard block |
||
2621 | 2618 | * 'data' => array of id => "full name (addressbook)" pairs |
2622 | 2619 | * 'fileas_options' |
2623 | 2620 | */ |
2624 | - public function ajax_check_values($values, $name, $own_id=0) |
|
2621 | + public function ajax_check_values($values, $name, $own_id = 0) |
|
2625 | 2622 | { |
2626 | 2623 | $matches = null; |
2627 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
2624 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
2628 | 2625 | |
2629 | 2626 | $ret = array('doublicates' => array(), 'msg' => null); |
2630 | 2627 | |
@@ -2648,17 +2645,17 @@ discard block |
||
2648 | 2645 | |
2649 | 2646 | // if name, firstname or org changed and enough are specified, check for doublicates |
2650 | 2647 | $specified_count = 0; |
2651 | - foreach($fields as $field) |
|
2648 | + foreach ($fields as $field) |
|
2652 | 2649 | { |
2653 | - if($values[trim($field)]) |
|
2650 | + if ($values[trim($field)]) |
|
2654 | 2651 | { |
2655 | 2652 | $specified_count++; |
2656 | 2653 | } |
2657 | 2654 | } |
2658 | - if (in_array($name,$fields) && $specified_count >= 2) |
|
2655 | + if (in_array($name, $fields) && $specified_count >= 2) |
|
2659 | 2656 | { |
2660 | 2657 | $filter = array(); |
2661 | - foreach($fields as $n) // use email too, to exclude obvious false positives |
|
2658 | + foreach ($fields as $n) // use email too, to exclude obvious false positives |
|
2662 | 2659 | { |
2663 | 2660 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
2664 | 2661 | } |
@@ -2667,7 +2664,7 @@ discard block |
||
2667 | 2664 | } |
2668 | 2665 | if ($contacts) |
2669 | 2666 | { |
2670 | - foreach($contacts as $contact) |
|
2667 | + foreach ($contacts as $contact) |
|
2671 | 2668 | { |
2672 | 2669 | if ($own_id && $contact['id'] == $own_id) continue; |
2673 | 2670 | |
@@ -2691,26 +2688,24 @@ discard block |
||
2691 | 2688 | * |
2692 | 2689 | * @param array $content |
2693 | 2690 | */ |
2694 | - function view(array $content=null) |
|
2691 | + function view(array $content = null) |
|
2695 | 2692 | { |
2696 | 2693 | // CRM list comes from content, request, or preference |
2697 | - $crm_list = $content['crm_list'] ? $content['crm_list'] : |
|
2698 | - ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
2699 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2694 | + $crm_list = $content['crm_list'] ? $content['crm_list'] : ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
2695 | + if (!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2700 | 2696 | |
2701 | - if(is_array($content)) |
|
2697 | + if (is_array($content)) |
|
2702 | 2698 | { |
2703 | 2699 | list($button) = each($content['button']); |
2704 | 2700 | switch ($content['toolbar'] ? $content['toolbar'] : $button) |
2705 | 2701 | { |
2706 | - case 'vcard': |
|
2707 | - Egw::redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']); |
|
2702 | + case 'vcard' : Egw::redirect_link('/index.php', 'menuaction=addressbook.uivcard.out&ab_id='.$content['id']); |
|
2708 | 2703 | |
2709 | 2704 | case 'cancel': |
2710 | - Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
2705 | + Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
2711 | 2706 | |
2712 | 2707 | case 'delete': |
2713 | - Egw::redirect_link('/index.php',array( |
|
2708 | + Egw::redirect_link('/index.php', array( |
|
2714 | 2709 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2715 | 2710 | 'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'), |
2716 | 2711 | )); |
@@ -2728,9 +2723,9 @@ discard block |
||
2728 | 2723 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
2729 | 2724 | //error_log(__METHOD__."() get_rows()=$num_rows rows=".array2string($rows)); |
2730 | 2725 | $contact_id = $rows[0]; |
2731 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2726 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2732 | 2727 | { |
2733 | - Egw::redirect_link('/index.php',array( |
|
2728 | + Egw::redirect_link('/index.php', array( |
|
2734 | 2729 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2735 | 2730 | 'msg' => $content, |
2736 | 2731 | 'ajax' => 'true' |
@@ -2739,14 +2734,14 @@ discard block |
||
2739 | 2734 | $content['index'] = $query['start']; |
2740 | 2735 | |
2741 | 2736 | // List nextmatch is already there, just update the filter |
2742 | - if($contact_id && Api\Json\Request::isJSONRequest()) |
|
2737 | + if ($contact_id && Api\Json\Request::isJSONRequest()) |
|
2743 | 2738 | { |
2744 | - switch($crm_list) |
|
2739 | + switch ($crm_list) |
|
2745 | 2740 | { |
2746 | 2741 | case 'infolog': |
2747 | 2742 | case 'tracker': |
2748 | 2743 | default: |
2749 | - Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2744 | + Api\Json\Response::get()->apply('app.addressbook.view_set_list', Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2750 | 2745 | break; |
2751 | 2746 | } |
2752 | 2747 | |
@@ -2777,13 +2772,13 @@ discard block |
||
2777 | 2772 | $_GET['index'] = 0; |
2778 | 2773 | } |
2779 | 2774 | $contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0); |
2780 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2775 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2781 | 2776 | { |
2782 | - Egw::redirect_link('/index.php',array( |
|
2777 | + Egw::redirect_link('/index.php', array( |
|
2783 | 2778 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2784 | 2779 | 'msg' => $content, |
2785 | 2780 | 'ajax' => 'true' |
2786 | - )+(isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
2781 | + ) + (isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
2787 | 2782 | } |
2788 | 2783 | if (isset($_GET['index'])) |
2789 | 2784 | { |
@@ -2796,25 +2791,25 @@ discard block |
||
2796 | 2791 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
2797 | 2792 | } |
2798 | 2793 | } |
2799 | - $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2794 | + $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2800 | 2795 | |
2801 | 2796 | // make everything not explicit mentioned readonly |
2802 | 2797 | $readonlys['__ALL__'] = true; |
2803 | 2798 | $readonlys['photo'] = $readonlys['button[cancel]'] = $readonlys['button[copy]'] = |
2804 | 2799 | $readonlys['button[ok]'] = $readonlys['button[more]'] = $readonlys['toolbar'] = false; |
2805 | 2800 | |
2806 | - foreach(array_keys($this->contact_fields) as $key) |
|
2801 | + foreach (array_keys($this->contact_fields) as $key) |
|
2807 | 2802 | { |
2808 | - if (in_array($key,array('tel_home','tel_work','tel_cell','tel_fax'))) |
|
2803 | + if (in_array($key, array('tel_home', 'tel_work', 'tel_cell', 'tel_fax'))) |
|
2809 | 2804 | { |
2810 | 2805 | $content[$key.'2'] = $content[$key]; |
2811 | 2806 | } |
2812 | 2807 | } |
2813 | 2808 | |
2814 | 2809 | // respect category permissions |
2815 | - if(!empty($content['cat_id'])) |
|
2810 | + if (!empty($content['cat_id'])) |
|
2816 | 2811 | { |
2817 | - $content['cat_id'] = $this->categories->check_list(Acl::READ,$content['cat_id']); |
|
2812 | + $content['cat_id'] = $this->categories->check_list(Acl::READ, $content['cat_id']); |
|
2818 | 2813 | } |
2819 | 2814 | $content['cat_id_tree'] = $content['cat_id']; |
2820 | 2815 | |
@@ -2824,12 +2819,12 @@ discard block |
||
2824 | 2819 | 'to_id' => $content['id'], |
2825 | 2820 | ); |
2826 | 2821 | // Links for deleted entries |
2827 | - if($content['tid'] == self::DELETED_TYPE) |
|
2822 | + if ($content['tid'] == self::DELETED_TYPE) |
|
2828 | 2823 | { |
2829 | 2824 | $content['link_to']['show_deleted'] = true; |
2830 | 2825 | } |
2831 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
2832 | - $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT,$content); |
|
2826 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
2827 | + $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT, $content); |
|
2833 | 2828 | |
2834 | 2829 | // how to display addresses |
2835 | 2830 | $content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']); |
@@ -2837,7 +2832,7 @@ discard block |
||
2837 | 2832 | |
2838 | 2833 | $sel_options['fileas_type'][$content['fileas_type']] = $this->fileas($content); |
2839 | 2834 | $sel_options['owner'] = $this->get_addressbooks(); |
2840 | - for($i = -23; $i<=23; $i++) |
|
2835 | + for ($i = -23; $i <= 23; $i++) |
|
2841 | 2836 | { |
2842 | 2837 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
2843 | 2838 | } |
@@ -2845,11 +2840,11 @@ discard block |
||
2845 | 2840 | $content['tz'] = $content['tz'] ? $content['tz'] : 0; |
2846 | 2841 | if (count($this->content_types) > 1) |
2847 | 2842 | { |
2848 | - foreach($this->content_types as $type => $data) |
|
2843 | + foreach ($this->content_types as $type => $data) |
|
2849 | 2844 | { |
2850 | 2845 | $sel_options['tid'][$type] = $data['name']; |
2851 | 2846 | } |
2852 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
2847 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
2853 | 2848 | } |
2854 | 2849 | else |
2855 | 2850 | { |
@@ -2866,7 +2861,7 @@ discard block |
||
2866 | 2861 | { |
2867 | 2862 | $content['owner'] .= 'p'; |
2868 | 2863 | } |
2869 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
2864 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
2870 | 2865 | |
2871 | 2866 | // Prevent double countries - invalid code blanks it, disabling doesn't work |
2872 | 2867 | $content['adr_one_countrycode'] = '-'; |
@@ -2879,14 +2874,14 @@ discard block |
||
2879 | 2874 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2880 | 2875 | $readonlys['tabs']['custom'] = !$this->customfields; |
2881 | 2876 | $readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab']; |
2882 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
2877 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
2883 | 2878 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2884 | 2879 | $this->account_repository != 'sql' && $content['account_id']; |
2885 | 2880 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
2886 | 2881 | |
2887 | 2882 | // last and next calendar date |
2888 | - if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2889 | - if(is_array($dates)) $content += $dates; |
|
2883 | + if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
2884 | + if (is_array($dates)) $content += $dates; |
|
2890 | 2885 | |
2891 | 2886 | // Disable importexport |
2892 | 2887 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2928,7 +2923,7 @@ discard block |
||
2928 | 2923 | { |
2929 | 2924 | unset($actions['back']); |
2930 | 2925 | } |
2931 | - if (!isset($content['index']) || $content['index'] >= $num_rows-1) |
|
2926 | + if (!isset($content['index']) || $content['index'] >= $num_rows - 1) |
|
2932 | 2927 | { |
2933 | 2928 | unset($actions['next']); |
2934 | 2929 | } |
@@ -2940,7 +2935,7 @@ discard block |
||
2940 | 2935 | // need to load list's app.js now, as exec calls header before other app can include it |
2941 | 2936 | Framework::includeJS('/'.$crm_list.'/js/app.js'); |
2942 | 2937 | |
2943 | - $this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array( |
|
2938 | + $this->tmpl->exec('addressbook.addressbook_ui.view', $content, $sel_options, $readonlys, array( |
|
2944 | 2939 | 'id' => $content['id'], |
2945 | 2940 | 'index' => $content['index'], |
2946 | 2941 | 'crm_list' => $crm_list |
@@ -2948,12 +2943,12 @@ discard block |
||
2948 | 2943 | |
2949 | 2944 | // Only load this on first time - we're using AJAX, so it stays there through submits. |
2950 | 2945 | // Sending it again (via ajax) will break the addressbook.view etemplate2 |
2951 | - if($contact_id) |
|
2946 | + if ($contact_id) |
|
2952 | 2947 | { |
2953 | 2948 | Api\Hooks::single(array( |
2954 | 2949 | 'location' => 'addressbook_view', |
2955 | 2950 | 'ab_id' => $content['id'] |
2956 | - ),$crm_list); |
|
2951 | + ), $crm_list); |
|
2957 | 2952 | } |
2958 | 2953 | } |
2959 | 2954 | |
@@ -2965,30 +2960,30 @@ discard block |
||
2965 | 2960 | */ |
2966 | 2961 | function email2link($email) |
2967 | 2962 | { |
2968 | - if (strpos($email,'@') == false) return ''; |
|
2963 | + if (strpos($email, '@') == false) return ''; |
|
2969 | 2964 | |
2970 | - if($GLOBALS['egw_info']['user']['apps']['mail']) |
|
2965 | + if ($GLOBALS['egw_info']['user']['apps']['mail']) |
|
2971 | 2966 | { |
2972 | 2967 | return array( |
2973 | 2968 | 'menuaction' => 'mail.mail_compose.compose', |
2974 | 2969 | 'send_to' => base64_encode($email) |
2975 | 2970 | ); |
2976 | 2971 | } |
2977 | - if($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
2972 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
2978 | 2973 | { |
2979 | 2974 | return array( |
2980 | 2975 | 'menuaction' => 'felamimail.uicompose.compose', |
2981 | 2976 | 'send_to' => base64_encode($email) |
2982 | 2977 | ); |
2983 | 2978 | } |
2984 | - if($GLOBALS['egw_info']['user']['apps']['email']) |
|
2979 | + if ($GLOBALS['egw_info']['user']['apps']['email']) |
|
2985 | 2980 | { |
2986 | 2981 | return array( |
2987 | 2982 | 'menuaction' => 'email.uicompose.compose', |
2988 | 2983 | 'to' => $email, |
2989 | 2984 | ); |
2990 | 2985 | } |
2991 | - return 'mailto:' . $email; |
|
2986 | + return 'mailto:'.$email; |
|
2992 | 2987 | } |
2993 | 2988 | |
2994 | 2989 | /** |
@@ -2997,9 +2992,9 @@ discard block |
||
2997 | 2992 | * @param array $_content |
2998 | 2993 | * @return string |
2999 | 2994 | */ |
3000 | - function search($_content=array()) |
|
2995 | + function search($_content = array()) |
|
3001 | 2996 | { |
3002 | - if(!empty($_content)) |
|
2997 | + if (!empty($_content)) |
|
3003 | 2998 | { |
3004 | 2999 | |
3005 | 3000 | $_content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $_content['cat_id_tree'] : $_content['cat_id']; |
@@ -3014,10 +3009,10 @@ discard block |
||
3014 | 3009 | } |
3015 | 3010 | else |
3016 | 3011 | { |
3017 | - $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
|
3012 | + $query['advanced_search'] = array_intersect_key($_content, array_flip(array_merge($this->get_contact_columns(), array('operator', 'meth_select')))); |
|
3018 | 3013 | foreach ($query['advanced_search'] as $key => $value) |
3019 | 3014 | { |
3020 | - if(!$value) unset($query['advanced_search'][$key]); |
|
3015 | + if (!$value) unset($query['advanced_search'][$key]); |
|
3021 | 3016 | } |
3022 | 3017 | // Skip n_fn, it causes problems in sql |
3023 | 3018 | unset($query['advanced_search']['n_fn']); |
@@ -3033,7 +3028,7 @@ discard block |
||
3033 | 3028 | $response->call("app.addressbook.adv_search", array('advanced_search' => $_content['button']['search'] ? $query['advanced_search'] : '')); |
3034 | 3029 | if ($_content['button']['cancelsearch']) |
3035 | 3030 | { |
3036 | - Framework::window_close (); |
|
3031 | + Framework::window_close(); |
|
3037 | 3032 | |
3038 | 3033 | // No need to reload popup |
3039 | 3034 | return; |
@@ -3050,7 +3045,7 @@ discard block |
||
3050 | 3045 | // Avoid ID conflict with tree & selectboxes |
3051 | 3046 | $content['cat_id_tree'] = $content['cat_id']; |
3052 | 3047 | |
3053 | - for($i = -23; $i<=23; $i++) |
|
3048 | + for ($i = -23; $i <= 23; $i++) |
|
3054 | 3049 | { |
3055 | 3050 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
3056 | 3051 | } |
@@ -3059,8 +3054,8 @@ discard block |
||
3059 | 3054 | //foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name']; |
3060 | 3055 | |
3061 | 3056 | // configure search options |
3062 | - $sel_options['owner'] = $this->get_addressbooks(Acl::READ,lang('all')); |
|
3063 | - $sel_options['operator'] = array( |
|
3057 | + $sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('all')); |
|
3058 | + $sel_options['operator'] = array( |
|
3064 | 3059 | 'AND' => 'AND', |
3065 | 3060 | 'OR' => 'OR', |
3066 | 3061 | ); |
@@ -3070,12 +3065,12 @@ discard block |
||
3070 | 3065 | ); |
3071 | 3066 | if ($this->customfields) |
3072 | 3067 | { |
3073 | - foreach($this->customfields as $name => $data) |
|
3068 | + foreach ($this->customfields as $name => $data) |
|
3074 | 3069 | { |
3075 | 3070 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
3076 | 3071 | { |
3077 | 3072 | if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
3078 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3073 | + if (!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3079 | 3074 | } |
3080 | 3075 | // Make them not required, otherwise you can't search |
3081 | 3076 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -3101,8 +3096,8 @@ discard block |
||
3101 | 3096 | |
3102 | 3097 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
3103 | 3098 | |
3104 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
3105 | - return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |
|
3099 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
3100 | + return $this->tmpl->exec('addressbook.addressbook_ui.search', $content, $sel_options, $readonlys, array(), 2); |
|
3106 | 3101 | } |
3107 | 3102 | |
3108 | 3103 | /** |
@@ -3111,12 +3106,12 @@ discard block |
||
3111 | 3106 | * |
3112 | 3107 | * @param type $contact_id |
3113 | 3108 | */ |
3114 | - function ajax_noPhotoExists ($contact_id) |
|
3109 | + function ajax_noPhotoExists($contact_id) |
|
3115 | 3110 | { |
3116 | 3111 | $response = Api\Json\Response::get(); |
3117 | 3112 | $response->data((!($contact = $this->read($contact_id)) || |
3118 | - empty($contact['jpegphoto']) && !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) && |
|
3119 | - ($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
3113 | + empty($contact['jpegphoto']) && !(($contact['files']&Api\Contacts::FILES_BIT_PHOTO) && |
|
3114 | + ($size = filesize($url = Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
3120 | 3115 | } |
3121 | 3116 | |
3122 | 3117 | /** |
@@ -3125,13 +3120,13 @@ discard block |
||
3125 | 3120 | * @param string $etemplate_exec_id to update id, files, etag, ... |
3126 | 3121 | * @param file string $file null means to delete |
3127 | 3122 | */ |
3128 | - function ajax_update_photo ($etemplate_exec_id, $file) |
|
3123 | + function ajax_update_photo($etemplate_exec_id, $file) |
|
3129 | 3124 | { |
3130 | 3125 | $et_request = Api\Etemplate\Request::read($etemplate_exec_id); |
3131 | 3126 | $response = Api\Json\Response::get(); |
3132 | 3127 | if ($file) |
3133 | 3128 | { |
3134 | - $filteredFile = substr($file, strpos($file, ",")+1); |
|
3129 | + $filteredFile = substr($file, strpos($file, ",") + 1); |
|
3135 | 3130 | // resize photo if wider then default width of 240pixel (keeping aspect ratio) |
3136 | 3131 | $decoded = $this->resize_photo(base64_decode($filteredFile)); |
3137 | 3132 | } |
@@ -3139,7 +3134,7 @@ discard block |
||
3139 | 3134 | // add photo into current eT2 request |
3140 | 3135 | $et_request->preserv = array_merge($et_request->preserv, array( |
3141 | 3136 | 'jpegphoto' => is_null($file) ? $file : $decoded, |
3142 | - 'photo_unchanged' => false, // hint photo is changed |
|
3137 | + 'photo_unchanged' => false, // hint photo is changed |
|
3143 | 3138 | )); |
3144 | 3139 | } |
3145 | 3140 | |
@@ -3154,14 +3149,14 @@ discard block |
||
3154 | 3149 | public function pubkey_uploaded(array $file, $widget_id, Api\Etemplate\Request $request, Api\Json\Response $response) |
3155 | 3150 | { |
3156 | 3151 | //error_log(__METHOD__."(".array2string($file).", ...) widget_id=$widget_id, id=".$request->content['id'].", files=".$request->content['files']); |
3157 | - unset($file, $response); // not used, but required by function signature |
|
3158 | - list(,,$path) = explode(':', $widget_id); |
|
3152 | + unset($file, $response); // not used, but required by function signature |
|
3153 | + list(,, $path) = explode(':', $widget_id); |
|
3159 | 3154 | $bit = $path === Api\Contacts::FILES_PGP_PUBKEY ? Api\Contacts::FILES_BIT_PGP_PUBKEY : Api\Contacts::FILES_BIT_SMIME_PUBKEY; |
3160 | - if (!($request->content['files'] & $bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
3155 | + if (!($request->content['files']&$bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
3161 | 3156 | { |
3162 | 3157 | $content = $request->content; |
3163 | 3158 | $content['files'] |= $bit; |
3164 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
3159 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
3165 | 3160 | if ($this->save($content)) |
3166 | 3161 | { |
3167 | 3162 | $changed = array_diff_assoc($content, $request->content); |
@@ -3179,19 +3174,18 @@ discard block |
||
3179 | 3174 | function photo() |
3180 | 3175 | { |
3181 | 3176 | ob_start(); |
3182 | - $contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] : |
|
3183 | - (isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0); |
|
3177 | + $contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] : (isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0); |
|
3184 | 3178 | |
3185 | - if (substr($contact_id,0,8) == 'account:') |
|
3179 | + if (substr($contact_id, 0, 8) == 'account:') |
|
3186 | 3180 | { |
3187 | - $contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id,8),'person_id'); |
|
3181 | + $contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id, 8), 'person_id'); |
|
3188 | 3182 | } |
3189 | 3183 | if (!($contact = $this->read($contact_id)) || |
3190 | - empty($contact['jpegphoto']) && // LDAP/AD (not updated SQL) |
|
3191 | - !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) && // new SQL in VFS |
|
3192 | - ($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO))))) |
|
3184 | + empty($contact['jpegphoto']) && // LDAP/AD (not updated SQL) |
|
3185 | + !(($contact['files']&Api\Contacts::FILES_BIT_PHOTO) && // new SQL in VFS |
|
3186 | + ($size = filesize($url = Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO))))) |
|
3193 | 3187 | { |
3194 | - Egw::redirect(Api\Image::find('addressbook','photo')); |
|
3188 | + Egw::redirect(Api\Image::find('addressbook', 'photo')); |
|
3195 | 3189 | } |
3196 | 3190 | // use an etag over the image mapp |
3197 | 3191 | $etag = '"'.$contact_id.':'.$contact['etag'].'"'; |
@@ -3203,14 +3197,14 @@ discard block |
||
3203 | 3197 | // different url with different etag parameter will force a reload |
3204 | 3198 | if (isset($_GET['etag'])) |
3205 | 3199 | { |
3206 | - Api\Session::cache_control(30*86400); // cache for 30 days |
|
3200 | + Api\Session::cache_control(30 * 86400); // cache for 30 days |
|
3207 | 3201 | } |
3208 | 3202 | // if servers send a If-None-Match header, response with 304 Not Modified, if etag matches |
3209 | 3203 | if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag) |
3210 | 3204 | { |
3211 | 3205 | header("HTTP/1.1 304 Not Modified"); |
3212 | 3206 | } |
3213 | - elseif(!empty($contact['jpegphoto'])) |
|
3207 | + elseif (!empty($contact['jpegphoto'])) |
|
3214 | 3208 | { |
3215 | 3209 | header('Content-length: '.bytes($contact['jpegphoto'])); |
3216 | 3210 | echo $contact['jpegphoto']; |
@@ -3260,15 +3254,15 @@ discard block |
||
3260 | 3254 | echo $GLOBALS['egw']->framework->navbar(); |
3261 | 3255 | |
3262 | 3256 | // check if user has admin rights AND if a valid fileas type is given (Security) |
3263 | - if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types)) |
|
3257 | + if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'], $this->fileas_types)) |
|
3264 | 3258 | { |
3265 | 3259 | echo '<h1>'.lang('Permission denied !!!')."</h1>\n"; |
3266 | 3260 | } |
3267 | 3261 | else |
3268 | 3262 | { |
3269 | 3263 | $errors = null; |
3270 | - $updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore Acl |
|
3271 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
3264 | + $updated = parent::set_all_fileas($_GET['type'], (boolean)$_GET['all'], $errors, true); // true = ignore Acl |
|
3265 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
3272 | 3266 | } |
3273 | 3267 | echo $GLOBALS['egw']->framework->footer(); |
3274 | 3268 | } |
@@ -3292,8 +3286,8 @@ discard block |
||
3292 | 3286 | else |
3293 | 3287 | { |
3294 | 3288 | $errors = null; |
3295 | - $updated = parent::set_all_cleanup($errors,true); // true = ignore Acl |
|
3296 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
3289 | + $updated = parent::set_all_cleanup($errors, true); // true = ignore Acl |
|
3290 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
3297 | 3291 | } |
3298 | 3292 | echo $GLOBALS['egw']->framework->footer(); |
3299 | 3293 | } |
@@ -3306,7 +3300,7 @@ discard block |
||
3306 | 3300 | if ($this->contact_repository == 'ldap' || !$content['id'] || |
3307 | 3301 | $this->account_repository == 'ldap' && $content['account_id']) |
3308 | 3302 | { |
3309 | - return; // no history for ldap as history table only allows integer id's |
|
3303 | + return; // no history for ldap as history table only allows integer id's |
|
3310 | 3304 | } |
3311 | 3305 | $content['history'] = array( |
3312 | 3306 | 'id' => $content['id'], |
@@ -3321,7 +3315,7 @@ discard block |
||
3321 | 3315 | ), |
3322 | 3316 | ); |
3323 | 3317 | |
3324 | - foreach($this->content_types as $id => $settings) |
|
3318 | + foreach ($this->content_types as $id => $settings) |
|
3325 | 3319 | { |
3326 | 3320 | $content['history']['status-widgets']['tid'][$id] = $settings['name']; |
3327 | 3321 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Overridden to be able to skip the next step |
|
39 | - */ |
|
38 | + * Overridden to be able to skip the next step |
|
39 | + */ |
|
40 | 40 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) { |
41 | 41 | |
42 | 42 | if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Choose how to export multi-selects (includes Api\Categories) |
|
57 | - */ |
|
58 | - function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
|
55 | + /** |
|
56 | + * Choose how to export multi-selects (includes Api\Categories) |
|
57 | + */ |
|
58 | + function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
|
59 | 59 | { |
60 | 60 | if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
61 | 61 | // return from step50 |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * Get a list of multi-select fields |
|
134 | - */ |
|
133 | + * Get a list of multi-select fields |
|
134 | + */ |
|
135 | 135 | protected function get_field_list($content) { |
136 | 136 | $field_list = array(); |
137 | 137 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | // Field mapping |
23 | 23 | $bocontacts = new Api\Contacts(); |
24 | 24 | $this->export_fields = $bocontacts->contact_fields; |
25 | - foreach($bocontacts->customfields as $name => $data) { |
|
25 | + foreach ($bocontacts->customfields as $name => $data) { |
|
26 | 26 | $this->export_fields['#'.$name] = $data['label']; |
27 | 27 | } |
28 | - unset($this->export_fields['jpegphoto']); // can't cvs export that |
|
28 | + unset($this->export_fields['jpegphoto']); // can't cvs export that |
|
29 | 29 | |
30 | 30 | // Add in last/next appointments |
31 | 31 | // NB: last_date and next_date are used instead of last_event & next_event |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
43 | 43 | $result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
44 | 44 | $field_list = $this->get_field_list($content); |
45 | - if(count($field_list)) { |
|
45 | + if (count($field_list)) { |
|
46 | 46 | return $result; |
47 | 47 | } else { |
48 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2); |
|
48 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 2); |
|
49 | 49 | } |
50 | 50 | } else { |
51 | 51 | return parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
59 | 59 | { |
60 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
60 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
61 | 61 | // return from step50 |
62 | 62 | if ($content['step'] == 'wizard_step50') |
63 | 63 | { |
64 | - if($content['explode_multiselects']) { |
|
64 | + if ($content['explode_multiselects']) { |
|
65 | 65 | $explodes = $content['explode_multiselects']; |
66 | 66 | $content['explode_multiselects'] = array(); |
67 | - foreach($explodes as $row => $settings) { |
|
68 | - if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
67 | + foreach ($explodes as $row => $settings) { |
|
68 | + if ($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
69 | 69 | $content['explode_multiselects'][$settings['field']] = $settings; |
70 | 70 | } |
71 | 71 | } |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | switch (array_search('pressed', $content['button'])) |
74 | 74 | { |
75 | 75 | case 'next': |
76 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
76 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
77 | 77 | case 'previous' : |
78 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
78 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
79 | 79 | case 'finish': |
80 | 80 | return 'wizard_finish'; |
81 | 81 | default : |
82 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
82 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | // init step50 |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects']; |
94 | 94 | |
95 | 95 | // Skip this step if no fields applicable |
96 | - if(count($field_list) == 0) { |
|
96 | + if (count($field_list) == 0) { |
|
97 | 97 | $content['explode_multiselects'] = array(); |
98 | 98 | } |
99 | 99 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | $row = 1; |
111 | - foreach($field_list as $field => $name) { |
|
111 | + foreach ($field_list as $field => $name) { |
|
112 | 112 | $content['explode_multiselects'][$row] = array( |
113 | 113 | 'field' => $field, |
114 | 114 | 'name' => $name, |
115 | 115 | 'explode'=> $settings[$field] |
116 | 116 | ); |
117 | - if($field == 'cat_id') { |
|
117 | + if ($field == 'cat_id') { |
|
118 | 118 | $sel_options['explode_multiselects'][$row]['explode'] = $cat_options; |
119 | 119 | } else { |
120 | 120 | $sel_options['explode_multiselects'][$row]['explode'] = $multi_options; |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | $field_list = array(); |
137 | 137 | |
138 | 138 | // Category gets special handling |
139 | - if(in_array('cat_id', array_keys($content['mapping']))) { |
|
139 | + if (in_array('cat_id', array_keys($content['mapping']))) { |
|
140 | 140 | $field_list['cat_id'] = $this->export_fields['cat_id']; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Add any multi-select custom fields |
144 | 144 | $custom = Api\Storage\Customfields::get('addressbook'); |
145 | - foreach($custom as $name => $c_field) { |
|
146 | - if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
145 | + foreach ($custom as $name => $c_field) { |
|
146 | + if ($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
147 | 147 | $field_list['#'.$name] = $c_field['label']; |
148 | 148 | } |
149 | 149 | } |
@@ -13,7 +13,8 @@ discard block |
||
13 | 13 | |
14 | 14 | class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_export_csv |
15 | 15 | { |
16 | - public function __construct() { |
|
16 | + public function __construct() |
|
17 | + { |
|
17 | 18 | parent::__construct(); |
18 | 19 | |
19 | 20 | $this->steps['wizard_step50'] = lang('Choose export options'); |
@@ -22,7 +23,8 @@ discard block |
||
22 | 23 | // Field mapping |
23 | 24 | $bocontacts = new Api\Contacts(); |
24 | 25 | $this->export_fields = $bocontacts->contact_fields; |
25 | - foreach($bocontacts->customfields as $name => $data) { |
|
26 | + foreach($bocontacts->customfields as $name => $data) |
|
27 | + { |
|
26 | 28 | $this->export_fields['#'.$name] = $data['label']; |
27 | 29 | } |
28 | 30 | unset($this->export_fields['jpegphoto']); // can't cvs export that |
@@ -37,17 +39,24 @@ discard block |
||
37 | 39 | /** |
38 | 40 | * Overridden to be able to skip the next step |
39 | 41 | */ |
40 | - function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) { |
|
42 | + function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
|
43 | + { |
|
41 | 44 | |
42 | - if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
|
45 | + if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') |
|
46 | + { |
|
43 | 47 | $result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
44 | 48 | $field_list = $this->get_field_list($content); |
45 | - if(count($field_list)) { |
|
49 | + if(count($field_list)) |
|
50 | + { |
|
46 | 51 | return $result; |
47 | - } else { |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
48 | 55 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2); |
49 | 56 | } |
50 | - } else { |
|
57 | + } |
|
58 | + else |
|
59 | + { |
|
51 | 60 | return parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
52 | 61 | } |
53 | 62 | } |
@@ -56,16 +65,22 @@ discard block |
||
56 | 65 | * Choose how to export multi-selects (includes Api\Categories) |
57 | 66 | */ |
58 | 67 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
59 | - { |
|
60 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
68 | + { |
|
69 | + if($this->debug) |
|
70 | + { |
|
71 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
72 | + } |
|
61 | 73 | // return from step50 |
62 | 74 | if ($content['step'] == 'wizard_step50') |
63 | 75 | { |
64 | - if($content['explode_multiselects']) { |
|
76 | + if($content['explode_multiselects']) |
|
77 | + { |
|
65 | 78 | $explodes = $content['explode_multiselects']; |
66 | 79 | $content['explode_multiselects'] = array(); |
67 | - foreach($explodes as $row => $settings) { |
|
68 | - if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
80 | + foreach($explodes as $row => $settings) |
|
81 | + { |
|
82 | + if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) |
|
83 | + { |
|
69 | 84 | $content['explode_multiselects'][$settings['field']] = $settings; |
70 | 85 | } |
71 | 86 | } |
@@ -93,7 +108,8 @@ discard block |
||
93 | 108 | $settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects']; |
94 | 109 | |
95 | 110 | // Skip this step if no fields applicable |
96 | - if(count($field_list) == 0) { |
|
111 | + if(count($field_list) == 0) |
|
112 | + { |
|
97 | 113 | $content['explode_multiselects'] = array(); |
98 | 114 | } |
99 | 115 | |
@@ -108,15 +124,19 @@ discard block |
||
108 | 124 | ); |
109 | 125 | |
110 | 126 | $row = 1; |
111 | - foreach($field_list as $field => $name) { |
|
127 | + foreach($field_list as $field => $name) |
|
128 | + { |
|
112 | 129 | $content['explode_multiselects'][$row] = array( |
113 | 130 | 'field' => $field, |
114 | 131 | 'name' => $name, |
115 | 132 | 'explode'=> $settings[$field] |
116 | 133 | ); |
117 | - if($field == 'cat_id') { |
|
134 | + if($field == 'cat_id') |
|
135 | + { |
|
118 | 136 | $sel_options['explode_multiselects'][$row]['explode'] = $cat_options; |
119 | - } else { |
|
137 | + } |
|
138 | + else |
|
139 | + { |
|
120 | 140 | $sel_options['explode_multiselects'][$row]['explode'] = $multi_options; |
121 | 141 | } |
122 | 142 | $row++; |
@@ -132,18 +152,22 @@ discard block |
||
132 | 152 | /** |
133 | 153 | * Get a list of multi-select fields |
134 | 154 | */ |
135 | - protected function get_field_list($content) { |
|
155 | + protected function get_field_list($content) |
|
156 | + { |
|
136 | 157 | $field_list = array(); |
137 | 158 | |
138 | 159 | // Category gets special handling |
139 | - if(in_array('cat_id', array_keys($content['mapping']))) { |
|
160 | + if(in_array('cat_id', array_keys($content['mapping']))) |
|
161 | + { |
|
140 | 162 | $field_list['cat_id'] = $this->export_fields['cat_id']; |
141 | 163 | } |
142 | 164 | |
143 | 165 | // Add any multi-select custom fields |
144 | 166 | $custom = Api\Storage\Customfields::get('addressbook'); |
145 | - foreach($custom as $name => $c_field) { |
|
146 | - if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
167 | + foreach($custom as $name => $c_field) |
|
168 | + { |
|
169 | + if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) |
|
170 | + { |
|
147 | 171 | $field_list['#'.$name] = $c_field['label']; |
148 | 172 | } |
149 | 173 | } |
@@ -25,4 +25,4 @@ |
||
25 | 25 | unset($old_state['advanced_search']); |
26 | 26 | Api\Cache::setSession('addressbook', 'index', $old_state); |
27 | 27 | } |
28 | -Api\Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index'); |
|
28 | +Api\Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index'); |
@@ -168,7 +168,7 @@ |
||
168 | 168 | // some apache mod_auth_* modules use REMOTE_USER instead of PHP_AUTH_USER, thanks to Sylvain Beucler |
169 | 169 | if ($GLOBALS['egw_info']['server']['auth_type'] == 'http' && !isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['REMOTE_USER'])) |
170 | 170 | { |
171 | - $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER']; |
|
171 | + $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER']; |
|
172 | 172 | } |
173 | 173 | if($GLOBALS['egw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
174 | 174 | { |
@@ -365,14 +365,21 @@ |
||
365 | 365 | $extra_vars .= ($extra_vars ? '&' : '').'cd=yes'; |
366 | 366 | } |
367 | 367 | |
368 | - if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) { |
|
368 | + if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) |
|
369 | + { |
|
369 | 370 | // login requuest does not come from login.php |
370 | 371 | // redirect to referer on logout |
371 | 372 | Api\Cache::setSession('login', 'referer', $_SERVER['HTTP_REFERER']); |
372 | 373 | } |
373 | 374 | $strength = ($GLOBALS['egw_info']['server']['force_pwd_strength']?$GLOBALS['egw_info']['server']['force_pwd_strength']:false); |
374 | - if ($strength && $strength>5) $strength =5; |
|
375 | - if ($strength && $strength<0) $strength = false; |
|
375 | + if ($strength && $strength>5) |
|
376 | + { |
|
377 | + $strength =5; |
|
378 | + } |
|
379 | + if ($strength && $strength<0) |
|
380 | + { |
|
381 | + $strength = false; |
|
382 | + } |
|
376 | 383 | // Check for save passwd |
377 | 384 | if($strength && $GLOBALS['egw_info']['server']['check_save_passwd'] && !$GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences') && |
378 | 385 | ($unsave_msg = $GLOBALS['egw']->auth->crackcheck($passwd, $strength))) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | use EGroupware\Api\Framework; |
16 | 16 | use EGroupware\Api\Egw; |
17 | 17 | |
18 | -$submit = False; // set to some initial value |
|
18 | +$submit = False; // set to some initial value |
|
19 | 19 | |
20 | 20 | $GLOBALS['egw_info'] = array('flags' => array( |
21 | 21 | 'disable_Template_class' => True, |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | 'currentapp' => 'login', |
24 | 24 | )); |
25 | 25 | |
26 | -if(file_exists('./header.inc.php')) |
|
26 | +if (file_exists('./header.inc.php')) |
|
27 | 27 | { |
28 | 28 | include('./header.inc.php'); |
29 | - if(!function_exists('CreateObject')) |
|
29 | + if (!function_exists('CreateObject')) |
|
30 | 30 | { |
31 | 31 | Header('Location: setup/index.php'); |
32 | 32 | exit; |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | * Destroy any existing anonymous session. |
43 | 43 | * Copied from logout.php. Maybe make it a common function? |
44 | 44 | */ |
45 | -if(isset($GLOBALS['sitemgr_info']) && $GLOBALS['egw_info']['user']['userid'] == $GLOBALS['sitemgr_info']['anonymous_user']) |
|
45 | +if (isset($GLOBALS['sitemgr_info']) && $GLOBALS['egw_info']['user']['userid'] == $GLOBALS['sitemgr_info']['anonymous_user']) |
|
46 | 46 | { |
47 | - if($GLOBALS['egw']->session->verify()) |
|
47 | + if ($GLOBALS['egw']->session->verify()) |
|
48 | 48 | { |
49 | 49 | Api\Hooks::process('logout'); |
50 | - $GLOBALS['egw']->session->destroy($GLOBALS['sessionid'],$GLOBALS['kp3']); |
|
50 | + $GLOBALS['egw']->session->destroy($GLOBALS['sessionid'], $GLOBALS['kp3']); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | 54 | // CAS : |
55 | -if($GLOBALS['egw_info']['server']['auth_type'] == 'cas') |
|
55 | +if ($GLOBALS['egw_info']['server']['auth_type'] == 'cas') |
|
56 | 56 | { |
57 | 57 | ob_end_clean(); |
58 | 58 | |
@@ -60,32 +60,32 @@ discard block |
||
60 | 60 | |
61 | 61 | //phpCAS::setDebug('/var/log/log_phpcas.php'); |
62 | 62 | |
63 | - if($GLOBALS['egw_info']['server']['cas_authentication_mode'] == 'Proxy') |
|
63 | + if ($GLOBALS['egw_info']['server']['cas_authentication_mode'] == 'Proxy') |
|
64 | 64 | { |
65 | 65 | phpCAS::proxy(CAS_VERSION_2_0, |
66 | 66 | $GLOBALS['egw_info']['server']['cas_server_host_name'], |
67 | - (int) $GLOBALS['egw_info']['server']['cas_server_port'], |
|
68 | - $GLOBALS['egw_info']['server']['cas_server_uri'] ); |
|
67 | + (int)$GLOBALS['egw_info']['server']['cas_server_port'], |
|
68 | + $GLOBALS['egw_info']['server']['cas_server_uri']); |
|
69 | 69 | } |
70 | 70 | else |
71 | 71 | { |
72 | 72 | phpCAS::client(CAS_VERSION_2_0, |
73 | 73 | $GLOBALS['egw_info']['server']['cas_server_host_name'], |
74 | - (int) $GLOBALS['egw_info']['server']['cas_server_port'], |
|
75 | - $GLOBALS['egw_info']['server']['cas_server_uri'] ); |
|
74 | + (int)$GLOBALS['egw_info']['server']['cas_server_port'], |
|
75 | + $GLOBALS['egw_info']['server']['cas_server_uri']); |
|
76 | 76 | } |
77 | 77 | |
78 | - if($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'PEMCertificate') |
|
78 | + if ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'PEMCertificate') |
|
79 | 79 | { |
80 | 80 | // Set the certificate of the CAS server (PEM Certificate) |
81 | 81 | phpCAS::setCasServerCert($GLOBALS['egw_info']['server']['cas_cert']); |
82 | 82 | } |
83 | - elseif($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'CACertificate') |
|
83 | + elseif ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'CACertificate') |
|
84 | 84 | { |
85 | 85 | // Set the CA certificate of the CAS server |
86 | 86 | phpCAS::setCasServerCACert($GLOBALS['egw_info']['server']['cas_cert']); |
87 | 87 | } |
88 | - elseif($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'No') |
|
88 | + elseif ($GLOBALS['egw_info']['server']['cas_ssl_validation'] == 'No') |
|
89 | 89 | { |
90 | 90 | // no SSL validation for the CAS server |
91 | 91 | phpCAS::setNoCasServerValidation(); |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | ob_start(); |
97 | 97 | |
98 | 98 | $login = phpCAS::getUser(); |
99 | - $password = phpCAS::retrievePT("imap://".$GLOBALS['egw_info']['server']['mail_server'],$err_code,$output); |
|
100 | - $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login,$password,'text'); |
|
99 | + $password = phpCAS::retrievePT("imap://".$GLOBALS['egw_info']['server']['mail_server'], $err_code, $output); |
|
100 | + $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $password, 'text'); |
|
101 | 101 | |
102 | 102 | /* set auth_cookie */ |
103 | - $GLOBALS['egw']->redirect_link($forward,$extra_vars); |
|
103 | + $GLOBALS['egw']->redirect_link($forward, $extra_vars); |
|
104 | 104 | } |
105 | 105 | else |
106 | 106 | { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $GLOBALS['egw']->framework = Framework::factory(); |
126 | 126 | |
127 | 127 | // This is used for system downtime, to prevent new logins. |
128 | - if($GLOBALS['egw_info']['server']['deny_all_logins']) |
|
128 | + if ($GLOBALS['egw_info']['server']['deny_all_logins']) |
|
129 | 129 | { |
130 | 130 | echo $GLOBALS['egw']->framework->denylogin_screen(); |
131 | 131 | exit; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER']; |
140 | 140 | } |
141 | - if($GLOBALS['egw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
|
141 | + if ($GLOBALS['egw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER'])) |
|
142 | 142 | { |
143 | 143 | $submit = True; |
144 | 144 | $login = $_SERVER['PHP_AUTH_USER']; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | $passwd = get_magic_quotes_gpc() ? stripslashes($_POST['passwd']) : $_POST['passwd']; |
151 | 151 | $passwd_type = $_POST['passwd_type']; |
152 | 152 | |
153 | - if($GLOBALS['egw_info']['server']['allow_cookie_auth']) |
|
153 | + if ($GLOBALS['egw_info']['server']['allow_cookie_auth']) |
|
154 | 154 | { |
155 | - $eGW_remember = explode('::::',get_magic_quotes_gpc() ? stripslashes($_COOKIE['eGW_remember']) : $_COOKIE['eGW_remember']); |
|
155 | + $eGW_remember = explode('::::', get_magic_quotes_gpc() ? stripslashes($_COOKIE['eGW_remember']) : $_COOKIE['eGW_remember']); |
|
156 | 156 | |
157 | - if($eGW_remember[0] && $eGW_remember[1] && $eGW_remember[2]) |
|
157 | + if ($eGW_remember[0] && $eGW_remember[1] && $eGW_remember[2]) |
|
158 | 158 | { |
159 | 159 | $_SERVER['PHP_AUTH_USER'] = $login = $eGW_remember[0]; |
160 | 160 | $_SERVER['PHP_AUTH_PW'] = $passwd = $eGW_remember[1]; |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | $submit = True; |
163 | 163 | } |
164 | 164 | } |
165 | - if(!$passwd && ($GLOBALS['egw_info']['server']['auto_anon_login']) && !$_GET['cd']) |
|
165 | + if (!$passwd && ($GLOBALS['egw_info']['server']['auto_anon_login']) && !$_GET['cd']) |
|
166 | 166 | { |
167 | 167 | $_SERVER['PHP_AUTH_USER'] = $login = 'anonymous'; |
168 | - $_SERVER['PHP_AUTH_PW'] = $passwd = 'anonymous'; |
|
168 | + $_SERVER['PHP_AUTH_PW'] = $passwd = 'anonymous'; |
|
169 | 169 | $passwd_type = 'text'; |
170 | 170 | $submit = True; |
171 | 171 | } |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | |
174 | 174 | # Apache + mod_ssl style SSL certificate authentication |
175 | 175 | # Certificate (chain) verification occurs inside mod_ssl |
176 | - if($GLOBALS['egw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) |
|
176 | + if ($GLOBALS['egw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd'])) |
|
177 | 177 | { |
178 | 178 | // an X.509 subject looks like: |
179 | 179 | // CN=john.doe/OU=Department/O=Company/C=xx/[email protected]/L=City/ |
180 | 180 | // the username is deliberately lowercase, to ease LDAP integration |
181 | - $sslattribs = explode('/',$_SERVER['SSL_CLIENT_S_DN']); |
|
181 | + $sslattribs = explode('/', $_SERVER['SSL_CLIENT_S_DN']); |
|
182 | 182 | # skip the part in front of the first '/' (nothing) |
183 | - while(($sslattrib = next($sslattribs))) |
|
183 | + while (($sslattrib = next($sslattribs))) |
|
184 | 184 | { |
185 | - list($key,$val) = explode('=',$sslattrib); |
|
185 | + list($key, $val) = explode('=', $sslattrib); |
|
186 | 186 | $sslattributes[$key] = $val; |
187 | 187 | } |
188 | 188 | |
189 | - if(isset($sslattributes['Email'])) |
|
189 | + if (isset($sslattributes['Email'])) |
|
190 | 190 | { |
191 | 191 | $submit = True; |
192 | 192 | |
193 | 193 | # login will be set here if the user logged out and uses a different username with |
194 | 194 | # the same SSL-certificate. |
195 | - if(!isset($_POST['login'])&&isset($sslattributes['Email'])) |
|
195 | + if (!isset($_POST['login']) && isset($sslattributes['Email'])) |
|
196 | 196 | { |
197 | 197 | $login = $sslattributes['Email']; |
198 | 198 | # not checked against the database, but delivered to authentication module |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | unset($sslattributes); |
205 | 205 | } |
206 | 206 | |
207 | - if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
|
207 | + if (isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit) |
|
208 | 208 | { |
209 | - if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
|
209 | + if (getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && |
|
210 | 210 | !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN'])) |
211 | 211 | { |
212 | - $GLOBALS['egw']->session->egw_setcookie('eGW_remember','',0,'/'); |
|
213 | - Egw::redirect_link('/login.php','cd=5'); |
|
212 | + $GLOBALS['egw']->session->egw_setcookie('eGW_remember', '', 0, '/'); |
|
213 | + Egw::redirect_link('/login.php', 'cd=5'); |
|
214 | 214 | } |
215 | 215 | /* cookie enabled check comment out, as it seems to cause a redirect loop under certain conditions and browsers :-( |
216 | 216 | if ($_COOKIE['eGW_cookie_test'] !== 'enabled') |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | }*/ |
220 | 220 | |
221 | 221 | // don't get login data again when $submit is true |
222 | - if($submit == false) |
|
222 | + if ($submit == false) |
|
223 | 223 | { |
224 | 224 | $login = $_POST['login']; |
225 | 225 | } |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | //conference - for strings like [email protected]@default , allows |
228 | 228 | //that user have a login that is his e-mail. (viniciuscb) |
229 | 229 | // remove blanks |
230 | - $login_parts = array_map('trim',explode('@',$login)); |
|
231 | - $login = implode('@',$login_parts); |
|
230 | + $login_parts = array_map('trim', explode('@', $login)); |
|
231 | + $login = implode('@', $login_parts); |
|
232 | 232 | |
233 | 233 | $got_login = false; |
234 | 234 | if (count($login_parts) > 1) |
235 | 235 | { |
236 | 236 | //Last part of login string, when separated by @, is a domain name |
237 | - if (array_key_exists(array_pop($login_parts),$GLOBALS['egw_domain'])) |
|
237 | + if (array_key_exists(array_pop($login_parts), $GLOBALS['egw_domain'])) |
|
238 | 238 | { |
239 | 239 | $got_login = true; |
240 | 240 | } |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | |
243 | 243 | if (!$got_login) |
244 | 244 | { |
245 | - if(isset($_POST['logindomain'])) |
|
245 | + if (isset($_POST['logindomain'])) |
|
246 | 246 | { |
247 | - $login .= '@' . $_POST['logindomain']; |
|
247 | + $login .= '@'.$_POST['logindomain']; |
|
248 | 248 | } |
249 | - elseif(!isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) |
|
249 | + elseif (!isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) |
|
250 | 250 | { |
251 | 251 | $login .= '@'.$GLOBALS['egw_info']['server']['default_domain']; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $passwd, |
255 | - $passwd_type, false, true, true); // true = let session fail on forced password change |
|
255 | + $passwd_type, false, true, true); // true = let session fail on forced password change |
|
256 | 256 | |
257 | 257 | if (!$GLOBALS['sessionid'] && $GLOBALS['egw']->session->cd_reason == Api\Session::CD_FORCE_PASSWORD_CHANGE) |
258 | 258 | { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | } |
265 | 265 | else |
266 | 266 | { |
267 | - $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login,$_POST['new_passwd'],$passwd_type); |
|
267 | + $GLOBALS['sessionid'] = $GLOBALS['egw']->session->create($login, $_POST['new_passwd'], $passwd_type); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | else |
@@ -276,46 +276,46 @@ discard block |
||
276 | 276 | { |
277 | 277 | // will show new login-screen incl. new password field below |
278 | 278 | } |
279 | - elseif (!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid']) |
|
279 | + elseif (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) |
|
280 | 280 | { |
281 | - Api\Session::egw_setcookie('eGW_remember','',0,'/'); |
|
282 | - Egw::redirect_link('/login.php?cd=' . $GLOBALS['egw']->session->cd_reason); |
|
281 | + Api\Session::egw_setcookie('eGW_remember', '', 0, '/'); |
|
282 | + Egw::redirect_link('/login.php?cd='.$GLOBALS['egw']->session->cd_reason); |
|
283 | 283 | } |
284 | 284 | else |
285 | 285 | { |
286 | 286 | /* set auth_cookie */ |
287 | - if($GLOBALS['egw_info']['server']['allow_cookie_auth'] && $_POST['remember_me'] && $_POST['passwd']) |
|
287 | + if ($GLOBALS['egw_info']['server']['allow_cookie_auth'] && $_POST['remember_me'] && $_POST['passwd']) |
|
288 | 288 | { |
289 | 289 | switch ($_POST['remember_me']) |
290 | 290 | { |
291 | 291 | case '1hour' : |
292 | - $remember_time = time()+60*60; |
|
292 | + $remember_time = time() + 60 * 60; |
|
293 | 293 | break; |
294 | 294 | case '1day' : |
295 | - $remember_time = time()+60*60*24; |
|
295 | + $remember_time = time() + 60 * 60 * 24; |
|
296 | 296 | break; |
297 | 297 | case '1week' : |
298 | - $remember_time = time()+60*60*24*7; |
|
298 | + $remember_time = time() + 60 * 60 * 24 * 7; |
|
299 | 299 | break; |
300 | 300 | case '1month' : |
301 | - $remember_time = time()+60*60*24*30; |
|
301 | + $remember_time = time() + 60 * 60 * 24 * 30; |
|
302 | 302 | break; |
303 | 303 | case 'forever' : |
304 | 304 | default: |
305 | 305 | $remember_time = 2147483647; |
306 | 306 | break; |
307 | 307 | } |
308 | - $GLOBALS['egw']->session->egw_setcookie('eGW_remember',implode('::::',array( |
|
308 | + $GLOBALS['egw']->session->egw_setcookie('eGW_remember', implode('::::', array( |
|
309 | 309 | 'login' => $login, |
310 | 310 | 'passwd' => $passwd, |
311 | 311 | 'passwd_type' => $passwd_type)), |
312 | - $remember_time,'/'); // make the cookie valid for the whole site (incl. sitemgr) and not only the eGW install-dir |
|
312 | + $remember_time, '/'); // make the cookie valid for the whole site (incl. sitemgr) and not only the eGW install-dir |
|
313 | 313 | } |
314 | 314 | |
315 | - if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_POST['lang']) && |
|
315 | + if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_POST['lang']) && |
|
316 | 316 | $_POST['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) |
317 | 317 | { |
318 | - $GLOBALS['egw']->preferences->add('common','lang',$_POST['lang'],'session'); |
|
318 | + $GLOBALS['egw']->preferences->add('common', 'lang', $_POST['lang'], 'session'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | // check if new translations are available |
@@ -329,27 +329,27 @@ discard block |
||
329 | 329 | } |
330 | 330 | else |
331 | 331 | { |
332 | - list($forward,$extra_vars) = explode('?',$forward,2); |
|
332 | + list($forward, $extra_vars) = explode('?', $forward, 2); |
|
333 | 333 | $extra_vars .= ($extra_vars ? '&' : '').'cd=yes'; |
334 | 334 | } |
335 | 335 | |
336 | - if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) { |
|
336 | + if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['REQUEST_URI']) === false) { |
|
337 | 337 | // login requuest does not come from login.php |
338 | 338 | // redirect to referer on logout |
339 | 339 | Api\Cache::setSession('login', 'referer', $_SERVER['HTTP_REFERER']); |
340 | 340 | } |
341 | - $strength = ($GLOBALS['egw_info']['server']['force_pwd_strength']?$GLOBALS['egw_info']['server']['force_pwd_strength']:false); |
|
342 | - if ($strength && $strength>5) $strength =5; |
|
343 | - if ($strength && $strength<0) $strength = false; |
|
341 | + $strength = ($GLOBALS['egw_info']['server']['force_pwd_strength'] ? $GLOBALS['egw_info']['server']['force_pwd_strength'] : false); |
|
342 | + if ($strength && $strength > 5) $strength = 5; |
|
343 | + if ($strength && $strength < 0) $strength = false; |
|
344 | 344 | // Check for save passwd |
345 | - if($strength && $GLOBALS['egw_info']['server']['check_save_passwd'] && !$GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences') && |
|
345 | + if ($strength && $GLOBALS['egw_info']['server']['check_save_passwd'] && !$GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences') && |
|
346 | 346 | ($unsave_msg = $GLOBALS['egw']->auth->crackcheck($passwd, $strength))) |
347 | 347 | { |
348 | - error_log('login::'.__LINE__.' User '. $login. ' authenticated with an unsave password'.' '.$unsave_msg); |
|
348 | + error_log('login::'.__LINE__.' User '.$login.' authenticated with an unsave password'.' '.$unsave_msg); |
|
349 | 349 | $message = lang('eGroupWare checked your password for safetyness. You have to change your password for the following reason:')."\n"; |
350 | 350 | Egw::redirect_link('/index.php', array( |
351 | 351 | 'menuaction' => 'preferences.uipassword.change', |
352 | - 'message' => $message . $unsave_msg, |
|
352 | + 'message' => $message.$unsave_msg, |
|
353 | 353 | 'cd' => 'yes', |
354 | 354 | )); |
355 | 355 | } |
@@ -357,66 +357,66 @@ discard block |
||
357 | 357 | { |
358 | 358 | // commiting the session, before redirecting might fix racecondition in session creation |
359 | 359 | $GLOBALS['egw']->session->commit_session(); |
360 | - Egw::redirect_link($forward,$extra_vars); |
|
360 | + Egw::redirect_link($forward, $extra_vars); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
364 | 364 | // show login screen |
365 | - if(isset($_COOKIE['last_loginid'])) |
|
365 | + if (isset($_COOKIE['last_loginid'])) |
|
366 | 366 | { |
367 | 367 | $prefs = new Api\Preferences($GLOBALS['egw']->accounts->name2id($_COOKIE['last_loginid'])); |
368 | 368 | |
369 | - if($prefs->account_id) |
|
369 | + if ($prefs->account_id) |
|
370 | 370 | { |
371 | 371 | $GLOBALS['egw_info']['user']['preferences'] = $prefs->read_repository(); |
372 | 372 | } |
373 | 373 | } |
374 | - if ($_GET['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_GET['lang'])) |
|
374 | + if ($_GET['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_GET['lang'])) |
|
375 | 375 | { |
376 | 376 | $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $_GET['lang']; |
377 | 377 | } |
378 | - elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id) |
|
378 | + elseif (!isset($_COOKIE['last_loginid']) || !$prefs->account_id) |
|
379 | 379 | { |
380 | 380 | // If the lastloginid cookies isn't set, we will default to the first language, |
381 | 381 | // the users browser accepts. |
382 | - list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
383 | - if(strlen($lang) > 2) |
|
382 | + list($lang) = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); |
|
383 | + if (strlen($lang) > 2) |
|
384 | 384 | { |
385 | - $lang = substr($lang,0,2); |
|
385 | + $lang = substr($lang, 0, 2); |
|
386 | 386 | } |
387 | 387 | $GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $lang; |
388 | 388 | } |
389 | 389 | if ($_COOKIE['eGW_cookie_test'] !== 'enabled') |
390 | 390 | { |
391 | - Api\Session::egw_setcookie('eGW_cookie_test','enabled',0); |
|
391 | + Api\Session::egw_setcookie('eGW_cookie_test', 'enabled', 0); |
|
392 | 392 | } |
393 | 393 | #print 'LANG:' . $GLOBALS['egw_info']['user']['preferences']['common']['lang'] . '<br>'; |
394 | - Api\Translation::init(); // this will set the language according to the (new) set prefs |
|
394 | + Api\Translation::init(); // this will set the language according to the (new) set prefs |
|
395 | 395 | Api\Translation::add_app('login'); |
396 | 396 | Api\Translation::add_app('loginscreen'); |
397 | - $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message',false,''); |
|
398 | - if($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
397 | + $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message', false, ''); |
|
398 | + if ($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
399 | 399 | { |
400 | - Api\Translation::add_app('loginscreen','en'); // trying the en one |
|
401 | - $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message',false,''); |
|
400 | + Api\Translation::add_app('loginscreen', 'en'); // trying the en one |
|
401 | + $GLOBALS['loginscreenmessage'] = Api\Translation::translate('loginscreen_message', false, ''); |
|
402 | 402 | } |
403 | - if($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
403 | + if ($GLOBALS['loginscreenmessage'] == 'loginscreen_message' || empty($GLOBALS['loginscreenmessage'])) |
|
404 | 404 | { |
405 | 405 | // remove the global var since the lang loginscreen message and its fallback (en) is empty or not set |
406 | 406 | unset($GLOBALS['loginscreenmessage']); |
407 | 407 | } |
408 | 408 | |
409 | - foreach($_GET as $name => $value) |
|
409 | + foreach ($_GET as $name => $value) |
|
410 | 410 | { |
411 | - if(strpos($name,'phpgw_') !== false) |
|
411 | + if (strpos($name, 'phpgw_') !== false) |
|
412 | 412 | { |
413 | - $extra_vars .= '&' . $name . '=' . urlencode($value); |
|
413 | + $extra_vars .= '&'.$name.'='.urlencode($value); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
417 | - if($extra_vars) |
|
417 | + if ($extra_vars) |
|
418 | 418 | { |
419 | - $extra_vars = '?' . substr($extra_vars,1); |
|
419 | + $extra_vars = '?'.substr($extra_vars, 1); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $GLOBALS['egw']->framework->login_screen($extra_vars, $force_password_change); |
@@ -19,8 +19,8 @@ |
||
19 | 19 | // or an uncoditional redirect to this file or copy groupdav.htaccess to your docroot as .htaccess |
20 | 20 | if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND' || $_SERVER['REQUEST_METHOD'] == 'OPTIONS') |
21 | 21 | { |
22 | - header('Location: groupdav.php/'); |
|
23 | - exit; |
|
22 | + header('Location: groupdav.php/'); |
|
23 | + exit; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // forward for not existing or empty header to setup |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | // forward for not existing or empty header to setup |
27 | -if(!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
27 | +if (!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
28 | 28 | { |
29 | 29 | Header('Location: setup/index.php'); |
30 | 30 | exit; |
31 | 31 | } |
32 | 32 | |
33 | -if(isset($_GET['hasupdates']) && $_GET['hasupdates'] == 'yes') |
|
33 | +if (isset($_GET['hasupdates']) && $_GET['hasupdates'] == 'yes') |
|
34 | 34 | { |
35 | 35 | $hasupdates = True; |
36 | 36 | } |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | /* |
39 | 39 | This is the menuaction driver for the multi-layered design |
40 | 40 | */ |
41 | -if(isset($_GET['menuaction']) && preg_match('/^[A-Za-z0-9_]+\.[A-Za-z0-9_\\\\]+\.[A-Za-z0-9_]+$/',$_GET['menuaction'])) |
|
41 | +if (isset($_GET['menuaction']) && preg_match('/^[A-Za-z0-9_]+\.[A-Za-z0-9_\\\\]+\.[A-Za-z0-9_]+$/', $_GET['menuaction'])) |
|
42 | 42 | { |
43 | - list($app,$class,$method) = explode('.',$_GET['menuaction']); |
|
43 | + list($app, $class, $method) = explode('.', $_GET['menuaction']); |
|
44 | 44 | |
45 | 45 | // check if autoloadable class belongs to given app |
46 | 46 | if (substr($class, 0, 11) == 'EGroupware\\') |
47 | 47 | { |
48 | 48 | list(,$app_from_class) = explode('\\', strtolower($class)); |
49 | 49 | } |
50 | - elseif(strpos($class, '_') !== false) |
|
50 | + elseif (strpos($class, '_') !== false) |
|
51 | 51 | { |
52 | 52 | list($app_from_class) = explode('_', $class); |
53 | 53 | } |
54 | - if(!$app || !$class || !$method || isset($app_from_class) && |
|
54 | + if (!$app || !$class || !$method || isset($app_from_class) && |
|
55 | 55 | isset($GLOBALS['egw_info']['apps'][$app_from_class]) && $app_from_class != $app) |
56 | 56 | { |
57 | 57 | $invalid_data = True; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $invalid_data = True; |
64 | 64 | } |
65 | 65 | //error_log(__METHOD__."$app,$class,$method"); |
66 | -if($app == 'phpgwapi') |
|
66 | +if ($app == 'phpgwapi') |
|
67 | 67 | { |
68 | 68 | $app = 'api'; |
69 | 69 | $api_requested = True; |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | // user changed timezone |
82 | 82 | if (isset($_GET['tz'])) |
83 | 83 | { |
84 | - Api\DateTime::setUserPrefs($_GET['tz']); // throws exception, if tz is invalid |
|
84 | + Api\DateTime::setUserPrefs($_GET['tz']); // throws exception, if tz is invalid |
|
85 | 85 | |
86 | - $GLOBALS['egw']->preferences->add('common','tz',$_GET['tz']); |
|
86 | + $GLOBALS['egw']->preferences->add('common', 'tz', $_GET['tz']); |
|
87 | 87 | $GLOBALS['egw']->preferences->save_repository(); |
88 | 88 | |
89 | 89 | if (($referer = Api\Header\Referer::get())) |
@@ -94,30 +94,30 @@ discard block |
||
94 | 94 | |
95 | 95 | // Check if we are using windows or normal webpage |
96 | 96 | $windowed = false; |
97 | -$tpl_info = EGW_SERVER_ROOT . '/phpgwapi/templates/' . basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']) . '/setup/setup.inc.php'; |
|
97 | +$tpl_info = EGW_SERVER_ROOT.'/phpgwapi/templates/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']).'/setup/setup.inc.php'; |
|
98 | 98 | if (!file_exists($tpl_info)) |
99 | 99 | { |
100 | - $tpl_info = EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']) . '/setup/setup.inc.php'; |
|
100 | + $tpl_info = EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']).'/setup/setup.inc.php'; |
|
101 | 101 | } |
102 | -if(@file_exists($tpl_info)) |
|
102 | +if (@file_exists($tpl_info)) |
|
103 | 103 | { |
104 | 104 | include_once($tpl_info); |
105 | - if($GLOBALS['egw_info']['template'][$GLOBALS['egw_info']['user']['preferences']['common']['template_set']]['windowed']) |
|
105 | + if ($GLOBALS['egw_info']['template'][$GLOBALS['egw_info']['user']['preferences']['common']['template_set']]['windowed']) |
|
106 | 106 | { |
107 | 107 | $windowed = true; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | -if($app == 'api' && !$class && !$api_requested && !($windowed && $_GET['cd'] == 'yes' && !Api\Header\UserAgent::mobile()) && $GLOBALS['egw_info']['user']['preferences']['common']['template_set'] == 'idots') |
|
112 | +if ($app == 'api' && !$class && !$api_requested && !($windowed && $_GET['cd'] == 'yes' && !Api\Header\UserAgent::mobile()) && $GLOBALS['egw_info']['user']['preferences']['common']['template_set'] == 'idots') |
|
113 | 113 | { |
114 | 114 | if ($GLOBALS['egw_info']['server']['force_default_app'] && $GLOBALS['egw_info']['server']['force_default_app'] != 'user_choice') |
115 | 115 | { |
116 | 116 | $GLOBALS['egw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['egw_info']['server']['force_default_app']; |
117 | 117 | } |
118 | - if($GLOBALS['egw_info']['user']['preferences']['common']['default_app'] && !$hasupdates) |
|
118 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['default_app'] && !$hasupdates) |
|
119 | 119 | { |
120 | - Egw::redirect(Framework::index($GLOBALS['egw_info']['user']['preferences']['common']['default_app']),$GLOBALS['egw_info']['user']['preferences']['common']['default_app']); |
|
120 | + Egw::redirect(Framework::index($GLOBALS['egw_info']['user']['preferences']['common']['default_app']), $GLOBALS['egw_info']['user']['preferences']['common']['default_app']); |
|
121 | 121 | } |
122 | 122 | else |
123 | 123 | { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -if($windowed && $_GET['cd'] == 'yes') |
|
128 | +if ($windowed && $_GET['cd'] == 'yes') |
|
129 | 129 | { |
130 | 130 | $GLOBALS['egw_info']['flags'] = array( |
131 | 131 | 'noheader' => False, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - if($api_requested) |
|
140 | + if ($api_requested) |
|
141 | 141 | { |
142 | 142 | $app = 'phpgwapi'; |
143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $obj = CreateObject($app.'.'.$class); |
152 | 152 | } |
153 | - if((is_array($obj->public_functions) && $obj->public_functions[$method]) && !$invalid_data) |
|
153 | + if ((is_array($obj->public_functions) && $obj->public_functions[$method]) && !$invalid_data) |
|
154 | 154 | { |
155 | 155 | $obj->$method(); |
156 | 156 | unset($app); |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - if(!$app || !$class || !$method || $invalid_data) |
|
164 | + if (!$app || !$class || !$method || $invalid_data) |
|
165 | 165 | { |
166 | - if(@is_object($GLOBALS['egw']->log)) |
|
166 | + if (@is_object($GLOBALS['egw']->log)) |
|
167 | 167 | { |
168 | 168 | $GLOBALS['egw']->log->message(array( |
169 | 169 | 'text' => 'W-BadmenuactionVariable, menuaction missing or corrupt: %1', |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if(!is_array($GLOBALS[$class]->public_functions) || !$GLOBALS[$class]->public_functions[$method] && $method) |
|
177 | + if (!is_array($GLOBALS[$class]->public_functions) || !$GLOBALS[$class]->public_functions[$method] && $method) |
|
178 | 178 | { |
179 | - if(@is_object($GLOBALS['egw']->log)) |
|
179 | + if (@is_object($GLOBALS['egw']->log)) |
|
180 | 180 | { |
181 | 181 | $GLOBALS['egw']->log->message(array( |
182 | 182 | 'text' => 'W-BadmenuactionVariable, attempted to access private method: %1', |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | )); |
187 | 187 | } |
188 | 188 | } |
189 | - if(@is_object($GLOBALS['egw']->log)) |
|
189 | + if (@is_object($GLOBALS['egw']->log)) |
|
190 | 190 | { |
191 | 191 | $GLOBALS['egw']->log->commit(); |
192 | 192 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $GLOBALS['egw']->redirect_link('/home/index.php'); |
195 | 195 | } |
196 | 196 | |
197 | - if(!isset($GLOBALS['egw_info']['nofooter'])) |
|
197 | + if (!isset($GLOBALS['egw_info']['nofooter'])) |
|
198 | 198 | { |
199 | 199 | echo $GLOBALS['egw']->framework->footer(); |
200 | 200 | } |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | |
23 | 23 | // switching off output compression for Lighttpd and HTTPS, as it makes problems with TB Lightning |
24 | 24 | if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' && |
25 | - strpos($_SERVER['SERVER_SOFTWARE'],'lighttpd/1.4') === 0 && |
|
26 | - strpos($_SERVER['HTTP_USER_AGENT'],'Lightning') !== false) |
|
25 | + strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd/1.4') === 0 && |
|
26 | + strpos($_SERVER['HTTP_USER_AGENT'], 'Lightning') !== false) |
|
27 | 27 | { |
28 | - ini_set('zlib.output_compression',0); |
|
28 | + ini_set('zlib.output_compression', 0); |
|
29 | 29 | } |
30 | 30 | //error_log("HTTPS='$_SERVER[HTTPS]', SERVER_SOFTWARE='$_SERVER[SERVER_SOFTWARE]', HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', REQUEST_METHOD='$_SERVER[REQUEST_METHOD]' --> zlib.output_compression=".ini_get('zlib.output_compression')); |
31 | 31 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | 'flags' => array( |
36 | 36 | 'noheader' => True, |
37 | 37 | 'currentapp' => 'groupdav', |
38 | - 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
38 | + 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
39 | 39 | 'autocreate_session_callback' => 'EGroupware\\Api\\Header\\Authenticate::autocreate_session_callback', |
40 | - 'auth_realm' => 'EGroupware CalDAV/CardDAV/GroupDAV server', // cant use groupdav::REALM as autoloading and include path not yet setup! |
|
40 | + 'auth_realm' => 'EGroupware CalDAV/CardDAV/GroupDAV server', // cant use groupdav::REALM as autoloading and include path not yet setup! |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | // if you move this file somewhere else, you need to adapt the path to the header! |