another mayor code cleanup

checked for register globals bugs
moved all unneccesary global vars to class vars
added basedir test with feedback to alert for wrong configuration
added fakedir test with feedback to alert for wrong configuration
improved homedir creation withg feedback
improved standard messages
This commit is contained in:
Pim Snel 2004-03-02 00:39:52 +00:00
parent f67b3cb853
commit 9933a9c3fa
4 changed files with 233 additions and 1990 deletions

View File

@ -2,52 +2,24 @@
class bofilemanager class bofilemanager
{ {
// used
var $so; var $so;
var $vfs; var $vfs;
var $sep;
var $file_attributes;
var $help_info;
var $rootdir; var $rootdir;
var $fakebase; var $fakebase;
var $appname; var $appname;
var $settings;
var $filesdir; var $filesdir;
var $hostname; var $hostname;
var $userinfo = Array(); var $userinfo = Array();
var $homedir; var $homedir;
var $sep;
var $file_attributes;
var $errors; var $matches;//FIXME matches not defined
var $rename;
var $delete;
var $go;
var $copy;
var $move;
var $download;
var $createdir;
var $newdir;
var $createfile;
var $newfile;
var $fileman = Array();
var $op;
var $file;
var $help_name;
var $path;
var $disppath;
var $dispsep;
var $sortby = 'name';
var $messages = Array();
var $renamefiles;
var $comment_files = Array();
var $show_upload_boxes = 5;
var $memberships;
var $now;
var $matches;
// var $debug = True;
var $debug = False; var $debug = False;
function bofilemanager() function bofilemanager()
@ -63,30 +35,30 @@
### These are automatically set in phpGW - do not edit ### ### These are automatically set in phpGW - do not edit ###
$this->sep = SEP; $this->sep = SEP;
$GLOBALS['rootdir'] = $this->vfs->basedir; $this->rootdir = $this->vfs->basedir;
$GLOBALS['fakebase'] = $this->vfs->fakebase; $this->fakebase = $this->vfs->fakebase;
$GLOBALS['appname'] = $GLOBALS['phpgw_info']['flags']['currentapp']; $this->appname = $GLOBALS['phpgw_info']['flags']['currentapp'];
$GLOBALS['settings'] = $GLOBALS['phpgw_info']['user']['preferences'][$appname];
if (stristr ($GLOBALS['rootdir'], PHPGW_SERVER_ROOT)) if (stristr ($this->rootdir, PHPGW_SERVER_ROOT))
{ {
$GLOBALS['filesdir'] = substr ($GLOBALS['rootdir'], strlen (PHPGW_SERVER_ROOT)); $this->filesdir = substr ($this->rootdir, strlen (PHPGW_SERVER_ROOT));
} }
else else
{ {
unset ($GLOBALS['filesdir']); unset ($this->filesdir);
} }
$GLOBALS['hostname'] = $GLOBALS['phpgw_info']['server']['webserver_url'] . $GLOBALS['filesdir']; $this->hostname = $GLOBALS['phpgw_info']['server']['webserver_url'] . $this->filesdir;
// die($this->hostname);
### ###
# Note that $userinfo["username"] is actually the id number, not the login name # Note that $userinfo["username"] is actually the id number, not the login name
### ###
$GLOBALS['userinfo']['username'] = $GLOBALS['phpgw_info']['user']['account_id']; $this->userinfo['username'] = $GLOBALS['phpgw_info']['user']['account_id'];
$GLOBALS['userinfo']['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['username']); $this->userinfo['account_lid'] = $GLOBALS['phpgw']->accounts->id2name ($this->userinfo['username']);
$GLOBALS['userinfo']['hdspace'] = 10000000000; $this->userinfo['hdspace'] = 10000000000; // to settings
$GLOBALS['homedir'] = $GLOBALS['fakebase'].'/'.$GLOBALS['userinfo']['account_lid']; $this->homedir = $this->fakebase.'/'.$this->userinfo['account_lid'];
### End Configuration Options ### ### End Configuration Options ###
@ -199,8 +171,6 @@
function html_text ($string, $times = 1, $return = 0, $lang = 0) function html_text ($string, $times = 1, $return = 0, $lang = 0)
{ {
global $phpgw;
if ($lang) if ($lang)
$string = lang($string); $string = lang($string);
@ -231,20 +201,23 @@
{ {
$rstring = $string; $rstring = $string;
preg_match_all ("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER); preg_match_all ("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER);//FIXME matches not defined
reset ($matches);//FIXME matches not defined
while (list (,$match_array) = each ($matches))//FIXME matches not defined
reset ($matches);
while (list (,$match_array) = each ($matches))
{ {
$var_encoded = rawurlencode (base64_encode ($match_array[1])); $var_encoded = rawurlencode (base64_encode ($match_array[1]));
$rstring = str_replace ($match_array[0], '=' . $var_encoded . $match_array[2], $rstring); $rstring = str_replace ($match_array[0], '=' . $var_encoded . $match_array[2], $rstring);
} }
} }
elseif (ereg ('^'.$GLOBALS['hostname'], $string)) elseif ($this->hostname != "" && ereg('^'.$this->hostname, $string))
// elseif (ereg ('^'.$this->hostname, $string))
{ {
$rstring = ereg_replace ('^'.$GLOBALS['hostname'].'/', '', $string); $rstring = ereg_replace ('^'.$this->hostname.'/', '', $string);
$rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring); $rstring = preg_replace ("/(.*)(\/|$)/Ue", "rawurlencode (base64_encode ('\\1')) . '\\2'", $rstring);
$rstring = $GLOBALS['hostname'].'/'.$rstring; $rstring = $this->hostname.'/'.$rstring;
} }
else else
{ {

View File

@ -3,30 +3,21 @@
class sofilemanager class sofilemanager
{ {
var $db; var $db;
// var $phpgw;
// var $phpgw_info;
function sofilemanager() function sofilemanager()
{ {
$this->db = $GLOBALS['phpgw']->db; $this->db = $GLOBALS['phpgw']->db;
// $this->phpgw=$GLOBALS[phpgw];
// $this->phpgw_info=$GLOBALS[phpgw_info];
} }
/* Any initializations that need to be done */ /* Any initializations that need to be done */
function db_init () function db_init ()
{ {
//global $phpgw;
//global $phpgw_info;
$this->db->Auto_Free = 0; $this->db->Auto_Free = 0;
} }
/* General SQL query */ /* General SQL query */
function db_query ($query) function db_query ($query)
{ {
// global $phpgw;
// global $phpgw_info;
return $this->db->query ($query); return $this->db->query ($query);
} }
@ -34,8 +25,6 @@
/* Fetch next array for $query_id */ /* Fetch next array for $query_id */
function db_fetch_array ($query_id) function db_fetch_array ($query_id)
{ {
// global $phpgw;
// global $phpgw_info;
// $phpgw->db->Query_ID = $query_id; // $phpgw->db->Query_ID = $query_id;
$this->db->next_record (); $this->db->next_record ();
@ -48,8 +37,6 @@
*/ */
function db_call ($function, $query_id) function db_call ($function, $query_id)
{ {
// global $phpgw;
// global $phpgw_info;
// $phpgw->db->Query_ID = $query_id; // $phpgw->db->Query_ID = $query_id;
return $this->db->$function (); return $this->db->$function ();

View File

@ -51,11 +51,11 @@
var $todir; var $todir;
var $changedir; // for switching dir. var $changedir; // for switching dir.
var $cdtodir; // for switching dir. var $cdtodir; // for switching dir.
var $createdir; // var $createdir;
var $newfile_or_dir; var $newfile_or_dir;
var $newdir_x; var $newdir_x;
var $newfile_x; var $newfile_x;
var $createfile; var $createfile_var;
var $delete_x; var $delete_x;
var $renamefiles; var $renamefiles;
var $rename_x; var $rename_x;
@ -74,11 +74,12 @@
var $uploadprocess; var $uploadprocess;
// this ones must be checked thorougly; // this ones must be checked thorougly;
var $fileman; var $fileman = Array();
//var $fileman;
var $path; var $path;
var $file; var $file; // FIXME WHERE IS THIS FILLED?
var $sortby; var $sortby;
var $messages; var $messages = array();
var $show_upload_boxes; var $show_upload_boxes;
var $debug = false; var $debug = false;
@ -160,12 +161,12 @@
} }
// get appl. and user prefs // get appl. and user prefs
$pref = CreateObject('phpgwapi.preferences', $GLOBALS['userinfo']['username']); $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']);
$pref->read_repository(); $pref->read_repository();
// $GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); // $GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']);
$pref->save_repository(True); $pref->save_repository(True);
$pref_array = $pref->read_repository(); $pref_array = $pref->read_repository();
$this->prefs = $pref_array[$GLOBALS['appname']]; $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array
//always show name //always show name
@ -176,6 +177,78 @@
{ {
$this->target = '_blank'; $this->target = '_blank';
} }
/*
Check for essential directories
admin must be able to disable these tests
*/
// check if basedir exist
$test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
if($test[mime_type]!='Directory')
{
die('Base directory does not exist, Ask adminstrator to check the global configuration.');
}
$test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
if($test[mime_type]!='Directory')
{
$this->bo->vfs->override_acl = 1;
$this->bo->vfs->mkdir(array(
'string' => $this->bo->fakebase,
'relatives' => array(RELATIVE_NONE)
));
$this->bo->vfs->override_acl = 0;
//test one more time
$test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
if($test[mime_type]!='Directory')
{
die('Fake Base directory does not exist and could not be created, please ask the adminstrator to check the global configuration.');
}
else
{
$this->messages[]= $GLOBALS['phpgw']->common->error_list(array(
lang('Fake Base Dir did not exist, eGroupWare created a new one.')
));
}
}
// die($this->bo->homedir);
$test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
if($test[mime_type]!='Directory')
{
$this->bo->vfs->override_acl = 1;
$this->bo->vfs->mkdir(array(
'string' => $this->bo->homedir,
'relatives' => array(RELATIVE_NONE)
));
$this->bo->vfs->override_acl = 0;
//test one more time
$test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
if($test[mime_type]!='Directory')
{
die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.');
}
else
{
$this->messages[]= $GLOBALS['phpgw']->common->error_list(array(
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
}
}
} }
function index() function index()
@ -185,7 +258,7 @@
$noheader = True; $noheader = True;
$nofooter = True; $nofooter = True;
$noappheader= True; $noappheader= True;
$nonavbar=True; $nonavbar= True;
} }
else else
{ {
@ -203,8 +276,6 @@
} }
// var_dump($GLOBALS[HTTP_POST_VARS]);
//var_dump($this->delete_x);
# Page to process users # Page to process users
# Code is fairly hackish at the beginning, but it gets better # Code is fairly hackish at the beginning, but it gets better
@ -231,7 +302,7 @@
if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '')
{ {
$this->path = $GLOBALS['homedir']; $this->path = $this->bo->homedir;
} }
} }
@ -240,7 +311,7 @@
$pwd = $this->bo->vfs->pwd(); $pwd = $this->bo->vfs->pwd();
if(!$this->cwd = substr($this->path, strlen($GLOBALS['homedir']) + 1)) if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1))
{ {
$this->cwd = '/'; $this->cwd = '/';
} }
@ -293,61 +364,68 @@
# We determine if they're in their home directory or a group's directory, # We determine if they're in their home directory or a group's directory,
# and set the VFS working_id appropriately # and set the VFS working_id appropriately
if((preg_match('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined
{ {
$this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined
} }
else else
{ {
$this->bo->vfs->working_id = $GLOBALS['userinfo']['username']; $this->bo->vfs->working_id = $this->bo->userinfo['username'];
} }
# FIXME # comment waht happens here # FIXME # comment waht happens here
if($this->path != $GLOBALS['homedir'] && $this->path != $GLOBALS['fakebase'] && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ))) if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->bo->vfs->acl_check(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE),'operation' => PHPGW_ACL_READ)))
{ {
$this->messages.= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('You do not have access to %1', $this->path)));
$this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir'], lang('Go to your home directory')); $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory'));
$GLOBALS['phpgw']->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['phpgw']->common->phpgw_exit();
} }
$GLOBALS['userinfo']['working_id'] = $this->bo->vfs->working_id; $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id;
$GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['userinfo']['working_id']); $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']);
# If their home directory doesn't exist, we try to create it # If their home directory doesn't exist, we try to create it
# Same for group directories # Same for group directories
if(($this->path == $GLOBALS['homedir']) && !$this->bo->vfs->file_exists($pim_tmp_arr))
// Moved to constructor
/*
if(($this->path == $this->homedir) && !$this->bo->vfs->file_exists($pim_tmp_arr))
{ {
$this->bo->vfs->override_acl = 1; $this->bo->vfs->override_acl = 1;
if(!$this->bo->vfs->mkdir(array( if(!$this->bo->vfs->mkdir(array(
'string' => $GLOBALS['homedir'], 'string' => $this->bo->homedir,
'relatives' => array(RELATIVE_NONE) 'relatives' => array(RELATIVE_NONE)
))) )))
{ {
$p = $this->bo->vfs->path_parts($pim_tmp_arr); $p = $this->bo->vfs->path_parts($pim_tmp_arr);
$this->messages= $GLOBALS['phpgw']->common->error_list(array( $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(
lang('Could not create directory %1', lang('Could not create directory %1',
$GLOBALS['homedir'] . ' (' . $p->real_full_path . ')' $this->bo->homedir . ' (' . $p->real_full_path . ')'
))); )));
} }
$this->bo->vfs->override_acl = 0; $this->bo->vfs->override_acl = 0;
} }
*/
# Verify path is real # Verify path is real
if($this->path != $GLOBALS['homedir'] && $this->path != '/' && $this->path != $GLOBALS['fakebase']) if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase)
{ {
if(!$this->bo->vfs->file_exists(array( if(!$this->bo->vfs->file_exists(array(
'string' => $this->path, 'string' => $this->path,
'relatives' => array(RELATIVE_NONE) 'relatives' => array(RELATIVE_NONE)
))) )))
{ {
$this->messages = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path))); $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 does not exist', $this->path)));
$this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir'], lang('Go to your home directory')); $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory'));
$GLOBALS['phpgw']->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['phpgw']->common->phpgw_exit();
@ -465,8 +543,16 @@
$vars[toolbar0]=$this->toolbar('location'); $vars[toolbar0]=$this->toolbar('location');
$vars[toolbar1]=$this->toolbar('list_nav'); $vars[toolbar1]=$this->toolbar('list_nav');
if($this->messages) $this->messages='<p>'.$this->messages.'</p>';
$vars[messages]=$this->messages; if(count($this->messages)>0)
{
foreach($this->messages as $msg)
{
$messages.='<p>'.$msg.'</p>';
}
}
$vars[messages]=$messages;
$this->t->set_var($vars); $this->t->set_var($vars);
$this->t->pparse('out','filemanager_header'); $this->t->pparse('out','filemanager_header');
@ -492,7 +578,10 @@
} }
$this->t->set_var('row_tr_color','#dedede'); $this->t->set_var('row_tr_color','#dedede');
//kan dit weg?
$this->t->parse('rows','row'); $this->t->parse('rows','row');
$this->t->pparse('out','row'); $this->t->pparse('out','row');
} }
else else
@ -563,7 +652,7 @@
} }
# Checkboxes # Checkboxes
if(!$this->rename_x && !$this->edit_comments_x && $this->path != $GLOBALS['fakebase'] && $this->path != '/') if(!$this->rename_x && !$this->edit_comments_x && $this->path != $this->bo->fakebase && $this->path != '/')
{ {
$cbox='<input type="checkbox" name="fileman['.$i.']" value="'.$files['name'].'">'; $cbox='<input type="checkbox" name="fileman['.$i.']" value="'.$files['name'].'">';
$this->t->set_var('actions',$cbox); $this->t->set_var('actions',$cbox);
@ -598,10 +687,10 @@
else else
{ {
if($this->prefs['viewonserver'] && isset($GLOBALS['filesdir']) && !$files['link_directory']) if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory'])
{ {
#FIXME #FIXME
$clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; $clickview = $this->filesdir.$pwd.'/'.$files['name'];
if($phpwh_debug) if($phpwh_debug)
{ {
@ -768,10 +857,10 @@
$vars[lang_used_space]=lang('Used space'); $vars[lang_used_space]=lang('Used space');
$vars[used_space]=$this->bo->borkb($usedspace, NULL, 1); $vars[used_space]=$this->bo->borkb($usedspace, NULL, 1);
if($this->path == $GLOBALS['homedir'] || $this->path == $GLOBALS['fakebase']) if($this->path == $this->bo->homedir || $this->path == $this->bo->fakebase)
{ {
$vars[lang_unused_space]=lang('Unused space'); $vars[lang_unused_space]=lang('Unused space');
$vars[unused_space]=$this->bo->borkb($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1); $vars[unused_space]=$this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace, NULL, 1);
$tmp_arr=array( $tmp_arr=array(
'string' => $this->path, 'string' => $this->path,
@ -799,15 +888,16 @@
# $fakebase is a special directory. In that directory, we list the user's # $fakebase is a special directory. In that directory, we list the user's
# home directory and the directories for the groups they're in # home directory and the directories for the groups they're in
$this->numoffiles = 0; $this->numoffiles = 0;
if($this->path == $GLOBALS['fakebase']) if($this->path == $this->bo->fakebase)
{ {
if(!$this->bo->vfs->file_exists(array('string' => $GLOBALS['homedir'], 'relatives' => array(RELATIVE_NONE)))) // FIXME this test can be removed
if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))))
{ {
$this->bo->vfs->mkdir(array('string' => $GLOBALS['homedir'], 'relatives' => array(RELATIVE_NONE))); $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)));
} }
$ls_array = $this->bo->vfs->ls(array( $ls_array = $this->bo->vfs->ls(array(
'string' => $GLOBALS['homedir'], 'string' => $this->bo->homedir,
'relatives' => array(RELATIVE_NONE), 'relatives' => array(RELATIVE_NONE),
'checksubdirs' => False, 'checksubdirs' => False,
'nofiles' => True 'nofiles' => True
@ -819,26 +909,29 @@
while(list($num, $group_array) = each($this->readable_groups)) while(list($num, $group_array) = each($this->readable_groups))
{ {
# If the group doesn't have access to this app, we don't show it # If the group doesn't have access to this app, we don't show it
if(!$this->groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
{ {
continue; continue;
} }
if(!$this->bo->vfs->file_exists(array('string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE)))) if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE))))
{ {
$this->bo->vfs->override_acl = 1; $this->bo->vfs->override_acl = 1;
$this->bo->vfs->mkdir(array( $this->bo->vfs->mkdir(array(
'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], 'string' => $this->bo->fakebase.'/'.$group_array['account_name'],
'relatives' => array(RELATIVE_NONE) 'relatives' => array(RELATIVE_NONE)
)); ));
// FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content
$this->bo->vfs->override_acl = 0; $this->bo->vfs->override_acl = 0;
$this->bo->vfs->set_attributes(array('string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id']))); $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'attributes' => array('owner_id' => $group_array['account_id'],'createdby_id' => $group_array['account_id'])));
} }
$ls_array = $this->bo->vfs->ls(array('string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives' => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True));
$this->files_array[] = $ls_array[0]; $this->files_array[] = $ls_array[0];
@ -900,9 +993,9 @@
} }
// go home icon when we're not home already // go home icon when we're not home already
if($this->path != $GLOBALS['homedir']) if($this->path != $this->bo->homedir)
{ {
$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir']); $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir);
$toolbar.=$this->buttonImage($link,'home',lang('go home')); $toolbar.=$this->buttonImage($link,'home',lang('go home'));
} }
@ -920,7 +1013,7 @@
'; ';
$toolbar.=$this->inputImage('goto','goto',lang('Quick jump to')); $toolbar.=$this->inputImage('goto','goto',lang('Quick jump to'));
// upload button // upload button
if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
{ {
$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
@ -940,7 +1033,7 @@
<tr>'; <tr>';
// selectbox for change/move/and copy to // selectbox for change/move/and copy to
// submit buttons for // submit buttons for
if($this->path != '/' && $this->path != $GLOBALS['fakebase']) if($this->path != '/' && $this->path != $this->bo->fakebase)
{ {
$toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
$toolbar.=' $toolbar.='
@ -973,7 +1066,7 @@
if(!$this->rename_x && !$this->edit_comments_x) if(!$this->rename_x && !$this->edit_comments_x)
{ {
// copy and move buttons // copy and move buttons
if($this->path != '/' && $this->path != $GLOBALS['fakebase']) if($this->path != '/' && $this->path != $this->bo->fakebase)
{ {
$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
@ -989,7 +1082,7 @@
} }
// create dir and file button // create dir and file button
if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
{ {
$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>'; $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
$toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>'; $toolbar3.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
@ -1023,13 +1116,13 @@
# Handle File Uploads # Handle File Uploads
function fileUpload() function fileUpload()
{ {
if($this->path != '/' && $this->path != $GLOBALS['fakebase']) if($this->path != '/' && $this->path != $this->bo->fakebase)
{ {
for($i = 0; $i != $this->show_upload_boxes; $i++) for($i = 0; $i != $this->show_upload_boxes; $i++)
{ {
if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True))
{ {
$this->messages.= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1)));
continue; continue;
} }
@ -1048,7 +1141,7 @@
{ {
if($fileinfo['mime_type'] == 'Directory') if($fileinfo['mime_type'] == 'Directory')
{ {
$this->messages.= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot replace %1 because it is a directory', $fileinfo['name'])));
continue; continue;
} }
} }
@ -1061,8 +1154,8 @@
'string'=> $_FILES['upload_file']['name'][$i], 'string'=> $_FILES['upload_file']['name'][$i],
'relatives' => array(RELATIVE_ALL), 'relatives' => array(RELATIVE_ALL),
'attributes' => array( 'attributes' => array(
'owner_id' => $GLOBALS['userinfo']['username'], 'owner_id' => $this->bo->userinfo['username'],
'modifiedby_id' => $GLOBALS['userinfo']['username'], 'modifiedby_id' => $this->bo->userinfo['username'],
'modified' => $this->now, 'modified' => $this->now,
'size' => $_FILES['upload_file']['size'][$i], 'size' => $_FILES['upload_file']['size'][$i],
'mime_type' => $_FILES['upload_file']['type'][$i], 'mime_type' => $_FILES['upload_file']['type'][$i],
@ -1079,7 +1172,7 @@
); );
$this->bo->vfs->cp($tmp_arr); $this->bo->vfs->cp($tmp_arr);
$this->messages.=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); $this->messages[]=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]);
} }
else else
{ {
@ -1099,7 +1192,7 @@
) )
)); ));
$this->messages.=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]); $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]);
} }
} }
elseif($_FILES['upload_file']['name'][$i]) elseif($_FILES['upload_file']['name'][$i])
@ -1118,7 +1211,7 @@
) )
)); ));
$this->messages.=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]); $this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]);
} }
} }
@ -1134,7 +1227,7 @@
{ {
if($badchar = $this->bo->bad_chars($this->comment_files[$file], False, True)) if($badchar = $this->bo->bad_chars($this->comment_files[$file], False, True))
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($file . $this->bo->html_encode(': ' . lang('Comments cannot contain "%1"', $badchar), 1)));
continue; continue;
} }
@ -1146,7 +1239,7 @@
) )
)); ));
$this->messages=lang('Updated comment for %1', $this->path.'/'.$file); $this->messages[]=lang('Updated comment for %1', $this->path.'/'.$file);
} }
$this->readFilesInfo(); $this->readFilesInfo();
@ -1160,24 +1253,24 @@
{ {
if($badchar = $this->bo->bad_chars($to, True, True)) if($badchar = $this->bo->bad_chars($to, True, True))
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('File names cannot contain "%1"', $badchar), 1)));
continue; continue;
} }
if(ereg("/", $to) || ereg("\\\\", $to)) if(ereg("/", $to) || ereg("\\\\", $to))
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /"))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang("File names cannot contain \\ or /")));
} }
elseif(!$this->bo->vfs->mv(array( elseif(!$this->bo->vfs->mv(array(
'from' => $from, 'from' => $from,
'to' => $to 'to' => $to
))) )))
{ {
$this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to)));
} }
else else
{ {
$this->messages=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); $this->messages[]=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to);
} }
} }
$this->readFilesInfo(); $this->readFilesInfo();
@ -1196,11 +1289,11 @@
))) )))
{ {
$moved++; $moved++;
$this->messages=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); $this->messages[]=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file);
} }
else else
{ {
$this->messages = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file)));
} }
} }
@ -1248,13 +1341,13 @@
{ {
if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True))
{ {
$this->messages= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array($this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1)));
} }
/* TODO is this right or should it be a single $ ? */ /* TODO is this right or should it be a single $ ? */
if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ')
{ {
$this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space'))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Cannot create directory because it begins or ends in a space')));
} }
$ls_array = $this->bo->vfs->ls(array( $ls_array = $this->bo->vfs->ls(array(
@ -1270,25 +1363,25 @@
{ {
if($fileinfo['mime_type'] != 'Directory') if($fileinfo['mime_type'] != 'Directory')
{ {
$this->messages= $GLOBALS['phpgw']->common->error_list(array( $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(
lang('%1 already exists as a file', lang('%1 already exists as a file',
$fileinfo['name']) $fileinfo['name'])
)); ));
} }
else else
{ {
$this->messages= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name']))); $this->messages[]= $GLOBALS['phpgw']->common->error_list(array(lang('Directory %1 already exists', $fileinfo['name'])));
} }
} }
else else
{ {
if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir))) if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir)))
{ {
$this->messages=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir);
} }
else else
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir)));
} }
} }
@ -1305,18 +1398,18 @@
{ {
if($this->bo->vfs->delete(array('string' => $filename))) if($this->bo->vfs->delete(array('string' => $filename)))
{ {
$this->messages .= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>'; $this->messages[]= lang('Deleted %1', $this->disppath.'/'.$filename).'<br/>';
} }
else else
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Could not delete %1', $this->disppath.'/'.$filename)));
} }
} }
} }
else else
{ {
// make this a javascript func for quicker respons // make this a javascript func for quicker respons
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.'))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('Please select a file to delete.')));
} }
$this->readFilesInfo(); $this->readFilesInfo();
$this->filelisting(); $this->filelisting();
@ -1359,7 +1452,7 @@
} }
# Show file upload boxes. Note the last argument to html(). Repeats $this->show_upload_boxes times # Show file upload boxes. Note the last argument to html(). Repeats $this->show_upload_boxes times
if($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
{ {
$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); $vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index');
$vars[path]=$this->path; $vars[path]=$this->path;
@ -1396,12 +1489,12 @@
/* create textfile */ /* create textfile */
function createfile() function createfile()
{ {
$this->createfile=$this->newfile_or_dir; $this->createfile_var=$this->newfile_or_dir;
if($this->createfile) if($this->createfile_var)
{ {
if($badchar = $this->bo->bad_chars($this->createfile, True, True)) if($badchar = $this->bo->bad_chars($this->createfile_var, True, True))
{ {
$this->messages = $GLOBALS['phpgw']->common->error_list(array( $this->messages[] = $GLOBALS['phpgw']->common->error_list(array(
lang('File names cannot contain "%1"',$badchar), lang('File names cannot contain "%1"',$badchar),
1) 1)
); );
@ -1410,28 +1503,28 @@
} }
if($this->bo->vfs->file_exists(array( if($this->bo->vfs->file_exists(array(
'string'=> $this->createfile, 'string'=> $this->createfile_var,
'relatives' => array(RELATIVE_ALL) 'relatives' => array(RELATIVE_ALL)
))) )))
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 already exists. Please edit it or delete it first.', $this->createfile_var)));
$this->fileListing(); $this->fileListing();
} }
if($this->bo->vfs->touch(array( if($this->bo->vfs->touch(array(
'string' => $this->createfile, 'string' => $this->createfile_var,
'relatives' => array(RELATIVE_ALL) 'relatives' => array(RELATIVE_ALL)
))) )))
{ {
$this->fileman = array(); $this->fileman = array();
$this->fileman[0] = $this->createfile; $this->fileman[0] = $this->createfile_var;
$this->edit = 1; $this->edit = 1;
$this->numoffiles++; $this->numoffiles++;
$this->edit(); $this->edit();
} }
else else
{ {
$this->messages=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile))); $this->messages[]=$GLOBALS['phpgw']->common->error_list(array(lang('File %1 could not be created.', $this->createfile_var)));
$this->fileListing(); $this->fileListing();
} }
} }
@ -1469,7 +1562,7 @@
'content' => $content 'content' => $content
))) )))
{ {
$this->messages=lang('Saved %1', $this->path.'/'.$this->edit_file); $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file);
if($this->edit_save_done_x) if($this->edit_save_done_x)
{ {
@ -1480,7 +1573,7 @@
} }
else else
{ {
$this->messages=lang('Could not save %1', $this->path.'/'.$this->edit_file); $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file);
} }
} }
@ -1535,10 +1628,10 @@
function history() function history()
{ {
if($this->file) if($this->file) // FIXME this-file is never defined
{ {
$journal_array = $this->bo->vfs->get_journal(array( $journal_array = $this->bo->vfs->get_journal(array(
'string' => $this->file, 'string' => $this->file,//FIXME
'relatives' => array(RELATIVE_ALL) 'relatives' => array(RELATIVE_ALL)
)); ));
@ -1590,10 +1683,10 @@
function view() function view()
{ {
if($this->file) if($this->file) //FIXME
{ {
$ls_array = $this->bo->vfs->ls(array( $ls_array = $this->bo->vfs->ls(array(
'string' => $this->path.'/'.$this->file, 'string' => $this->path.'/'.$this->file,//FIXME
'relatives' => array(RELATIVE_ALL), 'relatives' => array(RELATIVE_ALL),
'checksubdirs' => False, 'checksubdirs' => False,
'nofiles' => True 'nofiles' => True
@ -1612,14 +1705,14 @@
if(in_array($mime_type,$viewable)) if(in_array($mime_type,$viewable))
{ {
header('Content-type: ' . $mime_type); header('Content-type: ' . $mime_type);
header('Content-disposition: filename="' . $this->file . '"'); header('Content-disposition: filename="' . $this->file . '"');//FIXME
} }
else else
{ {
$GLOBALS['phpgw']->browser->content_header($this->file,$mime_type); $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME
} }
echo $this->bo->vfs->read(array( echo $this->bo->vfs->read(array(
'string' => $this->path.'/'.$this->file, 'string' => $this->path.'/'.$this->file,//FIXME
'relatives' => array(RELATIVE_NONE) 'relatives' => array(RELATIVE_NONE)
)); ));
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['phpgw']->common->phpgw_exit();
@ -1647,10 +1740,10 @@
{ {
# First we get the directories in their home directory # First we get the directories in their home directory
$dirs = array(); $dirs = array();
$dirs[] = array('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']);
$tmp_arr=array( $tmp_arr=array(
'string' => $GLOBALS['homedir'], 'string' => $this->bo->homedir,
'relatives' => array(RELATIVE_NONE), 'relatives' => array(RELATIVE_NONE),
'checksubdirs' => True, 'checksubdirs' => True,
'mime_type' => 'Directory' 'mime_type' => 'Directory'
@ -1669,15 +1762,15 @@
while(list($num, $group_array) = each($this->readable_groups)) while(list($num, $group_array) = each($this->readable_groups))
{ {
# Don't list directories for groups that don't have access # Don't list directories for groups that don't have access
if(!$this->groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
{ {
continue; continue;
} }
$dirs[] = array('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']);
$tmp_arr=array( $tmp_arr=array(
'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], 'string' => $this->bo->fakebase.'/'.$group_array['account_name'],
'relatives' => array(RELATIVE_NONE), 'relatives' => array(RELATIVE_NONE),
'checksubdirs' => True, 'checksubdirs' => True,
'mime_type' => 'Directory' 'mime_type' => 'Directory'

File diff suppressed because it is too large Load Diff