@@ -127,8 +127,7 @@ |
||
127 | 127 | /** |
128 | 128 | * Show files shared |
129 | 129 | * |
130 | - * @param array $content=null |
|
131 | - * @param string $msg='' |
|
130 | + * @param array $content |
|
132 | 131 | */ |
133 | 132 | public function index(array $content=null) |
134 | 133 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $readonlys = null; |
90 | 90 | $total = Sharing::so()->get_rows($query, $rows, $readonlys); |
91 | 91 | |
92 | - foreach($rows as &$row) |
|
92 | + foreach ($rows as &$row) |
|
93 | 93 | { |
94 | 94 | if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir) |
95 | 95 | { |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | * @param array $content=null |
131 | 131 | * @param string $msg='' |
132 | 132 | */ |
133 | - public function index(array $content=null) |
|
133 | + public function index(array $content = null) |
|
134 | 134 | { |
135 | 135 | if (!is_array($content)) |
136 | 136 | { |
137 | 137 | $content = array( |
138 | 138 | 'nm' => array( |
139 | - 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
140 | - 'no_filter' => True, // current dir only |
|
141 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
142 | - 'no_cat' => True, // I disable the cat-selectbox |
|
143 | - 'lettersearch' => false, // I show a lettersearch |
|
144 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
145 | - 'start' => 0, // IO position in list |
|
146 | - 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
147 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
139 | + 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
140 | + 'no_filter' => True, // current dir only |
|
141 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
142 | + 'no_cat' => True, // I disable the cat-selectbox |
|
143 | + 'lettersearch' => false, // I show a lettersearch |
|
144 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
145 | + 'start' => 0, // IO position in list |
|
146 | + 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
147 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
148 | 148 | //'default_cols' => '!', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
149 | 149 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
150 | 150 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | elseif ($content['nm']['action']) |
158 | 158 | { |
159 | - switch($content['nm']['action']) |
|
159 | + switch ($content['nm']['action']) |
|
160 | 160 | { |
161 | 161 | case 'delete': |
162 | 162 | $where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']); |
@@ -101,7 +101,10 @@ |
||
101 | 101 | $row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY; |
102 | 102 | } |
103 | 103 | $row['share_passwd'] = (boolean)$row['share_passwd']; |
104 | - if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
104 | + if ($row['share_with']) |
|
105 | + { |
|
106 | + $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
107 | + } |
|
105 | 108 | } |
106 | 109 | return $total; |
107 | 110 | } |
@@ -536,6 +536,9 @@ discard block |
||
536 | 536 | * @param int &$errs=null on return number of errors |
537 | 537 | * @param int &$dirs=null on return number of dirs deleted |
538 | 538 | * @param int &$files=null on return number of files deleted |
539 | + * @param integer $errs |
|
540 | + * @param integer $files |
|
541 | + * @param integer $dirs |
|
539 | 542 | * @return string success or failure message displayed to the user |
540 | 543 | */ |
541 | 544 | static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
@@ -704,6 +707,9 @@ discard block |
||
704 | 707 | * @param int &$errs=null on return number of errors |
705 | 708 | * @param int &$dirs=null on return number of dirs deleted |
706 | 709 | * @param int &$files=null on return number of files deleted |
710 | + * @param integer $errs |
|
711 | + * @param integer $dirs |
|
712 | + * @param integer $files |
|
707 | 713 | * @return string |
708 | 714 | */ |
709 | 715 | public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
@@ -1325,7 +1331,6 @@ discard block |
||
1325 | 1331 | * |
1326 | 1332 | * @param string $action eg. 'delete', ... |
1327 | 1333 | * @param array $selected selected path(s) |
1328 | - * @param string $dir=null current directory |
|
1329 | 1334 | * @see static::action() |
1330 | 1335 | */ |
1331 | 1336 | public static function ajax_action($action, $selected, $dir=null, $props=null) |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | if (!static::$views_init) |
81 | 81 | { |
82 | 82 | // translate our labels |
83 | - foreach(static::$views as &$label) |
|
83 | + foreach (static::$views as &$label) |
|
84 | 84 | { |
85 | 85 | $label = lang($label); |
86 | 86 | } |
87 | 87 | // search for plugins with additional filemanager views |
88 | - foreach(Api\Hooks::process('filemanager_views') as $views) |
|
88 | + foreach (Api\Hooks::process('filemanager_views') as $views) |
|
89 | 89 | { |
90 | 90 | if (is_array($views)) static::$views += $views; |
91 | 91 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function get_view() |
103 | 103 | { |
104 | - $view =& Api\Cache::getSession('filemanager', 'view'); |
|
104 | + $view = & Api\Cache::getSession('filemanager', 'view'); |
|
105 | 105 | if (isset($_GET['view'])) |
106 | 106 | { |
107 | 107 | $view = $_GET['view']; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | 'open' => array( |
126 | 126 | 'caption' => lang('Open'), |
127 | 127 | 'icon' => '', |
128 | - 'group' => $group=1, |
|
128 | + 'group' => $group = 1, |
|
129 | 129 | 'allowOnMultiple' => false, |
130 | 130 | 'onExecute' => 'javaScript:app.filemanager.open', |
131 | 131 | 'default' => true |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'caption' => lang('Edit settings'), |
151 | 151 | 'group' => $group, |
152 | 152 | 'allowOnMultiple' => false, |
153 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs', |
|
153 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs', |
|
154 | 154 | 'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet')) |
155 | 155 | ), |
156 | 156 | 'mkdir' => array( |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | ), |
180 | 180 | // DRAG and DROP events |
181 | 181 | 'file_drag' => array( |
182 | - 'dragType' => array('file','link'), |
|
182 | + 'dragType' => array('file', 'link'), |
|
183 | 183 | 'type' => 'drag', |
184 | 184 | 'onExecute' => 'javaScript:app.filemanager.drag' |
185 | 185 | ), |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | else |
220 | 220 | { |
221 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
221 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
222 | 222 | { |
223 | 223 | $actions['mail']['children']['mail_'.$mode] = array( |
224 | 224 | 'caption' => $data['label'], |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string merge application or NULL if no property found |
242 | 242 | */ |
243 | - private static function get_mergeapp($path, $scope='self') |
|
243 | + private static function get_mergeapp($path, $scope = 'self') |
|
244 | 244 | { |
245 | 245 | $app = null; |
246 | - switch($scope) |
|
246 | + switch ($scope) |
|
247 | 247 | { |
248 | 248 | case 'self': |
249 | 249 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | case 'parents': |
253 | 253 | // search for props in parent directories |
254 | 254 | $currentpath = $path; |
255 | - while($dir = Vfs::dirname($currentpath)) |
|
255 | + while ($dir = Vfs::dirname($currentpath)) |
|
256 | 256 | { |
257 | 257 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
258 | - if(!empty($props)) |
|
258 | + if (!empty($props)) |
|
259 | 259 | { |
260 | 260 | // found prop in parent directory |
261 | 261 | return $app = $props[0]['val']; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param array $content |
275 | 275 | * @param string $msg |
276 | 276 | */ |
277 | - function index(array $content=null,$msg=null) |
|
277 | + function index(array $content = null, $msg = null) |
|
278 | 278 | { |
279 | 279 | if (!is_array($content)) |
280 | 280 | { |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | if (!is_array($content['nm'])) |
285 | 285 | { |
286 | 286 | $content['nm'] = array( |
287 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
288 | - 'filter' => '', // current dir only |
|
289 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
290 | - 'no_cat' => True, // I disable the cat-selectbox |
|
291 | - 'lettersearch' => True, // I show a lettersearch |
|
292 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
293 | - 'start' => 0, // IO position in list |
|
294 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
295 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
296 | - 'default_cols' => '!comment,ctime', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
287 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
288 | + 'filter' => '', // current dir only |
|
289 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
290 | + 'no_cat' => True, // I disable the cat-selectbox |
|
291 | + 'lettersearch' => True, // I show a lettersearch |
|
292 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
293 | + 'start' => 0, // IO position in list |
|
294 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
295 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
296 | + 'default_cols' => '!comment,ctime', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
297 | 297 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
298 | 298 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
299 | 299 | 'actions' => static::get_actions(), |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'is_parent' => 'mime', |
304 | 304 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
305 | 305 | 'favorites' => true, |
306 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
306 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
307 | 307 | ); |
308 | 308 | $content['nm']['path'] = static::get_home_dir(); |
309 | 309 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
326 | 326 | { |
327 | - switch($path) |
|
327 | + switch ($path) |
|
328 | 328 | { |
329 | 329 | case '..': |
330 | 330 | $path = Vfs::dirname($content['nm']['path']); |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | $path = static::get_home_dir(); |
334 | 334 | break; |
335 | 335 | } |
336 | - if ($path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
336 | + if ($path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
337 | 337 | { |
338 | 338 | $content['nm']['path'] = $path; |
339 | 339 | } |
340 | 340 | else |
341 | 341 | { |
342 | - $msg .= lang('The requested path %1 is not available.',Vfs::decodePath($path)); |
|
342 | + $msg .= lang('The requested path %1 is not available.', Vfs::decodePath($path)); |
|
343 | 343 | } |
344 | 344 | // reset lettersearch as it confuses users (they think the dir is empty) |
345 | 345 | $content['nm']['searchletter'] = false; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | } |
350 | 350 | $view = static::get_view(); |
351 | 351 | |
352 | - call_user_func($view,$content,$msg); |
|
352 | + call_user_func($view, $content, $msg); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
363 | 363 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
364 | 364 | */ |
365 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
365 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
366 | 366 | { |
367 | 367 | if (!$user) |
368 | 368 | { |
@@ -371,15 +371,15 @@ discard block |
||
371 | 371 | else |
372 | 372 | { |
373 | 373 | // config user & password |
374 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
374 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
375 | 375 | // or vfs root user from setup >> configuration |
376 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
377 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
376 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
377 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
378 | 378 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
379 | 379 | } |
380 | 380 | //echo "<p>".__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".Api\Session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root)."</p>\n"; |
381 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
382 | - return Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
381 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
382 | + return Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | * @param array $content |
389 | 389 | * @param string $msg |
390 | 390 | */ |
391 | - function listview(array $content=null,$msg=null) |
|
391 | + function listview(array $content = null, $msg = null) |
|
392 | 392 | { |
393 | 393 | $tpl = new Etemplate('filemanager.index'); |
394 | 394 | |
395 | - if($msg) Framework::message($msg); |
|
395 | + if ($msg) Framework::message($msg); |
|
396 | 396 | |
397 | 397 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
398 | 398 | { |
399 | 399 | if ($content['nm']['action']) |
400 | 400 | { |
401 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
402 | - if($msg) Framework::message($msg); |
|
401 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
402 | + if ($msg) Framework::message($msg); |
|
403 | 403 | |
404 | 404 | // clean up after action |
405 | 405 | unset($content['nm']['selected']); |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
411 | 411 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
412 | 412 | } |
413 | - elseif($content['nm']['rows']['delete']) |
|
413 | + elseif ($content['nm']['rows']['delete']) |
|
414 | 414 | { |
415 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
416 | - if($msg) Framework::message($msg); |
|
415 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
416 | + if ($msg) Framework::message($msg); |
|
417 | 417 | |
418 | 418 | // clean up after action |
419 | 419 | unset($content['nm']['rows']['delete']); |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
426 | 426 | } |
427 | 427 | unset($content['nm']['rows']); |
428 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
428 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // be tolerant with (in previous versions) not correct urlencoded pathes |
432 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
432 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
433 | 433 | { |
434 | 434 | $content['nm']['path'] = urldecode($content['nm']['path']); |
435 | 435 | } |
@@ -440,22 +440,22 @@ discard block |
||
440 | 440 | list($button) = each($content['button']); |
441 | 441 | unset($content['button']); |
442 | 442 | } |
443 | - switch($button) |
|
443 | + switch ($button) |
|
444 | 444 | { |
445 | 445 | case 'upload': |
446 | 446 | if (!$content['upload']) |
447 | 447 | { |
448 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
448 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
449 | 449 | break; |
450 | 450 | } |
451 | 451 | $upload_success = $upload_failure = array(); |
452 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
452 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
453 | 453 | { |
454 | 454 | // encode chars which special meaning in url/vfs (some like / get removed!) |
455 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
455 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
456 | 456 | if ($upload && |
457 | 457 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
458 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
458 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
459 | 459 | { |
460 | 460 | $upload_success[] = $upload['name']; |
461 | 461 | } |
@@ -467,12 +467,11 @@ discard block |
||
467 | 467 | $content['nm']['msg'] = ''; |
468 | 468 | if ($upload_success) |
469 | 469 | { |
470 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
471 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
470 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
472 | 471 | } |
473 | 472 | if ($upload_failure) |
474 | 473 | { |
475 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
474 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
476 | 475 | } |
477 | 476 | break; |
478 | 477 | } |
@@ -493,16 +492,16 @@ discard block |
||
493 | 492 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
494 | 493 | } |
495 | 494 | // Set view button to match current settings |
496 | - if($content['nm']['view'] == 'tile') |
|
495 | + if ($content['nm']['view'] == 'tile') |
|
497 | 496 | { |
498 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
499 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
497 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
498 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
500 | 499 | } |
501 | 500 | // if initial load is done via GET request (idots template or share.php) |
502 | 501 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
503 | 502 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
504 | 503 | |
505 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
504 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
506 | 505 | } |
507 | 506 | |
508 | 507 | /** |
@@ -538,7 +537,7 @@ discard block |
||
538 | 537 | * @param int &$files=null on return number of files deleted |
539 | 538 | * @return string success or failure message displayed to the user |
540 | 539 | */ |
541 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
540 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
542 | 541 | { |
543 | 542 | if (!count($selected)) |
544 | 543 | { |
@@ -546,20 +545,20 @@ discard block |
||
546 | 545 | } |
547 | 546 | $errs = $dirs = $files = 0; |
548 | 547 | |
549 | - switch($action) |
|
548 | + switch ($action) |
|
550 | 549 | { |
551 | 550 | |
552 | 551 | case 'delete': |
553 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
552 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
554 | 553 | |
555 | 554 | case 'mail': |
556 | 555 | case 'copy': |
557 | - foreach($selected as $path) |
|
556 | + foreach ($selected as $path) |
|
558 | 557 | { |
559 | 558 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
560 | 559 | { |
561 | 560 | // Support for dropping mail in filemanager - Pass mail back to mail app |
562 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
561 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
563 | 562 | { |
564 | 563 | ++$files; |
565 | 564 | } |
@@ -570,8 +569,8 @@ discard block |
||
570 | 569 | } |
571 | 570 | elseif (!Vfs::is_dir($path)) |
572 | 571 | { |
573 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
574 | - if ($path != $to && Vfs::copy($path,$to)) |
|
572 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
573 | + if ($path != $to && Vfs::copy($path, $to)) |
|
575 | 574 | { |
576 | 575 | ++$files; |
577 | 576 | } |
@@ -583,19 +582,19 @@ discard block |
||
583 | 582 | else |
584 | 583 | { |
585 | 584 | $len = strlen(dirname($path)); |
586 | - foreach(Vfs::find($path) as $p) |
|
585 | + foreach (Vfs::find($path) as $p) |
|
587 | 586 | { |
588 | - $to = $dir.substr($p,$len); |
|
587 | + $to = $dir.substr($p, $len); |
|
589 | 588 | if ($to == $p) // cant copy into itself! |
590 | 589 | { |
591 | 590 | ++$errs; |
592 | 591 | continue; |
593 | 592 | } |
594 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
593 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
595 | 594 | { |
596 | 595 | ++$dirs; |
597 | 596 | } |
598 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
597 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
599 | 598 | { |
600 | 599 | ++$files; |
601 | 600 | } |
@@ -608,15 +607,15 @@ discard block |
||
608 | 607 | } |
609 | 608 | if ($errs) |
610 | 609 | { |
611 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
610 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
612 | 611 | } |
613 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
612 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
614 | 613 | |
615 | 614 | case 'move': |
616 | - foreach($selected as $path) |
|
615 | + foreach ($selected as $path) |
|
617 | 616 | { |
618 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
619 | - if ($path != $to && Vfs::rename($path,$to)) |
|
617 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
618 | + if ($path != $to && Vfs::rename($path, $to)) |
|
620 | 619 | { |
621 | 620 | ++$files; |
622 | 621 | } |
@@ -627,17 +626,17 @@ discard block |
||
627 | 626 | } |
628 | 627 | if ($errs) |
629 | 628 | { |
630 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
629 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
631 | 630 | } |
632 | - return lang('%1 files moved.',$files); |
|
631 | + return lang('%1 files moved.', $files); |
|
633 | 632 | |
634 | 633 | case 'symlink': // symlink given files to $dir |
635 | - foreach((array)$selected as $target) |
|
634 | + foreach ((array)$selected as $target) |
|
636 | 635 | { |
637 | 636 | $link = Vfs::concat($dir, Vfs::basename($target)); |
638 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
637 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
639 | 638 | { |
640 | - if(!$ok) |
|
639 | + if (!$ok) |
|
641 | 640 | { |
642 | 641 | $errs++; |
643 | 642 | continue; |
@@ -659,15 +658,14 @@ discard block |
||
659 | 658 | } |
660 | 659 | if (count((array)$selected) == 1) |
661 | 660 | { |
662 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
663 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
661 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
664 | 662 | } |
665 | 663 | $ret = lang('%1 elements linked.', $files); |
666 | 664 | if ($errs) |
667 | 665 | { |
668 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
666 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
669 | 667 | } |
670 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
668 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
671 | 669 | |
672 | 670 | case 'createdir': |
673 | 671 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -683,13 +681,13 @@ discard block |
||
683 | 681 | |
684 | 682 | default: |
685 | 683 | list($action, $settings) = explode('_', $action, 2); |
686 | - switch($action) |
|
684 | + switch ($action) |
|
687 | 685 | { |
688 | 686 | case 'document': |
689 | 687 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
690 | 688 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
691 | 689 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
692 | - if($msg) return $msg; |
|
690 | + if ($msg) return $msg; |
|
693 | 691 | $errs = count($selected); |
694 | 692 | return false; |
695 | 693 | } |
@@ -706,12 +704,12 @@ discard block |
||
706 | 704 | * @param int &$files=null on return number of files deleted |
707 | 705 | * @return string |
708 | 706 | */ |
709 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
707 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
710 | 708 | { |
711 | 709 | $dirs = $files = $errs = 0; |
712 | 710 | // we first delete all selected links (and files) |
713 | 711 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
714 | - foreach($selected as $key => $path) |
|
712 | + foreach ($selected as $key => $path) |
|
715 | 713 | { |
716 | 714 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
717 | 715 | { |
@@ -729,21 +727,21 @@ discard block |
||
729 | 727 | if ($selected) // somethings left to delete |
730 | 728 | { |
731 | 729 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
732 | - foreach((array)$selected as $path) |
|
730 | + foreach ((array)$selected as $path) |
|
733 | 731 | { |
734 | - if (preg_match('/^\/?(home|apps|)\/*$/',$path)) |
|
732 | + if (preg_match('/^\/?(home|apps|)\/*$/', $path)) |
|
735 | 733 | { |
736 | 734 | $errs++; |
737 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
735 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
738 | 736 | } |
739 | 737 | } |
740 | 738 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
741 | 739 | // - depth=true to get first the files and then the dir containing it |
742 | 740 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
743 | 741 | // - show-deleted=false to not (finally) deleted versioned files |
744 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
742 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
745 | 743 | { |
746 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
744 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
747 | 745 | { |
748 | 746 | ++$dirs; |
749 | 747 | } |
@@ -759,13 +757,13 @@ discard block |
||
759 | 757 | } |
760 | 758 | if ($errs) |
761 | 759 | { |
762 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
760 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
763 | 761 | } |
764 | 762 | if ($dirs) |
765 | 763 | { |
766 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
764 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
767 | 765 | } |
768 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
766 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
769 | 767 | } |
770 | 768 | |
771 | 769 | /** |
@@ -777,44 +775,44 @@ discard block |
||
777 | 775 | function get_rows(&$query, &$rows) |
778 | 776 | { |
779 | 777 | // show projectmanager sidebox for projectmanager path |
780 | - if (substr($query['path'],0,20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
778 | + if (substr($query['path'], 0, 20) == '/apps/projectmanager' && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
781 | 779 | { |
782 | 780 | $GLOBALS['egw_info']['flags']['currentapp'] = 'projectmanager'; |
783 | 781 | } |
784 | 782 | // do NOT store query, if hierarchical data / children are requested |
785 | 783 | if (!$query['csv_export']) |
786 | 784 | { |
787 | - Api\Cache::setSession('filemanager', 'index',$query); |
|
785 | + Api\Cache::setSession('filemanager', 'index', $query); |
|
788 | 786 | } |
789 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
787 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
790 | 788 | |
791 | 789 | // Change template to match selected view |
792 | - if($query['view']) |
|
790 | + if ($query['view']) |
|
793 | 791 | { |
794 | 792 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
795 | 793 | |
796 | 794 | // Store as preference but only for index, not home |
797 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
795 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
798 | 796 | { |
799 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
797 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
800 | 798 | $GLOBALS['egw']->preferences->save_repository(); |
801 | 799 | } |
802 | 800 | } |
803 | 801 | // be tolerant with (in previous versions) not correct urlencoded pathes |
804 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
802 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
805 | 803 | { |
806 | 804 | $query['path'] = urldecode($query['path']); |
807 | 805 | } |
808 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
806 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
809 | 807 | { |
810 | 808 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
811 | 809 | if ($query['path'] != ($path = static::get_home_dir())) |
812 | 810 | { |
813 | 811 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
814 | 812 | // an appropriate message |
815 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
813 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
816 | 814 | 'path' => $path, |
817 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
815 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
818 | 816 | 'ajax' => 'true' |
819 | 817 | )); |
820 | 818 | } |
@@ -822,35 +820,35 @@ discard block |
||
822 | 820 | return 0; |
823 | 821 | } |
824 | 822 | $rows = $dir_is_writable = array(); |
825 | - if($query['searchletter'] && !empty($query['search'])) |
|
823 | + if ($query['searchletter'] && !empty($query['search'])) |
|
826 | 824 | { |
827 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
825 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
828 | 826 | if ($query['searchletter'] == strtolower($query['search'][0])) |
829 | 827 | { |
830 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
831 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
828 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
829 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
832 | 830 | } |
833 | 831 | } |
834 | 832 | elseif ($query['searchletter']) |
835 | 833 | { |
836 | 834 | $namefilter = '/^'.$query['searchletter'].'/i'; |
837 | 835 | } |
838 | - elseif(!empty($query['search'])) |
|
836 | + elseif (!empty($query['search'])) |
|
839 | 837 | { |
840 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
838 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
841 | 839 | } |
842 | 840 | |
843 | 841 | // Re-map so 'No filters' favorite ('') is depth 1 |
844 | 842 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
845 | 843 | |
846 | 844 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
847 | - if($filter == 5) $maxdepth = 2; |
|
845 | + if ($filter == 5) $maxdepth = 2; |
|
848 | 846 | $n = 0; |
849 | 847 | $vfs_options = array( |
850 | 848 | 'mindepth' => 1, |
851 | 849 | 'maxdepth' => $maxdepth, |
852 | 850 | 'dirsontop' => $filter <= 1, |
853 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
851 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
854 | 852 | 'order' => $query['order'], 'sort' => $query['sort'], |
855 | 853 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
856 | 854 | 'need_mime' => true, |
@@ -858,11 +856,11 @@ discard block |
||
858 | 856 | 'hidden' => $filter == 3, |
859 | 857 | 'follow' => $filter == 5, |
860 | 858 | ); |
861 | - if($query['col_filter']['mime']) |
|
859 | + if ($query['col_filter']['mime']) |
|
862 | 860 | { |
863 | 861 | $vfs_options['mime'] = $query['col_filter']['mime']; |
864 | 862 | } |
865 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
863 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
866 | 864 | { |
867 | 865 | //echo $path; _debug_array($row); |
868 | 866 | |
@@ -876,32 +874,32 @@ discard block |
||
876 | 874 | $row['class'] = 'isDir'; |
877 | 875 | } |
878 | 876 | $row['download_url'] = Vfs::download_url($path); |
879 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
877 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
880 | 878 | |
881 | 879 | $rows[++$n] = $row; |
882 | 880 | $path2n[$path] = $n; |
883 | 881 | } |
884 | 882 | // query comments and cf's for the displayed rows |
885 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
883 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
886 | 884 | |
887 | 885 | // Always include comment in tiles |
888 | - if($query['view'] == 'tile') |
|
886 | + if ($query['view'] == 'tile') |
|
889 | 887 | { |
890 | 888 | $cols_to_show[] = 'comment'; |
891 | 889 | } |
892 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
893 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
890 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
891 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
894 | 892 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
895 | 893 | { |
896 | - foreach($path2props as $path => $props) |
|
894 | + foreach ($path2props as $path => $props) |
|
897 | 895 | { |
898 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
899 | - $row =& $rows[$path2n[$path]]; |
|
900 | - if ( !is_array($props) ) continue; |
|
901 | - foreach($props as $prop) |
|
896 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
897 | + $row = & $rows[$path2n[$path]]; |
|
898 | + if (!is_array($props)) continue; |
|
899 | + foreach ($props as $prop) |
|
902 | 900 | { |
903 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
904 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
901 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
902 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
905 | 903 | } |
906 | 904 | } |
907 | 905 | } |
@@ -913,7 +911,7 @@ discard block |
||
913 | 911 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
914 | 912 | { |
915 | 913 | // we need our app.css file |
916 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
914 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
917 | 915 | { |
918 | 916 | $css_file = '/filemanager/templates/default/app.css'; |
919 | 917 | } |
@@ -929,7 +927,7 @@ discard block |
||
929 | 927 | * @param array $content |
930 | 928 | * @param string $msg |
931 | 929 | */ |
932 | - function file(array $content=null,$msg='') |
|
930 | + function file(array $content = null, $msg = '') |
|
933 | 931 | { |
934 | 932 | $tpl = new Etemplate('filemanager.file'); |
935 | 933 | |
@@ -939,9 +937,9 @@ discard block |
||
939 | 937 | { |
940 | 938 | $msg .= $_GET['msg']; |
941 | 939 | } |
942 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
940 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
943 | 941 | // actions enclose pathes containing comma with " |
944 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
942 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
945 | 943 | !($stat = Vfs::lstat($path))) |
946 | 944 | { |
947 | 945 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -954,10 +952,10 @@ discard block |
||
954 | 952 | $content['path'] = $path; |
955 | 953 | $content['hsize'] = Vfs::hsize($stat['size']); |
956 | 954 | $content['mime'] = Vfs::mime_content_type($path); |
957 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
955 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
958 | 956 | if (($props = Vfs::propfind($path))) |
959 | 957 | { |
960 | - foreach($props as $prop) |
|
958 | + foreach ($props as $prop) |
|
961 | 959 | { |
962 | 960 | $content[$prop['name']] = $prop['val']; |
963 | 961 | } |
@@ -970,9 +968,9 @@ discard block |
||
970 | 968 | $content['tabs'] = $_GET['tabs']; |
971 | 969 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
972 | 970 | { |
973 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
971 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
974 | 972 | $mask = 6; |
975 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
973 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
976 | 974 | { |
977 | 975 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
978 | 976 | } |
@@ -982,19 +980,19 @@ discard block |
||
982 | 980 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
983 | 981 | $mask = 7; |
984 | 982 | } |
985 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
983 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
986 | 984 | { |
987 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
985 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
988 | 986 | } |
989 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
987 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
990 | 988 | } |
991 | 989 | else |
992 | 990 | { |
993 | 991 | //_debug_array($content); |
994 | - $path =& $content['path']; |
|
992 | + $path = & $content['path']; |
|
995 | 993 | |
996 | 994 | list($button) = @each($content['button']); unset($content['button']); |
997 | - if(!$button && $content['sudo']) |
|
995 | + if (!$button && $content['sudo']) |
|
998 | 996 | { |
999 | 997 | // Button to stop sudo is not in button namespace |
1000 | 998 | $button = 'sudo'; |
@@ -1003,45 +1001,45 @@ discard block |
||
1003 | 1001 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
1004 | 1002 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
1005 | 1003 | { |
1006 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
1004 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
1007 | 1005 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
1008 | 1006 | lang('Wrong username or password!') : lang('Root access stopped.')); |
1009 | 1007 | unset($content['sudo']); |
1010 | 1008 | $content['is_owner'] = Vfs::has_owner_rights($path); |
1011 | 1009 | } |
1012 | - if (in_array($button,array('save','apply'))) |
|
1010 | + if (in_array($button, array('save', 'apply'))) |
|
1013 | 1011 | { |
1014 | 1012 | $props = array(); |
1015 | 1013 | $perm_changed = $perm_failed = 0; |
1016 | - foreach($content['old'] as $name => $old_value) |
|
1014 | + foreach ($content['old'] as $name => $old_value) |
|
1017 | 1015 | { |
1018 | 1016 | if (isset($content[$name]) && ($old_value != $content[$name] || |
1019 | 1017 | // do not check for modification, if modify_subs is checked! |
1020 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
1018 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
1021 | 1019 | ($name != 'uid' || Vfs::$is_root)) |
1022 | 1020 | { |
1023 | 1021 | if ($name == 'name') |
1024 | 1022 | { |
1025 | - $to = Vfs::concat(Vfs::dirname($path),$content['name']); |
|
1023 | + $to = Vfs::concat(Vfs::dirname($path), $content['name']); |
|
1026 | 1024 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
1027 | 1025 | { |
1028 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
1029 | - lang('To overwrite the existing file store again.',lang($button))); |
|
1026 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
1027 | + lang('To overwrite the existing file store again.', lang($button))); |
|
1030 | 1028 | $content['confirm_overwrite'] = $to; |
1031 | 1029 | if ($button == 'save') $button = 'apply'; |
1032 | 1030 | continue; |
1033 | 1031 | } |
1034 | - if (Vfs::rename($path,$to)) |
|
1032 | + if (Vfs::rename($path, $to)) |
|
1035 | 1033 | { |
1036 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1034 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1037 | 1035 | $content['old']['name'] = $content[$name]; |
1038 | 1036 | $path = $to; |
1039 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1040 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1037 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1038 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1041 | 1039 | } |
1042 | 1040 | else |
1043 | 1041 | { |
1044 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1042 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1045 | 1043 | if (Vfs::deny_script($to)) |
1046 | 1044 | { |
1047 | 1045 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1061,7 +1059,7 @@ discard block |
||
1061 | 1059 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
1062 | 1060 | ), |
1063 | 1061 | ); |
1064 | - if (Vfs::proppatch($path,$mergeprop)) |
|
1062 | + if (Vfs::proppatch($path, $mergeprop)) |
|
1065 | 1063 | { |
1066 | 1064 | $content['old'][$name] = $content[$name]; |
1067 | 1065 | $msg .= lang('Setting for document merge saved.'); |
@@ -1073,22 +1071,22 @@ discard block |
||
1073 | 1071 | } |
1074 | 1072 | else |
1075 | 1073 | { |
1076 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
1077 | - $cmd = array('egw_vfs',$name2cmd[$name]); |
|
1074 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
1075 | + $cmd = array('egw_vfs', $name2cmd[$name]); |
|
1078 | 1076 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
1079 | 1077 | if ($content['modify_subs']) |
1080 | 1078 | { |
1081 | 1079 | if ($name == 'perms') |
1082 | 1080 | { |
1083 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
1084 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
1081 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
1082 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
1085 | 1083 | } |
1086 | 1084 | else |
1087 | 1085 | { |
1088 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
1086 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
1089 | 1087 | } |
1090 | 1088 | $ok = $failed = 0; |
1091 | - foreach($changed as &$r) |
|
1089 | + foreach ($changed as &$r) |
|
1092 | 1090 | { |
1093 | 1091 | if ($r) |
1094 | 1092 | { |
@@ -1101,32 +1099,32 @@ discard block |
||
1101 | 1099 | } |
1102 | 1100 | if ($ok && !$failed) |
1103 | 1101 | { |
1104 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1102 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
1105 | 1103 | $content['old'][$name] = $content[$name]; |
1106 | 1104 | } |
1107 | - elseif($failed) |
|
1105 | + elseif ($failed) |
|
1108 | 1106 | { |
1109 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1110 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
1107 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
1108 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
1111 | 1109 | } |
1112 | 1110 | } |
1113 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
1111 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
1114 | 1112 | { |
1115 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
1113 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
1116 | 1114 | $content['old'][$name] = $content[$name]; |
1117 | 1115 | } |
1118 | 1116 | else |
1119 | 1117 | { |
1120 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
1118 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
1121 | 1119 | } |
1122 | 1120 | } |
1123 | 1121 | } |
1124 | 1122 | } |
1125 | 1123 | if ($props) |
1126 | 1124 | { |
1127 | - if (Vfs::proppatch($path,$props)) |
|
1125 | + if (Vfs::proppatch($path, $props)) |
|
1128 | 1126 | { |
1129 | - foreach($props as $prop) |
|
1127 | + foreach ($props as $prop) |
|
1130 | 1128 | { |
1131 | 1129 | $content['old'][$prop['name']] = $prop['val']; |
1132 | 1130 | } |
@@ -1143,8 +1141,8 @@ discard block |
||
1143 | 1141 | if ($content['eacl']['delete']) |
1144 | 1142 | { |
1145 | 1143 | list($ino_owner) = each($content['eacl']['delete']); |
1146 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
1147 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1144 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
1145 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1148 | 1146 | } |
1149 | 1147 | elseif ($button == 'eacl') |
1150 | 1148 | { |
@@ -1154,7 +1152,7 @@ discard block |
||
1154 | 1152 | } |
1155 | 1153 | else |
1156 | 1154 | { |
1157 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
1155 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
1158 | 1156 | lang('ACL added.') : lang('Error adding the ACL!'); |
1159 | 1157 | } |
1160 | 1158 | } |
@@ -1164,7 +1162,7 @@ discard block |
||
1164 | 1162 | } |
1165 | 1163 | if ($content['is_link'] && !Vfs::stat($path)) |
1166 | 1164 | { |
1167 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
1165 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
1168 | 1166 | } |
1169 | 1167 | $content['link'] = Egw::link(Vfs::download_url($path)); |
1170 | 1168 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1173,10 +1171,10 @@ discard block |
||
1173 | 1171 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
1174 | 1172 | // only owner can change group & perms |
1175 | 1173 | if (($readonlys['gid'] = !$content['is_owner'] || |
1176 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1174 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1177 | 1175 | { |
1178 | 1176 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1179 | - foreach($content['perms'] as $name => $value) |
|
1177 | + foreach ($content['perms'] as $name => $value) |
|
1180 | 1178 | { |
1181 | 1179 | $readonlys['perms['.$name.']'] = true; |
1182 | 1180 | } |
@@ -1194,37 +1192,37 @@ discard block |
||
1194 | 1192 | } |
1195 | 1193 | elseif (!Vfs::is_writable($path)) |
1196 | 1194 | { |
1197 | - foreach($cfs as $name => $data) |
|
1195 | + foreach ($cfs as $name => $data) |
|
1198 | 1196 | { |
1199 | 1197 | $readonlys['#'.$name] = true; |
1200 | 1198 | } |
1201 | 1199 | } |
1202 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1200 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1203 | 1201 | if ($content['is_dir']) |
1204 | 1202 | { |
1205 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1206 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1203 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1204 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1207 | 1205 | 7 => lang('Display and modification of content'), |
1208 | 1206 | 5 => lang('Display of content'), |
1209 | 1207 | 0 => lang('No access'), |
1210 | 1208 | ); |
1211 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1209 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1212 | 1210 | { |
1213 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1214 | - foreach($content['eacl'] as &$eacl) |
|
1211 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1212 | + foreach ($content['eacl'] as &$eacl) |
|
1215 | 1213 | { |
1216 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
1214 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
1217 | 1215 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
1218 | 1216 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
1219 | 1217 | } |
1220 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
1218 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
1221 | 1219 | $content['eacl']['owner'] = 0; |
1222 | 1220 | $content['eacl']['rights'] = 5; |
1223 | 1221 | } |
1224 | 1222 | } |
1225 | 1223 | else |
1226 | 1224 | { |
1227 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1225 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1228 | 1226 | 6 => lang('Read & write access'), |
1229 | 1227 | 4 => lang('Read access only'), |
1230 | 1228 | 0 => lang('No access'), |
@@ -1234,11 +1232,11 @@ discard block |
||
1234 | 1232 | // mergeapp |
1235 | 1233 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
1236 | 1234 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
1237 | - if(!empty($content['mergeapp'])) |
|
1235 | + if (!empty($content['mergeapp'])) |
|
1238 | 1236 | { |
1239 | 1237 | $content['mergeapp_effective'] = $content['mergeapp']; |
1240 | 1238 | } |
1241 | - elseif(!empty($content['mergeapp_parent'])) |
|
1239 | + elseif (!empty($content['mergeapp_parent'])) |
|
1242 | 1240 | { |
1243 | 1241 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
1244 | 1242 | } |
@@ -1250,7 +1248,7 @@ discard block |
||
1250 | 1248 | $mergeapp_list = Link::app_list('merge'); |
1251 | 1249 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
1252 | 1250 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
1253 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
1251 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
1254 | 1252 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
1255 | 1253 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
1256 | 1254 | // mergeapp other gui options |
@@ -1267,7 +1265,7 @@ discard block |
||
1267 | 1265 | 'comment' => (string)$content['comment'], |
1268 | 1266 | 'mergeapp' => $content['mergeapp'] |
1269 | 1267 | ); |
1270 | - if ($cfs) foreach($cfs as $name => $data) |
|
1268 | + if ($cfs) foreach ($cfs as $name => $data) |
|
1271 | 1269 | { |
1272 | 1270 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1273 | 1271 | } |
@@ -1275,26 +1273,26 @@ discard block |
||
1275 | 1273 | if (Vfs::$is_root) |
1276 | 1274 | { |
1277 | 1275 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
1278 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
1276 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
1279 | 1277 | // Need a more complex submit because button type is buttononly, which doesn't submit |
1280 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
1278 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
1281 | 1279 | |
1282 | 1280 | } |
1283 | 1281 | elseif ($button == 'sudo') |
1284 | 1282 | { |
1285 | 1283 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
1286 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
1287 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
1284 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
1285 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
1288 | 1286 | } |
1289 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
1287 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
1290 | 1288 | { |
1291 | 1289 | // add to existing tabs in template |
1292 | 1290 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1293 | 1291 | |
1294 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
1292 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
1295 | 1293 | if (true) $tabs = array(); |
1296 | 1294 | |
1297 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1295 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1298 | 1296 | { |
1299 | 1297 | $tabs[] = array( |
1300 | 1298 | 'label' => $extra_tab['label'], |
@@ -1317,7 +1315,7 @@ discard block |
||
1317 | 1315 | Framework::window_focus(); |
1318 | 1316 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
1319 | 1317 | |
1320 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
1318 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
1321 | 1319 | } |
1322 | 1320 | |
1323 | 1321 | /** |
@@ -1328,7 +1326,7 @@ discard block |
||
1328 | 1326 | * @param string $dir=null current directory |
1329 | 1327 | * @see static::action() |
1330 | 1328 | */ |
1331 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
1329 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
1332 | 1330 | { |
1333 | 1331 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
1334 | 1332 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1347,15 +1345,15 @@ discard block |
||
1347 | 1345 | |
1348 | 1346 | if (!isset($dir)) $dir = array_pop($selected); |
1349 | 1347 | |
1350 | - switch($action) |
|
1348 | + switch ($action) |
|
1351 | 1349 | { |
1352 | 1350 | case 'upload': |
1353 | 1351 | $script_error = 0; |
1354 | - foreach($selected as $tmp_name => &$data) |
|
1352 | + foreach ($selected as $tmp_name => &$data) |
|
1355 | 1353 | { |
1356 | 1354 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
1357 | 1355 | |
1358 | - if(Vfs::deny_script($path)) |
|
1356 | + if (Vfs::deny_script($path)) |
|
1359 | 1357 | { |
1360 | 1358 | if (!isset($script_error)) |
1361 | 1359 | { |
@@ -1377,7 +1375,7 @@ discard block |
||
1377 | 1375 | { |
1378 | 1376 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
1379 | 1377 | { |
1380 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
1378 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
1381 | 1379 | } |
1382 | 1380 | else |
1383 | 1381 | { |
@@ -1412,16 +1410,16 @@ discard block |
||
1412 | 1410 | case 'link': |
1413 | 1411 | // First upload |
1414 | 1412 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
1415 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
1413 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
1416 | 1414 | |
1417 | - foreach($arr['uploaded'] as $file) |
|
1415 | + foreach ($arr['uploaded'] as $file) |
|
1418 | 1416 | { |
1419 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
1417 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
1420 | 1418 | if (Vfs::file_exists($target) && $app_dir) |
1421 | 1419 | { |
1422 | 1420 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1423 | 1421 | error_log("Symlinking $target to $app_dir"); |
1424 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
1422 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
1425 | 1423 | } |
1426 | 1424 | } |
1427 | 1425 | // Must return to avoid adding to $response again |
@@ -1443,7 +1441,7 @@ discard block |
||
1443 | 1441 | */ |
1444 | 1442 | private function perms2mode(array $perms) |
1445 | 1443 | { |
1446 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
1444 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
1447 | 1445 | if ($mode['executable']) |
1448 | 1446 | { |
1449 | 1447 | $mode |= 0111; |
@@ -87,7 +87,10 @@ discard block |
||
87 | 87 | // search for plugins with additional filemanager views |
88 | 88 | foreach(Api\Hooks::process('filemanager_views') as $views) |
89 | 89 | { |
90 | - if (is_array($views)) static::$views += $views; |
|
90 | + if (is_array($views)) |
|
91 | + { |
|
92 | + static::$views += $views; |
|
93 | + } |
|
91 | 94 | } |
92 | 95 | static::$views_init = true; |
93 | 96 | } |
@@ -310,7 +313,10 @@ discard block |
||
310 | 313 | $content['nm']['home_dir'] = static::get_home_dir(); |
311 | 314 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
312 | 315 | |
313 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
316 | + if (isset($_GET['msg'])) |
|
317 | + { |
|
318 | + $msg = $_GET['msg']; |
|
319 | + } |
|
314 | 320 | |
315 | 321 | // Blank favorite set via GET needs special handling for path |
316 | 322 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -344,7 +350,10 @@ discard block |
||
344 | 350 | // reset lettersearch as it confuses users (they think the dir is empty) |
345 | 351 | $content['nm']['searchletter'] = false; |
346 | 352 | // switch recusive display off |
347 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
353 | + if (!$content['nm']['filter']) |
|
354 | + { |
|
355 | + $content['nm']['filter'] = ''; |
|
356 | + } |
|
348 | 357 | } |
349 | 358 | } |
350 | 359 | $view = static::get_view(); |
@@ -392,37 +401,70 @@ discard block |
||
392 | 401 | { |
393 | 402 | $tpl = new Etemplate('filemanager.index'); |
394 | 403 | |
395 | - if($msg) Framework::message($msg); |
|
404 | + if($msg) |
|
405 | + { |
|
406 | + Framework::message($msg); |
|
407 | + } |
|
396 | 408 | |
397 | 409 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
398 | 410 | { |
399 | 411 | if ($content['nm']['action']) |
400 | 412 | { |
401 | 413 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
402 | - if($msg) Framework::message($msg); |
|
414 | + if($msg) |
|
415 | + { |
|
416 | + Framework::message($msg); |
|
417 | + } |
|
403 | 418 | |
404 | 419 | // clean up after action |
405 | 420 | unset($content['nm']['selected']); |
406 | 421 | // reset any occasion where action may be stored, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
407 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
408 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
409 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
422 | + if (isset($content['nm']['action'])) |
|
423 | + { |
|
424 | + unset($content['nm']['action']); |
|
425 | + } |
|
426 | + if (isset($content['nm']['nm_action'])) |
|
427 | + { |
|
428 | + unset($content['nm']['nm_action']); |
|
429 | + } |
|
430 | + if (isset($content['nm_action'])) |
|
431 | + { |
|
432 | + unset($content['nm_action']); |
|
433 | + } |
|
410 | 434 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
411 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
435 | + if (isset($content['nm']['rows']['delete'])) |
|
436 | + { |
|
437 | + unset($content['nm']['rows']['delete']); |
|
438 | + } |
|
412 | 439 | } |
413 | 440 | elseif($content['nm']['rows']['delete']) |
414 | 441 | { |
415 | 442 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
416 | - if($msg) Framework::message($msg); |
|
443 | + if($msg) |
|
444 | + { |
|
445 | + Framework::message($msg); |
|
446 | + } |
|
417 | 447 | |
418 | 448 | // clean up after action |
419 | 449 | unset($content['nm']['rows']['delete']); |
420 | 450 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
421 | 451 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
422 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
423 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
424 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
425 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
452 | + if (isset($content['nm']['action'])) |
|
453 | + { |
|
454 | + unset($content['nm']['action']); |
|
455 | + } |
|
456 | + if (isset($content['nm']['nm_action'])) |
|
457 | + { |
|
458 | + unset($content['nm']['nm_action']); |
|
459 | + } |
|
460 | + if (isset($content['nm_action'])) |
|
461 | + { |
|
462 | + unset($content['nm_action']); |
|
463 | + } |
|
464 | + if (isset($content['nm']['selected'])) |
|
465 | + { |
|
466 | + unset($content['nm']['selected']); |
|
467 | + } |
|
426 | 468 | } |
427 | 469 | unset($content['nm']['rows']); |
428 | 470 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -586,9 +628,12 @@ discard block |
||
586 | 628 | foreach(Vfs::find($path) as $p) |
587 | 629 | { |
588 | 630 | $to = $dir.substr($p,$len); |
589 | - if ($to == $p) // cant copy into itself! |
|
631 | + if ($to == $p) |
|
632 | + { |
|
633 | + // cant copy into itself! |
|
590 | 634 | { |
591 | 635 | ++$errs; |
636 | + } |
|
592 | 637 | continue; |
593 | 638 | } |
594 | 639 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -643,7 +688,10 @@ discard block |
||
643 | 688 | continue; |
644 | 689 | } |
645 | 690 | } |
646 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
691 | + if ($target[0] != '/') |
|
692 | + { |
|
693 | + $target = Vfs::concat($dir, $target); |
|
694 | + } |
|
647 | 695 | if (!Vfs::stat($target)) |
648 | 696 | { |
649 | 697 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -686,10 +734,16 @@ discard block |
||
686 | 734 | switch($action) |
687 | 735 | { |
688 | 736 | case 'document': |
689 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
737 | + if (!$settings) |
|
738 | + { |
|
739 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
740 | + } |
|
690 | 741 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
691 | 742 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
692 | - if($msg) return $msg; |
|
743 | + if($msg) |
|
744 | + { |
|
745 | + return $msg; |
|
746 | + } |
|
693 | 747 | $errs = count($selected); |
694 | 748 | return false; |
695 | 749 | } |
@@ -726,7 +780,9 @@ discard block |
||
726 | 780 | unset($selected[$key]); |
727 | 781 | } |
728 | 782 | } |
729 | - if ($selected) // somethings left to delete |
|
783 | + if ($selected) |
|
784 | + { |
|
785 | + // somethings left to delete |
|
730 | 786 | { |
731 | 787 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
732 | 788 | foreach((array)$selected as $path) |
@@ -734,6 +790,7 @@ discard block |
||
734 | 790 | if (preg_match('/^\/?(home|apps|)\/*$/',$path)) |
735 | 791 | { |
736 | 792 | $errs++; |
793 | + } |
|
737 | 794 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
738 | 795 | } |
739 | 796 | } |
@@ -786,7 +843,10 @@ discard block |
||
786 | 843 | { |
787 | 844 | Api\Cache::setSession('filemanager', 'index',$query); |
788 | 845 | } |
789 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
846 | + if(!$query['path']) |
|
847 | + { |
|
848 | + $query['path'] = static::get_home_dir(); |
|
849 | + } |
|
790 | 850 | |
791 | 851 | // Change template to match selected view |
792 | 852 | if($query['view']) |
@@ -844,7 +904,10 @@ discard block |
||
844 | 904 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
845 | 905 | |
846 | 906 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
847 | - if($filter == 5) $maxdepth = 2; |
|
907 | + if($filter == 5) |
|
908 | + { |
|
909 | + $maxdepth = 2; |
|
910 | + } |
|
848 | 911 | $n = 0; |
849 | 912 | $vfs_options = array( |
850 | 913 | 'mindepth' => 1, |
@@ -897,10 +960,16 @@ discard block |
||
897 | 960 | { |
898 | 961 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
899 | 962 | $row =& $rows[$path2n[$path]]; |
900 | - if ( !is_array($props) ) continue; |
|
963 | + if ( !is_array($props) ) |
|
964 | + { |
|
965 | + continue; |
|
966 | + } |
|
901 | 967 | foreach($props as $prop) |
902 | 968 | { |
903 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
969 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
970 | + { |
|
971 | + continue; |
|
972 | + } |
|
904 | 973 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
905 | 974 | } |
906 | 975 | } |
@@ -1028,7 +1097,10 @@ discard block |
||
1028 | 1097 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
1029 | 1098 | lang('To overwrite the existing file store again.',lang($button))); |
1030 | 1099 | $content['confirm_overwrite'] = $to; |
1031 | - if ($button == 'save') $button = 'apply'; |
|
1100 | + if ($button == 'save') |
|
1101 | + { |
|
1102 | + $button = 'apply'; |
|
1103 | + } |
|
1032 | 1104 | continue; |
1033 | 1105 | } |
1034 | 1106 | if (Vfs::rename($path,$to)) |
@@ -1101,13 +1173,19 @@ discard block |
||
1101 | 1173 | } |
1102 | 1174 | if ($ok && !$failed) |
1103 | 1175 | { |
1104 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1176 | + if(!$perm_changed++) |
|
1177 | + { |
|
1178 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1179 | + } |
|
1105 | 1180 | $content['old'][$name] = $content[$name]; |
1106 | 1181 | } |
1107 | 1182 | elseif($failed) |
1108 | 1183 | { |
1109 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1184 | + if(!$perm_failed++) |
|
1185 | + { |
|
1186 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1110 | 1187 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
1188 | + } |
|
1111 | 1189 | } |
1112 | 1190 | } |
1113 | 1191 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1160,7 +1238,10 @@ discard block |
||
1160 | 1238 | } |
1161 | 1239 | } |
1162 | 1240 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
1163 | - if ($button == 'save') Framework::window_close(); |
|
1241 | + if ($button == 'save') |
|
1242 | + { |
|
1243 | + Framework::window_close(); |
|
1244 | + } |
|
1164 | 1245 | } |
1165 | 1246 | if ($content['is_link'] && !Vfs::stat($path)) |
1166 | 1247 | { |
@@ -1170,12 +1251,18 @@ discard block |
||
1170 | 1251 | $content['icon'] = Vfs::mime_icon($content['mime']); |
1171 | 1252 | $content['msg'] = $msg; |
1172 | 1253 | |
1173 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
1254 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
1255 | + { |
|
1256 | + $content['ro_uid_root'] = 'root'; |
|
1257 | + } |
|
1174 | 1258 | // only owner can change group & perms |
1175 | 1259 | if (($readonlys['gid'] = !$content['is_owner'] || |
1176 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1260 | + Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) |
|
1261 | + { |
|
1262 | + // no uid, gid or perms in oldvfs |
|
1177 | 1263 | { |
1178 | 1264 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1265 | + } |
|
1179 | 1266 | foreach($content['perms'] as $name => $value) |
1180 | 1267 | { |
1181 | 1268 | $readonlys['perms['.$name.']'] = true; |
@@ -1208,9 +1295,13 @@ discard block |
||
1208 | 1295 | 5 => lang('Display of content'), |
1209 | 1296 | 0 => lang('No access'), |
1210 | 1297 | ); |
1211 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1298 | + if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) |
|
1212 | 1299 | { |
1213 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1300 | + // backend supports eacl |
|
1301 | + { |
|
1302 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
1303 | + } |
|
1304 | + // --> switch the tab on again |
|
1214 | 1305 | foreach($content['eacl'] as &$eacl) |
1215 | 1306 | { |
1216 | 1307 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1267,10 +1358,13 @@ discard block |
||
1267 | 1358 | 'comment' => (string)$content['comment'], |
1268 | 1359 | 'mergeapp' => $content['mergeapp'] |
1269 | 1360 | ); |
1270 | - if ($cfs) foreach($cfs as $name => $data) |
|
1361 | + if ($cfs) |
|
1362 | + { |
|
1363 | + foreach($cfs as $name => $data) |
|
1271 | 1364 | { |
1272 | 1365 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1273 | 1366 | } |
1367 | + } |
|
1274 | 1368 | } |
1275 | 1369 | if (Vfs::$is_root) |
1276 | 1370 | { |
@@ -1292,7 +1386,10 @@ discard block |
||
1292 | 1386 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1293 | 1387 | |
1294 | 1388 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
1295 | - if (true) $tabs = array(); |
|
1389 | + if (true) |
|
1390 | + { |
|
1391 | + $tabs = array(); |
|
1392 | + } |
|
1296 | 1393 | |
1297 | 1394 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
1298 | 1395 | { |
@@ -1345,7 +1442,10 @@ discard block |
||
1345 | 1442 | 'files' => 0, |
1346 | 1443 | ); |
1347 | 1444 | |
1348 | - if (!isset($dir)) $dir = array_pop($selected); |
|
1445 | + if (!isset($dir)) |
|
1446 | + { |
|
1447 | + $dir = array_pop($selected); |
|
1448 | + } |
|
1349 | 1449 | |
1350 | 1450 | switch($action) |
1351 | 1451 | { |
@@ -1419,7 +1519,10 @@ discard block |
||
1419 | 1519 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
1420 | 1520 | if (Vfs::file_exists($target) && $app_dir) |
1421 | 1521 | { |
1422 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
1522 | + if (!Vfs::file_exists($app_dir)) |
|
1523 | + { |
|
1524 | + Vfs::mkdir($app_dir); |
|
1525 | + } |
|
1423 | 1526 | error_log("Symlinking $target to $app_dir"); |
1424 | 1527 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
1425 | 1528 | } |
@@ -1420,7 +1420,7 @@ |
||
1420 | 1420 | if (Vfs::file_exists($target) && $app_dir) |
1421 | 1421 | { |
1422 | 1422 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1423 | - error_log("Symlinking $target to $app_dir"); |
|
1423 | + error_log("symlinking $target to $app_dir"); |
|
1424 | 1424 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
1425 | 1425 | } |
1426 | 1426 | } |
@@ -198,7 +198,7 @@ |
||
198 | 198 | /** |
199 | 199 | * This portlet accepts files and links |
200 | 200 | * |
201 | - * @return boolean|String[] |
|
201 | + * @return string[] |
|
202 | 202 | */ |
203 | 203 | public function accept_drop() |
204 | 204 | { |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | { |
43 | 43 | if (false) parent::__construct(); |
44 | 44 | |
45 | - if(!is_array($context['list'])) $context['list'] = array(); |
|
45 | + if (!is_array($context['list'])) $context['list'] = array(); |
|
46 | 46 | |
47 | 47 | // Process dropped data (Should be GUIDs) into something useable |
48 | - if($context['dropped_data']) |
|
48 | + if ($context['dropped_data']) |
|
49 | 49 | { |
50 | - foreach((Array)$context['dropped_data'] as $dropped) |
|
50 | + foreach ((Array)$context['dropped_data'] as $dropped) |
|
51 | 51 | { |
52 | 52 | $add = array(); |
53 | 53 | list($add['app'], $add['id']) = explode('::', $dropped, 2); |
54 | - if($add['app'] && $add['id']) |
|
54 | + if ($add['app'] && $add['id']) |
|
55 | 55 | { |
56 | 56 | $context['list'][] = $add; |
57 | 57 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | unset($context['dropped_data']); |
61 | 61 | $need_reload = true; |
62 | 62 | } |
63 | - if($context['title']) |
|
63 | + if ($context['title']) |
|
64 | 64 | { |
65 | 65 | $this->title = $context['title']; |
66 | 66 | } |
67 | - foreach($context['list'] as &$item) |
|
67 | + foreach ($context['list'] as &$item) |
|
68 | 68 | { |
69 | - if($item['app'] == 'filemanager' || $item['app'] == 'file') |
|
69 | + if ($item['app'] == 'filemanager' || $item['app'] == 'file') |
|
70 | 70 | { |
71 | 71 | $item['app'] = 'file'; |
72 | 72 | $item['type'] = Vfs::mime_content_type($item['id']); |
@@ -105,21 +105,21 @@ discard block |
||
105 | 105 | * unique, if needed. |
106 | 106 | * @return string HTML fragment for display |
107 | 107 | */ |
108 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
108 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
109 | 109 | { |
110 | 110 | $etemplate->read('home.list'); |
111 | 111 | |
112 | 112 | $etemplate->set_dom_id($id); |
113 | 113 | $content = $this->context; |
114 | - if(!is_array($content['list'])) |
|
114 | + if (!is_array($content['list'])) |
|
115 | 115 | { |
116 | 116 | $content['list'] = Array(); |
117 | 117 | } |
118 | 118 | // Filemanager support - links need app = 'file' and type set |
119 | - foreach($content['list'] as &$list) |
|
119 | + foreach ($content['list'] as &$list) |
|
120 | 120 | { |
121 | - if($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
122 | - if($list['app'] == 'file') |
|
121 | + if ($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
122 | + if ($list['app'] == 'file') |
|
123 | 123 | { |
124 | 124 | $list['app'] = 'file'; |
125 | 125 | $list['path'] = $list['title'] = $list['icon'] = $list['id']; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - $etemplate->exec('home.home_list_portlet.exec',$content); |
|
130 | + $etemplate->exec('home.home_list_portlet.exec', $content); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'type' => 'drop', |
183 | 183 | 'caption' => lang('add'), |
184 | 184 | 'onExecute' => 'javaScript:app.home.add_link', |
185 | - 'acceptedTypes' => array('file','link') + array_keys($GLOBALS['egw_info']['apps']), |
|
185 | + 'acceptedTypes' => array('file', 'link') + array_keys($GLOBALS['egw_info']['apps']), |
|
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | return $actions; |
@@ -202,6 +202,6 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function accept_drop() |
204 | 204 | { |
205 | - return array('file','link'); |
|
205 | + return array('file', 'link'); |
|
206 | 206 | } |
207 | 207 | } |
@@ -40,9 +40,15 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function __construct(Array &$context = array(), &$need_reload = false) |
42 | 42 | { |
43 | - if (false) parent::__construct(); |
|
43 | + if (false) |
|
44 | + { |
|
45 | + parent::__construct(); |
|
46 | + } |
|
44 | 47 | |
45 | - if(!is_array($context['list'])) $context['list'] = array(); |
|
48 | + if(!is_array($context['list'])) |
|
49 | + { |
|
50 | + $context['list'] = array(); |
|
51 | + } |
|
46 | 52 | |
47 | 53 | // Process dropped data (Should be GUIDs) into something useable |
48 | 54 | if($context['dropped_data']) |
@@ -118,7 +124,10 @@ discard block |
||
118 | 124 | // Filemanager support - links need app = 'file' and type set |
119 | 125 | foreach($content['list'] as &$list) |
120 | 126 | { |
121 | - if($list['app'] == 'filemanager') $list['app'] = 'file'; |
|
127 | + if($list['app'] == 'filemanager') |
|
128 | + { |
|
129 | + $list['app'] = 'file'; |
|
130 | + } |
|
122 | 131 | if($list['app'] == 'file') |
123 | 132 | { |
124 | 133 | $list['app'] = 'file'; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * Construct the portlet |
39 | 39 | * |
40 | 40 | */ |
41 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
41 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
42 | 42 | { |
43 | 43 | if (false) parent::__construct(); |
44 | 44 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $content = $this->context; |
114 | 114 | if(!is_array($content['list'])) |
115 | 115 | { |
116 | - $content['list'] = Array(); |
|
116 | + $content['list'] = array(); |
|
117 | 117 | } |
118 | 118 | // Filemanager support - links need app = 'file' and type set |
119 | 119 | foreach($content['list'] as &$list) |
@@ -113,7 +113,7 @@ |
||
113 | 113 | * If this portlet can be created by dropping, these are the drop types |
114 | 114 | * that are accepted |
115 | 115 | * |
116 | - * @return boolean|String[] |
|
116 | + * @return boolean |
|
117 | 117 | */ |
118 | 118 | public function accept_drop() |
119 | 119 | { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * unique, if needed. |
57 | 57 | * @param Etemplate $etemplate eTemplate to generate content |
58 | 58 | */ |
59 | - public abstract function exec($id = null, Etemplate &$etemplate = null); |
|
59 | + public abstract function exec($id = null, Etemplate&$etemplate = null); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Return a list of settings to customize the portlet. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | // Include the common attributes, or they won't get saved |
80 | 80 | $properties = array(); |
81 | - foreach(self::$common_attributes as $prop) |
|
81 | + foreach (self::$common_attributes as $prop) |
|
82 | 82 | { |
83 | 83 | $properties[$prop] = array('name' => $prop); |
84 | 84 | } |
@@ -123,6 +123,6 @@ discard block |
||
123 | 123 | |
124 | 124 | public function __toString() |
125 | 125 | { |
126 | - return get_called_class() . ' Context:' . array2string($this->context); |
|
126 | + return get_called_class().' Context:'.array2string($this->context); |
|
127 | 127 | } |
128 | 128 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param context Array portlet settings such as size, as well as values for properties |
35 | 35 | * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) |
36 | 36 | */ |
37 | - public abstract function __construct(Array &$context = array(), &$need_reload = false); |
|
37 | + public abstract function __construct(array &$context = array(), &$need_reload = false); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Some descriptive information about the portlet, so that users can decide if |
@@ -155,7 +155,7 @@ |
||
155 | 155 | * Get a list of the user's portlets, and their associated values & settings, for display |
156 | 156 | * |
157 | 157 | * Actual portlet content is provided by each portlet. |
158 | - * @param template etemplate so attributes can be set |
|
158 | + * @param template Etemplate so attributes can be set |
|
159 | 159 | */ |
160 | 160 | protected function get_user_portlets(Etemplate &$template) |
161 | 161 | { |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | $content = array( |
50 | 50 | 'portlets' => $this->get_user_portlets($template) |
51 | 51 | ); |
52 | - $template->setElementAttribute('home.index','actions',$this->get_actions()); |
|
52 | + $template->setElementAttribute('home.index', 'actions', $this->get_actions()); |
|
53 | 53 | |
54 | 54 | $GLOBALS['egw_info']['flags']['app_header'] = lang('home'); |
55 | 55 | $GLOBALS['egw_info']['flags']['currentapp'] = 'home'; |
56 | 56 | |
57 | 57 | // Main screen message |
58 | 58 | Api\Translation::add_app('mainscreen'); |
59 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
59 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
60 | 60 | |
61 | - if($greeting == 'mainscreen_message'|| empty($greeting)) |
|
61 | + if ($greeting == 'mainscreen_message' || empty($greeting)) |
|
62 | 62 | { |
63 | - Api\Translation::add_app('mainscreen','en'); // trying the en one |
|
64 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
63 | + Api\Translation::add_app('mainscreen', 'en'); // trying the en one |
|
64 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
65 | 65 | } |
66 | - if(!($greeting == 'mainscreen_message'|| empty($greeting))) |
|
66 | + if (!($greeting == 'mainscreen_message' || empty($greeting))) |
|
67 | 67 | { |
68 | 68 | $content['mainscreen_message'] = $greeting; |
69 | 69 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | // Now run the portlets themselves |
74 | 74 | $attrs = array(); |
75 | - foreach($content['portlets'] as $portlet => $p_data) |
|
75 | + foreach ($content['portlets'] as $portlet => $p_data) |
|
76 | 76 | { |
77 | 77 | $id = $p_data['id']; |
78 | 78 | |
79 | - if(!$id) continue; |
|
79 | + if (!$id) continue; |
|
80 | 80 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
81 | 81 | } |
82 | 82 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | $add_portlets = $portlets; |
95 | 95 | $change_for_add = function(&$add_portlets) use (&$change_for_add) |
96 | 96 | { |
97 | - foreach($add_portlets as $id => &$add) |
|
97 | + foreach ($add_portlets as $id => &$add) |
|
98 | 98 | { |
99 | - if(is_array($add['children'])) |
|
99 | + if (is_array($add['children'])) |
|
100 | 100 | { |
101 | 101 | $change_for_add($add['children']); |
102 | 102 | } |
103 | - if($id && !$add['children']) |
|
103 | + if ($id && !$add['children']) |
|
104 | 104 | { |
105 | - $add['id'] = 'add_' . $id; |
|
105 | + $add['id'] = 'add_'.$id; |
|
106 | 106 | $add['class'] = 'add_'.$id; |
107 | 107 | } |
108 | 108 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | |
122 | 122 | // Add all known portlets as drop actions too. If there are multiple matches, there will be a menu |
123 | 123 | $drop_execute = 'javaScript:app.home.add_from_drop'; |
124 | - foreach($portlets as $app => &$children) |
|
124 | + foreach ($portlets as $app => &$children) |
|
125 | 125 | { |
126 | 126 | // Home portlets - uses link system, so all apps that support that are accepted |
127 | - if(!$children['children']) |
|
127 | + if (!$children['children']) |
|
128 | 128 | { |
129 | 129 | $children['class'] = $app; |
130 | 130 | $children['onExecute'] = $drop_execute; |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
136 | - foreach($children['children'] as $portlet => $app_portlet) |
|
136 | + foreach ($children['children'] as $portlet => $app_portlet) |
|
137 | 137 | { |
138 | - if(!is_array($app_portlet)) continue; |
|
138 | + if (!is_array($app_portlet)) continue; |
|
139 | 139 | $app_portlet['class'] = $portlet; |
140 | - $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
|
140 | + $app_portlet['id'] = 'drop_'.$app_portlet['id']; |
|
141 | 141 | $app_portlet['onExecute'] = $drop_execute; |
142 | 142 | $app_portlet['acceptedTypes'] = $app; |
143 | 143 | $app_portlet['type'] = 'drop'; |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | * Actual portlet content is provided by each portlet. |
158 | 158 | * @param template etemplate so attributes can be set |
159 | 159 | */ |
160 | - protected function get_user_portlets(Etemplate &$template) |
|
160 | + protected function get_user_portlets(Etemplate&$template) |
|
161 | 161 | { |
162 | 162 | $portlets = array(); |
163 | 163 | |
164 | - foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
164 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
165 | 165 | { |
166 | - if(strpos($id,'portlet_') !== 0 || // Not a portlet |
|
166 | + if (strpos($id, 'portlet_') !== 0 || // Not a portlet |
|
167 | 167 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
168 | 168 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
169 | 169 | ) continue; |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $classname = $context['class']; |
172 | 172 | |
173 | 173 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
174 | - list($app,$other) = explode('_',$classname); |
|
175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
174 | + list($app, $other) = explode('_', $classname); |
|
175 | + if (!$GLOBALS['egw_info']['apps'][$app]) $app .= '_'.$other; |
|
176 | + if (!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | // Get settings |
188 | 188 | // Exclude common attributes changed through UI and settings lacking a type |
189 | 189 | $settings = $portlet->get_properties(); |
190 | - foreach($settings as $key => $setting) |
|
190 | + foreach ($settings as $key => $setting) |
|
191 | 191 | { |
192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
192 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
193 | 193 | } |
194 | 194 | $settings += $context; |
195 | - foreach(home_portlet::$common_attributes as $attr) |
|
195 | + foreach (home_portlet::$common_attributes as $attr) |
|
196 | 196 | { |
197 | 197 | unset($settings[$attr]); |
198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | // Add in default for admins |
206 | 206 | self::create_default_actions($actions, $id); |
207 | 207 | |
208 | - $template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions); |
|
208 | + $template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions); |
|
209 | 209 | |
210 | 210 | $portlets[] = $portlet_content; |
211 | 211 | } |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | */ |
230 | 230 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
231 | 231 | { |
232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
232 | + if (!$context['class']) $context['class'] = 'home_link_portlet'; |
|
233 | 233 | |
234 | 234 | // This should be set already, but just in case the execution path |
235 | 235 | // is different from normal... |
236 | - if(Api\Json\Response::isJSONResponse()) |
|
236 | + if (Api\Json\Response::isJSONResponse()) |
|
237 | 237 | { |
238 | 238 | $GLOBALS['egw']->framework->response = Api\Json\Response::get(); |
239 | 239 | } |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | |
249 | 249 | // Exclude common attributes changed through UI and settings lacking a type |
250 | 250 | $settings = $portlet->get_properties(); |
251 | - foreach($settings as $key => $setting) |
|
251 | + foreach ($settings as $key => $setting) |
|
252 | 252 | { |
253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
253 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
254 | 254 | } |
255 | 255 | $settings += $context; |
256 | - foreach(home_portlet::$common_attributes as $attr) |
|
256 | + foreach (home_portlet::$common_attributes as $attr) |
|
257 | 257 | { |
258 | 258 | unset($settings[$attr]); |
259 | 259 | } |
@@ -268,31 +268,31 @@ discard block |
||
268 | 268 | self::create_default_actions($attributes['actions'], $id); |
269 | 269 | |
270 | 270 | // Set any provided common attributes (size, etc) |
271 | - foreach(home_portlet::$common_attributes as $name) |
|
271 | + foreach (home_portlet::$common_attributes as $name) |
|
272 | 272 | { |
273 | - if(array_key_exists($name, $context)) |
|
273 | + if (array_key_exists($name, $context)) |
|
274 | 274 | { |
275 | 275 | $attributes[$name] = $context[$name]; |
276 | 276 | } |
277 | 277 | } |
278 | - foreach($attributes as $attr => $value) |
|
278 | + foreach ($attributes as $attr => $value) |
|
279 | 279 | { |
280 | 280 | $etemplate->setElementAttribute($id, $attr, $value); |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Make sure custom javascript is loaded |
284 | 284 | $appname = $context['appname']; |
285 | - if(!$appname) |
|
285 | + if (!$appname) |
|
286 | 286 | { |
287 | - list($app) = explode('_',$classname); |
|
288 | - if($GLOBALS['egw_info']['apps'][$app]) |
|
287 | + list($app) = explode('_', $classname); |
|
288 | + if ($GLOBALS['egw_info']['apps'][$app]) |
|
289 | 289 | { |
290 | 290 | $appname = $app; |
291 | 291 | } |
292 | 292 | } |
293 | 293 | Framework::includeJS('', $classname, $appname ? $appname : 'home'); |
294 | 294 | |
295 | - if($full_exec) |
|
295 | + if ($full_exec) |
|
296 | 296 | { |
297 | 297 | $content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1); |
298 | 298 | } |
@@ -309,23 +309,23 @@ discard block |
||
309 | 309 | protected function get_legacy_portlets(&$content, &$attributes) |
310 | 310 | { |
311 | 311 | $sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']); |
312 | - $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display'); |
|
312 | + $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display'); |
|
313 | 313 | |
314 | - foreach($sorted_apps as $appname) |
|
314 | + foreach ($sorted_apps as $appname) |
|
315 | 315 | { |
316 | 316 | // If there's already [new] settings, or no preference, skip it |
317 | - if($content[$appname]) continue; |
|
317 | + if ($content[$appname]) continue; |
|
318 | 318 | $no_pref = true; |
319 | - foreach($portal_oldvarnames as $varcheck) |
|
319 | + foreach ($portal_oldvarnames as $varcheck) |
|
320 | 320 | { |
321 | 321 | $thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]; |
322 | - if($thisd) |
|
322 | + if ($thisd) |
|
323 | 323 | { |
324 | 324 | $no_pref = false; |
325 | 325 | break; |
326 | 326 | } |
327 | 327 | } |
328 | - if($no_pref || !Api\Hooks::exists('home', $appname)) |
|
328 | + if ($no_pref || !Api\Hooks::exists('home', $appname)) |
|
329 | 329 | { |
330 | 330 | continue; |
331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $_content = ''; |
337 | 337 | $_attributes = array(); |
338 | 338 | $this->get_portlet($appname, $context, $_content, $_attributes); |
339 | - if(trim($_content)) |
|
339 | + if (trim($_content)) |
|
340 | 340 | { |
341 | 341 | $content[$appname] = $_content; |
342 | 342 | $attributes[$appname] = $_attributes; |
@@ -355,24 +355,24 @@ discard block |
||
355 | 355 | |
356 | 356 | // Ignore some problem files and base classes that shouldn't be options |
357 | 357 | $ignore = array( |
358 | - '.','..', |
|
358 | + '.', '..', |
|
359 | 359 | 'class.home_portlet.inc.php', |
360 | 360 | 'class.home_legacy_portlet.inc.php', |
361 | 361 | 'class.home_favorite_portlet.inc.php' |
362 | 362 | ); |
363 | 363 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
364 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
364 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
365 | 365 | { |
366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
367 | - $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
|
368 | - if(!$files) continue; |
|
366 | + if (in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
367 | + $files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/'); |
|
368 | + if (!$files) continue; |
|
369 | 369 | |
370 | - foreach($files as $entry) |
|
370 | + foreach ($files as $entry) |
|
371 | 371 | { |
372 | - if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet')) |
|
372 | + if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet')) |
|
373 | 373 | { |
374 | 374 | list(,$classname) = explode('.', $entry); |
375 | - if(class_exists($classname) && |
|
375 | + if (class_exists($classname) && |
|
376 | 376 | in_array('home_portlet', class_parents($classname, false))) |
377 | 377 | { |
378 | 378 | $classes[$appname][] = $classname; |
@@ -384,19 +384,19 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - if(!$classes[$appname]) continue; |
|
387 | + if (!$classes[$appname]) continue; |
|
388 | 388 | |
389 | 389 | // Build 'Add' actions for each discovered portlet. |
390 | 390 | // Portlets from other apps go in sub-actions |
391 | - $add_to =& $list; |
|
392 | - if($classes[$appname] && $appname != 'home') |
|
391 | + $add_to = & $list; |
|
392 | + if ($classes[$appname] && $appname != 'home') |
|
393 | 393 | { |
394 | 394 | $list[$appname] = array( |
395 | 395 | 'caption' => lang($appname), |
396 | 396 | ); |
397 | - $add_to =& $list[$appname]['children']; |
|
397 | + $add_to = & $list[$appname]['children']; |
|
398 | 398 | } |
399 | - foreach($classes[$appname] as $portlet) |
|
399 | + foreach ($classes[$appname] as $portlet) |
|
400 | 400 | { |
401 | 401 | $instance = new $portlet(); |
402 | 402 | $desc = $instance->get_description(); |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | }, array(), 60); |
417 | 417 | |
418 | 418 | // Filter list by current user's permissions |
419 | - foreach(array_keys($list) as $appname) |
|
419 | + foreach (array_keys($list) as $appname) |
|
420 | 420 | { |
421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
422 | - if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
421 | + if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
422 | + if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
423 | 423 | { |
424 | 424 | unset($list[$appname]); |
425 | 425 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | protected static function create_default_actions(&$actions, $portlet_id = null) |
438 | 438 | { |
439 | - if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
439 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
440 | 440 | { |
441 | 441 | $actions['add_default'] = array( |
442 | 442 | 'type' => 'popup', |
@@ -446,25 +446,25 @@ discard block |
||
446 | 446 | 'icon' => 'preference' |
447 | 447 | ); |
448 | 448 | // Customize for the given portlet |
449 | - if($portlet_id !== null) |
|
449 | + if ($portlet_id !== null) |
|
450 | 450 | { |
451 | - foreach(array('forced','group','default') as $location) |
|
451 | + foreach (array('forced', 'group', 'default') as $location) |
|
452 | 452 | { |
453 | 453 | $loc = $GLOBALS['egw']->preferences->$location; |
454 | 454 | |
455 | - if($loc['home'][$portlet_id]) |
|
455 | + if ($loc['home'][$portlet_id]) |
|
456 | 456 | { |
457 | 457 | // If it's forced, no point in setting default |
458 | - if($location == 'forced') |
|
458 | + if ($location == 'forced') |
|
459 | 459 | { |
460 | 460 | unset($actions['add_default']); |
461 | 461 | } |
462 | 462 | // If it's a group, we'd like to know which |
463 | - if($location == 'group') |
|
463 | + if ($location == 'group') |
|
464 | 464 | { |
465 | 465 | $options = array('account_type' => 'groups'); |
466 | - $groups = Api\Accounts::link_query('',$options); |
|
467 | - foreach(array_keys($groups) as $gid) |
|
466 | + $groups = Api\Accounts::link_query('', $options); |
|
467 | + foreach (array_keys($groups) as $gid) |
|
468 | 468 | { |
469 | 469 | $prefs = new Api\Preferences($gid); |
470 | 470 | $prefs->read_repository(); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | $actions['remove_default_'.$location] = array( |
479 | 479 | 'type' => 'popup', |
480 | - 'caption' => lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location), |
|
480 | + 'caption' => lang('Remove as default for %1', is_numeric($location) ? Api\Accounts::id2name($location, 'account_fullname') : $location), |
|
481 | 481 | 'onExecute' => 'javaScript:app.home.set_default', |
482 | 482 | 'group' => 'Admins', |
483 | 483 | 'portlet_group' => $location |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | // Change action for forced |
491 | - if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
491 | + if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
492 | 492 | { |
493 | 493 | // No one can remove it |
494 | 494 | $actions['remove_portlet']['enabled'] = false; |
495 | - $actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')'; |
|
495 | + $actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')'; |
|
496 | 496 | |
497 | 497 | // Non-admins can't edit it |
498 | - if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
498 | + if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
499 | 499 | { |
500 | 500 | $actions['edit_settings']['enabled'] = false; |
501 | 501 | $actions['edit_settings']['visible'] = false; |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | public function ajax_set_properties($portlet_id, $attributes, $values, $group = false) |
515 | 515 | { |
516 | 516 | //error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)"); |
517 | - if(!$attributes) |
|
517 | + if (!$attributes) |
|
518 | 518 | { |
519 | 519 | $attributes = array(); |
520 | 520 | } |
521 | 521 | |
522 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
522 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
523 | 523 | { |
524 | - if($group == 'forced') |
|
524 | + if ($group == 'forced') |
|
525 | 525 | { |
526 | 526 | // Quietly reject |
527 | 527 | return; |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | // Not an admin, can only override. |
530 | 530 | $group = false; |
531 | 531 | } |
532 | - if($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
532 | + if ($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
533 | 533 | { |
534 | 534 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
535 | 535 | } |
@@ -543,23 +543,23 @@ discard block |
||
543 | 543 | |
544 | 544 | $response = Api\Json\Response::get(); |
545 | 545 | |
546 | - if($values =='~reload~') |
|
546 | + if ($values == '~reload~') |
|
547 | 547 | { |
548 | 548 | $full_exec = true; |
549 | 549 | $values = array(); |
550 | 550 | } |
551 | - if($values == '~remove~') |
|
551 | + if ($values == '~remove~') |
|
552 | 552 | { |
553 | 553 | // Already removed client side, needs to be removed permanently |
554 | - $default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id]; |
|
554 | + $default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id]; |
|
555 | 555 | |
556 | - if($default) |
|
556 | + if ($default) |
|
557 | 557 | { |
558 | 558 | // Can't delete forced - not a UI option though |
559 | - if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
559 | + if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
560 | 560 | { |
561 | 561 | // Set a flag to override default instead of just delete |
562 | - $GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted'); |
|
562 | + $GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted'); |
|
563 | 563 | $GLOBALS['egw']->preferences->save_repository(); |
564 | 564 | } |
565 | 565 | } |
@@ -576,19 +576,19 @@ discard block |
||
576 | 576 | // Remove some constant stuff that winds up here |
577 | 577 | unset($values['edit_template']); |
578 | 578 | unset($values['readonly']); |
579 | - unset($values['disabled']);unset($values['no_lang']); |
|
579 | + unset($values['disabled']); unset($values['no_lang']); |
|
580 | 580 | unset($values['actions']); |
581 | 581 | unset($values['statustext']); |
582 | - unset($values['type']);unset($values['label']);unset($values['status']); |
|
583 | - unset($values['value']);unset($values['align']); |
|
582 | + unset($values['type']); unset($values['label']); unset($values['status']); |
|
583 | + unset($values['value']); unset($values['align']); |
|
584 | 584 | |
585 | 585 | // Get portlet settings, and merge new with old |
586 | 586 | $context = array_merge((array)$portlets[$portlet_id], $values); |
587 | 587 | $context['group'] = $group; |
588 | 588 | |
589 | 589 | // Handle add IDs |
590 | - $classname =& $context['class']; |
|
591 | - if(strpos($classname,'add_') == 0 && !class_exists($classname)) |
|
590 | + $classname = & $context['class']; |
|
591 | + if (strpos($classname, 'add_') == 0 && !class_exists($classname)) |
|
592 | 592 | { |
593 | 593 | $add = true; |
594 | 594 | $classname = substr($classname, 4); |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | $portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec); |
598 | 598 | |
599 | 599 | $context['class'] = get_class($portlet); |
600 | - foreach($portlet->get_properties() as $property) |
|
600 | + foreach ($portlet->get_properties() as $property) |
|
601 | 601 | { |
602 | - if($values[$property['name']]) |
|
602 | + if ($values[$property['name']]) |
|
603 | 603 | { |
604 | 604 | $context[$property['name']] = $values[$property['name']]; |
605 | 605 | } |
606 | - elseif($portlets[$portlet_id][$property['name']]) |
|
606 | + elseif ($portlets[$portlet_id][$property['name']]) |
|
607 | 607 | { |
608 | 608 | $context[$property['name']] = $portlets[$portlet_id][$property['name']]; |
609 | 609 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $update = array('attributes' => $attributes); |
614 | 614 | |
615 | 615 | // New portlet? Flag going straight to edit mode |
616 | - if($add) |
|
616 | + if ($add) |
|
617 | 617 | { |
618 | 618 | $update['edit_settings'] = true; |
619 | 619 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | |
627 | 627 | // Save updated preferences |
628 | - $prefs->save_repository(True,$type); |
|
628 | + $prefs->save_repository(True, $type); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -638,10 +638,10 @@ discard block |
||
638 | 638 | public static function ajax_set_default($action, $portlet_ids, $group) |
639 | 639 | { |
640 | 640 | // Admins only |
641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
641 | + if (!$GLOBALS['egw_info']['apps']['admin']) return; |
|
642 | 642 | |
643 | 643 | // Load the appropriate group |
644 | - if($group) |
|
644 | + if ($group) |
|
645 | 645 | { |
646 | 646 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
647 | 647 | } |
@@ -653,30 +653,30 @@ discard block |
||
653 | 653 | |
654 | 654 | $type = is_numeric($group) ? "user" : $group; |
655 | 655 | |
656 | - if($action == 'add') |
|
656 | + if ($action == 'add') |
|
657 | 657 | { |
658 | - foreach($portlet_ids as $id) |
|
658 | + foreach ($portlet_ids as $id) |
|
659 | 659 | { |
660 | 660 | Api\Json\Response::get()->call('egw.message', lang("Set default")); |
661 | 661 | // Current user is setting the default, copy their settings |
662 | 662 | $settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id]; |
663 | 663 | $settings['group'] = $group; |
664 | - $prefs->add('home',$id,$settings,$type); |
|
664 | + $prefs->add('home', $id, $settings, $type); |
|
665 | 665 | |
666 | 666 | // Remove user's copy |
667 | - $GLOBALS['egw']->preferences->delete('home',$id); |
|
667 | + $GLOBALS['egw']->preferences->delete('home', $id); |
|
668 | 668 | $GLOBALS['egw']->preferences->save_repository(true); |
669 | 669 | } |
670 | 670 | } |
671 | 671 | else if ($action == "delete") |
672 | 672 | { |
673 | - foreach($portlet_ids as $id) |
|
673 | + foreach ($portlet_ids as $id) |
|
674 | 674 | { |
675 | 675 | Api\Json\Response::get()->call('egw.message', lang("Removed default")); |
676 | - $prefs->delete('home',$id, $type); |
|
676 | + $prefs->delete('home', $id, $type); |
|
677 | 677 | } |
678 | 678 | } |
679 | - $prefs->save_repository(false,$type); |
|
679 | + $prefs->save_repository(false, $type); |
|
680 | 680 | |
681 | 681 | // Update Api\Preferences client side for consistency |
682 | 682 | $prefs = $GLOBALS['egw']->preferences; |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | 'state' => array( |
730 | 730 | 'cat_id' => '0', |
731 | 731 | 'filter' => 'default', |
732 | - 'owner' => 0, // current user |
|
732 | + 'owner' => 0, // current user |
|
733 | 733 | 'sortby' => 'user', |
734 | 734 | 'planner_days' => '0', |
735 | 735 | 'view' => 'week', |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | { |
779 | 779 | unset($app_prefs['home']['portlet_setup142n']); |
780 | 780 | } |
781 | - foreach($app_prefs as $app => $prefs) |
|
781 | + foreach ($app_prefs as $app => $prefs) |
|
782 | 782 | { |
783 | - foreach($prefs as $name => $value) |
|
783 | + foreach ($prefs as $name => $value) |
|
784 | 784 | { |
785 | 785 | Api\Preferences::delete_preference($app, $name, 'default'); |
786 | 786 | $preferences->add($app, $name, $value, 'default'); |
@@ -801,10 +801,10 @@ discard block |
||
801 | 801 | */ |
802 | 802 | public static function setup_default_home() |
803 | 803 | { |
804 | - switch($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
804 | + switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
805 | 805 | { |
806 | 806 | case self::CURRENT_HOME_VERSION: |
807 | - return; // already up to date --> nothing to do |
|
807 | + return; // already up to date --> nothing to do |
|
808 | 808 | |
809 | 809 | default: |
810 | 810 | call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION))); |
@@ -76,7 +76,10 @@ discard block |
||
76 | 76 | { |
77 | 77 | $id = $p_data['id']; |
78 | 78 | |
79 | - if(!$id) continue; |
|
79 | + if(!$id) |
|
80 | + { |
|
81 | + continue; |
|
82 | + } |
|
80 | 83 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
81 | 84 | } |
82 | 85 | |
@@ -135,7 +138,10 @@ discard block |
||
135 | 138 | { |
136 | 139 | foreach($children['children'] as $portlet => $app_portlet) |
137 | 140 | { |
138 | - if(!is_array($app_portlet)) continue; |
|
141 | + if(!is_array($app_portlet)) |
|
142 | + { |
|
143 | + continue; |
|
144 | + } |
|
139 | 145 | $app_portlet['class'] = $portlet; |
140 | 146 | $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
141 | 147 | $app_portlet['onExecute'] = $drop_execute; |
@@ -166,14 +172,21 @@ discard block |
||
166 | 172 | if(strpos($id,'portlet_') !== 0 || // Not a portlet |
167 | 173 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
168 | 174 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
169 | - ) continue; |
|
175 | + ) |
|
176 | + { |
|
177 | + continue; |
|
178 | + } |
|
170 | 179 | |
171 | 180 | $classname = $context['class']; |
172 | 181 | |
173 | 182 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
174 | 183 | list($app,$other) = explode('_',$classname); |
175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
184 | + if(!$GLOBALS['egw_info']['apps'][$app]) |
|
185 | + { |
|
186 | + $app .='_'.$other; |
|
187 | + } |
|
188 | + if(!$GLOBALS['egw_info']['user']['apps'][$app]) |
|
189 | + { |
|
177 | 190 | continue; |
178 | 191 | } |
179 | 192 | |
@@ -189,7 +202,10 @@ discard block |
||
189 | 202 | $settings = $portlet->get_properties(); |
190 | 203 | foreach($settings as $key => $setting) |
191 | 204 | { |
192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
205 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
206 | + { |
|
207 | + unset($settings[$key]); |
|
208 | + } |
|
193 | 209 | } |
194 | 210 | $settings += $context; |
195 | 211 | foreach(home_portlet::$common_attributes as $attr) |
@@ -229,7 +245,10 @@ discard block |
||
229 | 245 | */ |
230 | 246 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
231 | 247 | { |
232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
248 | + if(!$context['class']) |
|
249 | + { |
|
250 | + $context['class'] = 'home_link_portlet'; |
|
251 | + } |
|
233 | 252 | |
234 | 253 | // This should be set already, but just in case the execution path |
235 | 254 | // is different from normal... |
@@ -250,7 +269,10 @@ discard block |
||
250 | 269 | $settings = $portlet->get_properties(); |
251 | 270 | foreach($settings as $key => $setting) |
252 | 271 | { |
253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
272 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
273 | + { |
|
274 | + unset($settings[$key]); |
|
275 | + } |
|
254 | 276 | } |
255 | 277 | $settings += $context; |
256 | 278 | foreach(home_portlet::$common_attributes as $attr) |
@@ -314,7 +336,10 @@ discard block |
||
314 | 336 | foreach($sorted_apps as $appname) |
315 | 337 | { |
316 | 338 | // If there's already [new] settings, or no preference, skip it |
317 | - if($content[$appname]) continue; |
|
339 | + if($content[$appname]) |
|
340 | + { |
|
341 | + continue; |
|
342 | + } |
|
318 | 343 | $no_pref = true; |
319 | 344 | foreach($portal_oldvarnames as $varcheck) |
320 | 345 | { |
@@ -349,7 +374,8 @@ discard block |
||
349 | 374 | */ |
350 | 375 | protected function get_portlet_list() |
351 | 376 | { |
352 | - $list = Api\Cache::getTree('home', 'portlet_classes', function() { |
|
377 | + $list = Api\Cache::getTree('home', 'portlet_classes', function() |
|
378 | + { |
|
353 | 379 | $list = array(); |
354 | 380 | $classes = array(); |
355 | 381 | |
@@ -363,9 +389,15 @@ discard block |
||
363 | 389 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
364 | 390 | foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
365 | 391 | { |
366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
392 | + if(in_array($appname, array('phpgwapi', 'felamimail'))) |
|
393 | + { |
|
394 | + continue; |
|
395 | + } |
|
367 | 396 | $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
368 | - if(!$files) continue; |
|
397 | + if(!$files) |
|
398 | + { |
|
399 | + continue; |
|
400 | + } |
|
369 | 401 | |
370 | 402 | foreach($files as $entry) |
371 | 403 | { |
@@ -384,7 +416,10 @@ discard block |
||
384 | 416 | } |
385 | 417 | } |
386 | 418 | |
387 | - if(!$classes[$appname]) continue; |
|
419 | + if(!$classes[$appname]) |
|
420 | + { |
|
421 | + continue; |
|
422 | + } |
|
388 | 423 | |
389 | 424 | // Build 'Add' actions for each discovered portlet. |
390 | 425 | // Portlets from other apps go in sub-actions |
@@ -418,7 +453,8 @@ discard block |
||
418 | 453 | // Filter list by current user's permissions |
419 | 454 | foreach(array_keys($list) as $appname) |
420 | 455 | { |
421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
456 | + if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) |
|
457 | + { |
|
422 | 458 | if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
423 | 459 | { |
424 | 460 | unset($list[$appname]); |
@@ -638,7 +674,10 @@ discard block |
||
638 | 674 | public static function ajax_set_default($action, $portlet_ids, $group) |
639 | 675 | { |
640 | 676 | // Admins only |
641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
677 | + if(!$GLOBALS['egw_info']['apps']['admin']) |
|
678 | + { |
|
679 | + return; |
|
680 | + } |
|
642 | 681 | |
643 | 682 | // Load the appropriate group |
644 | 683 | if($group) |
@@ -701,7 +740,10 @@ discard block |
||
701 | 740 | $preferences = $GLOBALS['egw']->preferences; |
702 | 741 | $preferences->read_repository(); |
703 | 742 | $lang = $preferences->default['common']['lang']; |
704 | - if (empty($lang)) $lang = 'en'; |
|
743 | + if (empty($lang)) |
|
744 | + { |
|
745 | + $lang = 'en'; |
|
746 | + } |
|
705 | 747 | |
706 | 748 | Api\Translation::add_app('calendar', $lang); |
707 | 749 | $weekview = lang('Weekview'); |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * imports entries according to given definition object. |
120 | 120 | * @param resource $_stream |
121 | - * @param string $_charset |
|
122 | - * @param definition $_definition |
|
121 | + * @param importexport_definition $_definition |
|
123 | 122 | */ |
124 | 123 | public function import( $_stream, importexport_definition $_definition ) { |
125 | 124 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -222,7 +221,7 @@ discard block |
||
222 | 221 | * |
223 | 222 | * Updates the count of actions taken |
224 | 223 | * |
225 | - * @return boolean success |
|
224 | + * @return null|boolean success |
|
226 | 225 | */ |
227 | 226 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 227 | { |
@@ -274,7 +273,7 @@ discard block |
||
274 | 273 | * @param condition array = array('string' => field name) |
275 | 274 | * @param matches - On return, will be filled with matching records |
276 | 275 | * |
277 | - * @return boolean |
|
276 | + * @return boolean|null |
|
278 | 277 | */ |
279 | 278 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
280 | 279 | { |
@@ -451,7 +450,7 @@ discard block |
||
451 | 450 | /** |
452 | 451 | * Allows an extending class to alter a row for preview |
453 | 452 | * |
454 | - * @param egw_record $row_entry |
|
453 | + * @param importexport_iface_egw_record $row_entry |
|
455 | 454 | */ |
456 | 455 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
457 | 456 | { |
@@ -523,7 +522,7 @@ discard block |
||
523 | 522 | * Get the primary key for an entry based on a custom field |
524 | 523 | * Returns key, so regular linking can take over |
525 | 524 | * |
526 | - * @param int $record_number Row number, used for errors |
|
525 | + * @param int $record_num Row number, used for errors |
|
527 | 526 | * @param string $app Target application name |
528 | 527 | * @param string $value CSV value in the form of custom_field_name:value |
529 | 528 | */ |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $record_class = isset(static::$record_class) ? static::$record_class : "{$app}_egw_record"; |
164 | 164 | |
165 | 165 | // Needed for categories to work right |
166 | - $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
166 | + $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
167 | 167 | |
168 | 168 | $this->init($_definition); |
169 | 169 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - *Import a single record |
|
219 | - * |
|
220 | - * You don't need to worry about mappings or translations, they've been done already. |
|
221 | - * You do need to handle the conditions and the actions taken. |
|
222 | - * |
|
223 | - * Updates the count of actions taken |
|
224 | - * |
|
225 | - * @return boolean success |
|
226 | - */ |
|
218 | + *Import a single record |
|
219 | + * |
|
220 | + * You don't need to worry about mappings or translations, they've been done already. |
|
221 | + * You do need to handle the conditions and the actions taken. |
|
222 | + * |
|
223 | + * Updates the count of actions taken |
|
224 | + * |
|
225 | + * @return boolean success |
|
226 | + */ |
|
227 | 227 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 228 | { |
229 | 229 | if ( $this->definition->plugin_options['conditions'] ) { |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param stream $stream |
404 | 404 | * @param importexport_definition $definition |
405 | 405 | * @return String HTML for preview |
406 | - */ |
|
406 | + */ |
|
407 | 407 | public function preview( $stream, importexport_definition $definition ) |
408 | 408 | { |
409 | 409 | $this->import($stream, $definition); |
@@ -639,37 +639,37 @@ discard block |
||
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
642 | - * Returns warnings that were encountered during importing |
|
643 | - * Maximum of one warning message per record, but you can append if you need to |
|
644 | - * |
|
645 | - * @return Array ( |
|
646 | - * record_# => warning message |
|
647 | - * ) |
|
648 | - */ |
|
642 | + * Returns warnings that were encountered during importing |
|
643 | + * Maximum of one warning message per record, but you can append if you need to |
|
644 | + * |
|
645 | + * @return Array ( |
|
646 | + * record_# => warning message |
|
647 | + * ) |
|
648 | + */ |
|
649 | 649 | public function get_warnings() { |
650 | 650 | return $this->warnings; |
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
654 | - * Returns errors that were encountered during importing |
|
655 | - * Maximum of one error message per record, but you can append if you need to |
|
656 | - * |
|
657 | - * @return Array ( |
|
658 | - * record_# => error message |
|
659 | - * ) |
|
660 | - */ |
|
654 | + * Returns errors that were encountered during importing |
|
655 | + * Maximum of one error message per record, but you can append if you need to |
|
656 | + * |
|
657 | + * @return Array ( |
|
658 | + * record_# => error message |
|
659 | + * ) |
|
660 | + */ |
|
661 | 661 | public function get_errors() { |
662 | 662 | return $this->errors; |
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
666 | - * Returns a list of actions taken, and the number of records for that action. |
|
667 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
668 | - * |
|
669 | - * @return Array ( |
|
670 | - * action => record count |
|
671 | - * ) |
|
672 | - */ |
|
666 | + * Returns a list of actions taken, and the number of records for that action. |
|
667 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
668 | + * |
|
669 | + * @return Array ( |
|
670 | + * action => record count |
|
671 | + * ) |
|
672 | + */ |
|
673 | 673 | public function get_results() { |
674 | 674 | return $this->results; |
675 | 675 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
19 | 19 | * |
20 | 20 | */ |
21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
22 | 22 | |
23 | 23 | protected static $plugin_options = array( |
24 | - 'fieldsep', // char |
|
25 | - 'charset', // string |
|
26 | - 'record_owner', // int |
|
27 | - 'update_cats', // string {override|add} overides record |
|
24 | + 'fieldsep', // char |
|
25 | + 'charset', // string |
|
26 | + 'record_owner', // int |
|
27 | + 'update_cats', // string {override|add} overides record |
|
28 | 28 | // with cat(s) from csv OR add the cat from |
29 | 29 | // csv file to exeisting cat(s) of record |
30 | 30 | 'num_header_lines', // int number of header lines |
31 | 31 | 'field_conversion', // array( $csv_col_num => conversion) |
32 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
33 | - 'conditions', /* => array containing condition arrays: |
|
32 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
33 | + 'conditions', /* => array containing condition arrays: |
|
34 | 34 | 'type' => exists, // exists |
35 | 35 | 'string' => '#kundennummer', |
36 | 36 | 'true' => array( |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * Actions wich could be done to data entries |
49 | 49 | * If your plugin supports different actions, be sure to modify this array |
50 | 50 | */ |
51 | - protected static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
51 | + protected static $actions = array('none', 'update', 'insert', 'delete',); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Conditions for actions |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var array |
58 | 58 | */ |
59 | - protected static $conditions = array( 'exists', 'equal', 'less_than'); |
|
59 | + protected static $conditions = array('exists', 'equal', 'less_than'); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * This is the definition that will be used to deal with the CSV file |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $_charset |
122 | 122 | * @param definition $_definition |
123 | 123 | */ |
124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
125 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
124 | + public function import($_stream, importexport_definition $_definition) { |
|
125 | + $import_csv = new importexport_import_csv($_stream, array( |
|
126 | 126 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
127 | 127 | 'charset' => $_definition->plugin_options['charset'], |
128 | 128 | )); |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | $this->definition = $_definition; |
131 | 131 | |
132 | 132 | // user, is admin ? |
133 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
133 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
134 | 134 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
135 | 135 | |
136 | 136 | // dry run? |
137 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
137 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
138 | 138 | |
139 | 139 | // set FieldMapping. |
140 | 140 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
144 | 144 | |
145 | 145 | //check if file has a header lines |
146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
146 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
147 | 147 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
148 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
149 | 149 | // First method is preferred |
150 | 150 | $import_csv->skip_records(1); |
151 | 151 | } |
@@ -167,38 +167,38 @@ discard block |
||
167 | 167 | |
168 | 168 | $this->init($_definition); |
169 | 169 | |
170 | - while ( $record = $import_csv->get_record() ) { |
|
170 | + while ($record = $import_csv->get_record()) { |
|
171 | 171 | $success = false; |
172 | 172 | |
173 | 173 | // don't import empty records |
174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
174 | + if (count(array_unique($record)) < 2) continue; |
|
175 | 175 | |
176 | 176 | |
177 | 177 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
178 | + if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
179 | 179 | |
180 | 180 | $egw_record = new $record_class(); |
181 | 181 | $egw_record->set_record($record); |
182 | 182 | $success = $this->import_record($egw_record, $import_csv); |
183 | 183 | |
184 | - if($success) |
|
184 | + if ($success) |
|
185 | 185 | { |
186 | 186 | $this->do_special_fields($egw_record, $import_csv); |
187 | 187 | } |
188 | - if($success) $count++; |
|
188 | + if ($success) $count++; |
|
189 | 189 | |
190 | 190 | // Add some more time |
191 | - if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
191 | + if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
192 | 192 | { |
193 | 193 | set_time_limit(10); |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Keep a few records for preview, but process the whole file |
197 | - if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
197 | + if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
198 | 198 | { |
199 | 199 | $this->preview_records[] = $egw_record; |
200 | 200 | } |
201 | - if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
201 | + if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
202 | 202 | { |
203 | 203 | $this->errors[] = 'Too many errors, aborted'; |
204 | 204 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * Stub to hook into import initialization - set lookups, etc. |
212 | 212 | */ |
213 | - protected function init(importexport_definition &$definition) |
|
213 | + protected function init(importexport_definition&$definition) |
|
214 | 214 | { |
215 | 215 | } |
216 | 216 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return boolean success |
226 | 226 | */ |
227 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
227 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
228 | 228 | { |
229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
229 | + if ($this->definition->plugin_options['conditions']) { |
|
230 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
231 | 231 | $result = false; |
232 | - switch ( $condition['type'] ) { |
|
232 | + switch ($condition['type']) { |
|
233 | 233 | // exists |
234 | 234 | case 'exists' : |
235 | 235 | // Check for that record |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | die('condition / action not supported!!!'); |
246 | 246 | break; |
247 | 247 | } |
248 | - if($result) |
|
248 | + if ($result) |
|
249 | 249 | { |
250 | 250 | // Apply true action to any matching records found |
251 | 251 | $action = $condition['true']; |
252 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
252 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
253 | 253 | } |
254 | 254 | else |
255 | 255 | { |
256 | 256 | // Apply false action if no matching records found |
257 | 257 | $action = $condition['false']; |
258 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
258 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
259 | 259 | } |
260 | 260 | if ($action['stop']) break; |
261 | 261 | } |
262 | 262 | } else { |
263 | 263 | // unconditional insert |
264 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
264 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $success; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
|
279 | + protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$matches = array()) |
|
280 | 280 | { |
281 | 281 | } |
282 | 282 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | - protected function equal(importexport_iface_egw_record &$record, Array &$condition) |
|
291 | + protected function equal(importexport_iface_egw_record&$record, Array &$condition) |
|
292 | 292 | { |
293 | 293 | $field = $condition['string']; |
294 | 294 | return $record->$field == $condition['op_2']; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - protected function less_than(importexport_iface_egw_record &$record, Array &$condition) |
|
306 | + protected function less_than(importexport_iface_egw_record&$record, Array &$condition) |
|
307 | 307 | { |
308 | 308 | $field = $condition['string']; |
309 | 309 | return $record->$field < $condition['op_2']; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param int $record_num Which record number is being dealt with. Used for error messages. |
323 | 323 | * @return bool success or not |
324 | 324 | */ |
325 | - protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ); |
|
325 | + protected abstract function action($_action, importexport_iface_egw_record&$record, $record_num = 0); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Handle special fields |
@@ -332,51 +332,51 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param importexport_iface_egw_record $record |
334 | 334 | */ |
335 | - protected function do_special_fields(importexport_iface_egw_record &$record, &$import_csv) |
|
335 | + protected function do_special_fields(importexport_iface_egw_record&$record, &$import_csv) |
|
336 | 336 | { |
337 | 337 | $id = $record->get_identifier(); |
338 | 338 | |
339 | 339 | // Warn if there's no ID unless it's a dry_run because there probably won't be an ID then |
340 | - if(!$this->dry_run && !$id) |
|
340 | + if (!$this->dry_run && !$id) |
|
341 | 341 | { |
342 | 342 | $this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record"; |
343 | 343 | return; |
344 | 344 | } |
345 | 345 | |
346 | - foreach(self::$special_fields as $field => $desc) { |
|
347 | - if(!$record->$field) continue; |
|
348 | - if(strpos($field, 'link') === 0) { |
|
349 | - list($app, $app_id) = explode(':', $record->$field,2); |
|
346 | + foreach (self::$special_fields as $field => $desc) { |
|
347 | + if (!$record->$field) continue; |
|
348 | + if (strpos($field, 'link') === 0) { |
|
349 | + list($app, $app_id) = explode(':', $record->$field, 2); |
|
350 | 350 | |
351 | - list($link, $type) = explode('_',$field); |
|
351 | + list($link, $type) = explode('_', $field); |
|
352 | 352 | |
353 | 353 | // Searching, take first result |
354 | - if($type == 'custom') |
|
354 | + if ($type == 'custom') |
|
355 | 355 | { |
356 | 356 | $app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position()); |
357 | 357 | } |
358 | - else if($type == 'search') |
|
358 | + else if ($type == 'search') |
|
359 | 359 | { |
360 | 360 | $result = Link::query($app, $app_id); |
361 | 361 | do |
362 | 362 | { |
363 | 363 | $app_id = key($result); |
364 | 364 | shift($result); |
365 | - } while($result && !$app_id); |
|
365 | + } while ($result && !$app_id); |
|
366 | 366 | } |
367 | 367 | } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
368 | 368 | $app = $field; |
369 | 369 | $app_id = $record->$field; |
370 | 370 | |
371 | 371 | // Searching, take first result |
372 | - if(!is_numeric($app_id)) |
|
372 | + if (!is_numeric($app_id)) |
|
373 | 373 | { |
374 | 374 | $result = Link::query($app, $app_id); |
375 | 375 | do |
376 | 376 | { |
377 | 377 | $app_id = key($result); |
378 | 378 | shift($result); |
379 | - } while($result && !$app_id); |
|
379 | + } while ($result && !$app_id); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | else if ($field == 'contact') |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id)) |
389 | 389 | { |
390 | - $link_id = Link::link($this->definition->application,$id,$app,$app_id); |
|
390 | + $link_id = Link::link($this->definition->application, $id, $app, $app_id); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | * @param importexport_definition $definition |
405 | 405 | * @return String HTML for preview |
406 | 406 | */ |
407 | - public function preview( $stream, importexport_definition $definition ) |
|
407 | + public function preview($stream, importexport_definition $definition) |
|
408 | 408 | { |
409 | 409 | $this->import($stream, $definition); |
410 | 410 | rewind($stream); |
411 | 411 | |
412 | 412 | // Set up result |
413 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
413 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
414 | 414 | |
415 | 415 | // Load labels for app |
416 | 416 | $record_class = get_class($this->preview_records[0]); |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | $labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']); |
420 | 420 | |
421 | 421 | $plugin = get_called_class(); |
422 | - $wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin); |
|
422 | + $wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin); |
|
423 | 423 | try { |
424 | 424 | $wizard = new $wizard_name; |
425 | 425 | $fields = $wizard->get_import_fields(); |
426 | - foreach($labels as $field => &$label) |
|
426 | + foreach ($labels as $field => &$label) |
|
427 | 427 | { |
428 | - if($fields[$field]) $label = $fields[$field]; |
|
428 | + if ($fields[$field]) $label = $fields[$field]; |
|
429 | 429 | } |
430 | 430 | } catch (Exception $e) { |
431 | 431 | Api\Translation::add_app($definition->application); |
432 | - foreach($labels as $field => &$label) { |
|
432 | + foreach ($labels as $field => &$label) { |
|
433 | 433 | $label = lang($label); |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | 437 | // Set up HTML |
438 | 438 | $rows['h1'] = $labels; |
439 | - foreach($this->preview_records as $i => $row_data) |
|
439 | + foreach ($this->preview_records as $i => $row_data) |
|
440 | 440 | { |
441 | 441 | // Convert to human-friendly |
442 | - importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups); |
|
442 | + importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups); |
|
443 | 443 | $this->row_preview($row_data); |
444 | 444 | $rows[] = $row_data->get_record_array(); |
445 | 445 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param egw_record $row_entry |
455 | 455 | */ |
456 | - protected function row_preview(importexport_iface_egw_record &$row_entry) |
|
456 | + protected function row_preview(importexport_iface_egw_record&$row_entry) |
|
457 | 457 | { |
458 | 458 | } |
459 | 459 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @param string $org_name |
469 | 469 | * @return int|boolean Contact ID of first match, or false if none found |
470 | 470 | */ |
471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
471 | + public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) { |
|
472 | 472 | |
473 | 473 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
474 | 474 | static $contacts; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
479 | 479 | } |
480 | 480 | $n_family = trim($n_family); |
481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
481 | + if (!is_null($n_given)) $n_given = trim($n_given); |
|
482 | 482 | if (!is_object($contacts)) |
483 | 483 | { |
484 | 484 | $contacts = new Api\Contacts(); |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | if (!is_null($org_name)) // org_name given? |
487 | 487 | { |
488 | 488 | $org_name = trim($org_name); |
489 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
|
489 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name"); |
|
490 | 490 | if (!count($addrs)) |
491 | 491 | { |
492 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
|
492 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name'); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | } |
499 | 499 | if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
500 | 500 | { |
501 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
|
501 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn'); |
|
502 | 502 | } |
503 | 503 | if (count($addrs)) |
504 | 504 | { |
505 | - if(!$record || !$record->get_identifier()) |
|
505 | + if (!$record || !$record->get_identifier()) |
|
506 | 506 | { |
507 | 507 | return $addrs[0]['id']; |
508 | 508 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | { |
513 | 513 | $id = key($addrs); |
514 | 514 | array_shift($addrs); |
515 | - } while($addrs && !$id && $id == $record->get_identifier()); |
|
515 | + } while ($addrs && !$id && $id == $record->get_identifier()); |
|
516 | 516 | return $id; |
517 | 517 | } |
518 | 518 | } |
@@ -527,22 +527,22 @@ discard block |
||
527 | 527 | * @param string $app Target application name |
528 | 528 | * @param string $value CSV value in the form of custom_field_name:value |
529 | 529 | */ |
530 | - protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num) |
|
530 | + protected function link_by_cf(importexport_iface_egw_record&$record, $app, $value, $record_num) |
|
531 | 531 | { |
532 | 532 | $app_id = false; |
533 | 533 | |
534 | - list($custom_field, $value) = explode(':',$value); |
|
534 | + list($custom_field, $value) = explode(':', $value); |
|
535 | 535 | // Find matching entry |
536 | - if($app && $custom_field && $value) |
|
536 | + if ($app && $custom_field && $value) |
|
537 | 537 | { |
538 | 538 | $cfs = Api\Storage\Customfields::get($app); |
539 | 539 | // Error if no custom fields, probably something wrong in definition |
540 | - if(!$cfs[$custom_field]) |
|
540 | + if (!$cfs[$custom_field]) |
|
541 | 541 | { |
542 | 542 | // Check for users specifing label instead of name |
543 | - foreach($cfs as $name => $settings) |
|
543 | + foreach ($cfs as $name => $settings) |
|
544 | 544 | { |
545 | - if(strtolower($settings['label']) == strtolower($custom_field)) |
|
545 | + if (strtolower($settings['label']) == strtolower($custom_field)) |
|
546 | 546 | { |
547 | 547 | $custom_field = $name; |
548 | 548 | break; |
@@ -551,30 +551,30 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | // Couldn't find field, give an error - something's wrong |
554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
554 | + if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) { |
|
555 | 555 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
556 | 556 | $custom_field, lang($app)); |
557 | 557 | return false; |
558 | 558 | } |
559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
559 | + if ($custom_field[0] != '#') $custom_field = '#'.$custom_field; |
|
560 | 560 | error_log("Searching for $custom_field = $value"); |
561 | 561 | // Search |
562 | - if(Link::get_registry($app, 'query')) |
|
562 | + if (Link::get_registry($app, 'query')) |
|
563 | 563 | { |
564 | - $options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value))); |
|
564 | + $options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value))); |
|
565 | 565 | $result = Link::query($app, '', $options); |
566 | 566 | |
567 | 567 | // Only one allowed |
568 | - if($record->get_identifier()) |
|
568 | + if ($record->get_identifier()) |
|
569 | 569 | { |
570 | - while(key($result) == $record->get_identifier()) |
|
570 | + while (key($result) == $record->get_identifier()) |
|
571 | 571 | { |
572 | 572 | array_shift($result); |
573 | 573 | } |
574 | 574 | } |
575 | - if(count($result) != 1) |
|
575 | + if (count($result) != 1) |
|
576 | 576 | { |
577 | - $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') . |
|
577 | + $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : ''). |
|
578 | 578 | lang('Unable to link to %3 by custom field "%1": "%4". %2 matches.', |
579 | 579 | $custom_field, count($result), lang($app), $options['filter'][0] |
580 | 580 | ); |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
19 | 19 | * |
20 | 20 | */ |
21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin |
|
22 | +{ |
|
22 | 23 | |
23 | 24 | protected static $plugin_options = array( |
24 | 25 | 'fieldsep', // char |
@@ -121,7 +122,8 @@ discard block |
||
121 | 122 | * @param string $_charset |
122 | 123 | * @param definition $_definition |
123 | 124 | */ |
124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
125 | + public function import( $_stream, importexport_definition $_definition ) |
|
126 | + { |
|
125 | 127 | $import_csv = new importexport_import_csv( $_stream, array( |
126 | 128 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
127 | 129 | 'charset' => $_definition->plugin_options['charset'], |
@@ -143,9 +145,12 @@ discard block |
||
143 | 145 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
144 | 146 | |
145 | 147 | //check if file has a header lines |
146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
148 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
149 | + { |
|
147 | 150 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
151 | + } |
|
152 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
153 | + { |
|
149 | 154 | // First method is preferred |
150 | 155 | $import_csv->skip_records(1); |
151 | 156 | } |
@@ -167,15 +172,22 @@ discard block |
||
167 | 172 | |
168 | 173 | $this->init($_definition); |
169 | 174 | |
170 | - while ( $record = $import_csv->get_record() ) { |
|
175 | + while ( $record = $import_csv->get_record() ) |
|
176 | + { |
|
171 | 177 | $success = false; |
172 | 178 | |
173 | 179 | // don't import empty records |
174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
180 | + if( count( array_unique( $record ) ) < 2 ) |
|
181 | + { |
|
182 | + continue; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | |
177 | 186 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
187 | + if($warning) |
|
188 | + { |
|
189 | + $this->warnings[$import_csv->get_current_position()] = $warning; |
|
190 | + } |
|
179 | 191 | |
180 | 192 | $egw_record = new $record_class(); |
181 | 193 | $egw_record->set_record($record); |
@@ -185,7 +197,10 @@ discard block |
||
185 | 197 | { |
186 | 198 | $this->do_special_fields($egw_record, $import_csv); |
187 | 199 | } |
188 | - if($success) $count++; |
|
200 | + if($success) |
|
201 | + { |
|
202 | + $count++; |
|
203 | + } |
|
189 | 204 | |
190 | 205 | // Add some more time |
191 | 206 | if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
@@ -226,10 +241,13 @@ discard block |
||
226 | 241 | */ |
227 | 242 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
228 | 243 | { |
229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
244 | + if ( $this->definition->plugin_options['conditions'] ) |
|
245 | + { |
|
246 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
247 | + { |
|
231 | 248 | $result = false; |
232 | - switch ( $condition['type'] ) { |
|
249 | + switch ( $condition['type'] ) |
|
250 | + { |
|
233 | 251 | // exists |
234 | 252 | case 'exists' : |
235 | 253 | // Check for that record |
@@ -257,9 +275,14 @@ discard block |
||
257 | 275 | $action = $condition['false']; |
258 | 276 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
259 | 277 | } |
260 | - if ($action['stop']) break; |
|
278 | + if ($action['stop']) |
|
279 | + { |
|
280 | + break; |
|
281 | + } |
|
261 | 282 | } |
262 | - } else { |
|
283 | + } |
|
284 | + else |
|
285 | + { |
|
263 | 286 | // unconditional insert |
264 | 287 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
265 | 288 | } |
@@ -343,9 +366,14 @@ discard block |
||
343 | 366 | return; |
344 | 367 | } |
345 | 368 | |
346 | - foreach(self::$special_fields as $field => $desc) { |
|
347 | - if(!$record->$field) continue; |
|
348 | - if(strpos($field, 'link') === 0) { |
|
369 | + foreach(self::$special_fields as $field => $desc) |
|
370 | + { |
|
371 | + if(!$record->$field) |
|
372 | + { |
|
373 | + continue; |
|
374 | + } |
|
375 | + if(strpos($field, 'link') === 0) |
|
376 | + { |
|
349 | 377 | list($app, $app_id) = explode(':', $record->$field,2); |
350 | 378 | |
351 | 379 | list($link, $type) = explode('_',$field); |
@@ -364,7 +392,9 @@ discard block |
||
364 | 392 | shift($result); |
365 | 393 | } while($result && !$app_id); |
366 | 394 | } |
367 | - } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
|
395 | + } |
|
396 | + else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) |
|
397 | + { |
|
368 | 398 | $app = $field; |
369 | 399 | $app_id = $record->$field; |
370 | 400 | |
@@ -425,11 +455,16 @@ discard block |
||
425 | 455 | $fields = $wizard->get_import_fields(); |
426 | 456 | foreach($labels as $field => &$label) |
427 | 457 | { |
428 | - if($fields[$field]) $label = $fields[$field]; |
|
458 | + if($fields[$field]) |
|
459 | + { |
|
460 | + $label = $fields[$field]; |
|
461 | + } |
|
429 | 462 | } |
430 | - } catch (Exception $e) { |
|
463 | + } |
|
464 | + catch (Exception $e) { |
|
431 | 465 | Api\Translation::add_app($definition->application); |
432 | - foreach($labels as $field => &$label) { |
|
466 | + foreach($labels as $field => &$label) |
|
467 | + { |
|
433 | 468 | $label = lang($label); |
434 | 469 | } |
435 | 470 | } |
@@ -468,7 +503,8 @@ discard block |
||
468 | 503 | * @param string $org_name |
469 | 504 | * @return int|boolean Contact ID of first match, or false if none found |
470 | 505 | */ |
471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
506 | + public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) |
|
507 | + { |
|
472 | 508 | |
473 | 509 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
474 | 510 | static $contacts; |
@@ -478,28 +514,40 @@ discard block |
||
478 | 514 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
479 | 515 | } |
480 | 516 | $n_family = trim($n_family); |
481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
517 | + if(!is_null($n_given)) |
|
518 | + { |
|
519 | + $n_given = trim($n_given); |
|
520 | + } |
|
482 | 521 | if (!is_object($contacts)) |
483 | 522 | { |
484 | 523 | $contacts = new Api\Contacts(); |
485 | 524 | } |
486 | - if (!is_null($org_name)) // org_name given? |
|
525 | + if (!is_null($org_name)) |
|
526 | + { |
|
527 | + // org_name given? |
|
487 | 528 | { |
488 | 529 | $org_name = trim($org_name); |
530 | + } |
|
489 | 531 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
490 | 532 | if (!count($addrs)) |
491 | 533 | { |
492 | 534 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
493 | 535 | } |
494 | 536 | } |
495 | - if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
|
537 | + if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) |
|
538 | + { |
|
539 | + // first name given and no result so far |
|
496 | 540 | { |
497 | 541 | $addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given)); |
498 | 542 | } |
499 | - if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
|
543 | + } |
|
544 | + if (is_null($n_given) && is_null($org_name)) |
|
545 | + { |
|
546 | + // just one name given, check against fn (= full name) |
|
500 | 547 | { |
501 | 548 | $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
502 | 549 | } |
550 | + } |
|
503 | 551 | if (count($addrs)) |
504 | 552 | { |
505 | 553 | if(!$record || !$record->get_identifier()) |
@@ -551,13 +599,17 @@ discard block |
||
551 | 599 | } |
552 | 600 | |
553 | 601 | // Couldn't find field, give an error - something's wrong |
554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
602 | + if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) |
|
603 | + { |
|
555 | 604 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
556 | 605 | $custom_field, lang($app)); |
557 | 606 | return false; |
558 | 607 | } |
559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
560 | -error_log("Searching for $custom_field = $value"); |
|
608 | + if($custom_field[0] != '#') |
|
609 | + { |
|
610 | + $custom_field = '#' . $custom_field; |
|
611 | + } |
|
612 | + error_log("Searching for $custom_field = $value"); |
|
561 | 613 | // Search |
562 | 614 | if(Link::get_registry($app, 'query')) |
563 | 615 | { |
@@ -591,7 +643,8 @@ discard block |
||
591 | 643 | * |
592 | 644 | * @return string name |
593 | 645 | */ |
594 | - public static function get_name() { |
|
646 | + public static function get_name() |
|
647 | + { |
|
595 | 648 | return lang('Basic CSV import'); |
596 | 649 | } |
597 | 650 | |
@@ -600,7 +653,8 @@ discard block |
||
600 | 653 | * |
601 | 654 | * @return string descriprion |
602 | 655 | */ |
603 | - public static function get_description() { |
|
656 | + public static function get_description() |
|
657 | + { |
|
604 | 658 | return lang("Imports information from a CSV file. This is only a base class, and doesn't do anything on its own."); |
605 | 659 | } |
606 | 660 | |
@@ -609,7 +663,8 @@ discard block |
||
609 | 663 | * |
610 | 664 | * @return string suffix (comma seperated) |
611 | 665 | */ |
612 | - public static function get_filesuffix() { |
|
666 | + public static function get_filesuffix() |
|
667 | + { |
|
613 | 668 | return 'csv'; |
614 | 669 | } |
615 | 670 | |
@@ -625,7 +680,8 @@ discard block |
||
625 | 680 | * preserv => array, |
626 | 681 | * ) |
627 | 682 | */ |
628 | - public function get_options_etpl() { |
|
683 | + public function get_options_etpl() |
|
684 | + { |
|
629 | 685 | // lets do it! |
630 | 686 | } |
631 | 687 | |
@@ -634,7 +690,8 @@ discard block |
||
634 | 690 | * |
635 | 691 | * @return string etemplate name |
636 | 692 | */ |
637 | - public function get_selectors_etpl() { |
|
693 | + public function get_selectors_etpl() |
|
694 | + { |
|
638 | 695 | // lets do it! |
639 | 696 | } |
640 | 697 | |
@@ -646,7 +703,8 @@ discard block |
||
646 | 703 | * record_# => warning message |
647 | 704 | * ) |
648 | 705 | */ |
649 | - public function get_warnings() { |
|
706 | + public function get_warnings() |
|
707 | + { |
|
650 | 708 | return $this->warnings; |
651 | 709 | } |
652 | 710 | |
@@ -658,7 +716,8 @@ discard block |
||
658 | 716 | * record_# => error message |
659 | 717 | * ) |
660 | 718 | */ |
661 | - public function get_errors() { |
|
719 | + public function get_errors() |
|
720 | + { |
|
662 | 721 | return $this->errors; |
663 | 722 | } |
664 | 723 | |
@@ -670,7 +729,8 @@ discard block |
||
670 | 729 | * action => record count |
671 | 730 | * ) |
672 | 731 | */ |
673 | - public function get_results() { |
|
732 | + public function get_results() |
|
733 | + { |
|
674 | 734 | return $this->results; |
675 | 735 | } |
676 | 736 | } // end of iface_export_plugin |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
|
279 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$matches = array()) |
|
280 | 280 | { |
281 | 281 | } |
282 | 282 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | - protected function equal(importexport_iface_egw_record &$record, Array &$condition) |
|
291 | + protected function equal(importexport_iface_egw_record &$record, array &$condition) |
|
292 | 292 | { |
293 | 293 | $field = $condition['string']; |
294 | 294 | return $record->$field == $condition['op_2']; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - protected function less_than(importexport_iface_egw_record &$record, Array &$condition) |
|
306 | + protected function less_than(importexport_iface_egw_record &$record, array &$condition) |
|
307 | 307 | { |
308 | 308 | $field = $condition['string']; |
309 | 309 | return $record->$field < $condition['op_2']; |
@@ -176,7 +176,6 @@ |
||
176 | 176 | /** |
177 | 177 | * sets options |
178 | 178 | * |
179 | - * @param array $options |
|
180 | 179 | */ |
181 | 180 | private function set_options(array $_plugin_options) { |
182 | 181 | $this->definition['plugin_options'] = $_plugin_options; |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $_identifier |
67 | 67 | */ |
68 | - public function __construct( $_identifier='' ) { |
|
69 | - $this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe); |
|
68 | + public function __construct($_identifier = '') { |
|
69 | + $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_talbe); |
|
70 | 70 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
71 | 71 | $this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false; |
72 | 72 | // compability to string identifiers |
@@ -74,17 +74,17 @@ discard block |
||
74 | 74 | |
75 | 75 | if ((int)$_identifier != 0) { |
76 | 76 | $this->definition = $this->so_sql->read(array('definition_id' => $_identifier)); |
77 | - if ( empty( $this->definition ) ) { |
|
77 | + if (empty($this->definition)) { |
|
78 | 78 | throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!'); |
79 | 79 | } |
80 | - if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
80 | + if (!(importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
81 | 81 | throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!'); |
82 | 82 | } |
83 | 83 | try |
84 | 84 | { |
85 | - $options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] ); |
|
85 | + $options_data = importexport_arrayxml::xml2array($this->definition['plugin_options']); |
|
86 | 86 | $this->definition['plugin_options'] = $options_data['root']; |
87 | - if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
87 | + if ($this->definition['filter']) $filter = importexport_arrayxml::xml2array($this->definition['filter']); |
|
88 | 88 | $this->definition['filter'] = $filter['root']; |
89 | 89 | } |
90 | 90 | catch (Exception $e) |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * @param string $_name |
101 | 101 | * @return int |
102 | 102 | */ |
103 | - private function name2identifier( $_name ) { |
|
104 | - $identifiers = $this->so_sql->search(array('name' => $_name),true); |
|
103 | + private function name2identifier($_name) { |
|
104 | + $identifiers = $this->so_sql->search(array('name' => $_name), true); |
|
105 | 105 | if (isset($identifiers[1])) { |
106 | - throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier'); |
|
106 | + throw new Exception('Error: Definition: "'.$_name.'" is not unique! Can\'t convert to identifier'); |
|
107 | 107 | } |
108 | - if ( empty( $identifiers[0] ) ) { |
|
108 | + if (empty($identifiers[0])) { |
|
109 | 109 | // not a good idea, till we don't have different exceptions so far |
110 | 110 | // throw new Exception('Error: No such definition :"'.$_name.'"!'); |
111 | - $identifiers = array( array( 'definition_id' => 0 ) ); |
|
111 | + $identifiers = array(array('definition_id' => 0)); |
|
112 | 112 | } |
113 | 113 | return $identifiers[0]['definition_id']; |
114 | 114 | } |
115 | 115 | |
116 | 116 | public function __get($_attribute_name) { |
117 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
118 | - throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
|
117 | + if (!array_key_exists($_attribute_name, $this->attributes)) { |
|
118 | + throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion'); |
|
119 | 119 | } |
120 | 120 | switch ($_attribute_name) { |
121 | 121 | case 'allowed_users' : |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function __set($_attribute_name,$_data) { |
|
133 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
134 | - throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
|
132 | + public function __set($_attribute_name, $_data) { |
|
133 | + if (!array_key_exists($_attribute_name, $this->attributes)) { |
|
134 | + throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion'); |
|
135 | 135 | } |
136 | 136 | switch ($_attribute_name) { |
137 | 137 | case 'allowed_users' : |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | */ |
154 | 154 | private function get_allowed_users() { |
155 | - return explode(',',substr($this->definition['allowed_users'],1,-1)); |
|
155 | + return explode(',', substr($this->definition['allowed_users'], 1, -1)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param array $_allowed_users |
162 | 162 | */ |
163 | - private function set_allowed_users( $_allowed_users ) { |
|
164 | - $this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .','; |
|
163 | + private function set_allowed_users($_allowed_users) { |
|
164 | + $this->definition['allowed_users'] = ','.implode(',', (array)$_allowed_users).','; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - public function set_record( array $_record ) { |
|
234 | - $this->definition = array_intersect_key( $_record, $this->attributes ); |
|
233 | + public function set_record(array $_record) { |
|
234 | + $this->definition = array_intersect_key($_record, $this->attributes); |
|
235 | 235 | |
236 | 236 | // anything which is not an attribute is perhaps a plugin_option. |
237 | 237 | // If not, it gets whiped out on save time. |
238 | - foreach ( $_record as $attribute => $value) { |
|
239 | - if ( !array_key_exists( $attribute, $this->attributes ) ) { |
|
238 | + foreach ($_record as $attribute => $value) { |
|
239 | + if (!array_key_exists($attribute, $this->attributes)) { |
|
240 | 240 | $this->definition['plugin_options'][$attribute] = $value; |
241 | 241 | } |
242 | 242 | } |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | $this->plugin = $_record['plugin']; |
245 | 245 | |
246 | 246 | // convert plugin_options into internal representation |
247 | - $this->set_allowed_users( $this->definition['allowed_users'] ); |
|
248 | - $this->set_options( $this->definition['plugin_options'] ? $this->definition['plugin_options'] : array()); |
|
249 | - $this->set_filter( $this->definition['filter'] ? $this->definition['filter'] : array()); |
|
247 | + $this->set_allowed_users($this->definition['allowed_users']); |
|
248 | + $this->set_options($this->definition['plugin_options'] ? $this->definition['plugin_options'] : array()); |
|
249 | + $this->set_filter($this->definition['filter'] ? $this->definition['filter'] : array()); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @return string Full URL of an icon, or appname/icon_name |
267 | 267 | */ |
268 | 268 | public function get_icon() { |
269 | - return self::_appname . '/navbar'; |
|
269 | + return self::_appname.'/navbar'; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -274,16 +274,16 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return string identifier |
276 | 276 | */ |
277 | - public function save ( $_dst_identifier ) { |
|
278 | - if ( strlen($this->definition['name']) < 3 ) { |
|
277 | + public function save($_dst_identifier) { |
|
278 | + if (strlen($this->definition['name']) < 3) { |
|
279 | 279 | throw new Exception('Error: Can\'t save definition, no valid name given!'); |
280 | 280 | } |
281 | 281 | |
282 | 282 | $this->so_sql->data = $this->definition; |
283 | - $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] ); |
|
284 | - $this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] ); |
|
283 | + $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml($this->definition['plugin_options']); |
|
284 | + $this->so_sql->data['filter'] = importexport_arrayxml::array2xml($this->definition['filter']); |
|
285 | 285 | $this->so_sql->data['modified'] = time(); |
286 | - if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) { |
|
286 | + if ($this->so_sql->save(array('definition_id' => $_dst_identifier))) { |
|
287 | 287 | throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier()); |
288 | 288 | } |
289 | 289 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | * @param string $_dst_identifier |
297 | 297 | * @return string dst_identifier |
298 | 298 | */ |
299 | - public function copy ( $_dst_identifier ) { |
|
299 | + public function copy($_dst_identifier) { |
|
300 | 300 | $dst_object = clone $this; |
301 | 301 | try { |
302 | 302 | $dst_object->set_owner($this->user); |
303 | 303 | $dst_identifier = $dst_object->save($_dst_identifier); |
304 | 304 | } |
305 | - catch(exception $Exception) { |
|
305 | + catch (exception $Exception) { |
|
306 | 306 | unset($dst_object); |
307 | 307 | throw $Exception; |
308 | 308 | } |
@@ -317,16 +317,16 @@ discard block |
||
317 | 317 | * @param string $_dst_identifier |
318 | 318 | * @return string dst_identifier |
319 | 319 | */ |
320 | - public function move ( $_dst_identifier ) { |
|
320 | + public function move($_dst_identifier) { |
|
321 | 321 | if ($this->user != $this->get_owner() && !$this->is_admin) { |
322 | - throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier()); |
|
322 | + throw('Error: User '.$this->user.'does not have permissions to move definition '.$this->get_identifier()); |
|
323 | 323 | } |
324 | 324 | $old_object = clone $this; |
325 | 325 | try { |
326 | 326 | $dst_identifier = $this->save($_dst_identifier); |
327 | 327 | $old_object->delete(); |
328 | 328 | } |
329 | - catch(exception $Exception) { |
|
329 | + catch (exception $Exception) { |
|
330 | 330 | unset($old_object); |
331 | 331 | throw $Exception; |
332 | 332 | } |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @return void |
340 | 340 | * |
341 | 341 | */ |
342 | - public function delete () { |
|
343 | - if($this->user != $this->get_owner() && !$this->is_admin) { |
|
344 | - throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier()); |
|
342 | + public function delete() { |
|
343 | + if ($this->user != $this->get_owner() && !$this->is_admin) { |
|
344 | + throw('Error: User '.$this->user.'does not have permissions to delete definition '.$this->get_identifier()); |
|
345 | 345 | } |
346 | - if(!$this->so_sql->delete()) { |
|
346 | + if (!$this->so_sql->delete()) { |
|
347 | 347 | throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier()); |
348 | 348 | } |
349 | 349 | } |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * are in one assiozative array which is complely managed by {Im|Ex}port plugins |
21 | 21 | * @todo testing |
22 | 22 | */ |
23 | -class importexport_definition implements importexport_iface_egw_record { |
|
23 | +class importexport_definition implements importexport_iface_egw_record |
|
24 | +{ |
|
24 | 25 | |
25 | 26 | const _appname = 'importexport'; |
26 | 27 | const _defintion_talbe = 'egw_importexport_definitions'; |
@@ -65,26 +66,36 @@ discard block |
||
65 | 66 | * |
66 | 67 | * @param string $_identifier |
67 | 68 | */ |
68 | - public function __construct( $_identifier='' ) { |
|
69 | + public function __construct( $_identifier='' ) |
|
70 | + { |
|
69 | 71 | $this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe); |
70 | 72 | $this->user = $GLOBALS['egw_info']['user']['user_id']; |
71 | 73 | $this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false; |
72 | 74 | // compability to string identifiers |
73 | - if (!is_numeric($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier); |
|
75 | + if (!is_numeric($_identifier) && strlen($_identifier) > 3) |
|
76 | + { |
|
77 | + $_identifier = $this->name2identifier($_identifier); |
|
78 | + } |
|
74 | 79 | |
75 | - if ((int)$_identifier != 0) { |
|
80 | + if ((int)$_identifier != 0) |
|
81 | + { |
|
76 | 82 | $this->definition = $this->so_sql->read(array('definition_id' => $_identifier)); |
77 | - if ( empty( $this->definition ) ) { |
|
83 | + if ( empty( $this->definition ) ) |
|
84 | + { |
|
78 | 85 | throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!'); |
79 | 86 | } |
80 | - if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) { |
|
87 | + if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) |
|
88 | + { |
|
81 | 89 | throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!'); |
82 | 90 | } |
83 | 91 | try |
84 | 92 | { |
85 | 93 | $options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] ); |
86 | 94 | $this->definition['plugin_options'] = $options_data['root']; |
87 | - if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
95 | + if($this->definition['filter']) |
|
96 | + { |
|
97 | + $filter = importexport_arrayxml::xml2array( $this->definition['filter'] ); |
|
98 | + } |
|
88 | 99 | $this->definition['filter'] = $filter['root']; |
89 | 100 | } |
90 | 101 | catch (Exception $e) |
@@ -100,12 +111,15 @@ discard block |
||
100 | 111 | * @param string $_name |
101 | 112 | * @return int |
102 | 113 | */ |
103 | - private function name2identifier( $_name ) { |
|
114 | + private function name2identifier( $_name ) |
|
115 | + { |
|
104 | 116 | $identifiers = $this->so_sql->search(array('name' => $_name),true); |
105 | - if (isset($identifiers[1])) { |
|
117 | + if (isset($identifiers[1])) |
|
118 | + { |
|
106 | 119 | throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier'); |
107 | 120 | } |
108 | - if ( empty( $identifiers[0] ) ) { |
|
121 | + if ( empty( $identifiers[0] ) ) |
|
122 | + { |
|
109 | 123 | // not a good idea, till we don't have different exceptions so far |
110 | 124 | // throw new Exception('Error: No such definition :"'.$_name.'"!'); |
111 | 125 | $identifiers = array( array( 'definition_id' => 0 ) ); |
@@ -113,11 +127,14 @@ discard block |
||
113 | 127 | return $identifiers[0]['definition_id']; |
114 | 128 | } |
115 | 129 | |
116 | - public function __get($_attribute_name) { |
|
117 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
130 | + public function __get($_attribute_name) |
|
131 | + { |
|
132 | + if (!array_key_exists($_attribute_name,$this->attributes)) |
|
133 | + { |
|
118 | 134 | throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
119 | 135 | } |
120 | - switch ($_attribute_name) { |
|
136 | + switch ($_attribute_name) |
|
137 | + { |
|
121 | 138 | case 'allowed_users' : |
122 | 139 | return $this->get_allowed_users(); |
123 | 140 | case 'plugin_options' : |
@@ -129,11 +146,14 @@ discard block |
||
129 | 146 | } |
130 | 147 | } |
131 | 148 | |
132 | - public function __set($_attribute_name,$_data) { |
|
133 | - if (!array_key_exists($_attribute_name,$this->attributes)) { |
|
149 | + public function __set($_attribute_name,$_data) |
|
150 | + { |
|
151 | + if (!array_key_exists($_attribute_name,$this->attributes)) |
|
152 | + { |
|
134 | 153 | throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion'); |
135 | 154 | } |
136 | - switch ($_attribute_name) { |
|
155 | + switch ($_attribute_name) |
|
156 | + { |
|
137 | 157 | case 'allowed_users' : |
138 | 158 | return $this->set_allowed_users($_data); |
139 | 159 | case 'plugin_options' : |
@@ -151,7 +171,8 @@ discard block |
||
151 | 171 | * |
152 | 172 | * @return array |
153 | 173 | */ |
154 | - private function get_allowed_users() { |
|
174 | + private function get_allowed_users() |
|
175 | + { |
|
155 | 176 | return explode(',',substr($this->definition['allowed_users'],1,-1)); |
156 | 177 | } |
157 | 178 | |
@@ -160,7 +181,8 @@ discard block |
||
160 | 181 | * |
161 | 182 | * @param array $_allowed_users |
162 | 183 | */ |
163 | - private function set_allowed_users( $_allowed_users ) { |
|
184 | + private function set_allowed_users( $_allowed_users ) |
|
185 | + { |
|
164 | 186 | $this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .','; |
165 | 187 | } |
166 | 188 | |
@@ -169,7 +191,8 @@ discard block |
||
169 | 191 | * |
170 | 192 | * @return array |
171 | 193 | */ |
172 | - private function get_options() { |
|
194 | + private function get_options() |
|
195 | + { |
|
173 | 196 | return $this->definition['plugin_options']; |
174 | 197 | } |
175 | 198 | |
@@ -178,7 +201,8 @@ discard block |
||
178 | 201 | * |
179 | 202 | * @param array $options |
180 | 203 | */ |
181 | - private function set_options(array $_plugin_options) { |
|
204 | + private function set_options(array $_plugin_options) |
|
205 | + { |
|
182 | 206 | $this->definition['plugin_options'] = $_plugin_options; |
183 | 207 | } |
184 | 208 | |
@@ -187,7 +211,8 @@ discard block |
||
187 | 211 | * |
188 | 212 | * @return array |
189 | 213 | */ |
190 | - private function get_filter() { |
|
214 | + private function get_filter() |
|
215 | + { |
|
191 | 216 | return $this->definition['filter']; |
192 | 217 | } |
193 | 218 | |
@@ -196,7 +221,8 @@ discard block |
||
196 | 221 | * |
197 | 222 | * @param filter array of field => settings |
198 | 223 | */ |
199 | - private function set_filter(Array $filter) { |
|
224 | + private function set_filter(Array $filter) |
|
225 | + { |
|
200 | 226 | $this->definition['filter'] = $filter; |
201 | 227 | } |
202 | 228 | |
@@ -208,7 +234,8 @@ discard block |
||
208 | 234 | * |
209 | 235 | * @return array complete record as associative array |
210 | 236 | */ |
211 | - public function get_record_array() { |
|
237 | + public function get_record_array() |
|
238 | + { |
|
212 | 239 | $definition = $this->definition; |
213 | 240 | $definition['allowed_users'] = $this->get_allowed_users(); |
214 | 241 | $definition['plugin_options'] = $this->get_options(); |
@@ -221,7 +248,8 @@ discard block |
||
221 | 248 | * |
222 | 249 | *@return string tiltle |
223 | 250 | */ |
224 | - public function get_title() { |
|
251 | + public function get_title() |
|
252 | + { |
|
225 | 253 | return $this->definition['name']; |
226 | 254 | } |
227 | 255 | |
@@ -230,13 +258,16 @@ discard block |
||
230 | 258 | * |
231 | 259 | * @return void |
232 | 260 | */ |
233 | - public function set_record( array $_record ) { |
|
261 | + public function set_record( array $_record ) |
|
262 | + { |
|
234 | 263 | $this->definition = array_intersect_key( $_record, $this->attributes ); |
235 | 264 | |
236 | 265 | // anything which is not an attribute is perhaps a plugin_option. |
237 | 266 | // If not, it gets whiped out on save time. |
238 | - foreach ( $_record as $attribute => $value) { |
|
239 | - if ( !array_key_exists( $attribute, $this->attributes ) ) { |
|
267 | + foreach ( $_record as $attribute => $value) |
|
268 | + { |
|
269 | + if ( !array_key_exists( $attribute, $this->attributes ) ) |
|
270 | + { |
|
240 | 271 | $this->definition['plugin_options'][$attribute] = $value; |
241 | 272 | } |
242 | 273 | } |
@@ -254,7 +285,8 @@ discard block |
||
254 | 285 | * |
255 | 286 | * @return int identifier of this record |
256 | 287 | */ |
257 | - public function get_identifier() { |
|
288 | + public function get_identifier() |
|
289 | + { |
|
258 | 290 | return $this->definition['definition_id']; |
259 | 291 | } |
260 | 292 | |
@@ -265,7 +297,8 @@ discard block |
||
265 | 297 | * |
266 | 298 | * @return string Full URL of an icon, or appname/icon_name |
267 | 299 | */ |
268 | - public function get_icon() { |
|
300 | + public function get_icon() |
|
301 | + { |
|
269 | 302 | return self::_appname . '/navbar'; |
270 | 303 | } |
271 | 304 | |
@@ -274,8 +307,10 @@ discard block |
||
274 | 307 | * |
275 | 308 | * @return string identifier |
276 | 309 | */ |
277 | - public function save ( $_dst_identifier ) { |
|
278 | - if ( strlen($this->definition['name']) < 3 ) { |
|
310 | + public function save ( $_dst_identifier ) |
|
311 | + { |
|
312 | + if ( strlen($this->definition['name']) < 3 ) |
|
313 | + { |
|
279 | 314 | throw new Exception('Error: Can\'t save definition, no valid name given!'); |
280 | 315 | } |
281 | 316 | |
@@ -283,7 +318,8 @@ discard block |
||
283 | 318 | $this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] ); |
284 | 319 | $this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] ); |
285 | 320 | $this->so_sql->data['modified'] = time(); |
286 | - if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) { |
|
321 | + if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) |
|
322 | + { |
|
287 | 323 | throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier()); |
288 | 324 | } |
289 | 325 | |
@@ -296,7 +332,8 @@ discard block |
||
296 | 332 | * @param string $_dst_identifier |
297 | 333 | * @return string dst_identifier |
298 | 334 | */ |
299 | - public function copy ( $_dst_identifier ) { |
|
335 | + public function copy ( $_dst_identifier ) |
|
336 | + { |
|
300 | 337 | $dst_object = clone $this; |
301 | 338 | try { |
302 | 339 | $dst_object->set_owner($this->user); |
@@ -317,8 +354,10 @@ discard block |
||
317 | 354 | * @param string $_dst_identifier |
318 | 355 | * @return string dst_identifier |
319 | 356 | */ |
320 | - public function move ( $_dst_identifier ) { |
|
321 | - if ($this->user != $this->get_owner() && !$this->is_admin) { |
|
357 | + public function move ( $_dst_identifier ) |
|
358 | + { |
|
359 | + if ($this->user != $this->get_owner() && !$this->is_admin) |
|
360 | + { |
|
322 | 361 | throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier()); |
323 | 362 | } |
324 | 363 | $old_object = clone $this; |
@@ -339,11 +378,14 @@ discard block |
||
339 | 378 | * @return void |
340 | 379 | * |
341 | 380 | */ |
342 | - public function delete () { |
|
343 | - if($this->user != $this->get_owner() && !$this->is_admin) { |
|
381 | + public function delete () |
|
382 | + { |
|
383 | + if($this->user != $this->get_owner() && !$this->is_admin) |
|
384 | + { |
|
344 | 385 | throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier()); |
345 | 386 | } |
346 | - if(!$this->so_sql->delete()) { |
|
387 | + if(!$this->so_sql->delete()) |
|
388 | + { |
|
347 | 389 | throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier()); |
348 | 390 | } |
349 | 391 | } |
@@ -352,7 +394,8 @@ discard block |
||
352 | 394 | * destructor |
353 | 395 | * |
354 | 396 | */ |
355 | - public function __destruct() { |
|
397 | + public function __destruct() |
|
398 | + { |
|
356 | 399 | unset($this->so_sql); |
357 | 400 | } |
358 | 401 |
@@ -196,7 +196,7 @@ |
||
196 | 196 | * |
197 | 197 | * @param filter array of field => settings |
198 | 198 | */ |
199 | - private function set_filter(Array $filter) { |
|
199 | + private function set_filter(array $filter) { |
|
200 | 200 | $this->definition['filter'] = $filter; |
201 | 201 | } |
202 | 202 |
@@ -139,7 +139,6 @@ discard block |
||
139 | 139 | /** |
140 | 140 | * Save a definition |
141 | 141 | * |
142 | - * @param definition $definition |
|
143 | 142 | */ |
144 | 143 | public function save(Array $data) { |
145 | 144 | $definition = new importexport_definition(); |
@@ -209,7 +208,7 @@ discard block |
||
209 | 208 | /** |
210 | 209 | * imports definitions from file |
211 | 210 | * |
212 | - * @param string $import_file |
|
211 | + * @param string $_import_file |
|
213 | 212 | * @throws Exeption |
214 | 213 | * @return void |
215 | 214 | */ |
@@ -268,7 +267,6 @@ discard block |
||
268 | 267 | * It is not possible to handle some plugin options automatically, because they |
269 | 268 | * just don't have equivalents. (eg: What to do with unknown categories) |
270 | 269 | * |
271 | - * @param importexport_definition $definition Import definition |
|
272 | 270 | * |
273 | 271 | * @return importexport_definition Export definition |
274 | 272 | */ |
@@ -137,10 +137,10 @@ |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Save a definition |
|
141 | - * |
|
142 | - * @param definition $definition |
|
143 | - */ |
|
140 | + * Save a definition |
|
141 | + * |
|
142 | + * @param definition $definition |
|
143 | + */ |
|
144 | 144 | public function save(Array $data) { |
145 | 145 | $definition = new importexport_definition(); |
146 | 146 | $definition->set_record($data); |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | private $definitions; |
33 | 33 | |
34 | - public function __construct($_query=false, $ignore_acl = false) |
|
34 | + public function __construct($_query = false, $ignore_acl = false) |
|
35 | 35 | { |
36 | - $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table ); |
|
36 | + $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table); |
|
37 | 37 | if ($_query) { |
38 | 38 | $definitions = $this->so_sql->search($_query, false); |
39 | 39 | foreach ((array)$definitions as $definition) { |
40 | - if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
40 | + if (self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | public function get_rows(&$query, &$rows, &$readonlys) |
46 | 46 | { |
47 | 47 | // Filter only definitions user is allowed to use |
48 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
48 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
49 | 49 | $this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true); |
50 | 50 | $this_membership[] = $GLOBALS['egw_info']['user']['account_id']; |
51 | 51 | $sql .= ' ('; |
52 | 52 | $read = array(); |
53 | - foreach($this_membership as $id) |
|
53 | + foreach ($this_membership as $id) |
|
54 | 54 | { |
55 | 55 | $read[] = 'allowed_users '. |
56 | 56 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '. |
57 | - $GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%'); |
|
57 | + $GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%'); |
|
58 | 58 | } |
59 | 59 | $sql .= implode(' OR ', $read); |
60 | 60 | $sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id']; |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | // Handle allowed filter |
65 | - if($query['col_filter']['allowed_users']) |
|
65 | + if ($query['col_filter']['allowed_users']) |
|
66 | 66 | { |
67 | 67 | $allowed = array(); |
68 | - foreach((array)$query['col_filter']['allowed_users'] as $id) |
|
68 | + foreach ((array)$query['col_filter']['allowed_users'] as $id) |
|
69 | 69 | { |
70 | 70 | $allowed[] = 'allowed_users '. |
71 | 71 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '. |
72 | - $GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%'); |
|
72 | + $GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%'); |
|
73 | 73 | } |
74 | - if($allowed) |
|
74 | + if ($allowed) |
|
75 | 75 | { |
76 | 76 | unset($query['col_filter']['allowed_users']); |
77 | - $query['col_filter'][] = '('.implode(' OR ', $allowed) . ')'; |
|
77 | + $query['col_filter'][] = '('.implode(' OR ', $allowed).')'; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | $total = $this->so_sql->get_rows($query, $rows, $readonlys); |
82 | 82 | $ro_count = 0; |
83 | - foreach($rows as &$row) { |
|
83 | + foreach ($rows as &$row) { |
|
84 | 84 | // Strip off leading + trailing , |
85 | - $row['allowed_users'] = substr($row['allowed_users'],1,-1); |
|
85 | + $row['allowed_users'] = substr($row['allowed_users'], 1, -1); |
|
86 | 86 | |
87 | 87 | $readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] = |
88 | 88 | ($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) && |
89 | 89 | !$GLOBALS['egw_info']['user']['apps']['admin']; |
90 | - if($readonlys["edit[{$row['definition_id']}]"]) |
|
90 | + if ($readonlys["edit[{$row['definition_id']}]"]) |
|
91 | 91 | { |
92 | 92 | $row['class'] .= 'rowNoEdit rowNoDelete'; |
93 | 93 | $ro_count++; |
94 | 94 | } |
95 | - $row['class'] .= ' ' . $row['type']; |
|
95 | + $row['class'] .= ' '.$row['type']; |
|
96 | 96 | } |
97 | 97 | $readonlys['delete_selected'] = $ro_count == count($rows); |
98 | 98 | return $total; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | return $this->definitions; |
108 | 108 | } |
109 | 109 | public function read($definition_id) { |
110 | - if(is_numeric($definition_id)) { |
|
110 | + if (is_numeric($definition_id)) { |
|
111 | 111 | $this->so_sql->read($definition_id); |
112 | 112 | $definition = new importexport_definition($this->so_sql->data['name']); |
113 | 113 | } else { |
114 | - $definition = new importexport_definition( $definition_id['name'] ); |
|
114 | + $definition = new importexport_definition($definition_id['name']); |
|
115 | 115 | } |
116 | 116 | return $definition->get_record_array(); |
117 | 117 | } |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | foreach ($keys as $index => $key) { |
125 | 125 | // Check for ownership |
126 | 126 | $definition = $this->read($key); |
127 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
127 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
128 | 128 | // clear private cache |
129 | - unset($this->definitions[array_search($key,$this->definitions)]); |
|
129 | + unset($this->definitions[array_search($key, $this->definitions)]); |
|
130 | 130 | } else { |
131 | 131 | unset($keys[$index]); |
132 | 132 | } |
133 | 133 | } |
134 | - if(count($keys) > 0) { |
|
134 | + if (count($keys) > 0) { |
|
135 | 135 | $this->so_sql->delete(array('definition_id' => $keys)); |
136 | 136 | } |
137 | 137 | } |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | * @return bool |
155 | 155 | */ |
156 | 156 | static public function is_permitted($_definition) { |
157 | - $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']); |
|
157 | + $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',', $_definition['allowed_users']); |
|
158 | 158 | $this_user_id = $GLOBALS['egw_info']['user']['account_id']; |
159 | 159 | $this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true); |
160 | 160 | $this_membership[] = $this_user_id; |
161 | 161 | $this_membership[] = 'all'; |
162 | - $alluser = array_intersect($allowed_user,$this_membership); |
|
162 | + $alluser = array_intersect($allowed_user, $this_membership); |
|
163 | 163 | return ($this_user_id == $_definition['owner'] || count($alluser) > 0); |
164 | 164 | } |
165 | 165 | |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | |
179 | 179 | $export_data['definitions'] = array(); |
180 | 180 | foreach ($keys as $definition_id) { |
181 | - $definition = new importexport_definition( $definition_id ); |
|
181 | + $definition = new importexport_definition($definition_id); |
|
182 | 182 | $export_data['definitions'][$definition->name] = $definition->get_record_array(); |
183 | 183 | $export_data['definitions'][$definition->name]['allowed_users'] = |
184 | 184 | importexport_helper_functions::account_id2name( |
185 | 185 | $export_data['definitions'][$definition->name]['allowed_users'] |
186 | 186 | ); |
187 | - if($export_date['definitions'][$definition->name]['owner']) { |
|
187 | + if ($export_date['definitions'][$definition->name]['owner']) { |
|
188 | 188 | $export_data['definitions'][$definition->name]['owner'] = |
189 | 189 | importexport_helper_functions::account_id2name( |
190 | 190 | $export_data['definitions'][$definition->name]['owner'] |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | unset($export_data['definitions'][$definition->name]['definition_id']); |
196 | 196 | unset($export_data['definitions'][$definition->name]['description']); |
197 | 197 | unset($export_data['definitions'][$definition->name]['user_timezone_read']); |
198 | - if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
198 | + if (is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
199 | 199 | unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']); |
200 | 200 | } |
201 | 201 | unset($definition); |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | * @throws Exeption |
214 | 214 | * @return void |
215 | 215 | */ |
216 | - public static function import( $_import_file ) |
|
216 | + public static function import($_import_file) |
|
217 | 217 | { |
218 | - if ( !is_file( $_import_file ) ) { |
|
219 | - throw new Exception("'$_import_file' does not exist or is not readable" ); |
|
218 | + if (!is_file($_import_file)) { |
|
219 | + throw new Exception("'$_import_file' does not exist or is not readable"); |
|
220 | 220 | } |
221 | 221 | |
222 | - $data = importexport_arrayxml::xml2array( file_get_contents( $_import_file ) ); |
|
222 | + $data = importexport_arrayxml::xml2array(file_get_contents($_import_file)); |
|
223 | 223 | |
224 | 224 | $metainfo = $data['importExportDefinitions']['metainfo']; |
225 | 225 | $definitions = $data['importExportDefinitions']['definitions']; |
226 | - unset ( $data ); |
|
226 | + unset ($data); |
|
227 | 227 | |
228 | 228 | // convert charset into internal used charset |
229 | 229 | $definitions = Api\Translation::convert( |
@@ -233,26 +233,26 @@ discard block |
||
233 | 233 | ); |
234 | 234 | |
235 | 235 | // Avoid warning if no definitions found |
236 | - if(!is_array($definitions)) return lang('None found'); |
|
236 | + if (!is_array($definitions)) return lang('None found'); |
|
237 | 237 | |
238 | 238 | // save definition(s) into internal table |
239 | - foreach ( $definitions as $name => $definition_data ) |
|
239 | + foreach ($definitions as $name => $definition_data) |
|
240 | 240 | { |
241 | 241 | // convert allowed_user |
242 | - $definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] ); |
|
243 | - if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
242 | + $definition_data['allowed_users'] = importexport_helper_functions::account_name2id($definition_data['allowed_users']); |
|
243 | + if ($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
244 | 244 | |
245 | - $definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] ); |
|
245 | + $definition_data['owner'] = importexport_helper_functions::account_name2id($definition_data['owner']); |
|
246 | 246 | |
247 | - $definition = new importexport_definition( $definition_data['name'] ); |
|
247 | + $definition = new importexport_definition($definition_data['name']); |
|
248 | 248 | |
249 | 249 | // Only update if the imported is newer |
250 | - if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0) |
|
250 | + if (strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0) |
|
251 | 251 | { |
252 | 252 | $definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL; |
253 | 253 | |
254 | - $definition->set_record( $definition_data ); |
|
255 | - $definition->save( $definition_id ); |
|
254 | + $definition->set_record($definition_data); |
|
255 | + $definition->save($definition_id); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | return $definitions; |
@@ -275,28 +275,28 @@ discard block |
||
275 | 275 | public static function export_from_import(importexport_definition $import) |
276 | 276 | { |
277 | 277 | // Only operates on import definitions |
278 | - if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
278 | + if ($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
279 | 279 | |
280 | 280 | // Find export plugin |
281 | - $plugin = str_replace('import', 'export',$import->plugin); |
|
281 | + $plugin = str_replace('import', 'export', $import->plugin); |
|
282 | 282 | $plugin_list = importexport_helper_functions::get_plugins($import->application, 'export'); |
283 | - foreach($plugin_list as $appname => $type) |
|
283 | + foreach ($plugin_list as $appname => $type) |
|
284 | 284 | { |
285 | 285 | $plugins = $type['export']; |
286 | - foreach($plugins as $name => $label) |
|
286 | + foreach ($plugins as $name => $label) |
|
287 | 287 | { |
288 | - if($plugin == $name) break; |
|
288 | + if ($plugin == $name) break; |
|
289 | 289 | } |
290 | - if($plugin !== $name) $plugin = $name; |
|
290 | + if ($plugin !== $name) $plugin = $name; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $export = new importexport_definition(); |
294 | 294 | |
295 | 295 | // Common settings |
296 | - $export->name = str_replace('import', 'export',$import->name); |
|
297 | - if($export->name == $import->name) $export->name = $export->name . '-export'; |
|
296 | + $export->name = str_replace('import', 'export', $import->name); |
|
297 | + if ($export->name == $import->name) $export->name = $export->name.'-export'; |
|
298 | 298 | $test = new importexport_definition($export->name); |
299 | - if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
299 | + if ($test->name) $export->name = $export->name.'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
300 | 300 | |
301 | 301 | $export->application = $import->application; |
302 | 302 | $export->plugin = $plugin; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | ); |
313 | 313 | |
314 | 314 | // Mapping |
315 | - foreach($i_options['field_mapping'] as $col_num => $field) |
|
315 | + foreach ($i_options['field_mapping'] as $col_num => $field) |
|
316 | 316 | { |
317 | 317 | // Try to use heading from import file, if possible |
318 | 318 | $e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field; |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @todo make this class an egw_record_pool! |
18 | 18 | */ |
19 | -class importexport_definitions_bo { |
|
19 | +class importexport_definitions_bo |
|
20 | +{ |
|
20 | 21 | |
21 | 22 | const _appname = 'importexport'; |
22 | 23 | const _defintion_table = 'egw_importexport_definitions'; |
@@ -34,10 +35,15 @@ discard block |
||
34 | 35 | public function __construct($_query=false, $ignore_acl = false) |
35 | 36 | { |
36 | 37 | $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table ); |
37 | - if ($_query) { |
|
38 | + if ($_query) |
|
39 | + { |
|
38 | 40 | $definitions = $this->so_sql->search($_query, false); |
39 | - foreach ((array)$definitions as $definition) { |
|
40 | - if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
41 | + foreach ((array)$definitions as $definition) |
|
42 | + { |
|
43 | + if(self::is_permitted($definition) || $ignore_acl) |
|
44 | + { |
|
45 | + $this->definitions[] = $definition['definition_id']; |
|
46 | + } |
|
41 | 47 | } |
42 | 48 | } |
43 | 49 | } |
@@ -45,7 +51,8 @@ discard block |
||
45 | 51 | public function get_rows(&$query, &$rows, &$readonlys) |
46 | 52 | { |
47 | 53 | // Filter only definitions user is allowed to use |
48 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
54 | + if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
55 | + { |
|
49 | 56 | $this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true); |
50 | 57 | $this_membership[] = $GLOBALS['egw_info']['user']['account_id']; |
51 | 58 | $sql .= ' ('; |
@@ -80,7 +87,8 @@ discard block |
||
80 | 87 | |
81 | 88 | $total = $this->so_sql->get_rows($query, $rows, $readonlys); |
82 | 89 | $ro_count = 0; |
83 | - foreach($rows as &$row) { |
|
90 | + foreach($rows as &$row) |
|
91 | + { |
|
84 | 92 | // Strip off leading + trailing , |
85 | 93 | $row['allowed_users'] = substr($row['allowed_users'],1,-1); |
86 | 94 | |
@@ -103,14 +111,19 @@ discard block |
||
103 | 111 | * |
104 | 112 | * @return array |
105 | 113 | */ |
106 | - public function get_definitions() { |
|
114 | + public function get_definitions() |
|
115 | + { |
|
107 | 116 | return $this->definitions; |
108 | 117 | } |
109 | - public function read($definition_id) { |
|
110 | - if(is_numeric($definition_id)) { |
|
118 | + public function read($definition_id) |
|
119 | + { |
|
120 | + if(is_numeric($definition_id)) |
|
121 | + { |
|
111 | 122 | $this->so_sql->read($definition_id); |
112 | 123 | $definition = new importexport_definition($this->so_sql->data['name']); |
113 | - } else { |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
114 | 127 | $definition = new importexport_definition( $definition_id['name'] ); |
115 | 128 | } |
116 | 129 | return $definition->get_record_array(); |
@@ -120,18 +133,24 @@ discard block |
||
120 | 133 | * |
121 | 134 | * @param array $keys |
122 | 135 | */ |
123 | - public function delete($keys) { |
|
124 | - foreach ($keys as $index => $key) { |
|
136 | + public function delete($keys) |
|
137 | + { |
|
138 | + foreach ($keys as $index => $key) |
|
139 | + { |
|
125 | 140 | // Check for ownership |
126 | 141 | $definition = $this->read($key); |
127 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
142 | + if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
143 | + { |
|
128 | 144 | // clear private cache |
129 | 145 | unset($this->definitions[array_search($key,$this->definitions)]); |
130 | - } else { |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
131 | 149 | unset($keys[$index]); |
132 | 150 | } |
133 | 151 | } |
134 | - if(count($keys) > 0) { |
|
152 | + if(count($keys) > 0) |
|
153 | + { |
|
135 | 154 | $this->so_sql->delete(array('definition_id' => $keys)); |
136 | 155 | } |
137 | 156 | } |
@@ -141,7 +160,8 @@ discard block |
||
141 | 160 | * |
142 | 161 | * @param definition $definition |
143 | 162 | */ |
144 | - public function save(Array $data) { |
|
163 | + public function save(Array $data) |
|
164 | + { |
|
145 | 165 | $definition = new importexport_definition(); |
146 | 166 | $definition->set_record($data); |
147 | 167 | $definition->save($data['definition_id']); |
@@ -153,7 +173,8 @@ discard block |
||
153 | 173 | * @param array $_definition |
154 | 174 | * @return bool |
155 | 175 | */ |
156 | - static public function is_permitted($_definition) { |
|
176 | + static public function is_permitted($_definition) |
|
177 | + { |
|
157 | 178 | $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']); |
158 | 179 | $this_user_id = $GLOBALS['egw_info']['user']['account_id']; |
159 | 180 | $this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true); |
@@ -177,25 +198,30 @@ discard block |
||
177 | 198 | )); |
178 | 199 | |
179 | 200 | $export_data['definitions'] = array(); |
180 | - foreach ($keys as $definition_id) { |
|
201 | + foreach ($keys as $definition_id) |
|
202 | + { |
|
181 | 203 | $definition = new importexport_definition( $definition_id ); |
182 | 204 | $export_data['definitions'][$definition->name] = $definition->get_record_array(); |
183 | 205 | $export_data['definitions'][$definition->name]['allowed_users'] = |
184 | 206 | importexport_helper_functions::account_id2name( |
185 | 207 | $export_data['definitions'][$definition->name]['allowed_users'] |
186 | 208 | ); |
187 | - if($export_date['definitions'][$definition->name]['owner']) { |
|
209 | + if($export_date['definitions'][$definition->name]['owner']) |
|
210 | + { |
|
188 | 211 | $export_data['definitions'][$definition->name]['owner'] = |
189 | 212 | importexport_helper_functions::account_id2name( |
190 | 213 | $export_data['definitions'][$definition->name]['owner'] |
191 | 214 | ); |
192 | - } else { |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
193 | 218 | unset($export_data['definitions'][$definition->name]['owner']); |
194 | 219 | } |
195 | 220 | unset($export_data['definitions'][$definition->name]['definition_id']); |
196 | 221 | unset($export_data['definitions'][$definition->name]['description']); |
197 | 222 | unset($export_data['definitions'][$definition->name]['user_timezone_read']); |
198 | - if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
223 | + if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) |
|
224 | + { |
|
199 | 225 | unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']); |
200 | 226 | } |
201 | 227 | unset($definition); |
@@ -215,7 +241,8 @@ discard block |
||
215 | 241 | */ |
216 | 242 | public static function import( $_import_file ) |
217 | 243 | { |
218 | - if ( !is_file( $_import_file ) ) { |
|
244 | + if ( !is_file( $_import_file ) ) |
|
245 | + { |
|
219 | 246 | throw new Exception("'$_import_file' does not exist or is not readable" ); |
220 | 247 | } |
221 | 248 | |
@@ -233,14 +260,20 @@ discard block |
||
233 | 260 | ); |
234 | 261 | |
235 | 262 | // Avoid warning if no definitions found |
236 | - if(!is_array($definitions)) return lang('None found'); |
|
263 | + if(!is_array($definitions)) |
|
264 | + { |
|
265 | + return lang('None found'); |
|
266 | + } |
|
237 | 267 | |
238 | 268 | // save definition(s) into internal table |
239 | 269 | foreach ( $definitions as $name => $definition_data ) |
240 | 270 | { |
241 | 271 | // convert allowed_user |
242 | 272 | $definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] ); |
243 | - if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
273 | + if($definition_data['all_users'] && !$definition_data['allowed_users']) |
|
274 | + { |
|
275 | + $definition_data['allowed_users'] = 'all'; |
|
276 | + } |
|
244 | 277 | |
245 | 278 | $definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] ); |
246 | 279 | |
@@ -275,7 +308,10 @@ discard block |
||
275 | 308 | public static function export_from_import(importexport_definition $import) |
276 | 309 | { |
277 | 310 | // Only operates on import definitions |
278 | - if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
311 | + if($import->type != 'import') |
|
312 | + { |
|
313 | + throw new Api\Exception\WrongParameter('Only import definitions'); |
|
314 | + } |
|
279 | 315 | |
280 | 316 | // Find export plugin |
281 | 317 | $plugin = str_replace('import', 'export',$import->plugin); |
@@ -285,18 +321,30 @@ discard block |
||
285 | 321 | $plugins = $type['export']; |
286 | 322 | foreach($plugins as $name => $label) |
287 | 323 | { |
288 | - if($plugin == $name) break; |
|
324 | + if($plugin == $name) |
|
325 | + { |
|
326 | + break; |
|
327 | + } |
|
328 | + } |
|
329 | + if($plugin !== $name) |
|
330 | + { |
|
331 | + $plugin = $name; |
|
289 | 332 | } |
290 | - if($plugin !== $name) $plugin = $name; |
|
291 | 333 | } |
292 | 334 | |
293 | 335 | $export = new importexport_definition(); |
294 | 336 | |
295 | 337 | // Common settings |
296 | 338 | $export->name = str_replace('import', 'export',$import->name); |
297 | - if($export->name == $import->name) $export->name = $export->name . '-export'; |
|
339 | + if($export->name == $import->name) |
|
340 | + { |
|
341 | + $export->name = $export->name . '-export'; |
|
342 | + } |
|
298 | 343 | $test = new importexport_definition($export->name); |
299 | - if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
344 | + if($test->name) |
|
345 | + { |
|
346 | + $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
347 | + } |
|
300 | 348 | |
301 | 349 | $export->application = $import->application; |
302 | 350 | $export->plugin = $plugin; |
@@ -141,7 +141,7 @@ |
||
141 | 141 | * |
142 | 142 | * @param definition $definition |
143 | 143 | */ |
144 | - public function save(Array $data) { |
|
144 | + public function save(array $data) { |
|
145 | 145 | $definition = new importexport_definition(); |
146 | 146 | $definition->set_record($data); |
147 | 147 | $definition->save($data['definition_id']); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * List defined {im|ex}ports |
84 | 84 | * |
85 | - * @param array $content=null |
|
85 | + * @param array $content |
|
86 | 86 | */ |
87 | 87 | function index($content = null,$msg='') |
88 | 88 | { |
@@ -309,8 +309,9 @@ discard block |
||
309 | 309 | * @param int &$success number of succeded actions |
310 | 310 | * @param int &$failed number of failed actions (not enought permissions) |
311 | 311 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 entries 'deleted' |
312 | - * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
313 | - * @return boolean true if all actions succeded, false otherwise |
|
312 | + * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
313 | + * @param string $msg |
|
314 | + * @return null|boolean true if all actions succeded, false otherwise |
|
314 | 315 | */ |
315 | 316 | function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
316 | 317 | { |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | function __construct() |
63 | 63 | { |
64 | 64 | // we cant deal with notice and warnings, as we are on ajax! |
65 | - error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); |
|
65 | + error_reporting(E_ALL&~E_NOTICE&~E_WARNING); |
|
66 | 66 | Api\Translation::add_app(self::_appname); |
67 | 67 | $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; |
68 | 68 | |
69 | 69 | $this->etpl = new Etemplate(); |
70 | - $this->clock = Api\Html::image(self::_appname,'clock'); |
|
70 | + $this->clock = Api\Html::image(self::_appname, 'clock'); |
|
71 | 71 | $this->steps = array( |
72 | 72 | 'wizard_step10' => lang('Choose an application'), |
73 | 73 | 'wizard_step20' => lang('Choose a plugin'), |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param array $content=null |
86 | 86 | */ |
87 | - function index($content = null,$msg='') |
|
87 | + function index($content = null, $msg = '') |
|
88 | 88 | { |
89 | 89 | $filter = array('name' => '*'); |
90 | 90 | |
91 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
91 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
92 | 92 | // Any public definition |
93 | - $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
|
93 | + $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = '.$GLOBALS['egw_info']['user']['account_id'].')'; |
|
94 | 94 | } else { |
95 | 95 | // Filter private definitions |
96 | 96 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
97 | 97 | $config = Api\Config::read('phpgwapi'); |
98 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
98 | + if ($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
99 | 99 | $filter['type'] = 'import'; |
100 | 100 | } |
101 | 101 | } |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | if (isset($content['nm']['rows']['delete'])) |
107 | 107 | { |
108 | 108 | $content['nm']['action'] = 'delete'; |
109 | - $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'],'pressed'); |
|
109 | + $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'], 'pressed'); |
|
110 | 110 | } |
111 | - elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
|
111 | + elseif (($button = array_search('pressed', $content['nm']['rows'])) !== false) |
|
112 | 112 | { |
113 | 113 | $selected = $content['nm']['rows']['selected']; |
114 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
114 | + if (count($selected) < 1 || !is_array($selected)) exit(); |
|
115 | 115 | switch ($button) |
116 | 116 | { |
117 | 117 | case 'delete_selected' : |
@@ -133,54 +133,54 @@ discard block |
||
133 | 133 | else |
134 | 134 | { |
135 | 135 | // Action has an additional parameter |
136 | - if(in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
136 | + if (in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
137 | 137 | { |
138 | 138 | $action = $content['nm']['action']; |
139 | - if($content['nm']['action'] == 'allowed') |
|
139 | + if ($content['nm']['action'] == 'allowed') |
|
140 | 140 | { |
141 | 141 | $content['allowed'] = $content['allowed_popup']['allowed_private'] == 'true' ? null : ( |
142 | - $content['allowed_popup']['all_users']=='true' ? 'all' : implode(',',$content['allowed_popup']['allowed']) |
|
142 | + $content['allowed_popup']['all_users'] == 'true' ? 'all' : implode(',', $content['allowed_popup']['allowed']) |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | 147 | $content['owner'] = $content['owner_popup']['owner']; |
148 | 148 | } |
149 | - if(is_array($content[$content['nm']['action']])) |
|
149 | + if (is_array($content[$content['nm']['action']])) |
|
150 | 150 | { |
151 | - $content[$content['nm']['action']] = implode(',',$content[$content['nm']['action']]); |
|
151 | + $content[$content['nm']['action']] = implode(',', $content[$content['nm']['action']]); |
|
152 | 152 | } |
153 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
153 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
154 | 154 | unset($content[$action]); |
155 | 155 | unset($content['allowed_popup']); |
156 | 156 | } |
157 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
158 | - $success,$failed,$action_msg,'index',$msg)) |
|
157 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
158 | + $success, $failed, $action_msg, 'index', $msg)) |
|
159 | 159 | { |
160 | - $msg .= lang('%1 definition(s) %2',$success,$action_msg); |
|
160 | + $msg .= lang('%1 definition(s) %2', $success, $action_msg); |
|
161 | 161 | } |
162 | - elseif(empty($msg)) |
|
162 | + elseif (empty($msg)) |
|
163 | 163 | { |
164 | - $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
164 | + $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if(!is_array($content['nm'])) { |
|
170 | + if (!is_array($content['nm'])) { |
|
171 | 171 | $content['nm'] = array( |
172 | 172 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
173 | 173 | 'no_cat' => true, |
174 | 174 | 'no_filter' => true, |
175 | 175 | 'no_filter2' => true, |
176 | - 'csv_fields' => false, // Disable CSV export, uses own export |
|
177 | - 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
176 | + 'csv_fields' => false, // Disable CSV export, uses own export |
|
177 | + 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
178 | 178 | 'row_id' => 'definition_id', |
179 | 179 | 'placeholder_actions' => array('add') |
180 | 180 | ); |
181 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
181 | + if ($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
182 | 182 | } |
183 | - if(Api\Cache::getSession('importexport', 'index')) |
|
183 | + if (Api\Cache::getSession('importexport', 'index')) |
|
184 | 184 | { |
185 | 185 | $content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index')); |
186 | 186 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | ); |
198 | 198 | foreach ($this->plugins as $appname => $options) |
199 | 199 | { |
200 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
200 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
201 | 201 | $sel_options['application'][$appname] = lang($appname); |
202 | 202 | } |
203 | 203 | } |
204 | - if($msg) $content['msg'] = $msg; |
|
204 | + if ($msg) $content['msg'] = $msg; |
|
205 | 205 | |
206 | 206 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
207 | - return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
|
207 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | private function get_actions() { |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | ); |
294 | 294 | |
295 | 295 | // Unset admin actions |
296 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
296 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
297 | 297 | { |
298 | 298 | unset($actions['schedule']); |
299 | 299 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
313 | 313 | * @return boolean true if all actions succeded, false otherwise |
314 | 314 | */ |
315 | - function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
315 | + function action($action, $selected, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
316 | 316 | { |
317 | 317 | //error_log( __METHOD__."('$action', ".array2string($selected).', '.array2string($use_all).",,, '$session_name')"); |
318 | 318 | if ($use_all) |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | // get the whole selection |
321 | 321 | $old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name); |
322 | 322 | |
323 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
324 | - $query['num_rows'] = -1; // all |
|
325 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
326 | - $this->get_rows($query,$rows,$readonlys); |
|
323 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
324 | + $query['num_rows'] = -1; // all |
|
325 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
326 | + $this->get_rows($query, $rows, $readonlys); |
|
327 | 327 | |
328 | 328 | $selected = array(); |
329 | - foreach($rows as $row) { |
|
329 | + foreach ($rows as $row) { |
|
330 | 330 | $selected[] = $row['definition_id']; |
331 | 331 | } |
332 | - if(!is_array($session_name)) |
|
332 | + if (!is_array($session_name)) |
|
333 | 333 | { |
334 | 334 | // Restore old query |
335 | 335 | Api\Cache::setSession('importexport', $session_name, $old_query); |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | |
342 | 342 | $bodefinitions = new importexport_definitions_bo(false, true); |
343 | 343 | |
344 | - switch($action) { |
|
344 | + switch ($action) { |
|
345 | 345 | case 'execute': |
346 | 346 | // There's probably a way to do this in just JS, all the info should be there... |
347 | - foreach($selected as $id) { |
|
347 | + foreach ($selected as $id) { |
|
348 | 348 | $definition = $bodefinitions->read((int)$id); |
349 | 349 | $link = Egw::link('/index.php', array( |
350 | 350 | 'menuaction' => 'importexport.importexport_'.$definition['type'].'_ui.'.$definition['type'].'_dialog', |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | } |
356 | 356 | break; |
357 | 357 | case 'allowed': |
358 | - $action = 'allowed_users';// Field is allowed_users, popup doesn't like _ |
|
358 | + $action = 'allowed_users'; // Field is allowed_users, popup doesn't like _ |
|
359 | 359 | case 'owner': |
360 | - $action_msg = lang('changed'. ' ' . $action); |
|
361 | - foreach($selected as $id) { |
|
360 | + $action_msg = lang('changed'.' '.$action); |
|
361 | + foreach ($selected as $id) { |
|
362 | 362 | $definition = $bodefinitions->read((int)$id); |
363 | - if($definition['definition_id']) { |
|
363 | + if ($definition['definition_id']) { |
|
364 | 364 | // Prevent private with no owner |
365 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
365 | + if (!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
366 | 366 | |
367 | 367 | $definition[$action] = $settings; |
368 | 368 | $bodefinitions->save($definition); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ? |
381 | 381 | 'application/octetstream' : 'application/octet-stream'; |
382 | 382 | $name = 'importexport_definition.xml'; |
383 | - header('Content-Type: ' . $mime_type); |
|
383 | + header('Content-Type: '.$mime_type); |
|
384 | 384 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
385 | 385 | echo $bodefinitions->export($selected); |
386 | 386 | exit(); |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | case 'copy': |
390 | 390 | $action_msg = lang('copied'); |
391 | 391 | // Should only be one selected |
392 | - foreach($selected as $id) { |
|
392 | + foreach ($selected as $id) { |
|
393 | 393 | $definition = $bodefinitions->read((int)$id); |
394 | - if($definition['definition_id']) { |
|
394 | + if ($definition['definition_id']) { |
|
395 | 395 | unset($definition['definition_id']); |
396 | - $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
|
396 | + $definition['name'] = $settings ? $settings : $definition['name'].' copy'; |
|
397 | 397 | try { |
398 | 398 | $bodefinitions->save($definition); |
399 | 399 | } catch (Exception $e) { |
400 | 400 | try { |
401 | - $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
401 | + $definition['name'] .= ' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
402 | 402 | $bodefinitions->save($definition); |
403 | 403 | } catch (Exception $ex) { |
404 | 404 | $failed++; |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | case 'createexport': |
414 | 414 | $action_msg = lang('created'); |
415 | 415 | // Should only be one selected |
416 | - foreach($selected as $id) { |
|
416 | + foreach ($selected as $id) { |
|
417 | 417 | $definition = new importexport_definition($id); |
418 | 418 | try { |
419 | 419 | $export = $bodefinitions->export_from_import($definition); |
420 | 420 | $export->save(); |
421 | 421 | } catch (Exception $e) { |
422 | - if($export) |
|
422 | + if ($export) |
|
423 | 423 | { |
424 | 424 | try { |
425 | - $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
425 | + $export->name = $export->name.' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
426 | 426 | $export->save(); |
427 | 427 | } catch (Exception $ex) { |
428 | 428 | $failed++; |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | Api\Cache::setSession('importexport', 'index', $query); |
448 | 448 | |
449 | 449 | // Special handling for allowed users 'private' |
450 | - if($query['col_filter']['allowed_users'] == 'private') |
|
450 | + if ($query['col_filter']['allowed_users'] == 'private') |
|
451 | 451 | { |
452 | 452 | unset($query['col_filter']['allowed_users']); |
453 | - $query['col_filter'][] = 'allowed_users = ' . $GLOBALS['egw']->db->quote(',,'); |
|
453 | + $query['col_filter'][] = 'allowed_users = '.$GLOBALS['egw']->db->quote(',,'); |
|
454 | 454 | } |
455 | 455 | $bodefinitions = new importexport_definitions_bo($query['col_filter'], true); |
456 | 456 | // We don't care about readonlys for the UI |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | function edit() |
467 | 467 | { |
468 | - if(!$_definition = $_GET['definition']) |
|
468 | + if (!$_definition = $_GET['definition']) |
|
469 | 469 | { |
470 | 470 | $content = array( |
471 | 471 | 'edit' => true, |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | ); |
475 | 475 | |
476 | 476 | // Jump to a step |
477 | - if($_GET['step']) |
|
477 | + if ($_GET['step']) |
|
478 | 478 | { |
479 | 479 | $content['edit'] = false; |
480 | 480 | // Wizard will process previous step, then advance |
481 | - $content['step'] = $this->get_step($_GET['step'],-1); |
|
481 | + $content['step'] = $this->get_step($_GET['step'], -1); |
|
482 | 482 | $content['button']['next'] = 'pressed'; |
483 | 483 | $this->wizard($content); |
484 | 484 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | } |
490 | 490 | return; |
491 | 491 | } |
492 | - if(is_numeric($_GET['definition'])) |
|
492 | + if (is_numeric($_GET['definition'])) |
|
493 | 493 | { |
494 | 494 | $definition = (int)$_GET['definition']; |
495 | 495 | } |
@@ -501,31 +501,31 @@ discard block |
||
501 | 501 | $definition = $bodefinitions->read($definition); |
502 | 502 | $definition['edit'] = true; |
503 | 503 | // Jump to a step |
504 | - if($_GET['step']) |
|
504 | + if ($_GET['step']) |
|
505 | 505 | { |
506 | 506 | $definition['edit'] = false; |
507 | 507 | // Wizard will process previous step, then advance |
508 | - $definition['step'] = $_GET['step'];; |
|
508 | + $definition['step'] = $_GET['step']; ; |
|
509 | 509 | $definition['button'] = array('next' => 'pressed'); |
510 | 510 | } |
511 | 511 | $this->wizard($definition); |
512 | 512 | } |
513 | 513 | |
514 | - function wizard($content = null, $msg='') |
|
514 | + function wizard($content = null, $msg = '') |
|
515 | 515 | { |
516 | 516 | $this->etpl->read('importexport.wizardbox'); |
517 | 517 | |
518 | - if(is_array($content) &&! $content['edit']) |
|
518 | + if (is_array($content) && !$content['edit']) |
|
519 | 519 | { |
520 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
520 | + if (self::_debug) error_log('importexport.wizard->$content '.print_r($content, true)); |
|
521 | 521 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
522 | 522 | // fetch plugin object |
523 | - if($content['plugin'] && $content['application']) |
|
523 | + if ($content['plugin'] && $content['application']) |
|
524 | 524 | { |
525 | - $wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']); |
|
525 | + $wizard_name = $content['application'].'_wizard_'.str_replace($content['application'].'_', '', $content['plugin']); |
|
526 | 526 | |
527 | 527 | // we need to deal with the wizard object if exists |
528 | - if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php")) |
|
528 | + if (file_exists(EGW_SERVER_ROOT.'/'.$content['application']."/inc/class.$wizard_name.inc.php")) |
|
529 | 529 | { |
530 | 530 | $wizard_plugin = $wizard_name; |
531 | 531 | } |
@@ -534,38 +534,38 @@ discard block |
||
534 | 534 | $wizard_plugin = $content['plugin']; |
535 | 535 | } |
536 | 536 | // App translations |
537 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
537 | + if ($content['application']) Api\Translation::add_app($content['application']); |
|
538 | 538 | |
539 | 539 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
540 | 540 | |
541 | 541 | // Global object needs to be the same, or references to plugin don't work |
542 | - if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
543 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
542 | + if (!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
543 | + $GLOBALS['egw']->importexport_definitions_ui = & $this; |
|
544 | 544 | } |
545 | 545 | // deal with buttons even if we are not on ajax |
546 | - if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
|
546 | + if (isset($content['button']) && array_search('pressed', $content['button']) === false && count($content['button']) == 1) |
|
547 | 547 | { |
548 | 548 | $button = array_keys($content['button']); |
549 | 549 | $content['button'] = array($button[0] => 'pressed'); |
550 | 550 | } |
551 | 551 | |
552 | 552 | // post process submitted step |
553 | - if($content['step']) |
|
553 | + if ($content['step']) |
|
554 | 554 | { |
555 | - if(!$this->can_edit($content)) |
|
555 | + if (!$this->can_edit($content)) |
|
556 | 556 | { |
557 | 557 | // Each step changes definition, reload it |
558 | 558 | $bodefinitions = new importexport_definitions_bo(); |
559 | 559 | $definition = $bodefinitions->read($content); |
560 | 560 | $content = $definition + array('step' => $content['step'], 'button' => $content['button']); |
561 | 561 | } |
562 | - if(!key_exists($content['step'],$this->steps)) |
|
562 | + if (!key_exists($content['step'], $this->steps)) |
|
563 | 563 | { |
564 | - $next_step = $this->plugin->$content['step']($content,$sel_options,$readonlys,$preserv); |
|
564 | + $next_step = $this->plugin->$content['step']($content, $sel_options, $readonlys, $preserv); |
|
565 | 565 | } |
566 | 566 | else |
567 | 567 | { |
568 | - $next_step = $this->$content['step']($content,$sel_options,$readonlys,$preserv); |
|
568 | + $next_step = $this->$content['step']($content, $sel_options, $readonlys, $preserv); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | else |
@@ -577,23 +577,23 @@ discard block |
||
577 | 577 | $sel_options = $readonlys = $preserv = array(); |
578 | 578 | |
579 | 579 | // Disable finish button if required fields are missing |
580 | - if(!$content['name'] || !$content['type'] || !$content['plugin']) |
|
580 | + if (!$content['name'] || !$content['type'] || !$content['plugin']) |
|
581 | 581 | { |
582 | 582 | $readonlys['button[finish]'] = true; |
583 | 583 | } |
584 | 584 | do |
585 | 585 | { |
586 | - if(!key_exists($next_step,$this->steps)) |
|
586 | + if (!key_exists($next_step, $this->steps)) |
|
587 | 587 | { |
588 | - $this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv); |
|
588 | + $this->wizard_content_template = $this->plugin->$next_step($content, $sel_options, $readonlys, $preserv); |
|
589 | 589 | } |
590 | 590 | else |
591 | 591 | { |
592 | - $this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv); |
|
592 | + $this->wizard_content_template = $this->$next_step($content, $sel_options, $readonlys, $preserv); |
|
593 | 593 | } |
594 | - if($this->wizard_content_template == self::SKIP) |
|
594 | + if ($this->wizard_content_template == self::SKIP) |
|
595 | 595 | { |
596 | - if(!key_exists($content['step'],$this->steps)) |
|
596 | + if (!key_exists($content['step'], $this->steps)) |
|
597 | 597 | { |
598 | 598 | $next_step = $this->plugin->$content['step']($content); |
599 | 599 | } |
@@ -602,9 +602,9 @@ discard block |
||
602 | 602 | $next_step = $this->$content['step']($content); |
603 | 603 | } |
604 | 604 | } |
605 | - } while($this->wizard_content_template == self::SKIP); |
|
605 | + } while ($this->wizard_content_template == self::SKIP); |
|
606 | 606 | |
607 | - if(!$this->can_edit($content)) |
|
607 | + if (!$this->can_edit($content)) |
|
608 | 608 | { |
609 | 609 | $readonlys[$this->wizard_content_template] = true; |
610 | 610 | $preserve = $content; |
@@ -613,21 +613,21 @@ discard block |
||
613 | 613 | |
614 | 614 | unset($content['button']); |
615 | 615 | $content['wizard_content'] = $this->wizard_content_template; |
616 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
616 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
617 | 617 | } |
618 | 618 | else |
619 | 619 | { |
620 | 620 | // initial content |
621 | 621 | $sel_options = $readonlys = $preserv = array(); |
622 | 622 | $readonlys['button[previous]'] = true; |
623 | - if($content['edit']) |
|
623 | + if ($content['edit']) |
|
624 | 624 | { |
625 | 625 | unset ($content['edit']); |
626 | 626 | } |
627 | 627 | |
628 | 628 | $this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
629 | 629 | |
630 | - if(!$this->can_edit($content)) |
|
630 | + if (!$this->can_edit($content)) |
|
631 | 631 | { |
632 | 632 | $readonlys[$this->wizard_content_template] = true; |
633 | 633 | $preserve = $content; |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | } |
636 | 636 | |
637 | 637 | $content['wizard_content'] = $this->wizard_content_template; |
638 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
638 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param int $step_width |
647 | 647 | * @return string containing function name of next step |
648 | 648 | */ |
649 | - function get_step ($curr_step, $step_width) |
|
649 | + function get_step($curr_step, $step_width) |
|
650 | 650 | { |
651 | 651 | /*if($content['plugin'] && $content['application']&& !is_object($this->plugin)) |
652 | 652 | { |
653 | 653 | $plugin_definition = $this->plugins[$content['application']][$content['plugin']]['definition']; |
654 | 654 | if($plugin_definition) $this->plugin = new $plugin_definition; |
655 | 655 | }*/ |
656 | - if(is_object($this->plugin) && is_array($this->plugin->steps)) |
|
656 | + if (is_object($this->plugin) && is_array($this->plugin->steps)) |
|
657 | 657 | { |
658 | - $steps = array_merge($this->steps,$this->plugin->steps); |
|
659 | - $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
658 | + $steps = array_merge($this->steps, $this->plugin->steps); |
|
659 | + $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
660 | 660 | } |
661 | 661 | else |
662 | 662 | { |
663 | 663 | $steps = $this->steps; |
664 | 664 | } |
665 | 665 | $step_keys = array_keys($steps); |
666 | - $nn = array_search($curr_step,$step_keys)+(int)$step_width; |
|
667 | - return (key_exists($nn,$step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
666 | + $nn = array_search($curr_step, $step_keys) + (int)$step_width; |
|
667 | + return (key_exists($nn, $step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
671 | 671 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
672 | 672 | { |
673 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
673 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content, true)); |
|
674 | 674 | |
675 | 675 | // return from step10 |
676 | 676 | if ($content['step'] == 'wizard_step10') |
@@ -678,11 +678,11 @@ discard block |
||
678 | 678 | switch (array_search('pressed', $content['button'])) |
679 | 679 | { |
680 | 680 | case 'next': |
681 | - return $this->get_step($content['step'],1); |
|
681 | + return $this->get_step($content['step'], 1); |
|
682 | 682 | case 'finish': |
683 | 683 | return 'wizard_finish'; |
684 | 684 | default : |
685 | - return $this->wizard_step10($content,$sel_options,$readonlys,$preserv); |
|
685 | + return $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | $content['text'] = $this->steps['wizard_step10']; |
693 | 693 | foreach ($this->plugins as $appname => $options) |
694 | 694 | { |
695 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
695 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
696 | 696 | $sel_options['application'][$appname] = lang($appname); |
697 | 697 | } |
698 | 698 | } |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | // get plugin |
709 | 709 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
710 | 710 | { |
711 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
711 | + if (self::_debug) error_log('importexport.'.get_class($this).'::wizard_step20->$content '.print_r($content, true)); |
|
712 | 712 | |
713 | 713 | // return from step20 |
714 | 714 | if ($content['step'] == 'wizard_step20') |
@@ -717,21 +717,21 @@ discard block |
||
717 | 717 | { |
718 | 718 | case 'next': |
719 | 719 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
720 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
720 | + if ($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
721 | 721 | $content['type'] = 'import'; |
722 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
722 | + } elseif ($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin), 'export') !== false) { |
|
723 | 723 | $content['type'] = 'export'; |
724 | 724 | } else { |
725 | 725 | throw new Api\Exception('Invalid plugin'); |
726 | 726 | } |
727 | - return $this->get_step($content['step'],1); |
|
727 | + return $this->get_step($content['step'], 1); |
|
728 | 728 | case 'previous' : |
729 | 729 | $readonlys['button[previous]'] = true; |
730 | - return $this->get_step($content['step'],-1); |
|
730 | + return $this->get_step($content['step'], -1); |
|
731 | 731 | case 'finish': |
732 | 732 | return 'wizard_finish'; |
733 | 733 | default : |
734 | - return $this->wizard_step20($content,$sel_options,$readonlys,$preserv); |
|
734 | + return $this->wizard_step20($content, $sel_options, $readonlys, $preserv); |
|
735 | 735 | } |
736 | 736 | } |
737 | 737 | // init step20 |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | $content['text'] = $this->steps['wizard_step20']; |
741 | 741 | $config = Api\Config::read('phpgwapi'); |
742 | 742 | foreach ($this->plugins[$content['application']] as $type => $plugins) { |
743 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
744 | - foreach($plugins as $plugin => $name) { |
|
743 | + if ($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
744 | + foreach ($plugins as $plugin => $name) { |
|
745 | 745 | $sel_options['plugin'][$plugin] = $name; |
746 | 746 | } |
747 | 747 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | // name |
758 | 758 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
759 | 759 | { |
760 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
760 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content, true)); |
|
761 | 761 | |
762 | 762 | // Check for duplicate name |
763 | 763 | $duplicate = isset($content['duplicate_error']); |
764 | - if($content['name'] && !$duplicate) |
|
764 | + if ($content['name'] && !$duplicate) |
|
765 | 765 | { |
766 | 766 | try { |
767 | 767 | $check_definition = new importexport_definition($content['name']); |
768 | - if($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
768 | + if ($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
769 | 769 | { |
770 | 770 | throw new Exception('Already exists'); |
771 | 771 | } |
@@ -775,21 +775,21 @@ discard block |
||
775 | 775 | |
776 | 776 | // Try some suggestions |
777 | 777 | $suggestions = array( |
778 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'], |
|
779 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'], |
|
780 | - $content['name'] .'-'. Api\DateTime::to('now', true), |
|
778 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_lid'], |
|
779 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_id'], |
|
780 | + $content['name'].'-'.Api\DateTime::to('now', true), |
|
781 | 781 | //$content['name'] .'-'. rand(0,100), |
782 | 782 | ); |
783 | - foreach($suggestions as $key => $suggestion) { |
|
783 | + foreach ($suggestions as $key => $suggestion) { |
|
784 | 784 | $sug_definition = new importexport_definition($suggestion); |
785 | - if($sug_definition->definition_id) { |
|
785 | + if ($sug_definition->definition_id) { |
|
786 | 786 | unset($suggestions[$key]); |
787 | 787 | } |
788 | 788 | } |
789 | - if($suggestions) { |
|
790 | - $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
|
789 | + if ($suggestions) { |
|
790 | + $content['duplicate_error'] .= ' '.lang('Try')." \n".implode("\n", $suggestions); |
|
791 | 791 | } |
792 | - return $this->get_step($content['step'],0); |
|
792 | + return $this->get_step($content['step'], 0); |
|
793 | 793 | } |
794 | 794 | } |
795 | 795 | |
@@ -799,19 +799,19 @@ discard block |
||
799 | 799 | switch (array_search('pressed', $content['button'])) |
800 | 800 | { |
801 | 801 | case 'next': |
802 | - return $this->get_step($content['step'],1); |
|
802 | + return $this->get_step($content['step'], 1); |
|
803 | 803 | case 'previous' : |
804 | - return $this->get_step($content['step'],-1); |
|
804 | + return $this->get_step($content['step'], -1); |
|
805 | 805 | case 'finish': |
806 | 806 | return 'wizard_finish'; |
807 | 807 | default : |
808 | - return $this->wizard_step21($content,$sel_options,$readonlys,$preserv); |
|
808 | + return $this->wizard_step21($content, $sel_options, $readonlys, $preserv); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | // init step21 |
812 | 812 | else |
813 | 813 | { |
814 | - $content['text'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
814 | + $content['text'] = $this->steps['wizard_step21'].($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
815 | 815 | $content['step'] = 'wizard_step21'; |
816 | 816 | unset($content['duplicate_error']); |
817 | 817 | $preserv = $content; |
@@ -823,17 +823,16 @@ discard block |
||
823 | 823 | // allowed users |
824 | 824 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
825 | 825 | { |
826 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
826 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content, true)); |
|
827 | 827 | |
828 | 828 | // return from step90 |
829 | 829 | if ($content['step'] == 'wizard_step90') |
830 | 830 | { |
831 | - if($this->can_edit($content)) |
|
831 | + if ($this->can_edit($content)) |
|
832 | 832 | { |
833 | - $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ? |
|
834 | - ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : |
|
835 | - null; |
|
836 | - $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users'])); |
|
833 | + $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ, 'importexport') ? |
|
834 | + ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : null; |
|
835 | + $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',', $content['allowed_users'])); |
|
837 | 836 | unset($content['just_me']); |
838 | 837 | } |
839 | 838 | |
@@ -841,12 +840,12 @@ discard block |
||
841 | 840 | switch (array_search('pressed', $content['button'])) |
842 | 841 | { |
843 | 842 | case 'previous' : |
844 | - return $this->get_step($content['step'],-1); |
|
843 | + return $this->get_step($content['step'], -1); |
|
845 | 844 | case 'next': |
846 | 845 | case 'finish': |
847 | 846 | return 'wizard_finish'; |
848 | 847 | default : |
849 | - return $this->wizard_step90($content,$sel_options,$readonlys,$preserv); |
|
848 | + return $this->wizard_step90($content, $sel_options, $readonlys, $preserv); |
|
850 | 849 | } |
851 | 850 | } |
852 | 851 | // init step90 |
@@ -857,10 +856,10 @@ discard block |
||
857 | 856 | $preserv = $content; |
858 | 857 | |
859 | 858 | // Set owner for non-admins |
860 | - $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']); |
|
861 | - $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
859 | + $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) == 1) && $content['owner']); |
|
860 | + $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0', $content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
862 | 861 | $content['allowed_users'] == 'all'; |
863 | - if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
862 | + if (!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
864 | 863 | { |
865 | 864 | $content['allowed_users'] = array(); |
866 | 865 | $readonlys['allowed_users'] = true; |
@@ -876,11 +875,11 @@ discard block |
||
876 | 875 | ) |
877 | 876 | ); |
878 | 877 | // Hide 'just me' checkbox, users get confused by read-only |
879 | - if($readonlys['just_me'] || !$this->can_edit($content)) |
|
878 | + if ($readonlys['just_me'] || !$this->can_edit($content)) |
|
880 | 879 | { |
881 | 880 | $content['no_just_me'] = true; |
882 | 881 | } |
883 | - if($readonlys['all_users'] || !$this->can_edit($content)) |
|
882 | + if ($readonlys['all_users'] || !$this->can_edit($content)) |
|
884 | 883 | { |
885 | 884 | $content['no_all_users'] = true; |
886 | 885 | } |
@@ -893,7 +892,7 @@ discard block |
||
893 | 892 | |
894 | 893 | function wizard_finish(&$content) |
895 | 894 | { |
896 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
895 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content, true)); |
|
897 | 896 | // Take out some UI leavings |
898 | 897 | unset($content['text']); |
899 | 898 | unset($content['step']); |
@@ -903,26 +902,26 @@ discard block |
||
903 | 902 | $bodefinitions->save($content); |
904 | 903 | // This message is displayed if browser cant close window |
905 | 904 | $content['msg'] = lang('ImportExport wizard finished successfully!'); |
906 | - Framework::refresh_opener('','importexport'); |
|
905 | + Framework::refresh_opener('', 'importexport'); |
|
907 | 906 | Framework::window_close(); |
908 | 907 | return 'importexport.wizard_close'; |
909 | 908 | } |
910 | 909 | |
911 | - function import_definition($content='') |
|
910 | + function import_definition($content = '') |
|
912 | 911 | { |
913 | 912 | $bodefinitions = new importexport_definitions_bo(); |
914 | 913 | if (is_array($content)) |
915 | 914 | { |
916 | - if($content['import_file']['tmp_name']) |
|
915 | + if ($content['import_file']['tmp_name']) |
|
917 | 916 | { |
918 | 917 | $result = $bodefinitions->import($content['import_file']['tmp_name']); |
919 | - $msg = lang('%1 definitions %2', count($result), lang('imported')) ."\n". implode("\n", array_keys($result)); |
|
918 | + $msg = lang('%1 definitions %2', count($result), lang('imported'))."\n".implode("\n", array_keys($result)); |
|
920 | 919 | return $this->index(null, $msg); |
921 | 920 | } |
922 | - if($content['update']) |
|
921 | + if ($content['update']) |
|
923 | 922 | { |
924 | 923 | $applist = importexport_helper_functions::get_apps('all', true); |
925 | - foreach($applist as $appname) { |
|
924 | + foreach ($applist as $appname) { |
|
926 | 925 | importexport_helper_functions::load_defaults($appname); |
927 | 926 | } |
928 | 927 | return $this->index(); |
@@ -932,7 +931,7 @@ discard block |
||
932 | 931 | { |
933 | 932 | $content = array(); |
934 | 933 | $etpl = new etemplate(self::_appname.'.import_definition'); |
935 | - return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv); |
|
934 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition', $content, array(), $readonlys, $preserv); |
|
936 | 935 | } |
937 | 936 | } |
938 | 937 | |
@@ -942,17 +941,17 @@ discard block |
||
942 | 941 | */ |
943 | 942 | protected function can_edit(Array $definition) |
944 | 943 | { |
945 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
944 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
946 | 945 | { |
947 | 946 | // Definition belongs to user |
948 | 947 | return true; |
949 | 948 | } |
950 | - elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
949 | + elseif ($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
951 | 950 | { |
952 | 951 | // Definition is unowned, and user is an admin |
953 | 952 | return true; |
954 | 953 | } |
955 | - elseif(!$definition['definition_id']) |
|
954 | + elseif (!$definition['definition_id']) |
|
956 | 955 | { |
957 | 956 | // Definition is in-progress, not saved yet |
958 | 957 | return true; |
@@ -965,26 +964,26 @@ discard block |
||
965 | 964 | */ |
966 | 965 | public function site_config($content = array()) |
967 | 966 | { |
968 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
967 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
969 | 968 | { |
970 | 969 | Egw::redirect_link('/home'); |
971 | 970 | } |
972 | - if($content['save']) |
|
971 | + if ($content['save']) |
|
973 | 972 | { |
974 | 973 | unset($content['save']); |
975 | 974 | |
976 | 975 | // ACL |
977 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false); |
|
978 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition',false); |
|
976 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition', false); |
|
977 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition', false); |
|
979 | 978 | |
980 | - foreach($content['share_definition'] as $group) |
|
979 | + foreach ($content['share_definition'] as $group) |
|
981 | 980 | { |
982 | - $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ); |
|
981 | + $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group, Acl::READ); |
|
983 | 982 | } |
984 | 983 | unset($content['share_definition']); |
985 | 984 | |
986 | 985 | // Other Api\Config |
987 | - foreach($content as $key=>$value) |
|
986 | + foreach ($content as $key=>$value) |
|
988 | 987 | { |
989 | 988 | Api\Config::save_value($key, $value, 'importexport'); |
990 | 989 | } |
@@ -994,18 +993,18 @@ discard block |
||
994 | 993 | |
995 | 994 | $data = Api\Config::read(self::_appname); |
996 | 995 | $data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Acl::READ, self::_appname); |
997 | - $sel_options['import_charsets'] = array_combine(mb_list_encodings(),mb_list_encodings()); |
|
996 | + $sel_options['import_charsets'] = array_combine(mb_list_encodings(), mb_list_encodings()); |
|
998 | 997 | |
999 | 998 | // Remove 'standard' encodings to prevent doubles |
1000 | - foreach(Api\Translation::get_installed_charsets() as $charset => $label) |
|
999 | + foreach (Api\Translation::get_installed_charsets() as $charset => $label) |
|
1001 | 1000 | { |
1002 | 1001 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
1003 | 1002 | } |
1004 | 1003 | |
1005 | - if(!$data['update']) $data['update'] = 'request'; |
|
1004 | + if (!$data['update']) $data['update'] = 'request'; |
|
1006 | 1005 | |
1007 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
|
1006 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration').' - '.lang(self::_appname); |
|
1008 | 1007 | $etpl = new etemplate(self::_appname.'.config'); |
1009 | - $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv); |
|
1008 | + $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config', $data, $sel_options, $readonlys, $preserv); |
|
1010 | 1009 | } |
1011 | 1010 | } |
@@ -88,14 +88,18 @@ discard block |
||
88 | 88 | { |
89 | 89 | $filter = array('name' => '*'); |
90 | 90 | |
91 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
91 | + if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
92 | + { |
|
92 | 93 | // Any public definition |
93 | 94 | $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
94 | - } else { |
|
95 | + } |
|
96 | + else |
|
97 | + { |
|
95 | 98 | // Filter private definitions |
96 | 99 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
97 | 100 | $config = Api\Config::read('phpgwapi'); |
98 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
101 | + if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) |
|
102 | + { |
|
99 | 103 | $filter['type'] = 'import'; |
100 | 104 | } |
101 | 105 | } |
@@ -111,7 +115,10 @@ discard block |
||
111 | 115 | elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
112 | 116 | { |
113 | 117 | $selected = $content['nm']['rows']['selected']; |
114 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
118 | + if(count($selected) < 1 || !is_array($selected)) |
|
119 | + { |
|
120 | + exit(); |
|
121 | + } |
|
115 | 122 | switch ($button) |
116 | 123 | { |
117 | 124 | case 'delete_selected' : |
@@ -167,7 +174,8 @@ discard block |
||
167 | 174 | } |
168 | 175 | } |
169 | 176 | |
170 | - if(!is_array($content['nm'])) { |
|
177 | + if(!is_array($content['nm'])) |
|
178 | + { |
|
171 | 179 | $content['nm'] = array( |
172 | 180 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
173 | 181 | 'no_cat' => true, |
@@ -178,7 +186,10 @@ discard block |
||
178 | 186 | 'row_id' => 'definition_id', |
179 | 187 | 'placeholder_actions' => array('add') |
180 | 188 | ); |
181 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
189 | + if($_GET['application']) |
|
190 | + { |
|
191 | + $content['nm']['col_filter']['application'] = $_GET['application']; |
|
192 | + } |
|
182 | 193 | } |
183 | 194 | if(Api\Cache::getSession('importexport', 'index')) |
184 | 195 | { |
@@ -197,17 +208,22 @@ discard block |
||
197 | 208 | ); |
198 | 209 | foreach ($this->plugins as $appname => $options) |
199 | 210 | { |
200 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
211 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
212 | + { |
|
201 | 213 | $sel_options['application'][$appname] = lang($appname); |
202 | 214 | } |
203 | 215 | } |
204 | - if($msg) $content['msg'] = $msg; |
|
216 | + if($msg) |
|
217 | + { |
|
218 | + $content['msg'] = $msg; |
|
219 | + } |
|
205 | 220 | |
206 | 221 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
207 | 222 | return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
208 | 223 | } |
209 | 224 | |
210 | - private function get_actions() { |
|
225 | + private function get_actions() |
|
226 | + { |
|
211 | 227 | $group = 0; |
212 | 228 | $actions = array( |
213 | 229 | 'edit' => array( |
@@ -326,7 +342,8 @@ discard block |
||
326 | 342 | $this->get_rows($query,$rows,$readonlys); |
327 | 343 | |
328 | 344 | $selected = array(); |
329 | - foreach($rows as $row) { |
|
345 | + foreach($rows as $row) |
|
346 | + { |
|
330 | 347 | $selected[] = $row['definition_id']; |
331 | 348 | } |
332 | 349 | if(!is_array($session_name)) |
@@ -341,10 +358,12 @@ discard block |
||
341 | 358 | |
342 | 359 | $bodefinitions = new importexport_definitions_bo(false, true); |
343 | 360 | |
344 | - switch($action) { |
|
361 | + switch($action) |
|
362 | + { |
|
345 | 363 | case 'execute': |
346 | 364 | // There's probably a way to do this in just JS, all the info should be there... |
347 | - foreach($selected as $id) { |
|
365 | + foreach($selected as $id) |
|
366 | + { |
|
348 | 367 | $definition = $bodefinitions->read((int)$id); |
349 | 368 | $link = Egw::link('/index.php', array( |
350 | 369 | 'menuaction' => 'importexport.importexport_'.$definition['type'].'_ui.'.$definition['type'].'_dialog', |
@@ -358,11 +377,16 @@ discard block |
||
358 | 377 | $action = 'allowed_users';// Field is allowed_users, popup doesn't like _ |
359 | 378 | case 'owner': |
360 | 379 | $action_msg = lang('changed'. ' ' . $action); |
361 | - foreach($selected as $id) { |
|
380 | + foreach($selected as $id) |
|
381 | + { |
|
362 | 382 | $definition = $bodefinitions->read((int)$id); |
363 | - if($definition['definition_id']) { |
|
383 | + if($definition['definition_id']) |
|
384 | + { |
|
364 | 385 | // Prevent private with no owner |
365 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
386 | + if(!$definition['owner'] && !$settings) |
|
387 | + { |
|
388 | + $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
389 | + } |
|
366 | 390 | |
367 | 391 | $definition[$action] = $settings; |
368 | 392 | $bodefinitions->save($definition); |
@@ -389,18 +413,22 @@ discard block |
||
389 | 413 | case 'copy': |
390 | 414 | $action_msg = lang('copied'); |
391 | 415 | // Should only be one selected |
392 | - foreach($selected as $id) { |
|
416 | + foreach($selected as $id) |
|
417 | + { |
|
393 | 418 | $definition = $bodefinitions->read((int)$id); |
394 | - if($definition['definition_id']) { |
|
419 | + if($definition['definition_id']) |
|
420 | + { |
|
395 | 421 | unset($definition['definition_id']); |
396 | 422 | $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
397 | 423 | try { |
398 | 424 | $bodefinitions->save($definition); |
399 | - } catch (Exception $e) { |
|
425 | + } |
|
426 | + catch (Exception $e) { |
|
400 | 427 | try { |
401 | 428 | $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
402 | 429 | $bodefinitions->save($definition); |
403 | - } catch (Exception $ex) { |
|
430 | + } |
|
431 | + catch (Exception $ex) { |
|
404 | 432 | $failed++; |
405 | 433 | $msg .= lang('Duplicate name, please choose another.'); |
406 | 434 | continue; |
@@ -413,18 +441,21 @@ discard block |
||
413 | 441 | case 'createexport': |
414 | 442 | $action_msg = lang('created'); |
415 | 443 | // Should only be one selected |
416 | - foreach($selected as $id) { |
|
444 | + foreach($selected as $id) |
|
445 | + { |
|
417 | 446 | $definition = new importexport_definition($id); |
418 | 447 | try { |
419 | 448 | $export = $bodefinitions->export_from_import($definition); |
420 | 449 | $export->save(); |
421 | - } catch (Exception $e) { |
|
450 | + } |
|
451 | + catch (Exception $e) { |
|
422 | 452 | if($export) |
423 | 453 | { |
424 | 454 | try { |
425 | 455 | $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
426 | 456 | $export->save(); |
427 | - } catch (Exception $ex) { |
|
457 | + } |
|
458 | + catch (Exception $ex) { |
|
428 | 459 | $failed++; |
429 | 460 | $msg .= lang('Duplicate name, please choose another.'); |
430 | 461 | continue; |
@@ -442,7 +473,8 @@ discard block |
||
442 | 473 | return !$failed; |
443 | 474 | } |
444 | 475 | |
445 | - public function get_rows(&$query, &$rows, &$readonlys) { |
|
476 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
477 | + { |
|
446 | 478 | $rows = array(); |
447 | 479 | Api\Cache::setSession('importexport', 'index', $query); |
448 | 480 | |
@@ -517,7 +549,10 @@ discard block |
||
517 | 549 | |
518 | 550 | if(is_array($content) &&! $content['edit']) |
519 | 551 | { |
520 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
552 | + if(self::_debug) |
|
553 | + { |
|
554 | + error_log('importexport.wizard->$content '. print_r($content,true)); |
|
555 | + } |
|
521 | 556 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
522 | 557 | // fetch plugin object |
523 | 558 | if($content['plugin'] && $content['application']) |
@@ -534,13 +569,18 @@ discard block |
||
534 | 569 | $wizard_plugin = $content['plugin']; |
535 | 570 | } |
536 | 571 | // App translations |
537 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
572 | + if($content['application']) |
|
573 | + { |
|
574 | + Api\Translation::add_app($content['application']); |
|
575 | + } |
|
538 | 576 | |
539 | 577 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
540 | 578 | |
541 | 579 | // Global object needs to be the same, or references to plugin don't work |
542 | 580 | if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
543 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
581 | + { |
|
582 | + $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
583 | + } |
|
544 | 584 | } |
545 | 585 | // deal with buttons even if we are not on ajax |
546 | 586 | if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
@@ -670,7 +710,10 @@ discard block |
||
670 | 710 | |
671 | 711 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
672 | 712 | { |
673 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
713 | + if(self::_debug) |
|
714 | + { |
|
715 | + error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
716 | + } |
|
674 | 717 | |
675 | 718 | // return from step10 |
676 | 719 | if ($content['step'] == 'wizard_step10') |
@@ -692,7 +735,8 @@ discard block |
||
692 | 735 | $content['text'] = $this->steps['wizard_step10']; |
693 | 736 | foreach ($this->plugins as $appname => $options) |
694 | 737 | { |
695 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
738 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
739 | + { |
|
696 | 740 | $sel_options['application'][$appname] = lang($appname); |
697 | 741 | } |
698 | 742 | } |
@@ -708,7 +752,10 @@ discard block |
||
708 | 752 | // get plugin |
709 | 753 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
710 | 754 | { |
711 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
755 | + if(self::_debug) |
|
756 | + { |
|
757 | + error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
758 | + } |
|
712 | 759 | |
713 | 760 | // return from step20 |
714 | 761 | if ($content['step'] == 'wizard_step20') |
@@ -717,11 +764,16 @@ discard block |
||
717 | 764 | { |
718 | 765 | case 'next': |
719 | 766 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
720 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
767 | + if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) |
|
768 | + { |
|
721 | 769 | $content['type'] = 'import'; |
722 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
770 | + } |
|
771 | + elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) |
|
772 | + { |
|
723 | 773 | $content['type'] = 'export'; |
724 | - } else { |
|
774 | + } |
|
775 | + else |
|
776 | + { |
|
725 | 777 | throw new Api\Exception('Invalid plugin'); |
726 | 778 | } |
727 | 779 | return $this->get_step($content['step'],1); |
@@ -739,9 +791,14 @@ discard block |
||
739 | 791 | { |
740 | 792 | $content['text'] = $this->steps['wizard_step20']; |
741 | 793 | $config = Api\Config::read('phpgwapi'); |
742 | - foreach ($this->plugins[$content['application']] as $type => $plugins) { |
|
743 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
744 | - foreach($plugins as $plugin => $name) { |
|
794 | + foreach ($this->plugins[$content['application']] as $type => $plugins) |
|
795 | + { |
|
796 | + if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') |
|
797 | + { |
|
798 | + continue; |
|
799 | + } |
|
800 | + foreach($plugins as $plugin => $name) |
|
801 | + { |
|
745 | 802 | $sel_options['plugin'][$plugin] = $name; |
746 | 803 | } |
747 | 804 | } |
@@ -757,7 +814,10 @@ discard block |
||
757 | 814 | // name |
758 | 815 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
759 | 816 | { |
760 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
817 | + if(self::_debug) |
|
818 | + { |
|
819 | + error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
820 | + } |
|
761 | 821 | |
762 | 822 | // Check for duplicate name |
763 | 823 | $duplicate = isset($content['duplicate_error']); |
@@ -769,7 +829,8 @@ discard block |
||
769 | 829 | { |
770 | 830 | throw new Exception('Already exists'); |
771 | 831 | } |
772 | - } catch (Exception $e) { |
|
832 | + } |
|
833 | + catch (Exception $e) { |
|
773 | 834 | // throw new Exception('Already exists'); |
774 | 835 | $content['duplicate_error'] = lang('Duplicate name, please choose another.'); |
775 | 836 | |
@@ -780,13 +841,16 @@ discard block |
||
780 | 841 | $content['name'] .'-'. Api\DateTime::to('now', true), |
781 | 842 | //$content['name'] .'-'. rand(0,100), |
782 | 843 | ); |
783 | - foreach($suggestions as $key => $suggestion) { |
|
844 | + foreach($suggestions as $key => $suggestion) |
|
845 | + { |
|
784 | 846 | $sug_definition = new importexport_definition($suggestion); |
785 | - if($sug_definition->definition_id) { |
|
847 | + if($sug_definition->definition_id) |
|
848 | + { |
|
786 | 849 | unset($suggestions[$key]); |
787 | 850 | } |
788 | 851 | } |
789 | - if($suggestions) { |
|
852 | + if($suggestions) |
|
853 | + { |
|
790 | 854 | $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
791 | 855 | } |
792 | 856 | return $this->get_step($content['step'],0); |
@@ -823,7 +887,10 @@ discard block |
||
823 | 887 | // allowed users |
824 | 888 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
825 | 889 | { |
826 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
890 | + if(self::_debug) |
|
891 | + { |
|
892 | + error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
893 | + } |
|
827 | 894 | |
828 | 895 | // return from step90 |
829 | 896 | if ($content['step'] == 'wizard_step90') |
@@ -893,7 +960,10 @@ discard block |
||
893 | 960 | |
894 | 961 | function wizard_finish(&$content) |
895 | 962 | { |
896 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
963 | + if(self::_debug) |
|
964 | + { |
|
965 | + error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
966 | + } |
|
897 | 967 | // Take out some UI leavings |
898 | 968 | unset($content['text']); |
899 | 969 | unset($content['step']); |
@@ -922,7 +992,8 @@ discard block |
||
922 | 992 | if($content['update']) |
923 | 993 | { |
924 | 994 | $applist = importexport_helper_functions::get_apps('all', true); |
925 | - foreach($applist as $appname) { |
|
995 | + foreach($applist as $appname) |
|
996 | + { |
|
926 | 997 | importexport_helper_functions::load_defaults($appname); |
927 | 998 | } |
928 | 999 | return $this->index(); |
@@ -988,7 +1059,9 @@ discard block |
||
988 | 1059 | { |
989 | 1060 | Api\Config::save_value($key, $value, 'importexport'); |
990 | 1061 | } |
991 | - } elseif (isset($content['cancel'])) { |
|
1062 | + } |
|
1063 | + elseif (isset($content['cancel'])) |
|
1064 | + { |
|
992 | 1065 | $GLOBALS['egw']->redirect_link('/admin/index.php'); |
993 | 1066 | } |
994 | 1067 | |
@@ -1002,7 +1075,10 @@ discard block |
||
1002 | 1075 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
1003 | 1076 | } |
1004 | 1077 | |
1005 | - if(!$data['update']) $data['update'] = 'request'; |
|
1078 | + if(!$data['update']) |
|
1079 | + { |
|
1080 | + $data['update'] = 'request'; |
|
1081 | + } |
|
1006 | 1082 | |
1007 | 1083 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
1008 | 1084 | $etpl = new etemplate(self::_appname.'.config'); |
@@ -940,7 +940,7 @@ |
||
940 | 940 | * Determine if the user is allowed to edit the definition |
941 | 941 | * |
942 | 942 | */ |
943 | - protected function can_edit(Array $definition) |
|
943 | + protected function can_edit(array $definition) |
|
944 | 944 | { |
945 | 945 | if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
946 | 946 | { |