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