diff --git a/filemanager/CHANGELOG b/filemanager/CHANGELOG new file mode 100644 index 0000000000..e69de29bb2 diff --git a/filemanager/inc/class.bofilemanager.inc.php b/filemanager/inc/class.bofilemanager.inc.php index a8e534b0b7..047298307f 100755 --- a/filemanager/inc/class.bofilemanager.inc.php +++ b/filemanager/inc/class.bofilemanager.inc.php @@ -4,6 +4,7 @@ { var $so; var $vfs; + var $sep; var $file_attributes; var $help_info; @@ -51,16 +52,13 @@ function bofilemanager() { + $this->so = CreateObject('filemanager.sofilemanager'); + $this->so->db_init(); + $this->vfs = CreateObject('phpgwapi.vfs'); - // This comes from the top of main (pim) // error_reporting (4); - /* if (@!is_object($GLOBALS['phpgw']->vfs)) - { - $GLOBALS['phpgw']->vfs = CreateObject ('phpgwapi.vfs'); - } - */ ### Start Configuration Options ### ### These are automatically set in phpGW - do not edit ### @@ -97,35 +95,6 @@ define ('NULL', ''); } - - // FIXME - require (PHPGW_APP_INC . '/db.inc.php'); - - /* Set up any initial db settings */ - db_init (); - //die('hallo?'); - - ### - # Get user settings from database - ### - - /* We have to define these by hand in phpGW, or rely on it's templates */ - - define ('HTML_TABLE_FILES_HEADER_BG_COLOR', ''); - define ('HTML_TABLE_FILES_HEADER_TEXT_COLOR', 'maroon'); - define ('HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR', '#cccccc'); - define ('HTML_TABLE_FILES_COLUMN_HEADER_TEXT_COLOR', '#000000'); - define ('HTML_TABLE_FILES_BG_COLOR', '#dedede'); - define ('HTML_TABLE_FILES_TEXT_COLOR', 'maroon'); - define ('HTML_TEXT_ERROR_COLOR', 'red'); - define ('HTML_TEXT_NAVIGATION_BACK_TO_USER', lang('Back to file manager')); - - ### - # Need to include this here so they recognize the settings - ### - - // require (PHPGW_APP_INC . '/html.inc.php'); - ### # Define the list of file attributes. Format is "internal_name" => "Displayed name" # This is used both by internally and externally for things like preferences @@ -152,47 +121,10 @@ # but it does do something ### - $this->help_info = Array( -array ("up", "The Up button takes you to the directory above the current directory. For example, if you're in /home/jdoe/mydir, the Up button would take you to /home/jdoe."), -array ("directory_name", "The name of the directory you're currently in."), -array ("home", "The Home button takes you to your personal home directory."), -array ("sort_by", "Click on any of the column headers to sort the list by that column."), -array ("filename", "The name of the file or directory."), -array ("mime_type", "The MIME-type of the file. Examples include text/plain, text/html, image/jpeg. The special MIME-type Directory is used for directories."), -array ("size", "The size of the file or directory in the most convenient units: bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB). Sizes for directories include subfiles and subdirectories."), -array ("created", "When the file or directory was created."), -array ("modified", "When the file or directory was last modified."), -array ("owner", "The owner of the file or directory. This can be a user or group name."), -array ("created_by", "Displays who created the file or directory."), -array ("modified_by", "Displays who last modified the file or directory."), -array ("application", "The application associated with the file or directory. Usually the application used to create it. A blank application field is ok."), -array ("comment", "The comment for the file or directory. Comments can be set when creating the file or directory, and created or edited any time thereafter."), -array ("version", "The current version for the file or directory. Clicking on the version number will display a list of changes made to the file or directory."), -array ("edit", "Edit the text of the selected file(s). You can select more than one file; this is useful when you want to copy part of one file into another. Clicking Preview will show you a preview of the file. Click Save to save your changes."), -array ("rename", "Rename the selected file(s). You can select as many files or directories as you want. You are presented with a text field to enter the new name of each file or directory."), -array ("delete", "Delete the selected file(s). You can select as many files or directories as you want. When deleting directories, the entire directory and all of its contents are deleted. You will not be prompted to make sure you want to delete the file(s); make sure you really want to delete them before clicking Delete."), -array ("edit_comments", "Create a comment for a file or directory, or edit an existing comment. You can select as many files or directories as you want."), -array ("go_to", "The Go to button takes you to the directory selected in the drop down [directory_list|Directory List]."), -array ("copy_to", "This will copy all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), -array ("move_to", "This will move all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), -array ("directory_list", "The Directory List contains a list of all directories you have (at least) read access to. Selecting a directory and clicking one of the [go_to|Go to]/[copy_to|Copy to]/[move_to|Move to] buttons will perform the selected action on that directory. For example, if you select \"/home/somegroup/reports\" from the Directory List, and click the \"[copy_to|Copy to]\" button, all selected files and directories will be copied to \"/home/somegroup/reports\"."), -array ("download", "Download the first selected file to your local computer. You can only download one file at a time. Directories cannot be downloaded, only files."), -array ("create_folder", "Creates a directory (folder == directory). The name of the directory is specified in the text box next to the Create Folder button."), -array ("create_file", "Creates a file in the current directory. The name of the file is specified in the text box next to the Create File button. After clicking the Create File button you will be presented with the [edit|Edit] screen, where you may edit the file you just created. If you do not with to make any changes to the file at this time, simply click the Save button and the file will be saved as an empty file."), -array ("command_line", "Enter a Unix-style command line here, which will be executed when the [execute|Execute] button is pressed. If you don't know what this is, you probably should turn the option off in the Preferences."), -array ("execute", "Clicking the Execute button will execute the Unix-style [command_line|command line] specified in the text box above. If you don't know what this is, you probably should turn the option off in the Preferences."), -array ("update", "Sync the database with the filesystem for the current directory. This is useful if you use another interface to access the same files. Any new files or directories in the current directory will be read in, and the attributes for the other files will be updated to reflect any changes to the filesystem. Update is run automatically every few page loads (currently every 20 page loads as of this writing, but that may have changed by now)."), -array ("file_stats", "Various statistics on the number and size of the files in the current directory. In some situations, these reflect different statistics. For example, when in / or the base directory."), -array ("upload_file", "The full path of the local file to upload. You can type it in or use the Browse.. button to select it. The file will be uploaded to the current directory. You cannot upload directories, only files."), -array ("upload_comment", "The inital comment to use for the newly uploaded file. Totally optional and completely arbitrary. You can [edit_comments|create or edit the comment] at any time in the future."), -array ("upload_files", "This will upload the files listed in the input boxes above, and store them in the current directory."), -array ("show_upload_fields", "This setting determines how many [upload_files|upload fields] will be shown at once. You can change the default number that will be shown in the [preferences].") -); - } - function borkb ($size, $enclosed = NULL, $return = 0) + function borkb ($size, $enclosed = NULL, $return = 1) { if (!$size) $size = 0; @@ -270,7 +202,7 @@ array ("show_upload_fields", "This setting determines how many [upload_files|upl global $phpgw; if ($lang) - $string = $this->translate ($string); + $string = lang($string); if ($times == NULL) $times = 1; @@ -294,6 +226,7 @@ array ("show_upload_fields", "This setting determines how many [upload_files|upl function string_encode ($string, $return = False) { + //var_dump($string); if (preg_match ("/=(.*)(&|$)/U", $string)) { $rstring = $string; @@ -342,12 +275,5 @@ array ("show_upload_fields", "This setting determines how many [upload_files|upl return ($this->eor ($rstring, $return)); } - - function translate ($text) - { - return ($GLOBALS['phpgw']->lang($text)); - } - - } ?> diff --git a/filemanager/inc/class.bophpwebhosting.inc.php b/filemanager/inc/class.bophpwebhosting.inc.php deleted file mode 100755 index 63e717aaea..0000000000 --- a/filemanager/inc/class.bophpwebhosting.inc.php +++ /dev/null @@ -1,709 +0,0 @@ - True - ); - - var $so; - var $vfs; - var $rootdir; - var $fakebase; - var $appname; - var $settings; - var $filesdir; - var $hostname; - var $userinfo = Array(); - var $homedir; - var $file_attributes; - var $help_info; - - var $errors; - - 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; - - function bophpwebhosting() - { - $this->vfs = CreateObject('phpgwapi.vfs'); - - $to_decode = Array( - /* - Decode - 'var' when 'avar' == 'value' - or - 'var' when 'var' is set - */ - - 'errors', - 'op', - 'path', - 'file', - 'todir', - 'sortby', - 'fileman', - 'messages', - 'help_name', - 'renamefiles', - 'comment_files', - 'show_upload_boxes', - 'submit', - 'rename', - 'delete', - 'go', - 'copy', - 'move', - 'download', - 'newfile', - 'createfile', - 'newdir', - 'createdir' - ); - - $c_to_decode = count($to_decode); - for($i=0;$i<$c_to_decode;$i++) - { - $this->initialize_vars($to_decode[$i]); - } - - $this->rootdir = $this->vfs->basedir; - $this->fakebase = $this->vfs->fakebase; - $this->appname = $GLOBALS['phpgw_info']['flags']['currentapp']; - $this->settings = $GLOBALS['phpgw_info']['user']['preferences'][$this->appname]; - - if(stristr($this->rootdir,PHPGW_SERVER_ROOT)) - { - $this->filesdir = substr($this->rootdir,strlen(PHPGW_SERVER_ROOT)); - } - else - { - $this->filesdir = ''; - } - $this->hostname = $GLOBALS['phpgw_info']['server']['webserver_url'].$this->filesdir; - $this->userinfo['username'] = $GLOBALS['phpgw_info']['user']['account_id']; - $this->userinfo['account_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->userinfo['username']); - $this->userinfo['hdspace'] = 10000000000; - $this->homedir = $this->fakebase.SEP.$this->userinfo['account_lid']; - - if(!defined('NULL')) - { - define('NULL',''); - } - - $this->so = CreateObject('filemanager.sophpwebhosting'); - - $this->file_attributes = Array( - 'name' => 'Filename', - 'deletable' => 'Deletable', - 'mime_type' => 'MIME Type', - 'size' => 'Size', - 'created' => 'Created', - 'modified' => 'Modified', - 'owner' => 'Owner', - 'createdby_id' => 'Created by', - 'modifiedby_id' => 'Modified by', - 'app' => 'Application', - 'comment' => 'Comment', - 'version' => 'Version' - ); - - if($this->go) - { - $this->path = $this->todir; - } - - if($this->debug) - { - echo 'DEBUG: bo.bophpwebhosting: PATH = '.$this->path.'
'."\n"; - } - - if(!$this->path) - { - $this->path = $this->vfs->pwd(); - if (!$this->path || $this->vfs->pwd(False) == '') - { - $this->path = $this->homedir; - } - } - $this->vfs->cd(False,False,Array(RELATIVE_NONE)); - $this->vfs->cd($this->path,False,Array(RELATIVE_NONE)); - - $this->pwd = $this->vfs->pwd(); - - if (!$this->cwd = substr($this->path,strlen($this->homedir) + 1)) - { - $this->cwd = '/'; - } - else - { - $this->cwd = substr($this->pwd,strrpos($this->pwd,'/')+1); - } - - $this->disppath = $this->path; - - /* This just prevents // in some cases */ - if($this->path == '/') - { - $this->dispsep = ''; - } - else - { - $this->dispsep = '/'; - } - - if (!($this->lesspath = substr($this->path,0,strrpos($this->path, '/')))) - { - $this->lesspath = '/'; - } - - $this->now = date('Y-m-d'); - - if($this->debug) - { - echo 'PHPWebHosting debug:
' - . 'path: '.$this->path.'
' - . 'disppath: '.$this->disppath.'
' - . 'cwd: '.$this->cwd.'
' - . 'lesspath: '.$this->lesspath.'
' - . 'fakebase: '.$this->fakebase.'
' - . 'homedir: '.$this->homedir.'

' - . 'phpGW debug:
' - . 'real getabsolutepath: '.$this->vfs->getabsolutepath(False, False, False).'
' - . 'fake getabsolutepath: '.$this->vfs->getabsolutepath(False).'
' - . 'appsession: '.$GLOBALS['phpgw']->session->appsession('vfs','').'
' - . 'pwd: '.$this->vfs->pwd().'
'; - } - - - ### - # Get their memberships to be used throughout the script - ### - - $this->memberships = $GLOBALS['phpgw']->accounts->membership($this->userinfo['username']); - - if(!is_array($this->memberships)) - { - settype($this->memberships,'array'); - $this->memberships = Array(); - } - - $group_applications = CreateObject('phpgwapi.applications'); - while(list($num,$group_array) = each($this->memberships)) - { - $group_applications->account_id = get_account_id($GLOBALS['phpgw']->accounts->name2id($group_array['account_name'])); - $this->membership_applications[$group_array['account_name']] = $group_applications->read_account_specific(); - } - - ### - # We determine if they're in their home directory or a group's directory, - # and set the VFS working_id appropriately - ### - if((preg_match('+^'.$this->fakebase.'\/(.*)(\/|$)+U',$this->path,$this->matches)) && $this->matches[1] != $this->userinfo['account_lid']) - { - $this->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); - } - else - { - $this->vfs->working_id = $this->userinfo['username']; - } - } - - function initialize_vars($name) - { - $var = ($GLOBALS['HTTP_GET_VARS'][$name]?$GLOBALS['HTTP_GET_VARS'][$name]:''); - $var = ($GLOBALS['HTTP_POST_VARS'][$name]?$GLOBALS['HTTP_POST_VARS'][$name]:$var); - if($this->debug) - { - echo ''."\n"; - } - if(is_array($this->$name) && $var) - { - $temp = Array(); - while(list($varkey,$varvalue) = each($var)) - { - if(is_int($varkey)) - { - $temp[$varkey] = urldecode($varvalue); - } - else - { - $temp[urldecode($varkey)] = $varvalue; - } - } - } - elseif($var) - { - $temp = urldecode($var); - } - if(isset($temp)) - { - $this->$name = $temp; - } - } - - function load_files() - { - ### - # Read in file info from database to use in the rest of the script - # $fakebase is a special directory. In that directory, we list the user's - # home directory and the directories for the groups they're in - ### - - if ($this->path == $this->fakebase) - { - if (!$this->vfs->file_exists($this->homedir,Array(RELATIVE_NONE))) - { - $this->vfs->mkdir($this->homedir,Array(RELATIVE_NONE)); - } - - $ls_array = $this->vfs->ls($this->homedir,Array(RELATIVE_NONE),False,False,True); - $this->files_array[] = $ls_array[0]; - - reset ($this->memberships); - while(list($num, $group_array) = each($this->memberships)) - { - ### - # If the group doesn't have access to this app, we don't show it - ### - - if (!$this->membership_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) - { - continue; - } - - if (!$this->vfs->file_exists($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE))) - { - $this->vfs->mkdir($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE)); - $this->vfs->set_attributes($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE),Array('owner_id' => $group_array['account_id'], 'createdby_id' => $group_array['account_id'])); - } - - $ls_array = $this->vfs->ls($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE),False,False,True); - - $this->files_array[] = $ls_array[0]; - } - } - else - { - $ls_array = $this->vfs->ls($this->path,Array(RELATIVE_NONE),False,False,False,$this->sortby); - - if ($this->debug) - { - echo '# of files found in "'.$this->path.'" : '.count($ls_array).'
'."\n"; - } - - while(list($num,$file_array) = each($ls_array)) - { - $this->files_array[] = $file_array; - if ($this->debug) - { - echo 'Filename: '.$file_array['name'].'
'."\n"; - } - } - } - if(!is_array($this->files_array)) - { - $this->files_array = Array(); - } - - return $this->files_array; - } - - function convert_date($data) - { - if($data && $data != '0000-00-00') - { - $year = substr($data,0,4); - $month = substr($data,5,2); - $day = substr($data,8,2); - $datetime = mktime(0,0,0,$month,$day,$year); - $data = date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$datetime); - } - else - { - $data = ' '; - } - return $data; - } - - function f_go() - { - $this->path = $this->todir; - } - - function f_delete() - { - $numoffiles = count($this->fileman); - for($i=0;$i!=$numoffiles;$i++) - { - if($this->fileman[$i]) - { - $ls_array = $this->vfs->ls($this->path.SEP.$this->fileman[$i],Array(RELATIVE_NONE),False,False,True); - $fileinfo = $ls_array[0]; - if($fileinfo) - { - if($fileinfo['mime_type'] == 'Directory') - { - $mime_type = $fileinfo['mime_type']; - } - else - { - $mime_type = 'File'; - } - if($this->vfs->delete($this->path.SEP.$this->fileman[$i],Array(RELATIVE_USER_NONE))) - { - $errors[] = ''.$mime_type.' Deleted: '.$this->path.SEP.$this->fileman[$i].''; - } - else - { - $errors[] = 'Could not delete '.$this->path.SEP.$this->fileman[$i].''; - } - } - else - { - $errors[] = ''.$this->path.SEP.$this->fileman[$i].' does not exist!'; - } - } - } - return $errors; - } - - function f_copy() - { - $numoffiles = count($this->fileman); - for($i=0;$i!=$numoffiles;$i++) - { - if($this->fileman[$i]) - { - if($this->vfs->cp($this->path.SEP.$this->fileman[$i],$this->todir.SEP.$this->fileman[$i],Array(RELATIVE_NONE,RELATIVE_NONE))) - { - $errors[] = 'File copied: '.$this->path.SEP.$this->fileman[$i].' to '.$this->todir.SEP.$this->fileman[$i].''; - } - else - { - $errors[] = 'Could not copy '.$this->path.SEP.$this->fileman[$i].' to '.$this->todir.SEP.$this->fileman[$i].''; - } - } - } - return $errors; - } - - function f_move() - { - $numoffiles = count($this->fileman); - for($i=0;$i!=$numoffiles;$i++) - { - if($this->fileman[$i]) - { - if($this->vfs->mv($this->path.SEP.$this->fileman[$i],$this->todir.SEP.$this->fileman[$i],Array(RELATIVE_NONE,RELATIVE_NONE))) - { - $errors[] = 'File moved: '.$this->path.SEP.$this->fileman[$i].' to '.$this->todir.SEP.$this->fileman[$i].''; - } - else - { - $errors[] = 'Could not move '.$this->path.SEP.$this->fileman[$i].' to '.$this->todir.SEP.$this->fileman[$i].''; - } - } - } - return $errors; - } - - function f_download() - { - $numoffiles = count($this->fileman); - for($i=0;$i!=$numoffiles;$i++) - { - if($this->fileman[$i] && $this->vfs->file_exists($this->bo->path.SEP.$this->bo->fileman[$i],Array(RELATIVE_NONE))) - { - execmethod($this->appname.'.ui'.$this->appname.'.view_file', - Array( - 'path' => $this->path, - 'file' => $this->fileman[$i] - ) - ); - $errors[] = 'File downloaded: '.$this->path.SEP.$this->fileman[$i].''; - } - else - { - $errors[] = 'File does not exist: '.$this->path.SEP.$this->fileman[$i].''; - } - } - return $errors; - } - - function f_newdir() - { - if ($this->newdir && $this->createdir) - { - if ($badchar = $this->bad_chars($this->createdir,True,True)) - { - $errors[] = 'Directory names cannot contain "'.$badchar.'"'; - return $errors; - } - - if (substr($this->createdir,strlen($this->createdir)-1,1) == ' ' || substr($this->createdir,0,1) == ' ') - { - $errors[] = 'Cannot create directory because it begins or ends in a space'; - return $errors; - } - - $ls_array = $this->vfs->ls($this->path.SEP.$this->createdir,Array(RELATIVE_NONE),False,False,True); - $fileinfo = $ls_array[0]; - - if ($fileinfo['name']) - { - if ($fileinfo['mime_type'] != 'Directory') - { - $errors[] = ''.$fileinfo['name'].' already exists as a file'; - } - else - { - $errors[] = 'Directory '.$fileinfo['name'].' already exists.'; - } - } - else - { - if ($this->vfs->mkdir($this->path.SEP.$this->createdir,Array(RELATIVE_NONE))) - { - $errors[] = 'Created directory '.$this->path.SEP.$this->createdir.''; -// $this->path = $this->path.SEP.$this->createdir; - } - else - { - $errors[] = 'Could not create '.$this->path.SEP.$this->createdir.''; - } - } - } - return $errors; - } - - function f_newfile() - { - if ($this->newfile && $this->createfile) - { - if($badchar = $this->bad_chars($this->createfile,True,True)) - { - $errors[] = 'Filenames cannot contain "'.$badchar.'"'; - return $errors; - } - if($this->vfs->file_exists($this->path.SEP.$this->createfile,Array(RELATIVE_NONE))) - { - $errors[] = 'File '.$this->path.SEP.$this->createfile.' already exists. Please edit it or delete it first.'; - return $errors; - } - if(!$this->vfs->touch($this->path.SEP.$this->createfile,Array(RELATIVE_NONE))) - { - $errors[] = 'File '.$this->path.SEP.$this->createfile.' could not be created.'; - } - } - else - { - $errors[] = 'Filename not provided!'; - } - return $errors; - } - - function load_help_info() - { - $this->help_info = Array( - array ("up", "The Up button takes you to the directory above the current directory. For example, if you're in /home/jdoe/mydir, the Up button would take you to /home/jdoe."), - array ("directory_name", "The name of the directory you're currently in."), - array ("home", "The Home button takes you to your personal home directory."), - array ("sort_by", "Click on any of the column headers to sort the list by that column."), - array ("filename", "The name of the file or directory."), - array ("mime_type", "The MIME-type of the file. Examples include text/plain, text/html, image/jpeg. The special MIME-type Directory is used for directories."), - array ("size", "The size of the file or directory in the most convenient units: bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB). Sizes for directories include subfiles and subdirectories."), - array ("created", "When the file or directory was created."), - array ("modified", "When the file or directory was last modified."), - array ("owner", "The owner of the file or directory. This can be a user or group name."), - array ("created_by", "Displays who created the file or directory."), - array ("modified_by", "Displays who last modified the file or directory."), - array ("application", "The application associated with the file or directory. Usually the application used to create it. A blank application field is ok."), - array ("comment", "The comment for the file or directory. Comments can be set when creating the file or directory, and created or edited any time thereafter."), - array ("version", "The current version for the file or directory. Clicking on the version number will display a list of changes made to the file or directory."), - array ("edit", "Edit the text of the selected file(s). You can select more than one file; this is useful when you want to copy part of one file into another. Clicking Preview will show you a preview of the file. Click Save to save your changes."), - array ("rename", "Rename the selected file(s). You can select as many files or directories as you want. You are presented with a text field to enter the new name of each file or directory."), - array ("delete", "Delete the selected file(s). You can select as many files or directories as you want. When deleting directories, the entire directory and all of its contents are deleted. You will not be prompted to make sure you want to delete the file(s); make sure you really want to delete them before clicking Delete."), - array ("edit_comments", "Create a comment for a file or directory, or edit an existing comment. You can select as many files or directories as you want."), - array ("go_to", "The Go to button takes you to the directory selected in the drop down [directory_list|Directory List]."), - array ("copy_to", "This will copy all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), - array ("move_to", "This will move all selected files and directories to the directory selected in the drop down [directory_list|Directory List]."), - array ("directory_list", "The Directory List contains a list of all directories you have (at least) read access to. Selecting a directory and clicking one of the [go_to|Go to]/[copy_to|Copy to]/[move_to|Move to] buttons will perform the selected action on that directory. For example, if you select \"/home/somegroup/reports\" from the Directory List, and click the \"[copy_to|Copy to]\" button, all selected files and directories will be copied to \"/home/somegroup/reports\"."), - array ("download", "Download the first selected file to your local computer. You can only download one file at a time. Directories cannot be downloaded, only files."), - array ("create_folder", "Creates a directory (folder == directory). The name of the directory is specified in the text box next to the Create Folder button."), - array ("create_file", "Creates a file in the current directory. The name of the file is specified in the text box next to the Create File button. After clicking the Create File button you will be presented with the [edit|Edit] screen, where you may edit the file you just created. If you do not with to make any changes to the file at this time, simply click the Save button and the file will be saved as an empty file."), - array ("command_line", "Enter a Unix-style command line here, which will be executed when the [execute|Execute] button is pressed. If you don't know what this is, you probably should turn the option off in the Preferences."), - array ("execute", "Clicking the Execute button will execute the Unix-style [command_line|command line] specified in the text box above. If you don't know what this is, you probably should turn the option off in the Preferences."), - array ("update", "Sync the database with the filesystem for the current directory. This is useful if you use another interface to access the same files. Any new files or directories in the current directory will be read in, and the attributes for the other files will be updated to reflect any changes to the filesystem. Update is run automatically every few page loads (currently every 20 page loads as of this writing, but that may have changed by now)."), - array ("file_stats", "Various statistics on the number and size of the files in the current directory. In some situations, these reflect different statistics. For example, when in / or the base directory."), - array ("upload_file", "The full path of the local file to upload. You can type it in or use the Browse.. button to select it. The file will be uploaded to the current directory. You cannot upload directories, only files."), - array ("upload_comment", "The inital comment to use for the newly uploaded file. Totally optional and completely arbitrary. You can [edit_comments|create or edit the comment] at any time in the future."), - array ("upload_files", "This will upload the files listed in the input boxes above, and store them in the current directory."), - array ("show_upload_fields", "This setting determines how many [upload_files|upload fields] will be shown at once. You can change the default number that will be shown in the preferences.") - ); - } - - function borkb ($size,$enclosed = NULL,$return = 0) - { - if(!$size) - { - $size = 0; - } - - if($enclosed) - { - $left = '('; - $right = ')'; - } - - if($size<1024) - { - return $left.$size.' B  '.$right; - } - else - { - return $left.round($size/1024).' KB'.$right; - } - } - - ### - # Check for and return the first unwanted character - ### - - function bad_chars($string,$all = True,$return = 0) - { - if($all) - { - if (preg_match("-([\\/<>\'\"\&])-", $string, $badchars)) - { - $rstring = $badchars[1]; - } - } - else - { - if (preg_match("-([\\/<>])-", $string, $badchars)) - { - $rstring = $badchars[1]; - } - } - return $rstring; - } - - ### - # Match character in string using ord (). - ### - function ord_match($string, $charnum) - { - for ($i=0;$ihostname,$string)) - { - $rstring = ereg_replace('^'.$this->hostname.'/','',$string); - $rstring = preg_replace("/(.*)(\/|$)/Ue","rawurlencode (base64_encode ('\\1')).'\\2'",$rstring); - $rstring = $this->hostname.'/'.$rstring; - } - else - { - $rstring = rawurlencode($string); - - /* Terrible hack, decodes all /'s back to normal */ - $rstring = preg_replace("/%2F/",'/',$rstring); - } - - return($this->eor($rstring,$return)); - } - - function string_decode($string,$return = False) - { - $rstring = rawurldecode($string); - - return($this->eor($rstring,$return)); - } - - ### - # HTML encode a string - # This should be used with anything in an HTML tag that might contain < or > - ### - - function html_encode($string, $return) - { - return($this->eor(htmlspecialchars($string),$return)); - } - - function translate ($text) - { - return($GLOBALS['phpgw']->lang($text)); - } - } -?> diff --git a/filemanager/inc/class.sofilemanager.inc.php b/filemanager/inc/class.sofilemanager.inc.php new file mode 100755 index 0000000000..66300e8d86 --- /dev/null +++ b/filemanager/inc/class.sofilemanager.inc.php @@ -0,0 +1,60 @@ +db = $GLOBALS['phpgw']->db; +// $this->phpgw=$GLOBALS[phpgw]; +// $this->phpgw_info=$GLOBALS[phpgw_info]; + } + + /* Any initializations that need to be done */ + function db_init () + { + //global $phpgw; + //global $phpgw_info; + + $this->db->Auto_Free = 0; + } + + /* General SQL query */ + function db_query ($query) + { + // global $phpgw; + // global $phpgw_info; + + return $this->db->query ($query); + } + + /* Fetch next array for $query_id */ + function db_fetch_array ($query_id) + { +// global $phpgw; +// global $phpgw_info; + + // $phpgw->db->Query_ID = $query_id; + $this->db->next_record (); + return $this->db->Record; + } + + /* + General wrapper for all other db calls + Calls in here are simply returned, so not all will work + */ + function db_call ($function, $query_id) + { +// global $phpgw; +// global $phpgw_info; + + // $phpgw->db->Query_ID = $query_id; + return $this->db->$function (); + } + + + } +?> diff --git a/filemanager/inc/class.sophpwebhosting.inc.php b/filemanager/inc/class.sophpwebhosting.inc.php deleted file mode 100755 index f3f5097500..0000000000 --- a/filemanager/inc/class.sophpwebhosting.inc.php +++ /dev/null @@ -1,34 +0,0 @@ -db->Auto_Free = 0; - } - - /* General SQL query */ - function query($query) - { - return $GLOBALS['phpgw']->db->query($query); - } - - /* Fetch next array for $query_id */ - function fetch_array($query_id) - { - $GLOBALS['phpgw']->db->next_record (); - return $GLOBALS['phpgw']->db->Record; - } - - /* - General wrapper for all other db calls - Calls in here are simply returned, so not all will work - */ - function call($function, $query_id) - { - return $GLOBALS['phpgw']->db->$function(); - } - } -?> diff --git a/filemanager/inc/class.uifilemanager.inc.php b/filemanager/inc/class.uifilemanager.inc.php index 68c7d82227..a2d14f8040 100755 --- a/filemanager/inc/class.uifilemanager.inc.php +++ b/filemanager/inc/class.uifilemanager.inc.php @@ -21,42 +21,80 @@ var $public_functions = array( 'index' => True, + 'help' => True, + 'view' => True, + 'history' => True, + 'edit' => True, + 'download'=>True ); + //keep var $bo; -// var $pref; - var $imgroot; + var $t; //template object + var $dispath; + var $cwd; + var $lesspath; + var $readable_groups; + var $files_array; + var $numoffiles; + var $dispsep; + + var $target; + + + var $prefs;//array + + //originally post_vars + var $goto; + var $todir; + var $createdir; + var $newfile_or_dir; + var $newdir; + var $newfile; + var $createfile; + var $delete; + var $renamefiles; + var $rename; + var $move_to; + var $copy_to; + var $edit; + var $edit_file; + var $edit_preview; + var $edit_save; + var $edit_save_done; + var $edit_cancel; + var $comment_files; + var $upload; + var $uploadprocess; + + // this ones must be checked thorougly; + var $fileman; + var $path; + var $file; + var $sortby; + var $messages; + var $show_upload_boxes; + + var $debug = false; + var $now; function uifilemanager() { +// error_reporting (8); + + $this->now = date ('Y-m-d'); + $this->bo = CreateObject('filemanager.bofilemanager'); - - //FIXME remove this one - $this->imgroot='filemanager/templates/default/'; - - - } + $this->t = $GLOBALS['phpgw']->template; - function index() - { - global $download,$path,$sortby,$op,$go,$file,$show_upload_boxes; - - ### - # Enable this to display some debugging info - ### - - $phpwh_debug = 0; - + // here local vars are created from the HTTP vars @reset ($GLOBALS['HTTP_POST_VARS']); while (list ($name,) = @each ($GLOBALS['HTTP_POST_VARS'])) { - $$name = $GLOBALS['HTTP_POST_VARS'][$name]; + $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; } - - // var_dump($GLOBALS['HTTP_POST_VARS']); - - + @reset ($GLOBALS['HTTP_GET_VARS']); while (list ($name,) = @each ($GLOBALS['HTTP_GET_VARS'])) { @@ -75,18 +113,14 @@ 'path' => array ('path' => ''), 'file' => array ('file' => ''), 'sortby' => array ('sortby' => ''), - 'fileman' => array ('fileman' => ''), +// 'fileman' => array ('fileman' => ''), 'messages' => array ('messages' => ''), - 'help_name' => array ('help_name' => ''), - 'renamefiles' => array ('renamefiles' => ''), +// 'help_name' => array ('help_name' => ''), +// 'renamefiles' => array ('renamefiles' => ''), 'comment_files' => array ('comment_files' => ''), 'show_upload_boxes' => array ('show_upload_boxes' => '') ); - // FIXME (pim) decode doesn't work and I don't know where its for - - /* - reset ($to_decode); while (list ($var, $conditions) = each ($to_decode)) { @@ -97,7 +131,6 @@ if (is_array ($$var)) { $temp = array (); - //some fixes in this section were supplied by Michael Totschnig while (list ($varkey, $varvalue) = each ($$var)) { if (is_int ($varkey)) @@ -109,789 +142,444 @@ $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; } } - $$var = $temp; + $this->$var = $temp; } elseif (isset ($$var)) { - $$var = stripslashes (base64_decode(urldecode ($$var))); + $this->$var = stripslashes (base64_decode(urldecode ($$var))); } } } } - */ + // get appl. and user prefs + $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $pref->read_repository (); +// $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); + $pref->save_repository (True); + $pref_array = $pref->read_repository (); + $this->prefs = $pref_array[$GLOBALS['appname']]; + + //always show name + + $this->prefs[name] =1; - //FIXME re-enable this here above - if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) + if ($this->prefs['viewinnewwin']) + { + $this->target = '_blank'; + } + } + + function index() + { + if ($noheader || $nofooter || ($this->download && (count ($this->fileman) > 0))) { $noheader = True; $nofooter = True; + $noappheader= True; + $nonavbar=True; } - - $GLOBALS['phpgw_info']['flags'] = array - ( - 'currentapp' => 'filemanager', - 'noheader' => $noheader, - 'nofooter' => $nofooter, - 'noappheader' => False, - 'enable_browser_class' => True - ); - -// var_dump($GLOBALS['phpgw_info']['flags']); - $GLOBALS['phpgw']->common->phpgw_header(); - - - if ($execute && $command_line) + else { - if ($result = $this->bo->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) - { - $messages = $this->html_text_bold (lang('Command sucessfully run'),1); - if ($result != 1 && strlen ($result) > 0) - { - $messages .= $this->html_break (2, NULL, 1) . $result; - } - } - else - { - $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); - } + $GLOBALS['phpgw_info']['flags'] = array + ( + 'currentapp' => 'filemanager', + 'noheader' => $noheader, + 'nonavbar' => $nonavbar, + 'nofooter' => $nofooter, + 'noappheader' => $noappheader, + 'enable_browser_class' => True + ); + + $GLOBALS['phpgw']->common->phpgw_header(); + } - ### + //var_dump($GLOBALS[HTTP_POST_VARS]); + + # Page to process users # Code is fairly hackish at the beginning, but it gets better # Highly suggest turning wrapping off due to long SQL queries - ### ### # Some hacks to set and display directory paths correctly ### - if ($go) + if ($this->goto) { - $path = $todir; + $this->path = $this->todir; } - - // var_dump($GLOBALS['phpgw_info']); - // var_dump($GLOBALS['phpgw']); - // die(); - - if (!$path) + + if (!$this->path) { - $path = $this->bo->vfs->pwd (); + $this->path = $this->bo->vfs->pwd (); - if (!$path || $this->bo->vfs->pwd (array ('full' => False)) == '') + if (!$this->path || $this->bo->vfs->pwd (array ('full' => False)) == '') { - $path = $GLOBALS['homedir']; + $this->path = $GLOBALS['homedir']; } } - - $this->bo->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); - $this->bo->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + $this->bo->vfs->cd (array ('string' => $this->path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); $pwd = $this->bo->vfs->pwd (); - if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) + if (!$this->cwd = substr ($this->path, strlen ($GLOBALS['homedir']) + 1)) { - $cwd = '/'; + $this->cwd = '/'; } else { - $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); + $this->cwd = substr ($pwd, strrpos ($pwd, '/') + 1); } - $disppath = $path; + $this->disppath = $this->path; /* This just prevents // in some cases */ - if ($path == '/') - $dispsep = ''; + if ($this->path == '/') + $this->dispsep = ''; else - $dispsep = '/'; + $this->dispsep = '/'; - if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) - $lesspath = '/'; + if (!($this->lesspath = substr ($this->path, 0, strrpos ($this->path, '/')))) + $this->lesspath = '/'; - $now = date ('Y-m-d'); - - if ($phpwh_debug) - { - echo "PHPWebHosting debug:
- path: $path
- disppath: $disppath
- cwd: $cwd
- lesspath: $lesspath -

