@@ -91,7 +91,7 @@ |
||
91 | 91 | /** |
92 | 92 | * Entries for filemanagers's admin menu |
93 | 93 | * |
94 | - * @param string|array $location ='admin' hook name or params |
|
94 | + * @param string $location ='admin' hook name or params |
|
95 | 95 | */ |
96 | 96 | static function admin($location = 'admin') |
97 | 97 | { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ); |
106 | 106 | if ($location == 'admin') |
107 | 107 | { |
108 | - display_section(self::$appname,$file); |
|
108 | + display_section(self::$appname,$file); |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'yes' => lang('Yes') |
129 | 129 | ); |
130 | 130 | |
131 | - $settings = array( |
|
131 | + $settings = array( |
|
132 | 132 | 'startfolder' => array( |
133 | 133 | 'type' => 'input', |
134 | 134 | 'name' => 'startfolder', |
@@ -85,7 +85,10 @@ discard block |
||
85 | 85 | $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
86 | 86 | display_sidebox(self::$appname,$title,$file); |
87 | 87 | } |
88 | - if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
|
88 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
89 | + { |
|
90 | + self::admin(self::$appname); |
|
91 | + } |
|
89 | 92 | } |
90 | 93 | |
91 | 94 | /** |
@@ -95,7 +98,10 @@ discard block |
||
95 | 98 | */ |
96 | 99 | static function admin($location = 'admin') |
97 | 100 | { |
98 | - if (is_array($location)) $location = $location['location']; |
|
101 | + if (is_array($location)) |
|
102 | + { |
|
103 | + $location = $location['location']; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | $file = Array( |
101 | 107 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | $basepath = '/home'; |
37 | 37 | $homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
38 | 38 | //echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n"; |
39 | - $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
39 | + $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
40 | 40 | if ($location == 'sidebox_menu') |
41 | 41 | { |
42 | - $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu'); |
|
42 | + $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu'); |
|
43 | 43 | $file = array(); |
44 | - if($GLOBALS['egw_info']['apps']['stylite']) |
|
44 | + if ($GLOBALS['egw_info']['apps']['stylite']) |
|
45 | 45 | { |
46 | 46 | // add "file a file" (upload) dialog |
47 | 47 | $file[] = array( |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | // add selection for available views, if we have more then one |
55 | 55 | if (count(filemanager_ui::init_views()) > 1) |
56 | 56 | { |
57 | - $index_url = Egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false); |
|
57 | + $index_url = Egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false); |
|
58 | 58 | $file[] = array( |
59 | - 'text' => Api\Html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false, |
|
59 | + 'text' => Api\Html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false, |
|
60 | 60 | ' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;". |
61 | 61 | '" style="width: 100%;"'), |
62 | 62 | 'no_lang' => True, |
@@ -65,23 +65,23 @@ discard block |
||
65 | 65 | } |
66 | 66 | if ($file_prefs['showhome'] != 'no') |
67 | 67 | { |
68 | - $file['Your home directory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true')); |
|
68 | + $file['Your home directory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true')); |
|
69 | 69 | } |
70 | 70 | if ($file_prefs['showusers'] != 'no') |
71 | 71 | { |
72 | - $file['Users and groups'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true')); |
|
72 | + $file['Users and groups'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true')); |
|
73 | 73 | } |
74 | - if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes') |
|
74 | + if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes') |
|
75 | 75 | { |
76 | - $file['Basedirectory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true')); |
|
76 | + $file['Basedirectory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true')); |
|
77 | 77 | } |
78 | 78 | if (!empty($file_prefs['startfolder'])) |
79 | 79 | { |
80 | - $file['Startfolder']= Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true')); |
|
80 | + $file['Startfolder'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true')); |
|
81 | 81 | } |
82 | - $file['Placeholders'] = Egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements'); |
|
83 | - $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
84 | - display_sidebox(self::$appname,$title,$file); |
|
82 | + $file['Placeholders'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements'); |
|
83 | + $file['Shared files'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
84 | + display_sidebox(self::$appname, $title, $file); |
|
85 | 85 | } |
86 | 86 | if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
87 | 87 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | |
98 | 98 | $file = Array( |
99 | 99 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
100 | - 'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
|
101 | - 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
|
100 | + 'Custom fields' => Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
|
101 | + 'Check virtual filesystem' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'), |
|
102 | 102 | 'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'), |
103 | 103 | ); |
104 | 104 | if ($location == 'admin') |
105 | 105 | { |
106 | - display_section(self::$appname,$file); |
|
106 | + display_section(self::$appname, $file); |
|
107 | 107 | } |
108 | 108 | else |
109 | 109 | { |
110 | - display_sidebox(self::$appname,lang('Admin'),$file); |
|
110 | + display_sidebox(self::$appname, lang('Admin'), $file); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'type' => 'select', |
151 | 151 | 'name' => 'showhome', |
152 | 152 | 'values' => $yes_no, |
153 | - 'label' => lang('Show link "%1" in side box menu?',lang('Your home directory')), |
|
153 | + 'label' => lang('Show link "%1" in side box menu?', lang('Your home directory')), |
|
154 | 154 | 'xmlrpc' => True, |
155 | 155 | 'admin' => False, |
156 | 156 | 'forced' => 'yes', |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'type' => 'select', |
160 | 160 | 'name' => 'showusers', |
161 | 161 | 'values' => $yes_no, |
162 | - 'label' => lang('Show link "%1" in side box menu?',lang('Users and groups')), |
|
162 | + 'label' => lang('Show link "%1" in side box menu?', lang('Users and groups')), |
|
163 | 163 | 'xmlrpc' => True, |
164 | 164 | 'admin' => False, |
165 | 165 | 'forced' => 'yes', |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | 'size' => 60, |
172 | 172 | 'label' => 'Default document to insert entries', |
173 | 173 | 'name' => 'default_document', |
174 | - 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '. |
|
174 | + 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '. |
|
175 | 175 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
176 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
176 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
177 | 177 | 'run_lang' => false, |
178 | 178 | 'xmlrpc' => True, |
179 | 179 | 'admin' => False, |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | 'label' => 'Directory with documents to insert entries', |
185 | 185 | 'name' => 'document_dir', |
186 | 186 | 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '. |
187 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '. |
|
188 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
187 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
|
188 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
189 | 189 | 'run_lang' => false, |
190 | 190 | 'xmlrpc' => True, |
191 | 191 | 'admin' => False, |
@@ -95,7 +95,7 @@ |
||
95 | 95 | { |
96 | 96 | if (is_array($location)) $location = $location['location']; |
97 | 97 | |
98 | - $file = Array( |
|
98 | + $file = array( |
|
99 | 99 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
100 | 100 | 'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
101 | 101 | 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
@@ -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) |
@@ -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 | } |
@@ -88,7 +88,10 @@ discard block |
||
88 | 88 | // search for plugins with additional filemanager views |
89 | 89 | foreach(Api\Hooks::process('filemanager_views') as $views) |
90 | 90 | { |
91 | - if (is_array($views)) static::$views += $views; |
|
91 | + if (is_array($views)) |
|
92 | + { |
|
93 | + static::$views += $views; |
|
94 | + } |
|
92 | 95 | } |
93 | 96 | static::$views_init = true; |
94 | 97 | } |
@@ -362,7 +365,10 @@ discard block |
||
362 | 365 | $content['nm']['home_dir'] = static::get_home_dir(); |
363 | 366 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
364 | 367 | |
365 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
368 | + if (isset($_GET['msg'])) |
|
369 | + { |
|
370 | + $msg = $_GET['msg']; |
|
371 | + } |
|
366 | 372 | |
367 | 373 | // Blank favorite set via GET needs special handling for path |
368 | 374 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -396,7 +402,10 @@ discard block |
||
396 | 402 | // reset lettersearch as it confuses users (they think the dir is empty) |
397 | 403 | $content['nm']['searchletter'] = false; |
398 | 404 | // switch recusive display off |
399 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
405 | + if (!$content['nm']['filter']) |
|
406 | + { |
|
407 | + $content['nm']['filter'] = ''; |
|
408 | + } |
|
400 | 409 | } |
401 | 410 | } |
402 | 411 | $view = static::get_view(); |
@@ -445,37 +454,70 @@ discard block |
||
445 | 454 | { |
446 | 455 | $tpl = new Etemplate('filemanager.index'); |
447 | 456 | |
448 | - if($msg) Framework::message($msg); |
|
457 | + if($msg) |
|
458 | + { |
|
459 | + Framework::message($msg); |
|
460 | + } |
|
449 | 461 | |
450 | 462 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
451 | 463 | { |
452 | 464 | if ($content['nm']['action']) |
453 | 465 | { |
454 | 466 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
455 | - if($msg) Framework::message($msg); |
|
467 | + if($msg) |
|
468 | + { |
|
469 | + Framework::message($msg); |
|
470 | + } |
|
456 | 471 | |
457 | 472 | // clean up after action |
458 | 473 | unset($content['nm']['selected']); |
459 | 474 | // 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 |
460 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
461 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
462 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
475 | + if (isset($content['nm']['action'])) |
|
476 | + { |
|
477 | + unset($content['nm']['action']); |
|
478 | + } |
|
479 | + if (isset($content['nm']['nm_action'])) |
|
480 | + { |
|
481 | + unset($content['nm']['nm_action']); |
|
482 | + } |
|
483 | + if (isset($content['nm_action'])) |
|
484 | + { |
|
485 | + unset($content['nm_action']); |
|
486 | + } |
|
463 | 487 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
464 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
488 | + if (isset($content['nm']['rows']['delete'])) |
|
489 | + { |
|
490 | + unset($content['nm']['rows']['delete']); |
|
491 | + } |
|
465 | 492 | } |
466 | 493 | elseif($content['nm']['rows']['delete']) |
467 | 494 | { |
468 | 495 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
469 | - if($msg) Framework::message($msg); |
|
496 | + if($msg) |
|
497 | + { |
|
498 | + Framework::message($msg); |
|
499 | + } |
|
470 | 500 | |
471 | 501 | // clean up after action |
472 | 502 | unset($content['nm']['rows']['delete']); |
473 | 503 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
474 | 504 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
475 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
476 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
477 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
478 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
505 | + if (isset($content['nm']['action'])) |
|
506 | + { |
|
507 | + unset($content['nm']['action']); |
|
508 | + } |
|
509 | + if (isset($content['nm']['nm_action'])) |
|
510 | + { |
|
511 | + unset($content['nm']['nm_action']); |
|
512 | + } |
|
513 | + if (isset($content['nm_action'])) |
|
514 | + { |
|
515 | + unset($content['nm_action']); |
|
516 | + } |
|
517 | + if (isset($content['nm']['selected'])) |
|
518 | + { |
|
519 | + unset($content['nm']['selected']); |
|
520 | + } |
|
479 | 521 | } |
480 | 522 | unset($content['nm']['rows']); |
481 | 523 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -639,9 +681,12 @@ discard block |
||
639 | 681 | foreach(Vfs::find($path) as $p) |
640 | 682 | { |
641 | 683 | $to = $dir.substr($p,$len); |
642 | - if ($to == $p) // cant copy into itself! |
|
684 | + if ($to == $p) |
|
685 | + { |
|
686 | + // cant copy into itself! |
|
643 | 687 | { |
644 | 688 | ++$errs; |
689 | + } |
|
645 | 690 | continue; |
646 | 691 | } |
647 | 692 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -696,7 +741,10 @@ discard block |
||
696 | 741 | continue; |
697 | 742 | } |
698 | 743 | } |
699 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
744 | + if ($target[0] != '/') |
|
745 | + { |
|
746 | + $target = Vfs::concat($dir, $target); |
|
747 | + } |
|
700 | 748 | if (!Vfs::stat($target)) |
701 | 749 | { |
702 | 750 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -739,10 +787,16 @@ discard block |
||
739 | 787 | switch($action) |
740 | 788 | { |
741 | 789 | case 'document': |
742 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
790 | + if (!$settings) |
|
791 | + { |
|
792 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
793 | + } |
|
743 | 794 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
744 | 795 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
745 | - if($msg) return $msg; |
|
796 | + if($msg) |
|
797 | + { |
|
798 | + return $msg; |
|
799 | + } |
|
746 | 800 | $errs = count($selected); |
747 | 801 | return false; |
748 | 802 | } |
@@ -779,7 +833,9 @@ discard block |
||
779 | 833 | unset($selected[$key]); |
780 | 834 | } |
781 | 835 | } |
782 | - if ($selected) // somethings left to delete |
|
836 | + if ($selected) |
|
837 | + { |
|
838 | + // somethings left to delete |
|
783 | 839 | { |
784 | 840 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
785 | 841 | foreach((array)$selected as $path) |
@@ -787,6 +843,7 @@ discard block |
||
787 | 843 | if (Vfs::isProtectedDir($path)) |
788 | 844 | { |
789 | 845 | $errs++; |
846 | + } |
|
790 | 847 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
791 | 848 | } |
792 | 849 | } |
@@ -835,7 +892,10 @@ discard block |
||
835 | 892 | Api\Cache::setSession('filemanager', 'index', |
836 | 893 | array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
837 | 894 | } |
838 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
895 | + if(!$query['path']) |
|
896 | + { |
|
897 | + $query['path'] = static::get_home_dir(); |
|
898 | + } |
|
839 | 899 | |
840 | 900 | // Change template to match selected view |
841 | 901 | if($query['view']) |
@@ -893,7 +953,10 @@ discard block |
||
893 | 953 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
894 | 954 | |
895 | 955 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
896 | - if($filter == 5) $maxdepth = 2; |
|
956 | + if($filter == 5) |
|
957 | + { |
|
958 | + $maxdepth = 2; |
|
959 | + } |
|
897 | 960 | $n = 0; |
898 | 961 | $vfs_options = array( |
899 | 962 | 'mindepth' => 1, |
@@ -955,10 +1018,16 @@ discard block |
||
955 | 1018 | { |
956 | 1019 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
957 | 1020 | $row =& $rows[$path2n[$path]]; |
958 | - if ( !is_array($props) ) continue; |
|
1021 | + if ( !is_array($props) ) |
|
1022 | + { |
|
1023 | + continue; |
|
1024 | + } |
|
959 | 1025 | foreach($props as $prop) |
960 | 1026 | { |
961 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
1027 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
1028 | + { |
|
1029 | + continue; |
|
1030 | + } |
|
962 | 1031 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
963 | 1032 | } |
964 | 1033 | } |
@@ -1083,7 +1152,10 @@ discard block |
||
1083 | 1152 | if (!($dir = Vfs::dirname($path))) |
1084 | 1153 | { |
1085 | 1154 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
1086 | - if ($button == 'save') $button = 'apply'; |
|
1155 | + if ($button == 'save') |
|
1156 | + { |
|
1157 | + $button = 'apply'; |
|
1158 | + } |
|
1087 | 1159 | continue; |
1088 | 1160 | } |
1089 | 1161 | $to = Vfs::concat($dir, $content['name']); |
@@ -1092,7 +1164,10 @@ discard block |
||
1092 | 1164 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
1093 | 1165 | lang('To overwrite the existing file store again.',lang($button))); |
1094 | 1166 | $content['confirm_overwrite'] = $to; |
1095 | - if ($button == 'save') $button = 'apply'; |
|
1167 | + if ($button == 'save') |
|
1168 | + { |
|
1169 | + $button = 'apply'; |
|
1170 | + } |
|
1096 | 1171 | continue; |
1097 | 1172 | } |
1098 | 1173 | if (Vfs::rename($path,$to)) |
@@ -1165,13 +1240,19 @@ discard block |
||
1165 | 1240 | } |
1166 | 1241 | if ($ok && !$failed) |
1167 | 1242 | { |
1168 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1243 | + if(!$perm_changed++) |
|
1244 | + { |
|
1245 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1246 | + } |
|
1169 | 1247 | $content['old'][$name] = $content[$name]; |
1170 | 1248 | } |
1171 | 1249 | elseif($failed) |
1172 | 1250 | { |
1173 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1251 | + if(!$perm_failed++) |
|
1252 | + { |
|
1253 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1174 | 1254 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
1255 | + } |
|
1175 | 1256 | } |
1176 | 1257 | } |
1177 | 1258 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1224,7 +1305,10 @@ discard block |
||
1224 | 1305 | } |
1225 | 1306 | } |
1226 | 1307 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
1227 | - if ($button == 'save') Framework::window_close(); |
|
1308 | + if ($button == 'save') |
|
1309 | + { |
|
1310 | + Framework::window_close(); |
|
1311 | + } |
|
1228 | 1312 | } |
1229 | 1313 | if ($content['is_link'] && !Vfs::stat($path)) |
1230 | 1314 | { |
@@ -1234,12 +1318,18 @@ discard block |
||
1234 | 1318 | $content['icon'] = Vfs::mime_icon($content['mime']); |
1235 | 1319 | $content['msg'] = $msg; |
1236 | 1320 | |
1237 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
1321 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
1322 | + { |
|
1323 | + $content['ro_uid_root'] = 'root'; |
|
1324 | + } |
|
1238 | 1325 | // only owner can change group & perms |
1239 | 1326 | if (($readonlys['gid'] = !$content['is_owner'] || |
1240 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1327 | + Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) |
|
1328 | + { |
|
1329 | + // no uid, gid or perms in oldvfs |
|
1241 | 1330 | { |
1242 | 1331 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1332 | + } |
|
1243 | 1333 | foreach($content['perms'] as $name => $value) |
1244 | 1334 | { |
1245 | 1335 | $readonlys['perms['.$name.']'] = true; |
@@ -1272,9 +1362,13 @@ discard block |
||
1272 | 1362 | 5 => lang('Display of content'), |
1273 | 1363 | 0 => lang('No access'), |
1274 | 1364 | ); |
1275 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1365 | + if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) |
|
1276 | 1366 | { |
1277 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1367 | + // backend supports eacl |
|
1368 | + { |
|
1369 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
1370 | + } |
|
1371 | + // --> switch the tab on again |
|
1278 | 1372 | foreach($content['eacl'] as &$eacl) |
1279 | 1373 | { |
1280 | 1374 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1331,10 +1425,13 @@ discard block |
||
1331 | 1425 | 'comment' => (string)$content['comment'], |
1332 | 1426 | 'mergeapp' => $content['mergeapp'] |
1333 | 1427 | ); |
1334 | - if ($cfs) foreach($cfs as $name => $data) |
|
1428 | + if ($cfs) |
|
1429 | + { |
|
1430 | + foreach($cfs as $name => $data) |
|
1335 | 1431 | { |
1336 | 1432 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1337 | 1433 | } |
1434 | + } |
|
1338 | 1435 | } |
1339 | 1436 | if (Vfs::$is_root) |
1340 | 1437 | { |
@@ -1356,7 +1453,10 @@ discard block |
||
1356 | 1453 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1357 | 1454 | |
1358 | 1455 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
1359 | - if (true) $tabs = array(); |
|
1456 | + if (true) |
|
1457 | + { |
|
1458 | + $tabs = array(); |
|
1459 | + } |
|
1360 | 1460 | |
1361 | 1461 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
1362 | 1462 | { |
@@ -1409,7 +1509,10 @@ discard block |
||
1409 | 1509 | 'files' => 0, |
1410 | 1510 | ); |
1411 | 1511 | |
1412 | - if (!isset($dir)) $dir = array_pop($selected); |
|
1512 | + if (!isset($dir)) |
|
1513 | + { |
|
1514 | + $dir = array_pop($selected); |
|
1515 | + } |
|
1413 | 1516 | |
1414 | 1517 | switch($action) |
1415 | 1518 | { |
@@ -1483,7 +1586,10 @@ discard block |
||
1483 | 1586 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
1484 | 1587 | if (Vfs::file_exists($target) && $app_dir) |
1485 | 1588 | { |
1486 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
1589 | + if (!Vfs::file_exists($app_dir)) |
|
1590 | + { |
|
1591 | + Vfs::mkdir($app_dir); |
|
1592 | + } |
|
1487 | 1593 | error_log("Symlinking $target to $app_dir"); |
1488 | 1594 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
1489 | 1595 | } |
@@ -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( |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ), |
209 | 209 | // DRAG and DROP events |
210 | 210 | 'file_drag' => array( |
211 | - 'dragType' => array('file','link'), |
|
211 | + 'dragType' => array('file', 'link'), |
|
212 | 212 | 'type' => 'drag', |
213 | 213 | 'onExecute' => 'javaScript:app.filemanager.drag' |
214 | 214 | ), |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
250 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
251 | 251 | { |
252 | 252 | $actions['mail']['children']['mail_'.$mode] = array( |
253 | 253 | 'caption' => $data['label'], |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | // This would be done automatically, but we're overriding |
261 | - foreach($actions as $action_id => $action) |
|
261 | + foreach ($actions as $action_id => $action) |
|
262 | 262 | { |
263 | - if($action['type'] == 'drop' && $action['caption']) |
|
263 | + if ($action['type'] == 'drop' && $action['caption']) |
|
264 | 264 | { |
265 | 265 | $action['type'] = 'popup'; |
266 | - if($action['acceptedTypes'] == 'file') |
|
266 | + if ($action['acceptedTypes'] == 'file') |
|
267 | 267 | { |
268 | 268 | $action['enabled'] = 'javaScript:app.filemanager.paste_enabled'; |
269 | 269 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return string merge application or NULL if no property found |
285 | 285 | */ |
286 | - private static function get_mergeapp($path, $scope='self') |
|
286 | + private static function get_mergeapp($path, $scope = 'self') |
|
287 | 287 | { |
288 | 288 | $app = null; |
289 | - switch($scope) |
|
289 | + switch ($scope) |
|
290 | 290 | { |
291 | 291 | case 'self': |
292 | 292 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | case 'parents': |
296 | 296 | // search for props in parent directories |
297 | 297 | $currentpath = $path; |
298 | - while($dir = Vfs::dirname($currentpath)) |
|
298 | + while ($dir = Vfs::dirname($currentpath)) |
|
299 | 299 | { |
300 | 300 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
301 | - if(!empty($props)) |
|
301 | + if (!empty($props)) |
|
302 | 302 | { |
303 | 303 | // found prop in parent directory |
304 | 304 | return $app = $props[0]['val']; |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param array $content |
318 | 318 | * @param string $msg |
319 | 319 | */ |
320 | - function index(array $content=null,$msg=null) |
|
320 | + function index(array $content = null, $msg = null) |
|
321 | 321 | { |
322 | 322 | if (!is_array($content)) |
323 | 323 | { |
@@ -327,16 +327,16 @@ discard block |
||
327 | 327 | if (!is_array($content['nm'])) |
328 | 328 | { |
329 | 329 | $content['nm'] = array( |
330 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
331 | - 'filter' => '', // current dir only |
|
332 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
333 | - 'no_cat' => True, // I disable the cat-selectbox |
|
334 | - 'lettersearch' => True, // I show a lettersearch |
|
335 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
336 | - 'start' => 0, // IO position in list |
|
337 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
338 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
339 | - '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 |
|
330 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
331 | + 'filter' => '', // current dir only |
|
332 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
333 | + 'no_cat' => True, // I disable the cat-selectbox |
|
334 | + 'lettersearch' => True, // I show a lettersearch |
|
335 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
336 | + 'start' => 0, // IO position in list |
|
337 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
338 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
339 | + '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 |
|
340 | 340 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
341 | 341 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
342 | 342 | 'row_id' => 'path', |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | 'parent_id' => 'dir', |
345 | 345 | 'is_parent' => 'is_dir', |
346 | 346 | 'favorites' => true, |
347 | - 'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
347 | + 'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
348 | 348 | ); |
349 | 349 | $content['nm']['path'] = static::get_home_dir(); |
350 | 350 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | } |
367 | 367 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
368 | 368 | { |
369 | - switch($path) |
|
369 | + switch ($path) |
|
370 | 370 | { |
371 | 371 | case '..': |
372 | 372 | $path = Vfs::dirname($content['nm']['path']); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $path = static::get_home_dir(); |
376 | 376 | break; |
377 | 377 | } |
378 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
378 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
379 | 379 | { |
380 | 380 | $content['nm']['path'] = $path; |
381 | 381 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | } |
392 | 392 | $view = static::get_view(); |
393 | 393 | |
394 | - call_user_func($view,$content,$msg); |
|
394 | + call_user_func($view, $content, $msg); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
405 | 405 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
406 | 406 | */ |
407 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
407 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
408 | 408 | { |
409 | 409 | if (!$user) |
410 | 410 | { |
@@ -413,15 +413,15 @@ discard block |
||
413 | 413 | else |
414 | 414 | { |
415 | 415 | // config user & password |
416 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
416 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
417 | 417 | // or vfs root user from setup >> configuration |
418 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
419 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
418 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
419 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
420 | 420 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
421 | 421 | } |
422 | 422 | //error_log(__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)); |
423 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
424 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
423 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
424 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
425 | 425 | return Vfs::$is_root; |
426 | 426 | } |
427 | 427 | |
@@ -431,18 +431,18 @@ discard block |
||
431 | 431 | * @param array $content |
432 | 432 | * @param string $msg |
433 | 433 | */ |
434 | - function listview(array $content=null,$msg=null) |
|
434 | + function listview(array $content = null, $msg = null) |
|
435 | 435 | { |
436 | 436 | $tpl = new Etemplate('filemanager.index'); |
437 | 437 | |
438 | - if($msg) Framework::message($msg); |
|
438 | + if ($msg) Framework::message($msg); |
|
439 | 439 | |
440 | 440 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
441 | 441 | { |
442 | 442 | if ($content['nm']['action']) |
443 | 443 | { |
444 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
445 | - if($msg) Framework::message($msg); |
|
444 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
445 | + if ($msg) Framework::message($msg); |
|
446 | 446 | |
447 | 447 | // clean up after action |
448 | 448 | unset($content['nm']['selected']); |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
454 | 454 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
455 | 455 | } |
456 | - elseif($content['nm']['rows']['delete']) |
|
456 | + elseif ($content['nm']['rows']['delete']) |
|
457 | 457 | { |
458 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
459 | - if($msg) Framework::message($msg); |
|
458 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
459 | + if ($msg) Framework::message($msg); |
|
460 | 460 | |
461 | 461 | // clean up after action |
462 | 462 | unset($content['nm']['rows']['delete']); |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
469 | 469 | } |
470 | 470 | unset($content['nm']['rows']); |
471 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
471 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | // be tolerant with (in previous versions) not correct urlencoded pathes |
475 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
475 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
476 | 476 | { |
477 | 477 | $content['nm']['path'] = urldecode($content['nm']['path']); |
478 | 478 | } |
@@ -483,22 +483,22 @@ discard block |
||
483 | 483 | list($button) = each($content['button']); |
484 | 484 | unset($content['button']); |
485 | 485 | } |
486 | - switch($button) |
|
486 | + switch ($button) |
|
487 | 487 | { |
488 | 488 | case 'upload': |
489 | 489 | if (!$content['upload']) |
490 | 490 | { |
491 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
491 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
492 | 492 | break; |
493 | 493 | } |
494 | 494 | $upload_success = $upload_failure = array(); |
495 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
495 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
496 | 496 | { |
497 | 497 | // encode chars which special meaning in url/vfs (some like / get removed!) |
498 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
498 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
499 | 499 | if ($upload && |
500 | 500 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
501 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
501 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
502 | 502 | { |
503 | 503 | $upload_success[] = $upload['name']; |
504 | 504 | } |
@@ -510,12 +510,11 @@ discard block |
||
510 | 510 | $content['nm']['msg'] = ''; |
511 | 511 | if ($upload_success) |
512 | 512 | { |
513 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
514 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
513 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
515 | 514 | } |
516 | 515 | if ($upload_failure) |
517 | 516 | { |
518 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
517 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
519 | 518 | } |
520 | 519 | break; |
521 | 520 | } |
@@ -536,16 +535,16 @@ discard block |
||
536 | 535 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
537 | 536 | } |
538 | 537 | // Set view button to match current settings |
539 | - if($content['nm']['view'] == 'tile') |
|
538 | + if ($content['nm']['view'] == 'tile') |
|
540 | 539 | { |
541 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
542 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
540 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
541 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
543 | 542 | } |
544 | 543 | // if initial load is done via GET request (idots template or share.php) |
545 | 544 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
546 | 545 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
547 | 546 | |
548 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
547 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
549 | 548 | } |
550 | 549 | |
551 | 550 | /** |
@@ -581,7 +580,7 @@ discard block |
||
581 | 580 | * @param int &$files=null on return number of files deleted |
582 | 581 | * @return string success or failure message displayed to the user |
583 | 582 | */ |
584 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
583 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
585 | 584 | { |
586 | 585 | if (!count($selected)) |
587 | 586 | { |
@@ -589,20 +588,20 @@ discard block |
||
589 | 588 | } |
590 | 589 | $errs = $dirs = $files = 0; |
591 | 590 | |
592 | - switch($action) |
|
591 | + switch ($action) |
|
593 | 592 | { |
594 | 593 | |
595 | 594 | case 'delete': |
596 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
595 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
597 | 596 | |
598 | 597 | case 'mail': |
599 | 598 | case 'copy': |
600 | - foreach($selected as $path) |
|
599 | + foreach ($selected as $path) |
|
601 | 600 | { |
602 | 601 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
603 | 602 | { |
604 | 603 | // Support for dropping mail in filemanager - Pass mail back to mail app |
605 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
604 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
606 | 605 | { |
607 | 606 | ++$files; |
608 | 607 | } |
@@ -613,8 +612,8 @@ discard block |
||
613 | 612 | } |
614 | 613 | elseif (!Vfs::is_dir($path)) |
615 | 614 | { |
616 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
617 | - if ($path != $to && Vfs::copy($path,$to)) |
|
615 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
616 | + if ($path != $to && Vfs::copy($path, $to)) |
|
618 | 617 | { |
619 | 618 | ++$files; |
620 | 619 | } |
@@ -626,19 +625,19 @@ discard block |
||
626 | 625 | else |
627 | 626 | { |
628 | 627 | $len = strlen(dirname($path)); |
629 | - foreach(Vfs::find($path) as $p) |
|
628 | + foreach (Vfs::find($path) as $p) |
|
630 | 629 | { |
631 | - $to = $dir.substr($p,$len); |
|
630 | + $to = $dir.substr($p, $len); |
|
632 | 631 | if ($to == $p) // cant copy into itself! |
633 | 632 | { |
634 | 633 | ++$errs; |
635 | 634 | continue; |
636 | 635 | } |
637 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
636 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
638 | 637 | { |
639 | 638 | ++$dirs; |
640 | 639 | } |
641 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
640 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
642 | 641 | { |
643 | 642 | ++$files; |
644 | 643 | } |
@@ -651,15 +650,15 @@ discard block |
||
651 | 650 | } |
652 | 651 | if ($errs) |
653 | 652 | { |
654 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
653 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
655 | 654 | } |
656 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
655 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
657 | 656 | |
658 | 657 | case 'move': |
659 | - foreach($selected as $path) |
|
658 | + foreach ($selected as $path) |
|
660 | 659 | { |
661 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
662 | - if ($path != $to && Vfs::rename($path,$to)) |
|
660 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
661 | + if ($path != $to && Vfs::rename($path, $to)) |
|
663 | 662 | { |
664 | 663 | ++$files; |
665 | 664 | } |
@@ -670,17 +669,17 @@ discard block |
||
670 | 669 | } |
671 | 670 | if ($errs) |
672 | 671 | { |
673 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
672 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
674 | 673 | } |
675 | - return lang('%1 files moved.',$files); |
|
674 | + return lang('%1 files moved.', $files); |
|
676 | 675 | |
677 | 676 | case 'symlink': // symlink given files to $dir |
678 | - foreach((array)$selected as $target) |
|
677 | + foreach ((array)$selected as $target) |
|
679 | 678 | { |
680 | 679 | $link = Vfs::concat($dir, Vfs::basename($target)); |
681 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
680 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
682 | 681 | { |
683 | - if(!$ok) |
|
682 | + if (!$ok) |
|
684 | 683 | { |
685 | 684 | $errs++; |
686 | 685 | continue; |
@@ -702,15 +701,14 @@ discard block |
||
702 | 701 | } |
703 | 702 | if (count((array)$selected) == 1) |
704 | 703 | { |
705 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
706 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
704 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
707 | 705 | } |
708 | 706 | $ret = lang('%1 elements linked.', $files); |
709 | 707 | if ($errs) |
710 | 708 | { |
711 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
709 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
712 | 710 | } |
713 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
711 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
714 | 712 | |
715 | 713 | case 'createdir': |
716 | 714 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -726,13 +724,13 @@ discard block |
||
726 | 724 | |
727 | 725 | default: |
728 | 726 | list($action, $settings) = explode('_', $action, 2); |
729 | - switch($action) |
|
727 | + switch ($action) |
|
730 | 728 | { |
731 | 729 | case 'document': |
732 | 730 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
733 | 731 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
734 | 732 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
735 | - if($msg) return $msg; |
|
733 | + if ($msg) return $msg; |
|
736 | 734 | $errs = count($selected); |
737 | 735 | return false; |
738 | 736 | } |
@@ -749,12 +747,12 @@ discard block |
||
749 | 747 | * @param int &$files=null on return number of files deleted |
750 | 748 | * @return string |
751 | 749 | */ |
752 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
750 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
753 | 751 | { |
754 | 752 | $dirs = $files = $errs = 0; |
755 | 753 | // we first delete all selected links (and files) |
756 | 754 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
757 | - foreach($selected as $key => $path) |
|
755 | + foreach ($selected as $key => $path) |
|
758 | 756 | { |
759 | 757 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
760 | 758 | { |
@@ -772,21 +770,21 @@ discard block |
||
772 | 770 | if ($selected) // somethings left to delete |
773 | 771 | { |
774 | 772 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
775 | - foreach((array)$selected as $path) |
|
773 | + foreach ((array)$selected as $path) |
|
776 | 774 | { |
777 | 775 | if (Vfs::isProtectedDir($path)) |
778 | 776 | { |
779 | 777 | $errs++; |
780 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
778 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
781 | 779 | } |
782 | 780 | } |
783 | 781 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
784 | 782 | // - depth=true to get first the files and then the dir containing it |
785 | 783 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
786 | 784 | // - show-deleted=false to not (finally) deleted versioned files |
787 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
785 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
788 | 786 | { |
789 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
787 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
790 | 788 | { |
791 | 789 | ++$dirs; |
792 | 790 | } |
@@ -802,13 +800,13 @@ discard block |
||
802 | 800 | } |
803 | 801 | if ($errs) |
804 | 802 | { |
805 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
803 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
806 | 804 | } |
807 | 805 | if ($dirs) |
808 | 806 | { |
809 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
807 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
810 | 808 | } |
811 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
809 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
812 | 810 | } |
813 | 811 | |
814 | 812 | /** |
@@ -823,37 +821,37 @@ discard block |
||
823 | 821 | if (!$query['csv_export']) |
824 | 822 | { |
825 | 823 | Api\Cache::setSession('filemanager', 'index', |
826 | - array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
|
824 | + array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
827 | 825 | } |
828 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
826 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
829 | 827 | |
830 | 828 | // Change template to match selected view |
831 | - if($query['view']) |
|
829 | + if ($query['view']) |
|
832 | 830 | { |
833 | 831 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
834 | 832 | |
835 | 833 | // Store as preference but only for index, not home |
836 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
834 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
837 | 835 | { |
838 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
836 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
839 | 837 | $GLOBALS['egw']->preferences->save_repository(); |
840 | 838 | } |
841 | 839 | } |
842 | 840 | // be tolerant with (in previous versions) not correct urlencoded pathes |
843 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
841 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
844 | 842 | { |
845 | 843 | $query['path'] = urldecode($query['path']); |
846 | 844 | } |
847 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
845 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
848 | 846 | { |
849 | 847 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
850 | 848 | if ($query['path'] != ($path = static::get_home_dir())) |
851 | 849 | { |
852 | 850 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
853 | 851 | // an appropriate message |
854 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
852 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
855 | 853 | 'path' => $path, |
856 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
854 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
857 | 855 | 'ajax' => 'true' |
858 | 856 | )); |
859 | 857 | } |
@@ -861,35 +859,35 @@ discard block |
||
861 | 859 | return 0; |
862 | 860 | } |
863 | 861 | $rows = $dir_is_writable = array(); |
864 | - if($query['searchletter'] && !empty($query['search'])) |
|
862 | + if ($query['searchletter'] && !empty($query['search'])) |
|
865 | 863 | { |
866 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
864 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
867 | 865 | if ($query['searchletter'] == strtolower($query['search'][0])) |
868 | 866 | { |
869 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
870 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
867 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
868 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
871 | 869 | } |
872 | 870 | } |
873 | 871 | elseif ($query['searchletter']) |
874 | 872 | { |
875 | 873 | $namefilter = '/^'.$query['searchletter'].'/i'; |
876 | 874 | } |
877 | - elseif(!empty($query['search'])) |
|
875 | + elseif (!empty($query['search'])) |
|
878 | 876 | { |
879 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
877 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
880 | 878 | } |
881 | 879 | |
882 | 880 | // Re-map so 'No filters' favorite ('') is depth 1 |
883 | 881 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
884 | 882 | |
885 | 883 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
886 | - if($filter == 5) $maxdepth = 2; |
|
884 | + if ($filter == 5) $maxdepth = 2; |
|
887 | 885 | $n = 0; |
888 | 886 | $vfs_options = array( |
889 | 887 | 'mindepth' => 1, |
890 | 888 | 'maxdepth' => $maxdepth, |
891 | 889 | 'dirsontop' => $filter <= 1, |
892 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
890 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
893 | 891 | 'order' => $query['order'], 'sort' => $query['sort'], |
894 | 892 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
895 | 893 | 'need_mime' => true, |
@@ -897,11 +895,11 @@ discard block |
||
897 | 895 | 'hidden' => $filter == 3, |
898 | 896 | 'follow' => $filter == 5, |
899 | 897 | ); |
900 | - if($query['col_filter']['mime']) |
|
898 | + if ($query['col_filter']['mime']) |
|
901 | 899 | { |
902 | 900 | $vfs_options['mime'] = $query['col_filter']['mime']; |
903 | 901 | } |
904 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
902 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
905 | 903 | { |
906 | 904 | //echo $path; _debug_array($row); |
907 | 905 | |
@@ -916,7 +914,7 @@ discard block |
||
916 | 914 | { |
917 | 915 | $dir_is_writable[$path] = Vfs::is_writable($path); |
918 | 916 | } |
919 | - if(!$dir_is_writable[$path]) |
|
917 | + if (!$dir_is_writable[$path]) |
|
920 | 918 | { |
921 | 919 | $row['class'] .= 'noEdit '; |
922 | 920 | } |
@@ -924,32 +922,32 @@ discard block |
||
924 | 922 | $row['is_dir'] = 1; |
925 | 923 | } |
926 | 924 | $row['download_url'] = Vfs::download_url($path); |
927 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
925 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
928 | 926 | |
929 | 927 | $rows[++$n] = $row; |
930 | 928 | $path2n[$path] = $n; |
931 | 929 | } |
932 | 930 | // query comments and cf's for the displayed rows |
933 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
931 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
934 | 932 | |
935 | 933 | // Always include comment in tiles |
936 | - if($query['view'] == 'tile') |
|
934 | + if ($query['view'] == 'tile') |
|
937 | 935 | { |
938 | 936 | $cols_to_show[] = 'comment'; |
939 | 937 | } |
940 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
941 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
938 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
939 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
942 | 940 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
943 | 941 | { |
944 | - foreach($path2props as $path => $props) |
|
942 | + foreach ($path2props as $path => $props) |
|
945 | 943 | { |
946 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
947 | - $row =& $rows[$path2n[$path]]; |
|
948 | - if ( !is_array($props) ) continue; |
|
949 | - foreach($props as $prop) |
|
944 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
945 | + $row = & $rows[$path2n[$path]]; |
|
946 | + if (!is_array($props)) continue; |
|
947 | + foreach ($props as $prop) |
|
950 | 948 | { |
951 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
952 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
949 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
950 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
953 | 951 | } |
954 | 952 | } |
955 | 953 | } |
@@ -961,7 +959,7 @@ discard block |
||
961 | 959 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
962 | 960 | { |
963 | 961 | // we need our app.css file |
964 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
962 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
965 | 963 | { |
966 | 964 | $css_file = '/filemanager/templates/default/app.css'; |
967 | 965 | } |
@@ -977,7 +975,7 @@ discard block |
||
977 | 975 | * @param array $content |
978 | 976 | * @param string $msg |
979 | 977 | */ |
980 | - function file(array $content=null,$msg='') |
|
978 | + function file(array $content = null, $msg = '') |
|
981 | 979 | { |
982 | 980 | $tpl = new Etemplate('filemanager.file'); |
983 | 981 | |
@@ -987,9 +985,9 @@ discard block |
||
987 | 985 | { |
988 | 986 | $msg .= $_GET['msg']; |
989 | 987 | } |
990 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
988 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
991 | 989 | // actions enclose pathes containing comma with " |
992 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
990 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
993 | 991 | !($stat = Vfs::lstat($path))) |
994 | 992 | { |
995 | 993 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -1002,10 +1000,10 @@ discard block |
||
1002 | 1000 | $content['path'] = $path; |
1003 | 1001 | $content['hsize'] = Vfs::hsize($stat['size']); |
1004 | 1002 | $content['mime'] = Vfs::mime_content_type($path); |
1005 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
1003 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
1006 | 1004 | if (($props = Vfs::propfind($path))) |
1007 | 1005 | { |
1008 | - foreach($props as $prop) |
|
1006 | + foreach ($props as $prop) |
|
1009 | 1007 | { |
1010 | 1008 | $content[$prop['name']] = $prop['val']; |
1011 | 1009 | } |
@@ -1018,9 +1016,9 @@ discard block |
||
1018 | 1016 | $content['tabs'] = $_GET['tabs']; |
1019 | 1017 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
1020 | 1018 | { |
1021 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
1019 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
1022 | 1020 | $mask = 6; |
1023 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
1021 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
1024 | 1022 | { |
1025 | 1023 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
1026 | 1024 | } |
@@ -1030,19 +1028,19 @@ discard block |
||
1030 | 1028 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
1031 | 1029 | $mask = 7; |
1032 | 1030 | } |
1033 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
1031 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
1034 | 1032 | { |
1035 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
1033 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
1036 | 1034 | } |
1037 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
1035 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
1038 | 1036 | } |
1039 | 1037 | else |
1040 | 1038 | { |
1041 | 1039 | //_debug_array($content); |
1042 | - $path =& $content['path']; |
|
1040 | + $path = & $content['path']; |
|
1043 | 1041 | |
1044 | 1042 | list($button) = @each($content['button']); unset($content['button']); |
1045 | - if(!$button && $content['sudo']) |
|
1043 | + if (!$button && $content['sudo']) |
|
1046 | 1044 | { |
1047 | 1045 | // Button to stop sudo is not in button namespace |
1048 | 1046 | $button = 'sudo'; |
@@ -1051,21 +1049,21 @@ discard block |
||
1051 | 1049 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
1052 | 1050 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
1053 | 1051 | { |
1054 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
1052 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
1055 | 1053 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
1056 | 1054 | lang('Wrong username or password!') : lang('Root access stopped.')); |
1057 | 1055 | unset($content['sudo']); |
1058 | 1056 | $content['is_owner'] = Vfs::has_owner_rights($path); |
1059 | 1057 | } |
1060 | - if (in_array($button,array('save','apply'))) |
|
1058 | + if (in_array($button, array('save', 'apply'))) |
|
1061 | 1059 | { |
1062 | 1060 | $props = array(); |
1063 | 1061 | $perm_changed = $perm_failed = 0; |
1064 | - foreach($content['old'] as $name => $old_value) |
|
1062 | + foreach ($content['old'] as $name => $old_value) |
|
1065 | 1063 | { |
1066 | 1064 | if (isset($content[$name]) && ($old_value != $content[$name] || |
1067 | 1065 | // do not check for modification, if modify_subs is checked! |
1068 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
1066 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
1069 | 1067 | ($name != 'uid' || Vfs::$is_root)) |
1070 | 1068 | { |
1071 | 1069 | if ($name == 'name') |
@@ -1079,23 +1077,23 @@ discard block |
||
1079 | 1077 | $to = Vfs::concat($dir, $content['name']); |
1080 | 1078 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
1081 | 1079 | { |
1082 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
1083 | - lang('To overwrite the existing file store again.',lang($button))); |
|
1080 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
1081 | + lang('To overwrite the existing file store again.', lang($button))); |
|
1084 | 1082 | $content['confirm_overwrite'] = $to; |
1085 | 1083 | if ($button == 'save') $button = 'apply'; |
1086 | 1084 | continue; |
1087 | 1085 | } |
1088 | - if (Vfs::rename($path,$to)) |
|
1086 | + if (Vfs::rename($path, $to)) |
|
1089 | 1087 | { |
1090 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1088 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1091 | 1089 | $content['old']['name'] = $content[$name]; |
1092 | 1090 | $path = $to; |
1093 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1094 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1091 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
1092 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
1095 | 1093 | } |
1096 | 1094 | else |
1097 | 1095 | { |
1098 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
1096 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
1099 | 1097 | if (Vfs::deny_script($to)) |
1100 | 1098 | { |
1101 | 1099 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1115,7 +1113,7 @@ discard block |
||
1115 | 1113 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
1116 | 1114 | ), |
1117 | 1115 | ); |
1118 | - if (Vfs::proppatch($path,$mergeprop)) |
|
1116 | + if (Vfs::proppatch($path, $mergeprop)) |
|
1119 | 1117 | { |
1120 | 1118 | $content['old'][$name] = $content[$name]; |
1121 | 1119 | $msg .= lang('Setting for document merge saved.'); |
@@ -1127,22 +1125,22 @@ discard block |
||
1127 | 1125 | } |
1128 | 1126 | else |
1129 | 1127 | { |
1130 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
1131 | - $cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]); |
|
1128 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
1129 | + $cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]); |
|
1132 | 1130 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
1133 | 1131 | if ($content['modify_subs']) |
1134 | 1132 | { |
1135 | 1133 | if ($name == 'perms') |
1136 | 1134 | { |
1137 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
1138 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
1135 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
1136 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
1139 | 1137 | } |
1140 | 1138 | else |
1141 | 1139 | { |
1142 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
1140 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
1143 | 1141 | } |
1144 | 1142 | $ok = $failed = 0; |
1145 | - foreach($changed as &$r) |
|
1143 | + foreach ($changed as &$r) |
|
1146 | 1144 | { |
1147 | 1145 | if ($r) |
1148 | 1146 | { |
@@ -1155,32 +1153,32 @@ discard block |
||
1155 | 1153 | } |
1156 | 1154 | if ($ok && !$failed) |
1157 | 1155 | { |
1158 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
1156 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
1159 | 1157 | $content['old'][$name] = $content[$name]; |
1160 | 1158 | } |
1161 | - elseif($failed) |
|
1159 | + elseif ($failed) |
|
1162 | 1160 | { |
1163 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
1164 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
1161 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
1162 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
1165 | 1163 | } |
1166 | 1164 | } |
1167 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
1165 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
1168 | 1166 | { |
1169 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
1167 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
1170 | 1168 | $content['old'][$name] = $content[$name]; |
1171 | 1169 | } |
1172 | 1170 | else |
1173 | 1171 | { |
1174 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
1172 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
1175 | 1173 | } |
1176 | 1174 | } |
1177 | 1175 | } |
1178 | 1176 | } |
1179 | 1177 | if ($props) |
1180 | 1178 | { |
1181 | - if (Vfs::proppatch($path,$props)) |
|
1179 | + if (Vfs::proppatch($path, $props)) |
|
1182 | 1180 | { |
1183 | - foreach($props as $prop) |
|
1181 | + foreach ($props as $prop) |
|
1184 | 1182 | { |
1185 | 1183 | $content['old'][$prop['name']] = $prop['val']; |
1186 | 1184 | } |
@@ -1197,8 +1195,8 @@ discard block |
||
1197 | 1195 | if ($content['eacl']['delete']) |
1198 | 1196 | { |
1199 | 1197 | list($ino_owner) = each($content['eacl']['delete']); |
1200 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
1201 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1198 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
1199 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
1202 | 1200 | } |
1203 | 1201 | elseif ($button == 'eacl') |
1204 | 1202 | { |
@@ -1208,7 +1206,7 @@ discard block |
||
1208 | 1206 | } |
1209 | 1207 | else |
1210 | 1208 | { |
1211 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
1209 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
1212 | 1210 | lang('ACL added.') : lang('Error adding the ACL!'); |
1213 | 1211 | } |
1214 | 1212 | } |
@@ -1218,7 +1216,7 @@ discard block |
||
1218 | 1216 | } |
1219 | 1217 | if ($content['is_link'] && !Vfs::stat($path)) |
1220 | 1218 | { |
1221 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
1219 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
1222 | 1220 | } |
1223 | 1221 | $content['link'] = Egw::link(Vfs::download_url($path)); |
1224 | 1222 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1227,10 +1225,10 @@ discard block |
||
1227 | 1225 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
1228 | 1226 | // only owner can change group & perms |
1229 | 1227 | if (($readonlys['gid'] = !$content['is_owner'] || |
1230 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1228 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs')) // no uid, gid or perms in oldvfs |
|
1231 | 1229 | { |
1232 | 1230 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
1233 | - foreach($content['perms'] as $name => $value) |
|
1231 | + foreach ($content['perms'] as $name => $value) |
|
1234 | 1232 | { |
1235 | 1233 | $readonlys['perms['.$name.']'] = true; |
1236 | 1234 | } |
@@ -1248,37 +1246,37 @@ discard block |
||
1248 | 1246 | } |
1249 | 1247 | elseif (!Vfs::is_writable($path)) |
1250 | 1248 | { |
1251 | - foreach($cfs as $name => $data) |
|
1249 | + foreach ($cfs as $name => $data) |
|
1252 | 1250 | { |
1253 | 1251 | $readonlys['#'.$name] = true; |
1254 | 1252 | } |
1255 | 1253 | } |
1256 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1254 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
1257 | 1255 | if ($content['is_dir']) |
1258 | 1256 | { |
1259 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1260 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1257 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
1258 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1261 | 1259 | 7 => lang('Display and modification of content'), |
1262 | 1260 | 5 => lang('Display of content'), |
1263 | 1261 | 0 => lang('No access'), |
1264 | 1262 | ); |
1265 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1263 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false) // backend supports eacl |
|
1266 | 1264 | { |
1267 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1268 | - foreach($content['eacl'] as &$eacl) |
|
1265 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
1266 | + foreach ($content['eacl'] as &$eacl) |
|
1269 | 1267 | { |
1270 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
1268 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
1271 | 1269 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
1272 | 1270 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
1273 | 1271 | } |
1274 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
1272 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
1275 | 1273 | $content['eacl']['owner'] = 0; |
1276 | 1274 | $content['eacl']['rights'] = 5; |
1277 | 1275 | } |
1278 | 1276 | } |
1279 | 1277 | else |
1280 | 1278 | { |
1281 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
1279 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
1282 | 1280 | 6 => lang('Read & write access'), |
1283 | 1281 | 4 => lang('Read access only'), |
1284 | 1282 | 0 => lang('No access'), |
@@ -1288,11 +1286,11 @@ discard block |
||
1288 | 1286 | // mergeapp |
1289 | 1287 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
1290 | 1288 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
1291 | - if(!empty($content['mergeapp'])) |
|
1289 | + if (!empty($content['mergeapp'])) |
|
1292 | 1290 | { |
1293 | 1291 | $content['mergeapp_effective'] = $content['mergeapp']; |
1294 | 1292 | } |
1295 | - elseif(!empty($content['mergeapp_parent'])) |
|
1293 | + elseif (!empty($content['mergeapp_parent'])) |
|
1296 | 1294 | { |
1297 | 1295 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
1298 | 1296 | } |
@@ -1304,7 +1302,7 @@ discard block |
||
1304 | 1302 | $mergeapp_list = Link::app_list('merge'); |
1305 | 1303 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
1306 | 1304 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
1307 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
1305 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
1308 | 1306 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
1309 | 1307 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
1310 | 1308 | // mergeapp other gui options |
@@ -1321,7 +1319,7 @@ discard block |
||
1321 | 1319 | 'comment' => (string)$content['comment'], |
1322 | 1320 | 'mergeapp' => $content['mergeapp'] |
1323 | 1321 | ); |
1324 | - if ($cfs) foreach($cfs as $name => $data) |
|
1322 | + if ($cfs) foreach ($cfs as $name => $data) |
|
1325 | 1323 | { |
1326 | 1324 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
1327 | 1325 | } |
@@ -1329,26 +1327,26 @@ discard block |
||
1329 | 1327 | if (Vfs::$is_root) |
1330 | 1328 | { |
1331 | 1329 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
1332 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
1330 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
1333 | 1331 | // Need a more complex submit because button type is buttononly, which doesn't submit |
1334 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
1332 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
1335 | 1333 | |
1336 | 1334 | } |
1337 | 1335 | elseif ($button == 'sudo') |
1338 | 1336 | { |
1339 | 1337 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
1340 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
1341 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
1338 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
1339 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
1342 | 1340 | } |
1343 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
1341 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
1344 | 1342 | { |
1345 | 1343 | // add to existing tabs in template |
1346 | 1344 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
1347 | 1345 | |
1348 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
1346 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
1349 | 1347 | if (true) $tabs = array(); |
1350 | 1348 | |
1351 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1349 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
1352 | 1350 | { |
1353 | 1351 | $tabs[] = array( |
1354 | 1352 | 'label' => $extra_tab['label'], |
@@ -1371,7 +1369,7 @@ discard block |
||
1371 | 1369 | Framework::window_focus(); |
1372 | 1370 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
1373 | 1371 | |
1374 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
1372 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
1375 | 1373 | } |
1376 | 1374 | |
1377 | 1375 | /** |
@@ -1382,7 +1380,7 @@ discard block |
||
1382 | 1380 | * @param string $dir=null current directory |
1383 | 1381 | * @see static::action() |
1384 | 1382 | */ |
1385 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
1383 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
1386 | 1384 | { |
1387 | 1385 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
1388 | 1386 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1401,15 +1399,15 @@ discard block |
||
1401 | 1399 | |
1402 | 1400 | if (!isset($dir)) $dir = array_pop($selected); |
1403 | 1401 | |
1404 | - switch($action) |
|
1402 | + switch ($action) |
|
1405 | 1403 | { |
1406 | 1404 | case 'upload': |
1407 | 1405 | $script_error = 0; |
1408 | - foreach($selected as $tmp_name => &$data) |
|
1406 | + foreach ($selected as $tmp_name => &$data) |
|
1409 | 1407 | { |
1410 | 1408 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
1411 | 1409 | |
1412 | - if(Vfs::deny_script($path)) |
|
1410 | + if (Vfs::deny_script($path)) |
|
1413 | 1411 | { |
1414 | 1412 | if (!isset($script_error)) |
1415 | 1413 | { |
@@ -1431,7 +1429,7 @@ discard block |
||
1431 | 1429 | { |
1432 | 1430 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
1433 | 1431 | { |
1434 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
1432 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
1435 | 1433 | } |
1436 | 1434 | else |
1437 | 1435 | { |
@@ -1463,7 +1461,7 @@ discard block |
||
1463 | 1461 | break; |
1464 | 1462 | |
1465 | 1463 | case 'sharelink': |
1466 | - $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() ); |
|
1464 | + $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array()); |
|
1467 | 1465 | $arr["share_link"] = $link = Vfs\Sharing::share2link($share); |
1468 | 1466 | $arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet'); |
1469 | 1467 | break; |
@@ -1472,16 +1470,16 @@ discard block |
||
1472 | 1470 | case 'link': |
1473 | 1471 | // First upload |
1474 | 1472 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
1475 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
1473 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
1476 | 1474 | |
1477 | - foreach($arr['uploaded'] as $file) |
|
1475 | + foreach ($arr['uploaded'] as $file) |
|
1478 | 1476 | { |
1479 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
1477 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
1480 | 1478 | if (Vfs::file_exists($target) && $app_dir) |
1481 | 1479 | { |
1482 | 1480 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
1483 | 1481 | error_log("Symlinking $target to $app_dir"); |
1484 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
1482 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
1485 | 1483 | } |
1486 | 1484 | } |
1487 | 1485 | // Must return to avoid adding to $response again |
@@ -1503,7 +1501,7 @@ discard block |
||
1503 | 1501 | */ |
1504 | 1502 | private function perms2mode(array $perms) |
1505 | 1503 | { |
1506 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
1504 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
1507 | 1505 | if ($mode['executable']) |
1508 | 1506 | { |
1509 | 1507 | $mode |= 0111; |
@@ -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; |
@@ -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 |
@@ -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'] = (array)$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'] = (array)$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 |
@@ -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 | { |
@@ -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 | { |
@@ -81,14 +81,18 @@ discard block |
||
81 | 81 | { |
82 | 82 | $filter = array('name' => '*'); |
83 | 83 | |
84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
84 | + if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
85 | + { |
|
85 | 86 | // Any public definition |
86 | 87 | $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
87 | - } else { |
|
88 | + } |
|
89 | + else |
|
90 | + { |
|
88 | 91 | // Filter private definitions |
89 | 92 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
90 | 93 | $config = Api\Config::read('phpgwapi'); |
91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
94 | + if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) |
|
95 | + { |
|
92 | 96 | $filter['type'] = 'import'; |
93 | 97 | } |
94 | 98 | } |
@@ -104,7 +108,10 @@ discard block |
||
104 | 108 | elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
105 | 109 | { |
106 | 110 | $selected = $content['nm']['rows']['selected']; |
107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
111 | + if(count($selected) < 1 || !is_array($selected)) |
|
112 | + { |
|
113 | + exit(); |
|
114 | + } |
|
108 | 115 | switch ($button) |
109 | 116 | { |
110 | 117 | case 'delete_selected' : |
@@ -160,7 +167,8 @@ discard block |
||
160 | 167 | } |
161 | 168 | } |
162 | 169 | |
163 | - if(!is_array($content['nm'])) { |
|
170 | + if(!is_array($content['nm'])) |
|
171 | + { |
|
164 | 172 | $content['nm'] = array( |
165 | 173 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
166 | 174 | 'no_cat' => true, |
@@ -171,7 +179,10 @@ discard block |
||
171 | 179 | 'row_id' => 'definition_id', |
172 | 180 | 'placeholder_actions' => array('add') |
173 | 181 | ); |
174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
182 | + if($_GET['application']) |
|
183 | + { |
|
184 | + $content['nm']['col_filter']['application'] = $_GET['application']; |
|
185 | + } |
|
175 | 186 | } |
176 | 187 | if(Api\Cache::getSession('importexport', 'index')) |
177 | 188 | { |
@@ -190,17 +201,22 @@ discard block |
||
190 | 201 | ); |
191 | 202 | foreach ($this->plugins as $appname => $options) |
192 | 203 | { |
193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
204 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
205 | + { |
|
194 | 206 | $sel_options['application'][$appname] = lang($appname); |
195 | 207 | } |
196 | 208 | } |
197 | - if($msg) $content['msg'] = $msg; |
|
209 | + if($msg) |
|
210 | + { |
|
211 | + $content['msg'] = $msg; |
|
212 | + } |
|
198 | 213 | |
199 | 214 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
200 | 215 | return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
201 | 216 | } |
202 | 217 | |
203 | - private function get_actions() { |
|
218 | + private function get_actions() |
|
219 | + { |
|
204 | 220 | $group = 0; |
205 | 221 | $actions = array( |
206 | 222 | 'edit' => array( |
@@ -319,7 +335,8 @@ discard block |
||
319 | 335 | $this->get_rows($query,$rows,$readonlys); |
320 | 336 | |
321 | 337 | $selected = array(); |
322 | - foreach($rows as $row) { |
|
338 | + foreach($rows as $row) |
|
339 | + { |
|
323 | 340 | $selected[] = $row['definition_id']; |
324 | 341 | } |
325 | 342 | if(!is_array($session_name)) |
@@ -334,18 +351,24 @@ discard block |
||
334 | 351 | |
335 | 352 | $bodefinitions = new importexport_definitions_bo(false, true); |
336 | 353 | |
337 | - switch($action) { |
|
354 | + switch($action) |
|
355 | + { |
|
338 | 356 | case 'allowed': |
339 | 357 | // Field is allowed_users, popup doesn't like _ |
340 | 358 | $action = 'allowed_users'; |
341 | 359 | // Fall through |
342 | 360 | case 'owner': |
343 | 361 | $action_msg = lang('changed'. ' ' . $action); |
344 | - foreach($selected as $id) { |
|
362 | + foreach($selected as $id) |
|
363 | + { |
|
345 | 364 | $definition = $bodefinitions->read((int)$id); |
346 | - if($definition['definition_id']) { |
|
365 | + if($definition['definition_id']) |
|
366 | + { |
|
347 | 367 | // Prevent private with no owner |
348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
368 | + if(!$definition['owner'] && !$settings) |
|
369 | + { |
|
370 | + $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
371 | + } |
|
349 | 372 | |
350 | 373 | $definition[$action] = $settings; |
351 | 374 | $bodefinitions->save($definition); |
@@ -372,18 +395,22 @@ discard block |
||
372 | 395 | case 'copy': |
373 | 396 | $action_msg = lang('copied'); |
374 | 397 | // Should only be one selected |
375 | - foreach($selected as $id) { |
|
398 | + foreach($selected as $id) |
|
399 | + { |
|
376 | 400 | $definition = $bodefinitions->read((int)$id); |
377 | - if($definition['definition_id']) { |
|
401 | + if($definition['definition_id']) |
|
402 | + { |
|
378 | 403 | unset($definition['definition_id']); |
379 | 404 | $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
380 | 405 | try { |
381 | 406 | $bodefinitions->save($definition); |
382 | - } catch (Exception $e) { |
|
407 | + } |
|
408 | + catch (Exception $e) { |
|
383 | 409 | try { |
384 | 410 | $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
385 | 411 | $bodefinitions->save($definition); |
386 | - } catch (Exception $ex) { |
|
412 | + } |
|
413 | + catch (Exception $ex) { |
|
387 | 414 | $failed++; |
388 | 415 | $msg .= lang('Duplicate name, please choose another.'); |
389 | 416 | continue; |
@@ -396,18 +423,21 @@ discard block |
||
396 | 423 | case 'createexport': |
397 | 424 | $action_msg = lang('created'); |
398 | 425 | // Should only be one selected |
399 | - foreach($selected as $id) { |
|
426 | + foreach($selected as $id) |
|
427 | + { |
|
400 | 428 | $definition = new importexport_definition($id); |
401 | 429 | try { |
402 | 430 | $export = $bodefinitions->export_from_import($definition); |
403 | 431 | $export->save(); |
404 | - } catch (Exception $e) { |
|
432 | + } |
|
433 | + catch (Exception $e) { |
|
405 | 434 | if($export) |
406 | 435 | { |
407 | 436 | try { |
408 | 437 | $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
409 | 438 | $export->save(); |
410 | - } catch (Exception $ex) { |
|
439 | + } |
|
440 | + catch (Exception $ex) { |
|
411 | 441 | $failed++; |
412 | 442 | $msg .= lang('Duplicate name, please choose another.'); |
413 | 443 | continue; |
@@ -425,7 +455,8 @@ discard block |
||
425 | 455 | return !$failed; |
426 | 456 | } |
427 | 457 | |
428 | - public function get_rows(&$query, &$rows, &$readonlys) { |
|
458 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
459 | + { |
|
429 | 460 | $rows = array(); |
430 | 461 | Api\Cache::setSession('importexport', 'index', $query); |
431 | 462 | |
@@ -500,7 +531,10 @@ discard block |
||
500 | 531 | |
501 | 532 | if(is_array($content) &&! $content['edit']) |
502 | 533 | { |
503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
534 | + if(self::_debug) |
|
535 | + { |
|
536 | + error_log('importexport.wizard->$content '. print_r($content,true)); |
|
537 | + } |
|
504 | 538 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
505 | 539 | // fetch plugin object |
506 | 540 | if($content['plugin'] && $content['application']) |
@@ -517,13 +551,18 @@ discard block |
||
517 | 551 | $wizard_plugin = $content['plugin']; |
518 | 552 | } |
519 | 553 | // App translations |
520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
554 | + if($content['application']) |
|
555 | + { |
|
556 | + Api\Translation::add_app($content['application']); |
|
557 | + } |
|
521 | 558 | |
522 | 559 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
523 | 560 | |
524 | 561 | // Global object needs to be the same, or references to plugin don't work |
525 | 562 | if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
563 | + { |
|
564 | + $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
565 | + } |
|
527 | 566 | } |
528 | 567 | // deal with buttons even if we are not on ajax |
529 | 568 | if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
@@ -653,7 +692,10 @@ discard block |
||
653 | 692 | |
654 | 693 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
655 | 694 | { |
656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
695 | + if(self::_debug) |
|
696 | + { |
|
697 | + error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
698 | + } |
|
657 | 699 | |
658 | 700 | // return from step10 |
659 | 701 | if ($content['step'] == 'wizard_step10') |
@@ -675,7 +717,8 @@ discard block |
||
675 | 717 | $content['text'] = $this->steps['wizard_step10']; |
676 | 718 | foreach ($this->plugins as $appname => $options) |
677 | 719 | { |
678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
720 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
721 | + { |
|
679 | 722 | $sel_options['application'][$appname] = lang($appname); |
680 | 723 | } |
681 | 724 | } |
@@ -691,7 +734,10 @@ discard block |
||
691 | 734 | // get plugin |
692 | 735 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
693 | 736 | { |
694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
737 | + if(self::_debug) |
|
738 | + { |
|
739 | + error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
740 | + } |
|
695 | 741 | |
696 | 742 | // return from step20 |
697 | 743 | if ($content['step'] == 'wizard_step20') |
@@ -700,11 +746,16 @@ discard block |
||
700 | 746 | { |
701 | 747 | case 'next': |
702 | 748 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
749 | + if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) |
|
750 | + { |
|
704 | 751 | $content['type'] = 'import'; |
705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
752 | + } |
|
753 | + elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) |
|
754 | + { |
|
706 | 755 | $content['type'] = 'export'; |
707 | - } else { |
|
756 | + } |
|
757 | + else |
|
758 | + { |
|
708 | 759 | throw new Api\Exception('Invalid plugin'); |
709 | 760 | } |
710 | 761 | return $this->get_step($content['step'],1); |
@@ -722,9 +773,14 @@ discard block |
||
722 | 773 | { |
723 | 774 | $content['text'] = $this->steps['wizard_step20']; |
724 | 775 | $config = Api\Config::read('phpgwapi'); |
725 | - foreach ($this->plugins[$content['application']] as $type => $plugins) { |
|
726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | - foreach($plugins as $plugin => $name) { |
|
776 | + foreach ($this->plugins[$content['application']] as $type => $plugins) |
|
777 | + { |
|
778 | + if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') |
|
779 | + { |
|
780 | + continue; |
|
781 | + } |
|
782 | + foreach($plugins as $plugin => $name) |
|
783 | + { |
|
728 | 784 | $sel_options['plugin'][$plugin] = $name; |
729 | 785 | } |
730 | 786 | } |
@@ -740,7 +796,10 @@ discard block |
||
740 | 796 | // name |
741 | 797 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
742 | 798 | { |
743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
799 | + if(self::_debug) |
|
800 | + { |
|
801 | + error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
802 | + } |
|
744 | 803 | |
745 | 804 | // Check for duplicate name |
746 | 805 | $duplicate = isset($content['duplicate_error']); |
@@ -752,7 +811,8 @@ discard block |
||
752 | 811 | { |
753 | 812 | throw new Exception('Already exists'); |
754 | 813 | } |
755 | - } catch (Exception $e) { |
|
814 | + } |
|
815 | + catch (Exception $e) { |
|
756 | 816 | // throw new Exception('Already exists'); |
757 | 817 | $content['duplicate_error'] = lang('Duplicate name, please choose another.'); |
758 | 818 | |
@@ -763,13 +823,16 @@ discard block |
||
763 | 823 | $content['name'] .'-'. Api\DateTime::to('now', true), |
764 | 824 | //$content['name'] .'-'. rand(0,100), |
765 | 825 | ); |
766 | - foreach($suggestions as $key => $suggestion) { |
|
826 | + foreach($suggestions as $key => $suggestion) |
|
827 | + { |
|
767 | 828 | $sug_definition = new importexport_definition($suggestion); |
768 | - if($sug_definition->definition_id) { |
|
829 | + if($sug_definition->definition_id) |
|
830 | + { |
|
769 | 831 | unset($suggestions[$key]); |
770 | 832 | } |
771 | 833 | } |
772 | - if($suggestions) { |
|
834 | + if($suggestions) |
|
835 | + { |
|
773 | 836 | $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
774 | 837 | } |
775 | 838 | return $this->get_step($content['step'],0); |
@@ -806,7 +869,10 @@ discard block |
||
806 | 869 | // allowed users |
807 | 870 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
808 | 871 | { |
809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
872 | + if(self::_debug) |
|
873 | + { |
|
874 | + error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
875 | + } |
|
810 | 876 | |
811 | 877 | // return from step90 |
812 | 878 | if ($content['step'] == 'wizard_step90') |
@@ -876,7 +942,10 @@ discard block |
||
876 | 942 | |
877 | 943 | function wizard_finish(&$content) |
878 | 944 | { |
879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
945 | + if(self::_debug) |
|
946 | + { |
|
947 | + error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
948 | + } |
|
880 | 949 | // Take out some UI leavings |
881 | 950 | unset($content['text']); |
882 | 951 | unset($content['step']); |
@@ -905,7 +974,8 @@ discard block |
||
905 | 974 | if($content['update']) |
906 | 975 | { |
907 | 976 | $applist = importexport_helper_functions::get_apps('all', true); |
908 | - foreach($applist as $appname) { |
|
977 | + foreach($applist as $appname) |
|
978 | + { |
|
909 | 979 | importexport_helper_functions::load_defaults($appname); |
910 | 980 | } |
911 | 981 | return $this->index(); |
@@ -971,7 +1041,9 @@ discard block |
||
971 | 1041 | { |
972 | 1042 | Api\Config::save_value($key, $value, 'importexport'); |
973 | 1043 | } |
974 | - } elseif (isset($content['cancel'])) { |
|
1044 | + } |
|
1045 | + elseif (isset($content['cancel'])) |
|
1046 | + { |
|
975 | 1047 | $GLOBALS['egw']->redirect_link('/admin/index.php'); |
976 | 1048 | } |
977 | 1049 | |
@@ -985,7 +1057,10 @@ discard block |
||
985 | 1057 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
986 | 1058 | } |
987 | 1059 | |
988 | - if(!$data['update']) $data['update'] = 'request'; |
|
1060 | + if(!$data['update']) |
|
1061 | + { |
|
1062 | + $data['update'] = 'request'; |
|
1063 | + } |
|
989 | 1064 | |
990 | 1065 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
991 | 1066 | $etpl = new etemplate(self::_appname.'.config'); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | function __construct() |
56 | 56 | { |
57 | 57 | // we cant deal with notice and warnings, as we are on ajax! |
58 | - error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); |
|
58 | + error_reporting(E_ALL&~E_NOTICE&~E_WARNING); |
|
59 | 59 | Api\Translation::add_app(self::_appname); |
60 | 60 | $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; |
61 | 61 | |
62 | 62 | $this->etpl = new Etemplate(); |
63 | - $this->clock = Api\Html::image(self::_appname,'clock'); |
|
63 | + $this->clock = Api\Html::image(self::_appname, 'clock'); |
|
64 | 64 | $this->steps = array( |
65 | 65 | 'wizard_step10' => lang('Choose an application'), |
66 | 66 | 'wizard_step20' => lang('Choose a plugin'), |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $content=null |
79 | 79 | */ |
80 | - function index($content = null,$msg='') |
|
80 | + function index($content = null, $msg = '') |
|
81 | 81 | { |
82 | 82 | $filter = array('name' => '*'); |
83 | 83 | |
84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
84 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
85 | 85 | // Any public definition |
86 | - $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
|
86 | + $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = '.$GLOBALS['egw_info']['user']['account_id'].')'; |
|
87 | 87 | } else { |
88 | 88 | // Filter private definitions |
89 | 89 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
90 | 90 | $config = Api\Config::read('phpgwapi'); |
91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
91 | + if ($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
92 | 92 | $filter['type'] = 'import'; |
93 | 93 | } |
94 | 94 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | if (isset($content['nm']['rows']['delete'])) |
100 | 100 | { |
101 | 101 | $content['nm']['action'] = 'delete'; |
102 | - $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'],'pressed'); |
|
102 | + $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'], 'pressed'); |
|
103 | 103 | } |
104 | - elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
|
104 | + elseif (($button = array_search('pressed', $content['nm']['rows'])) !== false) |
|
105 | 105 | { |
106 | 106 | $selected = $content['nm']['rows']['selected']; |
107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
107 | + if (count($selected) < 1 || !is_array($selected)) exit(); |
|
108 | 108 | switch ($button) |
109 | 109 | { |
110 | 110 | case 'delete_selected' : |
@@ -126,54 +126,54 @@ discard block |
||
126 | 126 | else |
127 | 127 | { |
128 | 128 | // Action has an additional parameter |
129 | - if(in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
129 | + if (in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
130 | 130 | { |
131 | 131 | $action = $content['nm']['action']; |
132 | - if($content['nm']['action'] == 'allowed') |
|
132 | + if ($content['nm']['action'] == 'allowed') |
|
133 | 133 | { |
134 | 134 | $content['allowed'] = $content['allowed_popup']['allowed_private'] == 'true' ? null : ( |
135 | - $content['allowed_popup']['all_users']=='true' ? 'all' : implode(',',$content['allowed_popup']['allowed']) |
|
135 | + $content['allowed_popup']['all_users'] == 'true' ? 'all' : implode(',', $content['allowed_popup']['allowed']) |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | 140 | $content['owner'] = $content['owner_popup']['owner']; |
141 | 141 | } |
142 | - if(is_array($content[$content['nm']['action']])) |
|
142 | + if (is_array($content[$content['nm']['action']])) |
|
143 | 143 | { |
144 | - $content[$content['nm']['action']] = implode(',',$content[$content['nm']['action']]); |
|
144 | + $content[$content['nm']['action']] = implode(',', $content[$content['nm']['action']]); |
|
145 | 145 | } |
146 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
146 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
147 | 147 | unset($content[$action]); |
148 | 148 | unset($content['allowed_popup']); |
149 | 149 | } |
150 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
151 | - $success,$failed,$action_msg,'index',$msg)) |
|
150 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
151 | + $success, $failed, $action_msg, 'index', $msg)) |
|
152 | 152 | { |
153 | - $msg .= lang('%1 definition(s) %2',$success,$action_msg); |
|
153 | + $msg .= lang('%1 definition(s) %2', $success, $action_msg); |
|
154 | 154 | } |
155 | - elseif(empty($msg)) |
|
155 | + elseif (empty($msg)) |
|
156 | 156 | { |
157 | - $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
157 | + $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if(!is_array($content['nm'])) { |
|
163 | + if (!is_array($content['nm'])) { |
|
164 | 164 | $content['nm'] = array( |
165 | 165 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
166 | 166 | 'no_cat' => true, |
167 | 167 | 'no_filter' => true, |
168 | 168 | 'no_filter2' => true, |
169 | - 'csv_fields' => false, // Disable CSV export, uses own export |
|
170 | - 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
169 | + 'csv_fields' => false, // Disable CSV export, uses own export |
|
170 | + 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
171 | 171 | 'row_id' => 'definition_id', |
172 | 172 | 'placeholder_actions' => array('add') |
173 | 173 | ); |
174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
174 | + if ($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
175 | 175 | } |
176 | - if(Api\Cache::getSession('importexport', 'index')) |
|
176 | + if (Api\Cache::getSession('importexport', 'index')) |
|
177 | 177 | { |
178 | 178 | $content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index')); |
179 | 179 | } |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | ); |
191 | 191 | foreach ($this->plugins as $appname => $options) |
192 | 192 | { |
193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
193 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
194 | 194 | $sel_options['application'][$appname] = lang($appname); |
195 | 195 | } |
196 | 196 | } |
197 | - if($msg) $content['msg'] = $msg; |
|
197 | + if ($msg) $content['msg'] = $msg; |
|
198 | 198 | |
199 | 199 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
200 | - return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
|
200 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | private function get_actions() { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | ); |
287 | 287 | |
288 | 288 | // Unset admin actions |
289 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
289 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
290 | 290 | { |
291 | 291 | unset($actions['schedule']); |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
306 | 306 | * @return boolean true if all actions succeded, false otherwise |
307 | 307 | */ |
308 | - function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
308 | + function action($action, $selected, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
309 | 309 | { |
310 | 310 | //error_log( __METHOD__."('$action', ".array2string($selected).', '.array2string($use_all).",,, '$session_name')"); |
311 | 311 | if ($use_all) |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | // get the whole selection |
314 | 314 | $old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name); |
315 | 315 | |
316 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
317 | - $query['num_rows'] = -1; // all |
|
318 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
319 | - $this->get_rows($query,$rows,$readonlys); |
|
316 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
317 | + $query['num_rows'] = -1; // all |
|
318 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
319 | + $this->get_rows($query, $rows, $readonlys); |
|
320 | 320 | |
321 | 321 | $selected = array(); |
322 | - foreach($rows as $row) { |
|
322 | + foreach ($rows as $row) { |
|
323 | 323 | $selected[] = $row['definition_id']; |
324 | 324 | } |
325 | - if(!is_array($session_name)) |
|
325 | + if (!is_array($session_name)) |
|
326 | 326 | { |
327 | 327 | // Restore old query |
328 | 328 | Api\Cache::setSession('importexport', $session_name, $old_query); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | |
335 | 335 | $bodefinitions = new importexport_definitions_bo(false, true); |
336 | 336 | |
337 | - switch($action) { |
|
337 | + switch ($action) { |
|
338 | 338 | case 'allowed': |
339 | 339 | // Field is allowed_users, popup doesn't like _ |
340 | 340 | $action = 'allowed_users'; |
341 | 341 | // Fall through |
342 | 342 | case 'owner': |
343 | - $action_msg = lang('changed'. ' ' . $action); |
|
344 | - foreach($selected as $id) { |
|
343 | + $action_msg = lang('changed'.' '.$action); |
|
344 | + foreach ($selected as $id) { |
|
345 | 345 | $definition = $bodefinitions->read((int)$id); |
346 | - if($definition['definition_id']) { |
|
346 | + if ($definition['definition_id']) { |
|
347 | 347 | // Prevent private with no owner |
348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
348 | + if (!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
349 | 349 | |
350 | 350 | $definition[$action] = $settings; |
351 | 351 | $bodefinitions->save($definition); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ? |
364 | 364 | 'application/octetstream' : 'application/octet-stream'; |
365 | 365 | $name = 'importexport_definition.xml'; |
366 | - header('Content-Type: ' . $mime_type); |
|
366 | + header('Content-Type: '.$mime_type); |
|
367 | 367 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
368 | 368 | echo $bodefinitions->export($selected); |
369 | 369 | exit(); |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | case 'copy': |
373 | 373 | $action_msg = lang('copied'); |
374 | 374 | // Should only be one selected |
375 | - foreach($selected as $id) { |
|
375 | + foreach ($selected as $id) { |
|
376 | 376 | $definition = $bodefinitions->read((int)$id); |
377 | - if($definition['definition_id']) { |
|
377 | + if ($definition['definition_id']) { |
|
378 | 378 | unset($definition['definition_id']); |
379 | - $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
|
379 | + $definition['name'] = $settings ? $settings : $definition['name'].' copy'; |
|
380 | 380 | try { |
381 | 381 | $bodefinitions->save($definition); |
382 | 382 | } catch (Exception $e) { |
383 | 383 | try { |
384 | - $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
384 | + $definition['name'] .= ' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
385 | 385 | $bodefinitions->save($definition); |
386 | 386 | } catch (Exception $ex) { |
387 | 387 | $failed++; |
@@ -396,16 +396,16 @@ discard block |
||
396 | 396 | case 'createexport': |
397 | 397 | $action_msg = lang('created'); |
398 | 398 | // Should only be one selected |
399 | - foreach($selected as $id) { |
|
399 | + foreach ($selected as $id) { |
|
400 | 400 | $definition = new importexport_definition($id); |
401 | 401 | try { |
402 | 402 | $export = $bodefinitions->export_from_import($definition); |
403 | 403 | $export->save(); |
404 | 404 | } catch (Exception $e) { |
405 | - if($export) |
|
405 | + if ($export) |
|
406 | 406 | { |
407 | 407 | try { |
408 | - $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
408 | + $export->name = $export->name.' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
409 | 409 | $export->save(); |
410 | 410 | } catch (Exception $ex) { |
411 | 411 | $failed++; |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | Api\Cache::setSession('importexport', 'index', $query); |
431 | 431 | |
432 | 432 | // Special handling for allowed users 'private' |
433 | - if($query['col_filter']['allowed_users'] == 'private') |
|
433 | + if ($query['col_filter']['allowed_users'] == 'private') |
|
434 | 434 | { |
435 | 435 | unset($query['col_filter']['allowed_users']); |
436 | - $query['col_filter'][] = 'allowed_users = ' . $GLOBALS['egw']->db->quote(',,'); |
|
436 | + $query['col_filter'][] = 'allowed_users = '.$GLOBALS['egw']->db->quote(',,'); |
|
437 | 437 | } |
438 | 438 | $bodefinitions = new importexport_definitions_bo($query['col_filter'], true); |
439 | 439 | // We don't care about readonlys for the UI |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | function edit() |
450 | 450 | { |
451 | - if(!$_definition = $_GET['definition']) |
|
451 | + if (!$_definition = $_GET['definition']) |
|
452 | 452 | { |
453 | 453 | $content = array( |
454 | 454 | 'edit' => true, |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | ); |
458 | 458 | |
459 | 459 | // Jump to a step |
460 | - if($_GET['step']) |
|
460 | + if ($_GET['step']) |
|
461 | 461 | { |
462 | 462 | $content['edit'] = false; |
463 | 463 | // Wizard will process previous step, then advance |
464 | - $content['step'] = $this->get_step($_GET['step'],-1); |
|
464 | + $content['step'] = $this->get_step($_GET['step'], -1); |
|
465 | 465 | $content['button']['next'] = 'pressed'; |
466 | 466 | $this->wizard($content); |
467 | 467 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | return; |
474 | 474 | } |
475 | - if(is_numeric($_GET['definition'])) |
|
475 | + if (is_numeric($_GET['definition'])) |
|
476 | 476 | { |
477 | 477 | $definition = (int)$_GET['definition']; |
478 | 478 | } |
@@ -484,31 +484,31 @@ discard block |
||
484 | 484 | $definition = $bodefinitions->read($definition); |
485 | 485 | $definition['edit'] = true; |
486 | 486 | // Jump to a step |
487 | - if($_GET['step']) |
|
487 | + if ($_GET['step']) |
|
488 | 488 | { |
489 | 489 | $definition['edit'] = false; |
490 | 490 | // Wizard will process previous step, then advance |
491 | - $definition['step'] = $_GET['step'];; |
|
491 | + $definition['step'] = $_GET['step']; ; |
|
492 | 492 | $definition['button'] = array('next' => 'pressed'); |
493 | 493 | } |
494 | 494 | $this->wizard($definition); |
495 | 495 | } |
496 | 496 | |
497 | - function wizard($content = null, $msg='') |
|
497 | + function wizard($content = null, $msg = '') |
|
498 | 498 | { |
499 | 499 | $this->etpl->read('importexport.wizardbox'); |
500 | 500 | |
501 | - if(is_array($content) &&! $content['edit']) |
|
501 | + if (is_array($content) && !$content['edit']) |
|
502 | 502 | { |
503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
503 | + if (self::_debug) error_log('importexport.wizard->$content '.print_r($content, true)); |
|
504 | 504 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
505 | 505 | // fetch plugin object |
506 | - if($content['plugin'] && $content['application']) |
|
506 | + if ($content['plugin'] && $content['application']) |
|
507 | 507 | { |
508 | - $wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']); |
|
508 | + $wizard_name = $content['application'].'_wizard_'.str_replace($content['application'].'_', '', $content['plugin']); |
|
509 | 509 | |
510 | 510 | // we need to deal with the wizard object if exists |
511 | - if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php")) |
|
511 | + if (file_exists(EGW_SERVER_ROOT.'/'.$content['application']."/inc/class.$wizard_name.inc.php")) |
|
512 | 512 | { |
513 | 513 | $wizard_plugin = $wizard_name; |
514 | 514 | } |
@@ -517,38 +517,38 @@ discard block |
||
517 | 517 | $wizard_plugin = $content['plugin']; |
518 | 518 | } |
519 | 519 | // App translations |
520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
520 | + if ($content['application']) Api\Translation::add_app($content['application']); |
|
521 | 521 | |
522 | 522 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
523 | 523 | |
524 | 524 | // Global object needs to be the same, or references to plugin don't work |
525 | - if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
525 | + if (!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
526 | + $GLOBALS['egw']->importexport_definitions_ui = & $this; |
|
527 | 527 | } |
528 | 528 | // deal with buttons even if we are not on ajax |
529 | - if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
|
529 | + if (isset($content['button']) && array_search('pressed', $content['button']) === false && count($content['button']) == 1) |
|
530 | 530 | { |
531 | 531 | $button = array_keys($content['button']); |
532 | 532 | $content['button'] = array($button[0] => 'pressed'); |
533 | 533 | } |
534 | 534 | |
535 | 535 | // post process submitted step |
536 | - if($content['step']) |
|
536 | + if ($content['step']) |
|
537 | 537 | { |
538 | - if(!$this->can_edit($content)) |
|
538 | + if (!$this->can_edit($content)) |
|
539 | 539 | { |
540 | 540 | // Each step changes definition, reload it |
541 | 541 | $bodefinitions = new importexport_definitions_bo(); |
542 | 542 | $definition = $bodefinitions->read($content); |
543 | 543 | $content = $definition + array('step' => $content['step'], 'button' => $content['button']); |
544 | 544 | } |
545 | - if(!key_exists($content['step'],$this->steps)) |
|
545 | + if (!key_exists($content['step'], $this->steps)) |
|
546 | 546 | { |
547 | - $next_step = $this->plugin->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
547 | + $next_step = $this->plugin->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
548 | 548 | } |
549 | 549 | else |
550 | 550 | { |
551 | - $next_step = $this->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
551 | + $next_step = $this->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | else |
@@ -560,23 +560,23 @@ discard block |
||
560 | 560 | $sel_options = $readonlys = $preserv = array(); |
561 | 561 | |
562 | 562 | // Disable finish button if required fields are missing |
563 | - if(!$content['name'] || !$content['type'] || !$content['plugin']) |
|
563 | + if (!$content['name'] || !$content['type'] || !$content['plugin']) |
|
564 | 564 | { |
565 | 565 | $readonlys['button[finish]'] = true; |
566 | 566 | } |
567 | 567 | do |
568 | 568 | { |
569 | - if(!key_exists($next_step,$this->steps)) |
|
569 | + if (!key_exists($next_step, $this->steps)) |
|
570 | 570 | { |
571 | - $this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv); |
|
571 | + $this->wizard_content_template = $this->plugin->$next_step($content, $sel_options, $readonlys, $preserv); |
|
572 | 572 | } |
573 | 573 | else |
574 | 574 | { |
575 | - $this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv); |
|
575 | + $this->wizard_content_template = $this->$next_step($content, $sel_options, $readonlys, $preserv); |
|
576 | 576 | } |
577 | - if($this->wizard_content_template == self::SKIP) |
|
577 | + if ($this->wizard_content_template == self::SKIP) |
|
578 | 578 | { |
579 | - if(!key_exists($content['step'],$this->steps)) |
|
579 | + if (!key_exists($content['step'], $this->steps)) |
|
580 | 580 | { |
581 | 581 | $next_step = $this->plugin->{$content['step']}($content); |
582 | 582 | } |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | $next_step = $this->{$content['step']}($content); |
586 | 586 | } |
587 | 587 | } |
588 | - } while($this->wizard_content_template == self::SKIP); |
|
588 | + } while ($this->wizard_content_template == self::SKIP); |
|
589 | 589 | |
590 | - if(!$this->can_edit($content)) |
|
590 | + if (!$this->can_edit($content)) |
|
591 | 591 | { |
592 | 592 | $readonlys[$this->wizard_content_template] = true; |
593 | 593 | $preserve = $content; |
@@ -596,21 +596,21 @@ discard block |
||
596 | 596 | |
597 | 597 | unset($content['button']); |
598 | 598 | $content['wizard_content'] = $this->wizard_content_template; |
599 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
599 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
600 | 600 | } |
601 | 601 | else |
602 | 602 | { |
603 | 603 | // initial content |
604 | 604 | $sel_options = $readonlys = $preserv = array(); |
605 | 605 | $readonlys['button[previous]'] = true; |
606 | - if($content['edit']) |
|
606 | + if ($content['edit']) |
|
607 | 607 | { |
608 | 608 | unset ($content['edit']); |
609 | 609 | } |
610 | 610 | |
611 | 611 | $this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
612 | 612 | |
613 | - if(!$this->can_edit($content)) |
|
613 | + if (!$this->can_edit($content)) |
|
614 | 614 | { |
615 | 615 | $readonlys[$this->wizard_content_template] = true; |
616 | 616 | $preserve = $content; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | } |
619 | 619 | |
620 | 620 | $content['wizard_content'] = $this->wizard_content_template; |
621 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
621 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
@@ -629,31 +629,31 @@ discard block |
||
629 | 629 | * @param int $step_width |
630 | 630 | * @return string containing function name of next step |
631 | 631 | */ |
632 | - function get_step ($curr_step, $step_width) |
|
632 | + function get_step($curr_step, $step_width) |
|
633 | 633 | { |
634 | 634 | /*if($content['plugin'] && $content['application']&& !is_object($this->plugin)) |
635 | 635 | { |
636 | 636 | $plugin_definition = $this->plugins[$content['application']][$content['plugin']]['definition']; |
637 | 637 | if($plugin_definition) $this->plugin = new $plugin_definition; |
638 | 638 | }*/ |
639 | - if(is_object($this->plugin) && is_array($this->plugin->steps)) |
|
639 | + if (is_object($this->plugin) && is_array($this->plugin->steps)) |
|
640 | 640 | { |
641 | - $steps = array_merge($this->steps,$this->plugin->steps); |
|
642 | - $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
641 | + $steps = array_merge($this->steps, $this->plugin->steps); |
|
642 | + $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
643 | 643 | } |
644 | 644 | else |
645 | 645 | { |
646 | 646 | $steps = $this->steps; |
647 | 647 | } |
648 | 648 | $step_keys = array_keys($steps); |
649 | - $nn = array_search($curr_step,$step_keys)+(int)$step_width; |
|
650 | - return (key_exists($nn,$step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
649 | + $nn = array_search($curr_step, $step_keys) + (int)$step_width; |
|
650 | + return (key_exists($nn, $step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
654 | 654 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
655 | 655 | { |
656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
656 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content, true)); |
|
657 | 657 | |
658 | 658 | // return from step10 |
659 | 659 | if ($content['step'] == 'wizard_step10') |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | switch (array_search('pressed', $content['button'])) |
662 | 662 | { |
663 | 663 | case 'next': |
664 | - return $this->get_step($content['step'],1); |
|
664 | + return $this->get_step($content['step'], 1); |
|
665 | 665 | case 'finish': |
666 | 666 | return 'wizard_finish'; |
667 | 667 | default : |
668 | - return $this->wizard_step10($content,$sel_options,$readonlys,$preserv); |
|
668 | + return $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $content['text'] = $this->steps['wizard_step10']; |
676 | 676 | foreach ($this->plugins as $appname => $options) |
677 | 677 | { |
678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
678 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
679 | 679 | $sel_options['application'][$appname] = lang($appname); |
680 | 680 | } |
681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | // get plugin |
692 | 692 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
693 | 693 | { |
694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
694 | + if (self::_debug) error_log('importexport.'.get_class($this).'::wizard_step20->$content '.print_r($content, true)); |
|
695 | 695 | |
696 | 696 | // return from step20 |
697 | 697 | if ($content['step'] == 'wizard_step20') |
@@ -700,21 +700,21 @@ discard block |
||
700 | 700 | { |
701 | 701 | case 'next': |
702 | 702 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
703 | + if ($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
704 | 704 | $content['type'] = 'import'; |
705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
705 | + } elseif ($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin), 'export') !== false) { |
|
706 | 706 | $content['type'] = 'export'; |
707 | 707 | } else { |
708 | 708 | throw new Api\Exception('Invalid plugin'); |
709 | 709 | } |
710 | - return $this->get_step($content['step'],1); |
|
710 | + return $this->get_step($content['step'], 1); |
|
711 | 711 | case 'previous' : |
712 | 712 | $readonlys['button[previous]'] = true; |
713 | - return $this->get_step($content['step'],-1); |
|
713 | + return $this->get_step($content['step'], -1); |
|
714 | 714 | case 'finish': |
715 | 715 | return 'wizard_finish'; |
716 | 716 | default : |
717 | - return $this->wizard_step20($content,$sel_options,$readonlys,$preserv); |
|
717 | + return $this->wizard_step20($content, $sel_options, $readonlys, $preserv); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | // init step20 |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | $content['text'] = $this->steps['wizard_step20']; |
724 | 724 | $config = Api\Config::read('phpgwapi'); |
725 | 725 | foreach ($this->plugins[$content['application']] as $type => $plugins) { |
726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | - foreach($plugins as $plugin => $name) { |
|
726 | + if ($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | + foreach ($plugins as $plugin => $name) { |
|
728 | 728 | $sel_options['plugin'][$plugin] = $name; |
729 | 729 | } |
730 | 730 | } |
@@ -740,15 +740,15 @@ discard block |
||
740 | 740 | // name |
741 | 741 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
742 | 742 | { |
743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
743 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content, true)); |
|
744 | 744 | |
745 | 745 | // Check for duplicate name |
746 | 746 | $duplicate = isset($content['duplicate_error']); |
747 | - if($content['name'] && !$duplicate) |
|
747 | + if ($content['name'] && !$duplicate) |
|
748 | 748 | { |
749 | 749 | try { |
750 | 750 | $check_definition = new importexport_definition($content['name']); |
751 | - if($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
751 | + if ($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
752 | 752 | { |
753 | 753 | throw new Exception('Already exists'); |
754 | 754 | } |
@@ -758,21 +758,21 @@ discard block |
||
758 | 758 | |
759 | 759 | // Try some suggestions |
760 | 760 | $suggestions = array( |
761 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'], |
|
762 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'], |
|
763 | - $content['name'] .'-'. Api\DateTime::to('now', true), |
|
761 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_lid'], |
|
762 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_id'], |
|
763 | + $content['name'].'-'.Api\DateTime::to('now', true), |
|
764 | 764 | //$content['name'] .'-'. rand(0,100), |
765 | 765 | ); |
766 | - foreach($suggestions as $key => $suggestion) { |
|
766 | + foreach ($suggestions as $key => $suggestion) { |
|
767 | 767 | $sug_definition = new importexport_definition($suggestion); |
768 | - if($sug_definition->definition_id) { |
|
768 | + if ($sug_definition->definition_id) { |
|
769 | 769 | unset($suggestions[$key]); |
770 | 770 | } |
771 | 771 | } |
772 | - if($suggestions) { |
|
773 | - $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
|
772 | + if ($suggestions) { |
|
773 | + $content['duplicate_error'] .= ' '.lang('Try')." \n".implode("\n", $suggestions); |
|
774 | 774 | } |
775 | - return $this->get_step($content['step'],0); |
|
775 | + return $this->get_step($content['step'], 0); |
|
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
@@ -782,19 +782,19 @@ discard block |
||
782 | 782 | switch (array_search('pressed', $content['button'])) |
783 | 783 | { |
784 | 784 | case 'next': |
785 | - return $this->get_step($content['step'],1); |
|
785 | + return $this->get_step($content['step'], 1); |
|
786 | 786 | case 'previous' : |
787 | - return $this->get_step($content['step'],-1); |
|
787 | + return $this->get_step($content['step'], -1); |
|
788 | 788 | case 'finish': |
789 | 789 | return 'wizard_finish'; |
790 | 790 | default : |
791 | - return $this->wizard_step21($content,$sel_options,$readonlys,$preserv); |
|
791 | + return $this->wizard_step21($content, $sel_options, $readonlys, $preserv); |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | // init step21 |
795 | 795 | else |
796 | 796 | { |
797 | - $content['text'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
797 | + $content['text'] = $this->steps['wizard_step21'].($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
798 | 798 | $content['step'] = 'wizard_step21'; |
799 | 799 | unset($content['duplicate_error']); |
800 | 800 | $preserv = $content; |
@@ -806,17 +806,16 @@ discard block |
||
806 | 806 | // allowed users |
807 | 807 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
808 | 808 | { |
809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
809 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content, true)); |
|
810 | 810 | |
811 | 811 | // return from step90 |
812 | 812 | if ($content['step'] == 'wizard_step90') |
813 | 813 | { |
814 | - if($this->can_edit($content)) |
|
814 | + if ($this->can_edit($content)) |
|
815 | 815 | { |
816 | - $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ? |
|
817 | - ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : |
|
818 | - null; |
|
819 | - $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users'])); |
|
816 | + $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ, 'importexport') ? |
|
817 | + ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : null; |
|
818 | + $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',', $content['allowed_users'])); |
|
820 | 819 | unset($content['just_me']); |
821 | 820 | } |
822 | 821 | |
@@ -824,12 +823,12 @@ discard block |
||
824 | 823 | switch (array_search('pressed', $content['button'])) |
825 | 824 | { |
826 | 825 | case 'previous' : |
827 | - return $this->get_step($content['step'],-1); |
|
826 | + return $this->get_step($content['step'], -1); |
|
828 | 827 | case 'next': |
829 | 828 | case 'finish': |
830 | 829 | return 'wizard_finish'; |
831 | 830 | default : |
832 | - return $this->wizard_step90($content,$sel_options,$readonlys,$preserv); |
|
831 | + return $this->wizard_step90($content, $sel_options, $readonlys, $preserv); |
|
833 | 832 | } |
834 | 833 | } |
835 | 834 | // init step90 |
@@ -840,10 +839,10 @@ discard block |
||
840 | 839 | $preserv = $content; |
841 | 840 | |
842 | 841 | // Set owner for non-admins |
843 | - $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']); |
|
844 | - $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
842 | + $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) == 1) && $content['owner']); |
|
843 | + $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0', $content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
845 | 844 | $content['allowed_users'] == 'all'; |
846 | - if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
845 | + if (!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
847 | 846 | { |
848 | 847 | $content['allowed_users'] = array(); |
849 | 848 | $readonlys['allowed_users'] = true; |
@@ -859,11 +858,11 @@ discard block |
||
859 | 858 | ) |
860 | 859 | ); |
861 | 860 | // Hide 'just me' checkbox, users get confused by read-only |
862 | - if($readonlys['just_me'] || !$this->can_edit($content)) |
|
861 | + if ($readonlys['just_me'] || !$this->can_edit($content)) |
|
863 | 862 | { |
864 | 863 | $content['no_just_me'] = true; |
865 | 864 | } |
866 | - if($readonlys['all_users'] || !$this->can_edit($content)) |
|
865 | + if ($readonlys['all_users'] || !$this->can_edit($content)) |
|
867 | 866 | { |
868 | 867 | $content['no_all_users'] = true; |
869 | 868 | } |
@@ -876,7 +875,7 @@ discard block |
||
876 | 875 | |
877 | 876 | function wizard_finish(&$content) |
878 | 877 | { |
879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
878 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content, true)); |
|
880 | 879 | // Take out some UI leavings |
881 | 880 | unset($content['text']); |
882 | 881 | unset($content['step']); |
@@ -886,26 +885,26 @@ discard block |
||
886 | 885 | $bodefinitions->save($content); |
887 | 886 | // This message is displayed if browser cant close window |
888 | 887 | $content['msg'] = lang('ImportExport wizard finished successfully!'); |
889 | - Framework::refresh_opener('','importexport'); |
|
888 | + Framework::refresh_opener('', 'importexport'); |
|
890 | 889 | Framework::window_close(); |
891 | 890 | return 'importexport.wizard_close'; |
892 | 891 | } |
893 | 892 | |
894 | - function import_definition($content='') |
|
893 | + function import_definition($content = '') |
|
895 | 894 | { |
896 | 895 | $bodefinitions = new importexport_definitions_bo(); |
897 | 896 | if (is_array($content)) |
898 | 897 | { |
899 | - if($content['import_file']['tmp_name']) |
|
898 | + if ($content['import_file']['tmp_name']) |
|
900 | 899 | { |
901 | 900 | $result = $bodefinitions->import($content['import_file']['tmp_name']); |
902 | - $msg = lang('%1 definitions %2', count($result), lang('imported')) ."\n". implode("\n", array_keys($result)); |
|
901 | + $msg = lang('%1 definitions %2', count($result), lang('imported'))."\n".implode("\n", array_keys($result)); |
|
903 | 902 | return $this->index(null, $msg); |
904 | 903 | } |
905 | - if($content['update']) |
|
904 | + if ($content['update']) |
|
906 | 905 | { |
907 | 906 | $applist = importexport_helper_functions::get_apps('all', true); |
908 | - foreach($applist as $appname) { |
|
907 | + foreach ($applist as $appname) { |
|
909 | 908 | importexport_helper_functions::load_defaults($appname); |
910 | 909 | } |
911 | 910 | return $this->index(); |
@@ -915,7 +914,7 @@ discard block |
||
915 | 914 | { |
916 | 915 | $content = array(); |
917 | 916 | $etpl = new etemplate(self::_appname.'.import_definition'); |
918 | - return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv); |
|
917 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition', $content, array(), $readonlys, $preserv); |
|
919 | 918 | } |
920 | 919 | } |
921 | 920 | |
@@ -925,17 +924,17 @@ discard block |
||
925 | 924 | */ |
926 | 925 | protected function can_edit(Array $definition) |
927 | 926 | { |
928 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
927 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
929 | 928 | { |
930 | 929 | // Definition belongs to user |
931 | 930 | return true; |
932 | 931 | } |
933 | - elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
932 | + elseif ($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
934 | 933 | { |
935 | 934 | // Definition is unowned, and user is an admin |
936 | 935 | return true; |
937 | 936 | } |
938 | - elseif(!$definition['definition_id']) |
|
937 | + elseif (!$definition['definition_id']) |
|
939 | 938 | { |
940 | 939 | // Definition is in-progress, not saved yet |
941 | 940 | return true; |
@@ -948,26 +947,26 @@ discard block |
||
948 | 947 | */ |
949 | 948 | public function site_config($content = array()) |
950 | 949 | { |
951 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
950 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
952 | 951 | { |
953 | 952 | Egw::redirect_link('/home'); |
954 | 953 | } |
955 | - if($content['save']) |
|
954 | + if ($content['save']) |
|
956 | 955 | { |
957 | 956 | unset($content['save']); |
958 | 957 | |
959 | 958 | // ACL |
960 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false); |
|
961 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition',false); |
|
959 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition', false); |
|
960 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition', false); |
|
962 | 961 | |
963 | - foreach($content['share_definition'] as $group) |
|
962 | + foreach ($content['share_definition'] as $group) |
|
964 | 963 | { |
965 | - $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ); |
|
964 | + $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group, Acl::READ); |
|
966 | 965 | } |
967 | 966 | unset($content['share_definition']); |
968 | 967 | |
969 | 968 | // Other Api\Config |
970 | - foreach($content as $key=>$value) |
|
969 | + foreach ($content as $key=>$value) |
|
971 | 970 | { |
972 | 971 | Api\Config::save_value($key, $value, 'importexport'); |
973 | 972 | } |
@@ -977,18 +976,18 @@ discard block |
||
977 | 976 | |
978 | 977 | $data = Api\Config::read(self::_appname); |
979 | 978 | $data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Acl::READ, self::_appname); |
980 | - $sel_options['import_charsets'] = array_combine(mb_list_encodings(),mb_list_encodings()); |
|
979 | + $sel_options['import_charsets'] = array_combine(mb_list_encodings(), mb_list_encodings()); |
|
981 | 980 | |
982 | 981 | // Remove 'standard' encodings to prevent doubles |
983 | - foreach(Api\Translation::get_installed_charsets() as $charset => $label) |
|
982 | + foreach (Api\Translation::get_installed_charsets() as $charset => $label) |
|
984 | 983 | { |
985 | 984 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
986 | 985 | } |
987 | 986 | |
988 | - if(!$data['update']) $data['update'] = 'request'; |
|
987 | + if (!$data['update']) $data['update'] = 'request'; |
|
989 | 988 | |
990 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
|
989 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration').' - '.lang(self::_appname); |
|
991 | 990 | $etpl = new etemplate(self::_appname.'.config'); |
992 | - $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv); |
|
991 | + $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config', $data, $sel_options, $readonlys, $preserv); |
|
993 | 992 | } |
994 | 993 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param stram $_stream resource where records are exported to. |
98 | 98 | * @param array _options options for specific backends |
99 | - * @return bool |
|
99 | + * @return boolean|null |
|
100 | 100 | */ |
101 | 101 | public function __construct( $_stream, array $_options ) { |
102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * exports a record into resource of handle |
152 | 152 | * |
153 | 153 | * @param importexport_iface_egw_record record |
154 | - * @return bool |
|
154 | + * @return boolean|null |
|
155 | 155 | */ |
156 | 156 | public function export_record( importexport_iface_egw_record $_record ) { |
157 | 157 | $this->record = $_record; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * Uses the static variable $types to convert various datatypes. |
286 | 286 | * |
287 | - * @param record Record to be converted |
|
287 | + * @param record importexport_iface_egw_record to be converted |
|
288 | 288 | * @parem fields List of field types => field names to be converted |
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @parem fields List of field types => field names to be converted |
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
291 | + public static function convert(importexport_iface_egw_record &$record, array $fields = array(), $appname = null, $selects = array()) { |
|
292 | 292 | if($appname) { |
293 | 293 | if(!self::$cf_parse_cache[$appname]) { |
294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @param char $delimiter |
453 | 453 | * @param char $enclosure |
454 | 454 | */ |
455 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
455 | + protected function fputcsv($filePointer, array $dataArray, $delimiter, $enclosure){ |
|
456 | 456 | $string = ""; |
457 | 457 | $writeDelimiter = false; |
458 | 458 | foreach($dataArray as $dataElement) { |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | * @param array _options options for specific backends |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - public function __construct( $_stream, array $_options ) { |
|
101 | + public function __construct($_stream, array $_options) { |
|
102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
103 | 103 | $GLOBALS['egw']->translation = new Api\Translation(); |
104 | 104 | } |
105 | 105 | $this->translation = &$GLOBALS['egw']->translation; |
106 | 106 | $this->handle = $_stream; |
107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
107 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
108 | 108 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
109 | - if ( !empty( $_options ) ) { |
|
110 | - $this->csv_options = array_merge( $this->csv_options, $_options ); |
|
109 | + if (!empty($_options)) { |
|
110 | + $this->csv_options = array_merge($this->csv_options, $_options); |
|
111 | 111 | } |
112 | 112 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
113 | + if (!Api\Storage\Merge::is_export_limit_excepted()) { |
|
114 | 114 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
115 | 115 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
116 | + if ($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param array $_mapping egw_field_name => csv_field_name |
124 | 124 | */ |
125 | - public function set_mapping( array &$_mapping) { |
|
125 | + public function set_mapping(array &$_mapping) { |
|
126 | 126 | if ($this->num_of_records > 0) { |
127 | 127 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
128 | 128 | } |
129 | - if($_mapping['all_custom_fields']) { |
|
129 | + if ($_mapping['all_custom_fields']) { |
|
130 | 130 | // Field value is the appname, so we can pull the fields |
131 | 131 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
132 | 132 | unset($_mapping['all_custom_fields']); |
133 | - foreach($custom as $field => $info) { |
|
133 | + foreach ($custom as $field => $info) { |
|
134 | 134 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
135 | 135 | } |
136 | 136 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param array $_conversion |
145 | 145 | */ |
146 | - public function set_conversion( array $_conversion) { |
|
146 | + public function set_conversion(array $_conversion) { |
|
147 | 147 | $this->conversion = $_conversion; |
148 | 148 | } |
149 | 149 | |
@@ -153,59 +153,59 @@ discard block |
||
153 | 153 | * @param importexport_iface_egw_record record |
154 | 154 | * @return bool |
155 | 155 | */ |
156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
156 | + public function export_record(importexport_iface_egw_record $_record) { |
|
157 | 157 | $this->record = $_record; |
158 | 158 | $this->record_array = $_record->get_record_array(); |
159 | 159 | |
160 | 160 | // begin with fieldnames ? |
161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
161 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) { |
|
162 | + if ($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
163 | 163 | // Load translations for app |
164 | 164 | list($appname, $part2) = explode('_', get_class($_record)); |
165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
165 | + if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
166 | 166 | |
167 | 167 | // Get translations from wizard, if possible |
168 | - if(!$this->csv_options['no_header_translation']) |
|
168 | + if (!$this->csv_options['no_header_translation']) |
|
169 | 169 | { |
170 | 170 | $backtrace = debug_backtrace(); |
171 | 171 | $plugin = $backtrace[1]['class']; |
172 | - $wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin); |
|
172 | + $wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin); |
|
173 | 173 | try { |
174 | 174 | $wizard = new $wizard_name; |
175 | 175 | $fields = $wizard->get_export_fields(); |
176 | - foreach($this->mapping as $field => &$label) |
|
176 | + foreach ($this->mapping as $field => &$label) |
|
177 | 177 | { |
178 | - if($fields[$field]) |
|
178 | + if ($fields[$field]) |
|
179 | 179 | { |
180 | 180 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
181 | 181 | } |
182 | 182 | // Make sure no * |
183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
183 | + if (substr($label, -1) == '*') $label = substr($label, 0, -1); |
|
184 | 184 | } |
185 | 185 | } catch (Exception $e) { |
186 | 186 | Api\Translation::add_app($appname); |
187 | - foreach($this->mapping as $field => &$label) { |
|
187 | + foreach ($this->mapping as $field => &$label) { |
|
188 | 188 | $label = lang($label); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | - $mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array ); |
|
194 | - self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
193 | + $mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array); |
|
194 | + self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // Check for limit |
198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
198 | + if ($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // do conversions |
203 | - if ( !empty( $this->conversion )) { |
|
204 | - $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
|
203 | + if (!empty($this->conversion)) { |
|
204 | + $this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // do fieldmapping |
208 | - if ( !empty( $this->mapping ) ) { |
|
208 | + if (!empty($this->mapping)) { |
|
209 | 209 | $record_data = $this->record_array; |
210 | 210 | $this->record_array = array(); |
211 | 211 | foreach ($this->mapping as $egw_field => $csv_field) { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
216 | + self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
217 | 217 | $this->num_of_records++; |
218 | 218 | } |
219 | 219 | |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | * @return Array of fields to be added to list of fields needing conversion |
238 | 238 | */ |
239 | 239 | public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
240 | - if(!$appname) return; |
|
240 | + if (!$appname) return; |
|
241 | 241 | |
242 | 242 | $fields = array(); |
243 | 243 | $custom = Api\Storage\Customfields::get($appname); |
244 | - foreach($custom as $name => $c_field) { |
|
245 | - $name = '#' . $name; |
|
246 | - switch($c_field['type']) { |
|
244 | + foreach ($custom as $name => $c_field) { |
|
245 | + $name = '#'.$name; |
|
246 | + switch ($c_field['type']) { |
|
247 | 247 | case 'date': |
248 | 248 | $fields['date'][] = $name; |
249 | 249 | break; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $fields['select-account'][] = $name; |
255 | 255 | break; |
256 | 256 | case 'ajax_select': |
257 | - if($c_field['values']['get_title']) { |
|
257 | + if ($c_field['values']['get_title']) { |
|
258 | 258 | $methods[$name] = $c_field['values']['get_title']; |
259 | 259 | break; |
260 | 260 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $selects[$name] = $c_field['values']; |
269 | 269 | break; |
270 | 270 | default: |
271 | - list($type) = explode('-',$c_field['type'],2); |
|
272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
271 | + list($type) = explode('-', $c_field['type'], 2); |
|
272 | + if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
273 | 273 | $fields['links'][] = $name; |
274 | 274 | $links[$name] = $c_field['type']; |
275 | 275 | } |
@@ -288,18 +288,18 @@ discard block |
||
288 | 288 | * @parem fields List of field types => field names to be converted |
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
292 | - if($appname) { |
|
293 | - if(!self::$cf_parse_cache[$appname]) { |
|
291 | + public static function convert(importexport_iface_egw_record&$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
292 | + if ($appname) { |
|
293 | + if (!self::$cf_parse_cache[$appname]) { |
|
294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
295 | 295 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
296 | 296 | } |
297 | 297 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
298 | 298 | |
299 | 299 | // Add in any fields that are keys to another app |
300 | - foreach((array)$fields['links'] as $link_field => $app) |
|
300 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
301 | 301 | { |
302 | - if(is_numeric($link_field)) continue; |
|
302 | + if (is_numeric($link_field)) continue; |
|
303 | 303 | $links[$link_field] = $app; |
304 | 304 | // Set it as a normal link field |
305 | 305 | $fields['links'][] = $link_field; |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | // Not quite a recursive merge, since only one level |
310 | - foreach($fields as $type => &$list) { |
|
311 | - if($c_fields[$type]) { |
|
310 | + foreach ($fields as $type => &$list) { |
|
311 | + if ($c_fields[$type]) { |
|
312 | 312 | $list = array_merge($c_fields[$type], $list); |
313 | 313 | unset($c_fields[$type]); |
314 | 314 | } |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | $fields += $c_fields; |
317 | 317 | $selects += $c_selects; |
318 | 318 | } |
319 | - foreach((array)$fields['select'] as $name) { |
|
320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
319 | + foreach ((array)$fields['select'] as $name) { |
|
320 | + if ($record->$name != null && is_array($selects) && $selects[$name]) { |
|
321 | 321 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
322 | - if(is_array($record->$name)) { |
|
322 | + if (is_array($record->$name)) { |
|
323 | 323 | $names = array(); |
324 | - foreach($record->$name as $_name) { |
|
324 | + foreach ($record->$name as $_name) { |
|
325 | 325 | $names[] = lang($selects[$name][$_name]); |
326 | 326 | } |
327 | 327 | $record->$name = implode(', ', $names); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | $record->$name = ''; |
335 | 335 | } |
336 | 336 | } |
337 | - foreach((array)$fields['links'] as $name) { |
|
338 | - if($record->$name) { |
|
339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
337 | + foreach ((array)$fields['links'] as $name) { |
|
338 | + if ($record->$name) { |
|
339 | + if (is_numeric($record->$name) && !$links[$name]) { |
|
340 | 340 | $link = Link::get_link($record->$name); |
341 | 341 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
342 | 342 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
343 | 343 | } |
344 | - if($links[$name]) |
|
344 | + if ($links[$name]) |
|
345 | 345 | { |
346 | 346 | $record->$name = Link::title($links[$name], $record->$name); |
347 | 347 | } |
348 | - else if ( is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
348 | + else if (is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
349 | 349 | { |
350 | 350 | $record->$name = Link::title($record->$name['app'], $record->$name['id']); |
351 | 351 | } |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | $record->$name = ''; |
356 | 356 | } |
357 | 357 | } |
358 | - foreach((array)$fields['select-account'] as $name) { |
|
358 | + foreach ((array)$fields['select-account'] as $name) { |
|
359 | 359 | // Compare against null to deal with empty arrays |
360 | 360 | if ($record->$name !== null) { |
361 | - if(is_array($record->$name)) { |
|
361 | + if (is_array($record->$name)) { |
|
362 | 362 | $names = array(); |
363 | - foreach($record->$name as $_name) { |
|
363 | + foreach ($record->$name as $_name) { |
|
364 | 364 | $names[] = Api\Accounts::username($_name); |
365 | 365 | } |
366 | 366 | $record->$name = implode(', ', $names); |
@@ -373,64 +373,64 @@ discard block |
||
373 | 373 | $record->$name = ''; |
374 | 374 | } |
375 | 375 | } |
376 | - foreach((array)$fields['select-bool'] as $name) { |
|
377 | - if($record->$name !== null) { |
|
376 | + foreach ((array)$fields['select-bool'] as $name) { |
|
377 | + if ($record->$name !== null) { |
|
378 | 378 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
379 | 379 | } |
380 | 380 | } |
381 | - foreach((array)$fields['date-time'] as $name) { |
|
381 | + foreach ((array)$fields['date-time'] as $name) { |
|
382 | 382 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
383 | 383 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
384 | + if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '. |
|
385 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format |
|
386 | 386 | if (!$record->$name) $record->$name = ''; |
387 | 387 | } |
388 | - foreach((array)$fields['date'] as $name) { |
|
388 | + foreach ((array)$fields['date'] as $name) { |
|
389 | 389 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
390 | 390 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
391 | 391 | if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
392 | 392 | if (!$record->$name) $record->$name = ''; |
393 | 393 | } |
394 | - foreach((array)$fields['float'] as $name) |
|
394 | + foreach ((array)$fields['float'] as $name) |
|
395 | 395 | { |
396 | - static $dec_separator,$thousands_separator; |
|
396 | + static $dec_separator, $thousands_separator; |
|
397 | 397 | if (is_null($dec_separator)) |
398 | 398 | { |
399 | 399 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
400 | 400 | if (empty($dec_separator)) $dec_separator = '.'; |
401 | 401 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
402 | 402 | } |
403 | - if($record->$name && (string)$record->$name != '') |
|
403 | + if ($record->$name && (string)$record->$name != '') |
|
404 | 404 | { |
405 | - if(!is_numeric($record->$name)) |
|
405 | + if (!is_numeric($record->$name)) |
|
406 | 406 | { |
407 | 407 | $record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name))); |
408 | 408 | } |
409 | - $record->$name = number_format(str_replace(' ','',$record->$name), 2, |
|
410 | - $dec_separator,$thousands_separator |
|
409 | + $record->$name = number_format(str_replace(' ', '', $record->$name), 2, |
|
410 | + $dec_separator, $thousands_separator |
|
411 | 411 | ); |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | // Some custom methods for conversion |
416 | - foreach((array)$methods as $name => $method) { |
|
417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
416 | + foreach ((array)$methods as $name => $method) { |
|
417 | + if ($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | static $cat_object; |
421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
422 | - foreach((array)$fields['select-cat'] as $name) { |
|
423 | - if($record->$name) { |
|
421 | + if (is_null($cat_object)) $cat_object = new Api\Categories(false, $appname); |
|
422 | + foreach ((array)$fields['select-cat'] as $name) { |
|
423 | + if ($record->$name) { |
|
424 | 424 | $cats = array(); |
425 | 425 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
426 | - foreach($ids as $n => $cat_id) { |
|
426 | + foreach ($ids as $n => $cat_id) { |
|
427 | 427 | |
428 | - if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
|
428 | + if ($cat_id && $cat_object->check_perms(Acl::READ, $cat_id)) |
|
429 | 429 | { |
430 | 430 | $cats[] = $cat_object->id2name($cat_id); |
431 | 431 | } |
432 | 432 | } |
433 | - $record->$name = implode(', ',$cats); |
|
433 | + $record->$name = implode(', ', $cats); |
|
434 | 434 | } |
435 | 435 | else |
436 | 436 | { |
@@ -457,18 +457,18 @@ discard block |
||
457 | 457 | * @param char $delimiter |
458 | 458 | * @param char $enclosure |
459 | 459 | */ |
460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
460 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) { |
|
461 | 461 | $string = ""; |
462 | 462 | $writeDelimiter = false; |
463 | - foreach($dataArray as $dataElement) { |
|
464 | - if($writeDelimiter) $string .= $delimiter; |
|
465 | - $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
|
463 | + foreach ($dataArray as $dataElement) { |
|
464 | + if ($writeDelimiter) $string .= $delimiter; |
|
465 | + $string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure; |
|
466 | 466 | $writeDelimiter = true; |
467 | 467 | } |
468 | 468 | $string .= "\n"; |
469 | 469 | |
470 | 470 | // do charset translation |
471 | - $string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset ); |
|
471 | + $string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset); |
|
472 | 472 | |
473 | 473 | fwrite($filePointer, $string); |
474 | 474 |
@@ -98,22 +98,32 @@ discard block |
||
98 | 98 | * @param array _options options for specific backends |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - public function __construct( $_stream, array $_options ) { |
|
102 | - if (!is_object($GLOBALS['egw']->translation)) { |
|
101 | + public function __construct( $_stream, array $_options ) |
|
102 | + { |
|
103 | + if (!is_object($GLOBALS['egw']->translation)) |
|
104 | + { |
|
103 | 105 | $GLOBALS['egw']->translation = new Api\Translation(); |
104 | 106 | } |
105 | 107 | $this->translation = &$GLOBALS['egw']->translation; |
106 | 108 | $this->handle = $_stream; |
107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
109 | + if($_options['charset'] == 'user') |
|
110 | + { |
|
111 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
112 | + } |
|
108 | 113 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
109 | - if ( !empty( $_options ) ) { |
|
114 | + if ( !empty( $_options ) ) |
|
115 | + { |
|
110 | 116 | $this->csv_options = array_merge( $this->csv_options, $_options ); |
111 | 117 | } |
112 | 118 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
119 | + if(!Api\Storage\Merge::is_export_limit_excepted()) |
|
120 | + { |
|
114 | 121 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
115 | 122 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
123 | + if($this->export_limit == 'no') |
|
124 | + { |
|
125 | + throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
126 | + } |
|
117 | 127 | } |
118 | 128 | } |
119 | 129 | |
@@ -122,15 +132,19 @@ discard block |
||
122 | 132 | * |
123 | 133 | * @param array $_mapping egw_field_name => csv_field_name |
124 | 134 | */ |
125 | - public function set_mapping( array &$_mapping) { |
|
126 | - if ($this->num_of_records > 0) { |
|
135 | + public function set_mapping( array &$_mapping) |
|
136 | + { |
|
137 | + if ($this->num_of_records > 0) |
|
138 | + { |
|
127 | 139 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
128 | 140 | } |
129 | - if($_mapping['all_custom_fields']) { |
|
141 | + if($_mapping['all_custom_fields']) |
|
142 | + { |
|
130 | 143 | // Field value is the appname, so we can pull the fields |
131 | 144 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
132 | 145 | unset($_mapping['all_custom_fields']); |
133 | - foreach($custom as $field => $info) { |
|
146 | + foreach($custom as $field => $info) |
|
147 | + { |
|
134 | 148 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
135 | 149 | } |
136 | 150 | } |
@@ -143,7 +157,8 @@ discard block |
||
143 | 157 | * |
144 | 158 | * @param array $_conversion |
145 | 159 | */ |
146 | - public function set_conversion( array $_conversion) { |
|
160 | + public function set_conversion( array $_conversion) |
|
161 | + { |
|
147 | 162 | $this->conversion = $_conversion; |
148 | 163 | } |
149 | 164 | |
@@ -153,16 +168,23 @@ discard block |
||
153 | 168 | * @param importexport_iface_egw_record record |
154 | 169 | * @return bool |
155 | 170 | */ |
156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
171 | + public function export_record( importexport_iface_egw_record $_record ) |
|
172 | + { |
|
157 | 173 | $this->record = $_record; |
158 | 174 | $this->record_array = $_record->get_record_array(); |
159 | 175 | |
160 | 176 | // begin with fieldnames ? |
161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
177 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) |
|
178 | + { |
|
179 | + if($this->csv_options['begin_with_fieldnames'] == 'label') |
|
180 | + { |
|
163 | 181 | // Load translations for app |
164 | 182 | list($appname, $part2) = explode('_', get_class($_record)); |
165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
183 | + if(!$GLOBALS['egw_info']['apps'][$appname]) |
|
184 | + { |
|
185 | + $appname .= $part2; |
|
186 | + } |
|
187 | + // Handle apps with _ in the name |
|
166 | 188 | |
167 | 189 | // Get translations from wizard, if possible |
168 | 190 | if(!$this->csv_options['no_header_translation']) |
@@ -180,11 +202,16 @@ discard block |
||
180 | 202 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
181 | 203 | } |
182 | 204 | // Make sure no * |
183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
205 | + if(substr($label,-1) == '*') |
|
206 | + { |
|
207 | + $label = substr($label,0,-1); |
|
208 | + } |
|
184 | 209 | } |
185 | - } catch (Exception $e) { |
|
210 | + } |
|
211 | + catch (Exception $e) { |
|
186 | 212 | Api\Translation::add_app($appname); |
187 | - foreach($this->mapping as $field => &$label) { |
|
213 | + foreach($this->mapping as $field => &$label) |
|
214 | + { |
|
188 | 215 | $label = lang($label); |
189 | 216 | } |
190 | 217 | } |
@@ -195,20 +222,24 @@ discard block |
||
195 | 222 | } |
196 | 223 | |
197 | 224 | // Check for limit |
198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
225 | + if($this->export_limit && $this->num_of_records >= $this->export_limit) |
|
226 | + { |
|
199 | 227 | return; |
200 | 228 | } |
201 | 229 | |
202 | 230 | // do conversions |
203 | - if ( !empty( $this->conversion )) { |
|
231 | + if ( !empty( $this->conversion )) |
|
232 | + { |
|
204 | 233 | $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
205 | 234 | } |
206 | 235 | |
207 | 236 | // do fieldmapping |
208 | - if ( !empty( $this->mapping ) ) { |
|
237 | + if ( !empty( $this->mapping ) ) |
|
238 | + { |
|
209 | 239 | $record_data = $this->record_array; |
210 | 240 | $this->record_array = array(); |
211 | - foreach ($this->mapping as $egw_field => $csv_field) { |
|
241 | + foreach ($this->mapping as $egw_field => $csv_field) |
|
242 | + { |
|
212 | 243 | $this->record_array[$csv_field] = $record_data[$egw_field]; |
213 | 244 | } |
214 | 245 | } |
@@ -222,7 +253,8 @@ discard block |
||
222 | 253 | * |
223 | 254 | * @return int |
224 | 255 | */ |
225 | - public function get_num_of_records() { |
|
256 | + public function get_num_of_records() |
|
257 | + { |
|
226 | 258 | return $this->num_of_records; |
227 | 259 | } |
228 | 260 | |
@@ -236,14 +268,20 @@ discard block |
||
236 | 268 | * |
237 | 269 | * @return Array of fields to be added to list of fields needing conversion |
238 | 270 | */ |
239 | - public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
|
240 | - if(!$appname) return; |
|
271 | + public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) |
|
272 | + { |
|
273 | + if(!$appname) |
|
274 | + { |
|
275 | + return; |
|
276 | + } |
|
241 | 277 | |
242 | 278 | $fields = array(); |
243 | 279 | $custom = Api\Storage\Customfields::get($appname); |
244 | - foreach($custom as $name => $c_field) { |
|
280 | + foreach($custom as $name => $c_field) |
|
281 | + { |
|
245 | 282 | $name = '#' . $name; |
246 | - switch($c_field['type']) { |
|
283 | + switch($c_field['type']) |
|
284 | + { |
|
247 | 285 | case 'date': |
248 | 286 | $fields['date'][] = $name; |
249 | 287 | break; |
@@ -254,7 +292,8 @@ discard block |
||
254 | 292 | $fields['select-account'][] = $name; |
255 | 293 | break; |
256 | 294 | case 'ajax_select': |
257 | - if($c_field['values']['get_title']) { |
|
295 | + if($c_field['values']['get_title']) |
|
296 | + { |
|
258 | 297 | $methods[$name] = $c_field['values']['get_title']; |
259 | 298 | break; |
260 | 299 | } |
@@ -269,7 +308,8 @@ discard block |
||
269 | 308 | break; |
270 | 309 | default: |
271 | 310 | list($type) = explode('-',$c_field['type'],2); |
272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
311 | + if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) |
|
312 | + { |
|
273 | 313 | $fields['links'][] = $name; |
274 | 314 | $links[$name] = $c_field['type']; |
275 | 315 | } |
@@ -288,9 +328,12 @@ discard block |
||
288 | 328 | * @parem fields List of field types => field names to be converted |
289 | 329 | * @param appname Current appname if you want to do custom fields too |
290 | 330 | */ |
291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
292 | - if($appname) { |
|
293 | - if(!self::$cf_parse_cache[$appname]) { |
|
331 | + public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) |
|
332 | + { |
|
333 | + if($appname) |
|
334 | + { |
|
335 | + if(!self::$cf_parse_cache[$appname]) |
|
336 | + { |
|
294 | 337 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
295 | 338 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
296 | 339 | } |
@@ -299,7 +342,10 @@ discard block |
||
299 | 342 | // Add in any fields that are keys to another app |
300 | 343 | foreach((array)$fields['links'] as $link_field => $app) |
301 | 344 | { |
302 | - if(is_numeric($link_field)) continue; |
|
345 | + if(is_numeric($link_field)) |
|
346 | + { |
|
347 | + continue; |
|
348 | + } |
|
303 | 349 | $links[$link_field] = $app; |
304 | 350 | // Set it as a normal link field |
305 | 351 | $fields['links'][] = $link_field; |
@@ -307,8 +353,10 @@ discard block |
||
307 | 353 | } |
308 | 354 | |
309 | 355 | // Not quite a recursive merge, since only one level |
310 | - foreach($fields as $type => &$list) { |
|
311 | - if($c_fields[$type]) { |
|
356 | + foreach($fields as $type => &$list) |
|
357 | + { |
|
358 | + if($c_fields[$type]) |
|
359 | + { |
|
312 | 360 | $list = array_merge($c_fields[$type], $list); |
313 | 361 | unset($c_fields[$type]); |
314 | 362 | } |
@@ -316,16 +364,22 @@ discard block |
||
316 | 364 | $fields += $c_fields; |
317 | 365 | $selects += $c_selects; |
318 | 366 | } |
319 | - foreach((array)$fields['select'] as $name) { |
|
320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
367 | + foreach((array)$fields['select'] as $name) |
|
368 | + { |
|
369 | + if($record->$name != null && is_array($selects) && $selects[$name]) |
|
370 | + { |
|
321 | 371 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
322 | - if(is_array($record->$name)) { |
|
372 | + if(is_array($record->$name)) |
|
373 | + { |
|
323 | 374 | $names = array(); |
324 | - foreach($record->$name as $_name) { |
|
375 | + foreach($record->$name as $_name) |
|
376 | + { |
|
325 | 377 | $names[] = lang($selects[$name][$_name]); |
326 | 378 | } |
327 | 379 | $record->$name = implode(', ', $names); |
328 | - } else { |
|
380 | + } |
|
381 | + else |
|
382 | + { |
|
329 | 383 | $record->$name = lang($selects[$name][$record->$name]); |
330 | 384 | } |
331 | 385 | } |
@@ -334,9 +388,12 @@ discard block |
||
334 | 388 | $record->$name = ''; |
335 | 389 | } |
336 | 390 | } |
337 | - foreach((array)$fields['links'] as $name) { |
|
338 | - if($record->$name) { |
|
339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
391 | + foreach((array)$fields['links'] as $name) |
|
392 | + { |
|
393 | + if($record->$name) |
|
394 | + { |
|
395 | + if(is_numeric($record->$name) && !$links[$name]) |
|
396 | + { |
|
340 | 397 | $link = Link::get_link($record->$name); |
341 | 398 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
342 | 399 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
@@ -355,16 +412,22 @@ discard block |
||
355 | 412 | $record->$name = ''; |
356 | 413 | } |
357 | 414 | } |
358 | - foreach((array)$fields['select-account'] as $name) { |
|
415 | + foreach((array)$fields['select-account'] as $name) |
|
416 | + { |
|
359 | 417 | // Compare against null to deal with empty arrays |
360 | - if ($record->$name !== null) { |
|
361 | - if(is_array($record->$name)) { |
|
418 | + if ($record->$name !== null) |
|
419 | + { |
|
420 | + if(is_array($record->$name)) |
|
421 | + { |
|
362 | 422 | $names = array(); |
363 | - foreach($record->$name as $_name) { |
|
423 | + foreach($record->$name as $_name) |
|
424 | + { |
|
364 | 425 | $names[] = Api\Accounts::username($_name); |
365 | 426 | } |
366 | 427 | $record->$name = implode(', ', $names); |
367 | - } else { |
|
428 | + } |
|
429 | + else |
|
430 | + { |
|
368 | 431 | $record->$name = Api\Accounts::username($record->$name); |
369 | 432 | } |
370 | 433 | } |
@@ -373,23 +436,49 @@ discard block |
||
373 | 436 | $record->$name = ''; |
374 | 437 | } |
375 | 438 | } |
376 | - foreach((array)$fields['select-bool'] as $name) { |
|
377 | - if($record->$name !== null) { |
|
439 | + foreach((array)$fields['select-bool'] as $name) |
|
440 | + { |
|
441 | + if($record->$name !== null) |
|
442 | + { |
|
378 | 443 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
379 | 444 | } |
380 | 445 | } |
381 | - foreach((array)$fields['date-time'] as $name) { |
|
446 | + foreach((array)$fields['date-time'] as $name) |
|
447 | + { |
|
382 | 448 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
383 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
386 | - if (!$record->$name) $record->$name = ''; |
|
449 | + if ($record->$name && !is_numeric($record->$name)) |
|
450 | + { |
|
451 | + $record->$name = strtotime($record->$name); |
|
452 | + } |
|
453 | + // Custom fields stored as string |
|
454 | + if ($record->$name && is_numeric($record->$name)) |
|
455 | + { |
|
456 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
457 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); |
|
458 | + } |
|
459 | + // User date format |
|
460 | + if (!$record->$name) |
|
461 | + { |
|
462 | + $record->$name = ''; |
|
463 | + } |
|
387 | 464 | } |
388 | - foreach((array)$fields['date'] as $name) { |
|
465 | + foreach((array)$fields['date'] as $name) |
|
466 | + { |
|
389 | 467 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
390 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
391 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
|
392 | - if (!$record->$name) $record->$name = ''; |
|
468 | + if ($record->$name && !is_numeric($record->$name)) |
|
469 | + { |
|
470 | + $record->$name = strtotime($record->$name); |
|
471 | + } |
|
472 | + // Custom fields stored as string |
|
473 | + if ($record->$name && is_numeric($record->$name)) |
|
474 | + { |
|
475 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); |
|
476 | + } |
|
477 | + // User date format |
|
478 | + if (!$record->$name) |
|
479 | + { |
|
480 | + $record->$name = ''; |
|
481 | + } |
|
393 | 482 | } |
394 | 483 | foreach((array)$fields['float'] as $name) |
395 | 484 | { |
@@ -397,7 +486,10 @@ discard block |
||
397 | 486 | if (is_null($dec_separator)) |
398 | 487 | { |
399 | 488 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
400 | - if (empty($dec_separator)) $dec_separator = '.'; |
|
489 | + if (empty($dec_separator)) |
|
490 | + { |
|
491 | + $dec_separator = '.'; |
|
492 | + } |
|
401 | 493 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
402 | 494 | } |
403 | 495 | if($record->$name && (string)$record->$name != '') |
@@ -413,17 +505,27 @@ discard block |
||
413 | 505 | } |
414 | 506 | |
415 | 507 | // Some custom methods for conversion |
416 | - foreach((array)$methods as $name => $method) { |
|
417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
508 | + foreach((array)$methods as $name => $method) |
|
509 | + { |
|
510 | + if($record->$name) |
|
511 | + { |
|
512 | + $record->$name = ExecMethod($method, $record->$name); |
|
513 | + } |
|
418 | 514 | } |
419 | 515 | |
420 | 516 | static $cat_object; |
421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
422 | - foreach((array)$fields['select-cat'] as $name) { |
|
423 | - if($record->$name) { |
|
517 | + if(is_null($cat_object)) |
|
518 | + { |
|
519 | + $cat_object = new Api\Categories(false,$appname); |
|
520 | + } |
|
521 | + foreach((array)$fields['select-cat'] as $name) |
|
522 | + { |
|
523 | + if($record->$name) |
|
524 | + { |
|
424 | 525 | $cats = array(); |
425 | 526 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
426 | - foreach($ids as $n => $cat_id) { |
|
527 | + foreach($ids as $n => $cat_id) |
|
528 | + { |
|
427 | 529 | |
428 | 530 | if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
429 | 531 | { |
@@ -444,7 +546,8 @@ discard block |
||
444 | 546 | * |
445 | 547 | * @return |
446 | 548 | */ |
447 | - public function __destruct() { |
|
549 | + public function __destruct() |
|
550 | + { |
|
448 | 551 | |
449 | 552 | } |
450 | 553 | |
@@ -457,11 +560,16 @@ discard block |
||
457 | 560 | * @param char $delimiter |
458 | 561 | * @param char $enclosure |
459 | 562 | */ |
460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
563 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) |
|
564 | + { |
|
461 | 565 | $string = ""; |
462 | 566 | $writeDelimiter = false; |
463 | - foreach($dataArray as $dataElement) { |
|
464 | - if($writeDelimiter) $string .= $delimiter; |
|
567 | + foreach($dataArray as $dataElement) |
|
568 | + { |
|
569 | + if($writeDelimiter) |
|
570 | + { |
|
571 | + $string .= $delimiter; |
|
572 | + } |
|
465 | 573 | $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
466 | 574 | $writeDelimiter = true; |
467 | 575 | } |