@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @param array $content=null |
79 | 79 | * @param string $msg='' |
80 | 80 | */ |
81 | - public function index(array $content=null, $msg='', $msg_type=null) |
|
81 | + public function index(array $content = null, $msg = '', $msg_type = null) |
|
82 | 82 | { |
83 | 83 | if (is_array($content)) |
84 | 84 | { |
85 | 85 | //_debug_array($content); |
86 | 86 | if ($content['sudo']) |
87 | 87 | { |
88 | - $msg = $this->sudo($content['user'],$content['password'],self::$is_setup) ? |
|
88 | + $msg = $this->sudo($content['user'], $content['password'], self::$is_setup) ? |
|
89 | 89 | lang('Root access granted.') : lang('Wrong username or password!'); |
90 | 90 | $msg_type = Vfs::$is_root ? 'success' : 'error'; |
91 | 91 | } |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | $backup = Vfs::$is_root; |
97 | 97 | Vfs::$is_root = true; |
98 | 98 | $msg = Vfs::mount($url, $path) ? |
99 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
99 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
100 | 100 | Vfs::$is_root = $backup; |
101 | 101 | } |
102 | 102 | elseif (Vfs::$is_root) |
103 | 103 | { |
104 | 104 | if ($content['logout']) |
105 | 105 | { |
106 | - $msg = $this->sudo('','',self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
106 | + $msg = $this->sudo('', '', self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
107 | 107 | $msg_type = !Vfs::$is_root ? 'success' : 'error'; |
108 | 108 | } |
109 | 109 | if ($content['mounts']['disable'] || self::$is_setup && $content['mounts']['umount']) |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | if (!in_array($path, self::$protected_path) && $path != '/') |
120 | 120 | { |
121 | 121 | $msg = Vfs::umount($path) ? |
122 | - lang('%1 successful unmounted.',$path) : lang('Error unmounting %1!',$path); |
|
122 | + lang('%1 successful unmounted.', $path) : lang('Error unmounting %1!', $path); |
|
123 | 123 | } |
124 | 124 | else // re-mount / with sqlFS, to disable versioning |
125 | 125 | { |
126 | - $msg = Vfs::mount($url=Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path,$path) ? |
|
127 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
126 | + $msg = Vfs::mount($url = Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path, $path) ? |
|
127 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | if (($path = $content['mounts']['path']) && |
131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
132 | 132 | { |
133 | - $url = str_replace('$path',$path,$content['mounts']['url']); |
|
133 | + $url = str_replace('$path', $path, $content['mounts']['url']); |
|
134 | 134 | if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
135 | 135 | |
136 | 136 | if ($content['mounts']['enable'] && !$this->versioning) |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | elseif (!Vfs::file_exists($path) || !Vfs::is_dir($path)) |
142 | 142 | { |
143 | - $msg = lang('Path %1 not found or not a directory!',$path); |
|
143 | + $msg = lang('Path %1 not found or not a directory!', $path); |
|
144 | 144 | $msg_type = 'error'; |
145 | 145 | } |
146 | 146 | // dont allow to change mount of /apps or /templates (eg. switching on versioning) |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - $msg = Vfs::mount($url,$path) ? |
|
155 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
154 | + $msg = Vfs::mount($url, $path) ? |
|
155 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | if ($content['allow_delete_versions'] != $GLOBALS['egw_info']['server']['allow_delete_versions']) |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | 'hidden' => true, |
198 | 198 | 'depth' => true, |
199 | 199 | 'path_preg' => '#/\.(attic|versions)/#', |
200 | - )+(!(int)$content['mtime'] ? array() : array( |
|
201 | - 'mtime' => ($content['mtime']<0?'-':'+').(int)$content['mtime'], |
|
200 | + ) + (!(int)$content['mtime'] ? array() : array( |
|
201 | + 'mtime' => ($content['mtime'] < 0 ? '-' : '+').(int)$content['mtime'], |
|
202 | 202 | )), function($path) use (&$deleted, &$errors) |
203 | 203 | { |
204 | 204 | if (($is_dir = Vfs::is_dir($path)) && Vfs::rmdir($path) || |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | }); |
214 | 214 | } |
215 | - $time = number_format(microtime(true)-$starttime, 1); |
|
215 | + $time = number_format(microtime(true) - $starttime, 1); |
|
216 | 216 | $msg = ($errors ? lang('%1 errors deleting!', $errors)."\n\n" : ''). |
217 | 217 | lang('%1 files or directories deleted in %2 seconds.', $deleted, $time); |
218 | 218 | $msg_type = $errors ? 'error' : 'info'; |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | { |
236 | 236 | // statistical information |
237 | 237 | $content += Versioning\StreamWrapper::summary(); |
238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
238 | + if ($content['total_files']) $content['percent_files'] = number_format(100.0 * $content['version_files'] / $content['total_files'], 1).'%'; |
|
239 | + if ($content['total_size']) $content['percent_size'] = number_format(100.0 * $content['version_size'] / $content['total_size'], 1).'%'; |
|
240 | 240 | } |
241 | - if (!($content['is_root']=Vfs::$is_root)) |
|
241 | + if (!($content['is_root'] = Vfs::$is_root)) |
|
242 | 242 | { |
243 | 243 | if (empty($msg)) |
244 | 244 | { |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | |
255 | 255 | $n = 2; |
256 | 256 | $content['mounts'] = array(); |
257 | - foreach(Vfs::mount() as $path => $url) |
|
257 | + foreach (Vfs::mount() as $path => $url) |
|
258 | 258 | { |
259 | 259 | $content['mounts'][$n++] = array( |
260 | 260 | 'path' => $path, |
261 | 261 | 'url' => $url, |
262 | 262 | ); |
263 | 263 | $readonlys["disable[$path]"] = !$this->versioning || !Vfs::$is_root || |
264 | - Vfs::parse_url($url,PHP_URL_SCHEME) != $this->versioning; |
|
264 | + Vfs::parse_url($url, PHP_URL_SCHEME) != $this->versioning; |
|
265 | 265 | } |
266 | - $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
266 | + $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
267 | 267 | $readonlys['url'] = !self::$is_setup; |
268 | 268 | |
269 | 269 | $sel_options['allow_delete_versions'] = array( |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | ); |
275 | 275 | // show [Mount /etemplates] button for admin, if not already mounted and available |
276 | 276 | $readonlys['etemplates'] = !class_exists('\EGroupware\Stylite\Vfs\Merge\StreamWrapper') || |
277 | - ($fs_tab=Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
277 | + ($fs_tab = Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
278 | 278 | !isset($GLOBALS['egw_info']['user']['apps']['admin']); |
279 | 279 | //_debug_array($content); |
280 | 280 | |
281 | 281 | $tpl = new Etemplate('filemanager.admin'); |
282 | 282 | $GLOBALS['egw_info']['flags']['app_header'] = lang('VFS mounts and versioning'); |
283 | - $tpl->exec('filemanager.filemanager_admin.index',$content,$sel_options,$readonlys); |
|
283 | + $tpl->exec('filemanager.filemanager_admin.index', $content, $sel_options, $readonlys); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | } |
301 | 301 | $content = '<p>'.implode("</p>\n<p>", (array)$msgs)."</p>\n"; |
302 | 302 | |
303 | - $content .= Api\Html::form('<p>'.($check_only&&is_array($msgs) ? |
|
303 | + $content .= Api\Html::form('<p>'.($check_only && is_array($msgs) ? |
|
304 | 304 | Api\Html::submit_button('fix', lang('Fix reported problems')) : ''). |
305 | 305 | Api\Html::submit_button('cancel', lang('Cancel')).'</p>', |
306 | - '','/index.php',array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
306 | + '', '/index.php', array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
307 | 307 | |
308 | 308 | $GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true); |
309 | 309 | } |
@@ -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 | { |
@@ -131,7 +131,10 @@ discard block |
||
131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
132 | 132 | { |
133 | 133 | $url = str_replace('$path',$path,$content['mounts']['url']); |
134 | - if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
|
134 | + if (empty($url) && $this->versioning) |
|
135 | + { |
|
136 | + $url = Versioning\StreamWrapper::PREFIX.$path; |
|
137 | + } |
|
135 | 138 | |
136 | 139 | if ($content['mounts']['enable'] && !$this->versioning) |
137 | 140 | { |
@@ -227,16 +230,25 @@ discard block |
||
227 | 230 | $content['versionedpath'] = '/'; |
228 | 231 | $content['mtime'] = 100; |
229 | 232 | } |
230 | - if (true) $content = array( |
|
233 | + if (true) |
|
234 | + { |
|
235 | + $content = array( |
|
231 | 236 | 'versionedpath' => $content['versionedpath'], |
232 | 237 | 'mtime' => $content['mtime'], |
233 | 238 | ); |
239 | + } |
|
234 | 240 | if ($this->versioning) |
235 | 241 | { |
236 | 242 | // statistical information |
237 | 243 | $content += Versioning\StreamWrapper::summary(); |
238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
244 | + if ($content['total_files']) |
|
245 | + { |
|
246 | + $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
247 | + } |
|
248 | + if ($content['total_size']) |
|
249 | + { |
|
250 | + $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | if (!($content['is_root']=Vfs::$is_root)) |
242 | 254 | { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param array $content |
67 | 67 | */ |
68 | - function select(array $content=null) |
|
68 | + function select(array $content = null) |
|
69 | 69 | { |
70 | 70 | if (!is_array($content)) |
71 | 71 | { |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | $content['msg'] = $_GET['msg']; |
77 | 77 | $_GET['mode'] = 'open'; |
78 | 78 | $_GET['method'] = 'ckeditor_return'; |
79 | - $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager','ckeditorfuncnum'); |
|
79 | + $_GET['CKEditorFuncNum'] = Api\Cache::getSession('filemanager', 'ckeditorfuncnum'); |
|
80 | 80 | } |
81 | 81 | $content['mode'] = $_GET['mode']; |
82 | - if (!in_array($content['mode'],array('open','open-multiple','saveas','select-dir'))) |
|
82 | + if (!in_array($content['mode'], array('open', 'open-multiple', 'saveas', 'select-dir'))) |
|
83 | 83 | { |
84 | 84 | throw new Api\Exception\WrongParameter("Wrong or unset required mode parameter!"); |
85 | 85 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | if (isset($_GET['CKEditorFuncNum']) && is_numeric($_GET['CKEditorFuncNum'])) |
96 | 96 | { |
97 | - Api\Cache::setSession('filemanager','ckeditorfuncnum', |
|
97 | + Api\Cache::setSession('filemanager', 'ckeditorfuncnum', |
|
98 | 98 | $content['ckeditorfuncnum'] = $_GET['CKEditorFuncNum']); |
99 | 99 | } |
100 | 100 | else |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | throw new Api\Exception\WrongParameter("chkeditor_return has been specified as a method but some parameters are missing or invalid."); |
103 | 103 | } |
104 | 104 | } |
105 | - $content['id'] = $_GET['id']; |
|
105 | + $content['id'] = $_GET['id']; |
|
106 | 106 | $content['label'] = isset($_GET['label']) ? $_GET['label'] : lang('Open'); |
107 | 107 | if (($content['options-mime'] = isset($_GET['mime']))) |
108 | 108 | { |
109 | 109 | $sel_options['mime'] = array(); |
110 | - foreach((array)$_GET['mime'] as $key => $value) |
|
110 | + foreach ((array)$_GET['mime'] as $key => $value) |
|
111 | 111 | { |
112 | 112 | if (is_numeric($key)) |
113 | 113 | { |
114 | - $sel_options['mime'][$value] = lang('%1 files',strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
114 | + $sel_options['mime'][$value] = lang('%1 files', strtoupper(Api\MimeMagic::mime2ext($value))).' ('.$value.')'; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
118 | - $sel_options['mime'][$key] = lang('%1 files',strtoupper($value)).' ('.$key.')'; |
|
118 | + $sel_options['mime'][$key] = lang('%1 files', strtoupper($value)).' ('.$key.')'; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | error_log(array2string($content['options-mime'])); |
124 | 124 | } |
125 | 125 | } |
126 | - elseif(isset($content['button'])) |
|
126 | + elseif (isset($content['button'])) |
|
127 | 127 | { |
128 | 128 | list($button) = each($content['button']); |
129 | 129 | unset($content['button']); |
130 | - switch($button) |
|
130 | + switch ($button) |
|
131 | 131 | { |
132 | 132 | case 'home': |
133 | 133 | $content['path'] = filemanager_ui::get_home_dir(); |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | //Set the "content" name filed accordingly to the uploaded file |
140 | 140 | // encode chars which special meaning in url/vfs (some like / get removed!) |
141 | 141 | $content['name'] = Vfs::encodePathComponent($content['file_upload']['name']); |
142 | - $to_path = Vfs::concat($content['path'],$content['name']); |
|
142 | + $to_path = Vfs::concat($content['path'], $content['name']); |
|
143 | 143 | |
144 | 144 | $copy_result = (Vfs::is_writable($content['path']) || Vfs::is_writable($to_path)) && |
145 | - copy($content['file_upload']['tmp_name'],Vfs::PREFIX.$to_path); |
|
145 | + copy($content['file_upload']['tmp_name'], Vfs::PREFIX.$to_path); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //Break on an error condition |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | break; |
162 | 162 | } |
163 | 163 | |
164 | - switch($content['mode']) |
|
164 | + switch ($content['mode']) |
|
165 | 165 | { |
166 | 166 | case 'open-multiple': |
167 | - foreach((array)$content['dir']['selected'] as $name) |
|
167 | + foreach ((array)$content['dir']['selected'] as $name) |
|
168 | 168 | { |
169 | - $files[] = Vfs::concat($content['path'],$name); |
|
169 | + $files[] = Vfs::concat($content['path'], $name); |
|
170 | 170 | } |
171 | 171 | //Add an uploaded file to the files result array2string |
172 | 172 | if ($copy_result === true) $files[] = $to_path; |
@@ -182,33 +182,33 @@ discard block |
||
182 | 182 | // Fall through |
183 | 183 | |
184 | 184 | default: |
185 | - $files = Vfs::concat($content['path'],$content['name']); |
|
185 | + $files = Vfs::concat($content['path'], $content['name']); |
|
186 | 186 | break; |
187 | 187 | } |
188 | 188 | |
189 | 189 | if ($content['method'] && $content['method'] != 'ckeditor_return') |
190 | 190 | { |
191 | - $js = ExecMethod2($content['method'],$content['id'],$files); |
|
191 | + $js = ExecMethod2($content['method'], $content['id'], $files); |
|
192 | 192 | } |
193 | 193 | else if ($content['method'] == 'ckeditor_return') |
194 | 194 | { |
195 | - $download_url = Vfs::download_url(Vfs::concat($content['path'],$content['name'])); |
|
195 | + $download_url = Vfs::download_url(Vfs::concat($content['path'], $content['name'])); |
|
196 | 196 | if ($download_url[0] == '/') $download_url = Egw::link($download_url); |
197 | 197 | $js = "window.opener.CKEDITOR.tools.callFunction(". |
198 | 198 | $content['ckeditorfuncnum'].",'". |
199 | 199 | htmlspecialchars($download_url)."',". |
200 | 200 | "'');\negw(window).close();"; |
201 | 201 | } |
202 | - if(Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
202 | + if (Api\Json\Response::isJSONResponse() && !($content['method'] == 'ckeditor_return')) |
|
203 | 203 | { |
204 | 204 | $response = Api\Json\Response::get(); |
205 | - if($js) |
|
205 | + if ($js) |
|
206 | 206 | { |
207 | 207 | $response->script($js); |
208 | 208 | } |
209 | 209 | // Ahh! |
210 | 210 | // The vfs-select widget looks for this |
211 | - $response->script('this.selected_files = '.json_encode($files) . '; egw(this).close();'); |
|
211 | + $response->script('this.selected_files = '.json_encode($files).'; egw(this).close();'); |
|
212 | 212 | } |
213 | 213 | else |
214 | 214 | { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | $sel_options['mime'] = $content['options-mime']; |
222 | 222 | } |
223 | - elseif(isset($content['apps'])) |
|
223 | + elseif (isset($content['apps'])) |
|
224 | 224 | { |
225 | 225 | list($app) = each($content['apps']); |
226 | 226 | if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir(); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | //Deactivate the opload field if the current directory is not writeable or |
230 | 230 | //we're currently not in the single file open mode. |
231 | 231 | $content['no_upload'] = !Vfs::is_writable($content['path']) || |
232 | - !in_array($content['mode'],array('open')); |
|
232 | + !in_array($content['mode'], array('open')); |
|
233 | 233 | |
234 | 234 | $content['apps'] = array_keys(self::get_apps()); |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | // Set a flag for easy detection as we go |
242 | - $favorites_flag = substr($content['path'],0,strlen('/apps/favorites')) == '/apps/favorites'; |
|
242 | + $favorites_flag = substr($content['path'], 0, strlen('/apps/favorites')) == '/apps/favorites'; |
|
243 | 243 | |
244 | 244 | if (!$favorites_flag && (!$content['path'] || !Vfs::is_dir($content['path']))) |
245 | 245 | { |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | $files = array(); |
254 | 254 | $favorites = Framework\Favorites::get_favorites('filemanager'); |
255 | 255 | $n = 0; |
256 | - foreach($favorites as $favorite) |
|
256 | + foreach ($favorites as $favorite) |
|
257 | 257 | { |
258 | 258 | $path = $favorite['state']['path']; |
259 | 259 | // Just directories |
260 | - if(!$path) continue; |
|
261 | - if ($path == $content['path']) continue; // remove directory itself |
|
260 | + if (!$path) continue; |
|
261 | + if ($path == $content['path']) continue; // remove directory itself |
|
262 | 262 | |
263 | 263 | $mime = Vfs::mime_content_type($path); |
264 | 264 | $content['dir'][$n] = array( |
@@ -274,29 +274,29 @@ discard block |
||
274 | 274 | ++$n; |
275 | 275 | } |
276 | 276 | } |
277 | - else if (!($files = Vfs::find($content['path'],array( |
|
277 | + else if (!($files = Vfs::find($content['path'], array( |
|
278 | 278 | 'dirsontop' => true, |
279 | 279 | 'order' => 'name', |
280 | 280 | 'sort' => 'ASC', |
281 | 281 | 'maxdepth' => 1, |
282 | 282 | )))) |
283 | 283 | { |
284 | - $content['msg'] = lang("Can't open directory %1!",$content['path']); |
|
284 | + $content['msg'] = lang("Can't open directory %1!", $content['path']); |
|
285 | 285 | } |
286 | 286 | else |
287 | 287 | { |
288 | 288 | $n = 0; |
289 | 289 | $content['dir'] = array('mode' => $content['mode']); |
290 | - foreach($files as $path) |
|
290 | + foreach ($files as $path) |
|
291 | 291 | { |
292 | - if ($path == $content['path']) continue; // remove directory itself |
|
292 | + if ($path == $content['path']) continue; // remove directory itself |
|
293 | 293 | |
294 | 294 | $name = Vfs::basename($path); |
295 | 295 | $is_dir = Vfs::is_dir($path); |
296 | 296 | $mime = Vfs::mime_content_type($path); |
297 | 297 | if ($content['mime'] && !$is_dir && $mime != $content['mime']) |
298 | 298 | { |
299 | - continue; // does not match mime-filter --> ignore |
|
299 | + continue; // does not match mime-filter --> ignore |
|
300 | 300 | } |
301 | 301 | $content['dir'][$n] = array( |
302 | 302 | 'name' => $name, |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | ++$n; |
312 | 312 | } |
313 | - if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
313 | + if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
314 | 314 | } |
315 | 315 | $readonlys['button[createdir]'] = !Vfs::is_writable($content['path']); |
316 | 316 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | { |
338 | 338 | Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline'); |
339 | 339 | } |
340 | - $tpl->exec('filemanager.filemanager_select.select',$content,$sel_options,$readonlys,$preserve,2); |
|
340 | + $tpl->exec('filemanager.filemanager_select.select', $content, $sel_options, $readonlys, $preserve, 2); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | */ |
348 | 348 | static function get_apps() |
349 | 349 | { |
350 | - $apps = array(false); // index starting from 1 |
|
350 | + $apps = array(false); // index starting from 1 |
|
351 | 351 | if (isset($GLOBALS['egw_info']['apps']['stylite'])) $apps = array('favorites' => lang('Favorites')); |
352 | 352 | $apps += Link::app_list('query'); |
353 | 353 | |
354 | - unset($apps['mydms']); // they do NOT support adding files to VFS |
|
354 | + unset($apps['mydms']); // they do NOT support adding files to VFS |
|
355 | 355 | unset($apps['wiki']); |
356 | 356 | unset($apps['api-accounts']); |
357 | 357 | unset($apps['addressbook-email']); |
@@ -169,7 +169,10 @@ discard block |
||
169 | 169 | $files[] = Vfs::concat($content['path'],$name); |
170 | 170 | } |
171 | 171 | //Add an uploaded file to the files result array2string |
172 | - if ($copy_result === true) $files[] = $to_path; |
|
172 | + if ($copy_result === true) |
|
173 | + { |
|
174 | + $files[] = $to_path; |
|
175 | + } |
|
173 | 176 | break; |
174 | 177 | |
175 | 178 | case 'select-dir': |
@@ -193,7 +196,10 @@ discard block |
||
193 | 196 | else if ($content['method'] == 'ckeditor_return') |
194 | 197 | { |
195 | 198 | $download_url = Vfs::download_url(Vfs::concat($content['path'],$content['name'])); |
196 | - if ($download_url[0] == '/') $download_url = Egw::link($download_url); |
|
199 | + if ($download_url[0] == '/') |
|
200 | + { |
|
201 | + $download_url = Egw::link($download_url); |
|
202 | + } |
|
197 | 203 | $js = "window.opener.CKEDITOR.tools.callFunction(". |
198 | 204 | $content['ckeditorfuncnum'].",'". |
199 | 205 | htmlspecialchars($download_url)."',". |
@@ -223,7 +229,10 @@ discard block |
||
223 | 229 | elseif(isset($content['apps'])) |
224 | 230 | { |
225 | 231 | list($app) = each($content['apps']); |
226 | - if ($app == 'home') $content['path'] = filemanager_ui::get_home_dir(); |
|
232 | + if ($app == 'home') |
|
233 | + { |
|
234 | + $content['path'] = filemanager_ui::get_home_dir(); |
|
235 | + } |
|
227 | 236 | } |
228 | 237 | |
229 | 238 | //Deactivate the opload field if the current directory is not writeable or |
@@ -257,8 +266,15 @@ discard block |
||
257 | 266 | { |
258 | 267 | $path = $favorite['state']['path']; |
259 | 268 | // Just directories |
260 | - if(!$path) continue; |
|
261 | - if ($path == $content['path']) continue; // remove directory itself |
|
269 | + if(!$path) |
|
270 | + { |
|
271 | + continue; |
|
272 | + } |
|
273 | + if ($path == $content['path']) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
277 | + // remove directory itself |
|
262 | 278 | |
263 | 279 | $mime = Vfs::mime_content_type($path); |
264 | 280 | $content['dir'][$n] = array( |
@@ -289,7 +305,11 @@ discard block |
||
289 | 305 | $content['dir'] = array('mode' => $content['mode']); |
290 | 306 | foreach($files as $path) |
291 | 307 | { |
292 | - if ($path == $content['path']) continue; // remove directory itself |
|
308 | + if ($path == $content['path']) |
|
309 | + { |
|
310 | + continue; |
|
311 | + } |
|
312 | + // remove directory itself |
|
293 | 313 | |
294 | 314 | $name = Vfs::basename($path); |
295 | 315 | $is_dir = Vfs::is_dir($path); |
@@ -310,7 +330,11 @@ discard block |
||
310 | 330 | } |
311 | 331 | ++$n; |
312 | 332 | } |
313 | - if (!$n) $readonlys['selected[]'] = true; // remove checkbox from empty line |
|
333 | + if (!$n) |
|
334 | + { |
|
335 | + $readonlys['selected[]'] = true; |
|
336 | + } |
|
337 | + // remove checkbox from empty line |
|
314 | 338 | } |
315 | 339 | $readonlys['button[createdir]'] = !Vfs::is_writable($content['path']); |
316 | 340 | |
@@ -348,7 +372,10 @@ discard block |
||
348 | 372 | static function get_apps() |
349 | 373 | { |
350 | 374 | $apps = array(false); // index starting from 1 |
351 | - if (isset($GLOBALS['egw_info']['apps']['stylite'])) $apps = array('favorites' => lang('Favorites')); |
|
375 | + if (isset($GLOBALS['egw_info']['apps']['stylite'])) |
|
376 | + { |
|
377 | + $apps = array('favorites' => lang('Favorites')); |
|
378 | + } |
|
352 | 379 | $apps += Link::app_list('query'); |
353 | 380 | |
354 | 381 | unset($apps['mydms']); // they do NOT support adding files to VFS |
@@ -123,7 +123,7 @@ |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | parent::__construct(); |
62 | 62 | |
63 | - if($_dir) |
|
63 | + if ($_dir) |
|
64 | 64 | { |
65 | 65 | $this->dir = $_dir; |
66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string &$content=null content to create some replacements only if they are use |
77 | 77 | * @return array|boolean |
78 | 78 | */ |
79 | - protected function get_replacements($id,&$content=null) |
|
79 | + protected function get_replacements($id, &$content = null) |
|
80 | 80 | { |
81 | 81 | if (!($replacements = $this->filemanager_replacements($id, '', $content))) |
82 | 82 | { |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | * @param string $prefix='' prefix like eg. 'erole' |
93 | 93 | * @return array|boolean |
94 | 94 | */ |
95 | - public function filemanager_replacements($id,$prefix='', &$content = null) |
|
95 | + public function filemanager_replacements($id, $prefix = '', &$content = null) |
|
96 | 96 | { |
97 | 97 | $info = array(); |
98 | - $file = Vfs::lstat($id,true); |
|
98 | + $file = Vfs::lstat($id, true); |
|
99 | 99 | |
100 | 100 | $file['mtime'] = Api\DateTime::to($file['mtime']); |
101 | 101 | $file['ctime'] = Api\DateTime::to($file['ctime']); |
102 | 102 | |
103 | 103 | $file['name'] = Vfs::basename($id); |
104 | 104 | $file['dir'] = Vfs::decodePath(Vfs::dirname($id)); |
105 | - $dirlist = explode('/',$file['dir']); |
|
105 | + $dirlist = explode('/', $file['dir']); |
|
106 | 106 | $file['folder'] = array_pop($dirlist); |
107 | - $file['folder_file'] = $file['folder'] . '/'.$file['name']; |
|
107 | + $file['folder_file'] = $file['folder'].'/'.$file['name']; |
|
108 | 108 | $file['path'] = $id; |
109 | 109 | $file['rel_path'] = str_replace($this->dir.'/', '', $id); |
110 | 110 | $file['hsize'] = Vfs::hsize($file['size']); |
111 | 111 | $file['mime'] = Vfs::mime_content_type($id); |
112 | - $file['gid'] *= -1; // our widgets use negative gid's |
|
112 | + $file['gid'] *= -1; // our widgets use negative gid's |
|
113 | 113 | if (($props = Vfs::propfind($id))) |
114 | 114 | { |
115 | - foreach($props as $prop) |
|
115 | + foreach ($props as $prop) |
|
116 | 116 | { |
117 | 117 | $file[$prop['name']] = $prop['val']; |
118 | 118 | } |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $file['symlink'] = Vfs::readlink($id); |
123 | 123 | } |
124 | 124 | // Custom fields |
125 | - if($content && strpos($content, '#') !== 0) |
|
125 | + if ($content && strpos($content, '#') !== 0) |
|
126 | 126 | { |
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
130 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
130 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
131 | 131 | { |
132 | 132 | // Set any missing custom fields, or the marker will stay |
133 | - if(!$file['#'.$name]) |
|
133 | + if (!$file['#'.$name]) |
|
134 | 134 | { |
135 | 135 | $file['#'.$name] = ''; |
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Format date cfs per user Api\Preferences |
140 | - if($field['type'] == 'date' || $field['type'] == 'date-time') |
|
140 | + if ($field['type'] == 'date' || $field['type'] == 'date-time') |
|
141 | 141 | { |
142 | 142 | $this->date_fields[] = '#'.$name; |
143 | 143 | $file['#'.$name] = Api\DateTime::to($file['#'.$name], $field['type'] == 'date' ? true : ''); |
@@ -146,51 +146,51 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // If in apps folder, try for app-specific placeholders |
149 | - if($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
149 | + if ($dirlist[1] == 'apps' && count($dirlist) > 1) |
|
150 | 150 | { |
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | - list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
|
152 | + list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5)); |
|
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
155 | 155 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | - $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
|
157 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
156 | + $resolved = Vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4))); |
|
157 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
158 | 158 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
159 | + if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | 160 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 161 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | - list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
|
162 | + list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5)); |
|
163 | 163 | } |
164 | 164 | } |
165 | - if($app && $app_id) |
|
165 | + if ($app && $app_id) |
|
166 | 166 | { |
167 | - if($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
167 | + if ($app && $GLOBALS['egw_info']['user']['apps'][$app]) |
|
168 | 168 | { |
169 | 169 | $app_merge = null; |
170 | 170 | try |
171 | 171 | { |
172 | - $classname = $app .'_merge'; |
|
173 | - if(class_exists($classname)) |
|
172 | + $classname = $app.'_merge'; |
|
173 | + if (class_exists($classname)) |
|
174 | 174 | { |
175 | 175 | $app_merge = new $classname(); |
176 | - if($app_merge && method_exists($app_merge, 'get_replacements')) |
|
176 | + if ($app_merge && method_exists($app_merge, 'get_replacements')) |
|
177 | 177 | { |
178 | 178 | $app_placeholders = $app_merge->get_replacements($app_id, $content); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | 182 | // Silently discard & continue |
183 | - catch(Exception $e) { |
|
184 | - unset($e); // not used |
|
183 | + catch (Exception $e) { |
|
184 | + unset($e); // not used |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
189 | 189 | $link = Link::mime_open($file['url'], $file['mime']); |
190 | - if(is_array($link)) |
|
190 | + if (is_array($link)) |
|
191 | 191 | { |
192 | 192 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
193 | + if ($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
194 | 194 | $link = Api\Session::link('/index.php', $link); |
195 | 195 | } |
196 | 196 | else |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | $file['url'] = $link; |
210 | 210 | |
211 | 211 | // Add markers |
212 | - foreach($file as $key => &$value) |
|
212 | + foreach ($file as $key => &$value) |
|
213 | 213 | { |
214 | - if(!$value) $value = ''; |
|
215 | - $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
|
214 | + if (!$value) $value = ''; |
|
215 | + $info['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value; |
|
216 | 216 | } |
217 | - if($app_placeholders) |
|
217 | + if ($app_placeholders) |
|
218 | 218 | { |
219 | 219 | $info = array_merge($app_placeholders, $info); |
220 | 220 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'hsize' => 'Size', |
251 | 251 | 'size' => 'Size (in bytes)', |
252 | 252 | ); |
253 | - foreach($fields as $name => $label) |
|
253 | + foreach ($fields as $name => $label) |
|
254 | 254 | { |
255 | 255 | if (!($n&1)) echo '<tr>'; |
256 | 256 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
262 | - foreach(Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
262 | + foreach (Api\Storage\Customfields::get('filemanager') as $name => $field) |
|
263 | 263 | { |
264 | 264 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
265 | 265 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | echo '<tr><td colspan="4">'.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available. See the specific application for a list of available placeholders.').'</td></tr>'; |
269 | 269 | |
270 | 270 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
271 | - foreach(array( |
|
271 | + foreach (array( |
|
272 | 272 | 'date' => lang('Date'), |
273 | 273 | 'user/n_fn' => lang('Name of current user, all other contact fields are valid too'), |
274 | 274 | 'user/account_lid' => lang('Username'), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | // Custom fields |
125 | 125 | if($content && strpos($content, '#') !== 0) |
126 | - { |
|
126 | + { |
|
127 | 127 | // Expand link-to custom fields |
128 | 128 | $this->cf_link_to_expand($file, $content, $info); |
129 | 129 | |
@@ -151,12 +151,14 @@ discard block |
||
151 | 151 | // Try this first - a normal path /apps/appname/id/file |
152 | 152 | list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5)); |
153 | 153 | // Symlink? |
154 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
154 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
155 | + { |
|
155 | 156 | // Try resolving just app + ID - /apps/App Name/Record Title/file |
156 | 157 | $resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4))); |
157 | 158 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
158 | 159 | |
159 | - if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) { |
|
160 | + if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) |
|
161 | + { |
|
160 | 162 | // Get rid of any virtual folders (eg: All$) and symlinks |
161 | 163 | $resolved = Vfs::resolve_url_symlinks($file['path']); |
162 | 164 | list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5)); |
@@ -190,7 +192,10 @@ discard block |
||
190 | 192 | if(is_array($link)) |
191 | 193 | { |
192 | 194 | // Directories have their internal protocol in path here |
193 | - if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path']; |
|
195 | + if($link['path'] && strpos($link['path'], '://') !== false) |
|
196 | + { |
|
197 | + $link['path'] = $file['path']; |
|
198 | + } |
|
194 | 199 | $link = Api\Session::link('/index.php', $link); |
195 | 200 | } |
196 | 201 | else |
@@ -211,7 +216,10 @@ discard block |
||
211 | 216 | // Add markers |
212 | 217 | foreach($file as $key => &$value) |
213 | 218 | { |
214 | - if(!$value) $value = ''; |
|
219 | + if(!$value) |
|
220 | + { |
|
221 | + $value = ''; |
|
222 | + } |
|
215 | 223 | $info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value; |
216 | 224 | } |
217 | 225 | if($app_placeholders) |
@@ -252,9 +260,15 @@ discard block |
||
252 | 260 | ); |
253 | 261 | foreach($fields as $name => $label) |
254 | 262 | { |
255 | - if (!($n&1)) echo '<tr>'; |
|
263 | + if (!($n&1)) |
|
264 | + { |
|
265 | + echo '<tr>'; |
|
266 | + } |
|
256 | 267 | echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>'; |
257 | - if ($n&1) echo "</tr>\n"; |
|
268 | + if ($n&1) |
|
269 | + { |
|
270 | + echo "</tr>\n"; |
|
271 | + } |
|
258 | 272 | $n++; |
259 | 273 | } |
260 | 274 |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | $context['appname'] = 'filemanager'; |
29 | 29 | |
30 | 30 | // Let parent handle the basic stuff |
31 | - parent::__construct($context,$need_reload); |
|
31 | + parent::__construct($context, $need_reload); |
|
32 | 32 | |
33 | 33 | $this->nm_settings += array( |
34 | 34 | 'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows', |
35 | 35 | 'csv_export' => true, |
36 | 36 | // Use a different template so it can be accessed from client side |
37 | - 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows' ), |
|
37 | + 'template' => ($this->nm_settings['view'] == 'tile' ? 'filemanager.tile' : 'filemanager.home.rows'), |
|
38 | 38 | // Filemanager needs this header, it's an important component for actions, but we reduce it to the minimum |
39 | 39 | 'header_left' => 'filemanager.home.header_left', |
40 | 40 | // Use a reduced column set for home, user can change if needed |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | 'parent_id' => 'dir', |
47 | 47 | 'is_parent' => 'mime', |
48 | 48 | 'is_parent_value'=> Vfs::DIR_MIME_TYPE, |
49 | - 'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
49 | + 'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
53 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
54 | 54 | { |
55 | 55 | |
56 | 56 | $this->context['sel_options']['filter'] = array( |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $ui = new filemanager_ui(); |
81 | 81 | $total = $ui->get_rows($query, $rows, $readonlys); |
82 | 82 | // Change template to match selected view |
83 | - if($query['view']) |
|
83 | + if ($query['view']) |
|
84 | 84 | { |
85 | 85 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.home.rows' : 'filemanager.tile'); |
86 | 86 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | // the etemplate exec to fire again. |
104 | 104 | if ($content['nm']['action']) |
105 | 105 | { |
106 | - $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
107 | - if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
108 | - foreach($content['nm']['selected'] as &$id) |
|
106 | + $msg = filemanager_ui::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
107 | + if ($msg) Api\Json\Response::get()->apply('egw.message', array($msg)); |
|
108 | + foreach ($content['nm']['selected'] as &$id) |
|
109 | 109 | { |
110 | 110 | $id = 'filemanager::'.$id; |
111 | 111 | } |
112 | 112 | // Directly request an update - this will get filemanager tab too |
113 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected'])); |
|
113 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected'])); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | 117 | \ No newline at end of file |
@@ -86,8 +86,6 @@ |
||
86 | 86 | * Here we need to handle any incoming data. Setup is done in the constructor, |
87 | 87 | * output is handled by parent. |
88 | 88 | * |
89 | - * @param type $id |
|
90 | - * @param Etemplate $etemplate |
|
91 | 89 | */ |
92 | 90 | public static function process($content = array()) |
93 | 91 | { |
@@ -104,7 +104,10 @@ |
||
104 | 104 | if ($content['nm']['action']) |
105 | 105 | { |
106 | 106 | $msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
107 | - if($msg) Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
107 | + if($msg) |
|
108 | + { |
|
109 | + Api\Json\Response::get()->apply('egw.message',array($msg)); |
|
110 | + } |
|
108 | 111 | foreach($content['nm']['selected'] as &$id) |
109 | 112 | { |
110 | 113 | $id = 'filemanager::'.$id; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called) |
51 | 51 | */ |
52 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
52 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
53 | 53 | { |
54 | 54 | if (false) parent::__construct(); |
55 | 55 |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | use EGroupware\Api; |
17 | 17 | use EGroupware\Api\Vfs; |
18 | 18 | |
19 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
19 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
20 | 20 | |
21 | -error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED); |
|
21 | +error_reporting(error_reporting()&~E_NOTICE&~E_DEPRECATED); |
|
22 | 22 | |
23 | 23 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling filemanager/cli.php as web-page |
24 | 24 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $error_msg ='' error-message to be printed in front of usage |
49 | 49 | */ |
50 | -function usage($error_msg='') |
|
50 | +function usage($error_msg = '') |
|
51 | 51 | { |
52 | 52 | if ($error_msg) |
53 | 53 | { |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | } |
82 | 82 | $long = $numeric = $recursive = $perms = $all = $inode = false; |
83 | 83 | $args = $_SERVER['argv']; |
84 | -$cmd = basename(array_shift($args),'.php'); |
|
85 | -if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0],'://') === false) |
|
84 | +$cmd = basename(array_shift($args), '.php'); |
|
85 | +if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0], '://') === false) |
|
86 | 86 | { |
87 | 87 | $cmd = array_shift($args); |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if (!$args) $args = array('-h'); |
91 | 91 | |
92 | 92 | $argv = $find_options = array(); |
93 | -while(!is_null($option = array_shift($args))) |
|
93 | +while (!is_null($option = array_shift($args))) |
|
94 | 94 | { |
95 | 95 | if ($option == '-' || $option[0] != '-') // no option --> argument |
96 | 96 | { |
@@ -98,34 +98,34 @@ discard block |
||
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | |
101 | - switch($option) |
|
101 | + switch ($option) |
|
102 | 102 | { |
103 | 103 | default: |
104 | 104 | if ($cmd == 'find') |
105 | 105 | { |
106 | - if (!in_array($option,array('-type','-depth','-mindepth','-maxdepth','-name','-path', |
|
107 | - '-uid','-user','-nouser','-gid','-group','-nogroup','-mime', |
|
108 | - '-empty','-size','-cmin','-ctime','-mmin','-mtime','-limit','-order','-sort', |
|
109 | - '-hidden','-show-deleted','-name-preg','-path','-path-preg'))) |
|
106 | + if (!in_array($option, array('-type', '-depth', '-mindepth', '-maxdepth', '-name', '-path', |
|
107 | + '-uid', '-user', '-nouser', '-gid', '-group', '-nogroup', '-mime', |
|
108 | + '-empty', '-size', '-cmin', '-ctime', '-mmin', '-mtime', '-limit', '-order', '-sort', |
|
109 | + '-hidden', '-show-deleted', '-name-preg', '-path', '-path-preg'))) |
|
110 | 110 | { |
111 | 111 | usage("Unknown find option '$option'!"); |
112 | 112 | } |
113 | - if (in_array($option,array('-empty','-depth','-nouser','-nogroup','-hidden','-show-deleted'))) |
|
113 | + if (in_array($option, array('-empty', '-depth', '-nouser', '-nogroup', '-hidden', '-show-deleted'))) |
|
114 | 114 | { |
115 | - $find_options[substr($option,1)] = true; |
|
115 | + $find_options[substr($option, 1)] = true; |
|
116 | 116 | } |
117 | 117 | else |
118 | 118 | { |
119 | - $find_options[str_replace('-','_',substr($option,1))] = array_shift($args); |
|
119 | + $find_options[str_replace('-', '_', substr($option, 1))] = array_shift($args); |
|
120 | 120 | } |
121 | 121 | break; |
122 | 122 | } |
123 | 123 | // multiple options, eg. -rp --> -r -p |
124 | - elseif($option[0] == '-' && $option[1] != '-' && strlen($option) > 2) |
|
124 | + elseif ($option[0] == '-' && $option[1] != '-' && strlen($option) > 2) |
|
125 | 125 | { |
126 | - for($i = 1; $i < strlen($option); ++$i) |
|
126 | + for ($i = 1; $i < strlen($option); ++$i) |
|
127 | 127 | { |
128 | - array_unshift($args,'-'.$option[$i]); |
|
128 | + array_unshift($args, '-'.$option[$i]); |
|
129 | 129 | } |
130 | 130 | break; |
131 | 131 | } |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | } |
182 | 182 | if ($user && $passwd) |
183 | 183 | { |
184 | - load_egw($user,$passwd,$domain ? $domain : 'default'); |
|
184 | + load_egw($user, $passwd, $domain ? $domain : 'default'); |
|
185 | 185 | } |
186 | 186 | $argc = count($argv); |
187 | 187 | |
188 | -switch($cmd) |
|
188 | +switch ($cmd) |
|
189 | 189 | { |
190 | 190 | case 'umount': |
191 | 191 | if ($argc != 1 && !$all) |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | usage('Wrong number of parameters!'); |
194 | 194 | } |
195 | 195 | if (($url = $argv[0])) load_wrapper($url); |
196 | - if(!Vfs::$is_root) |
|
196 | + if (!Vfs::$is_root) |
|
197 | 197 | { |
198 | 198 | die("You need to be root to do that!\n"); |
199 | 199 | } |
200 | 200 | if ($all) |
201 | 201 | { |
202 | - Api\Config::save_value('vfs_fstab',$GLOBALS['egw_info']['server']['vfs_fstab']='','phpgwapi'); |
|
202 | + Api\Config::save_value('vfs_fstab', $GLOBALS['egw_info']['server']['vfs_fstab'] = '', 'phpgwapi'); |
|
203 | 203 | echo "Restored default mounts:\n"; |
204 | 204 | } |
205 | 205 | elseif (!Vfs::umount($url)) |
@@ -216,16 +216,16 @@ discard block |
||
216 | 216 | { |
217 | 217 | usage('Wrong number of parameters!'); |
218 | 218 | } |
219 | - load_wrapper($url=$argv[0]); |
|
219 | + load_wrapper($url = $argv[0]); |
|
220 | 220 | |
221 | - if($argc > 1 && !Vfs::$is_root) |
|
221 | + if ($argc > 1 && !Vfs::$is_root) |
|
222 | 222 | { |
223 | 223 | die("You need to be root to do that!\n"); |
224 | 224 | } |
225 | - $fstab = Vfs::mount($url,$path=$argv[1]); |
|
225 | + $fstab = Vfs::mount($url, $path = $argv[1]); |
|
226 | 226 | if (is_array($fstab)) |
227 | 227 | { |
228 | - foreach($fstab as $path => $url) |
|
228 | + foreach ($fstab as $path => $url) |
|
229 | 229 | { |
230 | 230 | echo "$url\t$path\n"; |
231 | 231 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | break; |
246 | 246 | |
247 | 247 | case 'find': |
248 | - do_find($argv,$find_options); |
|
248 | + do_find($argv, $find_options); |
|
249 | 249 | break; |
250 | 250 | |
251 | 251 | case 'lntree': |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | break; |
254 | 254 | |
255 | 255 | case 'cp': |
256 | - do_cp($argv,$recursive,$perms); |
|
256 | + do_cp($argv, $recursive, $perms); |
|
257 | 257 | break; |
258 | 258 | |
259 | 259 | case 'rename': |
260 | 260 | if (count($argv) != 2) usage('Wrong number of parameters!'); |
261 | 261 | load_wrapper($argv[0]); |
262 | 262 | load_wrapper($argv[1]); |
263 | - rename($argv[0],$argv[1]); |
|
263 | + rename($argv[0], $argv[1]); |
|
264 | 264 | break; |
265 | 265 | |
266 | 266 | case 'migrate-db2fs': |
@@ -268,21 +268,21 @@ discard block |
||
268 | 268 | { |
269 | 269 | die("\nYou need to be root to do that!\n\n"); |
270 | 270 | } |
271 | - if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
271 | + if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
272 | 272 | $fstab = Vfs::mount(); |
273 | - if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false) |
|
273 | + if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'], 'storage=db') === false) |
|
274 | 274 | { |
275 | - foreach($fstab as $path => $url) |
|
275 | + foreach ($fstab as $path => $url) |
|
276 | 276 | { |
277 | 277 | echo "$url\t$path\n"; |
278 | 278 | } |
279 | 279 | die("\n/ NOT mounted with 'storage=db' --> no need to convert!\n\n"); |
280 | 280 | } |
281 | - $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
|
281 | + $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
|
282 | 282 | echo "\n$num_files files migrated from DB to filesystem.\n"; |
283 | - $new_url = preg_replace('/storage=db&?/','',$fstab['/']); |
|
284 | - if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1); |
|
285 | - if (Vfs::mount($new_url,'/')) |
|
283 | + $new_url = preg_replace('/storage=db&?/', '', $fstab['/']); |
|
284 | + if (substr($new_url, -1) == '?') $new_url = substr($new_url, 0, -1); |
|
285 | + if (Vfs::mount($new_url, '/')) |
|
286 | 286 | { |
287 | 287 | echo "/ successful re-mounted on $new_url\n"; |
288 | 288 | } |
@@ -293,24 +293,24 @@ discard block |
||
293 | 293 | break; |
294 | 294 | |
295 | 295 | default: |
296 | - while($argv) |
|
296 | + while ($argv) |
|
297 | 297 | { |
298 | 298 | $url = array_shift($argv); |
299 | 299 | |
300 | 300 | load_wrapper($url); |
301 | 301 | echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.", recursive=".(int)$recursive.")\n"; |
302 | 302 | |
303 | - switch($cmd) |
|
303 | + switch ($cmd) |
|
304 | 304 | { |
305 | 305 | case 'rm': |
306 | 306 | if ($recursive) |
307 | 307 | { |
308 | 308 | if (!class_exists('egw_vfs')) |
309 | 309 | { |
310 | - die("rm -r only implemented for eGW streams!"); // dont want to repeat the code here |
|
310 | + die("rm -r only implemented for eGW streams!"); // dont want to repeat the code here |
|
311 | 311 | } |
312 | - array_unshift($argv,$url); |
|
313 | - Vfs::remove($argv,true); |
|
312 | + array_unshift($argv, $url); |
|
313 | + Vfs::remove($argv, true); |
|
314 | 314 | $argv = array(); |
315 | 315 | } |
316 | 316 | else |
@@ -324,27 +324,27 @@ discard block |
||
324 | 324 | break; |
325 | 325 | |
326 | 326 | case 'mkdir': |
327 | - if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n"; |
|
327 | + if (!mkdir($url, null, $recursive)) echo "Can't create directory, permission denied!\n"; |
|
328 | 328 | break; |
329 | 329 | |
330 | 330 | case 'touch': |
331 | 331 | case 'chmod': |
332 | 332 | case 'chown': |
333 | 333 | case 'chgrp': |
334 | - switch($cmd) |
|
334 | + switch ($cmd) |
|
335 | 335 | { |
336 | 336 | case 'touch': |
337 | - $params = array($url,$time); |
|
337 | + $params = array($url, $time); |
|
338 | 338 | break; |
339 | 339 | case 'chmod': |
340 | 340 | if (!isset($mode)) |
341 | 341 | { |
342 | - $mode = $url; // first param is mode |
|
342 | + $mode = $url; // first param is mode |
|
343 | 343 | $url = array_shift($argv); |
344 | 344 | } |
345 | - if (Vfs::parse_url($url,PHP_URL_SCHEME)) load_wrapper($url); // cant use stat or Vfs::mode2int otherwise! |
|
345 | + if (Vfs::parse_url($url, PHP_URL_SCHEME)) load_wrapper($url); // cant use stat or Vfs::mode2int otherwise! |
|
346 | 346 | |
347 | - if (strpos($mode,'+') !== false || strpos($mode,'-') !== false) |
|
347 | + if (strpos($mode, '+') !== false || strpos($mode, '-') !== false) |
|
348 | 348 | { |
349 | 349 | $stat = stat($url); |
350 | 350 | $set = $stat['mode']; |
@@ -355,19 +355,19 @@ discard block |
||
355 | 355 | } |
356 | 356 | if (!class_exists('egw_vfs')) |
357 | 357 | { |
358 | - die("chmod only implemented for eGW streams!"); // dont want to repeat the code here |
|
358 | + die("chmod only implemented for eGW streams!"); // dont want to repeat the code here |
|
359 | 359 | } |
360 | - $set = Vfs::mode2int($mode,$set); |
|
361 | - $params = array($url,$set); |
|
360 | + $set = Vfs::mode2int($mode, $set); |
|
361 | + $params = array($url, $set); |
|
362 | 362 | break; |
363 | 363 | case 'chown': |
364 | 364 | case 'chgrp': |
365 | 365 | $type = $cmd == 'chgrp' ? 'group' : 'user'; |
366 | 366 | if (!isset($owner)) |
367 | 367 | { |
368 | - $owner = $url; // first param is owner/group |
|
368 | + $owner = $url; // first param is owner/group |
|
369 | 369 | $url = array_shift($argv); |
370 | - if (Vfs::parse_url($url,PHP_URL_SCHEME)) load_wrapper($url); // we need the header loaded |
|
370 | + if (Vfs::parse_url($url, PHP_URL_SCHEME)) load_wrapper($url); // we need the header loaded |
|
371 | 371 | if ($owner == 'root') |
372 | 372 | { |
373 | 373 | $owner = 0; |
@@ -378,34 +378,34 @@ discard block |
||
378 | 378 | { |
379 | 379 | die("only numeric user/group-id's allowed for non eGW streams!"); |
380 | 380 | } |
381 | - if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) || |
|
381 | + if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was = $owner, 'account_lid', $type[0])) || |
|
382 | 382 | ($owner < 0) != ($cmd == 'chgrp')) |
383 | 383 | { |
384 | 384 | die("Unknown $type '$owner_was'!"); |
385 | 385 | } |
386 | 386 | } |
387 | - elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
|
387 | + elseif ($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
|
388 | 388 | ($owner < 0) != ($cmd == 'chgrp'))) |
389 | 389 | { |
390 | 390 | die("Unknown $type '$owner_was'!"); |
391 | 391 | } |
392 | 392 | } |
393 | - $params = array($url,$owner); |
|
393 | + $params = array($url, $owner); |
|
394 | 394 | break; |
395 | 395 | } |
396 | - if (($scheme = Vfs::parse_url($url,PHP_URL_SCHEME))) |
|
396 | + if (($scheme = Vfs::parse_url($url, PHP_URL_SCHEME))) |
|
397 | 397 | { |
398 | 398 | load_wrapper($url); |
399 | 399 | } |
400 | 400 | if ($recursive && class_exists('egw_vfs')) |
401 | 401 | { |
402 | - array_unshift($argv,$url); |
|
403 | - $params = array($argv,null,$cmd,$params[1]); |
|
404 | - $cmd = array('egw_vfs','find'); |
|
405 | - $argv = array(); // we processed all url's |
|
402 | + array_unshift($argv, $url); |
|
403 | + $params = array($argv, null, $cmd, $params[1]); |
|
404 | + $cmd = array('egw_vfs', 'find'); |
|
405 | + $argv = array(); // we processed all url's |
|
406 | 406 | } |
407 | 407 | //echo "calling cmd=".print_r($cmd,true).", params=".print_r($params,true)."\n"; |
408 | - call_user_func_array($cmd,$params); |
|
408 | + call_user_func_array($cmd, $params); |
|
409 | 409 | break; |
410 | 410 | |
411 | 411 | case 'cat': |
@@ -415,35 +415,35 @@ discard block |
||
415 | 415 | if ($cmd != 'cat' && $recursive && class_exists('egw_vfs')) |
416 | 416 | { |
417 | 417 | load_wrapper($url); |
418 | - array_unshift($argv,$url); |
|
419 | - Vfs::find($argv,array('url'=>true,),'do_stat',array($long,$numeric,true,$inode)); |
|
418 | + array_unshift($argv, $url); |
|
419 | + Vfs::find($argv, array('url'=>true,), 'do_stat', array($long, $numeric, true, $inode)); |
|
420 | 420 | $argv = array(); |
421 | 421 | } |
422 | 422 | elseif (is_dir($url) && ($dir = opendir($url))) |
423 | 423 | { |
424 | 424 | if ($argc) |
425 | 425 | { |
426 | - if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/'; |
|
426 | + if (!($name = basename(Vfs::parse_url($url, PHP_URL_PATH)))) $name = '/'; |
|
427 | 427 | echo "\n$name:\n"; |
428 | 428 | } |
429 | 429 | // separate evtl. query part, to re-add it after the file-name |
430 | 430 | unset($query); |
431 | - list($url,$query) = explode('?',$url,2); |
|
431 | + list($url, $query) = explode('?', $url, 2); |
|
432 | 432 | if ($query) $query = '?'.$query; |
433 | 433 | |
434 | - if (substr($url,-1) == '/') |
|
434 | + if (substr($url, -1) == '/') |
|
435 | 435 | { |
436 | - $url = substr($url,0,-1); |
|
436 | + $url = substr($url, 0, -1); |
|
437 | 437 | } |
438 | - while(($file = readdir($dir)) !== false) |
|
438 | + while (($file = readdir($dir)) !== false) |
|
439 | 439 | { |
440 | - do_stat($url.'/'.$file.$query,$long,$numeric,false,$inode); |
|
440 | + do_stat($url.'/'.$file.$query, $long, $numeric, false, $inode); |
|
441 | 441 | } |
442 | 442 | closedir($dir); |
443 | 443 | } |
444 | 444 | elseif ($cmd == 'cat') |
445 | 445 | { |
446 | - if (!($f = fopen($url,'r'))) |
|
446 | + if (!($f = fopen($url, 'r'))) |
|
447 | 447 | { |
448 | 448 | echo "File $url not found !!!\n\n"; |
449 | 449 | } |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | { |
452 | 452 | if ($argc) |
453 | 453 | { |
454 | - echo "\n".basename(Vfs::parse_url($url,PHP_URL_PATH)).":\n"; |
|
454 | + echo "\n".basename(Vfs::parse_url($url, PHP_URL_PATH)).":\n"; |
|
455 | 455 | } |
456 | 456 | fpassthru($f); |
457 | 457 | fclose($f); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | else |
461 | 461 | { |
462 | - do_stat($url,$long,$numeric,false,$inode); |
|
462 | + do_stat($url, $long, $numeric, false, $inode); |
|
463 | 463 | } |
464 | 464 | if (!$long && $cmd == 'ls') echo "\n"; |
465 | 465 | break; |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | */ |
475 | 475 | function load_wrapper($url) |
476 | 476 | { |
477 | - $scheme = parse_url($url,PHP_URL_SCHEME); |
|
477 | + $scheme = parse_url($url, PHP_URL_SCHEME); |
|
478 | 478 | |
479 | - if (!in_array($scheme,stream_get_wrappers())) |
|
479 | + if (!in_array($scheme, stream_get_wrappers())) |
|
480 | 480 | { |
481 | - switch($scheme) |
|
481 | + switch ($scheme) |
|
482 | 482 | { |
483 | 483 | case 'webdav': |
484 | 484 | case 'webdavs': |
@@ -487,9 +487,9 @@ discard block |
||
487 | 487 | case '': // default scheme is file and always available |
488 | 488 | break; |
489 | 489 | default: |
490 | - if (!isset($GLOBALS['egw']) && !in_array($scheme,array('smb','imap'))) |
|
490 | + if (!isset($GLOBALS['egw']) && !in_array($scheme, array('smb', 'imap'))) |
|
491 | 491 | { |
492 | - load_egw(parse_url($url,PHP_URL_USER), parse_url($url,PHP_URL_PASS), parse_url($url,PHP_URL_HOST)); |
|
492 | + load_egw(parse_url($url, PHP_URL_USER), parse_url($url, PHP_URL_PASS), parse_url($url, PHP_URL_HOST)); |
|
493 | 493 | } |
494 | 494 | // get eGW's __autoload() function |
495 | 495 | include_once(EGW_API_INC.'/common_functions.inc.php'); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @param string $passwd |
511 | 511 | * @param string $domain |
512 | 512 | */ |
513 | -function load_egw($user,$passwd,$domain='default') |
|
513 | +function load_egw($user, $passwd, $domain = 'default') |
|
514 | 514 | { |
515 | 515 | //echo "load_egw($user,$passwd,$domain)\n"; |
516 | 516 | $_REQUEST['domain'] = $domain; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
524 | 524 | { |
525 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
525 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | $GLOBALS['egw_info'] = array( |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | ) |
535 | 535 | ); |
536 | 536 | |
537 | - if (substr($user,0,5) != 'root_') |
|
537 | + if (substr($user, 0, 5) != 'root_') |
|
538 | 538 | { |
539 | 539 | include('../header.inc.php'); |
540 | 540 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | $cmd = $GLOBALS['cmd']; |
563 | - if (!in_array($cmd,array('ls','find','mount','umount','eacl')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
563 | + if (!in_array($cmd, array('ls', 'find', 'mount', 'umount', 'eacl')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
564 | 564 | { |
565 | 565 | echo "\nError: eGroupWare's files directory {$GLOBALS['egw_info']['server']['files_dir']} is NOT writable by the user running ".basename(__FILE__)."!\n". |
566 | 566 | "--> Please run it as the same user the webserver uses or root, otherwise the $cmd command will fail!\n\n"; |
@@ -591,22 +591,22 @@ discard block |
||
591 | 591 | } |
592 | 592 | if ($argc == 1) |
593 | 593 | { |
594 | - foreach(Vfs::get_eacl($url) as $acl) |
|
594 | + foreach (Vfs::get_eacl($url) as $acl) |
|
595 | 595 | { |
596 | - $mode = ($acl['rights'] & Vfs::READABLE ? 'r' : '-'). |
|
597 | - ($acl['rights'] & Vfs::WRITABLE ? 'w' : '-'). |
|
598 | - ($acl['rights'] & Vfs::EXECUTABLE ? 'x' : '-'); |
|
596 | + $mode = ($acl['rights']&Vfs::READABLE ? 'r' : '-'). |
|
597 | + ($acl['rights']&Vfs::WRITABLE ? 'w' : '-'). |
|
598 | + ($acl['rights']&Vfs::EXECUTABLE ? 'x' : '-'); |
|
599 | 599 | echo $acl['path']."\t$mode\t".$GLOBALS['egw']->accounts->id2name($acl['owner'])."\n"; |
600 | 600 | } |
601 | 601 | return; |
602 | 602 | } |
603 | 603 | if ($argc > 1 && !is_numeric($argv[1])) |
604 | 604 | { |
605 | - $mode=$argv[1]; |
|
605 | + $mode = $argv[1]; |
|
606 | 606 | $argv[1] = null; |
607 | - for($i = 0; $mode[$i]; ++$i) |
|
607 | + for ($i = 0; $mode[$i]; ++$i) |
|
608 | 608 | { |
609 | - switch($mode[$i]) |
|
609 | + switch ($mode[$i]) |
|
610 | 610 | { |
611 | 611 | case 'x': $argv[1] |= Vfs::EXECUTABLE; break; |
612 | 612 | case 'w': $argv[1] |= Vfs::WRITABLE; break; |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | } |
616 | 616 | } |
617 | - if (!Vfs::eacl($url,$argv[1],$argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2])) |
|
617 | + if (!Vfs::eacl($url, $argv[1], $argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2])) |
|
618 | 618 | { |
619 | 619 | echo "Error setting extended Acl for $argv[0]!\n"; |
620 | 620 | } |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param boolean $full_path =false true=give full path instead of just filename |
630 | 630 | * @param boolean $inode =false true=display inode (sqlfs id) |
631 | 631 | */ |
632 | -function do_stat($url,$long=false,$numeric=false,$full_path=false,$inode=false) |
|
632 | +function do_stat($url, $long = false, $numeric = false, $full_path = false, $inode = false) |
|
633 | 633 | { |
634 | 634 | //echo "do_stat($url,$long,$numeric,$full_path)\n"; |
635 | - $bname = Vfs::parse_url($url,PHP_URL_PATH); |
|
635 | + $bname = Vfs::parse_url($url, PHP_URL_PATH); |
|
636 | 636 | |
637 | 637 | if (!$full_path) |
638 | 638 | { |
@@ -663,25 +663,23 @@ discard block |
||
663 | 663 | { |
664 | 664 | if ($stat['uid']) |
665 | 665 | { |
666 | - $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : |
|
667 | - (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
|
666 | + $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
|
668 | 667 | if (is_array($uid)) $uid = $uid['name']; |
669 | 668 | if (empty($uid)) $uid = $stat['uid']; |
670 | 669 | } |
671 | 670 | if (!isset($uid)) $uid = 'root'; |
672 | 671 | if ($stat['gid']) |
673 | 672 | { |
674 | - $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : |
|
675 | - (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
|
673 | + $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
|
676 | 674 | if (is_array($gid)) $gid = $gid['name']; |
677 | 675 | if (empty($gid)) $gid = $stat['gid']; |
678 | 676 | } |
679 | 677 | if (!isset($gid)) $gid = 'root'; |
680 | 678 | } |
681 | 679 | $size = hsize($stat['size']); |
682 | - $mtime = date('Y-m-d H:i:s',$stat['mtime']); |
|
680 | + $mtime = date('Y-m-d H:i:s', $stat['mtime']); |
|
683 | 681 | $nlink = $stat['nlink']; |
684 | - if (($stat['mode'] & 0xA000) == 0xA000) |
|
682 | + if (($stat['mode']&0xA000) == 0xA000) |
|
685 | 683 | { |
686 | 684 | $symlink = " -> ".(class_exists('egw_vfs') ? Vfs::readlink($url) : readlink($url)); |
687 | 685 | } |
@@ -700,12 +698,12 @@ discard block |
||
700 | 698 | function hsize($size) |
701 | 699 | { |
702 | 700 | if ($size < 1024) return $size; |
703 | - if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024); |
|
704 | - return sprintf('%3.1lfM',(float)$size/(1024*1024)); |
|
701 | + if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024); |
|
702 | + return sprintf('%3.1lfM', (float)$size / (1024 * 1024)); |
|
705 | 703 | } |
706 | 704 | |
707 | 705 | |
708 | -function do_cp($argv,$recursive=false,$perms=false) |
|
706 | +function do_cp($argv, $recursive = false, $perms = false) |
|
709 | 707 | { |
710 | 708 | $to = array_pop($argv); |
711 | 709 | load_wrapper($to); |
@@ -717,13 +715,13 @@ discard block |
||
717 | 715 | usage("No such directory '$to'!"); |
718 | 716 | } |
719 | 717 | $anz_dirs = $anz_files = 0; |
720 | - foreach($argv as $from) |
|
718 | + foreach ($argv as $from) |
|
721 | 719 | { |
722 | 720 | if (is_dir($from) && (!file_exists($to) || is_dir($to)) && $recursive && class_exists('egw_vfs')) |
723 | 721 | { |
724 | - foreach(Vfs::find($from,array('url' => true)) as $f) |
|
722 | + foreach (Vfs::find($from, array('url' => true)) as $f) |
|
725 | 723 | { |
726 | - $t = $to.substr($f,strlen($from)); |
|
724 | + $t = $to.substr($f, strlen($from)); |
|
727 | 725 | if (is_dir($f)) |
728 | 726 | { |
729 | 727 | ++$anz_dirs; |
@@ -732,43 +730,43 @@ discard block |
||
732 | 730 | else |
733 | 731 | { |
734 | 732 | ++$anz_files; |
735 | - _cp($f,$t); |
|
733 | + _cp($f, $t); |
|
736 | 734 | } |
737 | - if ($perms) _cp_perms($f,$t); |
|
735 | + if ($perms) _cp_perms($f, $t); |
|
738 | 736 | } |
739 | - echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n"; |
|
737 | + echo ($anz_dirs ? "$anz_dirs dir(s) created and " : '')."$anz_files file(s) copied.\n"; |
|
740 | 738 | } |
741 | 739 | else |
742 | 740 | { |
743 | - _cp($from,$to,true); |
|
744 | - if ($perms) _cp_perms($from,$to); |
|
741 | + _cp($from, $to, true); |
|
742 | + if ($perms) _cp_perms($from, $to); |
|
745 | 743 | } |
746 | 744 | } |
747 | 745 | } |
748 | 746 | |
749 | -function _cp($from,$to,$verbose=false) |
|
747 | +function _cp($from, $to, $verbose = false) |
|
750 | 748 | { |
751 | 749 | load_wrapper($from); |
752 | 750 | |
753 | 751 | if (is_dir($to)) |
754 | 752 | { |
755 | - $path = Vfs::parse_url($from,PHP_URL_PATH); |
|
753 | + $path = Vfs::parse_url($from, PHP_URL_PATH); |
|
756 | 754 | if (is_dir($to)) |
757 | 755 | { |
758 | - list($to,$query) = explode('?',$to,2); |
|
756 | + list($to, $query) = explode('?', $to, 2); |
|
759 | 757 | $to .= '/'.basename($path).($query ? '?'.$query : ''); |
760 | 758 | } |
761 | 759 | } |
762 | - if (!($from_fp = fopen($from,'r'))) |
|
760 | + if (!($from_fp = fopen($from, 'r'))) |
|
763 | 761 | { |
764 | 762 | die("File $from not found!\n"); |
765 | 763 | } |
766 | - if (!($to_fp = fopen($to,'w'))) |
|
764 | + if (!($to_fp = fopen($to, 'w'))) |
|
767 | 765 | { |
768 | 766 | die("Can't open $to for writing!\n"); |
769 | 767 | } |
770 | 768 | //stream_filter_append($from_fp,'convert.base64-decode'); |
771 | - $count = stream_copy_to_stream($from_fp,$to_fp); |
|
769 | + $count = stream_copy_to_stream($from_fp, $to_fp); |
|
772 | 770 | |
773 | 771 | if ($verbose) echo hsize($count)." bytes written to $to\n"; |
774 | 772 | |
@@ -781,11 +779,11 @@ discard block |
||
781 | 779 | } |
782 | 780 | |
783 | 781 | |
784 | -function _cp_perms($from,$to) |
|
782 | +function _cp_perms($from, $to) |
|
785 | 783 | { |
786 | 784 | if (($from_stat = stat($from)) && ($to_stat = stat($to))) |
787 | 785 | { |
788 | - foreach(array( |
|
786 | + foreach (array( |
|
789 | 787 | 'mode' => 'chmod', |
790 | 788 | 'uid' => 'chown', |
791 | 789 | 'gid' => 'chgrp', |
@@ -794,27 +792,27 @@ discard block |
||
794 | 792 | if ($from_stat[$perm] != $to_stat[$perm]) |
795 | 793 | { |
796 | 794 | //echo "egw_vfs::$cmd($to,{$from_stat[$perm]}\n"; |
797 | - call_user_func(array('egw_vfs',$cmd),$to,$from_stat[$perm]); |
|
795 | + call_user_func(array('egw_vfs', $cmd), $to, $from_stat[$perm]); |
|
798 | 796 | } |
799 | 797 | } |
800 | 798 | } |
801 | 799 | } |
802 | 800 | |
803 | -function do_find($bases,$options) |
|
801 | +function do_find($bases, $options) |
|
804 | 802 | { |
805 | - foreach($bases as $url) |
|
803 | + foreach ($bases as $url) |
|
806 | 804 | { |
807 | 805 | load_wrapper($url); |
808 | 806 | } |
809 | - $options['url'] = true; // we use url's not vfs pathes in filemanager/cli.php |
|
807 | + $options['url'] = true; // we use url's not vfs pathes in filemanager/cli.php |
|
810 | 808 | |
811 | - foreach(Vfs::find($bases,$options) as $path) |
|
809 | + foreach (Vfs::find($bases, $options) as $path) |
|
812 | 810 | { |
813 | 811 | echo "$path\n"; |
814 | 812 | } |
815 | 813 | } |
816 | 814 | |
817 | -function do_lntree($from,$to) |
|
815 | +function do_lntree($from, $to) |
|
818 | 816 | { |
819 | 817 | echo "lntree $from $to\n"; |
820 | 818 | if ($from[0] == '/') $from = 'sqlfs://default'.$from; |
@@ -877,33 +875,33 @@ discard block |
||
877 | 875 | * @param int $mode |
878 | 876 | * @return string |
879 | 877 | */ |
880 | -function int2mode( $mode ) |
|
878 | +function int2mode($mode) |
|
881 | 879 | { |
882 | - if(($mode & 0xA000) == 0xA000) // Symbolic Link |
|
880 | + if (($mode&0xA000) == 0xA000) // Symbolic Link |
|
883 | 881 | { |
884 | 882 | $sP = 'l'; |
885 | 883 | } |
886 | - elseif(($mode & 0xC000) == 0xC000) // Socket |
|
884 | + elseif (($mode&0xC000) == 0xC000) // Socket |
|
887 | 885 | { |
888 | 886 | $sP = 's'; |
889 | 887 | } |
890 | - elseif($mode & 0x1000) // FIFO pipe |
|
888 | + elseif ($mode&0x1000) // FIFO pipe |
|
891 | 889 | { |
892 | 890 | $sP = 'p'; |
893 | 891 | } |
894 | - elseif($mode & 0x2000) // Character special |
|
892 | + elseif ($mode&0x2000) // Character special |
|
895 | 893 | { |
896 | 894 | $sP = 'c'; |
897 | 895 | } |
898 | - elseif($mode & 0x4000) // Directory |
|
896 | + elseif ($mode&0x4000) // Directory |
|
899 | 897 | { |
900 | 898 | $sP = 'd'; |
901 | 899 | } |
902 | - elseif($mode & 0x6000) // Block special |
|
900 | + elseif ($mode&0x6000) // Block special |
|
903 | 901 | { |
904 | 902 | $sP = 'b'; |
905 | 903 | } |
906 | - elseif($mode & 0x8000) // Regular |
|
904 | + elseif ($mode&0x8000) // Regular |
|
907 | 905 | { |
908 | 906 | $sP = '-'; |
909 | 907 | } |
@@ -913,22 +911,19 @@ discard block |
||
913 | 911 | } |
914 | 912 | |
915 | 913 | // owner |
916 | - $sP .= (($mode & 0x0100) ? 'r' : '-') . |
|
917 | - (($mode & 0x0080) ? 'w' : '-') . |
|
918 | - (($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) : |
|
919 | - (($mode & 0x0800) ? 'S' : '-')); |
|
914 | + $sP .= (($mode&0x0100) ? 'r' : '-'). |
|
915 | + (($mode&0x0080) ? 'w' : '-'). |
|
916 | + (($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-')); |
|
920 | 917 | |
921 | 918 | // group |
922 | - $sP .= (($mode & 0x0020) ? 'r' : '-') . |
|
923 | - (($mode & 0x0010) ? 'w' : '-') . |
|
924 | - (($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) : |
|
925 | - (($mode & 0x0400) ? 'S' : '-')); |
|
919 | + $sP .= (($mode&0x0020) ? 'r' : '-'). |
|
920 | + (($mode&0x0010) ? 'w' : '-'). |
|
921 | + (($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-')); |
|
926 | 922 | |
927 | 923 | // world |
928 | - $sP .= (($mode & 0x0004) ? 'r' : '-') . |
|
929 | - (($mode & 0x0002) ? 'w' : '-') . |
|
930 | - (($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) : |
|
931 | - (($mode & 0x0200) ? 'T' : '-')); |
|
924 | + $sP .= (($mode&0x0004) ? 'r' : '-'). |
|
925 | + (($mode&0x0002) ? 'w' : '-'). |
|
926 | + (($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-')); |
|
932 | 927 | |
933 | 928 | return $sP; |
934 | 929 | } |
@@ -20,10 +20,13 @@ discard block |
||
20 | 20 | |
21 | 21 | error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED); |
22 | 22 | |
23 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling filemanager/cli.php as web-page |
|
23 | +if (php_sapi_name() !== 'cli') |
|
24 | +{ |
|
25 | + // security precaution: forbit calling filemanager/cli.php as web-page |
|
24 | 26 | { |
25 | 27 | die('<h1>'.basename(__FILE__).' must NOT be called as web-page --> exiting !!!</h1>'); |
26 | 28 | } |
29 | +} |
|
27 | 30 | |
28 | 31 | /** |
29 | 32 | * callback if the session-check fails, creates session from user/passwd in $GLOBALS['egw_login_data'] |
@@ -87,14 +90,20 @@ discard block |
||
87 | 90 | $cmd = array_shift($args); |
88 | 91 | } |
89 | 92 | |
90 | -if (!$args) $args = array('-h'); |
|
93 | +if (!$args) |
|
94 | +{ |
|
95 | + $args = array('-h'); |
|
96 | +} |
|
91 | 97 | |
92 | 98 | $argv = $find_options = array(); |
93 | 99 | while(!is_null($option = array_shift($args))) |
94 | 100 | { |
95 | - if ($option == '-' || $option[0] != '-') // no option --> argument |
|
101 | + if ($option == '-' || $option[0] != '-') |
|
102 | + { |
|
103 | + // no option --> argument |
|
96 | 104 | { |
97 | 105 | $argv[] = $option; |
106 | + } |
|
98 | 107 | continue; |
99 | 108 | } |
100 | 109 | |
@@ -192,7 +201,10 @@ discard block |
||
192 | 201 | { |
193 | 202 | usage('Wrong number of parameters!'); |
194 | 203 | } |
195 | - if (($url = $argv[0])) load_wrapper($url); |
|
204 | + if (($url = $argv[0])) |
|
205 | + { |
|
206 | + load_wrapper($url); |
|
207 | + } |
|
196 | 208 | if(!Vfs::$is_root) |
197 | 209 | { |
198 | 210 | die("You need to be root to do that!\n"); |
@@ -257,7 +269,10 @@ discard block |
||
257 | 269 | break; |
258 | 270 | |
259 | 271 | case 'rename': |
260 | - if (count($argv) != 2) usage('Wrong number of parameters!'); |
|
272 | + if (count($argv) != 2) |
|
273 | + { |
|
274 | + usage('Wrong number of parameters!'); |
|
275 | + } |
|
261 | 276 | load_wrapper($argv[0]); |
262 | 277 | load_wrapper($argv[1]); |
263 | 278 | rename($argv[0],$argv[1]); |
@@ -268,7 +283,11 @@ discard block |
||
268 | 283 | { |
269 | 284 | die("\nYou need to be root to do that!\n\n"); |
270 | 285 | } |
271 | - if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given |
|
286 | + if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) |
|
287 | + { |
|
288 | + exit; |
|
289 | + } |
|
290 | + // we need write access, error msg already given |
|
272 | 291 | $fstab = Vfs::mount(); |
273 | 292 | if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false) |
274 | 293 | { |
@@ -281,7 +300,10 @@ discard block |
||
281 | 300 | $num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error |
282 | 301 | echo "\n$num_files files migrated from DB to filesystem.\n"; |
283 | 302 | $new_url = preg_replace('/storage=db&?/','',$fstab['/']); |
284 | - if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1); |
|
303 | + if (substr($new_url,-1) == '?') |
|
304 | + { |
|
305 | + $new_url = substr($new_url,0,-1); |
|
306 | + } |
|
285 | 307 | if (Vfs::mount($new_url,'/')) |
286 | 308 | { |
287 | 309 | echo "/ successful re-mounted on $new_url\n"; |
@@ -324,7 +346,10 @@ discard block |
||
324 | 346 | break; |
325 | 347 | |
326 | 348 | case 'mkdir': |
327 | - if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n"; |
|
349 | + if (!mkdir($url,null,$recursive)) |
|
350 | + { |
|
351 | + echo "Can't create directory, permission denied!\n"; |
|
352 | + } |
|
328 | 353 | break; |
329 | 354 | |
330 | 355 | case 'touch': |
@@ -342,7 +367,11 @@ discard block |
||
342 | 367 | $mode = $url; // first param is mode |
343 | 368 | $url = array_shift($argv); |
344 | 369 | } |
345 | - if (Vfs::parse_url($url,PHP_URL_SCHEME)) load_wrapper($url); // cant use stat or Vfs::mode2int otherwise! |
|
370 | + if (Vfs::parse_url($url,PHP_URL_SCHEME)) |
|
371 | + { |
|
372 | + load_wrapper($url); |
|
373 | + } |
|
374 | + // cant use stat or Vfs::mode2int otherwise! |
|
346 | 375 | |
347 | 376 | if (strpos($mode,'+') !== false || strpos($mode,'-') !== false) |
348 | 377 | { |
@@ -367,7 +396,11 @@ discard block |
||
367 | 396 | { |
368 | 397 | $owner = $url; // first param is owner/group |
369 | 398 | $url = array_shift($argv); |
370 | - if (Vfs::parse_url($url,PHP_URL_SCHEME)) load_wrapper($url); // we need the header loaded |
|
399 | + if (Vfs::parse_url($url,PHP_URL_SCHEME)) |
|
400 | + { |
|
401 | + load_wrapper($url); |
|
402 | + } |
|
403 | + // we need the header loaded |
|
371 | 404 | if ($owner == 'root') |
372 | 405 | { |
373 | 406 | $owner = 0; |
@@ -423,13 +456,19 @@ discard block |
||
423 | 456 | { |
424 | 457 | if ($argc) |
425 | 458 | { |
426 | - if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/'; |
|
459 | + if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) |
|
460 | + { |
|
461 | + $name = '/'; |
|
462 | + } |
|
427 | 463 | echo "\n$name:\n"; |
428 | 464 | } |
429 | 465 | // separate evtl. query part, to re-add it after the file-name |
430 | 466 | unset($query); |
431 | 467 | list($url,$query) = explode('?',$url,2); |
432 | - if ($query) $query = '?'.$query; |
|
468 | + if ($query) |
|
469 | + { |
|
470 | + $query = '?'.$query; |
|
471 | + } |
|
433 | 472 | |
434 | 473 | if (substr($url,-1) == '/') |
435 | 474 | { |
@@ -461,7 +500,10 @@ discard block |
||
461 | 500 | { |
462 | 501 | do_stat($url,$long,$numeric,false,$inode); |
463 | 502 | } |
464 | - if (!$long && $cmd == 'ls') echo "\n"; |
|
503 | + if (!$long && $cmd == 'ls') |
|
504 | + { |
|
505 | + echo "\n"; |
|
506 | + } |
|
465 | 507 | break; |
466 | 508 | } |
467 | 509 | } |
@@ -665,18 +707,36 @@ discard block |
||
665 | 707 | { |
666 | 708 | $uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : |
667 | 709 | (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']); |
668 | - if (is_array($uid)) $uid = $uid['name']; |
|
669 | - if (empty($uid)) $uid = $stat['uid']; |
|
710 | + if (is_array($uid)) |
|
711 | + { |
|
712 | + $uid = $uid['name']; |
|
713 | + } |
|
714 | + if (empty($uid)) |
|
715 | + { |
|
716 | + $uid = $stat['uid']; |
|
717 | + } |
|
718 | + } |
|
719 | + if (!isset($uid)) |
|
720 | + { |
|
721 | + $uid = 'root'; |
|
670 | 722 | } |
671 | - if (!isset($uid)) $uid = 'root'; |
|
672 | 723 | if ($stat['gid']) |
673 | 724 | { |
674 | 725 | $gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : |
675 | 726 | (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']); |
676 | - if (is_array($gid)) $gid = $gid['name']; |
|
677 | - if (empty($gid)) $gid = $stat['gid']; |
|
727 | + if (is_array($gid)) |
|
728 | + { |
|
729 | + $gid = $gid['name']; |
|
730 | + } |
|
731 | + if (empty($gid)) |
|
732 | + { |
|
733 | + $gid = $stat['gid']; |
|
734 | + } |
|
735 | + } |
|
736 | + if (!isset($gid)) |
|
737 | + { |
|
738 | + $gid = 'root'; |
|
678 | 739 | } |
679 | - if (!isset($gid)) $gid = 'root'; |
|
680 | 740 | } |
681 | 741 | $size = hsize($stat['size']); |
682 | 742 | $mtime = date('Y-m-d H:i:s',$stat['mtime']); |
@@ -699,8 +759,14 @@ discard block |
||
699 | 759 | |
700 | 760 | function hsize($size) |
701 | 761 | { |
702 | - if ($size < 1024) return $size; |
|
703 | - if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024); |
|
762 | + if ($size < 1024) |
|
763 | + { |
|
764 | + return $size; |
|
765 | + } |
|
766 | + if ($size < 1024*1024) |
|
767 | + { |
|
768 | + return sprintf('%3.1lfk',(float)$size/1024); |
|
769 | + } |
|
704 | 770 | return sprintf('%3.1lfM',(float)$size/(1024*1024)); |
705 | 771 | } |
706 | 772 | |
@@ -734,14 +800,20 @@ discard block |
||
734 | 800 | ++$anz_files; |
735 | 801 | _cp($f,$t); |
736 | 802 | } |
737 | - if ($perms) _cp_perms($f,$t); |
|
803 | + if ($perms) |
|
804 | + { |
|
805 | + _cp_perms($f,$t); |
|
806 | + } |
|
738 | 807 | } |
739 | 808 | echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n"; |
740 | 809 | } |
741 | 810 | else |
742 | 811 | { |
743 | 812 | _cp($from,$to,true); |
744 | - if ($perms) _cp_perms($from,$to); |
|
813 | + if ($perms) |
|
814 | + { |
|
815 | + _cp_perms($from,$to); |
|
816 | + } |
|
745 | 817 | } |
746 | 818 | } |
747 | 819 | } |
@@ -770,7 +842,10 @@ discard block |
||
770 | 842 | //stream_filter_append($from_fp,'convert.base64-decode'); |
771 | 843 | $count = stream_copy_to_stream($from_fp,$to_fp); |
772 | 844 | |
773 | - if ($verbose) echo hsize($count)." bytes written to $to\n"; |
|
845 | + if ($verbose) |
|
846 | + { |
|
847 | + echo hsize($count)." bytes written to $to\n"; |
|
848 | + } |
|
774 | 849 | |
775 | 850 | fclose($from_fp); |
776 | 851 | |
@@ -817,7 +892,10 @@ discard block |
||
817 | 892 | function do_lntree($from,$to) |
818 | 893 | { |
819 | 894 | echo "lntree $from $to\n"; |
820 | - if ($from[0] == '/') $from = 'sqlfs://default'.$from; |
|
895 | + if ($from[0] == '/') |
|
896 | + { |
|
897 | + $from = 'sqlfs://default'.$from; |
|
898 | + } |
|
821 | 899 | load_wrapper($from); |
822 | 900 | |
823 | 901 | if (!file_exists($from)) |
@@ -879,34 +957,55 @@ discard block |
||
879 | 957 | */ |
880 | 958 | function int2mode( $mode ) |
881 | 959 | { |
882 | - if(($mode & 0xA000) == 0xA000) // Symbolic Link |
|
960 | + if(($mode & 0xA000) == 0xA000) |
|
961 | + { |
|
962 | + // Symbolic Link |
|
883 | 963 | { |
884 | 964 | $sP = 'l'; |
885 | 965 | } |
886 | - elseif(($mode & 0xC000) == 0xC000) // Socket |
|
966 | + } |
|
967 | + elseif(($mode & 0xC000) == 0xC000) |
|
968 | + { |
|
969 | + // Socket |
|
887 | 970 | { |
888 | 971 | $sP = 's'; |
889 | 972 | } |
890 | - elseif($mode & 0x1000) // FIFO pipe |
|
973 | + } |
|
974 | + elseif($mode & 0x1000) |
|
975 | + { |
|
976 | + // FIFO pipe |
|
891 | 977 | { |
892 | 978 | $sP = 'p'; |
893 | 979 | } |
894 | - elseif($mode & 0x2000) // Character special |
|
980 | + } |
|
981 | + elseif($mode & 0x2000) |
|
982 | + { |
|
983 | + // Character special |
|
895 | 984 | { |
896 | 985 | $sP = 'c'; |
897 | 986 | } |
898 | - elseif($mode & 0x4000) // Directory |
|
987 | + } |
|
988 | + elseif($mode & 0x4000) |
|
989 | + { |
|
990 | + // Directory |
|
899 | 991 | { |
900 | 992 | $sP = 'd'; |
901 | 993 | } |
902 | - elseif($mode & 0x6000) // Block special |
|
994 | + } |
|
995 | + elseif($mode & 0x6000) |
|
996 | + { |
|
997 | + // Block special |
|
903 | 998 | { |
904 | 999 | $sP = 'b'; |
905 | 1000 | } |
906 | - elseif($mode & 0x8000) // Regular |
|
1001 | + } |
|
1002 | + elseif($mode & 0x8000) |
|
1003 | + { |
|
1004 | + // Regular |
|
907 | 1005 | { |
908 | 1006 | $sP = '-'; |
909 | 1007 | } |
1008 | + } |
|
910 | 1009 | else // UNKNOWN |
911 | 1010 | { |
912 | 1011 | $sP = 'u'; |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) || |
382 | 382 | ($owner < 0) != ($cmd == 'chgrp')) |
383 | 383 | { |
384 | - die("Unknown $type '$owner_was'!"); |
|
384 | + die("unknown $type '$owner_was'!"); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) || |
388 | 388 | ($owner < 0) != ($cmd == 'chgrp'))) |
389 | 389 | { |
390 | - die("Unknown $type '$owner_was'!"); |
|
390 | + die("unknown $type '$owner_was'!"); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | $params = array($url,$owner); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | { |
446 | 446 | if (!($f = fopen($url,'r'))) |
447 | 447 | { |
448 | - echo "File $url not found !!!\n\n"; |
|
448 | + echo "file $url not found !!!\n\n"; |
|
449 | 449 | } |
450 | 450 | else |
451 | 451 | { |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | } |
762 | 762 | if (!($from_fp = fopen($from,'r'))) |
763 | 763 | { |
764 | - die("File $from not found!\n"); |
|
764 | + die("file $from not found!\n"); |
|
765 | 765 | } |
766 | 766 | if (!($to_fp = fopen($to,'w'))) |
767 | 767 | { |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | ); |
19 | 19 | include('../header.inc.php'); |
20 | 20 | |
21 | -if (!($path = Api\Cache::getSession('filemanger','test'))) |
|
21 | +if (!($path = Api\Cache::getSession('filemanger', 'test'))) |
|
22 | 22 | { |
23 | 23 | $path = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
24 | 24 | } |
25 | 25 | if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; |
26 | -echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"'). |
|
27 | - Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET'); |
|
26 | +echo Api\Html::form("<p>Path: ".Api\Html::input('path', $path, 'text', 'size="40"'). |
|
27 | + Api\Html::submit_button('', lang('Submit'))."</p>\n", array(), '', '', '', '', 'GET'); |
|
28 | 28 | |
29 | 29 | if (isset($path) && !empty($path)) |
30 | 30 | { |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | { |
33 | 33 | throw new Api\Exception\WrongUserinput('Not an absolute path!'); |
34 | 34 | } |
35 | - Api\Cache::setSession('filemanger','test',$path); |
|
35 | + Api\Cache::setSession('filemanger', 'test', $path); |
|
36 | 36 | |
37 | 37 | echo "<h2>"; |
38 | - foreach(explode('/',$path) as $n => $part) |
|
38 | + foreach (explode('/', $path) as $n => $part) |
|
39 | 39 | { |
40 | 40 | $p .= ($p != '/' ? '/' : '').$part; |
41 | - echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ','/filemanager/test.php',array('path'=>$p)); |
|
41 | + echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ', '/filemanager/test.php', array('path'=>$p)); |
|
42 | 42 | } |
43 | 43 | echo "</h2>\n"; |
44 | 44 | |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | |
51 | 51 | $time = microtime(true); |
52 | 52 | $stat = Vfs::stat($path); |
53 | - $stime = number_format(1000*(microtime(true)-$time),1); |
|
53 | + $stime = number_format(1000 * (microtime(true) - $time), 1); |
|
54 | 54 | |
55 | 55 | $time2 = microtime(true); |
56 | 56 | if ($is_dir)// && ($d = Vfs::opendir($path))) |
57 | 57 | { |
58 | 58 | $files = array(); |
59 | 59 | //while(($file = readdir($d))) |
60 | - foreach(Vfs::scandir($path) as $file) |
|
60 | + foreach (Vfs::scandir($path) as $file) |
|
61 | 61 | { |
62 | - if (Vfs::is_readable($fpath=Vfs::concat($path,$file))) |
|
62 | + if (Vfs::is_readable($fpath = Vfs::concat($path, $file))) |
|
63 | 63 | { |
64 | - $file = Api\Html::a_href($file,'/filemanager/test.php',array('path'=>$fpath)); |
|
64 | + $file = Api\Html::a_href($file, '/filemanager/test.php', array('path'=>$fpath)); |
|
65 | 65 | } |
66 | 66 | $file .= ' ('.Vfs::mime_content_type($fpath).')'; |
67 | 67 | $files[] = $file; |
68 | 68 | } |
69 | 69 | //closedir($d); |
70 | - $time2f = number_format(1000*(microtime(true)-$time2),1); |
|
70 | + $time2f = number_format(1000 * (microtime(true) - $time2), 1); |
|
71 | 71 | echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n"; |
72 | - if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
72 | + if ($files) echo '<ol><li>'.implode("</li>\n<li>", $files).'</ol>'."\n"; |
|
73 | 73 | } |
74 | 74 | |
75 | - echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')'; |
|
75 | + echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode']) ? sprintf('%o', $stat['mode']).' = '.Vfs::int2mode($stat['mode']) : 'NULL').')'; |
|
76 | 76 | if (is_array($stat)) |
77 | 77 | { |
78 | 78 | _debug_array($stat); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | echo "<p><b>readlink('$path')</b>=".array2string(Vfs::readlink($path))."</p>\n"; |
90 | 90 | $time3 = microtime(true); |
91 | 91 | $lstat = Vfs::lstat($path); |
92 | - $time3f = number_format(1000*(microtime(true)-$time3),1); |
|
93 | - echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode'])?sprintf('%o',$lstat['mode']).' = '.Vfs::int2mode($lstat['mode']):'NULL').')'; |
|
92 | + $time3f = number_format(1000 * (microtime(true) - $time3), 1); |
|
93 | + echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode']) ? sprintf('%o', $lstat['mode']).' = '.Vfs::int2mode($lstat['mode']) : 'NULL').')'; |
|
94 | 94 | if (is_array($lstat)) |
95 | 95 | { |
96 | 96 | _debug_array($lstat); |
@@ -22,7 +22,10 @@ discard block |
||
22 | 22 | { |
23 | 23 | $path = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
24 | 24 | } |
25 | -if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; |
|
25 | +if (isset($_REQUEST['path'])) |
|
26 | +{ |
|
27 | + $path = $_REQUEST['path']; |
|
28 | +} |
|
26 | 29 | echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"'). |
27 | 30 | Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET'); |
28 | 31 | |
@@ -53,9 +56,12 @@ discard block |
||
53 | 56 | $stime = number_format(1000*(microtime(true)-$time),1); |
54 | 57 | |
55 | 58 | $time2 = microtime(true); |
56 | - if ($is_dir)// && ($d = Vfs::opendir($path))) |
|
59 | + if ($is_dir) |
|
60 | + { |
|
61 | + // && ($d = Vfs::opendir($path))) |
|
57 | 62 | { |
58 | 63 | $files = array(); |
64 | + } |
|
59 | 65 | //while(($file = readdir($d))) |
60 | 66 | foreach(Vfs::scandir($path) as $file) |
61 | 67 | { |
@@ -69,7 +75,10 @@ discard block |
||
69 | 75 | //closedir($d); |
70 | 76 | $time2f = number_format(1000*(microtime(true)-$time2),1); |
71 | 77 | echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n"; |
72 | - if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
78 | + if($files) |
|
79 | + { |
|
80 | + echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
|
81 | + } |
|
73 | 82 | } |
74 | 83 | |
75 | 84 | echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')'; |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | //print_r($config); exit; |
38 | 38 | |
39 | -$uglify =& $config['uglify']; |
|
39 | +$uglify = & $config['uglify']; |
|
40 | 40 | |
41 | -foreach(Bundle::all() as $name => $files) |
|
41 | +foreach (Bundle::all() as $name => $files) |
|
42 | 42 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
43 | + if ($name == '.ts') continue; // ignore timestamp |
|
44 | 44 | |
45 | 45 | // remove leading / from file-names |
46 | 46 | array_walk($files, function(&$path) |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | // add css for all templates and themes |
82 | -$cssmin =& $config['cssmin']; |
|
83 | -$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | -$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | -foreach(array('pixelegg','jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
82 | +$cssmin = & $config['cssmin']; |
|
83 | +$GLOBALS['egw_info']['flags']['currentapp'] = '*grunt*'; // to no find any app.css files |
|
84 | +$GLOBALS['egw_info']['server']['debug_minify'] = 'True'; // otherwise we would only get minified file |
|
85 | +foreach (array('pixelegg', 'jdots')/*array_keys(Framework::list_templates())*/ as $template) |
|
86 | 86 | { |
87 | 87 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 88 | $tpl = Framework::factory(); |
89 | 89 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | - foreach($themes as $theme) |
|
90 | + if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
91 | + foreach ($themes as $theme) |
|
92 | 92 | { |
93 | 93 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | 94 | if ($template == 'pixelegg' && $theme == 'traditional') continue; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $new_json = str_replace("\n", "\n\t", |
115 | 115 | preg_replace_callback('/^( *)/m', function($matches) |
116 | 116 | { |
117 | - return str_repeat("\t", strlen($matches[1])/4); |
|
117 | + return str_repeat("\t", strlen($matches[1]) / 4); |
|
118 | 118 | }, json_encode($config, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES))); |
119 | 119 | |
120 | 120 | $new_content = preg_replace('/^(\s*)"([a-z0-9]+)":/mi', '$1$2:', $new_json); |
@@ -13,7 +13,10 @@ discard block |
||
13 | 13 | use EGroupware\Api\Framework; |
14 | 14 | use EGroupware\Api\Framework\Bundle; |
15 | 15 | |
16 | -if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n"); |
|
16 | +if (php_sapi_name() !== 'cli') |
|
17 | +{ |
|
18 | + die("This is a commandline ONLY tool!\n"); |
|
19 | +} |
|
17 | 20 | |
18 | 21 | $GLOBALS['egw_info'] = array( |
19 | 22 | 'flags' => array( |
@@ -40,12 +43,19 @@ discard block |
||
40 | 43 | |
41 | 44 | foreach(Bundle::all() as $name => $files) |
42 | 45 | { |
43 | - if ($name == '.ts') continue; // ignore timestamp |
|
46 | + if ($name == '.ts') |
|
47 | + { |
|
48 | + continue; |
|
49 | + } |
|
50 | + // ignore timestamp |
|
44 | 51 | |
45 | 52 | // remove leading / from file-names |
46 | 53 | array_walk($files, function(&$path) |
47 | 54 | { |
48 | - if ($path[0] == '/') $path = substr($path, 1); |
|
55 | + if ($path[0] == '/') |
|
56 | + { |
|
57 | + $path = substr($path, 1); |
|
58 | + } |
|
49 | 59 | }); |
50 | 60 | |
51 | 61 | // api/js/jsapi/egw.js loaded via own tag, and we must not load it twice! |
@@ -87,11 +97,18 @@ discard block |
||
87 | 97 | $GLOBALS['egw_info']['server']['template_set'] = $template; |
88 | 98 | $tpl = Framework::factory(); |
89 | 99 | $themes = $tpl->list_themes(); |
90 | - if ($template == 'pixelegg') $themes[] = 'fw_mobile'; // this is for mobile devices |
|
100 | + if ($template == 'pixelegg') |
|
101 | + { |
|
102 | + $themes[] = 'fw_mobile'; |
|
103 | + } |
|
104 | + // this is for mobile devices |
|
91 | 105 | foreach($themes as $theme) |
92 | 106 | { |
93 | 107 | // skip not working cssmin of pixelegg/traditional: Broken @import declaration of "../../etemplate/templates/default/etemplate2.css" |
94 | - if ($template == 'pixelegg' && $theme == 'traditional') continue; |
|
108 | + if ($template == 'pixelegg' && $theme == 'traditional') |
|
109 | + { |
|
110 | + continue; |
|
111 | + } |
|
95 | 112 | $GLOBALS['egw_info']['user']['preferences']['common']['theme'] = $theme; |
96 | 113 | // empty include list by not-existing file plus last true |
97 | 114 | Framework\CssIncludes::add('*grunt*', null, true, true); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'cat_id' => array( |
49 | 49 | 'type' => 'select', |
50 | 50 | 'label' => lang('Choose a category'), |
51 | - 'options' => array(), // done by get_user_interface() |
|
51 | + 'options' => array(), // done by get_user_interface() |
|
52 | 52 | 'multiple' => true, |
53 | 53 | ), |
54 | 54 | 'owner' => array( |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function get_user_interface() |
95 | 95 | { |
96 | - $cats = new Api\Categories('','calendar'); |
|
97 | - foreach($cats->return_array('all',0,False,'','cat_name','',True) as $cat) |
|
96 | + $cats = new Api\Categories('', 'calendar'); |
|
97 | + foreach ($cats->return_array('all', 0, False, '', 'cat_name', '', True) as $cat) |
|
98 | 98 | { |
99 | - $this->arguments['cat_id']['options'][$cat['id']] = str_repeat(' ',$cat['level']).$cat['name']; |
|
99 | + $this->arguments['cat_id']['options'][$cat['id']] = str_repeat(' ', $cat['level']).$cat['name']; |
|
100 | 100 | } |
101 | 101 | if (count($this->arguments['cat_id']['options']) > 5) |
102 | 102 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $GLOBALS['egw']->accounts = new Api\Accounts(); |
109 | 109 | } |
110 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
110 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
111 | 111 | $search_params = array( |
112 | 112 | 'type' => 'both', |
113 | 113 | 'app' => 'calendar', |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $users = array(); |
118 | 118 | $groups = array(); |
119 | 119 | // sort users and groups separately. |
120 | - $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u'); |
|
121 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
120 | + $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'], 'account_lid', 'u'); |
|
121 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
122 | 122 | foreach ($accounts as $entry) |
123 | 123 | { |
124 | 124 | $is_group = false; |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | $acl = new Acl($entry['account_id']); |
127 | 127 | $acl->read_repository(); |
128 | 128 | // get the rights for each account to check whether the anon user has read permissions. |
129 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
129 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
130 | 130 | // also add the anon user if it's his own calendar. |
131 | - if ($calendar_bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$entry['account_id'],'ts',null,$anon_user) || ($entry['account_id'] == $anon_user)) |
|
131 | + if ($calendar_bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $entry['account_id'], 'ts', null, $anon_user) || ($entry['account_id'] == $anon_user)) |
|
132 | 132 | { |
133 | 133 | $has_read_permissions = true; |
134 | 134 | } |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | // or ass permissions if this is the anon group's calendar. |
139 | 139 | foreach ($anon_groups as $parent_group) |
140 | 140 | { |
141 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
142 | - if (($rights & Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
141 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
142 | + if (($rights&Acl::READ) || ($entry['account_id'] == $parent_group)) |
|
143 | 143 | { |
144 | 144 | $has_read_permissions = true; |
145 | 145 | break; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | else |
157 | 157 | { |
158 | - $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
158 | + $users[$entry['account_id']] = Api\Accounts::format_username($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | foreach ($calendar_bo->resources as $type => $data) |
181 | 181 | { |
182 | 182 | // Check anon user's permissions - must have at least run for the hook to be available |
183 | - if($acl->check('run',EGW_ACL_READ, $data['app']) && |
|
183 | + if ($acl->check('run', EGW_ACL_READ, $data['app']) && |
|
184 | 184 | $type != '' && $data['app'] && Link::get_registry($data['app'], 'query') |
185 | 185 | ) |
186 | 186 | { |
187 | - $_results = Link::query($data['app'], $query,$options); |
|
187 | + $_results = Link::query($data['app'], $query, $options); |
|
188 | 188 | } |
189 | - if(!$_results) continue; |
|
189 | + if (!$_results) continue; |
|
190 | 190 | $_results = array_unique($_results); |
191 | 191 | foreach ($_results as $key => $value) |
192 | 192 | { |
193 | - if($calendar_bo->check_perms(Acl::READ,0,$type.$key,'ts',null,$anon_user)) |
|
193 | + if ($calendar_bo->check_perms(Acl::READ, 0, $type.$key, 'ts', null, $anon_user)) |
|
194 | 194 | { |
195 | 195 | $this->arguments['resources']['options'][$type.$key] = $value; |
196 | 196 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param $arguments |
210 | 210 | * @param $properties |
211 | 211 | */ |
212 | - function get_content(&$arguments,$properties) |
|
212 | + function get_content(&$arguments, $properties) |
|
213 | 213 | { |
214 | 214 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
215 | 215 | |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | if ($arguments['sortby'] == 'yearly') |
222 | 222 | { |
223 | 223 | $arguments['sortby'] = 'month'; |
224 | - $arguments['date'] = substr($arguments['date'],0,4).'0101'; |
|
224 | + $arguments['date'] = substr($arguments['date'], 0, 4).'0101'; |
|
225 | 225 | } |
226 | 226 | if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
227 | 227 | if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
228 | - if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
|
228 | + if (isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
|
229 | 229 | { |
230 | - foreach($arguments['resources'] as $index => $value) |
|
230 | + foreach ($arguments['resources'] as $index => $value) |
|
231 | 231 | { |
232 | - if($value == 'r0') |
|
232 | + if ($value == 'r0') |
|
233 | 233 | { |
234 | 234 | unset($arguments['resources'][$index]); |
235 | 235 | } |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | { |
273 | 273 | if ($ui->day < 15) // show one complete month |
274 | 274 | { |
275 | - $ui->_week_align_month($ui->first,$ui->last); |
|
275 | + $ui->_week_align_month($ui->first, $ui->last); |
|
276 | 276 | } |
277 | 277 | else // show 2 half month |
278 | 278 | { |
279 | - $ui->_week_align_month($ui->first,$ui->last,15); |
|
279 | + $ui->_week_align_month($ui->first, $ui->last, 15); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') // weeekview |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $start->setWeekstart(); |
286 | 286 | $ui->first = $start->format('ts'); |
287 | 287 | $ui->last = $ui->bo->date2array($this->first); |
288 | - $ui->last['day'] += ($ui->planner_view == 'week' ? 7 : 7 * $ui->cal_prefs['multiple_weeks'])-1; |
|
288 | + $ui->last['day'] += ($ui->planner_view == 'week' ? 7 : 7 * $ui->cal_prefs['multiple_weeks']) - 1; |
|
289 | 289 | $ui->last['hour'] = 23; $ui->last['minute'] = $ui->last['sec'] = 59; |
290 | 290 | unset($ui->last['raw']); |
291 | 291 | $ui->last = $ui->bo->date2ts($ui->last); |
@@ -310,22 +310,22 @@ discard block |
||
310 | 310 | $content = array(); |
311 | 311 | $sel_options = array(); |
312 | 312 | $content['planner'] = $ui->bo->search($search_params); |
313 | - foreach($content['planner'] as &$event) |
|
313 | + foreach ($content['planner'] as &$event) |
|
314 | 314 | { |
315 | 315 | $ui->to_client($event); |
316 | 316 | } |
317 | 317 | |
318 | 318 | $tmpl = new Etemplate('calendar.planner'); |
319 | 319 | |
320 | - $tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($ui->first, Api\DateTime::ET2)); |
|
321 | - $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); |
|
322 | - $tmpl->setElementAttribute('planner','owner', $search_params['owner']); |
|
323 | - $tmpl->setElementAttribute('planner','group_by', $ui->sortby); |
|
320 | + $tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($ui->first, Api\DateTime::ET2)); |
|
321 | + $tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); |
|
322 | + $tmpl->setElementAttribute('planner', 'owner', $search_params['owner']); |
|
323 | + $tmpl->setElementAttribute('planner', 'group_by', $ui->sortby); |
|
324 | 324 | |
325 | 325 | // Make sure all used owners are there, faking |
326 | 326 | // calendar_owner_etemplate_widget::beforeSendToClient() since the |
327 | 327 | // rest of the calendar app is probably missing. |
328 | - foreach($search_params['owner'] as $owner) |
|
328 | + foreach ($search_params['owner'] as $owner) |
|
329 | 329 | { |
330 | 330 | $sel_options['owner'][] = Array( |
331 | 331 | 'id' => $owner, |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) |
334 | 334 | ); |
335 | 335 | } |
336 | - $tmpl->exec(__METHOD__, $content,$sel_options, array('__ALL__' => true),array(),2); |
|
336 | + $tmpl->exec(__METHOD__, $content, $sel_options, array('__ALL__' => true), array(), 2); |
|
337 | 337 | $html .= ob_get_contents(); |
338 | 338 | $html .= '<script>' |
339 | 339 | . ' window.egw_LAB.wait(function() {$j(function() {' |
340 | - . 'app.calendar.set_state(' . json_encode(array( |
|
340 | + . 'app.calendar.set_state('.json_encode(array( |
|
341 | 341 | 'owner' => $search_params['owner'], |
342 | 342 | 'sortby' => $ui->sortby, |
343 | 343 | 'filter' => $arguments['filter'] |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $html .= '<div class="message" align="center">'.lang('No owner selected').'</div>'; |
351 | 351 | } |
352 | 352 | |
353 | - while(@ob_end_clean()); |
|
353 | + while (@ob_end_clean()); |
|
354 | 354 | |
355 | 355 | return $html; |
356 | 356 | } |
@@ -178,15 +178,17 @@ discard block |
||
178 | 178 | $acl = new Acl($anon_user); |
179 | 179 | $acl->read_repository(); |
180 | 180 | foreach ($calendar_bo->resources as $type => $data) |
181 | - { |
|
181 | + { |
|
182 | 182 | // Check anon user's permissions - must have at least run for the hook to be available |
183 | 183 | if($acl->check('run',EGW_ACL_READ, $data['app']) && |
184 | 184 | $type != '' && $data['app'] && Link::get_registry($data['app'], 'query') |
185 | - ) |
|
186 | - { |
|
185 | + ) { |
|
187 | 186 | $_results = Link::query($data['app'], $query,$options); |
188 | 187 | } |
189 | - if(!$_results) continue; |
|
188 | + if(!$_results) |
|
189 | + { |
|
190 | + continue; |
|
191 | + } |
|
190 | 192 | $_results = array_unique($_results); |
191 | 193 | foreach ($_results as $key => $value) |
192 | 194 | { |
@@ -223,8 +225,14 @@ discard block |
||
223 | 225 | $arguments['sortby'] = 'month'; |
224 | 226 | $arguments['date'] = substr($arguments['date'],0,4).'0101'; |
225 | 227 | } |
226 | - if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
|
227 | - if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
|
228 | + if (isset($_GET['date'])) |
|
229 | + { |
|
230 | + $arguments['date'] = $_GET['date']; |
|
231 | + } |
|
232 | + if (empty($arguments['cat_id'])) |
|
233 | + { |
|
234 | + $arguments['cat_id'] = ''; |
|
235 | + } |
|
228 | 236 | if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
229 | 237 | { |
230 | 238 | foreach($arguments['resources'] as $index => $value) |
@@ -259,7 +267,8 @@ discard block |
||
259 | 267 | if (is_array($params['owner'])) |
260 | 268 | { |
261 | 269 | // Buffer, and add anything that gets cleared to the content |
262 | - ob_start(function($buffer) use(&$html) { |
|
270 | + ob_start(function($buffer) use(&$html) |
|
271 | + { |
|
263 | 272 | $html .= $buffer; |
264 | 273 | return ''; |
265 | 274 | }); |
@@ -268,20 +277,26 @@ discard block |
||
268 | 277 | $ui->sortby = $arguments['sortby']; |
269 | 278 | $ui->owner = $params['owner']; |
270 | 279 | |
271 | - if (!$ui->planner_view || $ui->planner_view == 'month') // planner monthview |
|
280 | + if (!$ui->planner_view || $ui->planner_view == 'month') |
|
281 | + { |
|
282 | + // planner monthview |
|
272 | 283 | { |
273 | 284 | if ($ui->day < 15) // show one complete month |
274 | 285 | { |
275 | 286 | $ui->_week_align_month($ui->first,$ui->last); |
287 | + } |
|
276 | 288 | } |
277 | 289 | else // show 2 half month |
278 | 290 | { |
279 | 291 | $ui->_week_align_month($ui->first,$ui->last,15); |
280 | 292 | } |
281 | 293 | } |
282 | - elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') // weeekview |
|
294 | + elseif ($ui->planner_view == 'week' || $ui->planner_view == 'weekN') |
|
295 | + { |
|
296 | + // weeekview |
|
283 | 297 | { |
284 | 298 | $start = new Api\DateTime($ui->date); |
299 | + } |
|
285 | 300 | $start->setWeekstart(); |
286 | 301 | $ui->first = $start->format('ts'); |
287 | 302 | $ui->last = $ui->bo->date2array($this->first); |
@@ -327,7 +327,7 @@ |
||
327 | 327 | // rest of the calendar app is probably missing. |
328 | 328 | foreach($search_params['owner'] as $owner) |
329 | 329 | { |
330 | - $sel_options['owner'][] = Array( |
|
330 | + $sel_options['owner'][] = array( |
|
331 | 331 | 'id' => $owner, |
332 | 332 | 'value' => $owner, |
333 | 333 | 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) |
@@ -27,12 +27,12 @@ |
||
27 | 27 | $this->description = lang('This module displays the current month'); |
28 | 28 | } |
29 | 29 | |
30 | - function get_content(&$arguments,$properties) |
|
30 | + function get_content(&$arguments, $properties) |
|
31 | 31 | { |
32 | - $date = (int) (strtotime(get_var('date',array('POST','GET')))); |
|
32 | + $date = (int)(strtotime(get_var('date', array('POST', 'GET')))); |
|
33 | 33 | $redirect = $arguments['redirect'] ? $arguments['redirect'] : '#'; |
34 | 34 | |
35 | 35 | return $GLOBALS['egw']->jscalendar->get_javascript(). |
36 | - $GLOBALS['egw']->jscalendar->flat($redirect,$date); |
|
36 | + $GLOBALS['egw']->jscalendar->flat($redirect, $date); |
|
37 | 37 | } |
38 | 38 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | /** |
13 | 13 | * Calendar day selection for sitemgr |
14 | 14 | */ |
15 | -class module_calendar extends Module |
|
15 | +class module_calendar extends Module |
|
16 | 16 | { |
17 | - function module_calendar() |
|
17 | + function module_calendar() |
|
18 | 18 | { |
19 | 19 | $this->arguments = array( |
20 | 20 | 'redirect' => array( |