[1506] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * -------------------------------------------------------------------------* |
---|
| 4 | * This library is free software; you can redistribute it and/or modify it * |
---|
| 5 | * under the terms of the GNU Lesser General Public License as published by * |
---|
| 6 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
| 7 | * or any later version. * |
---|
| 8 | * This library is distributed in the hope that it will be useful, but * |
---|
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
| 11 | * See the GNU Lesser General Public License for more details. * |
---|
| 12 | * You should have received a copy of the GNU Lesser General Public License * |
---|
| 13 | * along with this library; if not, write to the Free Software Foundation, * |
---|
| 14 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
| 15 | \**************************************************************************/ |
---|
| 16 | |
---|
| 17 | /* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ |
---|
| 18 | |
---|
| 19 | class uifilemanager |
---|
| 20 | { |
---|
| 21 | var $public_functions = array( |
---|
| 22 | 'index' => True, |
---|
| 23 | 'help' => True, |
---|
| 24 | 'view' => True, |
---|
| 25 | 'history' => True, |
---|
| 26 | 'edit' => True, |
---|
| 27 | 'download'=>True |
---|
| 28 | ); |
---|
| 29 | |
---|
| 30 | //keep |
---|
| 31 | var $bo; |
---|
| 32 | var $t; //template object |
---|
| 33 | var $dispath; |
---|
| 34 | var $cwd; |
---|
| 35 | var $lesspath; |
---|
| 36 | var $readable_groups; |
---|
| 37 | var $files_array; |
---|
| 38 | var $numoffiles; |
---|
| 39 | var $dispsep; |
---|
| 40 | |
---|
| 41 | var $target; |
---|
| 42 | |
---|
| 43 | var $prefs;//array |
---|
| 44 | |
---|
| 45 | var $groups_applications; |
---|
| 46 | |
---|
| 47 | //originally post_vars |
---|
| 48 | // var $goto; |
---|
| 49 | var $goto_x; |
---|
| 50 | var $download_x; |
---|
| 51 | var $todir; |
---|
| 52 | var $changedir; // for switching dir. |
---|
| 53 | var $cdtodir; // for switching dir. |
---|
| 54 | // var $createdir; |
---|
| 55 | var $newfile_or_dir; |
---|
| 56 | var $newdir_x; |
---|
| 57 | var $newfile_x; |
---|
| 58 | var $createfile_var; |
---|
| 59 | var $delete_x; |
---|
| 60 | var $renamefiles; |
---|
| 61 | var $rename_x; |
---|
| 62 | var $move_to_x; |
---|
| 63 | // var $copy_to; |
---|
| 64 | var $copy_to_x; |
---|
| 65 | var $edit_x; |
---|
| 66 | var $edit_comments_x; |
---|
| 67 | var $edit_file; |
---|
| 68 | var $edit_preview_x; |
---|
| 69 | var $edit_save_x; |
---|
| 70 | var $edit_save_done_x; |
---|
| 71 | var $edit_cancel_x; |
---|
| 72 | var $comment_files; |
---|
| 73 | var $upload_x; |
---|
| 74 | var $uploadprocess; |
---|
| 75 | |
---|
| 76 | // this ones must be checked thorougly; |
---|
| 77 | var $fileman = Array(); |
---|
| 78 | //var $fileman; |
---|
| 79 | var $path; |
---|
| 80 | var $file; // FIXME WHERE IS THIS FILLED? |
---|
| 81 | var $sortby; |
---|
| 82 | var $messages = array(); |
---|
| 83 | var $show_upload_boxes; |
---|
| 84 | |
---|
| 85 | var $debug = false; |
---|
| 86 | var $now; |
---|
| 87 | |
---|
| 88 | function uifilemanager() |
---|
| 89 | { |
---|
| 90 | // error_reporting(8); |
---|
| 91 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
| 92 | |
---|
| 93 | $this->now = date('Y-m-d'); |
---|
| 94 | |
---|
| 95 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
| 96 | |
---|
| 97 | $this->t = $GLOBALS['phpgw']->template; |
---|
| 98 | |
---|
| 99 | // here local vars are created from the HTTP vars |
---|
| 100 | @reset($GLOBALS['HTTP_POST_VARS']); |
---|
| 101 | while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) |
---|
| 102 | { |
---|
| 103 | $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | @reset($GLOBALS['HTTP_GET_VARS']); |
---|
| 107 | while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) |
---|
| 108 | { |
---|
| 109 | $$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | $to_decode = array |
---|
| 113 | ( |
---|
| 114 | /* |
---|
| 115 | Decode |
---|
| 116 | 'var' when 'avar' == 'value' |
---|
| 117 | or |
---|
| 118 | 'var' when 'var' is set |
---|
| 119 | */ |
---|
| 120 | 'op' => array('op' => ''), |
---|
| 121 | 'path' => array('path' => ''), |
---|
| 122 | 'file' => array('file' => ''), |
---|
| 123 | 'sortby' => array('sortby' => ''), |
---|
| 124 | // 'fileman' => array('fileman' => ''), |
---|
| 125 | 'messages' => array('messages' => ''), |
---|
| 126 | // 'help_name' => array('help_name' => ''), |
---|
| 127 | // 'renamefiles' => array('renamefiles' => ''), |
---|
| 128 | 'comment_files' => array('comment_files' => ''), |
---|
| 129 | 'show_upload_boxes' => array('show_upload_boxes' => '') |
---|
| 130 | ); |
---|
| 131 | |
---|
| 132 | reset($to_decode); |
---|
| 133 | while(list($var, $conditions) = each($to_decode)) |
---|
| 134 | { |
---|
| 135 | while(list($condvar, $condvalue) = each($conditions)) |
---|
| 136 | { |
---|
| 137 | if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) |
---|
| 138 | { |
---|
| 139 | if(is_array($$var)) |
---|
| 140 | { |
---|
| 141 | $temp = array(); |
---|
| 142 | while(list($varkey, $varvalue) = each($$var)) |
---|
| 143 | { |
---|
| 144 | if(is_int($varkey)) |
---|
| 145 | { |
---|
| 146 | $temp[$varkey] = stripslashes(base64_decode(urldecode(($varvalue)))); |
---|
| 147 | } |
---|
| 148 | else |
---|
| 149 | { |
---|
| 150 | $temp[stripslashes(base64_decode(urldecode(($varkey))))] = $varvalue; |
---|
| 151 | } |
---|
| 152 | } |
---|
| 153 | $this->$var = $temp; |
---|
| 154 | } |
---|
| 155 | elseif(isset($$var)) |
---|
| 156 | { |
---|
| 157 | $this->$var = stripslashes(base64_decode(urldecode($$var))); |
---|
| 158 | } |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | // get appl. and user prefs |
---|
| 164 | $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); |
---|
| 165 | $pref->read_repository(); |
---|
| 166 | // $GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); |
---|
| 167 | $pref->save_repository(True); |
---|
| 168 | $pref_array = $pref->read_repository(); |
---|
| 169 | $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array |
---|
| 170 | |
---|
| 171 | //always show name |
---|
| 172 | |
---|
| 173 | $this->prefs[name] =1; |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | if($this->prefs['viewinnewwin']) |
---|
| 177 | { |
---|
| 178 | $this->target = '_blank'; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | /* |
---|
| 183 | Check for essential directories |
---|
| 184 | admin must be able to disable these tests |
---|
| 185 | */ |
---|
| 186 | |
---|
| 187 | // check if basedir exist |
---|
| 188 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 189 | if($test[mime_type]!='Directory') |
---|
| 190 | { |
---|
| 191 | die('Base directory does not exist, Ask adminstrator to check the global configuration.'); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 195 | if($test[mime_type]!='Directory') |
---|
| 196 | { |
---|
| 197 | |
---|
| 198 | $this->bo->vfs->override_acl = 1; |
---|
| 199 | |
---|
| 200 | $this->bo->vfs->mkdir(array( |
---|
| 201 | 'string' => $this->bo->fakebase, |
---|
| 202 | 'relatives' => array(RELATIVE_NONE) |
---|
| 203 | )); |
---|
| 204 | |
---|
| 205 | $this->bo->vfs->override_acl = 0; |
---|
| 206 | |
---|
| 207 | //test one more time |
---|
| 208 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 209 | |
---|
| 210 | if($test[mime_type]!='Directory') |
---|
| 211 | { |
---|
| 212 | die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); |
---|
| 213 | } |
---|
| 214 | else |
---|
| 215 | { |
---|
| 216 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( |
---|
| 217 | lang('Fake Base Dir did not exist, eGroupWare created a new one.') |
---|
| 218 | )); |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | // die($this->bo->homedir); |
---|
| 223 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 224 | if($test[mime_type]!='Directory') |
---|
| 225 | { |
---|
| 226 | $this->bo->vfs->override_acl = 1; |
---|
| 227 | |
---|
| 228 | $this->bo->vfs->mkdir(array( |
---|
| 229 | 'string' => $this->bo->homedir, |
---|
| 230 | 'relatives' => array(RELATIVE_NONE) |
---|
| 231 | )); |
---|
| 232 | |
---|
| 233 | $this->bo->vfs->override_acl = 0; |
---|
| 234 | |
---|
| 235 | //test one more time |
---|
| 236 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 237 | |
---|
| 238 | if($test[mime_type]!='Directory') |
---|
| 239 | { |
---|
| 240 | die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); |
---|
| 241 | } |
---|
| 242 | else |
---|
| 243 | { |
---|
| 244 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( |
---|
| 245 | lang('Your Home Dir did not exist, eGroupWare created a new one.') |
---|
| 246 | )); |
---|
| 247 | // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content |
---|
| 248 | } |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | function index() |
---|
| 255 | { |
---|
| 256 | if($noheader || $nofooter || ($this->download_x && (count($this->fileman) > 0))) |
---|
| 257 | { |
---|
| 258 | $noheader = True; |
---|
| 259 | $nofooter = True; |
---|
| 260 | $noappheader= True; |
---|
| 261 | $nonavbar= True; |
---|
| 262 | } |
---|
| 263 | else |
---|
| 264 | { |
---|
| 265 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 266 | ( |
---|
| 267 | 'currentapp' => 'filemanager', |
---|
| 268 | 'noheader' => $noheader, |
---|
| 269 | 'nonavbar' => $nonavbar, |
---|
| 270 | 'nofooter' => $nofooter, |
---|
| 271 | 'noappheader' => $noappheader, |
---|
| 272 | 'enable_browser_class' => True |
---|
| 273 | ); |
---|
| 274 | |
---|
| 275 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 276 | |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | |
---|
| 280 | # Page to process users |
---|
| 281 | # Code is fairly hackish at the beginning, but it gets better |
---|
| 282 | # Highly suggest turning wrapping off due to long SQL queries |
---|
| 283 | |
---|
| 284 | ### |
---|
| 285 | # Some hacks to set and display directory paths correctly |
---|
| 286 | ### |
---|
| 287 | /* |
---|
| 288 | if($this->goto || $this->goto_x) |
---|
| 289 | { |
---|
| 290 | $this->path = $this->cdtodir; |
---|
| 291 | } |
---|
| 292 | */ |
---|
| 293 | // new method for switching to a new dir. |
---|
| 294 | if($this->changedir=='true' && $this->cdtodir || $this->goto_x) |
---|
| 295 | { |
---|
| 296 | $this->path = $this->cdtodir; |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | if(!$this->path) |
---|
| 300 | { |
---|
| 301 | $this->path = $this->bo->vfs->pwd(); |
---|
| 302 | |
---|
| 303 | if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') |
---|
| 304 | { |
---|
| 305 | $this->path = $this->bo->homedir; |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 310 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 311 | |
---|
| 312 | $pwd = $this->bo->vfs->pwd(); |
---|
| 313 | |
---|
| 314 | if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) |
---|
| 315 | { |
---|
| 316 | $this->cwd = '/'; |
---|
| 317 | } |
---|
| 318 | else |
---|
| 319 | { |
---|
| 320 | $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | $this->disppath = $this->path; |
---|
| 324 | |
---|
| 325 | /* This just prevents // in some cases */ |
---|
| 326 | if($this->path == '/') |
---|
| 327 | { |
---|
| 328 | $this->dispsep = ''; |
---|
| 329 | } |
---|
| 330 | else |
---|
| 331 | { |
---|
| 332 | $this->dispsep = '/'; |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) |
---|
| 336 | { |
---|
| 337 | $this->lesspath = '/'; |
---|
| 338 | } |
---|
| 339 | |
---|
| 340 | # Get their readable groups to be used throughout the script |
---|
[1508] | 341 | $acl = array(); |
---|
[1506] | 342 | $groups = array(); |
---|
[1519] | 343 | $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager'); |
---|
[1508] | 344 | if (is_array($acl)) |
---|
| 345 | foreach($acl as $key => $value){ |
---|
| 346 | $info = array(); |
---|
| 347 | $info = $GLOBALS['phpgw']->accounts->get_account_data($value); |
---|
| 348 | $groups[$key]['account_id'] = $value; |
---|
| 349 | $groups[$key]['account_lid'] = $info[$value]['lid']; |
---|
| 350 | $groups[$key]['account_name'] = $info[$value]['firstname']; |
---|
| 351 | $groups[$key]['account_lastname'] = $info[$value]['lastname']; |
---|
| 352 | $groups[$key]['account_fullname'] = $info[$value]['fullname']; |
---|
| 353 | } |
---|
[1506] | 354 | $this->readable_groups = array(); |
---|
| 355 | |
---|
| 356 | while(list($num, $account) = each($groups)) |
---|
| 357 | { |
---|
[1508] | 358 | // if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) |
---|
[1506] | 359 | { |
---|
| 360 | $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
[1508] | 364 | |
---|
[1506] | 365 | $this->groups_applications = array(); |
---|
| 366 | |
---|
[1508] | 367 | foreach ($this->readable_groups as $value) |
---|
[1506] | 368 | { |
---|
[1508] | 369 | $applications = CreateObject('phpgwapi.applications', $value['account_id']); |
---|
| 370 | $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); |
---|
[1506] | 371 | } |
---|
| 372 | |
---|
| 373 | # We determine if they're in their home directory or a group's directory, |
---|
| 374 | # and set the VFS working_id appropriately |
---|
| 375 | if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined |
---|
| 376 | |
---|
| 377 | { |
---|
| 378 | $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined |
---|
| 379 | |
---|
| 380 | } |
---|
| 381 | else |
---|
| 382 | { |
---|
| 383 | $this->bo->vfs->working_id = $this->bo->userinfo['username']; |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | |
---|
| 387 | # FIXME # comment waht happens here |
---|
| 388 | if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ))) |
---|
| 389 | { |
---|
| 390 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path))); |
---|
| 391 | $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory')); |
---|
| 392 | |
---|
| 393 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 394 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; |
---|
| 398 | $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); |
---|
| 399 | |
---|
| 400 | # If their home directory doesn't exist, we try to create it |
---|
| 401 | # Same for group directories |
---|
| 402 | |
---|
| 403 | |
---|
| 404 | // Moved to constructor |
---|
| 405 | /* |
---|
| 406 | if(($this->path == $this->homedir) && !$this->bo->vfs->file_exists($pim_tmp_arr)) |
---|
| 407 | { |
---|
| 408 | $this->bo->vfs->override_acl = 1; |
---|
| 409 | |
---|
| 410 | if(!$this->bo->vfs->mkdir(array( |
---|
| 411 | 'string' => $this->bo->homedir, |
---|
| 412 | 'relatives' => array(RELATIVE_NONE) |
---|
| 413 | ))) |
---|
| 414 | { |
---|
| 415 | $p = $this->bo->vfs->path_parts($pim_tmp_arr); |
---|
| 416 | |
---|
| 417 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( |
---|
| 418 | lang('Could not create directory %1', |
---|
| 419 | $this->bo->homedir . ' (' . $p->real_full_path . ')' |
---|
| 420 | ))); |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | $this->bo->vfs->override_acl = 0; |
---|
| 424 | } |
---|
| 425 | */ |
---|
| 426 | |
---|
| 427 | # Verify path is real |
---|
| 428 | if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 429 | { |
---|
| 430 | if(!$this->bo->vfs->file_exists(array( |
---|
| 431 | 'string' => $this->path, |
---|
| 432 | 'relatives' => array(RELATIVE_NONE) |
---|
| 433 | ))) |
---|
| 434 | { |
---|
| 435 | $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path))); |
---|
| 436 | $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory')); |
---|
| 437 | |
---|
| 438 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 439 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | /* Update if they request it, or one out of 20 page loads */ |
---|
| 444 | srand((double) microtime() * 1000000); |
---|
| 445 | if($update || rand(0, 19) == 4) |
---|
| 446 | { |
---|
| 447 | $this->bo->vfs->update_real(array( |
---|
| 448 | 'string' => $this->path, |
---|
| 449 | 'relatives' => array(RELATIVE_NONE) |
---|
| 450 | )); |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | # Check available permissions for $this->path, so we can disable unusable operations in user interface |
---|
| 454 | if($this->bo->vfs->acl_check(array( |
---|
| 455 | 'string' => $this->path, |
---|
| 456 | 'relatives' => array(RELATIVE_NONE), |
---|
| 457 | 'operation' => PHPGW_ACL_ADD |
---|
| 458 | ))) |
---|
| 459 | { |
---|
| 460 | $this->can_add = True; |
---|
| 461 | } |
---|
[1524] | 462 | if($this->bo->vfs->acl_check(array( |
---|
| 463 | 'string' => $this->path, |
---|
| 464 | 'relatives' => array(RELATIVE_NONE), |
---|
| 465 | 'operation' => PHPGW_ACL_EDIT |
---|
| 466 | ))) |
---|
| 467 | { |
---|
| 468 | $this->can_edit = True; |
---|
| 469 | } |
---|
| 470 | if($this->bo->vfs->acl_check(array( |
---|
| 471 | 'string' => $this->path, |
---|
| 472 | 'relatives' => array(RELATIVE_NONE), |
---|
| 473 | 'operation' => PHPGW_ACL_DELETE |
---|
| 474 | ))) |
---|
| 475 | { |
---|
| 476 | $this->can_delete = True; |
---|
| 477 | } |
---|
[1506] | 478 | |
---|
[1524] | 479 | |
---|
[1506] | 480 | # Default is to sort by name |
---|
| 481 | if(!$this->sortby) |
---|
| 482 | { |
---|
| 483 | $this->sortby = 'name'; |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | if($this->debug) |
---|
| 487 | { |
---|
| 488 | $this->debug_filemanager(); |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | # main action switch |
---|
| 492 | // FIXME this will become a switch |
---|
| 493 | if($this->newfile_x && $this->newfile_or_dir) // create new textfile |
---|
| 494 | { |
---|
| 495 | $this->createfile(); |
---|
| 496 | } |
---|
| 497 | elseif($this->newfile_or_dir && $this->newdir_x) |
---|
| 498 | { |
---|
| 499 | $this->createdir(); |
---|
| 500 | } |
---|
| 501 | elseif($this->uploadprocess) |
---|
| 502 | { |
---|
| 503 | $this->fileUpload(); |
---|
| 504 | } |
---|
| 505 | elseif($this->upload_x || $this->show_upload_boxes) |
---|
| 506 | { |
---|
| 507 | $this->showUploadboxes(); |
---|
| 508 | } |
---|
| 509 | elseif($this->copy_to_x) |
---|
| 510 | { |
---|
| 511 | $this->copyTo(); |
---|
| 512 | } |
---|
| 513 | elseif($this->move_to_x) |
---|
| 514 | { |
---|
| 515 | $this->moveTo(); |
---|
| 516 | } |
---|
| 517 | elseif($this->download_x) |
---|
| 518 | { |
---|
| 519 | $this->download(); |
---|
| 520 | } |
---|
| 521 | elseif($this->renamefiles) |
---|
| 522 | { |
---|
| 523 | $this->rename(); |
---|
| 524 | } |
---|
| 525 | elseif($this->comment_files) |
---|
| 526 | { |
---|
| 527 | $this->editComment(); |
---|
| 528 | } |
---|
| 529 | elseif($this->edit_cancel_x) |
---|
| 530 | { |
---|
| 531 | $this->readFilesInfo(); |
---|
| 532 | $this->fileListing(); |
---|
| 533 | } |
---|
| 534 | elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) |
---|
| 535 | { |
---|
| 536 | $this->edit(); |
---|
| 537 | } |
---|
| 538 | elseif($this->delete_x) |
---|
| 539 | { |
---|
| 540 | $this->delete(); |
---|
| 541 | } |
---|
| 542 | else |
---|
| 543 | { |
---|
| 544 | $this->readFilesInfo(); |
---|
| 545 | $this->fileListing(); |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | function fileListing() |
---|
| 550 | { |
---|
| 551 | $this->t->set_file(array('filemanager_list_t' => 'filelisting.tpl')); |
---|
| 552 | $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); |
---|
| 553 | $this->t->set_block('filemanager_list_t','column','column'); |
---|
| 554 | $this->t->set_block('filemanager_list_t','row','row'); |
---|
| 555 | $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); |
---|
| 556 | |
---|
| 557 | $vars['form_action']=$this->encode_href('/index.php', 'menuaction=filemanager.uifilemanager.index','path='.$this->path); |
---|
| 558 | if($this->numoffiles || $this->cwd) |
---|
| 559 | { |
---|
| 560 | while(list($num, $name) = each($this->prefs)) |
---|
| 561 | { |
---|
| 562 | if($name) |
---|
| 563 | { |
---|
| 564 | $columns++; |
---|
| 565 | } |
---|
| 566 | } |
---|
| 567 | $columns++; |
---|
| 568 | |
---|
| 569 | $vars[toolbar0]=$this->toolbar('location'); |
---|
| 570 | $vars[toolbar1]=$this->toolbar('list_nav'); |
---|
| 571 | |
---|
| 572 | if(count($this->messages)>0) |
---|
| 573 | { |
---|
| 574 | foreach($this->messages as $msg) |
---|
| 575 | { |
---|
| 576 | $messages.='<p>'.$msg.'</p>'; |
---|
| 577 | } |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | $vars[messages]=$messages; |
---|
| 581 | |
---|
| 582 | $this->t->set_var($vars); |
---|
| 583 | $this->t->pparse('out','filemanager_header'); |
---|
| 584 | |
---|
| 585 | ### |
---|
| 586 | # Start File Table Column Headers |
---|
| 587 | # Reads values from $file_attributes array and preferences |
---|
| 588 | ### |
---|
| 589 | $this->t->set_var('actions',lang('select')); |
---|
| 590 | |
---|
| 591 | reset($this->bo->file_attributes); |
---|
| 592 | |
---|
| 593 | if($this->numoffiles>0) |
---|
| 594 | { |
---|
| 595 | while(list($internal, $displayed) = each($this->bo->file_attributes)) |
---|
| 596 | { |
---|
| 597 | if($this->prefs[$internal]) |
---|
| 598 | { |
---|
| 599 | $col_data='<span><a href="'.$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.'&sortby='.$internal).'">'.$displayed.'</a></span>'; |
---|
| 600 | $this->t->set_var('col_data',$col_data); |
---|
| 601 | $this->t->parse('columns','column',True); |
---|
| 602 | } |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | $this->t->set_var('row_tr_color','#dedede'); |
---|
| 606 | |
---|
| 607 | //kan dit weg? |
---|
| 608 | $this->t->parse('rows','row'); |
---|
| 609 | |
---|
| 610 | $this->t->pparse('out','row'); |
---|
| 611 | } |
---|
| 612 | else |
---|
| 613 | { |
---|
| 614 | $lang_nofiles=lang('No files in this directory.'); |
---|
| 615 | } |
---|
| 616 | $vars[lang_no_files]=$lang_nofiles; |
---|
| 617 | |
---|
| 618 | |
---|
| 619 | if($this->prefs['dotdot'] && $this->prefs['name'] && $this->path != '/') |
---|
| 620 | { |
---|
| 621 | $this->t->set_var('actions',''); |
---|
| 622 | |
---|
| 623 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); |
---|
| 624 | |
---|
| 625 | $col_data='<a href="'.$link.'"><img src="'.$GLOBALS['phpgw']->common->image('filemanager','mime16up').' "alt="'.lang('Folder Up').'" /></a>'; |
---|
| 626 | $col_data.=' <a href="'.$link.'">..</a>'; |
---|
| 627 | |
---|
| 628 | $this->t->set_var('col_data',$col_data); |
---|
| 629 | $this->t->parse('columns','column'); |
---|
| 630 | |
---|
| 631 | if($this->prefs['mime_type']) |
---|
| 632 | { |
---|
| 633 | $col_data=lang('Directory'); |
---|
| 634 | $this->t->set_var('col_data',$col_data); |
---|
| 635 | $this->t->parse('columns','column',True); |
---|
| 636 | } |
---|
| 637 | |
---|
| 638 | $this->t->set_var('row_tr_color',$tr_color); |
---|
| 639 | $this->t->parse('rows','row'); |
---|
| 640 | $this->t->pparse('out','row'); |
---|
| 641 | } |
---|
| 642 | |
---|
| 643 | # List all of the files, with their attributes |
---|
| 644 | @reset($this->files_array); |
---|
| 645 | for($i = 0; $i != $this->numoffiles; $i++) |
---|
| 646 | { |
---|
| 647 | $files = $this->files_array[$i]; |
---|
| 648 | |
---|
| 649 | if($this->rename_x || $this->edit_comments_x) |
---|
| 650 | { |
---|
| 651 | unset($this_selected); |
---|
| 652 | unset($renamethis); |
---|
| 653 | unset($edit_this_comment); |
---|
| 654 | |
---|
| 655 | for($j = 0; $j != $this->numoffiles; $j++) |
---|
| 656 | { |
---|
| 657 | if($this->fileman[$j] == $files['name']) |
---|
| 658 | { |
---|
| 659 | $this_selected = 1; |
---|
| 660 | break; |
---|
| 661 | } |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | if($this->rename_x && $this_selected) |
---|
| 665 | { |
---|
| 666 | $renamethis = 1; |
---|
| 667 | } |
---|
| 668 | elseif($this->edit_comments_x && $this_selected) |
---|
| 669 | { |
---|
| 670 | $edit_this_comment = 1; |
---|
| 671 | } |
---|
| 672 | } |
---|
| 673 | |
---|
| 674 | if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])) |
---|
| 675 | { |
---|
| 676 | continue; |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | # Checkboxes |
---|
| 680 | if(!$this->rename_x && !$this->edit_comments_x && $this->path != $this->bo->fakebase && $this->path != '/') |
---|
| 681 | { |
---|
| 682 | $cbox='<input type="checkbox" name="fileman['.$i.']" value="'.$files['name'].'">'; |
---|
| 683 | $this->t->set_var('actions',$cbox); |
---|
| 684 | } |
---|
| 685 | elseif($renamethis) |
---|
| 686 | { |
---|
| 687 | $cbox=$this->html_form_input('hidden', 'fileman[' . base64_encode($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); |
---|
| 688 | $this->t->set_var('actions',$cbox); |
---|
| 689 | } |
---|
| 690 | else |
---|
| 691 | { |
---|
| 692 | $this->t->set_var('actions',''); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | # File name and icon |
---|
| 696 | if($renamethis) |
---|
| 697 | { |
---|
| 698 | $col_data=$this->mime_icon($files['mime_type']); |
---|
| 699 | $col_data.='<input type="text" maxlength="255" name="renamefiles[' . $files['name'] . ']" value="'.$files['name'].'">'; |
---|
| 700 | } |
---|
| 701 | else |
---|
| 702 | { |
---|
| 703 | if($files['mime_type'] == 'Directory') |
---|
| 704 | { |
---|
| 705 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']); |
---|
| 706 | |
---|
| 707 | $icon=$this->mime_icon($files['mime_type']); |
---|
| 708 | |
---|
| 709 | $col_data='<a href="'.$link.'">'.$icon.'</a> '; |
---|
| 710 | $col_data.='<a href="'.$link.'">'.$files['name'].'</a> '; |
---|
| 711 | } |
---|
| 712 | else |
---|
| 713 | { |
---|
| 714 | |
---|
| 715 | if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory']) |
---|
| 716 | { |
---|
| 717 | #FIXME |
---|
| 718 | $clickview = $this->filesdir.$pwd.'/'.$files['name']; |
---|
| 719 | |
---|
| 720 | if($phpwh_debug) |
---|
| 721 | { |
---|
| 722 | echo 'Setting clickview = '.$clickview.'<br>'."\n"; |
---|
| 723 | $this->html_link($clickview,'', '',$files['name'], 0, 1, 0, ''); |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | else |
---|
| 727 | { |
---|
| 728 | $icon=$this->mime_icon($files['mime_type']); |
---|
| 729 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path); |
---|
| 730 | |
---|
| 731 | $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a> <a href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>'; |
---|
| 732 | } |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | $this->t->set_var('col_data',$col_data); |
---|
| 737 | $this->t->parse('columns','column'); |
---|
| 738 | |
---|
| 739 | # MIME type |
---|
| 740 | if($this->prefs['mime_type']) |
---|
| 741 | { |
---|
| 742 | $col_data=$files['mime_type']; |
---|
| 743 | $this->t->set_var('col_data',$col_data); |
---|
| 744 | $this->t->parse('columns','column',True); |
---|
| 745 | } |
---|
| 746 | |
---|
| 747 | # File size |
---|
| 748 | if($this->prefs['size']) |
---|
| 749 | { |
---|
| 750 | $tmp_arr=array( |
---|
| 751 | 'string' => $files['directory'] . '/' . $files['name'], |
---|
| 752 | 'relatives' => array(RELATIVE_NONE) |
---|
| 753 | ); |
---|
| 754 | if($files['mime_type'] != 'Directory') $tmp_arr['checksubdirs'] = false; |
---|
| 755 | |
---|
| 756 | $size = $this->bo->vfs->get_size($tmp_arr); |
---|
| 757 | |
---|
| 758 | $col_data=$this->bo->borkb($size); |
---|
| 759 | |
---|
| 760 | $this->t->set_var('col_data',$col_data); |
---|
| 761 | $this->t->parse('columns','column',True); |
---|
| 762 | } |
---|
| 763 | |
---|
| 764 | # Date created |
---|
| 765 | if($this->prefs['created']) |
---|
| 766 | { |
---|
| 767 | $col_data=$files['created']; |
---|
| 768 | $this->t->set_var('col_data',$col_data); |
---|
| 769 | $this->t->parse('columns','column',True); |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | # Date modified |
---|
| 773 | if($this->prefs['modified']) |
---|
| 774 | { |
---|
| 775 | if($files['modified'] != '0000-00-00') |
---|
| 776 | { |
---|
| 777 | $col_data=$files['modified']; |
---|
| 778 | } |
---|
| 779 | else |
---|
| 780 | { |
---|
| 781 | $col_data=''; |
---|
| 782 | } |
---|
| 783 | |
---|
| 784 | $this->t->set_var('col_data',$col_data); |
---|
| 785 | $this->t->parse('columns','column',True); |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | # Owner name |
---|
| 789 | if($this->prefs['owner']) |
---|
| 790 | { |
---|
| 791 | $this->t->set_var('col_data',$GLOBALS['phpgw']->accounts->id2name($files['owner_id'])); |
---|
| 792 | $this->t->parse('columns','column',True); |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | # Creator name |
---|
| 796 | if($this->prefs['createdby_id']) |
---|
| 797 | { |
---|
| 798 | $this->html_table_col_begin(); |
---|
| 799 | if($files['createdby_id']) |
---|
| 800 | { |
---|
| 801 | $col_data=$GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); |
---|
| 802 | } |
---|
| 803 | else $col_data=''; |
---|
| 804 | |
---|
| 805 | $this->t->set_var('col_data',$col_data); |
---|
| 806 | $this->t->parse('columns','column',True); |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | # Modified by name |
---|
| 810 | if($this->prefs['modifiedby_id']) |
---|
| 811 | { |
---|
| 812 | if($files['modifiedby_id']) |
---|
| 813 | { |
---|
| 814 | $col_data=$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']); |
---|
| 815 | } |
---|
| 816 | else $col_data=''; |
---|
| 817 | $this->t->set_var('col_data',$col_data); |
---|
| 818 | $this->t->parse('columns','column',True); |
---|
| 819 | } |
---|
| 820 | |
---|
| 821 | # Application |
---|
| 822 | if($this->prefs['app']) |
---|
| 823 | { |
---|
| 824 | $col_data=$files['app']; |
---|
| 825 | $this->t->set_var('col_data',$col_data); |
---|
| 826 | $this->t->parse('columns','column',True); |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | # Comment |
---|
| 830 | if($this->prefs['comment']) |
---|
| 831 | { |
---|
| 832 | if($edit_this_comment) |
---|
| 833 | { |
---|
| 834 | $col_data='<input type="text" name="comment_files[' . $files['name'] . ']" value="'.$files['comment'].'" maxlength="255">'; |
---|
| 835 | } |
---|
| 836 | else |
---|
| 837 | { |
---|
| 838 | $col_data=$files['comment']; |
---|
| 839 | } |
---|
| 840 | $this->t->set_var('col_data',$col_data); |
---|
| 841 | $this->t->parse('columns','column',True); |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | # Version |
---|
| 845 | if($this->prefs['version']) |
---|
| 846 | { |
---|
| 847 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.history','file='.$files['name'].'&path='.$this->path); |
---|
| 848 | $col_data='<a href="'.$link.'" target="_blank">'.$files['version'].'</a>'; |
---|
| 849 | $this->t->set_var('col_data',$col_data); |
---|
| 850 | $this->t->parse('columns','column',True); |
---|
| 851 | } |
---|
| 852 | |
---|
| 853 | if($files['mime_type'] == 'Directory') |
---|
| 854 | { |
---|
| 855 | $usedspace += $fileinfo[0]; |
---|
| 856 | } |
---|
| 857 | else |
---|
| 858 | { |
---|
| 859 | $usedspace += $files['size']; |
---|
| 860 | } |
---|
| 861 | |
---|
| 862 | $this->t->set_var('row_tr_color',''); |
---|
| 863 | $this->t->parse('rows','row'); |
---|
| 864 | $this->t->pparse('out','row'); |
---|
| 865 | } |
---|
| 866 | |
---|
| 867 | // when renaming or changing comments render extra sumbmit button |
---|
| 868 | if($this->rename_x || $this->edit_comments_x) |
---|
| 869 | { |
---|
| 870 | $col_data='<br/><input type="submit" name="save_changes" value="'.lang('Save changes').'">'; |
---|
| 871 | $this->t->set_var('col_data',$col_data); |
---|
| 872 | $this->t->parse('columns','column'); |
---|
| 873 | $this->t->set_var('row_tr_color',''); |
---|
| 874 | $this->t->parse('rows','row'); |
---|
| 875 | $this->t->pparse('out','row'); |
---|
| 876 | } |
---|
| 877 | } |
---|
| 878 | |
---|
| 879 | // The file and directory information |
---|
| 880 | $vars[lang_files_in_this_dir]=lang('Files in this directory'); |
---|
| 881 | $vars[files_in_this_dir]=$this->numoffiles; |
---|
| 882 | |
---|
| 883 | $vars[lang_used_space]=lang('Used space'); |
---|
| 884 | $vars[used_space]=$this->bo->borkb($usedspace, NULL, 1); |
---|
| 885 | |
---|
| 886 | if($this->path == $this->bo->homedir || $this->path == $this->bo->fakebase) |
---|
| 887 | { |
---|
| 888 | $vars[lang_unused_space]=lang('Unused space'); |
---|
| 889 | $vars[unused_space]=$this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace, NULL, 1); |
---|
| 890 | |
---|
| 891 | $tmp_arr=array( |
---|
| 892 | 'string' => $this->path, |
---|
| 893 | 'relatives' => array(RELATIVE_NONE) |
---|
| 894 | ); |
---|
| 895 | |
---|
| 896 | $ls_array = $this->bo->vfs->ls($tmp_arr); |
---|
| 897 | |
---|
| 898 | $vars[lang_total_files]=lang('Total Files'); |
---|
| 899 | $vars[total_files]= count($ls_array); |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | $this->t->set_var($vars); |
---|
| 903 | $this->t->pparse('out','filemanager_footer'); |
---|
| 904 | |
---|
| 905 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 906 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | function readFilesInfo() |
---|
| 910 | { |
---|
| 911 | // start files info |
---|
| 912 | |
---|
| 913 | # Read in file info from database to use in the rest of the script |
---|
| 914 | # $fakebase is a special directory. In that directory, we list the user's |
---|
| 915 | # home directory and the directories for the groups they're in |
---|
| 916 | $this->numoffiles = 0; |
---|
| 917 | if($this->path == $this->bo->fakebase) |
---|
| 918 | { |
---|
| 919 | // FIXME this test can be removed |
---|
| 920 | if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) |
---|
| 921 | { |
---|
| 922 | $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); |
---|
| 923 | } |
---|
| 924 | |
---|
| 925 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 926 | 'string' => $this->bo->homedir, |
---|
| 927 | 'relatives' => array(RELATIVE_NONE), |
---|
| 928 | 'checksubdirs' => False, |
---|
| 929 | 'nofiles' => True |
---|
| 930 | )); |
---|
| 931 | $this->files_array[] = $ls_array[0]; |
---|
| 932 | $this->numoffiles++; |
---|
| 933 | |
---|
| 934 | reset($this->readable_groups); |
---|
| 935 | while(list($num, $group_array) = each($this->readable_groups)) |
---|
| 936 | { |
---|
| 937 | # If the group doesn't have access to this app, we don't show it |
---|
[1508] | 938 | /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) |
---|
[1506] | 939 | { |
---|
| 940 | continue; |
---|
| 941 | } |
---|
[1508] | 942 | */ |
---|
[1506] | 943 | |
---|
| 944 | |
---|
| 945 | if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE)))) |
---|
| 946 | { |
---|
| 947 | $this->bo->vfs->override_acl = 1; |
---|
| 948 | $this->bo->vfs->mkdir(array( |
---|
| 949 | 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], |
---|
| 950 | 'relatives' => array(RELATIVE_NONE) |
---|
| 951 | )); |
---|
| 952 | |
---|
| 953 | // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content |
---|
| 954 | |
---|
| 955 | |
---|
| 956 | $this->bo->vfs->override_acl = 0; |
---|
| 957 | |
---|
| 958 | $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id']))); |
---|
| 959 | } |
---|
| 960 | |
---|
| 961 | $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); |
---|
| 962 | |
---|
| 963 | $this->files_array[] = $ls_array[0]; |
---|
| 964 | |
---|
| 965 | $this->numoffiles++; |
---|
| 966 | } |
---|
| 967 | } |
---|
| 968 | else |
---|
| 969 | { |
---|
| 970 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 971 | 'string' => $this->path, |
---|
| 972 | 'relatives' => array(RELATIVE_NONE), |
---|
| 973 | 'checksubdirs' => False, |
---|
| 974 | 'nofiles' => False, |
---|
| 975 | 'orderby' => $this->sortby |
---|
| 976 | )); |
---|
| 977 | |
---|
| 978 | if($phpwh_debug) |
---|
| 979 | { |
---|
| 980 | echo '# of files found in "'.$this->path.'" : '.count($ls_array).'<br>'."\n"; |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | while(list($num, $file_array) = each($ls_array)) |
---|
| 984 | { |
---|
| 985 | $this->numoffiles++; |
---|
| 986 | $this->files_array[] = $file_array; |
---|
| 987 | if($phpwh_debug) |
---|
| 988 | { |
---|
| 989 | echo 'Filename: '.$file_array['name'].'<br>'."\n"; |
---|
| 990 | } |
---|
| 991 | } |
---|
| 992 | } |
---|
| 993 | |
---|
| 994 | if(!is_array($this->files_array)) |
---|
| 995 | { |
---|
| 996 | $this->files_array = array(); |
---|
| 997 | } |
---|
| 998 | // end file count |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | function toolbar($type) |
---|
| 1002 | { |
---|
| 1003 | switch($type) |
---|
| 1004 | { |
---|
| 1005 | case 'location': |
---|
| 1006 | $toolbar=' |
---|
| 1007 | <div id="fmLocation"> |
---|
[1524] | 1008 | <table cellspacing="10" cellpadding="0" border="0"> |
---|
[1506] | 1009 | <tr> |
---|
| 1010 | '; |
---|
[1524] | 1011 | // $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; |
---|
| 1012 | // $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
[1506] | 1013 | |
---|
| 1014 | // go up icon when we're not at the top, dont allow to go outside /home = fakebase |
---|
| 1015 | if($this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 1016 | { |
---|
| 1017 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); |
---|
| 1018 | $toolbar.=$this->buttonImage($link,'up',lang('go up')); |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | // go home icon when we're not home already |
---|
| 1022 | if($this->path != $this->bo->homedir) |
---|
| 1023 | { |
---|
| 1024 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir); |
---|
| 1025 | $toolbar.=$this->buttonImage($link,'home',lang('go home')); |
---|
| 1026 | } |
---|
| 1027 | |
---|
| 1028 | // reload button with this url |
---|
| 1029 | $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); |
---|
| 1030 | $toolbar.=$this->buttonImage($link,'reload',lang('reload')); |
---|
| 1031 | |
---|
| 1032 | $toolbar.='<td>'.lang('Location').': '; |
---|
| 1033 | //$toolbar.='<input id="fmInputLocation" type="text" size="20" disabled="disabled" name="location" value="'.$this->disppath.'"/> '; |
---|
| 1034 | $current_option='<option>'.$this->disppath.'</option>'; |
---|
| 1035 | // selectbox for change/move/and copy to |
---|
| 1036 | $dirs_options=$this->all_other_directories_options(); |
---|
| 1037 | $toolbar.='<select name="cdtodir" onChange="document.formfm.changedir.value=\'true\';document.formfm.submit()">'.$current_option.$dirs_options.'</select> |
---|
| 1038 | <input type="hidden" name="changedir" value="false"></td> |
---|
| 1039 | '; |
---|
[1524] | 1040 | //$toolbar.=$this->inputImage('goto','goto',lang('Quick jump to')); |
---|
[1506] | 1041 | // upload button |
---|
| 1042 | if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) |
---|
| 1043 | { |
---|
| 1044 | |
---|
[1524] | 1045 | // $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
| 1046 | // $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; |
---|
| 1047 | // $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
| 1048 | // $toolbar.=$this->inputImage('download','download',lang('Download')); |
---|
[1506] | 1049 | // upload button |
---|
| 1050 | $toolbar.=$this->inputImage('upload','upload',lang('Upload')); |
---|
| 1051 | } |
---|
| 1052 | $toolbar.='</tr></table>'; |
---|
[1524] | 1053 | $toolbar.='</div><br><br>'; |
---|
[1506] | 1054 | break; |
---|
| 1055 | case 'list_nav': |
---|
| 1056 | $toolbar=' |
---|
[1524] | 1057 | <table cellspacing="10" cellpadding="0" border="0"> |
---|
[1506] | 1058 | <tr>'; |
---|
| 1059 | // selectbox for change/move/and copy to |
---|
| 1060 | // submit buttons for |
---|
| 1061 | if($this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 1062 | { |
---|
[1524] | 1063 | //$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; |
---|
| 1064 | //$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
[1506] | 1065 | |
---|
[1524] | 1066 | if(!$this->rename_x && !$this->edit_comments_x && $this->can_edit) |
---|
[1506] | 1067 | { |
---|
| 1068 | // edit text file button |
---|
| 1069 | $toolbar.=$this->inputImage('edit','edit',lang('edit')); |
---|
| 1070 | } |
---|
| 1071 | |
---|
[1524] | 1072 | if(!$this->edit_comments_x && $this->can_edit) |
---|
[1506] | 1073 | { |
---|
| 1074 | $toolbar.=$this->inputImage('rename','rename',lang('Rename')); |
---|
| 1075 | } |
---|
| 1076 | |
---|
[1524] | 1077 | if(!$this->rename_x && !$this->edit_comments_x && $this->can_delete) |
---|
[1506] | 1078 | { |
---|
| 1079 | $toolbar.=$this->inputImage('delete','delete',lang('Delete')); |
---|
| 1080 | } |
---|
| 1081 | |
---|
[1524] | 1082 | if(!$this->rename_x && $this->can_edit) |
---|
[1506] | 1083 | { |
---|
| 1084 | $toolbar.=$this->inputImage('edit_comments','edit_comments',lang('Edit comments')); |
---|
| 1085 | } |
---|
| 1086 | $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
| 1087 | } |
---|
| 1088 | |
---|
| 1089 | // $toolbar.='</tr></table>'; |
---|
| 1090 | if(!$this->rename_x && !$this->edit_comments_x) |
---|
| 1091 | { |
---|
| 1092 | // copy and move buttons |
---|
| 1093 | if($this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 1094 | { |
---|
[1524] | 1095 | //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; |
---|
| 1096 | //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
[1506] | 1097 | |
---|
| 1098 | $dirs_options=$this->all_other_directories_options(); |
---|
| 1099 | $toolbar3.='<td><select name="todir">'.$dirs_options.'</select></td>'; |
---|
| 1100 | |
---|
| 1101 | $toolbar3.=$this->inputImage('copy_to','copy_to',lang('Copy to')); |
---|
| 1102 | $toolbar3.=$this->inputImage('move_to','move_to',lang('Move to')); |
---|
| 1103 | |
---|
| 1104 | $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
| 1105 | |
---|
| 1106 | } |
---|
| 1107 | |
---|
| 1108 | // create dir and file button |
---|
| 1109 | if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) |
---|
| 1110 | { |
---|
[1524] | 1111 | //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; |
---|
| 1112 | //$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; |
---|
[1506] | 1113 | |
---|
| 1114 | $toolbar3.='<td><input type=text size="15" name="newfile_or_dir" value="" /></td>'; |
---|
| 1115 | $toolbar3.=$this->inputImage('newdir','createdir',lang('Create Folder')); |
---|
| 1116 | $toolbar3.=$this->inputImage('newfile','createfile',lang('Create File')); |
---|
| 1117 | } |
---|
| 1118 | |
---|
| 1119 | if($toolbar3) |
---|
| 1120 | { |
---|
| 1121 | $toolbar.=$toolbar3; |
---|
| 1122 | /* $toolbar.=' |
---|
| 1123 | <table cellspacing="1" cellpadding="0" border="0"> |
---|
| 1124 | <tr>'.$toolbar3;*/ |
---|
| 1125 | } |
---|
| 1126 | } |
---|
| 1127 | $toolbar.='</tr></table>'; |
---|
| 1128 | |
---|
| 1129 | break; |
---|
| 1130 | default:$x=''; |
---|
| 1131 | } |
---|
| 1132 | |
---|
| 1133 | if($toolbar) |
---|
| 1134 | { |
---|
| 1135 | return $toolbar; |
---|
| 1136 | } |
---|
| 1137 | } |
---|
| 1138 | |
---|
| 1139 | // move to bo |
---|
| 1140 | # Handle File Uploads |
---|
| 1141 | function fileUpload() |
---|
| 1142 | { |
---|
| 1143 | if($this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 1144 | { |
---|
| 1145 | for($i = 0; $i != $this->show_upload_boxes; $i++) |
---|
| 1146 | { |
---|
| 1147 | if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) |
---|
| 1148 | { |
---|
| 1149 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); |
---|
| 1150 | |
---|
| 1151 | continue; |
---|
| 1152 | } |
---|
| 1153 | |
---|
| 1154 | # Check to see if the file exists in the database, and get its info at the same time |
---|
| 1155 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 1156 | 'string'=> $this->path . '/' . $_FILES['upload_file']['name'][$i], |
---|
| 1157 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1158 | 'checksubdirs' => False, |
---|
| 1159 | 'nofiles' => True |
---|
| 1160 | )); |
---|
| 1161 | |
---|
| 1162 | $fileinfo = $ls_array[0]; |
---|
| 1163 | |
---|
| 1164 | if($fileinfo['name']) |
---|
| 1165 | { |
---|
| 1166 | if($fileinfo['mime_type'] == 'Directory') |
---|
| 1167 | { |
---|
| 1168 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); |
---|
| 1169 | continue; |
---|
| 1170 | } |
---|
| 1171 | } |
---|
| 1172 | |
---|
| 1173 | if($_FILES['upload_file']['size'][$i] > 0) |
---|
| 1174 | { |
---|
| 1175 | if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') |
---|
| 1176 | { |
---|
| 1177 | $tmp_arr=array( |
---|
| 1178 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 1179 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1180 | 'attributes' => array( |
---|
| 1181 | 'owner_id' => $this->bo->userinfo['username'], |
---|
| 1182 | 'modifiedby_id' => $this->bo->userinfo['username'], |
---|
| 1183 | 'modified' => $this->now, |
---|
| 1184 | 'size' => $_FILES['upload_file']['size'][$i], |
---|
| 1185 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 1186 | 'deleteable' => 'Y', |
---|
| 1187 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 1188 | ) |
---|
| 1189 | ); |
---|
| 1190 | $this->bo->vfs->set_attributes($tmp_arr); |
---|
| 1191 | |
---|
| 1192 | $tmp_arr=array( |
---|
| 1193 | 'from' => $_FILES['upload_file']['tmp_name'][$i], |
---|
| 1194 | 'to' => $_FILES['upload_file']['name'][$i], |
---|
| 1195 | 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
| 1196 | ); |
---|
| 1197 | $this->bo->vfs->cp($tmp_arr); |
---|
| 1198 | |
---|
| 1199 | $this->messages[]=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); |
---|
| 1200 | } |
---|
| 1201 | else |
---|
| 1202 | { |
---|
| 1203 | |
---|
| 1204 | $this->bo->vfs->cp(array( |
---|
| 1205 | 'from'=> $_FILES['upload_file']['tmp_name'][$i], |
---|
| 1206 | 'to'=> $_FILES['upload_file']['name'][$i], |
---|
| 1207 | 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
| 1208 | )); |
---|
| 1209 | |
---|
| 1210 | $this->bo->vfs->set_attributes(array( |
---|
| 1211 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 1212 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1213 | 'attributes'=> array( |
---|
| 1214 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 1215 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 1216 | ) |
---|
| 1217 | )); |
---|
| 1218 | |
---|
| 1219 | $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]); |
---|
| 1220 | } |
---|
| 1221 | } |
---|
| 1222 | elseif($_FILES['upload_file']['name'][$i]) |
---|
| 1223 | { |
---|
| 1224 | $this->bo->vfs->touch(array( |
---|
| 1225 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 1226 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1227 | )); |
---|
| 1228 | |
---|
| 1229 | $this->bo->vfs->set_attributes(array( |
---|
| 1230 | 'string'=> $_FILES['upload_file']['name'][$i], |
---|
| 1231 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1232 | 'attributes'=> array( |
---|
| 1233 | 'mime_type' => $_FILES['upload_file']['type'][$i], |
---|
| 1234 | 'comment' => stripslashes($_POST['upload_comment'][$i]) |
---|
| 1235 | ) |
---|
| 1236 | )); |
---|
| 1237 | |
---|
| 1238 | $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]); |
---|
| 1239 | } |
---|
| 1240 | } |
---|
| 1241 | |
---|
| 1242 | $this->readFilesInfo(); |
---|
| 1243 | $this->filelisting(); |
---|
| 1244 | } |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | # Handle Editing comments |
---|
| 1248 | function editComment() |
---|
| 1249 | { |
---|
| 1250 | while(list($file) = each($this->comment_files)) |
---|
| 1251 | { |
---|
| 1252 | if($badchar = $this->bo->bad_chars($this->comment_files[$file], False, True)) |
---|
| 1253 | { |
---|
| 1254 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1))); |
---|
| 1255 | continue; |
---|
| 1256 | } |
---|
| 1257 | |
---|
| 1258 | $this->bo->vfs->set_attributes(array( |
---|
| 1259 | 'string' => $file, |
---|
| 1260 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1261 | 'attributes' => array( |
---|
| 1262 | 'comment' => stripslashes($this->comment_files[$file]) |
---|
| 1263 | ) |
---|
| 1264 | )); |
---|
| 1265 | |
---|
| 1266 | $this->messages[]=lang('Updated comment for %1', $this->path.'/'.$file); |
---|
| 1267 | } |
---|
| 1268 | |
---|
| 1269 | $this->readFilesInfo(); |
---|
| 1270 | $this->filelisting(); |
---|
| 1271 | } |
---|
| 1272 | |
---|
| 1273 | # Handle Renaming Files and Directories |
---|
| 1274 | function rename() |
---|
| 1275 | { |
---|
| 1276 | while(list($from, $to) = each($this->renamefiles)) |
---|
| 1277 | { |
---|
| 1278 | if($badchar = $this->bo->bad_chars($to, True, True)) |
---|
| 1279 | { |
---|
| 1280 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); |
---|
| 1281 | continue; |
---|
| 1282 | } |
---|
| 1283 | |
---|
| 1284 | if(ereg("/", $to) || ereg("\\\\", $to)) |
---|
| 1285 | { |
---|
| 1286 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /"))); |
---|
| 1287 | } |
---|
| 1288 | elseif(!$this->bo->vfs->mv(array( |
---|
| 1289 | 'from' => $from, |
---|
| 1290 | 'to' => $to |
---|
| 1291 | ))) |
---|
| 1292 | { |
---|
| 1293 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); |
---|
| 1294 | } |
---|
| 1295 | else |
---|
| 1296 | { |
---|
| 1297 | $this->messages[]=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); |
---|
| 1298 | } |
---|
| 1299 | } |
---|
| 1300 | $this->readFilesInfo(); |
---|
| 1301 | $this->filelisting(); |
---|
| 1302 | } |
---|
| 1303 | |
---|
| 1304 | # Handle Moving Files and Directories |
---|
| 1305 | function moveTo() |
---|
| 1306 | { |
---|
| 1307 | if(!$this->todir) |
---|
| 1308 | { |
---|
| 1309 | $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move file because no destination directory is given ', $this->disppath.'/'.$file))); |
---|
| 1310 | |
---|
| 1311 | } |
---|
| 1312 | else |
---|
| 1313 | { |
---|
| 1314 | |
---|
| 1315 | while(list($num, $file) = each($this->fileman)) |
---|
| 1316 | { |
---|
| 1317 | if($this->bo->vfs->mv(array( |
---|
| 1318 | 'from' => $file, |
---|
| 1319 | 'to' => $this->todir . '/' . $file, |
---|
| 1320 | 'relatives' => array(RELATIVE_ALL, RELATIVE_NONE) |
---|
| 1321 | ))) |
---|
| 1322 | { |
---|
| 1323 | $moved++; |
---|
| 1324 | $this->messages[]=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); |
---|
| 1325 | } |
---|
| 1326 | else |
---|
| 1327 | { |
---|
| 1328 | $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); |
---|
| 1329 | } |
---|
| 1330 | } |
---|
| 1331 | } |
---|
| 1332 | |
---|
| 1333 | if($moved) |
---|
| 1334 | { |
---|
| 1335 | $x=0; |
---|
| 1336 | } |
---|
| 1337 | |
---|
| 1338 | $this->readFilesInfo(); |
---|
| 1339 | $this->filelisting(); |
---|
| 1340 | } |
---|
| 1341 | |
---|
| 1342 | // Handle Copying of Files and Directories |
---|
| 1343 | function copyTo() |
---|
| 1344 | { |
---|
| 1345 | if(!$this->todir) |
---|
| 1346 | { |
---|
| 1347 | $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not copy file because no destination directory is given ', $this->disppath.'/'.$file))); |
---|
| 1348 | |
---|
| 1349 | } |
---|
| 1350 | else |
---|
| 1351 | { |
---|
| 1352 | while(list($num, $file) = each($this->fileman)) |
---|
| 1353 | { |
---|
| 1354 | if($this->bo->vfs->cp(array( |
---|
| 1355 | 'from' => $file, |
---|
| 1356 | 'to' => $this->todir . '/' . $file, |
---|
| 1357 | 'relatives' => array(RELATIVE_ALL, RELATIVE_NONE) |
---|
| 1358 | ))) |
---|
| 1359 | { |
---|
| 1360 | $copied++; |
---|
| 1361 | $this->message .= lang('Copied %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); |
---|
| 1362 | } |
---|
| 1363 | else |
---|
| 1364 | { |
---|
| 1365 | $this->message .= $GLOBALS['phpgw']->common->error_list(array(lang('Could not copy %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); |
---|
| 1366 | } |
---|
| 1367 | } |
---|
| 1368 | } |
---|
| 1369 | if($copied) |
---|
| 1370 | { |
---|
| 1371 | $x=0; |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | $this->readFilesInfo(); |
---|
| 1375 | $this->filelisting(); |
---|
| 1376 | } |
---|
| 1377 | |
---|
| 1378 | function createdir() |
---|
| 1379 | { |
---|
| 1380 | if($this->newdir_x && $this->newfile_or_dir) |
---|
| 1381 | { |
---|
| 1382 | if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) |
---|
| 1383 | { |
---|
| 1384 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1))); |
---|
| 1385 | } |
---|
| 1386 | |
---|
| 1387 | /* TODO is this right or should it be a single $ ? */ |
---|
| 1388 | if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') |
---|
| 1389 | { |
---|
| 1390 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space'))); |
---|
| 1391 | } |
---|
| 1392 | |
---|
| 1393 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 1394 | 'string' => $this->path . '/' . $this->newfile_or_dir, |
---|
| 1395 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1396 | 'checksubdirs' => False, |
---|
| 1397 | 'nofiles' => True |
---|
| 1398 | )); |
---|
| 1399 | |
---|
| 1400 | $fileinfo = $ls_array[0]; |
---|
| 1401 | |
---|
| 1402 | if($fileinfo['name']) |
---|
| 1403 | { |
---|
| 1404 | if($fileinfo['mime_type'] != 'Directory') |
---|
| 1405 | { |
---|
| 1406 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array( |
---|
| 1407 | lang('%1 already exists as a file', |
---|
| 1408 | $fileinfo['name']) |
---|
| 1409 | )); |
---|
| 1410 | } |
---|
| 1411 | else |
---|
| 1412 | { |
---|
| 1413 | $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name']))); |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | else |
---|
| 1417 | { |
---|
| 1418 | if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir))) |
---|
| 1419 | { |
---|
| 1420 | $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); |
---|
| 1421 | } |
---|
| 1422 | else |
---|
| 1423 | { |
---|
| 1424 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); |
---|
| 1425 | } |
---|
| 1426 | } |
---|
| 1427 | |
---|
| 1428 | $this->readFilesInfo(); |
---|
| 1429 | $this->filelisting(); |
---|
| 1430 | } |
---|
| 1431 | } |
---|
| 1432 | |
---|
| 1433 | function delete() |
---|
| 1434 | { |
---|
| 1435 | if( is_array($this->fileman) && count($this->fileman) >= 1) |
---|
| 1436 | { |
---|
| 1437 | foreach($this->fileman as $filename) |
---|
| 1438 | { |
---|
| 1439 | if($this->bo->vfs->delete(array('string' => $filename))) |
---|
| 1440 | { |
---|
| 1441 | $this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>'; |
---|
| 1442 | } |
---|
| 1443 | else |
---|
| 1444 | { |
---|
| 1445 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename))); |
---|
| 1446 | } |
---|
| 1447 | } |
---|
| 1448 | } |
---|
| 1449 | else |
---|
| 1450 | { |
---|
| 1451 | // make this a javascript func for quicker respons |
---|
| 1452 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.'))); |
---|
| 1453 | } |
---|
| 1454 | $this->readFilesInfo(); |
---|
| 1455 | $this->filelisting(); |
---|
| 1456 | } |
---|
| 1457 | |
---|
| 1458 | function debug_filemanager() |
---|
| 1459 | { |
---|
| 1460 | error_reporting(8); |
---|
| 1461 | |
---|
| 1462 | echo "<b>Filemanager debug:</b><br> |
---|
| 1463 | path: {$this->path}<br> |
---|
| 1464 | disppath: {$this->disppath}<br> |
---|
| 1465 | cwd: {$this->cwd}<br> |
---|
| 1466 | lesspath: {$this->lesspath} |
---|
| 1467 | <p> |
---|
| 1468 | <b>eGroupware debug:</b><br> |
---|
| 1469 | real getabsolutepath: " . $this->bo->vfs->getabsolutepath(array('target' => False, 'mask' => False, 'fake' => False)) . "<br> |
---|
| 1470 | fake getabsolutepath: " . $this->bo->vfs->getabsolutepath(array('target' => False)) . "<br> |
---|
| 1471 | appsession: " . $GLOBALS['phpgw']->session->appsession('vfs','') . "<br> |
---|
| 1472 | pwd: " . $this->bo->vfs->pwd() . "<br>"; |
---|
| 1473 | |
---|
| 1474 | echo '<p></p>'; |
---|
| 1475 | var_dump($this); |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | function showUploadboxes() |
---|
| 1479 | { |
---|
| 1480 | $this->t->set_file(array('upload' => 'upload.tpl')); |
---|
| 1481 | $this->t->set_block('upload','upload_header','upload_header'); |
---|
| 1482 | $this->t->set_block('upload','row','row'); |
---|
| 1483 | $this->t->set_block('upload','upload_footer','upload_footer'); |
---|
| 1484 | |
---|
| 1485 | # Decide how many upload boxes to show |
---|
| 1486 | if(!$this->show_upload_boxes || $this->show_upload_boxes <= 0) |
---|
| 1487 | { |
---|
| 1488 | if(!$this->show_upload_boxes = $this->prefs['show_upload_boxes']) |
---|
| 1489 | { |
---|
| 1490 | $this->show_upload_boxes = 1; |
---|
| 1491 | } |
---|
| 1492 | } |
---|
| 1493 | |
---|
| 1494 | # Show file upload boxes. Note the last argument to html(). Repeats $this->show_upload_boxes times |
---|
| 1495 | if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) |
---|
| 1496 | { |
---|
| 1497 | $vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); |
---|
| 1498 | $vars[path]=$this->path; |
---|
| 1499 | $vars[lang_file]=lang('File'); |
---|
| 1500 | $vars[lang_comment]=lang('Comment'); |
---|
| 1501 | $vars[num_upload_boxes]=$this->show_upload_boxes; |
---|
| 1502 | $this->t->set_var($vars); |
---|
| 1503 | $this->t->pparse('out','upload_header'); |
---|
| 1504 | |
---|
| 1505 | for($i=0;$i<$this->show_upload_boxes;$i++) |
---|
| 1506 | { |
---|
| 1507 | $this->t->set_var('row_tr_color',$tr_color); |
---|
| 1508 | $this->t->parse('rows','row'); |
---|
| 1509 | $this->t->pparse('out','row'); |
---|
| 1510 | } |
---|
| 1511 | |
---|
| 1512 | $vars[lang_upload]=lang('Upload files'); |
---|
| 1513 | $vars[change_upload_boxes].=lang('Show') . ' '; |
---|
| 1514 | $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=5', '5'); |
---|
| 1515 | $links.=' '; |
---|
| 1516 | $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=10', '10'); |
---|
| 1517 | $links.=' '; |
---|
| 1518 | $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=20', '20'); |
---|
| 1519 | $links.=' '; |
---|
| 1520 | $links.= $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=50', '50'); |
---|
| 1521 | $links.=' '; |
---|
| 1522 | $links.= lang('upload fields'); |
---|
| 1523 | $vars[change_upload_boxes].=$links; |
---|
| 1524 | $this->t->set_var($vars); |
---|
| 1525 | $this->t->pparse('out','upload_footer'); |
---|
| 1526 | } |
---|
| 1527 | } |
---|
| 1528 | |
---|
| 1529 | /* create textfile */ |
---|
| 1530 | function createfile() |
---|
| 1531 | { |
---|
| 1532 | $this->createfile_var=$this->newfile_or_dir; |
---|
| 1533 | if($this->createfile_var) |
---|
| 1534 | { |
---|
| 1535 | if($badchar = $this->bo->bad_chars($this->createfile_var, True, True)) |
---|
| 1536 | { |
---|
| 1537 | $this->messages[] = $GLOBALS['phpgw']->common->error_list(array( |
---|
| 1538 | lang('File names cannot contain "%1"',$badchar), |
---|
| 1539 | 1) |
---|
| 1540 | ); |
---|
| 1541 | |
---|
| 1542 | $this->fileListing(); |
---|
| 1543 | } |
---|
| 1544 | |
---|
| 1545 | if($this->bo->vfs->file_exists(array( |
---|
| 1546 | 'string'=> $this->createfile_var, |
---|
| 1547 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1548 | ))) |
---|
| 1549 | { |
---|
| 1550 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var))); |
---|
| 1551 | $this->fileListing(); |
---|
| 1552 | } |
---|
| 1553 | |
---|
| 1554 | if($this->bo->vfs->touch(array( |
---|
| 1555 | 'string' => $this->createfile_var, |
---|
| 1556 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1557 | ))) |
---|
| 1558 | { |
---|
| 1559 | $this->fileman = array(); |
---|
| 1560 | $this->fileman[0] = $this->createfile_var; |
---|
| 1561 | $this->edit = 1; |
---|
| 1562 | $this->numoffiles++; |
---|
| 1563 | $this->edit(); |
---|
| 1564 | } |
---|
| 1565 | else |
---|
| 1566 | { |
---|
| 1567 | $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile_var))); |
---|
| 1568 | $this->fileListing(); |
---|
| 1569 | } |
---|
| 1570 | } |
---|
| 1571 | } |
---|
| 1572 | |
---|
| 1573 | # Handle Editing files |
---|
| 1574 | function edit() |
---|
| 1575 | { |
---|
| 1576 | $this->readFilesInfo(); |
---|
| 1577 | |
---|
| 1578 | $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); |
---|
| 1579 | $this->t->set_block('filemanager_edit','row','row'); |
---|
| 1580 | |
---|
| 1581 | $vars[preview_content]=''; |
---|
| 1582 | if($this->edit_file) |
---|
| 1583 | { |
---|
| 1584 | $this->edit_file_content = stripslashes($this->edit_file_content); |
---|
| 1585 | } |
---|
| 1586 | |
---|
| 1587 | if($this->edit_preview_x) |
---|
| 1588 | { |
---|
| 1589 | $content = $this->edit_file_content; |
---|
| 1590 | |
---|
| 1591 | $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); |
---|
| 1592 | |
---|
| 1593 | $vars[preview_content]=nl2br($content); |
---|
| 1594 | } |
---|
| 1595 | elseif($this->edit_save_x || $this->edit_save_done_x) |
---|
| 1596 | { |
---|
| 1597 | $content = $this->edit_file_content; |
---|
| 1598 | //die( $content); |
---|
| 1599 | if($this->bo->vfs->write(array( |
---|
| 1600 | 'string' => $this->edit_file, |
---|
| 1601 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1602 | 'content' => $content |
---|
| 1603 | ))) |
---|
| 1604 | { |
---|
| 1605 | $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); |
---|
| 1606 | |
---|
| 1607 | if($this->edit_save_done_x) |
---|
| 1608 | { |
---|
| 1609 | $this->readFilesInfo(); |
---|
| 1610 | $this->fileListing(); |
---|
| 1611 | exit; |
---|
| 1612 | } |
---|
| 1613 | } |
---|
| 1614 | else |
---|
| 1615 | { |
---|
| 1616 | $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); |
---|
| 1617 | } |
---|
| 1618 | } |
---|
| 1619 | |
---|
| 1620 | # Now we display the edit boxes and forms |
---|
| 1621 | for($j = 0; $j != $this->numoffiles; $j++) |
---|
| 1622 | { |
---|
| 1623 | # If we're in preview or save mode, we only show the file |
---|
| 1624 | # being previewed or saved |
---|
| 1625 | if($this->edit_file &&($this->fileman[$j] != $this->edit_file)) |
---|
| 1626 | { |
---|
| 1627 | continue; |
---|
| 1628 | } |
---|
| 1629 | |
---|
| 1630 | if($this->fileman[$j] && $this->bo->vfs->file_exists(array( |
---|
| 1631 | 'string' => $this->fileman[$j], |
---|
| 1632 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1633 | ))) |
---|
| 1634 | { |
---|
| 1635 | if($this->edit_file) |
---|
| 1636 | { |
---|
| 1637 | $content = stripslashes($this->edit_file_content); |
---|
| 1638 | } |
---|
| 1639 | else |
---|
| 1640 | { |
---|
| 1641 | $content = $this->bo->vfs->read(array('string' => $this->fileman[$j])); |
---|
| 1642 | } |
---|
| 1643 | |
---|
| 1644 | $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); |
---|
| 1645 | $vars[edit_file]=$this->fileman[$j]; |
---|
| 1646 | |
---|
| 1647 | # We need to include all of the fileman entries for each file's form, |
---|
| 1648 | # so we loop through again |
---|
| 1649 | for($i = 0; $i != $this->numoffiles; $i++) |
---|
| 1650 | { |
---|
| 1651 | if($this->fileman[$i]) $value='value="'.$this->fileman[$i].'"'; |
---|
| 1652 | $vars[filemans_hidden]='<input type="hidden" name="fileman['.$i.']" '.$value.' />'; |
---|
| 1653 | } |
---|
| 1654 | |
---|
| 1655 | $vars[file_content]=$content; |
---|
| 1656 | |
---|
| 1657 | $vars[buttonPreview]=$this->inputImage('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[$j], 1))); |
---|
| 1658 | $vars[buttonSave]=$this->inputImage('edit_save','save',lang('Save %1', $this->bo->html_encode($this->fileman[$j], 1))); |
---|
| 1659 | $vars[buttonDone]=$this->inputImage('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->fileman[$j], 1))); |
---|
| 1660 | $vars[buttonCancel]=$this->inputImage('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->fileman[$j], 1))); |
---|
| 1661 | $this->t->set_var($vars); |
---|
| 1662 | $this->t->parse('rows','row'); |
---|
| 1663 | $this->t->pparse('out','row'); |
---|
| 1664 | |
---|
| 1665 | } |
---|
| 1666 | } |
---|
| 1667 | } |
---|
| 1668 | |
---|
| 1669 | function history() |
---|
| 1670 | { |
---|
| 1671 | if($this->file) // FIXME this-file is never defined |
---|
| 1672 | { |
---|
| 1673 | $journal_array = $this->bo->vfs->get_journal(array( |
---|
| 1674 | 'string' => $this->file,//FIXME |
---|
| 1675 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1676 | )); |
---|
| 1677 | |
---|
| 1678 | if(is_array($journal_array)) |
---|
| 1679 | { |
---|
| 1680 | $this->html_table_begin(); |
---|
| 1681 | $this->html_table_row_begin(); |
---|
| 1682 | $this->html_table_col_begin(); |
---|
| 1683 | echo lang('Date'); |
---|
| 1684 | $this->html_table_col_end(); |
---|
| 1685 | $this->html_table_col_begin(); |
---|
| 1686 | echo lang('Version'); |
---|
| 1687 | $this->html_table_col_end(); |
---|
| 1688 | $this->html_table_col_begin(); |
---|
| 1689 | echo lang('Who'); |
---|
| 1690 | $this->html_table_col_end(); |
---|
| 1691 | $this->html_table_col_begin(); |
---|
| 1692 | echo lang('Operation'); |
---|
| 1693 | $this->html_table_col_end(); |
---|
| 1694 | $this->html_table_row_end(); |
---|
| 1695 | |
---|
| 1696 | while(list($num, $journal_entry) = each($journal_array)) |
---|
| 1697 | { |
---|
| 1698 | $this->html_table_row_begin(); |
---|
| 1699 | $this->html_table_col_begin(); |
---|
| 1700 | $this->bo->html_text($journal_entry['created'] . ' '); |
---|
| 1701 | $this->html_table_col_end(); |
---|
| 1702 | $this->html_table_col_begin(); |
---|
| 1703 | $this->bo->html_text($journal_entry['version'] . ' ' ); |
---|
| 1704 | $this->html_table_col_end(); |
---|
| 1705 | $this->html_table_col_begin(); |
---|
| 1706 | $this->bo->html_text($GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']) . ' '); |
---|
| 1707 | $this->html_table_col_end(); |
---|
| 1708 | $this->html_table_col_begin(); |
---|
| 1709 | $this->bo->html_text($journal_entry['comment']); |
---|
| 1710 | $this->html_table_col_end(); |
---|
| 1711 | } |
---|
| 1712 | |
---|
| 1713 | $this->html_table_end(); |
---|
| 1714 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 1715 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1716 | } |
---|
| 1717 | else |
---|
| 1718 | { |
---|
| 1719 | echo lang('No version history for this file/directory'); |
---|
| 1720 | } |
---|
| 1721 | } |
---|
| 1722 | } |
---|
| 1723 | |
---|
| 1724 | function view() |
---|
| 1725 | { |
---|
| 1726 | if($this->file) //FIXME |
---|
| 1727 | { |
---|
| 1728 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 1729 | 'string' => $this->path.'/'.$this->file,//FIXME |
---|
| 1730 | 'relatives' => array(RELATIVE_ALL), |
---|
| 1731 | 'checksubdirs' => False, |
---|
| 1732 | 'nofiles' => True |
---|
| 1733 | )); |
---|
| 1734 | |
---|
| 1735 | if($ls_array[0]['mime_type']) |
---|
| 1736 | { |
---|
| 1737 | $mime_type = $ls_array[0]['mime_type']; |
---|
| 1738 | } |
---|
| 1739 | elseif($this->prefs['viewtextplain']) |
---|
| 1740 | { |
---|
| 1741 | $mime_type = 'text/plain'; |
---|
| 1742 | } |
---|
| 1743 | $viewable = array('','text/plain','text/csv','text/html','text/text'); |
---|
| 1744 | |
---|
| 1745 | if(in_array($mime_type,$viewable) && !$_GET['download']) |
---|
| 1746 | { |
---|
| 1747 | |
---|
| 1748 | header('Content-type: ' . $mime_type); |
---|
| 1749 | header('Content-disposition: filename="' . $this->file . '"');//FIXME |
---|
| 1750 | Header("Pragma: public"); |
---|
| 1751 | } |
---|
| 1752 | else |
---|
| 1753 | { |
---|
| 1754 | $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME |
---|
| 1755 | } |
---|
| 1756 | echo $this->bo->vfs->read(array( |
---|
| 1757 | 'string' => $this->path.'/'.$this->file,//FIXME |
---|
| 1758 | 'relatives' => array(RELATIVE_NONE) |
---|
| 1759 | )); |
---|
| 1760 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1761 | } |
---|
| 1762 | } |
---|
| 1763 | |
---|
| 1764 | function download() |
---|
| 1765 | { |
---|
| 1766 | for($i = 0; $i != $this->numoffiles; $i++) |
---|
| 1767 | { |
---|
| 1768 | if(!$this->fileman[$i]) |
---|
| 1769 | { |
---|
| 1770 | continue; |
---|
| 1771 | } |
---|
| 1772 | |
---|
| 1773 | $download_browser = CreateObject('phpgwapi.browser'); |
---|
| 1774 | $download_browser->content_header($this->fileman[$i]); |
---|
| 1775 | echo $this->bo->vfs->read(array('string' => $this->fileman[$i])); |
---|
| 1776 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1777 | } |
---|
| 1778 | } |
---|
| 1779 | |
---|
| 1780 | //give back an array with all directories except current and dirs that are not accessable |
---|
| 1781 | function all_other_directories_options() |
---|
| 1782 | { |
---|
| 1783 | # First we get the directories in their home directory |
---|
| 1784 | $dirs = array(); |
---|
| 1785 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); |
---|
| 1786 | |
---|
| 1787 | $tmp_arr=array( |
---|
| 1788 | 'string' => $this->bo->homedir, |
---|
| 1789 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1790 | 'checksubdirs' => True, |
---|
| 1791 | 'mime_type' => 'Directory' |
---|
| 1792 | ); |
---|
| 1793 | |
---|
| 1794 | $ls_array = $this->bo->vfs->ls($tmp_arr); |
---|
| 1795 | |
---|
| 1796 | while(list($num, $dir) = each($ls_array)) |
---|
| 1797 | { |
---|
| 1798 | $dirs[] = $dir; |
---|
| 1799 | } |
---|
| 1800 | |
---|
| 1801 | |
---|
| 1802 | # Then we get the directories in their readable groups' home directories |
---|
| 1803 | reset($this->readable_groups); |
---|
| 1804 | while(list($num, $group_array) = each($this->readable_groups)) |
---|
| 1805 | { |
---|
[1524] | 1806 | /* Don't list directories for groups that don't have access |
---|
[1506] | 1807 | if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) |
---|
| 1808 | { |
---|
[1524] | 1809 | ] continue; |
---|
| 1810 | }*/ |
---|
[1506] | 1811 | |
---|
| 1812 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); |
---|
| 1813 | |
---|
| 1814 | $tmp_arr=array( |
---|
| 1815 | 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], |
---|
| 1816 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1817 | 'checksubdirs' => True, |
---|
| 1818 | 'mime_type' => 'Directory' |
---|
| 1819 | ); |
---|
| 1820 | |
---|
| 1821 | $ls_array = $this->bo->vfs->ls($tmp_arr); |
---|
| 1822 | while(list($num, $dir) = each($ls_array)) |
---|
| 1823 | { |
---|
| 1824 | $dirs[] = $dir; |
---|
| 1825 | } |
---|
| 1826 | } |
---|
| 1827 | |
---|
| 1828 | reset($dirs); |
---|
| 1829 | while(list($num, $dir) = each($dirs)) |
---|
| 1830 | { |
---|
| 1831 | if(!$dir['directory']) |
---|
| 1832 | { |
---|
| 1833 | continue; |
---|
| 1834 | } |
---|
| 1835 | |
---|
| 1836 | # So we don't display // |
---|
| 1837 | if($dir['directory'] != '/') |
---|
| 1838 | { |
---|
| 1839 | $dir['directory'] .= '/'; |
---|
| 1840 | } |
---|
| 1841 | |
---|
| 1842 | # No point in displaying the current directory, or a directory that doesn't exist |
---|
| 1843 | if((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists(array('string' => $dir['directory'] . $dir['name'],'relatives' => array(RELATIVE_NONE)))) |
---|
| 1844 | { |
---|
| 1845 | //FIXME replace the html_form_option function |
---|
| 1846 | $options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); |
---|
| 1847 | } |
---|
| 1848 | } |
---|
| 1849 | |
---|
| 1850 | return $options; |
---|
| 1851 | } |
---|
| 1852 | |
---|
| 1853 | /* seek icon for mimetype else return an unknown icon */ |
---|
| 1854 | function mime_icon($mime_type, $size=16) |
---|
| 1855 | { |
---|
| 1856 | if(!$mime_type) $mime_type='unknown'; |
---|
| 1857 | |
---|
| 1858 | $mime_type= str_replace ('/','_',$mime_type); |
---|
| 1859 | |
---|
| 1860 | $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); |
---|
| 1861 | if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); |
---|
| 1862 | |
---|
| 1863 | $icon='<img src="'.$img.' "alt="'.lang($mime_type).'" />'; |
---|
| 1864 | return $icon; |
---|
| 1865 | } |
---|
| 1866 | |
---|
[1524] | 1867 | function buttonImage($link,$img='',$description='') |
---|
[1506] | 1868 | { |
---|
| 1869 | $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); |
---|
| 1870 | |
---|
| 1871 | if($img) |
---|
| 1872 | { |
---|
[1524] | 1873 | return '<td class="" align="center" valign="middle" height="28" width="70"> |
---|
| 1874 | <a href="'.$link.'" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/></a><br><small>'.$description.'</small> |
---|
[1506] | 1875 | </td>'; |
---|
| 1876 | } |
---|
| 1877 | } |
---|
| 1878 | |
---|
[1524] | 1879 | function inputImage($name,$img='',$description='') |
---|
[1506] | 1880 | { |
---|
| 1881 | $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); |
---|
| 1882 | |
---|
| 1883 | if($img) |
---|
| 1884 | { |
---|
[1524] | 1885 | return '<td class="" align="center" valign="middle" height="28" width="70"> |
---|
| 1886 | <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small> |
---|
[1506] | 1887 | </td>'; |
---|
| 1888 | } |
---|
| 1889 | } |
---|
| 1890 | |
---|
| 1891 | function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) |
---|
| 1892 | { |
---|
| 1893 | $text = ' '; |
---|
| 1894 | if($type != NULL && $type) |
---|
| 1895 | { |
---|
| 1896 | if($type == 'checkbox') |
---|
| 1897 | { |
---|
| 1898 | $value = $this->bo->string_encode($value, 1); |
---|
| 1899 | } |
---|
| 1900 | $text .= 'type="'.$type.'" '; |
---|
| 1901 | } |
---|
| 1902 | if($name != NULL && $name) |
---|
| 1903 | { |
---|
| 1904 | $text .= 'name="'.$name.'" '; |
---|
| 1905 | } |
---|
| 1906 | if($value != NULL && $value) |
---|
| 1907 | { |
---|
| 1908 | $text .= 'value="'.$value.'" '; |
---|
| 1909 | } |
---|
| 1910 | if(is_int($maxlength) && $maxlength >= 0) |
---|
| 1911 | { |
---|
| 1912 | $text .= 'maxlength="'.$maxlength.'" '; |
---|
| 1913 | } |
---|
| 1914 | if(is_int($size) && $size >= 0) |
---|
| 1915 | { |
---|
| 1916 | $text .= 'size="'.$size.'" '; |
---|
| 1917 | } |
---|
| 1918 | if($checked != NULL && $checked) |
---|
| 1919 | { |
---|
| 1920 | $text .= 'checked '; |
---|
| 1921 | } |
---|
| 1922 | |
---|
| 1923 | return '<input'.$text.$string.'>'; |
---|
| 1924 | } |
---|
| 1925 | |
---|
| 1926 | function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) |
---|
| 1927 | { |
---|
| 1928 | $text = ' '; |
---|
| 1929 | if($value != NULL && $value) |
---|
| 1930 | { |
---|
| 1931 | $text .= ' value="'.$value.'" '; |
---|
| 1932 | } |
---|
| 1933 | if($selected != NULL && $selected) |
---|
| 1934 | { |
---|
| 1935 | $text .= ' selected'; |
---|
| 1936 | } |
---|
| 1937 | return '<option'.$text.'>'.$displayed.'</option>'; |
---|
| 1938 | } |
---|
| 1939 | |
---|
| 1940 | function encode_href($href = NULL, $args = NULL , $extra_args) |
---|
| 1941 | { |
---|
| 1942 | $href = $this->bo->string_encode($href, 1); |
---|
| 1943 | $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); |
---|
| 1944 | |
---|
| 1945 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
| 1946 | |
---|
| 1947 | return $address; |
---|
| 1948 | } |
---|
| 1949 | |
---|
| 1950 | function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) |
---|
| 1951 | { |
---|
| 1952 | // unset($encode); |
---|
| 1953 | if($encode) |
---|
| 1954 | { |
---|
| 1955 | $href = $this->bo->string_encode($href, 1); |
---|
| 1956 | $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); |
---|
| 1957 | } |
---|
| 1958 | else |
---|
| 1959 | { |
---|
| 1960 | // $href = $this->bo->string_encode($href, 1); |
---|
| 1961 | $all_args = $args.'&'.$extra_args; |
---|
| 1962 | } |
---|
| 1963 | ### |
---|
| 1964 | # This decodes / back to normal |
---|
| 1965 | ### |
---|
| 1966 | // $all_args = preg_replace("/%2F/", "/", $all_args); |
---|
| 1967 | // $href = preg_replace("/%2F/", "/", $href); |
---|
| 1968 | |
---|
| 1969 | /* Auto-detect and don't disturb absolute links */ |
---|
| 1970 | if(!preg_match("|^http(.{0,1})://|", $href)) |
---|
| 1971 | { |
---|
| 1972 | //Only add an extra / if there isn't already one there |
---|
| 1973 | |
---|
| 1974 | // die(SEP); |
---|
| 1975 | if(!($href[0] == SEP)) |
---|
| 1976 | { |
---|
| 1977 | $href = SEP . $href; |
---|
| 1978 | } |
---|
| 1979 | |
---|
| 1980 | /* $phpgw->link requires that the extra vars be passed separately */ |
---|
| 1981 | // $link_parts = explode("?", $href); |
---|
| 1982 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
| 1983 | // $address = $GLOBALS['phpgw']->link($href); |
---|
| 1984 | } |
---|
| 1985 | else |
---|
| 1986 | { |
---|
| 1987 | $address = $href; |
---|
| 1988 | } |
---|
| 1989 | |
---|
| 1990 | /* If $linkonly is set, don't add any HTML */ |
---|
| 1991 | if($linkonly) |
---|
| 1992 | { |
---|
| 1993 | $rstring = $address; |
---|
| 1994 | } |
---|
| 1995 | else |
---|
| 1996 | { |
---|
| 1997 | if($target) |
---|
| 1998 | { |
---|
| 1999 | $target = 'target='.$target; |
---|
| 2000 | } |
---|
| 2001 | |
---|
| 2002 | $text = trim($text); |
---|
| 2003 | $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>'; |
---|
| 2004 | } |
---|
| 2005 | |
---|
| 2006 | return($this->bo->eor($rstring, $return)); |
---|
| 2007 | } |
---|
| 2008 | |
---|
| 2009 | function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) |
---|
| 2010 | { |
---|
| 2011 | if($width != NULL && $width) |
---|
| 2012 | { |
---|
| 2013 | $width = "width=$width"; |
---|
| 2014 | } |
---|
| 2015 | if(is_int($border) && $border >= 0) |
---|
| 2016 | { |
---|
| 2017 | $border = "border=$border"; |
---|
| 2018 | } |
---|
| 2019 | if(is_int($cellspacing) && $cellspacing >= 0) |
---|
| 2020 | { |
---|
| 2021 | $cellspacing = "cellspacing=$cellspacing"; |
---|
| 2022 | } |
---|
| 2023 | if(is_int($cellpadding) && $cellpadding >= 0) |
---|
| 2024 | { |
---|
| 2025 | $cellpadding = "cellpadding=$cellpadding"; |
---|
| 2026 | } |
---|
| 2027 | if($rules != NULL && $rules) |
---|
| 2028 | { |
---|
| 2029 | $rules = "rules=$rules"; |
---|
| 2030 | } |
---|
| 2031 | |
---|
| 2032 | $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>"; |
---|
| 2033 | return($this->bo->eor($rstring, $return)); |
---|
| 2034 | } |
---|
| 2035 | |
---|
| 2036 | function html_table_end($return = 0) |
---|
| 2037 | { |
---|
| 2038 | $rstring = "</table>"; |
---|
| 2039 | return($this->bo->eor($rstring, $return)); |
---|
| 2040 | } |
---|
| 2041 | |
---|
| 2042 | function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) |
---|
| 2043 | { |
---|
| 2044 | if($align != NULL && $align) |
---|
| 2045 | { |
---|
| 2046 | $align = "align=$align"; |
---|
| 2047 | } |
---|
| 2048 | if($halign != NULL && $halign) |
---|
| 2049 | { |
---|
| 2050 | $halign = "halign=$halign"; |
---|
| 2051 | } |
---|
| 2052 | if($valign != NULL && $valign) |
---|
| 2053 | { |
---|
| 2054 | $valign = "valign=$valign"; |
---|
| 2055 | } |
---|
| 2056 | if($bgcolor != NULL && $bgcolor) |
---|
| 2057 | { |
---|
| 2058 | $bgcolor = "bgcolor=$bgcolor"; |
---|
| 2059 | } |
---|
| 2060 | $rstring = "<tr $align $halign $valign $bgcolor $string>"; |
---|
| 2061 | return($this->bo->eor($rstring, $return)); |
---|
| 2062 | } |
---|
| 2063 | |
---|
| 2064 | function html_table_row_end($return = 0) |
---|
| 2065 | { |
---|
| 2066 | $rstring = "</tr>"; |
---|
| 2067 | return($this->bo->eor($rstring, $return)); |
---|
| 2068 | } |
---|
| 2069 | |
---|
| 2070 | function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) |
---|
| 2071 | { |
---|
| 2072 | if($align != NULL && $align) |
---|
| 2073 | { |
---|
| 2074 | $align = "align=$align"; |
---|
| 2075 | } |
---|
| 2076 | if($halign != NULL && $halign) |
---|
| 2077 | { |
---|
| 2078 | $halign = "halign=$halign"; |
---|
| 2079 | } |
---|
| 2080 | if($valign != NULL && $valign) |
---|
| 2081 | { |
---|
| 2082 | $valign = "valign=$valign"; |
---|
| 2083 | } |
---|
| 2084 | if(is_int($rowspan) && $rowspan >= 0) |
---|
| 2085 | { |
---|
| 2086 | $rowspan = "rowspan=$rowspan"; |
---|
| 2087 | } |
---|
| 2088 | if(is_int($colspan) && $colspan >= 0) |
---|
| 2089 | { |
---|
| 2090 | $colspan = "colspan=$colspan"; |
---|
| 2091 | } |
---|
| 2092 | |
---|
| 2093 | $rstring = "<td $align $halign $valign $rowspan $colspan $string>"; |
---|
| 2094 | return($this->bo->eor($rstring, $return)); |
---|
| 2095 | } |
---|
| 2096 | |
---|
| 2097 | function html_table_col_end($return = 0) |
---|
| 2098 | { |
---|
| 2099 | $rstring = "</td>"; |
---|
| 2100 | return($this->bo->eor($rstring, $return)); |
---|
| 2101 | } |
---|
| 2102 | } |
---|