[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, |
---|
[1575] | 25 | 'export'=> True, |
---|
| 26 | 'touch' => True, |
---|
[1506] | 27 | 'history' => True, |
---|
| 28 | 'edit' => True, |
---|
[1627] | 29 | 'fileModels'=>True, |
---|
[1693] | 30 | 'getReturnExecuteForm' => True, |
---|
[1719] | 31 | 'dir_ls' => True, |
---|
| 32 | 'get_permissions' => True, |
---|
[1627] | 33 | 'uploadModel'=>True |
---|
[1506] | 34 | ); |
---|
| 35 | |
---|
| 36 | //keep |
---|
| 37 | var $bo; |
---|
[1627] | 38 | var $vfs_functions; |
---|
[1506] | 39 | var $t; //template object |
---|
| 40 | var $dispath; |
---|
| 41 | var $cwd; |
---|
| 42 | var $lesspath; |
---|
| 43 | var $readable_groups; |
---|
| 44 | var $files_array; |
---|
| 45 | var $numoffiles; |
---|
| 46 | var $dispsep; |
---|
| 47 | |
---|
| 48 | var $target; |
---|
| 49 | |
---|
| 50 | var $prefs;//array |
---|
| 51 | |
---|
| 52 | var $groups_applications; |
---|
| 53 | |
---|
| 54 | //originally post_vars |
---|
| 55 | // var $goto; |
---|
[1556] | 56 | var $current_config; |
---|
[1506] | 57 | var $goto_x; |
---|
[1694] | 58 | var $to; |
---|
[1506] | 59 | var $changedir; // for switching dir. |
---|
| 60 | var $cdtodir; // for switching dir. |
---|
| 61 | // var $createdir; |
---|
| 62 | var $newfile_or_dir; |
---|
| 63 | var $newdir_x; |
---|
| 64 | var $newfile_x; |
---|
| 65 | var $createfile_var; |
---|
| 66 | var $move_to_x; |
---|
[1627] | 67 | // var $copy_to; |
---|
[1506] | 68 | var $copy_to_x; |
---|
| 69 | var $edit_x; |
---|
| 70 | var $edit_file; |
---|
| 71 | var $edit_preview_x; |
---|
| 72 | var $edit_save_x; |
---|
| 73 | var $edit_save_done_x; |
---|
| 74 | var $edit_cancel_x; |
---|
| 75 | var $upload_x; |
---|
| 76 | |
---|
| 77 | // this ones must be checked thorougly; |
---|
| 78 | var $fileman = Array(); |
---|
| 79 | //var $fileman; |
---|
| 80 | var $path; |
---|
| 81 | var $file; // FIXME WHERE IS THIS FILLED? |
---|
| 82 | var $sortby; |
---|
[1694] | 83 | var $messages; |
---|
[1506] | 84 | var $show_upload_boxes; |
---|
| 85 | |
---|
| 86 | var $now; |
---|
| 87 | |
---|
| 88 | function uifilemanager() |
---|
| 89 | { |
---|
[1694] | 90 | $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; |
---|
| 91 | |
---|
[1506] | 92 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
| 93 | |
---|
| 94 | $this->now = date('Y-m-d'); |
---|
| 95 | |
---|
| 96 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
| 97 | |
---|
[1627] | 98 | $this->vfs_functions = CreateObject('filemanager.vfs_functions'); |
---|
| 99 | |
---|
[1506] | 100 | $this->t = $GLOBALS['phpgw']->template; |
---|
[1556] | 101 | $c = CreateObject('phpgwapi.config','filemanager'); |
---|
| 102 | $c->read_repository(); |
---|
| 103 | $this->current_config = $c->config_data; |
---|
[1506] | 104 | |
---|
[1556] | 105 | |
---|
[1506] | 106 | // here local vars are created from the HTTP vars |
---|
| 107 | @reset($GLOBALS['HTTP_POST_VARS']); |
---|
| 108 | while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) |
---|
| 109 | { |
---|
| 110 | $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | @reset($GLOBALS['HTTP_GET_VARS']); |
---|
| 114 | while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) |
---|
| 115 | { |
---|
| 116 | $$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
[1627] | 117 | $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
| 118 | |
---|
[1506] | 119 | } |
---|
| 120 | |
---|
| 121 | $to_decode = array |
---|
| 122 | ( |
---|
| 123 | 'op' => array('op' => ''), |
---|
| 124 | 'path' => array('path' => ''), |
---|
[1654] | 125 | 'filename' => array('filename' => ''), |
---|
[1506] | 126 | 'file' => array('file' => ''), |
---|
| 127 | 'sortby' => array('sortby' => ''), |
---|
| 128 | 'messages' => array('messages' => ''), |
---|
[1694] | 129 | 'show_upload_boxes' => array('show_upload_boxes' => ''), |
---|
| 130 | 'to' => array('to' => '') |
---|
| 131 | |
---|
[1506] | 132 | ); |
---|
| 133 | |
---|
| 134 | reset($to_decode); |
---|
| 135 | while(list($var, $conditions) = each($to_decode)) |
---|
| 136 | { |
---|
| 137 | while(list($condvar, $condvalue) = each($conditions)) |
---|
| 138 | { |
---|
| 139 | if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) |
---|
| 140 | { |
---|
| 141 | if(is_array($$var)) |
---|
| 142 | { |
---|
| 143 | $temp = array(); |
---|
| 144 | while(list($varkey, $varvalue) = each($$var)) |
---|
| 145 | { |
---|
| 146 | if(is_int($varkey)) |
---|
| 147 | { |
---|
| 148 | $temp[$varkey] = stripslashes(base64_decode(urldecode(($varvalue)))); |
---|
| 149 | } |
---|
| 150 | else |
---|
| 151 | { |
---|
| 152 | $temp[stripslashes(base64_decode(urldecode(($varkey))))] = $varvalue; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | $this->$var = $temp; |
---|
| 156 | } |
---|
| 157 | elseif(isset($$var)) |
---|
| 158 | { |
---|
| 159 | $this->$var = stripslashes(base64_decode(urldecode($$var))); |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | } |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | // get appl. and user prefs |
---|
| 166 | $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); |
---|
| 167 | $pref->read_repository(); |
---|
[1693] | 168 | //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); |
---|
[1506] | 169 | $pref->save_repository(True); |
---|
| 170 | $pref_array = $pref->read_repository(); |
---|
| 171 | $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array |
---|
| 172 | |
---|
| 173 | //always show name |
---|
| 174 | |
---|
| 175 | $this->prefs[name] =1; |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | if($this->prefs['viewinnewwin']) |
---|
| 179 | { |
---|
| 180 | $this->target = '_blank'; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | /* |
---|
| 185 | Check for essential directories |
---|
| 186 | admin must be able to disable these tests |
---|
| 187 | */ |
---|
| 188 | |
---|
| 189 | // check if basedir exist |
---|
| 190 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 191 | if($test[mime_type]!='Directory') |
---|
| 192 | { |
---|
| 193 | die('Base directory does not exist, Ask adminstrator to check the global configuration.'); |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 197 | if($test[mime_type]!='Directory') |
---|
| 198 | { |
---|
| 199 | |
---|
| 200 | $this->bo->vfs->override_acl = 1; |
---|
| 201 | |
---|
| 202 | $this->bo->vfs->mkdir(array( |
---|
| 203 | 'string' => $this->bo->fakebase, |
---|
| 204 | 'relatives' => array(RELATIVE_NONE) |
---|
| 205 | )); |
---|
| 206 | |
---|
| 207 | $this->bo->vfs->override_acl = 0; |
---|
| 208 | |
---|
| 209 | //test one more time |
---|
| 210 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 211 | |
---|
| 212 | if($test[mime_type]!='Directory') |
---|
| 213 | { |
---|
| 214 | die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); |
---|
| 215 | } |
---|
| 216 | else |
---|
| 217 | { |
---|
[1627] | 218 | $this->messages[]= lang('Fake Base Dir did not exist, eGroupWare created a new one.'); |
---|
[1506] | 219 | } |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 223 | if($test[mime_type]!='Directory') |
---|
| 224 | { |
---|
| 225 | $this->bo->vfs->override_acl = 1; |
---|
| 226 | |
---|
| 227 | $this->bo->vfs->mkdir(array( |
---|
| 228 | 'string' => $this->bo->homedir, |
---|
| 229 | 'relatives' => array(RELATIVE_NONE) |
---|
| 230 | )); |
---|
[1627] | 231 | $this->bo->vfs->set_quota(array( |
---|
| 232 | 'string' => $this->bo->homedir, |
---|
| 233 | 'relatives' => array(RELATIVE_NONE), |
---|
| 234 | 'new_quota' => $this->current_config['filemanager_quota_size'] |
---|
| 235 | )); |
---|
| 236 | |
---|
[1506] | 237 | $this->bo->vfs->override_acl = 0; |
---|
| 238 | |
---|
| 239 | //test one more time |
---|
| 240 | $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 241 | |
---|
| 242 | if($test[mime_type]!='Directory') |
---|
| 243 | { |
---|
| 244 | die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); |
---|
| 245 | } |
---|
| 246 | else |
---|
| 247 | { |
---|
[1627] | 248 | $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); |
---|
[1506] | 249 | // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content |
---|
| 250 | } |
---|
[1693] | 251 | |
---|
| 252 | |
---|
[1506] | 253 | } |
---|
| 254 | |
---|
| 255 | } |
---|
[1627] | 256 | function fileModels() |
---|
| 257 | { |
---|
| 258 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 259 | ( |
---|
| 260 | 'currentapp' => 'filemanager', |
---|
| 261 | 'noheader' => False, |
---|
| 262 | 'nonavbar' => False, |
---|
| 263 | 'nofooter' => False, |
---|
| 264 | 'noappheader' => False, |
---|
| 265 | 'enable_browser_class' => True |
---|
| 266 | ); |
---|
[1506] | 267 | |
---|
[1627] | 268 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 269 | $this->t->set_file(array('models' => 'fileModels.tpl')); |
---|
| 270 | $this->t->set_block('models','header','header'); |
---|
| 271 | $this->t->set_block('models','body','body'); |
---|
| 272 | $this->t->set_block('models','footer','footer'); |
---|
| 273 | $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); |
---|
| 274 | $this->t->set_var('model_1','article'); |
---|
| 275 | $this->t->set_var('lang_1',lang('article')); |
---|
| 276 | |
---|
| 277 | $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); |
---|
| 278 | $this->t->set_var('model_2','calendar'); |
---|
| 279 | $this->t->set_var('lang_2',lang('calendar')); |
---|
| 280 | |
---|
| 281 | $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); |
---|
| 282 | $this->t->set_var('model_3','todo'); |
---|
| 283 | $this->t->set_var('lang_3',lang('todo')); |
---|
| 284 | |
---|
| 285 | $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); |
---|
| 286 | $this->t->set_var('model_4','slide'); |
---|
| 287 | $this->t->set_var('lang_4',lang('slide')); |
---|
| 288 | |
---|
| 289 | $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); |
---|
| 290 | $this->t->set_var('model_5','cards'); |
---|
| 291 | $this->t->set_var('lang_5',lang('cards')); |
---|
| 292 | |
---|
| 293 | $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); |
---|
| 294 | $this->t->set_var('model_6','resume'); |
---|
| 295 | $this->t->set_var('lang_6',lang('resume')); |
---|
| 296 | |
---|
| 297 | |
---|
| 298 | $this->t->pparse('out','models'); |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | } |
---|
| 302 | function uploadModel(){ |
---|
| 303 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 304 | ( |
---|
| 305 | 'currentapp' => 'filemanager', |
---|
| 306 | 'noheader' => False, |
---|
| 307 | 'nonavbar' => False, |
---|
| 308 | 'nofooter' => False, |
---|
| 309 | 'noappheader' => False, |
---|
| 310 | 'enable_browser_class' => True |
---|
| 311 | ); |
---|
| 312 | |
---|
| 313 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 314 | |
---|
| 315 | $filename = lang('new')."_".lang($this->model).rand(0,1000).".html"; |
---|
| 316 | $this->bo->vfs->cp(array( |
---|
| 317 | 'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html', |
---|
| 318 | 'to'=> $filename, |
---|
| 319 | 'relatives' => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) |
---|
| 320 | )); |
---|
| 321 | |
---|
| 322 | $this->bo->vfs->set_attributes(array( |
---|
| 323 | 'string'=> $filename, |
---|
| 324 | 'relatives' => array(RELATIVE_ALL), |
---|
| 325 | 'attributes'=> array( |
---|
| 326 | 'mime_type' => "text/html", |
---|
| 327 | 'comment' => "" |
---|
| 328 | ) |
---|
| 329 | )); |
---|
[1654] | 330 | $this->filename = $filename; |
---|
[1627] | 331 | $this->edit(); |
---|
| 332 | |
---|
| 333 | } |
---|
[1506] | 334 | function index() |
---|
| 335 | { |
---|
[1648] | 336 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 337 | ( |
---|
| 338 | 'currentapp' => 'filemanager', |
---|
| 339 | 'noheader' => False, |
---|
| 340 | 'nonavbar' => False, |
---|
| 341 | 'nofooter' => False, |
---|
| 342 | 'noappheader' => False, |
---|
| 343 | 'enable_browser_class' => True |
---|
| 344 | ); |
---|
[1506] | 345 | |
---|
[1648] | 346 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
[1506] | 347 | |
---|
[1556] | 348 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>"; |
---|
[1529] | 349 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; |
---|
| 350 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; |
---|
[1575] | 351 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; |
---|
[1654] | 352 | echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>"; |
---|
[1529] | 353 | include('load_lang.php'); |
---|
[1506] | 354 | |
---|
| 355 | # Page to process users |
---|
| 356 | # Code is fairly hackish at the beginning, but it gets better |
---|
| 357 | # Highly suggest turning wrapping off due to long SQL queries |
---|
| 358 | |
---|
| 359 | ### |
---|
| 360 | # Some hacks to set and display directory paths correctly |
---|
| 361 | ### |
---|
| 362 | // new method for switching to a new dir. |
---|
| 363 | if($this->changedir=='true' && $this->cdtodir || $this->goto_x) |
---|
| 364 | { |
---|
| 365 | $this->path = $this->cdtodir; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | if(!$this->path) |
---|
| 369 | { |
---|
| 370 | $this->path = $this->bo->vfs->pwd(); |
---|
| 371 | |
---|
| 372 | if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') |
---|
| 373 | { |
---|
| 374 | $this->path = $this->bo->homedir; |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 379 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
| 380 | |
---|
| 381 | $pwd = $this->bo->vfs->pwd(); |
---|
| 382 | |
---|
| 383 | if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) |
---|
| 384 | { |
---|
| 385 | $this->cwd = '/'; |
---|
| 386 | } |
---|
| 387 | else |
---|
| 388 | { |
---|
| 389 | $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | $this->disppath = $this->path; |
---|
| 393 | |
---|
| 394 | /* This just prevents // in some cases */ |
---|
| 395 | if($this->path == '/') |
---|
| 396 | { |
---|
| 397 | $this->dispsep = ''; |
---|
| 398 | } |
---|
| 399 | else |
---|
| 400 | { |
---|
| 401 | $this->dispsep = '/'; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) |
---|
| 405 | { |
---|
| 406 | $this->lesspath = '/'; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | # Get their readable groups to be used throughout the script |
---|
[1508] | 410 | $acl = array(); |
---|
[1506] | 411 | $groups = array(); |
---|
[1519] | 412 | $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager'); |
---|
[1508] | 413 | if (is_array($acl)) |
---|
| 414 | foreach($acl as $key => $value){ |
---|
| 415 | $info = array(); |
---|
| 416 | $info = $GLOBALS['phpgw']->accounts->get_account_data($value); |
---|
| 417 | $groups[$key]['account_id'] = $value; |
---|
| 418 | $groups[$key]['account_lid'] = $info[$value]['lid']; |
---|
| 419 | $groups[$key]['account_name'] = $info[$value]['firstname']; |
---|
| 420 | $groups[$key]['account_lastname'] = $info[$value]['lastname']; |
---|
| 421 | $groups[$key]['account_fullname'] = $info[$value]['fullname']; |
---|
| 422 | } |
---|
[1506] | 423 | $this->readable_groups = array(); |
---|
| 424 | while(list($num, $account) = each($groups)) |
---|
| 425 | { |
---|
[1648] | 426 | if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) |
---|
[1506] | 427 | { |
---|
| 428 | $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); |
---|
| 429 | } |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | $this->groups_applications = array(); |
---|
| 433 | |
---|
[1508] | 434 | foreach ($this->readable_groups as $value) |
---|
[1506] | 435 | { |
---|
[1508] | 436 | $applications = CreateObject('phpgwapi.applications', $value['account_id']); |
---|
| 437 | $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); |
---|
[1506] | 438 | } |
---|
| 439 | |
---|
| 440 | # We determine if they're in their home directory or a group's directory, |
---|
| 441 | # and set the VFS working_id appropriately |
---|
| 442 | if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined |
---|
| 443 | |
---|
| 444 | { |
---|
| 445 | $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined |
---|
| 446 | |
---|
| 447 | } |
---|
| 448 | else |
---|
| 449 | { |
---|
| 450 | $this->bo->vfs->working_id = $this->bo->userinfo['username']; |
---|
| 451 | } |
---|
| 452 | |
---|
[1648] | 453 | # Check available permissions for $this->path, so we can disable unusable operations in user interface |
---|
| 454 | $path = explode('/',$this->path); |
---|
| 455 | $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); |
---|
| 456 | $user_id = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 457 | if ($owner_id == $user_id) |
---|
[1506] | 458 | { |
---|
[1648] | 459 | $this->can_read = True; |
---|
| 460 | $this->can_add = True; |
---|
| 461 | $this->can_edit = True; |
---|
| 462 | $this->can_delete = True; |
---|
| 463 | $this->can_private = True; |
---|
| 464 | }else |
---|
| 465 | { |
---|
| 466 | $acl = CreateObject ('phpgwapi.acl', $owner_id); |
---|
| 467 | $acl->account_id = $owner_id; |
---|
| 468 | $acl->read_repository(); |
---|
| 469 | $rights = $acl->get_rights($user_id); |
---|
| 470 | $this->can_read = $rights & PHPGW_ACL_READ; |
---|
| 471 | $this->can_add = $rights & PHPGW_ACL_ADD; |
---|
| 472 | $this->can_edit = $rights & PHPGW_ACL_EDIT; |
---|
| 473 | $this->can_delete = $rights & PHPGW_ACL_DELETE; |
---|
| 474 | $this->can_private = $rights & PHPGW_ACL_PRIVATE; |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | # if is different path than home and no permission allowed |
---|
| 478 | if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) |
---|
| 479 | { |
---|
| 480 | echo lang('You do not have access to %1', $this->path); |
---|
[1506] | 481 | $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory')); |
---|
| 482 | |
---|
| 483 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 484 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 485 | } |
---|
| 486 | |
---|
| 487 | $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; |
---|
| 488 | $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); |
---|
| 489 | |
---|
| 490 | # Verify path is real |
---|
| 491 | if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 492 | { |
---|
| 493 | if(!$this->bo->vfs->file_exists(array( |
---|
| 494 | 'string' => $this->path, |
---|
| 495 | 'relatives' => array(RELATIVE_NONE) |
---|
| 496 | ))) |
---|
| 497 | { |
---|
[1627] | 498 | $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); |
---|
[1506] | 499 | $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory')); |
---|
| 500 | |
---|
| 501 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 502 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | |
---|
[1556] | 506 | |
---|
| 507 | /* Update the vfs */ |
---|
[1648] | 508 | if ($this->update_x == 'True') |
---|
[1506] | 509 | { |
---|
| 510 | $this->bo->vfs->update_real(array( |
---|
| 511 | 'string' => $this->path, |
---|
[1556] | 512 | 'relatives' => array(RELATIVE_ALL) |
---|
[1506] | 513 | )); |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | # Default is to sort by name |
---|
| 517 | if(!$this->sortby) |
---|
| 518 | { |
---|
| 519 | $this->sortby = 'name'; |
---|
| 520 | } |
---|
| 521 | |
---|
| 522 | # main action switch |
---|
| 523 | // FIXME this will become a switch |
---|
| 524 | if($this->newfile_x && $this->newfile_or_dir) // create new textfile |
---|
| 525 | { |
---|
| 526 | $this->createfile(); |
---|
| 527 | } |
---|
| 528 | elseif($this->newfile_or_dir && $this->newdir_x) |
---|
| 529 | { |
---|
| 530 | $this->createdir(); |
---|
| 531 | } |
---|
| 532 | elseif($this->upload_x || $this->show_upload_boxes) |
---|
| 533 | { |
---|
| 534 | $this->showUploadboxes(); |
---|
| 535 | } |
---|
| 536 | elseif($this->copy_to_x) |
---|
| 537 | { |
---|
| 538 | $this->copyTo(); |
---|
| 539 | } |
---|
| 540 | elseif($this->move_to_x) |
---|
| 541 | { |
---|
| 542 | $this->moveTo(); |
---|
| 543 | } |
---|
| 544 | elseif($this->edit_cancel_x) |
---|
| 545 | { |
---|
| 546 | $this->readFilesInfo(); |
---|
| 547 | $this->fileListing(); |
---|
| 548 | } |
---|
| 549 | elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) |
---|
| 550 | { |
---|
| 551 | $this->edit(); |
---|
| 552 | } |
---|
| 553 | else |
---|
| 554 | { |
---|
| 555 | $this->readFilesInfo(); |
---|
| 556 | $this->fileListing(); |
---|
| 557 | } |
---|
| 558 | } |
---|
[1719] | 559 | function get_permissions(){ |
---|
| 560 | /* get permissions */ |
---|
| 561 | if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined |
---|
| 562 | |
---|
| 563 | { |
---|
| 564 | $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined |
---|
| 565 | |
---|
| 566 | } |
---|
| 567 | else |
---|
| 568 | { |
---|
| 569 | $this->bo->vfs->working_id = $this->bo->userinfo['username']; |
---|
| 570 | } |
---|
| 571 | |
---|
| 572 | # Check available permissions for $this->path, so we can disable unusable operations in user interface |
---|
| 573 | $path = explode('/',$this->path); |
---|
| 574 | $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); |
---|
| 575 | $user_id = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
| 576 | if ($owner_id == $user_id) |
---|
| 577 | { |
---|
| 578 | $rights = 31; |
---|
| 579 | }else |
---|
| 580 | { |
---|
| 581 | $acl = CreateObject ('phpgwapi.acl', $owner_id); |
---|
| 582 | $acl->account_id = $owner_id; |
---|
| 583 | $acl->read_repository(); |
---|
| 584 | $rights = $acl->get_rights($user_id); |
---|
| 585 | } |
---|
| 586 | echo $rights; |
---|
| 587 | } |
---|
| 588 | function dir_ls() |
---|
| 589 | { |
---|
| 590 | reset($this->files_array); |
---|
| 591 | $this->readFilesInfo(); |
---|
| 592 | |
---|
| 593 | for($i = 0; $i != $this->numoffiles; $i++) |
---|
| 594 | { |
---|
| 595 | $files = $this->files_array[$i]; |
---|
| 596 | |
---|
| 597 | if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])) |
---|
| 598 | { |
---|
| 599 | continue; |
---|
| 600 | } |
---|
| 601 | /* small keys to safe bandwidth */ |
---|
| 602 | $tuple['name'] = $files['name']; |
---|
| 603 | $tuple['icon'] = $this->mime_icon($files['mime_type']); |
---|
| 604 | $tuple['type'] = $files['type']; |
---|
| 605 | if ($files['created'] != ''){ |
---|
| 606 | $timestamp = $this->vfs_functions->dateString2timeStamp($files['created']); |
---|
| 607 | if (time() - $timestamp > 86400) // Older than yesterday |
---|
| 608 | $tuple['creatd']=date("Y-m-d",$timestamp); |
---|
| 609 | else |
---|
| 610 | $tuple['creatd']=date("H:i",$timestamp); |
---|
| 611 | } |
---|
| 612 | else |
---|
| 613 | $tuple['creatd']=''; |
---|
| 614 | if ($files['modified'] != ''){ |
---|
| 615 | $timestamp = $this->vfs_functions->dateString2timeStamp($files['modified']); |
---|
| 616 | if (time() - $timestamp > 86400) // Older than yesterday |
---|
| 617 | $tuple['modifd']=date("Y-m-d",$timestamp); |
---|
| 618 | else |
---|
| 619 | $tuple['modifd']=date("H:i",$timestamp); |
---|
| 620 | } |
---|
| 621 | else |
---|
| 622 | $tuple['modifd']=''; |
---|
| 623 | |
---|
| 624 | $tuple['size'] = $files['size']; |
---|
| 625 | $tuple['mime'] = $files['mime_type']; |
---|
| 626 | $tuple['pub'] = $files['type']; |
---|
| 627 | $tuple['creatdby'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); |
---|
| 628 | $tuple['modifdby'] = $files['modifiedby_id']?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):''; |
---|
| 629 | $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); |
---|
| 630 | $tuple['comm'] = $files['comment']; |
---|
| 631 | $tuple['vers'] = $files['version']; |
---|
| 632 | $output[] = $tuple; |
---|
| 633 | |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | foreach ($output as $key => $row) { |
---|
| 637 | $temp[$key] = $row[$this->criteria]; |
---|
| 638 | } |
---|
| 639 | if ($this->otype == "1") |
---|
| 640 | array_multisort($temp, SORT_ASC, $output); |
---|
| 641 | else |
---|
| 642 | array_multisort($temp, SORT_DESC, $output); |
---|
| 643 | |
---|
| 644 | echo serialize($output); |
---|
| 645 | } |
---|
| 646 | |
---|
[1506] | 647 | function fileListing() |
---|
| 648 | { |
---|
[1719] | 649 | $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); |
---|
[1506] | 650 | $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); |
---|
| 651 | $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); |
---|
| 652 | |
---|
| 653 | if($this->numoffiles || $this->cwd) |
---|
| 654 | { |
---|
[1627] | 655 | $usedSpace = $this->bo->vfs->get_size(array( |
---|
| 656 | 'string' => $this->path, |
---|
| 657 | 'relatives' => array(RELATIVE_NONE) |
---|
| 658 | )); |
---|
| 659 | $quota = $this->bo->vfs->get_quota(array( |
---|
| 660 | 'string' => $this->path |
---|
| 661 | )); |
---|
| 662 | |
---|
| 663 | $vars[usedSpace]='<input type="hidden" id="usedSpace" value="'.$usedSpace.'">'; |
---|
| 664 | $vars[quotaSize]='<input type="hidden" id="quotaSize" value="'.($quota*1024*1024).'">'; |
---|
[1654] | 665 | $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; |
---|
[1704] | 666 | $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; |
---|
[1719] | 667 | $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; |
---|
[1704] | 668 | $vars[script]='<script>initDrawApi();</script>'; |
---|
[1506] | 669 | |
---|
[1704] | 670 | // create dir and file button |
---|
| 671 | if($this->can_add) |
---|
| 672 | { |
---|
| 673 | //TODO : create folder with problems |
---|
| 674 | //$toolbar3.=$this->toolButton('newdir','createdir',lang('Create Folder')); |
---|
| 675 | $vars[new_button]=$this->toolButton('new','createfile',lang('New...')); |
---|
| 676 | $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; |
---|
| 677 | } |
---|
| 678 | else |
---|
| 679 | $vars[new_button]=''; |
---|
| 680 | |
---|
[1719] | 681 | // reload button with this url |
---|
| 682 | $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); |
---|
| 683 | |
---|
[1704] | 684 | // go up icon when we're not at the top, dont allow to go outside /home = fakebase |
---|
| 685 | if($this->path != '/' && $this->path != $this->bo->fakebase) |
---|
| 686 | { |
---|
| 687 | $vars[tools_button] = $this->toolButton('tools','tools',lang('tools')); |
---|
| 688 | } |
---|
| 689 | else |
---|
| 690 | $vars[tools_button] = ""; |
---|
| 691 | |
---|
| 692 | |
---|
| 693 | // selectbox for change/move/and copy to |
---|
| 694 | $dirs=$this->all_other_directories_options(); |
---|
| 695 | foreach($dirs as $elem) |
---|
[1719] | 696 | $vars[folders].='<br><span onclick="load(\''.$elem['directory'].$elem['name'].'\')" class="l" onmouseover="this.style.border=\'1px solid black\'" onmouseout="this.style.border=\'1px solid transparent\'">'.$elem['name'].'</span>'; |
---|
[1704] | 697 | |
---|
| 698 | |
---|
| 699 | // copy and move buttons |
---|
| 700 | //if($this->path != '/' && $this->path != $this->bo->fakebase){} |
---|
| 701 | |
---|
| 702 | $dirs=$this->all_other_directories_options(); |
---|
| 703 | foreach($dirs as $dir) |
---|
| 704 | if((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists(array('string' => $dir['directory'] . $dir['name'],'relatives' => array(RELATIVE_NONE)))) |
---|
| 705 | { |
---|
| 706 | //FIXME replace the html_form_option function |
---|
| 707 | $dirs_options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | $toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>'; |
---|
| 711 | |
---|
| 712 | $vars[toolbar1]=$toolbar; |
---|
| 713 | |
---|
[1506] | 714 | if(count($this->messages)>0) |
---|
| 715 | { |
---|
| 716 | foreach($this->messages as $msg) |
---|
| 717 | { |
---|
[1694] | 718 | $messages.='<span>'.$msg.'</span>'; |
---|
[1506] | 719 | } |
---|
| 720 | } |
---|
[1694] | 721 | $this->messages = NULL; |
---|
| 722 | |
---|
[1506] | 723 | $vars[messages]=$messages; |
---|
| 724 | |
---|
| 725 | $this->t->set_var($vars); |
---|
| 726 | $this->t->pparse('out','filemanager_header'); |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | $this->t->set_var($vars); |
---|
| 730 | $this->t->pparse('out','filemanager_footer'); |
---|
| 731 | |
---|
| 732 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 733 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | function readFilesInfo() |
---|
| 737 | { |
---|
| 738 | // start files info |
---|
| 739 | |
---|
| 740 | # Read in file info from database to use in the rest of the script |
---|
| 741 | # $fakebase is a special directory. In that directory, we list the user's |
---|
| 742 | # home directory and the directories for the groups they're in |
---|
| 743 | $this->numoffiles = 0; |
---|
| 744 | if($this->path == $this->bo->fakebase) |
---|
| 745 | { |
---|
| 746 | // FIXME this test can be removed |
---|
| 747 | if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) |
---|
| 748 | { |
---|
| 749 | $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); |
---|
| 750 | } |
---|
| 751 | |
---|
| 752 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 753 | 'string' => $this->bo->homedir, |
---|
| 754 | 'relatives' => array(RELATIVE_NONE), |
---|
| 755 | 'checksubdirs' => False, |
---|
| 756 | 'nofiles' => True |
---|
| 757 | )); |
---|
[1627] | 758 | |
---|
[1506] | 759 | $this->files_array[] = $ls_array[0]; |
---|
| 760 | $this->numoffiles++; |
---|
| 761 | |
---|
| 762 | reset($this->readable_groups); |
---|
| 763 | while(list($num, $group_array) = each($this->readable_groups)) |
---|
| 764 | { |
---|
| 765 | # If the group doesn't have access to this app, we don't show it |
---|
[1508] | 766 | /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) |
---|
[1506] | 767 | { |
---|
| 768 | continue; |
---|
| 769 | } |
---|
[1508] | 770 | */ |
---|
[1506] | 771 | |
---|
| 772 | |
---|
| 773 | if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE)))) |
---|
| 774 | { |
---|
| 775 | $this->bo->vfs->override_acl = 1; |
---|
| 776 | $this->bo->vfs->mkdir(array( |
---|
| 777 | 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], |
---|
| 778 | 'relatives' => array(RELATIVE_NONE) |
---|
| 779 | )); |
---|
| 780 | |
---|
| 781 | // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content |
---|
| 782 | |
---|
| 783 | |
---|
| 784 | $this->bo->vfs->override_acl = 0; |
---|
| 785 | |
---|
| 786 | $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']))); |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); |
---|
| 790 | |
---|
| 791 | $this->files_array[] = $ls_array[0]; |
---|
| 792 | |
---|
| 793 | $this->numoffiles++; |
---|
| 794 | } |
---|
| 795 | } |
---|
| 796 | else |
---|
| 797 | { |
---|
| 798 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 799 | 'string' => $this->path, |
---|
| 800 | 'relatives' => array(RELATIVE_NONE), |
---|
| 801 | 'checksubdirs' => False, |
---|
| 802 | 'nofiles' => False, |
---|
| 803 | 'orderby' => $this->sortby |
---|
| 804 | )); |
---|
| 805 | |
---|
| 806 | while(list($num, $file_array) = each($ls_array)) |
---|
| 807 | { |
---|
| 808 | $this->numoffiles++; |
---|
| 809 | $this->files_array[] = $file_array; |
---|
| 810 | } |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | if(!is_array($this->files_array)) |
---|
| 814 | { |
---|
| 815 | $this->files_array = array(); |
---|
| 816 | } |
---|
| 817 | // end file count |
---|
| 818 | } |
---|
| 819 | |
---|
| 820 | # Handle Moving Files and Directories |
---|
| 821 | function moveTo() |
---|
| 822 | { |
---|
[1694] | 823 | if(!$this->to) |
---|
[1506] | 824 | { |
---|
[1627] | 825 | $this->messages[] = lang('Error:').lang('Could not move file because no destination directory is given ', $this->disppath.'/'.$file); |
---|
[1506] | 826 | |
---|
| 827 | } |
---|
| 828 | else |
---|
| 829 | { |
---|
[1719] | 830 | $this->to = $this->bo->fakebase.'/'.$this->to; |
---|
[1506] | 831 | while(list($num, $file) = each($this->fileman)) |
---|
| 832 | { |
---|
| 833 | if($this->bo->vfs->mv(array( |
---|
| 834 | 'from' => $file, |
---|
[1694] | 835 | 'to' => $this->to . '/' . $file, |
---|
[1506] | 836 | 'relatives' => array(RELATIVE_ALL, RELATIVE_NONE) |
---|
| 837 | ))) |
---|
| 838 | { |
---|
| 839 | $moved++; |
---|
[1694] | 840 | $this->messages[]=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file); |
---|
[1506] | 841 | } |
---|
| 842 | else |
---|
| 843 | { |
---|
[1694] | 844 | $this->messages[] = lang('Error:').lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file); |
---|
[1506] | 845 | } |
---|
| 846 | } |
---|
| 847 | } |
---|
| 848 | |
---|
| 849 | if($moved) |
---|
| 850 | { |
---|
| 851 | $x=0; |
---|
| 852 | } |
---|
| 853 | |
---|
| 854 | $this->readFilesInfo(); |
---|
| 855 | $this->filelisting(); |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | // Handle Copying of Files and Directories |
---|
| 859 | function copyTo() |
---|
| 860 | { |
---|
[1694] | 861 | if(!$this->to) |
---|
[1506] | 862 | { |
---|
[1627] | 863 | $this->messages[] = lang('Error:').lang('Could not copy file because no destination directory is given ', $this->disppath.'/'.$file); |
---|
[1506] | 864 | |
---|
| 865 | } |
---|
| 866 | else |
---|
| 867 | { |
---|
[1719] | 868 | $this->to = $this->bo->fakebase.'/'.$this->to; |
---|
[1506] | 869 | while(list($num, $file) = each($this->fileman)) |
---|
| 870 | { |
---|
| 871 | if($this->bo->vfs->cp(array( |
---|
| 872 | 'from' => $file, |
---|
[1694] | 873 | 'to' => $this->to . '/' . $file, |
---|
[1506] | 874 | 'relatives' => array(RELATIVE_ALL, RELATIVE_NONE) |
---|
| 875 | ))) |
---|
| 876 | { |
---|
| 877 | $copied++; |
---|
[1694] | 878 | $this->messages[] = lang('Copied %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file); |
---|
[1506] | 879 | } |
---|
| 880 | else |
---|
| 881 | { |
---|
[1694] | 882 | $this->messages[] = lang('Error:').lang('Could not copy %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file); |
---|
[1506] | 883 | } |
---|
| 884 | } |
---|
| 885 | } |
---|
| 886 | if($copied) |
---|
[1648] | 887 | |
---|
[1506] | 888 | { |
---|
| 889 | $x=0; |
---|
| 890 | } |
---|
| 891 | |
---|
| 892 | $this->readFilesInfo(); |
---|
| 893 | $this->filelisting(); |
---|
| 894 | } |
---|
| 895 | |
---|
| 896 | function createdir() |
---|
| 897 | { |
---|
| 898 | if($this->newdir_x && $this->newfile_or_dir) |
---|
| 899 | { |
---|
| 900 | if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) |
---|
| 901 | { |
---|
[1627] | 902 | $this->messages[]= lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); |
---|
[1506] | 903 | } |
---|
| 904 | |
---|
| 905 | /* TODO is this right or should it be a single $ ? */ |
---|
| 906 | if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') |
---|
| 907 | { |
---|
[1627] | 908 | $this->messages[]= lang('Error:').lang('Cannot create directory because it begins or ends in a space'); |
---|
[1506] | 909 | } |
---|
| 910 | |
---|
| 911 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 912 | 'string' => $this->path . '/' . $this->newfile_or_dir, |
---|
| 913 | 'relatives' => array(RELATIVE_NONE), |
---|
| 914 | 'checksubdirs' => False, |
---|
| 915 | 'nofiles' => True |
---|
| 916 | )); |
---|
| 917 | |
---|
| 918 | $fileinfo = $ls_array[0]; |
---|
| 919 | |
---|
| 920 | if($fileinfo['name']) |
---|
| 921 | { |
---|
| 922 | if($fileinfo['mime_type'] != 'Directory') |
---|
| 923 | { |
---|
[1627] | 924 | $this->messages[]= lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); |
---|
[1506] | 925 | } |
---|
| 926 | else |
---|
| 927 | { |
---|
[1627] | 928 | $this->messages[]= lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); |
---|
[1506] | 929 | } |
---|
| 930 | } |
---|
| 931 | else |
---|
| 932 | { |
---|
| 933 | if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir))) |
---|
| 934 | { |
---|
| 935 | $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); |
---|
| 936 | } |
---|
| 937 | else |
---|
| 938 | { |
---|
[1627] | 939 | $this->messages[]=lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir); |
---|
[1506] | 940 | } |
---|
| 941 | } |
---|
| 942 | |
---|
| 943 | $this->readFilesInfo(); |
---|
| 944 | $this->filelisting(); |
---|
| 945 | } |
---|
| 946 | } |
---|
[1693] | 947 | function getReturnExecuteForm(){ |
---|
| 948 | $response = $_SESSION['response']; |
---|
| 949 | $_SESSION['response'] = null; |
---|
| 950 | echo $response; |
---|
| 951 | return; |
---|
| 952 | } |
---|
[1506] | 953 | function showUploadboxes() |
---|
| 954 | { |
---|
| 955 | $this->t->set_file(array('upload' => 'upload.tpl')); |
---|
| 956 | $this->t->set_block('upload','upload_header','upload_header'); |
---|
| 957 | $this->t->set_block('upload','row','row'); |
---|
| 958 | $this->t->set_block('upload','upload_footer','upload_footer'); |
---|
| 959 | |
---|
| 960 | if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add) |
---|
| 961 | { |
---|
[1693] | 962 | $vars[max_size]=lang('Note: Uploaded is limited to %1MB',($this->current_config['filemanager_Max_file_size'])); |
---|
| 963 | $vars[form_action]=$GLOBALS[phpgw]->link('/filemanager/inc/upload.php'); |
---|
| 964 | //$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); |
---|
[1506] | 965 | $vars[path]=$this->path; |
---|
| 966 | $vars[lang_file]=lang('File'); |
---|
| 967 | $vars[lang_comment]=lang('Comment'); |
---|
[1627] | 968 | $vars[num_upload_boxes]=1; |
---|
[1506] | 969 | $this->t->set_var($vars); |
---|
| 970 | $this->t->pparse('out','upload_header'); |
---|
| 971 | |
---|
[1627] | 972 | $this->t->set_var('row_tr_color',$tr_color); |
---|
| 973 | $this->t->parse('rows','row'); |
---|
| 974 | $this->t->pparse('out','row'); |
---|
[1506] | 975 | |
---|
| 976 | $vars[lang_upload]=lang('Upload files'); |
---|
| 977 | $vars[change_upload_boxes].=lang('Show') . ' '; |
---|
| 978 | $this->t->set_var($vars); |
---|
| 979 | $this->t->pparse('out','upload_footer'); |
---|
| 980 | } |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | /* create textfile */ |
---|
| 984 | function createfile() |
---|
| 985 | { |
---|
[1654] | 986 | $this->filename=$this->newfile_or_dir; |
---|
| 987 | if($this->filename) |
---|
[1506] | 988 | { |
---|
[1654] | 989 | if($badchar = $this->bo->bad_chars($this->filename, True, True)) |
---|
[1506] | 990 | { |
---|
[1627] | 991 | $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); |
---|
[1506] | 992 | |
---|
| 993 | $this->fileListing(); |
---|
| 994 | } |
---|
| 995 | |
---|
| 996 | if($this->bo->vfs->file_exists(array( |
---|
[1654] | 997 | 'string'=> $this->filename, |
---|
[1506] | 998 | 'relatives' => array(RELATIVE_ALL) |
---|
| 999 | ))) |
---|
| 1000 | { |
---|
[1654] | 1001 | $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename); |
---|
[1506] | 1002 | $this->fileListing(); |
---|
| 1003 | } |
---|
| 1004 | |
---|
| 1005 | if($this->bo->vfs->touch(array( |
---|
[1654] | 1006 | 'string' => $this->filename, |
---|
[1506] | 1007 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1008 | ))) |
---|
| 1009 | { |
---|
| 1010 | $this->edit = 1; |
---|
| 1011 | $this->numoffiles++; |
---|
| 1012 | $this->edit(); |
---|
| 1013 | } |
---|
| 1014 | else |
---|
| 1015 | { |
---|
[1654] | 1016 | $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename); |
---|
[1506] | 1017 | $this->fileListing(); |
---|
| 1018 | } |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | |
---|
| 1022 | # Handle Editing files |
---|
| 1023 | function edit() |
---|
| 1024 | { |
---|
[1654] | 1025 | if($this->filename) |
---|
[1533] | 1026 | { |
---|
[1654] | 1027 | if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){ |
---|
[1590] | 1028 | echo $this->messages['0']; |
---|
| 1029 | $GLOBALS['phpgw']->redirect('/index.php'); |
---|
| 1030 | |
---|
| 1031 | //$GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1032 | } |
---|
[1533] | 1033 | $ls_array = $this->bo->vfs->ls(array( |
---|
[1654] | 1034 | 'string' => $this->path.'/'.$this->filename, |
---|
[1575] | 1035 | 'relatives' => array(RELATIVE_NONE), |
---|
[1533] | 1036 | 'checksubdirs' => False, |
---|
| 1037 | 'nofiles' => True |
---|
| 1038 | )); |
---|
[1575] | 1039 | $this->bo->vfs->touch(array( |
---|
[1654] | 1040 | 'string'=> $this->path.'/'.$this->filename, |
---|
[1575] | 1041 | 'relatives' => array(RELATIVE_NONE) |
---|
| 1042 | )); |
---|
[1533] | 1043 | |
---|
[1627] | 1044 | |
---|
[1533] | 1045 | if($ls_array[0]['mime_type']) |
---|
| 1046 | { |
---|
| 1047 | $mime_type = $ls_array[0]['mime_type']; |
---|
| 1048 | } |
---|
| 1049 | elseif($this->prefs['viewtextplain']) |
---|
| 1050 | { |
---|
| 1051 | $mime_type = 'text/plain'; |
---|
| 1052 | } |
---|
[1575] | 1053 | $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822'); |
---|
[1533] | 1054 | |
---|
[1575] | 1055 | if(!in_array($mime_type,$editable)){ |
---|
[1535] | 1056 | echo lang('Impossbile to edit this file'); |
---|
[1533] | 1057 | return False; |
---|
| 1058 | } |
---|
| 1059 | } |
---|
| 1060 | |
---|
[1506] | 1061 | $this->readFilesInfo(); |
---|
| 1062 | |
---|
[1575] | 1063 | if ($mime_type == 'text/html') |
---|
| 1064 | $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); |
---|
[1627] | 1065 | else |
---|
[1575] | 1066 | $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); |
---|
| 1067 | |
---|
[1627] | 1068 | $this->t->set_block('filemanager_edit','row','row'); |
---|
[1575] | 1069 | |
---|
[1627] | 1070 | |
---|
[1575] | 1071 | $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; |
---|
| 1072 | |
---|
[1506] | 1073 | $vars[preview_content]=''; |
---|
| 1074 | if($this->edit_file) |
---|
| 1075 | { |
---|
| 1076 | $this->edit_file_content = stripslashes($this->edit_file_content); |
---|
| 1077 | } |
---|
| 1078 | |
---|
| 1079 | if($this->edit_preview_x) |
---|
| 1080 | { |
---|
| 1081 | $content = $this->edit_file_content; |
---|
| 1082 | |
---|
| 1083 | $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); |
---|
| 1084 | |
---|
| 1085 | $vars[preview_content]=nl2br($content); |
---|
| 1086 | } |
---|
| 1087 | elseif($this->edit_save_x || $this->edit_save_done_x) |
---|
| 1088 | { |
---|
| 1089 | $content = $this->edit_file_content; |
---|
| 1090 | //die( $content); |
---|
| 1091 | if($this->bo->vfs->write(array( |
---|
[1590] | 1092 | 'string' => $this->path.'/'.$this->edit_file, |
---|
| 1093 | 'relatives' => array(RELATIVE_NONE), |
---|
[1506] | 1094 | 'content' => $content |
---|
| 1095 | ))) |
---|
| 1096 | { |
---|
| 1097 | $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); |
---|
| 1098 | |
---|
| 1099 | if($this->edit_save_done_x) |
---|
| 1100 | { |
---|
| 1101 | $this->readFilesInfo(); |
---|
| 1102 | $this->fileListing(); |
---|
| 1103 | exit; |
---|
| 1104 | } |
---|
| 1105 | } |
---|
| 1106 | else |
---|
| 1107 | { |
---|
[1535] | 1108 | echo lang('Could not save %1', $this->path.'/'.$this->edit_file); |
---|
[1506] | 1109 | $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); |
---|
| 1110 | } |
---|
| 1111 | } |
---|
| 1112 | |
---|
[1654] | 1113 | # If we're in preview or save mode, we only show the file |
---|
| 1114 | # being previewed or saved |
---|
| 1115 | if($this->edit_file &&($this->filename != $this->edit_file)) |
---|
[1506] | 1116 | { |
---|
[1654] | 1117 | continue; |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | if($this->filename && $this->bo->vfs->file_exists(array( |
---|
| 1121 | 'string' => $this->filename, |
---|
| 1122 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1123 | ))) |
---|
| 1124 | { |
---|
| 1125 | if($this->edit_file) |
---|
[1506] | 1126 | { |
---|
[1654] | 1127 | $content = stripslashes($this->edit_file_content); |
---|
[1506] | 1128 | } |
---|
[1654] | 1129 | else |
---|
[1506] | 1130 | { |
---|
[1654] | 1131 | $content = $this->bo->vfs->read(array('string' => $this->filename)); |
---|
| 1132 | } |
---|
| 1133 | $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); |
---|
| 1134 | $vars[edit_file]=$this->filename; |
---|
| 1135 | # We need to include all of the fileman entries for each file's form, |
---|
| 1136 | # so we loop through again |
---|
| 1137 | for($i = 0; $i != $this->numoffiles; $i++) |
---|
| 1138 | { |
---|
| 1139 | if($this->filename) $value='value="'.$this->filename.'"'; |
---|
| 1140 | $vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />'; |
---|
| 1141 | } |
---|
| 1142 | $vars[file_content]=$content; |
---|
[1506] | 1143 | |
---|
[1654] | 1144 | $vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[$j], 1))); |
---|
| 1145 | $vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1))); |
---|
| 1146 | $vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); |
---|
| 1147 | $vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); |
---|
[1506] | 1148 | |
---|
[1654] | 1149 | if ($mime_type == 'text/html'){ |
---|
| 1150 | $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> |
---|
| 1151 | <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea> |
---|
| 1152 | <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ |
---|
| 1153 | removePlugins : \'elementspath\', |
---|
| 1154 | skin : \'office2003\', |
---|
| 1155 | toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print", |
---|
| 1156 | "Undo","Redo","-","Find","Replace","-","SelectAll" ], |
---|
| 1157 | ["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold", |
---|
| 1158 | "Italic","Underline","Strike","-","Subscript","Superscript", |
---|
| 1159 | "NumberedList","BulletedList","-","Outdent","Indent","Blockquote", |
---|
| 1160 | "JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock", |
---|
| 1161 | "Link", "TextColor","BGColor","Maximize"], |
---|
| 1162 | ["Styles","Format","Font","FontSize"]] |
---|
| 1163 | });</script>'; |
---|
[1506] | 1164 | |
---|
[1654] | 1165 | } |
---|
[1506] | 1166 | |
---|
[1575] | 1167 | |
---|
[1654] | 1168 | $this->t->set_var($vars); |
---|
| 1169 | $this->t->parse('rows','row'); |
---|
| 1170 | $this->t->pparse('out','row'); |
---|
[1575] | 1171 | |
---|
[1506] | 1172 | } |
---|
[1654] | 1173 | |
---|
[1506] | 1174 | } |
---|
| 1175 | |
---|
| 1176 | function history() |
---|
| 1177 | { |
---|
| 1178 | if($this->file) // FIXME this-file is never defined |
---|
| 1179 | { |
---|
| 1180 | $journal_array = $this->bo->vfs->get_journal(array( |
---|
| 1181 | 'string' => $this->file,//FIXME |
---|
| 1182 | 'relatives' => array(RELATIVE_ALL) |
---|
| 1183 | )); |
---|
| 1184 | |
---|
| 1185 | if(is_array($journal_array)) |
---|
| 1186 | { |
---|
| 1187 | $this->html_table_begin(); |
---|
| 1188 | $this->html_table_row_begin(); |
---|
| 1189 | $this->html_table_col_begin(); |
---|
| 1190 | echo lang('Date'); |
---|
| 1191 | $this->html_table_col_end(); |
---|
| 1192 | $this->html_table_col_begin(); |
---|
| 1193 | echo lang('Version'); |
---|
| 1194 | $this->html_table_col_end(); |
---|
| 1195 | $this->html_table_col_begin(); |
---|
| 1196 | echo lang('Who'); |
---|
| 1197 | $this->html_table_col_end(); |
---|
| 1198 | $this->html_table_col_begin(); |
---|
| 1199 | echo lang('Operation'); |
---|
| 1200 | $this->html_table_col_end(); |
---|
| 1201 | $this->html_table_row_end(); |
---|
| 1202 | |
---|
| 1203 | while(list($num, $journal_entry) = each($journal_array)) |
---|
| 1204 | { |
---|
| 1205 | $this->html_table_row_begin(); |
---|
| 1206 | $this->html_table_col_begin(); |
---|
| 1207 | $this->bo->html_text($journal_entry['created'] . ' '); |
---|
| 1208 | $this->html_table_col_end(); |
---|
| 1209 | $this->html_table_col_begin(); |
---|
| 1210 | $this->bo->html_text($journal_entry['version'] . ' ' ); |
---|
| 1211 | $this->html_table_col_end(); |
---|
| 1212 | $this->html_table_col_begin(); |
---|
| 1213 | $this->bo->html_text($GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']) . ' '); |
---|
| 1214 | $this->html_table_col_end(); |
---|
| 1215 | $this->html_table_col_begin(); |
---|
| 1216 | $this->bo->html_text($journal_entry['comment']); |
---|
| 1217 | $this->html_table_col_end(); |
---|
| 1218 | } |
---|
| 1219 | |
---|
| 1220 | $this->html_table_end(); |
---|
| 1221 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 1222 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1223 | } |
---|
| 1224 | else |
---|
| 1225 | { |
---|
| 1226 | echo lang('No version history for this file/directory'); |
---|
| 1227 | } |
---|
| 1228 | } |
---|
| 1229 | } |
---|
[1627] | 1230 | function view() |
---|
| 1231 | { |
---|
| 1232 | if (!$this->bo->vfs->acl_check(array( |
---|
| 1233 | 'string' => $this->path, |
---|
| 1234 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1235 | 'operation' => PHPGW_ACL_READ |
---|
| 1236 | ))) |
---|
[1575] | 1237 | { |
---|
[1627] | 1238 | echo lang("You have no permission to access this file"); |
---|
| 1239 | return false; |
---|
[1575] | 1240 | } |
---|
[1506] | 1241 | if($this->file) //FIXME |
---|
| 1242 | { |
---|
| 1243 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 1244 | 'string' => $this->path.'/'.$this->file,//FIXME |
---|
[1535] | 1245 | 'relatives' => array(RELATIVE_NONE), |
---|
[1506] | 1246 | 'checksubdirs' => False, |
---|
| 1247 | 'nofiles' => True |
---|
| 1248 | )); |
---|
[1693] | 1249 | if ($ls_array[0]['size'] > 4194304){ |
---|
| 1250 | header('Location:'.$this->encode_href('inc/download.php','file='.base64_encode($this->file).'&path='.base64_encode($this->path))); |
---|
| 1251 | return; |
---|
| 1252 | } |
---|
[1506] | 1253 | if($ls_array[0]['mime_type']) |
---|
| 1254 | { |
---|
| 1255 | $mime_type = $ls_array[0]['mime_type']; |
---|
| 1256 | } |
---|
| 1257 | elseif($this->prefs['viewtextplain']) |
---|
| 1258 | { |
---|
| 1259 | $mime_type = 'text/plain'; |
---|
| 1260 | } |
---|
| 1261 | $viewable = array('','text/plain','text/csv','text/html','text/text'); |
---|
| 1262 | |
---|
[1627] | 1263 | if(in_array($mime_type,$viewable)) |
---|
[1506] | 1264 | { |
---|
[1693] | 1265 | /*Note: if you put application/octet-stream you force download */ |
---|
[1627] | 1266 | header('Content-type: ' . $mime_type); |
---|
[1506] | 1267 | header('Content-disposition: filename="' . $this->file . '"');//FIXME |
---|
| 1268 | Header("Pragma: public"); |
---|
| 1269 | } |
---|
| 1270 | else |
---|
| 1271 | { |
---|
| 1272 | $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME |
---|
| 1273 | } |
---|
[1693] | 1274 | |
---|
| 1275 | |
---|
[1506] | 1276 | echo $this->bo->vfs->read(array( |
---|
| 1277 | 'string' => $this->path.'/'.$this->file,//FIXME |
---|
| 1278 | 'relatives' => array(RELATIVE_NONE) |
---|
| 1279 | )); |
---|
| 1280 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1281 | } |
---|
| 1282 | } |
---|
| 1283 | |
---|
[1575] | 1284 | function export(){ |
---|
| 1285 | if($this->file) |
---|
| 1286 | { |
---|
| 1287 | $ls_array = $this->bo->vfs->ls(array( |
---|
| 1288 | 'string' => $this->path.'/'.$this->file, |
---|
| 1289 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1290 | 'checksubdirs' => False, |
---|
| 1291 | 'nofiles' => True |
---|
| 1292 | )); |
---|
[1627] | 1293 | /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); |
---|
[1575] | 1294 | if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); |
---|
| 1295 | { |
---|
[1627] | 1296 | // recently than last minute: someone is editing |
---|
| 1297 | }*/ |
---|
[1575] | 1298 | $mime_type = $ls_array[0]['mime_type']; |
---|
| 1299 | $formats = array('text/html'); |
---|
| 1300 | if(!in_array($mime_type,$formats)){ |
---|
| 1301 | echo lang('Impossbile to export this file'); |
---|
| 1302 | return False; |
---|
| 1303 | } |
---|
| 1304 | $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file, |
---|
| 1305 | 'relatives' => array(RELATIVE_NONE) |
---|
| 1306 | )); |
---|
| 1307 | |
---|
| 1308 | include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); |
---|
| 1309 | $dompdf = new DOMPDF(); |
---|
| 1310 | $dompdf->load_html($content); |
---|
[1592] | 1311 | $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); |
---|
| 1312 | /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate'*/ |
---|
[1575] | 1313 | $dompdf->render(); |
---|
| 1314 | $dompdf->stream(strtok($this->file,'.').".pdf"); |
---|
| 1315 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
| 1316 | } |
---|
| 1317 | } |
---|
[1506] | 1318 | |
---|
| 1319 | //give back an array with all directories except current and dirs that are not accessable |
---|
| 1320 | function all_other_directories_options() |
---|
| 1321 | { |
---|
| 1322 | # First we get the directories in their home directory |
---|
| 1323 | $dirs = array(); |
---|
| 1324 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); |
---|
| 1325 | |
---|
| 1326 | $tmp_arr=array( |
---|
| 1327 | 'string' => $this->bo->homedir, |
---|
| 1328 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1329 | 'checksubdirs' => True, |
---|
| 1330 | 'mime_type' => 'Directory' |
---|
| 1331 | ); |
---|
| 1332 | |
---|
| 1333 | $ls_array = $this->bo->vfs->ls($tmp_arr); |
---|
| 1334 | |
---|
| 1335 | while(list($num, $dir) = each($ls_array)) |
---|
| 1336 | { |
---|
| 1337 | $dirs[] = $dir; |
---|
| 1338 | } |
---|
| 1339 | |
---|
| 1340 | |
---|
| 1341 | # Then we get the directories in their readable groups' home directories |
---|
| 1342 | reset($this->readable_groups); |
---|
| 1343 | while(list($num, $group_array) = each($this->readable_groups)) |
---|
| 1344 | { |
---|
[1524] | 1345 | /* Don't list directories for groups that don't have access |
---|
[1506] | 1346 | if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) |
---|
| 1347 | { |
---|
[1524] | 1348 | ] continue; |
---|
| 1349 | }*/ |
---|
[1506] | 1350 | |
---|
| 1351 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); |
---|
| 1352 | |
---|
| 1353 | $tmp_arr=array( |
---|
| 1354 | 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], |
---|
| 1355 | 'relatives' => array(RELATIVE_NONE), |
---|
| 1356 | 'checksubdirs' => True, |
---|
| 1357 | 'mime_type' => 'Directory' |
---|
| 1358 | ); |
---|
| 1359 | |
---|
| 1360 | $ls_array = $this->bo->vfs->ls($tmp_arr); |
---|
| 1361 | while(list($num, $dir) = each($ls_array)) |
---|
| 1362 | { |
---|
| 1363 | $dirs[] = $dir; |
---|
| 1364 | } |
---|
| 1365 | } |
---|
| 1366 | reset($dirs); |
---|
| 1367 | while(list($num, $dir) = each($dirs)) |
---|
| 1368 | { |
---|
| 1369 | if(!$dir['directory']) |
---|
| 1370 | { |
---|
| 1371 | continue; |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | # So we don't display // |
---|
| 1375 | if($dir['directory'] != '/') |
---|
| 1376 | { |
---|
| 1377 | $dir['directory'] .= '/'; |
---|
| 1378 | } |
---|
[1704] | 1379 | $return[] = $dir; |
---|
[1506] | 1380 | } |
---|
[1704] | 1381 | return $return; |
---|
[1506] | 1382 | } |
---|
| 1383 | |
---|
| 1384 | /* seek icon for mimetype else return an unknown icon */ |
---|
| 1385 | function mime_icon($mime_type, $size=16) |
---|
| 1386 | { |
---|
| 1387 | if(!$mime_type) $mime_type='unknown'; |
---|
| 1388 | |
---|
[1575] | 1389 | $mime_type=str_replace ('/','_',$mime_type); |
---|
[1506] | 1390 | |
---|
| 1391 | $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); |
---|
| 1392 | if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); |
---|
| 1393 | |
---|
[1719] | 1394 | return $img; |
---|
[1506] | 1395 | } |
---|
| 1396 | |
---|
[1704] | 1397 | function toolButton($link,$img='',$description='') |
---|
[1506] | 1398 | { |
---|
| 1399 | $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); |
---|
| 1400 | |
---|
| 1401 | if($img) |
---|
| 1402 | { |
---|
[1704] | 1403 | return '<span name="'.$link.'" class="toolButton" onclick="toolbar_control(\''.$link.'\');" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/></a><small>'.$description.'</small></span>'; |
---|
[1506] | 1404 | } |
---|
| 1405 | } |
---|
| 1406 | |
---|
[1654] | 1407 | function inputButton($name,$img='',$description='') |
---|
| 1408 | { |
---|
| 1409 | $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); |
---|
| 1410 | |
---|
| 1411 | if($img) |
---|
| 1412 | { |
---|
| 1413 | return '<td class="" align="center" valign="middle" height="28" width="70"> |
---|
| 1414 | <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small> |
---|
| 1415 | </td>'; |
---|
| 1416 | } |
---|
| 1417 | } |
---|
[1506] | 1418 | |
---|
| 1419 | |
---|
| 1420 | function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) |
---|
| 1421 | { |
---|
| 1422 | $text = ' '; |
---|
| 1423 | if($type != NULL && $type) |
---|
| 1424 | { |
---|
| 1425 | if($type == 'checkbox') |
---|
| 1426 | { |
---|
| 1427 | $value = $this->bo->string_encode($value, 1); |
---|
| 1428 | } |
---|
| 1429 | $text .= 'type="'.$type.'" '; |
---|
| 1430 | } |
---|
| 1431 | if($name != NULL && $name) |
---|
| 1432 | { |
---|
| 1433 | $text .= 'name="'.$name.'" '; |
---|
| 1434 | } |
---|
| 1435 | if($value != NULL && $value) |
---|
| 1436 | { |
---|
| 1437 | $text .= 'value="'.$value.'" '; |
---|
| 1438 | } |
---|
| 1439 | if(is_int($maxlength) && $maxlength >= 0) |
---|
| 1440 | { |
---|
| 1441 | $text .= 'maxlength="'.$maxlength.'" '; |
---|
| 1442 | } |
---|
| 1443 | if(is_int($size) && $size >= 0) |
---|
| 1444 | { |
---|
| 1445 | $text .= 'size="'.$size.'" '; |
---|
| 1446 | } |
---|
| 1447 | if($checked != NULL && $checked) |
---|
| 1448 | { |
---|
| 1449 | $text .= 'checked '; |
---|
| 1450 | } |
---|
| 1451 | |
---|
| 1452 | return '<input'.$text.$string.'>'; |
---|
| 1453 | } |
---|
| 1454 | |
---|
| 1455 | function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) |
---|
| 1456 | { |
---|
| 1457 | $text = ' '; |
---|
| 1458 | if($value != NULL && $value) |
---|
| 1459 | { |
---|
| 1460 | $text .= ' value="'.$value.'" '; |
---|
| 1461 | } |
---|
| 1462 | if($selected != NULL && $selected) |
---|
| 1463 | { |
---|
| 1464 | $text .= ' selected'; |
---|
| 1465 | } |
---|
| 1466 | return '<option'.$text.'>'.$displayed.'</option>'; |
---|
| 1467 | } |
---|
| 1468 | |
---|
| 1469 | function encode_href($href = NULL, $args = NULL , $extra_args) |
---|
| 1470 | { |
---|
| 1471 | $href = $this->bo->string_encode($href, 1); |
---|
| 1472 | $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); |
---|
| 1473 | |
---|
| 1474 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
| 1475 | |
---|
| 1476 | return $address; |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) |
---|
| 1480 | { |
---|
| 1481 | // unset($encode); |
---|
| 1482 | if($encode) |
---|
| 1483 | { |
---|
| 1484 | $href = $this->bo->string_encode($href, 1); |
---|
| 1485 | $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); |
---|
| 1486 | } |
---|
| 1487 | else |
---|
| 1488 | { |
---|
| 1489 | // $href = $this->bo->string_encode($href, 1); |
---|
| 1490 | $all_args = $args.'&'.$extra_args; |
---|
| 1491 | } |
---|
| 1492 | ### |
---|
| 1493 | # This decodes / back to normal |
---|
| 1494 | ### |
---|
| 1495 | // $all_args = preg_replace("/%2F/", "/", $all_args); |
---|
| 1496 | // $href = preg_replace("/%2F/", "/", $href); |
---|
| 1497 | |
---|
| 1498 | /* Auto-detect and don't disturb absolute links */ |
---|
| 1499 | if(!preg_match("|^http(.{0,1})://|", $href)) |
---|
| 1500 | { |
---|
| 1501 | //Only add an extra / if there isn't already one there |
---|
| 1502 | |
---|
| 1503 | // die(SEP); |
---|
| 1504 | if(!($href[0] == SEP)) |
---|
| 1505 | { |
---|
| 1506 | $href = SEP . $href; |
---|
| 1507 | } |
---|
| 1508 | |
---|
| 1509 | /* $phpgw->link requires that the extra vars be passed separately */ |
---|
| 1510 | // $link_parts = explode("?", $href); |
---|
| 1511 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
| 1512 | // $address = $GLOBALS['phpgw']->link($href); |
---|
| 1513 | } |
---|
| 1514 | else |
---|
| 1515 | { |
---|
| 1516 | $address = $href; |
---|
| 1517 | } |
---|
| 1518 | |
---|
| 1519 | /* If $linkonly is set, don't add any HTML */ |
---|
| 1520 | if($linkonly) |
---|
| 1521 | { |
---|
| 1522 | $rstring = $address; |
---|
| 1523 | } |
---|
| 1524 | else |
---|
| 1525 | { |
---|
| 1526 | if($target) |
---|
| 1527 | { |
---|
| 1528 | $target = 'target='.$target; |
---|
| 1529 | } |
---|
| 1530 | |
---|
| 1531 | $text = trim($text); |
---|
| 1532 | $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>'; |
---|
| 1533 | } |
---|
| 1534 | |
---|
| 1535 | return($this->bo->eor($rstring, $return)); |
---|
| 1536 | } |
---|
| 1537 | |
---|
| 1538 | function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) |
---|
| 1539 | { |
---|
| 1540 | if($width != NULL && $width) |
---|
| 1541 | { |
---|
| 1542 | $width = "width=$width"; |
---|
| 1543 | } |
---|
| 1544 | if(is_int($border) && $border >= 0) |
---|
| 1545 | { |
---|
| 1546 | $border = "border=$border"; |
---|
| 1547 | } |
---|
| 1548 | if(is_int($cellspacing) && $cellspacing >= 0) |
---|
| 1549 | { |
---|
| 1550 | $cellspacing = "cellspacing=$cellspacing"; |
---|
| 1551 | } |
---|
| 1552 | if(is_int($cellpadding) && $cellpadding >= 0) |
---|
| 1553 | { |
---|
| 1554 | $cellpadding = "cellpadding=$cellpadding"; |
---|
| 1555 | } |
---|
| 1556 | if($rules != NULL && $rules) |
---|
| 1557 | { |
---|
| 1558 | $rules = "rules=$rules"; |
---|
| 1559 | } |
---|
| 1560 | |
---|
| 1561 | $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>"; |
---|
| 1562 | return($this->bo->eor($rstring, $return)); |
---|
| 1563 | } |
---|
| 1564 | |
---|
| 1565 | function html_table_end($return = 0) |
---|
| 1566 | { |
---|
| 1567 | $rstring = "</table>"; |
---|
| 1568 | return($this->bo->eor($rstring, $return)); |
---|
| 1569 | } |
---|
| 1570 | |
---|
| 1571 | function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) |
---|
| 1572 | { |
---|
| 1573 | if($align != NULL && $align) |
---|
| 1574 | { |
---|
| 1575 | $align = "align=$align"; |
---|
| 1576 | } |
---|
| 1577 | if($halign != NULL && $halign) |
---|
| 1578 | { |
---|
| 1579 | $halign = "halign=$halign"; |
---|
| 1580 | } |
---|
| 1581 | if($valign != NULL && $valign) |
---|
| 1582 | { |
---|
| 1583 | $valign = "valign=$valign"; |
---|
| 1584 | } |
---|
| 1585 | if($bgcolor != NULL && $bgcolor) |
---|
| 1586 | { |
---|
| 1587 | $bgcolor = "bgcolor=$bgcolor"; |
---|
| 1588 | } |
---|
| 1589 | $rstring = "<tr $align $halign $valign $bgcolor $string>"; |
---|
| 1590 | return($this->bo->eor($rstring, $return)); |
---|
| 1591 | } |
---|
| 1592 | |
---|
| 1593 | function html_table_row_end($return = 0) |
---|
| 1594 | { |
---|
| 1595 | $rstring = "</tr>"; |
---|
| 1596 | return($this->bo->eor($rstring, $return)); |
---|
| 1597 | } |
---|
| 1598 | |
---|
| 1599 | function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) |
---|
| 1600 | { |
---|
| 1601 | if($align != NULL && $align) |
---|
| 1602 | { |
---|
| 1603 | $align = "align=$align"; |
---|
| 1604 | } |
---|
| 1605 | if($halign != NULL && $halign) |
---|
| 1606 | { |
---|
| 1607 | $halign = "halign=$halign"; |
---|
| 1608 | } |
---|
| 1609 | if($valign != NULL && $valign) |
---|
| 1610 | { |
---|
| 1611 | $valign = "valign=$valign"; |
---|
| 1612 | } |
---|
| 1613 | if(is_int($rowspan) && $rowspan >= 0) |
---|
| 1614 | { |
---|
| 1615 | $rowspan = "rowspan=$rowspan"; |
---|
| 1616 | } |
---|
| 1617 | if(is_int($colspan) && $colspan >= 0) |
---|
| 1618 | { |
---|
| 1619 | $colspan = "colspan=$colspan"; |
---|
| 1620 | } |
---|
| 1621 | |
---|
| 1622 | $rstring = "<td $align $halign $valign $rowspan $colspan $string>"; |
---|
| 1623 | return($this->bo->eor($rstring, $return)); |
---|
| 1624 | } |
---|
| 1625 | |
---|
| 1626 | function html_table_col_end($return = 0) |
---|
| 1627 | { |
---|
| 1628 | $rstring = "</td>"; |
---|
| 1629 | return($this->bo->eor($rstring, $return)); |
---|
| 1630 | } |
---|
| 1631 | } |
---|