@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Constructor |
81 | 81 | * |
82 | - * @param int $user=null account_id of user to use for Acl, default current user |
|
82 | + * @param integer $user |
|
83 | 83 | */ |
84 | 84 | function __construct($user=null) |
85 | 85 | { |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | * |
775 | 775 | * Cornelius Weiss <[email protected]> |
776 | 776 | * @param array $file array with key => value |
777 | - * @param int $resource_id |
|
778 | - * @return mixed string with msg if somthing went wrong; nothing if all right |
|
777 | + * @param int $resouce_id |
|
778 | + * @return string|null string with msg if somthing went wrong; nothing if all right |
|
779 | 779 | */ |
780 | 780 | function save_picture($file,$resouce_id) |
781 | 781 | { |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | // Check for restore of deleted, restore held links |
371 | - if($old && $old['deleted'] && !$resource['deleted']) |
|
372 | - { |
|
373 | - Link::restore('resources', $resource['res_id']); |
|
374 | - } |
|
371 | + if($old && $old['deleted'] && !$resource['deleted']) |
|
372 | + { |
|
373 | + Link::restore('resources', $resource['res_id']); |
|
374 | + } |
|
375 | 375 | |
376 | 376 | // delete old pictures |
377 | 377 | if($resource['picture_src'] != 'own_src') |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | $list[$id] = ' ('.lang('conflict').') '.$resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
696 | 696 | } |
697 | 697 | } else { |
698 | - $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
698 | + $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
699 | 699 | } |
700 | 700 | } |
701 | 701 | } else { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @param int $user=null account_id of user to use for Acl, default current user |
83 | 83 | */ |
84 | - function __construct($user=null) |
|
84 | + function __construct($user = null) |
|
85 | 85 | { |
86 | 86 | $this->so = new resources_so(); |
87 | 87 | $this->acl = new resources_acl_bo($user); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->cal_right_transform = array( |
91 | 91 | resources_acl_bo::CAL_READ => Acl::READ, |
92 | - resources_acl_bo::DIRECT_BOOKING => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE, |
|
93 | - resources_acl_bo::CAT_ADMIN => Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE, |
|
92 | + resources_acl_bo::DIRECT_BOOKING => Acl::READ|Acl::ADD|Acl::EDIT|Acl::DELETE, |
|
93 | + resources_acl_bo::CAT_ADMIN => Acl::READ|Acl::ADD|Acl::EDIT|Acl::DELETE, |
|
94 | 94 | ); |
95 | 95 | } |
96 | 96 | |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * |
100 | 100 | * Cornelius Weiss <[email protected]> |
101 | 101 | */ |
102 | - function get_rows($query,&$rows,&$readonlys) |
|
102 | + function get_rows($query, &$rows, &$readonlys) |
|
103 | 103 | { |
104 | - if(!$query['csv_export']) |
|
104 | + if (!$query['csv_export']) |
|
105 | 105 | { |
106 | 106 | Api\Cache::setSession('resources', 'index_nm', $query); |
107 | 107 | } |
108 | 108 | if ($query['store_state']) // request to store state in session and filter in prefs? |
109 | 109 | { |
110 | - Api\Cache::setSession('resources',$query['store_state'],$query); |
|
110 | + Api\Cache::setSession('resources', $query['store_state'], $query); |
|
111 | 111 | //echo "<p>".__METHOD__."() query[filter]=$query[filter], prefs[resources][filter]={$GLOBALS['egw_info']['user']['preferences']['resources']['filter']}</p>\n"; |
112 | 112 | if ($query['filter'] != $GLOBALS['egw_info']['user']['preferences']['resources']['filter']) |
113 | 113 | { |
114 | - $GLOBALS['egw']->preferences->add('resources','filter',$query['filter'],'user'); |
|
114 | + $GLOBALS['egw']->preferences->add('resources', 'filter', $query['filter'], 'user'); |
|
115 | 115 | $GLOBALS['egw']->preferences->save_repository(); |
116 | 116 | } |
117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // Sub-query to get the count of accessories |
126 | 126 | $acc_join = "LEFT JOIN (SELECT accessory_of AS accessory_id, count(res_id) as acc_count FROM {$this->so->table_name} GROUP BY accessory_of) AS acc ON acc.accessory_id = {$this->so->table_name}.res_id "; |
127 | 127 | |
128 | - switch($query['filter2']) |
|
128 | + switch ($query['filter2']) |
|
129 | 129 | { |
130 | 130 | case -1: |
131 | 131 | // Resources only |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | default: |
151 | 151 | $filter['accessory_of'] = $query['filter2']; |
152 | 152 | } |
153 | - if($query['filter2'] != self::DELETED) |
|
153 | + if ($query['filter2'] != self::DELETED) |
|
154 | 154 | { |
155 | 155 | $filter['deleted'] = null; |
156 | 156 | } |
157 | 157 | |
158 | 158 | if ($query['filter']) |
159 | 159 | { |
160 | - if (($children = $this->acl->get_cats(Acl::READ,$query['filter']))) |
|
160 | + if (($children = $this->acl->get_cats(Acl::READ, $query['filter']))) |
|
161 | 161 | { |
162 | 162 | $filter['cat_id'] = array_keys($children); |
163 | 163 | $filter['cat_id'][] = $query['filter']; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $filter['bookable'] = true; |
182 | 182 | } |
183 | - $order_by = $query['order'] ? $query['order'].' '. $query['sort'] : ''; |
|
183 | + $order_by = $query['order'] ? $query['order'].' '.$query['sort'] : ''; |
|
184 | 184 | $start = (int)$query['start']; |
185 | 185 | |
186 | 186 | foreach ($filter as $k => $v) $query['col_filter'][$k] = $v; |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | $nr = $this->so->total; |
189 | 189 | |
190 | 190 | // we are called to serve bookable resources (e.g. calendar-dialog) |
191 | - if($query['show_bookable']) |
|
191 | + if ($query['show_bookable']) |
|
192 | 192 | { |
193 | 193 | // This is somehow ugly, i know... |
194 | - foreach((array)$rows as $num => $resource) |
|
194 | + foreach ((array)$rows as $num => $resource) |
|
195 | 195 | { |
196 | 196 | $rows[$num]['default_qty'] = 1; |
197 | 197 | } |
@@ -200,24 +200,24 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | $config = Api\Config::read('resources'); |
203 | - foreach($rows as $num => &$resource) |
|
203 | + foreach ($rows as $num => &$resource) |
|
204 | 204 | { |
205 | - if (!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT)) |
|
205 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::EDIT)) |
|
206 | 206 | { |
207 | 207 | $readonlys["edit[$resource[res_id]]"] = true; |
208 | 208 | } |
209 | - elseif($resource['deleted']) |
|
209 | + elseif ($resource['deleted']) |
|
210 | 210 | { |
211 | 211 | $resource['class'] .= 'deleted '; |
212 | 212 | } |
213 | - if (!$this->acl->is_permitted($resource['cat_id'],Acl::DELETE) || |
|
213 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::DELETE) || |
|
214 | 214 | ($resource['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history') |
215 | 215 | ) |
216 | 216 | { |
217 | 217 | $readonlys["delete[$resource[res_id]]"] = true; |
218 | 218 | $resource['class'] .= 'no_delete '; |
219 | 219 | } |
220 | - if ((!$this->acl->is_permitted($resource['cat_id'],Acl::ADD)) || |
|
220 | + if ((!$this->acl->is_permitted($resource['cat_id'], Acl::ADD)) || |
|
221 | 221 | // Allow new accessory action when viewing accessories of a certain resource |
222 | 222 | $query['filter2'] <= 0 && $resource['accessory_of'] != -1) |
223 | 223 | { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $resource['class'] .= 'no_book '; |
232 | 232 | $resource['class'] .= 'no_view_calendar '; |
233 | 233 | } |
234 | - if(!$this->acl->is_permitted($resource['cat_id'],resources_acl_bo::CAL_READ)) |
|
234 | + if (!$this->acl->is_permitted($resource['cat_id'], resources_acl_bo::CAL_READ)) |
|
235 | 235 | { |
236 | 236 | $readonlys["calendar[$resource[res_id]]"] = true; |
237 | 237 | $resource['class'] .= 'no_view_calendar '; |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | $resource['class'] .= 'no_buy '; |
243 | 243 | } |
244 | 244 | $readonlys["view_acc[{$resource['res_id']}]"] = ($resource['acc_count'] == 0); |
245 | - $resource['class'] .= ($resource['accessory_of']==-1 ? 'resource ' : 'accessory '); |
|
246 | - if($resource['acc_count']) |
|
245 | + $resource['class'] .= ($resource['accessory_of'] == -1 ? 'resource ' : 'accessory '); |
|
246 | + if ($resource['acc_count']) |
|
247 | 247 | { |
248 | 248 | $resource['class'] .= 'hasAccessories '; |
249 | - $accessories = $this->get_acc_list($resource['res_id'],$query['filter2']==self::DELETED); |
|
250 | - foreach($accessories as $acc_id => $acc_name) |
|
249 | + $accessories = $this->get_acc_list($resource['res_id'], $query['filter2'] == self::DELETED); |
|
250 | + foreach ($accessories as $acc_id => $acc_name) |
|
251 | 251 | { |
252 | 252 | $resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id)); |
253 | 253 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $resource['accessory_of_label'] = $this->link_title($resource['accessory_of']); |
256 | 256 | } |
257 | 257 | |
258 | - if($resource['deleted']) |
|
258 | + if ($resource['deleted']) |
|
259 | 259 | { |
260 | 260 | $rows[$num]['picture_thumb'] = 'deleted'; |
261 | 261 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $rows[$num]['admin'] = $this->acl->get_cat_admin($resource['cat_id']); |
277 | 277 | } |
278 | 278 | |
279 | - if(!Api\Storage\Customfields::get('resources')) |
|
279 | + if (!Api\Storage\Customfields::get('resources')) |
|
280 | 280 | { |
281 | 281 | $rows['no_customfields'] = true; |
282 | 282 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | { |
295 | 295 | if (!($data = $this->so->read(array('res_id' => $res_id)))) |
296 | 296 | { |
297 | - return null; // not found |
|
297 | + return null; // not found |
|
298 | 298 | } |
299 | - if (!$this->acl->is_permitted($data['cat_id'],Acl::READ)) |
|
299 | + if (!$this->acl->is_permitted($data['cat_id'], Acl::READ)) |
|
300 | 300 | { |
301 | - return false; // permission denied |
|
301 | + return false; // permission denied |
|
302 | 302 | } |
303 | 303 | return $data; |
304 | 304 | } |
@@ -312,35 +312,35 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function save($resource) |
314 | 314 | { |
315 | - if(!$this->acl->is_permitted($resource['cat_id'],Acl::EDIT)) |
|
315 | + if (!$this->acl->is_permitted($resource['cat_id'], Acl::EDIT)) |
|
316 | 316 | { |
317 | 317 | return lang('You are not permitted to edit this resource!'); |
318 | 318 | } |
319 | 319 | $old = array(); |
320 | 320 | // we need an id to save pictures and make links... |
321 | - if(!$resource['res_id']) |
|
321 | + if (!$resource['res_id']) |
|
322 | 322 | { |
323 | 323 | $resource['res_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
324 | - $resource['res_created'] = Api\DateTime::server2user(time(),'ts'); |
|
324 | + $resource['res_created'] = Api\DateTime::server2user(time(), 'ts'); |
|
325 | 325 | $resource['res_id'] = $this->so->save($resource); |
326 | 326 | } |
327 | 327 | else |
328 | 328 | { |
329 | 329 | $resource['res_modifier'] = $GLOBALS['egw_info']['user']['account_id']; |
330 | - $resource['res_modified'] = Api\DateTime::server2user(time(),'ts'); |
|
330 | + $resource['res_modified'] = Api\DateTime::server2user(time(), 'ts'); |
|
331 | 331 | $old = $this->read($resource['res_id']); |
332 | 332 | } |
333 | 333 | |
334 | 334 | switch ($resource['picture_src']) |
335 | 335 | { |
336 | 336 | case 'own_src': |
337 | - if($resource['own_file']['size'] > 0) |
|
337 | + if ($resource['own_file']['size'] > 0) |
|
338 | 338 | { |
339 | - $msg = $this->save_picture($resource['own_file'],$resource['res_id']); |
|
339 | + $msg = $this->save_picture($resource['own_file'], $resource['res_id']); |
|
340 | 340 | unset($resource['own_file']); |
341 | 341 | break; |
342 | 342 | } |
343 | - elseif(@egw_vfs::stat('/apps/resources/'.$resource['res_id'].'/'.self::PICTURE_NAME)) |
|
343 | + elseif (@egw_vfs::stat('/apps/resources/'.$resource['res_id'].'/'.self::PICTURE_NAME)) |
|
344 | 344 | { |
345 | 345 | break; |
346 | 346 | } |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | $resource['picture_src'] = 'gen_src'; |
352 | 352 | break; |
353 | 353 | default: |
354 | - if($resource['own_file']['size'] > 0) |
|
354 | + if ($resource['own_file']['size'] > 0) |
|
355 | 355 | { |
356 | 356 | $resource['picture_src'] = 'own_src'; |
357 | - $msg = $this->save_picture($resource['own_file'],$resource['res_id']); |
|
357 | + $msg = $this->save_picture($resource['own_file'], $resource['res_id']); |
|
358 | 358 | } |
359 | 359 | else |
360 | 360 | { |
@@ -362,55 +362,55 @@ discard block |
||
362 | 362 | } |
363 | 363 | } |
364 | 364 | // somthing went wrong on saving own picture |
365 | - if($msg) |
|
365 | + if ($msg) |
|
366 | 366 | { |
367 | 367 | return $msg; |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Check for restore of deleted, restore held links |
371 | - if($old && $old['deleted'] && !$resource['deleted']) |
|
371 | + if ($old && $old['deleted'] && !$resource['deleted']) |
|
372 | 372 | { |
373 | 373 | Link::restore('resources', $resource['res_id']); |
374 | 374 | } |
375 | 375 | |
376 | 376 | // delete old pictures |
377 | - if($resource['picture_src'] != 'own_src') |
|
377 | + if ($resource['picture_src'] != 'own_src') |
|
378 | 378 | { |
379 | 379 | $this->remove_picture($resource['res_id']); |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Update link title |
383 | - Link::notify_update('resources',$resource['res_id'], $resource); |
|
383 | + Link::notify_update('resources', $resource['res_id'], $resource); |
|
384 | 384 | // save links |
385 | - if(is_array($resource['link_to']['to_id'])) |
|
385 | + if (is_array($resource['link_to']['to_id'])) |
|
386 | 386 | { |
387 | - Link::link('resources',$resource['res_id'],$resource['link_to']['to_id']); |
|
387 | + Link::link('resources', $resource['res_id'], $resource['link_to']['to_id']); |
|
388 | 388 | } |
389 | - if($resource['accessory_of'] != $old['accessory_of']) |
|
389 | + if ($resource['accessory_of'] != $old['accessory_of']) |
|
390 | 390 | { |
391 | - Link::unlink(0,'resources',$resource['res_id'],'','resources',$old['accessory_of']); |
|
391 | + Link::unlink(0, 'resources', $resource['res_id'], '', 'resources', $old['accessory_of']); |
|
392 | 392 | |
393 | 393 | // Check for resource changing to accessory - move its accessories to resource |
394 | - if($old['accessory_of'] == -1 && $accessories = $this->get_acc_list($resource['res_id'])) |
|
394 | + if ($old['accessory_of'] == -1 && $accessories = $this->get_acc_list($resource['res_id'])) |
|
395 | 395 | { |
396 | - foreach($accessories as $accessory => $name) |
|
396 | + foreach ($accessories as $accessory => $name) |
|
397 | 397 | { |
398 | - Link::unlink(0,'resources',$accessory,'','resources',$resource['res_id']); |
|
398 | + Link::unlink(0, 'resources', $accessory, '', 'resources', $resource['res_id']); |
|
399 | 399 | $acc = $this->read($accessory); |
400 | 400 | $acc['accessory_of'] = -1; |
401 | 401 | $this->so->save($acc); |
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | - if($resource['accessory_of'] != -1) |
|
405 | + if ($resource['accessory_of'] != -1) |
|
406 | 406 | { |
407 | - Link::link('resources',$resource['res_id'],'resources',$resource['accessory_of']); |
|
407 | + Link::link('resources', $resource['res_id'], 'resources', $resource['accessory_of']); |
|
408 | 408 | } |
409 | 409 | |
410 | - if(!empty($resource['res_id']) && $this->so->get_value("cat_id",$resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1) |
|
410 | + if (!empty($resource['res_id']) && $this->so->get_value("cat_id", $resource['res_id']) != $resource['cat_id'] && $resource['accessory_of'] == -1) |
|
411 | 411 | { |
412 | 412 | $accessories = $this->get_acc_list($resource['res_id']); |
413 | - foreach($accessories as $accessory => $name) |
|
413 | + foreach ($accessories as $accessory => $name) |
|
414 | 414 | { |
415 | 415 | $acc = $this->so->read($accessory); |
416 | 416 | $acc['cat_id'] = $resource['cat_id']; |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | { |
427 | 427 | $this->tracking = new resources_tracking(); |
428 | 428 | } |
429 | - if ($this->tracking->track($resource,$old,$this->user) === false) |
|
429 | + if ($this->tracking->track($resource, $old, $this->user) === false) |
|
430 | 430 | { |
431 | - return implode(', ',$this->tracking->errors); |
|
431 | + return implode(', ', $this->tracking->errors); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $res_id ? $res_id : lang('Something went wrong by saving resource'); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | function delete($res_id) |
444 | 444 | { |
445 | - if(!$this->acl->is_permitted($this->so->get_value('cat_id',$res_id),Acl::DELETE)) |
|
445 | + if (!$this->acl->is_permitted($this->so->get_value('cat_id', $res_id), Acl::DELETE)) |
|
446 | 446 | { |
447 | 447 | return lang('You are not permitted to delete this resource!'); |
448 | 448 | } |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | { |
455 | 455 | $old['deleted'] = time(); |
456 | 456 | $this->save($old); |
457 | - Link::unlink(0,'resources',$res_id,'','','',true); |
|
457 | + Link::unlink(0, 'resources', $res_id, '', '', '', true); |
|
458 | 458 | $accessories = $this->get_acc_list($res_id); |
459 | - foreach($accessories as $acc_id => $name) |
|
459 | + foreach ($accessories as $acc_id => $name) |
|
460 | 460 | { |
461 | 461 | // Don't purge already deleted accessories |
462 | 462 | $acc = $this->read($acc_id); |
463 | - if(!$acc['deleted']) |
|
463 | + if (!$acc['deleted']) |
|
464 | 464 | { |
465 | 465 | $acc['deleted'] = time(); |
466 | 466 | $this->save($acc); |
467 | - Link::unlink(0,'resources',$acc_id,'','','',true); |
|
467 | + Link::unlink(0, 'resources', $acc_id, '', '', '', true); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | return false; |
@@ -472,9 +472,9 @@ discard block |
||
472 | 472 | elseif ($this->so->delete(array('res_id'=>$res_id))) |
473 | 473 | { |
474 | 474 | $accessories = $this->get_acc_list($res_id, true); |
475 | - foreach($accessories as $acc_id => $name) |
|
475 | + foreach ($accessories as $acc_id => $name) |
|
476 | 476 | { |
477 | - if($this->delete($acc_id)) |
|
477 | + if ($this->delete($acc_id)) |
|
478 | 478 | { |
479 | 479 | $acc = $this->read($acc_id); |
480 | 480 | $acc['accessory_of'] = -1; |
@@ -482,9 +482,9 @@ discard block |
||
482 | 482 | } |
483 | 483 | }; |
484 | 484 | $this->remove_picture($res_id); |
485 | - Link::unlink(0,'resources',$res_id); |
|
485 | + Link::unlink(0, 'resources', $res_id); |
|
486 | 486 | // delete the resource from the calendar |
487 | - ExecMethod('calendar.calendar_so.deleteaccount','r'.$res_id); |
|
487 | + ExecMethod('calendar.calendar_so.deleteaccount', 'r'.$res_id); |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | return lang('Something went wrong by deleting resource'); |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | * @param boolean $deleted Include deleted accessories |
499 | 499 | * @return array |
500 | 500 | */ |
501 | - function get_acc_list($res_id,$deleted=false) |
|
501 | + function get_acc_list($res_id, $deleted = false) |
|
502 | 502 | { |
503 | - if($res_id < 1){return;} |
|
504 | - $data = $this->so->search('','res_id,name,deleted','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true); |
|
503 | + if ($res_id < 1) {return; } |
|
504 | + $data = $this->so->search('', 'res_id,name,deleted', '', '', '', '', '', $start, array('accessory_of' => $res_id), '', $need_full_no_count = true); |
|
505 | 505 | $acc_list = array(); |
506 | - if($data) { |
|
507 | - foreach($data as $num => $resource) |
|
506 | + if ($data) { |
|
507 | + foreach ($data as $num => $resource) |
|
508 | 508 | { |
509 | - if($resource['deleted'] && !$deleted) continue; |
|
509 | + if ($resource['deleted'] && !$deleted) continue; |
|
510 | 510 | $acc_list[$resource['res_id']] = $resource['name']; |
511 | 511 | } |
512 | 512 | } |
@@ -522,20 +522,20 @@ discard block |
||
522 | 522 | function get_calendar_info($res_id) |
523 | 523 | { |
524 | 524 | //echo "<p>resources_bo::get_calendar_info(".print_r($res_id,true).")</p>\n"; |
525 | - if(!is_array($res_id) && $res_id < 1) return; |
|
525 | + if (!is_array($res_id) && $res_id < 1) return; |
|
526 | 526 | |
527 | - $data = $this->so->search(array('res_id' => $res_id),self::TITLE_COLS.',useable'); |
|
527 | + $data = $this->so->search(array('res_id' => $res_id), self::TITLE_COLS.',useable'); |
|
528 | 528 | if (!is_array($data)) |
529 | 529 | { |
530 | 530 | error_log(__METHOD__." No Calendar Data found for Resource with id $res_id"); |
531 | 531 | return array(); |
532 | 532 | } |
533 | - foreach($data as $num => &$resource) |
|
533 | + foreach ($data as $num => &$resource) |
|
534 | 534 | { |
535 | 535 | $resource['rights'] = false; |
536 | - foreach($this->cal_right_transform as $res_right => $cal_right) |
|
536 | + foreach ($this->cal_right_transform as $res_right => $cal_right) |
|
537 | 537 | { |
538 | - if($this->acl->is_permitted($resource['cat_id'],$res_right)) |
|
538 | + if ($this->acl->is_permitted($resource['cat_id'], $res_right)) |
|
539 | 539 | { |
540 | 540 | $resource['rights'] = $cal_right; |
541 | 541 | } |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $resource['responsible'] = $this->acl->get_cat_admin($resource['cat_id']); |
544 | 544 | |
545 | 545 | // preseed the cache |
546 | - Link::set_cache('resources',$resource['res_id'],$t=$this->link_title($resource)); |
|
546 | + Link::set_cache('resources', $resource['res_id'], $t = $this->link_title($resource)); |
|
547 | 547 | } |
548 | 548 | return $data; |
549 | 549 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | { |
561 | 561 | return false; |
562 | 562 | } |
563 | - return $this->acl->is_permitted($data['cat_id'],resources_acl_bo::DIRECT_BOOKING) ? A : U; |
|
563 | + return $this->acl->is_permitted($data['cat_id'], resources_acl_bo::DIRECT_BOOKING) ? A : U; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | * @param array $options Array of options for the search |
573 | 573 | * |
574 | 574 | */ |
575 | - function link_query( $pattern, Array &$options = array() ) |
|
575 | + function link_query($pattern, Array &$options = array()) |
|
576 | 576 | { |
577 | 577 | if (is_array($pattern)) |
578 | 578 | { |
579 | - $criteria =array('name' => $pattern['search'] |
|
579 | + $criteria = array('name' => $pattern['search'] |
|
580 | 580 | ,'short_description' => $pattern['search']); |
581 | 581 | } |
582 | 582 | else |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $only_keys = 'res_id,name,short_description,bookable,useable'; |
588 | 588 | |
589 | 589 | // If no read access to any category, just stop |
590 | - if(!$this->acl->get_cats(Acl::READ)) |
|
590 | + if (!$this->acl->get_cats(Acl::READ)) |
|
591 | 591 | { |
592 | 592 | $options['total'] = 0; |
593 | 593 | return array(); |
@@ -598,30 +598,30 @@ discard block |
||
598 | 598 | 'deleted' => null |
599 | 599 | ); |
600 | 600 | $limit = false; |
601 | - if($options['start'] || $options['num_rows']) { |
|
601 | + if ($options['start'] || $options['num_rows']) { |
|
602 | 602 | $limit = array($options['start'], $options['num_rows']); |
603 | 603 | } |
604 | - if($options['accessory_of']) |
|
604 | + if ($options['accessory_of']) |
|
605 | 605 | { |
606 | 606 | $filter['accessory_of'] = $options['accessory_of']; |
607 | 607 | } |
608 | - $data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter); |
|
608 | + $data = $this->so->search($criteria, $only_keys, $order_by = 'name', $extra_cols = '', $wildcard = '%', $empty, $op = 'OR', $limit, $filter); |
|
609 | 609 | // maybe we need to check disponibility of the searched resources in the calendar if $pattern ['exec'] contains some extra args |
610 | - $show_conflict=False; |
|
610 | + $show_conflict = False; |
|
611 | 611 | if ($options['exec'] && $GLOBALS['egw_info']['preferences']['calendar']['defaultresource_sel'] !== 'resources') |
612 | 612 | { |
613 | 613 | // we'll use a cache for resources info taken from database |
614 | 614 | static $res_info_cache = array(); |
615 | - $cal_info=$options['exec']; |
|
616 | - if ( isset($cal_info['start']) && isset($cal_info['duration'])) |
|
615 | + $cal_info = $options['exec']; |
|
616 | + if (isset($cal_info['start']) && isset($cal_info['duration'])) |
|
617 | 617 | { |
618 | 618 | //get a calendar objet for reservations |
619 | - if ( (!isset($this->bocal)) || !(is_object($this->bocal))) |
|
619 | + if ((!isset($this->bocal)) || !(is_object($this->bocal))) |
|
620 | 620 | { |
621 | 621 | $this->bocal = new calendar_bo(); |
622 | 622 | } |
623 | 623 | $start = new Api\DateTime($cal_info['start']); |
624 | - $startarr= getdate($start->format('ts')); |
|
624 | + $startarr = getdate($start->format('ts')); |
|
625 | 625 | if (isset($cal_info['whole_day']) && $cal_info['whole_day']) { |
626 | 626 | $startarr['hour'] = $startarr['minute'] = 0; |
627 | 627 | $start = new Api\DateTime($startarr); |
@@ -632,39 +632,39 @@ discard block |
||
632 | 632 | } |
633 | 633 | |
634 | 634 | // search events matching our timestamps |
635 | - $resource_list=array(); |
|
636 | - foreach($data as $num => $resource) |
|
635 | + $resource_list = array(); |
|
636 | + foreach ($data as $num => $resource) |
|
637 | 637 | { |
638 | 638 | // we only need resources id for the search, but with a 'r' prefix |
639 | 639 | // now we take this loop to store a new resource array indexed with resource id |
640 | 640 | // and as we work for calendar we use only bookable resources |
641 | - if ((isset($resource['bookable'])) && ($resource['bookable'])){ |
|
642 | - $res_info_cache[$resource['res_id']]=$resource; |
|
643 | - $resource_list[]='r'.$resource['res_id']; |
|
641 | + if ((isset($resource['bookable'])) && ($resource['bookable'])) { |
|
642 | + $res_info_cache[$resource['res_id']] = $resource; |
|
643 | + $resource_list[] = 'r'.$resource['res_id']; |
|
644 | 644 | } |
645 | 645 | } |
646 | - $overlapping_events =& $this->bocal->search(array( |
|
646 | + $overlapping_events = & $this->bocal->search(array( |
|
647 | 647 | 'start' => $start, |
648 | 648 | 'end' => $end, |
649 | 649 | 'users' => $resource_list, |
650 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
651 | - 'enum_groups' => false, // otherwise group-events would not block time |
|
650 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
651 | + 'enum_groups' => false, // otherwise group-events would not block time |
|
652 | 652 | )); |
653 | 653 | |
654 | 654 | // parse theses overlapping events |
655 | - foreach($overlapping_events as $event) |
|
655 | + foreach ($overlapping_events as $event) |
|
656 | 656 | { |
657 | 657 | if ($event['non_blocking']) continue; // ignore non_blocking events |
658 | - if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) { |
|
658 | + if (isset($cal_info['event_id']) && $event['id'] == $cal_info['event_id']) { |
|
659 | 659 | continue; //ignore this event, it's the current edited event, no conflict by def |
660 | 660 | } |
661 | 661 | // now we are interested only on resources booked by theses events |
662 | - if (isset($event['participants']) && is_array($event['participants'])){ |
|
663 | - foreach($event['participants'] as $part_key => $part_detail){ |
|
664 | - if ($part_key{0}=='r') |
|
662 | + if (isset($event['participants']) && is_array($event['participants'])) { |
|
663 | + foreach ($event['participants'] as $part_key => $part_detail) { |
|
664 | + if ($part_key{0} == 'r') |
|
665 | 665 | { //now we gatta resource here |
666 | 666 | //need to check the quantity of this resource |
667 | - $resource_id=substr($part_key,1); |
|
667 | + $resource_id = substr($part_key, 1); |
|
668 | 668 | // if we do not find this resource in our indexed array it's certainly |
669 | 669 | // because it was unset, non bookable maybe |
670 | 670 | if (!isset($res_info_cache[$resource_id])) continue; |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | } |
675 | 675 | // now decrement this quantity useable |
676 | 676 | $quantity = 1; |
677 | - $this->bocal->so->split_status($part_detail,$quantity); |
|
677 | + $this->bocal->so->split_status($part_detail, $quantity); |
|
678 | 678 | |
679 | - $res_info_cache[$resource_id]['useable']-=$quantity; |
|
679 | + $res_info_cache[$resource_id]['useable'] -= $quantity; |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | } |
@@ -684,27 +684,27 @@ discard block |
||
684 | 684 | } |
685 | 685 | } |
686 | 686 | if (isset($res_info_cache)) { |
687 | - $show_conflict= $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] === 'resources_conflict'; |
|
687 | + $show_conflict = $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] === 'resources_conflict'; |
|
688 | 688 | // if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar |
689 | 689 | // so we'll loop on this one and not $data |
690 | - foreach($res_info_cache as $id => $resource) { |
|
690 | + foreach ($res_info_cache as $id => $resource) { |
|
691 | 691 | //maybe this resource is reserved |
692 | - if ( ($resource['useable'] < 1) ) |
|
692 | + if (($resource['useable'] < 1)) |
|
693 | 693 | { |
694 | - if($show_conflict) { |
|
695 | - $list[$id] = ' ('.lang('conflict').') '.$resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
694 | + if ($show_conflict) { |
|
695 | + $list[$id] = ' ('.lang('conflict').') '.$resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
696 | 696 | } |
697 | 697 | } else { |
698 | - $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
698 | + $list[$id] = $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
699 | 699 | } |
700 | 700 | } |
701 | 701 | } else { |
702 | 702 | // we are not working for the calendar, we loop on the initial $data |
703 | 703 | if (is_array($data)) { |
704 | - foreach($data as $num => $resource) |
|
704 | + foreach ($data as $num => $resource) |
|
705 | 705 | { |
706 | - $id=$resource['res_id']; |
|
707 | - $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
706 | + $id = $resource['res_id']; |
|
707 | + $list[$id] = $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
708 | 708 | } |
709 | 709 | } else { |
710 | 710 | error_log(__METHOD__." No Data found for Resource with id ".$resource['res_id']); |
@@ -721,17 +721,17 @@ discard block |
||
721 | 721 | * @param int|array $resource |
722 | 722 | * @return string|boolean string with title, null if resource does not exist or false if no perms to view it |
723 | 723 | */ |
724 | - function link_title( $resource ) |
|
724 | + function link_title($resource) |
|
725 | 725 | { |
726 | 726 | if (!is_array($resource)) |
727 | 727 | { |
728 | - if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
728 | + if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
729 | 729 | } |
730 | - elseif (!$this->acl->is_permitted($resource['cat_id'],Acl::READ)) |
|
730 | + elseif (!$this->acl->is_permitted($resource['cat_id'], Acl::READ)) |
|
731 | 731 | { |
732 | 732 | return false; |
733 | 733 | } |
734 | - return $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
|
734 | + return $resource['name'].($resource['short_description'] ? ', ['.$resource['short_description'].']' : ''); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -751,15 +751,15 @@ discard block |
||
751 | 751 | function link_titles(array $ids) |
752 | 752 | { |
753 | 753 | $titles = array(); |
754 | - if (($resources =& $this->so->search(array('res_id' => $ids),self::TITLE_COLS))) |
|
754 | + if (($resources = & $this->so->search(array('res_id' => $ids), self::TITLE_COLS))) |
|
755 | 755 | { |
756 | - foreach($resources as $resource) |
|
756 | + foreach ($resources as $resource) |
|
757 | 757 | { |
758 | 758 | $titles[$resource['res_id']] = $this->link_title($resource); |
759 | 759 | } |
760 | 760 | } |
761 | 761 | // we assume all not returned contacts are not readable for the user (as we report all deleted contacts to Link) |
762 | - foreach($ids as $id) |
|
762 | + foreach ($ids as $id) |
|
763 | 763 | { |
764 | 764 | if (!isset($titles[$id])) |
765 | 765 | { |
@@ -777,9 +777,9 @@ discard block |
||
777 | 777 | * @param int $resource_id |
778 | 778 | * @return mixed string with msg if somthing went wrong; nothing if all right |
779 | 779 | */ |
780 | - function save_picture($file,$resouce_id) |
|
780 | + function save_picture($file, $resouce_id) |
|
781 | 781 | { |
782 | - switch($file['type']) |
|
782 | + switch ($file['type']) |
|
783 | 783 | { |
784 | 784 | case 'image/gif': |
785 | 785 | $src_img = imagecreatefromgif($file['tmp_name']); |
@@ -796,11 +796,11 @@ discard block |
||
796 | 796 | return lang('Picture type is not supported, sorry!'); |
797 | 797 | } |
798 | 798 | |
799 | - $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'resources-picture'); |
|
800 | - imagejpeg($src_img,$tmp_name); |
|
799 | + $tmp_name = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'resources-picture'); |
|
800 | + imagejpeg($src_img, $tmp_name); |
|
801 | 801 | imagedestroy($src_img); |
802 | 802 | |
803 | - Link::attach_file('resources',$resouce_id,array( |
|
803 | + Link::attach_file('resources', $resouce_id, array( |
|
804 | 804 | 'tmp_name' => $tmp_name, |
805 | 805 | 'name' => self::PICTURE_NAME, |
806 | 806 | 'type' => 'image/jpeg', |
@@ -814,14 +814,14 @@ discard block |
||
814 | 814 | * @param bool $fullsize false = thumb, true = full pic |
815 | 815 | * @return string url of picture |
816 | 816 | */ |
817 | - function get_picture($resource,$fullsize=false) |
|
817 | + function get_picture($resource, $fullsize = false) |
|
818 | 818 | { |
819 | 819 | if ($resource && !is_array($resource)) $resource = $this->read($resource); |
820 | 820 | |
821 | - switch($resource['picture_src']) |
|
821 | + switch ($resource['picture_src']) |
|
822 | 822 | { |
823 | 823 | case 'own_src': |
824 | - $picture = Link::vfs_path('resources',$resource['res_id'],self::PICTURE_NAME,true); // vfs path |
|
824 | + $picture = Link::vfs_path('resources', $resource['res_id'], self::PICTURE_NAME, true); // vfs path |
|
825 | 825 | if ($fullsize) |
826 | 826 | { |
827 | 827 | $picture = Egw::link(Vfs::download_url($picture)); |
@@ -830,23 +830,23 @@ discard block |
||
830 | 830 | { |
831 | 831 | $picture = Egw::link('/api/thumbnail.php', array( |
832 | 832 | 'path' => $picture |
833 | - ),false); |
|
833 | + ), false); |
|
834 | 834 | } |
835 | 835 | break; |
836 | 836 | |
837 | 837 | case 'cat_src': |
838 | 838 | $picture = Api\Categories::id2name($resource['cat_id'], 'data'); |
839 | - if($picture['icon']) |
|
839 | + if ($picture['icon']) |
|
840 | 840 | { |
841 | - $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$picture['icon']:self::ICON_PATH.'/'.$picture['icon']; |
|
841 | + $picture = !$fullsize ? $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$picture['icon'] : self::ICON_PATH.'/'.$picture['icon']; |
|
842 | 842 | break; |
843 | 843 | } |
844 | 844 | // fall through |
845 | 845 | case 'gen_src': |
846 | 846 | default : |
847 | 847 | $src = $resource['picture_src']; |
848 | - $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons:$this->resource_icons; |
|
849 | - $picture .= strpos($src,'.') !== false ? $src : 'generic.png'; |
|
848 | + $picture = !$fullsize ? $GLOBALS['egw_info']['server']['webserver_url'].$this->resource_icons : $this->resource_icons; |
|
849 | + $picture .= strpos($src, '.') !== false ? $src : 'generic.png'; |
|
850 | 850 | } |
851 | 851 | return $picture; |
852 | 852 | } |
@@ -860,9 +860,9 @@ discard block |
||
860 | 860 | */ |
861 | 861 | function remove_picture($res_id) |
862 | 862 | { |
863 | - if (($arr = Link::delete_attached('resources',$res_id,self::PICTURE_NAME)) && is_array($arr)) |
|
863 | + if (($arr = Link::delete_attached('resources', $res_id, self::PICTURE_NAME)) && is_array($arr)) |
|
864 | 864 | { |
865 | - return array_shift($arr); // $arr = array($path => (bool)$ok); |
|
865 | + return array_shift($arr); // $arr = array($path => (bool)$ok); |
|
866 | 866 | } |
867 | 867 | return false; |
868 | 868 | } |
@@ -878,11 +878,11 @@ discard block |
||
878 | 878 | { |
879 | 879 | $icons['generic.png'] = lang('gernal resource'); |
880 | 880 | $dir = dir(EGW_SERVER_ROOT.$this->resource_icons); |
881 | - while($file = $dir->read()) |
|
881 | + while ($file = $dir->read()) |
|
882 | 882 | { |
883 | - if (preg_match('/\\.(png|gif|jpe?g)$/i',$file) && $file != 'generic.png') |
|
883 | + if (preg_match('/\\.(png|gif|jpe?g)$/i', $file) && $file != 'generic.png') |
|
884 | 884 | { |
885 | - $icons[$file] = substr($file,0,strpos($file,'.')); |
|
885 | + $icons[$file] = substr($file, 0, strpos($file, '.')); |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | $dir->close(); |
@@ -105,9 +105,12 @@ discard block |
||
105 | 105 | { |
106 | 106 | Api\Cache::setSession('resources', 'index_nm', $query); |
107 | 107 | } |
108 | - if ($query['store_state']) // request to store state in session and filter in prefs? |
|
108 | + if ($query['store_state']) |
|
109 | + { |
|
110 | + // request to store state in session and filter in prefs? |
|
109 | 111 | { |
110 | 112 | Api\Cache::setSession('resources',$query['store_state'],$query); |
113 | + } |
|
111 | 114 | //echo "<p>".__METHOD__."() query[filter]=$query[filter], prefs[resources][filter]={$GLOBALS['egw_info']['user']['preferences']['resources']['filter']}</p>\n"; |
112 | 115 | if ($query['filter'] != $GLOBALS['egw_info']['user']['preferences']['resources']['filter']) |
113 | 116 | { |
@@ -115,7 +118,10 @@ discard block |
||
115 | 118 | $GLOBALS['egw']->preferences->save_repository(); |
116 | 119 | } |
117 | 120 | } |
118 | - if ($this->debug) _debug_array($query); |
|
121 | + if ($this->debug) |
|
122 | + { |
|
123 | + _debug_array($query); |
|
124 | + } |
|
119 | 125 | $read_onlys = 'res_id,name,short_description,quantity,useable,bookable,buyable,cat_id,location,storage_info'; |
120 | 126 | |
121 | 127 | $filter = array(); |
@@ -172,7 +178,8 @@ discard block |
||
172 | 178 | $filter['cat_id'] = array_keys($readcats); |
173 | 179 | } |
174 | 180 | // if there is no catfilter -> this means you have no rights, so set the cat filter to null |
175 | - if (!isset($filter['cat_id']) || empty($filter['cat_id'])) { |
|
181 | + if (!isset($filter['cat_id']) || empty($filter['cat_id'])) |
|
182 | + { |
|
176 | 183 | $filter['cat_id'] = NUll; |
177 | 184 | } |
178 | 185 | |
@@ -183,7 +190,10 @@ discard block |
||
183 | 190 | $order_by = $query['order'] ? $query['order'].' '. $query['sort'] : ''; |
184 | 191 | $start = (int)$query['start']; |
185 | 192 | |
186 | - foreach ($filter as $k => $v) $query['col_filter'][$k] = $v; |
|
193 | + foreach ($filter as $k => $v) |
|
194 | + { |
|
195 | + $query['col_filter'][$k] = $v; |
|
196 | + } |
|
187 | 197 | $this->so->get_rows($query, $rows, $readonlys, $join, false, false, $extra_cols); |
188 | 198 | $nr = $this->so->total; |
189 | 199 | |
@@ -212,8 +222,7 @@ discard block |
||
212 | 222 | } |
213 | 223 | if (!$this->acl->is_permitted($resource['cat_id'],Acl::DELETE) || |
214 | 224 | ($resource['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history') |
215 | - ) |
|
216 | - { |
|
225 | + ) { |
|
217 | 226 | $readonlys["delete[$resource[res_id]]"] = true; |
218 | 227 | $resource['class'] .= 'no_delete '; |
219 | 228 | } |
@@ -251,7 +260,9 @@ discard block |
||
251 | 260 | { |
252 | 261 | $resource['accessories'][] = array('acc_id' => $acc_id, 'name' => $this->link_title($acc_id)); |
253 | 262 | } |
254 | - } elseif ($resource['accessory_of'] > 0) { |
|
263 | + } |
|
264 | + elseif ($resource['accessory_of'] > 0) |
|
265 | + { |
|
255 | 266 | $resource['accessory_of_label'] = $this->link_title($resource['accessory_of']); |
256 | 267 | } |
257 | 268 | |
@@ -500,13 +511,19 @@ discard block |
||
500 | 511 | */ |
501 | 512 | function get_acc_list($res_id,$deleted=false) |
502 | 513 | { |
503 | - if($res_id < 1){return;} |
|
514 | + if($res_id < 1) |
|
515 | + { |
|
516 | +return;} |
|
504 | 517 | $data = $this->so->search('','res_id,name,deleted','','','','','',$start,array('accessory_of' => $res_id),'',$need_full_no_count=true); |
505 | 518 | $acc_list = array(); |
506 | - if($data) { |
|
519 | + if($data) |
|
520 | + { |
|
507 | 521 | foreach($data as $num => $resource) |
508 | 522 | { |
509 | - if($resource['deleted'] && !$deleted) continue; |
|
523 | + if($resource['deleted'] && !$deleted) |
|
524 | + { |
|
525 | + continue; |
|
526 | + } |
|
510 | 527 | $acc_list[$resource['res_id']] = $resource['name']; |
511 | 528 | } |
512 | 529 | } |
@@ -522,7 +539,10 @@ discard block |
||
522 | 539 | function get_calendar_info($res_id) |
523 | 540 | { |
524 | 541 | //echo "<p>resources_bo::get_calendar_info(".print_r($res_id,true).")</p>\n"; |
525 | - if(!is_array($res_id) && $res_id < 1) return; |
|
542 | + if(!is_array($res_id) && $res_id < 1) |
|
543 | + { |
|
544 | + return; |
|
545 | + } |
|
526 | 546 | |
527 | 547 | $data = $this->so->search(array('res_id' => $res_id),self::TITLE_COLS.',useable'); |
528 | 548 | if (!is_array($data)) |
@@ -598,7 +618,8 @@ discard block |
||
598 | 618 | 'deleted' => null |
599 | 619 | ); |
600 | 620 | $limit = false; |
601 | - if($options['start'] || $options['num_rows']) { |
|
621 | + if($options['start'] || $options['num_rows']) |
|
622 | + { |
|
602 | 623 | $limit = array($options['start'], $options['num_rows']); |
603 | 624 | } |
604 | 625 | if($options['accessory_of']) |
@@ -622,11 +643,14 @@ discard block |
||
622 | 643 | } |
623 | 644 | $start = new Api\DateTime($cal_info['start']); |
624 | 645 | $startarr= getdate($start->format('ts')); |
625 | - if (isset($cal_info['whole_day']) && $cal_info['whole_day']) { |
|
646 | + if (isset($cal_info['whole_day']) && $cal_info['whole_day']) |
|
647 | + { |
|
626 | 648 | $startarr['hour'] = $startarr['minute'] = 0; |
627 | 649 | $start = new Api\DateTime($startarr); |
628 | 650 | $end = $start->format('ts') + 86399; |
629 | - } else { |
|
651 | + } |
|
652 | + else |
|
653 | + { |
|
630 | 654 | $start = $start->format('ts'); |
631 | 655 | $end = $start + ($cal_info['duration']); |
632 | 656 | } |
@@ -638,7 +662,8 @@ discard block |
||
638 | 662 | // we only need resources id for the search, but with a 'r' prefix |
639 | 663 | // now we take this loop to store a new resource array indexed with resource id |
640 | 664 | // and as we work for calendar we use only bookable resources |
641 | - if ((isset($resource['bookable'])) && ($resource['bookable'])){ |
|
665 | + if ((isset($resource['bookable'])) && ($resource['bookable'])) |
|
666 | + { |
|
642 | 667 | $res_info_cache[$resource['res_id']]=$resource; |
643 | 668 | $resource_list[]='r'.$resource['res_id']; |
644 | 669 | } |
@@ -654,22 +679,34 @@ discard block |
||
654 | 679 | // parse theses overlapping events |
655 | 680 | foreach($overlapping_events as $event) |
656 | 681 | { |
657 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
658 | - if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) { |
|
682 | + if ($event['non_blocking']) |
|
683 | + { |
|
684 | + continue; |
|
685 | + } |
|
686 | + // ignore non_blocking events |
|
687 | + if (isset($cal_info['event_id']) && $event['id']==$cal_info['event_id']) |
|
688 | + { |
|
659 | 689 | continue; //ignore this event, it's the current edited event, no conflict by def |
660 | 690 | } |
661 | 691 | // now we are interested only on resources booked by theses events |
662 | - if (isset($event['participants']) && is_array($event['participants'])){ |
|
663 | - foreach($event['participants'] as $part_key => $part_detail){ |
|
692 | + if (isset($event['participants']) && is_array($event['participants'])) |
|
693 | + { |
|
694 | + foreach($event['participants'] as $part_key => $part_detail) |
|
695 | + { |
|
664 | 696 | if ($part_key{0}=='r') |
665 | - { //now we gatta resource here |
|
697 | + { |
|
698 | +//now we gatta resource here |
|
666 | 699 | //need to check the quantity of this resource |
667 | 700 | $resource_id=substr($part_key,1); |
668 | 701 | // if we do not find this resource in our indexed array it's certainly |
669 | 702 | // because it was unset, non bookable maybe |
670 | - if (!isset($res_info_cache[$resource_id])) continue; |
|
703 | + if (!isset($res_info_cache[$resource_id])) |
|
704 | + { |
|
705 | + continue; |
|
706 | + } |
|
671 | 707 | // to detect ressources with default to 1 quantity |
672 | - if (!isset($res_info_cache[$resource_id]['useable'])) { |
|
708 | + if (!isset($res_info_cache[$resource_id]['useable'])) |
|
709 | + { |
|
673 | 710 | $res_info_cache[$resource_id]['useable'] = 1; |
674 | 711 | } |
675 | 712 | // now decrement this quantity useable |
@@ -683,30 +720,40 @@ discard block |
||
683 | 720 | } |
684 | 721 | } |
685 | 722 | } |
686 | - if (isset($res_info_cache)) { |
|
723 | + if (isset($res_info_cache)) |
|
724 | + { |
|
687 | 725 | $show_conflict= $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultresource_sel'] === 'resources_conflict'; |
688 | 726 | // if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar |
689 | 727 | // so we'll loop on this one and not $data |
690 | - foreach($res_info_cache as $id => $resource) { |
|
728 | + foreach($res_info_cache as $id => $resource) |
|
729 | + { |
|
691 | 730 | //maybe this resource is reserved |
692 | 731 | if ( ($resource['useable'] < 1) ) |
693 | 732 | { |
694 | - if($show_conflict) { |
|
733 | + if($show_conflict) |
|
734 | + { |
|
695 | 735 | $list[$id] = ' ('.lang('conflict').') '.$resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
696 | 736 | } |
697 | - } else { |
|
737 | + } |
|
738 | + else |
|
739 | + { |
|
698 | 740 | $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
699 | 741 | } |
700 | 742 | } |
701 | - } else { |
|
743 | + } |
|
744 | + else |
|
745 | + { |
|
702 | 746 | // we are not working for the calendar, we loop on the initial $data |
703 | - if (is_array($data)) { |
|
747 | + if (is_array($data)) |
|
748 | + { |
|
704 | 749 | foreach($data as $num => $resource) |
705 | 750 | { |
706 | 751 | $id=$resource['res_id']; |
707 | 752 | $list[$id] = $resource['name']. ($resource['short_description'] ? ', ['.$resource['short_description'].']':''); |
708 | 753 | } |
709 | - } else { |
|
754 | + } |
|
755 | + else |
|
756 | + { |
|
710 | 757 | error_log(__METHOD__." No Data found for Resource with id ".$resource['res_id']); |
711 | 758 | } |
712 | 759 | } |
@@ -725,7 +772,10 @@ discard block |
||
725 | 772 | { |
726 | 773 | if (!is_array($resource)) |
727 | 774 | { |
728 | - if (!($resource = $this->read(array('res_id' => $resource)))) return $resource; |
|
775 | + if (!($resource = $this->read(array('res_id' => $resource)))) |
|
776 | + { |
|
777 | + return $resource; |
|
778 | + } |
|
729 | 779 | } |
730 | 780 | elseif (!$this->acl->is_permitted($resource['cat_id'],Acl::READ)) |
731 | 781 | { |
@@ -816,7 +866,10 @@ discard block |
||
816 | 866 | */ |
817 | 867 | function get_picture($resource,$fullsize=false) |
818 | 868 | { |
819 | - if ($resource && !is_array($resource)) $resource = $this->read($resource); |
|
869 | + if ($resource && !is_array($resource)) |
|
870 | + { |
|
871 | + $resource = $this->read($resource); |
|
872 | + } |
|
820 | 873 | |
821 | 874 | switch($resource['picture_src']) |
822 | 875 | { |
@@ -572,7 +572,7 @@ |
||
572 | 572 | * @param array $options Array of options for the search |
573 | 573 | * |
574 | 574 | */ |
575 | - function link_query( $pattern, Array &$options = array() ) |
|
575 | + function link_query( $pattern, array &$options = array() ) |
|
576 | 576 | { |
577 | 577 | if (is_array($pattern)) |
578 | 578 | { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | /** |
30 | 30 | * Exports records as defined in $_definition |
31 | 31 | * |
32 | - * @param egw_record $_definition |
|
32 | + * @param importexport_definition $_definition |
|
33 | 33 | */ |
34 | 34 | public function export( $_stream, importexport_definition $_definition) { |
35 | 35 | $options = $_definition->plugin_options; |
@@ -170,9 +170,9 @@ |
||
170 | 170 | * Get selectbox values |
171 | 171 | */ |
172 | 172 | protected function get_selects() |
173 | - { |
|
173 | + { |
|
174 | 174 | $this->selects = array(); |
175 | - } |
|
175 | + } |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Customize automatically generated filter fields |
@@ -31,54 +31,54 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param egw_record $_definition |
33 | 33 | */ |
34 | - public function export( $_stream, importexport_definition $_definition) { |
|
34 | + public function export($_stream, importexport_definition $_definition) { |
|
35 | 35 | $options = $_definition->plugin_options; |
36 | 36 | |
37 | 37 | $selection = array(); |
38 | 38 | if ($options['selection'] == 'search') { |
39 | 39 | // ui selection with checkbox 'selected' |
40 | 40 | $query = Api\Cache::getSession('resources', 'get_rows'); |
41 | - $query['num_rows'] = -1; // all |
|
41 | + $query['num_rows'] = -1; // all |
|
42 | 42 | unset($query['store_state']); |
43 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
44 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
43 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
44 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
45 | 45 | } |
46 | - elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
46 | + elseif ($options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
47 | 47 | $query = array( |
48 | 48 | 'num_rows' => -1, |
49 | - 'filter2' => -3, // Accessories & resources |
|
50 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
51 | - ); // all |
|
49 | + 'filter2' => -3, // Accessories & resources |
|
50 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
51 | + ); // all |
|
52 | 52 | |
53 | - if($options['selection'] == 'filter') |
|
53 | + if ($options['selection'] == 'filter') |
|
54 | 54 | { |
55 | 55 | $filter = $_definition->filter; |
56 | 56 | // Handle ranges |
57 | - foreach($filter as $field => $value) |
|
57 | + foreach ($filter as $field => $value) |
|
58 | 58 | { |
59 | - if($field == 'cat_id') |
|
59 | + if ($field == 'cat_id') |
|
60 | 60 | { |
61 | 61 | $query['filter'] = $value; |
62 | 62 | continue; |
63 | 63 | } |
64 | - if($field == 'filter2') |
|
64 | + if ($field == 'filter2') |
|
65 | 65 | { |
66 | 66 | $query['filter2'] = $value; |
67 | 67 | continue; |
68 | 68 | } |
69 | 69 | $query['col_filter'][$field] = $value; |
70 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
70 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
71 | 71 | |
72 | 72 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
73 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
74 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
73 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
74 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
75 | 75 | unset($query['col_filter'][$field]); |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
79 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
80 | 80 | } else { |
81 | - $selection = explode(',',$options['selection']); |
|
81 | + $selection = explode(',', $options['selection']); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -86,28 +86,28 @@ discard block |
||
86 | 86 | |
87 | 87 | // Check if we need to load the custom fields |
88 | 88 | $need_custom = false; |
89 | - foreach(Api\Storage\Customfields::get('resources') as $field => $settings) { |
|
90 | - if($options['mapping']['#'.$field]) { |
|
89 | + foreach (Api\Storage\Customfields::get('resources') as $field => $settings) { |
|
90 | + if ($options['mapping']['#'.$field]) { |
|
91 | 91 | $need_custom = true; |
92 | 92 | break; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | foreach ($selection as $record) { |
97 | - if(!is_array($record) || !$record['res_id']) continue; |
|
97 | + if (!is_array($record) || !$record['res_id']) continue; |
|
98 | 98 | |
99 | - if($need_custom) { |
|
99 | + if ($need_custom) { |
|
100 | 100 | $record = $this->bo->read($record['res_id']); |
101 | 101 | } |
102 | 102 | $resource = new resources_egw_record(); |
103 | 103 | $resource->set_record($record); |
104 | 104 | $resource->long_description = strip_tags($resource->long_description); |
105 | - if($options['convert']) { |
|
105 | + if ($options['convert']) { |
|
106 | 106 | importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects); |
107 | 107 | } else { |
108 | 108 | // Implode arrays, so they don't say 'Array' |
109 | - foreach($resource->get_record_array() as $key => $value) { |
|
110 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
109 | + foreach ($resource->get_record_array() as $key => $value) { |
|
110 | + if (is_array($value)) $resource->$key = implode(',', $value); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | // In resources, not all categories are used |
183 | 183 | $filters['cat_id']['type'] = 'select'; |
184 | 184 | $filters['cat_id']['name'] = 'filter'; |
185 | - $filters['cat_id']['values']= (array)$this->bo->acl->get_cats(Acl::READ); |
|
185 | + $filters['cat_id']['values'] = (array)$this->bo->acl->get_cats(Acl::READ); |
|
186 | 186 | |
187 | 187 | // Add in resources / accessories |
188 | 188 | $filters['filter2'] = array( |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | 'rows' => 5, |
193 | 193 | 'values' => resources_bo::$filter_options |
194 | 194 | ); |
195 | - foreach($filters as $field_name => &$settings) |
|
195 | + foreach ($filters as $field_name => &$settings) |
|
196 | 196 | { |
197 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
197 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * export resources to CSV |
19 | 19 | */ |
20 | -class resources_export_csv implements importexport_iface_export_plugin { |
|
20 | +class resources_export_csv implements importexport_iface_export_plugin |
|
21 | +{ |
|
21 | 22 | |
22 | 23 | public function __construct() |
23 | 24 | { |
@@ -31,11 +32,13 @@ discard block |
||
31 | 32 | * |
32 | 33 | * @param egw_record $_definition |
33 | 34 | */ |
34 | - public function export( $_stream, importexport_definition $_definition) { |
|
35 | + public function export( $_stream, importexport_definition $_definition) |
|
36 | + { |
|
35 | 37 | $options = $_definition->plugin_options; |
36 | 38 | |
37 | 39 | $selection = array(); |
38 | - if ($options['selection'] == 'search') { |
|
40 | + if ($options['selection'] == 'search') |
|
41 | + { |
|
39 | 42 | // ui selection with checkbox 'selected' |
40 | 43 | $query = Api\Cache::getSession('resources', 'get_rows'); |
41 | 44 | $query['num_rows'] = -1; // all |
@@ -43,7 +46,8 @@ discard block |
||
43 | 46 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
44 | 47 | $this->bo->get_rows($query,$selection,$readonlys); |
45 | 48 | } |
46 | - elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
49 | + elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') |
|
50 | + { |
|
47 | 51 | $query = array( |
48 | 52 | 'num_rows' => -1, |
49 | 53 | 'filter2' => -3, // Accessories & resources |
@@ -67,17 +71,28 @@ discard block |
||
67 | 71 | continue; |
68 | 72 | } |
69 | 73 | $query['col_filter'][$field] = $value; |
70 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
74 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
75 | + { |
|
76 | + continue; |
|
77 | + } |
|
71 | 78 | |
72 | 79 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
73 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
74 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
80 | + if($value['from']) |
|
81 | + { |
|
82 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
83 | + } |
|
84 | + if($value['to']) |
|
85 | + { |
|
86 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
87 | + } |
|
75 | 88 | unset($query['col_filter'][$field]); |
76 | 89 | } |
77 | 90 | } |
78 | 91 | |
79 | 92 | $this->bo->get_rows($query,$selection,$readonlys); |
80 | - } else { |
|
93 | + } |
|
94 | + else |
|
95 | + { |
|
81 | 96 | $selection = explode(',',$options['selection']); |
82 | 97 | } |
83 | 98 | |
@@ -86,28 +101,42 @@ discard block |
||
86 | 101 | |
87 | 102 | // Check if we need to load the custom fields |
88 | 103 | $need_custom = false; |
89 | - foreach(Api\Storage\Customfields::get('resources') as $field => $settings) { |
|
90 | - if($options['mapping']['#'.$field]) { |
|
104 | + foreach(Api\Storage\Customfields::get('resources') as $field => $settings) |
|
105 | + { |
|
106 | + if($options['mapping']['#'.$field]) |
|
107 | + { |
|
91 | 108 | $need_custom = true; |
92 | 109 | break; |
93 | 110 | } |
94 | 111 | } |
95 | 112 | |
96 | - foreach ($selection as $record) { |
|
97 | - if(!is_array($record) || !$record['res_id']) continue; |
|
113 | + foreach ($selection as $record) |
|
114 | + { |
|
115 | + if(!is_array($record) || !$record['res_id']) |
|
116 | + { |
|
117 | + continue; |
|
118 | + } |
|
98 | 119 | |
99 | - if($need_custom) { |
|
120 | + if($need_custom) |
|
121 | + { |
|
100 | 122 | $record = $this->bo->read($record['res_id']); |
101 | 123 | } |
102 | 124 | $resource = new resources_egw_record(); |
103 | 125 | $resource->set_record($record); |
104 | 126 | $resource->long_description = strip_tags($resource->long_description); |
105 | - if($options['convert']) { |
|
127 | + if($options['convert']) |
|
128 | + { |
|
106 | 129 | importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects); |
107 | - } else { |
|
130 | + } |
|
131 | + else |
|
132 | + { |
|
108 | 133 | // Implode arrays, so they don't say 'Array' |
109 | - foreach($resource->get_record_array() as $key => $value) { |
|
110 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
134 | + foreach($resource->get_record_array() as $key => $value) |
|
135 | + { |
|
136 | + if(is_array($value)) |
|
137 | + { |
|
138 | + $resource->$key = implode(',', $value); |
|
139 | + } |
|
111 | 140 | } |
112 | 141 | } |
113 | 142 | |
@@ -122,7 +151,8 @@ discard block |
||
122 | 151 | * |
123 | 152 | * @return string name |
124 | 153 | */ |
125 | - public static function get_name() { |
|
154 | + public static function get_name() |
|
155 | + { |
|
126 | 156 | return lang('Resources CSV export'); |
127 | 157 | } |
128 | 158 | |
@@ -131,7 +161,8 @@ discard block |
||
131 | 161 | * |
132 | 162 | * @return string descriprion |
133 | 163 | */ |
134 | - public static function get_description() { |
|
164 | + public static function get_description() |
|
165 | + { |
|
135 | 166 | return lang("Exports a list of resources to a CSV File."); |
136 | 167 | } |
137 | 168 | |
@@ -140,11 +171,13 @@ discard block |
||
140 | 171 | * |
141 | 172 | * @return string suffix |
142 | 173 | */ |
143 | - public static function get_filesuffix() { |
|
174 | + public static function get_filesuffix() |
|
175 | + { |
|
144 | 176 | return 'csv'; |
145 | 177 | } |
146 | 178 | |
147 | - public static function get_mimetype() { |
|
179 | + public static function get_mimetype() |
|
180 | + { |
|
148 | 181 | return 'text/csv'; |
149 | 182 | } |
150 | 183 | |
@@ -153,14 +186,16 @@ discard block |
||
153 | 186 | * this way the plugin has all opportunities for options tab |
154 | 187 | * |
155 | 188 | */ |
156 | - public function get_options_etpl() { |
|
189 | + public function get_options_etpl() |
|
190 | + { |
|
157 | 191 | } |
158 | 192 | |
159 | 193 | /** |
160 | 194 | * returns selectors information |
161 | 195 | * |
162 | 196 | */ |
163 | - public function get_selectors_etpl() { |
|
197 | + public function get_selectors_etpl() |
|
198 | + { |
|
164 | 199 | return array( |
165 | 200 | 'name' => 'importexport.export_csv_selectors', |
166 | 201 | ); |
@@ -170,7 +205,7 @@ discard block |
||
170 | 205 | * Get selectbox values |
171 | 206 | */ |
172 | 207 | protected function get_selects() |
173 | - { |
|
208 | + { |
|
174 | 209 | $this->selects = array(); |
175 | 210 | } |
176 | 211 | |
@@ -194,7 +229,10 @@ discard block |
||
194 | 229 | ); |
195 | 230 | foreach($filters as $field_name => &$settings) |
196 | 231 | { |
197 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
232 | + if($this->selects[$field_name]) |
|
233 | + { |
|
234 | + $settings['values'] = $this->selects[$field_name]; |
|
235 | + } |
|
198 | 236 | } |
199 | 237 | } |
200 | 238 |
@@ -247,7 +247,7 @@ |
||
247 | 247 | $this->selects['info_status'] = $this->bo->get_status(); |
248 | 248 | } |
249 | 249 | |
250 | - public function get_filter_fields(Array &$filters) |
|
250 | + public function get_filter_fields(array &$filters) |
|
251 | 251 | { |
252 | 252 | foreach($filters as $field_name => &$settings) |
253 | 253 | { |
@@ -28,9 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | /** |
30 | 30 | * imports entries according to given definition object. |
31 | - * @param resource $_stream |
|
32 | - * @param string $_charset |
|
33 | - * @param definition $_definition |
|
31 | + * @param importexport_definition $_definition |
|
34 | 32 | */ |
35 | 33 | public function init(importexport_definition $_definition ) { |
36 | 34 | |
@@ -52,7 +50,7 @@ discard block |
||
52 | 50 | * |
53 | 51 | * Updates the count of actions taken |
54 | 52 | * |
55 | - * @return boolean success |
|
53 | + * @return null|boolean success |
|
56 | 54 | */ |
57 | 55 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
58 | 56 | { |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * Import a single record |
|
49 | - * |
|
50 | - * You don't need to worry about mappings or translations, they've been done already. |
|
51 | - * You do need to handle the conditions and the actions taken. |
|
52 | - * |
|
53 | - * Updates the count of actions taken |
|
54 | - * |
|
55 | - * @return boolean success |
|
56 | - */ |
|
48 | + * Import a single record |
|
49 | + * |
|
50 | + * You don't need to worry about mappings or translations, they've been done already. |
|
51 | + * You do need to handle the conditions and the actions taken. |
|
52 | + * |
|
53 | + * Updates the count of actions taken |
|
54 | + * |
|
55 | + * @return boolean success |
|
56 | + */ |
|
57 | 57 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
58 | 58 | { |
59 | 59 | // Check for an un-matched accessory of, try again on just name |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Returns warnings that were encountered during importing |
|
254 | - * Maximum of one warning message per record, but you can append if you need to |
|
255 | - * |
|
256 | - * @return Array ( |
|
257 | - * record_# => warning message |
|
258 | - * ) |
|
259 | - */ |
|
260 | - public function get_warnings() { |
|
253 | + * Returns warnings that were encountered during importing |
|
254 | + * Maximum of one warning message per record, but you can append if you need to |
|
255 | + * |
|
256 | + * @return Array ( |
|
257 | + * record_# => warning message |
|
258 | + * ) |
|
259 | + */ |
|
260 | + public function get_warnings() { |
|
261 | 261 | return $this->warnings; |
262 | 262 | } |
263 | 263 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * class to import resources from CSV |
18 | 18 | */ |
19 | -class resources_import_csv extends importexport_basic_import_csv { |
|
19 | +class resources_import_csv extends importexport_basic_import_csv { |
|
20 | 20 | |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected static $conditions = array( 'exists' ); |
|
27 | + protected static $conditions = array('exists'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * imports entries according to given definition object. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string $_charset |
33 | 33 | * @param definition $_definition |
34 | 34 | */ |
35 | - public function init(importexport_definition $_definition ) { |
|
35 | + public function init(importexport_definition $_definition) { |
|
36 | 36 | |
37 | 37 | // fetch the resource bo |
38 | 38 | $this->bo = new resources_bo(); |
@@ -54,33 +54,33 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return boolean success |
56 | 56 | */ |
57 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
57 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
58 | 58 | { |
59 | 59 | // Check for an un-matched accessory of, try again on just name |
60 | - if(!is_numeric($record->accessory_of)) |
|
60 | + if (!is_numeric($record->accessory_of)) |
|
61 | 61 | { |
62 | 62 | $accessory_of = $record->accessory_of; |
63 | 63 | |
64 | 64 | // Look for exact match in just name |
65 | - $results = $this->bo->so->search(array('name' => $record->accessory_of),array('res_id','name')); |
|
66 | - if(count($results) >= 1) |
|
65 | + $results = $this->bo->so->search(array('name' => $record->accessory_of), array('res_id', 'name')); |
|
66 | + if (count($results) >= 1) |
|
67 | 67 | { |
68 | 68 | // More than 1 result? Bad names. Pick one. |
69 | - foreach($results as $result) |
|
69 | + foreach ($results as $result) |
|
70 | 70 | { |
71 | - if($result['name'] == $record->accessory_of) |
|
71 | + if ($result['name'] == $record->accessory_of) |
|
72 | 72 | { |
73 | 73 | $record->accessory_of = $result['res_id']; |
74 | 74 | break; |
75 | 75 | } |
76 | 76 | } |
77 | - if(is_numeric($record->accessory_of)) |
|
77 | + if (is_numeric($record->accessory_of)) |
|
78 | 78 | { |
79 | 79 | // Import/Export conversion gave a warning, so cancel it |
80 | - $pattern = lang('Unable to link to %1 "%2"',lang('resources'),$accessory_of) . ' - ('.lang('too many matches') . '|'.lang('no matches') . ')'; |
|
80 | + $pattern = lang('Unable to link to %1 "%2"', lang('resources'), $accessory_of).' - ('.lang('too many matches').'|'.lang('no matches').')'; |
|
81 | 81 | $this->warnings[$import_csv->get_current_position()] = preg_replace($pattern, '', $this->warnings[$import_csv->get_current_position()], 1); |
82 | 82 | // If that was the only warning, clear it for this row |
83 | - if(trim($this->warnings[$import_csv->get_current_position()]) == '') |
|
83 | + if (trim($this->warnings[$import_csv->get_current_position()]) == '') |
|
84 | 84 | { |
85 | 85 | unset($this->warnings[$import_csv->get_current_position()]); |
86 | 86 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // Check for a new category, it needs permissions set |
93 | 93 | $category = $GLOBALS['egw']->categories->read($record->cat_id); |
94 | 94 | |
95 | - if($category['last_mod'] >= $this->start_time) { |
|
95 | + if ($category['last_mod'] >= $this->start_time) { |
|
96 | 96 | // New category. Give read & write permissions to the current user's default group |
97 | 97 | $this->acl_bo->set_rights($record['cat_id'], |
98 | 98 | array($GLOBALS['egw_info']['user']['account_primary_group']), |
@@ -104,37 +104,37 @@ discard block |
||
104 | 104 | // Refresh ACL |
105 | 105 | //$GLOBALS['egw']->acl->read_repository(); |
106 | 106 | } |
107 | - if(!$record->accessory_of) $record->accessory_of = -1; |
|
107 | + if (!$record->accessory_of) $record->accessory_of = -1; |
|
108 | 108 | //error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions'])); |
109 | 109 | if ($this->definition->plugin_options['conditions']) { |
110 | 110 | |
111 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
111 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
112 | 112 | $results = array(); |
113 | - switch ( $condition['type'] ) { |
|
113 | + switch ($condition['type']) { |
|
114 | 114 | // exists |
115 | 115 | case 'exists' : |
116 | - if($record->$condition['string']) { |
|
116 | + if ($record->$condition['string']) { |
|
117 | 117 | $results = $this->bo->so->search( |
118 | - array( $condition['string'] => $record->$condition['string']), |
|
118 | + array($condition['string'] => $record->$condition['string']), |
|
119 | 119 | False |
120 | 120 | ); |
121 | 121 | } |
122 | 122 | |
123 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1) { |
|
123 | + if (is_array($results) && count(array_keys($results)) >= 1) { |
|
124 | 124 | // apply action to all contacts matching this exists condition |
125 | 125 | $action = $condition['true']; |
126 | - foreach ( (array)$results as $resource ) { |
|
126 | + foreach ((array)$results as $resource) { |
|
127 | 127 | $record->res_id = $resource['res_id']; |
128 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
129 | - if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
130 | - if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
131 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) ); |
|
128 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
129 | + if (!is_array($resource['cat_id'])) $resource['cat_id'] = explode(',', $resource['cat_id']); |
|
130 | + if (!is_array($record->cat_id)) $record->cat_id = explode(',', $record->cat_id); |
|
131 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $resource['cat_id']))); |
|
132 | 132 | } |
133 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
133 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
134 | 134 | } |
135 | 135 | } else { |
136 | 136 | $action = $condition['false']; |
137 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
137 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
138 | 138 | } |
139 | 139 | break; |
140 | 140 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | } else { |
149 | 149 | // unconditional insert |
150 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
150 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
151 | 151 | } |
152 | 152 | return $success; |
153 | 153 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param importexport_iface_egw_record $record Entry record |
160 | 160 | * @return bool success or not |
161 | 161 | */ |
162 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
162 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) { |
|
163 | 163 | $_data = $record->get_record_array(); |
164 | 164 | switch ($_action) { |
165 | 165 | case 'none' : |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | |
174 | 174 | // Fall through |
175 | 175 | case 'insert' : |
176 | - if($_action == 'insert') { |
|
176 | + if ($_action == 'insert') { |
|
177 | 177 | // Backend doesn't like inserting with ID specified, it can overwrite |
178 | 178 | unset($_data['res_id']); |
179 | 179 | } |
180 | - if ( $this->dry_run ) { |
|
180 | + if ($this->dry_run) { |
|
181 | 181 | //print_r($_data); |
182 | 182 | $this->results[$_action]++; |
183 | 183 | return true; |
184 | 184 | } else { |
185 | - $result = $this->bo->save( $_data ); |
|
186 | - if($result && !is_numeric($result)) { |
|
185 | + $result = $this->bo->save($_data); |
|
186 | + if ($result && !is_numeric($result)) { |
|
187 | 187 | $this->errors[$record_num] = $result; |
188 | 188 | return false; |
189 | 189 | } else { |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * class to import resources from CSV |
18 | 18 | */ |
19 | -class resources_import_csv extends importexport_basic_import_csv { |
|
19 | +class resources_import_csv extends importexport_basic_import_csv |
|
20 | +{ |
|
20 | 21 | |
21 | 22 | |
22 | 23 | /** |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | * @param string $_charset |
33 | 34 | * @param definition $_definition |
34 | 35 | */ |
35 | - public function init(importexport_definition $_definition ) { |
|
36 | + public function init(importexport_definition $_definition ) |
|
37 | + { |
|
36 | 38 | |
37 | 39 | // fetch the resource bo |
38 | 40 | $this->bo = new resources_bo(); |
@@ -92,7 +94,8 @@ discard block |
||
92 | 94 | // Check for a new category, it needs permissions set |
93 | 95 | $category = $GLOBALS['egw']->categories->read($record->cat_id); |
94 | 96 | |
95 | - if($category['last_mod'] >= $this->start_time) { |
|
97 | + if($category['last_mod'] >= $this->start_time) |
|
98 | + { |
|
96 | 99 | // New category. Give read & write permissions to the current user's default group |
97 | 100 | $this->acl_bo->set_rights($record['cat_id'], |
98 | 101 | array($GLOBALS['egw_info']['user']['account_primary_group']), |
@@ -104,35 +107,53 @@ discard block |
||
104 | 107 | // Refresh ACL |
105 | 108 | //$GLOBALS['egw']->acl->read_repository(); |
106 | 109 | } |
107 | - if(!$record->accessory_of) $record->accessory_of = -1; |
|
110 | + if(!$record->accessory_of) |
|
111 | + { |
|
112 | + $record->accessory_of = -1; |
|
113 | + } |
|
108 | 114 | //error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions'])); |
109 | - if ($this->definition->plugin_options['conditions']) { |
|
115 | + if ($this->definition->plugin_options['conditions']) |
|
116 | + { |
|
110 | 117 | |
111 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
118 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
119 | + { |
|
112 | 120 | $results = array(); |
113 | - switch ( $condition['type'] ) { |
|
121 | + switch ( $condition['type'] ) |
|
122 | + { |
|
114 | 123 | // exists |
115 | 124 | case 'exists' : |
116 | - if($record->$condition['string']) { |
|
125 | + if($record->$condition['string']) |
|
126 | + { |
|
117 | 127 | $results = $this->bo->so->search( |
118 | 128 | array( $condition['string'] => $record->$condition['string']), |
119 | 129 | False |
120 | 130 | ); |
121 | 131 | } |
122 | 132 | |
123 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1) { |
|
133 | + if ( is_array( $results ) && count( array_keys( $results )) >= 1) |
|
134 | + { |
|
124 | 135 | // apply action to all contacts matching this exists condition |
125 | 136 | $action = $condition['true']; |
126 | - foreach ( (array)$results as $resource ) { |
|
137 | + foreach ( (array)$results as $resource ) |
|
138 | + { |
|
127 | 139 | $record->res_id = $resource['res_id']; |
128 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
129 | - if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
130 | - if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
140 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
141 | + { |
|
142 | + if ( !is_array( $resource['cat_id'] ) ) |
|
143 | + { |
|
144 | + $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
145 | + } |
|
146 | + if ( !is_array( $record->cat_id ) ) |
|
147 | + { |
|
148 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
149 | + } |
|
131 | 150 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) ); |
132 | 151 | } |
133 | 152 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
134 | 153 | } |
135 | - } else { |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
136 | 157 | $action = $condition['false']; |
137 | 158 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
138 | 159 | } |
@@ -143,9 +164,14 @@ discard block |
||
143 | 164 | die('condition / action not supported!!!'); |
144 | 165 | break; |
145 | 166 | } |
146 | - if ($action['last']) break; |
|
167 | + if ($action['last']) |
|
168 | + { |
|
169 | + break; |
|
170 | + } |
|
147 | 171 | } |
148 | - } else { |
|
172 | + } |
|
173 | + else |
|
174 | + { |
|
149 | 175 | // unconditional insert |
150 | 176 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
151 | 177 | } |
@@ -159,9 +185,11 @@ discard block |
||
159 | 185 | * @param importexport_iface_egw_record $record Entry record |
160 | 186 | * @return bool success or not |
161 | 187 | */ |
162 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
188 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
189 | + { |
|
163 | 190 | $_data = $record->get_record_array(); |
164 | - switch ($_action) { |
|
191 | + switch ($_action) |
|
192 | + { |
|
165 | 193 | case 'none' : |
166 | 194 | return true; |
167 | 195 | case 'update' : |
@@ -173,20 +201,27 @@ discard block |
||
173 | 201 | |
174 | 202 | // Fall through |
175 | 203 | case 'insert' : |
176 | - if($_action == 'insert') { |
|
204 | + if($_action == 'insert') |
|
205 | + { |
|
177 | 206 | // Backend doesn't like inserting with ID specified, it can overwrite |
178 | 207 | unset($_data['res_id']); |
179 | 208 | } |
180 | - if ( $this->dry_run ) { |
|
209 | + if ( $this->dry_run ) |
|
210 | + { |
|
181 | 211 | //print_r($_data); |
182 | 212 | $this->results[$_action]++; |
183 | 213 | return true; |
184 | - } else { |
|
214 | + } |
|
215 | + else |
|
216 | + { |
|
185 | 217 | $result = $this->bo->save( $_data ); |
186 | - if($result && !is_numeric($result)) { |
|
218 | + if($result && !is_numeric($result)) |
|
219 | + { |
|
187 | 220 | $this->errors[$record_num] = $result; |
188 | 221 | return false; |
189 | - } else { |
|
222 | + } |
|
223 | + else |
|
224 | + { |
|
190 | 225 | $this->results[$_action]++; |
191 | 226 | return true; |
192 | 227 | } |
@@ -202,7 +237,8 @@ discard block |
||
202 | 237 | * |
203 | 238 | * @return string name |
204 | 239 | */ |
205 | - public static function get_name() { |
|
240 | + public static function get_name() |
|
241 | + { |
|
206 | 242 | return lang('Resources CSV import'); |
207 | 243 | } |
208 | 244 | |
@@ -211,7 +247,8 @@ discard block |
||
211 | 247 | * |
212 | 248 | * @return string descriprion |
213 | 249 | */ |
214 | - public static function get_description() { |
|
250 | + public static function get_description() |
|
251 | + { |
|
215 | 252 | return lang("Imports a list of resources from a CSV file."); |
216 | 253 | } |
217 | 254 | |
@@ -220,7 +257,8 @@ discard block |
||
220 | 257 | * |
221 | 258 | * @return string suffix (comma seperated) |
222 | 259 | */ |
223 | - public static function get_filesuffix() { |
|
260 | + public static function get_filesuffix() |
|
261 | + { |
|
224 | 262 | return 'csv'; |
225 | 263 | } |
226 | 264 | |
@@ -236,7 +274,8 @@ discard block |
||
236 | 274 | * preserv => array, |
237 | 275 | * ) |
238 | 276 | */ |
239 | - public function get_options_etpl() { |
|
277 | + public function get_options_etpl() |
|
278 | + { |
|
240 | 279 | // lets do it! |
241 | 280 | } |
242 | 281 | |
@@ -245,7 +284,8 @@ discard block |
||
245 | 284 | * |
246 | 285 | * @return string etemplate name |
247 | 286 | */ |
248 | - public function get_selectors_etpl() { |
|
287 | + public function get_selectors_etpl() |
|
288 | + { |
|
249 | 289 | // lets do it! |
250 | 290 | } |
251 | 291 | |
@@ -257,7 +297,8 @@ discard block |
||
257 | 297 | * record_# => warning message |
258 | 298 | * ) |
259 | 299 | */ |
260 | - public function get_warnings() { |
|
300 | + public function get_warnings() |
|
301 | + { |
|
261 | 302 | return $this->warnings; |
262 | 303 | } |
263 | 304 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @param string $key key of value to get |
35 | 35 | * @param int $res_id resource id |
36 | - * @return mixed value of key and resource, false if key or id not found. |
|
36 | + * @return integer value of key and resource, false if key or id not found. |
|
37 | 37 | */ |
38 | 38 | function get_value($key,$res_id) |
39 | 39 | { |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | { |
23 | 23 | function __construct() |
24 | 24 | { |
25 | - parent::__construct('resources','egw_resources', 'egw_resources_extra', '', |
|
26 | - 'extra_name', 'extra_value', 'extra_id' ); |
|
25 | + parent::__construct('resources', 'egw_resources', 'egw_resources_extra', '', |
|
26 | + 'extra_name', 'extra_value', 'extra_id'); |
|
27 | 27 | |
28 | - $this->columns_to_search = array('name','short_description','inventory_number','long_description','location'); |
|
28 | + $this->columns_to_search = array('name', 'short_description', 'inventory_number', 'long_description', 'location'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -35,10 +35,9 @@ discard block |
||
35 | 35 | * @param int $res_id resource id |
36 | 36 | * @return mixed value of key and resource, false if key or id not found. |
37 | 37 | */ |
38 | - function get_value($key,$res_id) |
|
38 | + function get_value($key, $res_id) |
|
39 | 39 | { |
40 | - return $res_id == $this->data['res_id'] ? $this->data[$key] : |
|
41 | - $this->db->select($this->table_name,$key,array('res_id' => $res_id),__LINE__,__FILE__)->fetchColumn(); |
|
40 | + return $res_id == $this->data['res_id'] ? $this->data[$key] : $this->db->select($this->table_name, $key, array('res_id' => $res_id), __LINE__, __FILE__)->fetchColumn(); |
|
42 | 41 | } |
43 | 42 | |
44 | 43 | /** |
@@ -90,7 +89,7 @@ discard block |
||
90 | 89 | function save($resource) |
91 | 90 | { |
92 | 91 | $this->data = $resource; |
93 | - if(parent::save() != 0) return false; |
|
92 | + if (parent::save() != 0) return false; |
|
94 | 93 | $res_id = $this->data['res_id']; |
95 | 94 | |
96 | 95 | return $res_id; |
@@ -51,7 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function read($res_id) |
53 | 53 | { |
54 | - if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id'])) $res_id = $res_id['res_id']; |
|
54 | + if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id'])) |
|
55 | + { |
|
56 | + $res_id = $res_id['res_id']; |
|
57 | + } |
|
55 | 58 | |
56 | 59 | /*if (!is_array($res_id) && $res_id == $this->data['res_id']) |
57 | 60 | { |
@@ -90,7 +93,10 @@ discard block |
||
90 | 93 | function save($resource) |
91 | 94 | { |
92 | 95 | $this->data = $resource; |
93 | - if(parent::save() != 0) return false; |
|
96 | + if(parent::save() != 0) |
|
97 | + { |
|
98 | + return false; |
|
99 | + } |
|
94 | 100 | $res_id = $this->data['res_id']; |
95 | 101 | |
96 | 102 | return $res_id; |
@@ -316,6 +316,7 @@ |
||
316 | 316 | * Check if given package is installed via composer in EGroupware's vendor directory |
317 | 317 | * |
318 | 318 | * @param string $package package-name in composer notation eg. "pear-pear.horde.org/Horde_Imap_Client" or "pear-pear.php.net/Net_Sieve" |
319 | + * @return string|null |
|
319 | 320 | */ |
320 | 321 | function composer_check($package) |
321 | 322 | { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use EGroupware\Api; |
14 | 14 | |
15 | 15 | $run_by_webserver = !!$_SERVER['PHP_SELF']; |
16 | -$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN'; |
|
16 | +$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; |
|
17 | 17 | |
18 | 18 | if ($run_by_webserver) |
19 | 19 | { |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $error_icon = '*** Error: '; |
42 | 42 | $warning_icon = '!!! Warning: '; |
43 | 43 | |
44 | - function lang($msg,$arg1=NULL,$arg2=NULL,$arg3=NULL,$arg4=NULL) |
|
44 | + function lang($msg, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL) |
|
45 | 45 | { |
46 | - return is_null($arg1) ? $msg : str_replace(array('%1','%2','%3','%4'),array($arg1,$arg2,$arg3,$arg4),$msg); |
|
46 | + return is_null($arg1) ? $msg : str_replace(array('%1', '%2', '%3', '%4'), array($arg1, $arg2, $arg3, $arg4), $msg); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | 'func' => 'php_ini_check', |
80 | 80 | 'value' => 0, |
81 | 81 | 'verbose_value' => 'Off', |
82 | - 'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!','display_errors',ini_get('display_errors')), |
|
82 | + 'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!', 'display_errors', ini_get('display_errors')), |
|
83 | 83 | ), |
84 | 84 | 'memory_limit' => array( |
85 | 85 | 'func' => 'php_ini_check', |
86 | 86 | 'value' => '128M', |
87 | 87 | 'check' => '>=', |
88 | - 'error' => lang('memory_limit is set to less than %1: some applications of eGroupWare need more than the recommend 8M, expect occasional failures','24M'), |
|
88 | + 'error' => lang('memory_limit is set to less than %1: some applications of eGroupWare need more than the recommend 8M, expect occasional failures', '24M'), |
|
89 | 89 | 'change' => 'memory_limit = 24M' |
90 | 90 | ), |
91 | 91 | 'max_execution_time' => array( |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | 'func' => 'php_ini_check', |
106 | 106 | 'value' => '8M', |
107 | 107 | 'check' => '>=', |
108 | - 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','upload_max_filesize',ini_get('upload_max_filesize')), |
|
108 | + 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'upload_max_filesize', ini_get('upload_max_filesize')), |
|
109 | 109 | 'change' => 'upload_max_filesize = 8M' |
110 | 110 | ), |
111 | 111 | 'post_max_size' => array( |
112 | 112 | 'func' => 'php_ini_check', |
113 | 113 | 'value' => '8M', |
114 | 114 | 'check' => '>=', |
115 | - 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','post_max_size',ini_get('max_post_size')), |
|
115 | + 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'post_max_size', ini_get('max_post_size')), |
|
116 | 116 | 'change' => 'post_max_size = 8M' |
117 | 117 | ), |
118 | 118 | 'allow_url_fopen' => array( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'verbose_value' => '"System/Localtime"', |
139 | 139 | 'check' => '!=', |
140 | 140 | 'error' => lang('No VALID timezone set! ("%1" is NOT sufficient, you have to use a timezone identifer like "%2", see %3full list of valid identifers%4)', |
141 | - 'System/Localtime','Europe/Berlin','<a href="http://www.php.net/manual/en/timezones.php" target="_blank">','</a>'), |
|
141 | + 'System/Localtime', 'Europe/Berlin', '<a href="http://www.php.net/manual/en/timezones.php" target="_blank">', '</a>'), |
|
142 | 142 | ), |
143 | 143 | 'pdo' => array( |
144 | 144 | 'func' => 'extension_check', |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | ), |
147 | 147 | 'mysqli' => array( |
148 | 148 | 'func' => 'extension_check', |
149 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','mysql','MySQL') |
|
149 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'mysql', 'MySQL') |
|
150 | 150 | ), |
151 | 151 | 'pdo_mysql' => array( |
152 | 152 | 'func' => 'extension_check', |
153 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_mysql','MySQL') |
|
153 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_mysql', 'MySQL') |
|
154 | 154 | ), |
155 | 155 | 'pgsql' => array( |
156 | 156 | 'func' => 'extension_check', |
157 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pgsql','pgSQL') |
|
157 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pgsql', 'pgSQL') |
|
158 | 158 | ), |
159 | 159 | 'pdo_pgsql' => array( |
160 | 160 | 'func' => 'extension_check', |
161 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_pgsql','pgSQL') |
|
161 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_pgsql', 'pgSQL') |
|
162 | 162 | ), |
163 | 163 | /* disable checks for other database extensions, as we are not really supporting them anymore |
164 | 164 | 'mssql' => array( |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | realpath('..') => array( |
203 | 203 | 'func' => 'permission_check', |
204 | 204 | 'is_world_writable' => False, |
205 | - 'only_if_exists' => true, // quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir |
|
205 | + 'only_if_exists' => true, // quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir |
|
206 | 206 | 'recursiv' => True |
207 | 207 | ), |
208 | 208 | realpath('../header.inc.php') => array( |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | $sp_visible = true; |
237 | 237 | if (($open_basedir = ini_get('open_basedir')) && $open_basedir != 'none') |
238 | 238 | { |
239 | - foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir) |
|
239 | + foreach (explode(PATH_SEPARATOR, $open_basedir) as $dir) |
|
240 | 240 | { |
241 | 241 | $dir = realpath($dir); |
242 | - if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break; |
|
242 | + if (($sp_visible = substr($session_path, 0, strlen($dir)) == $dir)) break; |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | if ($sp_visible) // only check if session_save_path is visible by webserver |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | $checks[$session_path] = array( |
248 | 248 | 'func' => 'permission_check', |
249 | 249 | 'is_writable' => true, |
250 | - 'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver",session_save_path()), |
|
250 | + 'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver", session_save_path()), |
|
251 | 251 | 'error' => lang('You will NOT be able to log into eGroupWare using PHP sessions: "session could not be verified" !!!'), |
252 | 252 | ); |
253 | 253 | } |
254 | 254 | } |
255 | 255 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
256 | -foreach($setup_info as $app => $app_data) |
|
256 | +foreach ($setup_info as $app => $app_data) |
|
257 | 257 | { |
258 | 258 | if (!isset($app_data['check_install'])) continue; |
259 | 259 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | { |
262 | 262 | if (isset($checks[$name])) |
263 | 263 | { |
264 | - if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
264 | + if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
265 | 265 | |
266 | - if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning'])) |
|
266 | + if ($data['func'] == 'pear_check' || in_array($data['func'], array('extension_check', 'php_ini_check')) && !isset($data['warning'])) |
|
267 | 267 | { |
268 | 268 | if (isset($checks[$name]['from']) && $checks[$name]['from'] && !is_array($checks[$name]['from'])) |
269 | 269 | { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | if (!isset($data['from'])) $data['from'] = $app; |
273 | 273 | if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array(); |
274 | - if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
274 | + if (!in_array($data['from'], $checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
275 | 275 | } |
276 | 276 | else |
277 | 277 | { |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | } |
288 | 288 | } |
289 | 289 | $sorted_checks = array(); |
290 | -foreach(array('php_version','php_ini_check','extension_check','pear_check','gd_check','permission_check') as $func) |
|
290 | +foreach (array('php_version', 'php_ini_check', 'extension_check', 'pear_check', 'gd_check', 'permission_check') as $func) |
|
291 | 291 | { |
292 | - foreach($checks as $name => $data) |
|
292 | + foreach ($checks as $name => $data) |
|
293 | 293 | { |
294 | 294 | if ($data['func'] == $func) |
295 | 295 | { |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | } |
301 | 301 | if ($checks) $sorted_checks += $checks; |
302 | 302 | |
303 | -function php_version($name,$args) |
|
303 | +function php_version($name, $args) |
|
304 | 304 | { |
305 | 305 | global $passed_icon, $error_icon; |
306 | - unset($name); // not used, but required by function signature |
|
306 | + unset($name); // not used, but required by function signature |
|
307 | 307 | |
308 | - $version_ok = version_compare(phpversion(),$args['value']) >= 0; |
|
308 | + $version_ok = version_compare(phpversion(), $args['value']) >= 0; |
|
309 | 309 | |
310 | 310 | echo '<div>'.($version_ok ? $passed_icon : $error_icon).' <span'.($version_ok ? '' : ' class="setup_error"').'>'. |
311 | - lang('Checking required PHP version %1 (recommended %2)',$args['verbose_value'],$args['recommended']).': '. |
|
311 | + lang('Checking required PHP version %1 (recommended %2)', $args['verbose_value'], $args['recommended']).': '. |
|
312 | 312 | phpversion().' ==> '.($version_ok ? lang('True') : lang('False'))."</span></div>\n"; |
313 | 313 | } |
314 | 314 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | */ |
320 | 320 | function composer_check($package) |
321 | 321 | { |
322 | - static $installed=null; |
|
322 | + static $installed = null; |
|
323 | 323 | if (!isset($installed)) |
324 | 324 | { |
325 | 325 | $installed = array(); |
326 | - if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json=EGW_SERVER_ROOT.'/vendor/composer/installed.json')) |
|
326 | + if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json = EGW_SERVER_ROOT.'/vendor/composer/installed.json')) |
|
327 | 327 | { |
328 | - foreach(json_decode(file_get_contents($json), true) as $package_data) |
|
328 | + foreach (json_decode(file_get_contents($json), true) as $package_data) |
|
329 | 329 | { |
330 | 330 | $installed[strtolower($package_data['name'])] = $package_data['version']; |
331 | 331 | } |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | * @param $channel =null use default or given channel |
342 | 342 | * @return array with package-name => version pairs, eg. array('Log' => '1.9.8','PEAR' => '1.4.11') |
343 | 343 | */ |
344 | -function get_installed_pear_packages($channel=null) |
|
344 | +function get_installed_pear_packages($channel = null) |
|
345 | 345 | { |
346 | - $pear_config = ''; // use the system default |
|
346 | + $pear_config = ''; // use the system default |
|
347 | 347 | // fix for SuSE having the pear.conf only for cli, will fail with open_basedir - no idea what to do then |
348 | 348 | if (@is_dir('/etc/php5/apache2') && !file_exists('/etc/php5/apache2/pear.conf') && @file_exists('/etc/php5/cli/pear.conf')) |
349 | 349 | { |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | |
354 | 354 | if (!class_exists('PEAR_Config')) return false; |
355 | 355 | |
356 | - $config = new PEAR_Config('',$pear_config); |
|
356 | + $config = new PEAR_Config('', $pear_config); |
|
357 | 357 | //echo "<pre>config = ".print_r($config,true)."</pre>\n"; |
358 | 358 | |
359 | 359 | if (empty($channel)) $channel = $config->get('default_channel'); |
360 | 360 | //echo "<pre>channel = ".print_r($channel,true)."</pre>\n"; |
361 | 361 | |
362 | - if (!method_exists($config,'getRegistry')) return false; // PEAR version to old |
|
362 | + if (!method_exists($config, 'getRegistry')) return false; // PEAR version to old |
|
363 | 363 | |
364 | 364 | $reg = &$config->getRegistry(); |
365 | 365 | //echo "<pre>reg = ".print_r($reg,true)."</pre>\n"; |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | // bug reported: http://pear.php.net/bugs/bug.php?id=11317 |
369 | 369 | if (!file_exists($reg->install_dir)) return false; |
370 | 370 | |
371 | - $installed = $reg->packageInfo(null,null,$channel); |
|
371 | + $installed = $reg->packageInfo(null, null, $channel); |
|
372 | 372 | |
373 | 373 | //echo "<pre>installed =".print_r($installed,true)."</pre>\n"; |
374 | 374 | $packages = array(); |
375 | - foreach($installed as $package) |
|
375 | + foreach ($installed as $package) |
|
376 | 376 | { |
377 | 377 | $name = isset($package['package']) ? $package['package'] : $package['name']; |
378 | 378 | $version = $package['version']; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | return $packages; |
387 | 387 | } |
388 | 388 | |
389 | -function pear_check($package,$args) |
|
389 | +function pear_check($package, $args) |
|
390 | 390 | { |
391 | 391 | global $passed_icon, $warning_icon; |
392 | 392 | static $pear_available = null; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $found = $pear_available; |
431 | 431 | if ($pear_available && $package) |
432 | 432 | { |
433 | - $file = str_replace('_','/',$package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php'; |
|
433 | + $file = str_replace('_', '/', $package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php'; |
|
434 | 434 | |
435 | 435 | $found = @include_once($file); |
436 | 436 | |
@@ -439,16 +439,15 @@ discard block |
||
439 | 439 | } |
440 | 440 | } |
441 | 441 | // is the right version availible |
442 | - $available = $found && (!$min_version || version_compare($min_version,$version_available) <= 0); |
|
442 | + $available = $found && (!$min_version || version_compare($min_version, $version_available) <= 0); |
|
443 | 443 | echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'. |
444 | - lang('Checking PEAR%1 is installed',($package?($channel?' '.$channel.'/':'::').$package:'').($min_version?" ($min_version)":'')).': '. |
|
445 | - ($available ? ($version_available ? $version_available : lang('True')) : |
|
446 | - ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
|
444 | + lang('Checking PEAR%1 is installed', ($package ? ($channel ? ' '.$channel.'/' : '::').$package : '').($min_version ? " ($min_version)" : '')).': '. |
|
445 | + ($available ? ($version_available ? $version_available : lang('True')) : ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
|
447 | 446 | |
448 | 447 | if (!$available) // give further info only if not availible |
449 | 448 | { |
450 | - echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '', |
|
451 | - is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
|
449 | + echo '<div class="setup_info">'.lang('PEAR%1 is needed by: %2.', $package ? '::'.$package : '', |
|
450 | + is_array($args['from']) ? implode(', ', $args['from']) : $args['from']); |
|
452 | 451 | |
453 | 452 | // if using Composer, dont confuse user with PEAR ;-) |
454 | 453 | if (file_exists(EGW_SERVER_ROOT.'/vendor')) |
@@ -461,7 +460,7 @@ discard block |
||
461 | 460 | if (!$pear_available) |
462 | 461 | { |
463 | 462 | echo '<br/>'.lang('PEAR (%1) is a PHP repository and is usually in a package called %2.', |
464 | - '<a href="http://pear.php.net" target="_blank">pear.php.net</a>','php-pear'); |
|
463 | + '<a href="http://pear.php.net" target="_blank">pear.php.net</a>', 'php-pear'); |
|
465 | 464 | } |
466 | 465 | elseif ($package && !$found) |
467 | 466 | { |
@@ -471,12 +470,12 @@ discard block |
||
471 | 470 | } |
472 | 471 | elseif ($min_version && !$version_available) |
473 | 472 | { |
474 | - echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2',$package,$min_version); |
|
473 | + echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2', $package, $min_version); |
|
475 | 474 | } |
476 | - elseif ($min_version && version_compare($min_version,$version_available) > 0) |
|
475 | + elseif ($min_version && version_compare($min_version, $version_available) > 0) |
|
477 | 476 | { |
478 | 477 | echo '<br/>'.lang('Your installed version of %1 is %2, required is at least %3, please run: ', |
479 | - $package,$version_available,$min_version).' pear upgrade '.$package; |
|
478 | + $package, $version_available, $min_version).' pear upgrade '.$package; |
|
480 | 479 | } |
481 | 480 | echo '<br/>'.lang('Alternatively you can use %1Composer%2 to install all requirements at once. Downloading it and run:', |
482 | 481 | '<a href="https://getcomposer.org/" target="_blank">', '</a>'). |
@@ -489,26 +488,26 @@ discard block |
||
489 | 488 | return $available; |
490 | 489 | } |
491 | 490 | |
492 | -function extension_check($name,$args) |
|
491 | +function extension_check($name, $args) |
|
493 | 492 | { |
494 | 493 | //echo "<p>extension_check($name,".print_r($args,true).")</p>\n"; |
495 | 494 | global $passed_icon, $warning_icon, $is_windows; |
496 | 495 | |
497 | 496 | if (isset($args['win_only']) && $args['win_only'] && !$is_windows) |
498 | 497 | { |
499 | - return True; // check only under windows |
|
498 | + return True; // check only under windows |
|
500 | 499 | } |
501 | 500 | // we check for the existens of 'dl', as multithreaded webservers dont have it !!! |
502 | 501 | $available = check_load_extension($name); |
503 | 502 | |
504 | - echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
503 | + echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
505 | 504 | |
506 | 505 | if (!$available) |
507 | 506 | { |
508 | 507 | if (!isset($args['warning'])) |
509 | 508 | { |
510 | - $args['warning'] = lang('The %1 extension is needed from: %2.',$name, |
|
511 | - is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
|
509 | + $args['warning'] = lang('The %1 extension is needed from: %2.', $name, |
|
510 | + is_array($args['from']) ? implode(', ', $args['from']) : $args['from']); |
|
512 | 511 | } |
513 | 512 | echo "<div class='setup_info'>".$args['warning'].'</div>'; |
514 | 513 | } |
@@ -517,20 +516,20 @@ discard block |
||
517 | 516 | return $available; |
518 | 517 | } |
519 | 518 | |
520 | -function function_check($name,$args) |
|
519 | +function function_check($name, $args) |
|
521 | 520 | { |
522 | 521 | global $passed_icon, $warning_icon; |
523 | 522 | |
524 | 523 | $available = function_exists($name); |
525 | 524 | |
526 | - echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
525 | + echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
527 | 526 | |
528 | 527 | if (!$available) |
529 | 528 | { |
530 | 529 | if (!isset($args['warning'])) |
531 | 530 | { |
532 | - $args['warning'] = lang('The function %1 is needed from: %2.',$name, |
|
533 | - is_array($args['from'] ? implode(', ',$args['from']) : $args['from'])); |
|
531 | + $args['warning'] = lang('The function %1 is needed from: %2.', $name, |
|
532 | + is_array($args['from'] ? implode(', ', $args['from']) : $args['from'])); |
|
534 | 533 | } |
535 | 534 | echo "<div class='setup_info'>".$args['warning'].'</div>'; |
536 | 535 | } |
@@ -539,33 +538,33 @@ discard block |
||
539 | 538 | return $available; |
540 | 539 | } |
541 | 540 | |
542 | -function verbosePerms( $in_Perms ) |
|
541 | +function verbosePerms($in_Perms) |
|
543 | 542 | { |
544 | - if($in_Perms & 0x1000) // FIFO pipe |
|
543 | + if ($in_Perms&0x1000) // FIFO pipe |
|
545 | 544 | { |
546 | 545 | $sP = 'p'; |
547 | 546 | } |
548 | - elseif($in_Perms & 0x2000) // Character special |
|
547 | + elseif ($in_Perms&0x2000) // Character special |
|
549 | 548 | { |
550 | 549 | $sP = 'c'; |
551 | 550 | } |
552 | - elseif($in_Perms & 0x4000) // Directory |
|
551 | + elseif ($in_Perms&0x4000) // Directory |
|
553 | 552 | { |
554 | 553 | $sP = 'd'; |
555 | 554 | } |
556 | - elseif($in_Perms & 0x6000) // Block special |
|
555 | + elseif ($in_Perms&0x6000) // Block special |
|
557 | 556 | { |
558 | 557 | $sP = 'b'; |
559 | 558 | } |
560 | - elseif($in_Perms & 0x8000) // Regular |
|
559 | + elseif ($in_Perms&0x8000) // Regular |
|
561 | 560 | { |
562 | 561 | $sP = '-'; |
563 | 562 | } |
564 | - elseif($in_Perms & 0xA000) // Symbolic Link |
|
563 | + elseif ($in_Perms&0xA000) // Symbolic Link |
|
565 | 564 | { |
566 | 565 | $sP = 'l'; |
567 | 566 | } |
568 | - elseif($in_Perms & 0xC000) // Socket |
|
567 | + elseif ($in_Perms&0xC000) // Socket |
|
569 | 568 | { |
570 | 569 | $sP = 's'; |
571 | 570 | } |
@@ -575,33 +574,30 @@ discard block |
||
575 | 574 | } |
576 | 575 | |
577 | 576 | // owner |
578 | - $sP .= (($in_Perms & 0x0100) ? 'r' : '-') . |
|
579 | - (($in_Perms & 0x0080) ? 'w' : '-') . |
|
580 | - (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : |
|
581 | - (($in_Perms & 0x0800) ? 'S' : '-')); |
|
577 | + $sP .= (($in_Perms&0x0100) ? 'r' : '-'). |
|
578 | + (($in_Perms&0x0080) ? 'w' : '-'). |
|
579 | + (($in_Perms&0x0040) ? (($in_Perms&0x0800) ? 's' : 'x') : (($in_Perms&0x0800) ? 'S' : '-')); |
|
582 | 580 | |
583 | 581 | // group |
584 | - $sP .= (($in_Perms & 0x0020) ? 'r' : '-') . |
|
585 | - (($in_Perms & 0x0010) ? 'w' : '-') . |
|
586 | - (($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) : |
|
587 | - (($in_Perms & 0x0400) ? 'S' : '-')); |
|
582 | + $sP .= (($in_Perms&0x0020) ? 'r' : '-'). |
|
583 | + (($in_Perms&0x0010) ? 'w' : '-'). |
|
584 | + (($in_Perms&0x0008) ? (($in_Perms&0x0400) ? 's' : 'x') : (($in_Perms&0x0400) ? 'S' : '-')); |
|
588 | 585 | |
589 | 586 | // world |
590 | - $sP .= (($in_Perms & 0x0004) ? 'r' : '-') . |
|
591 | - (($in_Perms & 0x0002) ? 'w' : '-') . |
|
592 | - (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : |
|
593 | - (($in_Perms & 0x0200) ? 'T' : '-')); |
|
587 | + $sP .= (($in_Perms&0x0004) ? 'r' : '-'). |
|
588 | + (($in_Perms&0x0002) ? 'w' : '-'). |
|
589 | + (($in_Perms&0x0001) ? (($in_Perms&0x0200) ? 't' : 'x') : (($in_Perms&0x0200) ? 'T' : '-')); |
|
594 | 590 | return $sP; |
595 | 591 | } |
596 | 592 | |
597 | -function permission_check($name,$args,$verbose=True) |
|
593 | +function permission_check($name, $args, $verbose = True) |
|
598 | 594 | { |
599 | - global $passed_icon, $error_icon, $warning_icon,$is_windows; |
|
595 | + global $passed_icon, $error_icon, $warning_icon, $is_windows; |
|
600 | 596 | //echo "<p>permision_check('$name',".print_r($args,True).",'$verbose')</p>\n"; |
601 | 597 | |
602 | 598 | // add a ../ for non-absolute pathes |
603 | 599 | $rel_name = $name; |
604 | - if ($name && substr($name,0,3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name,':') === false) |
|
600 | + if ($name && substr($name, 0, 3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name, ':') === false) |
|
605 | 601 | { |
606 | 602 | $name = '../'.$name; |
607 | 603 | } |
@@ -623,22 +619,22 @@ discard block |
||
623 | 619 | if (isset($args['is_readable'])) |
624 | 620 | { |
625 | 621 | $checks[] = lang('readable by the webserver'); |
626 | - $check_not = (!$args['is_readable']?lang('not'):''); |
|
622 | + $check_not = (!$args['is_readable'] ? lang('not') : ''); |
|
627 | 623 | } |
628 | 624 | if (isset($args['is_writable'])) |
629 | 625 | { |
630 | 626 | $checks[] = lang('writable by the webserver'); |
631 | - $check_not = (!$args['is_writable']?lang('not'):''); |
|
627 | + $check_not = (!$args['is_writable'] ? lang('not') : ''); |
|
632 | 628 | } |
633 | 629 | if (isset($args['is_world_readable'])) |
634 | 630 | { |
635 | 631 | $checks[] = lang('world readable'); |
636 | - $check_not = (!$args['is_world_readable']?lang('not'):''); |
|
632 | + $check_not = (!$args['is_world_readable'] ? lang('not') : ''); |
|
637 | 633 | } |
638 | 634 | if (isset($args['is_world_writable'])) |
639 | 635 | { |
640 | 636 | $checks[] = lang('world writable'); |
641 | - $check_not = (!$args['is_world_writable']?lang('not'):''); |
|
637 | + $check_not = (!$args['is_world_writable'] ? lang('not') : ''); |
|
642 | 638 | } |
643 | 639 | |
644 | 640 | if (isset($args['msg']) && ($msg = $args['msg'])) |
@@ -647,7 +643,7 @@ discard block |
||
647 | 643 | } |
648 | 644 | else |
649 | 645 | { |
650 | - $msg = lang('Checking file-permissions of %1 for %2 %3: %4',$rel_name,$check_not,implode(', ',$checks),$perms)."<br />\n"; |
|
646 | + $msg = lang('Checking file-permissions of %1 for %2 %3: %4', $rel_name, $check_not, implode(', ', $checks), $perms)."<br />\n"; |
|
651 | 647 | } |
652 | 648 | $extra_error_msg = ''; |
653 | 649 | if (isset($args['error']) && $args['error']) |
@@ -656,13 +652,13 @@ discard block |
||
656 | 652 | } |
657 | 653 | if (!file_exists($name)) |
658 | 654 | { |
659 | - echo '<div>'. $error_icon . '<span class="setup_error">' . $msg . lang('%1 does not exist !!!',$rel_name).$extra_error_msg."</span></div>\n"; |
|
655 | + echo '<div>'.$error_icon.'<span class="setup_error">'.$msg.lang('%1 does not exist !!!', $rel_name).$extra_error_msg."</span></div>\n"; |
|
660 | 656 | return False; |
661 | 657 | } |
662 | 658 | $warning = False; |
663 | 659 | if (!$GLOBALS['run_by_webserver'] && (@$args['is_readable'] || @$args['is_writable'])) |
664 | 660 | { |
665 | - echo $warning_icon.' '.$msg. lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n"; |
|
661 | + echo $warning_icon.' '.$msg.lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n"; |
|
666 | 662 | unset($args['is_readable']); |
667 | 663 | unset($args['is_writable']); |
668 | 664 | $warning = True; |
@@ -670,22 +666,22 @@ discard block |
||
670 | 666 | $Ok = True; |
671 | 667 | if (isset($args['is_writable']) && is_writable($name) != $args['is_writable']) |
672 | 668 | { |
673 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_writable']?lang('not').' ':'',lang('writable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
669 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_writable'] ? lang('not').' ' : '', lang('writable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
674 | 670 | $Ok = False; |
675 | 671 | } |
676 | 672 | if (isset($args['is_readable']) && is_readable($name) != $args['is_readable']) |
677 | 673 | { |
678 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_readable']?lang('not').' ':'',lang('readable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
674 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_readable'] ? lang('not').' ' : '', lang('readable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
679 | 675 | $Ok = False; |
680 | 676 | } |
681 | - if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name) & 04) == $args['is_world_readable']) |
|
677 | + if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name)&04) == $args['is_world_readable']) |
|
682 | 678 | { |
683 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_readable']?lang('not').' ':'',lang('world readable')).$extra_error_msg."</span></div>\n"; |
|
679 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_readable'] ? lang('not').' ' : '', lang('world readable')).$extra_error_msg."</span></div>\n"; |
|
684 | 680 | $Ok = False; |
685 | 681 | } |
686 | - if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name) & 02) == $args['is_world_writable']) |
|
682 | + if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name)&02) == $args['is_world_writable']) |
|
687 | 683 | { |
688 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_writable']?lang('not').' ':'',lang('world writable')).$extra_error_msg."</span></div>\n"; |
|
684 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_writable'] ? lang('not').' ' : '', lang('world writable')).$extra_error_msg."</span></div>\n"; |
|
689 | 685 | $Ok = False; |
690 | 686 | } |
691 | 687 | if ($Ok && !$warning && $verbose) |
@@ -697,16 +693,16 @@ discard block |
||
697 | 693 | if ($verbose) |
698 | 694 | { |
699 | 695 | @set_time_limit(0); |
700 | - echo "<div class='setup_info'>" . lang('This might take a while, please wait ...')."</div>\n"; |
|
696 | + echo "<div class='setup_info'>".lang('This might take a while, please wait ...')."</div>\n"; |
|
701 | 697 | flush(); |
702 | 698 | } |
703 | 699 | @set_time_limit(0); |
704 | 700 | $handle = @opendir($name); |
705 | - while($handle && ($file = readdir($handle))) |
|
701 | + while ($handle && ($file = readdir($handle))) |
|
706 | 702 | { |
707 | 703 | if ($file != '.' && $file != '..') |
708 | 704 | { |
709 | - $Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False); |
|
705 | + $Ok = $Ok && permission_check(($name != '.' ? $name.'/' : '').$file, $args, False); |
|
710 | 706 | } |
711 | 707 | } |
712 | 708 | if ($handle) closedir($handle); |
@@ -719,12 +715,12 @@ discard block |
||
719 | 715 | function mk_value($value) |
720 | 716 | { |
721 | 717 | $matches = null; |
722 | - if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value; |
|
718 | + if (!preg_match('/^([0-9]+)([mk]+)$/i', $value, $matches)) return $value; |
|
723 | 719 | |
724 | - return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1]; |
|
720 | + return (strtolower($matches[2]) == 'm' ? 1024 * 1024 : 1024) * (int)$matches[1]; |
|
725 | 721 | } |
726 | 722 | |
727 | -function php_ini_check($name,$args) |
|
723 | +function php_ini_check($name, $args) |
|
728 | 724 | { |
729 | 725 | global $passed_icon, $error_icon, $warning_icon, $is_windows; |
730 | 726 | |
@@ -742,20 +738,20 @@ discard block |
||
742 | 738 | { |
743 | 739 | case 'not set': |
744 | 740 | $check = lang('not set'); |
745 | - $result = !($ini_value & $args['value']); |
|
741 | + $result = !($ini_value&$args['value']); |
|
746 | 742 | break; |
747 | 743 | case 'set': |
748 | 744 | $check = lang('set'); |
749 | - $result = !!($ini_value & $args['value']); |
|
745 | + $result = !!($ini_value&$args['value']); |
|
750 | 746 | break; |
751 | 747 | case '>=': |
752 | - $result = !$ini_value || // value not used, eg. no memory limit |
|
753 | - (int) mk_value($ini_value) >= (int) mk_value($args['value']); |
|
748 | + $result = !$ini_value || // value not used, eg. no memory limit |
|
749 | + (int)mk_value($ini_value) >= (int)mk_value($args['value']); |
|
754 | 750 | break; |
755 | 751 | case 'contain': |
756 | 752 | $check = lang('contain'); |
757 | 753 | $sep = $is_windows ? '/[; ]+/' : '/[: ]+/'; |
758 | - $result = in_array($args['value'],preg_split($sep,$ini_value)); |
|
754 | + $result = in_array($args['value'], preg_split($sep, $ini_value)); |
|
759 | 755 | break; |
760 | 756 | case '!=': |
761 | 757 | $check = lang('set and not'); |
@@ -772,9 +768,9 @@ discard block |
||
772 | 768 | $tz = new DateTimeZone($ini_value); |
773 | 769 | unset($tz); |
774 | 770 | } |
775 | - catch(Exception $e) { |
|
771 | + catch (Exception $e) { |
|
776 | 772 | unset($e); |
777 | - $result = false; // no valid timezone |
|
773 | + $result = false; // no valid timezone |
|
778 | 774 | } |
779 | 775 | } |
780 | 776 | $msg = ' '.lang('Checking php.ini').": $name $check $verbose_value: <span class='setup_info'>ini_get('$name')='$ini_value'$ini_value_verbose</span>"; |
@@ -796,7 +792,7 @@ discard block |
||
796 | 792 | elseif (!isset($args['safe_mode'])) |
797 | 793 | { |
798 | 794 | echo "<div>".$warning_icon.' <span class="setup_warning">'.$msg.'</span><div class="setup_info">'. |
799 | - lang('%1 is needed by: %2.',$name,is_array($args['from']) ? implode(', ',$args['from']) : $args['from']) |
|
795 | + lang('%1 is needed by: %2.', $name, is_array($args['from']) ? implode(', ', $args['from']) : $args['from']) |
|
800 | 796 | ."</div></div>\n"; |
801 | 797 | } |
802 | 798 | if (isset($args['safe_mode']) && $safe_mode || @$args['change']) |
@@ -806,7 +802,7 @@ discard block |
||
806 | 802 | echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.'</span></div>'; |
807 | 803 | } |
808 | 804 | echo "<div class='setup_error'>\n"; |
809 | - echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode']?$args['safe_mode']:$args['change'])."<br />\n"; |
|
805 | + echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode'] ? $args['safe_mode'] : $args['change'])."<br />\n"; |
|
810 | 806 | echo '*** '.lang('AND reload your webserver, so the above changes take effect !!!')."</div>\n"; |
811 | 807 | } |
812 | 808 | } |
@@ -821,16 +817,16 @@ discard block |
||
821 | 817 | ob_end_clean(); |
822 | 818 | |
823 | 819 | $found = null; |
824 | - return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/',$phpinfo,$found) ? $found[1] : False; |
|
820 | + return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/', $phpinfo, $found) ? $found[1] : False; |
|
825 | 821 | } |
826 | 822 | |
827 | 823 | function gd_check() |
828 | 824 | { |
829 | 825 | global $passed_icon, $warning_icon; |
830 | 826 | |
831 | - $available = (function_exists('imagecopyresampled') || function_exists('imagecopyresized')); |
|
827 | + $available = (function_exists('imagecopyresampled') || function_exists('imagecopyresized')); |
|
832 | 828 | |
833 | - echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available?'':' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
829 | + echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
834 | 830 | |
835 | 831 | if (!$available) |
836 | 832 | { |
@@ -849,24 +845,24 @@ discard block |
||
849 | 845 | )); |
850 | 846 | $ConfigDomain = $_REQUEST['ConfigDomain']; |
851 | 847 | if (@$_GET['intro']) { |
852 | - if(($ConfigLang = setup::get_lang())) |
|
848 | + if (($ConfigLang = setup::get_lang())) |
|
853 | 849 | { |
854 | - $GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/'); |
|
850 | + $GLOBALS['egw_setup']->set_cookie('ConfigLang', $ConfigLang, (int)(time() + (1200 * 9)), '/'); |
|
855 | 851 | } |
856 | - $GLOBALS['egw_setup']->html->show_header(lang('Welcome to the eGroupWare Installation'),False,'config'); |
|
852 | + $GLOBALS['egw_setup']->html->show_header(lang('Welcome to the eGroupWare Installation'), False, 'config'); |
|
857 | 853 | echo '<h1>'.lang('Welcome to the eGroupWare Installation')."</h1>\n"; |
858 | - if(!$ConfigLang) |
|
854 | + if (!$ConfigLang) |
|
859 | 855 | { |
860 | - echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True,'en')."</form></p>\n"; |
|
856 | + echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True, 'en')."</form></p>\n"; |
|
861 | 857 | } |
862 | 858 | echo '<p>'.lang('The first step in installing eGroupWare is to ensure your environment has the necessary settings to correctly run the application.').'</p>'; |
863 | 859 | echo '<p>'.lang('We will now run a series of tests, which may take a few minutes. Click the link below to proceed.').'</p>'; |
864 | 860 | echo '<h3><a href="check_install.php">'.lang('Run installation tests').'</a></h3>'; |
865 | 861 | echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n"; |
866 | - $setup_tpl->pparse('out','T_footer'); |
|
862 | + $setup_tpl->pparse('out', 'T_footer'); |
|
867 | 863 | exit; |
868 | 864 | } else { |
869 | - $GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : ''); |
|
865 | + $GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'), False, 'config', $ConfigDomain ? $ConfigDomain.'('.@$GLOBALS['egw_domain'][$ConfigDomain]['db_type'].')' : ''); |
|
870 | 866 | echo '<h1>'.lang('Checking the eGroupWare Installation')."</h1>\n"; |
871 | 867 | # echo "<pre style=\"text-align: left;\">\n";; |
872 | 868 | } |
@@ -880,7 +876,7 @@ discard block |
||
880 | 876 | $Ok = True; |
881 | 877 | foreach ($sorted_checks as $name => $args) |
882 | 878 | { |
883 | - $check_ok = $args['func']($name,$args); |
|
879 | + $check_ok = $args['func']($name, $args); |
|
884 | 880 | $Ok = $Ok && $check_ok; |
885 | 881 | } |
886 | 882 | |
@@ -892,9 +888,9 @@ discard block |
||
892 | 888 | { |
893 | 889 | if (!$Ok) |
894 | 890 | { |
895 | - echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon)."</h3>\n"; |
|
891 | + echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon)."</h3>\n"; |
|
896 | 892 | echo '<h3><a href="check_install.php">'.lang('Click here to re-run the installation tests')."</a></h3>\n"; |
897 | - echo '<h3>'.lang('or %1Continue to the Header Admin%2','<a href="manageheader.php">','</a>')."</h3>\n"; |
|
893 | + echo '<h3>'.lang('or %1Continue to the Header Admin%2', '<a href="manageheader.php">', '</a>')."</h3>\n"; |
|
898 | 894 | } |
899 | 895 | else |
900 | 896 | { |
@@ -906,10 +902,10 @@ discard block |
||
906 | 902 | echo '<h3>'; |
907 | 903 | if (!$Ok) |
908 | 904 | { |
909 | - echo lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon).'. '; |
|
905 | + echo lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon).'. '; |
|
910 | 906 | } |
911 | - echo '<br /><a href="'.str_replace('check_install.php','',@$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n"; |
|
907 | + echo '<br /><a href="'.str_replace('check_install.php', '', @$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n"; |
|
912 | 908 | } |
913 | - $setup_tpl->pparse('out','T_footer'); |
|
909 | + $setup_tpl->pparse('out', 'T_footer'); |
|
914 | 910 | //echo "</body>\n</html>\n"; |
915 | 911 | } |
@@ -239,10 +239,15 @@ discard block |
||
239 | 239 | foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir) |
240 | 240 | { |
241 | 241 | $dir = realpath($dir); |
242 | - if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break; |
|
242 | + if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) |
|
243 | + { |
|
244 | + break; |
|
245 | + } |
|
243 | 246 | } |
244 | 247 | } |
245 | - if ($sp_visible) // only check if session_save_path is visible by webserver |
|
248 | + if ($sp_visible) |
|
249 | + { |
|
250 | + // only check if session_save_path is visible by webserver |
|
246 | 251 | { |
247 | 252 | $checks[$session_path] = array( |
248 | 253 | 'func' => 'permission_check', |
@@ -251,17 +256,25 @@ discard block |
||
251 | 256 | 'error' => lang('You will NOT be able to log into eGroupWare using PHP sessions: "session could not be verified" !!!'), |
252 | 257 | ); |
253 | 258 | } |
259 | + } |
|
254 | 260 | } |
255 | 261 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
256 | 262 | foreach($setup_info as $app => $app_data) |
257 | 263 | { |
258 | - if (!isset($app_data['check_install'])) continue; |
|
264 | + if (!isset($app_data['check_install'])) |
|
265 | + { |
|
266 | + continue; |
|
267 | + } |
|
259 | 268 | |
260 | 269 | foreach ($app_data['check_install'] as $name => $data) |
261 | 270 | { |
262 | 271 | if (isset($checks[$name])) |
263 | 272 | { |
264 | - if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
273 | + if ($checks[$name] == $data) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
277 | + // identical check --> ignore it |
|
265 | 278 | |
266 | 279 | if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning'])) |
267 | 280 | { |
@@ -269,9 +282,18 @@ discard block |
||
269 | 282 | { |
270 | 283 | $checks[$name]['from'] = array($checks[$name]['from']); |
271 | 284 | } |
272 | - if (!isset($data['from'])) $data['from'] = $app; |
|
273 | - if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array(); |
|
274 | - if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
285 | + if (!isset($data['from'])) |
|
286 | + { |
|
287 | + $data['from'] = $app; |
|
288 | + } |
|
289 | + if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) |
|
290 | + { |
|
291 | + $checks[$name]['from'] = array(); |
|
292 | + } |
|
293 | + if (!in_array($data['from'],$checks[$name]['from'])) |
|
294 | + { |
|
295 | + $checks[$name]['from'][] = $data['from']; |
|
296 | + } |
|
275 | 297 | } |
276 | 298 | else |
277 | 299 | { |
@@ -280,7 +302,10 @@ discard block |
||
280 | 302 | } |
281 | 303 | else |
282 | 304 | { |
283 | - if (!isset($data['from'])) $data['from'] = $app; |
|
305 | + if (!isset($data['from'])) |
|
306 | + { |
|
307 | + $data['from'] = $app; |
|
308 | + } |
|
284 | 309 | $checks[$name] = $data; |
285 | 310 | } |
286 | 311 | //echo "added check $data[func]($name) for $app"; _debug_array($data); |
@@ -298,7 +323,10 @@ discard block |
||
298 | 323 | } |
299 | 324 | } |
300 | 325 | } |
301 | -if ($checks) $sorted_checks += $checks; |
|
326 | +if ($checks) |
|
327 | +{ |
|
328 | + $sorted_checks += $checks; |
|
329 | +} |
|
302 | 330 | |
303 | 331 | function php_version($name,$args) |
304 | 332 | { |
@@ -351,22 +379,35 @@ discard block |
||
351 | 379 | } |
352 | 380 | @include_once 'PEAR/Config.php'; |
353 | 381 | |
354 | - if (!class_exists('PEAR_Config')) return false; |
|
382 | + if (!class_exists('PEAR_Config')) |
|
383 | + { |
|
384 | + return false; |
|
385 | + } |
|
355 | 386 | |
356 | 387 | $config = new PEAR_Config('',$pear_config); |
357 | 388 | //echo "<pre>config = ".print_r($config,true)."</pre>\n"; |
358 | 389 | |
359 | - if (empty($channel)) $channel = $config->get('default_channel'); |
|
390 | + if (empty($channel)) |
|
391 | + { |
|
392 | + $channel = $config->get('default_channel'); |
|
393 | + } |
|
360 | 394 | //echo "<pre>channel = ".print_r($channel,true)."</pre>\n"; |
361 | 395 | |
362 | - if (!method_exists($config,'getRegistry')) return false; // PEAR version to old |
|
396 | + if (!method_exists($config,'getRegistry')) |
|
397 | + { |
|
398 | + return false; |
|
399 | + } |
|
400 | + // PEAR version to old |
|
363 | 401 | |
364 | 402 | $reg = &$config->getRegistry(); |
365 | 403 | //echo "<pre>reg = ".print_r($reg,true)."</pre>\n"; |
366 | 404 | |
367 | 405 | // a bug in pear causes an endless loop if the install-dir does not exist |
368 | 406 | // bug reported: http://pear.php.net/bugs/bug.php?id=11317 |
369 | - if (!file_exists($reg->install_dir)) return false; |
|
407 | + if (!file_exists($reg->install_dir)) |
|
408 | + { |
|
409 | + return false; |
|
410 | + } |
|
370 | 411 | |
371 | 412 | $installed = $reg->packageInfo(null,null,$channel); |
372 | 413 | |
@@ -376,7 +417,10 @@ discard block |
||
376 | 417 | { |
377 | 418 | $name = isset($package['package']) ? $package['package'] : $package['name']; |
378 | 419 | $version = $package['version']; |
379 | - if (is_array($version)) $version = $version['release']; |
|
420 | + if (is_array($version)) |
|
421 | + { |
|
422 | + $version = $version['release']; |
|
423 | + } |
|
380 | 424 | |
381 | 425 | $packages[$name] = $version; |
382 | 426 | //echo "<p>$name: ".print_r($package['version'],true)."</p>\n"; |
@@ -415,7 +459,10 @@ discard block |
||
415 | 459 | { |
416 | 460 | $pear_available = $found = true; |
417 | 461 | // check if package is installed |
418 | - if ($package && isset($pear_packages[$package])) $available = true; |
|
462 | + if ($package && isset($pear_packages[$package])) |
|
463 | + { |
|
464 | + $available = true; |
|
465 | + } |
|
419 | 466 | // check if it's the right version |
420 | 467 | $version_available = $pear_packages[$package ? $package : 'PEAR']; |
421 | 468 | } |
@@ -425,7 +472,10 @@ discard block |
||
425 | 472 | { |
426 | 473 | $pear_available = @include_once('PEAR.php'); |
427 | 474 | |
428 | - if (!class_exists('PEAR')) $pear_available = false; |
|
475 | + if (!class_exists('PEAR')) |
|
476 | + { |
|
477 | + $pear_available = false; |
|
478 | + } |
|
429 | 479 | } |
430 | 480 | $found = $pear_available; |
431 | 481 | if ($pear_available && $package) |
@@ -434,7 +484,10 @@ discard block |
||
434 | 484 | |
435 | 485 | $found = @include_once($file); |
436 | 486 | |
437 | - if (!class_exists($package)) $found = false; |
|
487 | + if (!class_exists($package)) |
|
488 | + { |
|
489 | + $found = false; |
|
490 | + } |
|
438 | 491 | } |
439 | 492 | } |
440 | 493 | } |
@@ -445,10 +498,13 @@ discard block |
||
445 | 498 | ($available ? ($version_available ? $version_available : lang('True')) : |
446 | 499 | ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
447 | 500 | |
448 | - if (!$available) // give further info only if not availible |
|
501 | + if (!$available) |
|
502 | + { |
|
503 | + // give further info only if not availible |
|
449 | 504 | { |
450 | 505 | echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '', |
451 | 506 | is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
507 | + } |
|
452 | 508 | |
453 | 509 | // if using Composer, dont confuse user with PEAR ;-) |
454 | 510 | if (file_exists(EGW_SERVER_ROOT.'/vendor')) |
@@ -541,34 +597,55 @@ discard block |
||
541 | 597 | |
542 | 598 | function verbosePerms( $in_Perms ) |
543 | 599 | { |
544 | - if($in_Perms & 0x1000) // FIFO pipe |
|
600 | + if($in_Perms & 0x1000) |
|
601 | + { |
|
602 | + // FIFO pipe |
|
545 | 603 | { |
546 | 604 | $sP = 'p'; |
547 | 605 | } |
548 | - elseif($in_Perms & 0x2000) // Character special |
|
606 | + } |
|
607 | + elseif($in_Perms & 0x2000) |
|
608 | + { |
|
609 | + // Character special |
|
549 | 610 | { |
550 | 611 | $sP = 'c'; |
551 | 612 | } |
552 | - elseif($in_Perms & 0x4000) // Directory |
|
613 | + } |
|
614 | + elseif($in_Perms & 0x4000) |
|
615 | + { |
|
616 | + // Directory |
|
553 | 617 | { |
554 | 618 | $sP = 'd'; |
555 | 619 | } |
556 | - elseif($in_Perms & 0x6000) // Block special |
|
620 | + } |
|
621 | + elseif($in_Perms & 0x6000) |
|
622 | + { |
|
623 | + // Block special |
|
557 | 624 | { |
558 | 625 | $sP = 'b'; |
559 | 626 | } |
560 | - elseif($in_Perms & 0x8000) // Regular |
|
627 | + } |
|
628 | + elseif($in_Perms & 0x8000) |
|
629 | + { |
|
630 | + // Regular |
|
561 | 631 | { |
562 | 632 | $sP = '-'; |
563 | 633 | } |
564 | - elseif($in_Perms & 0xA000) // Symbolic Link |
|
634 | + } |
|
635 | + elseif($in_Perms & 0xA000) |
|
636 | + { |
|
637 | + // Symbolic Link |
|
565 | 638 | { |
566 | 639 | $sP = 'l'; |
567 | 640 | } |
568 | - elseif($in_Perms & 0xC000) // Socket |
|
641 | + } |
|
642 | + elseif($in_Perms & 0xC000) |
|
643 | + { |
|
644 | + // Socket |
|
569 | 645 | { |
570 | 646 | $sP = 's'; |
571 | 647 | } |
648 | + } |
|
572 | 649 | else // UNKNOWN |
573 | 650 | { |
574 | 651 | $sP = 'u'; |
@@ -709,9 +786,15 @@ discard block |
||
709 | 786 | $Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False); |
710 | 787 | } |
711 | 788 | } |
712 | - if ($handle) closedir($handle); |
|
789 | + if ($handle) |
|
790 | + { |
|
791 | + closedir($handle); |
|
792 | + } |
|
793 | + } |
|
794 | + if ($verbose) |
|
795 | + { |
|
796 | + echo "\n"; |
|
713 | 797 | } |
714 | - if ($verbose) echo "\n"; |
|
715 | 798 | |
716 | 799 | return $Ok; |
717 | 800 | } |
@@ -719,7 +802,10 @@ discard block |
||
719 | 802 | function mk_value($value) |
720 | 803 | { |
721 | 804 | $matches = null; |
722 | - if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value; |
|
805 | + if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) |
|
806 | + { |
|
807 | + return $value; |
|
808 | + } |
|
723 | 809 | |
724 | 810 | return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1]; |
725 | 811 | } |
@@ -848,7 +934,8 @@ discard block |
||
848 | 934 | 'T_footer' => 'footer.tpl', |
849 | 935 | )); |
850 | 936 | $ConfigDomain = $_REQUEST['ConfigDomain']; |
851 | - if (@$_GET['intro']) { |
|
937 | + if (@$_GET['intro']) |
|
938 | + { |
|
852 | 939 | if(($ConfigLang = setup::get_lang())) |
853 | 940 | { |
854 | 941 | $GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/'); |
@@ -865,7 +952,9 @@ discard block |
||
865 | 952 | echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n"; |
866 | 953 | $setup_tpl->pparse('out','T_footer'); |
867 | 954 | exit; |
868 | - } else { |
|
955 | + } |
|
956 | + else |
|
957 | + { |
|
869 | 958 | $GLOBALS['egw_setup']->html->show_header(lang('Checking the eGroupWare Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : ''); |
870 | 959 | echo '<h1>'.lang('Checking the eGroupWare Installation')."</h1>\n"; |
871 | 960 | # echo "<pre style=\"text-align: left;\">\n";; |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | /** |
742 | 742 | * egw version checking, is param 1 < param 2 in phpgw versionspeak? |
743 | 743 | * @param $a phpgw version number to check if less than $b |
744 | - * @param $b phpgw version number to check $a against |
|
745 | - * @return True if $a < $b |
|
744 | + * @param string $b phpgw version number to check $a against |
|
745 | + * @return boolean if $a < $b |
|
746 | 746 | */ |
747 | 747 | function alessthanb($a,$b,$DEBUG=False) |
748 | 748 | { |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param $a phpgw version number to check if more than $b |
831 | 831 | * @param $b phpgw version number to check $a against |
832 | - * @return True if $a < $b |
|
832 | + * @return boolean if $a < $b |
|
833 | 833 | */ |
834 | 834 | function amorethanb($a,$b,$DEBUG=False) |
835 | 835 | { |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * Dont use it to set group-membership, use set_memberships instead! |
1103 | 1103 | * |
1104 | - * @param string|array $apps app-names |
|
1104 | + * @param string $apps app-names |
|
1105 | 1105 | * @param string $location eg. "run" |
1106 | 1106 | * @param int|string $account accountid or account_lid |
1107 | 1107 | * @param int $rights rights to set, default 1 |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | /** |
1148 | 1148 | * checks if one of the given tables exist, returns the first match |
1149 | 1149 | * |
1150 | - * @param array $tables array with possible table-names |
|
1150 | + * @param string[] $tables array with possible table-names |
|
1151 | 1151 | * @return string/boolean tablename or false |
1152 | 1152 | */ |
1153 | 1153 | function table_exist($tables,$force_refresh=False) |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Set the domain used for cookies |
|
155 | - * |
|
156 | - * @return string domain |
|
157 | - */ |
|
154 | + * Set the domain used for cookies |
|
155 | + * |
|
156 | + * @return string domain |
|
157 | + */ |
|
158 | 158 | static function cookiedomain() |
159 | 159 | { |
160 | 160 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Set a cookie |
|
179 | - * |
|
180 | - * @param string $cookiename name of cookie to be set |
|
181 | - * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | - * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | - */ |
|
178 | + * Set a cookie |
|
179 | + * |
|
180 | + * @param string $cookiename name of cookie to be set |
|
181 | + * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | + * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | + */ |
|
184 | 184 | function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
185 | 185 | { |
186 | 186 | if(!isset($this->cookie_domain)) |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | |
347 | - /** |
|
348 | - * check if username and password is valid |
|
349 | - * |
|
350 | - * this function compares the supplied and stored username and password |
|
351 | - * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | - * internal and compare always the md5 hashs |
|
353 | - * |
|
354 | - * @param string $user the user supplied username |
|
355 | - * @param string $pw the user supplied password |
|
356 | - * @param string $conf_user the configured username |
|
357 | - * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | - * @returns bool true on success |
|
359 | - */ |
|
347 | + /** |
|
348 | + * check if username and password is valid |
|
349 | + * |
|
350 | + * this function compares the supplied and stored username and password |
|
351 | + * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | + * internal and compare always the md5 hashs |
|
353 | + * |
|
354 | + * @param string $user the user supplied username |
|
355 | + * @param string $pw the user supplied password |
|
356 | + * @param string $conf_user the configured username |
|
357 | + * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | + * @returns bool true on success |
|
359 | + */ |
|
360 | 360 | static function check_auth($user, $pw, $conf_user, $hash) |
361 | 361 | { |
362 | 362 | if ($user !== $conf_user) |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * call the hooks for a single application |
|
732 | - * |
|
733 | - * @param $location hook location - required |
|
734 | - * @param $appname application name - optional |
|
731 | + * call the hooks for a single application |
|
732 | + * |
|
733 | + * @param $location hook location - required |
|
734 | + * @param $appname application name - optional |
|
735 | 735 | */ |
736 | 736 | static function hook($location, $appname='') |
737 | 737 | { |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | var $recommended_php_version = '5.6'; |
75 | 75 | |
76 | - function __construct($html=False, $translation=False) |
|
76 | + function __construct($html = False, $translation = False) |
|
77 | 77 | { |
78 | 78 | // setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects |
79 | - $GLOBALS['egw_setup'] =& $this; |
|
79 | + $GLOBALS['egw_setup'] = & $this; |
|
80 | 80 | |
81 | 81 | if (!is_object($GLOBALS['egw'])) |
82 | 82 | { |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * include api db class for the ConfigDomain and connect to the db |
97 | 97 | */ |
98 | - function loaddb($connect_and_setcharset=true) |
|
98 | + function loaddb($connect_and_setcharset = true) |
|
99 | 99 | { |
100 | - if(!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
100 | + if (!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
101 | 101 | { |
102 | 102 | $this->ConfigDomain = isset($_REQUEST['ConfigDomain']) ? $_REQUEST['ConfigDomain'] : $_POST['FormDomain']; |
103 | 103 | } |
@@ -121,24 +121,24 @@ discard block |
||
121 | 121 | if ($connect_and_setcharset) |
122 | 122 | { |
123 | 123 | try { |
124 | - $this->set_table_names(); // sets/checks config- and applications-table-name |
|
124 | + $this->set_table_names(); // sets/checks config- and applications-table-name |
|
125 | 125 | |
126 | 126 | // Set the DB's client charset if a system-charset is set |
127 | - if (($this->system_charset = $this->db->select($this->config_table,'config_value',array( |
|
127 | + if (($this->system_charset = $this->db->select($this->config_table, 'config_value', array( |
|
128 | 128 | 'config_app' => 'phpgwapi', |
129 | 129 | 'config_name' => 'system_charset', |
130 | - ),__LINE__,__FILE__)->fetchColumn())) |
|
130 | + ), __LINE__, __FILE__)->fetchColumn())) |
|
131 | 131 | { |
132 | - $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
132 | + $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
133 | 133 | |
134 | 134 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
135 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
135 | + if (substr($this->db->Type, 0, 5) == 'mysql') // we need to check the api version |
|
136 | 136 | { |
137 | - $api_version = $this->db->select($this->applications_table,'app_version',array( |
|
137 | + $api_version = $this->db->select($this->applications_table, 'app_version', array( |
|
138 | 138 | 'app_name' => 'phpgwapi', |
139 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
139 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
140 | 140 | } |
141 | - if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
|
141 | + if (!$api_version || !$this->alessthanb($api_version, '1.0.1.019')) |
|
142 | 142 | { |
143 | 143 | $this->db->Link_ID->SetCharSet($this->system_charset); |
144 | 144 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | static function cookiedomain() |
159 | 159 | { |
160 | 160 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
161 | - $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
161 | + $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
162 | 162 | |
163 | 163 | // remove port from HTTP_HOST |
164 | 164 | $arr = null; |
165 | - if (preg_match("/^(.*):(.*)$/",$cookie_domain,$arr)) |
|
165 | + if (preg_match("/^(.*):(.*)$/", $cookie_domain, $arr)) |
|
166 | 166 | { |
167 | 167 | $cookie_domain = $arr[1]; |
168 | 168 | } |
169 | - if (count(explode('.',$cookie_domain)) <= 1) |
|
169 | + if (count(explode('.', $cookie_domain)) <= 1) |
|
170 | 170 | { |
171 | 171 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in |
172 | 172 | $cookie_domain = ''; |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
182 | 182 | * @param int $cookietime when cookie should expire, 0 for session only (optional) |
183 | 183 | */ |
184 | - function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
|
184 | + function set_cookie($cookiename, $cookievalue = '', $cookietime = 0) |
|
185 | 185 | { |
186 | - if(!isset($this->cookie_domain)) |
|
186 | + if (!isset($this->cookie_domain)) |
|
187 | 187 | { |
188 | 188 | $this->cookie_domain = self::cookiedomain(); |
189 | 189 | } |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | if (!isset($_SESSION)) self::session_start(); |
209 | 209 | $ConfigLang = $_SESSION['ConfigLang']; |
210 | 210 | } |
211 | - if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
|
211 | + if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $ConfigLang)) |
|
212 | 212 | { |
213 | - $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
213 | + $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
214 | 214 | } |
215 | 215 | //error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang'])." returning ".array2string($ConfigLang)); |
216 | 216 | return $ConfigLang; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
244 | 244 | |
245 | - $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
245 | + $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
246 | 246 | // need to decrypt session, in case session encryption is switched on in header.inc.php |
247 | 247 | Api\Session::decrypt(); |
248 | 248 | //error_log(__METHOD__."() returning ".array2string($ok).' _SESSION='.array2string($_SESSION)); |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param string $_auth_type ='config' 'config' or 'header' (caseinsensitiv) |
256 | 256 | */ |
257 | - function auth($_auth_type='config') |
|
257 | + function auth($_auth_type = 'config') |
|
258 | 258 | { |
259 | 259 | $auth_type = strtolower($_auth_type); |
260 | 260 | $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = ''; |
261 | 261 | |
262 | - if(!$this->checkip($_SERVER['REMOTE_ADDR'])) |
|
262 | + if (!$this->checkip($_SERVER['REMOTE_ADDR'])) |
|
263 | 263 | { |
264 | 264 | //error_log(__METHOD__."('$auth_type') invalid IP"); |
265 | 265 | return false; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST)); |
272 | 272 | if (isset($_REQUEST['FormLogout'])) |
273 | 273 | { |
274 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
274 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
275 | 275 | session_destroy(); |
276 | 276 | if ($_REQUEST['FormLogout'] == 'config') |
277 | 277 | { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | return false; |
289 | 289 | } |
290 | - switch($auth_type) |
|
290 | + switch ($auth_type) |
|
291 | 291 | { |
292 | 292 | case 'config': |
293 | 293 | if (!isset($GLOBALS['egw_domain'][$_POST['FormDomain']]) || |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION)); |
328 | 328 | if ($_SESSION['egw_last_action_time'] < time() - self::TIMEOUT) |
329 | 329 | { |
330 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
330 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
331 | 331 | session_destroy(); |
332 | 332 | $GLOBALS['egw_info']['setup'][$_SESSION['egw_setup_auth_type'] == 'config' ? 'ConfigLoginMSG' : 'HeaderLoginMSG'] = |
333 | 333 | lang('Session expired'); |
@@ -382,37 +382,37 @@ discard block |
||
382 | 382 | * @param string $remoteip |
383 | 383 | * @return boolean |
384 | 384 | */ |
385 | - function checkip($remoteip='') |
|
385 | + function checkip($remoteip = '') |
|
386 | 386 | { |
387 | 387 | //echo "<p>setup::checkip($remoteip) against setup_acl='".$GLOBALS['egw_info']['server']['setup_acl']."'</p>\n"; |
388 | - $allowed_ips = explode(',',@$GLOBALS['egw_info']['server']['setup_acl']); |
|
389 | - if(empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
388 | + $allowed_ips = explode(',', @$GLOBALS['egw_info']['server']['setup_acl']); |
|
389 | + if (empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
390 | 390 | { |
391 | - return True; // no test |
|
391 | + return True; // no test |
|
392 | 392 | } |
393 | - $remotes = explode('.',$remoteip); |
|
394 | - foreach($allowed_ips as $value) |
|
393 | + $remotes = explode('.', $remoteip); |
|
394 | + foreach ($allowed_ips as $value) |
|
395 | 395 | { |
396 | - if (!preg_match('/^[0-9.]+$/',$value)) |
|
396 | + if (!preg_match('/^[0-9.]+$/', $value)) |
|
397 | 397 | { |
398 | - $value = gethostbyname($was=$value); // resolve domain-name, eg. a dyndns account |
|
398 | + $value = gethostbyname($was = $value); // resolve domain-name, eg. a dyndns account |
|
399 | 399 | //echo "resolving '$was' to '$value'<br>\n"; |
400 | 400 | } |
401 | - $values = explode('.',$value); |
|
402 | - for($i = 0; $i < count($values); ++$i) |
|
401 | + $values = explode('.', $value); |
|
402 | + for ($i = 0; $i < count($values); ++$i) |
|
403 | 403 | { |
404 | - if ((int) $values[$i] != (int) $remotes[$i]) |
|
404 | + if ((int)$values[$i] != (int)$remotes[$i]) |
|
405 | 405 | { |
406 | 406 | break; |
407 | 407 | } |
408 | 408 | } |
409 | 409 | if ($i == count($values)) |
410 | 410 | { |
411 | - return True; // match |
|
411 | + return True; // match |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address').' '.$remoteip; |
415 | - error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip,true)); |
|
415 | + error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip, true)); |
|
416 | 416 | return False; |
417 | 417 | } |
418 | 418 | |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | */ |
424 | 424 | function get_major($versionstring) |
425 | 425 | { |
426 | - if(!$versionstring) |
|
426 | + if (!$versionstring) |
|
427 | 427 | { |
428 | 428 | return False; |
429 | 429 | } |
430 | 430 | |
431 | - $version = str_replace('pre','.',$versionstring); |
|
432 | - $varray = explode('.',$version); |
|
433 | - $major = implode('.',array($varray[0],$varray[1],$varray[2])); |
|
431 | + $version = str_replace('pre', '.', $versionstring); |
|
432 | + $varray = explode('.', $version); |
|
433 | + $major = implode('.', array($varray[0], $varray[1], $varray[2])); |
|
434 | 434 | |
435 | 435 | return $major; |
436 | 436 | } |
@@ -451,55 +451,55 @@ discard block |
||
451 | 451 | * @param $_enable =99 set to True/False to override setup.inc.php setting |
452 | 452 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
453 | 453 | */ |
454 | - function register_app($appname, $_enable=99, array $setup_info=null) |
|
454 | + function register_app($appname, $_enable = 99, array $setup_info = null) |
|
455 | 455 | { |
456 | 456 | if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
457 | 457 | |
458 | - if(!$appname) |
|
458 | + if (!$appname) |
|
459 | 459 | { |
460 | 460 | return False; |
461 | 461 | } |
462 | 462 | |
463 | - if($_enable == 99) |
|
463 | + if ($_enable == 99) |
|
464 | 464 | { |
465 | 465 | $_enable = $setup_info[$appname]['enable']; |
466 | 466 | } |
467 | 467 | $enable = (int)$_enable; |
468 | 468 | |
469 | - if($GLOBALS['DEBUG']) |
|
469 | + if ($GLOBALS['DEBUG']) |
|
470 | 470 | { |
471 | - echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', tables: ' . implode(', ',$setup_info[$appname]['tables']) . '<br>'; |
|
471 | + echo '<br>register_app(): '.$appname.', version: '.$setup_info[$appname]['version'].', tables: '.implode(', ', $setup_info[$appname]['tables']).'<br>'; |
|
472 | 472 | // _debug_array($setup_info[$appname]); |
473 | 473 | } |
474 | 474 | |
475 | - if($setup_info[$appname]['version']) |
|
475 | + if ($setup_info[$appname]['version']) |
|
476 | 476 | { |
477 | - if($setup_info[$appname]['tables']) |
|
477 | + if ($setup_info[$appname]['tables']) |
|
478 | 478 | { |
479 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
479 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
480 | 480 | } |
481 | 481 | if ($setup_info[$appname]['tables_use_prefix'] == True) |
482 | 482 | { |
483 | - if($GLOBALS['DEBUG']) |
|
483 | + if ($GLOBALS['DEBUG']) |
|
484 | 484 | { |
485 | - echo "<br>$appname uses tables_use_prefix, storing ". $setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
485 | + echo "<br>$appname uses tables_use_prefix, storing ".$setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
486 | 486 | } |
487 | - $this->db->insert($this->config_table,array( |
|
487 | + $this->db->insert($this->config_table, array( |
|
488 | 488 | 'config_app' => $appname, |
489 | 489 | 'config_name' => $appname.'_tables_prefix', |
490 | 490 | 'config_value' => $setup_info[$appname]['tables_prefix'], |
491 | - ),False,__LINE__,__FILE__); |
|
491 | + ), False, __LINE__, __FILE__); |
|
492 | 492 | } |
493 | - $this->db->insert($this->applications_table,array( |
|
493 | + $this->db->insert($this->applications_table, array( |
|
494 | 494 | 'app_name' => $appname, |
495 | 495 | 'app_enabled' => $enable, |
496 | 496 | 'app_order' => $setup_info[$appname]['app_order'], |
497 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
497 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
498 | 498 | 'app_version' => $setup_info[$appname]['version'], |
499 | 499 | 'app_index' => $setup_info[$appname]['index'], |
500 | 500 | 'app_icon' => $setup_info[$appname]['icon'], |
501 | 501 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
502 | - ),False,__LINE__,__FILE__); |
|
502 | + ), False, __LINE__, __FILE__); |
|
503 | 503 | |
504 | 504 | $this->clear_session_cache(); |
505 | 505 | } |
@@ -513,26 +513,26 @@ discard block |
||
513 | 513 | */ |
514 | 514 | function app_registered($appname) |
515 | 515 | { |
516 | - if(!$appname) |
|
516 | + if (!$appname) |
|
517 | 517 | { |
518 | 518 | return False; |
519 | 519 | } |
520 | 520 | |
521 | - if(@$GLOBALS['DEBUG']) |
|
521 | + if (@$GLOBALS['DEBUG']) |
|
522 | 522 | { |
523 | - echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table; |
|
523 | + echo '<br>app_registered(): checking '.$appname.', table: '.$this->applications_table; |
|
524 | 524 | // _debug_array($setup_info[$appname]); |
525 | 525 | } |
526 | 526 | |
527 | - if ($this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__)->fetchColumn()) |
|
527 | + if ($this->db->select($this->applications_table, 'COUNT(*)', array('app_name' => $appname), __LINE__, __FILE__)->fetchColumn()) |
|
528 | 528 | { |
529 | - if(@$GLOBALS['DEBUG']) |
|
529 | + if (@$GLOBALS['DEBUG']) |
|
530 | 530 | { |
531 | 531 | echo '... app previously registered.'; |
532 | 532 | } |
533 | 533 | return True; |
534 | 534 | } |
535 | - if(@$GLOBALS['DEBUG']) |
|
535 | + if (@$GLOBALS['DEBUG']) |
|
536 | 536 | { |
537 | 537 | echo '... app not registered'; |
538 | 538 | } |
@@ -545,42 +545,42 @@ discard block |
||
545 | 545 | * @param string $appname Application 'name' with a matching $setup_info[$appname] array slice |
546 | 546 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
547 | 547 | */ |
548 | - function update_app($appname, array $setup_info=null) |
|
548 | + function update_app($appname, array $setup_info = null) |
|
549 | 549 | { |
550 | 550 | if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
551 | 551 | |
552 | - if(!$appname) |
|
552 | + if (!$appname) |
|
553 | 553 | { |
554 | 554 | return False; |
555 | 555 | } |
556 | 556 | |
557 | - if($GLOBALS['DEBUG']) |
|
557 | + if ($GLOBALS['DEBUG']) |
|
558 | 558 | { |
559 | - echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>'; |
|
559 | + echo '<br>update_app(): '.$appname.', version: '.$setup_info[$appname]['currentver'].', table: '.$this->applications_table.'<br>'; |
|
560 | 560 | // _debug_array($setup_info[$appname]); |
561 | 561 | } |
562 | 562 | |
563 | - if(!$this->app_registered($appname)) |
|
563 | + if (!$this->app_registered($appname)) |
|
564 | 564 | { |
565 | 565 | return False; |
566 | 566 | } |
567 | 567 | |
568 | - if($setup_info[$appname]['version']) |
|
568 | + if ($setup_info[$appname]['version']) |
|
569 | 569 | { |
570 | 570 | //echo '<br>' . $setup_info[$appname]['version']; |
571 | - if($setup_info[$appname]['tables']) |
|
571 | + if ($setup_info[$appname]['tables']) |
|
572 | 572 | { |
573 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
573 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
574 | 574 | } |
575 | - $this->db->update($this->applications_table,array( |
|
575 | + $this->db->update($this->applications_table, array( |
|
576 | 576 | 'app_enabled' => $setup_info[$appname]['enable'], |
577 | 577 | 'app_order' => $setup_info[$appname]['app_order'], |
578 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
578 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
579 | 579 | 'app_version' => $setup_info[$appname]['version'], |
580 | 580 | 'app_index' => $setup_info[$appname]['index'], |
581 | 581 | 'app_icon' => $setup_info[$appname]['icon'], |
582 | 582 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
583 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
583 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
@@ -593,20 +593,20 @@ discard block |
||
593 | 593 | */ |
594 | 594 | function update_app_version($setup_info, $appname, $tableschanged = True) |
595 | 595 | { |
596 | - if(!$appname) |
|
596 | + if (!$appname) |
|
597 | 597 | { |
598 | 598 | return False; |
599 | 599 | } |
600 | 600 | |
601 | - if($tableschanged == True) |
|
601 | + if ($tableschanged == True) |
|
602 | 602 | { |
603 | 603 | $GLOBALS['egw_info']['setup']['tableschanged'] = True; |
604 | 604 | } |
605 | - if($setup_info[$appname]['currentver']) |
|
605 | + if ($setup_info[$appname]['currentver']) |
|
606 | 606 | { |
607 | - $this->db->update($this->applications_table,array( |
|
607 | + $this->db->update($this->applications_table, array( |
|
608 | 608 | 'app_version' => $setup_info[$appname]['currentver'], |
609 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
609 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
610 | 610 | } |
611 | 611 | return $setup_info; |
612 | 612 | } |
@@ -618,19 +618,19 @@ discard block |
||
618 | 618 | */ |
619 | 619 | function deregister_app($appname) |
620 | 620 | { |
621 | - if(!$appname) |
|
621 | + if (!$appname) |
|
622 | 622 | { |
623 | 623 | return False; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Remove categories |
627 | - $this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname),__LINE__,__FILE__); |
|
627 | + $this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname), __LINE__, __FILE__); |
|
628 | 628 | Api\Categories::invalidate_cache($appname); |
629 | 629 | |
630 | 630 | // Remove config |
631 | - $this->db->delete(Api\Config::TABLE, array('config_app'=>$appname),__LINE__,__FILE__); |
|
631 | + $this->db->delete(Api\Config::TABLE, array('config_app'=>$appname), __LINE__, __FILE__); |
|
632 | 632 | //echo 'DELETING application: ' . $appname; |
633 | - $this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__); |
|
633 | + $this->db->delete($this->applications_table, array('app_name'=>$appname), __LINE__, __FILE__); |
|
634 | 634 | |
635 | 635 | // Remove links to the app |
636 | 636 | Link::unlink(0, $appname); |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | */ |
646 | 646 | function register_hooks($appname) |
647 | 647 | { |
648 | - if(!$appname) |
|
648 | + if (!$appname) |
|
649 | 649 | { |
650 | 650 | return False; |
651 | 651 | } |
@@ -665,21 +665,21 @@ discard block |
||
665 | 665 | |
666 | 666 | if (!isset($setup_info) || !isset($setup_info['hooks'])) |
667 | 667 | { |
668 | - return false; // app not found or no hook |
|
668 | + return false; // app not found or no hook |
|
669 | 669 | } |
670 | 670 | $GLOBALS['settings'] = array(); |
671 | - $hook_data = array('location' => 'settings','setup' => true); |
|
671 | + $hook_data = array('location' => 'settings', 'setup' => true); |
|
672 | 672 | if (isset($setup_info['hooks']['settings'])) |
673 | 673 | { |
674 | - $settings = ExecMethod($setup_info['hooks']['settings'],$hook_data); |
|
674 | + $settings = ExecMethod($setup_info['hooks']['settings'], $hook_data); |
|
675 | 675 | } |
676 | - elseif(in_array('settings',$setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
676 | + elseif (in_array('settings', $setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
677 | 677 | { |
678 | 678 | include_once($file); |
679 | 679 | } |
680 | 680 | if (!isset($settings) || !is_array($settings)) |
681 | 681 | { |
682 | - $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
682 | + $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
683 | 683 | } |
684 | 684 | if (!is_array($settings) || !count($settings)) |
685 | 685 | { |
@@ -692,10 +692,10 @@ discard block |
||
692 | 692 | { |
693 | 693 | $GLOBALS['settings'] = array(); |
694 | 694 | include_once($file); |
695 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
695 | + if ($GLOBALS['settings']) $settings = array_merge($settings, $GLOBALS['settings']); |
|
696 | 696 | } |
697 | 697 | $default = $forced = array(); |
698 | - foreach($settings as $name => $setting) |
|
698 | + foreach ($settings as $name => $setting) |
|
699 | 699 | { |
700 | 700 | if (isset($setting['default'])) |
701 | 701 | { |
@@ -709,14 +709,14 @@ discard block |
||
709 | 709 | // store default/forced preferences, if any found |
710 | 710 | $preferences = new Api\Preferences(); |
711 | 711 | $preferences->read_repository(false); |
712 | - foreach(array( |
|
712 | + foreach (array( |
|
713 | 713 | 'default' => $default, |
714 | 714 | 'forced' => $forced, |
715 | 715 | ) as $type => $prefs) |
716 | 716 | { |
717 | 717 | if ($prefs) |
718 | 718 | { |
719 | - foreach($prefs as $name => $value) |
|
719 | + foreach ($prefs as $name => $value) |
|
720 | 720 | { |
721 | 721 | $preferences->add($appname == 'preferences' ? 'common' : $appname, $name, $value, $type); |
722 | 722 | } |
@@ -733,9 +733,9 @@ discard block |
||
733 | 733 | * @param $location hook location - required |
734 | 734 | * @param $appname application name - optional |
735 | 735 | */ |
736 | - static function hook($location, $appname='') |
|
736 | + static function hook($location, $appname = '') |
|
737 | 737 | { |
738 | - return Api\Hooks::single($location,$appname,True,True); |
|
738 | + return Api\Hooks::single($location, $appname, True, True); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
@@ -744,82 +744,82 @@ discard block |
||
744 | 744 | * @param $b phpgw version number to check $a against |
745 | 745 | * @return True if $a < $b |
746 | 746 | */ |
747 | - function alessthanb($a,$b,$DEBUG=False) |
|
747 | + function alessthanb($a, $b, $DEBUG = False) |
|
748 | 748 | { |
749 | - $num = array('1st','2nd','3rd','4th'); |
|
749 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
750 | 750 | |
751 | - if($DEBUG) |
|
751 | + if ($DEBUG) |
|
752 | 752 | { |
753 | 753 | echo'<br>Input values: ' |
754 | 754 | . 'A="'.$a.'", B="'.$b.'"'; |
755 | 755 | } |
756 | - $newa = str_replace('pre','.',$a); |
|
757 | - $newb = str_replace('pre','.',$b); |
|
758 | - $testa = explode('.',$newa); |
|
759 | - if(@$testa[1] == '') |
|
756 | + $newa = str_replace('pre', '.', $a); |
|
757 | + $newb = str_replace('pre', '.', $b); |
|
758 | + $testa = explode('.', $newa); |
|
759 | + if (@$testa[1] == '') |
|
760 | 760 | { |
761 | 761 | $testa[1] = 0; |
762 | 762 | } |
763 | 763 | |
764 | - $testb = explode('.',$newb); |
|
765 | - if(@$testb[1] == '') |
|
764 | + $testb = explode('.', $newb); |
|
765 | + if (@$testb[1] == '') |
|
766 | 766 | { |
767 | 767 | $testb[1] = 0; |
768 | 768 | } |
769 | - if(@$testb[3] == '') |
|
769 | + if (@$testb[3] == '') |
|
770 | 770 | { |
771 | 771 | $testb[3] = 0; |
772 | 772 | } |
773 | 773 | $less = 0; |
774 | 774 | |
775 | - for($i=0;$i<count($testa);$i++) |
|
775 | + for ($i = 0; $i < count($testa); $i++) |
|
776 | 776 | { |
777 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
778 | - if((int)$testa[$i] < (int)$testb[$i]) |
|
777 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is less than '.(int)$testb[$i].' ...'; } |
|
778 | + if ((int)$testa[$i] < (int)$testb[$i]) |
|
779 | 779 | { |
780 | 780 | if ($DEBUG) { echo ' yes.'; } |
781 | 781 | $less++; |
782 | - if($i<3) |
|
782 | + if ($i < 3) |
|
783 | 783 | { |
784 | 784 | /* Ensure that this is definitely smaller */ |
785 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
785 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
786 | 786 | $less = 5; |
787 | 787 | break; |
788 | 788 | } |
789 | 789 | } |
790 | - elseif((int)$testa[$i] > (int)$testb[$i]) |
|
790 | + elseif ((int)$testa[$i] > (int)$testb[$i]) |
|
791 | 791 | { |
792 | - if($DEBUG) { echo ' no.'; } |
|
792 | + if ($DEBUG) { echo ' no.'; } |
|
793 | 793 | $less--; |
794 | - if($i<2) |
|
794 | + if ($i < 2) |
|
795 | 795 | { |
796 | 796 | /* Ensure that this is definitely greater */ |
797 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
797 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
798 | 798 | $less = -5; |
799 | 799 | break; |
800 | 800 | } |
801 | 801 | } |
802 | 802 | else |
803 | 803 | { |
804 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
804 | + if ($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
805 | 805 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
806 | 806 | $less = count($testa) < count($testb) ? 1 : 0; |
807 | 807 | } |
808 | 808 | } |
809 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
810 | - if($less>0) |
|
809 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
810 | + if ($less > 0) |
|
811 | 811 | { |
812 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
812 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
813 | 813 | return True; |
814 | 814 | } |
815 | - elseif($less<0) |
|
815 | + elseif ($less < 0) |
|
816 | 816 | { |
817 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
817 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
818 | 818 | return False; |
819 | 819 | } |
820 | 820 | else |
821 | 821 | { |
822 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
822 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
823 | 823 | return False; |
824 | 824 | } |
825 | 825 | } |
@@ -831,76 +831,76 @@ discard block |
||
831 | 831 | * @param $b phpgw version number to check $a against |
832 | 832 | * @return True if $a < $b |
833 | 833 | */ |
834 | - function amorethanb($a,$b,$DEBUG=False) |
|
834 | + function amorethanb($a, $b, $DEBUG = False) |
|
835 | 835 | { |
836 | - $num = array('1st','2nd','3rd','4th'); |
|
836 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
837 | 837 | |
838 | - if($DEBUG) |
|
838 | + if ($DEBUG) |
|
839 | 839 | { |
840 | 840 | echo'<br>Input values: ' |
841 | 841 | . 'A="'.$a.'", B="'.$b.'"'; |
842 | 842 | } |
843 | - $newa = str_replace('pre','.',$a); |
|
844 | - $newb = str_replace('pre','.',$b); |
|
845 | - $testa = explode('.',$newa); |
|
846 | - if($testa[3] == '') |
|
843 | + $newa = str_replace('pre', '.', $a); |
|
844 | + $newb = str_replace('pre', '.', $b); |
|
845 | + $testa = explode('.', $newa); |
|
846 | + if ($testa[3] == '') |
|
847 | 847 | { |
848 | 848 | $testa[3] = 0; |
849 | 849 | } |
850 | - $testb = explode('.',$newb); |
|
851 | - if($testb[3] == '') |
|
850 | + $testb = explode('.', $newb); |
|
851 | + if ($testb[3] == '') |
|
852 | 852 | { |
853 | 853 | $testb[3] = 0; |
854 | 854 | } |
855 | 855 | $less = 0; |
856 | 856 | |
857 | - for($i=0;$i<count($testa);$i++) |
|
857 | + for ($i = 0; $i < count($testa); $i++) |
|
858 | 858 | { |
859 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
860 | - if((int)$testa[$i] > (int)$testb[$i]) |
|
859 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is more than '.(int)$testb[$i].' ...'; } |
|
860 | + if ((int)$testa[$i] > (int)$testb[$i]) |
|
861 | 861 | { |
862 | - if($DEBUG) { echo ' yes.'; } |
|
862 | + if ($DEBUG) { echo ' yes.'; } |
|
863 | 863 | $less++; |
864 | - if($i<3) |
|
864 | + if ($i < 3) |
|
865 | 865 | { |
866 | 866 | /* Ensure that this is definitely greater */ |
867 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
867 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
868 | 868 | $less = 5; |
869 | 869 | break; |
870 | 870 | } |
871 | 871 | } |
872 | - elseif((int)$testa[$i] < (int)$testb[$i]) |
|
872 | + elseif ((int)$testa[$i] < (int)$testb[$i]) |
|
873 | 873 | { |
874 | - if($DEBUG) { echo ' no.'; } |
|
874 | + if ($DEBUG) { echo ' no.'; } |
|
875 | 875 | $less--; |
876 | - if($i<2) |
|
876 | + if ($i < 2) |
|
877 | 877 | { |
878 | 878 | /* Ensure that this is definitely smaller */ |
879 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
879 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
880 | 880 | $less = -5; |
881 | 881 | break; |
882 | 882 | } |
883 | 883 | } |
884 | 884 | else |
885 | 885 | { |
886 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
886 | + if ($DEBUG) { echo ' no, they are equal.'; } |
|
887 | 887 | $less = 0; |
888 | 888 | } |
889 | 889 | } |
890 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
891 | - if($less>0) |
|
890 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
891 | + if ($less > 0) |
|
892 | 892 | { |
893 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
893 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
894 | 894 | return True; |
895 | 895 | } |
896 | - elseif($less<0) |
|
896 | + elseif ($less < 0) |
|
897 | 897 | { |
898 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
898 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
899 | 899 | return False; |
900 | 900 | } |
901 | 901 | else |
902 | 902 | { |
903 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
903 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
904 | 904 | return False; |
905 | 905 | } |
906 | 906 | } |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | */ |
913 | 913 | var $accounts; |
914 | 914 | |
915 | - function setup_account_object(array $config=array()) |
|
915 | + function setup_account_object(array $config = array()) |
|
916 | 916 | { |
917 | 917 | if (!isset($this->accounts) || $this->accounts->config || $config) |
918 | 918 | { |
@@ -923,9 +923,9 @@ discard block |
||
923 | 923 | if (!$config) |
924 | 924 | { |
925 | 925 | // load the configuration from the database |
926 | - foreach($this->db->select($this->config_table,'config_name,config_value', |
|
926 | + foreach ($this->db->select($this->config_table, 'config_name,config_value', |
|
927 | 927 | "config_name LIKE 'ads%' OR config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'", |
928 | - __LINE__,__FILE__) as $row) |
|
928 | + __LINE__, __FILE__) as $row) |
|
929 | 929 | { |
930 | 930 | $GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value']; |
931 | 931 | } |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | return false; |
939 | 939 | } |
940 | 940 | if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
941 | - Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
941 | + Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
942 | 942 | } |
943 | 943 | return true; |
944 | 944 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * @param string &$anonpw=null on return password for anonymous user |
965 | 965 | * @return int the numerical user-id |
966 | 966 | */ |
967 | - function add_account($username,$first,$last,$passwd,$primary_group='Default',$changepw=False,$email='',&$anonpw=null) |
|
967 | + function add_account($username, $first, $last, $passwd, $primary_group = 'Default', $changepw = False, $email = '', &$anonpw = null) |
|
968 | 968 | { |
969 | 969 | $this->setup_account_object(); |
970 | 970 | |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $passwd = $anonpw = $this->anonpw; |
977 | 977 | } |
978 | 978 | |
979 | - if(!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
979 | + if (!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
980 | 980 | { |
981 | 981 | $account = array( |
982 | 982 | 'account_type' => $primary_group ? 'u' : 'g', |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | } |
998 | 998 | } |
999 | 999 | // set password for existing account, if given and not '*unchanged*' |
1000 | - elseif($passwd && $passwd != '*unchanged*') |
|
1000 | + elseif ($passwd && $passwd != '*unchanged*') |
|
1001 | 1001 | { |
1002 | 1002 | try { |
1003 | 1003 | $auth = new Api\Auth; |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | { |
1036 | 1036 | $this->set_memberships(array($primary_group_id), $accountid); |
1037 | 1037 | |
1038 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1038 | + if (!$changepw) $this->add_acl('preferences', 'nopasswordchange', $accountid); |
|
1039 | 1039 | } |
1040 | 1040 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1041 | 1041 | return $accountid; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | * @param int|string $account accountid or account_lid |
1107 | 1107 | * @param int $rights rights to set, default 1 |
1108 | 1108 | */ |
1109 | - function add_acl($apps,$location,$account,$rights=1) |
|
1109 | + function add_acl($apps, $location, $account, $rights = 1) |
|
1110 | 1110 | { |
1111 | 1111 | //error_log("setup::add_acl(".(is_array($apps) ? "array('".implode("','",$apps)."')" : "'$apps'").",'$location',$account,$rights)"); |
1112 | 1112 | if (!is_numeric($account)) |
@@ -1114,32 +1114,32 @@ discard block |
||
1114 | 1114 | $this->setup_account_object(); |
1115 | 1115 | $account = $this->accounts->name2id($account); |
1116 | 1116 | } |
1117 | - if(!is_object($this->db)) |
|
1117 | + if (!is_object($this->db)) |
|
1118 | 1118 | { |
1119 | 1119 | $this->loaddb(); |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - if(!is_array($apps)) |
|
1122 | + if (!is_array($apps)) |
|
1123 | 1123 | { |
1124 | 1124 | $apps = array($apps); |
1125 | 1125 | } |
1126 | - foreach($apps as $app) |
|
1126 | + foreach ($apps as $app) |
|
1127 | 1127 | { |
1128 | - $this->db->delete($this->acl_table,array( |
|
1128 | + $this->db->delete($this->acl_table, array( |
|
1129 | 1129 | 'acl_appname' => $app, |
1130 | 1130 | 'acl_location' => $location, |
1131 | 1131 | 'acl_account' => $account |
1132 | - ),__LINE__,__FILE__); |
|
1132 | + ), __LINE__, __FILE__); |
|
1133 | 1133 | |
1134 | - if ((int) $rights) |
|
1134 | + if ((int)$rights) |
|
1135 | 1135 | { |
1136 | - $this->db->insert($this->acl_table,array( |
|
1136 | + $this->db->insert($this->acl_table, array( |
|
1137 | 1137 | 'acl_rights' => $rights |
1138 | - ),array( |
|
1138 | + ), array( |
|
1139 | 1139 | 'acl_appname' => $app, |
1140 | 1140 | 'acl_location' => $location, |
1141 | 1141 | 'acl_account' => $account, |
1142 | - ),__LINE__,__FILE__); |
|
1142 | + ), __LINE__, __FILE__); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 | } |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | * @param array $tables array with possible table-names |
1151 | 1151 | * @return string/boolean tablename or false |
1152 | 1152 | */ |
1153 | - function table_exist($tables,$force_refresh=False) |
|
1153 | + function table_exist($tables, $force_refresh = False) |
|
1154 | 1154 | { |
1155 | 1155 | static $table_names = False; |
1156 | 1156 | |
@@ -1158,9 +1158,9 @@ discard block |
||
1158 | 1158 | |
1159 | 1159 | if (!$table_names) return false; |
1160 | 1160 | |
1161 | - foreach($table_names as $data) |
|
1161 | + foreach ($table_names as $data) |
|
1162 | 1162 | { |
1163 | - if (($key = array_search($data['table_name'],$tables)) !== false) |
|
1163 | + if (($key = array_search($data['table_name'], $tables)) !== false) |
|
1164 | 1164 | { |
1165 | 1165 | return $tables[$key]; |
1166 | 1166 | } |
@@ -1173,18 +1173,18 @@ discard block |
||
1173 | 1173 | * |
1174 | 1174 | * Other tables can always use the most up to date name |
1175 | 1175 | */ |
1176 | - function set_table_names($force_refresh=False) |
|
1176 | + function set_table_names($force_refresh = False) |
|
1177 | 1177 | { |
1178 | - foreach(array( |
|
1179 | - 'config_table' => array('egw_config','phpgw_config','config'), |
|
1180 | - 'applications_table' => array('egw_applications','phpgw_applications','applications'), |
|
1181 | - 'accounts_table' => array('egw_accounts','phpgw_accounts'), |
|
1182 | - 'acl_table' => array('egw_acl','phpgw_acl'), |
|
1183 | - 'lang_table' => array('egw_lang','phpgw_lang','lang'), |
|
1184 | - 'languages_table' => array('egw_languages','phpgw_languages','languages'), |
|
1178 | + foreach (array( |
|
1179 | + 'config_table' => array('egw_config', 'phpgw_config', 'config'), |
|
1180 | + 'applications_table' => array('egw_applications', 'phpgw_applications', 'applications'), |
|
1181 | + 'accounts_table' => array('egw_accounts', 'phpgw_accounts'), |
|
1182 | + 'acl_table' => array('egw_acl', 'phpgw_acl'), |
|
1183 | + 'lang_table' => array('egw_lang', 'phpgw_lang', 'lang'), |
|
1184 | + 'languages_table' => array('egw_languages', 'phpgw_languages', 'languages'), |
|
1185 | 1185 | ) as $name => $tables) |
1186 | 1186 | { |
1187 | - $table = $this->table_exist($tables,$force_refresh); |
|
1187 | + $table = $this->table_exist($tables, $force_refresh); |
|
1188 | 1188 | |
1189 | 1189 | if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
1190 | 1190 | { |
@@ -85,11 +85,20 @@ discard block |
||
85 | 85 | $this->detection = new setup_detection(); |
86 | 86 | $this->process = new setup_process(); |
87 | 87 | |
88 | - if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) $this->system_charset = $_REQUEST['system_charset']; |
|
88 | + if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) |
|
89 | + { |
|
90 | + $this->system_charset = $_REQUEST['system_charset']; |
|
91 | + } |
|
89 | 92 | |
90 | 93 | /* The setup application needs these */ |
91 | - if ($html) $this->html = new setup_html(); |
|
92 | - if ($translation) $this->translation = new setup_translation(); |
|
94 | + if ($html) |
|
95 | + { |
|
96 | + $this->html = new setup_html(); |
|
97 | + } |
|
98 | + if ($translation) |
|
99 | + { |
|
100 | + $this->translation = new setup_translation(); |
|
101 | + } |
|
93 | 102 | } |
94 | 103 | |
95 | 104 | /** |
@@ -132,12 +141,15 @@ discard block |
||
132 | 141 | $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
133 | 142 | |
134 | 143 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
135 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
144 | + if (substr($this->db->Type,0,5) == 'mysql') |
|
145 | + { |
|
146 | + // we need to check the api version |
|
136 | 147 | { |
137 | 148 | $api_version = $this->db->select($this->applications_table,'app_version',array( |
138 | 149 | 'app_name' => 'phpgwapi', |
139 | 150 | ),__LINE__,__FILE__)->fetchColumn(); |
140 | 151 | } |
152 | + } |
|
141 | 153 | if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
142 | 154 | { |
143 | 155 | $this->db->Link_ID->SetCharSet($this->system_charset); |
@@ -205,7 +217,10 @@ discard block |
||
205 | 217 | } |
206 | 218 | else |
207 | 219 | { |
208 | - if (!isset($_SESSION)) self::session_start(); |
|
220 | + if (!isset($_SESSION)) |
|
221 | + { |
|
222 | + self::session_start(); |
|
223 | + } |
|
209 | 224 | $ConfigLang = $_SESSION['ConfigLang']; |
210 | 225 | } |
211 | 226 | if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
@@ -240,7 +255,10 @@ discard block |
||
240 | 255 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true) |
241 | 256 | !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true); |
242 | 257 | |
243 | - if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
|
258 | + if (isset($_COOKIE[self::SESSIONID])) |
|
259 | + { |
|
260 | + session_id($_COOKIE[self::SESSIONID]); |
|
261 | + } |
|
244 | 262 | |
245 | 263 | $ok = @session_start(); // suppress notice if session already started or warning in CLI |
246 | 264 | // need to decrypt session, in case session encryption is switched on in header.inc.php |
@@ -453,7 +471,10 @@ discard block |
||
453 | 471 | */ |
454 | 472 | function register_app($appname, $_enable=99, array $setup_info=null) |
455 | 473 | { |
456 | - if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
|
474 | + if (!isset($setup_info)) |
|
475 | + { |
|
476 | + $setup_info = $GLOBALS['setup_info']; |
|
477 | + } |
|
457 | 478 | |
458 | 479 | if(!$appname) |
459 | 480 | { |
@@ -547,7 +568,10 @@ discard block |
||
547 | 568 | */ |
548 | 569 | function update_app($appname, array $setup_info=null) |
549 | 570 | { |
550 | - if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
|
571 | + if (!isset($setup_info)) |
|
572 | + { |
|
573 | + $setup_info = $GLOBALS['setup_info']; |
|
574 | + } |
|
551 | 575 | |
552 | 576 | if(!$appname) |
553 | 577 | { |
@@ -692,7 +716,10 @@ discard block |
||
692 | 716 | { |
693 | 717 | $GLOBALS['settings'] = array(); |
694 | 718 | include_once($file); |
695 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
719 | + if ($GLOBALS['settings']) |
|
720 | + { |
|
721 | + $settings = array_merge($settings,$GLOBALS['settings']); |
|
722 | + } |
|
696 | 723 | } |
697 | 724 | $default = $forced = array(); |
698 | 725 | foreach($settings as $name => $setting) |
@@ -774,52 +801,72 @@ discard block |
||
774 | 801 | |
775 | 802 | for($i=0;$i<count($testa);$i++) |
776 | 803 | { |
777 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
804 | + if($DEBUG) |
|
805 | + { |
|
806 | +echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
778 | 807 | if((int)$testa[$i] < (int)$testb[$i]) |
779 | 808 | { |
780 | - if ($DEBUG) { echo ' yes.'; } |
|
809 | + if ($DEBUG) |
|
810 | + { |
|
811 | +echo ' yes.'; } |
|
781 | 812 | $less++; |
782 | 813 | if($i<3) |
783 | 814 | { |
784 | 815 | /* Ensure that this is definitely smaller */ |
785 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
816 | + if($DEBUG) |
|
817 | + { |
|
818 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
786 | 819 | $less = 5; |
787 | 820 | break; |
788 | 821 | } |
789 | 822 | } |
790 | 823 | elseif((int)$testa[$i] > (int)$testb[$i]) |
791 | 824 | { |
792 | - if($DEBUG) { echo ' no.'; } |
|
825 | + if($DEBUG) |
|
826 | + { |
|
827 | +echo ' no.'; } |
|
793 | 828 | $less--; |
794 | 829 | if($i<2) |
795 | 830 | { |
796 | 831 | /* Ensure that this is definitely greater */ |
797 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
832 | + if($DEBUG) |
|
833 | + { |
|
834 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
798 | 835 | $less = -5; |
799 | 836 | break; |
800 | 837 | } |
801 | 838 | } |
802 | 839 | else |
803 | 840 | { |
804 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
841 | + if($DEBUG) |
|
842 | + { |
|
843 | +echo ' no, they are equal or of different length.'; } |
|
805 | 844 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
806 | 845 | $less = count($testa) < count($testb) ? 1 : 0; |
807 | 846 | } |
808 | 847 | } |
809 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
848 | + if($DEBUG) |
|
849 | + { |
|
850 | +echo '<br>Check value is: "'.$less.'"'; } |
|
810 | 851 | if($less>0) |
811 | 852 | { |
812 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
853 | + if($DEBUG) |
|
854 | + { |
|
855 | +echo '<br>A is less than B'; } |
|
813 | 856 | return True; |
814 | 857 | } |
815 | 858 | elseif($less<0) |
816 | 859 | { |
817 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
860 | + if($DEBUG) |
|
861 | + { |
|
862 | +echo '<br>A is greater than B'; } |
|
818 | 863 | return False; |
819 | 864 | } |
820 | 865 | else |
821 | 866 | { |
822 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
867 | + if($DEBUG) |
|
868 | + { |
|
869 | +echo '<br>A is equal to B'; } |
|
823 | 870 | return False; |
824 | 871 | } |
825 | 872 | } |
@@ -856,51 +903,71 @@ discard block |
||
856 | 903 | |
857 | 904 | for($i=0;$i<count($testa);$i++) |
858 | 905 | { |
859 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
906 | + if($DEBUG) |
|
907 | + { |
|
908 | +echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
860 | 909 | if((int)$testa[$i] > (int)$testb[$i]) |
861 | 910 | { |
862 | - if($DEBUG) { echo ' yes.'; } |
|
911 | + if($DEBUG) |
|
912 | + { |
|
913 | +echo ' yes.'; } |
|
863 | 914 | $less++; |
864 | 915 | if($i<3) |
865 | 916 | { |
866 | 917 | /* Ensure that this is definitely greater */ |
867 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
918 | + if($DEBUG) |
|
919 | + { |
|
920 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
868 | 921 | $less = 5; |
869 | 922 | break; |
870 | 923 | } |
871 | 924 | } |
872 | 925 | elseif((int)$testa[$i] < (int)$testb[$i]) |
873 | 926 | { |
874 | - if($DEBUG) { echo ' no.'; } |
|
927 | + if($DEBUG) |
|
928 | + { |
|
929 | +echo ' no.'; } |
|
875 | 930 | $less--; |
876 | 931 | if($i<2) |
877 | 932 | { |
878 | 933 | /* Ensure that this is definitely smaller */ |
879 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
934 | + if($DEBUG) |
|
935 | + { |
|
936 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
880 | 937 | $less = -5; |
881 | 938 | break; |
882 | 939 | } |
883 | 940 | } |
884 | 941 | else |
885 | 942 | { |
886 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
943 | + if($DEBUG) |
|
944 | + { |
|
945 | +echo ' no, they are equal.'; } |
|
887 | 946 | $less = 0; |
888 | 947 | } |
889 | 948 | } |
890 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
949 | + if($DEBUG) |
|
950 | + { |
|
951 | +echo '<br>Check value is: "'.$less.'"'; } |
|
891 | 952 | if($less>0) |
892 | 953 | { |
893 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
954 | + if($DEBUG) |
|
955 | + { |
|
956 | +echo '<br>A is greater than B'; } |
|
894 | 957 | return True; |
895 | 958 | } |
896 | 959 | elseif($less<0) |
897 | 960 | { |
898 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
961 | + if($DEBUG) |
|
962 | + { |
|
963 | +echo '<br>A is less than B'; } |
|
899 | 964 | return False; |
900 | 965 | } |
901 | 966 | else |
902 | 967 | { |
903 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
968 | + if($DEBUG) |
|
969 | + { |
|
970 | +echo '<br>A is equal to B'; } |
|
904 | 971 | return False; |
905 | 972 | } |
906 | 973 | } |
@@ -937,7 +1004,10 @@ discard block |
||
937 | 1004 | echo "<p><b>".$e->getMessage()."</b></p>\n"; |
938 | 1005 | return false; |
939 | 1006 | } |
940 | - if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
|
1007 | + if (!isset($GLOBALS['egw']->accounts)) |
|
1008 | + { |
|
1009 | + $GLOBALS['egw']->accounts = $this->accounts; |
|
1010 | + } |
|
941 | 1011 | Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
942 | 1012 | } |
943 | 1013 | return true; |
@@ -972,7 +1042,10 @@ discard block |
||
972 | 1042 | |
973 | 1043 | if ($username == 'anonymous') |
974 | 1044 | { |
975 | - if (!isset($this->anonpw)) $this->anonpw = Api\Auth::randomstring(16); |
|
1045 | + if (!isset($this->anonpw)) |
|
1046 | + { |
|
1047 | + $this->anonpw = Api\Auth::randomstring(16); |
|
1048 | + } |
|
976 | 1049 | $passwd = $anonpw = $this->anonpw; |
977 | 1050 | } |
978 | 1051 | |
@@ -1031,11 +1104,17 @@ discard block |
||
1031 | 1104 | 'account_lid' => $username, |
1032 | 1105 | )); |
1033 | 1106 | } |
1034 | - if ($primary_group) // only for users, NOT groups |
|
1107 | + if ($primary_group) |
|
1108 | + { |
|
1109 | + // only for users, NOT groups |
|
1035 | 1110 | { |
1036 | 1111 | $this->set_memberships(array($primary_group_id), $accountid); |
1112 | + } |
|
1037 | 1113 | |
1038 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1114 | + if (!$changepw) |
|
1115 | + { |
|
1116 | + $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1117 | + } |
|
1039 | 1118 | } |
1040 | 1119 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1041 | 1120 | return $accountid; |
@@ -1071,7 +1150,10 @@ discard block |
||
1071 | 1150 | */ |
1072 | 1151 | function accounts_exist() |
1073 | 1152 | { |
1074 | - if (!$this->setup_account_object()) return false; |
|
1153 | + if (!$this->setup_account_object()) |
|
1154 | + { |
|
1155 | + return false; |
|
1156 | + } |
|
1075 | 1157 | |
1076 | 1158 | $this->accounts->search(array( |
1077 | 1159 | 'type' => 'accounts', |
@@ -1154,9 +1236,15 @@ discard block |
||
1154 | 1236 | { |
1155 | 1237 | static $table_names = False; |
1156 | 1238 | |
1157 | - if (!$table_names || $force_refresh) $table_names = $this->db->table_names(); |
|
1239 | + if (!$table_names || $force_refresh) |
|
1240 | + { |
|
1241 | + $table_names = $this->db->table_names(); |
|
1242 | + } |
|
1158 | 1243 | |
1159 | - if (!$table_names) return false; |
|
1244 | + if (!$table_names) |
|
1245 | + { |
|
1246 | + return false; |
|
1247 | + } |
|
1160 | 1248 | |
1161 | 1249 | foreach($table_names as $data) |
1162 | 1250 | { |
@@ -1186,10 +1274,13 @@ discard block |
||
1186 | 1274 | { |
1187 | 1275 | $table = $this->table_exist($tables,$force_refresh); |
1188 | 1276 | |
1189 | - if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
|
1277 | + if ($table && $table != $this->$name) |
|
1278 | + { |
|
1279 | + // only overwrite the default name, if we realy got one (important for new installs) |
|
1190 | 1280 | { |
1191 | 1281 | $this->$name = $table; |
1192 | 1282 | } |
1283 | + } |
|
1193 | 1284 | //echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n"; |
1194 | 1285 | } |
1195 | 1286 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Constructor |
37 | 37 | * |
38 | - * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
|
38 | + * @param string $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
|
39 | 39 | * @param array $arguments =null comand line arguments |
40 | 40 | */ |
41 | 41 | function __construct($sub_command='create',$arguments=null) |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
39 | 39 | * @param array $arguments =null comand line arguments |
40 | 40 | */ |
41 | - function __construct($sub_command='create',$arguments=null) |
|
41 | + function __construct($sub_command = 'create', $arguments = null) |
|
42 | 42 | { |
43 | 43 | if (!is_array($sub_command)) |
44 | 44 | { |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
74 | 74 | * @throws Exception('header.inc.php not found!'); |
75 | 75 | */ |
76 | - protected function exec($check_only=false) |
|
76 | + protected function exec($check_only = false) |
|
77 | 77 | { |
78 | 78 | if ($check_only && $this->remote_id) |
79 | 79 | { |
80 | - return true; // can only check locally |
|
80 | + return true; // can only check locally |
|
81 | 81 | } |
82 | 82 | if (!file_exists($this->header_path) || filesize($this->header_path) < 200) // redirect header in rpms is ~150 byte |
83 | 83 | { |
84 | 84 | if ($this->sub_command != 'create') |
85 | 85 | { |
86 | - throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1); |
|
86 | + throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'), 1); |
|
87 | 87 | } |
88 | 88 | $this->defaults(false); |
89 | 89 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | if ($this->sub_command == 'create') |
93 | 93 | { |
94 | 94 | throw new Api\Exception\WrongUserinput( |
95 | - lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'),20); |
|
95 | + lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'), 20); |
|
96 | 96 | } |
97 | 97 | if ($this->arguments) |
98 | 98 | { |
99 | - list($this->header_admin_password,$this->header_admin_user) = explode(',',$this->arguments[1]); |
|
99 | + list($this->header_admin_password, $this->header_admin_user) = explode(',', $this->arguments[1]); |
|
100 | 100 | } |
101 | - $this->check_setup_auth($this->header_admin_user,$this->header_admin_password); // no domain, we require header access! |
|
101 | + $this->check_setup_auth($this->header_admin_user, $this->header_admin_password); // no domain, we require header access! |
|
102 | 102 | |
103 | 103 | $GLOBALS['egw_info']['server']['server_root'] = EGW_SERVER_ROOT; |
104 | 104 | $GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT; |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | echo '$GLOBALS[egw_info] = '; print_r($GLOBALS['egw_info']); |
126 | 126 | echo '$GLOBALS[egw_domain] = '; print_r($GLOBALS['egw_domain']); |
127 | 127 | } |
128 | - throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ",$errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"),23); |
|
128 | + throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ", $errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"), 23); |
|
129 | 129 | } |
130 | 130 | if ($check_only) |
131 | 131 | { |
132 | 132 | return true; |
133 | 133 | } |
134 | - $header = $this->generate($GLOBALS['egw_info'],$GLOBALS['egw_domain']); |
|
134 | + $header = $this->generate($GLOBALS['egw_info'], $GLOBALS['egw_domain']); |
|
135 | 135 | |
136 | 136 | if ($this->arguments) |
137 | 137 | { |
138 | - echo $header; // for cli, we echo the header |
|
138 | + echo $header; // for cli, we echo the header |
|
139 | 139 | } |
140 | 140 | if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) || |
141 | 141 | function_exists('posix_getuid') && !posix_getuid()) // root has all rights |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | { |
145 | 145 | unlink($this->header_path); |
146 | 146 | } |
147 | - if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header)) |
|
147 | + if (($f = fopen($this->header_path, 'wb')) && fwrite($f, $header)) |
|
148 | 148 | { |
149 | 149 | fclose($f); |
150 | 150 | return lang('header.inc.php successful written.'); |
151 | 151 | } |
152 | 152 | } |
153 | - throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"),24); |
|
153 | + throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"), 24); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param array $args =null |
161 | 161 | * @return mixed |
162 | 162 | */ |
163 | - function __call($method,array $args=null) |
|
163 | + function __call($method, array $args = null) |
|
164 | 164 | { |
165 | - if (method_exists($this->setup_header,$method)) |
|
165 | + if (method_exists($this->setup_header, $method)) |
|
166 | 166 | { |
167 | - return call_user_func_array(array($this->setup_header,$method),$args); |
|
167 | + return call_user_func_array(array($this->setup_header, $method), $args); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -189,21 +189,21 @@ discard block |
||
189 | 189 | '--session-type' => array( |
190 | 190 | 'sessions_type' => array( |
191 | 191 | 'type' => 'egw_info/server/', |
192 | - 'allowed' => array('php'=>'php4','php4'=>'php4','php-restore'=>'php4-restore','php4-restore'=>'php4-restore','db'=>'db'), |
|
192 | + 'allowed' => array('php'=>'php4', 'php4'=>'php4', 'php-restore'=>'php4-restore', 'php4-restore'=>'php4-restore', 'db'=>'db'), |
|
193 | 193 | ), |
194 | 194 | ), |
195 | 195 | '--session-handler' => array( |
196 | 196 | 'session_handler' => array( |
197 | 197 | 'type' => 'egw_info/server/', |
198 | - 'allowed' => array('files'=>'files','memcache'=>'memcache','db'=>'db'), |
|
198 | + 'allowed' => array('files'=>'files', 'memcache'=>'memcache', 'db'=>'db'), |
|
199 | 199 | ), |
200 | 200 | ), |
201 | - '--limit-access' => 'egw_info/server/setup_acl', // name used in setup |
|
202 | - '--setup-acl' => 'egw_info/server/setup_acl', // alias to match the real name |
|
201 | + '--limit-access' => 'egw_info/server/setup_acl', // name used in setup |
|
202 | + '--setup-acl' => 'egw_info/server/setup_acl', // alias to match the real name |
|
203 | 203 | '--mcrypt' => array( |
204 | 204 | 'mcrypt_enabled' => array( |
205 | 205 | 'type' => 'egw_info/server/', |
206 | - 'allowed' => array('on' => true,'off' => false), |
|
206 | + 'allowed' => array('on' => true, 'off' => false), |
|
207 | 207 | ), |
208 | 208 | 'mcrypt_iv' => 'egw_info/server/', |
209 | 209 | 'mcrypt' => 'egw_info/versions/mcrypt', |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | '--domain-selectbox' => array( |
212 | 212 | 'show_domain_selectbox' => array( |
213 | 213 | 'type' => 'egw_info/server/', |
214 | - 'allowed' => array('on' => true,'off' => false), |
|
214 | + 'allowed' => array('on' => true, 'off' => false), |
|
215 | 215 | ), |
216 | 216 | ), |
217 | 217 | '--db-persistent' => array( |
218 | 218 | 'db_persistent' => array( |
219 | 219 | 'type' => 'egw_info/server/', |
220 | - 'allowed' => array('on' => true,'off' => false), |
|
220 | + 'allowed' => array('on' => true, 'off' => false), |
|
221 | 221 | ), |
222 | 222 | ), |
223 | 223 | '--domain' => array( |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | */ |
240 | 240 | private function _parse_properties() |
241 | 241 | { |
242 | - foreach(self::$options as $arg => $option) |
|
242 | + foreach (self::$options as $arg => $option) |
|
243 | 243 | { |
244 | - foreach(is_array($option) ? $option : array($option => $option) as $name => $data) |
|
244 | + foreach (is_array($option) ? $option : array($option => $option) as $name => $data) |
|
245 | 245 | { |
246 | - if (strpos($name,'/') !== false) |
|
246 | + if (strpos($name, '/') !== false) |
|
247 | 247 | { |
248 | - $name = array_pop($parts = explode('/',$name)); |
|
248 | + $name = array_pop($parts = explode('/', $name)); |
|
249 | 249 | } |
250 | 250 | if (isset($this->$name)) |
251 | 251 | { |
252 | - $this->_parse_value($arg,$name,$data,$this->$name); |
|
252 | + $this->_parse_value($arg, $name, $data, $this->$name); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | private function _parse_cli_arguments() |
262 | 262 | { |
263 | 263 | $arguments = $this->arguments; |
264 | - while(($arg = array_shift($arguments))) |
|
264 | + while (($arg = array_shift($arguments))) |
|
265 | 265 | { |
266 | - $values = count($arguments) && substr($arguments[0],0,2) !== '--' ? array_shift($arguments) : 'on'; |
|
266 | + $values = count($arguments) && substr($arguments[0], 0, 2) !== '--' ? array_shift($arguments) : 'on'; |
|
267 | 267 | |
268 | 268 | if ($arg == '--delete-domain') |
269 | 269 | { |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | |
274 | 274 | if (!isset(self::$options[$arg])) |
275 | 275 | { |
276 | - throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90); |
|
276 | + throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | $option = self::$options[$arg]; |
280 | - $vals = !is_array($option) ? array($values) : explode(',',$values); |
|
280 | + $vals = !is_array($option) ? array($values) : explode(',', $values); |
|
281 | 281 | if (!is_array($option)) $option = array($option => $option); |
282 | 282 | $n = 0; |
283 | - foreach($option as $name => $data) |
|
283 | + foreach ($option as $name => $data) |
|
284 | 284 | { |
285 | 285 | if ($n >= count($vals)) break; |
286 | 286 | |
287 | - $this->_parse_value($arg,$name,$data,$vals[$n++]); |
|
287 | + $this->_parse_value($arg, $name, $data, $vals[$n++]); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | if (!isset($GLOBALS['egw_domain'][$domain])) |
300 | 300 | { |
301 | - throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain),92); |
|
301 | + throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!", $domain), 92); |
|
302 | 302 | } |
303 | 303 | unset($GLOBALS['egw_domain'][$domain]); |
304 | 304 | } |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param array/string $data string with type or array containing values for type, allowed |
312 | 312 | * @param mixed $value value to set |
313 | 313 | */ |
314 | - private function _parse_value($arg,$name,$data,$value) |
|
314 | + private function _parse_value($arg, $name, $data, $value) |
|
315 | 315 | { |
316 | - static $domain=null; |
|
316 | + static $domain = null; |
|
317 | 317 | |
318 | 318 | if (!is_array($data)) $data = array('type' => $data); |
319 | 319 | $type = $data['type']; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | if (!isset($data['allowed'][$value])) |
324 | 324 | { |
325 | - throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1,$arg),91); |
|
325 | + throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1, $arg), 91); |
|
326 | 326 | } |
327 | 327 | $value = $data['allowed'][$value]; |
328 | 328 | } |
@@ -331,15 +331,15 @@ discard block |
||
331 | 331 | $domain = $arg == '--domain' && !$value ? 'default' : $value; |
332 | 332 | if ($arg == '--domain' && (!isset($GLOBALS['egw_domain'][$domain]) || $this->sub_command == 'create')) |
333 | 333 | { |
334 | - $GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'],$GLOBALS['egw_info']['server']['header_admin_password']); |
|
334 | + $GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'], $GLOBALS['egw_info']['server']['header_admin_password']); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | elseif ($value !== '') |
338 | 338 | { |
339 | - self::_set_value($GLOBALS,str_replace('@',$domain,$type),$name,$value); |
|
339 | + self::_set_value($GLOBALS, str_replace('@', $domain, $type), $name, $value); |
|
340 | 340 | if ($type == 'egw_info/server/server_root') |
341 | 341 | { |
342 | - self::_set_value($GLOBALS,'egw_info/server/include_root',$name,$value); |
|
342 | + self::_set_value($GLOBALS, 'egw_info/server/include_root', $name, $value); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | * @param string $name additional index to use if $index end with a slash |
353 | 353 | * @param mixed $value value to set |
354 | 354 | */ |
355 | - static private function _set_value(&$arr,$index,$name,$value) |
|
355 | + static private function _set_value(&$arr, $index, $name, $value) |
|
356 | 356 | { |
357 | - if (substr($index,-1) == '/') $index .= $name; |
|
357 | + if (substr($index, -1) == '/') $index .= $name; |
|
358 | 358 | |
359 | - $var =& $arr; |
|
360 | - foreach(explode('/',$index) as $name) |
|
359 | + $var = & $arr; |
|
360 | + foreach (explode('/', $index) as $name) |
|
361 | 361 | { |
362 | - $var =& $var[$name]; |
|
362 | + $var = & $var[$name]; |
|
363 | 363 | } |
364 | - if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
364 | + if (true) $var = strpos($name, 'passw') !== false ? md5($value) : $value; |
|
365 | 365 | } |
366 | 366 | } |
@@ -79,11 +79,14 @@ discard block |
||
79 | 79 | { |
80 | 80 | return true; // can only check locally |
81 | 81 | } |
82 | - if (!file_exists($this->header_path) || filesize($this->header_path) < 200) // redirect header in rpms is ~150 byte |
|
82 | + if (!file_exists($this->header_path) || filesize($this->header_path) < 200) |
|
83 | + { |
|
84 | + // redirect header in rpms is ~150 byte |
|
83 | 85 | { |
84 | 86 | if ($this->sub_command != 'create') |
85 | 87 | { |
86 | 88 | throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1); |
89 | + } |
|
87 | 90 | } |
88 | 91 | $this->defaults(false); |
89 | 92 | } |
@@ -104,10 +107,13 @@ discard block |
||
104 | 107 | $GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT; |
105 | 108 | } |
106 | 109 | |
107 | - if ($this->arguments) // we have command line arguments |
|
110 | + if ($this->arguments) |
|
111 | + { |
|
112 | + // we have command line arguments |
|
108 | 113 | { |
109 | 114 | $this->_parse_cli_arguments(); |
110 | 115 | } |
116 | + } |
|
111 | 117 | elseif ($this->sub_command == 'delete') |
112 | 118 | { |
113 | 119 | self::_delete_domain($this->domain); |
@@ -138,11 +144,14 @@ discard block |
||
138 | 144 | echo $header; // for cli, we echo the header |
139 | 145 | } |
140 | 146 | if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) || |
141 | - function_exists('posix_getuid') && !posix_getuid()) // root has all rights |
|
147 | + function_exists('posix_getuid') && !posix_getuid()) |
|
148 | + { |
|
149 | + // root has all rights |
|
142 | 150 | { |
143 | 151 | if (file_exists($this->header_path) && !is_writable($this->header_path)) |
144 | 152 | { |
145 | 153 | unlink($this->header_path); |
154 | + } |
|
146 | 155 | } |
147 | 156 | if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header)) |
148 | 157 | { |
@@ -278,11 +287,17 @@ discard block |
||
278 | 287 | |
279 | 288 | $option = self::$options[$arg]; |
280 | 289 | $vals = !is_array($option) ? array($values) : explode(',',$values); |
281 | - if (!is_array($option)) $option = array($option => $option); |
|
290 | + if (!is_array($option)) |
|
291 | + { |
|
292 | + $option = array($option => $option); |
|
293 | + } |
|
282 | 294 | $n = 0; |
283 | 295 | foreach($option as $name => $data) |
284 | 296 | { |
285 | - if ($n >= count($vals)) break; |
|
297 | + if ($n >= count($vals)) |
|
298 | + { |
|
299 | + break; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | $this->_parse_value($arg,$name,$data,$vals[$n++]); |
288 | 303 | } |
@@ -315,7 +330,10 @@ discard block |
||
315 | 330 | { |
316 | 331 | static $domain=null; |
317 | 332 | |
318 | - if (!is_array($data)) $data = array('type' => $data); |
|
333 | + if (!is_array($data)) |
|
334 | + { |
|
335 | + $data = array('type' => $data); |
|
336 | + } |
|
319 | 337 | $type = $data['type']; |
320 | 338 | |
321 | 339 | if (isset($data['allowed'])) |
@@ -354,13 +372,19 @@ discard block |
||
354 | 372 | */ |
355 | 373 | static private function _set_value(&$arr,$index,$name,$value) |
356 | 374 | { |
357 | - if (substr($index,-1) == '/') $index .= $name; |
|
375 | + if (substr($index,-1) == '/') |
|
376 | + { |
|
377 | + $index .= $name; |
|
378 | + } |
|
358 | 379 | |
359 | 380 | $var =& $arr; |
360 | 381 | foreach(explode('/',$index) as $name) |
361 | 382 | { |
362 | 383 | $var =& $var[$name]; |
363 | 384 | } |
364 | - if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
385 | + if (true) |
|
386 | + { |
|
387 | + $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
388 | + } |
|
365 | 389 | } |
366 | 390 | } |
@@ -19,9 +19,8 @@ |
||
19 | 19 | * Constructor |
20 | 20 | * |
21 | 21 | * @param string $domain string with domain-name or array with all arguments |
22 | - * @param string $config_user=null user to config the domain (or header_admin_user) |
|
23 | - * @param string $config_passwd=null pw of above user |
|
24 | - * @param boolean $verbose=false if true, echos out some status information during the run |
|
22 | + * @param string $config_user user to config the domain (or header_admin_user) |
|
23 | + * @param string $config_passwd pw of above user |
|
25 | 24 | */ |
26 | 25 | function __construct($domain,$config_user=null,$config_passwd=null) |
27 | 26 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $config_passwd=null pw of above user |
24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
25 | 25 | */ |
26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($domain)) |
29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 46 | * @throws Exception('header.inc.php not found!'); |
47 | 47 | */ |
48 | - protected function exec($check_only=false) |
|
48 | + protected function exec($check_only = false) |
|
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
51 | 51 | |
52 | 52 | // instanciate setup object and check authorisation |
53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
54 | 54 | |
55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
56 | 56 | |
57 | 57 | global $setup_info; |
58 | - foreach($setup_info as $appname => $info) |
|
58 | + foreach ($setup_info as $appname => $info) |
|
59 | 59 | { |
60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
61 | 61 | } |
@@ -47,7 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function exec($check_only=false) |
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) |
|
51 | + { |
|
52 | + return true; |
|
53 | + } |
|
54 | + // nothing to check, no arguments ... |
|
51 | 55 | |
52 | 56 | // instanciate setup object and check authorisation |
53 | 57 | $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
@@ -57,7 +61,10 @@ discard block |
||
57 | 61 | global $setup_info; |
58 | 62 | foreach($setup_info as $appname => $info) |
59 | 63 | { |
60 | - if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
|
64 | + if ($info['currentver']) |
|
65 | + { |
|
66 | + self::$egw_setup->register_hooks($appname); |
|
67 | + } |
|
61 | 68 | } |
62 | 69 | $this->restore_db(); |
63 | 70 |
@@ -936,9 +936,6 @@ |
||
936 | 936 | * |
937 | 937 | * Uses $this->ldap_host, $this->ldap_admin and $this->ldap_admin_pw to connect. |
938 | 938 | * |
939 | - * @param string $this->object_class ='qmailUser' |
|
940 | - * @param string $this->mbox_attr ='mailmessagestore' lowercase!!! |
|
941 | - * @param string $this->mail_login_type ='email' 'email', 'vmailmgr', 'standard' or 'uidNumber' |
|
942 | 939 | * @return string with success message N entries modified |
943 | 940 | * @throws Api\Exception if dn not found, not listable or delete fails |
944 | 941 | */ |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @param string $ldap_encryption_type ='des' |
85 | 85 | * @param boolean $truncate_egw_accounts =false truncate accounts table before migration to SQL |
86 | 86 | */ |
87 | - function __construct($domain,$ldap_host=null,$ldap_suffix=null,$ldap_admin=null,$ldap_admin_pw=null, |
|
88 | - $ldap_base=null,$ldap_root_dn=null,$ldap_root_pw=null,$ldap_context=null,$ldap_search_filter=null, |
|
89 | - $ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des',$truncate_egw_accounts=false) |
|
87 | + function __construct($domain, $ldap_host = null, $ldap_suffix = null, $ldap_admin = null, $ldap_admin_pw = null, |
|
88 | + $ldap_base = null, $ldap_root_dn = null, $ldap_root_pw = null, $ldap_context = null, $ldap_search_filter = null, |
|
89 | + $ldap_group_context = null, $sub_command = 'create_ldap', $ldap_encryption_type = 'des', $truncate_egw_accounts = false) |
|
90 | 90 | { |
91 | 91 | if (!is_array($domain)) |
92 | 92 | { |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
120 | 120 | * @throws Exception('header.inc.php not found!'); |
121 | 121 | */ |
122 | - protected function exec($check_only=false) |
|
122 | + protected function exec($check_only = false) |
|
123 | 123 | { |
124 | - if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain)) |
|
124 | + if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain)) |
|
125 | 125 | { |
126 | - throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain)); |
|
126 | + throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!", $this->domain)); |
|
127 | 127 | } |
128 | 128 | if ($this->remote_id && $check_only && !in_array($this->sub_command, array('set_mailbox', 'sid2uidnumber', 'copy2ad'))) |
129 | 129 | { |
130 | - return true; // further checks can only done locally |
|
130 | + return true; // further checks can only done locally |
|
131 | 131 | } |
132 | 132 | $this->_merge_defaults(); |
133 | 133 | //_debug_array($this->as_array()); |
134 | 134 | |
135 | - switch($this->sub_command) |
|
135 | + switch ($this->sub_command) |
|
136 | 136 | { |
137 | 137 | case 'test_ldap_root': |
138 | - $msg = $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
138 | + $msg = $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
139 | 139 | break; |
140 | 140 | case 'test_ldap': |
141 | 141 | $msg = $this->connect(); |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param boolean $check_only =false true: only connect and output necessary commands |
182 | 182 | */ |
183 | - private function sid2uidnumber($check_only=false) |
|
183 | + private function sid2uidnumber($check_only = false) |
|
184 | 184 | { |
185 | 185 | $msg = array(); |
186 | 186 | $this->connect(); |
187 | 187 | |
188 | 188 | // check if base does exist |
189 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
189 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
190 | 190 | { |
191 | - throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
191 | + throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
192 | 192 | } |
193 | 193 | |
194 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
195 | - $search='(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))', |
|
196 | - array('uidNumber','gidNumber','uid','cn', 'objectClass',self::sambaSID))) || |
|
194 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
195 | + $search = '(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))', |
|
196 | + array('uidNumber', 'gidNumber', 'uid', 'cn', 'objectClass', self::sambaSID))) || |
|
197 | 197 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
198 | 198 | { |
199 | - throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search)); |
|
199 | + throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search)); |
|
200 | 200 | } |
201 | 201 | $change = $accounts = array(); |
202 | 202 | $cmd_change_account_id = 'admin/admin-cli.php --change-account-id <admin>@<domain>,<adminpw>'; |
203 | 203 | $change_account_id = ''; |
204 | - foreach($entries as $key => $entry) |
|
204 | + foreach ($entries as $key => $entry) |
|
205 | 205 | { |
206 | 206 | if ($key === 'count') continue; |
207 | 207 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // now change them in LDAP |
238 | 238 | $changed = 0; |
239 | - foreach($accounts as $dn => $account) |
|
239 | + foreach ($accounts as $dn => $account) |
|
240 | 240 | { |
241 | 241 | $modify = array(); |
242 | 242 | if (!empty($account['uidnumber']) && isset($change[$account['uidnumber']])) |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if (!$check_only && $modify && !ldap_modify($this->test_ldap->ds, $dn, $modify)) |
251 | 251 | { |
252 | 252 | throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds). |
253 | - "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
|
253 | + "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
|
254 | 254 | } |
255 | 255 | if ($modify) ++$changed; |
256 | 256 | } |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param boolean $check_only =false true: only connect and output necessary commands |
267 | 267 | */ |
268 | - private function copy2ad($check_only=false) |
|
268 | + private function copy2ad($check_only = false) |
|
269 | 269 | { |
270 | 270 | $msg = array(); |
271 | 271 | $attrs = $rename = array(); |
272 | - foreach(explode(',', $this->attributes) as $attr) |
|
272 | + foreach (explode(',', $this->attributes) as $attr) |
|
273 | 273 | { |
274 | - if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson |
|
274 | + if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson |
|
275 | 275 | strpos($attr, '=') === false) |
276 | 276 | { |
277 | 277 | $attrs[] = $attr; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $ignore_attr = array_flip(array('dn', 'objectclass', 'cn', 'userpassword')); |
287 | 287 | if (!in_array('uid', $attrs)) |
288 | 288 | { |
289 | - $attrs[] = 'uid'; // need to match account |
|
289 | + $attrs[] = 'uid'; // need to match account |
|
290 | 290 | $ignore_attr['uid'] = true; |
291 | 291 | } |
292 | 292 | // connect to destination ads |
@@ -295,9 +295,8 @@ discard block |
||
295 | 295 | $this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain)); |
296 | 296 | } |
297 | 297 | if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator'; |
298 | - $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : |
|
299 | - 'CN='.$this->ads_admin_user.','.$this->ads_context; |
|
300 | - switch($this->ads_connection) |
|
298 | + $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : 'CN='.$this->ads_admin_user.','.$this->ads_context; |
|
299 | + switch ($this->ads_connection) |
|
301 | 300 | { |
302 | 301 | case 'ssl': |
303 | 302 | $url = 'ldaps://'.$this->ads_host.'/'; |
@@ -315,28 +314,27 @@ discard block |
||
315 | 314 | // check if ads base does exist |
316 | 315 | if (!@ldap_read($ads->ds, $this->ads_context, 'objectClass=*')) |
317 | 316 | { |
318 | - throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!',$this->ads_context)); |
|
317 | + throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!', $this->ads_context)); |
|
319 | 318 | } |
320 | 319 | |
321 | 320 | // connect to source ldap |
322 | 321 | $this->connect(); |
323 | 322 | |
324 | 323 | // check if ldap base does exist |
325 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
324 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
326 | 325 | { |
327 | - throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
326 | + throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
328 | 327 | } |
329 | 328 | |
330 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
331 | - $search = $this->no_sid_check ? '(objectClass=posixAccount)' : |
|
332 | - '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) || |
|
329 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
330 | + $search = $this->no_sid_check ? '(objectClass=posixAccount)' : '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) || |
|
333 | 331 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
334 | 332 | { |
335 | - throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search)); |
|
333 | + throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search)); |
|
336 | 334 | } |
337 | 335 | $changed = 0; |
338 | 336 | $utc_diff = null; |
339 | - foreach($entries as $key => $entry) |
|
337 | + foreach ($entries as $key => $entry) |
|
340 | 338 | { |
341 | 339 | if ($key === 'count') continue; |
342 | 340 | |
@@ -345,7 +343,7 @@ discard block |
||
345 | 343 | $entry = array_diff_key($entry_arr, $ignore_attr); |
346 | 344 | |
347 | 345 | if (!($sr = ldap_search($ads->ds, $this->ads_context, |
348 | - $search='(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) || |
|
346 | + $search = '(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) || |
|
349 | 347 | !($dest = ldap_get_entries($ads->ds, $sr))) |
350 | 348 | { |
351 | 349 | $msg[] = lang('User "%1" not found!', $uid); |
@@ -365,11 +363,11 @@ discard block |
||
365 | 363 | { |
366 | 364 | if (is_null($utc_diff)) $utc_diff = date('Z'); |
367 | 365 | $entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime( |
368 | - $entry['shadowexpire']*24*3600+$utc_diff); // ldap time to unixTime |
|
366 | + $entry['shadowexpire'] * 24 * 3600 + $utc_diff); // ldap time to unixTime |
|
369 | 367 | } |
370 | 368 | } |
371 | 369 | $update = array(); |
372 | - foreach($entry as $attr => $value) |
|
370 | + foreach ($entry as $attr => $value) |
|
373 | 371 | { |
374 | 372 | if ($value || $attr === '') |
375 | 373 | { |
@@ -379,14 +377,14 @@ discard block |
||
379 | 377 | { |
380 | 378 | list($prefix, $to) = explode('}', substr($to, 1)); |
381 | 379 | } |
382 | - foreach((array)$value as $val) |
|
380 | + foreach ((array)$value as $val) |
|
383 | 381 | { |
384 | 382 | if (isset($update[$to])) |
385 | 383 | { |
386 | 384 | if (!is_array($update[$to])) $update[$to] = array($update[$to]); |
387 | 385 | // we need to check (caseinsensitive) if value already exists in set |
388 | 386 | // as AD chokes on doublicate values "Type or value exists" |
389 | - foreach($update[$to] as $v) |
|
387 | + foreach ($update[$to] as $v) |
|
390 | 388 | { |
391 | 389 | if (!strcasecmp($v, $prefix.$val)) continue 2; |
392 | 390 | } |
@@ -418,7 +416,7 @@ discard block |
||
418 | 416 | if ($check_only) return lang("%1 accounts to copy found.", count($entries)); |
419 | 417 | |
420 | 418 | return "Copied data of $changed accounts from LDAP to AD ". |
421 | - (count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : ''); |
|
419 | + (count($msg) > $changed ? ' ('.(count($msg) - $changed).' errors!)' : ''); |
|
422 | 420 | } |
423 | 421 | |
424 | 422 | /** |
@@ -461,9 +459,9 @@ discard block |
||
461 | 459 | $accounts_created = $groups_created = $errors = $egw_info_set = 0; |
462 | 460 | $emailadmin_src = $ldap_class = null; |
463 | 461 | $target = strtoupper($to); |
464 | - foreach($accounts as $account_id => $account) |
|
462 | + foreach ($accounts as $account_id => $account) |
|
465 | 463 | { |
466 | - if (isset($this->only) && !in_array($account_id,$this->only)) |
|
464 | + if (isset($this->only) && !in_array($account_id, $this->only)) |
|
467 | 465 | { |
468 | 466 | continue; |
469 | 467 | } |
@@ -483,12 +481,12 @@ discard block |
||
483 | 481 | { |
484 | 482 | if (!($sql_account = $accounts_obj->read($account_id))) |
485 | 483 | { |
486 | - $msg[] = lang('%1 does NOT exist in %2.',$what,$target); |
|
484 | + $msg[] = lang('%1 does NOT exist in %2.', $what, $target); |
|
487 | 485 | $errors++; |
488 | 486 | } |
489 | - elseif(empty($account['account_pwd'])) |
|
487 | + elseif (empty($account['account_pwd'])) |
|
490 | 488 | { |
491 | - $msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!',$what); |
|
489 | + $msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!', $what); |
|
492 | 490 | $errors++; |
493 | 491 | } |
494 | 492 | else |
@@ -497,12 +495,12 @@ discard block |
||
497 | 495 | |
498 | 496 | if (!$accounts_obj->save($sql_account)) |
499 | 497 | { |
500 | - $msg[] = lang('Update of %1 in %2 failed !!!',$what,$target); |
|
498 | + $msg[] = lang('Update of %1 in %2 failed !!!', $what, $target); |
|
501 | 499 | $errors++; |
502 | 500 | } |
503 | 501 | else |
504 | 502 | { |
505 | - $msg[] = lang('%1 password set in %2.',$what,$target); |
|
503 | + $msg[] = lang('%1 password set in %2.', $what, $target); |
|
506 | 504 | $accounts_created++; |
507 | 505 | } |
508 | 506 | } |
@@ -513,7 +511,7 @@ discard block |
||
513 | 511 | { |
514 | 512 | if ($accounts_obj->exists($account_id)) |
515 | 513 | { |
516 | - $msg[] = lang('%1 already exists in %2.',$what,$target); |
|
514 | + $msg[] = lang('%1 already exists in %2.', $what, $target); |
|
517 | 515 | $errors++; |
518 | 516 | continue; |
519 | 517 | } |
@@ -521,7 +519,7 @@ discard block |
||
521 | 519 | { |
522 | 520 | if ($GLOBALS['egw_info']['server']['ldap_extra_attributes']) |
523 | 521 | { |
524 | - $account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'] . '/' . $account['account_lid']; |
|
522 | + $account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'].'/'.$account['account_lid']; |
|
525 | 523 | $account['loginshell'] = $GLOBALS['egw_info']['server']['ldap_account_shell']; |
526 | 524 | } |
527 | 525 | $account['account_passwd'] = self::hash_sql2ldap($account['account_pwd']); |
@@ -534,12 +532,12 @@ discard block |
||
534 | 532 | |
535 | 533 | if (!$accounts_obj->save($account)) |
536 | 534 | { |
537 | - $msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target); |
|
535 | + $msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target); |
|
538 | 536 | $errors++; |
539 | 537 | continue; |
540 | 538 | } |
541 | - $accounts_obj->set_memberships($account['memberships'],$account_id); |
|
542 | - $msg[] = lang('%1 created in %2.',$what,$target); |
|
539 | + $accounts_obj->set_memberships($account['memberships'], $account_id); |
|
540 | + $msg[] = lang('%1 created in %2.', $what, $target); |
|
543 | 541 | $accounts_created++; |
544 | 542 | |
545 | 543 | // check if we need to migrate mail-account |
@@ -548,7 +546,7 @@ discard block |
||
548 | 546 | $ldap_class = false; |
549 | 547 | $ldap = new ldap(); |
550 | 548 | $ldap->ldapConnect(); |
551 | - foreach(array( // todo: have these enumerated by emailadmin ... |
|
549 | + foreach (array( // todo: have these enumerated by emailadmin ... |
|
552 | 550 | 'qmailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Oldqmailuser', |
553 | 551 | 'dbMailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Dbmailuser', |
554 | 552 | // nothing to migrate for inetOrgPerson ... |
@@ -595,7 +593,7 @@ discard block |
||
595 | 593 | // setting up egw_info array with new ldap information, so hook can use Api\Ldap::ldapConnect() |
596 | 594 | if (!$egw_info_set++) |
597 | 595 | { |
598 | - foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name) |
|
596 | + foreach (array('ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', 'ldap_encryptin_type', 'mail_suffix', 'mail_login_type') as $name) |
|
599 | 597 | { |
600 | 598 | if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name; |
601 | 599 | } |
@@ -609,12 +607,12 @@ discard block |
||
609 | 607 | { |
610 | 608 | Api\Hooks::process($account, array(), true); |
611 | 609 | } |
612 | - elseif(is_callable($this->add_account_hook)) |
|
610 | + elseif (is_callable($this->add_account_hook)) |
|
613 | 611 | { |
614 | - call_user_func($this->add_account_hook,$account); |
|
612 | + call_user_func($this->add_account_hook, $account); |
|
615 | 613 | } |
616 | 614 | } |
617 | - catch(Exception $e) |
|
615 | + catch (Exception $e) |
|
618 | 616 | { |
619 | 617 | $msg[] = $e->getMessage(); |
620 | 618 | $errors++; |
@@ -628,38 +626,38 @@ discard block |
||
628 | 626 | { |
629 | 627 | if (!$accounts_obj->save($account)) |
630 | 628 | { |
631 | - $msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target); |
|
629 | + $msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target); |
|
632 | 630 | ++$errors; |
633 | 631 | continue; |
634 | 632 | } |
635 | - $msg[] = lang('%1 created in %2.',$what,$target); |
|
633 | + $msg[] = lang('%1 created in %2.', $what, $target); |
|
636 | 634 | $groups_created++; |
637 | 635 | } |
638 | 636 | else |
639 | 637 | { |
640 | - $msg[] = lang('%1 already exists in %2.',$what,$target); |
|
638 | + $msg[] = lang('%1 already exists in %2.', $what, $target); |
|
641 | 639 | $errors++; |
642 | 640 | |
643 | 641 | if ($accounts_obj->id2name($account_id) != $account['account_lid']) |
644 | 642 | { |
645 | - $msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!",$account['account_lid'],$account_id); |
|
643 | + $msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!", $account['account_lid'], $account_id); |
|
646 | 644 | ++$errors; |
647 | - continue; // different group under that gidnumber! |
|
645 | + continue; // different group under that gidnumber! |
|
648 | 646 | } |
649 | 647 | } |
650 | 648 | // now saving / updating the memberships |
651 | - $accounts_obj->set_members($account['members'],$account_id); |
|
649 | + $accounts_obj->set_members($account['members'], $account_id); |
|
652 | 650 | } |
653 | 651 | } |
654 | 652 | if ($passwords2sql) |
655 | 653 | { |
656 | - return lang('%1 passwords updated, %3 errors',$accounts_created,$groups_created,$errors). |
|
657 | - ($errors || $this->verbose ? "\n- ".implode("\n- ",$msg) : ''); |
|
654 | + return lang('%1 passwords updated, %3 errors', $accounts_created, $groups_created, $errors). |
|
655 | + ($errors || $this->verbose ? "\n- ".implode("\n- ", $msg) : ''); |
|
658 | 656 | } |
659 | 657 | // migrate addressbook data |
660 | - $GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup! |
|
658 | + $GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup! |
|
661 | 659 | $addressbook = new Api\Contacts\Storage(); |
662 | - foreach($this->as_array() as $name => $value) |
|
660 | + foreach ($this->as_array() as $name => $value) |
|
663 | 661 | { |
664 | 662 | if (substr($name, 5) == 'ldap_') |
665 | 663 | { |
@@ -672,8 +670,8 @@ discard block |
||
672 | 670 | |
673 | 671 | $this->restore_db(); |
674 | 672 | |
675 | - return lang('%1 users and %2 groups created, %3 errors',$accounts_created,$groups_created,$errors). |
|
676 | - ($errors || $this->verbose ? "\n- ".implode("\n- ",$msgs) : ''); |
|
673 | + return lang('%1 users and %2 groups created, %3 errors', $accounts_created, $groups_created, $errors). |
|
674 | + ($errors || $this->verbose ? "\n- ".implode("\n- ", $msgs) : ''); |
|
677 | 675 | } |
678 | 676 | |
679 | 677 | /** |
@@ -687,22 +685,22 @@ discard block |
||
687 | 685 | if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5'; |
688 | 686 | |
689 | 687 | $matches = null; |
690 | - if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches)) |
|
688 | + if (preg_match('/^\\{(.*)\\}(.*)$/', $hash, $matches)) |
|
691 | 689 | { |
692 | - list(,$type,$hash) = $matches; |
|
690 | + list(,$type, $hash) = $matches; |
|
693 | 691 | } |
694 | - elseif (preg_match('/^[0-9a-f]{32}$/',$hash)) |
|
692 | + elseif (preg_match('/^[0-9a-f]{32}$/', $hash)) |
|
695 | 693 | { |
696 | 694 | $type = 'md5'; |
697 | 695 | } |
698 | - switch(strtolower($type)) |
|
696 | + switch (strtolower($type)) |
|
699 | 697 | { |
700 | 698 | case 'plain': |
701 | 699 | // ldap stores plaintext passwords without {plain} prefix |
702 | 700 | break; |
703 | 701 | |
704 | 702 | case 'md5': |
705 | - $hash = base64_encode(pack("H*",$hash)); |
|
703 | + $hash = base64_encode(pack("H*", $hash)); |
|
706 | 704 | // fall through |
707 | 705 | default: |
708 | 706 | $hash = '{'.strtoupper($type).'}'.$hash; |
@@ -732,14 +730,14 @@ discard block |
||
732 | 730 | * @param string $type ='both' |
733 | 731 | * @return array |
734 | 732 | */ |
735 | - public function accounts($from='ldap', $type='both') |
|
733 | + public function accounts($from = 'ldap', $type = 'both') |
|
736 | 734 | { |
737 | 735 | $accounts_obj = $this->accounts_obj($from); |
738 | 736 | //error_log(__METHOD__."(from_ldap=".array2string($from_ldap).') get_class(accounts_obj->backend)='.get_class($accounts_obj->backend)); |
739 | 737 | |
740 | 738 | $accounts = $accounts_obj->search(array('type' => $type, 'objectclass' => true, 'active' => false)); |
741 | 739 | |
742 | - foreach($accounts as $account_id => &$account) |
|
740 | + foreach ($accounts as $account_id => &$account) |
|
743 | 741 | { |
744 | 742 | if ($account_id != $account['account_id']) // not all backends have as key the account_id |
745 | 743 | { |
@@ -750,11 +748,11 @@ discard block |
||
750 | 748 | |
751 | 749 | if ($account['account_type'] == 'g') |
752 | 750 | { |
753 | - $account['members'] = $accounts_obj->members($account_id,true); |
|
751 | + $account['members'] = $accounts_obj->members($account_id, true); |
|
754 | 752 | } |
755 | 753 | else |
756 | 754 | { |
757 | - $account['memberships'] = $accounts_obj->memberships($account_id,true); |
|
755 | + $account['memberships'] = $accounts_obj->memberships($account_id, true); |
|
758 | 756 | } |
759 | 757 | } |
760 | 758 | Api\Accounts::cache_invalidate(); |
@@ -770,13 +768,13 @@ discard block |
||
770 | 768 | */ |
771 | 769 | private function accounts_obj($type) |
772 | 770 | { |
773 | - static $enviroment_setup=null; |
|
771 | + static $enviroment_setup = null; |
|
774 | 772 | if (!$enviroment_setup) |
775 | 773 | { |
776 | 774 | parent::_setup_enviroment($this->domain); |
777 | 775 | $enviroment_setup = true; |
778 | 776 | } |
779 | - if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
777 | + if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
780 | 778 | |
781 | 779 | // otherwise search does NOT work, as accounts_sql uses addressbook_bo for it |
782 | 780 | $GLOBALS['egw_info']['server']['account_repository'] = $type; |
@@ -785,8 +783,8 @@ discard block |
||
785 | 783 | array( |
786 | 784 | 'account_repository' => $GLOBALS['egw_info']['server']['account_repository'], |
787 | 785 | ) + $this->as_array()) || |
788 | - !is_a(self::$egw_setup->accounts,'accounts') || |
|
789 | - !is_a(self::$egw_setup->accounts->backend,'accounts_'.$type)) |
|
786 | + !is_a(self::$egw_setup->accounts, 'accounts') || |
|
787 | + !is_a(self::$egw_setup->accounts->backend, 'accounts_'.$type)) |
|
790 | 788 | { |
791 | 789 | throw new Exception(lang("Can NOT instancate accounts object for %1", strtoupper($type))); |
792 | 790 | } |
@@ -801,7 +799,7 @@ discard block |
||
801 | 799 | * @param string $host =null default $this->ldap_host, hostname, ip or ldap-url |
802 | 800 | * @throws Api\Exception\WrongUserinput Can not connect to ldap ... |
803 | 801 | */ |
804 | - private function connect($dn=null,$pw=null,$host=null) |
|
802 | + private function connect($dn = null, $pw = null, $host = null) |
|
805 | 803 | { |
806 | 804 | if (is_null($dn)) $dn = $this->ldap_root_dn; |
807 | 805 | if (is_null($pw)) $pw = $this->ldap_root_pw; |
@@ -818,9 +816,9 @@ discard block |
||
818 | 816 | catch (Api\Exception\NoPermission $e) { |
819 | 817 | _egw_log_exception($e); |
820 | 818 | throw new Api\Exception\WrongUserinput(lang('Can not connect to LDAP server on host %1 using DN %2!', |
821 | - $host,$dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : '')); |
|
819 | + $host, $dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : '')); |
|
822 | 820 | } |
823 | - return lang('Successful connected to LDAP server on %1 using DN %2.',$this->ldap_host,$dn); |
|
821 | + return lang('Successful connected to LDAP server on %1 using DN %2.', $this->ldap_host, $dn); |
|
824 | 822 | } |
825 | 823 | |
826 | 824 | /** |
@@ -833,16 +831,16 @@ discard block |
||
833 | 831 | { |
834 | 832 | $this->connect(); |
835 | 833 | |
836 | - $sr = ldap_list($this->test_ldap->ds,$this->ldap_context,'ObjectClass=posixAccount',array('dn','shadowExpire')); |
|
834 | + $sr = ldap_list($this->test_ldap->ds, $this->ldap_context, 'ObjectClass=posixAccount', array('dn', 'shadowExpire')); |
|
837 | 835 | if (!($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
838 | 836 | { |
839 | - throw new Api\Exception('Error listing "dn=%1"!',$this->ldap_context); |
|
837 | + throw new Api\Exception('Error listing "dn=%1"!', $this->ldap_context); |
|
840 | 838 | } |
841 | 839 | $num = 0; |
842 | - foreach($entries as $n => $entry) |
|
840 | + foreach ($entries as $n => $entry) |
|
843 | 841 | { |
844 | 842 | if ($n === 'count') continue; |
845 | - if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue; |
|
843 | + if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0] * 24 * 3600 < time()) continue; |
|
846 | 844 | ++$num; |
847 | 845 | } |
848 | 846 | return $num; |
@@ -856,23 +854,23 @@ discard block |
||
856 | 854 | */ |
857 | 855 | private function create() |
858 | 856 | { |
859 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
857 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
860 | 858 | |
861 | - foreach(array( |
|
859 | + foreach (array( |
|
862 | 860 | $this->ldap_base => array(), |
863 | 861 | $this->ldap_context => array(), |
864 | 862 | $this->ldap_group_context => array(), |
865 | - $this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw,'ssha')), |
|
863 | + $this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw, 'ssha')), |
|
866 | 864 | ) as $dn => $extra) |
867 | 865 | { |
868 | - if (!$this->_create_node($dn,$extra,$this->check_only) && $dn == $this->ldap_root_dn) |
|
866 | + if (!$this->_create_node($dn, $extra, $this->check_only) && $dn == $this->ldap_root_dn) |
|
869 | 867 | { |
870 | 868 | // ldap_root already existed, lets check the pw is correct |
871 | 869 | $this->connect(); |
872 | 870 | } |
873 | 871 | } |
874 | 872 | return lang('Successful connected to LDAP server on %1 and created/checked required structur %2.', |
875 | - $this->ldap_host,$this->ldap_base); |
|
873 | + $this->ldap_host, $this->ldap_base); |
|
876 | 874 | } |
877 | 875 | |
878 | 876 | /** |
@@ -883,25 +881,25 @@ discard block |
||
883 | 881 | */ |
884 | 882 | private function delete_base() |
885 | 883 | { |
886 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
884 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
887 | 885 | |
888 | 886 | // if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local) |
889 | 887 | if (empty($this->ldap_base) && $this->ldap_context) |
890 | 888 | { |
891 | - list(,$this->ldap_base) = explode(',',$this->ldap_context,2); |
|
889 | + list(,$this->ldap_base) = explode(',', $this->ldap_context, 2); |
|
892 | 890 | } |
893 | 891 | // some precausion to not delete whole ldap tree! |
894 | - if (count(explode(',',$this->ldap_base)) < 2) |
|
892 | + if (count(explode(',', $this->ldap_base)) < 2) |
|
895 | 893 | { |
896 | - throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!',$this->ldap_base)); |
|
894 | + throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!', $this->ldap_base)); |
|
897 | 895 | } |
898 | 896 | // check if base does exist |
899 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
897 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
900 | 898 | { |
901 | - throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
899 | + throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
902 | 900 | } |
903 | 901 | return lang('LDAP dn="%1" with %2 entries deleted.', |
904 | - $this->ldap_base,$this->rdelete($this->ldap_base)); |
|
902 | + $this->ldap_base, $this->rdelete($this->ldap_base)); |
|
905 | 903 | } |
906 | 904 | |
907 | 905 | /** |
@@ -913,20 +911,20 @@ discard block |
||
913 | 911 | */ |
914 | 912 | private function rdelete($dn) |
915 | 913 | { |
916 | - if (!($sr = ldap_list($this->test_ldap->ds,$dn,'ObjectClass=*',array(''))) || |
|
914 | + if (!($sr = ldap_list($this->test_ldap->ds, $dn, 'ObjectClass=*', array(''))) || |
|
917 | 915 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
918 | 916 | { |
919 | - throw new Api\Exception(lang('Error listing "dn=%1"!',$dn)); |
|
917 | + throw new Api\Exception(lang('Error listing "dn=%1"!', $dn)); |
|
920 | 918 | } |
921 | 919 | $deleted = 0; |
922 | - foreach($entries as $n => $entry) |
|
920 | + foreach ($entries as $n => $entry) |
|
923 | 921 | { |
924 | 922 | if ($n === 'count') continue; |
925 | 923 | $deleted += $this->rdelete($entry['dn']); |
926 | 924 | } |
927 | - if (!ldap_delete($this->test_ldap->ds,$dn)) |
|
925 | + if (!ldap_delete($this->test_ldap->ds, $dn)) |
|
928 | 926 | { |
929 | - throw new Api\Exception(lang('Error deleting "dn=%1"!',$dn)); |
|
927 | + throw new Api\Exception(lang('Error deleting "dn=%1"!', $dn)); |
|
930 | 928 | } |
931 | 929 | return ++$deleted; |
932 | 930 | } |
@@ -942,32 +940,32 @@ discard block |
||
942 | 940 | * @return string with success message N entries modified |
943 | 941 | * @throws Api\Exception if dn not found, not listable or delete fails |
944 | 942 | */ |
945 | - private function set_mailbox($check_only=false) |
|
943 | + private function set_mailbox($check_only = false) |
|
946 | 944 | { |
947 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
945 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
948 | 946 | |
949 | 947 | // if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local) |
950 | 948 | if (empty($this->ldap_base) && $this->ldap_context) |
951 | 949 | { |
952 | - list(,$this->ldap_base) = explode(',',$this->ldap_context,2); |
|
950 | + list(,$this->ldap_base) = explode(',', $this->ldap_context, 2); |
|
953 | 951 | } |
954 | 952 | // check if base does exist |
955 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
953 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
956 | 954 | { |
957 | - throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
955 | + throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
958 | 956 | } |
959 | 957 | $object_class = $this->object_class ? $this->object_class : 'qmailUser'; |
960 | 958 | $mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore'; |
961 | 959 | $mail_login_type = $this->mail_login_type ? $this->mail_login_type : 'email'; |
962 | 960 | |
963 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
964 | - 'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) || |
|
961 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
962 | + 'objectClass='.$object_class, array('mail', 'uidNumber', 'uid', $mbox_attr))) || |
|
965 | 963 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
966 | 964 | { |
967 | - throw new Api\Exception(lang('Error listing "dn=%1"!',$this->ldap_base)); |
|
965 | + throw new Api\Exception(lang('Error listing "dn=%1"!', $this->ldap_base)); |
|
968 | 966 | } |
969 | 967 | $modified = 0; |
970 | - foreach($entries as $n => $entry) |
|
968 | + foreach ($entries as $n => $entry) |
|
971 | 969 | { |
972 | 970 | if ($n === 'count') continue; |
973 | 971 | |
@@ -975,21 +973,20 @@ discard block |
||
975 | 973 | 'account_id' => $entry['uidnumber'][0], |
976 | 974 | 'account_lid' => $entry['uid'][0], |
977 | 975 | 'account_email' => $entry['mail'][0], |
978 | - ),$this->domain,$mail_login_type); |
|
976 | + ), $this->domain, $mail_login_type); |
|
979 | 977 | |
980 | - if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
978 | + if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
981 | 979 | |
982 | - if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array( |
|
980 | + if (!$check_only && !ldap_modify($this->test_ldap->ds, $entry['dn'], array( |
|
983 | 981 | $mbox_attr => $mbox, |
984 | 982 | ))) |
985 | 983 | { |
986 | - throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox)); |
|
984 | + throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!", $entry['dn'], $mbox_attr, $mbox)); |
|
987 | 985 | } |
988 | 986 | ++$modified; |
989 | 987 | if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
990 | 988 | } |
991 | - return $check_only ? lang('%1 entries would have been modified.',$modified) : |
|
992 | - lang('%1 entries modified.',$modified); |
|
989 | + return $check_only ? lang('%1 entries would have been modified.', $modified) : lang('%1 entries modified.', $modified); |
|
993 | 990 | } |
994 | 991 | |
995 | 992 | /** |
@@ -1000,9 +997,9 @@ discard block |
||
1000 | 997 | static $requiredObjectclasses = array( |
1001 | 998 | 'o' => 'organization', |
1002 | 999 | 'ou' => 'organizationalUnit', |
1003 | - 'cn' => array('organizationalRole','simpleSecurityObject'), |
|
1004 | - 'uid' => array('uidObject','organizationalRole','simpleSecurityObject'), |
|
1005 | - 'dc' => array('organization','dcObject'), |
|
1000 | + 'cn' => array('organizationalRole', 'simpleSecurityObject'), |
|
1001 | + 'uid' => array('uidObject', 'organizationalRole', 'simpleSecurityObject'), |
|
1002 | + 'dc' => array('organization', 'dcObject'), |
|
1006 | 1003 | ); |
1007 | 1004 | |
1008 | 1005 | /** |
@@ -1013,37 +1010,37 @@ discard block |
||
1013 | 1010 | * @return boolean true if the node was create, false if it was already there |
1014 | 1011 | * @throws Api\Exception\WrongUserinput |
1015 | 1012 | */ |
1016 | - private function _create_node($dn,$extra=array()) |
|
1013 | + private function _create_node($dn, $extra = array()) |
|
1017 | 1014 | { |
1018 | 1015 | // check if the node already exists and return if it does |
1019 | - if (@ldap_read($this->test_ldap->ds,$dn,'objectClass=*')) |
|
1016 | + if (@ldap_read($this->test_ldap->ds, $dn, 'objectClass=*')) |
|
1020 | 1017 | { |
1021 | 1018 | return false; |
1022 | 1019 | } |
1023 | - list($node,$base) = explode(',',$dn,2); |
|
1020 | + list($node, $base) = explode(',', $dn, 2); |
|
1024 | 1021 | |
1025 | - if (!@ldap_read($this->test_ldap->ds,$base,'objectClass=*')) |
|
1022 | + if (!@ldap_read($this->test_ldap->ds, $base, 'objectClass=*')) |
|
1026 | 1023 | { |
1027 | - $this->_create_node($base); // create the base if it's not already there |
|
1024 | + $this->_create_node($base); // create the base if it's not already there |
|
1028 | 1025 | } |
1029 | 1026 | // now we need to create the node itself |
1030 | - list($name,$value) = explode('=',$node); |
|
1027 | + list($name, $value) = explode('=', $node); |
|
1031 | 1028 | |
1032 | 1029 | if (!isset(self::$requiredObjectclasses[$name])) |
1033 | 1030 | { |
1034 | - throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '. |
|
1035 | - lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses))); |
|
1031 | + throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn).' '. |
|
1032 | + lang('Supported node types:').implode(', ', array_keys(self::$requiredObjectclasses))); |
|
1036 | 1033 | } |
1037 | - if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
1038 | - if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
1034 | + if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
1035 | + if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
1039 | 1036 | |
1040 | - if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array( |
|
1037 | + if (!@ldap_add($this->test_ldap->ds, $dn, $attr = array( |
|
1041 | 1038 | $name => $value, |
1042 | 1039 | 'objectClass' => self::$requiredObjectclasses[$name], |
1043 | - )+$extra)) |
|
1040 | + ) + $extra)) |
|
1044 | 1041 | { |
1045 | - throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn). |
|
1046 | - ' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr,true).')'); |
|
1042 | + throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn). |
|
1043 | + ' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr, true).')'); |
|
1047 | 1044 | } |
1048 | 1045 | return true; |
1049 | 1046 | } |
@@ -1074,30 +1071,30 @@ discard block |
||
1074 | 1071 | */ |
1075 | 1072 | private function _merge_defaults() |
1076 | 1073 | { |
1077 | - foreach(self::defaults() as $name => $default) |
|
1074 | + foreach (self::defaults() as $name => $default) |
|
1078 | 1075 | { |
1079 | - if ($this->sub_command == 'delete_ldap' && in_array($name,array('ldap_base','ldap_context'))) |
|
1076 | + if ($this->sub_command == 'delete_ldap' && in_array($name, array('ldap_base', 'ldap_context'))) |
|
1080 | 1077 | { |
1081 | - continue; // no default on what to delete! |
|
1078 | + continue; // no default on what to delete! |
|
1082 | 1079 | } |
1083 | 1080 | if (!$this->$name) |
1084 | 1081 | { |
1085 | 1082 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
1086 | 1083 | $this->set_defaults[$name] = $this->$name = $default; |
1087 | 1084 | } |
1088 | - if (strpos($this->$name,'$') !== false) |
|
1085 | + if (strpos($this->$name, '$') !== false) |
|
1089 | 1086 | { |
1090 | 1087 | $this->set_defaults[$name] = $this->$name = str_replace(array( |
1091 | 1088 | '$domain', |
1092 | 1089 | '$suffix', |
1093 | 1090 | '$base', |
1094 | 1091 | '$admin_pw', |
1095 | - ),array( |
|
1092 | + ), array( |
|
1096 | 1093 | $this->domain, |
1097 | 1094 | $this->ldap_suffix, |
1098 | 1095 | $this->ldap_base, |
1099 | 1096 | $this->ldap_admin_pw, |
1100 | - ),$this->$name); |
|
1097 | + ), $this->$name); |
|
1101 | 1098 | } |
1102 | 1099 | } |
1103 | 1100 | } |
@@ -203,7 +203,10 @@ discard block |
||
203 | 203 | $change_account_id = ''; |
204 | 204 | foreach($entries as $key => $entry) |
205 | 205 | { |
206 | - if ($key === 'count') continue; |
|
206 | + if ($key === 'count') |
|
207 | + { |
|
208 | + continue; |
|
209 | + } |
|
207 | 210 | |
208 | 211 | $entry = Api\Ldap::result2array($entry); |
209 | 212 | $accounts[$entry['dn']] = $entry; |
@@ -230,7 +233,10 @@ discard block |
||
230 | 233 | //print_r($change); die('Stop'); |
231 | 234 | |
232 | 235 | // change account-ids inside EGroupware |
233 | - if ($check_only) $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id"; |
|
236 | + if ($check_only) |
|
237 | + { |
|
238 | + $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id"; |
|
239 | + } |
|
234 | 240 | //$cmd = new admin_cmd_change_account_id($change); |
235 | 241 | //$msg[] = $cmd->run($time=null, $set_modifier=false, $skip_checks=false, $check_only); |
236 | 242 | |
@@ -252,7 +258,10 @@ discard block |
||
252 | 258 | throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds). |
253 | 259 | "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
254 | 260 | } |
255 | - if ($modify) ++$changed; |
|
261 | + if ($modify) |
|
262 | + { |
|
263 | + ++$changed; |
|
264 | + } |
|
256 | 265 | } |
257 | 266 | $msg[] = "You need to run now on your samba share(s):\nsetup/doc/chown.php -R $change_account_id <share>"; |
258 | 267 | |
@@ -279,7 +288,10 @@ discard block |
||
279 | 288 | else |
280 | 289 | { |
281 | 290 | list($to, $from) = explode('=', $attr); |
282 | - if ($from) $attrs[] = $from; |
|
291 | + if ($from) |
|
292 | + { |
|
293 | + $attrs[] = $from; |
|
294 | + } |
|
283 | 295 | $rename[strtolower($from)] = $to; |
284 | 296 | } |
285 | 297 | } |
@@ -294,7 +306,10 @@ discard block |
||
294 | 306 | { |
295 | 307 | $this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain)); |
296 | 308 | } |
297 | - if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator'; |
|
309 | + if (empty($this->ads_admin_user)) |
|
310 | + { |
|
311 | + $this->ads_admin_user = 'Administrator'; |
|
312 | + } |
|
298 | 313 | $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : |
299 | 314 | 'CN='.$this->ads_admin_user.','.$this->ads_context; |
300 | 315 | switch($this->ads_connection) |
@@ -338,7 +353,10 @@ discard block |
||
338 | 353 | $utc_diff = null; |
339 | 354 | foreach($entries as $key => $entry) |
340 | 355 | { |
341 | - if ($key === 'count') continue; |
|
356 | + if ($key === 'count') |
|
357 | + { |
|
358 | + continue; |
|
359 | + } |
|
342 | 360 | |
343 | 361 | $entry_arr = Api\Ldap::result2array($entry); |
344 | 362 | $uid = $entry_arr['uid']; |
@@ -352,7 +370,10 @@ discard block |
||
352 | 370 | continue; |
353 | 371 | } |
354 | 372 | $dn = $dest[0]['dn']; |
355 | - if (isset($rename[''])) $entry[''] = ''; |
|
373 | + if (isset($rename[''])) |
|
374 | + { |
|
375 | + $entry[''] = ''; |
|
376 | + } |
|
356 | 377 | // special handling for copying shadowExpires to accountExpires |
357 | 378 | if (strtolower($rename['shadowexpire']) === 'accountexpires') |
358 | 379 | { |
@@ -363,7 +384,10 @@ discard block |
||
363 | 384 | } |
364 | 385 | else |
365 | 386 | { |
366 | - if (is_null($utc_diff)) $utc_diff = date('Z'); |
|
387 | + if (is_null($utc_diff)) |
|
388 | + { |
|
389 | + $utc_diff = date('Z'); |
|
390 | + } |
|
367 | 391 | $entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime( |
368 | 392 | $entry['shadowexpire']*24*3600+$utc_diff); // ldap time to unixTime |
369 | 393 | } |
@@ -375,20 +399,29 @@ discard block |
||
375 | 399 | { |
376 | 400 | $to = isset($rename[$attr]) ? $rename[$attr] : $attr; |
377 | 401 | $prefix = null; |
378 | - if ($to[0] == '{') // eg. {smtp:}proxyAddresses=forwardTo |
|
402 | + if ($to[0] == '{') |
|
403 | + { |
|
404 | + // eg. {smtp:}proxyAddresses=forwardTo |
|
379 | 405 | { |
380 | 406 | list($prefix, $to) = explode('}', substr($to, 1)); |
381 | 407 | } |
408 | + } |
|
382 | 409 | foreach((array)$value as $val) |
383 | 410 | { |
384 | 411 | if (isset($update[$to])) |
385 | 412 | { |
386 | - if (!is_array($update[$to])) $update[$to] = array($update[$to]); |
|
413 | + if (!is_array($update[$to])) |
|
414 | + { |
|
415 | + $update[$to] = array($update[$to]); |
|
416 | + } |
|
387 | 417 | // we need to check (caseinsensitive) if value already exists in set |
388 | 418 | // as AD chokes on doublicate values "Type or value exists" |
389 | 419 | foreach($update[$to] as $v) |
390 | 420 | { |
391 | - if (!strcasecmp($v, $prefix.$val)) continue 2; |
|
421 | + if (!strcasecmp($v, $prefix.$val)) |
|
422 | + { |
|
423 | + continue 2; |
|
424 | + } |
|
392 | 425 | } |
393 | 426 | $update[$to][] = $prefix.$val; |
394 | 427 | } |
@@ -415,7 +448,10 @@ discard block |
||
415 | 448 | $changed++; |
416 | 449 | } |
417 | 450 | } |
418 | - if ($check_only) return lang("%1 accounts to copy found.", count($entries)); |
|
451 | + if ($check_only) |
|
452 | + { |
|
453 | + return lang("%1 accounts to copy found.", count($entries)); |
|
454 | + } |
|
419 | 455 | |
420 | 456 | return "Copied data of $changed accounts from LDAP to AD ". |
421 | 457 | (count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : ''); |
@@ -431,7 +467,10 @@ discard block |
||
431 | 467 | private function migrate($mode) |
432 | 468 | { |
433 | 469 | // support old boolean mode |
434 | - if (is_bool($mode)) $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql'; |
|
470 | + if (is_bool($mode)) |
|
471 | + { |
|
472 | + $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql'; |
|
473 | + } |
|
435 | 474 | |
436 | 475 | $passwords2sql = $mode === "passwords_to_sql"; |
437 | 476 | list(,$to) = explode('_to_', $mode); |
@@ -597,7 +636,10 @@ discard block |
||
597 | 636 | { |
598 | 637 | foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name) |
599 | 638 | { |
600 | - if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name; |
|
639 | + if (!empty($this->$name)) |
|
640 | + { |
|
641 | + $GLOBALS['egw_info']['server'][$name] = $this->$name; |
|
642 | + } |
|
601 | 643 | } |
602 | 644 | //error_log(__METHOD__."() setup up egw_info[server]: ldap_host='{$GLOBALS['egw_info']['server']['ldap_host']}', ldap_root_dn='{$GLOBALS['egw_info']['server']['ldap_root_dn']}', ldap_root_pw='{$GLOBALS['egw_info']['server']['ldap_root_pw']}', ldap_context='{$GLOBALS['egw_info']['server']['ldap_context']}', mail_suffix='{$GLOBALS['egw_info']['server']['mail_suffix']}', mail_logig_type='{$GLOBALS['egw_info']['server']['mail_login-type']}'"); |
603 | 645 | } |
@@ -684,7 +726,10 @@ discard block |
||
684 | 726 | */ |
685 | 727 | public static function hash_sql2ldap($hash) |
686 | 728 | { |
687 | - if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5'; |
|
729 | + if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) |
|
730 | + { |
|
731 | + $type = 'md5'; |
|
732 | + } |
|
688 | 733 | |
689 | 734 | $matches = null; |
690 | 735 | if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches)) |
@@ -718,10 +763,13 @@ discard block |
||
718 | 763 | */ |
719 | 764 | public static function hash_ldap2sql($hash) |
720 | 765 | { |
721 | - if ($hash[0] != '{') // plain has to be explicitly specified for sql, in ldap it's the default |
|
766 | + if ($hash[0] != '{') |
|
767 | + { |
|
768 | + // plain has to be explicitly specified for sql, in ldap it's the default |
|
722 | 769 | { |
723 | 770 | $hash = '{PLAIN}'.$hash; |
724 | 771 | } |
772 | + } |
|
725 | 773 | return $hash; |
726 | 774 | } |
727 | 775 | |
@@ -741,9 +789,12 @@ discard block |
||
741 | 789 | |
742 | 790 | foreach($accounts as $account_id => &$account) |
743 | 791 | { |
744 | - if ($account_id != $account['account_id']) // not all backends have as key the account_id |
|
792 | + if ($account_id != $account['account_id']) |
|
793 | + { |
|
794 | + // not all backends have as key the account_id |
|
745 | 795 | { |
746 | 796 | unset($account); |
797 | + } |
|
747 | 798 | $account_id = $account['account_id']; |
748 | 799 | } |
749 | 800 | $account += $accounts_obj->read($account_id); |
@@ -776,7 +827,11 @@ discard block |
||
776 | 827 | parent::_setup_enviroment($this->domain); |
777 | 828 | $enviroment_setup = true; |
778 | 829 | } |
779 | - if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
830 | + if ($type != 'sql') |
|
831 | + { |
|
832 | + $this->connect(); |
|
833 | + } |
|
834 | + // throws exception, if it can NOT connect |
|
780 | 835 | |
781 | 836 | // otherwise search does NOT work, as accounts_sql uses addressbook_bo for it |
782 | 837 | $GLOBALS['egw_info']['server']['account_repository'] = $type; |
@@ -803,14 +858,26 @@ discard block |
||
803 | 858 | */ |
804 | 859 | private function connect($dn=null,$pw=null,$host=null) |
805 | 860 | { |
806 | - if (is_null($dn)) $dn = $this->ldap_root_dn; |
|
807 | - if (is_null($pw)) $pw = $this->ldap_root_pw; |
|
808 | - if (is_null($host)) $host = $this->ldap_host; |
|
861 | + if (is_null($dn)) |
|
862 | + { |
|
863 | + $dn = $this->ldap_root_dn; |
|
864 | + } |
|
865 | + if (is_null($pw)) |
|
866 | + { |
|
867 | + $pw = $this->ldap_root_pw; |
|
868 | + } |
|
869 | + if (is_null($host)) |
|
870 | + { |
|
871 | + $host = $this->ldap_host; |
|
872 | + } |
|
809 | 873 | |
810 | - if (!$pw) // Api\Ldap::ldapConnect use the current eGW's pw otherwise |
|
874 | + if (!$pw) |
|
875 | + { |
|
876 | + // Api\Ldap::ldapConnect use the current eGW's pw otherwise |
|
811 | 877 | { |
812 | 878 | throw new Api\Exception\WrongUserinput(lang('You need to specify a password!')); |
813 | 879 | } |
880 | + } |
|
814 | 881 | |
815 | 882 | try { |
816 | 883 | $this->test_ldap = Api\Ldap::factory(false, $host, $dn, $pw); |
@@ -841,8 +908,14 @@ discard block |
||
841 | 908 | $num = 0; |
842 | 909 | foreach($entries as $n => $entry) |
843 | 910 | { |
844 | - if ($n === 'count') continue; |
|
845 | - if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue; |
|
911 | + if ($n === 'count') |
|
912 | + { |
|
913 | + continue; |
|
914 | + } |
|
915 | + if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) |
|
916 | + { |
|
917 | + continue; |
|
918 | + } |
|
846 | 919 | ++$num; |
847 | 920 | } |
848 | 921 | return $num; |
@@ -921,7 +994,10 @@ discard block |
||
921 | 994 | $deleted = 0; |
922 | 995 | foreach($entries as $n => $entry) |
923 | 996 | { |
924 | - if ($n === 'count') continue; |
|
997 | + if ($n === 'count') |
|
998 | + { |
|
999 | + continue; |
|
1000 | + } |
|
925 | 1001 | $deleted += $this->rdelete($entry['dn']); |
926 | 1002 | } |
927 | 1003 | if (!ldap_delete($this->test_ldap->ds,$dn)) |
@@ -969,7 +1045,10 @@ discard block |
||
969 | 1045 | $modified = 0; |
970 | 1046 | foreach($entries as $n => $entry) |
971 | 1047 | { |
972 | - if ($n === 'count') continue; |
|
1048 | + if ($n === 'count') |
|
1049 | + { |
|
1050 | + continue; |
|
1051 | + } |
|
973 | 1052 | |
974 | 1053 | $mbox = Api\Mail\Smtp\Ldap::mailbox_addr(array( |
975 | 1054 | 'account_id' => $entry['uidnumber'][0], |
@@ -977,7 +1056,11 @@ discard block |
||
977 | 1056 | 'account_email' => $entry['mail'][0], |
978 | 1057 | ),$this->domain,$mail_login_type); |
979 | 1058 | |
980 | - if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
1059 | + if ($mbox === $entry[$mbox_attr][0]) |
|
1060 | + { |
|
1061 | + continue; |
|
1062 | + } |
|
1063 | + // nothing to change |
|
981 | 1064 | |
982 | 1065 | if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array( |
983 | 1066 | $mbox_attr => $mbox, |
@@ -986,7 +1069,10 @@ discard block |
||
986 | 1069 | throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox)); |
987 | 1070 | } |
988 | 1071 | ++$modified; |
989 | - if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
|
1072 | + if ($check_only) |
|
1073 | + { |
|
1074 | + echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
|
1075 | + } |
|
990 | 1076 | } |
991 | 1077 | return $check_only ? lang('%1 entries would have been modified.',$modified) : |
992 | 1078 | lang('%1 entries modified.',$modified); |
@@ -1034,8 +1120,16 @@ discard block |
||
1034 | 1120 | throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '. |
1035 | 1121 | lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses))); |
1036 | 1122 | } |
1037 | - if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
1038 | - if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
1123 | + if ($name == 'dc') |
|
1124 | + { |
|
1125 | + $extra['o'] = $value; |
|
1126 | + } |
|
1127 | + // required by organisation |
|
1128 | + if ($name == 'uid') |
|
1129 | + { |
|
1130 | + $extra['cn'] = $value; |
|
1131 | + } |
|
1132 | + // required by organizationalRole |
|
1039 | 1133 | |
1040 | 1134 | if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array( |
1041 | 1135 | $name => $value, |