- phpGW debug:
- real getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "
- fake getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False)) . "
- appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
- pwd: " . $this->bo->vfs->pwd () . "
"; - } - - ### # Get their readable groups to be used throughout the script - ### - - $groups = array (); + $groups = array(); $groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); - $readable_groups = array (); + $this->readable_groups = array(); while (list ($num, $account) = each ($groups)) { - if ($this->bo->vfs->acl_check (array ( - 'owner_id' => $account['account_id'], - 'operation' => PHPGW_ACL_READ - )) - ) - { - $readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); - } - } - - $groups_applications = array (); - - while (list ($num, $group_array) = each ($readable_groups)) - { - $group_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); - - $applications = CreateObject('phpgwapi.applications', $group_id); - $groups_applications[$group_array['account_name']] = $applications->read_account_specific (); - } - - ### - # We determine if they're in their home directory or a group's directory, - # and set the VFS working_id appropriately - ### - - if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) - { - $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); - } - else - { - $this->bo->vfs->working_id = $GLOBALS['userinfo']['username']; - } - - if ($path != $GLOBALS['homedir'] - && $path != $GLOBALS['fakebase'] - && $path != '/' - && !$this->bo->vfs->acl_check (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'operation' => PHPGW_ACL_READ - )) - ) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('You do not have access to %1', $path))); - $this->html_break (2); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], lang('Go to your home directory')); - $this->html_page_close (); - } - - $GLOBALS['userinfo']['working_id'] = $this->bo->vfs->working_id; - $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); - - ### - # If their home directory doesn't exist, we create it - # Same for group directories - ### - - if (($path == $GLOBALS['homedir']) - && !$this->bo->vfs->file_exists (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE) - )) -) -{ - $this->bo->vfs->override_acl = 1; - - if (!$this->bo->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) - { - // FIXME (pim) ?? - $p = $this->bo->vfs->path_parts (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create directory %1', $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')'))); - } - - $this->bo->vfs->override_acl = 0; -} - -### -# Verify path is real -### - -if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) -{ - if (!$this->bo->vfs->file_exists (array ('string' => $path, 'relatives' => array (RELATIVE_NONE)))) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 does not exist', $path))); - $this->html_break (2); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], lang('Go to your home directory')); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); - } -} - -/* Update if they request it, or one out of 20 page loads */ -srand ((double) microtime() * 1000000); -if ($update || rand (0, 19) == 4) -{ - $this->bo->vfs->update_real (array ('string' => $path, 'relatives' => array (RELATIVE_NONE))); -} - -### -# Check available permissions for $path, so we can disable unusable operations in user interface -### - -if ($this->bo->vfs->acl_check (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'operation' => PHPGW_ACL_ADD -)) - ) - { - $can_add = True; - } - - ### - # Default is to sort by name - ### - - if (!$sortby) - { - $sortby = 'name'; - } - - ### - # Decide how many upload boxes to show - ### - //var_dump($show_upload_boxes); - //die(); - - if (!$show_upload_boxes || $show_upload_boxes <= 0) - { - if (!$show_upload_boxes = $GLOBALS['settings']['show_upload_boxes']) + if ($this->bo->vfs->acl_check (array ('owner_id' => $account['account_id'], 'operation' => PHPGW_ACL_READ))) { - $show_upload_boxes = 5; + $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); } } - ### - # Read in file info from database to use in the rest of the script - # $fakebase is a special directory. In that directory, we list the user's - # home directory and the directories for the groups they're in - ### + $groups_applications = array (); - $numoffiles = 0; - if ($path == $GLOBALS['fakebase']) + while (list ($num, $group_array) = each ($this->readable_groups)) { - if (!$this->bo->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) - { - $this->bo->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); - } + $group_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); - $files_array[] = $ls_array[0]; - $numoffiles++; - // $files_array = $ls_array; - // $numoffiles = count($ls_array); + $applications = CreateObject('phpgwapi.applications', $group_id); + $groups_applications[$group_array['account_name']] = $applications->read_account_specific (); + } - reset ($readable_groups); - while (list ($num, $group_array) = each ($readable_groups)) + # We determine if they're in their home directory or a group's directory, + # and set the VFS working_id appropriately + if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) { - ### - # If the group doesn't have access to this app, we don't show it - ### - - if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) - { - continue; - } - - if (!$this->bo->vfs->file_exists (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE) - )) - ) - { - $this->bo->vfs->override_acl = 1; - $this->bo->vfs->mkdir (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE) - ) - ); - $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'] - ) - ) - ); - } - - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) -); - -$files_array[] = $ls_array[0]; - -$numoffiles++; - } + $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); } else { - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => False, - 'orderby' => $sortby - ) - ); - - if ($phpwh_debug) - { - echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; + $this->bo->vfs->working_id = $GLOBALS['userinfo']['username']; } - - while (list ($num, $file_array) = each ($ls_array)) + + + # 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 ))) { - $numoffiles++; - $files_array[] = $file_array; - if ($phpwh_debug) - { - echo 'Filename: '.$file_array['name'].'
'."\n"; - } - } - } + $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')); - if (!is_array ($files_array)) - { - $files_array = array (); - } - - if ($download) - { - for ($i = 0; $i != $numoffiles; $i++) - { - if (!$fileman[$i]) - { - continue; - } - - $download_browser = CreateObject ('phpgwapi.browser'); - $download_browser->content_header ($fileman[$i]); - echo $this->bo->vfs->read (array ('string' => $fileman[$i])); + $GLOBALS['phpgw']->common->phpgw_footer (); $GLOBALS['phpgw']->common->phpgw_exit (); } - } - if ($op == 'view' && $file) - { - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $path.'/'.$file, - 'relatives' => array (RELATIVE_ALL), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); + $GLOBALS['userinfo']['working_id'] = $this->bo->vfs->working_id; + $GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); - if ($ls_array[0]['mime_type']) - { - $mime_type = $ls_array[0]['mime_type']; - } - elseif ($GLOBALS['settings']['viewtextplain']) - { - $mime_type = 'text/plain'; - } - - header('Content-type: ' . $mime_type); - echo $this->bo->vfs->read (array ( - 'string' => $path.'/'.$file, - 'relatives' => array (RELATIVE_NONE) - ) - ); - $GLOBALS['phpgw']->common->phpgw_exit (); -} - -if ($op == 'history' && $file) -{ - $journal_array = $this->bo->vfs->get_journal (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL) - ) -); - -if (is_array ($journal_array)) -{ - $this->html_table_begin (); - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->html_text_bold (lang('Date')); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->html_text_bold (lang('Version')); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->html_text_bold (lang('Who')); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->html_text_bold (lang('Operation')); - $this->html_table_col_end (); - $this->html_table_row_end (); - - while (list ($num, $journal_entry) = each ($journal_array)) - { - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->bo->html_text ($journal_entry['created'] . $this->html_nbsp (3, 1)); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->bo->html_text ($journal_entry['version'] . $this->html_nbsp (3, 1)); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . $this->html_nbsp (3, 1)); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->bo->html_text ($journal_entry['comment']); - $this->html_table_col_end (); - } - - $this->html_table_end (); - $this->html_page_close (); -} -else -{ - $this->html_text_bold (lang('No version history for this file/directory')); -} - - } - - if ($newfile && $createfile) + # If their home directory doesn't exist, we try to create it + # Same for group directories + if (($this->path == $GLOBALS['homedir']) && !$this->bo->vfs->file_exists ($pim_tmp_arr)) { - if ($badchar = $this->bo->bad_chars ($createfile, True, True)) + $this->bo->vfs->override_acl = 1; + + if (!$this->bo->vfs->mkdir (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE) + ))) { - echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('File names cannot contain "%1"',$badchar), 1))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); + $p = $this->bo->vfs->path_parts ($pim_tmp_arr); + + $this->messages= $GLOBALS['phpgw']->common->error_list (array ( + lang('Could not create directory %1', + $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')' + ))); } - if ($this->bo->vfs->file_exists (array ( - 'string' => $createfile, - 'relatives' => array (RELATIVE_ALL) - )) - ) - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); + $this->bo->vfs->override_acl = 0; } - if ($this->bo->vfs->touch (array ( - 'string' => $createfile, - 'relatives' => array (RELATIVE_ALL) - )) - ) - { - $fileman = array (); - $fileman[0] = $createfile; - $edit = 1; - $numoffiles++; - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 could not be created.', $createfile))); - } - } - - if ($op == 'help' && $help_name) - { - while (list ($num, $help_array) = each ($help_info)) - { - if ($help_array[0] != $help_name) - continue; - - $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); - $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); - - $this->html_font_set ('4'); - $title = ereg_replace ('_', ' ', $help_array[0]); - $title = ucwords ($title); - $this->bo->html_text ($title); - $this->html_font_end (); - - $this->html_break (2); - - $this->html_font_set ('2'); - $this->bo->html_text ($help_array[1]); - $this->html_font_end (); - } - - $GLOBALS['phpgw']->common->phpgw_exit (); - } - - ### - # Start Main Page - ### - - $this->html_page_begin (lang('Users').' :: '.$GLOBALS['userinfo']['username']); - $this->html_page_body_begin (HTML_PAGE_BODY_COLOR); - - if ($messages) - { - $this->bo->html_text ($messages); - } - - if (!count ($GLOBALS['settings'])) - { - $GLOBALS[pref] = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); - $GLOBALS[pref]->read_repository (); - $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); - $GLOBALS[pref]->save_repository (True); - $pref_array = $GLOBALS[pref]->read_repository (); - $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; - } - - ### - # Start Main Table - ### - - if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) - { - $this->html_table_begin ('100%'); - $this->html_table_row_begin (); - $this->html_table_col_begin ('center', NULL, 'top'); - $this->html_align ('center'); - $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path); - if ($numoffiles || $cwd) - { - while (list ($num, $name) = each ($GLOBALS['settings'])) + # Verify path is real + if ($this->path != $GLOBALS['homedir'] && $this->path != '/' && $this->path != $GLOBALS['fakebase']) { - if ($name) + if (!$this->bo->vfs->file_exists (array ( + 'string' => $this->path, + 'relatives' => array (RELATIVE_NONE) + ))) { - $columns++; + $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')); + + $GLOBALS['phpgw']->common->phpgw_footer (); + $GLOBALS['phpgw']->common->phpgw_exit (); } } - $columns++; - $this->html_table_begin (); - $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); - $this->html_table_col_begin ('center', NULL, NULL, NULL, $columns); - $this->html_table_begin ('100%'); - $this->html_table_row_begin (); - $this->html_table_col_begin ('left'); - if ($path != '/') + /* Update if they request it, or one out of 20 page loads */ + srand ((double) microtime() * 1000000); + if ($update || rand (0, 19) == 4) { - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$lesspath, $this->html_image ($this->imgroot.'images/folder-up.png', lang('Up'), 'left', 0, NULL, 1)); - $this->html_help_link ('up'); + $this->bo->vfs->update_real (array ( + 'string' => $this->path, + 'relatives' => array (RELATIVE_NONE) + )); } - $this->html_table_col_end (); - $this->html_table_col_begin ('center'); - - if ($cwd) + # Check available permissions for $this->path, so we can disable unusable operations in user interface + if ($this->bo->vfs->acl_check (array( + 'string' => $this->path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_ADD + ))) { - if ($path == $GLOBALS['homedir']) - { - $this->html_image ($this->imgroot.'images/folder-home.png', lang('Folder'), 'center'); - } - else - { - $this->html_image ($this->imgroot.'images/folder.png', lang('Folder'), 'center'); - } + $this->can_add = True; + } + + + # Default is to sort by name + if (!$this->sortby) + { + $this->sortby = 'name'; + } + + if($this->debug) $this->debug_filemanager(); + + # main action switch + // FIXME this will become a switch + if($this->newfile && $this->newfile_or_dir) // create new textfile + { + $this->createfile(); + } + elseif($this->newfile_or_dir && $this->newdir) + { + $this->createdir(); + } + elseif ($this->uploadprocess) + { + $this->fileUpload(); + } + elseif ($this->upload || $this->show_upload_boxes) + { + $this->showUploadboxes(); + } + elseif ($this->copy_to) + { + $this->copyTo(); + } + elseif ($this->move_to) + { + $this->moveTo(); + } + elseif ($this->download) + { + $this->download(); + } + elseif ($this->renamefiles) + { + $this->rename(); + } + elseif ($this->comment_files) + { + $this->editComment(); + } + elseif ($this->edit_cancel) + { + $this->readFilesInfo(); + $this->fileListing(); + } + elseif ($this->edit || $this->edit_preview || $this->edit_save) + { + $this->edit(); + } + elseif ($this->delete) + { + $this->delete(); } else { - $this->html_image ($this->imgroot.'images/folder-home.png', lang('Home')); + $this->readFilesInfo(); + $this->fileListing(); } - $this->html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); - $this->html_text_bold ($disppath); - $this->html_font_end (); - $this->html_help_link ('directory_name'); - $this->html_table_col_end (); - $this->html_table_col_begin ('right'); + } - if ($path != $GLOBALS['homedir']) + function fileListing() + { + $this->t->set_file(array('filemanager_list_t' => 'filelisting.tpl')); + $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); + $this->t->set_block('filemanager_list_t','column','column'); + $this->t->set_block('filemanager_list_t','row','row'); + $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); + + $vars['form_action']=$this->encode_href ('/index.php', 'menuaction=filemanager.uifilemanager.index','path='.$this->path); + if ($this->numoffiles || $this->cwd) { - $this->html_link ('/index.php'.'menuaction=filemanager.uifilemanager.index&path='.$GLOBALS['homedir'], $this->html_image ($this->imgroot.'images/folder-home.png', lang('Home'), 'right', 0, NULL, 1)); - $this->html_help_link ('home'); - } - - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_table_end (); - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); - - ### - # Start File Table Column Headers - # Reads values from $file_attributes array and preferences - ### - - $this->html_table_col_begin (); - $this->bo->html_text (lang('Sort by:') . $this->html_nbsp (1, 1), NULL, NULL, 0); - $this->html_help_link ('sort_by'); - $this->html_table_col_end (); - - reset ($this->bo->file_attributes); - while (list ($internal, $displayed) = each ($this->bo->file_attributes)) - { - if ($GLOBALS['settings'][$internal]) + while (list ($num, $name) = each ($this->prefs)) { - $this->html_table_col_begin (); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path.'&sortby='.$internal, $this->html_text_bold ($displayed, 1, 0)); - $this->html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); - $this->html_table_col_end (); - } - } - - $this->html_table_col_begin (); - $this->html_table_col_end (); - $this->html_table_row_end (); - - if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') - { - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->html_table_col_end (); - - /* We can assume the next column is the name */ - $this->html_table_col_begin (); - $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$lesspath, '..'); - $this->html_table_col_end (); - - if ($GLOBALS['settings']['mime_type']) - { - $this->html_table_col_begin (); - $this->bo->html_text (lang('Directory')); - $this->html_table_col_end (); - } - - $this->html_table_row_end (); - } - - ### - # List all of the files, with their attributes - ### - - reset ($files_array); - for ($i = 0; $i != $numoffiles; $i++) - { - $files = $files_array[$i]; - - if ($rename || $edit_comments) - { - unset ($this_selected); - unset ($renamethis); - unset ($edit_this_comment); - - for ($j = 0; $j != $numoffiles; $j++) + if ($name) { - if ($fileman[$j] == $files['name']) + $columns++; + } + } + $columns++; + + $vars[toolbar0]=$this->toolbar('location'); + $vars[toolbar1]=$this->toolbar('list_nav'); + $vars[messages]=$this->messages; + + $this->t->set_var($vars); + $this->t->pparse('out','filemanager_header'); + + + ### + # Start File Table Column Headers + # Reads values from $file_attributes array and preferences + ### + $this->t->set_var('actions',lang('select')); + + reset ($this->bo->file_attributes); + + if($this->numoffiles>0) + { + while (list ($internal, $displayed) = each ($this->bo->file_attributes)) + { + if ($this->prefs[$internal]) { - $this_selected = 1; - break; + $col_data=''.$displayed.''; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); } } - if ($rename && $this_selected) - { - $renamethis = 1; - } - elseif ($edit_comments && $this_selected) - { - $edit_this_comment = 1; - } - } - - if (!$GLOBALS['settings']['dotfiles'] && ereg ("^\.", $files['name'])) - { - continue; - } - - $this->html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); - - ### - # Checkboxes - ### - - $this->html_table_col_begin ('right'); - - if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') - { - $this->html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); - } - elseif ($renamethis) - { - $this->html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); + $this->t->set_var('row_tr_color','#cbcbcb'); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); } else { - $this->html_nbsp(); + $lang_nofiles=lang('No files in this directory.'); } + $vars[lang_no_files]=$lang_nofiles; + - $this->html_table_col_end (); - - ### - # File name and icon - ### - - if ($GLOBALS['settings']['name']) + if ($this->prefs['dotdot'] && $this->prefs['name'] && $this->path != '/') { - if ($phpwh_debug) + $this->t->set_var('actions',''); + + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); + + $col_data=''.lang('Folder').''; + $col_data.=' ..'; + + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column'); + + if ($this->prefs['mime_type']) { - echo 'Setting file name: '.$files['name'].'
'."\n"; + $col_data=lang('Directory'); + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); } - $this->html_table_col_begin (); + $this->t->set_var('row_tr_color',$tr_color); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); + } + + # List all of the files, with their attributes + reset ($this->files_array); + for ($i = 0; $i != $this->numoffiles; $i++) + { + $files = $this->files_array[$i]; + + if ($this->rename || $this->edit_comments) + { + unset ($this_selected); + unset ($renamethis); + unset ($edit_this_comment); + + for ($j = 0; $j != $this->numoffiles; $j++) + { + if ($this->fileman[$j] == $files['name']) + { + $this_selected = 1; + break; + } + } + + if ($this->rename && $this_selected) + { + $renamethis = 1; + } + elseif ($this->edit_comments && $this_selected) + { + $edit_this_comment = 1; + } + } + + if (!$this->prefs['dotfiles'] && ereg ("^\.", $files['name'])) + { + continue; + } + + # Checkboxes + if (!$this->rename && !$this->edit_comments && $this->path != $GLOBALS['fakebase'] && $this->path != '/') + { + $cbox=''; + $this->t->set_var('actions',$cbox); + } + elseif ($renamethis) + { + $cbox=$this->html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); + $this->t->set_var('actions',$cbox); + } + else + { + $this->t->set_var('actions',''); + } + + # File name and icon if ($renamethis) { - if ($files['mime_type'] == 'Directory') - { - $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); - } - $this->html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); + $col_data=$this->mime_icon($files['mime_type']); + $col_data.=''; } else { if ($files['mime_type'] == 'Directory') { - $this->html_image ($this->imgroot.'images/folder.png', lang('Folder')); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path.$dispsep.$files['name'], $files['name']); + $link=$this->encode_href ('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']); + + $icon=$this->mime_icon($files['mime_type']); + + $col_data=''.$icon.' '; + $col_data.=''.$files['name'].' '; } else { - if ($GLOBALS['settings']['viewinnewwin']) - { - $target = '_new'; - } - if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) + if ($this->prefs['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) { #FIXME $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; @@ -899,974 +587,1094 @@ else if ($phpwh_debug) { echo 'Setting clickview = '.$clickview.'
'."\n"; - $this->html_link ($clickview, '',$files['name'], 0, 1, 0, ''); + $this->html_link ($clickview,'', '',$files['name'], 0, 1, 0, ''); } } else { - #FIXME?? - // $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; - $this->html_link ('index.php','menuaction=filemanager.uifilemanager.index&op=view&file='.$files['name'].'&path='.$path, $files['name'], 0, 1, 0, $target); + $icon=$this->mime_icon($files['mime_type']); + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path); + + $col_data=''.$icon.' '.$files['name'].''; } - - - #FIXME - //$this->html_link ($clickview, $files['name'], 0, 1, 0, $target); } } - $this->html_table_col_end (); + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column'); + + # MIME type + if ($this->prefs['mime_type']) + { + $col_data=$files['mime_type']; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # File size + if ($this->prefs['size']) + { + $tmp_arr=array( + 'string' => $files['directory'] . '/' . $files['name'], + 'relatives' => array (RELATIVE_NONE) + ); + + $size = $this->bo->vfs->get_size($tmp_arr); + + $col_data=$this->bo->borkb ($size); + + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Date created + if ($this->prefs['created']) + { + $col_data=$files['created']; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Date modified + if ($this->prefs['modified']) + { + if ($files['modified'] != '0000-00-00') $col_data=$files['modified']; + else $col_data=''; + + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Owner name + if ($this->prefs['owner']) + { + $this->t->set_var('col_data',$GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); + $this->t->parse('columns','column',True); + } + + # Creator name + if ($this->prefs['createdby_id']) + { + $this->html_table_col_begin (); + if ($files['createdby_id']) + { + $col_data=$GLOBALS['phpgw']->accounts->id2name ($files['createdby_id']); + } + else $col_data=''; + + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Modified by name + if ($this->prefs['modifiedby_id']) + { + if ($files['modifiedby_id']) + { + $col_data=$GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id']); + } + else $col_data=''; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Application + if ($this->prefs['app']) + { + $col_data=$files['app']; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Comment + if ($this->prefs['comment']) + { + if ($edit_this_comment) + { + $col_data='' ; + } + else + { + $col_data=$files['comment']; + } + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + # Version + if ($this->prefs['version']) + { + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.history','file='.$files['name'].'&path='.$this->path); + $col_data=''.$files['version'].''; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column',True); + } + + + + if ($files['mime_type'] == 'Directory') + { + $usedspace += $fileinfo[0]; + } + else + { + $usedspace += $files['size']; + } + + $this->t->set_var('row_tr_color',''); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); } - ### - # MIME type - ### - - if ($GLOBALS['settings']['mime_type']) + // when renaming or changing comments render extra sumbmit button + if ($this->rename || $this->edit_comments) { - $this->html_table_col_begin (); - $this->bo->html_text ($files['mime_type']); - $this->html_table_col_end (); + $col_data='
'; + $this->t->set_var('col_data',$col_data); + $this->t->parse('columns','column'); + $this->t->set_var('row_tr_color',''); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); } - ### - # File size - ### - if ($GLOBALS['settings']['size']) - { - $this->html_table_col_begin (); + } - $size = $this->bo->vfs->get_size (array ( - 'string' => $files['directory'] . '/' . $files['name'], - 'relatives' => array (RELATIVE_NONE) - ) + + + // The file and directory information + $vars[lang_files_in_this_dir]=lang('Files is this directory'); + $vars[files_in_this_dir]=$this->numoffiles; + + $vars[lang_used_space]=lang('Used space'); + $vars[used_space]=$this->bo->borkb ($usedspace, NULL, 1); + + if ($this->path == $GLOBALS['homedir'] || $this->path == $GLOBALS['fakebase']) + { + $vars[lang_unused_space]=lang('Unused space'); + $vars[unused_space]=$this->bo->borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1); + + $tmp_arr=array ( + 'string' => $this->path, + 'relatives' => array (RELATIVE_NONE) ); - $this->bo->borkb ($size); + $ls_array = $this->bo->vfs->ls ($tmp_arr); + + + $vars[lang_total_files]=lang('Total Files'); + $vars[total_files]= count ($ls_array); - $this->html_table_col_end (); } - ### - # Date created - ### - if ($GLOBALS['settings']['created']) - { - $this->html_table_col_begin (); - $this->bo->html_text ($files['created']); - $this->html_table_col_end (); - } + $this->t->set_var($vars); + $this->t->pparse('out','filemanager_footer'); - ### - # Date modified - ### + $GLOBALS['phpgw']->common->phpgw_footer (); + $GLOBALS['phpgw']->common->phpgw_exit (); - if ($GLOBALS['settings']['modified']) + } + + function readFilesInfo() + { + // start files info + + # Read in file info from database to use in the rest of the script + # $fakebase is a special directory. In that directory, we list the user's + # home directory and the directories for the groups they're in + $this->numoffiles = 0; + if ($this->path == $GLOBALS['fakebase']) { - $this->html_table_col_begin (); - if ($files['modified'] != '0000-00-00') + if (!$this->bo->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) { - $this->bo->html_text ($files['modified']); + $this->bo->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); } - $this->html_table_col_end (); - } - ### - # Owner name - ### + $ls_array = $this->bo->vfs->ls (array ( 'string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True ) ); + $this->files_array[] = $ls_array[0]; + $this->numoffiles++; - if ($GLOBALS['settings']['owner']) - { - $this->html_table_col_begin (); - $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); - $this->html_table_col_end (); - } - - ### - # Creator name - ### - - if ($GLOBALS['settings']['createdby_id']) - { - $this->html_table_col_begin (); - if ($files['createdby_id']) + reset ($this->readable_groups); + while (list ($num, $group_array) = each ($this->readable_groups)) { - $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); + # If the group doesn't have access to this app, we don't show it + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + + if (!$this->bo->vfs->file_exists (array ('string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'],'relatives' => array (RELATIVE_NONE) )) ) + { + $this->bo->vfs->override_acl = 1; + $this->bo->vfs->mkdir (array ( 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], 'relatives' => array (RELATIVE_NONE) ) ); + + $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'] ) ) ); + } + + $ls_array = $this->bo->vfs->ls (array ( 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], 'relatives' => array (RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True ) ); + + $this->files_array[] = $ls_array[0]; + + $this->numoffiles++; } - $this->html_table_col_end (); - } - - ### - # Modified by name - ### - - if ($GLOBALS['settings']['modifiedby_id']) - { - $this->html_table_col_begin (); - if ($files['modifiedby_id']) - { - $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); - } - $this->html_table_col_end (); - } - - ### - # Application - ### - - if ($GLOBALS['settings']['app']) - { - $this->html_table_col_begin (); - $this->bo->html_text ($files['app']); - $this->html_table_col_end (); - } - - ### - # Comment - ### - - if ($GLOBALS['settings']['comment']) - { - $this->html_table_col_begin (); - if ($edit_this_comment) - { - $this->html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', $this->bo->html_encode ($files['comment'], 1), 255); - } - else - { - $this->bo->html_text ($files['comment']); - } - $this->html_table_col_end (); - } - - ### - # Version - ### - - if ($GLOBALS['settings']['version']) - { - $this->html_table_col_begin (); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); - $this->html_table_col_end (); - } - - ### - # Deleteable (currently not used) - ### - - if ($GLOBALS['settings']['deleteable']) - { - if ($files['deleteable'] == 'N') - { - $this->html_table_col_begin (); - $this->html_image ($this->imgroot.'images/locked.png', lang('Locked')); - $this->html_table_col_end (); - } - else - { - $this->html_table_col_begin (); - $this->html_table_col_end (); - } - } - - $this->html_table_row_end (); - - if ($files['mime_type'] == 'Directory') - { - $usedspace += $fileinfo[0]; } else { - $usedspace += $files['size']; + $ls_array = $this->bo->vfs->ls (array ( 'string' => $this->path, 'relatives' => array (RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => False, 'orderby' => $this->sortby ) ); + + if ($phpwh_debug) + { + echo '# of files found in "'.$this->path.'" : '.count($ls_array).'
'."\n"; + } + + while (list ($num, $file_array) = each ($ls_array)) + { + $this->numoffiles++; + $this->files_array[] = $file_array; + if ($phpwh_debug) + { + echo 'Filename: '.$file_array['name'].'
'."\n"; + } + } } + + if (!is_array ($this->files_array)) + { + $this->files_array = array (); + } + // end file count } - - $this->html_table_end (); - $this->html_break (2); - - if ($path != '/' && $path != $GLOBALS['fakebase']) + function toolbar($type) { - if (!$rename && !$edit_comments) + switch($type) { - $this->html_form_input ('submit', 'edit', lang('Edit')); - $this->html_help_link ('edit'); - $this->html_nbsp (3); - } + case 'location': + $toolbar=' +

