2001-12-15 05:24:37 +01:00
|
|
|
<?php
|
2002-02-14 03:16:14 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare *
|
|
|
|
* This file written by Mark A Peters (Skeeter) <skeeter@phpgroupware.org> *
|
2003-03-04 01:04:06 +01:00
|
|
|
* Modified by Jonathon Sim <sim@zeald.com> for Zeald Ltd *
|
|
|
|
* User interface for the filemanager app *
|
|
|
|
* Copyright (C) 2002 Mark A Peters (C) 2003 Zeald Ltd *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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. *
|
2002-02-14 03:16:14 +01:00
|
|
|
\**************************************************************************/
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
|
2002-02-14 03:16:14 +01:00
|
|
|
/* $Id$ */
|
2003-03-04 01:04:06 +01:00
|
|
|
define('UI_DEBUG', 0);
|
2001-12-15 05:24:37 +01:00
|
|
|
|
2002-09-21 07:26:43 +02:00
|
|
|
class uifilemanager
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
var $public_functions = array(
|
|
|
|
'index' => True,
|
2001-12-20 03:11:29 +01:00
|
|
|
'action' => True,
|
|
|
|
'help' => True,
|
|
|
|
'history' => True,
|
2001-12-15 05:24:37 +01:00
|
|
|
'view' => True,
|
2001-12-24 04:08:32 +01:00
|
|
|
'view_file' => True,
|
2003-03-04 01:04:06 +01:00
|
|
|
'edit' => True,
|
|
|
|
'rename' => True,
|
|
|
|
'edit_comments' => True
|
2001-12-15 05:24:37 +01:00
|
|
|
);
|
2003-03-04 01:04:06 +01:00
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
var $bo;
|
|
|
|
var $nextmatchs;
|
|
|
|
var $browser;
|
2001-12-24 05:30:55 +01:00
|
|
|
var $template_dir;
|
2001-12-15 05:24:37 +01:00
|
|
|
var $help_info;
|
2003-03-04 01:04:06 +01:00
|
|
|
var $mime_ico = array (
|
2003-03-04 04:03:00 +01:00
|
|
|
'application/pdf' => 'pdf',
|
|
|
|
'application/postscript' => 'postscript',
|
|
|
|
'application/msword' => 'word',
|
|
|
|
'application/vnd.ms-excel' => 'excel',
|
|
|
|
'application/vnd.ms-powerpoint' => 'ppt',
|
|
|
|
'application/x-gzip' => 'tgz',
|
|
|
|
'application/x-bzip' => 'tgz',
|
|
|
|
'application/zip' => 'tgz',
|
|
|
|
'application/x-debian-package' => 'deb',
|
|
|
|
'application/x-rpm' => 'rpm',
|
|
|
|
'application' => 'document',
|
|
|
|
'application/octet-stream' => 'unknown',
|
|
|
|
'audio' => 'sound',
|
|
|
|
'audio/mpeg' => 'sound',
|
|
|
|
'Directory' => 'folder',
|
|
|
|
'exe' => 'exe',
|
|
|
|
'image' => 'image',
|
|
|
|
'text' => 'txt',
|
|
|
|
'text/html' => 'html',
|
|
|
|
'text/plain' => 'txt',
|
|
|
|
'text/xml' => 'html',
|
|
|
|
'text/x-vcalendar' => 'vcalendar',
|
|
|
|
'text/calendar' => 'vcalendar',
|
|
|
|
'text/x-vcard' => 'vcard',
|
|
|
|
'text/x-tex' => 'tex',
|
|
|
|
'unknown' => 'unknown',
|
|
|
|
'video' => 'video',
|
|
|
|
'message' => 'message'
|
2003-03-04 01:04:06 +01:00
|
|
|
);
|
2001-12-15 05:24:37 +01:00
|
|
|
|
2002-09-21 07:26:43 +02:00
|
|
|
function uifilemanager()
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-06 02:11:43 +01:00
|
|
|
$this->no_header();
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->actions = CreateObject('filemanager.uiactions');
|
2002-09-21 07:26:43 +02:00
|
|
|
$this->bo = CreateObject('filemanager.bofilemanager');
|
2001-12-15 05:24:37 +01:00
|
|
|
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
|
|
|
$this->browser = CreateObject('phpgwapi.browser');
|
2003-03-06 02:11:43 +01:00
|
|
|
//$this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir($GLOBALS['phpgw_info']['flags']['currentapp']);
|
2001-12-15 05:24:37 +01:00
|
|
|
$this->check_access();
|
|
|
|
$this->create_home_dir();
|
|
|
|
$this->verify_path();
|
|
|
|
$this->update();
|
2003-04-08 22:47:38 +02:00
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function load_header()
|
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
|
|
|
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
|
|
|
unset($GLOBALS['phpgw_info']['flags']['noappheader']);
|
|
|
|
unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
|
2003-03-06 23:15:58 +01:00
|
|
|
unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
|
|
|
|
unset($GLOBALS['phpgw_info']['flags']['headonly']);
|
2003-04-08 22:47:38 +02:00
|
|
|
$GLOBALS['phpgw']->xslttpl->add_file(array('widgets'));
|
2003-03-06 02:11:43 +01:00
|
|
|
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'app_header'));
|
2003-04-08 22:47:38 +02:00
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-06 02:11:43 +01:00
|
|
|
function no_header()
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw_info']['flags']['noheader'] = True;
|
|
|
|
$GLOBALS['phpgw_info']['flags']['nonavbar'] = True;
|
|
|
|
$GLOBALS['phpgw_info']['flags']['noappheader'] = True;
|
|
|
|
$GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
|
|
|
|
$GLOBALS['phpgw_info']['flags']['headonly'] = True;
|
2003-04-08 22:47:38 +02:00
|
|
|
$GLOBALS['phpgw']->xslttpl->add_file(array('widgets'));
|
2003-03-06 02:11:43 +01:00
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
|
2003-03-06 02:11:43 +01:00
|
|
|
}
|
2001-12-15 05:24:37 +01:00
|
|
|
function check_access()
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
if($this->bo->path != $this->bo->homedir && $this->bo->path != $this->bo->fakebase && $this->bo->path != '/' && !$this->bo->vfs->acl_check(array(
|
|
|
|
'string'=>$this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE),
|
|
|
|
'operation' => PHPGW_ACL_READ)))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 04:03:00 +01:00
|
|
|
$this->no_access_exists(lang('you do not have access to %1',$this->bo->path));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
$this->bo->userinfo['working_id'] = $this->bo->vfs->working_id;
|
|
|
|
$this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']);
|
|
|
|
}
|
|
|
|
|
2003-03-04 04:03:00 +01:00
|
|
|
/**TODO: xslt-ise this (and get rid of the hard-coded html)*/
|
2001-12-15 05:24:37 +01:00
|
|
|
function no_access_exists($error_msg)
|
|
|
|
{
|
|
|
|
if($this->bo->debug)
|
|
|
|
{
|
|
|
|
echo 'DEBUG: ui.no_access_exists: you do not have access to this directory<br>'."\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','<br><br>Go to your <a href="'.$GLOBALS['phpgw']->link('/index.php',
|
|
|
|
Array(
|
2001-12-24 04:18:50 +01:00
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->homedir)
|
2001-12-15 05:24:37 +01:00
|
|
|
)
|
|
|
|
).'">Home</a> directory'
|
|
|
|
);
|
|
|
|
$p->parse('errors','ind_error',True);
|
|
|
|
$p->pfp('output','error_page');
|
2003-03-04 01:04:06 +01:00
|
|
|
exit();
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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.'<br>'."\n";
|
|
|
|
echo 'DEBUG: ui.create_home_dir: PATH = '.urlencode($this->bo->path).'<br>'."\n";
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
if(($this->bo->path == $this->bo->homedir) && !$this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $this->bo->homedir,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->bo->vfs->override_acl = 1;
|
|
|
|
if (!$this->bo->vfs->mkdir(array(
|
|
|
|
'string' => $this->bo->homedir,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2002-02-14 03:16:14 +01:00
|
|
|
{
|
2003-03-06 23:15:58 +01:00
|
|
|
//TODO: xsltise echo lang('failed to create directory') . ' :'. $this->bo->homedir . "\n";
|
2002-02-14 03:16:14 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->bo->vfs->override_acl = 0;
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2001-12-24 05:30:55 +01:00
|
|
|
elseif(preg_match("|^".$this->bo->fakebase."\/(.*)$|U",$this->bo->path,$this->bo->matches))
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
if (!$this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-24 05:30:55 +01:00
|
|
|
{
|
|
|
|
//$this->bo->vfs->override_acl = 1;
|
2003-03-04 01:04:06 +01:00
|
|
|
if (!$this->bo->vfs->mkdir(array(
|
|
|
|
'string' => $this->bo->homedir,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2002-02-14 03:16:14 +01:00
|
|
|
{
|
2003-03-06 23:15:58 +01:00
|
|
|
//TODO: xsltise echo lang('failed to create directory') . ' <b>'. $this->bo->homedir . '</b><br><br>';
|
2002-02-14 03:16:14 +01:00
|
|
|
}
|
2001-12-24 05:30:55 +01:00
|
|
|
//$this->bo->vfs->override_acl = 0;
|
|
|
|
|
|
|
|
if($this->bo->debug)
|
|
|
|
{
|
|
|
|
echo 'DEBUG: ui.create_home_dir: PATH = '.$this->bo->path.'<br>'."\n";
|
|
|
|
echo 'DEBUG: ui.create_home_dir(): matches[1] = '.$this->bo->matches[1].'<br>'."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$group_id = $GLOBALS['phpgw']->accounts->name2id($this->bo->matches[1]);
|
|
|
|
if($group_id)
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->bo->vfs->set_attributes(array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE),
|
|
|
|
'attributes' => Array('owner_id' => $group_id, 'createdby_id' => $group_id)
|
|
|
|
));
|
2001-12-24 05:30:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function verify_path()
|
|
|
|
{
|
|
|
|
###
|
|
|
|
# Verify path is real
|
|
|
|
###
|
|
|
|
|
|
|
|
if($this->bo->debug)
|
|
|
|
{
|
|
|
|
echo 'DEBUG: ui.verify_path: PATH = '.$this->bo->path.'<br>'."\n";
|
2003-03-04 01:04:06 +01:00
|
|
|
echo 'DEBUG: ui.verify_path: exists = '.$this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE))).'<br>'."\n";
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if($this->bo->path != $this->bo->homedir &&
|
|
|
|
$this->bo->path != '/' &&
|
|
|
|
$this->bo->path != $this->bo->fakebase &&
|
2003-03-04 01:04:06 +01:00
|
|
|
!$this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 04:03:00 +01:00
|
|
|
$this->no_access_exists(lang('directory %1 does not exist',$this->bo->path));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function update()
|
|
|
|
{
|
|
|
|
/* Update if they request it, or one out of 20 page loads */
|
2001-12-24 04:08:32 +01:00
|
|
|
srand((double)microtime() * 1000000);
|
|
|
|
if($this->bo->update || rand(0,19) == 4)
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->bo->vfs->update_real( array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' =>Array(RELATIVE_NONE)
|
|
|
|
));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
if($this->bo->update)
|
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
Header('Location: '.$GLOBALS['phpgw']->link(
|
|
|
|
'/index.php',
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
//Dispatches various file manager actions to the appropriate handler
|
2001-12-20 03:11:29 +01:00
|
|
|
function action()
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
if (UI_DEBUG)
|
|
|
|
{
|
|
|
|
echo " Debug mode <br>";
|
|
|
|
echo "function : ".$this->bo->$function;
|
|
|
|
print_r($_POST);
|
|
|
|
die();
|
|
|
|
|
|
|
|
}
|
2001-12-20 03:11:29 +01:00
|
|
|
$actions = Array(
|
2003-03-04 04:03:00 +01:00
|
|
|
'rename' => lang('rename'),
|
|
|
|
'delete' => lang('delete'),
|
|
|
|
'go' => lang('go to'),
|
|
|
|
'copy' => lang('copy to'),
|
|
|
|
'move' => lang('move to'),
|
|
|
|
'download' => lang('download'),
|
|
|
|
'newdir' => lang('create folder'),
|
|
|
|
'newfile' => lang('create file'),
|
|
|
|
'edit' => lang('edit'),
|
|
|
|
'edit_comments' => lang('edit comments'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'apply_edit_comment' => '1',
|
|
|
|
'apply_edit_name' => '1',
|
2003-03-04 04:03:00 +01:00
|
|
|
'cancel' => lang('cancel'),
|
|
|
|
'upload' => lang('upload files')
|
2003-03-04 01:04:06 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$local_functions = array(
|
|
|
|
'rename',
|
|
|
|
'edit_comments'
|
|
|
|
);
|
|
|
|
$bo_functions = array(
|
|
|
|
'apply_edit_comment',
|
|
|
|
'apply_edit_name',
|
|
|
|
'copy',
|
|
|
|
'delete',
|
|
|
|
'move',
|
|
|
|
'newdir',
|
|
|
|
'newfile',
|
|
|
|
'go',
|
|
|
|
'upload',
|
|
|
|
'download'
|
2001-12-20 03:11:29 +01:00
|
|
|
);
|
2003-03-04 04:03:00 +01:00
|
|
|
if (trim(strtolower($this->bo->cancel)) == strtolower(lang('cancel'))) {
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->cancel();
|
2003-03-04 04:03:00 +01:00
|
|
|
exit();
|
2003-03-04 01:04:06 +01:00
|
|
|
}
|
|
|
|
//If the action is a "uiaction" (ie it has its own seperate interface), this will run it
|
|
|
|
$this->actions->dispatch($this);
|
2001-12-20 03:11:29 +01:00
|
|
|
@reset($actions);
|
|
|
|
while(list($function,$text) = each($actions))
|
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
if(isset($this->bo->$function) && !empty($this->bo->$function) && trim(strtolower($this->bo->$function)) == strtolower($text))
|
2001-12-20 03:11:29 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
//If the action is provided by this class, this'l do it
|
|
|
|
if (in_array($function, $local_functions))
|
|
|
|
{
|
2003-03-06 23:15:58 +01:00
|
|
|
//echo " uifunction $function ";
|
2003-03-04 01:04:06 +01:00
|
|
|
//Header('Location: '.$GLOBALS['phpgw']->link('/index.php',$var));
|
|
|
|
$this->$function();
|
|
|
|
exit();
|
|
|
|
} //For actions provided by the back-end, with no gui
|
|
|
|
elseif (in_array($function, $bo_functions))
|
2001-12-24 04:08:32 +01:00
|
|
|
{
|
2003-03-06 23:15:58 +01:00
|
|
|
//echo " bofunction $function ";
|
2003-03-04 01:04:06 +01:00
|
|
|
$f_function = 'f_'.$function;
|
2003-03-04 04:03:00 +01:00
|
|
|
$errors = implode("\n", $this->bo->$f_function());
|
2001-12-24 04:08:32 +01:00
|
|
|
$var = Array(
|
2003-03-04 01:04:06 +01:00
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
2001-12-24 04:08:32 +01:00
|
|
|
);
|
2003-03-04 01:04:06 +01:00
|
|
|
if($function == 'newfile')
|
|
|
|
{
|
|
|
|
$var = Array(
|
2003-03-06 02:11:43 +01:00
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.action',
|
|
|
|
'uiaction' => 'edit',
|
2003-03-04 01:04:06 +01:00
|
|
|
'path' => urlencode($this->bo->path),
|
|
|
|
'file' => urlencode($this->bo->createfile)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
elseif(strlen($errors))
|
|
|
|
{
|
|
|
|
$var['errors'] = $errors;
|
|
|
|
}
|
|
|
|
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',$var));
|
|
|
|
exit();
|
|
|
|
}
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path),
|
2003-03-04 04:03:00 +01:00
|
|
|
'errors' => lang('unknown action!')
|
2003-03-04 01:04:06 +01:00
|
|
|
)));
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 04:03:00 +01:00
|
|
|
/**TODO : xslt-ise this */
|
2001-12-20 03:11:29 +01:00
|
|
|
function help()
|
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
$this->load_header();
|
2001-12-20 03:11:29 +01:00
|
|
|
$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]);
|
|
|
|
|
2003-03-06 23:15:58 +01:00
|
|
|
// echo '<font size="+4">'."\n".ucwords(str_replace('_',' ',$help_array[0]))."\n".'</font></br>'."\n";
|
|
|
|
// echo '<font size="+2">'."\n".$help_array[1].'</font>';
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
exit();
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 04:03:00 +01:00
|
|
|
/**TODO : xslt-ise this */
|
2001-12-20 03:11:29 +01:00
|
|
|
function build_help($help_option,$text='')
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
|
|
|
if($this->bo->settings['show_help'])
|
|
|
|
{
|
2001-12-20 03:11:29 +01:00
|
|
|
$help = ($text?'':'<font size="-2" color="maroon" >'."\n");
|
|
|
|
$help .= ' <a href="'
|
2001-12-15 05:24:37 +01:00
|
|
|
. $GLOBALS['phpgw']->link('/index.php',
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.help',
|
|
|
|
'help_name' => urlencode($help_option),
|
2001-12-20 03:11:29 +01:00
|
|
|
'op' => 'help'
|
2001-12-15 05:24:37 +01:00
|
|
|
)
|
|
|
|
)
|
2001-12-20 03:11:29 +01:00
|
|
|
. '" target="_new">';
|
|
|
|
$help .= ($text?$text:'[?]');
|
|
|
|
$help .= '</a>';
|
|
|
|
$help .= ($text?'':"\n".' </font>');
|
|
|
|
return $help;
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
2003-03-06 02:11:43 +01:00
|
|
|
|
2001-12-20 03:11:29 +01:00
|
|
|
function display_buttons()
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var = array();
|
2001-12-20 03:11:29 +01:00
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['type'] = 'submit';
|
|
|
|
$button['name'] = 'uiaction_edit';
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] = lang('edit');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('edit');
|
|
|
|
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
$button['name'] = "rename";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] =lang('rename');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('rename');
|
|
|
|
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
$button['name'] = "delete";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] =lang('delete');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('delete');
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
|
|
|
|
$button['name'] = "edit_comments";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] =lang('edit comments');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('edit_comments');
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
|
|
|
|
$var[] = array('widget' => array( 'type' => 'seperator' ));
|
|
|
|
|
|
|
|
$button['name'] = "go";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] = lang('go to');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('go_to');
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
|
|
|
|
$button['name'] = "copy";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] = lang('copy to');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] = $this->build_help('copy_to');
|
|
|
|
$var[] = array('widget' => $button);
|
|
|
|
|
|
|
|
$button['name'] = "move";
|
2003-03-04 04:03:00 +01:00
|
|
|
$button['value'] = lang('move to');
|
2003-03-04 01:04:06 +01:00
|
|
|
$button['caption'] =$this->build_help('move_to');
|
|
|
|
$var[] = array('widget' => $button);
|
2001-12-20 03:11:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# First we get the directories in their home directory
|
|
|
|
###
|
|
|
|
|
|
|
|
$dirs[] = Array(
|
|
|
|
'directory' => $this->bo->fakebase,
|
|
|
|
'name' => $this->bo->userinfo['account_lid']
|
|
|
|
);
|
2003-03-04 01:04:06 +01:00
|
|
|
$ls_array = $this->bo->vfs->ls(array(
|
|
|
|
'string' => $this->bo->homedir,
|
|
|
|
'relatives' => Array(RELATIVE_NONE),
|
|
|
|
'nofiles' => True,
|
|
|
|
'mime_type' => 'Directory'));
|
2001-12-20 03:11:29 +01:00
|
|
|
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']
|
|
|
|
);
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$ls_array = $this->bo->vfs->ls(array(
|
|
|
|
'string' => $this->bo->fakebase.SEP.$group_array['account_name'],
|
|
|
|
'relatives' => Array(RELATIVE_NONE),
|
|
|
|
'nofiles' => True,
|
|
|
|
'mime_type' => 'Directory'
|
|
|
|
));
|
2001-12-20 03:11:29 +01:00
|
|
|
while(list($num,$dir) = each($ls_array))
|
|
|
|
{
|
|
|
|
$dirs[] = $dir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$dir_list = array();
|
2001-12-20 03:11:29 +01:00
|
|
|
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
|
|
|
|
###
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
if((($dir['directory'].$dir['name']) != $this->bo->path) && $this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $dir['directory'].$dir['name'],
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-20 03:11:29 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$dir_list[] =array('option'=> array('value'=> urlencode($dir['directory'].$dir['name']),
|
|
|
|
'selected' => $selected,
|
|
|
|
'caption' => $dir['directory'].$dir['name']
|
|
|
|
));
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$var[] = array('widget' => array( 'type' => 'select',
|
|
|
|
'name'=> 'todir',
|
|
|
|
'options' => $dir_list,
|
|
|
|
'caption' => $this->build_help('directory_list')
|
|
|
|
));
|
2001-12-20 03:11:29 +01:00
|
|
|
|
|
|
|
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var[] = array('widget' => array('type'=>'submit',
|
|
|
|
'name'=> 'download',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('download'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('download')
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array( 'type' => 'seperator' ));
|
|
|
|
$var[] = array('widget' => array('type' => 'text',
|
|
|
|
'name' => 'createdir',
|
|
|
|
'maxlength' => '255',
|
|
|
|
'size' => '15'
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array('type' => 'submit',
|
|
|
|
'name' => 'newdir',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('create folder'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('create_folder')
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array( 'type' => 'seperator' ));
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
/* $var[] = array('widget' => array('type' => 'submit',
|
|
|
|
'name' => 'update',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('update'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('update')
|
|
|
|
));
|
|
|
|
*/
|
2001-12-20 03:11:29 +01:00
|
|
|
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var[] = array('widget' => array( 'type' => 'text',
|
|
|
|
'name' => 'createfile',
|
|
|
|
'maxlength' => '255',
|
|
|
|
'size' => '15'
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array('type' => 'submit',
|
|
|
|
'name' => 'newfile',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('create file'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('create_file')
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array( 'type' => 'seperator' ));
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if($this->bo->settings['show_command_line'])
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
|
|
|
|
$var[] = array('widget' => array( 'type' => 'text' ,
|
|
|
|
'name'=> 'command_line',
|
|
|
|
'size' => '50',
|
|
|
|
'caption' => $this->build_help('command_line')
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array( 'type' => 'submit',
|
|
|
|
'name' => 'execute',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('execute'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('execute')
|
|
|
|
));
|
|
|
|
$var[] = array('widget' => array( 'type' => 'seperator' ));
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
return $var;
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-06 02:11:43 +01:00
|
|
|
/*
|
2001-12-20 03:11:29 +01:00
|
|
|
function display_summary_info($numoffiles,$usedspace)
|
|
|
|
{
|
|
|
|
|
|
|
|
$p->set_var($var);
|
|
|
|
$p->parse('col_headers','column_headers_normal',True);
|
|
|
|
|
|
|
|
$var['td_extras'] = ' align="right"';
|
2003-03-04 04:03:00 +01:00
|
|
|
$var['column_header'] = '<b>'.lang('used space').'</b>:';
|
2001-12-20 03:11:29 +01:00
|
|
|
$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"';
|
2003-03-04 04:03:00 +01:00
|
|
|
$var['column_header'] = '<b>'.lang('unused space').'</b>:';
|
2001-12-20 03:11:29 +01:00
|
|
|
$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%"';
|
2003-03-04 04:03:00 +01:00
|
|
|
$var['column_header'] = '<b>'.lang('total files').'</b>:';
|
2001-12-20 03:11:29 +01:00
|
|
|
$p->set_var($var);
|
|
|
|
$p->parse('col_headers','column_headers_normal',False);
|
|
|
|
|
|
|
|
$var['td_extras'] = ' colspan="'.($info_columns / 2).'" align="left" width="50%"';
|
2003-03-04 01:04:06 +01:00
|
|
|
$var['column_header'] = count($this->bo->vfs->ls(array(
|
|
|
|
'string' => $this->bo->path,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)));
|
2001-12-20 03:11:29 +01:00
|
|
|
$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');
|
|
|
|
}
|
2003-03-06 02:11:43 +01:00
|
|
|
*/
|
2001-12-20 03:11:29 +01:00
|
|
|
function display_uploads()
|
|
|
|
{
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$var_head[] = array('widget' => array('type' => 'label',
|
2003-03-04 04:03:00 +01:00
|
|
|
'caption' => lang('file').$this->build_help('upload_file')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
2001-12-20 03:11:29 +01:00
|
|
|
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$var_head[] = array('widget' => array('type' => 'label',
|
2003-03-04 04:03:00 +01:00
|
|
|
'caption' => lang('comment').$this->build_help('upload_comment')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
|
|
|
$table_head [] =array('table_col' => $var_head);
|
|
|
|
// $var[] = array('widget' => array('type' => 'seperator'));
|
|
|
|
for($i=0;$i<$this->bo->show_upload_boxes;$i++)
|
2001-12-20 03:11:29 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var = array();
|
|
|
|
$var[] = array('widget' => array('type' => 'file',
|
|
|
|
'name' => 'upload_file[]' ,
|
|
|
|
'maxlength'=> '255'
|
|
|
|
));
|
|
|
|
|
|
|
|
$var[] = array('widget' => array('type' => 'text',
|
|
|
|
'name' => 'upload_comment[]'
|
|
|
|
));
|
|
|
|
|
|
|
|
/* $var[] = array('widget' => array('type' => 'label',
|
|
|
|
'caption' => $input_file.$input_comment
|
|
|
|
)); */
|
|
|
|
$table_rows [] = array('table_col' => $var);
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
$var = array();
|
|
|
|
$var[] = array('widget' => array('type' =>'submit',
|
|
|
|
'name' => 'upload',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('upload Files'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'caption' => $this->build_help('upload_files')
|
|
|
|
));
|
|
|
|
|
|
|
|
$var[] = array('widget' => array('type' => 'hidden',
|
|
|
|
'name' => 'show_upload_boxes',
|
|
|
|
'value' => $this->bo->show_upload_boxes
|
|
|
|
));
|
|
|
|
|
|
|
|
$table_rows [] = array('table_col' => $var);
|
2001-12-20 03:11:29 +01:00
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
|
|
|
|
return array('table' => array('table_head' =>$table_head ,
|
|
|
|
'table_row' => $table_rows)
|
|
|
|
);
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
function dirs_first($files_array)
|
|
|
|
{
|
|
|
|
$dirs = array();
|
|
|
|
$files = array();
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
for($i=0;$i!=count($files_array);$i++)
|
|
|
|
{
|
|
|
|
$file = $files_array[$i];
|
|
|
|
if ($file['mime_type'] == 'Directory')
|
|
|
|
{
|
|
|
|
$dirs[] = $file;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$files[] = $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return array_merge($dirs, $files);
|
|
|
|
}
|
|
|
|
|
|
|
|
function index( $edit=array())
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-06 02:11:43 +01:00
|
|
|
//This lets you use an alternate xslt by appending &template=<name> to the url
|
|
|
|
if (!($template = get_var('template', array('GET', 'POST'))) )
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->xslttpl->add_file(array('index',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'app_header'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->xslttpl->add_file($template);
|
|
|
|
}
|
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
$files_array = $this->bo->load_files();
|
2003-04-08 22:47:38 +02:00
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$usage = 0;
|
|
|
|
$files_array = $this->dirs_first($files_array);
|
2001-12-15 05:24:37 +01:00
|
|
|
if(count($files_array) || $this->bo->cwd)
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$file_output = array();
|
|
|
|
for($i=0;$i!=count($files_array);$i++)
|
|
|
|
{
|
|
|
|
$file = $files_array[$i];
|
|
|
|
$usage += $file['size'];
|
2003-03-04 04:03:00 +01:00
|
|
|
if (!count($edit) )
|
|
|
|
{
|
|
|
|
$file_attributes['checkbox'] = '';
|
|
|
|
$file_output[$i]['checkbox'] =array('widget' => array( 'type' => 'checkbox',
|
|
|
|
'name' => 'fileman[]',
|
|
|
|
'value' => $file['name']
|
|
|
|
));
|
2003-03-04 01:04:06 +01:00
|
|
|
}
|
|
|
|
@reset($this->bo->file_attributes);
|
|
|
|
while(list($internal,$displayed) = each($this->bo->file_attributes))
|
|
|
|
{
|
2003-04-08 22:47:38 +02:00
|
|
|
if (!is_array($this->bo->settings)||$this->bo->settings[$internal])
|
2003-03-04 01:04:06 +01:00
|
|
|
{
|
|
|
|
if ($internal==$edit[$file['name']])
|
|
|
|
{
|
|
|
|
$file_output[$i][$internal] = array('widget' => array('type' => 'text',
|
|
|
|
'name' => 'changes['.$file['name'].']',
|
|
|
|
'value' => $file[$internal]
|
|
|
|
));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch($internal)
|
|
|
|
{
|
|
|
|
case 'owner_id':
|
|
|
|
case 'owner':
|
|
|
|
case 'createdby_id':
|
|
|
|
case 'modifiedby_id':
|
|
|
|
$name = $GLOBALS['phpgw']->accounts->id2name($file[$internal]) ;
|
|
|
|
$file_output[$i][$internal] = $name ? $name: '';
|
|
|
|
break;
|
|
|
|
case 'created':
|
|
|
|
case 'modified':
|
|
|
|
//Convert ISO 8601 date format used by DAV into something people can read
|
|
|
|
$file_output[$i][$internal] = $this->bo->convert_date($file[$internal]);
|
|
|
|
break;
|
|
|
|
case 'name':
|
|
|
|
$mime_parts = explode('/',$file['mime_type']);
|
2003-03-04 04:03:00 +01:00
|
|
|
$file_icon = $this->mime_ico[$file['mime_type']];
|
|
|
|
if (!$file_icon) {
|
|
|
|
$file_icon = ( $this->mime_ico[$mime_parts[0]]) ? $this->mime_ico[$mime_parts[0]] : $this->mime_ico['unknown'];
|
|
|
|
if (strpos($file['name'],'.exe') !== false) $file_icon = $this->mime_ico['exe'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$file_output[$i]['name']['icon'] = array(
|
|
|
|
'widget' => array( 'type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,$file_icon)
|
|
|
|
));
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
if ($file['mime_type']=='Directory')
|
|
|
|
{
|
|
|
|
$href = array('menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => $this->bo->path.SEP.$file['name']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$href = Array( 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view',
|
|
|
|
'path' => urlencode($this->bo->path),
|
|
|
|
'file' => urlencode($file['name'])
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
$file_output[$i]['name']['link'] = array(
|
|
|
|
"widget"=> array(
|
|
|
|
'type' => 'link',
|
|
|
|
'caption' => $file['name'],
|
|
|
|
'href' => $GLOBALS['phpgw']->link('/index.php', $href)
|
|
|
|
));
|
|
|
|
if ($mime_parts[0] == 'text')
|
2003-03-04 04:03:00 +01:00
|
|
|
{
|
|
|
|
$href['menuaction'] = $this->bo->appname.'.ui'.$this->bo->appname.'.action';
|
|
|
|
$href['uiaction'] = 'edit';
|
|
|
|
$file_output[$i]['name']['edit'] = array('widget' => array( 'type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'pencil'),
|
|
|
|
'link' => $GLOBALS['phpgw']->link('/index.php', $href)
|
|
|
|
));
|
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$file_output[$i][$internal] = $file[$internal];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$file_attributes[$internal] = array("widget"=> array(
|
|
|
|
'type' => 'link',
|
|
|
|
'caption' => $displayed,
|
|
|
|
'href' => $GLOBALS['phpgw']->link('/index.php', array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path'=>$this->bo->path,
|
|
|
|
'sortby' => $internal
|
|
|
|
))
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 22:47:38 +02:00
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('summary' => array(
|
|
|
|
'file_count' => count($files_array),
|
|
|
|
'usage' => $usage
|
|
|
|
)));
|
|
|
|
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('file_attributes' => $file_attributes));
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array(
|
|
|
|
'files' => array(
|
|
|
|
'file' => $file_output
|
|
|
|
)
|
2001-12-15 05:24:37 +01:00
|
|
|
)
|
|
|
|
);
|
2003-03-06 02:11:43 +01:00
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
|
2001-12-24 04:08:32 +01:00
|
|
|
$GLOBALS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off'];
|
2001-12-15 05:24:37 +01:00
|
|
|
$var = Array(
|
2003-03-06 02:11:43 +01:00
|
|
|
|
2001-12-20 03:11:29 +01:00
|
|
|
'form_action' => $GLOBALS['phpgw']->link('/index.php',
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.action',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
)
|
2001-12-15 05:24:37 +01:00
|
|
|
),
|
2003-03-04 01:04:06 +01:00
|
|
|
'error' => (isset($this->bo->errors) && is_array(unserialize(base64_decode($this->bo->errors)))?$GLOBALS['phpgw']->common->error_list(unserialize(base64_decode($this->bo->errors)),'Results'):''),
|
|
|
|
'img_up' => array('widget' => array('type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'up'),
|
2003-03-04 04:03:00 +01:00
|
|
|
'alt' => lang('up'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'link' => $GLOBALS['phpgw']->link('/index.php',Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->lesspath)
|
|
|
|
))
|
|
|
|
)),
|
2001-12-15 05:24:37 +01:00
|
|
|
'help_up' => $this->build_help('up'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'img_home' => array('widget' => array('type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'folder_home'),
|
2003-03-04 04:03:00 +01:00
|
|
|
'alt' => lang('folder'),
|
2003-03-04 01:04:06 +01:00
|
|
|
'link' => $GLOBALS['phpgw']->link('/index.php',Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->homedir)
|
|
|
|
))
|
|
|
|
)),
|
|
|
|
'dir' => $this->bo->path,
|
|
|
|
'img_dir' => array('widget' => array('type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'folder_large'),
|
2003-03-04 04:03:00 +01:00
|
|
|
'alt' => lang('folder'), 'link' => $GLOBALS['phpgw']->link('/index.php',Array(
|
2003-03-04 01:04:06 +01:00
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
))
|
|
|
|
)),
|
2001-12-15 05:24:37 +01:00
|
|
|
'help_home' => $this->build_help('home'),
|
|
|
|
);
|
2003-03-04 01:04:06 +01:00
|
|
|
if (strlen($this->bo->errors))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var['errors'] = $this->bo->errors;
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
if (count($edit))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var['img_cancel'] = array('widget' => array('type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'button_cancel'),
|
2003-03-04 04:03:00 +01:00
|
|
|
'alt' => lang('folder')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
|
|
|
$var['button_cancel'] = array('widget' => array('type' => 'submit',
|
|
|
|
'name' => 'cancel',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('cancel')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
|
|
|
$var['img_ok'] = array('widget' => array('type' => 'img',
|
|
|
|
'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'button_ok'),
|
2003-03-04 04:03:00 +01:00
|
|
|
'alt' => lang('folder')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
|
|
|
$var['button_ok'] = array('widget' => array('type' => 'submit',
|
|
|
|
'name' => 'submit',
|
2003-03-04 04:03:00 +01:00
|
|
|
'value' => lang('ok')
|
2003-03-04 01:04:06 +01:00
|
|
|
));
|
|
|
|
@reset($edit);
|
|
|
|
while( list($file,$prop) = each($edit))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$var['fileman'][] = array('widget' => array('type'=>'hidden',
|
|
|
|
'name' => 'fileman[]',
|
|
|
|
'value' => $file
|
|
|
|
));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
@reset($edit); list($file,$prop) = each($edit);
|
|
|
|
$var['action'] = array('widget' => array('type'=>'hidden',
|
|
|
|
'name' => 'apply_edit_'.$prop,
|
|
|
|
'value' => 1
|
|
|
|
));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('index' => $var));
|
2003-03-06 02:11:43 +01:00
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('sidebar' => array(
|
|
|
|
'url' => $GLOBALS['phpgw']->link('/index.php',
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
), 1
|
|
|
|
),
|
|
|
|
'label' => lang('phpgroupware files'),
|
|
|
|
'link_label' => lang('add mozilla/netscape sidebar tab')
|
|
|
|
)
|
|
|
|
));
|
2003-03-04 01:04:06 +01:00
|
|
|
@reset($this->bo->file_attributes);
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('settings' => $this->bo->settings));
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('display_settings' => $GLOBALS['phpgw_info']['theme']));
|
|
|
|
|
|
|
|
if(!count($edit))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('buttons'=> array('button' => $this->display_buttons()) ));
|
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('uploads' => $this->display_uploads() ));
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
$GLOBALS['phpgw']->xslttpl->set_var('phpgw', array('index' => $var));
|
|
|
|
}
|
2001-12-20 03:11:29 +01:00
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
}
|
|
|
|
function cancel()
|
|
|
|
{
|
|
|
|
$var = Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
);
|
|
|
|
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',$var));
|
|
|
|
}
|
|
|
|
function rename()
|
|
|
|
{
|
|
|
|
$edit=array();
|
|
|
|
for ($i=0; $i!=count($this->bo->fileman);$i++)
|
|
|
|
{
|
|
|
|
$edit[$this->bo->fileman[$i]] = 'name';
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
$this->index($edit);
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
function edit_comments()
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$edit=array();
|
|
|
|
for ($i=0; $i!=count($this->bo->fileman);$i++)
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
$edit[$this->bo->fileman[$i]] = 'comment';
|
|
|
|
}
|
|
|
|
$this->index($edit);
|
|
|
|
}
|
|
|
|
function view()
|
2003-04-08 22:47:38 +02:00
|
|
|
{
|
|
|
|
Header('Location: '.$GLOBALS['phpgw']->link(
|
|
|
|
'view.php',
|
|
|
|
Array('path' => urlencode($this->bo->path),
|
|
|
|
'file' => urlencode($this->bo->file))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2001-12-15 05:24:37 +01:00
|
|
|
}
|
2003-03-04 01:04:06 +01:00
|
|
|
|
2001-12-20 03:11:29 +01:00
|
|
|
function history()
|
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
$this->load_header();
|
2001-12-20 03:11:29 +01:00
|
|
|
$file = $this->bo->path.$this->bo->dispsep.$this->bo->file;
|
2003-03-04 01:04:06 +01:00
|
|
|
if($this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-20 03:11:29 +01:00
|
|
|
{
|
|
|
|
$col_headers = Array(
|
|
|
|
'Date' => 'created',
|
|
|
|
'Version' => 'version',
|
|
|
|
'Action Performed by' => 'owner_id',
|
|
|
|
'Operation' => 'comment'
|
|
|
|
);
|
|
|
|
$p = CreateObject('phpgwapi.Template',$this->template_dir);
|
|
|
|
$p->set_unknowns('remove');
|
|
|
|
|
|
|
|
$p->set_file(
|
|
|
|
Array(
|
|
|
|
'_history' => 'history.tpl'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$p->set_block('_history','history','history');
|
|
|
|
$p->set_block('_history','column_headers','column_headers');
|
|
|
|
$p->set_block('_history','column_rows','column_rows');
|
|
|
|
|
|
|
|
$var = Array(
|
|
|
|
'path' => $this->link(
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
|
|
|
|
'path' => urlencode($this->bo->path)
|
|
|
|
),
|
|
|
|
$this->bo->path
|
|
|
|
),
|
|
|
|
'filename' => $this->link(
|
|
|
|
Array(
|
|
|
|
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view',
|
|
|
|
'path' => urlencode($this->bo->path),
|
|
|
|
'file' => urlencode($this->bo->file)
|
|
|
|
),
|
|
|
|
$this->bo->file
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$p->set_var($var);
|
|
|
|
|
|
|
|
$GLOBALS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off'];
|
|
|
|
$var = Array(
|
|
|
|
'td_extras' => ''
|
|
|
|
);
|
|
|
|
@reset($col_headers);
|
|
|
|
while(list($label,$field)= each($col_headers))
|
|
|
|
{
|
|
|
|
$var['column_header'] = '<b>'.$label.'</b>';
|
2001-12-24 04:08:32 +01:00
|
|
|
$this->set_col_headers($p,$var);
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
$p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
|
|
|
|
$p->parse('col_row','column_rows',True);
|
|
|
|
$p->set_var('col_headers','');
|
|
|
|
|
2003-03-04 01:04:06 +01:00
|
|
|
$journal_array = $this->bo->vfs->get_journal(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
));
|
2001-12-20 03:11:29 +01:00
|
|
|
while(list($num,$journal_entry) = each($journal_array))
|
|
|
|
{
|
|
|
|
@reset($col_headers);
|
|
|
|
while(list($label,$field)= each($col_headers))
|
|
|
|
{
|
|
|
|
switch($field)
|
|
|
|
{
|
|
|
|
case 'owner_id':
|
|
|
|
$var['column_header'] = '<font size="-2">'.$GLOBALS['phpgw']->accounts->id2name($journal_entry[$field]).'</font>';
|
|
|
|
break;
|
|
|
|
case 'created':
|
2001-12-24 04:08:32 +01:00
|
|
|
$var['column_header'] = '<font size="-2">'.$this->bo->convert_date($journal_entry[$field]).'</font>';
|
2001-12-20 03:11:29 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$var['column_header'] = '<font size="-2">'.$journal_entry[$field].'</font>';
|
|
|
|
break;
|
|
|
|
}
|
2001-12-24 04:08:32 +01:00
|
|
|
$this->set_col_headers($p,$var);
|
2001-12-20 03:11:29 +01:00
|
|
|
}
|
|
|
|
$p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
|
|
|
|
$p->parse('col_row','column_rows',True);
|
|
|
|
$p->set_var('col_headers','');
|
|
|
|
}
|
|
|
|
$p->pfp('output','history');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-24 04:08:32 +01:00
|
|
|
function view_file($file_array='')
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
if(is_array($file_array))
|
|
|
|
{
|
|
|
|
$this->bo->path = $file_array['path'];
|
|
|
|
$this->bo->file = $file_array['file'];
|
|
|
|
}
|
|
|
|
$file = $this->bo->path.SEP.$this->bo->file;
|
2003-03-04 01:04:06 +01:00
|
|
|
if($this->bo->vfs->file_exists(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
)))
|
2001-12-15 05:24:37 +01:00
|
|
|
{
|
2001-12-24 04:08:32 +01:00
|
|
|
$browser = CreateObject('phpgwapi.browser');
|
2003-03-04 01:04:06 +01:00
|
|
|
$browser->content_header($this->bo->file,$this->bo->vfs->file_type(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE))),
|
|
|
|
$this->bo->vfs->get_size(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE),
|
|
|
|
'checksubdirs' => True
|
|
|
|
)));
|
2001-12-24 04:08:32 +01:00
|
|
|
// $browser->content_header($this->bo->file);
|
2003-03-04 01:04:06 +01:00
|
|
|
echo $this->bo->vfs->read(array(
|
|
|
|
'string' => $file,
|
|
|
|
'relatives' => Array(RELATIVE_NONE)
|
|
|
|
));
|
2001-12-15 05:24:37 +01:00
|
|
|
flush();
|
|
|
|
}
|
2001-12-24 04:08:32 +01:00
|
|
|
if(!is_array($file_array))
|
|
|
|
{
|
2003-03-04 01:04:06 +01:00
|
|
|
exit();
|
2001-12-24 04:08:32 +01:00
|
|
|
}
|
|
|
|
}
|
2001-12-15 05:24:37 +01:00
|
|
|
|
|
|
|
}
|