True,
'action' => True,
'help' => True,
'history' => True,
'view' => True,
'view_file' => True
);
var $bo;
var $nextmatchs;
var $browser;
var $tempalte_dir;
var $help_info;
function uiphpwebhosting()
{
$this->bo = CreateObject('phpwebhosting.bophpwebhosting');
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->browser = CreateObject('phpgwapi.browser');
$this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir($GLOBALS['phpgw_info']['flags']['currentapp']);
$this->load_header();
$this->check_access();
$this->create_home_dir();
$this->verify_path();
$this->update();
}
function load_header()
{
if(($this->bo->download && (count($this->bo->fileman) > 0)) || ($this->bo->op == 'view' && $this->bo->file) || ($this->bo->op == 'history' && $this->bo->file) || ($this->bo->op == 'help' && $this->bo->help_name) || ($this->bo->delete && count($this->bo->fileman) > 0) || ($this->bo->go && isset($this->bo->todir)))
{
}
else
{
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
unset($GLOBALS['phpgw_info']['flags']['noappheader']);
unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
$GLOBALS['phpgw']->common->phpgw_header();
}
}
function check_access()
{
if($this->bo->path != $this->bo->homedir && $this->bo->path != $this->bo->fakebase && $this->bo->path != '/' && !$this->bo->vfs->acl_check($this->bo->path,Array(RELATIVE_NONE),PHPGW_ACL_READ))
{
$this->no_access_exists(lang('You do not have access to X',$this->bo->path));
}
$this->bo->userinfo['working_id'] = $this->bo->vfs->working_id;
$this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']);
}
function no_access_exists($error_msg)
{
if($this->bo->debug)
{
echo 'DEBUG: ui.no_access_exists: you do not have access to this directory
'."\n";
}
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_unknowns('remove');
$p->set_file(
Array(
'_errors' => 'errors.tpl'
)
);
$p->set_block('_errors','error_page','error_page');
$p->set_block('_errors','ind_error','ind_error');
$p->set_var('error',$error_msg);
$p->parse('errors','ind_error',True);
$p->set_var('error','
Go to your Home directory'
);
$p->parse('errors','ind_error',True);
$p->pfp('output','error_page');
$GLOBALS['phpgw']->common->phpgw_exit();
}
function create_home_dir()
{
###
# If their home directory doesn't exist, we create it
# Same for group directories
###
if($this->bo->debug)
{
echo 'DEBUG: ui.create_home_dir: PATH = '.$this->bo->path.'
'."\n";
echo 'DEBUG: ui.create_home_dir: PATH = '.urlencode($this->bo->path).'
'."\n";
}
if(($this->bo->path == $this->bo->homedir) && !$this->bo->vfs->file_exists($this->bo->homedir,Array(RELATIVE_NONE)))
{
//$this->bo->vfs->override_acl = 1;
$this->bo->vfs->mkdir($this->bo->homedir,Array(RELATIVE_NONE));
//$this->bo->vfs->override_acl = 0;
}
// elseif(preg_match("|^".$this->bo->fakebase."\/(.*)$|U",$this->bo->path,$this->bo->matches))
// {
// if (!$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE)))
// {
// //$this->bo->vfs->override_acl = 1;
// $this->bo->vfs->mkdir($this->bo->path,Array(RELATIVE_NONE));
// //$this->bo->vfs->override_acl = 0;
//
// if($this->bo->debug)
// {
// echo 'DEBUG: ui.create_home_dir: PATH = '.$this->bo->path.'
'."\n";
// echo 'DEBUG: ui.create_home_dir(): matches[1] = '.$this->bo->matches[1].'
'."\n";
// }
//
// $group_id = $GLOBALS['phpgw']->accounts->name2id($this->bo->matches[1]);
// if($group_id)
// {
// $this->bo->vfs->set_attributes($this->bo->path,Array(RELATIVE_NONE),Array('owner_id' => $group_id, 'createdby_id' => $group_id));
// }
// }
// }
}
function verify_path()
{
###
# Verify path is real
###
if($this->bo->debug)
{
echo 'DEBUG: ui.verify_path: PATH = '.$this->bo->path.'
'."\n";
echo 'DEBUG: ui.verify_path: exists = '.$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE)).'
'."\n";
}
if($this->bo->path != $this->bo->homedir &&
$this->bo->path != '/' &&
$this->bo->path != $this->bo->fakebase &&
!$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE)))
{
$this->no_access_exists(lang('Directory '.$this->bo->path.' does not exist'));
}
}
function update()
{
/* Update if they request it, or one out of 20 page loads */
srand ((double) microtime() * 1000000);
if($this->bo->update || rand(0, 19) == 4)
{
$this->bo->vfs->update_real($this->bo->path,Array(RELATIVE_NONE));
}
if($this->bo->update)
{
// This needs to redirect to the index after the user issues an update.....
}
}
function action()
{
$actions = Array(
'delete' => lang('Delete'),
'go' => lang('Go To')
);
@reset($actions);
while(list($function,$text) = each($actions))
{
if(isset($this->bo->$function) && !empty($this->bo->$function) && trim($this->bo->$function) == $text)
{
if($this->bo->$function == 'go')
{
echo 'To Dir = '.$this->bo->todir.'
'."\n";
}
$this->bo->$function();
}
}
}
function help()
{
$this->bo->load_help_info();
@reset($this->bo->help_info);
while(list($num,$help_array) = each($this->bo->help_info))
{
if ($help_array[0] != $this->bo->help_name)
{
continue;
}
$help_array[1] = preg_replace("/\[(.*)\|(.*)\]/Ue","\$this->build_help('\\1','\\2')",$help_array[1]);
$help_array[1] = preg_replace("/\[(.*)\]/Ue","\$this->build_help('\\1','\\1')",$help_array[1]);
echo ''."\n".ucwords(str_replace('_',' ',$help_array[0]))."\n".''."\n";
echo ''."\n".$help_array[1].'';
}
$GLOBALS['phpgw']->common->phpgw_exit ();
}
function build_help($help_option,$text='')
{
if($this->bo->settings['show_help'])
{
$help = ($text?'':''."\n");
$help .= ' ';
$help .= ($text?$text:'[?]');
$help .= '';
$help .= ($text?'':"\n".' ');
return $help;
}
else
{
return '';
}
}
function image($image,$alt)
{
return '';
}
function link($array_params,$text)
{
return ''.$text.'';
}
function build_upload_choices($number)
{
return $this->link(
Array(
'menuaction' => $GLOBALS['HTTP_GET_VARS']['menuaction'],
'path' => $this->bo->path,
'show_upload_boxes' => $number
),
$number).' ';
}
function column_header($internal,$displayed,$link=True)
{
if($link)
{
$header_str = ''.lang($displayed).''.$this->build_help(ereg_replace(' ','_',$displayed));
}
else
{
$header_str = $displayed.$this->build_help(ereg_replace(' ','_',$displayed));
}
return Array(
'td_extras' => '',
'column_header' => $header_str
);
}
function display_buttons()
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_buttons' => 'small_table.tpl'
)
);
$p->set_block('_buttons','table','table');
$p->set_block('_buttons','column_headers','column_headers');
$p->set_block('_buttons','column_headers_normal','column_headers_normal');
$p->set_block('_buttons','column_rows','column_rows');
$var = Array(
'table_extras' => '',
'tr_extras' => '',
'td_extras' => ' align="center" width="25%"'
);
$var['column_header'] = ''.$this->build_help('edit');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$var['column_header'] = ''.$this->build_help('rename');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = ''.$this->build_help('delete');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = ''.$this->build_help('edit_comments');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$var['column_header'] = ''.$this->build_help('go_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$var['column_header'] = ''.$this->build_help('copy_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = ''.$this->build_help('move_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
###
# First we get the directories in their home directory
###
$dirs[] = Array(
'directory' => $this->bo->fakebase,
'name' => $this->bo->userinfo['account_lid']
);
$ls_array = $this->bo->vfs->ls($this->bo->homedir,Array(RELATIVE_NONE),True,'Directory');
while(list($num,$dir) = each($ls_array))
{
$dirs[] = $dir;
}
###
# Then we get the directories in their membership's home directories
###
reset($this->bo->memberships);
while(list($num,$group_array) = each($this->bo->memberships))
{
###
# Don't list directories for groups that don't have access
###
if(!$this->bo->membership_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
{
continue;
}
$dirs[] = Array(
'directory' => $this->bo->fakebase,
'name' => $group_array['account_name']
);
$ls_array = $this->bo->vfs->ls($this->bo->fakebase.SEP.$group_array['account_name'],Array(RELATIVE_NONE),True,'Directory');
while(list($num,$dir) = each($ls_array))
{
$dirs[] = $dir;
}
}
$dir_list = '';
reset($dirs);
while(list($num, $dir) = each($dirs))
{
if(!$dir['directory'])
{
continue;
}
###
# So we don't display //
###
if($dir['directory'] != '/')
{
$dir['directory'] .= SEP;
}
$selected = '';
if($num == 0)
{
$selected = ' selected';
}
###
# No point in displaying the current directory, or a directory that doesn't exist
###
if((($dir['directory'].$dir['name']) != $this->bo->path) && $this->bo->vfs->file_exists($dir['directory'].$dir['name'],Array(RELATIVE_NONE)))
{
$dir_list .= '';
}
}
$var['column_header'] = ''.$this->build_help('directory_list');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
$var = Array(
'tr_extras' => '',
'td_extras' => ' colspan="2" align="center" width="50%"'
);
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
{
$var['column_header'] = ''.$this->build_help('download');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = ' '.$this->build_help('create_folder');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
}
$var['column_header'] = ''.$this->build_help('update');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
{
$var['column_header'] = ' '.$this->build_help('create_file');
}
else
{
$var['column_header'] = ' ';
}
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
if($this->bo->settings['show_command_line'])
{
$var = Array(
'tr_extras' => '',
'td_extras' => ' colspan="4" align="center" width="100%"',
'column_header' => ''.$this->build_help('command_line').''.$this->build_help('execute')
);
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
}
return $p->fp('output','table');
}
function display_summary_info($numoffiles,$usedspace)
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_info' => 'small_table.tpl'
)
);
$p->set_block('_info','table','table');
$p->set_block('_info','column_headers','column_headers');
$p->set_block('_info','column_headers_normal','column_headers_normal');
$p->set_block('_info','column_rows','column_rows');
$this_homedir = ($this->bo->path == $this->bo->homedir || $this->bo->path == $this->bo->fakedir);
$info_columns = 4 + ($this_homedir?2:0);
$var = Array(
'table_extras' => ' cols="'.$info_columns.'"',
'tr_extras' => '',
'td_extras' => ' colspan="'.$info_columns.'" align="center" width="100%"',
'column_header' => $this->build_help('file_stats')
);
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
$var = Array(
'tr_extras' => '',
'td_extras' => ' align="right"'
);
$var['column_header'] = ''.lang('Files').':';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $numoffiles;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="right"';
$var['column_header'] = ''.lang('Used Space').':';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $this->bo->borkb($usedspace);
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
if($this_homedir)
{
$var['td_extras'] = ' align="right"';
$var['column_header'] = ''.lang('Unused space').':';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace);
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
}
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
if($this_homedir)
{
$var['td_extras'] = ' colspan="'.($info_columns / 2).'" align="right" width="50%"';
$var['column_header'] = ''.lang('Total Files').':';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' colspan="'.($info_columns / 2).'" align="left" width="50%"';
$var['column_header'] = count($this->bo->vfs->ls($this->bo->path,Array(RELATIVE_NONE)));
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
}
return $p->fp('output','table');
}
function display_uploads()
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_uploads' => 'small_table.tpl'
)
);
$p->set_block('_uploads','table','table');
$p->set_block('_uploads','column_headers','column_headers');
$p->set_block('_uploads','column_headers_normal','column_headers_normal');
$p->set_block('_uploads','column_rows','column_rows');
$var = Array(
'table_extras' => ' cols="3"',
'tr_extras' => ''
);
$var['td_extras'] = ' align="right" width="45%"';
$var['column_header'] = ''.lang('File').''.$this->build_help('upload_file');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' align="center" width="10%"';
$var['column_header'] = ' ';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left" width="45%"';
$var['column_header'] = ''.lang('Comment').''.$this->build_help('upload_comment');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$p->parse('list','column_rows',True);
$input_file = '';
$input_comment = '';
$var['tr_extras'] = '';
$var['td_extras'] = ' colspan="3" align="center"';
$var['column_header'] = ''."\n".$input_file.$input_comment;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
for($i=1;$i<$this->bo->show_upload_boxes;$i++)
{
$var['column_header'] = $input_file.$input_comment;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
}
$var['column_header'] = ''.$this->build_help('upload_files');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
$var['column_header'] = lang('Show').' '.$this->build_upload_choices(5).$this->build_upload_choices(10).$this->build_upload_choices(20).$this->build_upload_choices(30).lang('upload fields').$this->build_help('show_upload_fields');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
return '
'."\n"
. ' TYPE: '.$this->bo->vfs->file_type($file,Array(RELATIVE_NONE)).' '."\n" . ' | '."\n"
. '
'."\n" . ' FILENAME: '.$file."\n" . ' | '."\n" . '
'."\n" . ' VERSION: '.$this->bo->vfs->get_version($file,Array(RELATIVE_NONE))."\n" . ' | '."\n" . '
'."\n" . $file_content."\n" . ' | '."\n" . '