+ '.lang('location').':  +
'; + break; + case 'list_nav': + $toolbar=' + + + '; - if (!$edit_comments) - { - $this->html_form_input ('submit', 'rename', lang('Rename')); - $this->html_help_link ('rename'); - $this->html_nbsp (3); - } - - if (!$rename && !$edit_comments) - { - $this->html_form_input ('submit', 'delete', lang('Delete')); - $this->html_help_link ('delete'); - $this->html_nbsp (3); - } - - if (!$rename) - { - $this->html_form_input ('submit', 'edit_comments', lang('Edit comments')); - $this->html_help_link ('edit_comments'); - } - } - } - - ### - # Display some inputs and info, but not when renaming or editing comments - ### - - if (!$rename && !$edit_comments) - { - ### - # Begin Copy to/Move to selection - ### - - $this->html_break (1); - $this->html_form_input ('submit', 'go', lang('Go to:')); - $this->html_help_link ('go_to'); - - if ($path != '/' && $path != $GLOBALS['fakebase']) - { - $this->html_form_input ('submit', 'copy', lang('Copy to:')); - $this->html_help_link ('copy_to'); - $this->html_form_input ('submit', 'move', lang('Move to:')); - $this->html_help_link ('move_to'); - } - - $this->html_form_select_begin ('todir'); - - $this->html_break (1); - - ### - # First we get the directories in their home directory - ### - - $dirs = array (); - $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); - - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $GLOBALS['homedir'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => True, - 'mime_type' => 'Directory' - ) - ); - - while (list ($num, $dir) = each ($ls_array)) - { - $dirs[] = $dir; - } - - - ### - # Then we get the directories in their readable groups' home directories - ### - - reset ($readable_groups); - while (list ($num, $group_array) = each ($readable_groups)) - { - ### - # Don't list directories for groups that don't have access - ### - - if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) - { - continue; - } - - $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); - - // FIXME?? (pim) - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => True, - 'mime_type' => 'Directory' - ) - ); - while (list ($num, $dir) = each ($ls_array)) - { - $dirs[] = $dir; - } -} - -reset ($dirs); -while (list ($num, $dir) = each ($dirs)) -{ - if (!$dir['directory']) - { - continue; - } - - ### - # So we don't display // - ### - - if ($dir['directory'] != '/') - { - $dir['directory'] .= '/'; - } - - ### - # No point in displaying the current directory, or a directory that doesn't exist - ### - - if ((($dir['directory'] . $dir['name']) != $path) - && $this->bo->vfs->file_exists (array ( - 'string' => $dir['directory'] . $dir['name'], - 'relatives' => array (RELATIVE_NONE) - )) -) -{ - $this->html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); -} + // go up icon when we're not at the top + if ($this->path != '/') + { + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); + $toolbar.=$this->buttonImage($link,'up',lang('go up')); } - $this->html_form_select_end (); - $this->html_help_link ('directory_list'); - - if ($path != '/' && $path != $GLOBALS['fakebase']) + // go home icon when we're not home already + if ($this->path == $GLOBALS['homedir']) { - $this->html_break (1); + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$GLOBALS['homedir']); + $toolbar.=$this->buttonImage($link,'home',lang('go home')); + } - $this->html_form_input ('submit', 'download', lang('Download')); - $this->html_help_link ('download'); - $this->html_nbsp (3); + // reload button with this url + $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); + $toolbar.=$this->buttonImage($link,'reload',lang('reload')); - if ($can_add) + // selectbox for change/move/and copy to + $dirs_options=$this->all_other_directories_options(); + $toolbar.=''; + + $toolbar.=$this->inputImage('goto','goto','Quick jump to'); + + if (!$this->rename && !$this->edit_comments) + { + // copy and move buttons + if ($this->path != '/' && $this->path != $GLOBALS['fakebase']) { - $this->html_form_input ('text', 'createdir', NULL, 255, 15); - $this->html_form_input ('submit', 'newdir', lang('Create Folder')); - $this->html_help_link ('create_folder'); + $toolbar.=$this->inputImage('copy_to','copy_to',lang('Copy to')); + $toolbar.=$this->inputImage('move_to','move_to',lang('Move to')); } + + + // submit buttons for + if ($this->path != '/' && $this->path != $GLOBALS['fakebase']) + { + if (!$this->rename && !$this->edit_comments) + { + // edit text file button + $toolbar.=$this->inputImage('edit','edit',lang('edit')); + } + + if (!$this->edit_comments) + { + $toolbar.=$this->inputImage('rename','rename',lang('Rename')); + } + + if (!$this->rename && !$this->edit_comments) + { + $toolbar.=$this->inputImage('delete','delete',lang('Delete')); + } + + if (!$this->rename) + { + $toolbar.=$this->inputImage('edit_comments','edit_comments',lang('Edit comments')); + } + } + + // create dir and file button + if ($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) + { + $toolbar.=''; + $toolbar.=$this->inputImage('newdir','createdir',lang('Create Folder')); + $toolbar.=$this->inputImage('newfile','createfile',lang('Create File')); + } + + $toolbar.=''; + + // download button + if ($this->path != '/' && $this->path != $GLOBALS['fakebase'] && $this->can_add) + { + $toolbar.=$this->inputImage('download','download',lang('Download')); + } + // upload button + $toolbar.=$this->inputImage('upload','upload',lang('Upload')); + } - - $this->html_break (1); - $this->html_form_input ('submit', 'update', lang('Update')); - $this->html_help_link ('update'); - - if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) - { - $this->html_nbsp (3); - $this->html_form_input ('text', 'createfile', NULL, 255, 15); - $this->html_form_input ('submit', 'newfile', lang('Create File')); - $this->html_help_link ('create_file'); - } - - if ($GLOBALS['settings']['show_command_line']) - { - $this->html_break (2); - $this->html_form_input ('text', 'command_line', NULL, NULL, 50); - $this->html_help_link ('command_line'); - - $this->html_break (1); - $this->html_form_input ('submit', 'execute', lang('Execute')); - $this->html_help_link ('execute'); - } - - $this->html_form_end (); - - $this->html_help_link ('file_stats'); - $this->html_break (1); - $this->html_text_bold (lang('Files').': '); - $this->bo->html_text ($numoffiles); - $this->html_nbsp (3); - - $this->html_text_bold (lang('Used space').': '); - $this->bo->html_text ($this->bo->borkb ($usedspace, NULL, 1)); - $this->html_nbsp (3); - - if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) - { - $this->html_text_bold (lang('Unused space').': '); - $this->bo->html_text ($this->bo->borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); - - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $path, - 'relatives' => array (RELATIVE_NONE) - ) - ); - - $i = count ($ls_array); - - $this->html_break (2); - $this->html_text_bold (lang('Total Files').': '); - $this->bo->html_text ($i); + + $toolbar.='
spacerspacer
'; + break; + default:$x=''; } - ### - # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times - ### - if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) - { - $this->html_break (2); - $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&op=upload&path='.$path, 'post', 'multipart/form-data'); - $this->html_table_begin (); - $this->html_table_row_begin ('center'); - $this->html_table_col_begin (); - $this->html_text_bold (lang('File')); - $this->html_help_link ('upload_file'); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->html_text_bold (lang('Comment')); - $this->html_help_link ('upload_comment'); - $this->html_table_col_end (); - $this->html_table_row_end (); - - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); - $this->html ($this->html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . $this->html_break (1, NULL, 1), $show_upload_boxes); - $this->html_table_col_end (); - $this->html_table_col_begin (); - $this->html ($this->html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . $this->html_break (1, NULL, 1), $show_upload_boxes); - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_table_end (); - $this->html_form_input ('submit', 'upload_files', lang('Upload files')); - $this->html_help_link ('upload_files'); - $this->html_break (2); - $this->bo->html_text (lang('Show') . $this->html_nbsp (1, True)); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=5', '5'); - $this->html_nbsp (); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=10', '10'); - $this->html_nbsp (); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=20', '20'); - $this->html_nbsp (); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&show_upload_boxes=50', '50'); - $this->html_nbsp (); - $this->bo->html_text (lang('upload fields')); - $this->html_nbsp (); - $this->html_help_link ('show_upload_fields'); - $this->html_form_end (); - } + if($toolbar) + { + return $toolbar; } - - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_table_end (); - $this->html_page_close (); } + - ### - # Handle Editing files - ### - - if ($edit) + // move to bo + # Handle File Uploads + function fileUpload() { - ### - # If $edit is "Edit", we do nothing, and let the for loop take over - ### - - if ($edit_file) + if ($this->path != '/' && $this->path != $GLOBALS['fakebase']) { - $edit_file_content = stripslashes ($edit_file_content); - } - - if ($edit_preview) - { - $content = $edit_file_content; - - $this->html_break (1); - $this->html_text_bold (lang('Preview of %1', $path.'/'.$edit_file)); - $this->html_break (2); - - $this->html_table_begin ('90%'); - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->bo->html_text (nl2br ($content)); - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_table_end (); - } - elseif ($edit_save) - { - $content = $edit_file_content; - - if ($this->bo->vfs->write (array ( - 'string' => $edit_file, - 'relatives' => array (RELATIVE_ALL), - 'content' => $content - )) - ) - { - $this->html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); - $this->html_break (2); - $this->html_link_back (); - } - else - { - $this->html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); - $this->html_break (2); - $this->html_link_back (); - } - } - - /* This doesn't work just yet - elseif ($edit_save_all) - { - for ($j = 0; $j != $numoffiles; $j++) - { - $fileman[$j]; - - $content = $fileman[$j]; - echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; - continue; - - if ($this->bo->vfs->write (array ( - 'string' => $fileman[$j], - 'relatives' => array (RELATIVE_ALL), - 'content' => $content - )) - ) - { - $this->html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); - $this->html_break (1); - } - else - { - $this->html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); - $this->html_break (1); - } - } - - $this->html_break (1); - } - */ - - ### - # Now we display the edit boxes and forms - ### - - for ($j = 0; $j != $numoffiles; $j++) - { - ### - # If we're in preview or save mode, we only show the file - # being previewed or saved - ### - - if ($edit_file && ($fileman[$j] != $edit_file)) - { - continue; - } - - if ($fileman[$j] && $this->bo->vfs->file_exists (array ( - 'string' => $fileman[$j], - 'relatives' => array (RELATIVE_ALL) - )) - ) - { - if ($edit_file) - { - $content = stripslashes ($edit_file_content); - } - else - { - $content = $this->bo->vfs->read (array ('string' => $fileman[$j])); - } - - $this->html_table_begin ('100%'); - $this->html_form_begin ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path); - $this->html_form_input ('hidden', 'edit', True); - $this->html_form_input ('hidden', 'edit_file', $fileman[$j]); - - ### - # We need to include all of the fileman entries for each file's form, - # so we loop through again - ### - - for ($i = 0; $i != $numoffiles; $i++) - { - $this->html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); - } - - $this->html_table_row_begin (); - $this->html_table_col_begin (); - $this->html_form_textarea ('edit_file_content', 35, 75, $content); - $this->html_table_col_end (); - $this->html_table_col_begin ('center'); - $this->html_form_input ('submit', 'edit_preview', lang('Preview %1', $this->bo->html_encode ($fileman[$j], 1))); - $this->html_break (1); - $this->html_form_input ('submit', 'edit_save', lang('Save %1', $this->bo->html_encode ($fileman[$j], 1))); - // $this->html_break (1); - // $this->html_form_input ('submit', 'edit_save_all', lang('Save all')); - $this->html_table_col_end (); - $this->html_table_row_end (); - $this->html_break (2); - $this->html_form_end (); - $this->html_table_end (); - } -} - } - - ### - # Handle File Uploads - ### - - elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) - { - for ($i = 0; $i != $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)) { - echo $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; } - ### # Check to see if the file exists in the database, and get its info at the same time - ### - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], + 'string'=> $this->path . '/' . $_FILES['upload_file']['name'][$i], 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); + 'checksubdirs' => False, + 'nofiles' => True + )); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] == 'Directory') + { + $this->messages.= $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); + continue; + } + } + + if ($_FILES['upload_file']['size'][$i] > 0) + { + if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') + { + $tmp_arr=array( + 'string'=> $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'owner_id' => $GLOBALS['userinfo']['username'], + 'modifiedby_id' => $GLOBALS['userinfo']['username'], + 'modified' => $this->now, + 'size' => $_FILES['upload_file']['size'][$i], + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'deleteable' => 'Y', + 'comment' => stripslashes ($upload_comment[$i]) + ) + ); + $this->bo->vfs->set_attributes($tmp_arr); + + $tmp_arr=array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ); + $this->bo->vfs->cp($tmp_arr); + + $this->messages.=lang('Replaced %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]); + } + else + { + + $this->bo->vfs->cp (array ( + 'from'=> $_FILES['upload_file']['tmp_name'][$i], + 'to'=> $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + )); + + $this->bo->vfs->set_attributes (array ( + 'string'=> $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes'=> array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => stripslashes ($upload_comment[$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]) + { + $this->bo->vfs->touch (array ( + 'string'=> $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL) + )); + + $this->bo->vfs->set_attributes (array ( + 'string'=> $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes'=> array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => $upload_comment[$i] + ) + )); + + $this->messages.=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]); + } + } + + $this->readFilesInfo(); + $this->filelisting(); + } + + } + + # Handle Editing comments + function editComment() + { + while (list ($file) = each ($this->comment_files)) + { + 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))); + continue; + } + + $this->bo->vfs->set_attributes (array ( 'string' => $file, 'relatives' => array (RELATIVE_ALL), 'attributes' => array ( 'comment' => stripslashes ($this->comment_files[$file]) ) ) ); + + $this->messages=lang('Updated comment for %1', $this->path.'/'.$file); + } + + $this->readFilesInfo(); + $this->filelisting(); + } + + # Handle Renaming Files and Directories + function rename() + { + while (list ($from, $to) = each ($this->renamefiles)) + { + 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))); + continue; + } + + if (ereg ("/", $to) || ereg ("\\\\", $to)) + { + $this->messages=$GLOBALS['phpgw']->common->error_list (array (lang("File names cannot contain \\ or /"))); + } + elseif (!$this->bo->vfs->mv (array ( 'from' => $from, 'to' => $to )) ) + { + $this->messages= $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to))); + } + else + { + $this->messages=lang('Renamed %1 to %2', $this->disppath.'/'.$from, $this->disppath.'/'.$to); + } + } + $this->readFilesInfo(); + $this->filelisting(); + } + + # Handle Moving Files and Directories + function moveTo() + { + while (list ($num, $file) = each ($this->fileman)) + { + if ($this->bo->vfs->mv (array ( + 'from' => $file, + 'to' => $this->todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + ))) + { + $moved++; + $this->messages=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); + } + else + { + $this->messages = $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); + } + } + + if ($moved) + { + $x=0; + } + + $this->readFilesInfo(); + $this->filelisting(); + } + + // Handle Copying of Files and Directories + function copyTo() + { + while (list ($num, $file) = each ($this->fileman)) + { + if ($this->bo->vfs->cp (array ( 'from' => $file, 'to' => $this->todir . '/' . $file, 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) )) ) + { + $copied++; + $this->message .= lang('Copied %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file); + } + else + { + $this->message .= $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $this->disppath.'/'.$file, $this->todir.'/'.$file))); + } + } + + if ($copied) + { + $x=0; + } + + $this->readFilesInfo(); + $this->filelisting(); + + } + + function createdir() + { + if ($this->newdir && $this->newfile_or_dir) + { + 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))); + } + + 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'))); + } + + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $this->path . '/' . $this->newfile_or_dir, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + )); $fileinfo = $ls_array[0]; if ($fileinfo['name']) { - if ($fileinfo['mime_type'] == 'Directory') + if ($fileinfo['mime_type'] != 'Directory') { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); - continue; + $this->messages= $GLOBALS['phpgw']->common->error_list (array ( + lang('%1 already exists as a file', + $fileinfo['name']) + )); + } + else + { + $this->messages= $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); + } + } + else + { + if ($this->bo->vfs->mkdir (array ('string' => $this->newfile_or_dir))) + { + $this->messages=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); + } + else + { + $this->messages=$GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir))); } } - if ($_FILES['upload_file']['size'][$i] > 0) - { - if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') - { - $this->bo->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'owner_id' => $GLOBALS['userinfo']['username'], - 'modifiedby_id' => $GLOBALS['userinfo']['username'], - 'modified' => $now, - 'size' => $_FILES['upload_file']['size'][$i], - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'deleteable' => 'Y', - 'comment' => stripslashes ($upload_comment[$i]) - ) - ) - ); - - $this->bo->vfs->cp(array ( - 'from' => $_FILES['upload_file']['tmp_name'][$i], - 'to' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) - ) - ); - - $this->html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); - } - else - { - $this->bo->vfs->cp (array ( - 'from' => $_FILES['upload_file']['tmp_name'][$i], - 'to' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) - ) - ); - - $this->bo->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'comment' => stripslashes ($upload_comment[$i]) - ) - ) - ); - - $this->html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); - } -} -elseif ($_FILES['upload_file']['name'][$i]) -{ - $this->bo->vfs->touch (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL) - ) -); - -$this->bo->vfs->set_attributes (array ( - 'string' => $_FILES['upload_file']['name'][$i], - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'mime_type' => $_FILES['upload_file']['type'][$i], - 'comment' => $upload_comment[$i] - ) -) - ); - - $this->html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); - } - } - - $this->html_break (2); - $this->html_link_back (); + $this->readFilesInfo(); + $this->filelisting(); } - ### - # Handle Editing comments - ### - - elseif ($comment_files) - { - while (list ($file) = each ($comment_files)) - { - if ($badchar = $this->bo->bad_chars ($comment_files[$file], False, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array ($this->html_text_italic ($file, 1) . $this->bo->html_encode (': ' . lang('Comments cannot contain "%1"', $badchar), 1))); - continue; - } - - $this->bo->vfs->set_attributes (array ( - 'string' => $file, - 'relatives' => array (RELATIVE_ALL), - 'attributes' => array ( - 'comment' => stripslashes ($comment_files[$file]) - ) - ) - ); - - $this->html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); - } - - $this->html_break (2); - $this->html_link_back (); } - ### - # Handle Renaming Files and Directories - ### - - elseif ($renamefiles) + function delete() { - while (list ($from, $to) = each ($renamefiles)) + for ($i = 0; $i != $this->numoffiles; $i++) { - if ($badchar = $this->bo->bad_chars ($to, True, True)) + if ($this->fileman[$i]) { - echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('File names cannot contain "%1"', $badchar), 1))); - continue; + if ($this->bo->vfs->delete (array ('string' => $this->fileman[$i]))) + { + $this->messages .= lang('Deleted %1', $this->disppath.'/'.$this->fileman[$i]).'
'; + } + else + { + $this->messages=$GLOBALS['phpgw']->common->error_list (array (lang('Could not delete %1', $this->disppath.'/'.$this->fileman[$i]))); + } + } + } + $this->readFilesInfo(); + $this->filelisting(); + } + + + function debug_filemanager() + { + error_reporting (8); + + echo "Filemanager debug:
+ path: {$this->path}
+ disppath: {$this->disppath}
+ cwd: {$this->cwd}
+ lesspath: {$this->lesspath} +

