2003-10-24 22:33:34 +02:00
< ? php
2005-10-14 12:41:15 +02:00
/************************************************************************** \
* eGroupWare - Filemanager *
* http :// www . egroupware . org *
* ------------------------------------------------------------------------ *
* This program is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation ; either version 2 of the License , or ( at your *
* option ) any later version . *
\ **************************************************************************/
/* $Id$ */
2007-07-19 18:13:53 +02:00
require_once ( EGW_INCLUDE_ROOT . '/filemanager/inc/class.bofilemanager.inc.php' );
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
class uifilemanager extends bofilemanager
2003-10-24 22:33:34 +02:00
{
var $public_functions = array (
2005-09-14 03:58:20 +02:00
'index' => True ,
'help' => True ,
2003-11-22 04:05:00 +01:00
'view' => True ,
'history' => True ,
2005-09-14 03:58:20 +02:00
'edit' => True ,
2007-07-19 18:13:53 +02:00
'download' => True ,
'search_tpl' => True ,
2003-10-24 22:33:34 +02:00
);
2003-11-22 04:05:00 +01:00
//keep
2003-10-24 22:33:34 +02:00
var $bo ;
2007-07-19 18:13:53 +02:00
var $t ;
//template object
/**
* instantiation of the etemplate as classenvariable
*
* @ var etemplate
*/
var $tmpl ;
var $search_options ;
var $disppath ;
2003-11-22 04:05:00 +01:00
var $cwd ;
var $lesspath ;
var $readable_groups ;
2004-02-21 14:56:18 +01:00
var $files_array ;
2007-03-19 10:51:34 +01:00
var $dirs_options ;
2003-11-22 04:05:00 +01:00
var $numoffiles ;
var $dispsep ;
var $target ;
2003-12-09 00:18:34 +01:00
2003-11-22 04:05:00 +01:00
var $prefs ; //array
2003-12-09 00:18:34 +01:00
var $groups_applications ;
2003-11-22 04:05:00 +01:00
//originally post_vars
2003-12-09 00:18:34 +01:00
// var $goto;
var $goto_x ;
var $download_x ;
2003-11-22 04:05:00 +01:00
var $todir ;
2003-12-09 00:18:34 +01:00
var $changedir ; // for switching dir.
var $cdtodir ; // for switching dir.
2004-03-02 01:39:52 +01:00
// var $createdir;
2003-11-22 04:05:00 +01:00
var $newfile_or_dir ;
2003-12-09 00:18:34 +01:00
var $newdir_x ;
var $newfile_x ;
2004-03-02 01:39:52 +01:00
var $createfile_var ;
2003-12-09 00:18:34 +01:00
var $delete_x ;
2003-11-22 04:05:00 +01:00
var $renamefiles ;
2003-12-09 00:18:34 +01:00
var $rename_x ;
var $move_to_x ;
// var $copy_to;
var $copy_to_x ;
var $edit_x ;
var $edit_comments_x ;
2003-11-22 04:05:00 +01:00
var $edit_file ;
2003-12-09 00:18:34 +01:00
var $edit_preview_x ;
var $edit_save_x ;
var $edit_save_done_x ;
var $edit_cancel_x ;
2003-11-22 04:05:00 +01:00
var $comment_files ;
2003-12-09 00:18:34 +01:00
var $upload_x ;
2003-11-22 04:05:00 +01:00
var $uploadprocess ;
// this ones must be checked thorougly;
2004-03-02 01:39:52 +01:00
var $fileman = Array ();
//var $fileman;
2003-11-22 04:05:00 +01:00
var $path ;
2004-03-02 01:39:52 +01:00
var $file ; // FIXME WHERE IS THIS FILLED?
2003-11-22 04:05:00 +01:00
var $sortby ;
2004-03-02 01:39:52 +01:00
var $messages = array ();
2003-11-22 04:05:00 +01:00
var $show_upload_boxes ;
2007-07-19 18:13:53 +02:00
//var $debug = false;
2003-11-22 04:05:00 +01:00
var $debug = false ;
var $now ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
function uifilemanager ()
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
// discarded becouse of class extension
//$this->bo =& CreateObject('filemanager.bofilemanager');
$this -> bofilemanager ();
//KL begin 200703 searchtemplate
// etemplate stuff
$this -> tmpl =& CreateObject ( 'etemplate.etemplate' );
$this -> html =& $GLOBALS [ 'egw' ] -> html ;
// this may be needed using etemplates
if ( !@ is_object ( $GLOBALS [ 'egw' ] -> js ))
{
$GLOBALS [ 'egw' ] -> js =& CreateObject ( 'phpgwapi.javascript' );
}
//KL end 200703 searchtemplate
2004-02-21 14:56:18 +01:00
// error_reporting(8);
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> browser =& CreateObject ( 'phpgwapi.browser' );
2006-12-14 18:17:42 +01:00
2006-09-17 01:05:31 +02:00
$this -> dateformat = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ];
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
//$this->now = date($this->dateformat);
2004-02-21 14:56:18 +01:00
$this -> now = date ( 'Y-m-d' );
2007-07-19 18:13:53 +02:00
2005-09-14 03:58:20 +02:00
$this -> t = $GLOBALS [ 'egw' ] -> template ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
// here local vars are created from the HTTP vars
2005-10-14 12:41:15 +02:00
@ reset ( $_POST );
while ( list ( $name ,) = @ each ( $_POST ))
2003-10-24 22:33:34 +02:00
{
2005-10-14 12:41:15 +02:00
$this -> $name = $_POST [ $name ];
2003-10-24 22:33:34 +02:00
}
2003-12-09 00:18:34 +01:00
2005-10-14 12:41:15 +02:00
@ reset ( $_GET );
while ( list ( $name ,) = @ each ( $_GET ))
2003-10-24 22:33:34 +02:00
{
2005-10-14 12:41:15 +02:00
$$name = $_GET [ $name ];
2003-10-24 22:33:34 +02:00
}
$to_decode = array
(
/*
Decode
'var' when 'avar' == 'value'
or
'var' when 'var' is set
*/
2004-02-21 14:56:18 +01:00
'op' => array ( 'op' => '' ),
'path' => array ( 'path' => '' ),
'file' => array ( 'file' => '' ),
'sortby' => array ( 'sortby' => '' ),
// 'fileman' => array('fileman' => ''),
'messages' => array ( 'messages' => '' ),
// 'help_name' => array('help_name' => ''),
// 'renamefiles' => array('renamefiles' => ''),
'comment_files' => array ( 'comment_files' => '' ),
'show_upload_boxes' => array ( 'show_upload_boxes' => '' )
2003-10-24 22:33:34 +02:00
);
2004-02-21 14:56:18 +01:00
reset ( $to_decode );
while ( list ( $var , $conditions ) = each ( $to_decode ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
while ( list ( $condvar , $condvalue ) = each ( $conditions ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( isset ( $$condvar ) && ( $condvar == $var || $$condvar == $condvalue ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( is_array ( $$var ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
$temp = array ();
while ( list ( $varkey , $varvalue ) = each ( $$var ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( is_int ( $varkey ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
$temp [ $varkey ] = stripslashes ( base64_decode ( urldecode (( $varvalue ))));
2003-10-24 22:33:34 +02:00
}
else
{
2004-02-21 14:56:18 +01:00
$temp [ stripslashes ( base64_decode ( urldecode (( $varkey ))))] = $varvalue ;
2003-10-24 22:33:34 +02:00
}
}
2003-11-22 04:05:00 +01:00
$this -> $var = $temp ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
elseif ( isset ( $$var ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
$this -> $var = stripslashes ( base64_decode ( urldecode ( $$var )));
2003-10-24 22:33:34 +02:00
}
}
}
}
2004-02-21 14:56:18 +01:00
// get appl. and user prefs
2007-07-19 18:13:53 +02:00
$pref =& CreateObject ( 'phpgwapi.preferences' , $this -> userinfo [ 'username' ]);
2004-02-21 14:56:18 +01:00
$pref -> read_repository ();
2005-09-14 03:58:20 +02:00
// $GLOBALS['egw']->hooks->single('add_def_pref', $GLOBALS['appname']);
2004-02-21 14:56:18 +01:00
$pref -> save_repository ( True );
$pref_array = $pref -> read_repository ();
2007-07-19 18:13:53 +02:00
$this -> prefs = $pref_array [ $this -> appname ]; //FIXME check appname var in _debug_array
2003-12-09 00:18:34 +01:00
2003-11-22 04:05:00 +01:00
//always show name
2003-12-09 00:18:34 +01:00
2005-09-14 03:58:20 +02:00
$this -> prefs [ 'name' ] = 1 ;
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'viewinnewwin' ])
2003-11-22 04:05:00 +01:00
{
$this -> target = '_blank' ;
}
2004-03-02 01:39:52 +01:00
/*
Check for essential directories
admin must be able to disable these tests
*/
2005-09-14 03:58:20 +02:00
// check if basedir exist
2007-07-19 18:13:53 +02:00
$test = $this -> vfs -> get_real_info ( array ( 'string' => $this -> basedir , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2005-09-14 03:58:20 +02:00
if ( $test [ 'mime_type' ] != 'Directory' )
2004-03-02 01:39:52 +01:00
{
die ( 'Base directory does not exist, Ask adminstrator to check the global configuration.' );
}
2007-07-19 18:13:53 +02:00
$test = $this -> vfs -> get_real_info ( array ( 'string' => $this -> basedir . $this -> fakebase , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2005-09-14 03:58:20 +02:00
if ( $test [ 'mime_type' ] != 'Directory' )
2004-03-02 01:39:52 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 1 ;
2004-03-02 01:39:52 +01:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> mkdir ( array (
'string' => $this -> fakebase ,
2004-03-02 01:39:52 +01:00
'relatives' => array ( RELATIVE_NONE )
));
2005-09-14 03:58:20 +02:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 0 ;
2004-03-02 01:39:52 +01:00
//test one more time
2007-07-19 18:13:53 +02:00
$test = $this -> vfs -> get_real_info ( array ( 'string' => $this -> basedir . $this -> fakebase , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2004-03-02 01:39:52 +01:00
2005-09-14 03:58:20 +02:00
if ( $test [ 'mime_type' ] != 'Directory' )
2004-03-02 01:39:52 +01:00
{
2004-12-12 07:34:04 +01:00
die ( 'Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.' );
2004-03-02 01:39:52 +01:00
}
else
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array (
2004-03-02 01:39:52 +01:00
lang ( 'Fake Base Dir did not exist, eGroupWare created a new one.' )
));
}
}
2007-07-19 18:13:53 +02:00
// die($this->homedir);
$test = $this -> vfs -> get_real_info ( array ( 'string' => $this -> basedir . $this -> homedir , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2005-09-14 03:58:20 +02:00
if ( $test [ 'mime_type' ] != 'Directory' )
2004-03-02 01:39:52 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 1 ;
2004-03-02 01:39:52 +01:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> mkdir ( array (
'string' => $this -> homedir ,
2004-03-02 01:39:52 +01:00
'relatives' => array ( RELATIVE_NONE )
));
2005-09-14 03:58:20 +02:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 0 ;
2004-03-02 01:39:52 +01:00
//test one more time
2007-07-19 18:13:53 +02:00
$test = $this -> vfs -> get_real_info ( array ( 'string' => $this -> basedir . $this -> homedir , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2004-03-02 01:39:52 +01:00
2005-09-14 03:58:20 +02:00
if ( $test [ 'mime_type' ] != 'Directory' )
2004-03-02 01:39:52 +01:00
{
die ( 'Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.' );
}
else
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array (
2004-03-02 01:39:52 +01:00
lang ( 'Your Home Dir did not exist, eGroupWare created a new one.' )
));
// FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content
}
}
2007-07-19 18:13:53 +02:00
$GLOBALS [ 'uifilemanager' ] =& $this ; // make ourself available for ExecMethod of get_rows function
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
}
2003-11-22 04:05:00 +01:00
function index ()
{
2007-07-19 18:13:53 +02:00
//echo "<p>call index</p>";
if ( $_GET [ 'action' ] == 'search' )
{
$this -> search_tpl ();
}
else
{
$this -> index_2 ();
}
}
function index_2 ()
{
//echo "<p>call index_2</p>";
//_debug_array($this->tmpl);
$sessiondata = $this -> read_sessiondata ();
2004-02-21 14:56:18 +01:00
if ( $noheader || $nofooter || ( $this -> download_x && ( count ( $this -> fileman ) > 0 )))
2003-10-24 22:33:34 +02:00
{
$noheader = True ;
$nofooter = True ;
2003-11-22 04:05:00 +01:00
$noappheader = True ;
2004-03-02 01:39:52 +01:00
$nonavbar = True ;
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
else
{
2005-09-14 03:58:20 +02:00
$GLOBALS [ 'egw_info' ][ 'flags' ] = array
2003-11-22 04:05:00 +01:00
(
'currentapp' => 'filemanager' ,
'noheader' => $noheader ,
'nonavbar' => $nonavbar ,
'nofooter' => $nofooter ,
'noappheader' => $noappheader ,
'enable_browser_class' => True
);
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_header ();
2003-10-24 22:33:34 +02:00
}
# Page to process users
# Code is fairly hackish at the beginning, but it gets better
# Highly suggest turning wrapping off due to long SQL queries
###
# Some hacks to set and display directory paths correctly
###
2003-12-09 00:18:34 +01:00
/*
2004-02-21 14:56:18 +01:00
if ( $this -> goto || $this -> goto_x )
2003-12-09 00:18:34 +01:00
{
$this -> path = $this -> cdtodir ;
}
*/
// new method for switching to a new dir.
if ( $this -> changedir == 'true' && $this -> cdtodir || $this -> goto_x )
2003-10-24 22:33:34 +02:00
{
2003-12-09 00:18:34 +01:00
$this -> path = $this -> cdtodir ;
2003-10-24 22:33:34 +02:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
if ( ! $this -> path )
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
$this -> path = $this -> vfs -> pwd ();
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( ! $this -> path || $this -> vfs -> pwd ( array ( 'full' => False )) == '' )
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
$this -> path = $this -> homedir ;
2003-10-24 22:33:34 +02:00
}
}
2007-07-19 18:13:53 +02:00
$this -> vfs -> cd ( array ( 'string' => False , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
$this -> vfs -> cd ( array ( 'string' => $this -> path , 'relatives' => array ( RELATIVE_NONE ), 'relative' => False ));
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$pwd = $this -> vfs -> pwd ();
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( ! $this -> cwd = substr ( $this -> path , strlen ( $this -> homedir ) + 1 ))
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> cwd = '/' ;
2003-10-24 22:33:34 +02:00
}
else
{
2004-02-21 14:56:18 +01:00
$this -> cwd = substr ( $pwd , strrpos ( $pwd , '/' ) + 1 );
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
$this -> disppath = $this -> path ;
2007-07-19 18:13:53 +02:00
$sessiondata [ 'workingdir' ] = " $this->disppath " ;
2003-10-24 22:33:34 +02:00
/* This just prevents // in some cases */
2004-02-21 14:56:18 +01:00
if ( $this -> path == '/' )
{
$this -> dispsep = '' ;
}
2003-10-24 22:33:34 +02:00
else
2004-02-21 14:56:18 +01:00
{
$this -> dispsep = '/' ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( ! ( $this -> lesspath = substr ( $this -> path , 0 , strrpos ( $this -> path , '/' ))))
{
$this -> lesspath = '/' ;
}
2007-07-19 18:13:53 +02:00
//echo "<p>#$this->path#</p>";
2003-10-24 22:33:34 +02:00
# Get their readable groups to be used throughout the script
2003-11-22 04:05:00 +01:00
$groups = array ();
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$groups = $GLOBALS [ 'egw' ] -> accounts -> get_list ( 'groups' );
2007-07-19 18:13:53 +02:00
$this -> readable_groups = Array ();
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
while ( list ( $num , $account ) = each ( $groups ))
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> acl_check ( array ( 'owner_id' => $account [ 'account_id' ], 'operation' => EGW_ACL_READ )))
2003-11-22 04:05:00 +01:00
{
$this -> readable_groups [ $account [ 'account_lid' ]] = Array ( 'account_id' => $account [ 'account_id' ], 'account_name' => $account [ 'account_lid' ]);
}
2003-10-24 22:33:34 +02:00
}
2007-07-19 18:13:53 +02:00
$sessiondata [ 'readable_groups' ] = $this -> readable_groups ;
2004-02-21 14:56:18 +01:00
$this -> groups_applications = array ();
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
while ( list ( $num , $group_array ) = each ( $this -> readable_groups ))
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$group_id = $GLOBALS [ 'egw' ] -> accounts -> name2id ( $group_array [ 'account_name' ]);
2003-10-24 22:33:34 +02:00
2005-10-14 12:41:15 +02:00
$applications =& CreateObject ( 'phpgwapi.applications' , $group_id );
2004-02-21 14:56:18 +01:00
$this -> groups_applications [ $group_array [ 'account_name' ]] = $applications -> read_account_specific ();
2003-11-22 04:05:00 +01:00
}
2007-07-19 18:13:53 +02:00
$sessiondata [ 'groups_applications' ] = $this -> groups_applications ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# We determine if they're in their home directory or a group's directory,
# and set the VFS working_id appropriately
2007-07-19 18:13:53 +02:00
if (( preg_match ( '+^' . $this -> fakebase . '\/(.*)(\/|$)+U' , $this -> path , $matches )) && $matches [ 1 ] != $this -> userinfo [ 'account_lid' ]) //FIXME matches not defined
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> working_id = $GLOBALS [ 'egw' ] -> accounts -> name2id ( $matches [ 1 ]); //FIXME matches not defined
2003-11-22 04:05:00 +01:00
}
else
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> working_id = $this -> userinfo [ 'username' ];
2003-11-22 04:05:00 +01:00
}
2007-07-19 18:13:53 +02:00
$this -> save_sessiondata ( $sessiondata );
2003-12-09 00:18:34 +01:00
2007-07-19 18:13:53 +02:00
# FIXME # comment what happens here
if ( $this -> path != $this -> homedir && $this -> path != $this -> fakebase && $this -> path != '/' && ! $this -> vfs -> acl_check ( array ( 'string' => $this -> path , 'relatives' => array ( RELATIVE_NONE ), 'operation' => EGW_ACL_READ )))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
echo " <p>died for some reasons</p> " ;
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'You do not have access to %1' , $this -> path )));
2004-03-02 01:39:52 +01:00
$this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> homedir , lang ( 'Go to your home directory' ));
2003-10-24 22:33:34 +02:00
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_footer ();
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2003-11-22 04:05:00 +01:00
}
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$this -> userinfo [ 'working_id' ] = $this -> vfs -> working_id ;
$this -> userinfo [ 'working_lid' ] = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $this -> userinfo [ 'working_id' ]);
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# If their home directory doesn't exist, we try to create it
# Same for group directories
2004-03-02 01:39:52 +01:00
2005-09-14 03:58:20 +02:00
2007-07-19 18:13:53 +02:00
// Moved to constructor
/*
if (( $this -> path == $this -> homedir ) && ! $this -> vfs -> file_exists ( $pim_tmp_arr ))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 1 ;
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( ! $this -> vfs -> mkdir ( array (
'string' => $this -> homedir ,
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_NONE )
2003-11-22 04:05:00 +01:00
)))
{
2007-07-19 18:13:53 +02:00
$p = $this -> vfs -> path_parts ( $pim_tmp_arr );
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array (
2004-02-21 14:56:18 +01:00
lang ( 'Could not create directory %1' ,
2007-07-19 18:13:53 +02:00
$this -> homedir . ' (' . $p -> real_full_path . ')'
2003-11-22 04:05:00 +01:00
)));
}
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 0 ;
2003-11-22 04:05:00 +01:00
}
2004-03-02 01:39:52 +01:00
*/
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Verify path is real
2007-07-19 18:13:53 +02:00
if ( $this -> path != $this -> homedir && $this -> path != '/' && $this -> path != $this -> fakebase )
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
if ( ! $this -> vfs -> file_exists ( array (
2003-11-22 04:05:00 +01:00
'string' => $this -> path ,
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_NONE )
2003-11-22 04:05:00 +01:00
)))
{
2007-07-19 18:13:53 +02:00
echo " <p>died for some other reasons</p> " ;
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Directory %1 does not exist' , $this -> path )));
2007-07-19 18:13:53 +02:00
$this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> homedir , lang ( 'Go to your home directory' ));
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_footer ();
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2003-11-22 04:05:00 +01:00
}
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
/* Update if they request it, or one out of 20 page loads */
2004-02-21 14:56:18 +01:00
srand (( double ) microtime () * 1000000 );
2004-12-06 15:16:11 +01:00
if ( $_GET [ 'update' ] || rand ( 0 , 19 ) == 4 )
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> update_real ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> path ,
'relatives' => array ( RELATIVE_NONE )
2003-11-22 04:05:00 +01:00
));
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
# Check available permissions for $this->path, so we can disable unusable operations in user interface
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> acl_check ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> path ,
'relatives' => array ( RELATIVE_NONE ),
2005-09-14 03:58:20 +02:00
'operation' => EGW_ACL_ADD
2003-11-22 04:05:00 +01:00
)))
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> can_add = True ;
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
# Default is to sort by name
2004-02-21 14:56:18 +01:00
if ( ! $this -> sortby )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> sortby = 'name' ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
if ( $this -> debug )
{
$this -> debug_filemanager ();
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# main action switch
// FIXME this will become a switch
2003-12-09 00:18:34 +01:00
if ( $this -> newfile_x && $this -> newfile_or_dir ) // create new textfile
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> createfile ();
}
2003-12-09 00:18:34 +01:00
elseif ( $this -> newfile_or_dir && $this -> newdir_x )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> createdir ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> uploadprocess )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> fileUpload ();
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> upload_x || $this -> show_upload_boxes )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> showUploadboxes ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> copy_to_x )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> copyTo ();
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> move_to_x )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> moveTo ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> download_x )
2003-11-22 04:05:00 +01:00
{
$this -> download ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> renamefiles )
2003-11-22 04:05:00 +01:00
{
$this -> rename ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> comment_files )
2003-11-22 04:05:00 +01:00
{
$this -> editComment ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> edit_cancel_x )
2003-11-22 04:05:00 +01:00
{
$this -> readFilesInfo ();
$this -> fileListing ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> edit_x || $this -> edit_preview_x || $this -> edit_save_x || $this -> edit_save_done_x )
2003-11-22 04:05:00 +01:00
{
$this -> edit ();
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> delete_x )
2003-11-22 04:05:00 +01:00
{
$this -> delete ();
}
else
{
$this -> readFilesInfo ();
$this -> fileListing ();
2003-10-24 22:33:34 +02:00
}
}
2003-11-22 04:05:00 +01:00
function fileListing ()
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$this -> t -> set_file ( array ( 'filemanager_list_t' => 'filelisting.tpl' ));
$this -> t -> set_block ( 'filemanager_list_t' , 'filemanager_header' , 'filemanager_header' );
$this -> t -> set_block ( 'filemanager_list_t' , 'column' , 'column' );
$this -> t -> set_block ( 'filemanager_list_t' , 'row' , 'row' );
$this -> t -> set_block ( 'filemanager_list_t' , 'filemanager_footer' , 'filemanager_footer' );
2004-02-21 14:56:18 +01:00
$vars [ 'form_action' ] = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> path );
if ( $this -> numoffiles || $this -> cwd )
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
while ( list ( $num , $name ) = each ( $this -> prefs ))
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( $name )
2003-11-22 04:05:00 +01:00
{
$columns ++ ;
}
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
$columns ++ ;
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$vars [ 'toolbar0' ] = $this -> toolbar ( 'location' );
$vars [ 'toolbar1' ] = $this -> toolbar ( 'list_nav' );
2004-03-02 01:39:52 +01:00
2005-09-14 03:58:20 +02:00
if ( count ( $this -> messages ) > 0 )
2004-03-02 01:39:52 +01:00
{
foreach ( $this -> messages as $msg )
{
$messages .= '<p>' . $msg . '</p>' ;
}
}
2005-09-14 03:58:20 +02:00
$vars [ 'messages' ] = $messages ;
2003-12-09 00:18:34 +01:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( $vars );
$this -> t -> pparse ( 'out' , 'filemanager_header' );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
###
# Start File Table Column Headers
# Reads values from $file_attributes array and preferences
###
$this -> t -> set_var ( 'actions' , lang ( 'select' ));
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
reset ( $this -> file_attributes );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
if ( $this -> numoffiles > 0 )
{
2007-07-19 18:13:53 +02:00
while ( list ( $internal , $displayed ) = each ( $this -> file_attributes ))
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ $internal ])
2003-11-22 04:05:00 +01:00
{
$col_data = '<span><a href="' . $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> path . '&sortby=' . $internal ) . '">' . $displayed . '</a></span>' ;
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
}
2003-10-24 22:33:34 +02:00
2003-12-09 00:18:34 +01:00
$this -> t -> set_var ( 'row_tr_color' , '#dedede' );
2005-09-14 03:58:20 +02:00
2004-03-02 01:39:52 +01:00
//kan dit weg?
2003-11-22 04:05:00 +01:00
$this -> t -> parse ( 'rows' , 'row' );
2005-09-14 03:58:20 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> pparse ( 'out' , 'row' );
}
else
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$lang_nofiles = lang ( 'No files in this directory.' );
2003-10-24 22:33:34 +02:00
}
2005-09-14 03:58:20 +02:00
$vars [ 'lang_no_files' ] = $lang_nofiles ;
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'dotdot' ] && $this -> prefs [ 'name' ] && $this -> path != '/' )
2003-11-22 04:05:00 +01:00
{
$this -> t -> set_var ( 'actions' , '' );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> lesspath );
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$col_data = '<a href="' . $link . '"><img src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'mime16up' ) . ' "alt="' . lang ( 'Folder Up' ) . '" /></a>' ;
2003-11-22 04:05:00 +01:00
$col_data .= ' <a href="' . $link . '">..</a>' ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'mime_type' ])
2003-11-22 04:05:00 +01:00
{
$col_data = lang ( 'Directory' );
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'row_tr_color' , $tr_color );
$this -> t -> parse ( 'rows' , 'row' );
$this -> t -> pparse ( 'out' , 'row' );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# List all of the files, with their attributes
2004-02-21 14:56:18 +01:00
@ reset ( $this -> files_array );
for ( $i = 0 ; $i != $this -> numoffiles ; $i ++ )
2003-11-22 04:05:00 +01:00
{
$files = $this -> files_array [ $i ];
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> rename_x || $this -> edit_comments_x )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
unset ( $this_selected );
unset ( $renamethis );
unset ( $edit_this_comment );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
for ( $j = 0 ; $j != $this -> numoffiles ; $j ++ )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $this -> fileman [ $j ] == $files [ 'name' ])
2003-11-22 04:05:00 +01:00
{
$this_selected = 1 ;
break ;
}
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> rename_x && $this_selected )
2003-11-22 04:05:00 +01:00
{
$renamethis = 1 ;
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> edit_comments_x && $this_selected )
2003-11-22 04:05:00 +01:00
{
$edit_this_comment = 1 ;
}
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( ! $this -> prefs [ 'dotfiles' ] && ereg ( " ^ \ . " , $files [ 'name' ]))
2003-11-22 04:05:00 +01:00
{
continue ;
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Checkboxes
2007-07-19 18:13:53 +02:00
//if(!$this->rename_x && !$this->edit_comments_x && $this->path != $this->fakebase && $this->path != '/')
if ( ! $this -> rename_x && ! $this -> edit_comments_x && $this -> path != '/' )
2003-11-22 04:05:00 +01:00
{
$cbox = '<input type="checkbox" name="fileman[' . $i . ']" value="' . $files [ 'name' ] . '">' ;
$this -> t -> set_var ( 'actions' , $cbox );
}
2004-02-21 14:56:18 +01:00
elseif ( $renamethis )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$cbox = $this -> html_form_input ( 'hidden' , 'fileman[' . base64_encode ( $files [ 'name' ]) . ']' , $files [ 'name' ], NULL , NULL , 'checked' );
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'actions' , $cbox );
}
else
{
$this -> t -> set_var ( 'actions' , '' );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# File name and icon
2004-02-21 14:56:18 +01:00
if ( $renamethis )
2003-11-22 04:05:00 +01:00
{
$col_data = $this -> mime_icon ( $files [ 'mime_type' ]);
$col_data .= '<input type="text" maxlength="255" name="renamefiles[' . $files [ 'name' ] . ']" value="' . $files [ 'name' ] . '">' ;
}
else
{
2004-02-21 14:56:18 +01:00
if ( $files [ 'mime_type' ] == 'Directory' )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> path . $this -> dispsep . $files [ 'name' ]);
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$icon = $this -> mime_icon ( $files [ 'mime_type' ]);
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$col_data = '<a href="' . $link . '">' . $icon . '</a> ' ;
$col_data .= '<a href="' . $link . '">' . $files [ 'name' ] . '</a> ' ;
}
else
{
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( $this -> prefs [ 'viewonserver' ] && isset ( $this -> filesdir ) && ! $files [ 'link_directory' ])
2003-11-22 04:05:00 +01:00
{
#FIXME
2004-03-02 01:39:52 +01:00
$clickview = $this -> filesdir . $pwd . '/' . $files [ 'name' ];
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $phpwh_debug )
2003-11-22 04:05:00 +01:00
{
echo 'Setting clickview = ' . $clickview . '<br>' . " \n " ;
2004-02-21 14:56:18 +01:00
$this -> html_link ( $clickview , '' , '' , $files [ 'name' ], 0 , 1 , 0 , '' );
2003-11-22 04:05:00 +01:00
}
}
else
{
$icon = $this -> mime_icon ( $files [ 'mime_type' ]);
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.view' , 'file=' . $files [ 'name' ] . '&path=' . $this -> path );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$col_data = '<a href="' . $link . '" target="' . $this -> target . '">' . $icon . '</a> <a href="' . $link . '" target="' . $this -> target . '">' . $files [ 'name' ] . '</a>' ;
}
}
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# MIME type
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'mime_type' ])
2003-11-22 04:05:00 +01:00
{
$col_data = $files [ 'mime_type' ];
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# File size
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'size' ])
2003-11-22 04:05:00 +01:00
{
2006-12-14 18:17:42 +01:00
// KL to fetch the size of the object here is just WRONG, since the array may be already sorted by size
//$tmp_arr=array(
// 'string' => $files['directory'] . '/' . $files['name'],
// 'relatives' => array(RELATIVE_NONE)
//;
//if($files['mime_type'] != 'Directory') $tmp_arr['checksubdirs'] = false;
2007-07-19 18:13:53 +02:00
//$size = $this->vfs->get_size($tmp_arr);
2006-12-14 18:17:42 +01:00
$size = $files [ 'size' ];
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$col_data = $this -> borkb ( $size );
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Date created
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'created' ])
2003-11-22 04:05:00 +01:00
{
2006-09-17 01:05:31 +02:00
$col_data = date ( $this -> dateformat , strtotime ( $files [ 'created' ]));
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Date modified
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'modified' ])
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $files [ 'modified' ] != '0000-00-00' )
{
2006-09-17 01:05:31 +02:00
$col_data = date ( $this -> dateformat , strtotime ( $files [ 'modified' ]));
2004-02-21 14:56:18 +01:00
}
else
{
$col_data = '' ;
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Owner name
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'owner' ])
2003-11-22 04:05:00 +01:00
{
2006-12-14 18:17:42 +01:00
// KL to fetch the name of the object here is just WRONG, since the array may be already sorted by id
//$this->t->set_var('col_data',$GLOBALS['egw']->accounts->id2name($files['owner_id']));
$this -> t -> set_var ( 'col_data' , $files [ 'owner_name' ]);
2003-11-22 04:05:00 +01:00
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Creator name
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'createdby_id' ])
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> html_table_col_begin ();
if ( $files [ 'createdby_id' ])
2003-11-22 04:05:00 +01:00
{
2006-12-14 18:17:42 +01:00
// KL to fetch the name of the object here is just WRONG, since the array may be already sorted by id
//$col_data=$GLOBALS['egw']->accounts->id2name($files['createdby_id']);
$col_data = $files [ 'createdby_name' ];
2003-11-22 04:05:00 +01:00
}
else $col_data = '' ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
# Modified by name
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'modifiedby_id' ])
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( $files [ 'modifiedby_id' ])
2003-10-24 22:33:34 +02:00
{
2006-12-14 18:17:42 +01:00
// KL to fetch the name of the object here is just WRONG, since the array may be already sorted by id
//$col_data=$GLOBALS['egw']->accounts->id2name($files['modifiedby_id']);
$col_data = $files [ 'modifiedby_name' ];
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
else $col_data = '' ;
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
# Application
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'app' ])
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$col_data = $files [ 'app' ];
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
# Comment
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'comment' ])
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $edit_this_comment )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$col_data = '<input type="text" name="comment_files[' . $files [ 'name' ] . ']" value="' . $files [ 'comment' ] . '" maxlength="255">' ;
2003-11-22 04:05:00 +01:00
}
else
{
$col_data = $files [ 'comment' ];
}
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
# Version
2004-02-21 14:56:18 +01:00
if ( $this -> prefs [ 'version' ])
2003-11-22 04:05:00 +01:00
{
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.history' , 'file=' . $files [ 'name' ] . '&path=' . $this -> path );
$col_data = '<a href="' . $link . '" target="_blank">' . $files [ 'version' ] . '</a>' ;
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' , True );
}
2004-02-21 14:56:18 +01:00
if ( $files [ 'mime_type' ] == 'Directory' )
2003-11-22 04:05:00 +01:00
{
$usedspace += $fileinfo [ 0 ];
}
else
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$usedspace += $files [ 'size' ];
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
$this -> t -> set_var ( 'row_tr_color' , '' );
$this -> t -> parse ( 'rows' , 'row' );
$this -> t -> pparse ( 'out' , 'row' );
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
// when renaming or changing comments render extra sumbmit button
2004-02-21 14:56:18 +01:00
if ( $this -> rename_x || $this -> edit_comments_x )
2003-10-24 22:33:34 +02:00
{
2003-11-22 04:05:00 +01:00
$col_data = '<br/><input type="submit" name="save_changes" value="' . lang ( 'Save changes' ) . '">' ;
$this -> t -> set_var ( 'col_data' , $col_data );
$this -> t -> parse ( 'columns' , 'column' );
$this -> t -> set_var ( 'row_tr_color' , '' );
$this -> t -> parse ( 'rows' , 'row' );
$this -> t -> pparse ( 'out' , 'row' );
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
}
// The file and directory information
2005-09-14 03:58:20 +02:00
$vars [ 'lang_files_in_this_dir' ] = lang ( 'Files in this directory' );
$vars [ 'files_in_this_dir' ] = $this -> numoffiles ;
2003-11-22 04:05:00 +01:00
2005-09-14 03:58:20 +02:00
$vars [ 'lang_used_space' ] = lang ( 'Used space' );
2007-07-19 18:13:53 +02:00
$vars [ 'used_space' ] = $this -> borkb ( $usedspace , NULL , 1 );
2003-11-22 04:05:00 +01:00
2007-07-19 18:13:53 +02:00
if ( $this -> path == $this -> homedir || $this -> path == $this -> fakebase )
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$vars [ 'lang_unused_space' ] = lang ( 'Unused space' );
2007-07-19 18:13:53 +02:00
$vars [ 'unused_space' ] = $this -> borkb ( $this -> userinfo [ 'hdspace' ] - $usedspace , NULL , 1 );
2003-11-22 04:05:00 +01:00
2004-02-21 14:56:18 +01:00
$tmp_arr = array (
2003-11-22 04:05:00 +01:00
'string' => $this -> path ,
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_NONE )
2003-11-22 04:05:00 +01:00
);
2007-07-19 18:13:53 +02:00
$ls_array = $this -> vfs -> ls ( $tmp_arr );
2003-11-22 04:05:00 +01:00
2005-09-14 03:58:20 +02:00
$vars [ 'lang_total_files' ] = lang ( 'Total Files' );
$vars [ 'total_files' ] = count ( $ls_array );
2003-11-22 04:05:00 +01:00
}
$this -> t -> set_var ( $vars );
$this -> t -> pparse ( 'out' , 'filemanager_footer' );
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_footer ();
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2003-11-22 04:05:00 +01:00
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
function readFilesInfo ()
{
// start files info
2003-12-09 00:18:34 +01:00
2003-11-22 04:05:00 +01:00
# Read in file info from database to use in the rest of the script
# $fakebase is a special directory. In that directory, we list the user's
# home directory and the directories for the groups they're in
$this -> numoffiles = 0 ;
2007-07-19 18:13:53 +02:00
if ( $this -> path == $this -> fakebase )
2003-11-22 04:05:00 +01:00
{
2004-03-02 01:39:52 +01:00
// FIXME this test can be removed
2007-07-19 18:13:53 +02:00
if ( ! $this -> vfs -> file_exists ( array ( 'string' => $this -> homedir , 'relatives' => array ( RELATIVE_NONE ))))
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> mkdir ( array ( 'string' => $this -> homedir , 'relatives' => array ( RELATIVE_NONE )));
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
reset ( $this -> readable_groups );
2006-12-14 18:17:42 +01:00
// create the directorys of the readableGroups if they do not exist
2004-02-21 14:56:18 +01:00
while ( list ( $num , $group_array ) = each ( $this -> readable_groups ))
2003-10-24 22:33:34 +02:00
{
2006-12-14 18:17:42 +01:00
# If the group doesn't have access to this app, we don't show it, and do not appkly any action here
2007-07-19 18:13:53 +02:00
if ( ! $this -> groups_applications [ $group_array [ 'account_name' ]][ $this -> appname ][ 'enabled' ])
2003-11-22 04:05:00 +01:00
{
continue ;
}
2007-07-19 18:13:53 +02:00
if ( ! $this -> vfs -> file_exists ( array ( 'string' => $this -> fakebase . '/' . $group_array [ 'account_name' ], 'relatives' => array ( RELATIVE_NONE ))))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 1 ;
$this -> vfs -> mkdir ( array (
'string' => $this -> fakebase . '/' . $group_array [ 'account_name' ],
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_NONE )
));
2004-03-02 01:39:52 +01:00
// FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content
2007-07-19 18:13:53 +02:00
$this -> vfs -> override_acl = 0 ;
$this -> vfs -> set_attributes ( array ( 'string' => $this -> fakebase . '/' . $group_array [ 'account_name' ], 'relatives' => array ( RELATIVE_NONE ), 'attributes' => array ( 'owner_id' => $group_array [ 'account_id' ], 'createdby_id' => $group_array [ 'account_id' ])));
2003-11-22 04:05:00 +01:00
}
2006-12-14 18:17:42 +01:00
}
}
2003-11-22 04:05:00 +01:00
2006-12-14 18:17:42 +01:00
// read the list of the existing directorys/files
2007-07-19 18:13:53 +02:00
$ls_array = $this -> vfs -> ls ( array (
2006-12-14 18:17:42 +01:00
'string' => $this -> path ,
'relatives' => array ( RELATIVE_NONE ),
'checksubdirs' => false ,
'nofiles' => false ,
'orderby' => $this -> sortby
));
2007-07-19 18:13:53 +02:00
$heimatverz = explode ( '/' , $this -> homedir );
2006-12-14 18:17:42 +01:00
// process the list: check if we are allowed to read it, get the real size, and count the files/dirs
while ( list ( $num , $file_array ) = each ( $ls_array ))
{
2007-07-19 18:13:53 +02:00
if ( $this -> path == $this -> fakebase )
2006-12-14 18:17:42 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $file_array [ 'name' ] && ( array_key_exists ( $file_array [ 'name' ], $this -> readable_groups ) || $this -> fakebase . '/' . $file_array [ 'name' ] == $this -> homedir || $file_array [ 'name' ] == $heimatverz [ 2 ]))
2006-12-14 18:17:42 +01:00
{
2007-07-19 18:13:53 +02:00
if ( ! $this -> groups_applications [ $file_array [ 'name' ]][ $this -> appname ][ 'enabled' ] && $this -> fakebase . '/' . $file_array [ 'name' ] != $this -> homedir && $file_array [ 'name' ] != $heimatverz [ 2 ])
2006-12-14 18:17:42 +01:00
{
continue ;
}
}
2007-07-19 18:13:53 +02:00
if ( $file_array [ 'name' ] && ! array_key_exists ( $file_array [ 'name' ], $this -> readable_groups ) && ! ( $this -> fakebase . '/' . $file_array [ 'name' ] == $this -> homedir || $file_array [ 'name' ] == $heimatverz [ 2 ]))
2006-12-14 18:17:42 +01:00
{
continue ;
}
2003-10-24 22:33:34 +02:00
}
2006-12-14 18:17:42 +01:00
// get additional info, which was not retrieved meeting our needs -> size, ids
if ( $this -> prefs [ 'size' ])
{
//KL get the real size of the object
$tmp_arr = array (
'string' => $file_array [ 'directory' ] . '/' . $file_array [ 'name' ],
'relatives' => array ( RELATIVE_NONE )
);
if ( $file_array [ 'mime_type' ] != 'Directory' ) $tmp_arr [ 'checksubdirs' ] = false ;
2007-07-19 18:13:53 +02:00
$file_array [ 'size' ] = $this -> vfs -> get_size ( $tmp_arr );
2006-12-14 18:17:42 +01:00
// KL got the real size
}
if ( $this -> prefs [ 'owner' ])
{
$file_array [ 'owner_name' ] = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $file_array [ 'owner_id' ]);
}
# Creator name
if ( $this -> prefs [ 'createdby_id' ])
{
if ( $file_array [ 'createdby_id' ])
{
//$col_data=$GLOBALS['egw']->accounts->id2name($files['createdby_lid']);
$file_array [ 'createdby_name' ] = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $file_array [ 'createdby_id' ]);
}
else
{
$file_array [ 'createdby_name' ] = '' ;
}
}
# Modified by name
if ( $this -> prefs [ 'modifiedby_id' ])
{
if ( $file_array [ 'modifiedby_id' ])
{
$file_array [ 'modifiedby_name' ] = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $file_array [ 'modifiedby_id' ]);
}
else
{
$file_array [ 'modifiedby_name' ] = '' ;
}
}
// got additional info
$this -> numoffiles ++ ;
$this -> files_array [] = $file_array ;
if ( $phpwh_debug )
{
echo 'Filename: ' . $file_array [ 'name' ] . '<br>' . " \n " ;
}
}
if ( ! is_array ( $this -> files_array ) )
{
$this -> files_array = array ();
2003-11-22 04:05:00 +01:00
}
else
{
2006-12-14 18:17:42 +01:00
// KL sorting by multisort, if sort-param is set.
if ( $this -> sortby )
2003-10-24 22:33:34 +02:00
{
2006-12-14 18:17:42 +01:00
$mysorting = $this -> sortby ;
if ( $mysorting == 'owner' )
2003-10-24 22:33:34 +02:00
{
2006-12-14 18:17:42 +01:00
$mysorting = 'owner_name' ;
}
elseif ( $mysorting == 'createdby_id' )
{
$mysorting = 'createdby_name' ;
}
elseif ( $mysorting == 'modifiedby_id' )
{
$mysorting = 'modifiedby_name' ;
}
foreach ( $this -> files_array as $key => $row ) {
$file [ $key ] = $row [ $mysorting ];
2003-10-24 22:33:34 +02:00
}
2006-12-14 18:17:42 +01:00
// cast and sort file as container of the sort-key-column ascending to sort
// $files_array (as last Param), by the common key
array_multisort ( array_map ( 'strtolower' , $file ), SORT_ASC , $this -> files_array );
}
// KL sorting done
2003-11-22 04:05:00 +01:00
}
}
2004-02-21 14:56:18 +01:00
2003-11-22 04:05:00 +01:00
function toolbar ( $type )
{
2007-07-19 18:13:53 +02:00
//echo "<p> call toolbar </p>";
2003-11-22 04:05:00 +01:00
switch ( $type )
{
case 'location' :
$toolbar = '
< div id = " fmLocation " >
2004-02-21 14:56:18 +01:00
< table cellspacing = " 1 " cellpadding = " 0 " border = " 0 " >
2003-11-22 04:05:00 +01:00
< tr >
2003-12-09 00:18:34 +01:00
' ;
2005-09-14 03:58:20 +02:00
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
2003-12-09 00:18:34 +01:00
$toolbar .= '
2005-09-14 03:58:20 +02:00
< td >< img alt = " spacer " src = " '. $GLOBALS['egw'] ->common->image('filemanager','spacer').' " height = " 27 " width = " 1 " ></ td > ' ;
2003-10-24 22:33:34 +02:00
2004-08-01 20:29:50 +02:00
// go up icon when we're not at the top, dont allow to go outside /home = fakebase
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase )
2004-02-21 14:56:18 +01:00
{
2003-11-22 04:05:00 +01:00
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> lesspath );
$toolbar .= $this -> buttonImage ( $link , 'up' , lang ( 'go up' ));
}
// go home icon when we're not home already
2007-07-19 18:13:53 +02:00
if ( $this -> path != $this -> homedir )
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> homedir );
2003-11-22 04:05:00 +01:00
$toolbar .= $this -> buttonImage ( $link , 'home' , lang ( 'go home' ));
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
// reload button with this url
2004-12-06 15:16:11 +01:00
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index&update=1' , 'path=' . $this -> path );
2003-11-22 04:05:00 +01:00
$toolbar .= $this -> buttonImage ( $link , 'reload' , lang ( 'reload' ));
2003-12-09 00:18:34 +01:00
$toolbar .= '<td>' . lang ( 'Location' ) . ': ' ;
//$toolbar.='<input id="fmInputLocation" type="text" size="20" disabled="disabled" name="location" value="'.$this->disppath.'"/> ';
2004-02-21 14:56:18 +01:00
$current_option = '<option>' . $this -> disppath . '</option>' ;
2003-11-22 04:05:00 +01:00
// selectbox for change/move/and copy to
2007-07-19 18:13:53 +02:00
2007-03-19 10:51:34 +01:00
$this -> dirs_options = $this -> all_other_directories_options ();
$toolbar .= '<select name="cdtodir" onChange="document.formfm.changedir.value=\'true\';document.formfm.submit()">' . $current_option . $this -> dirs_options . ' </ select >
2003-12-09 00:18:34 +01:00
< input type = " hidden " name = " changedir " value = " false " ></ td >
' ;
2004-02-11 23:14:15 +01:00
$toolbar .= $this -> inputImage ( 'goto' , 'goto' , lang ( 'Quick jump to' ));
2003-12-09 00:18:34 +01:00
// upload button
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase && $this -> can_add )
2003-12-09 00:18:34 +01:00
{
2003-11-22 04:05:00 +01:00
2005-09-14 03:58:20 +02:00
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
2003-12-09 00:18:34 +01:00
// $toolbar.=$this->inputImage('download','download',lang('Download'));
// upload button
$toolbar .= $this -> inputImage ( 'upload' , 'upload' , lang ( 'Upload' ));
}
$toolbar .= '</tr></table>' ;
$toolbar .= '</div>' ;
break ;
case 'list_nav' :
$toolbar = '
2004-02-21 14:56:18 +01:00
< table cellspacing = " 1 " cellpadding = " 0 " border = " 0 " >
2003-12-09 00:18:34 +01:00
< tr > ' ;
// selectbox for change/move/and copy to
// submit buttons for
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase )
2003-10-24 22:33:34 +02:00
{
2005-09-14 03:58:20 +02:00
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
2003-12-09 00:18:34 +01:00
$toolbar .= '
2005-09-14 03:58:20 +02:00
< td >< img alt = " spacer " src = " '. $GLOBALS['egw'] ->common->image('filemanager','spacer').' " height = " 27 " width = " 1 " ></ td > ' ;
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
if ( ! $this -> rename_x && ! $this -> edit_comments_x )
2003-12-09 00:18:34 +01:00
{
// edit text file button
$toolbar .= $this -> inputImage ( 'edit' , 'edit' , lang ( 'edit' ));
}
2004-02-21 14:56:18 +01:00
if ( ! $this -> edit_comments_x )
2003-12-09 00:18:34 +01:00
{
$toolbar .= $this -> inputImage ( 'rename' , 'rename' , lang ( 'Rename' ));
}
2004-02-21 14:56:18 +01:00
if ( ! $this -> rename_x && ! $this -> edit_comments_x )
2003-12-09 00:18:34 +01:00
{
$toolbar .= $this -> inputImage ( 'delete' , 'delete' , lang ( 'Delete' ));
}
2004-02-21 14:56:18 +01:00
if ( ! $this -> rename_x )
2003-10-24 22:33:34 +02:00
{
2003-12-09 00:18:34 +01:00
$toolbar .= $this -> inputImage ( 'edit_comments' , 'edit_comments' , lang ( 'Edit comments' ));
2003-10-24 22:33:34 +02:00
}
2005-09-14 03:58:20 +02:00
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
2003-12-09 00:18:34 +01:00
}
2007-03-19 10:51:34 +01:00
else
{
2007-07-19 18:13:53 +02:00
if ( $this -> path = $this -> fakebase )
2007-03-19 10:51:34 +01:00
{
$toolbar .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
$toolbar .= '
< td >< img alt = " spacer " src = " '. $GLOBALS['egw'] ->common->image('filemanager','spacer').' " height = " 27 " width = " 1 " ></ td > ' ;
if ( ! $this -> rename_x )
{
$toolbar .= $this -> inputImage ( 'edit_comments' , 'edit_comments' , lang ( 'Edit comments' ));
}
}
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
// $toolbar.='</tr></table>';
if ( ! $this -> rename_x && ! $this -> edit_comments_x )
2003-12-09 00:18:34 +01:00
{
// copy and move buttons
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase )
2003-10-24 22:33:34 +02:00
{
2005-09-14 03:58:20 +02:00
$toolbar3 .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
$toolbar3 .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( ! $this -> dirs_options ) $this -> dirs_options = $this -> all_other_directories_options ();
2007-03-19 10:51:34 +01:00
$toolbar3 .= '<td><select name="todir">' . $this -> dirs_options . '</select></td>' ;
2003-11-22 04:05:00 +01:00
2003-12-09 00:18:34 +01:00
$toolbar3 .= $this -> inputImage ( 'copy_to' , 'copy_to' , lang ( 'Copy to' ));
$toolbar3 .= $this -> inputImage ( 'move_to' , 'move_to' , lang ( 'Move to' ));
2005-09-14 03:58:20 +02:00
$toolbar3 .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
}
2003-10-24 22:33:34 +02:00
2003-11-22 04:05:00 +01:00
// create dir and file button
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase && $this -> can_add )
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$toolbar3 .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , 'buttonseparator' ) . '" height="27" width="8"></td>' ;
$toolbar3 .= '<td><img alt="spacer" src="' . $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'spacer' ) . '" height="27" width="1"></td>' ;
2003-10-24 22:33:34 +02:00
2003-12-09 00:18:34 +01:00
$toolbar3 .= '<td><input type=text size="15" name="newfile_or_dir" value="" /></td>' ;
$toolbar3 .= $this -> inputImage ( 'newdir' , 'createdir' , lang ( 'Create Folder' ));
$toolbar3 .= $this -> inputImage ( 'newfile' , 'createfile' , lang ( 'Create File' ));
}
2003-10-24 22:33:34 +02:00
2003-12-09 00:18:34 +01:00
if ( $toolbar3 )
2003-11-22 04:05:00 +01:00
{
2003-12-09 00:18:34 +01:00
$toolbar .= $toolbar3 ;
/* $toolbar .= '
2004-02-21 14:56:18 +01:00
< table cellspacing = " 1 " cellpadding = " 0 " border = " 0 " >
2003-12-09 00:18:34 +01:00
< tr > ' . $toolbar3 ; */
2003-11-22 04:05:00 +01:00
}
}
$toolbar .= '</tr></table>' ;
2003-12-09 00:18:34 +01:00
2003-11-22 04:05:00 +01:00
break ;
default : $x = '' ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
if ( $toolbar )
{
return $toolbar ;
}
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
// move to bo
# Handle File Uploads
function fileUpload ()
{
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase )
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
for ( $i = 0 ; $i != $this -> show_upload_boxes ; $i ++ )
2003-10-24 22:33:34 +02:00
{
2007-07-19 18:13:53 +02:00
if ( $badchar = $this -> bad_chars ( $_FILES [ 'upload_file' ][ 'name' ][ $i ], True , True ))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( $this -> html_encode ( lang ( 'File names cannot contain "%1"' , $badchar ), 1 )));
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
continue ;
}
2007-07-19 18:13:53 +02:00
if ( $_FILES [ 'upload_file' ][ 'tmp_name' ][ $i ] == '' )
{
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( $this -> html_encode ( lang ( 'File %1 may be too big. Contact your Systemadministrator for further info' , $_FILES [ 'upload_file' ][ 'name' ]), 1 )));
continue ;
}
2004-02-21 14:56:18 +01:00
# Check to see if the file exists in the database, and get its info at the same time
2007-07-19 18:13:53 +02:00
$ls_array = $this -> vfs -> ls ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> path . '/' . $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_NONE ),
'checksubdirs' => False ,
'nofiles' => True
));
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$fileinfo = $ls_array [ 0 ];
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $fileinfo [ 'name' ])
{
if ( $fileinfo [ 'mime_type' ] == 'Directory' )
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Cannot replace %1 because it is a directory' , $fileinfo [ 'name' ])));
2004-02-21 14:56:18 +01:00
continue ;
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
}
2007-07-19 18:13:53 +02:00
2004-02-21 14:56:18 +01:00
if ( $_FILES [ 'upload_file' ][ 'size' ][ $i ] > 0 )
{
if ( $fileinfo [ 'name' ] && $fileinfo [ 'deleteable' ] != 'N' )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$tmp_arr = array (
'string' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_ALL ),
'attributes' => array (
2007-07-19 18:13:53 +02:00
'owner_id' => $this -> userinfo [ 'username' ],
'modifiedby_id' => $this -> userinfo [ 'username' ],
2004-02-21 14:56:18 +01:00
'modified' => $this -> now ,
'size' => $_FILES [ 'upload_file' ][ 'size' ][ $i ],
'mime_type' => $_FILES [ 'upload_file' ][ 'type' ][ $i ],
'deleteable' => 'Y' ,
2004-03-04 18:49:42 +01:00
'comment' => stripslashes ( $_POST [ 'upload_comment' ][ $i ])
2004-02-21 14:56:18 +01:00
)
);
2007-07-19 18:13:53 +02:00
$this -> vfs -> set_attributes ( $tmp_arr );
2003-11-22 04:05:00 +01:00
2004-02-21 14:56:18 +01:00
$tmp_arr = array (
'from' => $_FILES [ 'upload_file' ][ 'tmp_name' ][ $i ],
'to' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_NONE | VFS_REAL , RELATIVE_ALL )
);
2007-07-19 18:13:53 +02:00
$this -> vfs -> cp ( $tmp_arr );
2004-02-21 14:56:18 +01:00
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Replaced %1' , $this -> disppath . '/' . $_FILES [ 'upload_file' ][ 'name' ][ $i ]);
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> cp ( array (
2004-02-21 14:56:18 +01:00
'from' => $_FILES [ 'upload_file' ][ 'tmp_name' ][ $i ],
'to' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_NONE | VFS_REAL , RELATIVE_ALL )
2003-11-22 04:05:00 +01:00
));
2007-07-19 18:13:53 +02:00
$this -> vfs -> set_attributes ( array (
2003-11-22 04:05:00 +01:00
'string' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_ALL ),
'attributes' => array (
2003-11-22 04:05:00 +01:00
'mime_type' => $_FILES [ 'upload_file' ][ 'type' ][ $i ],
2004-03-04 18:49:42 +01:00
'comment' => stripslashes ( $_POST [ 'upload_comment' ][ $i ])
2003-11-22 04:05:00 +01:00
)
));
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Created %1,%2' , $this -> disppath . '/' . $_FILES [ 'upload_file' ][ 'name' ][ $i ], $_FILES [ 'upload_file' ][ 'size' ][ $i ]);
2003-11-22 04:05:00 +01:00
}
}
2004-02-21 14:56:18 +01:00
elseif ( $_FILES [ 'upload_file' ][ 'name' ][ $i ])
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> vfs -> touch ( array (
2004-02-21 14:56:18 +01:00
'string' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_ALL )
));
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> set_attributes ( array (
2004-02-21 14:56:18 +01:00
'string' => $_FILES [ 'upload_file' ][ 'name' ][ $i ],
'relatives' => array ( RELATIVE_ALL ),
'attributes' => array (
'mime_type' => $_FILES [ 'upload_file' ][ 'type' ][ $i ],
2004-03-04 18:49:42 +01:00
'comment' => stripslashes ( $_POST [ 'upload_comment' ][ $i ])
2004-02-21 14:56:18 +01:00
)
));
2003-10-24 22:33:34 +02:00
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Created %1,%2' , $this -> disppath . '/' . $_FILES [ 'upload_file' ][ 'name' ][ $i ], $file_size [ $i ]);
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
}
$this -> readFilesInfo ();
$this -> filelisting ();
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
# Handle Editing comments
function editComment ()
{
while ( list ( $file ) = each ( $this -> comment_files ))
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $badchar = $this -> bad_chars ( $this -> comment_files [ $file ], False , True ))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( $file . $this -> html_encode ( ': ' . lang ( 'Comments cannot contain "%1"' , $badchar ), 1 )));
2004-02-21 14:56:18 +01:00
continue ;
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
2007-07-19 18:13:53 +02:00
$this -> vfs -> set_attributes ( array (
2004-02-21 14:56:18 +01:00
'string' => $file ,
'relatives' => array ( RELATIVE_ALL ),
'attributes' => array (
'comment' => stripslashes ( $this -> comment_files [ $file ])
)
));
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Updated comment for %1' , $this -> path . '/' . $file );
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> filelisting ();
}
# Handle Renaming Files and Directories
function rename ()
{
while ( list ( $from , $to ) = each ( $this -> renamefiles ))
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $badchar = $this -> bad_chars ( $to , True , True ))
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( $this -> html_encode ( lang ( 'File names cannot contain "%1"' , $badchar ), 1 )));
2004-02-21 14:56:18 +01:00
continue ;
2003-11-22 04:05:00 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( ereg ( " / " , $to ) || ereg ( " \\ \\ " , $to ))
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( " File names cannot contain \\ or / " )));
2003-11-22 04:05:00 +01:00
}
2007-07-19 18:13:53 +02:00
elseif ( ! $this -> vfs -> mv ( array (
2004-02-21 14:56:18 +01:00
'from' => $from ,
'to' => $to
)))
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not rename %1 to %2' , $this -> disppath . '/' . $from , $this -> disppath . '/' . $to )));
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-11-22 04:05:00 +01:00
{
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Renamed %1 to %2' , $this -> disppath . '/' . $from , $this -> disppath . '/' . $to );
2003-11-22 04:05:00 +01:00
}
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> filelisting ();
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
# Handle Moving Files and Directories
function moveTo ()
{
2004-03-02 02:48:39 +01:00
if ( ! $this -> todir )
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not move file because no destination directory is given ' , $this -> disppath . '/' . $file )));
2004-03-02 02:48:39 +01:00
}
else
{
while ( list ( $num , $file ) = each ( $this -> fileman ))
2004-02-21 14:56:18 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> mv ( array (
2004-03-02 02:48:39 +01:00
'from' => $file ,
'to' => $this -> todir . '/' . $file ,
'relatives' => array ( RELATIVE_ALL , RELATIVE_NONE )
)))
{
$moved ++ ;
$this -> messages [] = lang ( 'Moved %1 to %2' , $this -> disppath . '/' . $file , $this -> todir . '/' . $file );
}
else
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not move %1 to %2' , $this -> disppath . '/' . $file , $this -> todir . '/' . $file )));
2004-03-02 02:48:39 +01:00
}
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
if ( $moved )
{
$x = 0 ;
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> filelisting ();
}
// Handle Copying of Files and Directories
function copyTo ()
{
2004-03-02 02:48:39 +01:00
if ( ! $this -> todir )
2003-12-09 00:18:34 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not copy file because no destination directory is given ' , $this -> disppath . '/' . $file )));
2004-03-02 02:48:39 +01:00
}
else
{
while ( list ( $num , $file ) = each ( $this -> fileman ))
2004-02-21 14:56:18 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> cp ( array (
2004-03-02 02:48:39 +01:00
'from' => $file ,
'to' => $this -> todir . '/' . $file ,
'relatives' => array ( RELATIVE_ALL , RELATIVE_NONE )
)))
{
$copied ++ ;
$this -> message .= lang ( 'Copied %1 to %2' , $this -> disppath . '/' . $file , $this -> todir . '/' . $file );
}
else
{
2005-09-14 03:58:20 +02:00
$this -> message .= $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not copy %1 to %2' , $this -> disppath . '/' . $file , $this -> todir . '/' . $file )));
2004-03-02 02:48:39 +01:00
}
2003-11-22 04:05:00 +01:00
}
}
2004-02-21 14:56:18 +01:00
if ( $copied )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$x = 0 ;
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> filelisting ();
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
function createdir ()
{
if ( $this -> newdir_x && $this -> newfile_or_dir )
{
2007-07-19 18:13:53 +02:00
if ( $this -> badchar = $this -> bad_chars ( $this -> newfile_or_dir , True , True ))
2004-02-21 14:56:18 +01:00
{
2007-07-19 18:13:53 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( $this -> html_encode ( lang ( 'Directory names cannot contain "%1"' , $badchar ), 1 )));
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
/* TODO is this right or should it be a single $ ? */
2007-04-19 14:52:38 +02:00
if ( $this -> newfile_or_dir [ strlen ( $this -> newfile_or_dir ) - 1 ] == ' ' || $this -> newfile_or_dir [ 0 ] == ' ' )
2004-02-21 14:56:18 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Cannot create directory because it begins or ends in a space' )));
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
2007-07-19 18:13:53 +02:00
$ls_array = $this -> vfs -> ls ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> path . '/' . $this -> newfile_or_dir ,
'relatives' => array ( RELATIVE_NONE ),
'checksubdirs' => False ,
'nofiles' => True
));
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
$fileinfo = $ls_array [ 0 ];
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
if ( $fileinfo [ 'name' ])
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $fileinfo [ 'mime_type' ] != 'Directory' )
2003-10-24 22:33:34 +02:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array (
2004-02-21 14:56:18 +01:00
lang ( '%1 already exists as a file' ,
$fileinfo [ 'name' ])
));
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-11-22 04:05:00 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Directory %1 already exists' , $fileinfo [ 'name' ])));
2003-11-22 04:05:00 +01:00
}
}
2004-02-21 14:56:18 +01:00
else
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> mkdir ( array ( 'string' => $this -> newfile_or_dir )))
2003-12-09 00:18:34 +01:00
{
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Created directory %1' , $this -> disppath . '/' . $this -> newfile_or_dir );
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-12-09 00:18:34 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not create %1' , $this -> disppath . '/' . $this -> newfile_or_dir )));
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> filelisting ();
}
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function delete ()
{
if ( is_array ( $this -> fileman ) && count ( $this -> fileman ) >= 1 )
{
foreach ( $this -> fileman as $filename )
{
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> delete ( array ( 'string' => $filename )))
2003-12-09 00:18:34 +01:00
{
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Deleted %1' , $this -> disppath . '/' . $filename ) . '<br/>' ;
2003-12-09 00:18:34 +01:00
}
else
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Could not delete %1' , $this -> disppath . '/' . $filename )));
2003-12-09 00:18:34 +01:00
}
2003-11-22 04:05:00 +01:00
}
}
2004-02-21 14:56:18 +01:00
else
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
// make this a javascript func for quicker respons
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'Please select a file to delete.' )));
2004-02-21 14:56:18 +01:00
}
$this -> readFilesInfo ();
$this -> filelisting ();
}
function debug_filemanager ()
{
error_reporting ( 8 );
echo " <b>Filemanager debug:</b><br>
path : { $this -> path } < br >
disppath : { $this -> disppath } < br >
cwd : { $this -> cwd } < br >
lesspath : { $this -> lesspath }
< p >
< b > eGroupware debug :</ b >< br >
2007-07-19 18:13:53 +02:00
real getabsolutepath : " . $this->vfs ->getabsolutepath(array('target' => False, 'mask' => False, 'fake' => False)) . " < br >
fake getabsolutepath : " . $this->vfs ->getabsolutepath(array('target' => False)) . " < br >
2005-09-14 03:58:20 +02:00
appsession : " . $GLOBALS['egw'] ->session->appsession('vfs','') . " < br >
2007-07-19 18:13:53 +02:00
pwd : " . $this->vfs ->pwd() . " < br > " ;
2004-02-21 14:56:18 +01:00
echo '<p></p>' ;
var_dump ( $this );
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
function showUploadboxes ()
{
$this -> t -> set_file ( array ( 'upload' => 'upload.tpl' ));
$this -> t -> set_block ( 'upload' , 'upload_header' , 'upload_header' );
$this -> t -> set_block ( 'upload' , 'row' , 'row' );
$this -> t -> set_block ( 'upload' , 'upload_footer' , 'upload_footer' );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
# Decide how many upload boxes to show
if ( ! $this -> show_upload_boxes || $this -> show_upload_boxes <= 0 )
{
if ( ! $this -> show_upload_boxes = $this -> prefs [ 'show_upload_boxes' ])
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> show_upload_boxes = 1 ;
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
}
# Show file upload boxes. Note the last argument to html(). Repeats $this->show_upload_boxes times
2007-07-19 18:13:53 +02:00
if ( $this -> path != '/' && $this -> path != $this -> fakebase && $this -> can_add )
2004-02-21 14:56:18 +01:00
{
2005-09-14 03:58:20 +02:00
$vars [ 'form_action' ] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' );
$vars [ 'path' ] = $this -> path ;
$vars [ 'lang_file' ] = lang ( 'File' );
$vars [ 'lang_comment' ] = lang ( 'Comment' );
$vars [ 'num_upload_boxes' ] = $this -> show_upload_boxes ;
2004-02-21 14:56:18 +01:00
$this -> t -> set_var ( $vars );
$this -> t -> pparse ( 'out' , 'upload_header' );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
for ( $i = 0 ; $i < $this -> show_upload_boxes ; $i ++ )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> t -> set_var ( 'row_tr_color' , $tr_color );
$this -> t -> parse ( 'rows' , 'row' );
$this -> t -> pparse ( 'out' , 'row' );
}
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$vars [ 'lang_upload' ] = lang ( 'Upload files' );
$vars [ 'change_upload_boxes' ] .= lang ( 'Show' ) . ' ' ;
2004-02-21 14:56:18 +01:00
$links .= $this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'show_upload_boxes=5' , '5' );
$links .= ' ' ;
$links .= $this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'show_upload_boxes=10' , '10' );
$links .= ' ' ;
$links .= $this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'show_upload_boxes=20' , '20' );
$links .= ' ' ;
$links .= $this -> html_link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'show_upload_boxes=50' , '50' );
$links .= ' ' ;
$links .= lang ( 'upload fields' );
2005-09-14 03:58:20 +02:00
$vars [ 'change_upload_boxes' ] .= $links ;
2004-02-21 14:56:18 +01:00
$this -> t -> set_var ( $vars );
$this -> t -> pparse ( 'out' , 'upload_footer' );
}
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
/* create textfile */
function createfile ()
{
2004-03-02 01:39:52 +01:00
$this -> createfile_var = $this -> newfile_or_dir ;
if ( $this -> createfile_var )
2004-02-21 14:56:18 +01:00
{
2007-07-19 18:13:53 +02:00
if ( $badchar = $this -> bad_chars ( $this -> createfile_var , True , True ))
2003-12-09 00:18:34 +01:00
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array (
2004-02-21 14:56:18 +01:00
lang ( 'File names cannot contain "%1"' , $badchar ),
1 )
);
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$this -> fileListing ();
}
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> file_exists ( array (
2004-03-02 01:39:52 +01:00
'string' => $this -> createfile_var ,
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_ALL )
)))
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'File %1 already exists. Please edit it or delete it first.' , $this -> createfile_var )));
2004-02-21 14:56:18 +01:00
$this -> fileListing ();
2003-11-22 04:05:00 +01:00
}
2003-12-09 00:18:34 +01:00
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> touch ( array (
2004-03-02 01:39:52 +01:00
'string' => $this -> createfile_var ,
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_ALL )
)))
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> fileman = array ();
2004-03-02 01:39:52 +01:00
$this -> fileman [ 0 ] = $this -> createfile_var ;
2004-02-21 14:56:18 +01:00
$this -> edit = 1 ;
$this -> numoffiles ++ ;
$this -> edit ();
}
else
{
2005-09-14 03:58:20 +02:00
$this -> messages [] = $GLOBALS [ 'egw' ] -> common -> error_list ( array ( lang ( 'File %1 could not be created.' , $this -> createfile_var )));
2004-02-21 14:56:18 +01:00
$this -> fileListing ();
2003-11-22 04:05:00 +01:00
}
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
# Handle Editing files
function edit ()
{
$this -> readFilesInfo ();
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$this -> t -> set_file ( array ( 'filemanager_edit' => 'edit_file.tpl' ));
$this -> t -> set_block ( 'filemanager_edit' , 'row' , 'row' );
2003-12-09 00:18:34 +01:00
2005-09-14 03:58:20 +02:00
$vars [ 'preview_content' ] = '' ;
2004-02-21 14:56:18 +01:00
if ( $this -> edit_file )
2003-11-22 04:05:00 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> edit_file_content = stripslashes ( $this -> edit_file_content );
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> edit_preview_x )
{
$content = $this -> edit_file_content ;
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$vars [ 'lang_preview_of' ] = lang ( 'Preview of %1' , $this -> path . '/' . $edit_file );
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$vars [ 'preview_content' ] = nl2br ( $content );
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
elseif ( $this -> edit_save_x || $this -> edit_save_done_x )
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$content = $this -> edit_file_content ;
//die( $content);
2007-07-19 18:13:53 +02:00
if ( $this -> vfs -> write ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> edit_file ,
'relatives' => array ( RELATIVE_ALL ),
'content' => $content
)))
2003-12-09 00:18:34 +01:00
{
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Saved %1' , $this -> path . '/' . $this -> edit_file );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
if ( $this -> edit_save_done_x )
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> readFilesInfo ();
$this -> fileListing ();
exit ;
2003-12-09 00:18:34 +01:00
}
}
2004-02-21 14:56:18 +01:00
else
2003-10-24 22:33:34 +02:00
{
2004-03-02 01:39:52 +01:00
$this -> messages [] = lang ( 'Could not save %1' , $this -> path . '/' . $this -> edit_file );
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
# Now we display the edit boxes and forms
for ( $j = 0 ; $j != $this -> numoffiles ; $j ++ )
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
# If we're in preview or save mode, we only show the file
# being previewed or saved
if ( $this -> edit_file && ( $this -> fileman [ $j ] != $this -> edit_file ))
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
continue ;
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
if ( $this -> fileman [ $j ] && $this -> vfs -> file_exists ( array (
2004-02-21 14:56:18 +01:00
'string' => $this -> fileman [ $j ],
'relatives' => array ( RELATIVE_ALL )
)))
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
if ( $this -> edit_file )
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$content = stripslashes ( $this -> edit_file_content );
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
$content = $this -> vfs -> read ( array ( 'string' => $this -> fileman [ $j ]));
2003-12-09 00:18:34 +01:00
}
2003-11-22 04:05:00 +01:00
2005-09-14 03:58:20 +02:00
$vars [ 'form_action' ] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $this -> path );
$vars [ 'edit_file' ] = $this -> fileman [ $j ];
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
# We need to include all of the fileman entries for each file's form,
# so we loop through again
for ( $i = 0 ; $i != $this -> numoffiles ; $i ++ )
2003-12-09 00:18:34 +01:00
{
2005-09-14 03:58:20 +02:00
if ( $this -> fileman [ $i ])
{
$value = 'value="' . $this -> fileman [ $i ] . '"' ;
}
$vars [ 'filemans_hidden' ] = '<input type="hidden" name="fileman[' . $i . ']" ' . $value . ' />' ;
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$vars [ 'file_content' ] = $content ;
2003-10-24 22:33:34 +02:00
2007-07-19 18:13:53 +02:00
$vars [ 'buttonPreview' ] = $this -> inputImage ( 'edit_preview' , 'edit_preview' , lang ( 'Preview %1' , $this -> html_encode ( $this -> fileman [ $j ], 1 )));
$vars [ 'buttonSave' ] = $this -> inputImage ( 'edit_save' , 'save' , lang ( 'Save %1' , $this -> html_encode ( $this -> fileman [ $j ], 1 )));
$vars [ 'buttonDone' ] = $this -> inputImage ( 'edit_save_done' , 'ok' , lang ( 'Save %1, and go back to file listing ' , $this -> html_encode ( $this -> fileman [ $j ], 1 )));
$vars [ 'buttonCancel' ] = $this -> inputImage ( 'edit_cancel' , 'cancel' , lang ( 'Cancel editing %1 without saving' , $this -> html_encode ( $this -> fileman [ $j ], 1 )));
2004-02-21 14:56:18 +01:00
$this -> t -> set_var ( $vars );
$this -> t -> parse ( 'rows' , 'row' );
$this -> t -> pparse ( 'out' , 'row' );
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
}
2003-11-22 04:05:00 +01:00
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function history ()
{
2004-03-02 01:39:52 +01:00
if ( $this -> file ) // FIXME this-file is never defined
2003-11-22 04:05:00 +01:00
{
2007-07-19 18:13:53 +02:00
$journal_array = $this -> vfs -> get_journal ( array (
2004-03-02 01:39:52 +01:00
'string' => $this -> file , //FIXME
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_ALL )
));
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
if ( is_array ( $journal_array ))
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$this -> html_table_begin ();
$this -> html_table_row_begin ();
$this -> html_table_col_begin ();
echo lang ( 'Date' );
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
echo lang ( 'Version' );
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
echo lang ( 'Who' );
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
echo lang ( 'Operation' );
$this -> html_table_col_end ();
$this -> html_table_row_end ();
while ( list ( $num , $journal_entry ) = each ( $journal_array ))
{
$this -> html_table_row_begin ();
$this -> html_table_col_begin ();
2007-07-19 18:13:53 +02:00
$this -> html_text ( $journal_entry [ 'created' ] . ' ' );
2004-02-21 14:56:18 +01:00
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
2007-07-19 18:13:53 +02:00
$this -> html_text ( $journal_entry [ 'version' ] . ' ' );
2004-02-21 14:56:18 +01:00
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
2007-07-19 18:13:53 +02:00
$this -> html_text ( $GLOBALS [ 'egw' ] -> accounts -> id2name ( $journal_entry [ 'owner_id' ]) . ' ' );
2004-02-21 14:56:18 +01:00
$this -> html_table_col_end ();
$this -> html_table_col_begin ();
2007-07-19 18:13:53 +02:00
$this -> html_text ( $journal_entry [ 'comment' ]);
2004-02-21 14:56:18 +01:00
$this -> html_table_col_end ();
}
$this -> html_table_end ();
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_footer ();
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
echo lang ( 'No version history for this file/directory' );
2003-12-09 00:18:34 +01:00
}
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function view ()
{
2004-03-02 01:39:52 +01:00
if ( $this -> file ) //FIXME
2003-12-09 00:18:34 +01:00
{
2007-03-19 10:51:34 +01:00
$mime_type = 'unknown' ;
2007-07-19 18:13:53 +02:00
$ls_array = $this -> vfs -> ls ( array (
'string' => $this -> path . '/' . $this -> file , //FIXME
'relatives' => array ( RELATIVE_ALL ),
'checksubdirs' => False ,
'nofiles' => True
2004-02-21 14:56:18 +01:00
));
if ( $ls_array [ 0 ][ 'mime_type' ])
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
$mime_type = $ls_array [ 0 ][ 'mime_type' ];
2003-12-09 00:18:34 +01:00
}
2007-07-19 18:13:53 +02:00
else
{
2007-06-03 20:04:31 +02:00
$parts = explode ( '.' , $this -> file );
$_ext = array_pop ( $parts );
$mime_type = ExecMethod ( 'phpgwapi.mime_magic.ext2mime' , $_ext );
2007-07-19 18:13:53 +02:00
}
2007-03-19 10:51:34 +01:00
// check if the prefs are set for viewing unknown extensions as text/plain and
// check if the mime_type is unknown, empty or not found (application/octet)
2007-07-19 18:13:53 +02:00
// or check if the mimetype contains text,
2007-03-19 10:51:34 +01:00
// THEN set the mime_type text/plain
if (( $this -> prefs [ 'viewtextplain' ] && ( $mime_type == '' or $mime_type == 'unknown' or $mime_type == 'application/octet-stream' )) or strpos ( $mime_type , 'text/' ) !== false )
2007-06-03 20:04:31 +02:00
{
$mime_type = 'text/plain' ;
}
2007-03-19 10:51:34 +01:00
// we want to define pdfs and text files as viewable
$viewable = array ( '' , 'text/plain' , 'text/csv' , 'text/html' , 'text/text' , 'application/pdf' );
// we want to view pdfs and text files within the browser
2004-04-11 16:25:33 +02:00
if ( in_array ( $mime_type , $viewable ) && ! $_GET [ 'download' ])
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
// if you add attachment; to the Content-disposition between disposition and filename
// you get a download dialog even for viewable files
header ( 'Content-type: ' . $mime_type );
header ( 'Content-disposition: filename="' . $this -> file . '"' ); //FIXME
Header ( " Pragma: public " );
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
else
2003-12-09 00:18:34 +01:00
{
2005-09-14 03:58:20 +02:00
2007-07-19 18:13:53 +02:00
$GLOBALS [ 'egw' ] -> browser -> content_header ( $this -> file , $mime_type ); //FIXME
2003-12-09 00:18:34 +01:00
}
2007-07-19 18:13:53 +02:00
echo $this -> vfs -> read ( array (
2004-03-02 01:39:52 +01:00
'string' => $this -> path . '/' . $this -> file , //FIXME
2004-02-21 14:56:18 +01:00
'relatives' => array ( RELATIVE_NONE )
));
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2004-02-21 14:56:18 +01:00
}
}
function download ()
{
for ( $i = 0 ; $i != $this -> numoffiles ; $i ++ )
{
if ( ! $this -> fileman [ $i ])
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
continue ;
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
2005-10-14 12:41:15 +02:00
$download_browser =& CreateObject ( 'phpgwapi.browser' );
2004-02-21 14:56:18 +01:00
$download_browser -> content_header ( $this -> fileman [ $i ]);
2007-07-19 18:13:53 +02:00
echo $this -> vfs -> read ( array ( 'string' => $this -> fileman [ $i ]));
2005-10-14 12:41:15 +02:00
$GLOBALS [ 'egw' ] -> common -> egw_exit ();
2004-02-21 14:56:18 +01:00
}
}
//give back an array with all directories except current and dirs that are not accessable
2007-07-19 18:13:53 +02:00
function all_other_directories_options ()
{
# First we get the directories in their home directory
$dirs = array ();
$dirs [] = array ( 'directory' => $this -> fakebase , 'name' => $this -> userinfo [ 'account_lid' ]);
$tmp_arr = array (
'string' => $this -> homedir ,
'relatives' => array ( RELATIVE_NONE ),
'checksubdirs' => True ,
'mime_type' => 'Directory'
);
$ls_array = $this -> vfs -> ls ( $tmp_arr );
while ( list ( $num , $dir ) = each ( $ls_array ))
{
$dirs [] = $dir ;
}
# Then we get the directories in their readable groups' home directories
reset ( $this -> readable_groups );
while ( list ( $num , $group_array ) = each ( $this -> readable_groups ))
{
# Don't list directories for groups that don't have access
if ( ! $this -> groups_applications [ $group_array [ 'account_name' ]][ $this -> appname ][ 'enabled' ])
{
continue ;
}
$dirs [] = array ( 'directory' => $this -> fakebase , 'name' => $group_array [ 'account_name' ]);
$tmp_arr = array (
'string' => $this -> fakebase . '/' . $group_array [ 'account_name' ],
'relatives' => array ( RELATIVE_NONE ),
'checksubdirs' => True ,
'mime_type' => 'Directory'
);
$ls_array = $this -> vfs -> ls ( $tmp_arr );
while ( list ( $num , $dir ) = each ( $ls_array ))
{
$dirs [] = $dir ;
}
}
reset ( $dirs );
2007-03-19 10:51:34 +01:00
// key for the sorted array
$i = 0 ;
2007-07-19 18:13:53 +02:00
while ( list ( $num , $dir ) = each ( $dirs ))
{
if ( ! $dir [ 'directory' ])
{
continue ;
}
# So we don't display //
if ( $dir [ 'directory' ] != '/' )
{
$dir [ 'directory' ] .= '/' ;
}
2007-03-19 10:51:34 +01:00
2007-07-19 18:13:53 +02:00
# No point in displaying the current directory, or a directory that doesn't exist
if ((( $dir [ 'directory' ] . $dir [ 'name' ]) != $this -> path ) && $this -> vfs -> file_exists ( array ( 'string' => $dir [ 'directory' ] . $dir [ 'name' ], 'relatives' => array ( RELATIVE_NONE ))))
{
//set the content of the sorted array
2007-03-19 10:51:34 +01:00
$i ++ ;
$dirs_sorted [ $i ] = $dir [ 'directory' ] . $dir [ 'name' ];
2007-07-19 18:13:53 +02:00
}
}
2007-03-19 10:51:34 +01:00
// sort the directory optionlist
natcasesort ( $dirs_sorted );
2007-07-19 18:13:53 +02:00
//_debug_array($dirs_sorted);
2007-03-19 10:51:34 +01:00
// set the optionlist
foreach ( $dirs_sorted as $key => $row ) {
2004-02-21 14:56:18 +01:00
//FIXME replace the html_form_option function
2007-03-19 10:51:34 +01:00
//$options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']);
$options .= $this -> html_form_option ( $row , $row );
2003-12-09 00:18:34 +01:00
}
2007-07-19 18:13:53 +02:00
// save some information with the session for retrieving it later
if ( $dirs_sorted ) $this -> save_sessiondata ( $dirs_sorted , 'dirs_options_array' );
return $options ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
/* seek icon for mimetype else return an unknown icon */
function mime_icon ( $mime_type , $size = 16 )
{
2005-09-14 03:58:20 +02:00
if ( ! $mime_type )
{
$mime_type = 'unknown' ;
}
2003-11-22 04:05:00 +01:00
2004-02-21 14:56:18 +01:00
$mime_type = str_replace ( '/' , '_' , $mime_type );
2003-11-22 04:05:00 +01:00
2005-09-14 03:58:20 +02:00
$img = $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'mime' . $size . '_' . strtolower ( $mime_type ));
if ( ! $img )
{
$img = $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'mime' . $size . '_unknown' );
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$icon = '<img src="' . $img . ' "alt="' . lang ( $mime_type ) . '" />' ;
return $icon ;
}
function buttonImage ( $link , $img = '' , $help = '' )
{
2005-09-14 03:58:20 +02:00
$image = $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'button_' . strtolower ( $img ));
2004-02-21 14:56:18 +01:00
if ( $img )
{
return ' < td class = " fmButton " align = " center " valign = " middle " height = " 28 " width = " 28 " >
< a href = " '. $link .' " title = " '. $help .' " >< img src = " '. $image .' " alt = " '. $help .' " /></ a >
</ td > ' ;
}
}
function inputImage ( $name , $img = '' , $help = '' )
{
2005-09-14 03:58:20 +02:00
$image = $GLOBALS [ 'egw' ] -> common -> image ( 'filemanager' , 'button_' . strtolower ( $img ));
2004-02-21 14:56:18 +01:00
if ( $img )
{
return ' < td class = " fmButton " align = " center " valign = " middle " height = " 28 " width = " 28 " >
< input title = " '. $help .' " name = " '. $name .' " type = " image " alt = " '. $name .' " src = " '. $image .' " value = " clicked " />
</ td > ' ;
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function html_form_input ( $type = NULL , $name = NULL , $value = NULL , $maxlength = NULL , $size = NULL , $checked = NULL , $string = '' , $return = 1 )
{
$text = ' ' ;
if ( $type != NULL && $type )
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
if ( $type == 'checkbox' )
2003-12-09 00:18:34 +01:00
{
2007-07-19 18:13:53 +02:00
$value = $this -> string_encode ( $value , 1 );
2003-12-09 00:18:34 +01:00
}
2004-02-21 14:56:18 +01:00
$text .= 'type="' . $type . '" ' ;
}
if ( $name != NULL && $name )
{
$text .= 'name="' . $name . '" ' ;
}
if ( $value != NULL && $value )
{
$text .= 'value="' . $value . '" ' ;
}
if ( is_int ( $maxlength ) && $maxlength >= 0 )
{
$text .= 'maxlength="' . $maxlength . '" ' ;
}
if ( is_int ( $size ) && $size >= 0 )
{
$text .= 'size="' . $size . '" ' ;
}
if ( $checked != NULL && $checked )
{
$text .= 'checked ' ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
return '<input' . $text . $string . '>' ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function html_form_option ( $value = NULL , $displayed = NULL , $selected = NULL , $return = 0 )
{
$text = ' ' ;
if ( $value != NULL && $value )
{
$text .= ' value="' . $value . '" ' ;
}
if ( $selected != NULL && $selected )
{
$text .= ' selected' ;
}
return '<option' . $text . '>' . $displayed . '</option>' ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function encode_href ( $href = NULL , $args = NULL , $extra_args )
{
2007-07-19 18:13:53 +02:00
$href = $this -> string_encode ( $href , 1 );
$all_args = $args . '&' . $this -> string_encode ( $extra_args , 1 );
2003-10-24 22:33:34 +02:00
2005-09-14 03:58:20 +02:00
$address = $GLOBALS [ 'egw' ] -> link ( $href , $all_args );
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
return $address ;
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function html_link ( $href = NULL , $args = NULL , $extra_args , $text = NULL , $return = 1 , $encode = 1 , $linkonly = 0 , $target = NULL )
{
// unset($encode);
if ( $encode )
{
2007-07-19 18:13:53 +02:00
$href = $this -> string_encode ( $href , 1 );
$all_args = $args . '&' . $this -> string_encode ( $extra_args , 1 );
2004-02-21 14:56:18 +01:00
}
else
{
2007-07-19 18:13:53 +02:00
// $href = $this->string_encode($href, 1);
2004-02-21 14:56:18 +01:00
$all_args = $args . '&' . $extra_args ;
}
###
# This decodes / back to normal
###
// $all_args = preg_replace("/%2F/", "/", $all_args);
// $href = preg_replace("/%2F/", "/", $href);
/* Auto-detect and don't disturb absolute links */
if ( ! preg_match ( " |^http(. { 0,1})://| " , $href ))
{
//Only add an extra / if there isn't already one there
// die(SEP);
if ( ! ( $href [ 0 ] == SEP ))
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$href = SEP . $href ;
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2005-10-14 12:41:15 +02:00
/* $GLOBALS['egw']->link requires that the extra vars be passed separately */
2004-02-21 14:56:18 +01:00
// $link_parts = explode("?", $href);
2005-09-14 03:58:20 +02:00
$address = $GLOBALS [ 'egw' ] -> link ( $href , $all_args );
// $address = $GLOBALS['egw']->link($href);
2004-02-21 14:56:18 +01:00
}
else
{
$address = $href ;
}
/* If $linkonly is set, don't add any HTML */
if ( $linkonly )
{
$rstring = $address ;
}
else
{
if ( $target )
{
$target = 'target=' . $target ;
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$text = trim ( $text );
$rstring = '<a href="' . $address . '" ' . $target . '>' . $text . '</a>' ;
2003-10-24 22:33:34 +02:00
}
2003-12-09 00:18:34 +01:00
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
function html_table_begin ( $width = NULL , $border = NULL , $cellspacing = NULL , $cellpadding = NULL , $rules = NULL , $string = '' , $return = 0 )
{
if ( $width != NULL && $width )
2003-10-24 22:33:34 +02:00
{
2003-12-09 00:18:34 +01:00
$width = " width= $width " ;
2004-02-21 14:56:18 +01:00
}
if ( is_int ( $border ) && $border >= 0 )
{
2003-12-09 00:18:34 +01:00
$border = " border= $border " ;
2004-02-21 14:56:18 +01:00
}
if ( is_int ( $cellspacing ) && $cellspacing >= 0 )
{
2003-12-09 00:18:34 +01:00
$cellspacing = " cellspacing= $cellspacing " ;
2004-02-21 14:56:18 +01:00
}
if ( is_int ( $cellpadding ) && $cellpadding >= 0 )
{
2003-12-09 00:18:34 +01:00
$cellpadding = " cellpadding= $cellpadding " ;
2004-02-21 14:56:18 +01:00
}
if ( $rules != NULL && $rules )
{
2003-12-09 00:18:34 +01:00
$rules = " rules= $rules " ;
2003-10-24 22:33:34 +02:00
}
2003-11-22 04:05:00 +01:00
2004-02-21 14:56:18 +01:00
$rstring = " <table $width $border $cellspacing $cellpadding $rules $string > " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
function html_table_end ( $return = 0 )
{
$rstring = " </table> " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
function html_table_row_begin ( $align = NULL , $halign = NULL , $valign = NULL , $bgcolor = NULL , $string = '' , $return = 0 )
{
if ( $align != NULL && $align )
2003-10-24 22:33:34 +02:00
{
2003-12-09 00:18:34 +01:00
$align = " align= $align " ;
2004-02-21 14:56:18 +01:00
}
if ( $halign != NULL && $halign )
{
2003-12-09 00:18:34 +01:00
$halign = " halign= $halign " ;
2004-02-21 14:56:18 +01:00
}
if ( $valign != NULL && $valign )
{
2003-12-09 00:18:34 +01:00
$valign = " valign= $valign " ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
if ( $bgcolor != NULL && $bgcolor )
2003-10-24 22:33:34 +02:00
{
2004-02-21 14:56:18 +01:00
$bgcolor = " bgcolor= $bgcolor " ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
$rstring = " <tr $align $halign $valign $bgcolor $string > " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
function html_table_row_end ( $return = 0 )
{
$rstring = " </tr> " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
2003-12-09 00:18:34 +01:00
2004-02-21 14:56:18 +01:00
function html_table_col_begin ( $align = NULL , $halign = NULL , $valign = NULL , $rowspan = NULL , $colspan = NULL , $string = '' , $return = 0 )
{
if ( $align != NULL && $align )
2003-10-24 22:33:34 +02:00
{
2003-12-09 00:18:34 +01:00
$align = " align= $align " ;
2004-02-21 14:56:18 +01:00
}
if ( $halign != NULL && $halign )
{
2003-12-09 00:18:34 +01:00
$halign = " halign= $halign " ;
2004-02-21 14:56:18 +01:00
}
if ( $valign != NULL && $valign )
{
2003-12-09 00:18:34 +01:00
$valign = " valign= $valign " ;
2004-02-21 14:56:18 +01:00
}
if ( is_int ( $rowspan ) && $rowspan >= 0 )
{
2003-12-09 00:18:34 +01:00
$rowspan = " rowspan= $rowspan " ;
2003-10-24 22:33:34 +02:00
}
2004-02-21 14:56:18 +01:00
if ( is_int ( $colspan ) && $colspan >= 0 )
2003-12-09 00:18:34 +01:00
{
2004-02-21 14:56:18 +01:00
$colspan = " colspan= $colspan " ;
2003-12-09 00:18:34 +01:00
}
2003-10-24 22:33:34 +02:00
2004-02-21 14:56:18 +01:00
$rstring = " <td $align $halign $valign $rowspan $colspan $string > " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2004-02-21 14:56:18 +01:00
}
function html_table_col_end ( $return = 0 )
{
$rstring = " </td> " ;
2007-07-19 18:13:53 +02:00
return ( $this -> eor ( $rstring , $return ));
2003-10-24 22:33:34 +02:00
}
2007-07-19 18:13:53 +02:00
function search_tpl ( $content = null )
{
//echo "<p>search_tpl</p>";
//_debug_array($content);
$debug = 0 ;
$content [ 'message' ] = '' ;
if ( $_GET [ 'action' ] == 'search' )
{
$content [ 'searchcreated' ] = 1 ;
$content [ 'datecreatedfrom' ] = date ( " U " ) - 24 * 60 * 60 ;
$content [ 'start_search' ] = lang ( 'start search' );
}
if ( $content [ 'start_search' ] && strlen ( $content [ 'start_search' ]) > 0 )
{
$searchactivated = 1 ;
$read_onlys [ 'searchstring' ] = true ;
}
$content [ 'nm' ] = $this -> read_sessiondata ( 'nm' );
$this -> search_options = $content [ 'nm' ][ 'search_options' ];
$content [ 'nm' ][ 'search' ] = $content [ 'searchstring' ];
$debug = $content [ 'debug' ];
// initialisieren des nextmatch widgets, durch auslesen der sessiondaten
// wenn leer, bzw. kein array dann von hand initialisieren
$content [ 'nm' ] = $this -> read_sessiondata ( 'nm' );
$content [ 'message' ] .= " <p>content may be set</p> " ;
if ( ! is_array ( $content [ 'nm' ]))
{
$content [ 'message' ] .= " <p>content is not set</p> " ;
$content [ 'debug' ] = $debug ;
$content [ 'nm' ] = array ( // I = value set by the app, 0 = value on return / output
'get_rows' => 'filemanager.uifilemanager.get_rows' , // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
'filter_label' => '' , // I label for filter (optional)
'filter_help' => '' , // I help-msg for filter (optional)
'no_filter' => True , // I disable the 1. filter
'no_filter2' => True , // I disable the 2. filter (params are the same as for filter)
'no_cat' => True , // I disable the cat-selectbox
//'template' => , // I template to use for the rows, if not set via options
//'header_left' => ,// I template to show left of the range-value, left-aligned (optional)
//'header_right' => ,// I template to show right of the range-value, right-aligned (optional)
//'bottom_too' => True, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows
'never_hide' => True , // I never hide the nextmatch-line if less then maxmatch entrie
'lettersearch' => True , // I show a lettersearch
'searchletter' => false , // I0 active letter of the lettersearch or false for [all]
'start' => 0 , // IO position in list
//'num_rows' => // IO number of rows to show, defaults to maxmatches from the general prefs
//'cat_id' => // IO category, if not 'no_cat' => True
//'search' => // IO search pattern
'order' => 'vfs_created' , // IO name of the column to sort after (optional for the sortheaders)
'sort' => 'DESC' , // IO direction of the sort: 'ASC' or 'DESC'
'col_filter' => array (), // IO array of column-name value pairs (optional for the filterheaders)
//'filter' => // IO filter, if not 'no_filter' => True
//'filter_no_lang' => True// I set no_lang for filter (=dont translate the options)
//'filter_onchange'=> 'this.form.submit();'// I onChange action for filter, default: this.form.submit();
//'filter2' => // IO filter2, if not 'no_filter2' => True
//'filter2_no_lang'=> True// I set no_lang for filter2 (=dont translate the options)
//'filter2_onchange'=> 'this.form.submit();'// I onChange action for filter, default: this.form.submit();
//'rows' => // O content set by callback
//'total' => // O the total number of entries
//'sel_options' => // O additional or changed sel_options set by the callback and merged into $tmpl->sel_options
'no_columnselection' => false ,
);
} else {
// lesen wenn gesetzt
$content [ 'message' ] .= " <p>content is set</p> " ;
//_debug_print($content);
}
//echo "<br>";
// loeschen wenn gesetzt
if (( $content [ 'clear_search' ] && strlen ( $content [ 'clear_search' ]) > 0 ) or $_GET [ 'actioncd' ] == 'clear' )
{
$content [ 'debug' ] = 0 ;
$content [ 'nm' ][ 'search_options' ] = array ();
unset ( $content [ 'nm' ][ 'search' ]);
$searchactivated = 0 ;
$content [ 'checkall' ] = 0 ;
$content [ 'checkonlyfiles' ] = 0 ;
$content [ 'checkonlydirs' ] = 0 ;
$content [ 'searchstring' ] = '' ;
$content [ 'searchcreated' ] = 0 ;
$content [ 'datecreatedto' ] = '' ;
$content [ 'datecreatedfrom' ] = '' ;
$content [ 'searchmodified' ] = 0 ;
$content [ 'datemodifiedto' ] = '' ;
$content [ 'datemodifiedfrom' ] = '' ;
$read_onlys = array ();
$this -> search_options = array ();
}
$sel_options = array (
'vfs_mime_type' => array ( 'directory' => 'directory' , '' => '' )
);
$this -> tmpl -> read ( 'filemanager.search' );
// the call of this function switches from enabled to disabled for various fields of the search dialog
//enable_disable_SearchFields($searchactivated);
//echo "<p>enable_disable_SearchFields</p>";
//echo "<p>".$content['datecreatedfrom']."</p>";
$switchflag = $searchactivated ;
$this -> tmpl -> set_cell_attribute ( 'checkall' , 'disabled' , $switchflag );
if ( $content [ 'checkall' ]) $this -> tmpl -> set_cell_attribute ( 'alllabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'alllabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'checkonlyfiles' , 'disabled' , $switchflag );
if ( $content [ 'checkonlyfiles' ]) $this -> tmpl -> set_cell_attribute ( 'filelabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'filelabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'checkonlydirs' , 'disabled' , $switchflag );
if ( $content [ 'checkonlydirs' ]) $this -> tmpl -> set_cell_attribute ( 'dirlabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'dirlabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'searchstring' , 'disabled' , $switchflag );
//search created date
if ( $content [ 'searchcreated' ] or $content [ 'datecreatedfrom' ] != '' or $content [ 'datecreatedto' ] != '' )
{
$content [ 'searchcreated' ] = 1 ;
$this -> tmpl -> set_cell_attribute ( 'createdlabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'createdlabel' , 'label' )) . '(x)' );
$read_onlys [ 'datecreatedto' ] = $switchflag ;
$read_onlys [ 'datecreatedfrom' ] = $switchflag ;
if (( $content [ 'datecreatedfrom' ] == '' && $content [ 'datecreatedto' ]) or ( $content [ 'datecreatedfrom' ] && $content [ 'datecreatedto' ] == '' ) ) $content [ 'searchcreatedtext' ] = lang ( 'Choosing only one date (from/to) will result in a search returning all entries older/younger than the entered date' );
if (( $content [ 'datecreatedfrom' ] != '' && $content [ 'datecreatedto' ] != '' && $content [ 'datecreatedto' ] < $content [ 'datecreatedfrom' ]) ) $content [ 'searchcreatedtext' ] = lang ( 'Choosing dates where to-date is smaller than the from-date, will result in a search returning all entries but thoose between the two entered dates' );
}
else
{
$content [ 'searchcreatedtext' ] = '' ;
}
$this -> tmpl -> set_cell_attribute ( 'searchcreated' , 'disabled' , $switchflag );
//search modified date
if ( $content [ 'searchmodified' ] or $content [ 'datemodifiedfrom' ] != '' or $content [ 'datemodifiedto' ] != '' )
{
$content [ 'searchmodified' ] = 1 ;
$this -> tmpl -> set_cell_attribute ( 'modifiedlabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'modifiedlabel' , 'label' )) . '(x)' );
$read_onlys [ 'datemodifiedto' ] = $switchflag ;
$read_onlys [ 'datemodifiedfrom' ] = $switchflag ;
if (( $content [ 'datemodifiedfrom' ] == '' && $content [ 'datemodifiedto' ]) or ( $content [ 'datemodifiedfrom' ] && $content [ 'datemodifiedto' ] == '' ) ) $content [ 'searchmodifiedtext' ] = lang ( 'Choosing only one date (from/to) will result in a search returning all entries older/younger than the entered date' );
if (( $content [ 'datemodifiedfrom' ] != '' && $content [ 'datemodifiedto' ] != '' && $content [ 'datemodifiedto' ] < $content [ 'datemodifiedfrom' ]) ) $content [ 'searchmodifiedtext' ] = lang ( 'Choosing dates where to-date is smaller than the from-date, will result in a search returning all entries but thoose between the two entered dates' );
}
else
{
$content [ 'searchmodifiedtext' ] = '' ;
}
$this -> tmpl -> set_cell_attribute ( 'searchmodified' , 'disabled' , $switchflag );
$this -> tmpl -> set_cell_attribute ( 'debuginfos' , 'disabled' , ! $debug );
//_debug_array($content);
//echo "<p>#$debug,$searchactivated#</p>";
$this -> search_options [ 'checkall' ] = $content [ 'checkall' ];
$this -> search_options [ 'checkonlyfiles' ] = $content [ 'checkonlyfiles' ];
$this -> search_options [ 'checkonlydirs' ] = $content [ 'checkonlydirs' ];
$this -> search_options [ 'searchstring' ] = $content [ 'searchstring' ];
$this -> search_options [ 'searchcreated' ] = $content [ 'searchcreated' ];
$this -> search_options [ 'datecreatedto' ] = $content [ 'datecreatedto' ];
$this -> search_options [ 'datecreatedfrom' ] = $content [ 'datecreatedfrom' ];
$this -> search_options [ 'searchmodified' ] = $content [ 'searchmodified' ];
$this -> search_options [ 'datemodifiedto' ] = $content [ 'datemodifiedto' ];
$this -> search_options [ 'datemodifiedfrom' ] = $content [ 'datemodifiedfrom' ];
$content [ 'nm' ][ 'search_options' ] = $this -> search_options ;
$content [ 'nm' ][ 'search' ] = $content [ 'searchstring' ];
$content [ 'nm' ][ 'start_search' ] = $content [ 'start_search' ];
$this -> save_sessiondata ( $content [ 'nm' ], 'nm' );
// call and execute thge template
$content [ 'message' ] .= " <p>execute the template</p> " ;
echo $this -> tmpl -> exec ( 'filemanager.uifilemanager.search_tpl' , $content , $sel_options , $read_onlys , array ( 'vfs_file_id' => $this -> data [ 'vfs_file_id' ]));
// the debug info will be displayed at the very end of the page
//_debug_array($content);
}
/**
* the call of this function switches from enabled to disabled for various fields of the search dialog
*/
function enable_disable_SearchFields ( $switchflag )
{
//does not work at all. The calling of $this->tmpl returns nothing
return ;
echo " <p>enable_disable_SearchFields</p> " ;
$this -> tmpl -> set_cell_attribute ( 'checkall' , 'disabled' , $switchflag );
if ( $content [ 'checkall' ]) $this -> tmpl -> set_cell_attribute ( 'alllabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'alllabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'checkonlyfiles' , 'disabled' , $switchflag );
if ( $content [ 'checkonlyfiles' ]) $this -> tmpl -> set_cell_attribute ( 'filelabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'filelabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'checkonlydirs' , 'disabled' , $switchflag );
if ( $content [ 'checkonlydirs' ]) $this -> tmpl -> set_cell_attribute ( 'dirlabel' , 'label' , lang ( $this -> tmpl -> get_cell_attribute ( 'dirlabel' , 'label' )) . '(x)' );
$this -> tmpl -> set_cell_attribute ( 'searchstring' , 'disabled' , $switchflag );
//return $template;
return true ;
}
/**
* Saves state of the filemanager list in the session
*
* @ param array $values
*/
function save_sessiondata ( $values , $key = '' )
{
if ( strlen ( $key ) > 0 )
{
$internalbuffer = $this -> read_sessiondata ();
$internalbuffer [ $key ] = $values ;
$this -> save_sessiondata ( $internalbuffer );
}
else
{
//echo "<p>$for: uifilemanager::save_sessiondata(".print_r($values,True).") called_by='$this->called_by', for='$for'<br />".function_backtrace()."</p>\n";
$GLOBALS [ 'egw' ] -> session -> appsession ( @ $this -> called_by . 'session_data' , 'filemanager' , $values );
}
}
/**
* reads list - state from the session
*
* @ return array
*/
function read_sessiondata ( $key = '' )
{
$values = $GLOBALS [ 'egw' ] -> session -> appsession ( @ $this -> called_by . 'session_data' , 'filemanager' );
if ( strlen ( $key ) > 0 )
{
return $values [ $key ];
}
else
{
return $values ;
}
}
/**
* query rows for the nextmatch widget
*
* @ param array $query with keys 'start' , 'search' , 'order' , 'sort' , 'col_filter'
* For other keys like 'filter' , 'cat_id' you have to reimplement this method in a derived class .
* @ param array & $rows returned rows / competitions
* @ param array & $readonlys eg . to disable buttons based on acl , not use here , maybe in a derived class
* @ param string $join = '' sql to do a join , added as is after the table - name , eg . " , table2 WHERE x=y " or
* " LEFT JOIN table2 ON (x=y) " , Note : there ' s no quoting done on $join !
* @ param boolean $need_full_no_count = false If true an unlimited query is run to determine the total number of rows , default false
* @ return int total number of rows
* optional not used here : $join = '' , $need_full_no_count = false
*/
function get_rows ( & $query , & $rows , & $readonlys )
{
//echo "<p>retrieve rows</p>";
$startposition = $query [ 'start' ];
//$this->save_sessiondata($query);
$sessiondata = $this -> read_sessiondata ();
//_debug_array($sessiondata['dirs_options_array']);
//_debug_array($sessiondata['readable_groups']);
//_debug_array($sessiondata['groups_applications']);
if ( ! ( $this -> search_options ))
{
$sessiondata [ 'start' ] = $startposition ;
$this -> search_options = $sessiondata [ 'nm' ][ 'search_options' ];
}
//_debug_array($this->search_options);
$additionalwhereclause = " , (select vfs_file_id as fileid, concat(concat(vfs_directory,'/'),vfs_name) as fulldir from egw_vfs WHERE vfs_mime_type <> 'journal' and vfs_mime_type <> 'journal-deleted' and vfs_name is not null and vfs_name <>'' and vfs_name<>'home' and vfs_app='filemanager') vfs2 WHERE vfs2.fileid=egw_vfs.vfs_file_id " ;
//search options
if ( $this -> search_options [ 'checkonlyfiles' ] && ! $this -> search_options [ 'checkonlydirs' ])
{
$additionalwhereclause .= " and vfs_mime_type<>'directory' " ;
}
elseif ( $this -> search_options [ 'checkonlydirs' ] && ! $this -> search_options [ 'checkonlyfiles' ])
{
$additionalwhereclause .= " and vfs_mime_type='directory' " ;
}
elseif ( $this -> search_options [ 'checkonlyfiles' ] && $this -> search_options [ 'checkonlydirs' ])
{
}
// timespecific search options
if ( $this -> search_options [ 'searchcreated' ] && $this -> search_options [ 'datecreatedfrom' ])
{
$additionalwhereclause .= " and vfs_created >=FROM_UNIXTIME( " . $this -> search_options [ 'datecreatedfrom' ] . " ) " ;
}
if ( $this -> search_options [ 'searchcreated' ] && $this -> search_options [ 'datecreatedto' ])
{
$additionalwhereclause .= " and vfs_created <=FROM_UNIXTIME( " . $this -> search_options [ 'datecreatedto' ] . " ) " ;
}
if ( $this -> search_options [ 'searchmodified' ] && $this -> search_options [ 'datemodifiedfrom' ])
{
$additionalwhereclause .= " and vfs_modified >=FROM_UNIXTIME( " . $this -> search_options [ 'datemodifiedfrom' ] . " ) " ;
}
if ( $this -> search_options [ 'searchmodified' ] && $this -> search_options [ 'datemodifiedto' ])
{
$additionalwhereclause .= " and vfs_modified <=FROM_UNIXTIME( " . $this -> search_options [ 'datemodifiedto' ] . " ) " ;
}
// only show contacts if the order-criteria starts with the given letter
if ( $query [ 'searchletter' ] != false )
{
$additionalwhereclause .= " and " . ( $query [ 'order' ]) . ' ' . $GLOBALS [ 'egw' ] -> db -> capabilities [ 'case_insensitive_like' ] . ' ' . $GLOBALS [ 'egw' ] -> db -> quote ( $query [ 'searchletter' ] . '%' );
}
else
{
//echo "<p>reset colfilter?!</p>";
$query [ 'searchletter' ] = false ;
}
// filter for allowed groups
$firstleveldirs [] = array ();
$count_fld = 0 ;
$or = '' ;
$aclcondition = " ( " ;
array_push ( $sessiondata [ 'dirs_options_array' ], $sessiondata [ 'workingdir' ]);
foreach ( $sessiondata [ 'dirs_options_array' ] as $dir )
{
$splitteddir = explode ( '/' , $dir );
$nix = array_shift ( $splitteddir );
$vfsbase = array_shift ( $splitteddir );
$vfs1stleveldir = array_shift ( $splitteddir );
if ( ! in_array ( " / $vfsbase / $vfs1stleveldir " , $firstleveldirs ))
{
$count_fld ++ ;
if ( $count_fld > 1 ) $or = 'or' ;
array_push ( $firstleveldirs , " / $vfsbase / $vfs1stleveldir " );
$aclcondition .= " $or concat(concat(vfs_directory,'/'),vfs_name) like '/ $vfsbase / $vfs1stleveldir %' and vfs_mime_type='directory' " ;
$aclcondition .= " or vfs_directory like '/ $vfsbase / $vfs1stleveldir %' " ;
//$aclcondition.=" or (vfs_directory='".implode('/',$splitteddir)."' and vfs_name='".$vfsname."')";
}
}
$aclcondition .= " ) " ;
if ( $count_fld > 0 ) $additionalwhereclause .= " and " . $aclcondition ;
//echo "<p>$aclcondition</p>";
// save the nextmatch entrys/settings with the sessiondata
if ( ! $_POST [ 'exec' ][ 'clear_search' ])
{
$query [ 'search_options' ] = $this -> search_options ;
}
else
{
//echo "<p>retrieve rows, clear search</p>";
unset ( $query [ 'search' ]);
unset ( $query [ 'start_search' ]);
$switchflag = 0 ;
}
$this -> save_sessiondata ( $query , 'nm' );
// defaultfilter we dont want journal, and a whole lot of other stuff excluded, so we use the Join part of get_rows to do that
// echo "<p>$additionalwhereclause</p>";
$rc = parent :: get_rows ( $query , $rows , $readonlys , $additionalwhereclause );
//set the applicationheader
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] = lang ( 'filemanager' );
foreach ( $rows as $key => $row )
{
$plink = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $rows [ $key ][ 'vfs_directory' ]);
$linktodir = '<a href="' . $plink . '">' . $rows [ $key ][ 'vfs_directory' ] . '</a> ' ;
if ( strtolower ( $rows [ $key ][ 'vfs_mime_type' ]) == 'directory' )
{
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.index' , 'path=' . $rows [ $key ][ 'vfs_directory' ] . " / " . $rows [ $key ][ 'vfs_name' ]);
$icon = $this -> mime_icon ( $rows [ $key ][ 'vfs_mime_type' ]);
$col_data = '<a href="' . $link . '">' . $icon . '</a> ' ;
$col_data .= '<a href="' . $link . '">' . $rows [ $key ][ 'vfs_directory' ] . " / " . $rows [ $key ][ 'vfs_name' ] . '</a> ' ;
}
else
{
if ( $this -> prefs [ 'viewonserver' ] && isset ( $this -> filesdir ) && ! $rows [ $key ][ 'vfs_link_directory' ])
{
#FIXME
$clickview = $rows [ $key ][ 'vfs_directory' ] . '/' . $rows [ $key ][ 'vfs_name' ];
}
else
{
$icon = $this -> mime_icon ( $rows [ $key ][ 'vfs_mime_type' ]);
$link = $this -> encode_href ( '/index.php' , 'menuaction=filemanager.uifilemanager.view' , 'file=' . $rows [ $key ][ 'vfs_name' ] . '&path=' . $rows [ $key ][ 'vfs_directory' ]);
$col_data = '<a href="' . $link . '" target="' . $this -> target . '">' . $icon . '</a> <a href="' . $link . '" target="' . $this -> target . '">' . $rows [ $key ][ 'vfs_directory' ] . " / " . $rows [ $key ][ 'vfs_name' ] . '</a>' ;
}
}
$rows [ $key ][ 'fulldir' ] = $col_data ;
$rows [ $key ][ 'vfs_directory' ] = $linktodir ;
}
// add some info to the appheader that the user may be informed about the search-base of its query-result
if ( $query [ 'searchletter' ])
{
$order = $order ;
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] .= ' - ' . lang ( " %1 starts with '%2' " , $order , $query [ 'searchletter' ]);
}
if ( $query [ 'search' ])
{
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] .= ' - ' . lang ( " Search for '%1' " , $query [ 'search' ]);
}
return $rc ;
}
2007-03-19 10:51:34 +01:00
}