@@ -157,7 +157,7 @@ |
||
157 | 157 | /** |
158 | 158 | * Create links |
159 | 159 | */ |
160 | - public static function ajax_link($app, $id, Array $links) |
|
160 | + public static function ajax_link($app, $id, array $links) |
|
161 | 161 | { |
162 | 162 | // Files need to know full path in tmp directory |
163 | 163 | foreach($links as $key => $link) { |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct($xml = '') |
39 | 39 | { |
40 | - if($xml) { |
|
40 | + if($xml) |
|
41 | + { |
|
41 | 42 | parent::__construct($xml); |
42 | 43 | } |
43 | 44 | } |
@@ -85,14 +86,18 @@ discard block |
||
85 | 86 | |
86 | 87 | |
87 | 88 | // ToDo: implement on client-side |
88 | - if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); |
|
89 | + if (!$attrs['help']) |
|
90 | + { |
|
91 | + self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); |
|
92 | + } |
|
89 | 93 | |
90 | 94 | if($attrs['type'] == 'link-list') |
91 | 95 | { |
92 | 96 | $app = $value['to_app']; |
93 | 97 | $id = $value['to_id']; |
94 | 98 | $links = Api\Link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']); |
95 | - foreach($links as $link) { |
|
99 | + foreach($links as $link) |
|
100 | + { |
|
96 | 101 | $value[] = $link; |
97 | 102 | } |
98 | 103 | } |
@@ -104,7 +109,10 @@ discard block |
||
104 | 109 | public static function ajax_link_search($app, $type, $pattern, $options=array()) |
105 | 110 | { |
106 | 111 | $options['type'] = $type ? $type : $options['type']; |
107 | - if(!$options['num_rows']) $options['num_rows'] = 1000; |
|
112 | + if(!$options['num_rows']) |
|
113 | + { |
|
114 | + $options['num_rows'] = 1000; |
|
115 | + } |
|
108 | 116 | |
109 | 117 | $links = Api\Link::query($app, $pattern, $options); |
110 | 118 | |
@@ -162,8 +170,10 @@ discard block |
||
162 | 170 | public static function ajax_link($app, $id, Array $links) |
163 | 171 | { |
164 | 172 | // Files need to know full path in tmp directory |
165 | - foreach($links as $key => $link) { |
|
166 | - if($link['app'] == Api\Link::VFS_APPNAME) { |
|
173 | + foreach($links as $key => $link) |
|
174 | + { |
|
175 | + if($link['app'] == Api\Link::VFS_APPNAME) |
|
176 | + { |
|
167 | 177 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
168 | 178 | { |
169 | 179 | $path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id']; |
@@ -267,7 +277,10 @@ discard block |
||
267 | 277 | $id .= "/$dest_file"; |
268 | 278 | } |
269 | 279 | |
270 | - if(!is_array($files)) $files = array($files); |
|
280 | + if(!is_array($files)) |
|
281 | + { |
|
282 | + $files = array($files); |
|
283 | + } |
|
271 | 284 | |
272 | 285 | if ($action == "copy") |
273 | 286 | { |
@@ -343,9 +356,12 @@ discard block |
||
343 | 356 | // keep values added into request by other ajax-functions, eg. files draged into htmlarea (Vfs) |
344 | 357 | if ((!$value || is_array($value) && !$value['to_id']) && is_array($expand['cont'][$this->id]) && !empty($expand['cont'][$this->id]['to_id'])) |
345 | 358 | { |
346 | - if (!is_array($value)) $value = array( |
|
359 | + if (!is_array($value)) |
|
360 | + { |
|
361 | + $value = array( |
|
347 | 362 | 'to_app' => $expand['cont'][$this->id]['to_app'], |
348 | 363 | ); |
364 | + } |
|
349 | 365 | $value['to_id'] = $expand['cont'][$this->id]['to_id']; |
350 | 366 | } |
351 | 367 | |
@@ -367,7 +383,10 @@ discard block |
||
367 | 383 | else |
368 | 384 | { |
369 | 385 | // Not enough information, leave it to the application |
370 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
386 | + if(!is_array($value['to_id'])) |
|
387 | + { |
|
388 | + $value['to_id'] = array(); |
|
389 | + } |
|
371 | 390 | $value['to_id'][] = $link; |
372 | 391 | } |
373 | 392 | } |
@@ -387,7 +406,10 @@ discard block |
||
387 | 406 | } |
388 | 407 | foreach($files as $name => $attrs) |
389 | 408 | { |
390 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
409 | + if(!is_array($value['to_id'])) |
|
410 | + { |
|
411 | + $value['to_id'] = array(); |
|
412 | + } |
|
391 | 413 | $value['to_id'][] = array( |
392 | 414 | 'app' => Api\Link::VFS_APPNAME, |
393 | 415 | 'id' => array( |
@@ -399,7 +421,10 @@ discard block |
||
399 | 421 | } |
400 | 422 | } |
401 | 423 | $valid =& self::get_array($validated, $form_name, true); |
402 | - if (true) $valid = $value; |
|
424 | + if (true) |
|
425 | + { |
|
426 | + $valid = $value; |
|
427 | + } |
|
403 | 428 | //error_log($this); |
404 | 429 | //error_log(" " . array2string($valid)); |
405 | 430 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct($xml = '') |
39 | 39 | { |
40 | - if($xml) { |
|
40 | + if ($xml) { |
|
41 | 41 | parent::__construct($xml); |
42 | 42 | } |
43 | 43 | } |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | * @param string $cname |
63 | 63 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
64 | 64 | */ |
65 | - public function beforeSendToClient($cname, array $expand=null) |
|
65 | + public function beforeSendToClient($cname, array $expand = null) |
|
66 | 66 | { |
67 | 67 | $attrs = $this->attrs; |
68 | 68 | $form_name = self::form_name($cname, $this->id, $expand); |
69 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
69 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
70 | 70 | |
71 | - if($value && !is_array($value) && !$this->attrs['only_app']) |
|
71 | + if ($value && !is_array($value) && !$this->attrs['only_app']) |
|
72 | 72 | { |
73 | 73 | // Try to explode |
74 | - if(count(explode(':',$value)) < 2) |
|
74 | + if (count(explode(':', $value)) < 2) |
|
75 | 75 | { |
76 | 76 | throw new Api\Exception\WrongParameter("Wrong value sent to $this, needs to be an array. ".array2string($value)); |
77 | 77 | } |
78 | - list($app, $id) = explode(':', $value,2); |
|
78 | + list($app, $id) = explode(':', $value, 2); |
|
79 | 79 | $value = array('app' => $app, 'id' => $id); |
80 | 80 | } |
81 | 81 | elseif (!$value) |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | // ToDo: implement on client-side |
88 | 88 | if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); |
89 | 89 | |
90 | - if($attrs['type'] == 'link-list') |
|
90 | + if ($attrs['type'] == 'link-list') |
|
91 | 91 | { |
92 | 92 | $app = $value['to_app']; |
93 | 93 | $id = $value['to_id']; |
94 | - $links = Api\Link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']); |
|
95 | - foreach($links as $link) { |
|
94 | + $links = Api\Link::get_links($app, $id, '', 'link_lastmod DESC', true, $value['show_deleted']); |
|
95 | + foreach ($links as $link) { |
|
96 | 96 | $value[] = $link; |
97 | 97 | } |
98 | 98 | } |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Find links that match the given parameters |
103 | 103 | */ |
104 | - public static function ajax_link_search($app, $type, $pattern, $options=array()) |
|
104 | + public static function ajax_link_search($app, $type, $pattern, $options = array()) |
|
105 | 105 | { |
106 | 106 | $options['type'] = $type ? $type : $options['type']; |
107 | - if(!$options['num_rows']) $options['num_rows'] = 1000; |
|
107 | + if (!$options['num_rows']) $options['num_rows'] = 1000; |
|
108 | 108 | |
109 | 109 | $links = Api\Link::query($app, $pattern, $options); |
110 | 110 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string|int $id |
127 | 127 | * @return string|boolean string with title, boolean false of permission denied or null if not found |
128 | 128 | */ |
129 | - public static function ajax_link_title($app,$id) |
|
129 | + public static function ajax_link_title($app, $id) |
|
130 | 130 | { |
131 | 131 | $title = Api\Link::title($app, $id); |
132 | 132 | //error_log(__METHOD__."('$app', '$id') = ".array2string($title)); |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | public static function ajax_link_titles(array $app_ids) |
143 | 143 | { |
144 | 144 | $response = array(); |
145 | - foreach($app_ids as $app => $ids) |
|
145 | + foreach ($app_ids as $app => $ids) |
|
146 | 146 | { |
147 | - if(count($ids)) |
|
147 | + if (count($ids)) |
|
148 | 148 | { |
149 | 149 | $response[$app] = Api\Link::titles($app, $ids); |
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
153 | - error_log(__METHOD__."(".array2string($app_ids).") got invalid title request: app=$app, ids=" . array2string($ids)); |
|
153 | + error_log(__METHOD__."(".array2string($app_ids).") got invalid title request: app=$app, ids=".array2string($ids)); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | Api\Json\Response::get()->data($response); |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | public static function ajax_link($app, $id, Array $links) |
163 | 163 | { |
164 | 164 | // Files need to know full path in tmp directory |
165 | - foreach($links as $key => $link) { |
|
166 | - if($link['app'] == Api\Link::VFS_APPNAME) { |
|
165 | + foreach ($links as $key => $link) { |
|
166 | + if ($link['app'] == Api\Link::VFS_APPNAME) { |
|
167 | 167 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
168 | 168 | { |
169 | - $path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id']; |
|
169 | + $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$link['id']; |
|
170 | 170 | } |
171 | 171 | else |
172 | 172 | { |
@@ -187,20 +187,20 @@ discard block |
||
187 | 187 | $app = $value['to_app']; |
188 | 188 | $id = $value['to_id']; |
189 | 189 | |
190 | - $links = Api\Link::get_links($app,$id,$value['only_app'],'link_lastmod DESC',true, $value['show_deleted']); |
|
191 | - foreach($links as &$link) |
|
190 | + $links = Api\Link::get_links($app, $id, $value['only_app'], 'link_lastmod DESC', true, $value['show_deleted']); |
|
191 | + foreach ($links as &$link) |
|
192 | 192 | { |
193 | - $link['title'] = Api\Link::title($link['app'],$link['id'],$link); |
|
193 | + $link['title'] = Api\Link::title($link['app'], $link['id'], $link); |
|
194 | 194 | if ($link['app'] == Api\Link::VFS_APPNAME) |
195 | 195 | { |
196 | 196 | $link['target'] = '_blank'; |
197 | 197 | $link['label'] = 'Delete'; |
198 | 198 | $link['help'] = lang('Delete this file'); |
199 | 199 | $link['title'] = Api\Vfs::decodePath($link['title']); |
200 | - $link['icon'] = Api\Link::vfs_path($link['app2'],$link['id2'],$link['id'],true); |
|
200 | + $link['icon'] = Api\Link::vfs_path($link['app2'], $link['id2'], $link['id'], true); |
|
201 | 201 | $link['download_url'] = Api\Vfs::download_url($link['icon']); |
202 | 202 | // Make links to directories load in filemanager |
203 | - if($link['type'] == Api\Vfs::DIR_MIME_TYPE) |
|
203 | + if ($link['type'] == Api\Vfs::DIR_MIME_TYPE) |
|
204 | 204 | { |
205 | 205 | $link['target'] = 'filemanager'; |
206 | 206 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public static function ajax_link_comment($link_id, $comment) |
225 | 225 | { |
226 | 226 | $result = false; |
227 | - if((int)$link_id > 0) |
|
227 | + if ((int)$link_id > 0) |
|
228 | 228 | { |
229 | 229 | Api\Link::update_remark((int)$link_id, $comment); |
230 | 230 | $result = true; |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | else |
233 | 233 | { |
234 | 234 | $link = Api\Link::get_link((int)$link_id); |
235 | - if($link && $link['app'] == Api\Link::VFS_APPNAME) |
|
235 | + if ($link && $link['app'] == Api\Link::VFS_APPNAME) |
|
236 | 236 | { |
237 | - $files = Api\Link::list_attached($link['app2'],$link['id2']); |
|
237 | + $files = Api\Link::list_attached($link['app2'], $link['id2']); |
|
238 | 238 | $file = $files[(int)$link_id]; |
239 | - $path = Api\Link::vfs_path($link['app2'],$link['id2'],$file['id']); |
|
239 | + $path = Api\Link::vfs_path($link['app2'], $link['id2'], $file['id']); |
|
240 | 240 | $result = Api\Vfs::proppatch($path, array(array('name' => 'comment', 'val' => $comment))); |
241 | 241 | } |
242 | 242 | } |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | |
261 | 261 | if (empty($app_id) || empty($id)) |
262 | 262 | { |
263 | - return; // cant do anything |
|
263 | + return; // cant do anything |
|
264 | 264 | } |
265 | - if($id && $dest_file && trim($dest_file) !== '') |
|
265 | + if ($id && $dest_file && trim($dest_file) !== '') |
|
266 | 266 | { |
267 | 267 | $id .= "/$dest_file"; |
268 | 268 | } |
269 | 269 | |
270 | - if(!is_array($files)) $files = array($files); |
|
270 | + if (!is_array($files)) $files = array($files); |
|
271 | 271 | |
272 | 272 | if ($action == "copy") |
273 | 273 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | else |
281 | 281 | { |
282 | - foreach($files as $target) |
|
282 | + foreach ($files as $target) |
|
283 | 283 | { |
284 | 284 | Api\Link::link_file($app, $id, $target); |
285 | 285 | } |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | { |
305 | 305 | $app = $_GET['app']; |
306 | 306 | $id = $_GET['id']; |
307 | - if(Api\Link::file_access($app, $id)) |
|
307 | + if (Api\Link::file_access($app, $id)) |
|
308 | 308 | { |
309 | - $app_path = Api\Link::vfs_path($app,$id,'',true); |
|
309 | + $app_path = Api\Link::vfs_path($app, $id, '', true); |
|
310 | 310 | |
311 | 311 | // Pass the files linked, not the entry path |
312 | 312 | $files = Api\Vfs::find($app_path); |
313 | - if($files[0] == $app_path) |
|
313 | + if ($files[0] == $app_path) |
|
314 | 314 | { |
315 | 315 | array_shift($files); |
316 | 316 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | * @param array $content |
335 | 335 | * @param array &$validated=array() validated content |
336 | 336 | */ |
337 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
337 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
338 | 338 | { |
339 | 339 | $form_name = self::form_name($cname, $this->id, $expand); |
340 | 340 | |
341 | 341 | if (!$this->is_readonly($cname, $form_name)) |
342 | 342 | { |
343 | - $value = $value_in =& self::get_array($content, $form_name); |
|
343 | + $value = $value_in = & self::get_array($content, $form_name); |
|
344 | 344 | |
345 | 345 | // keep values added into request by other ajax-functions, eg. files draged into htmlarea (Vfs) |
346 | 346 | if ((!$value || is_array($value) && !$value['to_id']) && is_array($expand['cont'][$this->id]) && !empty($expand['cont'][$this->id]['to_id'])) |
@@ -352,44 +352,44 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | // Link widgets can share IDs, make sure to preserve values from others |
355 | - $already = self::get_array($validated,$form_name); |
|
356 | - if($already != null) |
|
355 | + $already = self::get_array($validated, $form_name); |
|
356 | + if ($already != null) |
|
357 | 357 | { |
358 | - $value = array_merge($value,$already); |
|
358 | + $value = array_merge($value, $already); |
|
359 | 359 | } |
360 | 360 | // Automatically do link if user selected entry but didn't click 'Link' button |
361 | - $link = self::get_array($content, self::form_name($cname, $this->id . '_link_entry')); |
|
362 | - if($this->type =='link-to' && is_array($link) && $link['app'] && $link['id'] ) |
|
361 | + $link = self::get_array($content, self::form_name($cname, $this->id.'_link_entry')); |
|
362 | + if ($this->type == 'link-to' && is_array($link) && $link['app'] && $link['id']) |
|
363 | 363 | { |
364 | 364 | // Do we have enough information to link automatically? |
365 | - if(is_array($value) && $value['to_id']) |
|
365 | + if (is_array($value) && $value['to_id']) |
|
366 | 366 | { |
367 | 367 | Api\Link::link($value['to_app'], $value['to_id'], $link['app'], $link['id']); |
368 | 368 | } |
369 | 369 | else |
370 | 370 | { |
371 | 371 | // Not enough information, leave it to the application |
372 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
372 | + if (!is_array($value['to_id'])) $value['to_id'] = array(); |
|
373 | 373 | $value['to_id'][] = $link; |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Look for files - normally handled by ajax |
378 | - $files = self::get_array($content, self::form_name($cname, $this->id . '_file')); |
|
379 | - if(is_array($files) && !(is_array($value) && $value['to_id'])) |
|
378 | + $files = self::get_array($content, self::form_name($cname, $this->id.'_file')); |
|
379 | + if (is_array($files) && !(is_array($value) && $value['to_id'])) |
|
380 | 380 | { |
381 | 381 | $value = array(); |
382 | 382 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
383 | 383 | { |
384 | - $path = $GLOBALS['egw_info']['server']['temp_dir'] . '/'; |
|
384 | + $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'; |
|
385 | 385 | } |
386 | 386 | else |
387 | 387 | { |
388 | 388 | $path = ''; |
389 | 389 | } |
390 | - foreach($files as $name => $attrs) |
|
390 | + foreach ($files as $name => $attrs) |
|
391 | 391 | { |
392 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
392 | + if (!is_array($value['to_id'])) $value['to_id'] = array(); |
|
393 | 393 | $value['to_id'][] = array( |
394 | 394 | 'app' => Api\Link::VFS_APPNAME, |
395 | 395 | 'id' => array( |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | ); |
401 | 401 | } |
402 | 402 | } |
403 | - $valid =& self::get_array($validated, $form_name, true); |
|
403 | + $valid = & self::get_array($validated, $form_name, true); |
|
404 | 404 | if (true) $valid = $value; |
405 | 405 | //error_log($this); |
406 | 406 | //error_log(" " . array2string($valid)); |
@@ -101,7 +101,8 @@ |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // Special keys |
104 | - switch ($keyCode) { |
|
104 | + switch ($keyCode) |
|
105 | + { |
|
105 | 106 | case self::BACKSPACE: |
106 | 107 | return lang("Back"); |
107 | 108 | case self::TAB: |
@@ -63,12 +63,18 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function __construct($id=null) |
65 | 65 | { |
66 | - if (!$id) $id = self::request_id(); |
|
66 | + if (!$id) |
|
67 | + { |
|
68 | + $id = self::request_id(); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | $this->id = $id; |
69 | 72 | |
70 | 73 | // hack to quiten IDE Warning for not calling parent::__construct, which we can not! |
71 | - if (false) parent::__construct(); |
|
74 | + if (false) |
|
75 | + { |
|
76 | + parent::__construct(); |
|
77 | + } |
|
72 | 78 | } |
73 | 79 | |
74 | 80 | /** |
@@ -162,7 +168,11 @@ discard block |
||
162 | 168 | } |
163 | 169 | $this->garbage_collection_done = true; |
164 | 170 | |
165 | - if (count($appsessions) < 20) return; // we dont need to care |
|
171 | + if (count($appsessions) < 20) |
|
172 | + { |
|
173 | + return; |
|
174 | + } |
|
175 | + // we dont need to care |
|
166 | 176 | |
167 | 177 | $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
168 | 178 | |
@@ -170,15 +180,22 @@ discard block |
||
170 | 180 | { |
171 | 181 | list(,$time) = explode(':',$id); |
172 | 182 | |
173 | - if (!$time) continue; // other data, no session |
|
183 | + if (!$time) |
|
184 | + { |
|
185 | + continue; |
|
186 | + } |
|
187 | + // other data, no session |
|
174 | 188 | |
175 | 189 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
176 | 190 | |
177 | 191 | if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
178 | - $time < $now - 30*6000) // session not used and older then 30min |
|
192 | + $time < $now - 30*6000) |
|
193 | + { |
|
194 | + // session not used and older then 30min |
|
179 | 195 | { |
180 | 196 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
181 | 197 | unset($appsessions[$id]); |
198 | + } |
|
182 | 199 | unset($session_used[$id]); |
183 | 200 | } |
184 | 201 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param string|null $id =null |
63 | 63 | */ |
64 | - private function __construct($id=null) |
|
64 | + private function __construct($id = null) |
|
65 | 65 | { |
66 | 66 | if (!$id) $id = self::request_id(); |
67 | 67 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $id =null |
89 | 89 | * @return etemplate_request|boolean the object or false if $id is not found |
90 | 90 | */ |
91 | - static function read($id=null) |
|
91 | + static function read($id = null) |
|
92 | 92 | { |
93 | 93 | $request = new Session($id); |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | if (!($data = Api\Cache::getSession('etemplate', $id))) |
98 | 98 | { |
99 | - return false; // request not found |
|
99 | + return false; // request not found |
|
100 | 100 | } |
101 | 101 | $request->data = $data; |
102 | 102 | } |
@@ -139,30 +139,30 @@ discard block |
||
139 | 139 | protected function _php4_request_garbage_collection() |
140 | 140 | { |
141 | 141 | // now we are on php4 sessions and do a bit of garbage collection |
142 | - $appsessions =& $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate']; |
|
143 | - $session_used =& $appsessions['session_used']; |
|
142 | + $appsessions = & $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate']; |
|
143 | + $session_used = & $appsessions['session_used']; |
|
144 | 144 | |
145 | 145 | if ($this->id) |
146 | 146 | { |
147 | 147 | //echo "session_used[$id_used]='".$session_used[$id_used]."'<br/>\n"; |
148 | - ++$session_used[$this->id]; // count the number of times a session got used |
|
148 | + ++$session_used[$this->id]; // count the number of times a session got used |
|
149 | 149 | } |
150 | 150 | $this->garbage_collection_done = true; |
151 | 151 | |
152 | - if (count($appsessions) < 20) return; // we dont need to care |
|
152 | + if (count($appsessions) < 20) return; // we dont need to care |
|
153 | 153 | |
154 | - $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
|
154 | + $now = (int)(100 * microtime(true)); // gives precision of 1/100 sec |
|
155 | 155 | |
156 | - foreach(array_keys($appsessions) as $id) |
|
156 | + foreach (array_keys($appsessions) as $id) |
|
157 | 157 | { |
158 | - list(,$time) = explode(':',$id); |
|
158 | + list(,$time) = explode(':', $id); |
|
159 | 159 | |
160 | - if (!$time) continue; // other data, no session |
|
160 | + if (!$time) continue; // other data, no session |
|
161 | 161 | |
162 | 162 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
163 | 163 | |
164 | - if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
|
165 | - $time < $now - 30*6000) // session not used and older then 30min |
|
164 | + if ($session_used[$id] == 1 && $time < $now - 10 * 6000 || // session used and older then 10min |
|
165 | + $time < $now - 30 * 6000) // session not used and older then 30min |
|
166 | 166 | { |
167 | 167 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
168 | 168 | unset($appsessions[$id]); |
@@ -77,12 +77,18 @@ discard block |
||
77 | 77 | { |
78 | 78 | self::$directory = $GLOBALS['egw_info']['server']['temp_dir']; |
79 | 79 | } |
80 | - if (!$id) $id = self::request_id(); |
|
80 | + if (!$id) |
|
81 | + { |
|
82 | + $id = self::request_id(); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | $this->id = $id; |
83 | 86 | |
84 | 87 | // hack to quiten IDE Warning for not calling parent::__construct, which we can not! |
85 | - if (false) parent::__construct(); |
|
88 | + if (false) |
|
89 | + { |
|
90 | + parent::__construct(); |
|
91 | + } |
|
86 | 92 | } |
87 | 93 | |
88 | 94 | /** |
@@ -114,7 +120,10 @@ discard block |
||
114 | 120 | return false; |
115 | 121 | } |
116 | 122 | $request->data = unserialize(file_get_contents($filename)); |
117 | - if ($request->data === false) error_log("Error unserializing '$filename' to read the etemplate request data!"); |
|
123 | + if ($request->data === false) |
|
124 | + { |
|
125 | + error_log("Error unserializing '$filename' to read the etemplate request data!"); |
|
126 | + } |
|
118 | 127 | } |
119 | 128 | //error_log(__METHOD__."(id=$id"); |
120 | 129 | return $request; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string|null $id =null |
73 | 73 | */ |
74 | - private function __construct($id=null) |
|
74 | + private function __construct($id = null) |
|
75 | 75 | { |
76 | 76 | if (is_null(self::$directory)) |
77 | 77 | { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $id =null |
103 | 103 | * @return etemplate_request|boolean the object or false if $id is not found |
104 | 104 | */ |
105 | - static function read($id=null) |
|
105 | + static function read($id = null) |
|
106 | 106 | { |
107 | 107 | $request = new Files($id); |
108 | 108 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | $this->cleanup(); |
157 | 157 | |
158 | - if (!file_put_contents($filename = self::$directory.'/'.$this->id,serialize($this->data))) |
|
158 | + if (!file_put_contents($filename = self::$directory.'/'.$this->id, serialize($this->data))) |
|
159 | 159 | { |
160 | 160 | error_log("Error opening '$filename' to store the etemplate request data!"); |
161 | 161 | } |
@@ -78,7 +78,10 @@ |
||
78 | 78 | //error_log(__METHOD__."($_id) this->id=$this->id"); |
79 | 79 | |
80 | 80 | // hack to quiten IDE Warning for not calling parent::__construct, which we can not! |
81 | - if (false) parent::__construct(); |
|
81 | + if (false) |
|
82 | + { |
|
83 | + parent::__construct(); |
|
84 | + } |
|
82 | 85 | } |
83 | 86 | |
84 | 87 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param string $_id |
74 | 74 | */ |
75 | - private function __construct($_id=null) |
|
75 | + private function __construct($_id = null) |
|
76 | 76 | { |
77 | 77 | $this->id = $_id ? $_id : self::request_id(); |
78 | 78 | //error_log(__METHOD__."($_id) this->id=$this->id"); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param string $id =null |
99 | 99 | * @return Request|boolean the object or false if $id is not found |
100 | 100 | */ |
101 | - static function read($id=null) |
|
101 | + static function read($id = null) |
|
102 | 102 | { |
103 | 103 | $request = new Cache($id); |
104 | 104 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | elseif (($this->data_modified || |
134 | 134 | // if half of expiration time is over, save it anyway, to restart expiration time |
135 | - isset($this->data['last_saved']) && (time()-$this->data['last_saved']) > self::EXPIRATION/2)) |
|
135 | + isset($this->data['last_saved']) && (time() - $this->data['last_saved']) > self::EXPIRATION / 2)) |
|
136 | 136 | { |
137 | 137 | //error_log(__METHOD__."() saving $this->id".($this->data_modified?'':' data NOT modified, just keeping session alife')); |
138 | 138 | $this->cleanup(); |
@@ -122,7 +122,10 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function read($account_id) |
124 | 124 | { |
125 | - if (!(int)$account_id) return false; |
|
125 | + if (!(int)$account_id) |
|
126 | + { |
|
127 | + return false; |
|
128 | + } |
|
126 | 129 | |
127 | 130 | if ($account_id > 0) |
128 | 131 | { |
@@ -152,11 +155,14 @@ discard block |
||
152 | 155 | unset($e); |
153 | 156 | } |
154 | 157 | |
155 | - if (!$rs) // handle not (yet) existing mailaccounts table |
|
158 | + if (!$rs) |
|
159 | + { |
|
160 | + // handle not (yet) existing mailaccounts table |
|
156 | 161 | { |
157 | 162 | $rs = $this->db->select($this->table, $this->table.'.*', |
158 | 163 | $this->table.'.account_id='.abs($account_id), __LINE__, __FILE__); |
159 | 164 | } |
165 | + } |
|
160 | 166 | if (!$rs || !($data = $rs->fetch())) |
161 | 167 | { |
162 | 168 | return false; |
@@ -166,7 +172,10 @@ discard block |
||
166 | 172 | $data['account_id'] = -$data['account_id']; |
167 | 173 | $data['mailAllowed'] = true; |
168 | 174 | } |
169 | - if (!$data['account_firstname']) $data['account_firstname'] = $data['account_lid']; |
|
175 | + if (!$data['account_firstname']) |
|
176 | + { |
|
177 | + $data['account_firstname'] = $data['account_lid']; |
|
178 | + } |
|
170 | 179 | if (!$data['account_lastname']) |
171 | 180 | { |
172 | 181 | $data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User'; |
@@ -177,7 +186,10 @@ discard block |
||
177 | 186 | $data['account_lastname'] = lang($data['account_lastname']); |
178 | 187 | } |
179 | 188 | } |
180 | - if (!$data['account_fullname']) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname']; |
|
189 | + if (!$data['account_fullname']) |
|
190 | + { |
|
191 | + $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname']; |
|
192 | + } |
|
181 | 193 | |
182 | 194 | return $data; |
183 | 195 | } |
@@ -199,31 +211,57 @@ discard block |
||
199 | 211 | { |
200 | 212 | // if password it's not already entcrypted, do so now |
201 | 213 | if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) && |
202 | - !preg_match('/^[0-9a-f]{32}$/',$data['account_passwd'])) // md5 hash |
|
214 | + !preg_match('/^[0-9a-f]{32}$/',$data['account_passwd'])) |
|
215 | + { |
|
216 | + // md5 hash |
|
203 | 217 | { |
204 | 218 | $data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']); |
205 | 219 | } |
220 | + } |
|
206 | 221 | $to_write['account_pwd'] = $data['account_passwd']; |
207 | 222 | $to_write['account_lastpwd_change'] = time(); |
208 | 223 | } |
209 | - if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0; |
|
224 | + if ($data['mustchangepassword'] == 1) |
|
225 | + { |
|
226 | + $to_write['account_lastpwd_change']=0; |
|
227 | + } |
|
210 | 228 | if (!(int)$data['account_id'] || !$this->id2name($data['account_id'])) |
211 | 229 | { |
212 | - if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1; |
|
230 | + if ($to_write['account_id'] < 0) |
|
231 | + { |
|
232 | + $to_write['account_id'] *= -1; |
|
233 | + } |
|
213 | 234 | |
214 | - if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = ''; // is NOT NULL! |
|
215 | - if (!isset($to_write['account_status'])) $to_write['account_status'] = ''; // is NOT NULL! |
|
235 | + if (!isset($to_write['account_pwd'])) |
|
236 | + { |
|
237 | + $to_write['account_pwd'] = ''; |
|
238 | + } |
|
239 | + // is NOT NULL! |
|
240 | + if (!isset($to_write['account_status'])) |
|
241 | + { |
|
242 | + $to_write['account_status'] = ''; |
|
243 | + } |
|
244 | + // is NOT NULL! |
|
216 | 245 | |
217 | 246 | // postgres requires the auto-id field to be unset! |
218 | - if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']); |
|
247 | + if (isset($to_write['account_id']) && !$to_write['account_id']) |
|
248 | + { |
|
249 | + unset($to_write['account_id']); |
|
250 | + } |
|
219 | 251 | |
220 | 252 | if (!in_array($to_write['account_type'],array('u','g')) || |
221 | - !$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false; |
|
253 | + !$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) |
|
254 | + { |
|
255 | + return false; |
|
256 | + } |
|
222 | 257 | |
223 | 258 | if (!(int)$data['account_id']) |
224 | 259 | { |
225 | 260 | $data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id'); |
226 | - if ($data['account_type'] == 'g') $data['account_id'] *= -1; |
|
261 | + if ($data['account_type'] == 'g') |
|
262 | + { |
|
263 | + $data['account_id'] *= -1; |
|
264 | + } |
|
227 | 265 | } |
228 | 266 | } |
229 | 267 | else // update of existing account |
@@ -276,7 +314,10 @@ discard block |
||
276 | 314 | */ |
277 | 315 | function delete($account_id) |
278 | 316 | { |
279 | - if (!(int)$account_id) return false; |
|
317 | + if (!(int)$account_id) |
|
318 | + { |
|
319 | + return false; |
|
320 | + } |
|
280 | 321 | |
281 | 322 | $contact_id = $this->id2name($account_id,'person_id'); |
282 | 323 | |
@@ -286,7 +327,10 @@ discard block |
||
286 | 327 | } |
287 | 328 | if ($contact_id) |
288 | 329 | { |
289 | - if (!isset($this->contacts)) $this->contacts = new Api\Contacts(); |
|
330 | + if (!isset($this->contacts)) |
|
331 | + { |
|
332 | + $this->contacts = new Api\Contacts(); |
|
333 | + } |
|
290 | 334 | $this->contacts->delete($contact_id,false); // false = allow to delete accounts (!) |
291 | 335 | } |
292 | 336 | return true; |
@@ -300,7 +344,10 @@ discard block |
||
300 | 344 | */ |
301 | 345 | function memberships($account_id) |
302 | 346 | { |
303 | - if (!(int)$account_id) return false; |
|
347 | + if (!(int)$account_id) |
|
348 | + { |
|
349 | + return false; |
|
350 | + } |
|
304 | 351 | |
305 | 352 | $memberships = array(); |
306 | 353 | if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id))) |
@@ -321,7 +368,10 @@ discard block |
||
321 | 368 | */ |
322 | 369 | function set_memberships($groups,$account_id) |
323 | 370 | { |
324 | - if (!(int)$account_id) return; |
|
371 | + if (!(int)$account_id) |
|
372 | + { |
|
373 | + return; |
|
374 | + } |
|
325 | 375 | |
326 | 376 | $acl = new Api\Acl($account_id); |
327 | 377 | $acl->read_repository(); |
@@ -342,7 +392,10 @@ discard block |
||
342 | 392 | */ |
343 | 393 | function members($account_id) |
344 | 394 | { |
345 | - if (!is_numeric($account_id)) $account_id = $this->name2id($account_id); |
|
395 | + if (!is_numeric($account_id)) |
|
396 | + { |
|
397 | + $account_id = $this->name2id($account_id); |
|
398 | + } |
|
346 | 399 | |
347 | 400 | $members = array(); |
348 | 401 | foreach($this->db->select($this->table, 'account_id,account_lid', |
@@ -418,7 +471,10 @@ discard block |
||
418 | 471 | { |
419 | 472 | $order .= ($order?',':'').'account_lid'; |
420 | 473 | } |
421 | - if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort']; |
|
474 | + if ($param['sort']) |
|
475 | + { |
|
476 | + $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort']; |
|
477 | + } |
|
422 | 478 | |
423 | 479 | $search_cols = array('account_lid','n_family','n_given','email'); |
424 | 480 | $join = $this->contacts_join; |
@@ -455,7 +511,10 @@ discard block |
||
455 | 511 | { |
456 | 512 | unset($name); |
457 | 513 | $members = array_unique(array_merge($members, array_keys((array)$this->members($grp)))); |
458 | - if ($param['type'] == 'groupmembers+memberships') $members[] = abs($grp); |
|
514 | + if ($param['type'] == 'groupmembers+memberships') |
|
515 | + { |
|
516 | + $members[] = abs($grp); |
|
517 | + } |
|
459 | 518 | } |
460 | 519 | $filter['account_id'] = $members; |
461 | 520 | break; |
@@ -474,9 +533,12 @@ discard block |
||
474 | 533 | // fix ambigous account_id (used in accounts and contacts table) |
475 | 534 | if (array_key_exists('account_id', $filter)) |
476 | 535 | { |
477 | - if (!$filter['account_id']) // eg. group without members (would give SQL error) |
|
536 | + if (!$filter['account_id']) |
|
537 | + { |
|
538 | + // eg. group without members (would give SQL error) |
|
478 | 539 | { |
479 | 540 | $this->total = 0; |
541 | + } |
|
480 | 542 | return array(); |
481 | 543 | } |
482 | 544 | $filter[] = $this->db->expression($this->table, $this->table.'.', array( |
@@ -528,7 +590,10 @@ discard block |
||
528 | 590 | break; |
529 | 591 | } |
530 | 592 | } |
531 | - if (!isset($this->contacts)) $this->contacts = new Api\Contacts(); |
|
593 | + if (!isset($this->contacts)) |
|
594 | + { |
|
595 | + $this->contacts = new Api\Contacts(); |
|
596 | + } |
|
532 | 597 | |
533 | 598 | $accounts = array(); |
534 | 599 | foreach((array) $this->contacts->search($criteria, |
@@ -578,7 +643,10 @@ discard block |
||
578 | 643 | */ |
579 | 644 | function name2id($name,$which='account_lid',$account_type=null) |
580 | 645 | { |
581 | - if ($account_type === 'g' && $which != 'account_lid') return false; |
|
646 | + if ($account_type === 'g' && $which != 'account_lid') |
|
647 | + { |
|
648 | + return false; |
|
649 | + } |
|
582 | 650 | |
583 | 651 | $where = array(); |
584 | 652 | $cols = 'account_id'; |
@@ -601,9 +669,12 @@ discard block |
||
601 | 669 | $cols .= ',account_type'; |
602 | 670 | $where[$which] = $name; |
603 | 671 | // check if we need to treat username case-insensitive |
604 | - if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username']) // = is case sensitiv eg. on postgres, but not on mysql! |
|
672 | + if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username']) |
|
673 | + { |
|
674 | + // = is case sensitiv eg. on postgres, but not on mysql! |
|
605 | 675 | { |
606 | 676 | $where[] = 'account_lid '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($where['account_lid']); |
677 | + } |
|
607 | 678 | unset($where['account_lid']); |
608 | 679 | } |
609 | 680 | } |
@@ -198,38 +198,38 @@ discard block |
||
198 | 198 | if ($data['account_passwd']) |
199 | 199 | { |
200 | 200 | // if password it's not already entcrypted, do so now |
201 | - if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) && |
|
202 | - !preg_match('/^[0-9a-f]{32}$/',$data['account_passwd'])) // md5 hash |
|
201 | + if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $data['account_passwd']) && |
|
202 | + !preg_match('/^[0-9a-f]{32}$/', $data['account_passwd'])) // md5 hash |
|
203 | 203 | { |
204 | 204 | $data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']); |
205 | 205 | } |
206 | 206 | $to_write['account_pwd'] = $data['account_passwd']; |
207 | 207 | $to_write['account_lastpwd_change'] = time(); |
208 | 208 | } |
209 | - if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0; |
|
209 | + if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change'] = 0; |
|
210 | 210 | if (!(int)$data['account_id'] || !$this->id2name($data['account_id'])) |
211 | 211 | { |
212 | 212 | if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1; |
213 | 213 | |
214 | - if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = ''; // is NOT NULL! |
|
215 | - if (!isset($to_write['account_status'])) $to_write['account_status'] = ''; // is NOT NULL! |
|
214 | + if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = ''; // is NOT NULL! |
|
215 | + if (!isset($to_write['account_status'])) $to_write['account_status'] = ''; // is NOT NULL! |
|
216 | 216 | |
217 | 217 | // postgres requires the auto-id field to be unset! |
218 | 218 | if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']); |
219 | 219 | |
220 | - if (!in_array($to_write['account_type'],array('u','g')) || |
|
221 | - !$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false; |
|
220 | + if (!in_array($to_write['account_type'], array('u', 'g')) || |
|
221 | + !$this->db->insert($this->table, $to_write, false, __LINE__, __FILE__)) return false; |
|
222 | 222 | |
223 | 223 | if (!(int)$data['account_id']) |
224 | 224 | { |
225 | - $data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id'); |
|
225 | + $data['account_id'] = $this->db->get_last_insert_id($this->table, 'account_id'); |
|
226 | 226 | if ($data['account_type'] == 'g') $data['account_id'] *= -1; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | else // update of existing account |
230 | 230 | { |
231 | 231 | unset($to_write['account_id']); |
232 | - if (!$this->db->update($this->table,$to_write,array('account_id' => abs($data['account_id'])),__LINE__,__FILE__)) |
|
232 | + if (!$this->db->update($this->table, $to_write, array('account_id' => abs($data['account_id'])), __LINE__, __FILE__)) |
|
233 | 233 | { |
234 | 234 | return false; |
235 | 235 | } |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | { |
278 | 278 | if (!(int)$account_id) return false; |
279 | 279 | |
280 | - $contact_id = $this->id2name($account_id,'person_id'); |
|
280 | + $contact_id = $this->id2name($account_id, 'person_id'); |
|
281 | 281 | |
282 | - if (!$this->db->delete($this->table,array('account_id' => abs($account_id)),__LINE__,__FILE__)) |
|
282 | + if (!$this->db->delete($this->table, array('account_id' => abs($account_id)), __LINE__, __FILE__)) |
|
283 | 283 | { |
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | if ($contact_id) |
287 | 287 | { |
288 | 288 | if (!isset($this->contacts)) $this->contacts = new Api\Contacts(); |
289 | - $this->contacts->delete($contact_id,false); // false = allow to delete accounts (!) |
|
289 | + $this->contacts->delete($contact_id, false); // false = allow to delete accounts (!) |
|
290 | 290 | } |
291 | 291 | return true; |
292 | 292 | } |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | if (!(int)$account_id) return false; |
303 | 303 | |
304 | 304 | $memberships = array(); |
305 | - if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id))) |
|
305 | + if (($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id))) |
|
306 | 306 | { |
307 | - foreach($gids as $gid) |
|
307 | + foreach ($gids as $gid) |
|
308 | 308 | { |
309 | - $memberships[(string) $gid] = $this->id2name($gid); |
|
309 | + $memberships[(string)$gid] = $this->id2name($gid); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | return $memberships; |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | * @param array $groups array with gidnumbers |
319 | 319 | * @param int $account_id numerical account-id |
320 | 320 | */ |
321 | - function set_memberships($groups,$account_id) |
|
321 | + function set_memberships($groups, $account_id) |
|
322 | 322 | { |
323 | 323 | if (!(int)$account_id) return; |
324 | 324 | |
325 | 325 | $acl = new Api\Acl($account_id); |
326 | 326 | $acl->read_repository(); |
327 | - $acl->delete('phpgw_group',false); |
|
327 | + $acl->delete('phpgw_group', false); |
|
328 | 328 | |
329 | - foreach($groups as $group) |
|
329 | + foreach ($groups as $group) |
|
330 | 330 | { |
331 | - $acl->add('phpgw_group',$group,1); |
|
331 | + $acl->add('phpgw_group', $group, 1); |
|
332 | 332 | } |
333 | 333 | $acl->save_repository(); |
334 | 334 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | if (!is_numeric($account_id)) $account_id = $this->name2id($account_id); |
345 | 345 | |
346 | 346 | $members = array(); |
347 | - foreach($this->db->select($this->table, 'account_id,account_lid', |
|
347 | + foreach ($this->db->select($this->table, 'account_id,account_lid', |
|
348 | 348 | $this->db->expression(Api\Acl::TABLE, array( |
349 | 349 | 'acl_appname' => 'phpgw_group', |
350 | 350 | 'acl_location' => $account_id, |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | * @param array $members array with uidnumber or uid's |
364 | 364 | * @param int $gid gidnumber of group to set |
365 | 365 | */ |
366 | - function set_members($members,$gid) |
|
366 | + function set_members($members, $gid) |
|
367 | 367 | { |
368 | - $GLOBALS['egw']->acl->delete_repository('phpgw_group',$gid,false); |
|
368 | + $GLOBALS['egw']->acl->delete_repository('phpgw_group', $gid, false); |
|
369 | 369 | |
370 | 370 | if (is_array($members)) |
371 | 371 | { |
372 | - foreach($members as $id) |
|
372 | + foreach ($members as $id) |
|
373 | 373 | { |
374 | - $GLOBALS['egw']->acl->add_repository('phpgw_group',$gid,$id,1); |
|
374 | + $GLOBALS['egw']->acl->add_repository('phpgw_group', $gid, $id, 1); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | } |
@@ -406,21 +406,21 @@ discard block |
||
406 | 406 | ); |
407 | 407 | |
408 | 408 | // fetch order of account_fullname from Api\Accounts::format_username |
409 | - if (strpos($param['order'],'account_fullname') !== false) |
|
409 | + if (strpos($param['order'], 'account_fullname') !== false) |
|
410 | 410 | { |
411 | - $param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/',',',str_replace(array('[',']'),'', |
|
412 | - Api\Accounts::format_username('account_lid','account_firstname','account_lastname'))), $param['order']); |
|
411 | + $param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/', ',', str_replace(array('[', ']'), '', |
|
412 | + Api\Accounts::format_username('account_lid', 'account_firstname', 'account_lastname'))), $param['order']); |
|
413 | 413 | } |
414 | - $order = str_replace(array_keys($order2contact),array_values($order2contact),$param['order']); |
|
414 | + $order = str_replace(array_keys($order2contact), array_values($order2contact), $param['order']); |
|
415 | 415 | |
416 | 416 | // allways add 'account_lid' |
417 | 417 | if (strpos($order, 'account_lid') === false) |
418 | 418 | { |
419 | - $order .= ($order?',':'').'account_lid'; |
|
419 | + $order .= ($order ? ',' : '').'account_lid'; |
|
420 | 420 | } |
421 | 421 | if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort']; |
422 | 422 | |
423 | - $search_cols = array('account_lid','n_family','n_given','email'); |
|
423 | + $search_cols = array('account_lid', 'n_family', 'n_given', 'email'); |
|
424 | 424 | $join = $this->contacts_join; |
425 | 425 | $email_cols = array('email'); |
426 | 426 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | } |
437 | 437 | |
438 | 438 | $filter = array(); |
439 | - switch($param['type']) |
|
439 | + switch ($param['type']) |
|
440 | 440 | { |
441 | 441 | case 'accounts': |
442 | 442 | $filter['owner'] = 0; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | case 'groupmembers': |
452 | 452 | case 'groupmembers+memberships': |
453 | 453 | $members = array(); |
454 | - foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name) |
|
454 | + foreach ((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name) |
|
455 | 455 | { |
456 | 456 | unset($name); |
457 | 457 | $members = array_unique(array_merge($members, array_keys((array)$this->members($grp)))); |
@@ -486,13 +486,13 @@ discard block |
||
486 | 486 | } |
487 | 487 | if ($param['active']) |
488 | 488 | { |
489 | - $filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER); |
|
489 | + $filter[] = str_replace('UNIX_TIMESTAMP(NOW())', time(), Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER); |
|
490 | 490 | } |
491 | 491 | $criteria = array(); |
492 | 492 | $wildcard = $param['query_type'] == 'start' || $param['query_type'] == 'exact' ? '' : '%'; |
493 | 493 | if (($query = $param['query'])) |
494 | 494 | { |
495 | - switch($param['query_type']) |
|
495 | + switch ($param['query_type']) |
|
496 | 496 | { |
497 | 497 | case 'start': |
498 | 498 | $query .= '*'; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | case 'all': |
501 | 501 | default: |
502 | 502 | case 'exact': |
503 | - foreach($search_cols as $col) |
|
503 | + foreach ($search_cols as $col) |
|
504 | 504 | { |
505 | 505 | $criteria[$col] = $query; |
506 | 506 | } |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | case 'email': |
522 | 522 | $criteria['email'] = $query; |
523 | 523 | // Group email |
524 | - if(in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true))) |
|
524 | + if (in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true))) |
|
525 | 525 | { |
526 | 526 | $criteria[Api\Mail\Smtp\Sql::TABLE.'.mail_value'] = $query; |
527 | 527 | } |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | if (!isset($this->contacts)) $this->contacts = new Api\Contacts(); |
532 | 532 | |
533 | 533 | $accounts = array(); |
534 | - foreach((array) $this->contacts->search($criteria, |
|
535 | - array_merge(array(1,'n_given','n_family','id','created','modified',$this->table.'.account_id AS account_id'),$email_cols), |
|
534 | + foreach ((array)$this->contacts->search($criteria, |
|
535 | + array_merge(array(1, 'n_given', 'n_family', 'id', 'created', 'modified', $this->table.'.account_id AS account_id'), $email_cols), |
|
536 | 536 | $order, "account_lid,account_type,account_status,account_expires,account_primary_group,account_description". |
537 | 537 | ",account_lastlogin,account_lastloginfrom,account_lastpwd_change", |
538 | - $wildcard,false,$query[0] == '!' ? 'AND' : 'OR', |
|
538 | + $wildcard, false, $query[0] == '!' ? 'AND' : 'OR', |
|
539 | 539 | $param['offset'] ? array($param['start'], $param['offset']) : (is_null($param['start']) ? false : $param['start']), |
540 | - $filter,$join) as $contact) |
|
540 | + $filter, $join) as $contact) |
|
541 | 541 | { |
542 | 542 | if ($contact) |
543 | 543 | { |
@@ -582,13 +582,13 @@ discard block |
||
582 | 582 | * @param string $account_type u = user, g = group, default null = try both |
583 | 583 | * @return int/false numeric account_id or false on error ($name not found) |
584 | 584 | */ |
585 | - function name2id($name,$which='account_lid',$account_type=null) |
|
585 | + function name2id($name, $which = 'account_lid', $account_type = null) |
|
586 | 586 | { |
587 | 587 | if ($account_type === 'g' && $which != 'account_lid') return false; |
588 | 588 | |
589 | 589 | $where = array(); |
590 | 590 | $cols = 'account_id'; |
591 | - switch($which) |
|
591 | + switch ($which) |
|
592 | 592 | { |
593 | 593 | case 'account_fullname': |
594 | 594 | $table = $this->contacts_table; |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | } |
620 | 620 | else |
621 | 621 | { |
622 | - $where[] = 'account_id IS NOT NULL'. // otherwise contacts with eg. the same email hide the accounts! |
|
623 | - ($table == $this->contacts_table ? " AND contact_tid != 'D'" : ''); // ignore deleted accounts contact-data |
|
622 | + $where[] = 'account_id IS NOT NULL'.// otherwise contacts with eg. the same email hide the accounts! |
|
623 | + ($table == $this->contacts_table ? " AND contact_tid != 'D'" : ''); // ignore deleted accounts contact-data |
|
624 | 624 | |
625 | 625 | } |
626 | - if (!($rs = $this->db->select($table,$cols,$where,__LINE__,__FILE__)) || !($row = $rs->fetch())) |
|
626 | + if (!($rs = $this->db->select($table, $cols, $where, __LINE__, __FILE__)) || !($row = $rs->fetch())) |
|
627 | 627 | { |
628 | 628 | //error_log(__METHOD__."('$name', '$which', ".array2string($account_type).") db->select('$table', '$cols', ".array2string($where).") returned ".array2string($rs).' '.function_backtrace()); |
629 | 629 | return false; |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | * @param string $which ='account_lid' type to convert to: account_lid (default), account_email, ... |
641 | 641 | * @return string/false converted value or false on error ($account_id not found) |
642 | 642 | */ |
643 | - function id2name($account_id,$which='account_lid') |
|
643 | + function id2name($account_id, $which = 'account_lid') |
|
644 | 644 | { |
645 | - return $this->frontend->id2name($account_id,$which); |
|
645 | + return $this->frontend->id2name($account_id, $which); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | */ |
655 | 655 | function update_lastlogin($account_id, $ip) |
656 | 656 | { |
657 | - $previous_login = $this->db->select($this->table,'account_lastlogin',array('account_id'=>abs($account_id)),__LINE__,__FILE__)->fetchColumn(); |
|
657 | + $previous_login = $this->db->select($this->table, 'account_lastlogin', array('account_id'=>abs($account_id)), __LINE__, __FILE__)->fetchColumn(); |
|
658 | 658 | |
659 | - $this->db->update($this->table,array( |
|
659 | + $this->db->update($this->table, array( |
|
660 | 660 | 'account_lastloginfrom' => $ip, |
661 | 661 | 'account_lastlogin' => time(), |
662 | - ),array( |
|
662 | + ), array( |
|
663 | 663 | 'account_id' => abs($account_id), |
664 | - ),__LINE__,__FILE__); |
|
664 | + ), __LINE__, __FILE__); |
|
665 | 665 | |
666 | 666 | return $previous_login; |
667 | 667 | } |
@@ -50,7 +50,10 @@ discard block |
||
50 | 50 | else |
51 | 51 | { |
52 | 52 | $this->base_path = Api\Cache::get_system_config('temp_dir', false); |
53 | - if (isset($this->base_path)) $this->base_path .= '/egw_cache'; |
|
53 | + if (isset($this->base_path)) |
|
54 | + { |
|
55 | + $this->base_path .= '/egw_cache'; |
|
56 | + } |
|
54 | 57 | } |
55 | 58 | if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true)) |
56 | 59 | { |
@@ -86,7 +89,10 @@ discard block |
||
86 | 89 | { |
87 | 90 | flock($ret, LOCK_EX); |
88 | 91 | $ok = fwrite($ret, serialize($data)); |
89 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
92 | + if ((int)$expiration > 0) |
|
93 | + { |
|
94 | + file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
95 | + } |
|
90 | 96 | flock($ret, LOCK_UN); |
91 | 97 | fclose($ret); |
92 | 98 | $ret = $ok !== false; |
@@ -106,7 +112,10 @@ discard block |
||
106 | 112 | { |
107 | 113 | if (($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0)) |
108 | 114 | { |
109 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
115 | + if ((int)$expiration > 0) |
|
116 | + { |
|
117 | + file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
118 | + } |
|
110 | 119 | } |
111 | 120 | return $ret; |
112 | 121 | } |
@@ -182,17 +191,26 @@ discard block |
||
182 | 191 | } |
183 | 192 | foreach(scandir($path) as $file) |
184 | 193 | { |
185 | - if ($file == '.' || $file == '..') continue; |
|
194 | + if ($file == '.' || $file == '..') |
|
195 | + { |
|
196 | + continue; |
|
197 | + } |
|
186 | 198 | |
187 | 199 | $file = $path.'/'.$file; |
188 | 200 | |
189 | 201 | if (is_dir($file)) |
190 | 202 | { |
191 | - if (!self::rm_recursive($file)) return false; |
|
203 | + if (!self::rm_recursive($file)) |
|
204 | + { |
|
205 | + return false; |
|
206 | + } |
|
192 | 207 | } |
193 | 208 | else |
194 | 209 | { |
195 | - if (!unlink($file)) return false; |
|
210 | + if (!unlink($file)) |
|
211 | + { |
|
212 | + return false; |
|
213 | + } |
|
196 | 214 | } |
197 | 215 | } |
198 | 216 | return rmdir($path); |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | $this->base_path = Api\Cache::get_system_config('temp_dir', false); |
53 | 53 | if (isset($this->base_path)) $this->base_path .= '/egw_cache'; |
54 | 54 | } |
55 | - if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path,0700,true)) |
|
55 | + if (!isset($this->base_path) || !file_exists($this->base_path) && !mkdir($this->base_path, 0700, true)) |
|
56 | 56 | { |
57 | - throw new Exception (__METHOD__."() can't create basepath $this->base_path!"); |
|
57 | + throw new Exception(__METHOD__."() can't create basepath $this->base_path!"); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | * @param int $expiration =0 |
67 | 67 | * @return boolean true on success, false on error, incl. key already exists in cache |
68 | 68 | */ |
69 | - function add(array $keys,$data,$expiration=0) |
|
69 | + function add(array $keys, $data, $expiration = 0) |
|
70 | 70 | { |
71 | 71 | // open only if file does NOT exist |
72 | - if (!($ret = @fopen($fname=$this->filename($keys,true), 'x'))) |
|
72 | + if (!($ret = @fopen($fname = $this->filename($keys, true), 'x'))) |
|
73 | 73 | { |
74 | 74 | // if file exists, check if it is expired |
75 | - if (file_exists($fname_expiration=$fname.self::EXPIRATION_EXTENSION) && |
|
75 | + if (file_exists($fname_expiration = $fname.self::EXPIRATION_EXTENSION) && |
|
76 | 76 | ($expiration = (int)file_get_contents($fname_expiration)) && |
77 | - filemtime($fname) < time()-$expiration) |
|
77 | + filemtime($fname) < time() - $expiration) |
|
78 | 78 | { |
79 | 79 | // open and truncate it |
80 | 80 | $ret = fopen($fname, 'w'); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | flock($ret, LOCK_EX); |
88 | 88 | $ok = fwrite($ret, serialize($data)); |
89 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
89 | + if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION, (string)$expiration); |
|
90 | 90 | flock($ret, LOCK_UN); |
91 | 91 | fclose($ret); |
92 | 92 | $ret = $ok !== false; |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @param int $expiration =0 |
103 | 103 | * @return boolean true on success, false on error |
104 | 104 | */ |
105 | - function set(array $keys,$data,$expiration=0) |
|
105 | + function set(array $keys, $data, $expiration = 0) |
|
106 | 106 | { |
107 | - if (($ret = @file_put_contents($fname=$this->filename($keys,true),serialize($data),LOCK_EX) > 0)) |
|
107 | + if (($ret = @file_put_contents($fname = $this->filename($keys, true), serialize($data), LOCK_EX) > 0)) |
|
108 | 108 | { |
109 | - if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION,(string)$expiration); |
|
109 | + if ((int)$expiration > 0) file_put_contents($fname.self::EXPIRATION_EXTENSION, (string)$expiration); |
|
110 | 110 | } |
111 | 111 | return $ret; |
112 | 112 | } |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | { |
124 | 124 | return null; |
125 | 125 | } |
126 | - if (file_exists($fname_expiration=$fname.self::EXPIRATION_EXTENSION) && |
|
126 | + if (file_exists($fname_expiration = $fname.self::EXPIRATION_EXTENSION) && |
|
127 | 127 | ($expiration = (int)file_get_contents($fname_expiration)) && |
128 | - filemtime($fname) < time()-$expiration) |
|
128 | + filemtime($fname) < time() - $expiration) |
|
129 | 129 | { |
130 | 130 | unlink($fname); |
131 | 131 | unlink($fname_expiration); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | //error_log(__METHOD__.'('.array2string($keys).") file_exists('$fname') == FALSE!"); |
148 | 148 | return false; |
149 | 149 | } |
150 | - if (file_exists($fname_expiration=$fname.self::EXPIRATION_EXTENSION)) |
|
150 | + if (file_exists($fname_expiration = $fname.self::EXPIRATION_EXTENSION)) |
|
151 | 151 | { |
152 | 152 | unlink($fname_expiration); |
153 | 153 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | return unlink($path); |
182 | 182 | } |
183 | - foreach(scandir($path) as $file) |
|
183 | + foreach (scandir($path) as $file) |
|
184 | 184 | { |
185 | 185 | if ($file == '.' || $file == '..') continue; |
186 | 186 | |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | * @param boolean $mkdir =false should we create the directory |
206 | 206 | * @return string |
207 | 207 | */ |
208 | - function filename(array $keys,$mkdir=false) |
|
208 | + function filename(array $keys, $mkdir = false) |
|
209 | 209 | { |
210 | - $fname = $this->base_path.'/'.str_replace(array(':','*','\\'),'-',implode('/',$keys)); |
|
210 | + $fname = $this->base_path.'/'.str_replace(array(':', '*', '\\'), '-', implode('/', $keys)); |
|
211 | 211 | |
212 | - if ($mkdir && !file_exists($dirname=dirname($fname))) |
|
212 | + if ($mkdir && !file_exists($dirname = dirname($fname))) |
|
213 | 213 | { |
214 | - @mkdir($dirname,0700,true); |
|
214 | + @mkdir($dirname, 0700, true); |
|
215 | 215 | } |
216 | 216 | return $fname; |
217 | 217 | } |
@@ -18,4 +18,6 @@ |
||
18 | 18 | /** |
19 | 19 | * Exception thrown by Cache classes |
20 | 20 | */ |
21 | -class Exception extends Api\Exception {} |
|
21 | +class Exception extends Api\Exception |
|
22 | +{ |
|
23 | +} |
@@ -90,7 +90,10 @@ discard block |
||
90 | 90 | if (($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u'))) |
91 | 91 | { |
92 | 92 | $ret = $GLOBALS['egw']->accounts->id2name($id,'account_status') == 'A'; |
93 | - if (!$ret) error_log(__METHOD__."('$username') account_status check returning ".array2string($ret)); |
|
93 | + if (!$ret) |
|
94 | + { |
|
95 | + error_log(__METHOD__."('$username') account_status check returning ".array2string($ret)); |
|
96 | + } |
|
94 | 97 | return $ret; |
95 | 98 | } |
96 | 99 | // store homedirectory for egw_session->read_repositories |
@@ -158,7 +161,10 @@ discard block |
||
158 | 161 | static function setLastPwdChange($account_id=0, $passwd=NULL, $lastpwdchange=NULL, $return_mod=false) |
159 | 162 | { |
160 | 163 | unset($passwd); // not used but required by function signature |
161 | - if (!($adldap = Api\Accounts\Ads::get_adldap())) return false; |
|
164 | + if (!($adldap = Api\Accounts\Ads::get_adldap())) |
|
165 | + { |
|
166 | + return false; |
|
167 | + } |
|
162 | 168 | |
163 | 169 | if ($lastpwdchange) |
164 | 170 | { |
@@ -166,7 +172,10 @@ discard block |
||
166 | 172 | $ldapServerInfo = Api\Ldap\ServerInfo::get($adldap->getLdapConnection(), $GLOBALS['egw_info']['server']['ads_host']); |
167 | 173 | if ($ldapServerInfo->serverType == Api\Ldap\ServerInfo::SAMBA4) |
168 | 174 | { |
169 | - if ($lastpwdchange == -1) $lastpwdchange = time(); |
|
175 | + if ($lastpwdchange == -1) |
|
176 | + { |
|
177 | + $lastpwdchange = time(); |
|
178 | + } |
|
170 | 179 | } |
171 | 180 | // while Windows only allows to set -1 for current time (or 0 to force user to change password) |
172 | 181 | else |
@@ -179,7 +188,10 @@ discard block |
||
179 | 188 | $lastpwdchange = Api\Accounts\Ads::convertUnixTimeToWindowsTime($lastpwdchange); |
180 | 189 | } |
181 | 190 | $mod = array('pwdlastset' => $lastpwdchange); |
182 | - if ($return_mod) return $mod; |
|
191 | + if ($return_mod) |
|
192 | + { |
|
193 | + return $mod; |
|
194 | + } |
|
183 | 195 | |
184 | 196 | $ret = false; |
185 | 197 | if ($account_id && ($username = Api\Accounts::id2name($account_id, 'account_lid')) && |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
39 | 39 | * @return boolean true if successful authenticated, false otherwise |
40 | 40 | */ |
41 | - function authenticate($username, $_passwd, $passwd_type='text') |
|
41 | + function authenticate($username, $_passwd, $passwd_type = 'text') |
|
42 | 42 | { |
43 | - unset($passwd_type); // not used by required in function signature |
|
44 | - if (preg_match('/[()|&=*,<>!~]/',$username)) |
|
43 | + unset($passwd_type); // not used by required in function signature |
|
44 | + if (preg_match('/[()|&=*,<>!~]/', $username)) |
|
45 | 45 | { |
46 | 46 | return False; |
47 | 47 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | $adldap = Api\Accounts\Ads::get_adldap(); |
52 | 52 | // bind with username@ads_domain, only if a non-empty password given, in case anonymous search is enabled |
53 | - if(empty($passwd) || !$adldap->authenticate($username, $passwd)) |
|
53 | + if (empty($passwd) || !$adldap->authenticate($username, $passwd)) |
|
54 | 54 | { |
55 | 55 | $authenticated = false; |
56 | 56 | // check if password need to be set on next login (AD will not authenticate user!) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - $attributes = array('samaccountname','givenName','sn','mail','homeDirectory'); |
|
73 | + $attributes = array('samaccountname', 'givenName', 'sn', 'mail', 'homeDirectory'); |
|
74 | 74 | if (($allValues = $adldap->user()->info($username, $attributes))) |
75 | 75 | { |
76 | 76 | $allValues[0]['objectsid'][0] = $adldap->utilities()->getTextSID($allValues[0]['objectsid'][0]); |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | |
80 | 80 | if ($allValues && $allValues['count'] > 0) |
81 | 81 | { |
82 | - if($GLOBALS['egw_info']['server']['case_sensitive_username'] == true) |
|
82 | + if ($GLOBALS['egw_info']['server']['case_sensitive_username'] == true) |
|
83 | 83 | { |
84 | - if($allValues[0]['samaccountname'][0] != $username) |
|
84 | + if ($allValues[0]['samaccountname'][0] != $username) |
|
85 | 85 | { |
86 | 86 | error_log(__METHOD__."('$username') username has wrong case!"); |
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | } |
90 | - if (($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u'))) |
|
90 | + if (($id = $GLOBALS['egw']->accounts->name2id($username, 'account_lid', 'u'))) |
|
91 | 91 | { |
92 | - $ret = $GLOBALS['egw']->accounts->id2name($id,'account_status') == 'A'; |
|
92 | + $ret = $GLOBALS['egw']->accounts->id2name($id, 'account_status') == 'A'; |
|
93 | 93 | if (!$ret) error_log(__METHOD__."('$username') account_status check returning ".array2string($ret)); |
94 | 94 | return $ret; |
95 | 95 | } |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | $GLOBALS['auto_create_acct']['account_id'] = Api\Accounts\Ads::sid2account_id($allValues[0]['objectsid'][0]); |
105 | 105 | |
106 | 106 | // create a global array with all availible info about that account |
107 | - foreach(array( |
|
107 | + foreach (array( |
|
108 | 108 | 'givenname' => 'firstname', |
109 | 109 | 'sn' => 'lastname', |
110 | 110 | 'mail' => 'email', |
111 | 111 | ) as $ldap_name => $acct_name) |
112 | 112 | { |
113 | 113 | $GLOBALS['auto_create_acct'][$acct_name] = |
114 | - Api\Translation::convert($allValues[0][$ldap_name][0],'utf-8'); |
|
114 | + Api\Translation::convert($allValues[0][$ldap_name][0], 'utf-8'); |
|
115 | 115 | } |
116 | 116 | //error_log(__METHOD__."() \$GLOBALS[auto_create_acct]=".array2string($GLOBALS['auto_create_acct'])); |
117 | 117 | return True; |
@@ -137,8 +137,7 @@ discard block |
||
137 | 137 | if (($adldap = Api\Accounts\Ads::get_adldap()) && |
138 | 138 | ($data = $adldap->user()->info($username, array('pwdlastset')))) |
139 | 139 | { |
140 | - $ret = !$data[0]['pwdlastset'][0] ? $data[0]['pwdlastset'][0] : |
|
141 | - $adldap->utilities()->convertWindowsTimeToUnixTime($data[0]['pwdlastset'][0]); |
|
140 | + $ret = !$data[0]['pwdlastset'][0] ? $data[0]['pwdlastset'][0] : $adldap->utilities()->convertWindowsTimeToUnixTime($data[0]['pwdlastset'][0]); |
|
142 | 141 | } |
143 | 142 | //error_log(__METHOD__."('$username') pwdlastset=".array2string($data[0]['pwdlastset'][0])." returned ".array2string($ret)); |
144 | 143 | return $ret; |
@@ -155,9 +154,9 @@ discard block |
||
155 | 154 | * @param boolean $return_mod =false true return ldap modification instead of executing it |
156 | 155 | * @return boolean|array true if account_lastpwd_change successful changed, false otherwise or array if $return_mod |
157 | 156 | */ |
158 | - static function setLastPwdChange($account_id=0, $passwd=NULL, $lastpwdchange=NULL, $return_mod=false) |
|
157 | + static function setLastPwdChange($account_id = 0, $passwd = NULL, $lastpwdchange = NULL, $return_mod = false) |
|
159 | 158 | { |
160 | - unset($passwd); // not used but required by function signature |
|
159 | + unset($passwd); // not used but required by function signature |
|
161 | 160 | if (!($adldap = Api\Accounts\Ads::get_adldap())) return false; |
162 | 161 | |
163 | 162 | if ($lastpwdchange) |
@@ -200,7 +199,7 @@ discard block |
||
200 | 199 | * @return boolean true if password successful changed, false otherwise |
201 | 200 | * @throws Api\Exception_wrong_userinput |
202 | 201 | */ |
203 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
202 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
204 | 203 | { |
205 | 204 | if (!($adldap = Api\Accounts\Ads::get_adldap())) |
206 | 205 | { |
@@ -213,7 +212,7 @@ discard block |
||
213 | 212 | throw new Api\Exception(lang('Failed to change password.').' '.lang('Active directory requires SSL or TLS to change passwords!')); |
214 | 213 | } |
215 | 214 | |
216 | - if(!$account_id || $GLOBALS['egw_info']['flags']['currentapp'] == 'login') |
|
215 | + if (!$account_id || $GLOBALS['egw_info']['flags']['currentapp'] == 'login') |
|
217 | 216 | { |
218 | 217 | $admin = false; |
219 | 218 | if (!empty($GLOBALS['egw_info']['user']['account_id']) && $GLOBALS['egw_info']['user']['account_id'] > 0) |
@@ -249,7 +248,7 @@ discard block |
||
249 | 248 | // if admin has nothing configured use windows default of 3 char classes, 7 chars min and name-part-check |
250 | 249 | $GLOBALS['egw_info']['server']['force_pwd_strength'] ? $GLOBALS['egw_info']['server']['force_pwd_strength'] : 3, |
251 | 250 | $GLOBALS['egw_info']['server']['force_pwd_length'] ? $GLOBALS['egw_info']['server']['force_pwd_length'] : 7, |
252 | - 'yes', // always check with "passwd_forbid_name" enabled |
|
251 | + 'yes', // always check with "passwd_forbid_name" enabled |
|
253 | 252 | $account_id); |
254 | 253 | $msg = strtr($e->getMessage(), array( // translate possible adLDAP and LDAP error |
255 | 254 | 'Error' => lang('Error'), |