+ eGroupware debug:
+ real getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "
+ fake getabsolutepath: " . $this->bo->vfs->getabsolutepath (array ('target' => False)) . "
+ appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
+ pwd: " . $this->bo->vfs->pwd () . "
"; + + echo '

'; + var_dump($this); + + + } + + function showUploadboxes() + { + $this->t->set_file(array('upload' => 'upload.tpl')); + $this->t->set_block('upload','upload_header','upload_header'); + $this->t->set_block('upload','row','row'); + $this->t->set_block('upload','upload_footer','upload_footer'); + + # Decide how many upload boxes to show + if (!$this->show_upload_boxes || $this->show_upload_boxes <= 0) + { + if (!$this->show_upload_boxes = $this->prefs['show_upload_boxes']) + { + $this->show_upload_boxes = 1; + } + } + + # 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) + { + $vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index'); + $vars[path]=$this->path; + $vars[lang_file]=lang('File'); + $vars[lang_comment]=lang('Comment'); + $vars[num_upload_boxes]=$this->show_upload_boxes; + $this->t->set_var($vars); + $this->t->pparse('out','upload_header'); + + for($i=0;$i<$this->show_upload_boxes;$i++) + { + $this->t->set_var('row_tr_color',$tr_color); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); } - if (ereg ("/", $to) || ereg ("\\\\", $to)) + $vars[lang_upload]=lang('Upload files'); + $vars[change_upload_boxes].=lang('Show') . ' '; + $links.= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=5', '5'); + $links.=' '; + $links.= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=10', '10'); + $links.=' '; + $links.= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=20', '20'); + $links.=' '; + $links.= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index','show_upload_boxes=50', '50'); + $links.=' '; + $links.= lang('upload fields'); + $vars[change_upload_boxes].=$links; + $this->t->set_var($vars); + $this->t->pparse('out','upload_footer'); + } + } + + /* create textfile */ + function createfile() + { + $this->createfile=$this->newfile_or_dir; + if ($this->createfile) + { + if ($badchar = $this->bo->bad_chars ($this->createfile, True, True)) { - echo $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 "%1"',$badchar), + 1) + ); + + $this->fileListing(); } - elseif (!$this->bo->vfs->mv (array ( - 'from' => $from, - 'to' => $to + + if ($this->bo->vfs->file_exists (array ( + 'string'=> $this->createfile, + '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->fileListing(); + } + + + if ($this->bo->vfs->touch (array ( 'string' => $this->createfile, 'relatives' => array (RELATIVE_ALL) )) ) + { + $this->fileman = array (); + $this->fileman[0] = $this->createfile; + $this->edit = 1; + $this->numoffiles++; + $this->edit(); + } + else + { + $this->messages=$GLOBALS['phpgw']->common->error_list (array (lang('File %1 could not be created.', $this->createfile))); + $this->fileListing(); + } + } + } + + # Handle Editing files + function edit() + { + $this->readFilesInfo(); + + $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); + $this->t->set_block('filemanager_edit','row','row'); + + $vars[preview_content]=''; + if ($this->edit_file) + { + $this->edit_file_content = stripslashes ($this->edit_file_content); + } + + if ($this->edit_preview) + { + $content = $this->edit_file_content; + + $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); + + $vars[preview_content]=nl2br($content); + } + elseif ($this->edit_save || $this->edit_save_done) + { + $content = $this->edit_file_content; + + if ($this->bo->vfs->write (array ( + 'string' => $this->edit_file, + 'relatives' => array (RELATIVE_ALL), + 'content' => $content )) ) { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); - } - else - { - $this->html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); - } - } + $this->messages=lang('Saved %1', $this->path.'/'.$this->edit_file); - $this->html_break (2); - $this->html_link_back (); - } - - ### - # Handle Moving Files and Directories - ### - - elseif ($move) - { - while (list ($num, $file) = each ($fileman)) - { - if ($this->bo->vfs->mv (array ( - 'from' => $file, - 'to' => $todir . '/' . $file, - 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) - )) - ) - { - $moved++; - $this->html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); - } - } - - if ($moved) - { - $this->html_break (2); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index?path='.$todir, lang('Go to %1', $todir)); - } - - $this->html_break (2); - $this->html_link_back (); -} - -### -# Handle Copying of Files and Directories -### - -elseif ($copy) -{ - while (list ($num, $file) = each ($fileman)) - { - if ($this->bo->vfs->cp (array ( - 'from' => $file, - 'to' => $todir . '/' . $file, - 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) - )) - ) - { - $copied++; - $this->html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); - } -} - -if ($copied) -{ - $this->html_break (2); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$todir, lang('Go to %1', $todir)); -} - -$this->html_break (2); -$this->html_link_back (); - } - - ### - # Handle Deleting Files and Directories - ### - - elseif ($delete) - { - for ($i = 0; $i != $numoffiles; $i++) + if($this->edit_save_done) { - if ($fileman[$i]) - { - if ($this->bo->vfs->delete (array ('string' => $fileman[$i]))) - { - $this->html_text_summary (lang('Deleted %1', $disppath.'/'.$fileman[$i]), $fileinfo['size']); - } - else - { - $GLOBALS['phpgw']->common->error_list (array (lang('Could not delete %1', $disppath.'/'.$fileman[$i]))); - } - } - } - - $this->html_break (2); - $this->html_link_back (); - } - - elseif ($newdir && $createdir) - { - if ($this->bo->badchar = $this->bo->bad_chars ($createdir, True, True)) - { - echo $GLOBALS['phpgw']->common->error_list (array ($this->bo->html_encode (lang('Directory names cannot contain "%1"', $badchar), 1))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); - } - - if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot create directory because it begins or ends in a space'))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); - } - - $ls_array = $this->bo->vfs->ls (array ( - 'string' => $path . '/' . $createdir, - 'relatives' => array (RELATIVE_NONE), - 'checksubdirs' => False, - 'nofiles' => True - ) - ); - - $fileinfo = $ls_array[0]; - - if ($fileinfo['name']) - { - if ($fileinfo['mime_type'] != 'Directory') - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); - } - else - { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); - $this->html_break (2); - $this->html_link_back (); - $this->html_page_close (); + $this->readFilesInfo(); + $this->fileListing(); + exit; } } else { - if ($this->bo->vfs->mkdir (array ('string' => $createdir))) + $this->messages=lang('Could not save %1', $this->path.'/'.$this->edit_file); + } + } + + # Now we display the edit boxes and forms + for ($j = 0; $j != $this->numoffiles; $j++) + { + # If we're in preview or save mode, we only show the file + # being previewed or saved + if ($this->edit_file && ($this->fileman[$j] != $this->edit_file)) + { + continue; + } + + if ($this->fileman[$j] && $this->bo->vfs->file_exists (array ( 'string' => $this->fileman[$j], 'relatives' => array (RELATIVE_ALL) )) ) + { + if ($this->edit_file) { - $this->html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); - $this->html_break (2); - $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); + $content = stripslashes ($this->edit_file_content); } else { - echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); + $content = $this->bo->vfs->read (array ('string' => $this->fileman[$j])); } + + $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); + $vars[edit_file]=$this->fileman[$j]; + + # We need to include all of the fileman entries for each file's form, + # so we loop through again + for ($i = 0; $i != $this->numoffiles; $i++) + { + if($this->fileman[$i]) $value='value="'.$this->fileman[$i].'"'; + $vars[filemans_hidden]=''; + + } + + $vars[file_content]=$content; + + + $vars[buttonPreview]=$this->inputImage('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode ($this->fileman[$j], 1))); + $vars[buttonSave]=$this->inputImage('edit_save','save',lang('Save %1', $this->bo->html_encode ($this->fileman[$j], 1))); + $vars[buttonDone]=$this->inputImage('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode ($this->fileman[$j], 1))); + $vars[buttonCancel]=$this->inputImage('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode ($this->fileman[$j], 1))); + $this->t->set_var($vars); + $this->t->parse('rows','row'); + $this->t->pparse('out','row'); + + } + } + } + + + + function history() + { + if ($this->file) + { + $journal_array = $this->bo->vfs->get_journal (array ( + 'string' => $this->file, + 'relatives' => array (RELATIVE_ALL) + )); + + if (is_array ($journal_array)) + { + $this->html_table_begin (); + $this->html_table_row_begin (); + $this->html_table_col_begin (); + echo lang('Date'); + $this->html_table_col_end (); + $this->html_table_col_begin (); + echolang('Version'); + $this->html_table_col_end (); + $this->html_table_col_begin (); + echo lang('Who'); + $this->html_table_col_end (); + $this->html_table_col_begin (); + echo lang('Operation'); + $this->html_table_col_end (); + $this->html_table_row_end (); + + while (list ($num, $journal_entry) = each ($journal_array)) + { + $this->html_table_row_begin (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['created'] . '   '); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['version'] . '   ' ); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . '   '); + $this->html_table_col_end (); + $this->html_table_col_begin (); + $this->bo->html_text ($journal_entry['comment']); + $this->html_table_col_end (); + } + + $this->html_table_end (); + $GLOBALS['phpgw']->common->phpgw_footer (); + $GLOBALS['phpgw']->common->phpgw_exit (); + } + else + { + echo lang('No version history for this file/directory'); } - $this->html_break (2); - $this->html_link_back (); } - $this->html_page_close (); } - function html_form_begin ($action,$args, $method = 'post', $enctype = NULL, $string = HTML_FORM_BEGIN_STRING, $return = 0) + function view() { - $action = $this->bo->string_encode ($action, 1); - $action = SEP . $action; - //FIXME - $text = 'action="'.$this->html_link ($action, $args,NULL, 1, 0, 1).'"'; - - if ($method == NULL) + + if ($this->file) { - $method = 'post'; - } - $text .= ' method="'.$method.'"'; + $ls_array = $this->bo->vfs->ls (array ( + 'string' => $this->path.'/'.$this->file, + 'relatives' => array (RELATIVE_ALL), + 'checksubdirs' => False, + 'nofiles' => True + )); - if ($enctype != NULL && $enctype) - { - $text .= ' enctype="'.$enctype.'"'; - } + if ($ls_array[0]['mime_type']) + { + $mime_type = $ls_array[0]['mime_type']; + } + elseif ($this->prefs['viewtextplain']) + { + $mime_type = 'text/plain'; + } - $rstring = '
'; - return ($this->bo->eor ($rstring, $return)); + header('Content-type: ' . $mime_type); + echo $this->bo->vfs->read (array ( + 'string' => $this->path.'/'.$this->file, + 'relatives' => array (RELATIVE_NONE) + )); + $GLOBALS['phpgw']->common->phpgw_exit (); + } } - function html_form_input ($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = HTML_FORM_INPUT_STRING, $return = 0) + function download() + { + for ($i = 0; $i != $this->numoffiles; $i++) + { + if (!$this->fileman[$i]) + { + continue; + } + + $download_browser = CreateObject ('phpgwapi.browser'); + $download_browser->content_header ($this->fileman[$i]); + echo $this->bo->vfs->read (array ('string' => $this->fileman[$i])); + $GLOBALS['phpgw']->common->phpgw_exit (); + } + } + + //give back an array with all directories except current and dirs that are not accessable + function all_other_directories_options() + { + # First we get the directories in their home directory + $dirs = array (); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); + + $tmp_arr=array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ); + + $ls_array = $this->bo->vfs->ls ($tmp_arr); + + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } + + + # Then we get the directories in their readable groups' home directories + reset ($this->readable_groups); + while (list ($num, $group_array) = each ($this->readable_groups)) + { + # Don't list directories for groups that don't have access + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); + + $tmp_arr=array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ); + + $ls_array = $this->bo->vfs->ls ($tmp_arr); + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } + } + + reset ($dirs); + while (list ($num, $dir) = each ($dirs)) + { + if (!$dir['directory']) + { + continue; + } + + # So we don't display // + if ($dir['directory'] != '/') + { + $dir['directory'] .= '/'; + } + + # No point in displaying the current directory, or a directory that doesn't exist + if ((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists (array ( 'string' => $dir['directory'] . $dir['name'], 'relatives' => array (RELATIVE_NONE) )) ) + { + //FIXME replace the html_form_option function + $options.=$this->html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); + } + } + + return $options; + } + + + /* seek icon for mimetype else return an unknown icon */ + function mime_icon($mime_type, $size=16) + { + if(!$mime_type) $mime_type='unknown'; + + $mime_type= str_replace ('/','_',$mime_type); + + $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); + if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); + + $icon=''.lang($mime_type).''; + return $icon; + } + + function buttonImage($link,$img='',$help='') + { + + $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); + + if($img) + { + return ' + '.$help.' + '; + } + } + + function inputImage($name,$img='',$help='') + { + $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); + + if($img) + { + return ' + + '; + } + + + } + + function html_form_input ($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) { $text = ' '; if ($type != NULL && $type) @@ -1898,44 +1706,7 @@ $this->html_link_back (); $text .= 'checked '; } - $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_form_textarea ($name = NULL, $rows = NULL, $cols = NULL, $value = NULL, $string = HTML_FORM_TEXTAREA_STRING, $return = 0) - { - $text =' '; - if ($name != NULL && $name) - { - $text .= 'name="'.$name.'" '; - } - if (is_int ($rows) && $rows >= 0) - { - $text .= 'rows="'.$rows.'" '; - } - if (is_int ($cols) && $cols >= 0) - { - $text .= 'cols="'.$cols.'" '; - } - $rstring = ''.$value.''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_form_select_begin ($name = NULL, $return = 0) - { - $text = ' '; - if ($name != NULL && $name) - { - $text .= 'name="'.$name.'" '; - } - $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_form_select_end ($return = 0) - { - $rstring = ''; - return ($this->bo->eor ($rstring, $return)); + return ''; } function html_form_option ($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) @@ -1949,270 +1720,47 @@ $this->html_link_back (); { $text .= ' selected'; } - $rstring = ''.$displayed.''; - return ($this->bo->eor ($rstring, $return)); + return ''.$displayed.''; } - function html_form_end ($return = 0) - { - $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - function html_nbsp ($times = 1, $return = 0) - { - if ($times == NULL) + function encode_href($href = NULL, $args = NULL , $extra_args) { - $times = 1; - } - for ($i = 0; $i != $times; $i++) - { - if ($return) - { - $rstring .= ' '; - } - else - { - echo ' '; - } - } - if ($return) - { - return ($rstring); - } - } - - function html ($string, $times = 1, $return = 0) - { - for ($i = 0; $i != $times; $i++) - { - if ($return) - { - $rstring .= $string; - } - else - { - echo $string; - } - } - if ($return) - { - return ($rstring); - } - } - - function html_break ($break, $string = '', $return = 0) - { - switch($break) - { - case 1: - $break_str = '
'; - break; - case 2: - $break_str = '

'; - break; - case 5: - $break_str = '


'; - break; - } - return ($this->bo->eor ($break_str . $string, $return)); - } - - function html_page_begin ($title = NULL, $return = 0) - { - // $rstring = HTML_PAGE_BEGIN_BEFORE_TITLE . $title . HTML_PAGE_BEGIN_AFTER_TITLE; - return ($this->bo->eor ($rstring, $return)); - } - - function html_page_body_begin ($bgcolor = HTML_PAGE_BODY_COLOR, $background = NULL, $text = NULL, $link = NULL, $vlink = NULL, $alink = NULL, $string = HTML_PAGE_BODY_STRING, $return = 0) - { - $text_out = ' '; - if ($bgcolor != NULL && $bgcolor) - { - $text_out .= 'bgcolor="'.$bgcolor.'" '; - } - if ($background != NULL && $background) - { - $text_out .= 'background="'.$background.'" '; - } - if ($text != NULL && $text) - { - $text_out .= 'text="'.$text.'" '; - } - if ($link != NULL && $link) - { - $text_out .= 'link="'.$link.'" '; - } - if ($vlink != NULL && $vlink) - { - $text_out .= 'vlink="'.$vlink.'" '; - } - if ($alink != NULL && $alink) - { - $text_out .= 'alink="'.$alink.'" '; - } - // $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_page_body_end ($return = 0) - { - // $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_page_end ($return = 0) - { - // $rstring = ''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_page_close () - { - // html_page_body_end (); - // html_page_end (); - $GLOBALS['phpgw']->common->phpgw_footer (); - $GLOBALS['phpgw']->common->phpgw_exit (); - } - function html_text_bold ($text = NULL, $return = 0, $lang = 0) - { - if ($lang) - { - $text = $this->bo->translate ($text); - } - $rstring = ''.$text.''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_text_underline ($text = NULL, $return = 0, $lang = 0) - { - if ($lang) - { - $text = $this->bo->translate ($text); - } - $rstring = ''.$text.''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_text_italic ($text = NULL, $return = 0, $lang = 0) - { - if ($lang) - { - $text = $this->bo->translate ($text); - } - $rstring = ''.$text.''; - return ($this->bo->eor ($rstring, $return)); - } - - function html_text_summary ($text = NULL, $size = NULL, $return = 0, $lang = 0) - { - if ($lang) - { - $text = $this->bo->translate ($text); - } - $rstring = $this->html_break (1, NULL, $return); - $rstring .= $this->html_text_bold ($text, $return); - $rstring .= $this->html_nbsp (3, $return); - if ($size != NULL && $size >= 0) - $rstring .= $this->bo->borkb ($size, 1, $return); - - $rstring = $this->bo->html_encode ($rstring, 1); - - if ($return) - { - return ($rstring); - } - } - - function html_text_summary_error ($text = NULL, $text2 = NULL, $size = NULL, $return = 0, $lang = 0) - { - if ($lang) - { - $text = $this->bo->translate ($lang); - } - $rstring = $this->html_text_error ($text, 1, $return); - - if (($text2 != NULL && $text2) || ($size != NULL && $size)) - { - $rstring .= $this->html_nbsp (3, $return); - } - if ($text2 != NULL && $text2) - { - $rstring .= $this->html_text_error ($text2, NULL, $return); - } - if ($size != NULL && $size >= 0) - { - $rstring .= $this->bo->borkb ($size, 1, $return); - } - - if ($return) - { - return ($rstring); - } - } - - function html_font_set ($size = NULL, $color = NULL, $family = NULL, $return = 0) - { - if ($size != NULL && $size) - $size = "size=$size"; - if ($color != NULL && $color) - $color = "color=$color"; - if ($family != NULL && $family) - $family = "family=$family"; - - $rstring = ""; - return ($this->bo->eor ($rstring, $return)); - } - - function html_font_end ($return = 0) - { - $rstring = ""; - return ($this->bo->eor ($rstring, $return)); - } - - function html_text_error ($errorwas = NULL, $break = 1, $return = 0) - { - if ($break) - $rstring .= $this->html_break (1, NULL, 1); - - $rstring .= $this->html_font_set (NULL, HTML_TEXT_ERROR_COLOR, NULL, 1); - $rstring .= $this->html_text_bold ($this->html_text_italic ($errorwas, 1), 1); - $rstring .= $this->html_font_end (1); - return ($this->bo->eor ($rstring, $return)); - } - - function html_page_error ($errorwas = NULL, $title = "Error", $return = 0) - { - $rstring = $this->html_page_begin ($title, $return); - $rstring .= $this->html_page_body_begin (HTML_PAGE_BODY_COLOR, $return); - $rstring .= $this->html_break (2, NULL, $return); - $rstring .= $this->html_text_error ($errorwas, $return); - $rstring .= $this->html_page_body_end ($return); - $rstring .= $this->html_page_end ($return); - if (!$return) - $this->html_page_close (); - else - return ($rstring); - } - - function html_link ($href = NULL, $args = NULL ,$text = NULL, $return = 0, $encode = 1, $linkonly = 0, $target = NULL) - { - if ($encode) $href = $this->bo->string_encode ($href, 1); + $all_args = $args.'&'.$this->bo->string_encode ($extra_args, 1); - //echo $encode; + $address = $GLOBALS['phpgw']->link ($href, $all_args); + return $address; + + } + + function html_link ($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) + { + // unset($encode); + if ($encode) + { + $href = $this->bo->string_encode ($href, 1); + $all_args = $args.'&'.$this->bo->string_encode ($extra_args, 1); + } + else + { + // $href = $this->bo->string_encode ($href, 1); + $all_args = $args.'&'.$extra_args; + + } ### - # This decodes / back to normal + # This decodes / back to normal ### - $href = preg_replace ("/%2F/", "/", $href); - $text = trim ($text); + // $all_args = preg_replace ("/%2F/", "/", $all_args); + // $href = preg_replace ("/%2F/", "/", $href); + /* Auto-detect and don't disturb absolute links */ if (!preg_match ("|^http(.{0,1})://|", $href)) { //Only add an extra / if there isn't already one there - + // die(SEP); if (!($href[0] == SEP)) { @@ -2221,7 +1769,8 @@ $this->html_link_back (); /* $phpgw->link requires that the extra vars be passed separately */ // $link_parts = explode ("?", $href); - $address = $GLOBALS['phpgw']->link ($href, $args); + $address = $GLOBALS['phpgw']->link ($href, $all_args); + // $address = $GLOBALS['phpgw']->link ($href); } else { @@ -2240,22 +1789,14 @@ $this->html_link_back (); $target = 'target='.$target; } + $text = trim ($text); $rstring = ''.$text.''; } return ($this->bo->eor ($rstring, $return)); } - function html_link_back ($return = 0) - { - global $path; - - $rstring .= $this->html_link ('/index.php','menuaction=filemanager.uifilemanager.index&path='.$path, HTML_TEXT_NAVIGATION_BACK_TO_USER, 1); - - return ($this->bo->eor ($rstring, $return)); - } - - function html_table_begin ($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = HTML_TABLE_BEGIN_STRING, $return = 0) + function html_table_begin ($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) { if ($width != NULL && $width) $width = "width=$width"; @@ -2272,14 +1813,6 @@ $this->html_link_back (); return ($this->bo->eor ($rstring, $return)); } - function html_link_email ($address = NULL, $text = NULL, $return = 0, $encode = 1) - { - if ($encode) - $href = $this->bo->string_encode ($href, 1); - - $rstring = "$text"; - return ($this->bo->eor ($rstring, $return)); - } function html_table_end ($return = 0) { @@ -2287,7 +1820,7 @@ $this->html_link_back (); return ($this->bo->eor ($rstring, $return)); } - function html_table_row_begin ($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = HTML_TABLE_ROW_BEGIN_STRING, $return = 0) + function html_table_row_begin ($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) { if ($align != NULL && $align) $align = "align=$align"; @@ -2307,7 +1840,7 @@ $this->html_link_back (); return ($this->bo->eor ($rstring, $return)); } - function html_table_col_begin ($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = HTML_TABLE_COL_BEGIN_STRING, $return = 0) + function html_table_col_begin ($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) { if ($align != NULL && $align) $align = "align=$align"; @@ -2329,49 +1862,5 @@ $this->html_link_back (); $rstring = ""; return ($this->bo->eor ($rstring, $return)); } - - - function html_text_header ($size = 1, $string = NULL, $return = 0, $lang = 0) - { - $rstring = "$string"; - return ($this->bo->eor ($rstring, $return)); - } - - function html_align ($align = NULL, $string = HTML_ALIGN_MAIN_STRING, $return = 0) - { - $rstring = "

"; - return ($this->bo->eor ($rstring, $return)); - } - - function html_image ($src = NULL, $alt = NULL, $align = NULL, $border = NULL, $string = HTML_IMAGE_MAIN_STRING, $return = 0) - { - if ($src != NULL && $src) - $src = "src=$src"; - if ($alt != NULL && $alt) - $alt = "alt=\"$alt\""; - if ($align != NULL && $align) - $align = "align=$align"; - if (is_int ($border) && $border >= 0) - $border = "border=$border"; - $rstring = ""; - return ($this->bo->eor ($rstring, $return)); - } - - function html_help_link ($help_name = NULL, $text = "[?]", $target = "_new", $return = 0) - { - global $settings; - global $appname; - - if (!$settings["show_help"]) - { - return 0; - } - - $rstring = $this->html_link ('index.php','menuaction=filemanager.uifilemanager.index&op=help&help_name=$help_name', $text, True, 1, 0, $target); - - return ($this->bo->eor ($rstring, $return)); - } - - + } - diff --git a/filemanager/inc/class.uiphpwebhosting.inc.php b/filemanager/inc/class.uiphpwebhosting.inc.php deleted file mode 100755 index ee5669479a..0000000000 --- a/filemanager/inc/class.uiphpwebhosting.inc.php +++ /dev/null @@ -1,1060 +0,0 @@ - * - * This class user interface for the phpwebhosting app * - * Copyright (C) 2002 Mark A Peters * - * -------------------------------------------------------------------------* - * This library is free software; you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 of the License, * - * or any later version. * - * This library is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License * - * along with this library; if not, write to the Free Software Foundation, * - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - \**************************************************************************/ - - /* $Id$ */ - - class uiphpwebhosting - { - - var $public_functions = array( - 'index' => True, - 'action' => True, - 'help' => True, - 'history' => True, - 'view' => True, - 'view_file' => True, - 'edit' => True - ); - - var $bo; - var $nextmatchs; - var $browser; - var $template_dir; - var $help_info; - - function uiphpwebhosting() - { - $this->bo = CreateObject('filemanager.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->check_access(); - $this->create_home_dir(); - $this->verify_path(); - $this->update(); - } - - function load_header() - { - 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 %1',$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 set_col_headers(&$p,$var,$append=True) - { - $p->set_var($var); - $p->parse('col_headers','column_headers',$append); - } - - 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; - if (!$this->bo->vfs->mkdir($this->bo->homedir,Array(RELATIVE_NONE))) - { - echo lang('failed to create directory') . ' '. $this->bo->homedir . '

'; - } - //$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; - if (!$this->bo->vfs->mkdir($this->bo->homedir,Array(RELATIVE_NONE))) - { - echo lang('failed to create directory') . ' '. $this->bo->homedir . '

'; - } - //$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 %1 does not exist',$this->bo->path)); - } - } - - 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) - { - Header('Location: '.$GLOBALS['phpgw']->link( - '/index.php', - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', - 'path' => urlencode($this->bo->path) - ) - ) - ); - } - } - - function action() - { - $actions = Array( - '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') - ); - @reset($actions); - while(list($function,$text) = each($actions)) - { - if(isset($this->bo->$function) && !empty($this->bo->$function) && trim(strtolower($this->bo->$function)) == strtolower($text)) - { - $f_function = 'f_'.$function; - $errors = $this->bo->$f_function(); - $var = Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', - 'path' => urlencode($this->bo->path) - ); - if($function == 'newfile') - { - $var = Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.edit', - 'path' => urlencode($this->bo->path), - 'file' => urlencode($this->bo->createfile) - ); - } - elseif(is_array($errors)) - { - $var['errors'] = urlencode(base64_encode(serialize($errors))); - } - Header('Location: '.$GLOBALS['phpgw']->link('/index.php',$var)); - } - } - } - - function help() - { - $this->load_header(); - $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 ''.$alt.''; - } - - 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(&$p,$internal,$displayed,$link=True) - { - if($link) - { - $header_str = ''.lang($displayed).''; - } - else - { - $header_str = $displayed; - } - $this->set_col_headers( - $p, - Array( - 'td_extras' => '', - 'column_header' => $header_str.$this->build_help($internal) - ) - ); - } - - 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'); - $this->set_col_headers($p,$var,False); - - $var['column_header'] = ''.$this->build_help('rename'); - $this->set_col_headers($p,$var); - - $var['column_header'] = ''.$this->build_help('delete'); - $this->set_col_headers($p,$var); - - $var['column_header'] = ''.$this->build_help('edit_comments'); - $this->set_col_headers($p,$var); - $p->parse('list','column_rows',True); - - $var['column_header'] = ''.$this->build_help('go_to'); - $this->set_col_headers($p,$var,False); - - $var['column_header'] = ''.$this->build_help('copy_to'); - $this->set_col_headers($p,$var); - - $var['column_header'] = ''.$this->build_help('move_to'); - $this->set_col_headers($p,$var); - - ### - # 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'); - $this->set_col_headers($p,$var); - $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'); - $this->set_col_headers($p,$var); - - $var['column_header'] = '    '.$this->build_help('create_folder'); - $this->set_col_headers($p,$var); - $p->parse('list','column_rows',True); - } - - $var['column_header'] = ''.$this->build_help('update'); - $this->set_col_headers($p,$var,False); - - if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase) - { - $var['column_header'] = '    '.$this->build_help('create_file'); - } - else - { - $var['column_header'] = ' '; - } - $this->set_col_headers($p,$var); - $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') - ); - $this->set_col_headers($p,$var); - $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') - ); - $this->set_col_headers($p,$var,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".$p->fp('output','table').'
'."\n"; - } - - function index() - { - $this->load_header(); - $files_array = $this->bo->load_files(); - if(count($files_array) || $this->bo->cwd) - { - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $p->set_unknowns('remove'); - - $p->set_file( - Array( - '_index' => 'index.tpl' - ) - ); - $p->set_block('_index','index','index'); - $p->set_block('_index','column_headers','column_headers'); - $p->set_block('_index','column_headers_normal','column_headers_normal'); - $p->set_block('_index','column_rows','column_rows'); - - $GLOBALS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off']; - $var = Array( - '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'):''), - 'tr_extras' => ' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"', - 'form_action' => $GLOBALS['phpgw']->link('/index.php', - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.action', - 'path' => urlencode($this->bo->path) - ) - ), - 'img_up' => $this->link(Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', - 'path' => urlencode($this->bo->lesspath) - ), - $this->image('folder_up.gif',lang('Up'))), - 'help_up' => $this->build_help('up'), - 'img_home' => $this->image('folder_home.gif',lang('Folder')), - 'dir' => ''."\n" - . ' '.strtoupper($this->bo->path).''."\n" - . ' ', - 'help_home' => $this->build_help('home'), - 'col_headers' => '', - 'column_header' => '' - ); - $p->set_var($var); - - $this->column_header($p,'sort_by','Sort By',False); - - $columns = 1; - @reset($this->bo->file_attributes); - while(list($internal,$displayed) = each($this->bo->file_attributes)) - { - if ($this->bo->settings[$internal]) - { - $this->column_header($p,$internal,$displayed,True); - $columns++; - } - } - $p->parse('col_row','column_rows',True); - $p->set_var('col_headers',''); - -// $var = Array( -// 'tr_extras' => ' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"' -// ); -// $this->set_col_headers($p,$var,True); - - $p->set_var('colspan',$columns); - - if($this->bo->settings['dotdot'] && $this->bo->settings['name'] && $this->bo->path != '/') - { - $this->set_col_headers( - $p, - Array( - 'tr_extras' => ' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"', - 'col_headers' => '', - 'td_extras' => '', - 'column_header' => ' ' - ) - ); - - $this->set_col_headers( - $p, - Array( - 'column_header' => $this->image('folder.gif','folder') - .$this->link( - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', - 'path' => $this->bo->lesspath - ), - '..' - ) - ) - ); - - $loop_cntr = 2; - - if($this->bo->settings['mime_type']) - { - $this->set_col_headers( - $p, - Array( - 'column_header' => 'Directory' - ) - ); - $loop_cntr++; - } - - for($i=$loop_cntr;$i<$columns;$i++) - { - $this->set_col_headers( - $p, - Array( - 'column_header' => ' ' - ) - ); - } - $p->parse('col_row','column_rows',True); - $p->set_var('col_headers',''); - } - - $usedspace = 0; - reset($files_array); - $numoffiles = count($files_array); - for($i=0;$i!=$numoffiles;$i++) - { - $files = $files_array[$i]; - $var = Array( - 'tr_extras' => ' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"', - 'td_extras' => '', - 'column_header' => '' - ); - $this->set_col_headers($p,$var,False); -// $p->set_var($var); -// $p->parse('col_headers','column_headers'); - - $usedspace += $files['size']; - - @reset($this->bo->file_attributes); - while(list($internal,$displayed) = each($this->bo->file_attributes)) - { - if($this->bo->settings[$internal]) - { - $var = Array( - 'td_extras' => '' - ); - switch($internal) - { - case 'name': - switch($files['mime_type']) - { - case 'Directory': - $var['column_header'] = $this->image('folder.gif','folder') - .$this->link( - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', - 'path' => $this->bo->path.SEP.$files['name'] - ), - ''.$files['name'].'' - ); - break; - default: - $var['column_header'] = $this->link( - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view', - 'path' => urlencode($this->bo->path), - 'file' => urlencode($files['name']) - ), - ''.$files['name'].'' - ); - break; - } - break; - case 'deletable': - if ($files['deleteable'] == 'N') - { - $var['column_header'] = $this->image('locked.gif','locked'); - } - else - { - $var['column_header'] = ' '; - } - break; - case 'size': - $var['column_header'] = $this->bo->borkb($files['size']); - $var['td_extras'] = ' align="right"'; - break; - case 'version': - $var['column_header'] = $this->link( - Array( - 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.history', - 'path' => $this->bo->path, - 'file' => $files['name'] - ), - $files['version'] - ); - break; - case 'modified': - case 'created': - $var['column_header'] = $this->bo->convert_date($files[$internal]); - break; - case 'owner': - case 'createdby_id': - case 'modifiedby_id': - switch($internal) - { - case 'owner': - $ivar = 'owner_id'; - break; - default: - $ivar = $internal; - break; - } - $var['column_header'] = ($files[$ivar]?$GLOBALS['phpgw']->accounts->id2name($files[$ivar]):' '); - break; - default: - $var['column_header'] = ($files[$internal]?$files[$internal]:' '); - break; - } - $this->set_col_headers($p,$var); - } - } - $p->parse('col_row','column_rows',True); - $p->set_var('col_headers',''); - } - - $p->set_var('buttons',$this->display_buttons()); - $p->set_var('info',$this->display_summary_info($numoffiles,$usedspace)); - $p->set_var('uploads',$this->display_uploads()); - - $p->pfp('output','index'); - } - } - - function view() - { - $this->load_header(); - if($this->bo->vfs->file_exists($this->bo->path.'/'.$this->bo->file,Array(RELATIVE_NONE))) - { - $content_type = $this->bo->vfs->file_type($this->bo->path.$this->bo->dispsep.$this->bo->file,Array(RELATIVE_NONE)); - if($content_type) - { - $cont_type = explode('/',$content_type); - $content_type = $cont_type[1]; - } - else - { - } - switch($content_type) - { - case 'jpeg': - case 'gif': - case 'bmp': - case 'png': - $alignment = 'center'; - $file_content = ''."\n"; - break; - default: - $alignment = 'left'; - $file_content = nl2br($this->bo->vfs->read($this->bo->path.$this->bo->dispsep.$this->bo->file,Array(RELATIVE_NONE))); - break; - } - $file = $this->bo->path.$this->bo->dispsep.$this->bo->file; - $GLOBALS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off']; - - echo ''."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . ' '."\n" - . '
'."\n" - . ' TYPE: '.$this->bo->vfs->file_type($file,Array(RELATIVE_NONE)).'
'."\n" - . '
'."\n" - . ' FILENAME: '.$file."\n" - . '
'."\n" - . ' VERSION: '.$this->bo->vfs->get_version($file,Array(RELATIVE_NONE))."\n" - . '
'."\n" - . $file_content."\n" - . '
'."\n"; - } - } - - function history() - { - $this->load_header(); - $file = $this->bo->path.$this->bo->dispsep.$this->bo->file; - if($this->bo->vfs->file_exists($file,Array(RELATIVE_NONE))) - { - $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'] = ''.$label.''; - $this->set_col_headers($p,$var); - } - $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',''); - - $journal_array = $this->bo->vfs->get_journal($file,Array(RELATIVE_NONE)); - 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'] = ''.$GLOBALS['phpgw']->accounts->id2name($journal_entry[$field]).''; - break; - case 'created': - $var['column_header'] = ''.$this->bo->convert_date($journal_entry[$field]).''; - break; - default: - $var['column_header'] = ''.$journal_entry[$field].''; - break; - } - $this->set_col_headers($p,$var); - } - $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'); - } - } - - function view_file($file_array='') - { - 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; - if($this->bo->vfs->file_exists($file,Array(RELATIVE_NONE))) - { - $browser = CreateObject('phpgwapi.browser'); - $browser->content_header($this->bo->file,$this->bo->vfs->file_type($file,Array(RELATIVE_NONE)),$this->bo->vfs->get_size($file,Array(RELATIVE_NONE)),True); -// $browser->content_header($this->bo->file); - echo $this->bo->vfs->read($file,Array(RELATIVE_NONE)); - flush(); - } - if(!is_array($file_array)) - { - $GLOBALS['phpgw']->common->phpgw_exit (); - } - } - - function edit() - { - $this->load_header(); - } - } diff --git a/filemanager/inc/hook_preferences.inc.php b/filemanager/inc/hook_preferences.inc.php index b56245e026..321bf81933 100644 --- a/filemanager/inc/hook_preferences.inc.php +++ b/filemanager/inc/hook_preferences.inc.php @@ -15,7 +15,8 @@ // Only Modify the $file and $title variables..... $title = $appname; $file = Array( - lang('Preferences') => $GLOBALS['phpgw']->link('/filemanager/preferences.php') + 'Preferences Old' => $GLOBALS['phpgw']->link('/filemanager/preferences.php'), + 'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname) ); //Do not modify below this line display_section($appname,$title,$file); diff --git a/filemanager/inc/hook_settings.inc.php b/filemanager/inc/hook_settings.inc.php new file mode 100644 index 0000000000..d5bdd124f7 --- /dev/null +++ b/filemanager/inc/hook_settings.inc.php @@ -0,0 +1,65 @@ + * + * -------------------------------------------- * + * 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) * + \**************************************************************************/ + + //ExecMethod('filemanager.bofilemanager.check_set_default_prefs'); + + /*create_section('TESTING'); + + create_check_box('Use new experimental Filemanager?','experimental_new_code','The future filemanager, now for TESTING PURPOSES ONLY, please send bugreports'); + + */ + create_section('Display attributes'); + + $file_attributes = Array( + 'name' => 'File Name', + 'mime_type' => 'MIME Type', + 'size' => 'Size', + 'created' => 'Created', + 'modified' => 'Modified', + 'owner' => 'Owner', + 'createdby_id' => 'Created by', + 'modifiedby_id' => 'Created by', + 'modifiedby_id' => 'Modified by', + 'app' => 'Application', + 'comment' => 'Comment', + 'version' => 'Version' + ); + + while (list ($key, $value) = each ($file_attributes)) + { + create_check_box($value,$key); + } + + create_section('Other settings'); + + $other_checkboxes = array ( + "viewinnewwin" => "View documents in new window", + "viewonserver" => "View documents on server (if available)", + "viewtextplain" => "Unknown MIME-type defaults to text/plain when viewing", + "dotdot" => "Show ..", + "dotfiles" => "Show .files", + ); + + while (list ($key, $value) = each ($other_checkboxes)) + { + create_check_box($value,$key); + } + + $upload_boxes=array( + "1"=>"1", + "5"=>"5", + "10"=>"10", + "20"=>"20", + "30"=>"30" + ); + + create_select_box('Default number of upload fields to show','show_upload_boxes',$upload_boxes); diff --git a/filemanager/index.php b/filemanager/index.php index 307dd654ac..9e4dbf5dd3 100755 --- a/filemanager/index.php +++ b/filemanager/index.php @@ -1,15 +1,15 @@ 'filemanager', 'noheader' => True, 'nonavbar' => True, @@ -17,23 +17,17 @@ 'noappfooter' => True, 'nofooter' => True ); + + $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; - $GLOBALS['phpgw_info']['flags'] = $phpgw_flags; - - include('../header.inc.php'); + include('../header.inc.php'); + // $GLOBALS['phpgw']->common->phpgw_exit(); Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index')); $GLOBALS['phpgw']->common->phpgw_exit(); } - ### - # DEV NOTE: - # - # index.php is depreciated by the inc/class.xxphpwebhosting.inc.php files. - # index.php is still used in the 0.9.14 release, but all future changes should be - # made to the inc/class.xxphpwebhosting.inc.php files (3-tiered). This includes using templates. - ### - + ### # Enable this to display some debugging info ### @@ -104,6 +98,7 @@ } } + if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) { $noheader = True; @@ -122,6 +117,38 @@ include ('../header.inc.php'); + if (!count ($GLOBALS['settings'])) + { + $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $pref->read_repository (); +// $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); +// $pref->save_repository (True); + $pref_array = $pref->read_repository (); + $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; + } +//experimental_new_code +//die($GLOBALS[][experimental_new_code]); +/* if($GLOBALS[settings][experimental_new_code]) + { + echo ' + + + '; + + } +*/ + + + if ($execute && $command_line) { if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) @@ -138,6 +165,9 @@ } } + + + ### # Page to process users # Code is fairly hackish at the beginning, but it gets better @@ -635,15 +665,6 @@ if ($messages) html_text ($messages); } -if (!count ($GLOBALS['settings'])) -{ - $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); - $pref->read_repository (); - $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); - $pref->save_repository (True); - $pref_array = $pref->read_repository (); - $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; -} ### # Start Main Table diff --git a/filemanager/indexold.php b/filemanager/indexold.php new file mode 100755 index 0000000000..f01ae50f5d --- /dev/null +++ b/filemanager/indexold.php @@ -0,0 +1,1785 @@ + array ('op' => ''), + 'path' => array ('path' => ''), + 'file' => array ('file' => ''), + 'sortby' => array ('sortby' => ''), + 'fileman' => array ('fileman' => ''), + 'messages' => array ('messages' => ''), + 'help_name' => array ('help_name' => ''), + 'renamefiles' => array ('renamefiles' => ''), + 'comment_files' => array ('comment_files' => ''), + 'show_upload_boxes' => array ('show_upload_boxes' => '') +); + +reset ($to_decode); +while (list ($var, $conditions) = each ($to_decode)) +{ + while (list ($condvar, $condvalue) = each ($conditions)) + { + if (isset ($$condvar) && ($condvar == $var || $$condvar == $condvalue)) + { + if (is_array ($$var)) + { + $temp = array (); + //some fixes in this section were supplied by Michael Totschnig + while (list ($varkey, $varvalue) = each ($$var)) + { + if (is_int ($varkey)) + { + $temp[$varkey] = stripslashes (base64_decode(urldecode(($varvalue)))); + } + else + { + $temp[stripslashes (base64_decode(urldecode(($varkey))))] = $varvalue; + } + } + $$var = $temp; + } + elseif (isset ($$var)) + { + $$var = stripslashes (base64_decode(urldecode ($$var))); + } + } + } +} + +if ($noheader || $nofooter || ($download && (count ($fileman) > 0)) || ($op == 'view' && $file) || ($op == 'history' && $file) || ($op == 'help' && $help_name)) +{ + $noheader = True; + $nofooter = True; +} + +$GLOBALS['phpgw_info']['flags'] = array +( + 'currentapp' => 'filemanager', + 'noheader' => $noheader, + 'nofooter' => $nofooter, + 'noappheader' => False, + 'enable_vfs_class' => True, + 'enable_browser_class' => True +); + +include ('../header.inc.php'); + +if ($execute && $command_line) +{ + if ($result = $GLOBALS['phpgw']->vfs->command_line (array ('command_line' => stripslashes ($command_line)))) + { + $messages = html_text_bold (lang('Command sucessfully run'),1); + if ($result != 1 && strlen ($result) > 0) + { + $messages .= html_break (2, NULL, 1) . $result; + } + } + else + { + $messages = $GLOBALS['phpgw']->common->error_list (array (lang('Error running command'))); + } +} + +### +# Page to process users +# Code is fairly hackish at the beginning, but it gets better +# Highly suggest turning wrapping off due to long SQL queries +### + +### +# Some hacks to set and display directory paths correctly +### + +if ($go) +{ + $path = $todir; +} + +if (!$path) +{ + $path = $GLOBALS['phpgw']->vfs->pwd (); + + if (!$path || $GLOBALS['phpgw']->vfs->pwd (array ('full' => False)) == '') + { + $path = $GLOBALS['homedir']; + } +} + +$GLOBALS['phpgw']->vfs->cd (array ('string' => False, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); +$GLOBALS['phpgw']->vfs->cd (array ('string' => $path, 'relatives' => array (RELATIVE_NONE), 'relative' => False)); + +$pwd = $GLOBALS['phpgw']->vfs->pwd (); + +if (!$cwd = substr ($path, strlen ($GLOBALS['homedir']) + 1)) +{ + $cwd = '/'; +} +else +{ + $cwd = substr ($pwd, strrpos ($pwd, '/') + 1); +} + +$disppath = $path; + +/* This just prevents // in some cases */ +if ($path == '/') + $dispsep = ''; +else + $dispsep = '/'; + +if (!($lesspath = substr ($path, 0, strrpos ($path, '/')))) + $lesspath = '/'; + +$now = date ('Y-m-d'); + +if ($phpwh_debug) +{ + echo "PHPWebHosting debug:
+ path: $path
+ disppath: $disppath
+ cwd: $cwd
+ lesspath: $lesspath +

