@@ -491,6 +491,10 @@ |
||
| 491 | 491 | protected static function call_hook() |
| 492 | 492 | { |
| 493 | 493 | self::$hook_data = array(); |
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * @param string $appname |
|
| 497 | + */ |
|
| 494 | 498 | function display_section($appname,$file,$file2=False) |
| 495 | 499 | { |
| 496 | 500 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param array $content |
| 42 | 42 | */ |
| 43 | - public function index(array $content=null) |
|
| 43 | + public function index(array $content = null) |
|
| 44 | 44 | { |
| 45 | 45 | if (admin_statistics::check(false)) |
| 46 | 46 | { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | //$content['msg'] = 'Hi Ralf ;-)'; |
| 66 | 66 | $sel_options['tree'] = $this->tree_data(); |
| 67 | 67 | $sel_options['filter'] = array('' => lang('All groups')); |
| 68 | - foreach(self::$accounts->search(array( |
|
| 68 | + foreach (self::$accounts->search(array( |
|
| 69 | 69 | 'type' => 'groups', |
| 70 | 70 | 'start' => false, |
| 71 | 71 | 'order' => 'account_lid', |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | else |
| 98 | 98 | { |
| 99 | - $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
| 99 | + $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $tpl->exec('admin.admin_ui.index', $content, $sel_options); |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | 'caption' => 'Show members', |
| 118 | 118 | 'enableId' => '^/groups/-\\d+', |
| 119 | 119 | 'default' => true, |
| 120 | - 'group' => $group=1, |
|
| 120 | + 'group' => $group = 1, |
|
| 121 | 121 | ), |
| 122 | 122 | 'add' => array( |
| 123 | 123 | 'group' => $group, |
| 124 | - )+$user_actions['add'], |
|
| 124 | + ) + $user_actions['add'], |
|
| 125 | 125 | 'acl' => array( |
| 126 | 126 | 'onExecute' => 'javaScript:app.admin.group', |
| 127 | 127 | 'caption' => 'Access control', |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'group' => 2, |
| 133 | 133 | ), |
| 134 | 134 | ); |
| 135 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
| 135 | + if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin')) // no rights to set ACL-rights |
|
| 136 | 136 | { |
| 137 | 137 | $actions['deny'] = array( |
| 138 | 138 | 'caption' => 'Deny access', |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | 'group' => 2, |
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | - $group = 5; // allow to place actions in different groups by hook, this is the default |
|
| 146 | + $group = 5; // allow to place actions in different groups by hook, this is the default |
|
| 147 | 147 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
| 148 | 148 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group'))); |
| 149 | - foreach($apps as $app) |
|
| 149 | + foreach ($apps as $app) |
|
| 150 | 150 | { |
| 151 | 151 | $GLOBALS['menuData'] = $data = array(); |
| 152 | 152 | $data = Api\Hooks::single('edit_group', $app); |
| 153 | 153 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
| 154 | 154 | //error_log(__METHOD__."() app $app returned ".array2string($data)); |
| 155 | - foreach($data as $item) |
|
| 155 | + foreach ($data as $item) |
|
| 156 | 156 | { |
| 157 | 157 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
| 158 | 158 | if (empty($item['caption'])) |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | 'default' => true, |
| 204 | 204 | 'allowOnMultiple' => false, |
| 205 | 205 | 'onExecute' => 'javaScript:app.admin.account', |
| 206 | - 'group' => $group=0, |
|
| 206 | + 'group' => $group = 0, |
|
| 207 | 207 | ), |
| 208 | 208 | 'add' => array( |
| 209 | 209 | 'caption' => 'Add user', |
@@ -214,25 +214,25 @@ discard block |
||
| 214 | 214 | // generate urls for add/edit accounts via addressbook |
| 215 | 215 | $edit = Link::get_registry('addressbook', 'edit'); |
| 216 | 216 | $edit['account_id'] = '$id'; |
| 217 | - foreach($edit as $name => $val) |
|
| 217 | + foreach ($edit as $name => $val) |
|
| 218 | 218 | { |
| 219 | 219 | $actions['edit']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
| 220 | 220 | } |
| 221 | 221 | unset($edit['account_id']); |
| 222 | 222 | $edit['owner'] = 0; |
| 223 | - foreach($edit as $name => $val) |
|
| 223 | + foreach ($edit as $name => $val) |
|
| 224 | 224 | { |
| 225 | 225 | $actions['add']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
| 226 | 226 | } |
| 227 | 227 | ++$group; |
| 228 | 228 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
| 229 | 229 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_user'))); |
| 230 | - foreach($apps as $app) |
|
| 230 | + foreach ($apps as $app) |
|
| 231 | 231 | { |
| 232 | 232 | $GLOBALS['menuData'] = $data = array(); |
| 233 | 233 | $data = Api\Hooks::single('edit_user', $app); |
| 234 | 234 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
| 235 | - foreach($data as $item) |
|
| 235 | + foreach ($data as $item) |
|
| 236 | 236 | { |
| 237 | 237 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
| 238 | 238 | if (empty($item['caption'])) |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @param array &$rows=null |
| 282 | 282 | * @return int total number of rows available |
| 283 | 283 | */ |
| 284 | - public static function get_users(array $query, array &$rows=null) |
|
| 284 | + public static function get_users(array $query, array &$rows = null) |
|
| 285 | 285 | { |
| 286 | 286 | $params = array( |
| 287 | 287 | 'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts', |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $params['query'] = $query['searchletter']; |
| 297 | 297 | $params['query_type'] = 'start'; |
| 298 | 298 | } |
| 299 | - elseif($query['search']) |
|
| 299 | + elseif ($query['search']) |
|
| 300 | 300 | { |
| 301 | 301 | $params['query'] = $query['search']; |
| 302 | 302 | $params['query_type'] = 'all'; |
@@ -305,13 +305,10 @@ discard block |
||
| 305 | 305 | $rows = array_values(self::$accounts->search($params)); |
| 306 | 306 | //error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total); |
| 307 | 307 | |
| 308 | - foreach($rows as &$row) |
|
| 308 | + foreach ($rows as &$row) |
|
| 309 | 309 | { |
| 310 | 310 | $row['status'] = self::$accounts->is_expired($row) ? |
| 311 | - lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) : |
|
| 312 | - (!self::$accounts->is_active($row) ? lang('Disabled') : |
|
| 313 | - ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : |
|
| 314 | - lang('Enabled'))); |
|
| 311 | + lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) : (!self::$accounts->is_active($row) ? lang('Disabled') : ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : lang('Enabled'))); |
|
| 315 | 312 | |
| 316 | 313 | if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
| 317 | 314 | } |
@@ -352,14 +349,14 @@ discard block |
||
| 352 | 349 | if ($root == '/') |
| 353 | 350 | { |
| 354 | 351 | $hook_data = self::call_hook(); |
| 355 | - foreach($hook_data as $app => $app_data) |
|
| 352 | + foreach ($hook_data as $app => $app_data) |
|
| 356 | 353 | { |
| 357 | - if(!is_array($app_data)) |
|
| 354 | + if (!is_array($app_data)) |
|
| 358 | 355 | { |
| 359 | 356 | // Application has no data |
| 360 | 357 | continue; |
| 361 | 358 | } |
| 362 | - foreach($app_data as $text => $data) |
|
| 359 | + foreach ($app_data as $text => $data) |
|
| 363 | 360 | { |
| 364 | 361 | if (!is_array($data)) |
| 365 | 362 | { |
@@ -390,18 +387,17 @@ discard block |
||
| 390 | 387 | } |
| 391 | 388 | } |
| 392 | 389 | unset($data['icon']); |
| 393 | - $parent =& $tree['item']; |
|
| 390 | + $parent = & $tree['item']; |
|
| 394 | 391 | $parts = explode('/', $data['id']); |
| 395 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
| 392 | + if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
| 396 | 393 | array_pop($parts); |
| 397 | 394 | $path = ''; |
| 398 | - foreach($parts as $part) |
|
| 395 | + foreach ($parts as $part) |
|
| 399 | 396 | { |
| 400 | 397 | $path .= ($path == '/' ? '' : '/').$part; |
| 401 | 398 | if (!isset($parent[$path])) |
| 402 | 399 | { |
| 403 | - $icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') : |
|
| 404 | - (($i=Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav'))); |
|
| 400 | + $icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') : (($i = Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav'))); |
|
| 405 | 401 | $parent[$path] = array( |
| 406 | 402 | 'id' => $path, |
| 407 | 403 | 'text' => $part == 'apps' ? lang('Applications') : lang($part), |
@@ -413,7 +409,7 @@ discard block |
||
| 413 | 409 | ); |
| 414 | 410 | if ($path == '/admin') $parent[$path]['open'] = true; |
| 415 | 411 | } |
| 416 | - $parent =& $parent[$path]['item']; |
|
| 412 | + $parent = & $parent[$path]['item']; |
|
| 417 | 413 | } |
| 418 | 414 | $data['text'] = lang($data['text']); |
| 419 | 415 | if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
@@ -425,7 +421,7 @@ discard block |
||
| 425 | 421 | } |
| 426 | 422 | elseif ($root == '/groups') |
| 427 | 423 | { |
| 428 | - foreach($GLOBALS['egw']->accounts->search(array( |
|
| 424 | + foreach ($GLOBALS['egw']->accounts->search(array( |
|
| 429 | 425 | 'type' => 'groups', |
| 430 | 426 | 'order' => 'account_lid', |
| 431 | 427 | 'sort' => 'ASC', |
@@ -452,8 +448,8 @@ discard block |
||
| 452 | 448 | private static function fix_userdata(array $data) |
| 453 | 449 | { |
| 454 | 450 | // store link as userdata, maybe we should store everything not directly understood by tree this way ... |
| 455 | - foreach(array_diff_key($data, array_flip(array( |
|
| 456 | - 'id','text','tooltip','im0','im1','im2','item','child','select','open','call', |
|
| 451 | + foreach (array_diff_key($data, array_flip(array( |
|
| 452 | + 'id', 'text', 'tooltip', 'im0', 'im1', 'im2', 'item', 'child', 'select', 'open', 'call', |
|
| 457 | 453 | ))) as $name => $content) |
| 458 | 454 | { |
| 459 | 455 | $data['userdata'][] = array( |
@@ -473,7 +469,7 @@ discard block |
||
| 473 | 469 | private static function strip_item_keys(array &$items) |
| 474 | 470 | { |
| 475 | 471 | $items = array_values($items); |
| 476 | - foreach($items as &$item) |
|
| 472 | + foreach ($items as &$item) |
|
| 477 | 473 | { |
| 478 | 474 | if (is_array($item) && isset($item['item'])) |
| 479 | 475 | { |
@@ -491,7 +487,7 @@ discard block |
||
| 491 | 487 | protected static function call_hook() |
| 492 | 488 | { |
| 493 | 489 | self::$hook_data = array(); |
| 494 | - function display_section($appname,$file,$file2=False) |
|
| 490 | + function display_section($appname, $file, $file2 = False) |
|
| 495 | 491 | { |
| 496 | 492 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
| 497 | 493 | //error_log(__METHOD__."(".array2string(func_get_args()).")"); |
@@ -48,7 +48,10 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | $tpl = new Etemplate('admin.index'); |
| 50 | 50 | |
| 51 | - if (!is_array($content)) $content = array(); |
|
| 51 | + if (!is_array($content)) |
|
| 52 | + { |
|
| 53 | + $content = array(); |
|
| 54 | + } |
|
| 52 | 55 | $content['nm'] = array( |
| 53 | 56 | 'get_rows' => 'admin_ui::get_users', |
| 54 | 57 | 'no_cat' => true, |
@@ -132,7 +135,9 @@ discard block |
||
| 132 | 135 | 'group' => 2, |
| 133 | 136 | ), |
| 134 | 137 | ); |
| 135 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
| 138 | + if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) |
|
| 139 | + { |
|
| 140 | + // no rights to set ACL-rights |
|
| 136 | 141 | { |
| 137 | 142 | $actions['deny'] = array( |
| 138 | 143 | 'caption' => 'Deny access', |
@@ -143,6 +148,7 @@ discard block |
||
| 143 | 148 | 'group' => 2, |
| 144 | 149 | ); |
| 145 | 150 | } |
| 151 | + } |
|
| 146 | 152 | $group = 5; // allow to place actions in different groups by hook, this is the default |
| 147 | 153 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
| 148 | 154 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group'))); |
@@ -150,7 +156,10 @@ discard block |
||
| 150 | 156 | { |
| 151 | 157 | $GLOBALS['menuData'] = $data = array(); |
| 152 | 158 | $data = Api\Hooks::single('edit_group', $app); |
| 153 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
| 159 | + if (!is_array($data)) |
|
| 160 | + { |
|
| 161 | + $data = $GLOBALS['menuData']; |
|
| 162 | + } |
|
| 154 | 163 | //error_log(__METHOD__."() app $app returned ".array2string($data)); |
| 155 | 164 | foreach($data as $item) |
| 156 | 165 | { |
@@ -170,15 +179,33 @@ discard block |
||
| 170 | 179 | { |
| 171 | 180 | $item['popup'] = $matches[2].'x'.$matches[3]; |
| 172 | 181 | $item['onExecute'] = 'javaScript:nm_action'; |
| 173 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
| 182 | + if (isset($matches[5])) |
|
| 183 | + { |
|
| 184 | + $item['tooltip'] = $matches[5]; |
|
| 185 | + } |
|
| 174 | 186 | unset($item['options']); |
| 175 | 187 | } |
| 176 | 188 | } |
| 177 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
| 178 | - if (empty($item['group'])) $item['group'] = $group; |
|
| 179 | - if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group'; |
|
| 180 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
| 181 | - if (!isset($item['enableId'])) $item['enableId'] = '^/groups/-\\d+'; |
|
| 189 | + if (empty($item['icon'])) |
|
| 190 | + { |
|
| 191 | + $item['icon'] = $app.'/navbar'; |
|
| 192 | + } |
|
| 193 | + if (empty($item['group'])) |
|
| 194 | + { |
|
| 195 | + $item['group'] = $group; |
|
| 196 | + } |
|
| 197 | + if (empty($item['onExecute'])) |
|
| 198 | + { |
|
| 199 | + $item['onExecute'] = 'javaScript:app.admin.group'; |
|
| 200 | + } |
|
| 201 | + if (!isset($item['allowOnMultiple'])) |
|
| 202 | + { |
|
| 203 | + $item['allowOnMultiple'] = false; |
|
| 204 | + } |
|
| 205 | + if (!isset($item['enableId'])) |
|
| 206 | + { |
|
| 207 | + $item['enableId'] = '^/groups/-\\d+'; |
|
| 208 | + } |
|
| 182 | 209 | |
| 183 | 210 | $actions[$item['id']] = $item; |
| 184 | 211 | } |
@@ -231,7 +258,10 @@ discard block |
||
| 231 | 258 | { |
| 232 | 259 | $GLOBALS['menuData'] = $data = array(); |
| 233 | 260 | $data = Api\Hooks::single('edit_user', $app); |
| 234 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
| 261 | + if (!is_array($data)) |
|
| 262 | + { |
|
| 263 | + $data = $GLOBALS['menuData']; |
|
| 264 | + } |
|
| 235 | 265 | foreach($data as $item) |
| 236 | 266 | { |
| 237 | 267 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
@@ -249,15 +279,30 @@ discard block |
||
| 249 | 279 | if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches)) |
| 250 | 280 | { |
| 251 | 281 | $item['popup'] = $matches[2].'x'.$matches[3]; |
| 252 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
| 282 | + if (isset($matches[5])) |
|
| 283 | + { |
|
| 284 | + $item['tooltip'] = $matches[5]; |
|
| 285 | + } |
|
| 253 | 286 | unset($item['options']); |
| 254 | 287 | } |
| 255 | 288 | } |
| 256 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
| 257 | - if (empty($item['group'])) $item['group'] = $group; |
|
| 258 | - if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ? |
|
| 289 | + if (empty($item['icon'])) |
|
| 290 | + { |
|
| 291 | + $item['icon'] = $app.'/navbar'; |
|
| 292 | + } |
|
| 293 | + if (empty($item['group'])) |
|
| 294 | + { |
|
| 295 | + $item['group'] = $group; |
|
| 296 | + } |
|
| 297 | + if (empty($item['onExecute'])) |
|
| 298 | + { |
|
| 299 | + $item['onExecute'] = $item['popup'] ? |
|
| 259 | 300 | 'javaScript:nm_action' : 'javaScript:app.admin.iframe_location'; |
| 260 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
| 301 | + } |
|
| 302 | + if (!isset($item['allowOnMultiple'])) |
|
| 303 | + { |
|
| 304 | + $item['allowOnMultiple'] = false; |
|
| 305 | + } |
|
| 261 | 306 | |
| 262 | 307 | $actions[$item['id']] = $item; |
| 263 | 308 | } |
@@ -313,7 +358,10 @@ discard block |
||
| 313 | 358 | ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : |
| 314 | 359 | lang('Enabled'))); |
| 315 | 360 | |
| 316 | - if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
|
| 361 | + if (!self::$accounts->is_active($row)) |
|
| 362 | + { |
|
| 363 | + $row['status_class'] = 'adminAccountInactive'; |
|
| 364 | + } |
|
| 317 | 365 | } |
| 318 | 366 | |
| 319 | 367 | return self::$accounts->total; |
@@ -367,7 +415,10 @@ discard block |
||
| 367 | 415 | 'link' => $data, |
| 368 | 416 | ); |
| 369 | 417 | } |
| 370 | - if (empty($data['text'])) $data['text'] = $text; |
|
| 418 | + if (empty($data['text'])) |
|
| 419 | + { |
|
| 420 | + $data['text'] = $text; |
|
| 421 | + } |
|
| 371 | 422 | if (empty($data['id'])) |
| 372 | 423 | { |
| 373 | 424 | $data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/'; |
@@ -392,7 +443,11 @@ discard block |
||
| 392 | 443 | unset($data['icon']); |
| 393 | 444 | $parent =& $tree['item']; |
| 394 | 445 | $parts = explode('/', $data['id']); |
| 395 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
| 446 | + if ($data['id'][0] == '/') |
|
| 447 | + { |
|
| 448 | + array_shift($parts); |
|
| 449 | + } |
|
| 450 | + // remove root |
|
| 396 | 451 | array_pop($parts); |
| 397 | 452 | $path = ''; |
| 398 | 453 | foreach($parts as $part) |
@@ -411,14 +466,23 @@ discard block |
||
| 411 | 466 | 'item' => array(), |
| 412 | 467 | 'child' => 1, |
| 413 | 468 | ); |
| 414 | - if ($path == '/admin') $parent[$path]['open'] = true; |
|
| 469 | + if ($path == '/admin') |
|
| 470 | + { |
|
| 471 | + $parent[$path]['open'] = true; |
|
| 472 | + } |
|
| 415 | 473 | } |
| 416 | 474 | $parent =& $parent[$path]['item']; |
| 417 | 475 | } |
| 418 | 476 | $data['text'] = lang($data['text']); |
| 419 | - if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
|
| 477 | + if (!empty($data['tooltip'])) |
|
| 478 | + { |
|
| 479 | + $data['tooltip'] = lang($data['tooltip']); |
|
| 480 | + } |
|
| 420 | 481 | // make sure keys are unique, as we overwrite tree entries otherwise |
| 421 | - if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']); |
|
| 482 | + if (isset($parent[$data['id']])) |
|
| 483 | + { |
|
| 484 | + $data['id'] .= md5($data['link']); |
|
| 485 | + } |
|
| 422 | 486 | $parent[$data['id']] = self::fix_userdata($data); |
| 423 | 487 | } |
| 424 | 488 | } |
@@ -548,7 +548,7 @@ |
||
| 548 | 548 | * Validate and create a new content type |
| 549 | 549 | * |
| 550 | 550 | * @param array $content |
| 551 | - * @return string|boolean New type ID, or false for error |
|
| 551 | + * @return false|string New type ID, or false for error |
|
| 552 | 552 | */ |
| 553 | 553 | function create_content_type(&$content) |
| 554 | 554 | { |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * appname of app which want to add / edit its customfields |
|
| 36 | - * |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 35 | + * appname of app which want to add / edit its customfields |
|
| 36 | + * |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | 39 | var $appname; |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | protected $use_private = false; |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * userdefiened types e.g. type of infolog |
|
| 48 | - * |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 47 | + * userdefiened types e.g. type of infolog |
|
| 48 | + * |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | 51 | var $types2 = array(); |
| 52 | 52 | var $content_types,$fields; |
| 53 | 53 | |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
| 510 | - * deletes custom field from customfield definitions |
|
| 511 | - */ |
|
| 510 | + * deletes custom field from customfield definitions |
|
| 511 | + */ |
|
| 512 | 512 | function delete_field(&$content) |
| 513 | 513 | { |
| 514 | 514 | unset($this->fields[key($content['fields']['delete'])]); |
@@ -525,8 +525,8 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | - * create a new custom field |
|
| 529 | - */ |
|
| 528 | + * create a new custom field |
|
| 529 | + */ |
|
| 530 | 530 | function create_field(&$content) |
| 531 | 531 | { |
| 532 | 532 | $new_name = trim($content['fields'][count($content['fields'])-1]['name']); |
@@ -587,8 +587,8 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
| 590 | - * save changes to repository |
|
| 591 | - */ |
|
| 590 | + * save changes to repository |
|
| 591 | + */ |
|
| 592 | 592 | function save_repository() |
| 593 | 593 | { |
| 594 | 594 | //echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n"; |
@@ -601,25 +601,25 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | - * get customfields of using application |
|
| 605 | - * |
|
| 606 | - * @deprecated use Api\Storage\Customfields::get() direct, no need to instanciate this UI class |
|
| 607 | - * @author Cornelius Weiss |
|
| 608 | - * @param boolean $all_private_too =false should all the private fields be returned too |
|
| 609 | - * @return array with customfields |
|
| 610 | - */ |
|
| 604 | + * get customfields of using application |
|
| 605 | + * |
|
| 606 | + * @deprecated use Api\Storage\Customfields::get() direct, no need to instanciate this UI class |
|
| 607 | + * @author Cornelius Weiss |
|
| 608 | + * @param boolean $all_private_too =false should all the private fields be returned too |
|
| 609 | + * @return array with customfields |
|
| 610 | + */ |
|
| 611 | 611 | function get_customfields($all_private_too=false) |
| 612 | 612 | { |
| 613 | 613 | return Api\Storage\Customfields::get($this->appname,$all_private_too); |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | - * get_content_types of using application |
|
| 618 | - * |
|
| 619 | - * @deprecated use Api\Config::get_content_types() direct, no need to instanciate this UI class |
|
| 620 | - * @author Cornelius Weiss |
|
| 621 | - * @return array with content-types |
|
| 622 | - */ |
|
| 617 | + * get_content_types of using application |
|
| 618 | + * |
|
| 619 | + * @deprecated use Api\Config::get_content_types() direct, no need to instanciate this UI class |
|
| 620 | + * @author Cornelius Weiss |
|
| 621 | + * @return array with content-types |
|
| 622 | + */ |
|
| 623 | 623 | function get_content_types() |
| 624 | 624 | { |
| 625 | 625 | return Api\Config::get_content_types($this->appname); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | 51 | var $types2 = array(); |
| 52 | - var $content_types,$fields; |
|
| 52 | + var $content_types, $fields; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Currently selected content type (if used by app) |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param string $appname |
| 105 | 105 | */ |
| 106 | - function __construct($appname='') |
|
| 106 | + function __construct($appname = '') |
|
| 107 | 107 | { |
| 108 | 108 | if (($this->appname = $appname)) |
| 109 | 109 | { |
| 110 | - $this->fields = Api\Storage\Customfields::get($this->appname,true); |
|
| 110 | + $this->fields = Api\Storage\Customfields::get($this->appname, true); |
|
| 111 | 111 | $this->content_types = Api\Config::get_content_types($this->appname); |
| 112 | 112 | } |
| 113 | - $this->so = new Api\Storage\Base('phpgwapi','egw_customfields',null,'',true); |
|
| 113 | + $this->so = new Api\Storage\Base('phpgwapi', 'egw_customfields', null, '', true); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -120,43 +120,43 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | // determine appname |
| 122 | 122 | $this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['appname'] ? $content['appname'] : false)); |
| 123 | - if(!$this->appname) die(lang('Error! No appname found')); |
|
| 123 | + if (!$this->appname) die(lang('Error! No appname found')); |
|
| 124 | 124 | |
| 125 | 125 | $this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private']; |
| 126 | 126 | |
| 127 | 127 | // Read fields, constructor doesn't always know appname |
| 128 | - $this->fields = Api\Storage\Customfields::get($this->appname,true); |
|
| 128 | + $this->fields = Api\Storage\Customfields::get($this->appname, true); |
|
| 129 | 129 | |
| 130 | 130 | $this->tmpl = new Etemplate(); |
| 131 | 131 | $this->tmpl->read('admin.customfields'); |
| 132 | 132 | |
| 133 | 133 | // do we manage content-types? |
| 134 | 134 | $test = new Etemplate(); |
| 135 | - if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 135 | + if ($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 136 | 136 | |
| 137 | 137 | // Handle incoming - types, options, etc. |
| 138 | - if($this->manage_content_types) |
|
| 138 | + if ($this->manage_content_types) |
|
| 139 | 139 | { |
| 140 | - if(count($this->content_types) == 0) |
|
| 140 | + if (count($this->content_types) == 0) |
|
| 141 | 141 | { |
| 142 | 142 | $this->content_types = Api\Config::get_content_types($this->appname); |
| 143 | 143 | } |
| 144 | - if (count($this->content_types)==0) |
|
| 144 | + if (count($this->content_types) == 0) |
|
| 145 | 145 | { |
| 146 | 146 | // if you define your default types of your app with the search_link hook, they are available here, if no types were found |
| 147 | - $this->content_types = (array)Api\Link::get_registry($this->appname,'default_types'); |
|
| 147 | + $this->content_types = (array)Api\Link::get_registry($this->appname, 'default_types'); |
|
| 148 | 148 | } |
| 149 | 149 | // Set this now, we need to know it for updates |
| 150 | - $this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0,$this->content_types) ? $this->content_types[0] : key($this->content_types)); |
|
| 150 | + $this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0, $this->content_types) ? $this->content_types[0] : key($this->content_types)); |
|
| 151 | 151 | |
| 152 | 152 | // Common type changes - add, delete |
| 153 | - if($content['content_types']['delete']) |
|
| 153 | + if ($content['content_types']['delete']) |
|
| 154 | 154 | { |
| 155 | 155 | $this->delete_content_type($content); |
| 156 | 156 | } |
| 157 | - elseif($content['content_types']['create']) |
|
| 157 | + elseif ($content['content_types']['create']) |
|
| 158 | 158 | { |
| 159 | - if(($new_type = $this->create_content_type($content))) |
|
| 159 | + if (($new_type = $this->create_content_type($content))) |
|
| 160 | 160 | { |
| 161 | 161 | $content['content_types']['types'] = $this->content_type = $new_type; |
| 162 | 162 | } |
@@ -164,18 +164,18 @@ discard block |
||
| 164 | 164 | unset($content['content_types']['name']); |
| 165 | 165 | } |
| 166 | 166 | // No common type change and type didn't change, try an update |
| 167 | - elseif($this->content_type && is_array($content) && $this->content_type == $content['old_content_type']) |
|
| 167 | + elseif ($this->content_type && is_array($content) && $this->content_type == $content['old_content_type']) |
|
| 168 | 168 | { |
| 169 | 169 | $this->update($content); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Custom field deleted from nextmatch |
| 174 | - if($content['nm']['action'] == 'delete') |
|
| 174 | + if ($content['nm']['action'] == 'delete') |
|
| 175 | 175 | { |
| 176 | - foreach($this->fields as $name => $data) |
|
| 176 | + foreach ($this->fields as $name => $data) |
|
| 177 | 177 | { |
| 178 | - if(in_array($data['id'],$content['nm']['selected'])) |
|
| 178 | + if (in_array($data['id'], $content['nm']['selected'])) |
|
| 179 | 179 | { |
| 180 | 180 | unset($this->fields[$name]); |
| 181 | 181 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $this->save_repository(); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $content['nm']= Api\Cache::getSession('admin', 'customfield-index'); |
|
| 187 | + $content['nm'] = Api\Cache::getSession('admin', 'customfield-index'); |
|
| 188 | 188 | if (!is_array($content['nm'])) |
| 189 | 189 | { |
| 190 | 190 | // Initialize nextmatch |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | 'no_filter' => 'true', |
| 195 | 195 | 'no_filter2' => 'true', |
| 196 | 196 | 'row_id' => 'cf_id', |
| 197 | - 'order' => 'cf_order',// IO name of the column to sort |
|
| 198 | - 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' |
|
| 197 | + 'order' => 'cf_order', // IO name of the column to sort |
|
| 198 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 199 | 199 | 'actions' => $this->get_actions() |
| 200 | 200 | ); |
| 201 | 201 | } |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | $content['nm']['use_private'] = $this->use_private; |
| 204 | 204 | |
| 205 | 205 | // Set up sub-types |
| 206 | - if($this->manage_content_types) |
|
| 206 | + if ($this->manage_content_types) |
|
| 207 | 207 | { |
| 208 | - foreach($this->content_types as $type => $entry) |
|
| 208 | + foreach ($this->content_types as $type => $entry) |
|
| 209 | 209 | { |
| 210 | - if(!is_array($entry)) |
|
| 210 | + if (!is_array($entry)) |
|
| 211 | 211 | { |
| 212 | 212 | $this->content_types[$type] = array('name' => $entry); |
| 213 | 213 | $entry = $this->content_types[$type]; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | $sel_options['types'] = $sel_options['cf_type2'] = $this->types2; |
| 218 | 218 | |
| 219 | - $content['type_template'] = $this->appname . '.admin.types'; |
|
| 219 | + $content['type_template'] = $this->appname.'.admin.types'; |
|
| 220 | 220 | $content['content_types']['appname'] = $this->appname; |
| 221 | 221 | |
| 222 | 222 | $content['content_type_options'] = $this->content_types[$this->content_type]['options']; |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | static::app_index($content, $sel_options, $readonlys, $preserve); |
| 259 | 259 | |
| 260 | 260 | // Make sure app css gets loaded, extending app might cause et2 to miss it |
| 261 | - Framework::includeCSS('admin','app'); |
|
| 261 | + Framework::includeCSS('admin', 'app'); |
|
| 262 | 262 | |
| 263 | 263 | $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields'); |
| 264 | 264 | |
| 265 | 265 | // Some logic to make sure extending class (if there is one) gets called |
| 266 | 266 | // when etemplate2 comes back instead of parent class |
| 267 | - $exec = get_class() == get_called_class() ? 'admin.customfields.index' : $this->appname . '.' . get_called_class() . '.index'; |
|
| 267 | + $exec = get_class() == get_called_class() ? 'admin.customfields.index' : $this->appname.'.'.get_called_class().'.index'; |
|
| 268 | 268 | |
| 269 | - $this->tmpl->exec($exec,$content,$sel_options,$readonlys,$preserve); |
|
| 269 | + $this->tmpl->exec($exec, $content, $sel_options, $readonlys, $preserve); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -281,28 +281,28 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | // determine appname |
| 283 | 283 | $this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['cf_app'] ? $content['cf_app'] : false)); |
| 284 | - if(!$this->appname) |
|
| 284 | + if (!$this->appname) |
|
| 285 | 285 | { |
| 286 | - if($cf_id && $this->so) |
|
| 286 | + if ($cf_id && $this->so) |
|
| 287 | 287 | { |
| 288 | 288 | $content = $this->so->read($cf_id); |
| 289 | 289 | $this->appname = $content['cf_app']; |
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | - if(!$this->appname) |
|
| 292 | + if (!$this->appname) |
|
| 293 | 293 | { |
| 294 | 294 | die(lang('Error! No appname found')); |
| 295 | 295 | } |
| 296 | 296 | $this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private']; |
| 297 | 297 | |
| 298 | 298 | // Read fields, constructor doesn't always know appname |
| 299 | - $this->fields = Api\Storage\Customfields::get($this->appname,true); |
|
| 299 | + $this->fields = Api\Storage\Customfields::get($this->appname, true); |
|
| 300 | 300 | |
| 301 | 301 | // Update based on info returned from template |
| 302 | 302 | if (is_array($content)) |
| 303 | 303 | { |
| 304 | 304 | list($action) = @each($content['button']); |
| 305 | - switch($action) |
|
| 305 | + switch ($action) |
|
| 306 | 306 | { |
| 307 | 307 | case 'delete': |
| 308 | 308 | $this->so->delete($cf_id); |
@@ -311,46 +311,46 @@ discard block |
||
| 311 | 311 | break; |
| 312 | 312 | case 'save': |
| 313 | 313 | case 'apply': |
| 314 | - if(!$cf_id && $this->fields[$content['cf_name']]) |
|
| 314 | + if (!$cf_id && $this->fields[$content['cf_name']]) |
|
| 315 | 315 | { |
| 316 | - Framework::message(lang("Field '%1' already exists !!!",$content['cf_name']),'error'); |
|
| 316 | + Framework::message(lang("Field '%1' already exists !!!", $content['cf_name']), 'error'); |
|
| 317 | 317 | $content['cf_name'] = ''; |
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | - if(empty($content['cf_label'])) |
|
| 320 | + if (empty($content['cf_label'])) |
|
| 321 | 321 | { |
| 322 | 322 | $content['cf_label'] = $content['cf_name']; |
| 323 | 323 | } |
| 324 | 324 | if (!empty($content['cf_values'])) |
| 325 | 325 | { |
| 326 | 326 | $values = array(); |
| 327 | - if($content['cf_values'][0] === '@') |
|
| 327 | + if ($content['cf_values'][0] === '@') |
|
| 328 | 328 | { |
| 329 | - $values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2:1); |
|
| 329 | + $values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2 : 1); |
|
| 330 | 330 | } |
| 331 | 331 | else |
| 332 | 332 | { |
| 333 | - foreach(explode("\n",trim($content['cf_values'])) as $line) |
|
| 333 | + foreach (explode("\n", trim($content['cf_values'])) as $line) |
|
| 334 | 334 | { |
| 335 | - list($var_raw,$value) = explode('=',trim($line),2); |
|
| 335 | + list($var_raw, $value) = explode('=', trim($line), 2); |
|
| 336 | 336 | $var = trim($var_raw); |
| 337 | - $values[$var] = trim($value)==='' ? $var : $value; |
|
| 337 | + $values[$var] = trim($value) === '' ? $var : $value; |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | $content['cf_values'] = $values; |
| 341 | 341 | } |
| 342 | 342 | $update_content = array(); |
| 343 | - foreach($content as $key => $value) |
|
| 343 | + foreach ($content as $key => $value) |
|
| 344 | 344 | { |
| 345 | - if(substr($key,0,3) == 'cf_') |
|
| 345 | + if (substr($key, 0, 3) == 'cf_') |
|
| 346 | 346 | { |
| 347 | - $update_content[substr($key,3)] = $value; |
|
| 347 | + $update_content[substr($key, 3)] = $value; |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | Api\Storage\Customfields::update($update_content); |
| 351 | - if(!$cf_id) |
|
| 351 | + if (!$cf_id) |
|
| 352 | 352 | { |
| 353 | - $this->fields = Api\Storage\Customfields::get($this->appname,true); |
|
| 353 | + $this->fields = Api\Storage\Customfields::get($this->appname, true); |
|
| 354 | 354 | $cf_id = (int)$this->fields[$content['cf_name']]['id']; |
| 355 | 355 | } |
| 356 | 356 | Framework::refresh_opener('Saved', 'admin', $cf_id, 'edit'); |
@@ -371,30 +371,30 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | // do we manage content-types? |
| 373 | 373 | $test = new Etemplate(); |
| 374 | - if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 374 | + if ($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 375 | 375 | |
| 376 | 376 | $this->tmpl = new Etemplate(); |
| 377 | 377 | $this->tmpl->read('admin.customfield_edit'); |
| 378 | 378 | |
| 379 | - Api\Translation::add_app('infolog'); // til we move the translations |
|
| 379 | + Api\Translation::add_app('infolog'); // til we move the translations |
|
| 380 | 380 | |
| 381 | 381 | $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields'); |
| 382 | 382 | $sel_options = array(); |
| 383 | 383 | $readonlys = array(); |
| 384 | 384 | |
| 385 | 385 | //echo 'customfields=<pre style="text-align: left;">'; print_r($this->fields); echo "</pre>\n"; |
| 386 | - $content['cf_order'] = (count($this->fields)+1) * 10; |
|
| 386 | + $content['cf_order'] = (count($this->fields) + 1) * 10; |
|
| 387 | 387 | $content['use_private'] = $this->use_private; |
| 388 | 388 | |
| 389 | - if($cf_id) |
|
| 389 | + if ($cf_id) |
|
| 390 | 390 | { |
| 391 | 391 | $content = array_merge($content, $this->so->read($cf_id)); |
| 392 | 392 | $this->appname = $content['cf_app']; |
| 393 | - if($content['cf_private']) |
|
| 393 | + if ($content['cf_private']) |
|
| 394 | 394 | { |
| 395 | - $content['cf_private'] = explode(',',$content['cf_private']); |
|
| 395 | + $content['cf_private'] = explode(',', $content['cf_private']); |
|
| 396 | 396 | } |
| 397 | - if($content['cf_name']) |
|
| 397 | + if ($content['cf_name']) |
|
| 398 | 398 | { |
| 399 | 399 | $readonlys['cf_name'] = true; |
| 400 | 400 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | if (is_array($content['cf_values'])) |
| 408 | 408 | { |
| 409 | 409 | $values = ''; |
| 410 | - foreach($content['cf_values'] as $var => $value) |
|
| 410 | + foreach ($content['cf_values'] as $var => $value) |
|
| 411 | 411 | { |
| 412 | 412 | $values .= (!empty($values) ? "\n" : '').$var.'='.$value; |
| 413 | 413 | } |
@@ -415,18 +415,18 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Show sub-type row, and get types |
| 418 | - if($this->manage_content_types) |
|
| 418 | + if ($this->manage_content_types) |
|
| 419 | 419 | { |
| 420 | - if(count($this->content_types) == 0) |
|
| 420 | + if (count($this->content_types) == 0) |
|
| 421 | 421 | { |
| 422 | 422 | $this->content_types = Api\Config::get_content_types($this->appname); |
| 423 | 423 | } |
| 424 | - if (count($this->content_types)==0) |
|
| 424 | + if (count($this->content_types) == 0) |
|
| 425 | 425 | { |
| 426 | 426 | // if you define your default types of your app with the search_link hook, they are available here, if no types were found |
| 427 | - $this->content_types = (array)egw_link::get_registry($this->appname,'default_types'); |
|
| 427 | + $this->content_types = (array)egw_link::get_registry($this->appname, 'default_types'); |
|
| 428 | 428 | } |
| 429 | - foreach($this->content_types as $type => $entry) |
|
| 429 | + foreach ($this->content_types as $type => $entry) |
|
| 430 | 430 | { |
| 431 | 431 | $this->types2[$type] = is_array($entry) ? $entry['name'] : $entry; |
| 432 | 432 | } |
@@ -438,19 +438,19 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // Include type-specific value help |
| 441 | - foreach(self::$type_option_help as $key => $value) |
|
| 441 | + foreach (self::$type_option_help as $key => $value) |
|
| 442 | 442 | { |
| 443 | 443 | $content['options'][$key] = lang($value); |
| 444 | 444 | } |
| 445 | 445 | $content['statustext'] = $content['options'][$content['cf_type']]; |
| 446 | 446 | $content['attributes'] = self::$type_attribute_flags; |
| 447 | 447 | |
| 448 | - $this->tmpl->exec('admin.customfields.edit',$content,$sel_options,$readonlys,array( |
|
| 448 | + $this->tmpl->exec('admin.customfields.edit', $content, $sel_options, $readonlys, array( |
|
| 449 | 449 | 'cf_id' => $cf_id, |
| 450 | 450 | 'cf_app' => $this->appname, |
| 451 | 451 | 'cf_name' => $content['cf_name'], |
| 452 | 452 | 'use_private' => $this->use_private, |
| 453 | - ),2); |
|
| 453 | + ), 2); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | protected function app_index(&$content, &$sel_options, &$readonlys) |
| 461 | 461 | { |
| 462 | - unset($content, $sel_options, $readonlys); // not used, as this is a stub |
|
| 462 | + unset($content, $sel_options, $readonlys); // not used, as this is a stub |
|
| 463 | 463 | // This is just a stub. |
| 464 | 464 | } |
| 465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | 'allowOnMultiple' => false, |
| 480 | 480 | 'url' => 'menuaction=admin.customfields.edit&cf_id=$id&use_private='.$this->use_private, |
| 481 | 481 | 'popup' => '500x380', |
| 482 | - 'group' => $group=1, |
|
| 482 | + 'group' => $group = 1, |
|
| 483 | 483 | 'disableClass' => 'th', |
| 484 | 484 | ), |
| 485 | 485 | 'add' => array( |
@@ -529,17 +529,16 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | function create_field(&$content) |
| 531 | 531 | { |
| 532 | - $new_name = trim($content['fields'][count($content['fields'])-1]['name']); |
|
| 532 | + $new_name = trim($content['fields'][count($content['fields']) - 1]['name']); |
|
| 533 | 533 | if (empty($new_name) || isset($this->fields[$new_name])) |
| 534 | 534 | { |
| 535 | 535 | $content['error_msg'] .= empty($new_name) ? |
| 536 | - lang('You have to enter a name, to create a new field!!!') : |
|
| 537 | - lang("Field '%1' already exists !!!",$new_name); |
|
| 536 | + lang('You have to enter a name, to create a new field!!!') : lang("Field '%1' already exists !!!", $new_name); |
|
| 538 | 537 | } |
| 539 | 538 | else |
| 540 | 539 | { |
| 541 | - $this->fields[$new_name] = $content['fields'][count($content['fields'])-1]; |
|
| 542 | - if(!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name']; |
|
| 540 | + $this->fields[$new_name] = $content['fields'][count($content['fields']) - 1]; |
|
| 541 | + if (!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name']; |
|
| 543 | 542 | $this->save_repository(); |
| 544 | 543 | } |
| 545 | 544 | } |
@@ -556,20 +555,20 @@ discard block |
||
| 556 | 555 | $new_type = false; |
| 557 | 556 | if (empty($new_name)) |
| 558 | 557 | { |
| 559 | - $this->tmpl->set_validation_error('content_types[name]','You have to enter a name, to create a new type!!!'); |
|
| 558 | + $this->tmpl->set_validation_error('content_types[name]', 'You have to enter a name, to create a new type!!!'); |
|
| 560 | 559 | } |
| 561 | 560 | else |
| 562 | 561 | { |
| 563 | - foreach($this->content_types as $type) |
|
| 562 | + foreach ($this->content_types as $type) |
|
| 564 | 563 | { |
| 565 | - if($type['name'] == $new_name) |
|
| 564 | + if ($type['name'] == $new_name) |
|
| 566 | 565 | { |
| 567 | - $this->tmpl->set_validation_error('content_types[name]',lang("type '%1' already exists !!!",$new_name)); |
|
| 566 | + $this->tmpl->set_validation_error('content_types[name]', lang("type '%1' already exists !!!", $new_name)); |
|
| 568 | 567 | return false; |
| 569 | 568 | } |
| 570 | 569 | } |
| 571 | 570 | // search free type character |
| 572 | - for($i=97;$i<=122;$i++) |
|
| 571 | + for ($i = 97; $i <= 122; $i++) |
|
| 573 | 572 | { |
| 574 | 573 | if (!$this->content_types[chr($i)] && |
| 575 | 574 | // skip letter of deleted type for addressbook content-types, as it gives SQL error |
@@ -594,7 +593,7 @@ discard block |
||
| 594 | 593 | //echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n"; |
| 595 | 594 | $config = new Api\Config($this->appname); |
| 596 | 595 | $config->read_repository(); |
| 597 | - $config->value('types',$this->content_types); |
|
| 596 | + $config->value('types', $this->content_types); |
|
| 598 | 597 | $config->save_repository(); |
| 599 | 598 | |
| 600 | 599 | Api\Storage\Customfields::save($this->appname, $this->fields); |
@@ -608,9 +607,9 @@ discard block |
||
| 608 | 607 | * @param boolean $all_private_too =false should all the private fields be returned too |
| 609 | 608 | * @return array with customfields |
| 610 | 609 | */ |
| 611 | - function get_customfields($all_private_too=false) |
|
| 610 | + function get_customfields($all_private_too = false) |
|
| 612 | 611 | { |
| 613 | - return Api\Storage\Customfields::get($this->appname,$all_private_too); |
|
| 612 | + return Api\Storage\Customfields::get($this->appname, $all_private_too); |
|
| 614 | 613 | } |
| 615 | 614 | |
| 616 | 615 | /** |
@@ -636,13 +635,13 @@ discard block |
||
| 636 | 635 | $total = $this->so->get_rows($query, $rows, $readonlys); |
| 637 | 636 | unset($query['col_filter']['cf_app']); |
| 638 | 637 | |
| 639 | - foreach($rows as &$row) |
|
| 638 | + foreach ($rows as &$row) |
|
| 640 | 639 | { |
| 641 | 640 | $row['cf_values'] = json_decode($row['cf_values'], true); |
| 642 | 641 | if (is_array($row['cf_values'])) |
| 643 | 642 | { |
| 644 | 643 | $values = ''; |
| 645 | - foreach($row['cf_values'] as $var => $value) |
|
| 644 | + foreach ($row['cf_values'] as $var => $value) |
|
| 646 | 645 | { |
| 647 | 646 | $values .= (!empty($values) ? "\n" : '').$var.'='.$value; |
| 648 | 647 | } |
@@ -120,7 +120,10 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | // determine appname |
| 122 | 122 | $this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['appname'] ? $content['appname'] : false)); |
| 123 | - if(!$this->appname) die(lang('Error! No appname found')); |
|
| 123 | + if(!$this->appname) |
|
| 124 | + { |
|
| 125 | + die(lang('Error! No appname found')); |
|
| 126 | + } |
|
| 124 | 127 | |
| 125 | 128 | $this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private']; |
| 126 | 129 | |
@@ -132,7 +135,10 @@ discard block |
||
| 132 | 135 | |
| 133 | 136 | // do we manage content-types? |
| 134 | 137 | $test = new Etemplate(); |
| 135 | - if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 138 | + if($test->read($this->appname.'.admin.types')) |
|
| 139 | + { |
|
| 140 | + $this->manage_content_types = true; |
|
| 141 | + } |
|
| 136 | 142 | |
| 137 | 143 | // Handle incoming - types, options, etc. |
| 138 | 144 | if($this->manage_content_types) |
@@ -371,7 +377,10 @@ discard block |
||
| 371 | 377 | |
| 372 | 378 | // do we manage content-types? |
| 373 | 379 | $test = new Etemplate(); |
| 374 | - if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true; |
|
| 380 | + if($test->read($this->appname.'.admin.types')) |
|
| 381 | + { |
|
| 382 | + $this->manage_content_types = true; |
|
| 383 | + } |
|
| 375 | 384 | |
| 376 | 385 | $this->tmpl = new Etemplate(); |
| 377 | 386 | $this->tmpl->read('admin.customfield_edit'); |
@@ -539,7 +548,10 @@ discard block |
||
| 539 | 548 | else |
| 540 | 549 | { |
| 541 | 550 | $this->fields[$new_name] = $content['fields'][count($content['fields'])-1]; |
| 542 | - if(!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name']; |
|
| 551 | + if(!$this->fields[$new_name]['label']) |
|
| 552 | + { |
|
| 553 | + $this->fields[$new_name]['label'] = $this->fields[$new_name]['name']; |
|
| 554 | + } |
|
| 543 | 555 | $this->save_repository(); |
| 544 | 556 | } |
| 545 | 557 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * All key of the returned array use the 'account_' prefix. |
| 361 | 361 | * For backward compatibility some values are additionaly availible without the prefix, using them is depricated! |
| 362 | 362 | * |
| 363 | - * @param int|string $id numeric account_id or string with account_lid (use of default value of 0 is depricated!!!) |
|
| 363 | + * @param integer $id numeric account_id or string with account_lid (use of default value of 0 is depricated!!!) |
|
| 364 | 364 | * @param boolean $set_depricated_names =false set _additionaly_ the depricated keys without 'account_' prefix |
| 365 | 365 | * @return array/boolean array with account data (keys: account_id, account_lid, ...) or false if account not found |
| 366 | 366 | */ |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * - 'account_firstname','account_lastname','account_email','account_fullname','account_phone' |
| 401 | 401 | * |
| 402 | 402 | * @param int|string $id |
| 403 | - * @return string|boolean json or false if not found |
|
| 403 | + * @return string json or false if not found |
|
| 404 | 404 | */ |
| 405 | 405 | function json($id) |
| 406 | 406 | { |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | * Not all existing accounts are visible because off account_selection preference: 'none' or 'groupmembers' |
| 792 | 792 | * |
| 793 | 793 | * @param int|string $account_id nummeric account_id or account_lid |
| 794 | - * @return boolean true = account is visible, false = account not visible, null = account does not exist |
|
| 794 | + * @return null|boolean true = account is visible, false = account not visible, null = account does not exist |
|
| 795 | 795 | */ |
| 796 | 796 | function visible($account_id) |
| 797 | 797 | { |
@@ -986,7 +986,6 @@ discard block |
||
| 986 | 986 | * |
| 987 | 987 | * @param string $account_lid |
| 988 | 988 | * @param string $passwd |
| 989 | - * @param array $GLOBALS['auto_create_acct'] values for 'firstname', 'lastname', 'email' and 'primary_group' |
|
| 990 | 989 | * @return int|boolean account_id or false on error |
| 991 | 990 | */ |
| 992 | 991 | function auto_add($account_lid, $passwd) |
@@ -1106,7 +1105,7 @@ discard block |
||
| 1106 | 1105 | * |
| 1107 | 1106 | * We use now an instance-wide read-cache storing account-data and members(hips). |
| 1108 | 1107 | * |
| 1109 | - * @param int|array $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache |
|
| 1108 | + * @param integer $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache |
|
| 1110 | 1109 | */ |
| 1111 | 1110 | static function cache_invalidate($account_ids=0) |
| 1112 | 1111 | { |
@@ -148,7 +148,10 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $this->config =& $GLOBALS['egw_info']['server']; |
| 150 | 150 | |
| 151 | - if (!isset(self::$_instance)) self::$_instance = $this; |
|
| 151 | + if (!isset(self::$_instance)) |
|
| 152 | + { |
|
| 153 | + self::$_instance = $this; |
|
| 154 | + } |
|
| 152 | 155 | } |
| 153 | 156 | if (is_null($backend)) |
| 154 | 157 | { |
@@ -195,7 +198,11 @@ discard block |
||
| 195 | 198 | function search($param) |
| 196 | 199 | { |
| 197 | 200 | //error_log(__METHOD__.'('.array2string($param).') '.function_backtrace()); |
| 198 | - if (!isset($param['active'])) $param['active'] = true; // default is true = only return active accounts |
|
| 201 | + if (!isset($param['active'])) |
|
| 202 | + { |
|
| 203 | + $param['active'] = true; |
|
| 204 | + } |
|
| 205 | + // default is true = only return active accounts |
|
| 199 | 206 | |
| 200 | 207 | self::setup_cache(); |
| 201 | 208 | $account_search = &self::$cache['account_search']; |
@@ -229,7 +236,10 @@ discard block |
||
| 229 | 236 | foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true) as $grp) |
| 230 | 237 | { |
| 231 | 238 | $members = array_unique(array_merge($members, (array)$this->members($grp,true,$param['active']))); |
| 232 | - if ($param['type'] == 'groupmembers+memberships') $members[] = $grp; |
|
| 239 | + if ($param['type'] == 'groupmembers+memberships') |
|
| 240 | + { |
|
| 241 | + $members[] = $grp; |
|
| 242 | + } |
|
| 233 | 243 | } |
| 234 | 244 | $param['type'] = $param['type'] == 'groupmembers+memberships' ? 'both' : 'accounts'; |
| 235 | 245 | } |
@@ -246,7 +256,10 @@ discard block |
||
| 246 | 256 | if (isset($members)) |
| 247 | 257 | { |
| 248 | 258 | //error_log(__METHOD__.'() members='.array2string($members)); |
| 249 | - if (!$members) $members = array(); |
|
| 259 | + if (!$members) |
|
| 260 | + { |
|
| 261 | + $members = array(); |
|
| 262 | + } |
|
| 250 | 263 | $valid = !$app ? $members : array_intersect($valid,$members); // use the intersection |
| 251 | 264 | } |
| 252 | 265 | //error_log(__METHOD__."() limiting result to app='$app' and/or group=$group valid-ids=".array2string($valid)); |
@@ -366,15 +379,21 @@ discard block |
||
| 366 | 379 | */ |
| 367 | 380 | function read($id=0,$set_depricated_names=false) |
| 368 | 381 | { |
| 369 | - if (!$id) // deprecated use!!! |
|
| 382 | + if (!$id) |
|
| 383 | + { |
|
| 384 | + // deprecated use!!! |
|
| 370 | 385 | { |
| 371 | 386 | return $this->data ? $this->data : $this->read_repository(); |
| 372 | 387 | } |
| 388 | + } |
|
| 373 | 389 | if (!is_int($id) && !is_numeric($id)) |
| 374 | 390 | { |
| 375 | 391 | $id = $this->name2id($id); |
| 376 | 392 | } |
| 377 | - if (!$id) return false; |
|
| 393 | + if (!$id) |
|
| 394 | + { |
|
| 395 | + return false; |
|
| 396 | + } |
|
| 378 | 397 | |
| 379 | 398 | $data = self::cache_read($id); |
| 380 | 399 | |
@@ -442,7 +461,10 @@ discard block |
||
| 442 | 461 | } |
| 443 | 462 | $is_group = $GLOBALS['egw']->accounts->get_type($accountid ? $accountid : $lid) == 'g'; |
| 444 | 463 | |
| 445 | - if (empty($firstname)) $firstname = $lid; |
|
| 464 | + if (empty($firstname)) |
|
| 465 | + { |
|
| 466 | + $firstname = $lid; |
|
| 467 | + } |
|
| 446 | 468 | if (empty($lastname) || $is_group) |
| 447 | 469 | { |
| 448 | 470 | $lastname = $is_group ? lang('Group') : lang('User'); |
@@ -521,9 +543,12 @@ discard block |
||
| 521 | 543 | $$name = Translation::to_ascii($$name); |
| 522 | 544 | } |
| 523 | 545 | //echo " --> ('$first', '$last', '$account')"; |
| 524 | - if (!$first && !$last) // fallback to the account-name, if real names contain only special chars |
|
| 546 | + if (!$first && !$last) |
|
| 547 | + { |
|
| 548 | + // fallback to the account-name, if real names contain only special chars |
|
| 525 | 549 | { |
| 526 | 550 | $first = ''; |
| 551 | + } |
|
| 527 | 552 | $last = $account; |
| 528 | 553 | } |
| 529 | 554 | if (!$first || !$last) |
@@ -535,8 +560,14 @@ discard block |
||
| 535 | 560 | $dot = '.'; |
| 536 | 561 | $underscore = '_'; |
| 537 | 562 | } |
| 538 | - if (!$domain) $domain = $GLOBALS['egw_info']['server']['mail_suffix']; |
|
| 539 | - if (!$domain) $domain = $_SERVER['SERVER_NAME']; |
|
| 563 | + if (!$domain) |
|
| 564 | + { |
|
| 565 | + $domain = $GLOBALS['egw_info']['server']['mail_suffix']; |
|
| 566 | + } |
|
| 567 | + if (!$domain) |
|
| 568 | + { |
|
| 569 | + $domain = $_SERVER['SERVER_NAME']; |
|
| 570 | + } |
|
| 540 | 571 | |
| 541 | 572 | $email = str_replace(array('first','last','initial','account','dot','underscore','-'), |
| 542 | 573 | array($first,$last,substr($first,0,1),$account,$dot,$underscore,''), |
@@ -602,7 +633,10 @@ discard block |
||
| 602 | 633 | $old['account_lastname'] != $data['account_lastname'] || |
| 603 | 634 | $old['account_email'] != $data['account_email'])) |
| 604 | 635 | { |
| 605 | - if (!$data['person_id']) $data['person_id'] = $old['person_id']; |
|
| 636 | + if (!$data['person_id']) |
|
| 637 | + { |
|
| 638 | + $data['person_id'] = $old['person_id']; |
|
| 639 | + } |
|
| 606 | 640 | |
| 607 | 641 | $contact = array( |
| 608 | 642 | 'n_given' => $data['account_firstname'], |
@@ -642,7 +676,10 @@ discard block |
||
| 642 | 676 | { |
| 643 | 677 | $id = $this->name2id($id); |
| 644 | 678 | } |
| 645 | - if (!$id) return false; |
|
| 679 | + if (!$id) |
|
| 680 | + { |
|
| 681 | + return false; |
|
| 682 | + } |
|
| 646 | 683 | |
| 647 | 684 | if ($this->get_type($id) == 'u') |
| 648 | 685 | { |
@@ -677,7 +714,11 @@ discard block |
||
| 677 | 714 | */ |
| 678 | 715 | function is_expired($data=null) |
| 679 | 716 | { |
| 680 | - if (is_null($data)) $data = $this->data; // depricated use |
|
| 717 | + if (is_null($data)) |
|
| 718 | + { |
|
| 719 | + $data = $this->data; |
|
| 720 | + } |
|
| 721 | + // depricated use |
|
| 681 | 722 | |
| 682 | 723 | $expires = isset($data['account_expires']) ? $data['account_expires'] : $data['expires']; |
| 683 | 724 | |
@@ -694,7 +735,10 @@ discard block |
||
| 694 | 735 | */ |
| 695 | 736 | function is_active($data) |
| 696 | 737 | { |
| 697 | - if (!is_array($data)) $data = $this->read($data); |
|
| 738 | + if (!is_array($data)) |
|
| 739 | + { |
|
| 740 | + $data = $this->read($data); |
|
| 741 | + } |
|
| 698 | 742 | |
| 699 | 743 | return $data && !(self::is_expired($data) || $data['account_status'] != 'A'); |
| 700 | 744 | } |
@@ -747,7 +791,10 @@ discard block |
||
| 747 | 791 | return false; |
| 748 | 792 | } |
| 749 | 793 | try { |
| 750 | - if (!($data = self::cache_read($account_id))) return false; |
|
| 794 | + if (!($data = self::cache_read($account_id))) |
|
| 795 | + { |
|
| 796 | + return false; |
|
| 797 | + } |
|
| 751 | 798 | } |
| 752 | 799 | catch (Exception $e) { |
| 753 | 800 | unset($e); |
@@ -801,14 +848,23 @@ discard block |
||
| 801 | 848 | */ |
| 802 | 849 | function visible($account_id) |
| 803 | 850 | { |
| 804 | - if (!is_numeric($account_id)) // account_lid given |
|
| 851 | + if (!is_numeric($account_id)) |
|
| 852 | + { |
|
| 853 | + // account_lid given |
|
| 805 | 854 | { |
| 806 | 855 | $account_lid = $account_id; |
| 807 | - if (!($account_id = $this->name2id($account_lid))) return null; |
|
| 856 | + } |
|
| 857 | + if (!($account_id = $this->name2id($account_lid))) |
|
| 858 | + { |
|
| 859 | + return null; |
|
| 860 | + } |
|
| 808 | 861 | } |
| 809 | 862 | else |
| 810 | 863 | { |
| 811 | - if (!($account_lid = $this->id2name($account_id))) return null; |
|
| 864 | + if (!($account_lid = $this->id2name($account_id))) |
|
| 865 | + { |
|
| 866 | + return null; |
|
| 867 | + } |
|
| 812 | 868 | } |
| 813 | 869 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && |
| 814 | 870 | // do NOT allow other user, if account-selection is none |
@@ -862,7 +918,10 @@ discard block |
||
| 862 | 918 | { |
| 863 | 919 | $this->backend->set_memberships($groups, $account_id); |
| 864 | 920 | |
| 865 | - if (!$old_memberships) $old_memberships = array(); |
|
| 921 | + if (!$old_memberships) |
|
| 922 | + { |
|
| 923 | + $old_memberships = array(); |
|
| 924 | + } |
|
| 866 | 925 | self::cache_invalidate(array_unique(array_merge( |
| 867 | 926 | array($account_id), |
| 868 | 927 | array_diff($old_memberships, $groups), |
@@ -1008,7 +1067,10 @@ discard block |
||
| 1008 | 1067 | { |
| 1009 | 1068 | if (($group_id = $this->name2id($group_lid,'account_lid','g'))) |
| 1010 | 1069 | { |
| 1011 | - if (!$default_group_id) $default_group_id = $group_id; |
|
| 1070 | + if (!$default_group_id) |
|
| 1071 | + { |
|
| 1072 | + $default_group_id = $group_id; |
|
| 1073 | + } |
|
| 1012 | 1074 | $memberships[] = $group_id; |
| 1013 | 1075 | } |
| 1014 | 1076 | } |
@@ -1093,7 +1155,10 @@ discard block |
||
| 1093 | 1155 | function change_account_lid_allowed() |
| 1094 | 1156 | { |
| 1095 | 1157 | $change_account_lid = constant(get_class($this->backend).'::CHANGE_ACCOUNT_LID'); |
| 1096 | - if (!isset($change_account_lid)) $change_account_lid = true; |
|
| 1158 | + if (!isset($change_account_lid)) |
|
| 1159 | + { |
|
| 1160 | + $change_account_lid = true; |
|
| 1161 | + } |
|
| 1097 | 1162 | return $change_account_lid; |
| 1098 | 1163 | } |
| 1099 | 1164 | |
@@ -1132,12 +1197,19 @@ discard block |
||
| 1132 | 1197 | } |
| 1133 | 1198 | |
| 1134 | 1199 | // session-cache |
| 1135 | - if (self::$cache) self::$cache = array(); |
|
| 1200 | + if (self::$cache) |
|
| 1201 | + { |
|
| 1202 | + self::$cache = array(); |
|
| 1203 | + } |
|
| 1136 | 1204 | Cache::unsetSession('accounts_cache','phpgwapi'); |
| 1137 | 1205 | |
| 1138 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 1206 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 1139 | 1207 | { |
| 1140 | - Egw::invalidate_session_cache(); // invalidates whole egw-enviroment if stored in the session |
|
| 1208 | + // egw object in setup is limited |
|
| 1209 | + { |
|
| 1210 | + Egw::invalidate_session_cache(); |
|
| 1211 | + } |
|
| 1212 | + // invalidates whole egw-enviroment if stored in the session |
|
| 1141 | 1213 | } |
| 1142 | 1214 | } |
| 1143 | 1215 | |
@@ -1163,27 +1235,39 @@ discard block |
||
| 1163 | 1235 | */ |
| 1164 | 1236 | static function cache_read($account_id, $need_active=false) |
| 1165 | 1237 | { |
| 1166 | - if (!is_numeric($account_id)) throw new Exception\WrongParameter('Not an integer!'); |
|
| 1238 | + if (!is_numeric($account_id)) |
|
| 1239 | + { |
|
| 1240 | + throw new Exception\WrongParameter('Not an integer!'); |
|
| 1241 | + } |
|
| 1167 | 1242 | |
| 1168 | 1243 | $account =& self::$request_cache[$account_id]; |
| 1169 | 1244 | |
| 1170 | - if (!isset($account)) // not in request cache --> try instance cache |
|
| 1245 | + if (!isset($account)) |
|
| 1246 | + { |
|
| 1247 | + // not in request cache --> try instance cache |
|
| 1171 | 1248 | { |
| 1172 | 1249 | $instance = self::getInstance(); |
| 1250 | + } |
|
| 1173 | 1251 | |
| 1174 | 1252 | $account = Cache::getCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id); |
| 1175 | 1253 | |
| 1176 | - if (!isset($account)) // not in instance cache --> read from backend |
|
| 1254 | + if (!isset($account)) |
|
| 1255 | + { |
|
| 1256 | + // not in instance cache --> read from backend |
|
| 1177 | 1257 | { |
| 1178 | 1258 | if (($account = $instance->backend->read($account_id))) |
| 1179 | 1259 | { |
| 1180 | 1260 | if ($instance->get_type($account_id) == 'u') |
| 1181 | 1261 | { |
| 1182 | 1262 | if (!isset($account['memberships'])) $account['memberships'] = $instance->backend->memberships($account_id); |
| 1263 | + } |
|
| 1183 | 1264 | } |
| 1184 | 1265 | else |
| 1185 | 1266 | { |
| 1186 | - if (!isset($account['members'])) $account['members'] = $instance->backend->members($account_id); |
|
| 1267 | + if (!isset($account['members'])) |
|
| 1268 | + { |
|
| 1269 | + $account['members'] = $instance->backend->members($account_id); |
|
| 1270 | + } |
|
| 1187 | 1271 | } |
| 1188 | 1272 | Cache::setCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id, $account, self::READ_CACHE_TIMEOUT); |
| 1189 | 1273 | } |
@@ -1198,7 +1282,10 @@ discard block |
||
| 1198 | 1282 | $account['members-active'] = array(); |
| 1199 | 1283 | foreach((array)$account['members'] as $id => $lid) |
| 1200 | 1284 | { |
| 1201 | - if ($instance->is_active($id)) $account['members-active'][$id] = $lid; |
|
| 1285 | + if ($instance->is_active($id)) |
|
| 1286 | + { |
|
| 1287 | + $account['members-active'][$id] = $lid; |
|
| 1288 | + } |
|
| 1202 | 1289 | } |
| 1203 | 1290 | Cache::setCache($instance->config['install_id'], __CLASS__, 'account-'.$account_id, $account, self::READ_CACHE_TIMEOUT); |
| 1204 | 1291 | } |
@@ -1222,7 +1309,11 @@ discard block |
||
| 1222 | 1309 | */ |
| 1223 | 1310 | private static function setup_cache() |
| 1224 | 1311 | { |
| 1225 | - if (is_array(self::$cache)) return; // cache is already setup |
|
| 1312 | + if (is_array(self::$cache)) |
|
| 1313 | + { |
|
| 1314 | + return; |
|
| 1315 | + } |
|
| 1316 | + // cache is already setup |
|
| 1226 | 1317 | |
| 1227 | 1318 | if (self::$use_session_cache && is_object($GLOBALS['egw']->session)) |
| 1228 | 1319 | { |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @var array |
| 59 | 59 | */ |
| 60 | - var $depricated_names = array('firstname','lastname','fullname','email','type', |
|
| 61 | - 'status','expires','lastlogin','lastloginfrom','lastpasswd_change'); |
|
| 60 | + var $depricated_names = array('firstname', 'lastname', 'fullname', 'email', 'type', |
|
| 61 | + 'status', 'expires', 'lastlogin', 'lastloginfrom', 'lastpasswd_change'); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * List of all config vars accounts depend on and therefore should be passed in when calling contructor with array syntax |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @var array |
| 67 | 67 | */ |
| 68 | 68 | static public $config_vars = array( |
| 69 | - 'account_repository', 'auth_type', // auth_type if fallback if account_repository is not set |
|
| 70 | - 'install_id', // instance-specific caching |
|
| 71 | - 'auto_create_expire', 'default_group_lid', // auto-creation of accounts |
|
| 72 | - 'ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter', // ldap backend |
|
| 73 | - 'ads_domain', 'ads_host', 'ads_admin_user', 'ads_admin_passwd', 'ads_connection', 'ads_context', // ads backend |
|
| 69 | + 'account_repository', 'auth_type', // auth_type if fallback if account_repository is not set |
|
| 70 | + 'install_id', // instance-specific caching |
|
| 71 | + 'auto_create_expire', 'default_group_lid', // auto-creation of accounts |
|
| 72 | + 'ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', // ldap backend |
|
| 73 | + 'ads_domain', 'ads_host', 'ads_admin_user', 'ads_admin_passwd', 'ads_connection', 'ads_context', // ads backend |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param string|array $backend =null string with backend 'sql'|'ldap', or whole config array, default read from global egw_info |
| 137 | 137 | */ |
| 138 | - public function __construct($backend=null) |
|
| 138 | + public function __construct($backend = null) |
|
| 139 | 139 | { |
| 140 | 140 | if (is_array($backend)) |
| 141 | 141 | { |
| 142 | 142 | $this->config = $backend; |
| 143 | 143 | $backend = null; |
| 144 | - self::$_instance = $this; // also set instance returned by singleton |
|
| 145 | - self::$cache = array(); // and empty our internal (session) cache |
|
| 144 | + self::$_instance = $this; // also set instance returned by singleton |
|
| 145 | + self::$cache = array(); // and empty our internal (session) cache |
|
| 146 | 146 | } |
| 147 | 147 | else |
| 148 | 148 | { |
| 149 | - $this->config =& $GLOBALS['egw_info']['server']; |
|
| 149 | + $this->config = & $GLOBALS['egw_info']['server']; |
|
| 150 | 150 | |
| 151 | 151 | if (!isset(self::$_instance)) self::$_instance = $this; |
| 152 | 152 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | function search($param) |
| 196 | 196 | { |
| 197 | 197 | //error_log(__METHOD__.'('.array2string($param).') '.function_backtrace()); |
| 198 | - if (!isset($param['active'])) $param['active'] = true; // default is true = only return active accounts |
|
| 198 | + if (!isset($param['active'])) $param['active'] = true; // default is true = only return active accounts |
|
| 199 | 199 | |
| 200 | 200 | self::setup_cache(); |
| 201 | 201 | $account_search = &self::$cache['account_search']; |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | // no backend understands $param['app'], only sql understands type owngroups or groupmemember[+memberships] |
| 209 | 209 | // --> do an full search first and then filter and limit that search |
| 210 | - elseif($param['app'] || $this->config['account_repository'] != 'sql' && |
|
| 211 | - in_array($param['type'], array('owngroups','groupmembers','groupmembers+memberships'))) |
|
| 210 | + elseif ($param['app'] || $this->config['account_repository'] != 'sql' && |
|
| 211 | + in_array($param['type'], array('owngroups', 'groupmembers', 'groupmembers+memberships'))) |
|
| 212 | 212 | { |
| 213 | 213 | $app = $param['app']; |
| 214 | 214 | unset($param['app']); |
@@ -220,15 +220,15 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | if ($param['type'] == 'owngroups') |
| 222 | 222 | { |
| 223 | - $members = $this->memberships($GLOBALS['egw_info']['user']['account_id'],true); |
|
| 223 | + $members = $this->memberships($GLOBALS['egw_info']['user']['account_id'], true); |
|
| 224 | 224 | $param['type'] = 'groups'; |
| 225 | 225 | } |
| 226 | - elseif(in_array($param['type'],array('groupmembers','groupmembers+memberships'))) |
|
| 226 | + elseif (in_array($param['type'], array('groupmembers', 'groupmembers+memberships'))) |
|
| 227 | 227 | { |
| 228 | 228 | $members = array(); |
| 229 | - foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true) as $grp) |
|
| 229 | + foreach ((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp) |
|
| 230 | 230 | { |
| 231 | - $members = array_unique(array_merge($members, (array)$this->members($grp,true,$param['active']))); |
|
| 231 | + $members = array_unique(array_merge($members, (array)$this->members($grp, true, $param['active']))); |
|
| 232 | 232 | if ($param['type'] == 'groupmembers+memberships') $members[] = $grp; |
| 233 | 233 | } |
| 234 | 234 | $param['type'] = $param['type'] == 'groupmembers+memberships' ? 'both' : 'accounts'; |
@@ -241,20 +241,20 @@ discard block |
||
| 241 | 241 | if ($app) |
| 242 | 242 | { |
| 243 | 243 | // we want the result merged, whatever it takes, as we only care for the ids |
| 244 | - $valid = $this->split_accounts($app,!in_array($param['type'],array('accounts','groups')) ? 'merge' : $param['type'],$param['active']); |
|
| 244 | + $valid = $this->split_accounts($app, !in_array($param['type'], array('accounts', 'groups')) ? 'merge' : $param['type'], $param['active']); |
|
| 245 | 245 | } |
| 246 | 246 | if (isset($members)) |
| 247 | 247 | { |
| 248 | 248 | //error_log(__METHOD__.'() members='.array2string($members)); |
| 249 | 249 | if (!$members) $members = array(); |
| 250 | - $valid = !$app ? $members : array_intersect($valid,$members); // use the intersection |
|
| 250 | + $valid = !$app ? $members : array_intersect($valid, $members); // use the intersection |
|
| 251 | 251 | } |
| 252 | 252 | //error_log(__METHOD__."() limiting result to app='$app' and/or group=$group valid-ids=".array2string($valid)); |
| 253 | 253 | $n = 0; |
| 254 | 254 | $account_search[$serial]['data'] = array(); |
| 255 | 255 | foreach ($full_search as $id => $data) |
| 256 | 256 | { |
| 257 | - if (!in_array($id,$valid)) |
|
| 257 | + if (!in_array($id, $valid)) |
|
| 258 | 258 | { |
| 259 | 259 | $this->total--; |
| 260 | 260 | continue; |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $account_search[$serial]['data'] = $this->backend->search($param); |
| 275 | 275 | if ($param['type'] !== 'accounts') |
| 276 | 276 | { |
| 277 | - foreach($account_search[$serial]['data'] as &$account) |
|
| 277 | + foreach ($account_search[$serial]['data'] as &$account) |
|
| 278 | 278 | { |
| 279 | 279 | // add default description for Admins and Default group |
| 280 | 280 | if ($account['account_type'] === 'g') |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | { |
| 304 | 304 | $options['filter'] = (array)$options['filter']; |
| 305 | 305 | } |
| 306 | - switch($GLOBALS['egw_info']['user']['preferences']['common']['account_display']) |
|
| 306 | + switch ($GLOBALS['egw_info']['user']['preferences']['common']['account_display']) |
|
| 307 | 307 | { |
| 308 | 308 | case 'firstname': |
| 309 | 309 | case 'firstall': |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | $only_own = $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] === 'groupmembers' && |
| 321 | 321 | !isset($GLOBALS['egw_info']['user']['apps']['admin']); |
| 322 | - switch($options['account_type']) |
|
| 322 | + switch ($options['account_type']) |
|
| 323 | 323 | { |
| 324 | 324 | case 'accounts': |
| 325 | 325 | $type = $only_own ? 'groupmembers' : 'accounts'; |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | break; |
| 341 | 341 | } |
| 342 | 342 | $accounts = array(); |
| 343 | - foreach(self::getInstance()->search(array( |
|
| 343 | + foreach (self::getInstance()->search(array( |
|
| 344 | 344 | 'type' => $options['filter']['group'] < 0 ? $options['filter']['group'] : $type, |
| 345 | 345 | 'query' => $pattern, |
| 346 | 346 | 'query_type' => 'all', |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | )) as $account) |
| 349 | 349 | { |
| 350 | 350 | $accounts[$account['account_id']] = self::format_username($account['account_lid'], |
| 351 | - $account['account_firstname'],$account['account_lastname'],$account['account_id']); |
|
| 351 | + $account['account_firstname'], $account['account_lastname'], $account['account_id']); |
|
| 352 | 352 | } |
| 353 | 353 | return $accounts; |
| 354 | 354 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param boolean $set_depricated_names =false set _additionaly_ the depricated keys without 'account_' prefix |
| 365 | 365 | * @return array/boolean array with account data (keys: account_id, account_lid, ...) or false if account not found |
| 366 | 366 | */ |
| 367 | - function read($id=0,$set_depricated_names=false) |
|
| 367 | + function read($id = 0, $set_depricated_names = false) |
|
| 368 | 368 | { |
| 369 | 369 | if (!$id) // deprecated use!!! |
| 370 | 370 | { |
@@ -386,9 +386,9 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | if ($set_depricated_names && $data) |
| 388 | 388 | { |
| 389 | - foreach($this->depricated_names as $name) |
|
| 389 | + foreach ($this->depricated_names as $name) |
|
| 390 | 390 | { |
| 391 | - $data[$name] =& $data['account_'.$name]; |
|
| 391 | + $data[$name] = & $data['account_'.$name]; |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | return $data; |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | function json($id) |
| 406 | 406 | { |
| 407 | 407 | static $keys = array( |
| 408 | - 'account_id','account_lid','person_id','account_status', |
|
| 409 | - 'account_firstname','account_lastname','account_email','account_fullname','account_phone', |
|
| 408 | + 'account_id', 'account_lid', 'person_id', 'account_status', |
|
| 409 | + 'account_firstname', 'account_lastname', 'account_email', 'account_fullname', 'account_phone', |
|
| 410 | 410 | ); |
| 411 | 411 | if (($account = $this->read($id))) |
| 412 | 412 | { |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | // for current user, add the apps available to him |
| 416 | 416 | if ($id == $GLOBALS['egw_info']['user']['account_id']) |
| 417 | 417 | { |
| 418 | - foreach((array)$GLOBALS['egw_info']['user']['apps'] as $app => $data) |
|
| 418 | + foreach ((array)$GLOBALS['egw_info']['user']['apps'] as $app => $data) |
|
| 419 | 419 | { |
| 420 | - unset($data['table_defs']); // no need for that on the client |
|
| 420 | + unset($data['table_defs']); // no need for that on the client |
|
| 421 | 421 | $account['apps'][$app] = $data; |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | * @param $lastname ='' lastname |
| 433 | 433 | * @param $accountid =0 id, to check if it's a user or group, otherwise the lid will be used |
| 434 | 434 | */ |
| 435 | - static function format_username($lid = '', $firstname = '', $lastname = '', $accountid=0) |
|
| 435 | + static function format_username($lid = '', $firstname = '', $lastname = '', $accountid = 0) |
|
| 436 | 436 | { |
| 437 | 437 | if (!$lid && !$firstname && !$lastname) |
| 438 | 438 | { |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | if (empty($firstname)) $firstname = $lid; |
| 446 | 446 | if (empty($lastname) || $is_group) |
| 447 | 447 | { |
| 448 | - $lastname = $is_group ? lang('Group') : lang('User'); |
|
| 448 | + $lastname = $is_group ? lang('Group') : lang('User'); |
|
| 449 | 449 | } |
| 450 | 450 | $display = $GLOBALS['egw_info']['user']['preferences']['common']['account_display']; |
| 451 | 451 | |
@@ -459,30 +459,30 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $name = ''; |
| 462 | - switch($display) |
|
| 462 | + switch ($display) |
|
| 463 | 463 | { |
| 464 | 464 | case 'firstname': |
| 465 | - $name = $firstname . ' ' . $lastname; |
|
| 465 | + $name = $firstname.' '.$lastname; |
|
| 466 | 466 | break; |
| 467 | 467 | case 'lastname': |
| 468 | - $name = $lastname . $delimiter . $firstname; |
|
| 468 | + $name = $lastname.$delimiter.$firstname; |
|
| 469 | 469 | break; |
| 470 | 470 | case 'username': |
| 471 | 471 | $name = $lid; |
| 472 | 472 | break; |
| 473 | 473 | case 'firstall': |
| 474 | - $name = $firstname . ' ' . $lastname . ' ['.$lid.']'; |
|
| 474 | + $name = $firstname.' '.$lastname.' ['.$lid.']'; |
|
| 475 | 475 | break; |
| 476 | 476 | case 'lastall': |
| 477 | - $name = $lastname . $delimiter . $firstname . ' ['.$lid.']'; |
|
| 477 | + $name = $lastname.$delimiter.$firstname.' ['.$lid.']'; |
|
| 478 | 478 | break; |
| 479 | 479 | case 'allfirst': |
| 480 | - $name = '['.$lid.'] ' . $firstname . ' ' . $lastname; |
|
| 480 | + $name = '['.$lid.'] '.$firstname.' '.$lastname; |
|
| 481 | 481 | break; |
| 482 | 482 | case 'all': |
| 483 | 483 | /* fall through */ |
| 484 | 484 | default: |
| 485 | - $name = '['.$lid.'] ' . $lastname . $delimiter . $firstname; |
|
| 485 | + $name = '['.$lid.'] '.$lastname.$delimiter.$firstname; |
|
| 486 | 486 | } |
| 487 | 487 | return $name; |
| 488 | 488 | } |
@@ -493,14 +493,14 @@ discard block |
||
| 493 | 493 | * @param string $account_id =null account id |
| 494 | 494 | * @return string full name of user or "#$accountid" if user not found |
| 495 | 495 | */ |
| 496 | - static function username($account_id=null) |
|
| 496 | + static function username($account_id = null) |
|
| 497 | 497 | { |
| 498 | 498 | if ($account_id && !($account = self::cache_read((int)$account_id))) |
| 499 | 499 | { |
| 500 | 500 | return '#'.$account_id; |
| 501 | 501 | } |
| 502 | 502 | return self::format_username($account['account_lid'], |
| 503 | - $account['account_firstname'] , $account['account_lastname'], $account_id); |
|
| 503 | + $account['account_firstname'], $account['account_lastname'], $account_id); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | * @param string $domain =null domain-name or null to use eGW's default domain $GLOBALS['egw_info']['server']['mail_suffix] |
| 515 | 515 | * @return string with email address |
| 516 | 516 | */ |
| 517 | - static function email($first,$last,$account,$domain=null) |
|
| 517 | + static function email($first, $last, $account, $domain = null) |
|
| 518 | 518 | { |
| 519 | - foreach (array('first','last','account') as $name) |
|
| 519 | + foreach (array('first', 'last', 'account') as $name) |
|
| 520 | 520 | { |
| 521 | 521 | $$name = Translation::to_ascii($$name); |
| 522 | 522 | } |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | if (!$domain) $domain = $GLOBALS['egw_info']['server']['mail_suffix']; |
| 539 | 539 | if (!$domain) $domain = $_SERVER['SERVER_NAME']; |
| 540 | 540 | |
| 541 | - $email = str_replace(array('first','last','initial','account','dot','underscore','-'), |
|
| 542 | - array($first,$last,substr($first,0,1),$account,$dot,$underscore,''), |
|
| 541 | + $email = str_replace(array('first', 'last', 'initial', 'account', 'dot', 'underscore', '-'), |
|
| 542 | + array($first, $last, substr($first, 0, 1), $account, $dot, $underscore, ''), |
|
| 543 | 543 | $GLOBALS['egw_info']['server']['email_address_format'] ? $GLOBALS['egw_info']['server']['email_address_format'] : 'first-dot-last'). |
| 544 | 544 | ($domain ? '@'.$domain : ''); |
| 545 | 545 | //echo " = '$email'</p>\n"; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | { |
| 556 | 556 | if (empty($data['account_description'])) |
| 557 | 557 | { |
| 558 | - switch($data['account_lid']) |
|
| 558 | + switch ($data['account_lid']) |
|
| 559 | 559 | { |
| 560 | 560 | case 'Default': |
| 561 | 561 | $data['account_description'] = lang('EGroupware all users group, do NOT delete'); |
@@ -583,15 +583,15 @@ discard block |
||
| 583 | 583 | * @param boolean $check_depricated_names =false check _additionaly_ the depricated keys without 'account_' prefix |
| 584 | 584 | * @return int|boolean the account_id or false on error |
| 585 | 585 | */ |
| 586 | - function save(&$data,$check_depricated_names=false) |
|
| 586 | + function save(&$data, $check_depricated_names = false) |
|
| 587 | 587 | { |
| 588 | 588 | if ($check_depricated_names) |
| 589 | 589 | { |
| 590 | - foreach($this->depricated_names as $name) |
|
| 590 | + foreach ($this->depricated_names as $name) |
|
| 591 | 591 | { |
| 592 | 592 | if (isset($data[$name]) && !isset($data['account_'.$name])) |
| 593 | 593 | { |
| 594 | - $data['account_'.$name] =& $data[$name]; |
|
| 594 | + $data['account_'.$name] = & $data[$name]; |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | { |
| 605 | 605 | // if we are not on a pure LDAP system, we have to write the account-date via the contacts class now |
| 606 | 606 | if (($this->config['account_repository'] == 'sql' || $this->config['contact_repository'] == 'sql-ldap') && |
| 607 | - (!($old = $this->read($data['account_id'])) || // only for new account or changed contact-data |
|
| 607 | + (!($old = $this->read($data['account_id'])) || // only for new account or changed contact-data |
|
| 608 | 608 | $old['account_firstname'] != $data['account_firstname'] || |
| 609 | 609 | $old['account_lastname'] != $data['account_lastname'] || |
| 610 | 610 | $old['account_email'] != $data['account_email'])) |
@@ -619,14 +619,14 @@ discard block |
||
| 619 | 619 | 'id' => $data['person_id'], |
| 620 | 620 | 'owner' => 0, |
| 621 | 621 | ); |
| 622 | - $GLOBALS['egw']->contacts->save($contact,true); // true = ignore addressbook acl |
|
| 622 | + $GLOBALS['egw']->contacts->save($contact, true); // true = ignore addressbook acl |
|
| 623 | 623 | } |
| 624 | 624 | // save primary group if necessary |
| 625 | - if ($data['account_primary_group'] && (!($memberships = $this->memberships($id,true)) || |
|
| 626 | - !in_array($data['account_primary_group'],$memberships))) |
|
| 625 | + if ($data['account_primary_group'] && (!($memberships = $this->memberships($id, true)) || |
|
| 626 | + !in_array($data['account_primary_group'], $memberships))) |
|
| 627 | 627 | { |
| 628 | 628 | $memberships[] = $data['account_primary_group']; |
| 629 | - $this->set_memberships($memberships, $id); // invalidates cache for account_id and primary group |
|
| 629 | + $this->set_memberships($memberships, $id); // invalidates cache for account_id and primary group |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | // as some backends set (group-)members in save, we need to invalidate their members too! |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | * @param array $data =null array with account data, not specifying the account is depricated!!! |
| 683 | 683 | * @return boolean true=expired (no more login possible), false otherwise |
| 684 | 684 | */ |
| 685 | - function is_expired($data=null) |
|
| 685 | + function is_expired($data = null) |
|
| 686 | 686 | { |
| 687 | - if (is_null($data)) $data = $this->data; // depricated use |
|
| 687 | + if (is_null($data)) $data = $this->data; // depricated use |
|
| 688 | 688 | |
| 689 | 689 | $expires = isset($data['account_expires']) ? $data['account_expires'] : $data['expires']; |
| 690 | 690 | |
@@ -718,10 +718,10 @@ discard block |
||
| 718 | 718 | * @param string $account_type =null u = user or g = group, or default null = try both |
| 719 | 719 | * @return int|false numeric account_id or false on error ($name not found) |
| 720 | 720 | */ |
| 721 | - function name2id($name,$which='account_lid',$account_type=null) |
|
| 721 | + function name2id($name, $which = 'account_lid', $account_type = null) |
|
| 722 | 722 | { |
| 723 | 723 | // Don't bother searching for empty or non-scalar account_lid |
| 724 | - if(empty($name) || !is_scalar($name)) |
|
| 724 | + if (empty($name) || !is_scalar($name)) |
|
| 725 | 725 | { |
| 726 | 726 | return False; |
| 727 | 727 | } |
@@ -729,12 +729,12 @@ discard block |
||
| 729 | 729 | self::setup_cache(); |
| 730 | 730 | $name_list = &self::$cache['name_list']; |
| 731 | 731 | |
| 732 | - if(@isset($name_list[$which][$name]) && $name_list[$which][$name]) |
|
| 732 | + if (@isset($name_list[$which][$name]) && $name_list[$which][$name]) |
|
| 733 | 733 | { |
| 734 | 734 | return $name_list[$which][$name]; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - return $name_list[$which][$name] = $this->backend->name2id($name,$which,$account_type); |
|
| 737 | + return $name_list[$which][$name] = $this->backend->name2id($name, $which, $account_type); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | * @param boolean $generate_email =false true: generate an email address, if user has none |
| 748 | 748 | * @return string|boolean converted value or false on error ($account_id not found) |
| 749 | 749 | */ |
| 750 | - static function id2name($account_id, $which='account_lid', $generate_email=false) |
|
| 750 | + static function id2name($account_id, $which = 'account_lid', $generate_email = false) |
|
| 751 | 751 | { |
| 752 | 752 | if (!is_numeric($account_id) && !($account_id = self::getInstance()->name2id($account_id))) |
| 753 | 753 | { |
@@ -823,13 +823,13 @@ discard block |
||
| 823 | 823 | $account_lid != $GLOBALS['egw_info']['user']['account_lid'] || |
| 824 | 824 | // only allow group-members for account-selection is groupmembers |
| 825 | 825 | $GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'groupmembers' && |
| 826 | - !array_intersect((array)$this->memberships($account_id,true), |
|
| 827 | - (array)$this->memberships($GLOBALS['egw_info']['user']['account_id'],true)))) |
|
| 826 | + !array_intersect((array)$this->memberships($account_id, true), |
|
| 827 | + (array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true)))) |
|
| 828 | 828 | { |
| 829 | 829 | //error_log(__METHOD__."($account_id='$account_lid') returning FALSE"); |
| 830 | - return false; // user is not allowed to see given account |
|
| 830 | + return false; // user is not allowed to see given account |
|
| 831 | 831 | } |
| 832 | - return true; // user allowed to see given account |
|
| 832 | + return true; // user allowed to see given account |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -839,11 +839,11 @@ discard block |
||
| 839 | 839 | * @param boolean $just_id =false return just account_id's or account_id => account_lid pairs |
| 840 | 840 | * @return array with account_id's ($just_id) or account_id => account_lid pairs (!$just_id) |
| 841 | 841 | */ |
| 842 | - function memberships($account_id, $just_id=false) |
|
| 842 | + function memberships($account_id, $just_id = false) |
|
| 843 | 843 | { |
| 844 | 844 | if (!is_int($account_id) && !is_numeric($account_id)) |
| 845 | 845 | { |
| 846 | - $account_id = $this->name2id($account_id,'account_lid','u'); |
|
| 846 | + $account_id = $this->name2id($account_id, 'account_lid', 'u'); |
|
| 847 | 847 | } |
| 848 | 848 | if ($account_id && ($data = self::cache_read($account_id))) |
| 849 | 849 | { |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | * @param array $groups array with gidnumbers |
| 860 | 860 | * @param int $account_id uidnumber |
| 861 | 861 | */ |
| 862 | - function set_memberships($groups,$account_id) |
|
| 862 | + function set_memberships($groups, $account_id) |
|
| 863 | 863 | { |
| 864 | 864 | if (!is_int($account_id) && !is_numeric($account_id)) |
| 865 | 865 | { |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @param boolean $active =false true: return only active (not expired or deactived) members, false: return all accounts |
| 888 | 888 | * @return array with account_id ($just_id) or account_id => account_lid pairs (!$just_id) |
| 889 | 889 | */ |
| 890 | - function members($account_id, $just_id=false, $active=true) |
|
| 890 | + function members($account_id, $just_id = false, $active = true) |
|
| 891 | 891 | { |
| 892 | 892 | if (!is_int($account_id) && !is_numeric($account_id)) |
| 893 | 893 | { |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | * @param array $members array with uidnumber or uid's |
| 909 | 909 | * @param int $gid gidnumber of group to set |
| 910 | 910 | */ |
| 911 | - function set_members($members,$gid) |
|
| 911 | + function set_members($members, $gid) |
|
| 912 | 912 | { |
| 913 | 913 | if (($old_members = $this->members($gid, true, false)) != $members) |
| 914 | 914 | { |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | * @param boolean $active =false true: return only active (not expired or deactived) members, false: return all accounts |
| 933 | 933 | * @return array/boolean see $use, false on error (wront $use) |
| 934 | 934 | */ |
| 935 | - function split_accounts($app_users,$use='both',$active=true) |
|
| 935 | + function split_accounts($app_users, $use = 'both', $active = true) |
|
| 936 | 936 | { |
| 937 | 937 | if (!is_array($app_users)) |
| 938 | 938 | { |
@@ -943,21 +943,21 @@ discard block |
||
| 943 | 943 | { |
| 944 | 944 | return $cache; |
| 945 | 945 | } |
| 946 | - $app_users = $GLOBALS['egw']->acl->get_ids_for_location('run',1,$app_users); |
|
| 946 | + $app_users = $GLOBALS['egw']->acl->get_ids_for_location('run', 1, $app_users); |
|
| 947 | 947 | } |
| 948 | 948 | $accounts = array( |
| 949 | 949 | 'accounts' => array(), |
| 950 | 950 | 'groups' => array(), |
| 951 | 951 | ); |
| 952 | - foreach($app_users as $id) |
|
| 952 | + foreach ($app_users as $id) |
|
| 953 | 953 | { |
| 954 | 954 | $type = $this->get_type($id); |
| 955 | - if($type == 'g') |
|
| 955 | + if ($type == 'g') |
|
| 956 | 956 | { |
| 957 | 957 | $accounts['groups'][$id] = $id; |
| 958 | 958 | if ($use != 'groups') |
| 959 | 959 | { |
| 960 | - foreach((array)$this->members($id, true, $active) as $id) |
|
| 960 | + foreach ((array)$this->members($id, true, $active) as $id) |
|
| 961 | 961 | { |
| 962 | 962 | $accounts['accounts'][$id] = $id; |
| 963 | 963 | } |
@@ -978,7 +978,7 @@ discard block |
||
| 978 | 978 | $cache = $accounts; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - switch($use) |
|
| 981 | + switch ($use) |
|
| 982 | 982 | { |
| 983 | 983 | case 'both': |
| 984 | 984 | return $accounts; |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | case 'accounts': |
| 988 | 988 | return $accounts['accounts']; |
| 989 | 989 | case 'merge': |
| 990 | - return array_merge($accounts['accounts'],$accounts['groups']); |
|
| 990 | + return array_merge($accounts['accounts'], $accounts['groups']); |
|
| 991 | 991 | } |
| 992 | 992 | return False; |
| 993 | 993 | } |
@@ -1005,21 +1005,20 @@ discard block |
||
| 1005 | 1005 | function auto_add($account_lid, $passwd) |
| 1006 | 1006 | { |
| 1007 | 1007 | $expires = !isset($this->config['auto_create_expire']) || |
| 1008 | - $this->config['auto_create_expire'] == 'never' ? -1 : |
|
| 1009 | - time() + $this->config['auto_create_expire'] + 2; |
|
| 1008 | + $this->config['auto_create_expire'] == 'never' ? -1 : time() + $this->config['auto_create_expire'] + 2; |
|
| 1010 | 1009 | |
| 1011 | 1010 | $memberships = array(); |
| 1012 | 1011 | $default_group_id = null; |
| 1013 | 1012 | // check if we have a comma or semicolon delimited list of groups --> add first as primary and rest as memberships |
| 1014 | - foreach(preg_split('/[,;] */',$this->config['default_group_lid']) as $group_lid) |
|
| 1013 | + foreach (preg_split('/[,;] */', $this->config['default_group_lid']) as $group_lid) |
|
| 1015 | 1014 | { |
| 1016 | - if (($group_id = $this->name2id($group_lid,'account_lid','g'))) |
|
| 1015 | + if (($group_id = $this->name2id($group_lid, 'account_lid', 'g'))) |
|
| 1017 | 1016 | { |
| 1018 | 1017 | if (!$default_group_id) $default_group_id = $group_id; |
| 1019 | 1018 | $memberships[] = $group_id; |
| 1020 | 1019 | } |
| 1021 | 1020 | } |
| 1022 | - if (!$default_group_id && ($default_group_id = $this->name2id('Default','account_lid','g'))) |
|
| 1021 | + if (!$default_group_id && ($default_group_id = $this->name2id('Default', 'account_lid', 'g'))) |
|
| 1023 | 1022 | { |
| 1024 | 1023 | $memberships[] = $default_group_id; |
| 1025 | 1024 | } |
@@ -1056,25 +1055,25 @@ discard block |
||
| 1056 | 1055 | // set memberships if given |
| 1057 | 1056 | if ($memberships) |
| 1058 | 1057 | { |
| 1059 | - $this->set_memberships($memberships,$data['account_id']); |
|
| 1058 | + $this->set_memberships($memberships, $data['account_id']); |
|
| 1060 | 1059 | } |
| 1061 | 1060 | // set the appropriate value for the can change password flag (assume users can, if the admin requires users to change their password) |
| 1062 | 1061 | $data['changepassword'] = (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days']; |
| 1063 | - if(!$data['changepassword']) |
|
| 1062 | + if (!$data['changepassword']) |
|
| 1064 | 1063 | { |
| 1065 | - $GLOBALS['egw']->acl->add_repository('preferences','nopasswordchange',$data['account_id'],1); |
|
| 1064 | + $GLOBALS['egw']->acl->add_repository('preferences', 'nopasswordchange', $data['account_id'], 1); |
|
| 1066 | 1065 | } |
| 1067 | 1066 | else |
| 1068 | 1067 | { |
| 1069 | - $GLOBALS['egw']->acl->delete_repository('preferences','nopasswordchange',$data['account_id']); |
|
| 1068 | + $GLOBALS['egw']->acl->delete_repository('preferences', 'nopasswordchange', $data['account_id']); |
|
| 1070 | 1069 | } |
| 1071 | 1070 | // call hook to notify interested apps about the new account |
| 1072 | 1071 | $GLOBALS['hook_values'] = $data; |
| 1073 | - Hooks::process($data+array( |
|
| 1072 | + Hooks::process($data + array( |
|
| 1074 | 1073 | 'location' => 'addaccount', |
| 1075 | 1074 | // at login-time only the hooks from the following apps will be called |
| 1076 | - 'order' => array('felamimail','fudforum'), |
|
| 1077 | - ),False,True); // called for every app now, not only enabled ones |
|
| 1075 | + 'order' => array('felamimail', 'fudforum'), |
|
| 1076 | + ), False, True); // called for every app now, not only enabled ones |
|
| 1078 | 1077 | unset($data['changepassword']); |
| 1079 | 1078 | |
| 1080 | 1079 | return $data['account_id']; |
@@ -1121,14 +1120,14 @@ discard block |
||
| 1121 | 1120 | * |
| 1122 | 1121 | * @param int|array $account_ids user- or group-id(s) for which cache should be invalidated, default 0 = only search/name2id cache |
| 1123 | 1122 | */ |
| 1124 | - static function cache_invalidate($account_ids=0) |
|
| 1123 | + static function cache_invalidate($account_ids = 0) |
|
| 1125 | 1124 | { |
| 1126 | 1125 | //error_log(__METHOD__.'('.array2string($account_ids).')'); |
| 1127 | 1126 | |
| 1128 | 1127 | // instance-wide cache |
| 1129 | 1128 | if ($account_ids) |
| 1130 | 1129 | { |
| 1131 | - foreach((array)$account_ids as $account_id) |
|
| 1130 | + foreach ((array)$account_ids as $account_id) |
|
| 1132 | 1131 | { |
| 1133 | 1132 | $instance = self::getInstance(); |
| 1134 | 1133 | |
@@ -1140,11 +1139,11 @@ discard block |
||
| 1140 | 1139 | |
| 1141 | 1140 | // session-cache |
| 1142 | 1141 | if (self::$cache) self::$cache = array(); |
| 1143 | - Cache::unsetSession('accounts_cache','phpgwapi'); |
|
| 1142 | + Cache::unsetSession('accounts_cache', 'phpgwapi'); |
|
| 1144 | 1143 | |
| 1145 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 1144 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 1146 | 1145 | { |
| 1147 | - Egw::invalidate_session_cache(); // invalidates whole egw-enviroment if stored in the session |
|
| 1146 | + Egw::invalidate_session_cache(); // invalidates whole egw-enviroment if stored in the session |
|
| 1148 | 1147 | } |
| 1149 | 1148 | } |
| 1150 | 1149 | |
@@ -1168,11 +1167,11 @@ discard block |
||
| 1168 | 1167 | * @return array |
| 1169 | 1168 | * @throws Exception\WrongParameter if no integer was passed as $account_id |
| 1170 | 1169 | */ |
| 1171 | - static function cache_read($account_id, $need_active=false) |
|
| 1170 | + static function cache_read($account_id, $need_active = false) |
|
| 1172 | 1171 | { |
| 1173 | 1172 | if (!is_numeric($account_id)) throw new Exception\WrongParameter('Not an integer!'); |
| 1174 | 1173 | |
| 1175 | - $account =& self::$request_cache[$account_id]; |
|
| 1174 | + $account = & self::$request_cache[$account_id]; |
|
| 1176 | 1175 | |
| 1177 | 1176 | if (!isset($account)) // not in request cache --> try instance cache |
| 1178 | 1177 | { |
@@ -1203,7 +1202,7 @@ discard block |
||
| 1203 | 1202 | { |
| 1204 | 1203 | $instance = self::getInstance(); |
| 1205 | 1204 | $account['members-active'] = array(); |
| 1206 | - foreach((array)$account['members'] as $id => $lid) |
|
| 1205 | + foreach ((array)$account['members'] as $id => $lid) |
|
| 1207 | 1206 | { |
| 1208 | 1207 | if ($instance->is_active($id)) $account['members-active'][$id] = $lid; |
| 1209 | 1208 | } |
@@ -1229,11 +1228,11 @@ discard block |
||
| 1229 | 1228 | */ |
| 1230 | 1229 | private static function setup_cache() |
| 1231 | 1230 | { |
| 1232 | - if (is_array(self::$cache)) return; // cache is already setup |
|
| 1231 | + if (is_array(self::$cache)) return; // cache is already setup |
|
| 1233 | 1232 | |
| 1234 | 1233 | if (self::$use_session_cache && is_object($GLOBALS['egw']->session)) |
| 1235 | 1234 | { |
| 1236 | - self::$cache =& Cache::getSession('accounts_cache','phpgwapi'); |
|
| 1235 | + self::$cache = & Cache::getSession('accounts_cache', 'phpgwapi'); |
|
| 1237 | 1236 | } |
| 1238 | 1237 | //error_log(__METHOD__."() use_session_cache=".array2string(self::$use_session_cache).", is_array(self::\$cache)=".array2string(is_array(self::$cache))); |
| 1239 | 1238 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * If no account_id is set in data the account is added and the new id is set in $data. |
| 191 | 191 | * |
| 192 | 192 | * @param array $data array with account-data |
| 193 | - * @return int|boolean the account_id or false on error |
|
| 193 | + * @return false|string the account_id or false on error |
|
| 194 | 194 | */ |
| 195 | 195 | function save(&$data) |
| 196 | 196 | { |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | * |
| 996 | 996 | * @param int $_account_id |
| 997 | 997 | * @param string $ip |
| 998 | - * @return int lastlogin time |
|
| 998 | + * @return boolean lastlogin time |
|
| 999 | 999 | */ |
| 1000 | 1000 | function update_lastlogin($_account_id, $ip) |
| 1001 | 1001 | { |
@@ -1097,7 +1097,6 @@ discard block |
||
| 1097 | 1097 | * @param int $gid gidnumber of group to set |
| 1098 | 1098 | * @param array $objectclass =null should we set the member and uniqueMember attributes (groupOf(Unique)Names|univentionGroup) (default detect it) |
| 1099 | 1099 | * @param string $use_cn =null if set $cn is used instead $gid and the attributes are returned, not written to ldap |
| 1100 | - * @param boolean $uniqueMember =null should we set the uniqueMember attribute (default detect it) |
|
| 1101 | 1100 | * @return boolean/array false on failure, array or true otherwise |
| 1102 | 1101 | */ |
| 1103 | 1102 | function set_members($members, $gid, array $objectclass=null, $use_cn=null) |
@@ -962,7 +962,7 @@ |
||
| 962 | 962 | 'account_fullname' => 'cn', |
| 963 | 963 | ); |
| 964 | 964 | if (!isset($to_ldap[$which]) || $account_type === 'g') { |
| 965 | - return False; |
|
| 965 | + return False; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | $sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'=' . $name . ')(objectclass=posixaccount))', array('uidNumber')); |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | var $requiredObjectClasses = array( |
| 91 | 91 | 'user' => array( |
| 92 | - 'top','person','organizationalperson','inetorgperson','posixaccount','shadowaccount' |
|
| 92 | + 'top', 'person', 'organizationalperson', 'inetorgperson', 'posixaccount', 'shadowaccount' |
|
| 93 | 93 | ), |
| 94 | 94 | 'user-if-supported' => array( // these classes get added, if server supports them |
| 95 | 95 | 'mozillaabpersonalpha', 'mozillaorgperson', 'evolutionperson', |
| 96 | 96 | 'univentionperson', 'univentionmail', array('univentionobject', 'univentionObjectType' => 'users/user'), |
| 97 | 97 | ), |
| 98 | 98 | 'group' => array( |
| 99 | - 'top','posixgroup','groupofnames' |
|
| 99 | + 'top', 'posixgroup', 'groupofnames' |
|
| 100 | 100 | ), |
| 101 | 101 | 'group-if-supported' => array( // these classes get added, if servers supports them |
| 102 | 102 | 'univentiongroup', array('univentionobject', 'univentionObjectType' => 'groups/group'), |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | var $group_mail_classes = array( |
| 117 | 117 | 'dbmailforwardingaddress' => 'mailforwardingaddress', |
| 118 | - 'dbmailuser' => array('mailforwardingaddress','uid'), |
|
| 119 | - 'qmailuser' => array('mailforwardingaddress','uid'), |
|
| 118 | + 'dbmailuser' => array('mailforwardingaddress', 'uid'), |
|
| 119 | + 'qmailuser' => array('mailforwardingaddress', 'uid'), |
|
| 120 | 120 | 'mailaccount' => 'mailalias', |
| 121 | 121 | 'univentiongroup' => array(false, false, true), |
| 122 | 122 | ); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $this->use_session_cache = true; |
| 159 | 159 | |
| 160 | 160 | $this->ldap = Api\Ldap::factory(false, $this->frontend->config['ldap_host'], |
| 161 | - $this->frontend->config['ldap_root_dn'],$this->frontend->config['ldap_root_pw']); |
|
| 161 | + $this->frontend->config['ldap_root_dn'], $this->frontend->config['ldap_root_pw']); |
|
| 162 | 162 | $this->ds = $this->ldap->ds; |
| 163 | 163 | |
| 164 | 164 | $this->user_context = $this->frontend->config['ldap_context']; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $is_group = $data['account_id'] < 0 || $data['account_type'] === 'g'; |
| 198 | 198 | |
| 199 | - $data_utf8 = Api\Translation::convert($data,Api\Translation::charset(),'utf-8'); |
|
| 199 | + $data_utf8 = Api\Translation::convert($data, Api\Translation::charset(), 'utf-8'); |
|
| 200 | 200 | $members = $data['account_members']; |
| 201 | 201 | |
| 202 | 202 | if (!is_object($this->ldapServerInfo)) |
@@ -208,8 +208,7 @@ discard block |
||
| 208 | 208 | if ($data_utf8['account_id'] && $data_utf8['account_lid']) |
| 209 | 209 | { |
| 210 | 210 | // read the entry first, to check if the dn (account_lid) has changed |
| 211 | - $sri = $is_group ? ldap_search($this->ds,$this->group_context,'gidnumber='.abs($data['account_id'])) : |
|
| 212 | - ldap_search($this->ds,$this->user_context,'uidnumber='.$data['account_id']); |
|
| 211 | + $sri = $is_group ? ldap_search($this->ds, $this->group_context, 'gidnumber='.abs($data['account_id'])) : ldap_search($this->ds, $this->user_context, 'uidnumber='.$data['account_id']); |
|
| 213 | 212 | $old = ldap_get_entries($this->ds, $sri); |
| 214 | 213 | |
| 215 | 214 | if (!$old['count']) |
@@ -221,9 +220,9 @@ discard block |
||
| 221 | 220 | $old = Api\Ldap::result2array($old[0]); |
| 222 | 221 | $old['objectclass'] = array_map('strtolower', $old['objectclass']); |
| 223 | 222 | $key = false; |
| 224 | - if ($is_group && ($key = array_search('namedobject',$old['objectclass'])) !== false || |
|
| 225 | - $is_group && ($old['cn'] != $data_utf8['account_lid'] || substr($old['dn'],0,3) != 'cn=') || |
|
| 226 | - !$is_group && ($old['uid'] != $data_utf8['account_lid'] || substr($old['dn'],0,4) != 'uid=')) |
|
| 223 | + if ($is_group && ($key = array_search('namedobject', $old['objectclass'])) !== false || |
|
| 224 | + $is_group && ($old['cn'] != $data_utf8['account_lid'] || substr($old['dn'], 0, 3) != 'cn=') || |
|
| 225 | + !$is_group && ($old['uid'] != $data_utf8['account_lid'] || substr($old['dn'], 0, 4) != 'uid=')) |
|
| 227 | 226 | { |
| 228 | 227 | // query the memberships to set them again later |
| 229 | 228 | if (!$is_group) |
@@ -252,7 +251,7 @@ discard block |
||
| 252 | 251 | } |
| 253 | 252 | } |
| 254 | 253 | // check if we need to write the objectclass: new entry or required object classes are missing |
| 255 | - if (!$old || array_diff($this->requiredObjectClasses[$is_group ? 'group' : 'user'],$old['objectclass'])) |
|
| 254 | + if (!$old || array_diff($this->requiredObjectClasses[$is_group ? 'group' : 'user'], $old['objectclass'])) |
|
| 256 | 255 | { |
| 257 | 256 | // additional objectclasse might be already set in $to_write or $old |
| 258 | 257 | if (!is_array($to_write['objectclass'])) |
@@ -261,7 +260,7 @@ discard block |
||
| 261 | 260 | } |
| 262 | 261 | if (!$old) // for new accounts add additional addressbook object classes, if supported by server |
| 263 | 262 | { // as setting them later might loose eg. password, if we are not allowed to read them |
| 264 | - foreach($this->requiredObjectClasses[$is_group?'group-if-supported':'user-if-supported'] as $additional) |
|
| 263 | + foreach ($this->requiredObjectClasses[$is_group ? 'group-if-supported' : 'user-if-supported'] as $additional) |
|
| 265 | 264 | { |
| 266 | 265 | $add = array(); |
| 267 | 266 | if (is_array($additional)) |
@@ -283,8 +282,7 @@ discard block |
||
| 283 | 282 | { |
| 284 | 283 | if (!$data['account_lid']) return false; |
| 285 | 284 | |
| 286 | - $dn = $is_group ? 'cn='.$data_utf8['account_lid'].','.$this->group_context : |
|
| 287 | - 'uid='.$data_utf8['account_lid'].','.$this->user_context; |
|
| 285 | + $dn = $is_group ? 'cn='.$data_utf8['account_lid'].','.$this->group_context : 'uid='.$data_utf8['account_lid'].','.$this->user_context; |
|
| 288 | 286 | } |
| 289 | 287 | // now we merge the user or group data |
| 290 | 288 | if ($is_group) |
@@ -293,23 +291,23 @@ discard block |
||
| 293 | 291 | $data['account_type'] = 'g'; |
| 294 | 292 | |
| 295 | 293 | $objectclass = $old ? $old['objectclass'] : $to_write['objectclass']; |
| 296 | - if ($members || !$old && array_intersect(array('groupofnames','groupofuniquenames','univentiongroup'), $objectclass)) |
|
| 294 | + if ($members || !$old && array_intersect(array('groupofnames', 'groupofuniquenames', 'univentiongroup'), $objectclass)) |
|
| 297 | 295 | { |
| 298 | 296 | $to_write = array_merge($to_write, $this->set_members($members, $data['account_id'], $objectclass, $dn)); |
| 299 | 297 | } |
| 300 | 298 | // check if we should set a mail address and forwards for each member |
| 301 | - foreach($this->group_mail_classes as $objectclass => $forward) |
|
| 299 | + foreach ($this->group_mail_classes as $objectclass => $forward) |
|
| 302 | 300 | { |
| 303 | 301 | $extra_attr = false; |
| 304 | 302 | $keep_objectclass = false; |
| 305 | - if (is_array($forward)) list($forward,$extra_attr,$keep_objectclass) = $forward; |
|
| 303 | + if (is_array($forward)) list($forward, $extra_attr, $keep_objectclass) = $forward; |
|
| 306 | 304 | |
| 307 | 305 | if ($this->ldapServerInfo->supportsObjectClass($objectclass) && |
| 308 | - ($old && in_array($objectclass,$old['objectclass']) || $data_utf8['account_email'] || $old[static::MAIL_ATTR])) |
|
| 306 | + ($old && in_array($objectclass, $old['objectclass']) || $data_utf8['account_email'] || $old[static::MAIL_ATTR])) |
|
| 309 | 307 | { |
| 310 | 308 | if ($data_utf8['account_email']) // setting an email |
| 311 | 309 | { |
| 312 | - if (!in_array($objectclass,$old ? $old['objectclass'] : $to_write['objectclass'])) |
|
| 310 | + if (!in_array($objectclass, $old ? $old['objectclass'] : $to_write['objectclass'])) |
|
| 313 | 311 | { |
| 314 | 312 | if ($old) $to_write['objectclass'] = $old['objectclass']; |
| 315 | 313 | $to_write['objectclass'][] = $objectclass; |
@@ -323,19 +321,19 @@ discard block |
||
| 323 | 321 | $to_write[$forward] = array(); |
| 324 | 322 | foreach (array_keys($members) as $member) |
| 325 | 323 | { |
| 326 | - if (($email = $this->id2name($member,'account_email'))) |
|
| 324 | + if (($email = $this->id2name($member, 'account_email'))) |
|
| 327 | 325 | { |
| 328 | 326 | $to_write[$forward][] = $email; |
| 329 | 327 | } |
| 330 | 328 | } |
| 331 | 329 | } |
| 332 | 330 | } |
| 333 | - elseif($old) // remove the mail and forwards only for existing entries |
|
| 331 | + elseif ($old) // remove the mail and forwards only for existing entries |
|
| 334 | 332 | { |
| 335 | 333 | $to_write[static::MAIL_ATTR] = array(); |
| 336 | 334 | if ($forward) $to_write[$forward] = array(); |
| 337 | 335 | if ($extra_attr) $to_write[$extra_attr] = array(); |
| 338 | - if (!$keep_objectclass && ($key = array_search($objectclass,$old['objectclass']))) |
|
| 336 | + if (!$keep_objectclass && ($key = array_search($objectclass, $old['objectclass']))) |
|
| 339 | 337 | { |
| 340 | 338 | $to_write['objectclass'] = $old['objectclass']; |
| 341 | 339 | unset($to_write['objectclass'][$key]); |
@@ -349,7 +347,7 @@ discard block |
||
| 349 | 347 | } |
| 350 | 348 | else |
| 351 | 349 | { |
| 352 | - $to_write = $this->_merge_user($to_write,$data_utf8,!$old); |
|
| 350 | + $to_write = $this->_merge_user($to_write, $data_utf8, !$old); |
|
| 353 | 351 | // make sure multiple email-addresses in the mail attribute "survive" |
| 354 | 352 | if (isset($to_write[static::MAIL_ATTR]) && count($old[static::MAIL_ATTR]) > 1) |
| 355 | 353 | { |
@@ -368,21 +366,21 @@ discard block |
||
| 368 | 366 | } |
| 369 | 367 | |
| 370 | 368 | // remove memberuid when adding a group |
| 371 | - if(!$old && is_array($to_write['memberuid']) && empty($to_write['memberuid'])) { |
|
| 369 | + if (!$old && is_array($to_write['memberuid']) && empty($to_write['memberuid'])) { |
|
| 372 | 370 | unset($to_write['memberuid']); |
| 373 | 371 | } |
| 374 | 372 | // modifying or adding the entry |
| 375 | - if ($old && !@ldap_modify($this->ds,$dn,$to_write) || |
|
| 376 | - !$old && !@ldap_add($this->ds,$dn,$to_write)) |
|
| 373 | + if ($old && !@ldap_modify($this->ds, $dn, $to_write) || |
|
| 374 | + !$old && !@ldap_add($this->ds, $dn, $to_write)) |
|
| 377 | 375 | { |
| 378 | 376 | $err = true; |
| 379 | - if ($is_group && ($key = array_search('groupofnames',$to_write['objectclass'])) !== false) |
|
| 377 | + if ($is_group && ($key = array_search('groupofnames', $to_write['objectclass'])) !== false) |
|
| 380 | 378 | { |
| 381 | 379 | // try again with removed groupOfNames stuff, as I cant detect if posixGroup is a structural object |
| 382 | 380 | unset($to_write['objectclass'][$key]); |
| 383 | 381 | $to_write['objectclass'] = array_values($to_write['objectclass']); |
| 384 | 382 | unset($to_write['member']); |
| 385 | - $err = $old ? !ldap_modify($this->ds,$dn,$to_write) : !ldap_add($this->ds,$dn,$to_write); |
|
| 383 | + $err = $old ? !ldap_modify($this->ds, $dn, $to_write) : !ldap_add($this->ds, $dn, $to_write); |
|
| 386 | 384 | } |
| 387 | 385 | if ($err) |
| 388 | 386 | { |
@@ -392,7 +390,7 @@ discard block |
||
| 392 | 390 | } |
| 393 | 391 | if ($memberships) |
| 394 | 392 | { |
| 395 | - $this->set_memberships($memberships,$data['account_id']); |
|
| 393 | + $this->set_memberships($memberships, $data['account_id']); |
|
| 396 | 394 | } |
| 397 | 395 | return $data['account_id']; |
| 398 | 396 | } |
@@ -409,14 +407,14 @@ discard block |
||
| 409 | 407 | |
| 410 | 408 | if ($account_id < 0) |
| 411 | 409 | { |
| 412 | - $sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . abs($account_id)); |
|
| 410 | + $sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.abs($account_id)); |
|
| 413 | 411 | } |
| 414 | 412 | else |
| 415 | 413 | { |
| 416 | 414 | // remove the user's memberships |
| 417 | - $this->set_memberships(array(),$account_id); |
|
| 415 | + $this->set_memberships(array(), $account_id); |
|
| 418 | 416 | |
| 419 | - $sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . $account_id); |
|
| 417 | + $sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$account_id); |
|
| 420 | 418 | } |
| 421 | 419 | if (!$sri) return false; |
| 422 | 420 | |
@@ -440,7 +438,7 @@ discard block |
||
| 440 | 438 | { |
| 441 | 439 | $this->ldapServerInfo = $this->ldap->getLDAPServerInfo($this->frontend->config['ldap_host']); |
| 442 | 440 | } |
| 443 | - foreach(array_keys($this->group_mail_classes) as $objectclass) |
|
| 441 | + foreach (array_keys($this->group_mail_classes) as $objectclass) |
|
| 444 | 442 | { |
| 445 | 443 | if ($this->ldapServerInfo->supportsObjectClass($objectclass)) |
| 446 | 444 | { |
@@ -448,15 +446,15 @@ discard block |
||
| 448 | 446 | break; |
| 449 | 447 | } |
| 450 | 448 | } |
| 451 | - $sri = ldap_search($this->ds, $this->group_context,'(&(objectClass=posixGroup)(gidnumber=' . abs($account_id).'))', |
|
| 449 | + $sri = ldap_search($this->ds, $this->group_context, '(&(objectClass=posixGroup)(gidnumber='.abs($account_id).'))', |
|
| 452 | 450 | array('dn', 'gidnumber', 'cn', 'objectclass', static::MAIL_ATTR, 'memberuid', 'description')); |
| 453 | 451 | |
| 454 | 452 | $ldap_data = ldap_get_entries($this->ds, $sri); |
| 455 | 453 | if (!$ldap_data['count']) |
| 456 | 454 | { |
| 457 | - return false; // group not found |
|
| 455 | + return false; // group not found |
|
| 458 | 456 | } |
| 459 | - $data = Api\Translation::convert($ldap_data[0],'utf-8'); |
|
| 457 | + $data = Api\Translation::convert($ldap_data[0], 'utf-8'); |
|
| 460 | 458 | unset($data['objectclass']['count']); |
| 461 | 459 | |
| 462 | 460 | $group += array( |
@@ -477,7 +475,7 @@ discard block |
||
| 477 | 475 | { |
| 478 | 476 | unset($data['memberuid']['count']); |
| 479 | 477 | |
| 480 | - foreach($data['memberuid'] as $lid) |
|
| 478 | + foreach ($data['memberuid'] as $lid) |
|
| 481 | 479 | { |
| 482 | 480 | if (($id = $this->name2id($lid, 'account_lid', 'u'))) |
| 483 | 481 | { |
@@ -498,16 +496,16 @@ discard block |
||
| 498 | 496 | */ |
| 499 | 497 | protected function _read_user($account_id) |
| 500 | 498 | { |
| 501 | - $sri = ldap_search($this->ds, $this->user_context, '(&(objectclass=posixAccount)(uidnumber=' . (int)$account_id.'))', |
|
| 502 | - array('dn','uidnumber','uid','gidnumber','givenname','sn','cn',static::MAIL_ATTR,'userpassword','telephonenumber', |
|
| 503 | - 'shadowexpire','shadowlastchange','homedirectory','loginshell','createtimestamp','modifytimestamp')); |
|
| 499 | + $sri = ldap_search($this->ds, $this->user_context, '(&(objectclass=posixAccount)(uidnumber='.(int)$account_id.'))', |
|
| 500 | + array('dn', 'uidnumber', 'uid', 'gidnumber', 'givenname', 'sn', 'cn', static::MAIL_ATTR, 'userpassword', 'telephonenumber', |
|
| 501 | + 'shadowexpire', 'shadowlastchange', 'homedirectory', 'loginshell', 'createtimestamp', 'modifytimestamp')); |
|
| 504 | 502 | |
| 505 | 503 | $ldap_data = ldap_get_entries($this->ds, $sri); |
| 506 | 504 | if (!$ldap_data['count']) |
| 507 | 505 | { |
| 508 | - return false; // user not found |
|
| 506 | + return false; // user not found |
|
| 509 | 507 | } |
| 510 | - $data = Api\Translation::convert($ldap_data[0],'utf-8'); |
|
| 508 | + $data = Api\Translation::convert($ldap_data[0], 'utf-8'); |
|
| 511 | 509 | |
| 512 | 510 | $utc_diff = date('Z'); |
| 513 | 511 | $user = array( |
@@ -527,13 +525,13 @@ discard block |
||
| 527 | 525 | // - if it's set to 0, the account is disabled |
| 528 | 526 | // - if it's set to > 0, it will or already has expired --> acount is active if it not yet expired |
| 529 | 527 | // shadowexpire is in days since 1970/01/01 (equivalent to a timestamp (int UTC!) / (24*60*60) |
| 530 | - 'account_status' => isset($data['shadowexpire']) && $data['shadowexpire'][0]*24*3600+$utc_diff < time() ? false : 'A', |
|
| 531 | - 'account_expires' => isset($data['shadowexpire']) && $data['shadowexpire'][0] ? $data['shadowexpire'][0]*24*3600+$utc_diff : -1, // LDAP date is in UTC |
|
| 532 | - 'account_lastpwd_change' => isset($data['shadowlastchange']) ? $data['shadowlastchange'][0]*24*3600+($data['shadowlastchange'][0]!=0?$utc_diff:0) : null, |
|
| 528 | + 'account_status' => isset($data['shadowexpire']) && $data['shadowexpire'][0] * 24 * 3600 + $utc_diff < time() ? false : 'A', |
|
| 529 | + 'account_expires' => isset($data['shadowexpire']) && $data['shadowexpire'][0] ? $data['shadowexpire'][0] * 24 * 3600 + $utc_diff : -1, // LDAP date is in UTC |
|
| 530 | + 'account_lastpwd_change' => isset($data['shadowlastchange']) ? $data['shadowlastchange'][0] * 24 * 3600 + ($data['shadowlastchange'][0] != 0 ? $utc_diff : 0) : null, |
|
| 533 | 531 | // lastlogin and lastlogin from are not availible via the shadowAccount object class |
| 534 | 532 | // 'account_lastlogin' => $data['phpgwaccountlastlogin'][0], |
| 535 | 533 | // 'account_lastloginfrom' => $data['phpgwaccountlastloginfrom'][0], |
| 536 | - 'person_id' => $data['uid'][0], // id of associated contact |
|
| 534 | + 'person_id' => $data['uid'][0], // id of associated contact |
|
| 537 | 535 | 'account_created' => isset($data['createtimestamp'][0]) ? self::accounts_ldap2ts($data['createtimestamp'][0]) : null, |
| 538 | 536 | 'account_modified' => isset($data['modifytimestamp'][0]) ? self::accounts_ldap2ts($data['modifytimestamp'][0]) : null, |
| 539 | 537 | ); |
@@ -554,7 +552,7 @@ discard block |
||
| 554 | 552 | * @param array $data array with account-data in utf-8 |
| 555 | 553 | * @return array merged data |
| 556 | 554 | */ |
| 557 | - protected function _merge_group($to_write,$data,$old=null) |
|
| 555 | + protected function _merge_group($to_write, $data, $old = null) |
|
| 558 | 556 | { |
| 559 | 557 | $to_write['gidnumber'] = abs($data['account_id']); |
| 560 | 558 | $to_write['cn'] = $data['account_lid']; |
@@ -574,7 +572,7 @@ discard block |
||
| 574 | 572 | * @param boolean $new_entry |
| 575 | 573 | * @return array merged data |
| 576 | 574 | */ |
| 577 | - protected function _merge_user($to_write,$data,$new_entry) |
|
| 575 | + protected function _merge_user($to_write, $data, $new_entry) |
|
| 578 | 576 | { |
| 579 | 577 | $to_write['uidnumber'] = $data['account_id']; |
| 580 | 578 | $to_write['uid'] = $data['account_lid']; |
@@ -583,12 +581,12 @@ discard block |
||
| 583 | 581 | { |
| 584 | 582 | $to_write['givenname'] = $data['account_firstname'] ? $data['account_firstname'] : array(); |
| 585 | 583 | } |
| 586 | - $to_write['sn'] = $data['account_lastname']; |
|
| 584 | + $to_write['sn'] = $data['account_lastname']; |
|
| 587 | 585 | if (!$new_entry || $data['account_email']) |
| 588 | 586 | { |
| 589 | - $to_write[static::MAIL_ATTR] = $data['account_email'] ? $data['account_email'] : array(); |
|
| 587 | + $to_write[static::MAIL_ATTR] = $data['account_email'] ? $data['account_email'] : array(); |
|
| 590 | 588 | } |
| 591 | - $to_write['cn'] = $data['account_fullname'] ? $data['account_fullname'] : $data['account_firstname'].' '.$data['account_lastname']; |
|
| 589 | + $to_write['cn'] = $data['account_fullname'] ? $data['account_fullname'] : $data['account_firstname'].' '.$data['account_lastname']; |
|
| 592 | 590 | |
| 593 | 591 | $utc_diff = date('Z'); |
| 594 | 592 | if (isset($data['account_passwd']) && $data['account_passwd']) |
@@ -597,47 +595,46 @@ discard block |
||
| 597 | 595 | { |
| 598 | 596 | $data['account_passwd'] = setup_cmd_ldap::hash_sql2ldap($data['account_passwd']); |
| 599 | 597 | } |
| 600 | - elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) // if it's not already entcrypted, do so now |
|
| 598 | + elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $data['account_passwd'])) // if it's not already entcrypted, do so now |
|
| 601 | 599 | { |
| 602 | 600 | $data['account_passwd'] = Api\Auth::encrypt_ldap($data['account_passwd']); |
| 603 | 601 | } |
| 604 | 602 | $to_write['userpassword'] = $data['account_passwd']; |
| 605 | - $to_write['shadowlastchange'] = round((time()-$utc_diff) / (24*3600)); |
|
| 603 | + $to_write['shadowlastchange'] = round((time() - $utc_diff) / (24 * 3600)); |
|
| 606 | 604 | } |
| 607 | 605 | // both status and expires are encoded in the single shadowexpire value in LDAP |
| 608 | 606 | // - if it's unset an account is enabled AND does never expire |
| 609 | 607 | // - if it's set to 0, the account is disabled |
| 610 | 608 | // - if it's set to > 0, it will or already has expired --> acount is active if it not yet expired |
| 611 | 609 | // shadowexpire is in days since 1970/01/01 (equivalent to a timestamp (int UTC!) / (24*60*60) |
| 612 | - $shadowexpire = ($data['account_expires']-$utc_diff) / (24*3600); |
|
| 610 | + $shadowexpire = ($data['account_expires'] - $utc_diff) / (24 * 3600); |
|
| 613 | 611 | |
| 614 | 612 | $to_write['shadowexpire'] = !$data['account_status'] ? |
| 615 | - ($data['account_expires'] != -1 && $data['account_expires'] < time() ? round($shadowexpire) : 0) : |
|
| 616 | - ($data['account_expires'] != -1 ? round($shadowexpire) : array()); // array() = unset value |
|
| 613 | + ($data['account_expires'] != -1 && $data['account_expires'] < time() ? round($shadowexpire) : 0) : ($data['account_expires'] != -1 ? round($shadowexpire) : array()); // array() = unset value |
|
| 617 | 614 | |
| 618 | 615 | if ($new_entry && is_array($to_write['shadowexpire']) && !count($to_write['shadowexpire'])) |
| 619 | 616 | { |
| 620 | - unset($to_write['shadowexpire']); // gives protocoll error otherwise |
|
| 617 | + unset($to_write['shadowexpire']); // gives protocoll error otherwise |
|
| 621 | 618 | } |
| 622 | 619 | //error_log(__METHOD__.__LINE__.$data['account_lid'].'#'.$data['account_lastpwd_change'].'#'); |
| 623 | - if ($data['account_lastpwd_change']) $to_write['shadowlastchange'] = round(($data['account_lastpwd_change']-$utc_diff)/(24*3600)); |
|
| 624 | - if (isset($data['account_lastpwd_change']) && $data['account_lastpwd_change']==0) $to_write['shadowlastchange'] = 0; |
|
| 620 | + if ($data['account_lastpwd_change']) $to_write['shadowlastchange'] = round(($data['account_lastpwd_change'] - $utc_diff) / (24 * 3600)); |
|
| 621 | + if (isset($data['account_lastpwd_change']) && $data['account_lastpwd_change'] == 0) $to_write['shadowlastchange'] = 0; |
|
| 625 | 622 | // lastlogin and lastlogin from are not availible via the shadowAccount object class |
| 626 | 623 | // $to_write['phpgwaccountlastlogin'] = $data['lastlogin']; |
| 627 | 624 | // $to_write['phpgwaccountlastloginfrom'] = $data['lastloginfrom']; |
| 628 | 625 | |
| 629 | 626 | if ($this->frontend->config['ldap_extra_attributes']) |
| 630 | 627 | { |
| 631 | - if (isset($data['homedirectory'])) $to_write['homedirectory'] = $data['homedirectory']; |
|
| 628 | + if (isset($data['homedirectory'])) $to_write['homedirectory'] = $data['homedirectory']; |
|
| 632 | 629 | if (isset($data['loginshell'])) $to_write['loginshell'] = $data['loginshell'] ? $data['loginshell'] : array(); |
| 633 | 630 | } |
| 634 | 631 | if (($new_entry || isset($to_write['homedirectory'])) && empty($to_write['homedirectory'])) |
| 635 | 632 | { |
| 636 | - $to_write['homedirectory'] = '/dev/null'; // is a required attribute of posixAccount |
|
| 633 | + $to_write['homedirectory'] = '/dev/null'; // is a required attribute of posixAccount |
|
| 637 | 634 | } |
| 638 | 635 | if ($new_entry && empty($to_write['loginshell'])) |
| 639 | 636 | { |
| 640 | - unset($to_write['loginshell']); // setting array() for new entry gives "Protocol error", must not set it |
|
| 637 | + unset($to_write['loginshell']); // setting array() for new entry gives "Protocol error", must not set it |
|
| 641 | 638 | } |
| 642 | 639 | return $to_write; |
| 643 | 640 | } |
@@ -665,7 +662,7 @@ discard block |
||
| 665 | 662 | function search($param) |
| 666 | 663 | { |
| 667 | 664 | //error_log(__METHOD__."(".array2string($param).")"); |
| 668 | - $account_search =& Api\Accounts::$cache['account_search']; |
|
| 665 | + $account_search = & Api\Accounts::$cache['account_search']; |
|
| 669 | 666 | |
| 670 | 667 | // check if the query is cached |
| 671 | 668 | $serial = serialize($param); |
@@ -691,12 +688,12 @@ discard block |
||
| 691 | 688 | $query = Api\Ldap::quote(strtolower($param['query'])); |
| 692 | 689 | |
| 693 | 690 | $accounts = array(); |
| 694 | - if($param['type'] != 'groups') |
|
| 691 | + if ($param['type'] != 'groups') |
|
| 695 | 692 | { |
| 696 | 693 | $filter = "(&(objectclass=posixaccount)"; |
| 697 | 694 | if (!empty($query) && $query != '*') |
| 698 | 695 | { |
| 699 | - switch($param['query_type']) |
|
| 696 | + switch ($param['query_type']) |
|
| 700 | 697 | { |
| 701 | 698 | case 'all': |
| 702 | 699 | default: |
@@ -723,7 +720,7 @@ discard block |
||
| 723 | 720 | } |
| 724 | 721 | } |
| 725 | 722 | // add account_filter to filter (user has to be '*', as we otherwise only search uid's) |
| 726 | - $filter .= str_replace(array('%user','%domain'),array('*',$GLOBALS['egw_info']['user']['domain']),$this->account_filter); |
|
| 723 | + $filter .= str_replace(array('%user', '%domain'), array('*', $GLOBALS['egw_info']['user']['domain']), $this->account_filter); |
|
| 727 | 724 | $filter .= ')'; |
| 728 | 725 | |
| 729 | 726 | if ($param['type'] != 'both') |
@@ -742,9 +739,9 @@ discard block |
||
| 742 | 739 | 'account_fullname' => 'cn', |
| 743 | 740 | 'account_primary_group' => 'gidnumber', |
| 744 | 741 | ); |
| 745 | - $orders = explode(',',$param['order']); |
|
| 742 | + $orders = explode(',', $param['order']); |
|
| 746 | 743 | $order = isset($propertyMap[$orders[0]]) ? $propertyMap[$orders[0]] : 'uid'; |
| 747 | - $sri = ldap_search($this->ds, $this->user_context, $filter,array('uid', $order)); |
|
| 744 | + $sri = ldap_search($this->ds, $this->user_context, $filter, array('uid', $order)); |
|
| 748 | 745 | $fullSet = array(); |
| 749 | 746 | foreach ((array)ldap_get_entries($this->ds, $sri) as $key => $entry) |
| 750 | 747 | { |
@@ -754,7 +751,7 @@ discard block |
||
| 754 | 751 | if (is_numeric($param['type'])) // return only group-members |
| 755 | 752 | { |
| 756 | 753 | $relevantAccounts = array(); |
| 757 | - $sri = ldap_search($this->ds,$this->group_context,"(&(objectClass=posixGroup)(gidnumber=" . abs($param['type']) . "))",array('memberuid')); |
|
| 754 | + $sri = ldap_search($this->ds, $this->group_context, "(&(objectClass=posixGroup)(gidnumber=".abs($param['type'])."))", array('memberuid')); |
|
| 758 | 755 | $group = ldap_get_entries($this->ds, $sri); |
| 759 | 756 | $fullSet = $group[0]['memberuid'] ? array_intersect_key($fullSet, array_flip($group[0]['memberuid'])) : array(); |
| 760 | 757 | } |
@@ -763,26 +760,26 @@ discard block |
||
| 763 | 760 | $sortFn = $param['sort'] == 'DESC' ? 'arsort' : 'asort'; |
| 764 | 761 | $sortFn($fullSet); |
| 765 | 762 | $relevantAccounts = is_numeric($start) ? array_slice(array_keys($fullSet), $start, $offset) : array_keys($fullSet); |
| 766 | - $filter = '(&(objectclass=posixaccount)(|(uid='.implode(')(uid=',$relevantAccounts).'))' . $this->account_filter.')'; |
|
| 767 | - $filter = str_replace(array('%user','%domain'),array('*',$GLOBALS['egw_info']['user']['domain']),$filter); |
|
| 763 | + $filter = '(&(objectclass=posixaccount)(|(uid='.implode(')(uid=', $relevantAccounts).'))'.$this->account_filter.')'; |
|
| 764 | + $filter = str_replace(array('%user', '%domain'), array('*', $GLOBALS['egw_info']['user']['domain']), $filter); |
|
| 768 | 765 | } |
| 769 | - $sri = ldap_search($this->ds, $this->user_context, $filter,array('uid','uidNumber','givenname','sn',static::MAIL_ATTR,'shadowExpire','createtimestamp','modifytimestamp','objectclass','gidNumber')); |
|
| 766 | + $sri = ldap_search($this->ds, $this->user_context, $filter, array('uid', 'uidNumber', 'givenname', 'sn', static::MAIL_ATTR, 'shadowExpire', 'createtimestamp', 'modifytimestamp', 'objectclass', 'gidNumber')); |
|
| 770 | 767 | |
| 771 | 768 | $utc_diff = date('Z'); |
| 772 | - foreach(ldap_get_entries($this->ds, $sri) as $allVals) |
|
| 769 | + foreach (ldap_get_entries($this->ds, $sri) as $allVals) |
|
| 773 | 770 | { |
| 774 | - settype($allVals,'array'); |
|
| 771 | + settype($allVals, 'array'); |
|
| 775 | 772 | $test = @$allVals['uid'][0]; |
| 776 | 773 | if (!$this->frontend->config['global_denied_users'][$test] && $allVals['uid'][0]) |
| 777 | 774 | { |
| 778 | 775 | $account = Array( |
| 779 | 776 | 'account_id' => $allVals['uidnumber'][0], |
| 780 | - 'account_lid' => Api\Translation::convert($allVals['uid'][0],'utf-8'), |
|
| 777 | + 'account_lid' => Api\Translation::convert($allVals['uid'][0], 'utf-8'), |
|
| 781 | 778 | 'account_type' => 'u', |
| 782 | - 'account_firstname' => Api\Translation::convert($allVals['givenname'][0],'utf-8'), |
|
| 783 | - 'account_lastname' => Api\Translation::convert($allVals['sn'][0],'utf-8'), |
|
| 784 | - 'account_status' => isset($allVals['shadowexpire'][0]) && $allVals['shadowexpire'][0]*24*3600-$utc_diff < time() ? false : 'A', |
|
| 785 | - 'account_expires' => isset($allVals['shadowexpire']) && $allVals['shadowexpire'][0] ? $allVals['shadowexpire'][0]*24*3600+$utc_diff : -1, // LDAP date is in UTC |
|
| 779 | + 'account_firstname' => Api\Translation::convert($allVals['givenname'][0], 'utf-8'), |
|
| 780 | + 'account_lastname' => Api\Translation::convert($allVals['sn'][0], 'utf-8'), |
|
| 781 | + 'account_status' => isset($allVals['shadowexpire'][0]) && $allVals['shadowexpire'][0] * 24 * 3600 - $utc_diff < time() ? false : 'A', |
|
| 782 | + 'account_expires' => isset($allVals['shadowexpire']) && $allVals['shadowexpire'][0] ? $allVals['shadowexpire'][0] * 24 * 3600 + $utc_diff : -1, // LDAP date is in UTC |
|
| 786 | 783 | 'account_email' => $allVals[static::MAIL_ATTR][0], |
| 787 | 784 | 'account_created' => isset($allVals['createtimestamp'][0]) ? self::accounts_ldap2ts($allVals['createtimestamp'][0]) : null, |
| 788 | 785 | 'account_modified' => isset($allVals['modifytimestamp'][0]) ? self::accounts_ldap2ts($allVals['modifytimestamp'][0]) : null, |
@@ -808,13 +805,13 @@ discard block |
||
| 808 | 805 | } |
| 809 | 806 | if ($param['type'] == 'groups' || $param['type'] == 'both') |
| 810 | 807 | { |
| 811 | - if(empty($query) || $query == '*') |
|
| 808 | + if (empty($query) || $query == '*') |
|
| 812 | 809 | { |
| 813 | 810 | $filter = '(objectclass=posixgroup)'; |
| 814 | 811 | } |
| 815 | 812 | else |
| 816 | 813 | { |
| 817 | - switch($param['query_type']) |
|
| 814 | + switch ($param['query_type']) |
|
| 818 | 815 | { |
| 819 | 816 | case 'all': |
| 820 | 817 | default: |
@@ -828,21 +825,21 @@ discard block |
||
| 828 | 825 | } |
| 829 | 826 | $filter = "(&(objectclass=posixgroup)(cn=$query))"; |
| 830 | 827 | } |
| 831 | - $sri = ldap_search($this->ds, $this->group_context, $filter,array('cn','gidNumber')); |
|
| 832 | - foreach((array)ldap_get_entries($this->ds, $sri) as $allVals) |
|
| 828 | + $sri = ldap_search($this->ds, $this->group_context, $filter, array('cn', 'gidNumber')); |
|
| 829 | + foreach ((array)ldap_get_entries($this->ds, $sri) as $allVals) |
|
| 833 | 830 | { |
| 834 | - settype($allVals,'array'); |
|
| 831 | + settype($allVals, 'array'); |
|
| 835 | 832 | $test = $allVals['cn'][0]; |
| 836 | 833 | if (!$this->frontend->config['global_denied_groups'][$test] && $allVals['cn'][0]) |
| 837 | 834 | { |
| 838 | 835 | $accounts[(string)-$allVals['gidnumber'][0]] = Array( |
| 839 | 836 | 'account_id' => -$allVals['gidnumber'][0], |
| 840 | - 'account_lid' => Api\Translation::convert($allVals['cn'][0],'utf-8'), |
|
| 837 | + 'account_lid' => Api\Translation::convert($allVals['cn'][0], 'utf-8'), |
|
| 841 | 838 | 'account_type' => 'g', |
| 842 | - 'account_firstname' => Api\Translation::convert($allVals['cn'][0],'utf-8'), |
|
| 839 | + 'account_firstname' => Api\Translation::convert($allVals['cn'][0], 'utf-8'), |
|
| 843 | 840 | 'account_lastname' => lang('Group'), |
| 844 | 841 | 'account_status' => 'A', |
| 845 | - 'account_fullname' => Api\Translation::convert($allVals['cn'][0],'utf-8'), |
|
| 842 | + 'account_fullname' => Api\Translation::convert($allVals['cn'][0], 'utf-8'), |
|
| 846 | 843 | ); |
| 847 | 844 | if (isset($totalcount)) ++$totalcount; |
| 848 | 845 | } |
@@ -850,9 +847,9 @@ discard block |
||
| 850 | 847 | } |
| 851 | 848 | // sort the array |
| 852 | 849 | $this->_callback_sort = strtoupper($param['sort']); |
| 853 | - $this->_callback_order = empty($param['order']) ? array('account_lid') : explode(',',$param['order']); |
|
| 850 | + $this->_callback_order = empty($param['order']) ? array('account_lid') : explode(',', $param['order']); |
|
| 854 | 851 | $sortedAccounts = $accounts; |
| 855 | - uasort($sortedAccounts,array($this,'_sort_callback')); |
|
| 852 | + uasort($sortedAccounts, array($this, '_sort_callback')); |
|
| 856 | 853 | $this->total = isset($totalcount) ? $totalcount : count($accounts); |
| 857 | 854 | |
| 858 | 855 | // if totalcount is set, $sortedAccounts is NOT the full set, but already a limited set! |
@@ -864,7 +861,7 @@ discard block |
||
| 864 | 861 | } |
| 865 | 862 | // return only the wanted accounts |
| 866 | 863 | reset($sortedAccounts); |
| 867 | - if(is_numeric($start) && is_numeric($offset)) |
|
| 864 | + if (is_numeric($start) && is_numeric($offset)) |
|
| 868 | 865 | { |
| 869 | 866 | $account_search[$serial]['total'] = $this->total; |
| 870 | 867 | return $account_search[$serial]['data'] = isset($totalcount) ? $sortedAccounts : array_slice($sortedAccounts, $start, $offset); |
@@ -892,19 +889,19 @@ discard block |
||
| 892 | 889 | * @param array $b |
| 893 | 890 | * @return int |
| 894 | 891 | */ |
| 895 | - function _sort_callback($a,$b) |
|
| 892 | + function _sort_callback($a, $b) |
|
| 896 | 893 | { |
| 897 | - foreach($this->_callback_order as $col ) |
|
| 894 | + foreach ($this->_callback_order as $col) |
|
| 898 | 895 | { |
| 899 | - if($this->_callback_sort != 'DESC') |
|
| 896 | + if ($this->_callback_sort != 'DESC') |
|
| 900 | 897 | { |
| 901 | - $cmp = strcasecmp( $a[$col], $b[$col] ); |
|
| 898 | + $cmp = strcasecmp($a[$col], $b[$col]); |
|
| 902 | 899 | } |
| 903 | 900 | else |
| 904 | 901 | { |
| 905 | - $cmp = strcasecmp( $b[$col], $a[$col] ); |
|
| 902 | + $cmp = strcasecmp($b[$col], $a[$col]); |
|
| 906 | 903 | } |
| 907 | - if ( $cmp != 0 ) |
|
| 904 | + if ($cmp != 0) |
|
| 908 | 905 | { |
| 909 | 906 | return $cmp; |
| 910 | 907 | } |
@@ -923,8 +920,8 @@ discard block |
||
| 923 | 920 | { |
| 924 | 921 | if (!empty($date)) |
| 925 | 922 | { |
| 926 | - return gmmktime(substr($date,8,2),substr($date,10,2),substr($date,12,2), |
|
| 927 | - substr($date,4,2),substr($date,6,2),substr($date,0,4)); |
|
| 923 | + return gmmktime(substr($date, 8, 2), substr($date, 10, 2), substr($date, 12, 2), |
|
| 924 | + substr($date, 4, 2), substr($date, 6, 2), substr($date, 0, 4)); |
|
| 928 | 925 | } |
| 929 | 926 | return NULL; |
| 930 | 927 | } |
@@ -941,14 +938,14 @@ discard block |
||
| 941 | 938 | * @param string $account_type u = user, g = group, default null = try both |
| 942 | 939 | * @return int|false numeric account_id or false on error ($name not found) |
| 943 | 940 | */ |
| 944 | - function name2id($_name,$which='account_lid',$account_type=null) |
|
| 941 | + function name2id($_name, $which = 'account_lid', $account_type = null) |
|
| 945 | 942 | { |
| 946 | - $name = Api\Ldap::quote(Api\Translation::convert($_name,Api\Translation::charset(),'utf-8')); |
|
| 943 | + $name = Api\Ldap::quote(Api\Translation::convert($_name, Api\Translation::charset(), 'utf-8')); |
|
| 947 | 944 | |
| 948 | 945 | if ($which == 'account_lid' && $account_type !== 'u') // groups only support account_lid |
| 949 | 946 | { |
| 950 | 947 | |
| 951 | - $sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . $name . ')(objectclass=posixgroup))', array('gidNumber')); |
|
| 948 | + $sri = ldap_search($this->ds, $this->group_context, '(&(cn='.$name.')(objectclass=posixgroup))', array('gidNumber')); |
|
| 952 | 949 | $allValues = ldap_get_entries($this->ds, $sri); |
| 953 | 950 | |
| 954 | 951 | if (@$allValues[0]['gidnumber'][0]) |
@@ -965,7 +962,7 @@ discard block |
||
| 965 | 962 | return False; |
| 966 | 963 | } |
| 967 | 964 | |
| 968 | - $sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'=' . $name . ')(objectclass=posixaccount))', array('uidNumber')); |
|
| 965 | + $sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'='.$name.')(objectclass=posixaccount))', array('uidNumber')); |
|
| 969 | 966 | |
| 970 | 967 | $allValues = ldap_get_entries($this->ds, $sri); |
| 971 | 968 | |
@@ -985,9 +982,9 @@ discard block |
||
| 985 | 982 | * @param string $which ='account_lid' type to convert to: account_lid (default), account_email, ... |
| 986 | 983 | * @return string/false converted value or false on error ($account_id not found) |
| 987 | 984 | */ |
| 988 | - function id2name($account_id,$which='account_lid') |
|
| 985 | + function id2name($account_id, $which = 'account_lid') |
|
| 989 | 986 | { |
| 990 | - return $this->frontend->id2name($account_id,$which); |
|
| 987 | + return $this->frontend->id2name($account_id, $which); |
|
| 991 | 988 | } |
| 992 | 989 | |
| 993 | 990 | /** |
@@ -1000,7 +997,7 @@ discard block |
||
| 1000 | 997 | function update_lastlogin($_account_id, $ip) |
| 1001 | 998 | { |
| 1002 | 999 | unset($_account_id, $ip); |
| 1003 | - return false; // not longer supported |
|
| 1000 | + return false; // not longer supported |
|
| 1004 | 1001 | } |
| 1005 | 1002 | |
| 1006 | 1003 | /** |
@@ -1011,11 +1008,11 @@ discard block |
||
| 1011 | 1008 | */ |
| 1012 | 1009 | function memberships($account_id) |
| 1013 | 1010 | { |
| 1014 | - if (!(int) $account_id || !($account_lid = $this->id2name($account_id))) return false; |
|
| 1011 | + if (!(int)$account_id || !($account_lid = $this->id2name($account_id))) return false; |
|
| 1015 | 1012 | |
| 1016 | - $sri = ldap_search($this->ds,$this->group_context,'(&(objectClass=posixGroup)(memberuid='.Api\Ldap::quote($account_lid).'))',array('cn','gidnumber')); |
|
| 1013 | + $sri = ldap_search($this->ds, $this->group_context, '(&(objectClass=posixGroup)(memberuid='.Api\Ldap::quote($account_lid).'))', array('cn', 'gidnumber')); |
|
| 1017 | 1014 | $memberships = array(); |
| 1018 | - foreach((array)ldap_get_entries($this->ds, $sri) as $key => $data) |
|
| 1015 | + foreach ((array)ldap_get_entries($this->ds, $sri) as $key => $data) |
|
| 1019 | 1016 | { |
| 1020 | 1017 | if ($key === 'count') continue; |
| 1021 | 1018 | |
@@ -1035,13 +1032,13 @@ discard block |
||
| 1035 | 1032 | if (!is_numeric($_gid)) |
| 1036 | 1033 | { |
| 1037 | 1034 | // try to recover |
| 1038 | - $_gid = $this->name2id($_gid,'account_lid','g'); |
|
| 1035 | + $_gid = $this->name2id($_gid, 'account_lid', 'g'); |
|
| 1039 | 1036 | if (!is_numeric($_gid)) return false; |
| 1040 | 1037 | } |
| 1041 | 1038 | |
| 1042 | - $gid = abs($_gid); // our gid is negative! |
|
| 1039 | + $gid = abs($_gid); // our gid is negative! |
|
| 1043 | 1040 | |
| 1044 | - $sri = ldap_search($this->ds,$this->group_context,"(&(objectClass=posixGroup)(gidnumber=$gid))",array('memberuid')); |
|
| 1041 | + $sri = ldap_search($this->ds, $this->group_context, "(&(objectClass=posixGroup)(gidnumber=$gid))", array('memberuid')); |
|
| 1045 | 1042 | $group = ldap_get_entries($this->ds, $sri); |
| 1046 | 1043 | |
| 1047 | 1044 | $members = array(); |
@@ -1049,7 +1046,7 @@ discard block |
||
| 1049 | 1046 | { |
| 1050 | 1047 | unset($group[0]['memberuid']['count']); |
| 1051 | 1048 | |
| 1052 | - foreach($group[0]['memberuid'] as $lid) |
|
| 1049 | + foreach ($group[0]['memberuid'] as $lid) |
|
| 1053 | 1050 | { |
| 1054 | 1051 | if (($id = $this->name2id($lid, 'account_lid', 'u'))) |
| 1055 | 1052 | { |
@@ -1066,27 +1063,27 @@ discard block |
||
| 1066 | 1063 | * @param array $groups array with gidnumbers |
| 1067 | 1064 | * @param int $account_id uidnumber |
| 1068 | 1065 | */ |
| 1069 | - function set_memberships($groups,$account_id) |
|
| 1066 | + function set_memberships($groups, $account_id) |
|
| 1070 | 1067 | { |
| 1071 | 1068 | // remove not longer existing memberships |
| 1072 | 1069 | if (($old_memberships = $this->memberships($account_id))) |
| 1073 | 1070 | { |
| 1074 | 1071 | $old_memberships = array_keys($old_memberships); |
| 1075 | - foreach(array_diff($old_memberships,$groups) as $gid) |
|
| 1072 | + foreach (array_diff($old_memberships, $groups) as $gid) |
|
| 1076 | 1073 | { |
| 1077 | 1074 | if (($members = $this->members($gid))) |
| 1078 | 1075 | { |
| 1079 | 1076 | unset($members[$account_id]); |
| 1080 | - $this->set_members($members,$gid); |
|
| 1077 | + $this->set_members($members, $gid); |
|
| 1081 | 1078 | } |
| 1082 | 1079 | } |
| 1083 | 1080 | } |
| 1084 | 1081 | // adding new memberships |
| 1085 | - foreach($old_memberships ? array_diff($groups,$old_memberships) : $groups as $gid) |
|
| 1082 | + foreach ($old_memberships ? array_diff($groups, $old_memberships) : $groups as $gid) |
|
| 1086 | 1083 | { |
| 1087 | 1084 | $members = $this->members($gid); |
| 1088 | 1085 | $members[$account_id] = $this->id2name($account_id); |
| 1089 | - $this->set_members($members,$gid); |
|
| 1086 | + $this->set_members($members, $gid); |
|
| 1090 | 1087 | } |
| 1091 | 1088 | } |
| 1092 | 1089 | |
@@ -1100,15 +1097,15 @@ discard block |
||
| 1100 | 1097 | * @param boolean $uniqueMember =null should we set the uniqueMember attribute (default detect it) |
| 1101 | 1098 | * @return boolean/array false on failure, array or true otherwise |
| 1102 | 1099 | */ |
| 1103 | - function set_members($members, $gid, array $objectclass=null, $use_cn=null) |
|
| 1100 | + function set_members($members, $gid, array $objectclass = null, $use_cn = null) |
|
| 1104 | 1101 | { |
| 1105 | 1102 | if (!($cn = $use_cn) && !($cn = $this->id2name($gid))) return false; |
| 1106 | 1103 | |
| 1107 | 1104 | // do that group is a groupOf(Unique)Names or univentionGroup? |
| 1108 | - if (is_null($objectclass)) $objectclass = $this->id2name($gid,'objectclass'); |
|
| 1105 | + if (is_null($objectclass)) $objectclass = $this->id2name($gid, 'objectclass'); |
|
| 1109 | 1106 | |
| 1110 | 1107 | $to_write = array('memberuid' => array()); |
| 1111 | - foreach((array)$members as $key => $member) |
|
| 1108 | + foreach ((array)$members as $key => $member) |
|
| 1112 | 1109 | { |
| 1113 | 1110 | $member_dn = $this->id2name($member, 'account_dn'); |
| 1114 | 1111 | if (is_numeric($member)) $member = $this->id2name($member); |
@@ -1120,7 +1117,7 @@ discard block |
||
| 1120 | 1117 | { |
| 1121 | 1118 | $to_write['member'][] = $member_dn; |
| 1122 | 1119 | } |
| 1123 | - if (array_intersect(array('groupofuniquenames','univentiongroup'), $objectclass)) |
|
| 1120 | + if (array_intersect(array('groupofuniquenames', 'univentiongroup'), $objectclass)) |
|
| 1124 | 1121 | { |
| 1125 | 1122 | $to_write['uniquemember'][] = $member_dn; |
| 1126 | 1123 | } |
@@ -1131,31 +1128,31 @@ discard block |
||
| 1131 | 1128 | { |
| 1132 | 1129 | $to_write['member'][] = 'uid=dummy'.','.$this->user_context; |
| 1133 | 1130 | } |
| 1134 | - if (array_intersect(array('groupofuniquenames','univentiongroup'), $objectclass) && !$to_write['uniquemember']) |
|
| 1131 | + if (array_intersect(array('groupofuniquenames', 'univentiongroup'), $objectclass) && !$to_write['uniquemember']) |
|
| 1135 | 1132 | { |
| 1136 | 1133 | $to_write['uniquemember'][] = 'uid=dummy'.','.$this->user_context; |
| 1137 | 1134 | } |
| 1138 | 1135 | if ($use_cn) return $to_write; |
| 1139 | 1136 | |
| 1140 | 1137 | // set the member email addresses as forwards |
| 1141 | - if ($this->id2name($gid,'account_email') && ($objectclass = $this->id2name($gid,'mailAllowed'))) |
|
| 1138 | + if ($this->id2name($gid, 'account_email') && ($objectclass = $this->id2name($gid, 'mailAllowed'))) |
|
| 1142 | 1139 | { |
| 1143 | 1140 | $forward = $this->group_mail_classes[$objectclass]; |
| 1144 | - if (is_array($forward)) list($forward,$extra_attr) = $forward; |
|
| 1141 | + if (is_array($forward)) list($forward, $extra_attr) = $forward; |
|
| 1145 | 1142 | if ($extra_attr && ($uid = $this->id2name($gid))) $to_write[$extra_attr] = $uid; |
| 1146 | 1143 | |
| 1147 | 1144 | if ($forward) |
| 1148 | 1145 | { |
| 1149 | 1146 | $to_write[$forward] = array(); |
| 1150 | - foreach($members as $key => $member) |
|
| 1147 | + foreach ($members as $key => $member) |
|
| 1151 | 1148 | { |
| 1152 | - if (($email = $this->id2name($member,'account_email'))) $to_write[$forward][] = $email; |
|
| 1149 | + if (($email = $this->id2name($member, 'account_email'))) $to_write[$forward][] = $email; |
|
| 1153 | 1150 | } |
| 1154 | 1151 | } |
| 1155 | 1152 | } |
| 1156 | - if (!ldap_modify($this->ds,'cn='.Api\Ldap::quote($cn).','.$this->group_context,$to_write)) |
|
| 1153 | + if (!ldap_modify($this->ds, 'cn='.Api\Ldap::quote($cn).','.$this->group_context, $to_write)) |
|
| 1157 | 1154 | { |
| 1158 | - echo "ldap_modify(,'cn=$cn,$this->group_context',".print_r($to_write,true)."))\n"; |
|
| 1155 | + echo "ldap_modify(,'cn=$cn,$this->group_context',".print_r($to_write, true)."))\n"; |
|
| 1159 | 1156 | return false; |
| 1160 | 1157 | } |
| 1161 | 1158 | return true; |
@@ -1168,7 +1165,7 @@ discard block |
||
| 1168 | 1165 | * @param string $account_type ='u' (optional, default to 'u') |
| 1169 | 1166 | * @return int|boolean integer account_id (negative for groups) or false if none is free anymore |
| 1170 | 1167 | */ |
| 1171 | - protected function _get_nextid($account_type='u') |
|
| 1168 | + protected function _get_nextid($account_type = 'u') |
|
| 1172 | 1169 | { |
| 1173 | 1170 | $min = $this->frontend->config['account_min_id'] ? $this->frontend->config['account_min_id'] : 0; |
| 1174 | 1171 | $max = $this->frontend->config['account_max_id'] ? $this->frontend->config['account_max_id'] : 0; |
@@ -1190,15 +1187,15 @@ discard block |
||
| 1190 | 1187 | /* Loop until we find a free id */ |
| 1191 | 1188 | do |
| 1192 | 1189 | { |
| 1193 | - $account_id = (int) self::next_id($type,$min,$max); |
|
| 1190 | + $account_id = (int)self::next_id($type, $min, $max); |
|
| 1194 | 1191 | } |
| 1195 | - while ($account_id && ($this->frontend->exists($sign * $account_id) || // check need to include the sign! |
|
| 1192 | + while ($account_id && ($this->frontend->exists($sign * $account_id) || // check need to include the sign! |
|
| 1196 | 1193 | $this->frontend->exists(-1 * $sign * $account_id) || |
| 1197 | 1194 | // if sambaadmin is installed, call it to check there's not yet a relative id (last part of SID) with that number |
| 1198 | 1195 | // to ease migration to AD or Samba4 |
| 1199 | 1196 | $GLOBALS['egw_info']['apps']['sambaadmin'] && ExecMethod2('sambaadmin.sosambaadmin.sidExists', $account_id))); |
| 1200 | 1197 | |
| 1201 | - if (!$account_id || $max && $account_id > $max) |
|
| 1198 | + if (!$account_id || $max && $account_id > $max) |
|
| 1202 | 1199 | { |
| 1203 | 1200 | return False; |
| 1204 | 1201 | } |
@@ -1213,14 +1210,14 @@ discard block |
||
| 1213 | 1210 | * @param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false |
| 1214 | 1211 | * @return int|boolean the next id or false if $max given and exceeded |
| 1215 | 1212 | */ |
| 1216 | - static function next_id($location,$min=0,$max=0) |
|
| 1213 | + static function next_id($location, $min = 0, $max = 0) |
|
| 1217 | 1214 | { |
| 1218 | 1215 | if (!$location) |
| 1219 | 1216 | { |
| 1220 | 1217 | return -1; |
| 1221 | 1218 | } |
| 1222 | 1219 | |
| 1223 | - $id = (int)$GLOBALS['egw_info']['server'][$key='last_id_'.$location]; |
|
| 1220 | + $id = (int)$GLOBALS['egw_info']['server'][$key = 'last_id_'.$location]; |
|
| 1224 | 1221 | |
| 1225 | 1222 | if ($max && $id >= $max) |
| 1226 | 1223 | { |
@@ -1228,10 +1225,10 @@ discard block |
||
| 1228 | 1225 | } |
| 1229 | 1226 | ++$id; |
| 1230 | 1227 | |
| 1231 | - if($id < $min) $id = $min; |
|
| 1228 | + if ($id < $min) $id = $min; |
|
| 1232 | 1229 | |
| 1233 | 1230 | Api\Config::save_value($key, $id, 'phpgwapi', true); |
| 1234 | - $GLOBALS['egw_info']['server'][$key='last_id_'.$location] = $id; |
|
| 1231 | + $GLOBALS['egw_info']['server'][$key = 'last_id_'.$location] = $id; |
|
| 1235 | 1232 | |
| 1236 | 1233 | return (int)$id; |
| 1237 | 1234 | } |
@@ -1244,18 +1241,18 @@ discard block |
||
| 1244 | 1241 | * @param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false |
| 1245 | 1242 | * @return int|boolean current id in the next_id table for a particular app/class or -1 for no app and false if $max is exceeded. |
| 1246 | 1243 | */ |
| 1247 | - static function last_id($location,$min=0,$max=0) |
|
| 1244 | + static function last_id($location, $min = 0, $max = 0) |
|
| 1248 | 1245 | { |
| 1249 | 1246 | if (!$location) |
| 1250 | 1247 | { |
| 1251 | 1248 | return -1; |
| 1252 | 1249 | } |
| 1253 | 1250 | |
| 1254 | - $id = (int)$GLOBALS['egw_info']['server'][$key='last_id_'.$location]; |
|
| 1251 | + $id = (int)$GLOBALS['egw_info']['server'][$key = 'last_id_'.$location]; |
|
| 1255 | 1252 | |
| 1256 | 1253 | if (!$id || $id < $min) |
| 1257 | 1254 | { |
| 1258 | - return self::next_id($location,$min,$max); |
|
| 1255 | + return self::next_id($location, $min, $max); |
|
| 1259 | 1256 | } |
| 1260 | 1257 | if ($max && $id > $max) |
| 1261 | 1258 | { |
@@ -1270,6 +1267,6 @@ discard block |
||
| 1270 | 1267 | function __wakeup() |
| 1271 | 1268 | { |
| 1272 | 1269 | $this->ds = Api\Ldap::factory(true, $this->frontend->config['ldap_host'], |
| 1273 | - $this->frontend->config['ldap_root_dn'],$this->frontend->config['ldap_root_pw']); |
|
| 1270 | + $this->frontend->config['ldap_root_dn'], $this->frontend->config['ldap_root_pw']); |
|
| 1274 | 1271 | } |
| 1275 | 1272 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $test = @$allVals['uid'][0]; |
| 776 | 776 | if (!$this->frontend->config['global_denied_users'][$test] && $allVals['uid'][0]) |
| 777 | 777 | { |
| 778 | - $account = Array( |
|
| 778 | + $account = array( |
|
| 779 | 779 | 'account_id' => $allVals['uidnumber'][0], |
| 780 | 780 | 'account_lid' => Api\Translation::convert($allVals['uid'][0],'utf-8'), |
| 781 | 781 | 'account_type' => 'u', |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | $test = $allVals['cn'][0]; |
| 836 | 836 | if (!$this->frontend->config['global_denied_groups'][$test] && $allVals['cn'][0]) |
| 837 | 837 | { |
| 838 | - $accounts[(string)-$allVals['gidnumber'][0]] = Array( |
|
| 838 | + $accounts[(string)-$allVals['gidnumber'][0]] = array( |
|
| 839 | 839 | 'account_id' => -$allVals['gidnumber'][0], |
| 840 | 840 | 'account_lid' => Api\Translation::convert($allVals['cn'][0],'utf-8'), |
| 841 | 841 | 'account_type' => 'g', |
@@ -175,7 +175,10 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | function read($account_id) |
| 177 | 177 | { |
| 178 | - if (!(int)$account_id) return false; |
|
| 178 | + if (!(int)$account_id) |
|
| 179 | + { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 179 | 182 | |
| 180 | 183 | if ($account_id < 0) |
| 181 | 184 | { |
@@ -238,17 +241,23 @@ discard block |
||
| 238 | 241 | $this->delete($data['account_id']); |
| 239 | 242 | unset($old['dn']); |
| 240 | 243 | // removing the namedObject object-class, if it's included |
| 241 | - if ($key !== false) unset($old['objectclass'][$key]); |
|
| 244 | + if ($key !== false) |
|
| 245 | + { |
|
| 246 | + unset($old['objectclass'][$key]); |
|
| 247 | + } |
|
| 242 | 248 | $to_write = $old; |
| 243 | 249 | unset($old); |
| 244 | 250 | } |
| 245 | 251 | } |
| 246 | 252 | } |
| 247 | - if (!$data['account_id']) // new account |
|
| 253 | + if (!$data['account_id']) |
|
| 254 | + { |
|
| 255 | + // new account |
|
| 248 | 256 | { |
| 249 | 257 | if (!($data['account_id'] = $data_utf8['account_id'] = $this->_get_nextid($is_group ? 'g' : 'u'))) |
| 250 | 258 | { |
| 251 | 259 | return false; |
| 260 | + } |
|
| 252 | 261 | } |
| 253 | 262 | } |
| 254 | 263 | // check if we need to write the objectclass: new entry or required object classes are missing |
@@ -259,11 +268,14 @@ discard block |
||
| 259 | 268 | { |
| 260 | 269 | $to_write['objectclass'] = $old ? $old['objectclass'] : array(); |
| 261 | 270 | } |
| 262 | - if (!$old) // for new accounts add additional addressbook object classes, if supported by server |
|
| 271 | + if (!$old) |
|
| 272 | + { |
|
| 273 | + // for new accounts add additional addressbook object classes, if supported by server |
|
| 263 | 274 | { // as setting them later might loose eg. password, if we are not allowed to read them |
| 264 | 275 | foreach($this->requiredObjectClasses[$is_group?'group-if-supported':'user-if-supported'] as $additional) |
| 265 | 276 | { |
| 266 | 277 | $add = array(); |
| 278 | + } |
|
| 267 | 279 | if (is_array($additional)) |
| 268 | 280 | { |
| 269 | 281 | $add = $additional; |
@@ -272,7 +284,10 @@ discard block |
||
| 272 | 284 | if ($this->ldapServerInfo->supportsObjectClass($additional)) |
| 273 | 285 | { |
| 274 | 286 | $to_write['objectclass'][] = $additional; |
| 275 | - if ($add) $to_write += $add; |
|
| 287 | + if ($add) |
|
| 288 | + { |
|
| 289 | + $to_write += $add; |
|
| 290 | + } |
|
| 276 | 291 | } |
| 277 | 292 | } |
| 278 | 293 | } |
@@ -281,7 +296,10 @@ discard block |
||
| 281 | 296 | } |
| 282 | 297 | if (!($dn = $old['dn'])) |
| 283 | 298 | { |
| 284 | - if (!$data['account_lid']) return false; |
|
| 299 | + if (!$data['account_lid']) |
|
| 300 | + { |
|
| 301 | + return false; |
|
| 302 | + } |
|
| 285 | 303 | |
| 286 | 304 | $dn = $is_group ? 'cn='.$data_utf8['account_lid'].','.$this->group_context : |
| 287 | 305 | 'uid='.$data_utf8['account_lid'].','.$this->user_context; |
@@ -302,24 +320,36 @@ discard block |
||
| 302 | 320 | { |
| 303 | 321 | $extra_attr = false; |
| 304 | 322 | $keep_objectclass = false; |
| 305 | - if (is_array($forward)) list($forward,$extra_attr,$keep_objectclass) = $forward; |
|
| 323 | + if (is_array($forward)) |
|
| 324 | + { |
|
| 325 | + list($forward,$extra_attr,$keep_objectclass) = $forward; |
|
| 326 | + } |
|
| 306 | 327 | |
| 307 | 328 | if ($this->ldapServerInfo->supportsObjectClass($objectclass) && |
| 308 | 329 | ($old && in_array($objectclass,$old['objectclass']) || $data_utf8['account_email'] || $old[static::MAIL_ATTR])) |
| 309 | 330 | { |
| 310 | - if ($data_utf8['account_email']) // setting an email |
|
| 331 | + if ($data_utf8['account_email']) |
|
| 332 | + { |
|
| 333 | + // setting an email |
|
| 311 | 334 | { |
| 312 | 335 | if (!in_array($objectclass,$old ? $old['objectclass'] : $to_write['objectclass'])) |
| 313 | 336 | { |
| 314 | 337 | if ($old) $to_write['objectclass'] = $old['objectclass']; |
| 338 | + } |
|
| 315 | 339 | $to_write['objectclass'][] = $objectclass; |
| 316 | 340 | } |
| 317 | - if ($extra_attr) $to_write[$extra_attr] = $data_utf8['account_lid']; |
|
| 341 | + if ($extra_attr) |
|
| 342 | + { |
|
| 343 | + $to_write[$extra_attr] = $data_utf8['account_lid']; |
|
| 344 | + } |
|
| 318 | 345 | $to_write[static::MAIL_ATTR] = $data_utf8['account_email']; |
| 319 | 346 | |
| 320 | 347 | if ($forward) |
| 321 | 348 | { |
| 322 | - if (!$members) $members = $this->members($data['account_id']); |
|
| 349 | + if (!$members) |
|
| 350 | + { |
|
| 351 | + $members = $this->members($data['account_id']); |
|
| 352 | + } |
|
| 323 | 353 | $to_write[$forward] = array(); |
| 324 | 354 | foreach (array_keys($members) as $member) |
| 325 | 355 | { |
@@ -330,11 +360,20 @@ discard block |
||
| 330 | 360 | } |
| 331 | 361 | } |
| 332 | 362 | } |
| 333 | - elseif($old) // remove the mail and forwards only for existing entries |
|
| 363 | + elseif($old) |
|
| 364 | + { |
|
| 365 | + // remove the mail and forwards only for existing entries |
|
| 334 | 366 | { |
| 335 | 367 | $to_write[static::MAIL_ATTR] = array(); |
| 336 | - if ($forward) $to_write[$forward] = array(); |
|
| 337 | - if ($extra_attr) $to_write[$extra_attr] = array(); |
|
| 368 | + } |
|
| 369 | + if ($forward) |
|
| 370 | + { |
|
| 371 | + $to_write[$forward] = array(); |
|
| 372 | + } |
|
| 373 | + if ($extra_attr) |
|
| 374 | + { |
|
| 375 | + $to_write[$extra_attr] = array(); |
|
| 376 | + } |
|
| 338 | 377 | if (!$keep_objectclass && ($key = array_search($objectclass,$old['objectclass']))) |
| 339 | 378 | { |
| 340 | 379 | $to_write['objectclass'] = $old['objectclass']; |
@@ -368,7 +407,8 @@ discard block |
||
| 368 | 407 | } |
| 369 | 408 | |
| 370 | 409 | // remove memberuid when adding a group |
| 371 | - if(!$old && is_array($to_write['memberuid']) && empty($to_write['memberuid'])) { |
|
| 410 | + if(!$old && is_array($to_write['memberuid']) && empty($to_write['memberuid'])) |
|
| 411 | + { |
|
| 372 | 412 | unset($to_write['memberuid']); |
| 373 | 413 | } |
| 374 | 414 | // modifying or adding the entry |
@@ -405,7 +445,10 @@ discard block |
||
| 405 | 445 | */ |
| 406 | 446 | function delete($account_id) |
| 407 | 447 | { |
| 408 | - if (!(int)$account_id) return false; |
|
| 448 | + if (!(int)$account_id) |
|
| 449 | + { |
|
| 450 | + return false; |
|
| 451 | + } |
|
| 409 | 452 | |
| 410 | 453 | if ($account_id < 0) |
| 411 | 454 | { |
@@ -418,10 +461,16 @@ discard block |
||
| 418 | 461 | |
| 419 | 462 | $sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . $account_id); |
| 420 | 463 | } |
| 421 | - if (!$sri) return false; |
|
| 464 | + if (!$sri) |
|
| 465 | + { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 422 | 468 | |
| 423 | 469 | $allValues = ldap_get_entries($this->ds, $sri); |
| 424 | - if (!$allValues['count']) return false; |
|
| 470 | + if (!$allValues['count']) |
|
| 471 | + { |
|
| 472 | + return false; |
|
| 473 | + } |
|
| 425 | 474 | |
| 426 | 475 | return ldap_delete($this->ds, $allValues[0]['dn']); |
| 427 | 476 | } |
@@ -593,14 +642,20 @@ discard block |
||
| 593 | 642 | $utc_diff = date('Z'); |
| 594 | 643 | if (isset($data['account_passwd']) && $data['account_passwd']) |
| 595 | 644 | { |
| 596 | - if (preg_match('/^[a-f0-9]{32}$/', $data['account_passwd'])) // md5 --> ldap md5 |
|
| 645 | + if (preg_match('/^[a-f0-9]{32}$/', $data['account_passwd'])) |
|
| 646 | + { |
|
| 647 | + // md5 --> ldap md5 |
|
| 597 | 648 | { |
| 598 | 649 | $data['account_passwd'] = setup_cmd_ldap::hash_sql2ldap($data['account_passwd']); |
| 599 | 650 | } |
| 600 | - elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) // if it's not already entcrypted, do so now |
|
| 651 | + } |
|
| 652 | + elseif (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd'])) |
|
| 653 | + { |
|
| 654 | + // if it's not already entcrypted, do so now |
|
| 601 | 655 | { |
| 602 | 656 | $data['account_passwd'] = Api\Auth::encrypt_ldap($data['account_passwd']); |
| 603 | 657 | } |
| 658 | + } |
|
| 604 | 659 | $to_write['userpassword'] = $data['account_passwd']; |
| 605 | 660 | $to_write['shadowlastchange'] = round((time()-$utc_diff) / (24*3600)); |
| 606 | 661 | } |
@@ -620,16 +675,28 @@ discard block |
||
| 620 | 675 | unset($to_write['shadowexpire']); // gives protocoll error otherwise |
| 621 | 676 | } |
| 622 | 677 | //error_log(__METHOD__.__LINE__.$data['account_lid'].'#'.$data['account_lastpwd_change'].'#'); |
| 623 | - if ($data['account_lastpwd_change']) $to_write['shadowlastchange'] = round(($data['account_lastpwd_change']-$utc_diff)/(24*3600)); |
|
| 624 | - if (isset($data['account_lastpwd_change']) && $data['account_lastpwd_change']==0) $to_write['shadowlastchange'] = 0; |
|
| 678 | + if ($data['account_lastpwd_change']) |
|
| 679 | + { |
|
| 680 | + $to_write['shadowlastchange'] = round(($data['account_lastpwd_change']-$utc_diff)/(24*3600)); |
|
| 681 | + } |
|
| 682 | + if (isset($data['account_lastpwd_change']) && $data['account_lastpwd_change']==0) |
|
| 683 | + { |
|
| 684 | + $to_write['shadowlastchange'] = 0; |
|
| 685 | + } |
|
| 625 | 686 | // lastlogin and lastlogin from are not availible via the shadowAccount object class |
| 626 | 687 | // $to_write['phpgwaccountlastlogin'] = $data['lastlogin']; |
| 627 | 688 | // $to_write['phpgwaccountlastloginfrom'] = $data['lastloginfrom']; |
| 628 | 689 | |
| 629 | 690 | if ($this->frontend->config['ldap_extra_attributes']) |
| 630 | 691 | { |
| 631 | - if (isset($data['homedirectory'])) $to_write['homedirectory'] = $data['homedirectory']; |
|
| 632 | - if (isset($data['loginshell'])) $to_write['loginshell'] = $data['loginshell'] ? $data['loginshell'] : array(); |
|
| 692 | + if (isset($data['homedirectory'])) |
|
| 693 | + { |
|
| 694 | + $to_write['homedirectory'] = $data['homedirectory']; |
|
| 695 | + } |
|
| 696 | + if (isset($data['loginshell'])) |
|
| 697 | + { |
|
| 698 | + $to_write['loginshell'] = $data['loginshell'] ? $data['loginshell'] : array(); |
|
| 699 | + } |
|
| 633 | 700 | } |
| 634 | 701 | if (($new_entry || isset($to_write['homedirectory'])) && empty($to_write['homedirectory'])) |
| 635 | 702 | { |
@@ -676,8 +743,14 @@ discard block |
||
| 676 | 743 | } |
| 677 | 744 | // if it's a limited query, check if the unlimited query is cached |
| 678 | 745 | $start = $param['start']; |
| 679 | - if (!($maxmatchs = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])) $maxmatchs = 15; |
|
| 680 | - if (!($offset = $param['offset'])) $offset = $maxmatchs; |
|
| 746 | + if (!($maxmatchs = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])) |
|
| 747 | + { |
|
| 748 | + $maxmatchs = 15; |
|
| 749 | + } |
|
| 750 | + if (!($offset = $param['offset'])) |
|
| 751 | + { |
|
| 752 | + $offset = $maxmatchs; |
|
| 753 | + } |
|
| 681 | 754 | unset($param['start']); |
| 682 | 755 | unset($param['offset']); |
| 683 | 756 | $unl_serial = serialize($param); |
@@ -748,12 +821,18 @@ discard block |
||
| 748 | 821 | $fullSet = array(); |
| 749 | 822 | foreach ((array)ldap_get_entries($this->ds, $sri) as $key => $entry) |
| 750 | 823 | { |
| 751 | - if ($key !== 'count') $fullSet[$entry['uid'][0]] = $entry[$order][0]; |
|
| 824 | + if ($key !== 'count') |
|
| 825 | + { |
|
| 826 | + $fullSet[$entry['uid'][0]] = $entry[$order][0]; |
|
| 827 | + } |
|
| 752 | 828 | } |
| 753 | 829 | |
| 754 | - if (is_numeric($param['type'])) // return only group-members |
|
| 830 | + if (is_numeric($param['type'])) |
|
| 831 | + { |
|
| 832 | + // return only group-members |
|
| 755 | 833 | { |
| 756 | 834 | $relevantAccounts = array(); |
| 835 | + } |
|
| 757 | 836 | $sri = ldap_search($this->ds,$this->group_context,"(&(objectClass=posixGroup)(gidnumber=" . abs($param['type']) . "))",array('memberuid')); |
| 758 | 837 | $group = ldap_get_entries($this->ds, $sri); |
| 759 | 838 | $fullSet = $group[0]['memberuid'] ? array_intersect_key($fullSet, array_flip($group[0]['memberuid'])) : array(); |
@@ -791,7 +870,10 @@ discard block |
||
| 791 | 870 | //error_log(__METHOD__."() ldap=".array2string($allVals)." --> account=".array2string($account)); |
| 792 | 871 | if ($param['active'] && !$this->frontend->is_active($account)) |
| 793 | 872 | { |
| 794 | - if (isset($totalcount)) --$totalcount; |
|
| 873 | + if (isset($totalcount)) |
|
| 874 | + { |
|
| 875 | + --$totalcount; |
|
| 876 | + } |
|
| 795 | 877 | continue; |
| 796 | 878 | } |
| 797 | 879 | $account['account_fullname'] = Api\Accounts::format_username($account['account_lid'], |
@@ -844,7 +926,10 @@ discard block |
||
| 844 | 926 | 'account_status' => 'A', |
| 845 | 927 | 'account_fullname' => Api\Translation::convert($allVals['cn'][0],'utf-8'), |
| 846 | 928 | ); |
| 847 | - if (isset($totalcount)) ++$totalcount; |
|
| 929 | + if (isset($totalcount)) |
|
| 930 | + { |
|
| 931 | + ++$totalcount; |
|
| 932 | + } |
|
| 848 | 933 | } |
| 849 | 934 | } |
| 850 | 935 | } |
@@ -945,10 +1030,13 @@ discard block |
||
| 945 | 1030 | { |
| 946 | 1031 | $name = Api\Ldap::quote(Api\Translation::convert($_name,Api\Translation::charset(),'utf-8')); |
| 947 | 1032 | |
| 948 | - if ($which == 'account_lid' && $account_type !== 'u') // groups only support account_lid |
|
| 1033 | + if ($which == 'account_lid' && $account_type !== 'u') |
|
| 1034 | + { |
|
| 1035 | + // groups only support account_lid |
|
| 949 | 1036 | { |
| 950 | 1037 | |
| 951 | 1038 | $sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . $name . ')(objectclass=posixgroup))', array('gidNumber')); |
| 1039 | + } |
|
| 952 | 1040 | $allValues = ldap_get_entries($this->ds, $sri); |
| 953 | 1041 | |
| 954 | 1042 | if (@$allValues[0]['gidnumber'][0]) |
@@ -961,7 +1049,8 @@ discard block |
||
| 961 | 1049 | 'account_email' => static::MAIL_ATTR, |
| 962 | 1050 | 'account_fullname' => 'cn', |
| 963 | 1051 | ); |
| 964 | - if (!isset($to_ldap[$which]) || $account_type === 'g') { |
|
| 1052 | + if (!isset($to_ldap[$which]) || $account_type === 'g') |
|
| 1053 | + { |
|
| 965 | 1054 | return False; |
| 966 | 1055 | } |
| 967 | 1056 | |
@@ -1011,13 +1100,19 @@ discard block |
||
| 1011 | 1100 | */ |
| 1012 | 1101 | function memberships($account_id) |
| 1013 | 1102 | { |
| 1014 | - if (!(int) $account_id || !($account_lid = $this->id2name($account_id))) return false; |
|
| 1103 | + if (!(int) $account_id || !($account_lid = $this->id2name($account_id))) |
|
| 1104 | + { |
|
| 1105 | + return false; |
|
| 1106 | + } |
|
| 1015 | 1107 | |
| 1016 | 1108 | $sri = ldap_search($this->ds,$this->group_context,'(&(objectClass=posixGroup)(memberuid='.Api\Ldap::quote($account_lid).'))',array('cn','gidnumber')); |
| 1017 | 1109 | $memberships = array(); |
| 1018 | 1110 | foreach((array)ldap_get_entries($this->ds, $sri) as $key => $data) |
| 1019 | 1111 | { |
| 1020 | - if ($key === 'count') continue; |
|
| 1112 | + if ($key === 'count') |
|
| 1113 | + { |
|
| 1114 | + continue; |
|
| 1115 | + } |
|
| 1021 | 1116 | |
| 1022 | 1117 | $memberships[(string) -$data['gidnumber'][0]] = $data['cn'][0]; |
| 1023 | 1118 | } |
@@ -1037,7 +1132,10 @@ discard block |
||
| 1037 | 1132 | { |
| 1038 | 1133 | // try to recover |
| 1039 | 1134 | $_gid = $this->name2id($_gid,'account_lid','g'); |
| 1040 | - if (!is_numeric($_gid)) return false; |
|
| 1135 | + if (!is_numeric($_gid)) |
|
| 1136 | + { |
|
| 1137 | + return false; |
|
| 1138 | + } |
|
| 1041 | 1139 | } |
| 1042 | 1140 | |
| 1043 | 1141 | $gid = abs($_gid); // our gid is negative! |
@@ -1085,7 +1183,10 @@ discard block |
||
| 1085 | 1183 | // adding new memberships |
| 1086 | 1184 | foreach($old_memberships ? array_diff($groups,$old_memberships) : $groups as $gid) |
| 1087 | 1185 | { |
| 1088 | - if (!($members = $this->members($gid))) $members = array(); |
|
| 1186 | + if (!($members = $this->members($gid))) |
|
| 1187 | + { |
|
| 1188 | + $members = array(); |
|
| 1189 | + } |
|
| 1089 | 1190 | $members[$account_id] = $this->id2name($account_id); |
| 1090 | 1191 | $this->set_members($members,$gid); |
| 1091 | 1192 | } |
@@ -1103,16 +1204,25 @@ discard block |
||
| 1103 | 1204 | */ |
| 1104 | 1205 | function set_members($members, $gid, array $objectclass=null, $use_cn=null) |
| 1105 | 1206 | { |
| 1106 | - if (!($cn = $use_cn) && !($cn = $this->id2name($gid))) return false; |
|
| 1207 | + if (!($cn = $use_cn) && !($cn = $this->id2name($gid))) |
|
| 1208 | + { |
|
| 1209 | + return false; |
|
| 1210 | + } |
|
| 1107 | 1211 | |
| 1108 | 1212 | // do that group is a groupOf(Unique)Names or univentionGroup? |
| 1109 | - if (is_null($objectclass)) $objectclass = $this->id2name($gid,'objectclass'); |
|
| 1213 | + if (is_null($objectclass)) |
|
| 1214 | + { |
|
| 1215 | + $objectclass = $this->id2name($gid,'objectclass'); |
|
| 1216 | + } |
|
| 1110 | 1217 | |
| 1111 | 1218 | $to_write = array('memberuid' => array()); |
| 1112 | 1219 | foreach((array)$members as $key => $member) |
| 1113 | 1220 | { |
| 1114 | 1221 | $member_dn = $this->id2name($member, 'account_dn'); |
| 1115 | - if (is_numeric($member)) $member = $this->id2name($member); |
|
| 1222 | + if (is_numeric($member)) |
|
| 1223 | + { |
|
| 1224 | + $member = $this->id2name($member); |
|
| 1225 | + } |
|
| 1116 | 1226 | |
| 1117 | 1227 | if ($member) |
| 1118 | 1228 | { |
@@ -1136,21 +1246,33 @@ discard block |
||
| 1136 | 1246 | { |
| 1137 | 1247 | $to_write['uniquemember'][] = 'uid=dummy'.','.$this->user_context; |
| 1138 | 1248 | } |
| 1139 | - if ($use_cn) return $to_write; |
|
| 1249 | + if ($use_cn) |
|
| 1250 | + { |
|
| 1251 | + return $to_write; |
|
| 1252 | + } |
|
| 1140 | 1253 | |
| 1141 | 1254 | // set the member email addresses as forwards |
| 1142 | 1255 | if ($this->id2name($gid,'account_email') && ($objectclass = $this->id2name($gid,'mailAllowed'))) |
| 1143 | 1256 | { |
| 1144 | 1257 | $forward = $this->group_mail_classes[$objectclass]; |
| 1145 | - if (is_array($forward)) list($forward,$extra_attr) = $forward; |
|
| 1146 | - if ($extra_attr && ($uid = $this->id2name($gid))) $to_write[$extra_attr] = $uid; |
|
| 1258 | + if (is_array($forward)) |
|
| 1259 | + { |
|
| 1260 | + list($forward,$extra_attr) = $forward; |
|
| 1261 | + } |
|
| 1262 | + if ($extra_attr && ($uid = $this->id2name($gid))) |
|
| 1263 | + { |
|
| 1264 | + $to_write[$extra_attr] = $uid; |
|
| 1265 | + } |
|
| 1147 | 1266 | |
| 1148 | 1267 | if ($forward) |
| 1149 | 1268 | { |
| 1150 | 1269 | $to_write[$forward] = array(); |
| 1151 | 1270 | foreach($members as $key => $member) |
| 1152 | 1271 | { |
| 1153 | - if (($email = $this->id2name($member,'account_email'))) $to_write[$forward][] = $email; |
|
| 1272 | + if (($email = $this->id2name($member,'account_email'))) |
|
| 1273 | + { |
|
| 1274 | + $to_write[$forward][] = $email; |
|
| 1275 | + } |
|
| 1154 | 1276 | } |
| 1155 | 1277 | } |
| 1156 | 1278 | } |
@@ -1176,7 +1298,10 @@ discard block |
||
| 1176 | 1298 | |
| 1177 | 1299 | // prefer ids above 1000 (below reserved for system users under AD or Linux), |
| 1178 | 1300 | // if that's possible within what is configured, or nothing is configured |
| 1179 | - if ($min < 1000 && (!$max || $max > 1000)) $min = 1000; |
|
| 1301 | + if ($min < 1000 && (!$max || $max > 1000)) |
|
| 1302 | + { |
|
| 1303 | + $min = 1000; |
|
| 1304 | + } |
|
| 1180 | 1305 | |
| 1181 | 1306 | if ($account_type == 'g') |
| 1182 | 1307 | { |
@@ -1229,7 +1354,10 @@ discard block |
||
| 1229 | 1354 | } |
| 1230 | 1355 | ++$id; |
| 1231 | 1356 | |
| 1232 | - if($id < $min) $id = $min; |
|
| 1357 | + if($id < $min) |
|
| 1358 | + { |
|
| 1359 | + $id = $min; |
|
| 1360 | + } |
|
| 1233 | 1361 | |
| 1234 | 1362 | Api\Config::save_value($key, $id, 'phpgwapi', true); |
| 1235 | 1363 | $GLOBALS['egw_info']['server'][$key='last_id_'.$location] = $id; |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | * If no account_id is set in data the account is added and the new id is set in $data. |
| 48 | 48 | * |
| 49 | 49 | * @param array $data array with account-data |
| 50 | - * @return int|boolean the account_id or false on error |
|
| 50 | + * @return false|string the account_id or false on error |
|
| 51 | 51 | */ |
| 52 | 52 | function save(&$data) |
| 53 | 53 | { |
@@ -90,7 +90,10 @@ |
||
| 90 | 90 | catch(Exception $e) { |
| 91 | 91 | unset($e); |
| 92 | 92 | } |
| 93 | - if (empty($hostname)) $hostname = trim(system('hostname -f')); |
|
| 93 | + if (empty($hostname)) |
|
| 94 | + { |
|
| 95 | + $hostname = trim(system('hostname -f')); |
|
| 96 | + } |
|
| 94 | 97 | $params[] = '--set'; $params[] = 'mailHomeServer='.$hostname; |
| 95 | 98 | } |
| 96 | 99 | $cmd = self::DIRECTORY_MANAGER_BIN.' '.implode(' ', array_map('escapeshellarg', $params)); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | if (!$data['account_id'] && $data['account_type'] !== 'g') |
| 63 | 63 | { |
| 64 | 64 | $params = array( |
| 65 | - 'users/user','create', |
|
| 65 | + 'users/user', 'create', |
|
| 66 | 66 | '--binddn', $config['ldap_root_dn'], |
| 67 | 67 | '--bindpwd', 5=>$config['ldap_root_pw'], |
| 68 | 68 | '--position', $config['ldap_context'], |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | $hostname = $account->acc_imap_host; |
| 89 | 89 | } |
| 90 | - catch(\Exception $e) { |
|
| 90 | + catch (\Exception $e) { |
|
| 91 | 91 | unset($e); |
| 92 | 92 | } |
| 93 | 93 | if (empty($hostname)) $hostname = trim(system('hostname -f')); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | $output = implode("\n", $output_arr); |
| 100 | 100 | if ($ret || !preg_match('/^Object created: (uid=.*)$/mui', $output, $matches)) |
| 101 | 101 | { |
| 102 | - $params[5] = '********'; // mask out password! |
|
| 102 | + $params[5] = '********'; // mask out password! |
|
| 103 | 103 | $cmd = self::DIRECTORY_MANAGER_BIN.' '.implode(' ', array_map('escapeshellarg', $params)); |
| 104 | 104 | throw new Api\Exception\WrongUserinput($cmd."\nreturned\n".$output); |
| 105 | 105 | } |
| 106 | 106 | $data['account_dn'] = $matches[1]; |
| 107 | 107 | $data['account_id'] = $this->name2id($data['account_lid'], 'account_lid', 'u'); |
| 108 | 108 | } |
| 109 | - elseif($data['account_id'] && ($data['old_loginid'] || ($data['old_loginid'] = $this->id2name($data['account_id']))) && |
|
| 109 | + elseif ($data['account_id'] && ($data['old_loginid'] || ($data['old_loginid'] = $this->id2name($data['account_id']))) && |
|
| 110 | 110 | $data['account_lid'] != $data['old_loginid'] && |
| 111 | 111 | ($data['account_dn'] = $this->id2name($data['account_id'], 'account_dn'))) |
| 112 | 112 | { |
@@ -123,12 +123,11 @@ discard block |
||
| 123 | 123 | $output = implode("\n", $output_arr); |
| 124 | 124 | if ($ret || !preg_match('/^Object modified: ((uid|cn)=.*)$/mui', $output, $matches)) |
| 125 | 125 | { |
| 126 | - $params[5] = '********'; // mask out password! |
|
| 126 | + $params[5] = '********'; // mask out password! |
|
| 127 | 127 | $cmd = self::DIRECTORY_MANAGER_BIN.' '.implode(' ', array_map('escapeshellarg', $params)); |
| 128 | 128 | throw new Api\Exception\WrongUserinput($cmd."\nreturned\n".$output); |
| 129 | 129 | } |
| 130 | - $data['account_dn'] = $data['account_type'] !== 'g' ? $matches[1] : |
|
| 131 | - // duno why but directory-manager returns old dn for groups ... |
|
| 130 | + $data['account_dn'] = $data['account_type'] !== 'g' ? $matches[1] : // duno why but directory-manager returns old dn for groups ... |
|
| 132 | 131 | preg_replace('/^cn=[^,]+,/', 'cn='.$data['account_lid'].',', $data['account_dn']); |
| 133 | 132 | } |
| 134 | 133 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * Delete ACL record in the repository of the class |
| 167 | 167 | * |
| 168 | 168 | * @param string $appname appname or '' for $GLOBALS['egw_info']['flags']['currentapp'] |
| 169 | - * @param string/boolean $location location or false for all locations |
|
| 169 | + * @param boolean $location location or false for all locations |
|
| 170 | 170 | * @return array all ACL records from $this->data. |
| 171 | 171 | */ |
| 172 | 172 | function delete($appname,$location) |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * check required rights agains the internal repository (included rights of $this->account_id and all it's memberships) |
| 269 | 269 | * |
| 270 | - * @param $location app location |
|
| 271 | - * @param $required required right to check against |
|
| 270 | + * @param string $location app location |
|
| 271 | + * @param integer $required required right to check against |
|
| 272 | 272 | * @param $appname optional defaults to currentapp |
| 273 | 273 | * @return boolean |
| 274 | 274 | */ |
@@ -51,15 +51,15 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * Constants for acl rights, like old EGW_ACL_* defines |
| 53 | 53 | */ |
| 54 | - const READ = 1; // EGW_ACL_READ |
|
| 55 | - const ADD = 2; // EGW_ACL_ADD |
|
| 56 | - const EDIT = 4; // EGW_ACL_EDIT |
|
| 57 | - const DELETE = 8; // EGW_ACL_DELETE |
|
| 58 | - const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
| 59 | - const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
| 60 | - const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
| 61 | - const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
| 62 | - const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
| 54 | + const READ = 1; // EGW_ACL_READ |
|
| 55 | + const ADD = 2; // EGW_ACL_ADD |
|
| 56 | + const EDIT = 4; // EGW_ACL_EDIT |
|
| 57 | + const DELETE = 8; // EGW_ACL_DELETE |
|
| 58 | + const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
| 59 | + const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
| 60 | + const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
| 61 | + const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
| 62 | + const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * ACL constructor for setting account id |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | if ((int)$this->account_id != (int)$account_id) |
| 84 | 84 | { |
| 85 | - $this->account_id = get_account_id((int)$account_id,@$GLOBALS['egw_info']['user']['account_id']); |
|
| 85 | + $this->account_id = get_account_id((int)$account_id, @$GLOBALS['egw_info']['user']['account_id']); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param boolean|array $no_groups = false if true, do not use memberships, if array do not use given groups |
| 97 | 97 | * @return array along with storing it in $acl->data. <br> |
| 98 | 98 | */ |
| 99 | - function read_repository($no_groups=false) |
|
| 99 | + function read_repository($no_groups = false) |
|
| 100 | 100 | { |
| 101 | 101 | // For some reason, calling this via XML-RPC doesn't call the constructor. |
| 102 | 102 | // Here is yet another work around(tm) (jengo) |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | else |
| 112 | 112 | { |
| 113 | 113 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
| 114 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 115 | - array_unshift($acl_acc_list,$this->account_id); |
|
| 114 | + if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list, $no_groups); |
|
| 115 | + array_unshift($acl_acc_list, $this->account_id); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $this->data = Array(); |
| 119 | - foreach($this->db->select(self::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) |
|
| 119 | + foreach ($this->db->select(self::TABLE, '*', array('acl_account' => $acl_acc_list), __LINE__, __FILE__) as $row) |
|
| 120 | 120 | { |
| 121 | - $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row,'acl_'); |
|
| 121 | + $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row, 'acl_'); |
|
| 122 | 122 | } |
| 123 | 123 | return $this->data; |
| 124 | 124 | } |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * @param int $rights rights |
| 148 | 148 | * @return array all ACL records from $this->data. |
| 149 | 149 | */ |
| 150 | - function add($appname,$location,$rights) |
|
| 150 | + function add($appname, $location, $rights) |
|
| 151 | 151 | { |
| 152 | 152 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 153 | 153 | |
| 154 | 154 | $row = array( |
| 155 | 155 | 'appname' => $appname, |
| 156 | 156 | 'location' => $location, |
| 157 | - 'account' => (int) $this->account_id, |
|
| 158 | - 'rights' => (int) $rights |
|
| 157 | + 'account' => (int)$this->account_id, |
|
| 158 | + 'rights' => (int)$rights |
|
| 159 | 159 | ); |
| 160 | 160 | $this->data[$row['appname'].'-'.$row['location'].'-'.$row['account']] = $row; |
| 161 | 161 | |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | * @param string/boolean $location location or false for all locations |
| 170 | 170 | * @return array all ACL records from $this->data. |
| 171 | 171 | */ |
| 172 | - function delete($appname,$location) |
|
| 172 | + function delete($appname, $location) |
|
| 173 | 173 | { |
| 174 | 174 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 175 | 175 | |
| 176 | - foreach($this->data as $idx => $value) |
|
| 176 | + foreach ($this->data as $idx => $value) |
|
| 177 | 177 | { |
| 178 | 178 | if ($value['appname'] == $appname && |
| 179 | 179 | ($location === false || $value['location'] == $location) && |
@@ -192,24 +192,24 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | function save_repository() |
| 194 | 194 | { |
| 195 | - $this->db->delete(self::TABLE,array( |
|
| 195 | + $this->db->delete(self::TABLE, array( |
|
| 196 | 196 | 'acl_account' => $this->account_id, |
| 197 | - ),__LINE__,__FILE__); |
|
| 197 | + ), __LINE__, __FILE__); |
|
| 198 | 198 | |
| 199 | - foreach($this->data as $value) |
|
| 199 | + foreach ($this->data as $value) |
|
| 200 | 200 | { |
| 201 | 201 | if ($value['account'] == $this->account_id) |
| 202 | 202 | { |
| 203 | - $this->db->insert(self::TABLE,array( |
|
| 203 | + $this->db->insert(self::TABLE, array( |
|
| 204 | 204 | 'acl_appname' => $value['appname'], |
| 205 | 205 | 'acl_location' => $value['location'], |
| 206 | 206 | 'acl_account' => $this->account_id, |
| 207 | 207 | 'acl_rights' => $value['rights'], |
| 208 | - ),false,__LINE__,__FILE__); |
|
| 208 | + ), false, __LINE__, __FILE__); |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 212 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 212 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 213 | 213 | { |
| 214 | 214 | $GLOBALS['egw']->invalidate_session_cache(); |
| 215 | 215 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param string $appname optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 228 | 228 | * @return int all rights or'ed together |
| 229 | 229 | */ |
| 230 | - function get_rights($location,$appname = '') |
|
| 230 | + function get_rights($location, $appname = '') |
|
| 231 | 231 | { |
| 232 | 232 | // For XML-RPC, change this once its working correctly for passing parameters (jengo) |
| 233 | 233 | if (is_array($location)) |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | return True; |
| 248 | 248 | } |
| 249 | 249 | $rights = 0; |
| 250 | - foreach($this->data as $value) |
|
| 250 | + foreach ($this->data as $value) |
|
| 251 | 251 | { |
| 252 | 252 | if ($value['appname'] == $appname) |
| 253 | 253 | { |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | function check($location, $required, $appname = False) |
| 276 | 276 | { |
| 277 | - $rights = $this->get_rights($location,$appname); |
|
| 277 | + $rights = $this->get_rights($location, $appname); |
|
| 278 | 278 | |
| 279 | - return !!($rights & $required); |
|
| 279 | + return !!($rights&$required); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @param array $memberships = array() additional account_id, eg. memberships to match beside $this->account_id, default none |
| 288 | 288 | * @return int $rights |
| 289 | 289 | */ |
| 290 | - function get_specific_rights($location, $appname = '', $memberships=array()) |
|
| 290 | + function get_specific_rights($location, $appname = '', $memberships = array()) |
|
| 291 | 291 | { |
| 292 | 292 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 293 | 293 | |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | $rights = 0; |
| 299 | 299 | |
| 300 | - foreach($this->data as $value) |
|
| 300 | + foreach ($this->data as $value) |
|
| 301 | 301 | { |
| 302 | 302 | if ($value['appname'] == $appname && |
| 303 | - ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
| 303 | + ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
| 304 | 304 | ($value['account'] == $this->account_id || $memberships && in_array($value['account'], $memberships))) |
| 305 | 305 | { |
| 306 | 306 | if ($value['rights'] == 0) |
@@ -323,9 +323,9 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | function check_specific($location, $required, $appname = '') |
| 325 | 325 | { |
| 326 | - $rights = $this->get_specific_rights($location,$appname); |
|
| 326 | + $rights = $this->get_specific_rights($location, $appname); |
|
| 327 | 327 | |
| 328 | - return !!($rights & $required); |
|
| 328 | + return !!($rights&$required); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /**************************************************************************\ |
@@ -344,16 +344,16 @@ discard block |
||
| 344 | 344 | function add_repository($app, $location, $account_id, $rights) |
| 345 | 345 | { |
| 346 | 346 | //echo "<p>self::add_repository('$app','$location',$account_id,$rights);</p>\n"; |
| 347 | - $this->db->insert(self::TABLE,array( |
|
| 347 | + $this->db->insert(self::TABLE, array( |
|
| 348 | 348 | 'acl_rights' => $rights, |
| 349 | - ),array( |
|
| 349 | + ), array( |
|
| 350 | 350 | 'acl_appname' => $app, |
| 351 | 351 | 'acl_location' => $location, |
| 352 | 352 | 'acl_account' => $account_id, |
| 353 | - ),__LINE__,__FILE__); |
|
| 353 | + ), __LINE__, __FILE__); |
|
| 354 | 354 | |
| 355 | 355 | if ($account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 356 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 356 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 357 | 357 | { |
| 358 | 358 | $GLOBALS['egw']->invalidate_session_cache(); |
| 359 | 359 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @param int/boolean $accountid = '' account id, default 0=$this->account_id, or false to delete all entries for $app/$location |
| 369 | 369 | * @return int number of rows deleted |
| 370 | 370 | */ |
| 371 | - function delete_repository($app, $location, $accountid='') |
|
| 371 | + function delete_repository($app, $location, $accountid = '') |
|
| 372 | 372 | { |
| 373 | 373 | static $cache_accountid = array(); |
| 374 | 374 | |
@@ -378,22 +378,22 @@ discard block |
||
| 378 | 378 | ); |
| 379 | 379 | if ($accountid !== false) |
| 380 | 380 | { |
| 381 | - if(isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
| 381 | + if (isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
| 382 | 382 | { |
| 383 | 383 | $where['acl_account'] = $cache_accountid[$accountid]; |
| 384 | 384 | } |
| 385 | 385 | else |
| 386 | 386 | { |
| 387 | - $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
| 387 | + $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 390 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 391 | 391 | { |
| 392 | 392 | $GLOBALS['egw']->invalidate_session_cache(); |
| 393 | 393 | } |
| 394 | 394 | if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
| 395 | 395 | |
| 396 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
| 396 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
| 397 | 397 | |
| 398 | 398 | return $this->db->affected_rows(); |
| 399 | 399 | } |
@@ -406,15 +406,15 @@ discard block |
||
| 406 | 406 | * @param string $appname = '' defaults to current app |
| 407 | 407 | * @return int/boolean rights or false if none exist |
| 408 | 408 | */ |
| 409 | - function get_specific_rights_for_account($account_id,$location,$appname='') |
|
| 409 | + function get_specific_rights_for_account($account_id, $location, $appname = '') |
|
| 410 | 410 | { |
| 411 | 411 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 412 | 412 | |
| 413 | - return $this->db->select(self::TABLE,'acl_rights',array( |
|
| 413 | + return $this->db->select(self::TABLE, 'acl_rights', array( |
|
| 414 | 414 | 'acl_location' => $location, |
| 415 | 415 | 'acl_account' => $account_id, |
| 416 | 416 | 'acl_appname' => $appname, |
| 417 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
| 417 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -424,15 +424,15 @@ discard block |
||
| 424 | 424 | * @param string $appname = '' defaults to current app |
| 425 | 425 | * @return array with account => rights pairs |
| 426 | 426 | */ |
| 427 | - function get_all_rights($location,$appname='') |
|
| 427 | + function get_all_rights($location, $appname = '') |
|
| 428 | 428 | { |
| 429 | 429 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 430 | 430 | |
| 431 | 431 | $rights = array(); |
| 432 | - foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
|
| 432 | + foreach ($this->db->select(self::TABLE, 'acl_account,acl_rights', array( |
|
| 433 | 433 | 'acl_location' => $location, |
| 434 | 434 | 'acl_appname' => $appname, |
| 435 | - ),__LINE__,__FILE__) as $row) |
|
| 435 | + ), __LINE__, __FILE__) as $row) |
|
| 436 | 436 | { |
| 437 | 437 | $rights[$row['acl_account']] = $row['acl_rights']; |
| 438 | 438 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @param boolean $use_memberships = true |
| 448 | 448 | * @return array with location => rights pairs |
| 449 | 449 | */ |
| 450 | - function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
|
| 450 | + function get_all_location_rights($account_id, $appname = '', $use_memberships = true) |
|
| 451 | 451 | { |
| 452 | 452 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 453 | 453 | |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | $accounts[] = $account_id; |
| 459 | 459 | } |
| 460 | 460 | $rights = array(); |
| 461 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
| 461 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
| 462 | 462 | 'acl_account' => $accounts, |
| 463 | 463 | 'acl_appname' => $appname, |
| 464 | - ),__LINE__,__FILE__) as $row) |
|
| 464 | + ), __LINE__, __FILE__) as $row) |
|
| 465 | 465 | { |
| 466 | 466 | $rights[$row['acl_location']] |= $row['acl_rights']; |
| 467 | 467 | } |
@@ -480,28 +480,28 @@ discard block |
||
| 480 | 480 | { |
| 481 | 481 | static $cache_accountid = array(); |
| 482 | 482 | |
| 483 | - if(isset($cache_accountid[$accountid])) |
|
| 483 | + if (isset($cache_accountid[$accountid])) |
|
| 484 | 484 | { |
| 485 | 485 | $account_id = $cache_accountid[$accountid]; |
| 486 | 486 | } |
| 487 | 487 | else |
| 488 | 488 | { |
| 489 | - $account_id = get_account_id($accountid,$this->account_id); |
|
| 489 | + $account_id = get_account_id($accountid, $this->account_id); |
|
| 490 | 490 | $cache_accountid[$accountid] = $account_id; |
| 491 | 491 | } |
| 492 | 492 | $rights = 0; |
| 493 | 493 | $apps = false; |
| 494 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
| 494 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
| 495 | 495 | 'acl_location' => $location, |
| 496 | 496 | 'acl_account' => $account_id, |
| 497 | - ),__LINE__,__FILE__) as $row) |
|
| 497 | + ), __LINE__, __FILE__) as $row) |
|
| 498 | 498 | { |
| 499 | 499 | if ($row['acl_rights'] == 0) |
| 500 | 500 | { |
| 501 | 501 | return False; |
| 502 | 502 | } |
| 503 | 503 | $rights |= $row['acl_rights']; |
| 504 | - if (!!($rights & $required)) |
|
| 504 | + if (!!($rights&$required)) |
|
| 505 | 505 | { |
| 506 | 506 | $apps[] = $row['acl_appname']; |
| 507 | 507 | } |
@@ -521,21 +521,21 @@ discard block |
||
| 521 | 521 | { |
| 522 | 522 | static $cache_accountid = array(); |
| 523 | 523 | |
| 524 | - if(isset($cache_accountid[$accountid])) |
|
| 524 | + if (isset($cache_accountid[$accountid])) |
|
| 525 | 525 | { |
| 526 | 526 | $accountid = $cache_accountid[$accountid]; |
| 527 | 527 | } |
| 528 | 528 | else |
| 529 | 529 | { |
| 530 | - $accountid = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
| 530 | + $accountid = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
| 531 | 531 | } |
| 532 | 532 | $locations = false; |
| 533 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
| 533 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
| 534 | 534 | 'acl_appname' => $app, |
| 535 | 535 | 'acl_account' => $accountid, |
| 536 | - ),__LINE__,__FILE__) as $row) |
|
| 536 | + ), __LINE__, __FILE__) as $row) |
|
| 537 | 537 | { |
| 538 | - if ($row['acl_rights'] & $required) |
|
| 538 | + if ($row['acl_rights']&$required) |
|
| 539 | 539 | { |
| 540 | 540 | $locations[] = $row['acl_location']; |
| 541 | 541 | } |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 557 | 557 | |
| 558 | 558 | $accounts = false; |
| 559 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
|
| 559 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights'), array( |
|
| 560 | 560 | 'acl_appname' => $app, |
| 561 | 561 | 'acl_location' => $location, |
| 562 | - ),__LINE__,__FILE__) as $row) |
|
| 562 | + ), __LINE__, __FILE__) as $row) |
|
| 563 | 563 | { |
| 564 | - if (!!($row['acl_rights'] & $required)) |
|
| 564 | + if (!!($row['acl_rights']&$required)) |
|
| 565 | 565 | { |
| 566 | - $accounts[] = (int) $row['acl_account']; |
|
| 566 | + $accounts[] = (int)$row['acl_account']; |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | return $accounts; |
@@ -575,14 +575,14 @@ discard block |
||
| 575 | 575 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 576 | 576 | * @return boolean/array false if there are no matching location in the db or array of locations |
| 577 | 577 | */ |
| 578 | - function get_locations_for_app($app='') |
|
| 578 | + function get_locations_for_app($app = '') |
|
| 579 | 579 | { |
| 580 | 580 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 581 | 581 | |
| 582 | 582 | $locations = false; |
| 583 | - foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
|
| 583 | + foreach ($this->db->select(self::TABLE, 'DISTINCT '.'acl_location', array( |
|
| 584 | 584 | 'acl_appname' => $app, |
| 585 | - ),__LINE__,__FILE__) as $row) |
|
| 585 | + ), __LINE__, __FILE__) as $row) |
|
| 586 | 586 | { |
| 587 | 587 | if (($location = $row['acl_location']) != 'run') |
| 588 | 588 | { |
@@ -600,38 +600,38 @@ discard block |
||
| 600 | 600 | * @param boolean $add_implicit_apps = true true: add apps every user has implicit rights |
| 601 | 601 | * @return array containing list of apps |
| 602 | 602 | */ |
| 603 | - function get_user_applications($accountid = '', $use_memberships=true, $add_implicit_apps=true) |
|
| 603 | + function get_user_applications($accountid = '', $use_memberships = true, $add_implicit_apps = true) |
|
| 604 | 604 | { |
| 605 | 605 | static $cache_accountid = array(); |
| 606 | 606 | |
| 607 | - if(isset($cache_accountid[$accountid])) |
|
| 607 | + if (isset($cache_accountid[$accountid])) |
|
| 608 | 608 | { |
| 609 | 609 | $account_id = $cache_accountid[$accountid]; |
| 610 | 610 | } |
| 611 | 611 | else |
| 612 | 612 | { |
| 613 | - $account_id = get_account_id($accountid,$this->account_id); |
|
| 613 | + $account_id = get_account_id($accountid, $this->account_id); |
|
| 614 | 614 | $cache_accountid[$accountid] = $account_id; |
| 615 | 615 | } |
| 616 | 616 | if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
| 617 | 617 | $memberships[] = (int)$account_id; |
| 618 | 618 | |
| 619 | 619 | $apps = array(); |
| 620 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
| 620 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
| 621 | 621 | 'acl_location' => 'run', |
| 622 | 622 | 'acl_account' => $memberships, |
| 623 | - ),__LINE__,__FILE__) as $row) |
|
| 623 | + ), __LINE__, __FILE__) as $row) |
|
| 624 | 624 | { |
| 625 | 625 | $app = $row['acl_appname']; |
| 626 | - if(!isset($apps[$app])) |
|
| 626 | + if (!isset($apps[$app])) |
|
| 627 | 627 | { |
| 628 | 628 | $apps[$app] = 0; |
| 629 | 629 | } |
| 630 | - $apps[$app] |= (int) $row['acl_rights']; |
|
| 630 | + $apps[$app] |= (int)$row['acl_rights']; |
|
| 631 | 631 | } |
| 632 | 632 | if ($add_implicit_apps) |
| 633 | 633 | { |
| 634 | - $apps['api'] = 1; // give everyone implicit rights for the home app |
|
| 634 | + $apps['api'] = 1; // give everyone implicit rights for the home app |
|
| 635 | 635 | } |
| 636 | 636 | return $apps; |
| 637 | 637 | } |
@@ -645,29 +645,29 @@ discard block |
||
| 645 | 645 | * @param int $user = null user whos grants to return, default current user |
| 646 | 646 | * @return array with account-ids (of owners) and granted rights as values |
| 647 | 647 | */ |
| 648 | - function get_grants($app='',$enum_group_acls=true,$user=null) |
|
| 648 | + function get_grants($app = '', $enum_group_acls = true, $user = null) |
|
| 649 | 649 | { |
| 650 | 650 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 651 | 651 | if (!$user) $user = $this->account_id; |
| 652 | 652 | |
| 653 | - static $cache = array(); // some caching withing the request |
|
| 653 | + static $cache = array(); // some caching withing the request |
|
| 654 | 654 | |
| 655 | - $grants =& $cache[$app][$user]; |
|
| 655 | + $grants = & $cache[$app][$user]; |
|
| 656 | 656 | if (!isset($grants)) |
| 657 | 657 | { |
| 658 | 658 | if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 659 | 659 | $memberships[] = $user; |
| 660 | 660 | |
| 661 | 661 | $grants = $accounts = Array(); |
| 662 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights','acl_location'),array( |
|
| 662 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights', 'acl_location'), array( |
|
| 663 | 663 | 'acl_appname' => $app, |
| 664 | 664 | 'acl_location' => $memberships, |
| 665 | - ),__LINE__,__FILE__) as $row) |
|
| 665 | + ), __LINE__, __FILE__) as $row) |
|
| 666 | 666 | { |
| 667 | 667 | $grantor = $row['acl_account']; |
| 668 | 668 | $rights = $row['acl_rights']; |
| 669 | 669 | |
| 670 | - if(!isset($grants[$grantor])) |
|
| 670 | + if (!isset($grants[$grantor])) |
|
| 671 | 671 | { |
| 672 | 672 | $grants[$grantor] = 0; |
| 673 | 673 | } |
@@ -675,17 +675,17 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | // if the right is granted from a group and we enummerated group ACL's |
| 677 | 677 | if ($GLOBALS['egw']->accounts->get_type($grantor) == 'g' && $enum_group_acls && |
| 678 | - (!is_array($enum_group_acls) || !in_array($grantor,$enum_group_acls))) |
|
| 678 | + (!is_array($enum_group_acls) || !in_array($grantor, $enum_group_acls))) |
|
| 679 | 679 | { |
| 680 | 680 | // return the grant for each member of the group (false = also for no longer active users) |
| 681 | - foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
| 681 | + foreach ((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
| 682 | 682 | { |
| 683 | - if (!$grantor) continue; // can happen if group has no members |
|
| 683 | + if (!$grantor) continue; // can happen if group has no members |
|
| 684 | 684 | |
| 685 | 685 | // Don't allow to override private with group ACL's! |
| 686 | 686 | $rights &= ~self::PRIVAT; |
| 687 | 687 | |
| 688 | - if(!isset($grants[$grantor])) |
|
| 688 | + if (!isset($grants[$grantor])) |
|
| 689 | 689 | { |
| 690 | 690 | $grants[$grantor] = 0; |
| 691 | 691 | } |
@@ -707,21 +707,21 @@ discard block |
||
| 707 | 707 | */ |
| 708 | 708 | function delete_account($account_id) |
| 709 | 709 | { |
| 710 | - if ((int) $account_id) |
|
| 710 | + if ((int)$account_id) |
|
| 711 | 711 | { |
| 712 | 712 | // Delete all grants from this account |
| 713 | - $this->db->delete(self::TABLE,array( |
|
| 713 | + $this->db->delete(self::TABLE, array( |
|
| 714 | 714 | 'acl_account' => $account_id |
| 715 | - ),__LINE__,__FILE__); |
|
| 715 | + ), __LINE__, __FILE__); |
|
| 716 | 716 | // Delete all grants to this account |
| 717 | - $this->db->delete(self::TABLE,array( |
|
| 717 | + $this->db->delete(self::TABLE, array( |
|
| 718 | 718 | 'acl_location' => $account_id |
| 719 | - ),__LINE__, __FILE__); |
|
| 719 | + ), __LINE__, __FILE__); |
|
| 720 | 720 | // delete all memberships in account_id (if it is a group) |
| 721 | - $this->db->delete(self::TABLE,array( |
|
| 721 | + $this->db->delete(self::TABLE, array( |
|
| 722 | 722 | 'acl_appname' => 'phpgw_group', |
| 723 | 723 | 'acl_location' => $account_id, |
| 724 | - ),__LINE__,__FILE__); |
|
| 724 | + ), __LINE__, __FILE__); |
|
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | |
@@ -732,15 +732,15 @@ discard block |
||
| 732 | 732 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 733 | 733 | * @return array with location => array(account => rights) pairs |
| 734 | 734 | */ |
| 735 | - function get_location_grants($location,$app='') |
|
| 735 | + function get_location_grants($location, $app = '') |
|
| 736 | 736 | { |
| 737 | 737 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 738 | 738 | |
| 739 | 739 | $locations = array(); |
| 740 | - foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
|
| 740 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_account,acl_rights', array( |
|
| 741 | 741 | 'acl_appname' => $app, |
| 742 | 742 | 'acl_location LIKE '.$this->db->quote($location), |
| 743 | - ),__LINE__,__FILE__) as $row) |
|
| 743 | + ), __LINE__, __FILE__) as $row) |
|
| 744 | 744 | { |
| 745 | 745 | if (($location = $row['acl_location']) != 'run') |
| 746 | 746 | { |
@@ -111,7 +111,10 @@ discard block |
||
| 111 | 111 | else |
| 112 | 112 | { |
| 113 | 113 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
| 114 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 114 | + if (is_array($no_groups)) |
|
| 115 | + { |
|
| 116 | + $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 117 | + } |
|
| 115 | 118 | array_unshift($acl_acc_list,$this->account_id); |
| 116 | 119 | } |
| 117 | 120 | |
@@ -149,7 +152,10 @@ discard block |
||
| 149 | 152 | */ |
| 150 | 153 | function add($appname,$location,$rights) |
| 151 | 154 | { |
| 152 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 155 | + if (!$appname) |
|
| 156 | + { |
|
| 157 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 158 | + } |
|
| 153 | 159 | |
| 154 | 160 | $row = array( |
| 155 | 161 | 'appname' => $appname, |
@@ -171,7 +177,10 @@ discard block |
||
| 171 | 177 | */ |
| 172 | 178 | function delete($appname,$location) |
| 173 | 179 | { |
| 174 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 180 | + if (!$appname) |
|
| 181 | + { |
|
| 182 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 183 | + } |
|
| 175 | 184 | |
| 176 | 185 | foreach($this->data as $idx => $value) |
| 177 | 186 | { |
@@ -209,10 +218,13 @@ discard block |
||
| 209 | 218 | } |
| 210 | 219 | } |
| 211 | 220 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 212 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 221 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 222 | + { |
|
| 223 | + // egw object in setup is limited |
|
| 213 | 224 | { |
| 214 | 225 | $GLOBALS['egw']->invalidate_session_cache(); |
| 215 | 226 | } |
| 227 | + } |
|
| 216 | 228 | return $this->data; |
| 217 | 229 | } |
| 218 | 230 | |
@@ -240,7 +252,10 @@ discard block |
||
| 240 | 252 | { |
| 241 | 253 | $this->read_repository(); |
| 242 | 254 | } |
| 243 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 255 | + if (!$appname) |
|
| 256 | + { |
|
| 257 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 258 | + } |
|
| 244 | 259 | |
| 245 | 260 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
| 246 | 261 | { |
@@ -289,7 +304,10 @@ discard block |
||
| 289 | 304 | */ |
| 290 | 305 | function get_specific_rights($location, $appname = '', $memberships=array()) |
| 291 | 306 | { |
| 292 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 307 | + if (!$appname) |
|
| 308 | + { |
|
| 309 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 310 | + } |
|
| 293 | 311 | |
| 294 | 312 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
| 295 | 313 | { |
@@ -353,10 +371,13 @@ discard block |
||
| 353 | 371 | ),__LINE__,__FILE__); |
| 354 | 372 | |
| 355 | 373 | if ($account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 356 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 374 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 375 | + { |
|
| 376 | + // egw object in setup is limited |
|
| 357 | 377 | { |
| 358 | 378 | $GLOBALS['egw']->invalidate_session_cache(); |
| 359 | 379 | } |
| 380 | + } |
|
| 360 | 381 | return True; |
| 361 | 382 | } |
| 362 | 383 | |
@@ -387,11 +408,17 @@ discard block |
||
| 387 | 408 | $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
| 388 | 409 | } |
| 389 | 410 | } |
| 390 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 411 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 412 | + { |
|
| 413 | + // egw object in setup is limited |
|
| 391 | 414 | { |
| 392 | 415 | $GLOBALS['egw']->invalidate_session_cache(); |
| 393 | 416 | } |
| 394 | - if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
|
| 417 | + } |
|
| 418 | + if ($app == '%' || $app == '%%') |
|
| 419 | + { |
|
| 420 | + unset($where['acl_appname']); |
|
| 421 | + } |
|
| 395 | 422 | |
| 396 | 423 | $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
| 397 | 424 | |
@@ -408,7 +435,10 @@ discard block |
||
| 408 | 435 | */ |
| 409 | 436 | function get_specific_rights_for_account($account_id,$location,$appname='') |
| 410 | 437 | { |
| 411 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 438 | + if (!$appname) |
|
| 439 | + { |
|
| 440 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 441 | + } |
|
| 412 | 442 | |
| 413 | 443 | return $this->db->select(self::TABLE,'acl_rights',array( |
| 414 | 444 | 'acl_location' => $location, |
@@ -426,7 +456,10 @@ discard block |
||
| 426 | 456 | */ |
| 427 | 457 | function get_all_rights($location,$appname='') |
| 428 | 458 | { |
| 429 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 459 | + if (!$appname) |
|
| 460 | + { |
|
| 461 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 462 | + } |
|
| 430 | 463 | |
| 431 | 464 | $rights = array(); |
| 432 | 465 | foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
@@ -449,7 +482,10 @@ discard block |
||
| 449 | 482 | */ |
| 450 | 483 | function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
| 451 | 484 | { |
| 452 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 485 | + if (!$appname) |
|
| 486 | + { |
|
| 487 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 488 | + } |
|
| 453 | 489 | |
| 454 | 490 | $accounts = array($account_id); |
| 455 | 491 | if ($use_memberships && (int)$account_id > 0) |
@@ -553,7 +589,10 @@ discard block |
||
| 553 | 589 | */ |
| 554 | 590 | function get_ids_for_location($location, $required, $app = '') |
| 555 | 591 | { |
| 556 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 592 | + if (!$app) |
|
| 593 | + { |
|
| 594 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 595 | + } |
|
| 557 | 596 | |
| 558 | 597 | $accounts = false; |
| 559 | 598 | foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
@@ -577,7 +616,10 @@ discard block |
||
| 577 | 616 | */ |
| 578 | 617 | function get_locations_for_app($app='') |
| 579 | 618 | { |
| 580 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 619 | + if (!$app) |
|
| 620 | + { |
|
| 621 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 622 | + } |
|
| 581 | 623 | |
| 582 | 624 | $locations = false; |
| 583 | 625 | foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
@@ -613,7 +655,10 @@ discard block |
||
| 613 | 655 | $account_id = get_account_id($accountid,$this->account_id); |
| 614 | 656 | $cache_accountid[$accountid] = $account_id; |
| 615 | 657 | } |
| 616 | - if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
| 658 | + if ($use_memberships && (int)$account_id > 0) |
|
| 659 | + { |
|
| 660 | + $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
| 661 | + } |
|
| 617 | 662 | $memberships[] = (int)$account_id; |
| 618 | 663 | |
| 619 | 664 | $apps = array(); |
@@ -647,15 +692,24 @@ discard block |
||
| 647 | 692 | */ |
| 648 | 693 | function get_grants($app='',$enum_group_acls=true,$user=null) |
| 649 | 694 | { |
| 650 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 651 | - if (!$user) $user = $this->account_id; |
|
| 695 | + if (!$app) |
|
| 696 | + { |
|
| 697 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 698 | + } |
|
| 699 | + if (!$user) |
|
| 700 | + { |
|
| 701 | + $user = $this->account_id; |
|
| 702 | + } |
|
| 652 | 703 | |
| 653 | 704 | static $cache = array(); // some caching withing the request |
| 654 | 705 | |
| 655 | 706 | $grants =& $cache[$app][$user]; |
| 656 | 707 | if (!isset($grants)) |
| 657 | 708 | { |
| 658 | - if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 709 | + if ((int)$user > 0) |
|
| 710 | + { |
|
| 711 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 712 | + } |
|
| 659 | 713 | $memberships[] = $user; |
| 660 | 714 | |
| 661 | 715 | $grants = $accounts = Array(); |
@@ -680,7 +734,11 @@ discard block |
||
| 680 | 734 | // return the grant for each member of the group (false = also for no longer active users) |
| 681 | 735 | foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
| 682 | 736 | { |
| 683 | - if (!$grantor) continue; // can happen if group has no members |
|
| 737 | + if (!$grantor) |
|
| 738 | + { |
|
| 739 | + continue; |
|
| 740 | + } |
|
| 741 | + // can happen if group has no members |
|
| 684 | 742 | |
| 685 | 743 | // Don't allow to override private with group ACL's! |
| 686 | 744 | $rights &= ~self::PRIVAT; |
@@ -734,7 +792,10 @@ discard block |
||
| 734 | 792 | */ |
| 735 | 793 | function get_location_grants($location,$app='') |
| 736 | 794 | { |
| 737 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 795 | + if (!$app) |
|
| 796 | + { |
|
| 797 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 798 | + } |
|
| 738 | 799 | |
| 739 | 800 | $locations = array(); |
| 740 | 801 | foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @var array $data internal repository with acl rows for the given app and account-id (incl. memberships) |
| 38 | 38 | */ |
| 39 | - var $data = Array(); |
|
| 39 | + var $data = array(); |
|
| 40 | 40 | /** |
| 41 | 41 | * internal copy of the db-object |
| 42 | 42 | * |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | array_unshift($acl_acc_list,$this->account_id); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $this->data = Array(); |
|
| 118 | + $this->data = array(); |
|
| 119 | 119 | foreach($this->db->select(self::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) |
| 120 | 120 | { |
| 121 | 121 | $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row,'acl_'); |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 659 | 659 | $memberships[] = $user; |
| 660 | 660 | |
| 661 | - $grants = $accounts = Array(); |
|
| 661 | + $grants = $accounts = array(); |
|
| 662 | 662 | foreach($this->db->select(self::TABLE,array('acl_account','acl_rights','acl_location'),array( |
| 663 | 663 | 'acl_appname' => $app, |
| 664 | 664 | 'acl_location' => $memberships, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * cancels a timer |
| 325 | 325 | * |
| 326 | 326 | * @param string $id has to be the one used to set it. |
| 327 | - * @return boolean True if the timer exists and is not expired. |
|
| 327 | + * @return integer True if the timer exists and is not expired. |
|
| 328 | 328 | */ |
| 329 | 329 | function cancel_timer($id) |
| 330 | 330 | { |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | /** |
| 471 | 471 | * reads all matching db-rows / jobs |
| 472 | 472 | * |
| 473 | - * @param string $id =0 reads all expired rows / jobs ready to run\ |
|
| 473 | + * @param integer $id =0 reads all expired rows / jobs ready to run\ |
|
| 474 | 474 | * != 0 reads all rows/jobs matching $id (sql-wildcards '%' and '_' can be used) |
| 475 | 475 | * @param array|string $cols ='*' string or array of column-names / select-expressions |
| 476 | 476 | * @param int|bool $offset =False offset for a limited query or False (default) |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | /** |
| 559 | 559 | * delete db-row / job with $id |
| 560 | 560 | * |
| 561 | - * @return boolean False if $id not found else True |
|
| 561 | + * @return integer False if $id not found else True |
|
| 562 | 562 | */ |
| 563 | 563 | function delete($id) |
| 564 | 564 | { |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $this->db = $GLOBALS['egw_setup']->db; |
| 51 | 51 | } |
| 52 | - $this->cronline = EGW_SERVER_ROOT . '/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
| 52 | + $this->cronline = EGW_SERVER_ROOT.'/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
| 53 | 53 | |
| 54 | - $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
| 54 | + $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | * @param boolean $debug =false |
| 72 | 72 | * @return boolean False if $id already exists, else True |
| 73 | 73 | */ |
| 74 | - function set_timer($times,$id,$method,$data=null,$account_id=False,$debug=false) |
|
| 74 | + function set_timer($times, $id, $method, $data = null, $account_id = False, $debug = false) |
|
| 75 | 75 | { |
| 76 | 76 | if (empty($id) || empty($method) || $this->read($id) || |
| 77 | - !($next = $this->next_run($times,$debug))) |
|
| 77 | + !($next = $this->next_run($times, $debug))) |
|
| 78 | 78 | { |
| 79 | 79 | return False; |
| 80 | 80 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | * @param int $now Use this time to calculate then next run from. Defaults to time(). |
| 108 | 108 | * @return int a unix timestamp of the next execution time or False if no more executions |
| 109 | 109 | */ |
| 110 | - function next_run($times,$debug=False, $now = null) |
|
| 110 | + function next_run($times, $debug = False, $now = null) |
|
| 111 | 111 | { |
| 112 | 112 | if ($this->debug) |
| 113 | 113 | { |
| 114 | - echo "<p>next_run("; print_r($times); echo ",'$debug', " . date('Y-m-d H:i', $now) . ")</p>\n"; |
|
| 115 | - $debug = True; // enable syntax-error messages too |
|
| 114 | + echo "<p>next_run("; print_r($times); echo ",'$debug', ".date('Y-m-d H:i', $now).")</p>\n"; |
|
| 115 | + $debug = True; // enable syntax-error messages too |
|
| 116 | 116 | } |
| 117 | - if(is_null($now)) { |
|
| 117 | + if (is_null($now)) { |
|
| 118 | 118 | $now = time(); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | 'dow' => 6, |
| 143 | 143 | 'day' => 31, |
| 144 | 144 | 'month' => 12, |
| 145 | - 'year' => date('Y')+10 // else */[0-9] would never stop returning numbers |
|
| 145 | + 'year' => date('Y') + 10 // else */[0-9] would never stop returning numbers |
|
| 146 | 146 | ); |
| 147 | 147 | $min_unit = array( |
| 148 | 148 | 'min' => 0, |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | // get set to the minimum after |
| 159 | 159 | // |
| 160 | 160 | $i = $first_set = $last_set = 0; |
| 161 | - foreach($units as $u => $date_pattern) |
|
| 161 | + foreach ($units as $u => $date_pattern) |
|
| 162 | 162 | { |
| 163 | 163 | ++$i; |
| 164 | 164 | if (isset($times[$u])) |
@@ -176,24 +176,24 @@ discard block |
||
| 176 | 176 | // (as descript above), enumerations are arrays with unit-values as keys |
| 177 | 177 | // |
| 178 | 178 | $n = 0; |
| 179 | - foreach($units as $u => $date_pattern) |
|
| 179 | + foreach ($units as $u => $date_pattern) |
|
| 180 | 180 | { |
| 181 | 181 | ++$n; |
| 182 | - if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 182 | + if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u]) ? 'True' : 'False')."</p>\n"; } |
|
| 183 | 183 | if (isset($times[$u])) |
| 184 | 184 | { |
| 185 | - if(is_array($times[$u])) { |
|
| 185 | + if (is_array($times[$u])) { |
|
| 186 | 186 | $time = array_keys($times[$u]); |
| 187 | 187 | } else { |
| 188 | - $time = explode(',',$times[$u]); |
|
| 188 | + $time = explode(',', $times[$u]); |
|
| 189 | 189 | } |
| 190 | 190 | $times[$u] = array(); |
| 191 | 191 | |
| 192 | - foreach($time as $t) |
|
| 192 | + foreach ($time as $t) |
|
| 193 | 193 | { |
| 194 | - if (strpos($t,'-') !== False && strpos($t,'/') === False) |
|
| 194 | + if (strpos($t, '-') !== False && strpos($t, '/') === False) |
|
| 195 | 195 | { |
| 196 | - list($min,$max) = $arr = explode('-',$t); |
|
| 196 | + list($min, $max) = $arr = explode('-', $t); |
|
| 197 | 197 | |
| 198 | 198 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
| 199 | 199 | { |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | if ((string)$t == '*') $t = '*/1'; |
| 212 | 212 | |
| 213 | - list($one,$inc) = $arr = explode('/',$t); |
|
| 213 | + list($one, $inc) = $arr = explode('/', $t); |
|
| 214 | 214 | |
| 215 | 215 | if (!(is_numeric($one) && count($arr) == 1 || |
| 216 | 216 | count($arr) == 2 && is_numeric($inc))) |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | else |
| 227 | 227 | { |
| 228 | - list($min,$max) = $arr = explode('-',$one); |
|
| 228 | + list($min, $max) = $arr = explode('-', $one); |
|
| 229 | 229 | if (empty($one) || $one == '*') |
| 230 | 230 | { |
| 231 | 231 | $min = $min_unit[$u]; |
@@ -266,20 +266,19 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | $future = False; |
| 268 | 268 | |
| 269 | - foreach($units as $u => $date_pattern) |
|
| 269 | + foreach ($units as $u => $date_pattern) |
|
| 270 | 270 | { |
| 271 | - $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : |
|
| 272 | - (int)date($date_pattern,mktime(12,0,0,$found['month'],$found['day'],$found['year'])); |
|
| 271 | + $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : (int)date($date_pattern, mktime(12, 0, 0, $found['month'], $found['day'], $found['year'])); |
|
| 273 | 272 | |
| 274 | 273 | if (isset($found[$u])) |
| 275 | 274 | { |
| 276 | 275 | $future = $future || $found[$u] > $unit_now; |
| 277 | 276 | if ($this->debug) echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
| 278 | - continue; // already set |
|
| 277 | + continue; // already set |
|
| 279 | 278 | } |
| 280 | - foreach(array_keys($times[$u]) as $unit_value) |
|
| 279 | + foreach (array_keys($times[$u]) as $unit_value) |
|
| 281 | 280 | { |
| 282 | - switch($u) |
|
| 281 | + switch ($u) |
|
| 283 | 282 | { |
| 284 | 283 | case 'dow': |
| 285 | 284 | $valid = $unit_value == $unit_now; |
@@ -302,12 +301,12 @@ discard block |
||
| 302 | 301 | if (!isset($found[$u])) // we have to try the next one, if it exists |
| 303 | 302 | { |
| 304 | 303 | $nexts = array_keys($units); |
| 305 | - if (!isset($nexts[count($found)-1])) |
|
| 304 | + if (!isset($nexts[count($found) - 1])) |
|
| 306 | 305 | { |
| 307 | 306 | if ($this->debug) echo "<p>Nothing found, exiting !!!</p>\n"; |
| 308 | 307 | return False; |
| 309 | 308 | } |
| 310 | - $next = $nexts[count($found)-1]; |
|
| 309 | + $next = $nexts[count($found) - 1]; |
|
| 311 | 310 | $over = $found[$next]; |
| 312 | 311 | unset($found[$next]); |
| 313 | 312 | if ($this->debug) echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
@@ -317,7 +316,7 @@ discard block |
||
| 317 | 316 | } |
| 318 | 317 | if ($this->debug) { echo "<p>next="; print_r($found); echo "</p>\n"; } |
| 319 | 318 | |
| 320 | - return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
|
| 319 | + return mktime($found['hour'], $found['min'], 0, $found['month'], $found['day'], $found['year']); |
|
| 321 | 320 | } |
| 322 | 321 | |
| 323 | 322 | /** |
@@ -339,7 +338,7 @@ discard block |
||
| 339 | 338 | * @return mixed if !$set array('start' => $start,'end' => $end) with timestamps of last check_run start and end, \ |
| 340 | 339 | * !$end means check_run is just running. If $set returns True if it was able to get the semaphore, else False |
| 341 | 340 | */ |
| 342 | - function last_check_run($semaphore=False,$release=False,$run_by='') |
|
| 341 | + function last_check_run($semaphore = False, $release = False, $run_by = '') |
|
| 343 | 342 | { |
| 344 | 343 | //echo "<p>last_check_run(semaphore=".($semaphore?'True':'False').",release=".($release?'True':'False').")</p>\n"; |
| 345 | 344 | if (($exists = $this->read('##last-check-run##'))) |
@@ -361,7 +360,7 @@ discard block |
||
| 361 | 360 | } |
| 362 | 361 | else |
| 363 | 362 | { |
| 364 | - @set_time_limit(0); // dont stop for an execution-time-limit |
|
| 363 | + @set_time_limit(0); // dont stop for an execution-time-limit |
|
| 365 | 364 | ignore_user_abort(True); |
| 366 | 365 | |
| 367 | 366 | $last_run = array( |
@@ -377,7 +376,7 @@ discard block |
||
| 377 | 376 | ); |
| 378 | 377 | // as the async_next column is used as a semaphore we only update it, |
| 379 | 378 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
| 380 | - if ($exists) $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 379 | + if ($exists) $where = array('async_next=0 OR async_next<'.(time() - 600)); |
|
| 381 | 380 | } |
| 382 | 381 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
| 383 | 382 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -386,20 +385,20 @@ discard block |
||
| 386 | 385 | /** |
| 387 | 386 | * checks if there are any jobs ready to run (timer expired) and executes them |
| 388 | 387 | */ |
| 389 | - function check_run($run_by='') |
|
| 388 | + function check_run($run_by = '') |
|
| 390 | 389 | { |
| 391 | 390 | if ($run_by === 'fallback') flush(); |
| 392 | 391 | |
| 393 | - if (!$this->last_check_run(True,False,$run_by)) |
|
| 392 | + if (!$this->last_check_run(True, False, $run_by)) |
|
| 394 | 393 | { |
| 395 | - return False; // cant obtain semaphore |
|
| 394 | + return False; // cant obtain semaphore |
|
| 396 | 395 | } |
| 397 | 396 | // mark enviroment as async-service, check with isset()! |
| 398 | 397 | $GLOBALS['egw_info']['flags']['async-service'] = $run_by; |
| 399 | 398 | |
| 400 | 399 | if (($jobs = $this->read())) |
| 401 | 400 | { |
| 402 | - foreach($jobs as $job) |
|
| 401 | + foreach ($jobs as $job) |
|
| 403 | 402 | { |
| 404 | 403 | // checking / setting up egw_info/user |
| 405 | 404 | // |
@@ -408,7 +407,7 @@ discard block |
||
| 408 | 407 | // run notifications, before changing account_id of enviroment |
| 409 | 408 | Link::run_notifies(); |
| 410 | 409 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
| 411 | - foreach($GLOBALS as $name => $value) |
|
| 410 | + foreach ($GLOBALS as $name => $value) |
|
| 412 | 411 | { |
| 413 | 412 | if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
| 414 | 413 | } |
@@ -420,7 +419,7 @@ discard block |
||
| 420 | 419 | { |
| 421 | 420 | $GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']); |
| 422 | 421 | $GLOBALS['egw']->session->account_domain = $domain; |
| 423 | - $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
| 422 | + $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
| 424 | 423 | |
| 425 | 424 | if ($lang != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) |
| 426 | 425 | { |
@@ -435,12 +434,11 @@ discard block |
||
| 435 | 434 | $GLOBALS['egw_info']['user']['domain'] = $domain; |
| 436 | 435 | } |
| 437 | 436 | } |
| 438 | - list($app) = strpos($job['method'],'::') !== false ? explode('_',$job['method']) : |
|
| 439 | - explode('.',$job['method']); |
|
| 437 | + list($app) = strpos($job['method'], '::') !== false ? explode('_', $job['method']) : explode('.', $job['method']); |
|
| 440 | 438 | Translation::add_app($app); |
| 441 | 439 | if (is_array($job['data'])) |
| 442 | 440 | { |
| 443 | - $job['data'] += array_diff_key($job,array('data' => false)); |
|
| 441 | + $job['data'] += array_diff_key($job, array('data' => false)); |
|
| 444 | 442 | } |
| 445 | 443 | // update job before running it, to cope with jobs taking longer then async-frequency |
| 446 | 444 | if (($job['next'] = $this->next_run($job['times']))) |
@@ -453,16 +451,16 @@ discard block |
||
| 453 | 451 | } |
| 454 | 452 | try |
| 455 | 453 | { |
| 456 | - ExecMethod($job['method'],$job['data']); |
|
| 454 | + ExecMethod($job['method'], $job['data']); |
|
| 457 | 455 | } |
| 458 | - catch(Exception $e) |
|
| 456 | + catch (Exception $e) |
|
| 459 | 457 | { |
| 460 | 458 | // log the exception to error_log, but continue running other async jobs |
| 461 | 459 | _egw_log_exception($e); |
| 462 | 460 | } |
| 463 | 461 | } |
| 464 | 462 | } |
| 465 | - $this->last_check_run(True,True,$run_by); // release semaphore |
|
| 463 | + $this->last_check_run(True, True, $run_by); // release semaphore |
|
| 466 | 464 | |
| 467 | 465 | return $jobs ? count($jobs) : 0; |
| 468 | 466 | } |
@@ -478,7 +476,7 @@ discard block |
||
| 478 | 476 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 479 | 477 | * @return array/boolean db-rows / jobs as array or False if no matches |
| 480 | 478 | */ |
| 481 | - function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
|
| 479 | + function read($id = 0, $cols = '*', $offset = False, $append = 'ORDER BY async_next', $num_rows = 0) |
|
| 482 | 480 | { |
| 483 | 481 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
| 484 | 482 | |
@@ -486,7 +484,7 @@ discard block |
||
| 486 | 484 | { |
| 487 | 485 | $where = "async_id != '##last-check-run##'"; |
| 488 | 486 | } |
| 489 | - elseif (!is_array($id) && (strpos($id,'%') !== False || strpos($id,'_') !== False)) |
|
| 487 | + elseif (!is_array($id) && (strpos($id, '%') !== False || strpos($id, '_') !== False)) |
|
| 490 | 488 | { |
| 491 | 489 | $id = $this->db->quote($id); |
| 492 | 490 | $where = "async_id LIKE $id AND async_id != '##last-check-run##'"; |
@@ -500,21 +498,21 @@ discard block |
||
| 500 | 498 | $where = array('async_id' => $id); |
| 501 | 499 | } |
| 502 | 500 | $jobs = array(); |
| 503 | - foreach($this->db->select($this->db_table,$cols,$where,__LINE__,__FILE__,$offset,$append,False,$num_rows) as $row) |
|
| 501 | + foreach ($this->db->select($this->db_table, $cols, $where, __LINE__, __FILE__, $offset, $append, False, $num_rows) as $row) |
|
| 504 | 502 | { |
| 505 | 503 | $row['async_times'] = json_php_unserialize($row['async_times']); |
| 506 | 504 | // check for broken value during migration |
| 507 | 505 | if ($row['async_data'][0] == '"' && substr($row['async_data'], 0, 7) == '"\\"\\\\\\"') |
| 508 | 506 | { |
| 509 | 507 | $row['async_data'] = null; |
| 510 | - $this->write(Db::strip_array_keys($row,'async_'), true); |
|
| 508 | + $this->write(Db::strip_array_keys($row, 'async_'), true); |
|
| 511 | 509 | } |
| 512 | 510 | else |
| 513 | 511 | { |
| 514 | 512 | $row['async_data'] = !empty($row['async_data']) ? |
| 515 | - json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
| 513 | + json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
| 516 | 514 | } |
| 517 | - $jobs[$row['async_id']] = Db::strip_array_keys($row,'async_'); |
|
| 515 | + $jobs[$row['async_id']] = Db::strip_array_keys($row, 'async_'); |
|
| 518 | 516 | } |
| 519 | 517 | if (!count($jobs)) |
| 520 | 518 | { |
@@ -531,7 +529,7 @@ discard block |
||
| 531 | 529 | * @param array $where additional where statemetn to update only if a certain condition is met, used for the semaphore |
| 532 | 530 | * @return int affected rows, can be 0 if an additional where statement is given |
| 533 | 531 | */ |
| 534 | - function write($job, $exists = False, $where=array()) |
|
| 532 | + function write($job, $exists = False, $where = array()) |
|
| 535 | 533 | { |
| 536 | 534 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
| 537 | 535 | |
@@ -562,7 +560,7 @@ discard block |
||
| 562 | 560 | */ |
| 563 | 561 | function delete($id) |
| 564 | 562 | { |
| 565 | - $this->db->delete($this->db_table,array('async_id' => $id),__LINE__,__FILE__); |
|
| 563 | + $this->db->delete($this->db_table, array('async_id' => $id), __LINE__, __FILE__); |
|
| 566 | 564 | |
| 567 | 565 | return $this->db->affected_rows(); |
| 568 | 566 | } |
@@ -587,38 +585,38 @@ discard block |
||
| 587 | 585 | { |
| 588 | 586 | $binarys = array( |
| 589 | 587 | 'php' => '/usr/bin/php', |
| 590 | - 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
| 588 | + 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
| 591 | 589 | 'crontab' => '/usr/bin/crontab' |
| 592 | 590 | ); |
| 593 | 591 | foreach ($binarys as $name => $path) |
| 594 | 592 | { |
| 595 | - $this->$name = $path; // a reasonable default for *nix |
|
| 593 | + $this->$name = $path; // a reasonable default for *nix |
|
| 596 | 594 | |
| 597 | 595 | if (!($Ok = @is_executable($this->$name))) |
| 598 | 596 | { |
| 599 | 597 | if (file_exists($this->$name)) |
| 600 | 598 | { |
| 601 | - echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
|
| 599 | + echo '<p>'.lang('%1 is not executable by the webserver !!!', $this->$name)."</p>\n"; |
|
| 602 | 600 | $perms = fileperms($this->$name); |
| 603 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 601 | + if (!($perms&0x0001) && ($perms&0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 604 | 602 | { |
| 605 | 603 | $group = posix_getgrgid(filegroup($this->$name)); |
| 606 | - $webserver = posix_getpwuid(posix_getuid ()); |
|
| 607 | - echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
|
| 604 | + $webserver = posix_getpwuid(posix_getuid()); |
|
| 605 | + echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.", $webserver['name'], $group['name'])."</p>\n"; } |
|
| 608 | 606 | } |
| 609 | - if (($fd = popen('/bin/sh -c "type -p '.$name.'"','r'))) |
|
| 607 | + if (($fd = popen('/bin/sh -c "type -p '.$name.'"', 'r'))) |
|
| 610 | 608 | { |
| 611 | - $this->$name = fgets($fd,256); |
|
| 609 | + $this->$name = fgets($fd, 256); |
|
| 612 | 610 | @pclose($fd); |
| 613 | 611 | } |
| 614 | - if (($pos = strpos($this->$name,"\n"))) |
|
| 612 | + if (($pos = strpos($this->$name, "\n"))) |
|
| 615 | 613 | { |
| 616 | - $this->$name = substr($this->$name,0,$pos); |
|
| 614 | + $this->$name = substr($this->$name, 0, $pos); |
|
| 617 | 615 | } |
| 618 | 616 | } |
| 619 | 617 | if (!$Ok && !@is_executable($this->$name)) |
| 620 | 618 | { |
| 621 | - $this->$name = $name; // hopefully its in the path |
|
| 619 | + $this->$name = $name; // hopefully its in the path |
|
| 622 | 620 | } |
| 623 | 621 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
| 624 | 622 | } |
@@ -649,15 +647,15 @@ discard block |
||
| 649 | 647 | } |
| 650 | 648 | $times = False; |
| 651 | 649 | $this->other_cronlines = array(); |
| 652 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1','r')) !== False) |
|
| 650 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1', 'r')) !== False) |
|
| 653 | 651 | { |
| 654 | 652 | $n = 0; |
| 655 | - while ($line = fgets($crontab,256)) |
|
| 653 | + while ($line = fgets($crontab, 256)) |
|
| 656 | 654 | { |
| 657 | 655 | if ($this->debug) echo 'line '.++$n.": $line<br>\n"; |
| 658 | - $parts = explode(' ',$line,6); |
|
| 656 | + $parts = explode(' ', $line, 6); |
|
| 659 | 657 | |
| 660 | - if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
|
| 658 | + if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5], 0, 3) != 'php')) |
|
| 661 | 659 | { |
| 662 | 660 | // ignore comments |
| 663 | 661 | if ($line{0} != '#') |
@@ -665,12 +663,12 @@ discard block |
||
| 665 | 663 | $times['error'] .= $line; |
| 666 | 664 | } |
| 667 | 665 | } |
| 668 | - elseif (strpos($line,$this->cronline) !== False || |
|
| 666 | + elseif (strpos($line, $this->cronline) !== False || |
|
| 669 | 667 | // also check of old phpgwapi/cron path |
| 670 | 668 | strpos($line, str_replace('/api/', '/phpgwapi/cron/', $this->cronline)) !== False) |
| 671 | 669 | { |
| 672 | - $cron_units = array('min','hour','day','month','dow'); |
|
| 673 | - foreach($cron_units as $n => $u) |
|
| 670 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
| 671 | + foreach ($cron_units as $n => $u) |
|
| 674 | 672 | { |
| 675 | 673 | $times[$u] = $parts[$n]; |
| 676 | 674 | } |
@@ -701,29 +699,29 @@ discard block |
||
| 701 | 699 | if ($this->only_fallback && $times !== False) { |
| 702 | 700 | return 0; |
| 703 | 701 | } |
| 704 | - $this->installed(); // find other installed cronlines |
|
| 702 | + $this->installed(); // find other installed cronlines |
|
| 705 | 703 | |
| 706 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1','w')) !== False) |
|
| 704 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1', 'w')) !== False) |
|
| 707 | 705 | { |
| 708 | 706 | if (is_array($this->other_cronlines)) |
| 709 | 707 | { |
| 710 | 708 | foreach ($this->other_cronlines as $cronline) |
| 711 | 709 | { |
| 712 | - fwrite($crontab,$cronline); // preserv the other lines on install |
|
| 710 | + fwrite($crontab, $cronline); // preserv the other lines on install |
|
| 713 | 711 | } |
| 714 | 712 | } |
| 715 | 713 | if ($times !== False) |
| 716 | 714 | { |
| 717 | - $cron_units = array('min','hour','day','month','dow'); |
|
| 715 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
| 718 | 716 | $cronline = ''; |
| 719 | - foreach($cron_units as $cu) |
|
| 717 | + foreach ($cron_units as $cu) |
|
| 720 | 718 | { |
| 721 | - $cronline .= (isset($times[$cu]) ? $times[$cu] : '*') . ' '; |
|
| 719 | + $cronline .= (isset($times[$cu]) ? $times[$cu] : '*').' '; |
|
| 722 | 720 | } |
| 723 | 721 | // -d memory_limit=-1 --> no memory limit |
| 724 | 722 | $cronline .= $this->php.' -q -d memory_limit=-1 '.$this->cronline."\n"; |
| 725 | 723 | //echo "<p>Installing: '$cronline'</p>\n"; |
| 726 | - fwrite($crontab,$cronline); |
|
| 724 | + fwrite($crontab, $cronline); |
|
| 727 | 725 | } |
| 728 | 726 | @pclose($crontab); |
| 729 | 727 | } |
@@ -114,7 +114,8 @@ discard block |
||
| 114 | 114 | echo "<p>next_run("; print_r($times); echo ",'$debug', " . date('Y-m-d H:i', $now) . ")</p>\n"; |
| 115 | 115 | $debug = True; // enable syntax-error messages too |
| 116 | 116 | } |
| 117 | - if(is_null($now)) { |
|
| 117 | + if(is_null($now)) |
|
| 118 | + { |
|
| 118 | 119 | $now = time(); |
| 119 | 120 | } |
| 120 | 121 | |
@@ -179,12 +180,17 @@ discard block |
||
| 179 | 180 | foreach($units as $u => $date_pattern) |
| 180 | 181 | { |
| 181 | 182 | ++$n; |
| 182 | - if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 183 | + if ($this->debug) |
|
| 184 | + { |
|
| 185 | +echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 183 | 186 | if (isset($times[$u])) |
| 184 | 187 | { |
| 185 | - if(is_array($times[$u])) { |
|
| 188 | + if(is_array($times[$u])) |
|
| 189 | + { |
|
| 186 | 190 | $time = array_keys($times[$u]); |
| 187 | - } else { |
|
| 191 | + } |
|
| 192 | + else |
|
| 193 | + { |
|
| 188 | 194 | $time = explode(',',$times[$u]); |
| 189 | 195 | } |
| 190 | 196 | $times[$u] = array(); |
@@ -197,7 +203,10 @@ discard block |
||
| 197 | 203 | |
| 198 | 204 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
| 199 | 205 | { |
| 200 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'</p>\n"; |
|
| 206 | + if ($debug) |
|
| 207 | + { |
|
| 208 | + echo "<p>Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'</p>\n"; |
|
| 209 | + } |
|
| 201 | 210 | |
| 202 | 211 | return False; |
| 203 | 212 | } |
@@ -208,14 +217,20 @@ discard block |
||
| 208 | 217 | } |
| 209 | 218 | else |
| 210 | 219 | { |
| 211 | - if ((string)$t == '*') $t = '*/1'; |
|
| 220 | + if ((string)$t == '*') |
|
| 221 | + { |
|
| 222 | + $t = '*/1'; |
|
| 223 | + } |
|
| 212 | 224 | |
| 213 | 225 | list($one,$inc) = $arr = explode('/',$t); |
| 214 | 226 | |
| 215 | 227 | if (!(is_numeric($one) && count($arr) == 1 || |
| 216 | 228 | count($arr) == 2 && is_numeric($inc))) |
| 217 | 229 | { |
| 218 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'</p>\n"; |
|
| 230 | + if ($debug) |
|
| 231 | + { |
|
| 232 | + echo "<p>Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'</p>\n"; |
|
| 233 | + } |
|
| 219 | 234 | |
| 220 | 235 | return False; |
| 221 | 236 | } |
@@ -233,7 +248,10 @@ discard block |
||
| 233 | 248 | } |
| 234 | 249 | elseif (count($arr) != 2 || $min > $max) |
| 235 | 250 | { |
| 236 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'</p>\n"; |
|
| 251 | + if ($debug) |
|
| 252 | + { |
|
| 253 | + echo "<p>Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'</p>\n"; |
|
| 254 | + } |
|
| 237 | 255 | return False; |
| 238 | 256 | } |
| 239 | 257 | for ($i = $min; $i <= $max; $i += $inc) |
@@ -244,9 +262,13 @@ discard block |
||
| 244 | 262 | } |
| 245 | 263 | } |
| 246 | 264 | } |
| 247 | - elseif ($n < $last_set || $u == 'dow') // before last value set (or dow) => empty gets enumerated |
|
| 265 | + elseif ($n < $last_set || $u == 'dow') |
|
| 266 | + { |
|
| 267 | + // before last value set (or dow) => empty gets enumerated |
|
| 248 | 268 | { |
| 249 | - for ($i = $min_unit[$u]; $i <= $max_unit[$u]; ++$i) |
|
| 269 | + for ($i = $min_unit[$u]; |
|
| 270 | + } |
|
| 271 | + $i <= $max_unit[$u]; ++$i) |
|
| 250 | 272 | { |
| 251 | 273 | $times[$u][$i] = True; |
| 252 | 274 | } |
@@ -256,7 +278,9 @@ discard block |
||
| 256 | 278 | $times[$u][$min_unit[$u]] = True; |
| 257 | 279 | } |
| 258 | 280 | } |
| 259 | - if ($this->debug) { echo "enumerated times=<pre>"; print_r($times); echo "</pre>\n"; } |
|
| 281 | + if ($this->debug) |
|
| 282 | + { |
|
| 283 | +echo "enumerated times=<pre>"; print_r($times); echo "</pre>\n"; } |
|
| 260 | 284 | |
| 261 | 285 | // now we have the times enumerated, lets find the first not expired one |
| 262 | 286 | // |
@@ -274,7 +298,10 @@ discard block |
||
| 274 | 298 | if (isset($found[$u])) |
| 275 | 299 | { |
| 276 | 300 | $future = $future || $found[$u] > $unit_now; |
| 277 | - if ($this->debug) echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
|
| 301 | + if ($this->debug) |
|
| 302 | + { |
|
| 303 | + echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
|
| 304 | + } |
|
| 278 | 305 | continue; // already set |
| 279 | 306 | } |
| 280 | 307 | foreach(array_keys($times[$u]) as $unit_value) |
@@ -292,30 +319,44 @@ discard block |
||
| 292 | 319 | break; |
| 293 | 320 | |
| 294 | 321 | } |
| 295 | - if ($valid && ($u != $next || $unit_value > $over)) // valid and not over |
|
| 322 | + if ($valid && ($u != $next || $unit_value > $over)) |
|
| 323 | + { |
|
| 324 | + // valid and not over |
|
| 296 | 325 | { |
| 297 | 326 | $found[$u] = $unit_value; |
| 327 | + } |
|
| 298 | 328 | $future = $future || $unit_value > $unit_now; |
| 299 | 329 | break; |
| 300 | 330 | } |
| 301 | 331 | } |
| 302 | - if (!isset($found[$u])) // we have to try the next one, if it exists |
|
| 332 | + if (!isset($found[$u])) |
|
| 333 | + { |
|
| 334 | + // we have to try the next one, if it exists |
|
| 303 | 335 | { |
| 304 | 336 | $nexts = array_keys($units); |
| 337 | + } |
|
| 305 | 338 | if (!isset($nexts[count($found)-1])) |
| 306 | 339 | { |
| 307 | - if ($this->debug) echo "<p>Nothing found, exiting !!!</p>\n"; |
|
| 340 | + if ($this->debug) |
|
| 341 | + { |
|
| 342 | + echo "<p>Nothing found, exiting !!!</p>\n"; |
|
| 343 | + } |
|
| 308 | 344 | return False; |
| 309 | 345 | } |
| 310 | 346 | $next = $nexts[count($found)-1]; |
| 311 | 347 | $over = $found[$next]; |
| 312 | 348 | unset($found[$next]); |
| 313 | - if ($this->debug) echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
|
| 349 | + if ($this->debug) |
|
| 350 | + { |
|
| 351 | + echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
|
| 352 | + } |
|
| 314 | 353 | break; |
| 315 | 354 | } |
| 316 | 355 | } |
| 317 | 356 | } |
| 318 | - if ($this->debug) { echo "<p>next="; print_r($found); echo "</p>\n"; } |
|
| 357 | + if ($this->debug) |
|
| 358 | + { |
|
| 359 | +echo "<p>next="; print_r($found); echo "</p>\n"; } |
|
| 319 | 360 | |
| 320 | 361 | return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
| 321 | 362 | } |
@@ -377,7 +418,10 @@ discard block |
||
| 377 | 418 | ); |
| 378 | 419 | // as the async_next column is used as a semaphore we only update it, |
| 379 | 420 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
| 380 | - if ($exists) $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 421 | + if ($exists) |
|
| 422 | + { |
|
| 423 | + $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 424 | + } |
|
| 381 | 425 | } |
| 382 | 426 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
| 383 | 427 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -388,7 +432,10 @@ discard block |
||
| 388 | 432 | */ |
| 389 | 433 | function check_run($run_by='') |
| 390 | 434 | { |
| 391 | - if ($run_by === 'fallback') flush(); |
|
| 435 | + if ($run_by === 'fallback') |
|
| 436 | + { |
|
| 437 | + flush(); |
|
| 438 | + } |
|
| 392 | 439 | |
| 393 | 440 | if (!$this->last_check_run(True,False,$run_by)) |
| 394 | 441 | { |
@@ -410,7 +457,10 @@ discard block |
||
| 410 | 457 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
| 411 | 458 | foreach($GLOBALS as $name => $value) |
| 412 | 459 | { |
| 413 | - if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
|
| 460 | + if ($name !== 'egw' && is_object($value)) |
|
| 461 | + { |
|
| 462 | + unset($GLOBALS[$name]); |
|
| 463 | + } |
|
| 414 | 464 | } |
| 415 | 465 | $domain = $GLOBALS['egw_info']['user']['domain']; |
| 416 | 466 | $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; |
@@ -480,7 +530,10 @@ discard block |
||
| 480 | 530 | */ |
| 481 | 531 | function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
| 482 | 532 | { |
| 483 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
|
| 533 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
| 534 | + { |
|
| 535 | + return false; |
|
| 536 | + } |
|
| 484 | 537 | |
| 485 | 538 | if ($id === '%') |
| 486 | 539 | { |
@@ -533,9 +586,15 @@ discard block |
||
| 533 | 586 | */ |
| 534 | 587 | function write($job, $exists = False, $where=array()) |
| 535 | 588 | { |
| 536 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
|
| 589 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
| 590 | + { |
|
| 591 | + return 0; |
|
| 592 | + } |
|
| 537 | 593 | |
| 538 | - if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) $job['data']['next'] = $job['next']; |
|
| 594 | + if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) |
|
| 595 | + { |
|
| 596 | + $job['data']['next'] = $job['next']; |
|
| 597 | + } |
|
| 539 | 598 | $data = array( |
| 540 | 599 | 'async_next' => $job['next'], |
| 541 | 600 | 'async_times' => json_encode($job['times']), |
@@ -600,9 +659,12 @@ discard block |
||
| 600 | 659 | { |
| 601 | 660 | echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
| 602 | 661 | $perms = fileperms($this->$name); |
| 603 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 662 | + if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) |
|
| 663 | + { |
|
| 664 | + // only executable by group |
|
| 604 | 665 | { |
| 605 | 666 | $group = posix_getgrgid(filegroup($this->$name)); |
| 667 | + } |
|
| 606 | 668 | $webserver = posix_getpwuid(posix_getuid ()); |
| 607 | 669 | echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
| 608 | 670 | } |
@@ -622,10 +684,13 @@ discard block |
||
| 622 | 684 | } |
| 623 | 685 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
| 624 | 686 | } |
| 625 | - if ($this->php5[0] == '/') // we found a php5 binary |
|
| 687 | + if ($this->php5[0] == '/') |
|
| 688 | + { |
|
| 689 | + // we found a php5 binary |
|
| 626 | 690 | { |
| 627 | 691 | $this->php = $this->php5; |
| 628 | 692 | } |
| 693 | + } |
|
| 629 | 694 | } |
| 630 | 695 | } |
| 631 | 696 | |
@@ -637,7 +702,8 @@ discard block |
||
| 637 | 702 | */ |
| 638 | 703 | function installed() |
| 639 | 704 | { |
| 640 | - if ($this->only_fallback) { |
|
| 705 | + if ($this->only_fallback) |
|
| 706 | + { |
|
| 641 | 707 | return 0; |
| 642 | 708 | } |
| 643 | 709 | $this->find_binarys(); |
@@ -654,7 +720,10 @@ discard block |
||
| 654 | 720 | $n = 0; |
| 655 | 721 | while ($line = fgets($crontab,256)) |
| 656 | 722 | { |
| 657 | - if ($this->debug) echo 'line '.++$n.": $line<br>\n"; |
|
| 723 | + if ($this->debug) |
|
| 724 | + { |
|
| 725 | + echo 'line '.++$n.": $line<br>\n"; |
|
| 726 | + } |
|
| 658 | 727 | $parts = explode(' ',$line,6); |
| 659 | 728 | |
| 660 | 729 | if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
@@ -698,7 +767,8 @@ discard block |
||
| 698 | 767 | */ |
| 699 | 768 | function install($times) |
| 700 | 769 | { |
| 701 | - if ($this->only_fallback && $times !== False) { |
|
| 770 | + if ($this->only_fallback && $times !== False) |
|
| 771 | + { |
|
| 702 | 772 | return 0; |
| 703 | 773 | } |
| 704 | 774 | $this->installed(); // find other installed cronlines |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * check if users are supposed to change their password every x sdays, then check if password is of old age |
| 85 | 85 | * or the devil-admin reset the users password and forced the user to change his password on next login. |
| 86 | 86 | * |
| 87 | - * @param string& $message =null on return false: message why password needs to be changed |
|
| 88 | - * @return boolean true: all good, false: password change required, null: password expires in N days |
|
| 87 | + * @param string $message =null on return false: message why password needs to be changed |
|
| 88 | + * @return boolean|null true: all good, false: password change required, null: password expires in N days |
|
| 89 | 89 | */ |
| 90 | 90 | static function check_password_change(&$message=null) |
| 91 | 91 | { |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * uses the encryption type set in setup and calls the appropriate encryption functions |
| 296 | 296 | * |
| 297 | - * @param $password password to encrypt |
|
| 297 | + * @param string $password password to encrypt |
|
| 298 | 298 | */ |
| 299 | 299 | static function encrypt_password($password,$sql=False) |
| 300 | 300 | { |
@@ -406,6 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $form_val user input value for comparison |
| 407 | 407 | * @param string $db_val stored value / hash (from database) |
| 408 | 408 | * @param string &$type detected crypt type on return |
| 409 | + * @param string $type |
|
| 409 | 410 | * @return boolean True on successful comparison |
| 410 | 411 | */ |
| 411 | 412 | static function crypt_compare($form_val, $db_val, &$type) |
@@ -618,7 +619,7 @@ discard block |
||
| 618 | 619 | * @param string $forbid_name =null if "yes" username or full-name split by delimiters AND longer then 3 chars are |
| 619 | 620 | * forbidden to be included in password, default to whatever set in config for "passwd_forbid_name" |
| 620 | 621 | * @param array|int $account =null array with account_lid and account_fullname or account_id for $forbid_name check |
| 621 | - * @return mixed false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
|
| 622 | + * @return string|false false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
|
| 622 | 623 | */ |
| 623 | 624 | static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
| 624 | 625 | { |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @param string $db_val stored value / hash (from database) |
| 408 | 408 | * @param string &$type detected crypt type on return |
| 409 | 409 | * @return boolean True on successful comparison |
| 410 | - */ |
|
| 410 | + */ |
|
| 411 | 411 | static function crypt_compare($form_val, $db_val, &$type) |
| 412 | 412 | { |
| 413 | 413 | // detect type of hash by salt part of $db_val |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | * @param string $form_val user input value for comparison |
| 707 | 707 | * @param string $db_val stored value (from database) |
| 708 | 708 | * @return boolean True on successful comparison |
| 709 | - */ |
|
| 709 | + */ |
|
| 710 | 710 | static function smd5_compare($form_val,$db_val) |
| 711 | 711 | { |
| 712 | 712 | /* Start with the first char after {SMD5} */ |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | * @param string $form_val user input value for comparison |
| 729 | 729 | * @param string $db_val stored value (from database) |
| 730 | 730 | * @return boolean True on successful comparison |
| 731 | - */ |
|
| 731 | + */ |
|
| 732 | 732 | static function sha_compare($form_val,$db_val) |
| 733 | 733 | { |
| 734 | 734 | /* Start with the first char after {SHA} */ |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * @param string $form_val user input value for comparison |
| 746 | 746 | * @param string $db_val stored value (from database) |
| 747 | 747 | * @return boolean True on successful comparison |
| 748 | - */ |
|
| 748 | + */ |
|
| 749 | 749 | static function ssha_compare($form_val,$db_val) |
| 750 | 750 | { |
| 751 | 751 | /* Start with the first char after {SSHA} */ |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $GLOBALS['egw_info']['server']['auth_type'] = $GLOBALS['egw_info']['server']['auth_type_'.$GLOBALS['egw_info']['flags']['currentapp']]; |
| 22 | 22 | } |
| 23 | -if(empty($GLOBALS['egw_info']['server']['auth_type'])) |
|
| 23 | +if (empty($GLOBALS['egw_info']['server']['auth_type'])) |
|
| 24 | 24 | { |
| 25 | 25 | $GLOBALS['egw_info']['server']['auth_type'] = 'sql'; |
| 26 | 26 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param Backend $type =null |
| 62 | 62 | */ |
| 63 | - static function backend($type=null) |
|
| 63 | + static function backend($type = null) |
|
| 64 | 64 | { |
| 65 | 65 | if (is_null($type)) $type = $GLOBALS['egw_info']['server']['auth_type']; |
| 66 | 66 | |
@@ -87,29 +87,29 @@ discard block |
||
| 87 | 87 | * @param string& $message =null on return false: message why password needs to be changed |
| 88 | 88 | * @return boolean true: all good, false: password change required, null: password expires in N days |
| 89 | 89 | */ |
| 90 | - static function check_password_change(&$message=null) |
|
| 90 | + static function check_password_change(&$message = null) |
|
| 91 | 91 | { |
| 92 | 92 | // dont check anything for anonymous sessions/ users that are flagged as anonymous |
| 93 | 93 | if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') return true; |
| 94 | 94 | |
| 95 | 95 | // some statics (and initialisation to make information and timecalculation a) more readable in conditions b) persistent per request |
| 96 | 96 | // if user has to be warned about an upcomming passwordchange, remember for the session, that he was informed |
| 97 | - static $UserKnowsAboutPwdChange=null; |
|
| 98 | - if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
| 97 | + static $UserKnowsAboutPwdChange = null; |
|
| 98 | + if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange = & Cache::getSession('phpgwapi', 'auth_UserKnowsAboutPwdChange'); |
|
| 99 | 99 | |
| 100 | 100 | // retrieve the timestamp regarding the last change of the password from auth system and store it with the session |
| 101 | - static $alpwchange_val=null; |
|
| 102 | - static $pwdTsChecked=null; |
|
| 101 | + static $alpwchange_val = null; |
|
| 102 | + static $pwdTsChecked = null; |
|
| 103 | 103 | if (is_null($pwdTsChecked) && is_null($alpwchange_val) || (string)$alpwchange_val === '0') |
| 104 | 104 | { |
| 105 | - $alpwchange_val =& Cache::getSession('phpgwapi','auth_alpwchange_val'); // set that one with the session stored value |
|
| 105 | + $alpwchange_val = & Cache::getSession('phpgwapi', 'auth_alpwchange_val'); // set that one with the session stored value |
|
| 106 | 106 | // initalize statics - better readability of conditions |
| 107 | 107 | if (is_null($alpwchange_val) || (string)$alpwchange_val === '0') |
| 108 | 108 | { |
| 109 | 109 | $backend = self::backend(); |
| 110 | 110 | // this may change behavior, as it should detect forced PasswordChanges from your Authentication System too. |
| 111 | 111 | // on the other side, if your auth system does not require an forcedPasswordChange, you will not be asked. |
| 112 | - if (method_exists($backend,'getLastPwdChange')) |
|
| 112 | + if (method_exists($backend, 'getLastPwdChange')) |
|
| 113 | 113 | { |
| 114 | 114 | $alpwchange_val = $backend->getLastPwdChange($GLOBALS['egw']->session->account_lid); |
| 115 | 115 | $pwdTsChecked = true; |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | //error_log(__METHOD__.__LINE__.'#'.$alpwchange_val.'# is null:'.is_null($alpwchange_val).'# is empty:'.empty($alpwchange_val).'# is set:'.isset($alpwchange_val)); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - static $passwordAgeBorder=null; |
|
| 127 | - static $daysLeftUntilChangeReq=null; |
|
| 126 | + static $passwordAgeBorder = null; |
|
| 127 | + static $daysLeftUntilChangeReq = null; |
|
| 128 | 128 | |
| 129 | 129 | // if neither timestamp isset return true, nothing to do (exept this means the password is too old) |
| 130 | 130 | if (is_null($alpwchange_val) && |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | if (is_null($passwordAgeBorder) && $GLOBALS['egw_info']['server']['change_pwd_every_x_days']) |
| 136 | 136 | { |
| 137 | - $passwordAgeBorder = (DateTime::to('now','ts')-($GLOBALS['egw_info']['server']['change_pwd_every_x_days']*86400)); |
|
| 137 | + $passwordAgeBorder = (DateTime::to('now', 'ts') - ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] * 86400)); |
|
| 138 | 138 | } |
| 139 | 139 | if (is_null($daysLeftUntilChangeReq) && $GLOBALS['egw_info']['server']['warn_about_upcoming_pwd_change']) |
| 140 | 140 | { |
| 141 | 141 | // maxage - passwordage = days left until change is required |
| 142 | - $daysLeftUntilChangeReq = ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] - ((DateTime::to('now','ts')-($alpwchange_val?$alpwchange_val:0))/86400)); |
|
| 142 | + $daysLeftUntilChangeReq = ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] - ((DateTime::to('now', 'ts') - ($alpwchange_val ? $alpwchange_val : 0)) / 86400)); |
|
| 143 | 143 | } |
| 144 | - if ($alpwchange_val == 0 || // admin requested password change |
|
| 145 | - $passwordAgeBorder > $alpwchange_val || // change password every N days policy requests change |
|
| 144 | + if ($alpwchange_val == 0 || // admin requested password change |
|
| 145 | + $passwordAgeBorder > $alpwchange_val || // change password every N days policy requests change |
|
| 146 | 146 | // user should be warned N days in advance about change and is not yet |
| 147 | 147 | $GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && |
| 148 | 148 | $GLOBALS['egw_info']['user']['apps']['preferences'] && |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | error_log(__METHOD__.' Password of '.$GLOBALS['egw_info']['user']['account_lid'].' ('.$GLOBALS['egw_info']['user']['account_fullname'].') is of old age.'.array2string(array( |
| 160 | 160 | 'ts'=> $alpwchange_val, |
| 161 | 161 | 'date'=>DateTime::to($alpwchange_val)))); |
| 162 | - $message = lang('It has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']); |
|
| 162 | + $message = lang('It has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']); |
|
| 163 | 163 | } |
| 164 | 164 | else |
| 165 | 165 | { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | $UserKnowsAboutPwdChange = true; |
| 172 | 172 | } |
| 173 | - $message = lang('Your password is about to expire in %1 days, you may change your password now',round($daysLeftUntilChangeReq)); |
|
| 173 | + $message = lang('Your password is about to expire in %1 days, you may change your password now', round($daysLeftUntilChangeReq)); |
|
| 174 | 174 | // user has no rights to change password --> do NOT warn, as only forced check ignores rights |
| 175 | 175 | if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) return true; |
| 176 | 176 | return null; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | function getLastPwdChange($username) |
| 190 | 190 | { |
| 191 | - if (method_exists($this->backend,'getLastPwdChange')) |
|
| 191 | + if (method_exists($this->backend, 'getLastPwdChange')) |
|
| 192 | 192 | { |
| 193 | 193 | return $this->backend->getLastPwdChange($username); |
| 194 | 194 | } |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | * @param int $lastpwdchange must be a unixtimestamp |
| 204 | 204 | * @return boolean true if account_lastpwd_change successful changed, false otherwise |
| 205 | 205 | */ |
| 206 | - function setLastPwdChange($account_id=0, $passwd=NULL, $lastpwdchange=NULL) |
|
| 206 | + function setLastPwdChange($account_id = 0, $passwd = NULL, $lastpwdchange = NULL) |
|
| 207 | 207 | { |
| 208 | - if (method_exists($this->backend,'setLastPwdChange')) |
|
| 208 | + if (method_exists($this->backend, 'setLastPwdChange')) |
|
| 209 | 209 | { |
| 210 | 210 | return $this->backend->setLastPwdChange($account_id, $passwd, $lastpwdchange); |
| 211 | 211 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
| 221 | 221 | * @return boolean true if successful authenticated, false otherwise |
| 222 | 222 | */ |
| 223 | - function authenticate($username, $passwd, $passwd_type='text') |
|
| 223 | + function authenticate($username, $passwd, $passwd_type = 'text') |
|
| 224 | 224 | { |
| 225 | 225 | return $this->backend->authenticate($username, $passwd, $passwd_type); |
| 226 | 226 | } |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | * @throws Exception from backends having extra requirements |
| 236 | 236 | * @return boolean true if password successful changed, false otherwise |
| 237 | 237 | */ |
| 238 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
| 238 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
| 239 | 239 | { |
| 240 | - if (($err = self::crackcheck($new_passwd,null,null,null,$account_id))) |
|
| 240 | + if (($err = self::crackcheck($new_passwd, null, null, null, $account_id))) |
|
| 241 | 241 | { |
| 242 | 242 | throw new Exception\WrongUserinput($err); |
| 243 | 243 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | // need to change current users password in session |
| 249 | 249 | Cache::setSession('phpgwapi', 'password', base64_encode($new_passwd)); |
| 250 | 250 | $GLOBALS['egw_info']['user']['passwd'] = $new_passwd; |
| 251 | - $GLOBALS['egw_info']['user']['account_lastpwd_change'] = DateTime::to('now','ts'); |
|
| 251 | + $GLOBALS['egw_info']['user']['account_lastpwd_change'] = DateTime::to('now', 'ts'); |
|
| 252 | 252 | // invalidate EGroupware session, as password is stored in egw_info in session |
| 253 | 253 | Egw::invalidate_session_cache(); |
| 254 | 254 | } |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | 'old_passwd' => $old_passwd, |
| 261 | 261 | 'new_passwd' => $new_passwd, |
| 262 | 262 | ); |
| 263 | - Hooks::process($GLOBALS['hook_values']+array( |
|
| 263 | + Hooks::process($GLOBALS['hook_values'] + array( |
|
| 264 | 264 | 'location' => 'changepassword' |
| 265 | - ),False,True); // called for every app now, not only enabled ones) |
|
| 265 | + ), False, True); // called for every app now, not only enabled ones) |
|
| 266 | 266 | } |
| 267 | 267 | return $ret; |
| 268 | 268 | } |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | static function randomstring($size) |
| 276 | 276 | { |
| 277 | 277 | static $random_char = array( |
| 278 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
| 279 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
| 280 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
| 281 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' |
|
| 278 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
| 279 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
| 280 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
| 281 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' |
|
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | $s = ''; |
| 285 | - for ($i=0; $i<$size; $i++) |
|
| 285 | + for ($i = 0; $i < $size; $i++) |
|
| 286 | 286 | { |
| 287 | - $s .= $random_char[mt_rand(1,61)]; |
|
| 287 | + $s .= $random_char[mt_rand(1, 61)]; |
|
| 288 | 288 | } |
| 289 | 289 | return $s; |
| 290 | 290 | } |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @param $password password to encrypt |
| 298 | 298 | */ |
| 299 | - static function encrypt_password($password,$sql=False) |
|
| 299 | + static function encrypt_password($password, $sql = False) |
|
| 300 | 300 | { |
| 301 | - if($sql) |
|
| 301 | + if ($sql) |
|
| 302 | 302 | { |
| 303 | 303 | return self::encrypt_sql($password); |
| 304 | 304 | } |
@@ -317,21 +317,21 @@ discard block |
||
| 317 | 317 | * @param string &$type =null on return detected type of hash |
| 318 | 318 | * @return boolean |
| 319 | 319 | */ |
| 320 | - static function compare_password($cleartext, $encrypted, $type_in, $username='', &$type=null) |
|
| 320 | + static function compare_password($cleartext, $encrypted, $type_in, $username = '', &$type = null) |
|
| 321 | 321 | { |
| 322 | 322 | // allow to specify the hash type to prefix the hash, to easy migrate passwords from ldap |
| 323 | 323 | $type = $type_in; |
| 324 | 324 | $saved_enc = $encrypted; |
| 325 | 325 | $matches = null; |
| 326 | - if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i',$encrypted,$matches)) |
|
| 326 | + if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i', $encrypted, $matches)) |
|
| 327 | 327 | { |
| 328 | 328 | $type = strtolower($matches[1]); |
| 329 | 329 | $encrypted = $matches[2]; |
| 330 | 330 | |
| 331 | - switch($type) // some hashs are specially "packed" in ldap |
|
| 331 | + switch ($type) // some hashs are specially "packed" in ldap |
|
| 332 | 332 | { |
| 333 | 333 | case 'md5': |
| 334 | - $encrypted = implode('',unpack('H*',base64_decode($encrypted))); |
|
| 334 | + $encrypted = implode('', unpack('H*', base64_decode($encrypted))); |
|
| 335 | 335 | break; |
| 336 | 336 | case 'plain': |
| 337 | 337 | case 'crypt': |
@@ -342,24 +342,24 @@ discard block |
||
| 342 | 342 | break; |
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | - elseif($encrypted[0] == '$') |
|
| 345 | + elseif ($encrypted[0] == '$') |
|
| 346 | 346 | { |
| 347 | 347 | $type = 'crypt'; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - switch($type) |
|
| 350 | + switch ($type) |
|
| 351 | 351 | { |
| 352 | 352 | case 'plain': |
| 353 | 353 | $ret = $cleartext === $encrypted; |
| 354 | 354 | break; |
| 355 | 355 | case 'smd5': |
| 356 | - $ret = self::smd5_compare($cleartext,$encrypted); |
|
| 356 | + $ret = self::smd5_compare($cleartext, $encrypted); |
|
| 357 | 357 | break; |
| 358 | 358 | case 'sha': |
| 359 | - $ret = self::sha_compare($cleartext,$encrypted); |
|
| 359 | + $ret = self::sha_compare($cleartext, $encrypted); |
|
| 360 | 360 | break; |
| 361 | 361 | case 'ssha': |
| 362 | - $ret = self::ssha_compare($cleartext,$encrypted); |
|
| 362 | + $ret = self::ssha_compare($cleartext, $encrypted); |
|
| 363 | 363 | break; |
| 364 | 364 | case 'crypt': |
| 365 | 365 | case 'des': |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $ret = self::crypt_compare($cleartext, $encrypted, $type); |
| 373 | 373 | break; |
| 374 | 374 | case 'md5_hmac': |
| 375 | - $ret = self::md5_hmac_compare($cleartext,$encrypted,$username); |
|
| 375 | + $ret = self::md5_hmac_compare($cleartext, $encrypted, $username); |
|
| 376 | 376 | break; |
| 377 | 377 | default: |
| 378 | 378 | $type = 'md5'; |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | 'ext_crypt' => array('CRYPT_EXT_DES', '_J9..', 4, ''), |
| 396 | 396 | 'md5_crypt' => array('CRYPT_MD5', '$1$', 8, '$'), |
| 397 | 397 | //'old_blowfish_crypt' => array('CRYPT_BLOWFISH', '$2$', 13, ''), // old blowfish hash not in line with php.net docu, but could be in use |
| 398 | - 'blowfish_crypt' => array('CRYPT_BLOWFISH', '$2a$12$', 22, ''), // $2a$12$ = 2^12 = 4096 rounds |
|
| 399 | - 'sha256_crypt' => array('CRYPT_SHA256', '$5$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
| 400 | - 'sha512_crypt' => array('CRYPT_SHA512', '$6$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
| 398 | + 'blowfish_crypt' => array('CRYPT_BLOWFISH', '$2a$12$', 22, ''), // $2a$12$ = 2^12 = 4096 rounds |
|
| 399 | + 'sha256_crypt' => array('CRYPT_SHA256', '$5$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
| 400 | + 'sha512_crypt' => array('CRYPT_SHA512', '$6$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
| 401 | 401 | ); |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -412,17 +412,17 @@ discard block |
||
| 412 | 412 | { |
| 413 | 413 | // detect type of hash by salt part of $db_val |
| 414 | 414 | list($first, $dollar, $salt, $salt2) = explode('$', $db_val); |
| 415 | - foreach(self::$crypt_params as $type => $params) |
|
| 415 | + foreach (self::$crypt_params as $type => $params) |
|
| 416 | 416 | { |
| 417 | 417 | list(,$prefix, $random, $postfix) = $params; |
| 418 | 418 | list(,$d) = explode('$', $prefix); |
| 419 | 419 | if ($dollar === $d || !$dollar && ($first[0] === $prefix[0] || $first[0] !== '_' && !$prefix)) |
| 420 | 420 | { |
| 421 | - $len = !$postfix ? strlen($prefix)+$random : strlen($prefix.$salt.$postfix); |
|
| 421 | + $len = !$postfix ? strlen($prefix) + $random : strlen($prefix.$salt.$postfix); |
|
| 422 | 422 | // sha(256|512) might contain options, explicit $rounds=N$ prefix in salt |
| 423 | 423 | if (($type == 'sha256_crypt' || $type == 'sha512_crypt') && substr($salt, 0, 7) === 'rounds=') |
| 424 | 424 | { |
| 425 | - $len += strlen($salt2)+1; |
|
| 425 | + $len += strlen($salt2) + 1; |
|
| 426 | 426 | } |
| 427 | 427 | break; |
| 428 | 428 | } |
@@ -444,12 +444,12 @@ discard block |
||
| 444 | 444 | * @param string $type =null default to $GLOBALS['egw_info']['server']['ldap_encryption_type'] |
| 445 | 445 | * @return string |
| 446 | 446 | */ |
| 447 | - static function encrypt_ldap($password, $type=null) |
|
| 447 | + static function encrypt_ldap($password, $type = null) |
|
| 448 | 448 | { |
| 449 | 449 | if (is_null($type)) $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
| 450 | 450 | |
| 451 | 451 | $salt = ''; |
| 452 | - switch(strtolower($type)) |
|
| 452 | + switch (strtolower($type)) |
|
| 453 | 453 | { |
| 454 | 454 | default: // eg. setup >> config never saved |
| 455 | 455 | case 'des': |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | case 'md5_crypt': |
| 464 | 464 | case 'ext_crypt': |
| 465 | 465 | list($const, $prefix, $len, $postfix) = self::$crypt_params[$type]; |
| 466 | - if(defined($const) && constant($const) == 1) |
|
| 466 | + if (defined($const) && constant($const) == 1) |
|
| 467 | 467 | { |
| 468 | 468 | $salt = $prefix.self::randomstring($len).$postfix; |
| 469 | 469 | $e_password = '{crypt}'.crypt($password, $salt); |
@@ -476,20 +476,20 @@ discard block |
||
| 476 | 476 | /* New method taken from the openldap-software list as recommended by |
| 477 | 477 | * Kervin L. Pierre" <[email protected]> |
| 478 | 478 | */ |
| 479 | - $e_password = '{md5}' . base64_encode(pack("H*",md5($password))); |
|
| 479 | + $e_password = '{md5}'.base64_encode(pack("H*", md5($password))); |
|
| 480 | 480 | break; |
| 481 | 481 | case 'smd5': |
| 482 | 482 | $salt = self::randomstring(16); |
| 483 | - $hash = md5($password . $salt, true); |
|
| 484 | - $e_password = '{SMD5}' . base64_encode($hash . $salt); |
|
| 483 | + $hash = md5($password.$salt, true); |
|
| 484 | + $e_password = '{SMD5}'.base64_encode($hash.$salt); |
|
| 485 | 485 | break; |
| 486 | 486 | case 'sha': |
| 487 | - $e_password = '{SHA}' . base64_encode(sha1($password,true)); |
|
| 487 | + $e_password = '{SHA}'.base64_encode(sha1($password, true)); |
|
| 488 | 488 | break; |
| 489 | 489 | case 'ssha': |
| 490 | 490 | $salt = self::randomstring(16); |
| 491 | - $hash = sha1($password . $salt, true); |
|
| 492 | - $e_password = '{SSHA}' . base64_encode($hash . $salt); |
|
| 491 | + $hash = sha1($password.$salt, true); |
|
| 492 | + $e_password = '{SSHA}'.base64_encode($hash.$salt); |
|
| 493 | 493 | break; |
| 494 | 494 | case 'plain': |
| 495 | 495 | // if plain no type is prepended |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @param string $type =null default $GLOBALS['egw_info']['server']['sql_encryption_type'] |
| 508 | 508 | * @return string hash |
| 509 | 509 | */ |
| 510 | - static function encrypt_sql($password, $type=null) |
|
| 510 | + static function encrypt_sql($password, $type = null) |
|
| 511 | 511 | { |
| 512 | 512 | /* Grab configured type, or default to md5() (old method) */ |
| 513 | 513 | if (is_null($type)) |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $type = @$GLOBALS['egw_info']['server']['sql_encryption_type'] ? |
| 516 | 516 | strtolower($GLOBALS['egw_info']['server']['sql_encryption_type']) : 'md5'; |
| 517 | 517 | } |
| 518 | - switch($type) |
|
| 518 | + switch ($type) |
|
| 519 | 519 | { |
| 520 | 520 | case 'plain': |
| 521 | 521 | // since md5 is the default, type plain must be prepended, for eGroupware to understand |
@@ -557,28 +557,28 @@ discard block |
||
| 557 | 557 | * @param string &$securest =null on return securest available hash |
| 558 | 558 | * @return array hash => label |
| 559 | 559 | */ |
| 560 | - public static function passwdhashes(&$securest=null) |
|
| 560 | + public static function passwdhashes(&$securest = null) |
|
| 561 | 561 | { |
| 562 | 562 | $hashes = array(); |
| 563 | 563 | |
| 564 | 564 | /* Check for available crypt methods based on what is defined by php */ |
| 565 | - if(defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
| 565 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
| 566 | 566 | { |
| 567 | 567 | $hashes['blowfish_crypt'] = 'blowfish_crypt'; |
| 568 | 568 | } |
| 569 | - if(defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) |
|
| 569 | + if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) |
|
| 570 | 570 | { |
| 571 | 571 | $hashes['sha512_crypt'] = 'sha512_crypt'; |
| 572 | 572 | } |
| 573 | - if(defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) |
|
| 573 | + if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) |
|
| 574 | 574 | { |
| 575 | 575 | $hashes['sha256_crypt'] = 'sha256_crypt'; |
| 576 | 576 | } |
| 577 | - if(defined('CRYPT_MD5') && CRYPT_MD5 == 1) |
|
| 577 | + if (defined('CRYPT_MD5') && CRYPT_MD5 == 1) |
|
| 578 | 578 | { |
| 579 | 579 | $hashes['md5_crypt'] = 'md5_crypt'; |
| 580 | 580 | } |
| 581 | - if(defined('CRYPT_EXT_DES') && CRYPT_EXT_DES == 1) |
|
| 581 | + if (defined('CRYPT_EXT_DES') && CRYPT_EXT_DES == 1) |
|
| 582 | 582 | { |
| 583 | 583 | $hashes['ext_crypt'] = 'ext_crypt'; |
| 584 | 584 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | 'smd5' => 'smd5', |
| 588 | 588 | 'sha' => 'sha', |
| 589 | 589 | ); |
| 590 | - if(@defined('CRYPT_STD_DES') && CRYPT_STD_DES == 1) |
|
| 590 | + if (@defined('CRYPT_STD_DES') && CRYPT_STD_DES == 1) |
|
| 591 | 591 | { |
| 592 | 592 | $hashes['crypt'] = 'crypt'; |
| 593 | 593 | } |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | * @param array|int $account =null array with account_lid and account_fullname or account_id for $forbid_name check |
| 621 | 621 | * @return mixed false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
| 622 | 622 | */ |
| 623 | - static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
|
| 623 | + static function crackcheck($passwd, $reqstrength = null, $minlength = null, $forbid_name = null, $account = null) |
|
| 624 | 624 | { |
| 625 | 625 | if (!isset($reqstrength)) $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
| 626 | 626 | if (!isset($minlength)) $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
@@ -634,11 +634,11 @@ discard block |
||
| 634 | 634 | { |
| 635 | 635 | if (!isset($reqstrength) || $reqstrength == 5) |
| 636 | 636 | { |
| 637 | - Config::save_value('force_pwd_strength', $reqstrength=4, 'phpgwapi'); |
|
| 637 | + Config::save_value('force_pwd_strength', $reqstrength = 4, 'phpgwapi'); |
|
| 638 | 638 | } |
| 639 | 639 | if (!isset($minlength)) |
| 640 | 640 | { |
| 641 | - Config::save_value('force_pwd_length', $minlength=7, 'phpgwapi'); |
|
| 641 | + Config::save_value('force_pwd_length', $minlength = 7, 'phpgwapi'); |
|
| 642 | 642 | } |
| 643 | 643 | Config::save_value('check_save_passwd', null, 'phpgwapi'); |
| 644 | 644 | } |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | throw new Exception\WrongParameter('crackcheck(..., forbid_name=true, account) requires account-data!'); |
| 658 | 658 | } |
| 659 | 659 | $parts = preg_split("/[,._ \t0-9-]+/", $account['account_fullname'].','.$account['account_lid']); |
| 660 | - foreach($parts as $part) |
|
| 660 | + foreach ($parts as $part) |
|
| 661 | 661 | { |
| 662 | 662 | if (strlen($part) > 2 && stripos($passwd, $part) !== false) |
| 663 | 663 | { |
@@ -670,15 +670,15 @@ discard block |
||
| 670 | 670 | if ($reqstrength) |
| 671 | 671 | { |
| 672 | 672 | $missing = array(); |
| 673 | - if (!preg_match('/(.*\d.*){'. ($non=1). ',}/',$passwd)) |
|
| 673 | + if (!preg_match('/(.*\d.*){'.($non = 1).',}/', $passwd)) |
|
| 674 | 674 | { |
| 675 | 675 | $missing[] = lang('numbers'); |
| 676 | 676 | } |
| 677 | - if (!preg_match('/(.*[[:upper:]].*){'. ($nou=1). ',}/',$passwd)) |
|
| 677 | + if (!preg_match('/(.*[[:upper:]].*){'.($nou = 1).',}/', $passwd)) |
|
| 678 | 678 | { |
| 679 | 679 | $missing[] = lang('uppercase letters'); |
| 680 | 680 | } |
| 681 | - if (!preg_match('/(.*[[:lower:]].*){'. ($nol=1). ',}/',$passwd)) |
|
| 681 | + if (!preg_match('/(.*[[:lower:]].*){'.($nol = 1).',}/', $passwd)) |
|
| 682 | 682 | { |
| 683 | 683 | $missing[] = lang('lowercase letters'); |
| 684 | 684 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | if (4 - count($missing) < $reqstrength) |
| 690 | 690 | { |
| 691 | 691 | $errors[] = lang('password contains only %1 of required %2 character classes: no %3', |
| 692 | - 4-count($missing), $reqstrength, implode(', ', $missing)); |
|
| 692 | + 4 - count($missing), $reqstrength, implode(', ', $missing)); |
|
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | if ($errors) |
@@ -707,19 +707,19 @@ discard block |
||
| 707 | 707 | * @param string $db_val stored value (from database) |
| 708 | 708 | * @return boolean True on successful comparison |
| 709 | 709 | */ |
| 710 | - static function smd5_compare($form_val,$db_val) |
|
| 710 | + static function smd5_compare($form_val, $db_val) |
|
| 711 | 711 | { |
| 712 | 712 | /* Start with the first char after {SMD5} */ |
| 713 | - $hash = base64_decode(substr($db_val,6)); |
|
| 713 | + $hash = base64_decode(substr($db_val, 6)); |
|
| 714 | 714 | |
| 715 | 715 | /* SMD5 hashes are 16 bytes long */ |
| 716 | - $orig_hash = cut_bytes($hash, 0, 16); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
| 716 | + $orig_hash = cut_bytes($hash, 0, 16); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
| 717 | 717 | $salt = cut_bytes($hash, 16); |
| 718 | 718 | |
| 719 | - $new_hash = md5($form_val . $salt,true); |
|
| 719 | + $new_hash = md5($form_val.$salt, true); |
|
| 720 | 720 | //echo '<br> DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash); |
| 721 | 721 | |
| 722 | - return strcmp($orig_hash,$new_hash) == 0; |
|
| 722 | + return strcmp($orig_hash, $new_hash) == 0; |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
@@ -729,14 +729,14 @@ discard block |
||
| 729 | 729 | * @param string $db_val stored value (from database) |
| 730 | 730 | * @return boolean True on successful comparison |
| 731 | 731 | */ |
| 732 | - static function sha_compare($form_val,$db_val) |
|
| 732 | + static function sha_compare($form_val, $db_val) |
|
| 733 | 733 | { |
| 734 | 734 | /* Start with the first char after {SHA} */ |
| 735 | - $hash = base64_decode(substr($db_val,5)); |
|
| 736 | - $new_hash = sha1($form_val,true); |
|
| 735 | + $hash = base64_decode(substr($db_val, 5)); |
|
| 736 | + $new_hash = sha1($form_val, true); |
|
| 737 | 737 | //echo '<br> DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash); |
| 738 | 738 | |
| 739 | - return strcmp($hash,$new_hash) == 0; |
|
| 739 | + return strcmp($hash, $new_hash) == 0; |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | /** |
@@ -746,18 +746,18 @@ discard block |
||
| 746 | 746 | * @param string $db_val stored value (from database) |
| 747 | 747 | * @return boolean True on successful comparison |
| 748 | 748 | */ |
| 749 | - static function ssha_compare($form_val,$db_val) |
|
| 749 | + static function ssha_compare($form_val, $db_val) |
|
| 750 | 750 | { |
| 751 | 751 | /* Start with the first char after {SSHA} */ |
| 752 | 752 | $hash = base64_decode(substr($db_val, 6)); |
| 753 | 753 | |
| 754 | 754 | // SHA-1 hashes are 160 bits long |
| 755 | - $orig_hash = cut_bytes($hash, 0, 20); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
| 755 | + $orig_hash = cut_bytes($hash, 0, 20); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
| 756 | 756 | $salt = cut_bytes($hash, 20); |
| 757 | - $new_hash = sha1($form_val . $salt,true); |
|
| 757 | + $new_hash = sha1($form_val.$salt, true); |
|
| 758 | 758 | |
| 759 | 759 | //error_log(__METHOD__."('$form_val', '$db_val') hash='$hash', orig_hash='$orig_hash', salt='$salt', new_hash='$new_hash' returning ".array2string(strcmp($orig_hash,$new_hash) == 0)); |
| 760 | - return strcmp($orig_hash,$new_hash) == 0; |
|
| 760 | + return strcmp($orig_hash, $new_hash) == 0; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
@@ -768,11 +768,11 @@ discard block |
||
| 768 | 768 | * @param string $_key key for md5_hmac-encryption (username for imported smf users) |
| 769 | 769 | * @return boolean True on successful comparison |
| 770 | 770 | */ |
| 771 | - static function md5_hmac_compare($form_val,$db_val,$_key) |
|
| 771 | + static function md5_hmac_compare($form_val, $db_val, $_key) |
|
| 772 | 772 | { |
| 773 | 773 | $key = str_pad(strlen($_key) <= 64 ? $_key : pack('H*', md5($_key)), 64, chr(0x00)); |
| 774 | - $md5_hmac = md5(($key ^ str_repeat(chr(0x5c), 64)) . pack('H*', md5(($key ^ str_repeat(chr(0x36), 64)). $form_val))); |
|
| 774 | + $md5_hmac = md5(($key^str_repeat(chr(0x5c), 64)).pack('H*', md5(($key^str_repeat(chr(0x36), 64)).$form_val))); |
|
| 775 | 775 | |
| 776 | - return strcmp($md5_hmac,$db_val) == 0; |
|
| 776 | + return strcmp($md5_hmac, $db_val) == 0; |
|
| 777 | 777 | } |
| 778 | 778 | } |
@@ -62,7 +62,10 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | static function backend($type=null) |
| 64 | 64 | { |
| 65 | - if (is_null($type)) $type = $GLOBALS['egw_info']['server']['auth_type']; |
|
| 65 | + if (is_null($type)) |
|
| 66 | + { |
|
| 67 | + $type = $GLOBALS['egw_info']['server']['auth_type']; |
|
| 68 | + } |
|
| 66 | 69 | |
| 67 | 70 | $backend_class = __CLASS__.'\\'.ucfirst($type); |
| 68 | 71 | |
@@ -90,12 +93,18 @@ discard block |
||
| 90 | 93 | static function check_password_change(&$message=null) |
| 91 | 94 | { |
| 92 | 95 | // dont check anything for anonymous sessions/ users that are flagged as anonymous |
| 93 | - if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') return true; |
|
| 96 | + if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') |
|
| 97 | + { |
|
| 98 | + return true; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // some statics (and initialisation to make information and timecalculation a) more readable in conditions b) persistent per request |
| 96 | 102 | // if user has to be warned about an upcomming passwordchange, remember for the session, that he was informed |
| 97 | 103 | static $UserKnowsAboutPwdChange=null; |
| 98 | - if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
| 104 | + if (is_null($UserKnowsAboutPwdChange)) |
|
| 105 | + { |
|
| 106 | + $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
| 107 | + } |
|
| 99 | 108 | |
| 100 | 109 | // retrieve the timestamp regarding the last change of the password from auth system and store it with the session |
| 101 | 110 | static $alpwchange_val=null; |
@@ -172,7 +181,10 @@ discard block |
||
| 172 | 181 | } |
| 173 | 182 | $message = lang('Your password is about to expire in %1 days, you may change your password now',round($daysLeftUntilChangeReq)); |
| 174 | 183 | // user has no rights to change password --> do NOT warn, as only forced check ignores rights |
| 175 | - if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) return true; |
|
| 184 | + if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) |
|
| 185 | + { |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 176 | 188 | return null; |
| 177 | 189 | } |
| 178 | 190 | return false; |
@@ -446,7 +458,10 @@ discard block |
||
| 446 | 458 | */ |
| 447 | 459 | static function encrypt_ldap($password, $type=null) |
| 448 | 460 | { |
| 449 | - if (is_null($type)) $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
|
| 461 | + if (is_null($type)) |
|
| 462 | + { |
|
| 463 | + $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
|
| 464 | + } |
|
| 450 | 465 | |
| 451 | 466 | $salt = ''; |
| 452 | 467 | switch(strtolower($type)) |
@@ -622,9 +637,18 @@ discard block |
||
| 622 | 637 | */ |
| 623 | 638 | static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
| 624 | 639 | { |
| 625 | - if (!isset($reqstrength)) $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
|
| 626 | - if (!isset($minlength)) $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
|
| 627 | - if (!isset($forbid_name)) $forbid_name = $GLOBALS['egw_info']['server']['passwd_forbid_name']; |
|
| 640 | + if (!isset($reqstrength)) |
|
| 641 | + { |
|
| 642 | + $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
|
| 643 | + } |
|
| 644 | + if (!isset($minlength)) |
|
| 645 | + { |
|
| 646 | + $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
|
| 647 | + } |
|
| 648 | + if (!isset($forbid_name)) |
|
| 649 | + { |
|
| 650 | + $forbid_name = $GLOBALS['egw_info']['server']['passwd_forbid_name']; |
|
| 651 | + } |
|
| 628 | 652 | |
| 629 | 653 | // load preferences translations, as changepassword get's called from admin too |
| 630 | 654 | Translation::add_app('preferences'); |
@@ -311,6 +311,8 @@ discard block |
||
| 311 | 311 | * @param string $path |
| 312 | 312 | * @param array &$dav |
| 313 | 313 | * @param array &$allow |
| 314 | + * @param integer[] $dav |
|
| 315 | + * @param boolean $allow |
|
| 314 | 316 | */ |
| 315 | 317 | function OPTIONS($path, &$dav, &$allow) |
| 316 | 318 | { |
@@ -606,7 +608,7 @@ discard block |
||
| 606 | 608 | * @param string $path / or /<username>/ |
| 607 | 609 | * @param int $user |
| 608 | 610 | * @param int $depth |
| 609 | - * @return string|boolean http status or true|false |
|
| 611 | + * @return boolean http status or true|false |
|
| 610 | 612 | */ |
| 611 | 613 | protected function add_home(array &$files, $path, $user, $depth) |
| 612 | 614 | { |
@@ -738,7 +740,7 @@ discard block |
||
| 738 | 740 | * @param string $path /<username>/ |
| 739 | 741 | * @param int $app |
| 740 | 742 | * @param int $user |
| 741 | - * @return string|boolean http status or true|false |
|
| 743 | + * @return boolean http status or true|false |
|
| 742 | 744 | */ |
| 743 | 745 | protected function add_shared(array &$files, $path, $app, $user) |
| 744 | 746 | { |
@@ -1380,7 +1382,7 @@ discard block |
||
| 1380 | 1382 | * @param int|string $id |
| 1381 | 1383 | * @param array $attach array of array with values for keys 'name', 'params', 'value' |
| 1382 | 1384 | * @param boolean $delete_via_put |
| 1383 | - * @return boolean false on error, eg. invalid managed id, for false an xml-error body has been send |
|
| 1385 | + * @return null|false false on error, eg. invalid managed id, for false an xml-error body has been send |
|
| 1384 | 1386 | */ |
| 1385 | 1387 | public static function handle_attach($app, $id, $attach, $delete_via_put=false) |
| 1386 | 1388 | { |
@@ -1584,7 +1586,7 @@ discard block |
||
| 1584 | 1586 | * @param string $managed_id |
| 1585 | 1587 | * @param string $app =null app-name to check against path |
| 1586 | 1588 | * @param string|int $id =null id to check agains path |
| 1587 | - * @return string|boolean "/apps/$app/$id/something" or false if not found or not belonging to given $app/$id |
|
| 1589 | + * @return false|string "/apps/$app/$id/something" or false if not found or not belonging to given $app/$id |
|
| 1588 | 1590 | */ |
| 1589 | 1591 | static public function managed_id2path($managed_id, $app=null, $id=null) |
| 1590 | 1592 | { |
@@ -1783,7 +1785,7 @@ discard block |
||
| 1783 | 1785 | * MKCOL method handler |
| 1784 | 1786 | * |
| 1785 | 1787 | * @param array general parameter passing array |
| 1786 | - * @return bool true on success |
|
| 1788 | + * @return string true on success |
|
| 1787 | 1789 | */ |
| 1788 | 1790 | function MKCOL($options) |
| 1789 | 1791 | { |
@@ -1796,7 +1798,7 @@ discard block |
||
| 1796 | 1798 | * MOVE method handler |
| 1797 | 1799 | * |
| 1798 | 1800 | * @param array general parameter passing array |
| 1799 | - * @return bool true on success |
|
| 1801 | + * @return string true on success |
|
| 1800 | 1802 | */ |
| 1801 | 1803 | function MOVE($options) |
| 1802 | 1804 | { |
@@ -1809,7 +1811,7 @@ discard block |
||
| 1809 | 1811 | * COPY method handler |
| 1810 | 1812 | * |
| 1811 | 1813 | * @param array general parameter passing array |
| 1812 | - * @return bool true on success |
|
| 1814 | + * @return string true on success |
|
| 1813 | 1815 | */ |
| 1814 | 1816 | function COPY($options, $del=false) |
| 1815 | 1817 | { |
@@ -1822,7 +1824,7 @@ discard block |
||
| 1822 | 1824 | * LOCK method handler |
| 1823 | 1825 | * |
| 1824 | 1826 | * @param array general parameter passing array |
| 1825 | - * @return bool true on success |
|
| 1827 | + * @return string|boolean true on success |
|
| 1826 | 1828 | */ |
| 1827 | 1829 | function LOCK(&$options) |
| 1828 | 1830 | { |
@@ -1856,7 +1858,7 @@ discard block |
||
| 1856 | 1858 | * UNLOCK method handler |
| 1857 | 1859 | * |
| 1858 | 1860 | * @param array general parameter passing array |
| 1859 | - * @return bool true on success |
|
| 1861 | + * @return string true on success |
|
| 1860 | 1862 | */ |
| 1861 | 1863 | function UNLOCK(&$options) |
| 1862 | 1864 | { |
@@ -222,11 +222,20 @@ discard block |
||
| 222 | 222 | function __construct() |
| 223 | 223 | { |
| 224 | 224 | // log which CalDAVTester test is currently running, set as User-Agent header |
| 225 | - if (substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'scripts/tests/') error_log('****** '.$_SERVER['HTTP_USER_AGENT']); |
|
| 225 | + if (substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'scripts/tests/') |
|
| 226 | + { |
|
| 227 | + error_log('****** '.$_SERVER['HTTP_USER_AGENT']); |
|
| 228 | + } |
|
| 226 | 229 | |
| 227 | - if (!$this->debug) $this->debug = (int)$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']; |
|
| 230 | + if (!$this->debug) |
|
| 231 | + { |
|
| 232 | + $this->debug = (int)$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']; |
|
| 233 | + } |
|
| 228 | 234 | |
| 229 | - if ($this->debug > 2) error_log('groupdav: $_SERVER='.array2string($_SERVER)); |
|
| 235 | + if ($this->debug > 2) |
|
| 236 | + { |
|
| 237 | + error_log('groupdav: $_SERVER='.array2string($_SERVER)); |
|
| 238 | + } |
|
| 230 | 239 | |
| 231 | 240 | // setting our own exception handler, to be able to still log the requests |
| 232 | 241 | set_exception_handler(array(__CLASS__,'exception_handler')); |
@@ -254,7 +263,10 @@ discard block |
||
| 254 | 263 | $this->crrnd = true; // Older Apple Addressbook.app does not cope with namespace redundancy |
| 255 | 264 | break; |
| 256 | 265 | } |
| 257 | - if ($this->debug) error_log(__METHOD__."() HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]' --> '$agent' --> client_requires_href_as_url=$this->client_require_href_as_url, crrnd(client refuses redundand namespace declarations)=$this->crrnd"); |
|
| 266 | + if ($this->debug) |
|
| 267 | + { |
|
| 268 | + error_log(__METHOD__."() HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]' --> '$agent' --> client_requires_href_as_url=$this->client_require_href_as_url, crrnd(client refuses redundand namespace declarations)=$this->crrnd"); |
|
| 269 | + } |
|
| 258 | 270 | |
| 259 | 271 | // adding EGroupware version to X-Dav-Powered-By header eg. "EGroupware 1.8.001 CalDAV/CardDAV/GroupDAV server" |
| 260 | 272 | $this->dav_powered_by = str_replace('EGroupware','EGroupware '.$GLOBALS['egw_info']['server']['versions']['phpgwapi'], |
@@ -300,7 +312,10 @@ discard block |
||
| 300 | 312 | */ |
| 301 | 313 | function app_handler($app) |
| 302 | 314 | { |
| 303 | - if (isset($this->root[$app]['app'])) $app = $this->root[$app]['app']; |
|
| 315 | + if (isset($this->root[$app]['app'])) |
|
| 316 | + { |
|
| 317 | + $app = $this->root[$app]['app']; |
|
| 318 | + } |
|
| 304 | 319 | |
| 305 | 320 | return Handler::app_handler($app,$this); |
| 306 | 321 | } |
@@ -317,22 +332,34 @@ discard block |
||
| 317 | 332 | unset($allow); // not used, but required by function signature |
| 318 | 333 | |
| 319 | 334 | // locking support |
| 320 | - if (!in_array('2', $dav)) $dav[] = '2'; |
|
| 335 | + if (!in_array('2', $dav)) |
|
| 336 | + { |
|
| 337 | + $dav[] = '2'; |
|
| 338 | + } |
|
| 321 | 339 | |
| 322 | - if (preg_match('#/(calendar(-[^/]+)?|inbox|outbox)/#', $path)) // eg. /<username>/calendar-<otheruser>/ |
|
| 340 | + if (preg_match('#/(calendar(-[^/]+)?|inbox|outbox)/#', $path)) |
|
| 341 | + { |
|
| 342 | + // eg. /<username>/calendar-<otheruser>/ |
|
| 323 | 343 | { |
| 324 | 344 | $app = 'calendar'; |
| 325 | 345 | } |
| 326 | - elseif (preg_match('#/addressbook(-[^/]+)?/#', $path)) // eg. /<username>/addressbook-<otheruser>/ |
|
| 346 | + } |
|
| 347 | + elseif (preg_match('#/addressbook(-[^/]+)?/#', $path)) |
|
| 348 | + { |
|
| 349 | + // eg. /<username>/addressbook-<otheruser>/ |
|
| 327 | 350 | { |
| 328 | 351 | $app = 'addressbook'; |
| 329 | 352 | } |
| 353 | + } |
|
| 330 | 354 | // CalDAV and CardDAV |
| 331 | 355 | $dav[] = 'access-control'; |
| 332 | 356 | |
| 333 | - if ($app !== 'addressbook') // CalDAV |
|
| 357 | + if ($app !== 'addressbook') |
|
| 358 | + { |
|
| 359 | + // CalDAV |
|
| 334 | 360 | { |
| 335 | 361 | $dav[] = 'calendar-access'; |
| 362 | + } |
|
| 336 | 363 | $dav[] = 'calendar-auto-schedule'; |
| 337 | 364 | $dav[] = 'calendar-proxy'; |
| 338 | 365 | // required by iOS iCal to use principal-property-search to autocomplete participants (and locations) |
@@ -349,9 +376,13 @@ discard block |
||
| 349 | 376 | //$dav[] = 'calendarserver-sharing'; |
| 350 | 377 | //$dav[] = 'calendarserver-sharing-no-scheduling'; |
| 351 | 378 | } |
| 352 | - if ($app !== 'calendar') // CardDAV |
|
| 379 | + if ($app !== 'calendar') |
|
| 353 | 380 | { |
| 354 | - $dav[] = 'addressbook'; // CardDAV uses "addressbook" NOT "addressbook-access" |
|
| 381 | + // CardDAV |
|
| 382 | + { |
|
| 383 | + $dav[] = 'addressbook'; |
|
| 384 | + } |
|
| 385 | + // CardDAV uses "addressbook" NOT "addressbook-access" |
|
| 355 | 386 | } |
| 356 | 387 | //error_log(__METHOD__."('$path') --> app='$app' --> DAV: ".implode(', ', $dav)); |
| 357 | 388 | } |
@@ -365,7 +396,10 @@ discard block |
||
| 365 | 396 | */ |
| 366 | 397 | function PROPFIND(&$options, &$files, $method='PROPFIND') |
| 367 | 398 | { |
| 368 | - if ($this->debug) error_log(__CLASS__."::$method(".array2string($options).')'); |
|
| 399 | + if ($this->debug) |
|
| 400 | + { |
|
| 401 | + error_log(__CLASS__."::$method(".array2string($options).')'); |
|
| 402 | + } |
|
| 369 | 403 | |
| 370 | 404 | // make options (readonly) available to all class methods, eg. prop_requested |
| 371 | 405 | $this->propfind_options = $options; |
@@ -374,18 +408,27 @@ discard block |
||
| 374 | 408 | $id = $app = $user = $user_prefix = null; |
| 375 | 409 | if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user && $user !== 0) |
| 376 | 410 | { |
| 377 | - if ($this->debug > 1) error_log(__CLASS__."::$method: user='$user', app='$app', id='$id': 404 not found!"); |
|
| 411 | + if ($this->debug > 1) |
|
| 412 | + { |
|
| 413 | + error_log(__CLASS__."::$method: user='$user', app='$app', id='$id': 404 not found!"); |
|
| 414 | + } |
|
| 378 | 415 | return '404 Not Found'; |
| 379 | 416 | } |
| 380 | - if ($this->debug > 1) error_log(__CLASS__."::$method(path='$options[path]'): user='$user', user_prefix='$user_prefix', app='$app', id='$id'"); |
|
| 417 | + if ($this->debug > 1) |
|
| 418 | + { |
|
| 419 | + error_log(__CLASS__."::$method(path='$options[path]'): user='$user', user_prefix='$user_prefix', app='$app', id='$id'"); |
|
| 420 | + } |
|
| 381 | 421 | |
| 382 | 422 | $files = array('files' => array()); |
| 383 | 423 | $path = $user_prefix = $this->_slashify($user_prefix); |
| 384 | 424 | |
| 385 | - if (!$app) // user root folder containing apps |
|
| 425 | + if (!$app) |
|
| 426 | + { |
|
| 427 | + // user root folder containing apps |
|
| 386 | 428 | { |
| 387 | 429 | // add root with current users apps |
| 388 | 430 | $this->add_home($files, $path, $user, $options['depth']); |
| 431 | + } |
|
| 389 | 432 | |
| 390 | 433 | if ($path == '/') |
| 391 | 434 | { |
@@ -417,16 +460,22 @@ discard block |
||
| 417 | 460 | } |
| 418 | 461 | if ($app != 'principals' && !isset($GLOBALS['egw_info']['user']['apps'][$this->root[$app]['app'] ? $this->root[$app]['app'] : $app])) |
| 419 | 462 | { |
| 420 | - if ($this->debug) error_log(__CLASS__."::$method(path=$options[path]) 403 Forbidden: no app rights for '$app'"); |
|
| 463 | + if ($this->debug) |
|
| 464 | + { |
|
| 465 | + error_log(__CLASS__."::$method(path=$options[path]) 403 Forbidden: no app rights for '$app'"); |
|
| 466 | + } |
|
| 421 | 467 | return "403 Forbidden: no app rights for '$app'"; // no rights for the given app |
| 422 | 468 | } |
| 423 | 469 | if (($handler = self::app_handler($app))) |
| 424 | 470 | { |
| 425 | - if ($method != 'REPORT' && !$id) // no self URL for REPORT requests (only PROPFIND) or propfinds on an id |
|
| 471 | + if ($method != 'REPORT' && !$id) |
|
| 472 | + { |
|
| 473 | + // no self URL for REPORT requests (only PROPFIND) or propfinds on an id |
|
| 426 | 474 | { |
| 427 | 475 | // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes |
| 428 | 476 | $files['files'][0] = $this->add_app($app,$app=='addressbook'&&$handler->get_agent()=='kde',$user, |
| 429 | 477 | $this->_slashify($options['path'])); |
| 478 | + } |
|
| 430 | 479 | |
| 431 | 480 | // Hack for iOS 5.0.1 addressbook to stop asking directory gateway permissions with depth != 0 |
| 432 | 481 | // values for depth are 0, 1, "infinit" or not set which has to be interpreted as "infinit" |
@@ -436,7 +485,11 @@ discard block |
||
| 436 | 485 | $this->log(__CLASS__."::$method(".array2string($options).') Enabling hack for iOS 5.0.1 addressbook: force Depth: 0 on PROPFIND for directory gateway!'); |
| 437 | 486 | return true; |
| 438 | 487 | } |
| 439 | - if (!$options['depth']) return true; // depth 0 --> show only the self url |
|
| 488 | + if (!$options['depth']) |
|
| 489 | + { |
|
| 490 | + return true; |
|
| 491 | + } |
|
| 492 | + // depth 0 --> show only the self url |
|
| 440 | 493 | } |
| 441 | 494 | return $handler->propfind($this->_slashify($options['path']),$options,$files,$user,$id); |
| 442 | 495 | } |
@@ -457,7 +510,10 @@ discard block |
||
| 457 | 510 | // resourcetype: collection |
| 458 | 511 | $props['resourcetype'][] = self::mkprop('collection',''); |
| 459 | 512 | |
| 460 | - if (!isset($props['getcontenttype'])) $props['getcontenttype'] = 'httpd/unix-directory'; |
|
| 513 | + if (!isset($props['getcontenttype'])) |
|
| 514 | + { |
|
| 515 | + $props['getcontenttype'] = 'httpd/unix-directory'; |
|
| 516 | + } |
|
| 461 | 517 | |
| 462 | 518 | return $this->add_resource($path, $props, $privileges, $supported_privileges); |
| 463 | 519 | } |
@@ -489,11 +545,17 @@ discard block |
||
| 489 | 545 | 'resourcetype' => '', |
| 490 | 546 | ) as $name => $default) |
| 491 | 547 | { |
| 492 | - if (!isset($props[$name])) $props[$name] = $default; |
|
| 548 | + if (!isset($props[$name])) |
|
| 549 | + { |
|
| 550 | + $props[$name] = $default; |
|
| 551 | + } |
|
| 493 | 552 | } |
| 494 | 553 | |
| 495 | 554 | // if requested add privileges |
| 496 | - if (is_null($supported_privileges)) $supported_privileges = $this->supported_privileges; |
|
| 555 | + if (is_null($supported_privileges)) |
|
| 556 | + { |
|
| 557 | + $supported_privileges = $this->supported_privileges; |
|
| 558 | + } |
|
| 497 | 559 | if ($this->prop_requested('current-user-privilege-set') === true) |
| 498 | 560 | { |
| 499 | 561 | foreach($privileges as $name) |
@@ -514,7 +576,10 @@ discard block |
||
| 514 | 576 | $props['owner'] = ''; |
| 515 | 577 | } |
| 516 | 578 | |
| 517 | - if ($this->debug > 1) error_log(__METHOD__."(path='$path', props=".array2string($props).')'); |
|
| 579 | + if ($this->debug > 1) |
|
| 580 | + { |
|
| 581 | + error_log(__METHOD__."(path='$path', props=".array2string($props).')'); |
|
| 582 | + } |
|
| 518 | 583 | |
| 519 | 584 | // convert simple associative properties to HTTP_WebDAV_Server ones |
| 520 | 585 | foreach($props as $name => &$prop) |
@@ -554,7 +619,10 @@ discard block |
||
| 554 | 619 | { |
| 555 | 620 | foreach($data as $name => $data) |
| 556 | 621 | { |
| 557 | - if ($name[0] == '*') continue; |
|
| 622 | + if ($name[0] == '*') |
|
| 623 | + { |
|
| 624 | + continue; |
|
| 625 | + } |
|
| 558 | 626 | if (is_array($data) && $data['*only*'] && strpos($path, $data['*only*']) === false) |
| 559 | 627 | { |
| 560 | 628 | continue; // wrong path |
@@ -668,8 +736,15 @@ discard block |
||
| 668 | 736 | { |
| 669 | 737 | foreach($this->root as $app => $data) |
| 670 | 738 | { |
| 671 | - if (!$GLOBALS['egw_info']['user']['apps'][$data['app'] ? $data['app'] : $app]) continue; // no rights for the given app |
|
| 672 | - if (!empty($data['user-only']) && ($path == '/' || $user < 0)) continue; |
|
| 739 | + if (!$GLOBALS['egw_info']['user']['apps'][$data['app'] ? $data['app'] : $app]) |
|
| 740 | + { |
|
| 741 | + continue; |
|
| 742 | + } |
|
| 743 | + // no rights for the given app |
|
| 744 | + if (!empty($data['user-only']) && ($path == '/' || $user < 0)) |
|
| 745 | + { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 673 | 748 | |
| 674 | 749 | $files['files'][] = $this->add_app($app,false,$user,$path.$app.'/'); |
| 675 | 750 | |
@@ -705,7 +780,10 @@ discard block |
||
| 705 | 780 | { |
| 706 | 781 | if (!isset($GLOBALS['egw_info']['user']['apps']['resources'])) |
| 707 | 782 | { |
| 708 | - if ($this->debug) error_log(__METHOD__."(path=$path) 403 Forbidden: no app rights for 'resources'"); |
|
| 783 | + if ($this->debug) |
|
| 784 | + { |
|
| 785 | + error_log(__METHOD__."(path=$path) 403 Forbidden: no app rights for 'resources'"); |
|
| 786 | + } |
|
| 709 | 787 | return "403 Forbidden: no app rights for 'resources'"; // no rights for the given app |
| 710 | 788 | } |
| 711 | 789 | list(,$what) = explode('/', $path); |
@@ -744,10 +822,13 @@ discard block |
||
| 744 | 822 | { |
| 745 | 823 | // currently only show shared calendars/addressbooks for current user and not in the root |
| 746 | 824 | if ($path == '/' || $user != $GLOBALS['egw_info']['user']['account_id'] || |
| 747 | - !isset($GLOBALS['egw_info']['user']['apps'][$app])) // also avoids principals, inbox and outbox |
|
| 825 | + !isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
| 826 | + { |
|
| 827 | + // also avoids principals, inbox and outbox |
|
| 748 | 828 | { |
| 749 | 829 | return true; |
| 750 | 830 | } |
| 831 | + } |
|
| 751 | 832 | $handler = $this->app_handler($app); |
| 752 | 833 | if (($shared = $handler->get_shared())) |
| 753 | 834 | { |
@@ -755,7 +836,10 @@ discard block |
||
| 755 | 836 | { |
| 756 | 837 | $file = $this->add_app($app,false,$id,$path.$owner.'/'); |
| 757 | 838 | // mark other users calendar as shared (iOS 5.0.1 AB does NOT display AB marked as shared!) |
| 758 | - if ($app == 'calendar') $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared',''); |
|
| 839 | + if ($app == 'calendar') |
|
| 840 | + { |
|
| 841 | + $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared',''); |
|
| 842 | + } |
|
| 759 | 843 | $files[] = $file; |
| 760 | 844 | } |
| 761 | 845 | } |
@@ -791,7 +875,10 @@ discard block |
||
| 791 | 875 | { |
| 792 | 876 | $name = $this->accounts->id2name($account,'account_fullname'); |
| 793 | 877 | } |
| 794 | - if (empty($name)) $name = '#'.$account; |
|
| 878 | + if (empty($name)) |
|
| 879 | + { |
|
| 880 | + $name = '#'.$account; |
|
| 881 | + } |
|
| 795 | 882 | } |
| 796 | 883 | return $name; |
| 797 | 884 | } |
@@ -807,7 +894,10 @@ discard block |
||
| 807 | 894 | */ |
| 808 | 895 | protected function add_app($app,$no_extra_types=false,$user=null,$path='/') |
| 809 | 896 | { |
| 810 | - if ($this->debug) error_log(__METHOD__."(app='$app', no_extra_types=$no_extra_types, user='$user', path='$path')"); |
|
| 897 | + if ($this->debug) |
|
| 898 | + { |
|
| 899 | + error_log(__METHOD__."(app='$app', no_extra_types=$no_extra_types, user='$user', path='$path')"); |
|
| 900 | + } |
|
| 811 | 901 | $user_preferences = $GLOBALS['egw_info']['user']['preferences']; |
| 812 | 902 | if (is_string($user) && $user[0] == 'r' && ($resource = Principals::read_resource(substr($user, 1)))) |
| 813 | 903 | { |
@@ -831,7 +921,10 @@ discard block |
||
| 831 | 921 | $account_lid = $GLOBALS['egw_info']['user']['account_lid']; |
| 832 | 922 | $principalType = 'users'; |
| 833 | 923 | } |
| 834 | - if (!isset($displayname)) $displayname = $this->account_name($user); |
|
| 924 | + if (!isset($displayname)) |
|
| 925 | + { |
|
| 926 | + $displayname = $this->account_name($user); |
|
| 927 | + } |
|
| 835 | 928 | |
| 836 | 929 | $props = array( |
| 837 | 930 | 'owner' => array(self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/')), |
@@ -864,10 +957,13 @@ discard block |
||
| 864 | 957 | |
| 865 | 958 | // rfc 5995 (Use POST to add members to WebDAV collections): we use collection path with add-member query param |
| 866 | 959 | // leaving it switched off, until further testing, because OS X iCal seem to ignore it and OS X Addressbook uses POST to full URL without ?add-member |
| 867 | - if ($app && !in_array($app,array('inbox','outbox','principals'))) // not on inbox, outbox or principals |
|
| 960 | + if ($app && !in_array($app,array('inbox','outbox','principals'))) |
|
| 961 | + { |
|
| 962 | + // not on inbox, outbox or principals |
|
| 868 | 963 | { |
| 869 | 964 | $props['add-member'][] = self::mkprop('href',$this->base_uri.$path.'?add-member'); |
| 870 | 965 | } |
| 966 | + } |
|
| 871 | 967 | |
| 872 | 968 | // add props modifyable via proppatch from client, eg. calendar-color, see self::$proppatch_props |
| 873 | 969 | $ns = null; |
@@ -961,7 +1057,10 @@ discard block |
||
| 961 | 1057 | */ |
| 962 | 1058 | function REPORT(&$options, &$files) |
| 963 | 1059 | { |
| 964 | - if ($this->debug > 1) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1060 | + if ($this->debug > 1) |
|
| 1061 | + { |
|
| 1062 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1063 | + } |
|
| 965 | 1064 | |
| 966 | 1065 | return $this->PROPFIND($options,$files,'REPORT'); |
| 967 | 1066 | } |
@@ -984,7 +1083,10 @@ discard block |
||
| 984 | 1083 | */ |
| 985 | 1084 | function GET(&$options) |
| 986 | 1085 | { |
| 987 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1086 | + if ($this->debug) |
|
| 1087 | + { |
|
| 1088 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1089 | + } |
|
| 988 | 1090 | |
| 989 | 1091 | $id = $app = $user = null; |
| 990 | 1092 | if (!$this->_parse_path($options['path'],$id,$app,$user) || $app == 'principals') |
@@ -1220,7 +1322,10 @@ discard block |
||
| 1220 | 1322 | $_GET['add-member'] = ''; // otherwise we give no Location header |
| 1221 | 1323 | return $this->PUT($options); |
| 1222 | 1324 | } |
| 1223 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1325 | + if ($this->debug) |
|
| 1326 | + { |
|
| 1327 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1328 | + } |
|
| 1224 | 1329 | |
| 1225 | 1330 | $id = $app = $user = null; |
| 1226 | 1331 | $this->_parse_path($options['path'],$id,$app,$user); |
@@ -1391,7 +1496,11 @@ discard block |
||
| 1391 | 1496 | error_log(__METHOD__."('$app', $id, ...) no rights to update attachments"); |
| 1392 | 1497 | return; // no rights --> nothing to do |
| 1393 | 1498 | } |
| 1394 | - if (!is_array($attach)) $attach = array(); // could be PEAR_Error if not set |
|
| 1499 | + if (!is_array($attach)) |
|
| 1500 | + { |
|
| 1501 | + $attach = array(); |
|
| 1502 | + } |
|
| 1503 | + // could be PEAR_Error if not set |
|
| 1395 | 1504 | |
| 1396 | 1505 | if ($delete_via_put) |
| 1397 | 1506 | { |
@@ -1436,7 +1545,11 @@ discard block |
||
| 1436 | 1545 | // reuse valid managed-id --> symlink attachment |
| 1437 | 1546 | if (Vfs::file_exists($link)) |
| 1438 | 1547 | { |
| 1439 | - if (Vfs::readlink($link) === $path) continue; // no need to recreate identical link |
|
| 1548 | + if (Vfs::readlink($link) === $path) |
|
| 1549 | + { |
|
| 1550 | + continue; |
|
| 1551 | + } |
|
| 1552 | + // no need to recreate identical link |
|
| 1440 | 1553 | Vfs::unlink($link); // symlink will fail, if $link exists |
| 1441 | 1554 | } |
| 1442 | 1555 | if (!Vfs::symlink($path, $link)) |
@@ -1476,7 +1589,11 @@ discard block |
||
| 1476 | 1589 | { |
| 1477 | 1590 | $filename = empty($_filename) ? 'attachment' : Vfs::basename($_filename); |
| 1478 | 1591 | |
| 1479 | - if (strpos($mime, ';')) list($mime) = explode(';', $mime); // in case it contains eg. charset info |
|
| 1592 | + if (strpos($mime, ';')) |
|
| 1593 | + { |
|
| 1594 | + list($mime) = explode(';', $mime); |
|
| 1595 | + } |
|
| 1596 | + // in case it contains eg. charset info |
|
| 1480 | 1597 | |
| 1481 | 1598 | $ext = !empty($mime) ? MimeMagic::mime2ext($mime) : ''; |
| 1482 | 1599 | |
@@ -1495,9 +1612,15 @@ discard block |
||
| 1495 | 1612 | for($i = 1; $i < 100; ++$i) |
| 1496 | 1613 | { |
| 1497 | 1614 | $path = Link::vfs_path($app, $id, $filename.($i > 1 ? '-'.$i : '').$ext, true); |
| 1498 | - if (!Vfs::stat($path)) break; |
|
| 1615 | + if (!Vfs::stat($path)) |
|
| 1616 | + { |
|
| 1617 | + break; |
|
| 1618 | + } |
|
| 1619 | + } |
|
| 1620 | + if ($i >= 100) |
|
| 1621 | + { |
|
| 1622 | + return null; |
|
| 1499 | 1623 | } |
| 1500 | - if ($i >= 100) return null; |
|
| 1501 | 1624 | |
| 1502 | 1625 | if (!Vfs::file_exists($dir = Vfs::dirname($path)) && !Vfs::mkdir($dir, 0777, STREAM_MKDIR_RECURSIVE)) |
| 1503 | 1626 | { |
@@ -1546,7 +1669,11 @@ discard block |
||
| 1546 | 1669 | // handle symlinks --> return target size and mime-type |
| 1547 | 1670 | if (($target = Vfs::readlink($path))) |
| 1548 | 1671 | { |
| 1549 | - if (!($stat = Vfs::stat($target))) continue; // broken or inaccessible symlink |
|
| 1672 | + if (!($stat = Vfs::stat($target))) |
|
| 1673 | + { |
|
| 1674 | + continue; |
|
| 1675 | + } |
|
| 1676 | + // broken or inaccessible symlink |
|
| 1550 | 1677 | |
| 1551 | 1678 | // check if target is in /apps, probably reused MANAGED-ID --> return it |
| 1552 | 1679 | if (substr($target, 0, 6) == '/apps/') |
@@ -1638,14 +1765,20 @@ discard block |
||
| 1638 | 1765 | */ |
| 1639 | 1766 | function PROPPATCH(&$options) |
| 1640 | 1767 | { |
| 1641 | - if ($this->debug) error_log(__METHOD__."(".array2string($options).')'); |
|
| 1768 | + if ($this->debug) |
|
| 1769 | + { |
|
| 1770 | + error_log(__METHOD__."(".array2string($options).')'); |
|
| 1771 | + } |
|
| 1642 | 1772 | |
| 1643 | 1773 | // parse path in form [/account_lid]/app[/more] |
| 1644 | 1774 | $id = $app = $user = $user_prefix = null; |
| 1645 | 1775 | self::_parse_path($options['path'],$id,$app,$user,$user_prefix); // allways returns false if eg. !$id |
| 1646 | 1776 | if ($app == 'principals' || $id || $options['path'] == '/') |
| 1647 | 1777 | { |
| 1648 | - if ($this->debug > 1) error_log(__METHOD__.": user='$user', app='$app', id='$id': 404 not found!"); |
|
| 1778 | + if ($this->debug > 1) |
|
| 1779 | + { |
|
| 1780 | + error_log(__METHOD__.": user='$user', app='$app', id='$id': 404 not found!"); |
|
| 1781 | + } |
|
| 1649 | 1782 | foreach($options['props'] as &$prop) |
| 1650 | 1783 | { |
| 1651 | 1784 | $prop['status'] = '403 Forbidden'; |
@@ -1670,11 +1803,14 @@ discard block |
||
| 1670 | 1803 | self::$proppatch_props[$prop['name']] == $prop['ns'] ? '' : ':'.$prop['ns']); |
| 1671 | 1804 | } |
| 1672 | 1805 | //error_log("preferences['user']['$app']['$name']=".array2string($GLOBALS['egw_info']['user']['preferences'][$app][$name]).($GLOBALS['egw_info']['user']['preferences'][$app][$name] !== $prop['val'] ? ' !== ':' === ')."prop['val']=".array2string($prop['val'])); |
| 1673 | - if ($GLOBALS['egw_info']['user']['preferences'][$app][$name] !== $prop['val']) // nothing to change otherwise |
|
| 1806 | + if ($GLOBALS['egw_info']['user']['preferences'][$app][$name] !== $prop['val']) |
|
| 1807 | + { |
|
| 1808 | + // nothing to change otherwise |
|
| 1674 | 1809 | { |
| 1675 | 1810 | if (isset($prop['val'])) |
| 1676 | 1811 | { |
| 1677 | 1812 | $GLOBALS['egw']->preferences->add($app, $name, $prop['val']); |
| 1813 | + } |
|
| 1678 | 1814 | } |
| 1679 | 1815 | else |
| 1680 | 1816 | { |
@@ -1726,7 +1862,10 @@ discard block |
||
| 1726 | 1862 | } |
| 1727 | 1863 | } |
| 1728 | 1864 | |
| 1729 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1865 | + if ($this->debug) |
|
| 1866 | + { |
|
| 1867 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1868 | + } |
|
| 1730 | 1869 | |
| 1731 | 1870 | $id = $app = $user = $prefix = null; |
| 1732 | 1871 | if (!$this->_parse_path($options['path'],$id,$app,$user,$prefix)) |
@@ -1738,7 +1877,10 @@ discard block |
||
| 1738 | 1877 | $status = $handler->put($options,$id,$user,$prefix); |
| 1739 | 1878 | |
| 1740 | 1879 | // set default stati: true --> 204 No Content, false --> should be already handled |
| 1741 | - if (is_bool($status)) $status = $status ? '204 No Content' : '400 Something went wrong'; |
|
| 1880 | + if (is_bool($status)) |
|
| 1881 | + { |
|
| 1882 | + $status = $status ? '204 No Content' : '400 Something went wrong'; |
|
| 1883 | + } |
|
| 1742 | 1884 | |
| 1743 | 1885 | // check/handle Prefer: return-representation |
| 1744 | 1886 | if ($status[0] === '2' || $status === true) |
@@ -1762,7 +1904,10 @@ discard block |
||
| 1762 | 1904 | */ |
| 1763 | 1905 | function DELETE($options) |
| 1764 | 1906 | { |
| 1765 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1907 | + if ($this->debug) |
|
| 1908 | + { |
|
| 1909 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1910 | + } |
|
| 1766 | 1911 | |
| 1767 | 1912 | $id = $app = $user = null; |
| 1768 | 1913 | if (!$this->_parse_path($options['path'],$id,$app,$user)) |
@@ -1773,7 +1918,10 @@ discard block |
||
| 1773 | 1918 | { |
| 1774 | 1919 | $status = $handler->delete($options,$id); |
| 1775 | 1920 | // set default stati: true --> 204 No Content, false --> should be already handled |
| 1776 | - if (is_bool($status)) $status = $status ? '204 No Content' : '400 Something went wrong'; |
|
| 1921 | + if (is_bool($status)) |
|
| 1922 | + { |
|
| 1923 | + $status = $status ? '204 No Content' : '400 Something went wrong'; |
|
| 1924 | + } |
|
| 1777 | 1925 | return $status; |
| 1778 | 1926 | } |
| 1779 | 1927 | return '501 Not Implemented'; |
@@ -1787,7 +1935,10 @@ discard block |
||
| 1787 | 1935 | */ |
| 1788 | 1936 | function MKCOL($options) |
| 1789 | 1937 | { |
| 1790 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1938 | + if ($this->debug) |
|
| 1939 | + { |
|
| 1940 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1941 | + } |
|
| 1791 | 1942 | |
| 1792 | 1943 | return '501 Not Implemented'; |
| 1793 | 1944 | } |
@@ -1800,7 +1951,10 @@ discard block |
||
| 1800 | 1951 | */ |
| 1801 | 1952 | function MOVE($options) |
| 1802 | 1953 | { |
| 1803 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1954 | + if ($this->debug) |
|
| 1955 | + { |
|
| 1956 | + error_log(__METHOD__.'('.array2string($options).')'); |
|
| 1957 | + } |
|
| 1804 | 1958 | |
| 1805 | 1959 | return '501 Not Implemented'; |
| 1806 | 1960 | } |
@@ -1813,7 +1967,10 @@ discard block |
||
| 1813 | 1967 | */ |
| 1814 | 1968 | function COPY($options, $del=false) |
| 1815 | 1969 | { |
| 1816 | - if ($this->debug) error_log('self::'.($del ? 'MOVE' : 'COPY').'('.array2string($options).')'); |
|
| 1970 | + if ($this->debug) |
|
| 1971 | + { |
|
| 1972 | + error_log('self::'.($del ? 'MOVE' : 'COPY').'('.array2string($options).')'); |
|
| 1973 | + } |
|
| 1817 | 1974 | |
| 1818 | 1975 | return '501 Not Implemented'; |
| 1819 | 1976 | } |
@@ -1830,7 +1987,10 @@ discard block |
||
| 1830 | 1987 | self::_parse_path($options['path'],$id,$app,$user); |
| 1831 | 1988 | $path = Vfs::app_entry_lock_path($app,$id); |
| 1832 | 1989 | |
| 1833 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$path"); |
|
| 1990 | + if ($this->debug) |
|
| 1991 | + { |
|
| 1992 | + error_log(__METHOD__.'('.array2string($options).") path=$path"); |
|
| 1993 | + } |
|
| 1834 | 1994 | |
| 1835 | 1995 | // get the app handler, to check if the user has edit access to the entry (required to make locks) |
| 1836 | 1996 | $handler = self::app_handler($app); |
@@ -1845,10 +2005,13 @@ discard block |
||
| 1845 | 2005 | // dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND |
| 1846 | 2006 | // that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags |
| 1847 | 2007 | if (($ret = Vfs::lock($path,$options['locktoken'],$options['timeout'],strip_tags($options['owner']), |
| 1848 | - $options['scope'],$options['type'],isset($options['update']),false)) && !isset($options['update'])) // false = no ACL check |
|
| 2008 | + $options['scope'],$options['type'],isset($options['update']),false)) && !isset($options['update'])) |
|
| 2009 | + { |
|
| 2010 | + // false = no ACL check |
|
| 1849 | 2011 | { |
| 1850 | 2012 | return $ret ? '200 OK' : '409 Conflict'; |
| 1851 | 2013 | } |
| 2014 | + } |
|
| 1852 | 2015 | return $ret; |
| 1853 | 2016 | } |
| 1854 | 2017 | |
@@ -1864,7 +2027,10 @@ discard block |
||
| 1864 | 2027 | self::_parse_path($options['path'],$id,$app,$user); |
| 1865 | 2028 | $path = Vfs::app_entry_lock_path($app,$id); |
| 1866 | 2029 | |
| 1867 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$path"); |
|
| 2030 | + if ($this->debug) |
|
| 2031 | + { |
|
| 2032 | + error_log(__METHOD__.'('.array2string($options).") path=$path"); |
|
| 2033 | + } |
|
| 1868 | 2034 | return Vfs::unlock($path,$options['token']) ? '204 No Content' : '409 Conflict'; |
| 1869 | 2035 | } |
| 1870 | 2036 | |
@@ -1893,7 +2059,10 @@ discard block |
||
| 1893 | 2059 | $id = $app = $user = null; |
| 1894 | 2060 | self::_parse_path($options['path'],$id,$app,$user); |
| 1895 | 2061 | |
| 1896 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$options[path]"); |
|
| 2062 | + if ($this->debug) |
|
| 2063 | + { |
|
| 2064 | + error_log(__METHOD__.'('.array2string($options).") path=$options[path]"); |
|
| 2065 | + } |
|
| 1897 | 2066 | |
| 1898 | 2067 | $options['errors'] = array(); |
| 1899 | 2068 | switch ($app) |
@@ -1956,7 +2125,10 @@ discard block |
||
| 1956 | 2125 | $user = array_shift($parts); |
| 1957 | 2126 | } |
| 1958 | 2127 | |
| 1959 | - if (!isset($app)) $app = array_shift($parts); |
|
| 2128 | + if (!isset($app)) |
|
| 2129 | + { |
|
| 2130 | + $app = array_shift($parts); |
|
| 2131 | + } |
|
| 1960 | 2132 | |
| 1961 | 2133 | // /addressbook-accounts/ |
| 1962 | 2134 | if (!$account_id && $app == 'addressbook-accounts') |
@@ -2047,7 +2219,10 @@ discard block |
||
| 2047 | 2219 | } |
| 2048 | 2220 | parent::ServeRequest(); |
| 2049 | 2221 | |
| 2050 | - if (self::$request_starttime) self::log_request(); |
|
| 2222 | + if (self::$request_starttime) |
|
| 2223 | + { |
|
| 2224 | + self::log_request(); |
|
| 2225 | + } |
|
| 2051 | 2226 | } |
| 2052 | 2227 | |
| 2053 | 2228 | /** |
@@ -2103,11 +2278,23 @@ discard block |
||
| 2103 | 2278 | { |
| 2104 | 2279 | $content .= $line."\n"; |
| 2105 | 2280 | } |
| 2106 | - if (($c = ob_get_flush())) $content .= "\n"; |
|
| 2107 | - if (self::$log_level !== 'f' && strlen($c) > 1536) $c = substr($c,0,1536)."\n*** LOG TRUNKATED\n"; |
|
| 2281 | + if (($c = ob_get_flush())) |
|
| 2282 | + { |
|
| 2283 | + $content .= "\n"; |
|
| 2284 | + } |
|
| 2285 | + if (self::$log_level !== 'f' && strlen($c) > 1536) |
|
| 2286 | + { |
|
| 2287 | + $c = substr($c,0,1536)."\n*** LOG TRUNKATED\n"; |
|
| 2288 | + } |
|
| 2108 | 2289 | $content .= $c; |
| 2109 | - if ($extra) $content .= $extra; |
|
| 2110 | - if ($this->to_log) $content .= "\n### ".implode("\n### ", $this->to_log)."\n"; |
|
| 2290 | + if ($extra) |
|
| 2291 | + { |
|
| 2292 | + $content .= $extra; |
|
| 2293 | + } |
|
| 2294 | + if ($this->to_log) |
|
| 2295 | + { |
|
| 2296 | + $content .= "\n### ".implode("\n### ", $this->to_log)."\n"; |
|
| 2297 | + } |
|
| 2111 | 2298 | $content .= $this->_http_status[0] == '4' && substr($this->_http_status,0,3) != '412' || |
| 2112 | 2299 | $this->_http_status[0] == '5' ? '###' : '***'; // mark failed requests with ###, instead of *** |
| 2113 | 2300 | $content .= sprintf(' %s --> "%s" took %5.3f s',$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$this->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$this->_http_status,microtime(true)-self::$request_starttime)."\n\n"; |
@@ -2165,8 +2352,14 @@ discard block |
||
| 2165 | 2352 | */ |
| 2166 | 2353 | protected static function add_prop(\XMLWriter $xml, $props) |
| 2167 | 2354 | { |
| 2168 | - if (is_string($props)) $props = self::mkprop($props, ''); |
|
| 2169 | - if (isset($props['name'])) $props = array($props); |
|
| 2355 | + if (is_string($props)) |
|
| 2356 | + { |
|
| 2357 | + $props = self::mkprop($props, ''); |
|
| 2358 | + } |
|
| 2359 | + if (isset($props['name'])) |
|
| 2360 | + { |
|
| 2361 | + $props = array($props); |
|
| 2362 | + } |
|
| 2170 | 2363 | |
| 2171 | 2364 | foreach($props as $prop) |
| 2172 | 2365 | { |
@@ -2253,7 +2446,10 @@ discard block |
||
| 2253 | 2446 | */ |
| 2254 | 2447 | static function generate_uid($_appName, $_eventID) |
| 2255 | 2448 | { |
| 2256 | - if(empty($_appName) || empty($_eventID)) return false; |
|
| 2449 | + if(empty($_appName) || empty($_eventID)) |
|
| 2450 | + { |
|
| 2451 | + return false; |
|
| 2452 | + } |
|
| 2257 | 2453 | |
| 2258 | 2454 | return $_appName.'-'.$_eventID.'-'.$GLOBALS['egw_info']['server']['install_id']; |
| 2259 | 2455 | } |
@@ -2033,7 +2033,7 @@ |
||
| 2033 | 2033 | * |
| 2034 | 2034 | * Reimplemented to add logging |
| 2035 | 2035 | * |
| 2036 | - * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
| 2036 | + * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
|
| 2037 | 2037 | */ |
| 2038 | 2038 | function ServeRequest($prefix=null) |
| 2039 | 2039 | { |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | 'inbox' => array( |
| 118 | 118 | 'resourcetype' => array(self::CALDAV => 'schedule-inbox'), |
| 119 | 119 | 'app' => 'calendar', |
| 120 | - 'user-only' => true, // display just in user home |
|
| 120 | + 'user-only' => true, // display just in user home |
|
| 121 | 121 | ), |
| 122 | 122 | 'outbox' => array( |
| 123 | 123 | 'resourcetype' => array(self::CALDAV => 'schedule-outbox'), |
| 124 | 124 | 'app' => 'calendar', |
| 125 | - 'user-only' => true, // display just in user home |
|
| 125 | + 'user-only' => true, // display just in user home |
|
| 126 | 126 | ), |
| 127 | 127 | 'infolog' => array( |
| 128 | 128 | 'resourcetype' => array(self::GROUPDAV => 'vtodo-collection', self::CALDAV => 'calendar'), |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | if ($this->debug > 2) error_log('groupdav: $_SERVER='.array2string($_SERVER)); |
| 230 | 230 | |
| 231 | 231 | // setting our own exception handler, to be able to still log the requests |
| 232 | - set_exception_handler(array(__CLASS__,'exception_handler')); |
|
| 232 | + set_exception_handler(array(__CLASS__, 'exception_handler')); |
|
| 233 | 233 | |
| 234 | 234 | // crrnd: client refuses redundand namespace declarations |
| 235 | 235 | // setting redundand namespaces as the default for (Cal|Card|Group)DAV, as the majority of the clients either require or can live with it |
| 236 | 236 | $this->crrnd = false; |
| 237 | 237 | |
| 238 | 238 | // identify clients, which do NOT support path AND full url in <D:href> of PROPFIND request |
| 239 | - switch(($agent = Handler::get_agent())) |
|
| 239 | + switch (($agent = Handler::get_agent())) |
|
| 240 | 240 | { |
| 241 | 241 | case 'kde': // KAddressbook (at least in 3.5 can NOT subscribe / does NOT find addressbook) |
| 242 | 242 | $this->client_require_href_as_url = true; |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | if ($this->debug) error_log(__METHOD__."() HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]' --> '$agent' --> client_requires_href_as_url=$this->client_require_href_as_url, crrnd(client refuses redundand namespace declarations)=$this->crrnd"); |
| 258 | 258 | |
| 259 | 259 | // adding EGroupware version to X-Dav-Powered-By header eg. "EGroupware 1.8.001 CalDAV/CardDAV/GroupDAV server" |
| 260 | - $this->dav_powered_by = str_replace('EGroupware','EGroupware '.$GLOBALS['egw_info']['server']['versions']['phpgwapi'], |
|
| 260 | + $this->dav_powered_by = str_replace('EGroupware', 'EGroupware '.$GLOBALS['egw_info']['server']['versions']['phpgwapi'], |
|
| 261 | 261 | $this->dav_powered_by); |
| 262 | 262 | |
| 263 | 263 | parent::__construct(); |
| 264 | 264 | // hack to allow to use query parameters in WebDAV, which HTTP_WebDAV_Server interprets as part of the path |
| 265 | - list($this->_SERVER['REQUEST_URI']) = explode('?',$this->_SERVER['REQUEST_URI']); |
|
| 265 | + list($this->_SERVER['REQUEST_URI']) = explode('?', $this->_SERVER['REQUEST_URI']); |
|
| 266 | 266 | /*if (substr($this->_SERVER['REQUEST_URI'],-13) == '/;add-member/') |
| 267 | 267 | { |
| 268 | 268 | $_GET['add-member'] = ''; |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | else |
| 279 | 279 | { |
| 280 | - $this->current_user_principal = (@$_SERVER["HTTPS"] === "on" ? "https:" : "http:") . |
|
| 281 | - '//' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '/'; |
|
| 280 | + $this->current_user_principal = (@$_SERVER["HTTPS"] === "on" ? "https:" : "http:"). |
|
| 281 | + '//'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'/'; |
|
| 282 | 282 | } |
| 283 | 283 | $this->current_user_principal .= 'principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/'; |
| 284 | 284 | |
| 285 | 285 | // if client requires pathes instead of URLs |
| 286 | 286 | if (!$this->client_require_href_as_url) |
| 287 | 287 | { |
| 288 | - $this->current_user_principal = parse_url($this->current_user_principal,PHP_URL_PATH); |
|
| 288 | + $this->current_user_principal = parse_url($this->current_user_principal, PHP_URL_PATH); |
|
| 289 | 289 | } |
| 290 | 290 | $this->accounts = $GLOBALS['egw']->accounts; |
| 291 | 291 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | { |
| 303 | 303 | if (isset($this->root[$app]['app'])) $app = $this->root[$app]['app']; |
| 304 | 304 | |
| 305 | - return Handler::app_handler($app,$this); |
|
| 305 | + return Handler::app_handler($app, $this); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | function OPTIONS($path, &$dav, &$allow) |
| 316 | 316 | { |
| 317 | - unset($allow); // not used, but required by function signature |
|
| 317 | + unset($allow); // not used, but required by function signature |
|
| 318 | 318 | |
| 319 | 319 | // locking support |
| 320 | 320 | if (!in_array('2', $dav)) $dav[] = '2'; |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | if ($app !== 'calendar') // CardDAV |
| 353 | 353 | { |
| 354 | - $dav[] = 'addressbook'; // CardDAV uses "addressbook" NOT "addressbook-access" |
|
| 354 | + $dav[] = 'addressbook'; // CardDAV uses "addressbook" NOT "addressbook-access" |
|
| 355 | 355 | } |
| 356 | 356 | //error_log(__METHOD__."('$path') --> app='$app' --> DAV: ".implode(', ', $dav)); |
| 357 | 357 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param array return array for file properties |
| 364 | 364 | * @return bool true on success |
| 365 | 365 | */ |
| 366 | - function PROPFIND(&$options, &$files, $method='PROPFIND') |
|
| 366 | + function PROPFIND(&$options, &$files, $method = 'PROPFIND') |
|
| 367 | 367 | { |
| 368 | 368 | if ($this->debug) error_log(__CLASS__."::$method(".array2string($options).')'); |
| 369 | 369 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | // parse path in form [/account_lid]/app[/more] |
| 374 | 374 | $id = $app = $user = $user_prefix = null; |
| 375 | - if (!self::_parse_path($options['path'],$id,$app,$user,$user_prefix) && $app && !$user && $user !== 0) |
|
| 375 | + if (!self::_parse_path($options['path'], $id, $app, $user, $user_prefix) && $app && !$user && $user !== 0) |
|
| 376 | 376 | { |
| 377 | 377 | if ($this->debug > 1) error_log(__CLASS__."::$method: user='$user', app='$app', id='$id': 404 not found!"); |
| 378 | 378 | return '404 Not Found'; |
@@ -404,9 +404,9 @@ discard block |
||
| 404 | 404 | $files['files'][] = $this->add_collection('/principals/', array( |
| 405 | 405 | 'displayname' => lang('Accounts'), |
| 406 | 406 | )); |
| 407 | - foreach($this->accounts->search(array('type' => 'both','order'=>'account_lid')) as $account) |
|
| 407 | + foreach ($this->accounts->search(array('type' => 'both', 'order'=>'account_lid')) as $account) |
|
| 408 | 408 | { |
| 409 | - $this->add_home($files, $path.$account['account_lid'].'/', $account['account_id'], $options['depth'] == 'infinity' ? 'infinity' : $options['depth']-1); |
|
| 409 | + $this->add_home($files, $path.$account['account_lid'].'/', $account['account_id'], $options['depth'] == 'infinity' ? 'infinity' : $options['depth'] - 1); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | return true; |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | if ($app != 'principals' && !isset($GLOBALS['egw_info']['user']['apps'][$this->root[$app]['app'] ? $this->root[$app]['app'] : $app])) |
| 419 | 419 | { |
| 420 | 420 | if ($this->debug) error_log(__CLASS__."::$method(path=$options[path]) 403 Forbidden: no app rights for '$app'"); |
| 421 | - return "403 Forbidden: no app rights for '$app'"; // no rights for the given app |
|
| 421 | + return "403 Forbidden: no app rights for '$app'"; // no rights for the given app |
|
| 422 | 422 | } |
| 423 | 423 | if (($handler = self::app_handler($app))) |
| 424 | 424 | { |
| 425 | 425 | if ($method != 'REPORT' && !$id) // no self URL for REPORT requests (only PROPFIND) or propfinds on an id |
| 426 | 426 | { |
| 427 | 427 | // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes |
| 428 | - $files['files'][0] = $this->add_app($app,$app=='addressbook'&&$handler->get_agent()=='kde',$user, |
|
| 428 | + $files['files'][0] = $this->add_app($app, $app == 'addressbook' && $handler->get_agent() == 'kde', $user, |
|
| 429 | 429 | $this->_slashify($options['path'])); |
| 430 | 430 | |
| 431 | 431 | // Hack for iOS 5.0.1 addressbook to stop asking directory gateway permissions with depth != 0 |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | $this->log(__CLASS__."::$method(".array2string($options).') Enabling hack for iOS 5.0.1 addressbook: force Depth: 0 on PROPFIND for directory gateway!'); |
| 437 | 437 | return true; |
| 438 | 438 | } |
| 439 | - if (!$options['depth']) return true; // depth 0 --> show only the self url |
|
| 439 | + if (!$options['depth']) return true; // depth 0 --> show only the self url |
|
| 440 | 440 | } |
| 441 | - return $handler->propfind($this->_slashify($options['path']),$options,$files,$user,$id); |
|
| 441 | + return $handler->propfind($this->_slashify($options['path']), $options, $files, $user, $id); |
|
| 442 | 442 | } |
| 443 | 443 | return '501 Not Implemented'; |
| 444 | 444 | } |
@@ -452,10 +452,10 @@ discard block |
||
| 452 | 452 | * @param array $supported_privileges =null default $this->supported_privileges |
| 453 | 453 | * @return array with values for keys 'path' and 'props' |
| 454 | 454 | */ |
| 455 | - public function add_collection($path, array $props = array(), array $privileges=array('read','read-acl','read-current-user-privilege-set'), array $supported_privileges=null) |
|
| 455 | + public function add_collection($path, array $props = array(), array $privileges = array('read', 'read-acl', 'read-current-user-privilege-set'), array $supported_privileges = null) |
|
| 456 | 456 | { |
| 457 | 457 | // resourcetype: collection |
| 458 | - $props['resourcetype'][] = self::mkprop('collection',''); |
|
| 458 | + $props['resourcetype'][] = self::mkprop('collection', ''); |
|
| 459 | 459 | |
| 460 | 460 | if (!isset($props['getcontenttype'])) $props['getcontenttype'] = 'httpd/unix-directory'; |
| 461 | 461 | |
@@ -471,16 +471,16 @@ discard block |
||
| 471 | 471 | * @param array $supported_privileges =null default $this->supported_privileges |
| 472 | 472 | * @return array with values for keys 'path' and 'props' |
| 473 | 473 | */ |
| 474 | - public function add_resource($path, array $props = array(), array $privileges=array('read','read-current-user-privilege-set'), array $supported_privileges=null) |
|
| 474 | + public function add_resource($path, array $props = array(), array $privileges = array('read', 'read-current-user-privilege-set'), array $supported_privileges = null) |
|
| 475 | 475 | { |
| 476 | 476 | // props for all collections: current-user-principal and principal-collection-set |
| 477 | 477 | $props['current-user-principal'] = array( |
| 478 | - self::mkprop('href',$this->current_user_principal)); |
|
| 478 | + self::mkprop('href', $this->current_user_principal)); |
|
| 479 | 479 | $props['principal-collection-set'] = array( |
| 480 | - self::mkprop('href',$this->base_uri.'/principals/')); |
|
| 480 | + self::mkprop('href', $this->base_uri.'/principals/')); |
|
| 481 | 481 | |
| 482 | 482 | // required props per WebDAV standard |
| 483 | - foreach(array( |
|
| 483 | + foreach (array( |
|
| 484 | 484 | 'displayname' => basename($path), |
| 485 | 485 | 'getetag' => 'none', |
| 486 | 486 | 'getcontentlength' => '', |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | if (is_null($supported_privileges)) $supported_privileges = $this->supported_privileges; |
| 497 | 497 | if ($this->prop_requested('current-user-privilege-set') === true) |
| 498 | 498 | { |
| 499 | - foreach($privileges as $name) |
|
| 499 | + foreach ($privileges as $name) |
|
| 500 | 500 | { |
| 501 | 501 | $props['current-user-privilege-set'][] = self::mkprop('privilege', array( |
| 502 | 502 | is_array($name) ? self::mkprop($name['ns'], $name['name'], '') : self::mkprop($name, ''))); |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | if ($this->prop_requested('supported-privilege-set') === true) |
| 506 | 506 | { |
| 507 | - foreach($supported_privileges as $name => $data) |
|
| 507 | + foreach ($supported_privileges as $name => $data) |
|
| 508 | 508 | { |
| 509 | 509 | $props['supported-privilege-set'][] = $this->supported_privilege($name, $data, $path); |
| 510 | 510 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | if ($this->debug > 1) error_log(__METHOD__."(path='$path', props=".array2string($props).')'); |
| 518 | 518 | |
| 519 | 519 | // convert simple associative properties to HTTP_WebDAV_Server ones |
| 520 | - foreach($props as $name => &$prop) |
|
| 520 | + foreach ($props as $name => &$prop) |
|
| 521 | 521 | { |
| 522 | 522 | if (!is_array($prop) || !isset($prop['name'])) |
| 523 | 523 | { |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @param string $path =null path to match with $data['*only*'] |
| 545 | 545 | * @return array of self::mkprop() arrays |
| 546 | 546 | */ |
| 547 | - protected function supported_privilege($name, $data, $path=null) |
|
| 547 | + protected function supported_privilege($name, $data, $path = null) |
|
| 548 | 548 | { |
| 549 | 549 | $props = array(); |
| 550 | 550 | $props[] = self::mkprop('privilege', array(is_array($data) && $data['*ns*'] ? |
@@ -552,12 +552,12 @@ discard block |
||
| 552 | 552 | $props[] = self::mkprop('description', is_array($data) ? $data['*description*'] : $data); |
| 553 | 553 | if (is_array($data)) |
| 554 | 554 | { |
| 555 | - foreach($data as $name => $data) |
|
| 555 | + foreach ($data as $name => $data) |
|
| 556 | 556 | { |
| 557 | 557 | if ($name[0] == '*') continue; |
| 558 | 558 | if (is_array($data) && $data['*only*'] && strpos($path, $data['*only*']) === false) |
| 559 | 559 | { |
| 560 | - continue; // wrong path |
|
| 560 | + continue; // wrong path |
|
| 561 | 561 | } |
| 562 | 562 | $props[] = $this->supported_privilege($name, $data, $path); |
| 563 | 563 | } |
@@ -573,20 +573,20 @@ discard block |
||
| 573 | 573 | * @param boolean $return_prop =false if true return the property array with values for 'name', 'xmlns', 'attrs', 'children' |
| 574 | 574 | * @return boolean|string|array true: $name explicitly requested (or autoindex), "all": allprop or "names": propname requested, false: $name was not requested |
| 575 | 575 | */ |
| 576 | - function prop_requested($name, $ns=null, $return_prop=false) |
|
| 576 | + function prop_requested($name, $ns = null, $return_prop = false) |
|
| 577 | 577 | { |
| 578 | 578 | if (!is_array($this->propfind_options) || !isset($this->propfind_options['props'])) |
| 579 | 579 | { |
| 580 | - $ret = true; // no props set, should happen only in autoindex, we return true to show all available props |
|
| 580 | + $ret = true; // no props set, should happen only in autoindex, we return true to show all available props |
|
| 581 | 581 | } |
| 582 | 582 | elseif (!is_array($this->propfind_options['props'])) |
| 583 | 583 | { |
| 584 | - $ret = $this->propfind_options['props']; // "all": allprop or "names": propname |
|
| 584 | + $ret = $this->propfind_options['props']; // "all": allprop or "names": propname |
|
| 585 | 585 | } |
| 586 | 586 | else |
| 587 | 587 | { |
| 588 | 588 | $ret = false; |
| 589 | - foreach($this->propfind_options['props'] as $prop) |
|
| 589 | + foreach ($this->propfind_options['props'] as $prop) |
|
| 590 | 590 | { |
| 591 | 591 | if ($prop['name'] == $name && (is_null($ns) || $prop['xmlns'] == $ns)) |
| 592 | 592 | { |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $account = $this->accounts->read($account_lid); |
| 622 | 622 | |
| 623 | 623 | $calendar_user_address_set = array( |
| 624 | - self::mkprop('href','urn:uuid:'.$account['account_lid']), |
|
| 624 | + self::mkprop('href', 'urn:uuid:'.$account['account_lid']), |
|
| 625 | 625 | ); |
| 626 | 626 | if ($user < 0) |
| 627 | 627 | { |
@@ -632,29 +632,29 @@ discard block |
||
| 632 | 632 | { |
| 633 | 633 | $principalType = 'users'; |
| 634 | 634 | $displayname = $account['account_fullname']; |
| 635 | - $calendar_user_address_set[] = self::mkprop('href','mailto:'.$account['account_email']); |
|
| 635 | + $calendar_user_address_set[] = self::mkprop('href', 'mailto:'.$account['account_email']); |
|
| 636 | 636 | } |
| 637 | - $calendar_user_address_set[] = self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account['account_lid'].'/'); |
|
| 637 | + $calendar_user_address_set[] = self::mkprop('href', $this->base_uri.'/principals/'.$principalType.'/'.$account['account_lid'].'/'); |
|
| 638 | 638 | |
| 639 | 639 | if ($depth && $path == '/') |
| 640 | 640 | { |
| 641 | 641 | $displayname = 'EGroupware (Cal|Card|Group)DAV server'; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - $displayname = Translation::convert($displayname, Translation::charset(),'utf-8'); |
|
| 644 | + $displayname = Translation::convert($displayname, Translation::charset(), 'utf-8'); |
|
| 645 | 645 | // self url |
| 646 | 646 | $props = array( |
| 647 | 647 | 'displayname' => $displayname, |
| 648 | - 'owner' => $path == '/' ? '' : array(self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/')), |
|
| 648 | + 'owner' => $path == '/' ? '' : array(self::mkprop('href', $this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/')), |
|
| 649 | 649 | ); |
| 650 | 650 | |
| 651 | 651 | if ($path != '/') |
| 652 | 652 | { |
| 653 | 653 | // add props modifyable via proppatch from client, eg. jqcalendar stores it's preferences there |
| 654 | - foreach((array)$GLOBALS['egw_info']['user']['preferences']['groupdav'] as $name => $value) |
|
| 654 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences']['groupdav'] as $name => $value) |
|
| 655 | 655 | { |
| 656 | - list($prop,$prop4path,$ns) = explode(':', $name, 3); |
|
| 657 | - if ($prop4path == $path && (!in_array($ns,self::$ns_needs_explicit_named_props) || |
|
| 656 | + list($prop, $prop4path, $ns) = explode(':', $name, 3); |
|
| 657 | + if ($prop4path == $path && (!in_array($ns, self::$ns_needs_explicit_named_props) || |
|
| 658 | 658 | isset(self::$proppatch_props[$prop]) && self::$proppatch_props[$prop] === $ns)) |
| 659 | 659 | { |
| 660 | 660 | $props[] = self::mkprop($ns, $prop, $value); |
@@ -666,19 +666,19 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | if ($depth) |
| 668 | 668 | { |
| 669 | - foreach($this->root as $app => $data) |
|
| 669 | + foreach ($this->root as $app => $data) |
|
| 670 | 670 | { |
| 671 | - if (!$GLOBALS['egw_info']['user']['apps'][$data['app'] ? $data['app'] : $app]) continue; // no rights for the given app |
|
| 671 | + if (!$GLOBALS['egw_info']['user']['apps'][$data['app'] ? $data['app'] : $app]) continue; // no rights for the given app |
|
| 672 | 672 | if (!empty($data['user-only']) && ($path == '/' || $user < 0)) continue; |
| 673 | 673 | |
| 674 | - $files['files'][] = $this->add_app($app,false,$user,$path.$app.'/'); |
|
| 674 | + $files['files'][] = $this->add_app($app, false, $user, $path.$app.'/'); |
|
| 675 | 675 | |
| 676 | 676 | // only add global /addressbook-accounts/ as the one in home-set is added (and controled) by add_shared |
| 677 | 677 | if ($path == '/' && $app == 'addressbook' && |
| 678 | 678 | !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
| 679 | 679 | { |
| 680 | - $file = $this->add_app($app,false,0,$path.$app.'-accounts/'); |
|
| 681 | - $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared',''); |
|
| 680 | + $file = $this->add_app($app, false, 0, $path.$app.'-accounts/'); |
|
| 681 | + $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER, 'shared', ''); |
|
| 682 | 682 | $files['files'][] = $file; |
| 683 | 683 | } |
| 684 | 684 | // added shared calendars or addressbooks |
@@ -701,12 +701,12 @@ discard block |
||
| 701 | 701 | * @param int $depth =0 |
| 702 | 702 | * @return string|boolean http status or true|false |
| 703 | 703 | */ |
| 704 | - protected function add_resources_collection(array &$files, $path, $depth=0) |
|
| 704 | + protected function add_resources_collection(array &$files, $path, $depth = 0) |
|
| 705 | 705 | { |
| 706 | 706 | if (!isset($GLOBALS['egw_info']['user']['apps']['resources'])) |
| 707 | 707 | { |
| 708 | 708 | if ($this->debug) error_log(__METHOD__."(path=$path) 403 Forbidden: no app rights for 'resources'"); |
| 709 | - return "403 Forbidden: no app rights for 'resources'"; // no rights for the given app |
|
| 709 | + return "403 Forbidden: no app rights for 'resources'"; // no rights for the given app |
|
| 710 | 710 | } |
| 711 | 711 | list(,$what) = explode('/', $path); |
| 712 | 712 | if (($is_location = ($what == 'locations'))) |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | } |
| 720 | 720 | if ($depth) |
| 721 | 721 | { |
| 722 | - foreach(Principals::get_resources() as $resource) |
|
| 722 | + foreach (Principals::get_resources() as $resource) |
|
| 723 | 723 | { |
| 724 | 724 | if ($is_location == Principals::resource_is_location($resource)) |
| 725 | 725 | { |
@@ -751,11 +751,11 @@ discard block |
||
| 751 | 751 | $handler = $this->app_handler($app); |
| 752 | 752 | if (($shared = $handler->get_shared())) |
| 753 | 753 | { |
| 754 | - foreach($shared as $id => $owner) |
|
| 754 | + foreach ($shared as $id => $owner) |
|
| 755 | 755 | { |
| 756 | - $file = $this->add_app($app,false,$id,$path.$owner.'/'); |
|
| 756 | + $file = $this->add_app($app, false, $id, $path.$owner.'/'); |
|
| 757 | 757 | // mark other users calendar as shared (iOS 5.0.1 AB does NOT display AB marked as shared!) |
| 758 | - if ($app == 'calendar') $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER,'shared',''); |
|
| 758 | + if ($app == 'calendar') $file['props']['resourcetype']['val'][] = self::mkprop(self::CALENDARSERVER, 'shared', ''); |
|
| 759 | 759 | $files[] = $file; |
| 760 | 760 | } |
| 761 | 761 | } |
@@ -785,11 +785,11 @@ discard block |
||
| 785 | 785 | { |
| 786 | 786 | if ($account < 0) |
| 787 | 787 | { |
| 788 | - $name = lang('Group').' '.$this->accounts->id2name($account,'account_lid'); |
|
| 788 | + $name = lang('Group').' '.$this->accounts->id2name($account, 'account_lid'); |
|
| 789 | 789 | } |
| 790 | 790 | else |
| 791 | 791 | { |
| 792 | - $name = $this->accounts->id2name($account,'account_fullname'); |
|
| 792 | + $name = $this->accounts->id2name($account, 'account_fullname'); |
|
| 793 | 793 | } |
| 794 | 794 | if (empty($name)) $name = '#'.$account; |
| 795 | 795 | } |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * @param string $path ='/' |
| 806 | 806 | * @return array with values for keys 'path' and 'props' |
| 807 | 807 | */ |
| 808 | - protected function add_app($app,$no_extra_types=false,$user=null,$path='/') |
|
| 808 | + protected function add_app($app, $no_extra_types = false, $user = null, $path = '/') |
|
| 809 | 809 | { |
| 810 | 810 | if ($this->debug) error_log(__METHOD__."(app='$app', no_extra_types=$no_extra_types, user='$user', path='$path')"); |
| 811 | 811 | $user_preferences = $GLOBALS['egw_info']['user']['preferences']; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | if (!isset($displayname)) $displayname = $this->account_name($user); |
| 835 | 835 | |
| 836 | 836 | $props = array( |
| 837 | - 'owner' => array(self::mkprop('href',$this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/')), |
|
| 837 | + 'owner' => array(self::mkprop('href', $this->base_uri.'/principals/'.$principalType.'/'.$account_lid.'/')), |
|
| 838 | 838 | ); |
| 839 | 839 | |
| 840 | 840 | switch ($app) |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $props['displayname'] = lang('All addressbooks'); |
| 852 | 852 | break; |
| 853 | 853 | } |
| 854 | - elseif(!$user && !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 854 | + elseif (!$user && !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 855 | 855 | { |
| 856 | 856 | unset($props['owner']); |
| 857 | 857 | $props['displayname'] = lang($app).' '.lang('Accounts'); |
@@ -864,40 +864,40 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | // rfc 5995 (Use POST to add members to WebDAV collections): we use collection path with add-member query param |
| 866 | 866 | // leaving it switched off, until further testing, because OS X iCal seem to ignore it and OS X Addressbook uses POST to full URL without ?add-member |
| 867 | - if ($app && !in_array($app,array('inbox','outbox','principals'))) // not on inbox, outbox or principals |
|
| 867 | + if ($app && !in_array($app, array('inbox', 'outbox', 'principals'))) // not on inbox, outbox or principals |
|
| 868 | 868 | { |
| 869 | - $props['add-member'][] = self::mkprop('href',$this->base_uri.$path.'?add-member'); |
|
| 869 | + $props['add-member'][] = self::mkprop('href', $this->base_uri.$path.'?add-member'); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | // add props modifyable via proppatch from client, eg. calendar-color, see self::$proppatch_props |
| 873 | 873 | $ns = null; |
| 874 | - foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $name => $value) |
|
| 874 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $name => $value) |
|
| 875 | 875 | { |
| 876 | 876 | unset($ns); |
| 877 | - list($prop,$prop4user,$ns) = explode(':', $name, 3); |
|
| 877 | + list($prop, $prop4user, $ns) = explode(':', $name, 3); |
|
| 878 | 878 | if ($prop4user == (string)$user && isset(self::$proppatch_props[$prop]) && !isset($ns)) |
| 879 | 879 | { |
| 880 | 880 | $props[$prop] = self::mkprop(self::$proppatch_props[$prop], $prop, $value); |
| 881 | 881 | //error_log(__METHOD__."() explicit ".self::$proppatch_props[$prop].":$prop=".array2string($value)); |
| 882 | 882 | } |
| 883 | 883 | // props in arbitrary namespaces not mentioned in self::$ns_needs_explicit_named_props |
| 884 | - elseif(isset($ns) && !in_array($ns,self::$ns_needs_explicit_named_props)) |
|
| 884 | + elseif (isset($ns) && !in_array($ns, self::$ns_needs_explicit_named_props)) |
|
| 885 | 885 | { |
| 886 | 886 | $props[] = self::mkprop($ns, $prop, $value); |
| 887 | 887 | //error_log(__METHOD__."() arbitrary $ns:$prop=".array2string($value)); |
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - foreach((array)$this->root[$app] as $prop => $values) |
|
| 891 | + foreach ((array)$this->root[$app] as $prop => $values) |
|
| 892 | 892 | { |
| 893 | - switch($prop) |
|
| 893 | + switch ($prop) |
|
| 894 | 894 | { |
| 895 | 895 | case 'resourcetype'; |
| 896 | 896 | if (!$no_extra_types) |
| 897 | 897 | { |
| 898 | - foreach($this->root[$app]['resourcetype'] as $ns => $type) |
|
| 898 | + foreach ($this->root[$app]['resourcetype'] as $ns => $type) |
|
| 899 | 899 | { |
| 900 | - $props['resourcetype'][] = self::mkprop($ns,$type,''); |
|
| 900 | + $props['resourcetype'][] = self::mkprop($ns, $type, ''); |
|
| 901 | 901 | } |
| 902 | 902 | // add /addressbook/ as directory gateway |
| 903 | 903 | if ($path == '/addressbook/') |
@@ -908,13 +908,13 @@ discard block |
||
| 908 | 908 | break; |
| 909 | 909 | case 'app': |
| 910 | 910 | case 'user-only': |
| 911 | - break; // no props, already handled |
|
| 911 | + break; // no props, already handled |
|
| 912 | 912 | default: |
| 913 | 913 | if (is_array($values)) |
| 914 | 914 | { |
| 915 | - foreach($values as $ns => $value) |
|
| 915 | + foreach ($values as $ns => $value) |
|
| 916 | 916 | { |
| 917 | - $props[$prop] = self::mkprop($ns,$prop,$value); |
|
| 917 | + $props[$prop] = self::mkprop($ns, $prop, $value); |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | else |
@@ -927,20 +927,20 @@ discard block |
||
| 927 | 927 | // add other handler specific properties |
| 928 | 928 | if (($handler = self::app_handler($app))) |
| 929 | 929 | { |
| 930 | - if (method_exists($handler,'extra_properties')) |
|
| 930 | + if (method_exists($handler, 'extra_properties')) |
|
| 931 | 931 | { |
| 932 | 932 | $props = $handler->extra_properties($props, $displayname, $this->base_uri, $user, $path); |
| 933 | 933 | } |
| 934 | 934 | // add ctag if handler implements it |
| 935 | - if (method_exists($handler,'getctag') && $this->prop_requested('getctag') === true) |
|
| 935 | + if (method_exists($handler, 'getctag') && $this->prop_requested('getctag') === true) |
|
| 936 | 936 | { |
| 937 | 937 | $props['getctag'] = self::mkprop( |
| 938 | - self::CALENDARSERVER,'getctag',$handler->getctag($path,$user)); |
|
| 938 | + self::CALENDARSERVER, 'getctag', $handler->getctag($path, $user)); |
|
| 939 | 939 | } |
| 940 | 940 | // add sync-token url if handler supports sync-collection report |
| 941 | 941 | if (isset($props['supported-report-set']['sync-collection']) && $this->prop_requested('sync-token') === true) |
| 942 | 942 | { |
| 943 | - $props['sync-token'] = $handler->get_sync_token($path,$user); |
|
| 943 | + $props['sync-token'] = $handler->get_sync_token($path, $user); |
|
| 944 | 944 | } |
| 945 | 945 | } |
| 946 | 946 | if ($handler && !is_null($user)) |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | { |
| 964 | 964 | if ($this->debug > 1) error_log(__METHOD__.'('.array2string($options).')'); |
| 965 | 965 | |
| 966 | - return $this->PROPFIND($options,$files,'REPORT'); |
|
| 966 | + return $this->PROPFIND($options, $files, 'REPORT'); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -987,13 +987,13 @@ discard block |
||
| 987 | 987 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
| 988 | 988 | |
| 989 | 989 | $id = $app = $user = null; |
| 990 | - if (!$this->_parse_path($options['path'],$id,$app,$user) || $app == 'principals') |
|
| 990 | + if (!$this->_parse_path($options['path'], $id, $app, $user) || $app == 'principals') |
|
| 991 | 991 | { |
| 992 | 992 | return $this->autoindex($options); |
| 993 | 993 | } |
| 994 | 994 | if (($handler = self::app_handler($app))) |
| 995 | 995 | { |
| 996 | - return $handler->get($options,$id,$user); |
|
| 996 | + return $handler->get($options, $id, $user); |
|
| 997 | 997 | } |
| 998 | 998 | error_log(__METHOD__."(".array2string($options).") 501 Not Implemented"); |
| 999 | 999 | return '501 Not Implemented'; |
@@ -1011,9 +1011,9 @@ discard block |
||
| 1011 | 1011 | 'depth' => 1, |
| 1012 | 1012 | ); |
| 1013 | 1013 | $files = array(); |
| 1014 | - if (($ret = $this->PROPFIND($propfind_options,$files)) !== true) |
|
| 1014 | + if (($ret = $this->PROPFIND($propfind_options, $files)) !== true) |
|
| 1015 | 1015 | { |
| 1016 | - return $ret; // no collection |
|
| 1016 | + return $ret; // no collection |
|
| 1017 | 1017 | } |
| 1018 | 1018 | header('Content-type: text/html; charset='.Translation::charset()); |
| 1019 | 1019 | echo "<html>\n<head>\n\t<title>".'EGroupware (Cal|Card|Group)DAV server '.htmlspecialchars($options['path'])."</title>\n"; |
@@ -1024,10 +1024,10 @@ discard block |
||
| 1024 | 1024 | |
| 1025 | 1025 | echo '<h1>(Cal|Card|Group)DAV '; |
| 1026 | 1026 | $path = '/groupdav.php'; |
| 1027 | - foreach(explode('/',$this->_unslashify($options['path'])) as $n => $name) |
|
| 1027 | + foreach (explode('/', $this->_unslashify($options['path'])) as $n => $name) |
|
| 1028 | 1028 | { |
| 1029 | 1029 | $path .= ($n != 1 ? '/' : '').$name; |
| 1030 | - echo Html::a_href(htmlspecialchars($name.'/'),$path); |
|
| 1030 | + echo Html::a_href(htmlspecialchars($name.'/'), $path); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | echo "</h1>\n"; |
| 1033 | 1033 | |
@@ -1047,18 +1047,18 @@ discard block |
||
| 1047 | 1047 | ); |
| 1048 | 1048 | $n = 0; |
| 1049 | 1049 | $collection_props = null; |
| 1050 | - foreach($files['files'] as $file) |
|
| 1050 | + foreach ($files['files'] as $file) |
|
| 1051 | 1051 | { |
| 1052 | 1052 | if (!isset($collection_props)) |
| 1053 | 1053 | { |
| 1054 | 1054 | $collection_props = $this->props2array($file['props']); |
| 1055 | 1055 | echo '<h3>'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."</h3>\n"; |
| 1056 | - continue; // own entry --> displaying properies later |
|
| 1056 | + continue; // own entry --> displaying properies later |
|
| 1057 | 1057 | } |
| 1058 | - if(!$n++) |
|
| 1058 | + if (!$n++) |
|
| 1059 | 1059 | { |
| 1060 | 1060 | echo "<table>\n\t<tr class='th'>\n\t\t<th>#</th>\n\t\t<th>".lang('Name')."</th>"; |
| 1061 | - foreach($props2show as $label) |
|
| 1061 | + foreach ($props2show as $label) |
|
| 1062 | 1062 | { |
| 1063 | 1063 | echo "\t\t<th>".lang($label)."</th>\n"; |
| 1064 | 1064 | } |
@@ -1068,9 +1068,9 @@ discard block |
||
| 1068 | 1068 | //echo $file['path']; _debug_array($props); |
| 1069 | 1069 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 1070 | 1070 | |
| 1071 | - if (substr($file['path'],-1) == '/') |
|
| 1071 | + if (substr($file['path'], -1) == '/') |
|
| 1072 | 1072 | { |
| 1073 | - $name = basename(substr($file['path'],0,-1)).'/'; |
|
| 1073 | + $name = basename(substr($file['path'], 0, -1)).'/'; |
|
| 1074 | 1074 | } |
| 1075 | 1075 | else |
| 1076 | 1076 | { |
@@ -1078,14 +1078,14 @@ discard block |
||
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | echo "\t<tr class='$class'>\n\t\t<td>$n</td>\n\t\t<td>". |
| 1081 | - Html::a_href(htmlspecialchars($name),'/groupdav.php'.strtr($file['path'], array( |
|
| 1081 | + Html::a_href(htmlspecialchars($name), '/groupdav.php'.strtr($file['path'], array( |
|
| 1082 | 1082 | '%' => '%25', |
| 1083 | 1083 | '#' => '%23', |
| 1084 | 1084 | '?' => '%3F', |
| 1085 | 1085 | )))."</td>\n"; |
| 1086 | - foreach($props2show as $prop => $label) |
|
| 1086 | + foreach ($props2show as $prop => $label) |
|
| 1087 | 1087 | { |
| 1088 | - echo "\t\t<td>".($prop=='DAV:getlastmodified'&&!empty($props[$prop])?date('Y-m-d H:i:s',$props[$prop]):$props[$prop])."</td>\n"; |
|
| 1088 | + echo "\t\t<td>".($prop == 'DAV:getlastmodified' && !empty($props[$prop]) ? date('Y-m-d H:i:s', $props[$prop]) : $props[$prop])."</td>\n"; |
|
| 1089 | 1089 | } |
| 1090 | 1090 | echo "\t</tr>\n"; |
| 1091 | 1091 | } |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | } |
| 1100 | 1100 | echo '<h3>'.lang('Properties')."</h3>\n"; |
| 1101 | 1101 | echo "<table>\n\t<tr class='th'><th>".lang('Namespace')."</th><th>".lang('Name')."</th><th>".lang('Value')."</th></tr>\n"; |
| 1102 | - foreach($collection_props as $name => $value) |
|
| 1102 | + foreach ($collection_props as $name => $value) |
|
| 1103 | 1103 | { |
| 1104 | 1104 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 1105 | 1105 | $parts = explode(':', $name); |
@@ -1147,11 +1147,11 @@ discard block |
||
| 1147 | 1147 | 'wrap' => 0, |
| 1148 | 1148 | )); |
| 1149 | 1149 | } |
| 1150 | - if (($href=preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i',$value))) |
|
| 1150 | + if (($href = preg_match('/\<(D:)?href\>[^<]+\<\/(D:)?href\>/i', $value))) |
|
| 1151 | 1151 | { |
| 1152 | - $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/','/').')?([^<]+)\<\/(D:)?href\>/i','<\\1href><a href="\\2\\3">\\3</a></\\4href>',$value); |
|
| 1152 | + $value = preg_replace('/\<(D:)?href\>('.preg_quote($this->base_uri.'/', '/').')?([^<]+)\<\/(D:)?href\>/i', '<\\1href><a href="\\2\\3">\\3</a></\\4href>', $value); |
|
| 1153 | 1153 | } |
| 1154 | - $ret = $value[0] == '<' || strpos($value, "\n") !== false ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value); |
|
| 1154 | + $ret = $value[0] == '<' || strpos($value, "\n") !== false ? '<pre>'.htmlspecialchars($value).'</pre>' : htmlspecialchars($value); |
|
| 1155 | 1155 | |
| 1156 | 1156 | if ($href) |
| 1157 | 1157 | { |
@@ -1169,10 +1169,10 @@ discard block |
||
| 1169 | 1169 | protected function props2array(array $props) |
| 1170 | 1170 | { |
| 1171 | 1171 | $arr = array(); |
| 1172 | - foreach($props as $prop) |
|
| 1172 | + foreach ($props as $prop) |
|
| 1173 | 1173 | { |
| 1174 | 1174 | $ns_hash = array('DAV:' => 'D'); |
| 1175 | - switch($prop['ns']) |
|
| 1175 | + switch ($prop['ns']) |
|
| 1176 | 1176 | { |
| 1177 | 1177 | case 'DAV:'; |
| 1178 | 1178 | $ns = 'DAV'; |
@@ -1191,10 +1191,10 @@ discard block |
||
| 1191 | 1191 | } |
| 1192 | 1192 | if (is_array($prop['val'])) |
| 1193 | 1193 | { |
| 1194 | - $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs='', $ns_hash); |
|
| 1194 | + $prop['val'] = $this->_hierarchical_prop_encode($prop['val'], $prop['ns'], $ns_defs = '', $ns_hash); |
|
| 1195 | 1195 | // hack to show real namespaces instead of not (visibly) defined shortcuts |
| 1196 | 1196 | unset($ns_hash['DAV:']); |
| 1197 | - $value = strtr($v=$this->prop_value($prop['val']),array_flip($ns_hash)); |
|
| 1197 | + $value = strtr($v = $this->prop_value($prop['val']), array_flip($ns_hash)); |
|
| 1198 | 1198 | } |
| 1199 | 1199 | else |
| 1200 | 1200 | { |
@@ -1217,13 +1217,13 @@ discard block |
||
| 1217 | 1217 | // POST to the collection URL plus a UID like name component (like for regular PUT) to create new entrys |
| 1218 | 1218 | if (isset($_GET['add-member']) || Handler::get_agent() == 'cfnetwork') |
| 1219 | 1219 | { |
| 1220 | - $_GET['add-member'] = ''; // otherwise we give no Location header |
|
| 1220 | + $_GET['add-member'] = ''; // otherwise we give no Location header |
|
| 1221 | 1221 | return $this->PUT($options); |
| 1222 | 1222 | } |
| 1223 | 1223 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
| 1224 | 1224 | |
| 1225 | 1225 | $id = $app = $user = null; |
| 1226 | - $this->_parse_path($options['path'],$id,$app,$user); |
|
| 1226 | + $this->_parse_path($options['path'], $id, $app, $user); |
|
| 1227 | 1227 | |
| 1228 | 1228 | if (($handler = self::app_handler($app))) |
| 1229 | 1229 | { |
@@ -1239,12 +1239,12 @@ discard block |
||
| 1239 | 1239 | if (isset($options['stream'])) |
| 1240 | 1240 | { |
| 1241 | 1241 | $options['content'] = ''; |
| 1242 | - while(!feof($options['stream'])) |
|
| 1242 | + while (!feof($options['stream'])) |
|
| 1243 | 1243 | { |
| 1244 | - $options['content'] .= fread($options['stream'],8192); |
|
| 1244 | + $options['content'] .= fread($options['stream'], 8192); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | } |
| 1247 | - return $handler->post($options,$id,$user); |
|
| 1247 | + return $handler->post($options, $id, $user); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | } |
| 1250 | 1250 | return '501 Not Implemented'; |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | return '403 Forbidden'; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | - switch($action) |
|
| 1286 | + switch ($action) |
|
| 1287 | 1287 | { |
| 1288 | 1288 | case 'attachment-add': |
| 1289 | 1289 | $matches = null; |
@@ -1295,8 +1295,8 @@ discard block |
||
| 1295 | 1295 | } |
| 1296 | 1296 | $path = null; |
| 1297 | 1297 | if (!($to = self::fopen_attachment($handler->app, $handler->get_id($entry), $filename, $this->_SERVER['CONTENT_TYPE'], $path)) || |
| 1298 | - isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false || |
|
| 1299 | - isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false) |
|
| 1298 | + isset($options['stream']) && ($copied = stream_copy_to_stream($options['stream'], $to)) === false || |
|
| 1299 | + isset($options['content']) && ($copied = fwrite($to, $options['content'])) === false) |
|
| 1300 | 1300 | { |
| 1301 | 1301 | return '403 Forbidden'; |
| 1302 | 1302 | } |
@@ -1339,8 +1339,8 @@ discard block |
||
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | if (!($to = Vfs::fopen($path, 'w')) || |
| 1342 | - isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false || |
|
| 1343 | - isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false) |
|
| 1342 | + isset($options['stream']) && ($copied = stream_copy_to_stream($options['stream'], $to)) === false || |
|
| 1343 | + isset($options['content']) && ($copied = fwrite($to, $options['content'])) === false) |
|
| 1344 | 1344 | { |
| 1345 | 1345 | self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id-parameter', '')); |
| 1346 | 1346 | return '403 Forbidden'; |
@@ -1382,23 +1382,23 @@ discard block |
||
| 1382 | 1382 | * @param boolean $delete_via_put |
| 1383 | 1383 | * @return boolean false on error, eg. invalid managed id, for false an xml-error body has been send |
| 1384 | 1384 | */ |
| 1385 | - public static function handle_attach($app, $id, $attach, $delete_via_put=false) |
|
| 1385 | + public static function handle_attach($app, $id, $attach, $delete_via_put = false) |
|
| 1386 | 1386 | { |
| 1387 | 1387 | //error_log(__METHOD__."('$app', $id, attach=".array2string($attach).", delete_via_put=".array2string($delete_via_put).')'); |
| 1388 | 1388 | |
| 1389 | 1389 | if (!Link::file_access($app, $id, Acl::EDIT)) |
| 1390 | 1390 | { |
| 1391 | 1391 | error_log(__METHOD__."('$app', $id, ...) no rights to update attachments"); |
| 1392 | - return; // no rights --> nothing to do |
|
| 1392 | + return; // no rights --> nothing to do |
|
| 1393 | 1393 | } |
| 1394 | - if (!is_array($attach)) $attach = array(); // could be PEAR_Error if not set |
|
| 1394 | + if (!is_array($attach)) $attach = array(); // could be PEAR_Error if not set |
|
| 1395 | 1395 | |
| 1396 | 1396 | if ($delete_via_put) |
| 1397 | 1397 | { |
| 1398 | - foreach(Vfs::find(Link::vfs_path($app, $id, '', true), array('type' => 'F')) as $path) |
|
| 1398 | + foreach (Vfs::find(Link::vfs_path($app, $id, '', true), array('type' => 'F')) as $path) |
|
| 1399 | 1399 | { |
| 1400 | 1400 | $found = false; |
| 1401 | - foreach($attach as $key => $attr) |
|
| 1401 | + foreach ($attach as $key => $attr) |
|
| 1402 | 1402 | { |
| 1403 | 1403 | if ($attr['params']['MANAGED-ID'] === self::path2managed_id($path)) |
| 1404 | 1404 | { |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | } |
| 1416 | 1416 | } |
| 1417 | 1417 | // turn inline attachments into managed ones |
| 1418 | - foreach($attach as $key => $attr) |
|
| 1418 | + foreach ($attach as $key => $attr) |
|
| 1419 | 1419 | { |
| 1420 | 1420 | if (!empty($attr['params']['FMTTYPE'])) |
| 1421 | 1421 | { |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id', '')); |
| 1429 | 1429 | return false; |
| 1430 | 1430 | } |
| 1431 | - if($path == ($link = Link::vfs_path($app, $id, Vfs::basename($path)))) |
|
| 1431 | + if ($path == ($link = Link::vfs_path($app, $id, Vfs::basename($path)))) |
|
| 1432 | 1432 | { |
| 1433 | 1433 | error_log(__METHOD__."('$app', $id, ...) trying to modify existing MANAGED-ID --> ignored! ".array2string($attr)); |
| 1434 | 1434 | continue; |
@@ -1436,8 +1436,8 @@ discard block |
||
| 1436 | 1436 | // reuse valid managed-id --> symlink attachment |
| 1437 | 1437 | if (Vfs::file_exists($link)) |
| 1438 | 1438 | { |
| 1439 | - if (Vfs::readlink($link) === $path) continue; // no need to recreate identical link |
|
| 1440 | - Vfs::unlink($link); // symlink will fail, if $link exists |
|
| 1439 | + if (Vfs::readlink($link) === $path) continue; // no need to recreate identical link |
|
| 1440 | + Vfs::unlink($link); // symlink will fail, if $link exists |
|
| 1441 | 1441 | } |
| 1442 | 1442 | if (!Vfs::symlink($path, $link)) |
| 1443 | 1443 | { |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | } |
| 1446 | 1446 | continue; |
| 1447 | 1447 | } |
| 1448 | - if (!($to = self::fopen_attachment($app, $id, $filename=$attr['params']['FILENAME'], $attr['params']['FMTTYPE'], $path)) || |
|
| 1448 | + if (!($to = self::fopen_attachment($app, $id, $filename = $attr['params']['FILENAME'], $attr['params']['FMTTYPE'], $path)) || |
|
| 1449 | 1449 | // Horde Icalendar does NOT decode automatic |
| 1450 | 1450 | (/*$copied=*/fwrite($to, $attr['params']['ENCODING'] == 'BASE64' ? base64_decode($attr['value']) : $attr['value'])) === false) |
| 1451 | 1451 | { |
@@ -1472,16 +1472,16 @@ discard block |
||
| 1472 | 1472 | * @param string &$path =null on return path opened |
| 1473 | 1473 | * @return resource |
| 1474 | 1474 | */ |
| 1475 | - protected static function fopen_attachment($app, $id, $_filename, $mime=null, &$path=null) |
|
| 1475 | + protected static function fopen_attachment($app, $id, $_filename, $mime = null, &$path = null) |
|
| 1476 | 1476 | { |
| 1477 | 1477 | $filename = empty($_filename) ? 'attachment' : Vfs::basename($_filename); |
| 1478 | 1478 | |
| 1479 | - if (strpos($mime, ';')) list($mime) = explode(';', $mime); // in case it contains eg. charset info |
|
| 1479 | + if (strpos($mime, ';')) list($mime) = explode(';', $mime); // in case it contains eg. charset info |
|
| 1480 | 1480 | |
| 1481 | 1481 | $ext = !empty($mime) ? MimeMagic::mime2ext($mime) : ''; |
| 1482 | 1482 | |
| 1483 | 1483 | $matches = null; |
| 1484 | - if (!$ext || substr($filename, -strlen($ext)-1) == '.'.$ext || |
|
| 1484 | + if (!$ext || substr($filename, -strlen($ext) - 1) == '.'.$ext || |
|
| 1485 | 1485 | preg_match('/\.([^.]+)$/', $filename, $matches) && MimeMagic::ext2mime($matches[1]) == $mime) |
| 1486 | 1486 | { |
| 1487 | 1487 | $parts = explode('.', $filename); |
@@ -1492,7 +1492,7 @@ discard block |
||
| 1492 | 1492 | { |
| 1493 | 1493 | $ext = '.'.$ext; |
| 1494 | 1494 | } |
| 1495 | - for($i = 1; $i < 100; ++$i) |
|
| 1495 | + for ($i = 1; $i < 100; ++$i) |
|
| 1496 | 1496 | { |
| 1497 | 1497 | $path = Link::vfs_path($app, $id, $filename.($i > 1 ? '-'.$i : '').$ext, true); |
| 1498 | 1498 | if (!Vfs::stat($path)) break; |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | */ |
| 1539 | 1539 | public static function add_attach($app, $id, array &$attributes, array &$parameters) |
| 1540 | 1540 | { |
| 1541 | - foreach(Vfs::find(Link::vfs_path($app, $id, '', true), array( |
|
| 1541 | + foreach (Vfs::find(Link::vfs_path($app, $id, '', true), array( |
|
| 1542 | 1542 | 'type' => 'F', |
| 1543 | 1543 | 'need_mime' => true, |
| 1544 | 1544 | ), true) as $path => $stat) |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | // handle symlinks --> return target size and mime-type |
| 1547 | 1547 | if (($target = Vfs::readlink($path))) |
| 1548 | 1548 | { |
| 1549 | - if (!($stat = Vfs::stat($target))) continue; // broken or inaccessible symlink |
|
| 1549 | + if (!($stat = Vfs::stat($target))) continue; // broken or inaccessible symlink |
|
| 1550 | 1550 | |
| 1551 | 1551 | // check if target is in /apps, probably reused MANAGED-ID --> return it |
| 1552 | 1552 | if (substr($target, 0, 6) == '/apps/') |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | $parameters['ATTACH'][] = array( |
| 1559 | 1559 | 'MANAGED-ID' => self::path2managed_id($path), |
| 1560 | 1560 | 'FMTTYPE' => $stat['mime'], |
| 1561 | - 'SIZE' => (string)$stat['size'], // Horde_Icalendar renders int as empty string |
|
| 1561 | + 'SIZE' => (string)$stat['size'], // Horde_Icalendar renders int as empty string |
|
| 1562 | 1562 | 'FILENAME' => Vfs::basename($path), |
| 1563 | 1563 | ); |
| 1564 | 1564 | // if we have attachments, set X-attribute to enable deleting them by put |
@@ -1586,7 +1586,7 @@ discard block |
||
| 1586 | 1586 | * @param string|int $id =null id to check agains path |
| 1587 | 1587 | * @return string|boolean "/apps/$app/$id/something" or false if not found or not belonging to given $app/$id |
| 1588 | 1588 | */ |
| 1589 | - static public function managed_id2path($managed_id, $app=null, $id=null) |
|
| 1589 | + static public function managed_id2path($managed_id, $app = null, $id = null) |
|
| 1590 | 1590 | { |
| 1591 | 1591 | $path = base64_decode($managed_id); |
| 1592 | 1592 | |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | } |
| 1597 | 1597 | elseif (!empty($app) && !empty($id)) |
| 1598 | 1598 | { |
| 1599 | - list(,,$a,$i) = explode('/', $path); |
|
| 1599 | + list(,, $a, $i) = explode('/', $path); |
|
| 1600 | 1600 | if ($a !== $app || $i !== (string)$id) |
| 1601 | 1601 | { |
| 1602 | 1602 | $path = false; |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | 'displayname' => self::DAV, |
| 1625 | 1625 | 'calendar-description' => self::CALDAV, |
| 1626 | 1626 | 'addressbook-description' => self::CARDDAV, |
| 1627 | - 'calendar-color' => self::ICAL, // only mentioned that old prefs still work |
|
| 1627 | + 'calendar-color' => self::ICAL, // only mentioned that old prefs still work |
|
| 1628 | 1628 | 'calendar-order' => self::ICAL, |
| 1629 | 1629 | 'default-alarm-vevent-date' => self::CALDAV, |
| 1630 | 1630 | 'default-alarm-vevent-datetime' => self::CALDAV, |
@@ -1642,11 +1642,11 @@ discard block |
||
| 1642 | 1642 | |
| 1643 | 1643 | // parse path in form [/account_lid]/app[/more] |
| 1644 | 1644 | $id = $app = $user = $user_prefix = null; |
| 1645 | - self::_parse_path($options['path'],$id,$app,$user,$user_prefix); // allways returns false if eg. !$id |
|
| 1645 | + self::_parse_path($options['path'], $id, $app, $user, $user_prefix); // allways returns false if eg. !$id |
|
| 1646 | 1646 | if ($app == 'principals' || $id || $options['path'] == '/') |
| 1647 | 1647 | { |
| 1648 | 1648 | if ($this->debug > 1) error_log(__METHOD__.": user='$user', app='$app', id='$id': 404 not found!"); |
| 1649 | - foreach($options['props'] as &$prop) |
|
| 1649 | + foreach ($options['props'] as &$prop) |
|
| 1650 | 1650 | { |
| 1651 | 1651 | $prop['status'] = '403 Forbidden'; |
| 1652 | 1652 | } |
@@ -1654,10 +1654,10 @@ discard block |
||
| 1654 | 1654 | } |
| 1655 | 1655 | // store selected props in preferences, eg. calendar-color, see self::$proppatch_props |
| 1656 | 1656 | $need_save = array(); |
| 1657 | - foreach($options['props'] as &$prop) |
|
| 1657 | + foreach ($options['props'] as &$prop) |
|
| 1658 | 1658 | { |
| 1659 | 1659 | if ((isset(self::$proppatch_props[$prop['name']]) && self::$proppatch_props[$prop['name']] === $prop['xmlns'] || |
| 1660 | - !in_array($prop['xmlns'],self::$ns_needs_explicit_named_props))) |
|
| 1660 | + !in_array($prop['xmlns'], self::$ns_needs_explicit_named_props))) |
|
| 1661 | 1661 | { |
| 1662 | 1662 | if (!$app) |
| 1663 | 1663 | { |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | } |
| 1687 | 1687 | else |
| 1688 | 1688 | { |
| 1689 | - $prop['status'] = '409 Conflict'; // could also be "403 Forbidden" |
|
| 1689 | + $prop['status'] = '409 Conflict'; // could also be "403 Forbidden" |
|
| 1690 | 1690 | } |
| 1691 | 1691 | } |
| 1692 | 1692 | if ($need_save) |
@@ -1695,7 +1695,7 @@ discard block |
||
| 1695 | 1695 | // call calendar-hook, if default-alarms are changed, to sync them to calendar prefs |
| 1696 | 1696 | if (class_exists('calendar_hooks')) |
| 1697 | 1697 | { |
| 1698 | - foreach($need_save as $name) |
|
| 1698 | + foreach ($need_save as $name) |
|
| 1699 | 1699 | { |
| 1700 | 1700 | list($name) = explode(':', $name); |
| 1701 | 1701 | if (in_array($name, array('default-alarm-vevent-date', 'default-alarm-vevent-datetime'))) |
@@ -1720,22 +1720,22 @@ discard block |
||
| 1720 | 1720 | if (isset($options['stream'])) |
| 1721 | 1721 | { |
| 1722 | 1722 | $options['content'] = ''; |
| 1723 | - while(!feof($options['stream'])) |
|
| 1723 | + while (!feof($options['stream'])) |
|
| 1724 | 1724 | { |
| 1725 | - $options['content'] .= fread($options['stream'],8192); |
|
| 1725 | + $options['content'] .= fread($options['stream'], 8192); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
| 1730 | 1730 | |
| 1731 | 1731 | $id = $app = $user = $prefix = null; |
| 1732 | - if (!$this->_parse_path($options['path'],$id,$app,$user,$prefix)) |
|
| 1732 | + if (!$this->_parse_path($options['path'], $id, $app, $user, $prefix)) |
|
| 1733 | 1733 | { |
| 1734 | 1734 | return '404 Not Found'; |
| 1735 | 1735 | } |
| 1736 | 1736 | if (($handler = self::app_handler($app))) |
| 1737 | 1737 | { |
| 1738 | - $status = $handler->put($options,$id,$user,$prefix); |
|
| 1738 | + $status = $handler->put($options, $id, $user, $prefix); |
|
| 1739 | 1739 | |
| 1740 | 1740 | // set default stati: true --> 204 No Content, false --> should be already handled |
| 1741 | 1741 | if (is_bool($status)) $status = $status ? '204 No Content' : '400 Something went wrong'; |
@@ -1765,13 +1765,13 @@ discard block |
||
| 1765 | 1765 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).')'); |
| 1766 | 1766 | |
| 1767 | 1767 | $id = $app = $user = null; |
| 1768 | - if (!$this->_parse_path($options['path'],$id,$app,$user)) |
|
| 1768 | + if (!$this->_parse_path($options['path'], $id, $app, $user)) |
|
| 1769 | 1769 | { |
| 1770 | 1770 | return '404 Not Found'; |
| 1771 | 1771 | } |
| 1772 | 1772 | if (($handler = self::app_handler($app))) |
| 1773 | 1773 | { |
| 1774 | - $status = $handler->delete($options,$id); |
|
| 1774 | + $status = $handler->delete($options, $id); |
|
| 1775 | 1775 | // set default stati: true --> 204 No Content, false --> should be already handled |
| 1776 | 1776 | if (is_bool($status)) $status = $status ? '204 No Content' : '400 Something went wrong'; |
| 1777 | 1777 | return $status; |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | * @param array general parameter passing array |
| 1812 | 1812 | * @return bool true on success |
| 1813 | 1813 | */ |
| 1814 | - function COPY($options, $del=false) |
|
| 1814 | + function COPY($options, $del = false) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | if ($this->debug) error_log('self::'.($del ? 'MOVE' : 'COPY').'('.array2string($options).')'); |
| 1817 | 1817 | |
@@ -1827,8 +1827,8 @@ discard block |
||
| 1827 | 1827 | function LOCK(&$options) |
| 1828 | 1828 | { |
| 1829 | 1829 | $id = $app = $user = null; |
| 1830 | - self::_parse_path($options['path'],$id,$app,$user); |
|
| 1831 | - $path = Vfs::app_entry_lock_path($app,$id); |
|
| 1830 | + self::_parse_path($options['path'], $id, $app, $user); |
|
| 1831 | + $path = Vfs::app_entry_lock_path($app, $id); |
|
| 1832 | 1832 | |
| 1833 | 1833 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$path"); |
| 1834 | 1834 | |
@@ -1836,16 +1836,16 @@ discard block |
||
| 1836 | 1836 | $handler = self::app_handler($app); |
| 1837 | 1837 | |
| 1838 | 1838 | // TODO recursive locks on directories not supported yet |
| 1839 | - if (!$id || !empty($options['depth']) || !$handler->check_access(Acl::EDIT,$id)) |
|
| 1839 | + if (!$id || !empty($options['depth']) || !$handler->check_access(Acl::EDIT, $id)) |
|
| 1840 | 1840 | { |
| 1841 | 1841 | return '409 Conflict'; |
| 1842 | 1842 | } |
| 1843 | - $options['timeout'] = time()+300; // 5min. hardcoded |
|
| 1843 | + $options['timeout'] = time() + 300; // 5min. hardcoded |
|
| 1844 | 1844 | |
| 1845 | 1845 | // dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND |
| 1846 | 1846 | // that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags |
| 1847 | - if (($ret = Vfs::lock($path,$options['locktoken'],$options['timeout'],strip_tags($options['owner']), |
|
| 1848 | - $options['scope'],$options['type'],isset($options['update']),false)) && !isset($options['update'])) // false = no ACL check |
|
| 1847 | + if (($ret = Vfs::lock($path, $options['locktoken'], $options['timeout'], strip_tags($options['owner']), |
|
| 1848 | + $options['scope'], $options['type'], isset($options['update']), false)) && !isset($options['update'])) // false = no ACL check |
|
| 1849 | 1849 | { |
| 1850 | 1850 | return $ret ? '200 OK' : '409 Conflict'; |
| 1851 | 1851 | } |
@@ -1861,11 +1861,11 @@ discard block |
||
| 1861 | 1861 | function UNLOCK(&$options) |
| 1862 | 1862 | { |
| 1863 | 1863 | $id = $app = $user = null; |
| 1864 | - self::_parse_path($options['path'],$id,$app,$user); |
|
| 1865 | - $path = Vfs::app_entry_lock_path($app,$id); |
|
| 1864 | + self::_parse_path($options['path'], $id, $app, $user); |
|
| 1865 | + $path = Vfs::app_entry_lock_path($app, $id); |
|
| 1866 | 1866 | |
| 1867 | 1867 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$path"); |
| 1868 | - return Vfs::unlock($path,$options['token']) ? '204 No Content' : '409 Conflict'; |
|
| 1868 | + return Vfs::unlock($path, $options['token']) ? '204 No Content' : '409 Conflict'; |
|
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
@@ -1877,7 +1877,7 @@ discard block |
||
| 1877 | 1877 | function checkLock($path) |
| 1878 | 1878 | { |
| 1879 | 1879 | $id = $app = $user = null; |
| 1880 | - self::_parse_path($path,$id,$app,$user); |
|
| 1880 | + self::_parse_path($path, $id, $app, $user); |
|
| 1881 | 1881 | |
| 1882 | 1882 | return Vfs::checkLock(Vfs::app_entry_lock_path($app, $id)); |
| 1883 | 1883 | } |
@@ -1891,7 +1891,7 @@ discard block |
||
| 1891 | 1891 | function ACL(&$options) |
| 1892 | 1892 | { |
| 1893 | 1893 | $id = $app = $user = null; |
| 1894 | - self::_parse_path($options['path'],$id,$app,$user); |
|
| 1894 | + self::_parse_path($options['path'], $id, $app, $user); |
|
| 1895 | 1895 | |
| 1896 | 1896 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).") path=$options[path]"); |
| 1897 | 1897 | |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | * @param string &$user_prefix =null |
| 1922 | 1922 | * @return boolean true on success, false on error |
| 1923 | 1923 | */ |
| 1924 | - function _parse_path($path,&$id,&$app,&$user,&$user_prefix=null) |
|
| 1924 | + function _parse_path($path, &$id, &$app, &$user, &$user_prefix = null) |
|
| 1925 | 1925 | { |
| 1926 | 1926 | if ($this->debug) |
| 1927 | 1927 | { |
@@ -1950,7 +1950,7 @@ discard block |
||
| 1950 | 1950 | } |
| 1951 | 1951 | } |
| 1952 | 1952 | elseif (($account_id = $this->accounts->name2id($parts[0], 'account_lid')) || |
| 1953 | - ($account_id = $this->accounts->name2id($parts[0]=urldecode($parts[0])))) |
|
| 1953 | + ($account_id = $this->accounts->name2id($parts[0] = urldecode($parts[0])))) |
|
| 1954 | 1954 | { |
| 1955 | 1955 | // /$user/$app/... |
| 1956 | 1956 | $user = array_shift($parts); |
@@ -1974,7 +1974,7 @@ discard block |
||
| 1974 | 1974 | { |
| 1975 | 1975 | $account_id = 0; |
| 1976 | 1976 | } |
| 1977 | - elseif($app == 'resource' || $app == 'location') |
|
| 1977 | + elseif ($app == 'resource' || $app == 'location') |
|
| 1978 | 1978 | { |
| 1979 | 1979 | if (!Principals::read_resource($res_id = (int)$username)) |
| 1980 | 1980 | { |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | $app = 'calendar'; |
| 1985 | 1985 | } |
| 1986 | 1986 | elseif (!($account_id = $this->accounts->name2id($username, 'account_lid')) && |
| 1987 | - !($account_id = $this->accounts->name2id($username=urldecode($username)))) |
|
| 1987 | + !($account_id = $this->accounts->name2id($username = urldecode($username)))) |
|
| 1988 | 1988 | { |
| 1989 | 1989 | return false; |
| 1990 | 1990 | } |
@@ -2009,11 +2009,11 @@ discard block |
||
| 2009 | 2009 | $id = array_pop($parts); |
| 2010 | 2010 | |
| 2011 | 2011 | $ok = ($id || isset($_GET['add-member']) && $_SERVER['REQUEST_METHOD'] == 'POST') && |
| 2012 | - ($user || $user === 0) && in_array($app,array('addressbook','calendar','infolog','principals')); |
|
| 2012 | + ($user || $user === 0) && in_array($app, array('addressbook', 'calendar', 'infolog', 'principals')); |
|
| 2013 | 2013 | |
| 2014 | 2014 | if ($this->debug) |
| 2015 | 2015 | { |
| 2016 | - error_log(__METHOD__."('$path') returning " . ($ok ? 'true' : 'false') . ": id='$id', app='$app', user='$user', user_prefix='$user_prefix'"); |
|
| 2016 | + error_log(__METHOD__."('$path') returning ".($ok ? 'true' : 'false').": id='$id', app='$app', user='$user', user_prefix='$user_prefix'"); |
|
| 2017 | 2017 | } |
| 2018 | 2018 | return $ok; |
| 2019 | 2019 | } |
@@ -2035,9 +2035,9 @@ discard block |
||
| 2035 | 2035 | * |
| 2036 | 2036 | * @param $prefix =null prefix filesystem path with given path, eg. "/webdav" for owncloud 4.5 remote.php |
| 2037 | 2037 | */ |
| 2038 | - function ServeRequest($prefix=null) |
|
| 2038 | + function ServeRequest($prefix = null) |
|
| 2039 | 2039 | { |
| 2040 | - if ((self::$log_level=$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']) === 'r' || |
|
| 2040 | + if ((self::$log_level = $GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']) === 'r' || |
|
| 2041 | 2041 | self::$log_level === 'f' || $this->debug) |
| 2042 | 2042 | { |
| 2043 | 2043 | self::$request_starttime = microtime(true); |
@@ -2057,7 +2057,7 @@ discard block |
||
| 2057 | 2057 | * |
| 2058 | 2058 | * @param string $extra ='' extra text to add below request-log, eg. exception thrown |
| 2059 | 2059 | */ |
| 2060 | - protected function log_request($extra='') |
|
| 2060 | + protected function log_request($extra = '') |
|
| 2061 | 2061 | { |
| 2062 | 2062 | if (self::$request_starttime) |
| 2063 | 2063 | { |
@@ -2065,7 +2065,7 @@ discard block |
||
| 2065 | 2065 | { |
| 2066 | 2066 | $msg_file = $GLOBALS['egw_info']['server']['files_dir']; |
| 2067 | 2067 | $msg_file .= '/groupdav'; |
| 2068 | - if (!file_exists($msg_file) && !mkdir($msg_file,0700)) |
|
| 2068 | + if (!file_exists($msg_file) && !mkdir($msg_file, 0700)) |
|
| 2069 | 2069 | { |
| 2070 | 2070 | error_log(__METHOD__."() Could NOT create directory '$msg_file'!"); |
| 2071 | 2071 | return; |
@@ -2078,19 +2078,19 @@ discard block |
||
| 2078 | 2078 | } |
| 2079 | 2079 | else |
| 2080 | 2080 | { |
| 2081 | - $msg_file .= str_replace('/','!',$_SERVER['HTTP_USER_AGENT']).'.log'; |
|
| 2081 | + $msg_file .= str_replace('/', '!', $_SERVER['HTTP_USER_AGENT']).'.log'; |
|
| 2082 | 2082 | } |
| 2083 | 2083 | $content = '*** '.$_SERVER['REMOTE_ADDR'].' '.date('c')."\n"; |
| 2084 | 2084 | } |
| 2085 | 2085 | $content .= $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' HTTP/1.1'."\n"; |
| 2086 | 2086 | // reconstruct headers |
| 2087 | - foreach($_SERVER as $name => $value) |
|
| 2087 | + foreach ($_SERVER as $name => $value) |
|
| 2088 | 2088 | { |
| 2089 | - list($type,$name) = explode('_',$name,2); |
|
| 2089 | + list($type, $name) = explode('_', $name, 2); |
|
| 2090 | 2090 | if ($type == 'HTTP' || $type == 'CONTENT') |
| 2091 | 2091 | { |
| 2092 | - $content .= str_replace(' ','-',ucwords(strtolower(($type=='HTTP'?'':$type.' ').str_replace('_',' ',$name)))). |
|
| 2093 | - ': '.($name=='AUTHORIZATION'?'Basic ***************':$value)."\n"; |
|
| 2092 | + $content .= str_replace(' ', '-', ucwords(strtolower(($type == 'HTTP' ? '' : $type.' ').str_replace('_', ' ', $name)))). |
|
| 2093 | + ': '.($name == 'AUTHORIZATION' ? 'Basic ***************' : $value)."\n"; |
|
| 2094 | 2094 | } |
| 2095 | 2095 | } |
| 2096 | 2096 | $content .= "\n"; |
@@ -2101,29 +2101,29 @@ discard block |
||
| 2101 | 2101 | $content .= 'HTTP/1.1 '.$this->_http_status."\n"; |
| 2102 | 2102 | $content .= 'Date: '.str_replace('+0000', 'GMT', gmdate('r'))."\n"; |
| 2103 | 2103 | $content .= 'Server: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
| 2104 | - foreach(headers_list() as $line) |
|
| 2104 | + foreach (headers_list() as $line) |
|
| 2105 | 2105 | { |
| 2106 | 2106 | $content .= $line."\n"; |
| 2107 | 2107 | } |
| 2108 | 2108 | if (($c = ob_get_flush())) $content .= "\n"; |
| 2109 | - if (self::$log_level !== 'f' && strlen($c) > 1536) $c = substr($c,0,1536)."\n*** LOG TRUNKATED\n"; |
|
| 2109 | + if (self::$log_level !== 'f' && strlen($c) > 1536) $c = substr($c, 0, 1536)."\n*** LOG TRUNKATED\n"; |
|
| 2110 | 2110 | $content .= $c; |
| 2111 | 2111 | if ($extra) $content .= $extra; |
| 2112 | 2112 | if ($this->to_log) $content .= "\n### ".implode("\n### ", $this->to_log)."\n"; |
| 2113 | - $content .= $this->_http_status[0] == '4' && substr($this->_http_status,0,3) != '412' || |
|
| 2114 | - $this->_http_status[0] == '5' ? '###' : '***'; // mark failed requests with ###, instead of *** |
|
| 2115 | - $content .= sprintf(' %s --> "%s" took %5.3f s',$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$this->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$this->_http_status,microtime(true)-self::$request_starttime)."\n\n"; |
|
| 2113 | + $content .= $this->_http_status[0] == '4' && substr($this->_http_status, 0, 3) != '412' || |
|
| 2114 | + $this->_http_status[0] == '5' ? '###' : '***'; // mark failed requests with ###, instead of *** |
|
| 2115 | + $content .= sprintf(' %s --> "%s" took %5.3f s', $_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD'] == 'REPORT' ? ' '.$this->propfind_options['root']['name'] : '').' '.$_SERVER['PATH_INFO'], $this->_http_status, microtime(true) - self::$request_starttime)."\n\n"; |
|
| 2116 | 2116 | |
| 2117 | - if ($msg_file && ($f = fopen($msg_file,'a'))) |
|
| 2117 | + if ($msg_file && ($f = fopen($msg_file, 'a'))) |
|
| 2118 | 2118 | { |
| 2119 | - flock($f,LOCK_EX); |
|
| 2120 | - fwrite($f,$content); |
|
| 2121 | - flock($f,LOCK_UN); |
|
| 2119 | + flock($f, LOCK_EX); |
|
| 2120 | + fwrite($f, $content); |
|
| 2121 | + flock($f, LOCK_UN); |
|
| 2122 | 2122 | fclose($f); |
| 2123 | 2123 | } |
| 2124 | 2124 | else |
| 2125 | 2125 | { |
| 2126 | - foreach(explode("\n",$content) as $line) |
|
| 2126 | + foreach (explode("\n", $content) as $line) |
|
| 2127 | 2127 | { |
| 2128 | 2128 | error_log($line); |
| 2129 | 2129 | } |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | * @param string|array $xml_error string with name for empty element in DAV NS or array with props |
| 2138 | 2138 | * @param string $human_readable =null human readable error message |
| 2139 | 2139 | */ |
| 2140 | - public static function xml_error($xml_error, $human_readable=null) |
|
| 2140 | + public static function xml_error($xml_error, $human_readable = null) |
|
| 2141 | 2141 | { |
| 2142 | 2142 | header('Content-type: application/xml; charset=utf-8'); |
| 2143 | 2143 | |
@@ -2154,7 +2154,7 @@ discard block |
||
| 2154 | 2154 | $xml->writeElement('responsedescription', $human_readable); |
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | - $xml->endElement(); // DAV:error |
|
| 2157 | + $xml->endElement(); // DAV:error |
|
| 2158 | 2158 | $xml->endDocument(); |
| 2159 | 2159 | echo $xml->outputMemory(); |
| 2160 | 2160 | } |
@@ -2170,7 +2170,7 @@ discard block |
||
| 2170 | 2170 | if (is_string($props)) $props = self::mkprop($props, ''); |
| 2171 | 2171 | if (isset($props['name'])) $props = array($props); |
| 2172 | 2172 | |
| 2173 | - foreach($props as $prop) |
|
| 2173 | + foreach ($props as $prop) |
|
| 2174 | 2174 | { |
| 2175 | 2175 | if (isset($prop['ns']) && $prop['ns'] !== 'DAV:') |
| 2176 | 2176 | { |
@@ -2222,7 +2222,7 @@ discard block |
||
| 2222 | 2222 | { |
| 2223 | 2223 | // logging exception as regular egw_execption_hander does |
| 2224 | 2224 | $headline = null; |
| 2225 | - _egw_log_exception($e,$headline); |
|
| 2225 | + _egw_log_exception($e, $headline); |
|
| 2226 | 2226 | |
| 2227 | 2227 | // exception handler sending message back to the client as basic auth message |
| 2228 | 2228 | $error = str_replace(array("\r", "\n"), array('', ' | '), $e->getMessage()); |
@@ -2233,7 +2233,7 @@ discard block |
||
| 2233 | 2233 | // if our own logging is active, log the request plus a trace, if enabled in server-config |
| 2234 | 2234 | if (self::$request_starttime && isset(self::$instance)) |
| 2235 | 2235 | { |
| 2236 | - self::$instance->_http_status = '401 Unauthorized'; // to correctly log it |
|
| 2236 | + self::$instance->_http_status = '401 Unauthorized'; // to correctly log it |
|
| 2237 | 2237 | if ($GLOBALS['egw_info']['server']['exception_show_trace']) |
| 2238 | 2238 | { |
| 2239 | 2239 | self::$instance->log_request("\n".$e->getTraceAsString()."\n"); |
@@ -2255,7 +2255,7 @@ discard block |
||
| 2255 | 2255 | */ |
| 2256 | 2256 | static function generate_uid($_appName, $_eventID) |
| 2257 | 2257 | { |
| 2258 | - if(empty($_appName) || empty($_eventID)) return false; |
|
| 2258 | + if (empty($_appName) || empty($_eventID)) return false; |
|
| 2259 | 2259 | |
| 2260 | 2260 | return $_appName.'-'.$_eventID.'-'.$GLOBALS['egw_info']['server']['install_id']; |
| 2261 | 2261 | } |