+ phpGW debug:
+ real getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False, 'mask' => False, 'fake' => False)) . "
+ fake getabsolutepath: " . $GLOBALS['phpgw']->vfs->getabsolutepath (array ('target' => False)) . "
+ appsession: " . $GLOBALS['phpgw']->session->appsession ('vfs','') . "
+ pwd: " . $GLOBALS['phpgw']->vfs->pwd () . "
"; +} + +### +# Get their readable groups to be used throughout the script +### + +$groups = array (); + +$groups = $GLOBALS['phpgw']->accounts->get_list ('groups'); + +$readable_groups = array (); + +while (list ($num, $account) = each ($groups)) +{ + if ($GLOBALS['phpgw']->vfs->acl_check (array ( + 'owner_id' => $account['account_id'], + 'operation' => PHPGW_ACL_READ + )) + ) + { + $readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); + } +} + +$groups_applications = array (); + +while (list ($num, $group_array) = each ($readable_groups)) +{ + $group_id = $GLOBALS['phpgw']->accounts->name2id ($group_array['account_name']); + + $applications = CreateObject('phpgwapi.applications', $group_id); + $groups_applications[$group_array['account_name']] = $applications->read_account_specific (); +} + +### +# We determine if they're in their home directory or a group's directory, +# and set the VFS working_id appropriately +### + +if ((preg_match ('+^'.$GLOBALS['fakebase'].'\/(.*)(\/|$)+U', $path, $matches)) && $matches[1] != $GLOBALS['userinfo']['account_lid']) +{ + $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id ($matches[1]); +} +else +{ + $GLOBALS['phpgw']->vfs->working_id = $GLOBALS['userinfo']['username']; +} + +if ($path != $GLOBALS['homedir'] + && $path != $GLOBALS['fakebase'] + && $path != '/' + && !$GLOBALS['phpgw']->vfs->acl_check (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_READ + )) +) +{ + echo $GLOBALS['phpgw']->common->error_list (array (lang('You do not have access to %1', $path))); + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); + html_page_close (); +} + +$GLOBALS['userinfo']['working_id'] = $GLOBALS['phpgw']->vfs->working_id; +$GLOBALS['userinfo']['working_lid'] = $GLOBALS['phpgw']->accounts->id2name ($GLOBALS['userinfo']['working_id']); + +### +# If their home directory doesn't exist, we create it +# Same for group directories +### + +if (($path == $GLOBALS['homedir']) + && !$GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE) + )) +) +{ + $GLOBALS['phpgw']->vfs->override_acl = 1; + + if (!$GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) + { + $p = $phpgw->vfs->path_parts (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create directory %1', $GLOBALS['homedir'] . ' (' . $p->real_full_path . ')'))); + } + + $GLOBALS['phpgw']->vfs->override_acl = 0; +} + +### +# Verify path is real +### + +if ($path != $GLOBALS['homedir'] && $path != '/' && $path != $GLOBALS['fakebase']) +{ + if (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $path, 'relatives' => array (RELATIVE_NONE)))) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 does not exist', $path))); + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], lang('Go to your home directory')); + html_break (2); + html_link_back (); + html_page_close (); + } +} + +/* Update if they request it, or one out of 20 page loads */ +srand ((double) microtime() * 1000000); +if ($update || rand (0, 19) == 4) +{ + $GLOBALS['phpgw']->vfs->update_real (array ('string' => $path, 'relatives' => array (RELATIVE_NONE))); +} + +### +# Check available permissions for $path, so we can disable unusable operations in user interface +### + +if ($GLOBALS['phpgw']->vfs->acl_check (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'operation' => PHPGW_ACL_ADD + )) +) +{ + $can_add = True; +} + +### +# Default is to sort by name +### + +if (!$sortby) +{ + $sortby = 'name'; +} + +### +# Decide how many upload boxes to show +### + +if (!$show_upload_boxes || $show_upload_boxes <= 0) +{ + if (!$show_upload_boxes = $GLOBALS['settings']['show_upload_boxes']) + { + $show_upload_boxes = 5; + } +} + + +### +# Read in file info from database to use in the rest of the script +# $fakebase is a special directory. In that directory, we list the user's +# home directory and the directories for the groups they're in +### + +$numoffiles = 0; +if ($path == $GLOBALS['fakebase']) +{ + if (!$GLOBALS['phpgw']->vfs->file_exists (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE)))) + { + $GLOBALS['phpgw']->vfs->mkdir (array ('string' => $GLOBALS['homedir'], 'relatives' => array (RELATIVE_NONE))); + } + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + $files_array[] = $ls_array[0]; + $numoffiles++; +// $files_array = $ls_array; +// $numoffiles = count($ls_array); + + reset ($readable_groups); + while (list ($num, $group_array) = each ($readable_groups)) + { + ### + # If the group doesn't have access to this app, we don't show it + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + if (!$GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + )) + ) + { + $GLOBALS['phpgw']->vfs->override_acl = 1; + $GLOBALS['phpgw']->vfs->mkdir (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE) + ) + ); + $GLOBALS['phpgw']->vfs->override_acl = 0; + + $GLOBALS['phpgw']->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'] + ) + ) + ); + } + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $files_array[] = $ls_array[0]; + + $numoffiles++; + } +} +else +{ + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => False, + 'orderby' => $sortby + ) + ); + + if ($phpwh_debug) + { + echo '# of files found in "'.$path.'" : '.count($ls_array).'
'."\n"; + } + + while (list ($num, $file_array) = each ($ls_array)) + { + $numoffiles++; + $files_array[] = $file_array; + if ($phpwh_debug) + { + echo 'Filename: '.$file_array['name'].'
'."\n"; + } + } +} + +if (!is_array ($files_array)) +{ + $files_array = array (); +} + +if ($download) +{ + for ($i = 0; $i != $numoffiles; $i++) + { + if (!$fileman[$i]) + { + continue; + } + + $download_browser = CreateObject ('phpgwapi.browser'); + $download_browser->content_header ($fileman[$i]); + echo $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$i])); + $GLOBALS['phpgw']->common->phpgw_exit (); + } +} + +if ($op == 'view' && $file) +{ + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_ALL), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + if ($ls_array[0]['mime_type']) + { + $mime_type = $ls_array[0]['mime_type']; + } + elseif ($GLOBALS['settings']['viewtextplain']) + { + $mime_type = 'text/plain'; + } + + header('Content-type: ' . $mime_type); + echo $GLOBALS['phpgw']->vfs->read (array ( + 'string' => $path.'/'.$file, + 'relatives' => array (RELATIVE_NONE) + ) + ); + $GLOBALS['phpgw']->common->phpgw_exit (); +} + +if ($op == 'history' && $file) +{ + $journal_array = $GLOBALS['phpgw']->vfs->get_journal (array ( + 'string' => $file, + 'relatives' => array (RELATIVE_ALL) + ) + ); + + if (is_array ($journal_array)) + { + html_table_begin (); + html_table_row_begin (); + html_table_col_begin (); + html_text_bold (lang('Date')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Version')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Who')); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Operation')); + html_table_col_end (); + html_table_row_end (); + + while (list ($num, $journal_entry) = each ($journal_array)) + { + html_table_row_begin (); + html_table_col_begin (); + html_text ($journal_entry['created'] . html_nbsp (3, 1)); + html_table_col_end (); + html_table_col_begin (); + html_text ($journal_entry['version'] . html_nbsp (3, 1)); + html_table_col_end (); + html_table_col_begin (); + html_text ($GLOBALS['phpgw']->accounts->id2name ($journal_entry['owner_id']) . html_nbsp (3, 1)); + html_table_col_end (); + html_table_col_begin (); + html_text ($journal_entry['comment']); + html_table_col_end (); + } + + html_table_end (); + html_page_close (); + } + else + { + html_text_bold (lang('No version history for this file/directory')); + } + +} + +if ($newfile && $createfile) +{ + if ($badchar = bad_chars ($createfile, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"',$badchar), 1))); + html_break (2); + html_link_back (); + html_page_close (); + } + + if ($GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 already exists. Please edit it or delete it first.', $createfile))); + html_break (2); + html_link_back (); + html_page_close (); + } + + if ($GLOBALS['phpgw']->vfs->touch (array ( + 'string' => $createfile, + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + $fileman = array (); + $fileman[0] = $createfile; + $edit = 1; + $numoffiles++; + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('File %1 could not be created.', $createfile))); + } +} + +if ($op == 'help' && $help_name) +{ + while (list ($num, $help_array) = each ($help_info)) + { + if ($help_array[0] != $help_name) + continue; + + $help_array[1] = preg_replace ("/\[(.*)\|(.*)\]/Ue", "html_help_link ('\\1', '\\2', False, True)", $help_array[1]); + $help_array[1] = preg_replace ("/\[(.*)\]/Ue", "html_help_link ('\\1', '\\1', False, True)", $help_array[1]); + + html_font_set ('4'); + $title = ereg_replace ('_', ' ', $help_array[0]); + $title = ucwords ($title); + html_text ($title); + html_font_end (); + + html_break (2); + + html_font_set ('2'); + html_text ($help_array[1]); + html_font_end (); + } + + $GLOBALS['phpgw']->common->phpgw_exit (); +} + +### +# Start Main Page +### + +html_page_begin (lang('Users').' :: '.$GLOBALS['userinfo']['username']); +html_page_body_begin (HTML_PAGE_BODY_COLOR); + +if ($messages) +{ + html_text ($messages); +} + +if (!count ($GLOBALS['settings'])) +{ + $pref = CreateObject ('phpgwapi.preferences', $GLOBALS['userinfo']['username']); + $pref->read_repository (); + $GLOBALS['phpgw']->hooks->single ('add_def_pref', $GLOBALS['appname']); + $pref->save_repository (True); + $pref_array = $pref->read_repository (); + $GLOBALS['settings'] = $pref_array[$GLOBALS['appname']]; +} + +### +# Start Main Table +### + +if (!$op && !$delete && !$createdir && !$renamefiles && !$move && !$copy && !$edit && !$comment_files) +{ + html_table_begin ('100%'); + html_table_row_begin (); + html_table_col_begin ('center', NULL, 'top'); + html_align ('center'); + html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); + if ($numoffiles || $cwd) + { + while (list ($num, $name) = each ($GLOBALS['settings'])) + { + if ($name) + { + $columns++; + } + } + $columns++; + html_table_begin (); + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_HEADER_BG_COLOR); + html_table_col_begin ('center', NULL, NULL, NULL, $columns); + html_table_begin ('100%'); + html_table_row_begin (); + html_table_col_begin ('left'); + + if ($path != '/') + { + html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, html_image ('images/folder-up.png', lang('Up'), 'left', 0, NULL, 1)); + html_help_link ('up'); + } + + html_table_col_end (); + html_table_col_begin ('center'); + + if ($cwd) + { + if ($path == $GLOBALS['homedir']) + { + html_image ('images/folder-home.png', lang('Folder'), 'center'); + } + else + { + html_image ('images/folder.png', lang('Folder'), 'center'); + } + } + else + { + html_image ('images/folder-home.png', lang('Home')); + } + + html_font_set (4, HTML_TABLE_FILES_HEADER_TEXT_COLOR); + html_text_bold ($disppath); + html_font_end (); + html_help_link ('directory_name'); + html_table_col_end (); + html_table_col_begin ('right'); + + if ($path != $GLOBALS['homedir']) + { + html_link ($GLOBALS['appname'].'/index.php?path='.$GLOBALS['homedir'], html_image ('images/folder-home.png', lang('Home'), 'right', 0, NULL, 1)); + html_help_link ('home'); + } + + html_table_col_end (); + html_table_row_end (); + html_table_end (); + html_table_col_end (); + html_table_row_end (); + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_COLUMN_HEADER_BG_COLOR); + + ### + # Start File Table Column Headers + # Reads values from $file_attributes array and preferences + ### + + html_table_col_begin (); + html_text (lang('Sort by:') . html_nbsp (1, 1), NULL, NULL, 0); + html_help_link ('sort_by'); + html_table_col_end (); + + reset ($file_attributes); + while (list ($internal, $displayed) = each ($file_attributes)) + { + if ($GLOBALS['settings'][$internal]) + { + html_table_col_begin (); + html_link ($GLOBALS['appname'].'/index.php?path='.$path.'&sortby='.$internal, html_text_bold ($displayed, 1, 0)); + html_help_link (strtolower (ereg_replace (' ', '_', $displayed))); + html_table_col_end (); + } + } + + html_table_col_begin (); + html_table_col_end (); + html_table_row_end (); + + if ($GLOBALS['settings']['dotdot'] && $GLOBALS['settings']['name'] && $path != '/') + { + html_table_row_begin (); + html_table_col_begin (); + html_table_col_end (); + + /* We can assume the next column is the name */ + html_table_col_begin (); + html_image ('images/folder.png', lang('Folder')); + html_link ($GLOBALS['appname'].'/index.php?path='.$lesspath, '..'); + html_table_col_end (); + + if ($GLOBALS['settings']['mime_type']) + { + html_table_col_begin (); + html_text (lang('Directory')); + html_table_col_end (); + } + + html_table_row_end (); + } + + ### + # List all of the files, with their attributes + ### + + reset ($files_array); + for ($i = 0; $i != $numoffiles; $i++) + { + $files = $files_array[$i]; + + if ($rename || $edit_comments) + { + unset ($this_selected); + unset ($renamethis); + unset ($edit_this_comment); + + for ($j = 0; $j != $numoffiles; $j++) + { + if ($fileman[$j] == $files['name']) + { + $this_selected = 1; + break; + } + } + + if ($rename && $this_selected) + { + $renamethis = 1; + } + elseif ($edit_comments && $this_selected) + { + $edit_this_comment = 1; + } + } + + if (!$GLOBALS['settings']['dotfiles'] && ereg ("^\.", $files['name'])) + { + continue; + } + + html_table_row_begin (NULL, NULL, NULL, HTML_TABLE_FILES_BG_COLOR); + + ### + # Checkboxes + ### + + html_table_col_begin ('right'); + + if (!$rename && !$edit_comments && $path != $GLOBALS['fakebase'] && $path != '/') + { + html_form_input ('checkbox', 'fileman['.$i.']', base64_encode ($files['name'])); + } + elseif ($renamethis) + { + html_form_input ('hidden', 'fileman[' . base64_encode ($files['name']) . ']', $files['name'], NULL, NULL, 'checked'); + } + else + { + html_nbsp(); + } + + html_table_col_end (); + + ### + # File name and icon + ### + + if ($GLOBALS['settings']['name']) + { + if ($phpwh_debug) + { + echo 'Setting file name: '.$files['name'].'
'."\n"; + } + + html_table_col_begin (); + + if ($renamethis) + { + if ($files['mime_type'] == 'Directory') + { + html_image ('images/folder.png', lang('Folder')); + } + html_form_input ('text', 'renamefiles[' . base64_encode ($files['name']) . ']', $files['name'], 255); + } + else + { + if ($files['mime_type'] == 'Directory') + { + html_image ('images/folder.png', lang('Folder')); + html_link ($GLOBALS['appname'].'/index.php?path='.$path.$dispsep.$files['name'], $files['name']); + } + else + { + if ($GLOBALS['settings']['viewonserver'] && isset ($GLOBALS['filesdir']) && !$files['link_directory']) + { + $clickview = $GLOBALS['filesdir'].$pwd.'/'.$files['name']; + + if ($phpwh_debug) + { + echo 'Setting clickview = '.$clickview.'
'."\n"; + } + } + else + { + $clickview = $GLOBALS['appname'].'/index.php?op=view&file='.$files['name'].'&path='.$path; + } + + if ($GLOBALS['settings']['viewinnewwin']) + { + $target = '_new'; + } + + html_link ($clickview, $files['name'], 0, 1, 0, $target); + } + } + + html_table_col_end (); + } + + ### + # MIME type + ### + + if ($GLOBALS['settings']['mime_type']) + { + html_table_col_begin (); + html_text ($files['mime_type']); + html_table_col_end (); + } + + ### + # File size + ### + + if ($GLOBALS['settings']['size']) + { + html_table_col_begin (); + + $size = $GLOBALS['phpgw']->vfs->get_size (array ( + 'string' => $files['directory'] . '/' . $files['name'], + 'relatives' => array (RELATIVE_NONE) + ) + ); + + borkb ($size); + + html_table_col_end (); + } + + ### + # Date created + ### + if ($GLOBALS['settings']['created']) + { + html_table_col_begin (); + html_text ($files['created']); + html_table_col_end (); + } + + ### + # Date modified + ### + + if ($GLOBALS['settings']['modified']) + { + html_table_col_begin (); + if ($files['modified'] != '0000-00-00') + { + html_text ($files['modified']); + } + html_table_col_end (); + } + + ### + # Owner name + ### + + if ($GLOBALS['settings']['owner']) + { + html_table_col_begin (); + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['owner_id'])); + html_table_col_end (); + } + + ### + # Creator name + ### + + if ($GLOBALS['settings']['createdby_id']) + { + html_table_col_begin (); + if ($files['createdby_id']) + { + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['createdby_id'])); + } + html_table_col_end (); + } + + ### + # Modified by name + ### + + if ($GLOBALS['settings']['modifiedby_id']) + { + html_table_col_begin (); + if ($files['modifiedby_id']) + { + html_text ($GLOBALS['phpgw']->accounts->id2name ($files['modifiedby_id'])); + } + html_table_col_end (); + } + + ### + # Application + ### + + if ($GLOBALS['settings']['app']) + { + html_table_col_begin (); + html_text ($files['app']); + html_table_col_end (); + } + + ### + # Comment + ### + + if ($GLOBALS['settings']['comment']) + { + html_table_col_begin (); + if ($edit_this_comment) + { + html_form_input ('text', 'comment_files[' . base64_encode ($files['name']) . ']', html_encode ($files['comment'], 1), 255); + } + else + { + html_text ($files['comment']); + } + html_table_col_end (); + } + + ### + # Version + ### + + if ($GLOBALS['settings']['version']) + { + html_table_col_begin (); + html_link ($GLOBALS['appname'].'/index.php?op=history&file='.$files['name'].'&path='.$path, $files['version'], NULL, True, NULL, '_new'); + html_table_col_end (); + } + + ### + # Deleteable (currently not used) + ### + + if ($GLOBALS['settings']['deleteable']) + { + if ($files['deleteable'] == 'N') + { + html_table_col_begin (); + html_image ('images/locked.png', lang('Locked')); + html_table_col_end (); + } + else + { + html_table_col_begin (); + html_table_col_end (); + } + } + + html_table_row_end (); + + if ($files['mime_type'] == 'Directory') + { + $usedspace += $fileinfo[0]; + } + else + { + $usedspace += $files['size']; + } + } + + html_table_end (); + html_break (2); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + if (!$rename && !$edit_comments) + { + html_form_input ('submit', 'edit', lang('Edit')); + html_help_link ('edit'); + html_nbsp (3); + } + + if (!$edit_comments) + { + html_form_input ('submit', 'rename', lang('Rename')); + html_help_link ('rename'); + html_nbsp (3); + } + + if (!$rename && !$edit_comments) + { + html_form_input ('submit', 'delete', lang('Delete')); + html_help_link ('delete'); + html_nbsp (3); + } + + if (!$rename) + { + html_form_input ('submit', 'edit_comments', lang('Edit comments')); + html_help_link ('edit_comments'); + } + } + } + + ### + # Display some inputs and info, but not when renaming or editing comments + ### + + if (!$rename && !$edit_comments) + { + ### + # Begin Copy to/Move to selection + ### + + html_break (1); + html_form_input ('submit', 'go', lang('Go to:')); + html_help_link ('go_to'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + html_form_input ('submit', 'copy', lang('Copy to:')); + html_help_link ('copy_to'); + html_form_input ('submit', 'move', lang('Move to:')); + html_help_link ('move_to'); + } + + html_form_select_begin ('todir'); + + html_break (1); + + ### + # First we get the directories in their home directory + ### + + $dirs = array (); + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $GLOBALS['userinfo']['account_lid']); + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $GLOBALS['homedir'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) + ); + + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } + + + ### + # Then we get the directories in their readable groups' home directories + ### + + reset ($readable_groups); + while (list ($num, $group_array) = each ($readable_groups)) + { + ### + # Don't list directories for groups that don't have access + ### + + if (!$groups_applications[$group_array['account_name']][$GLOBALS['appname']]['enabled']) + { + continue; + } + + $dirs[] = array ('directory' => $GLOBALS['fakebase'], 'name' => $group_array['account_name']); + + $ls_array = $phpgw->vfs->ls (array ( + 'string' => $GLOBALS['fakebase'].'/'.$group_array['account_name'], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => True, + 'mime_type' => 'Directory' + ) + ); + while (list ($num, $dir) = each ($ls_array)) + { + $dirs[] = $dir; + } + } + + reset ($dirs); + while (list ($num, $dir) = each ($dirs)) + { + if (!$dir['directory']) + { + continue; + } + + ### + # So we don't display // + ### + + if ($dir['directory'] != '/') + { + $dir['directory'] .= '/'; + } + + ### + # No point in displaying the current directory, or a directory that doesn't exist + ### + + if ((($dir['directory'] . $dir['name']) != $path) + && $GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $dir['directory'] . $dir['name'], + 'relatives' => array (RELATIVE_NONE) + )) + ) + { + html_form_option ($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); + } + } + + html_form_select_end (); + html_help_link ('directory_list'); + + if ($path != '/' && $path != $GLOBALS['fakebase']) + { + html_break (1); + + html_form_input ('submit', 'download', lang('Download')); + html_help_link ('download'); + html_nbsp (3); + + if ($can_add) + { + html_form_input ('text', 'createdir', NULL, 255, 15); + html_form_input ('submit', 'newdir', lang('Create Folder')); + html_help_link ('create_folder'); + } + } + + html_break (1); + html_form_input ('submit', 'update', lang('Update')); + html_help_link ('update'); + + if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) + { + html_nbsp (3); + html_form_input ('text', 'createfile', NULL, 255, 15); + html_form_input ('submit', 'newfile', lang('Create File')); + html_help_link ('create_file'); + } + + if ($GLOBALS['settings']['show_command_line']) + { + html_break (2); + html_form_input ('text', 'command_line', NULL, NULL, 50); + html_help_link ('command_line'); + + html_break (1); + html_form_input ('submit', 'execute', lang('Execute')); + html_help_link ('execute'); + } + + html_form_end (); + + html_help_link ('file_stats'); + html_break (1); + html_text_bold (lang('Files').': '); + html_text ($numoffiles); + html_nbsp (3); + + html_text_bold (lang('Used space').': '); + html_text (borkb ($usedspace, NULL, 1)); + html_nbsp (3); + + if ($path == $GLOBALS['homedir'] || $path == $GLOBALS['fakebase']) + { + html_text_bold (lang('Unused space').': '); + html_text (borkb ($GLOBALS['userinfo']['hdspace'] - $usedspace, NULL, 1)); + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path, + 'relatives' => array (RELATIVE_NONE) + ) + ); + + $i = count ($ls_array); + + html_break (2); + html_text_bold (lang('Total Files').': '); + html_text ($i); + } + + ### + # Show file upload boxes. Note the last argument to html (). Repeats $show_upload_boxes times + ### + + if ($path != '/' && $path != $GLOBALS['fakebase'] && $can_add) + { + html_break (2); + html_form_begin ($GLOBALS['appname'].'/index.php?op=upload&path='.$path, 'post', 'multipart/form-data'); + html_table_begin (); + html_table_row_begin ('center'); + html_table_col_begin (); + html_text_bold (lang('File')); + html_help_link ('upload_file'); + html_table_col_end (); + html_table_col_begin (); + html_text_bold (lang('Comment')); + html_help_link ('upload_comment'); + html_table_col_end (); + html_table_row_end (); + + html_table_row_begin (); + html_table_col_begin (); + html_form_input ('hidden', 'show_upload_boxes', base64_encode ($show_upload_boxes)); + html (html_form_input ('file', 'upload_file[]', NULL, 255, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html_table_col_end (); + html_table_col_begin (); + html (html_form_input ('text', 'upload_comment[]', NULL, NULL, NULL, NULL, NULL, 1) . html_break (1, NULL, 1), $show_upload_boxes); + html_table_col_end (); + html_table_row_end (); + html_table_end (); + html_form_input ('submit', 'upload_files', lang('Upload files')); + html_help_link ('upload_files'); + html_break (2); + html_text (lang('Show') . html_nbsp (1, True)); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=5', '5'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=10', '10'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=20', '20'); + html_nbsp (); + html_link ($GLOBALS['appname'].'/index.php?show_upload_boxes=50', '50'); + html_nbsp (); + html_text (lang('upload fields')); + html_nbsp (); + html_help_link ('show_upload_fields'); + html_form_end (); + } + } + + html_table_col_end (); + html_table_row_end (); + html_table_end (); + html_page_close (); +} + +### +# Handle Editing files +### + +if ($edit) +{ + ### + # If $edit is "Edit", we do nothing, and let the for loop take over + ### + + if ($edit_file) + { + $edit_file_content = stripslashes ($edit_file_content); + } + + if ($edit_preview) + { + $content = $edit_file_content; + + html_break (1); + html_text_bold (lang('Preview of %1', $path.'/'.$edit_file)); + html_break (2); + + html_table_begin ('90%'); + html_table_row_begin (); + html_table_col_begin (); + html_text (nl2br ($content)); + html_table_col_end (); + html_table_row_end (); + html_table_end (); + } + elseif ($edit_save) + { + $content = $edit_file_content; + + if ($GLOBALS['phpgw']->vfs->write (array ( + 'string' => $edit_file, + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + html_text_bold (lang('Saved %1', $path.'/'.$edit_file)); + html_break (2); + html_link_back (); + } + else + { + html_text_error (lang('Could not save %1', $path.'/'.$edit_file)); + html_break (2); + html_link_back (); + } + } + +/* This doesn't work just yet + elseif ($edit_save_all) + { + for ($j = 0; $j != $numoffiles; $j++) + { + $fileman[$j]; + + $content = $fileman[$j]; + echo 'fileman['.$j.']: '.$fileman[$j].'
'.$content.'
'; + continue; + + if ($GLOBALS['phpgw']->vfs->write (array ( + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL), + 'content' => $content + )) + ) + { + html_text_bold (lang('Saved %1', $path.'/'.$fileman[$j])); + html_break (1); + } + else + { + html_text_error (lang('Could not save %1', $path.'/'.$fileman[$j])); + html_break (1); + } + } + + html_break (1); + } +*/ + + ### + # Now we display the edit boxes and forms + ### + + for ($j = 0; $j != $numoffiles; $j++) + { + ### + # If we're in preview or save mode, we only show the file + # being previewed or saved + ### + + if ($edit_file && ($fileman[$j] != $edit_file)) + { + continue; + } + + if ($fileman[$j] && $GLOBALS['phpgw']->vfs->file_exists (array ( + 'string' => $fileman[$j], + 'relatives' => array (RELATIVE_ALL) + )) + ) + { + if ($edit_file) + { + $content = stripslashes ($edit_file_content); + } + else + { + $content = $GLOBALS['phpgw']->vfs->read (array ('string' => $fileman[$j])); + } + + html_table_begin ('100%'); + html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path); + html_form_input ('hidden', 'edit', True); + html_form_input ('hidden', 'edit_file', $fileman[$j]); + + ### + # We need to include all of the fileman entries for each file's form, + # so we loop through again + ### + + for ($i = 0; $i != $numoffiles; $i++) + { + html_form_input ('hidden', 'fileman['.$i.']', base64_encode ($fileman[$i])); + } + + html_table_row_begin (); + html_table_col_begin (); + html_form_textarea ('edit_file_content', 35, 75, $content); + html_table_col_end (); + html_table_col_begin ('center'); + html_form_input ('submit', 'edit_preview', lang('Preview %1', html_encode ($fileman[$j], 1))); + html_break (1); + html_form_input ('submit', 'edit_save', lang('Save %1', html_encode ($fileman[$j], 1))); +// html_break (1); +// html_form_input ('submit', 'edit_save_all', lang('Save all')); + html_table_col_end (); + html_table_row_end (); + html_break (2); + html_form_end (); + html_table_end (); + } + } +} + +### +# Handle File Uploads +### + +elseif ($op == 'upload' && $path != '/' && $path != $GLOBALS['fakebase']) +{ + for ($i = 0; $i != $show_upload_boxes; $i++) + { + if ($badchar = bad_chars ($_FILES['upload_file']['name'][$i], True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"', $badchar), 1))); + + continue; + } + + ### + # Check to see if the file exists in the database, and get its info at the same time + ### + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path . '/' . $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] == 'Directory') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot replace %1 because it is a directory', $fileinfo['name']))); + continue; + } + } + + if ($_FILES['upload_file']['size'][$i] > 0) + { + if ($fileinfo['name'] && $fileinfo['deleteable'] != 'N') + { + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'owner_id' => $GLOBALS['userinfo']['username'], + 'modifiedby_id' => $GLOBALS['userinfo']['username'], + 'modified' => $now, + 'size' => $_FILES['upload_file']['size'][$i], + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'deleteable' => 'Y', + 'comment' => stripslashes ($upload_comment[$i]) + ) + ) + ); + + $GLOBALS['phpgw']->vfs->cp(array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) + ); + + html_text_summary(lang('Replaced %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); + } + else + { + $GLOBALS['phpgw']->vfs->cp (array ( + 'from' => $_FILES['upload_file']['tmp_name'][$i], + 'to' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) + ) + ); + + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => stripslashes ($upload_comment[$i]) + ) + ) + ); + + html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $_FILES['upload_file']['size'][$i]); + } + } + elseif ($_FILES['upload_file']['name'][$i]) + { + $GLOBALS['phpgw']->vfs->touch (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL) + ) + ); + + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $_FILES['upload_file']['name'][$i], + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'mime_type' => $_FILES['upload_file']['type'][$i], + 'comment' => $upload_comment[$i] + ) + ) + ); + + html_text_summary(lang('Created %1', $disppath.'/'.$_FILES['upload_file']['name'][$i]), $file_size[$i]); + } + } + + html_break (2); + html_link_back (); +} + +### +# Handle Editing comments +### + +elseif ($comment_files) +{ + while (list ($file) = each ($comment_files)) + { + if ($badchar = bad_chars ($comment_files[$file], False, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array (html_text_italic ($file, 1) . html_encode (': ' . lang('Comments cannot contain "%1"', $badchar), 1))); + continue; + } + + $GLOBALS['phpgw']->vfs->set_attributes (array ( + 'string' => $file, + 'relatives' => array (RELATIVE_ALL), + 'attributes' => array ( + 'comment' => stripslashes ($comment_files[$file]) + ) + ) + ); + + html_text_summary (lang('Updated comment for %1', $path.'/'.$file)); + } + + html_break (2); + html_link_back (); +} + +### +# Handle Renaming Files and Directories +### + +elseif ($renamefiles) +{ + while (list ($from, $to) = each ($renamefiles)) + { + if ($badchar = bad_chars ($to, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('File names cannot contain "%1"', $badchar), 1))); + continue; + } + + if (ereg ("/", $to) || ereg ("\\\\", $to)) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang("File names cannot contain \\ or /"))); + } + elseif (!$GLOBALS['phpgw']->vfs->mv (array ( + 'from' => $from, + 'to' => $to + )) + ) + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not rename %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to))); + } + else + { + html_text_summary (lang('Renamed %1 to %2', $disppath.'/'.$from, $disppath.'/'.$to)); + } + } + + html_break (2); + html_link_back (); +} + +### +# Handle Moving Files and Directories +### + +elseif ($move) +{ + while (list ($num, $file) = each ($fileman)) + { + if ($GLOBALS['phpgw']->vfs->mv (array ( + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) + { + $moved++; + html_text_summary (lang('Moved %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not move %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } + } + + if ($moved) + { + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); + } + + html_break (2); + html_link_back (); +} + +### +# Handle Copying of Files and Directories +### + +elseif ($copy) +{ + while (list ($num, $file) = each ($fileman)) + { + if ($GLOBALS['phpgw']->vfs->cp (array ( + 'from' => $file, + 'to' => $todir . '/' . $file, + 'relatives' => array (RELATIVE_ALL, RELATIVE_NONE) + )) + ) + { + $copied++; + html_text_summary (lang('Copied %1 to %2', $disppath.'/'.$file, $todir.'/'.$file)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not copy %1 to %2', $disppath.'/'.$file, $todir.'/'.$file))); + } + } + + if ($copied) + { + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$todir, lang('Go to %1', $todir)); + } + + html_break (2); + html_link_back (); +} + +### +# Handle Deleting Files and Directories +### + +elseif ($delete) +{ + for ($i = 0; $i != $numoffiles; $i++) + { + if ($fileman[$i]) + { + if ($GLOBALS['phpgw']->vfs->delete (array ('string' => $fileman[$i]))) + { + html_text_summary (lang('Deleted %1', $disppath.'/'.$fileman[$i]), $fileinfo['size']); + } + else + { + $GLOBALS['phpgw']->common->error_list (array (lang('Could not delete %1', $disppath.'/'.$fileman[$i]))); + } + } + } + + html_break (2); + html_link_back (); +} + +elseif ($newdir && $createdir) +{ + if ($badchar = bad_chars ($createdir, True, True)) + { + echo $GLOBALS['phpgw']->common->error_list (array (html_encode (lang('Directory names cannot contain "%1"', $badchar), 1))); + html_break (2); + html_link_back (); + html_page_close (); + } + + if ($createdir[strlen($createdir)-1] == ' ' || $createdir[0] == ' ') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Cannot create directory because it begins or ends in a space'))); + html_break (2); + html_link_back (); + html_page_close (); + } + + $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + 'string' => $path . '/' . $createdir, + 'relatives' => array (RELATIVE_NONE), + 'checksubdirs' => False, + 'nofiles' => True + ) + ); + + $fileinfo = $ls_array[0]; + + if ($fileinfo['name']) + { + if ($fileinfo['mime_type'] != 'Directory') + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('%1 already exists as a file', $fileinfo['name']))); + html_break (2); + html_link_back (); + html_page_close (); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Directory %1 already exists', $fileinfo['name']))); + html_break (2); + html_link_back (); + html_page_close (); + } + } + else + { + if ($GLOBALS['phpgw']->vfs->mkdir (array ('string' => $createdir))) + { + html_text_summary (lang('Created directory %1', $disppath.'/'.$createdir)); + html_break (2); + html_link ($GLOBALS['appname'].'/index.php?path='.$disppath.'/'.$createdir, lang('Go to %1', $disppath.'/'.$createdir)); + } + else + { + echo $GLOBALS['phpgw']->common->error_list (array (lang('Could not create %1', $disppath.'/'.$createdir))); + } + } + + html_break (2); + html_link_back (); +} + +html_page_close (); + +?> diff --git a/filemanager/preferences.php b/filemanager/preferences.php index d8abfaf240..86c9d9f5eb 100644 --- a/filemanager/preferences.php +++ b/filemanager/preferences.php @@ -19,8 +19,8 @@ "nonavbar" => True ); + var_dump($file_attributes); include("../header.inc.php"); - /* To add an on/off preference, just add it here. Key is internal name, value is displayed name */ @@ -36,12 +36,6 @@ { $phpgw->preferences->read_repository (); - reset ($file_attributes); - while (list ($internal, $displayed) = each ($file_attributes)) - { - $phpgw->preferences->add ($phpgw_info["flags"]["currentapp"], $internal, $$internal); - } - reset ($other_checkboxes); while (list ($internal, $displayed) = each ($other_checkboxes)) { @@ -54,6 +48,13 @@ $phpgw->preferences->add ($phpgw_info["flags"]["currentapp"], $internal, $$internal); } + reset ($file_attributes); + while (list ($internal, $displayed) = each ($file_attributes)) + { + $phpgw->preferences->add ($phpgw_info["flags"]["currentapp"], $internal, $$internal); + } + + $phpgw->preferences->save_repository (True); Header('Location: '.$phpgw->link('/preferences/index.php')); @@ -101,6 +102,7 @@ echo '

' . $phpgw->common->error_list($errors) . '
'; } + while (list ($internal, $displayed) = each ($file_attributes)) { unset ($checked); diff --git a/filemanager/setup/phpgw_nl.lang b/filemanager/setup/phpgw_nl.lang index e205a5841b..f2c6b6e707 100644 --- a/filemanager/setup/phpgw_nl.lang +++ b/filemanager/setup/phpgw_nl.lang @@ -1,6 +1,94 @@ +%1 already exists as a file filemanager nl %1 bestaat reeds als een bestand. +application filemanager nl Toepassing +back to file manager filemanager nl Terug naar de Filemanager +cannot create directory because it begins or ends in a space filemanager nl Can de directory niet aanmaken omdat deze begint of eindigt met een spatie +cannot replace %1 because it is a directory filemanager nl Kan %1 niet vevangen omdat het een directory is. +command sucessfully run filemanager nl Commando met succes uitgevoerd. +comment filemanager nl Opmerking +comments cannot contain "%1" filemanager nl Opmerkingen kunnen geen "%1" bevatten. +copied %1 to %2 filemanager nl %1 gekopieerd naar %2. +copy to filemanager nl Kopiëren naar +copy to: filemanager nl Kopiëren naar: +could not copy %1 to %2 filemanager nl Kon %1 niet naar %2 kopiëren. +could not create %1 filemanager nl Kon %1 niet aanmaken. +could not create directory %1 filemanager nl Kon directory %1 niet aanmaken. +could not delete %1 filemanager nl Kon %1 niet verwijderen. +could not move %1 to %2 filemanager nl Kon %1 niet verplaatsen naar %2. +could not rename %1 to %2 filemanager nl Kon %1 niet hernoemen naar %2. +could not save %1 filemanager nl Kon %1 niet opslaan. +create file filemanager nl Bestand aanmaken +create folder filemanager nl Directory aanmaken +created filemanager nl Aangemaakt +created %1 filemanager nl %1 aangemaakt. +created by filemanager nl Aangemaakt door +created directory %1 filemanager nl Directory %1 aangemaakt. +date filemanager nl Datum +default number of upload fields to show filemanager nl Standaard aantal uploadvelden in beeld +delete filemanager nl Verwijderen +deleted %1 filemanager nl %1 verwijderd +directory filemanager nl Directory +directory %1 already exists filemanager nl Directory %1 bestaat reeds. +directory %1 does not exist filemanager nl Directory %1 bestaat niet. +directory names cannot contain "%1" filemanager nl Directorynamen kunnen geen "%1" bevatten. +display attributes filemanager nl Attributen weergeven +download filemanager nl Downloaden +edit filemanager nl Bewerken +edit comments filemanager nl Opmerkingen bewerken +error running command filemanager nl Fout bij het uitvoeren van commando +execute filemanager nl Uitvoeren +failed to create directory filemanager nl Het aanmaken van de directory is niet gelukt. +file filemanager nl Bestand +file %1 already exists. please edit it or delete it first. filemanager nl Bestand %1 bestaat reeds. +file %1 could not be created. filemanager nl Bestand %1 kon niet worden aangemaakt. +file name filemanager nl Bestandsnaam +file names cannot contain "%1" filemanager nl Bestanden kunnen geen "%1" bevatten. +file names cannot contain \ or / filemanager nl Bestanden kunnen geen "\" of "/" bevatten. filemanager common nl Filemanager -filemanager preferences nl Filemanager voorkeuren -users filemanager nl gebruikers +filemanager preferences filemanager nl Filemanager voorkeuren +files filemanager nl Bestanden +folder filemanager nl Directory +go to filemanager nl Ga naar +go to %1 filemanager nl Ga naar %1 +go to your home directory filemanager nl Ga naar uw homedirectory +go to: filemanager nl Ga naar: +home filemanager nl Home +locked filemanager nl Gesloten +mime type filemanager nl MIME-type +modified filemanager nl Gewijzigd +modified by filemanager nl Gewijzigd door +move to filemanager nl Verplaatsen naar +move to: filemanager nl Verplaatsen naar: +moved %1 to %2 filemanager nl %1 verplaatst naar %2 +no version history for this file/directory filemanager nl Geen versiegeschiedenis voor dit bestand of deze directory +operation filemanager nl Actie +owner filemanager nl Eigenaar +preview %1 filemanager nl Preview %1 +preview of %1 filemanager nl Preview van %1 +rename filemanager nl Hernoemen +renamed %1 to %2 filemanager nl %1 hernoemd naar %2 +replaced %1 filemanager nl %1 vervangen +save %1 filemanager nl %1 opslaan +save all filemanager nl Alles opslaan +saved %1 filemanager nl %1 opgeslagen +show filemanager nl Weergeven +show .. filemanager nl .. weergeven +show .files filemanager nl Verborgen bestanden weergeven +show command line (experimental. dangerous.) filemanager nl Commandoinvoer weergeven (EXPERIMENTEEL EN GEVAARLIJK) +show help filemanager nl Help weergeven +size filemanager nl Grootte +sort by: filemanager nl Sorteren op: +total files filemanager nl Totaal aantal bestanden +unknown mime-type defaults to text/plain when viewing filemanager nl Onbekend MIME-type standaard als text/plain weergeven +unused space filemanager nl Ongebruikte schijfruimte +up filemanager nl Naar boven +update filemanager nl Bijgewerkt +updated comment for %1 filemanager nl Opmerking voor %1 bijgewerkt +upload fields filemanager nl uploadvelden +upload files filemanager nl Bestanden uploaden +used space filemanager nl Gebruikte schijfruimte +users filemanager nl Gebruikers version filemanager nl Versie +view documents in new window filemanager nl Documenten in een nieuw venster weergeven +view documents on server (if available) filemanager nl Documenten op server weergeven (als dit mogelijk is) who filemanager nl Wie you do not have access to %1 filemanager nl U heeft geen toedang tot %1 diff --git a/filemanager/setup/setup.inc.php b/filemanager/setup/setup.inc.php index c110a88b4b..18a3925509 100755 --- a/filemanager/setup/setup.inc.php +++ b/filemanager/setup/setup.inc.php @@ -23,6 +23,7 @@ 'add_def_pref', 'admin', 'deleteaccount', + 'settings', 'preferences' ); diff --git a/filemanager/templates/default/edit_file.tpl b/filemanager/templates/default/edit_file.tpl new file mode 100644 index 0000000000..a9807cc021 --- /dev/null +++ b/filemanager/templates/default/edit_file.tpl @@ -0,0 +1,33 @@ + + + + + + + + +{preview_content}
+
+ + + {filemans_hidden} + + + + + + +{buttonSave} {buttonPreview} {buttonDone} {buttonCancel} + + +
+ +
+ + + + + diff --git a/filemanager/templates/default/filelisting.tpl b/filemanager/templates/default/filelisting.tpl new file mode 100644 index 0000000000..145bbfcb89 --- /dev/null +++ b/filemanager/templates/default/filelisting.tpl @@ -0,0 +1,34 @@ + +
+
+{messages} +
+ +{toolbar0} +
+{toolbar1} +
+
+ + + + + + + + + + + + {columns} + + + + +{lang_no_files} +
{col_data} 
{actions}
+
+ +
{lang_files_in_this_dir}: {files_in_this_dir} {lang_used_space}: {used_space}
+
+ diff --git a/filemanager/templates/default/images/button_bookmark.png b/filemanager/templates/default/images/button_bookmark.png new file mode 100644 index 0000000000..ced954c97f Binary files /dev/null and b/filemanager/templates/default/images/button_bookmark.png differ diff --git a/filemanager/templates/default/images/button_bookmark_add.png b/filemanager/templates/default/images/button_bookmark_add.png new file mode 100644 index 0000000000..ce4fea6004 Binary files /dev/null and b/filemanager/templates/default/images/button_bookmark_add.png differ diff --git a/filemanager/templates/default/images/button_cancel.png b/filemanager/templates/default/images/button_cancel.png new file mode 100644 index 0000000000..96919575af Binary files /dev/null and b/filemanager/templates/default/images/button_cancel.png differ diff --git a/filemanager/templates/default/images/button_copy_to.png b/filemanager/templates/default/images/button_copy_to.png new file mode 100644 index 0000000000..eac4d8c93b Binary files /dev/null and b/filemanager/templates/default/images/button_copy_to.png differ diff --git a/filemanager/templates/default/images/button_createdir.png b/filemanager/templates/default/images/button_createdir.png new file mode 100644 index 0000000000..1277281fcc Binary files /dev/null and b/filemanager/templates/default/images/button_createdir.png differ diff --git a/filemanager/templates/default/images/button_createfile.png b/filemanager/templates/default/images/button_createfile.png new file mode 100644 index 0000000000..cfc3615fec Binary files /dev/null and b/filemanager/templates/default/images/button_createfile.png differ diff --git a/filemanager/templates/default/images/button_cut.png b/filemanager/templates/default/images/button_cut.png new file mode 100644 index 0000000000..192b5757a7 Binary files /dev/null and b/filemanager/templates/default/images/button_cut.png differ diff --git a/filemanager/templates/default/images/button_delete.png b/filemanager/templates/default/images/button_delete.png new file mode 100644 index 0000000000..6fb193f061 Binary files /dev/null and b/filemanager/templates/default/images/button_delete.png differ diff --git a/filemanager/templates/default/images/button_download.png b/filemanager/templates/default/images/button_download.png new file mode 100644 index 0000000000..4cfd6dd661 Binary files /dev/null and b/filemanager/templates/default/images/button_download.png differ diff --git a/filemanager/templates/default/images/button_edit.png b/filemanager/templates/default/images/button_edit.png new file mode 100644 index 0000000000..ce8b226710 Binary files /dev/null and b/filemanager/templates/default/images/button_edit.png differ diff --git a/filemanager/templates/default/images/button_edit_comments.png b/filemanager/templates/default/images/button_edit_comments.png new file mode 100644 index 0000000000..92a7fd9da1 Binary files /dev/null and b/filemanager/templates/default/images/button_edit_comments.png differ diff --git a/filemanager/templates/default/images/button_edit_preview.png b/filemanager/templates/default/images/button_edit_preview.png new file mode 100644 index 0000000000..54db9af36b Binary files /dev/null and b/filemanager/templates/default/images/button_edit_preview.png differ diff --git a/filemanager/templates/default/images/button_goto.png b/filemanager/templates/default/images/button_goto.png new file mode 100644 index 0000000000..da97aef509 Binary files /dev/null and b/filemanager/templates/default/images/button_goto.png differ diff --git a/filemanager/templates/default/images/button_home.png b/filemanager/templates/default/images/button_home.png new file mode 100644 index 0000000000..3afa803379 Binary files /dev/null and b/filemanager/templates/default/images/button_home.png differ diff --git a/filemanager/templates/default/images/button_info.png b/filemanager/templates/default/images/button_info.png new file mode 100644 index 0000000000..3626ba7ee6 Binary files /dev/null and b/filemanager/templates/default/images/button_info.png differ diff --git a/filemanager/templates/default/images/button_mail.png b/filemanager/templates/default/images/button_mail.png new file mode 100644 index 0000000000..384cbf34e9 Binary files /dev/null and b/filemanager/templates/default/images/button_mail.png differ diff --git a/filemanager/templates/default/images/button_move_to.png b/filemanager/templates/default/images/button_move_to.png new file mode 100644 index 0000000000..ba4fa6aecf Binary files /dev/null and b/filemanager/templates/default/images/button_move_to.png differ diff --git a/filemanager/templates/default/images/button_ok.png b/filemanager/templates/default/images/button_ok.png new file mode 100644 index 0000000000..31c064ba92 Binary files /dev/null and b/filemanager/templates/default/images/button_ok.png differ diff --git a/filemanager/templates/default/images/button_paste.png b/filemanager/templates/default/images/button_paste.png new file mode 100644 index 0000000000..b8454f91da Binary files /dev/null and b/filemanager/templates/default/images/button_paste.png differ diff --git a/filemanager/templates/default/images/button_reload.png b/filemanager/templates/default/images/button_reload.png new file mode 100644 index 0000000000..9b80d879c7 Binary files /dev/null and b/filemanager/templates/default/images/button_reload.png differ diff --git a/filemanager/templates/default/images/button_rename.png b/filemanager/templates/default/images/button_rename.png new file mode 100644 index 0000000000..4d2a11e04c Binary files /dev/null and b/filemanager/templates/default/images/button_rename.png differ diff --git a/filemanager/templates/default/images/button_save.png b/filemanager/templates/default/images/button_save.png new file mode 100644 index 0000000000..943719aef4 Binary files /dev/null and b/filemanager/templates/default/images/button_save.png differ diff --git a/filemanager/templates/default/images/button_search.png b/filemanager/templates/default/images/button_search.png new file mode 100644 index 0000000000..da3da6d625 Binary files /dev/null and b/filemanager/templates/default/images/button_search.png differ diff --git a/filemanager/templates/default/images/button_search2.png b/filemanager/templates/default/images/button_search2.png new file mode 100644 index 0000000000..40762a0250 Binary files /dev/null and b/filemanager/templates/default/images/button_search2.png differ diff --git a/filemanager/templates/default/images/button_trash.png b/filemanager/templates/default/images/button_trash.png new file mode 100644 index 0000000000..7b7b610e2e Binary files /dev/null and b/filemanager/templates/default/images/button_trash.png differ diff --git a/filemanager/templates/default/images/button_tree.png b/filemanager/templates/default/images/button_tree.png new file mode 100644 index 0000000000..ddf73f5f6e Binary files /dev/null and b/filemanager/templates/default/images/button_tree.png differ diff --git a/filemanager/templates/default/images/button_up.png b/filemanager/templates/default/images/button_up.png new file mode 100644 index 0000000000..8ec228df6b Binary files /dev/null and b/filemanager/templates/default/images/button_up.png differ diff --git a/filemanager/templates/default/images/button_upload.png b/filemanager/templates/default/images/button_upload.png new file mode 100644 index 0000000000..8cd8eb4ef0 Binary files /dev/null and b/filemanager/templates/default/images/button_upload.png differ diff --git a/filemanager/templates/default/images/button_zip.png b/filemanager/templates/default/images/button_zip.png new file mode 100644 index 0000000000..741b05ffd7 Binary files /dev/null and b/filemanager/templates/default/images/button_zip.png differ diff --git a/filemanager/templates/default/images/editcopy.png b/filemanager/templates/default/images/editcopy.png new file mode 100644 index 0000000000..eac4d8c93b Binary files /dev/null and b/filemanager/templates/default/images/editcopy.png differ diff --git a/filemanager/templates/default/images/editcut.png b/filemanager/templates/default/images/editcut.png new file mode 100644 index 0000000000..192b5757a7 Binary files /dev/null and b/filemanager/templates/default/images/editcut.png differ diff --git a/filemanager/templates/default/images/editpaste.png b/filemanager/templates/default/images/editpaste.png new file mode 100644 index 0000000000..b8454f91da Binary files /dev/null and b/filemanager/templates/default/images/editpaste.png differ diff --git a/filemanager/templates/default/images/mime16_directory.png b/filemanager/templates/default/images/mime16_directory.png new file mode 100644 index 0000000000..4b545f3e34 Binary files /dev/null and b/filemanager/templates/default/images/mime16_directory.png differ diff --git a/filemanager/templates/default/images/mime16_text_plain.png b/filemanager/templates/default/images/mime16_text_plain.png new file mode 100644 index 0000000000..91772c15e9 Binary files /dev/null and b/filemanager/templates/default/images/mime16_text_plain.png differ diff --git a/filemanager/templates/default/images/mime16_unknown.png b/filemanager/templates/default/images/mime16_unknown.png new file mode 100644 index 0000000000..f68776b977 Binary files /dev/null and b/filemanager/templates/default/images/mime16_unknown.png differ diff --git a/filemanager/templates/default/images/source/buttonbackground.xcf b/filemanager/templates/default/images/source/buttonbackground.xcf new file mode 100644 index 0000000000..f894ba087b Binary files /dev/null and b/filemanager/templates/default/images/source/buttonbackground.xcf differ diff --git a/filemanager/templates/default/images/spacer.gif b/filemanager/templates/default/images/spacer.gif new file mode 100755 index 0000000000..5bfd67a2d6 Binary files /dev/null and b/filemanager/templates/default/images/spacer.gif differ diff --git a/filemanager/templates/default/pref.tpl b/filemanager/templates/default/pref.tpl index 34b48b1c9d..8aaac4eb1d 100755 --- a/filemanager/templates/default/pref.tpl +++ b/filemanager/templates/default/pref.tpl @@ -1,6 +1,6 @@

{title}:


- +
{row}
diff --git a/filemanager/templates/default/pref_list.tpl b/filemanager/templates/default/pref_list.tpl index e8542cfbd1..ab84162c0e 100755 --- a/filemanager/templates/default/pref_list.tpl +++ b/filemanager/templates/default/pref_list.tpl @@ -1,5 +1,5 @@ {field} - {data} + {data} diff --git a/filemanager/templates/default/upload.tpl b/filemanager/templates/default/upload.tpl new file mode 100644 index 0000000000..deb3d65a3f --- /dev/null +++ b/filemanager/templates/default/upload.tpl @@ -0,0 +1,30 @@ + + +
+ + + + + + + + + + + + + + + + + +
{lang_file}{lang_comment}
+ + + + +
+{change_upload_boxes} +
+
+ diff --git a/filemanager/todo b/filemanager/todo index d8a098f4ef..5c94c19bd5 100644 --- a/filemanager/todo +++ b/filemanager/todo @@ -1,23 +1,13 @@ -architectuur -- let filemanager use templates -- drop the f...g html_functions_file!!! -- port it to egroupware for real!!! Someone forgot to finish his job - display -- clean file display table -- header in separate color -- icons for filetypes - practical out of the box userconfiguration -- replace all icons with crystal - seperate colors for row off an on -- make one statusrow with all main info like free space -- make alignments cleaner -- clean up conf screen -- upload section separated and in a clean table design -- per row buttons with edit/delete..etc - sort by with sort arrows so we know whats sorted - sidebox with basic featurelinks +- sort by up and down +- nicer colheads +- toolbar cleanup +- toolbar prefs extra funtionality - sharing file with others @@ -26,9 +16,14 @@ extra funtionality - not just presume a file is treated like a ascii file - cut/copy/paste - sidebox with explorerstyle (Reiner loves this) +- other views (with image preview mode?!!) +- download +- new popup +- zip remove functionaliteit -- execute command - some conf options - +bugs +- errors with errorreporting 8 +- errors with uploading thouh it works