From 8b614db835c6aaf9a9ea12f03dd23ce320e890b5 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 15 Dec 2001 04:24:37 +0000 Subject: [PATCH] Start of new 3-tier layout of the filemanager. Not fully coded, but a small preview. --- filemanager/inc/class.bophpwebhosting.inc.php | 477 ++++++++++++++++ filemanager/inc/class.sophpwebhosting.inc.php | 34 ++ filemanager/inc/class.uiphpwebhosting.inc.php | 518 ++++++++++++++++++ filemanager/templates/default/errors.tpl | 6 + .../templates/default/images/folder.gif | Bin 0 -> 1090 bytes .../templates/default/images/folder_home.gif | Bin 0 -> 1097 bytes .../templates/default/images/folder_open.gif | Bin 0 -> 1111 bytes .../templates/default/images/folder_up.gif | Bin 0 -> 1087 bytes .../templates/default/images/locked.gif | Bin 0 -> 348 bytes filemanager/templates/default/index.tpl | 40 ++ phpgwapi/inc/class.vfs_sql.inc.php | 147 ++++- 11 files changed, 1212 insertions(+), 10 deletions(-) create mode 100755 filemanager/inc/class.bophpwebhosting.inc.php create mode 100755 filemanager/inc/class.sophpwebhosting.inc.php create mode 100755 filemanager/inc/class.uiphpwebhosting.inc.php create mode 100755 filemanager/templates/default/errors.tpl create mode 100755 filemanager/templates/default/images/folder.gif create mode 100755 filemanager/templates/default/images/folder_home.gif create mode 100755 filemanager/templates/default/images/folder_open.gif create mode 100755 filemanager/templates/default/images/folder_up.gif create mode 100755 filemanager/templates/default/images/locked.gif create mode 100755 filemanager/templates/default/index.tpl diff --git a/filemanager/inc/class.bophpwebhosting.inc.php b/filemanager/inc/class.bophpwebhosting.inc.php new file mode 100755 index 0000000000..d7970970e4 --- /dev/null +++ b/filemanager/inc/class.bophpwebhosting.inc.php @@ -0,0 +1,477 @@ +vfs = CreateObject('phpgwapi.vfs'); + + $to_decode = Array( + /* + Decode + 'var' when 'avar' == 'value' + or + 'var' when 'var' is set + */ + + 'op', + 'path', + 'file', + 'sortby', + 'fileman', + 'messages', + 'help_name', + 'renamefiles', + 'comment_files', + 'show_upload_boxes' + ); + + $c_to_decode = count($to_decode); + for($i=0;$i<$c_to_decode;$i++) +// @reset($GLOBALS['HTTP_GET_VARS']); +// while(list($name,$data) = each($GLOBALS['HTTP_GET_VARS'])) + { + $this->initialize_vars($to_decode[$i]); + } + +// @reset($GLOBALS['HTTP_POST_VARS']); +// while(list($name,$data) = each($GLOBALS['HTTP_POST_VARS'])) +// { +// $this->initialize_vars($name,$data); +// } + + $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.'/'.$this->userinfo['account_lid']; + + if(!defined('NULL')) + { + define('NULL',''); + } + + $this->so = CreateObject('phpwebhosting.sophpwebhosting'); + + $this->file_attributes = Array( + 'name' => 'Filename', + '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.'

' + . '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']; + } + +// $this->load_files(); + + $this->load_help_info(); + } + + 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($var) +// { +// $this->$name = $var; +// } + 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(isset($this->$name) && $var) + 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 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) + { + $rstring = $left.$size.' B  '.$right; + } + else + { + $rstring = $left.round($size/1024).' KB'.$right; + } + return $rstring; +// return($this->eor($rstring,$return)); + } + + ### + # 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.sophpwebhosting.inc.php b/filemanager/inc/class.sophpwebhosting.inc.php new file mode 100755 index 0000000000..f3f5097500 --- /dev/null +++ b/filemanager/inc/class.sophpwebhosting.inc.php @@ -0,0 +1,34 @@ +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.uiphpwebhosting.inc.php b/filemanager/inc/class.uiphpwebhosting.inc.php new file mode 100755 index 0000000000..7b6d252814 --- /dev/null +++ b/filemanager/inc/class.uiphpwebhosting.inc.php @@ -0,0 +1,518 @@ + True, + 'view' => True, + 'view_file' => True + ); + + var $bo; + var $nextmatchs; + var $browser; + var $tempalte_dir; + var $help_info; + + function uiphpwebhosting() + { + $this->bo = CreateObject('phpwebhosting.bophpwebhosting'); + $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); + $this->browser = CreateObject('phpgwapi.browser'); + $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir($GLOBALS['phpgw_info']['flags']['currentapp']); + $this->load_header(); + $this->check_access(); + $this->create_home_dir(); + $this->verify_path(); + $this->update(); + } + + function load_header() + { + if(($this->bo->download && (count($this->bo->fileman) > 0)) || ($this->bo->op == 'view' && $this->bo->file) || ($this->bo->op == 'history' && $this->bo->file) || ($this->bo->op == 'help' && $this->bo->help_name)) + { + } + else + { + unset($GLOBALS['phpgw_info']['flags']['noheader']); + unset($GLOBALS['phpgw_info']['flags']['nonavbar']); + unset($GLOBALS['phpgw_info']['flags']['noappheader']); + unset($GLOBALS['phpgw_info']['flags']['noappfooter']); + $GLOBALS['phpgw']->common->phpgw_header(); + } + } + + function check_access() + { + if($this->bo->path != $this->bo->homedir && $this->bo->path != $this->bo->fakebase && $this->bo->path != '/' && !$this->bo->vfs->acl_check($this->bo->path,Array(RELATIVE_NONE),PHPGW_ACL_READ)) + { + $this->no_access_exists(lang('You do not have access to X',$this->bo->path)); + } + $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; + $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); + } + + function no_access_exists($error_msg) + { + if($this->bo->debug) + { + echo 'DEBUG: ui.no_access_exists: you do not have access to this directory
'."\n"; + } + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_unknowns('remove'); + + $p->set_file( + Array( + '_errors' => 'errors.tpl' + ) + ); + $p->set_block('_errors','error_page','error_page'); + $p->set_block('_errors','ind_error','ind_error'); + + $p->set_var('error',$error_msg); + $p->parse('errors','ind_error',True); + + $p->set_var('error','

Go to your Home directory' + ); + $p->parse('errors','ind_error',True); + $p->pfp('output','error_page'); + $GLOBALS['phpgw']->common->phpgw_exit(); + } + + function create_home_dir() + { + ### + # If their home directory doesn't exist, we create it + # Same for group directories + ### + + if($this->bo->debug) + { + echo 'DEBUG: ui.create_home_dir: PATH = '.$this->bo->path.'
'."\n"; + echo 'DEBUG: ui.create_home_dir: PATH = '.urlencode($this->bo->path).'
'."\n"; + } + + if(($this->bo->path == $this->bo->homedir) && !$this->bo->vfs->file_exists($this->bo->homedir,Array(RELATIVE_NONE))) + { + //$this->bo->vfs->override_acl = 1; + $this->bo->vfs->mkdir($this->bo->homedir,Array(RELATIVE_NONE)); + //$this->bo->vfs->override_acl = 0; + } +// elseif(preg_match("|^".$this->bo->fakebase."\/(.*)$|U",$this->bo->path,$this->bo->matches)) +// { +// if (!$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE))) +// { +// //$this->bo->vfs->override_acl = 1; +// $this->bo->vfs->mkdir($this->bo->path,Array(RELATIVE_NONE)); +// //$this->bo->vfs->override_acl = 0; +// +// if($this->bo->debug) +// { +// echo 'DEBUG: ui.create_home_dir: PATH = '.$this->bo->path.'
'."\n"; +// echo 'DEBUG: ui.create_home_dir(): matches[1] = '.$this->bo->matches[1].'
'."\n"; +// } +// +// $group_id = $GLOBALS['phpgw']->accounts->name2id($this->bo->matches[1]); +// if($group_id) +// { +// $this->bo->vfs->set_attributes($this->bo->path,Array(RELATIVE_NONE),Array('owner_id' => $group_id, 'createdby_id' => $group_id)); +// } +// } +// } + } + + function verify_path() + { + ### + # Verify path is real + ### + + if($this->bo->debug) + { + echo 'DEBUG: ui.verify_path: PATH = '.$this->bo->path.'
'."\n"; + echo 'DEBUG: ui.verify_path: exists = '.$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE)).'
'."\n"; + } + + if($this->bo->path != $this->bo->homedir && + $this->bo->path != '/' && + $this->bo->path != $this->bo->fakebase && + !$this->bo->vfs->file_exists($this->bo->path,Array(RELATIVE_NONE))) + { + $this->no_access_exists(lang('Directory '.$this->bo->path.' does not exist')); + } + } + + function update() + { + /* Update if they request it, or one out of 20 page loads */ + srand ((double) microtime() * 1000000); + if($this->bo->update || rand(0, 19) == 4) + { + $this->bo->vfs->update_real($this->bo->path,Array(RELATIVE_NONE)); + } + if($this->bo->update) + { + // This needs to redirect to the index after the user issues an update..... + } + } + + function build_help($help_option) + { + if($this->bo->settings['show_help']) + { + return ''."\n" + . ' [?]'."\n" + . ' '; + } + else + { + return ''; + } + } + + function image($image,$alt) + { + return ''.$alt.''; + } + + function link($array_params,$text) + { + return ''.$text.''; + } + + function column_header($internal,$displayed,$link=True) + { + if($link) + { + $header_str = ''.lang($displayed).''.$this->build_help(ereg_replace(' ','_',$displayed)); + } + else + { + $header_str = $displayed.$this->build_help(ereg_replace(' ','_',$displayed)); + } + return Array( + 'td_extras' => '', + 'column_header' => $header_str + ); + } + + function index() + { + $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_rows','column_rows'); + + $tr = $this->nextmatchs->alternate_row_color($tr); + $p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"'); + $var = Array( + 'img_up' => $this->link(Array( + 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', + 'path' => $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'), + ); + $p->set_var($var); + + $p->set_var($this->column_header('','Sort By:',False)); + $p->parse('col_headers','column_headers',True); + + $columns = 1; + reset($this->bo->file_attributes); + while(list($internal,$displayed) = each($this->bo->file_attributes)) + { + if ($this->bo->settings[$internal]) + { + $p->set_var($this->column_header($internal,$displayed,True)); + $p->parse('col_headers','column_headers',True); + $columns++; + } + } + $tr = $this->nextmatchs->alternate_row_color($tr); + $p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"'); + $p->parse('col_row','column_rows',True); + + $p->set_var('colspan',$columns); + + if($this->bo->settings['dotdot'] && $this->bo->settings['name'] && $this->bo->path != '/') + { + $var = Array( + 'col_headers' => '', + 'td_extras' => '', + 'column_header' => ' ' + ); + $p->set_var($var); + $p->parse('col_headers','column_headers',True); + + $var = Array( + 'td_extras' => '', + 'column_header' => $this->image('folder.gif','folder') + .$this->link( + Array( + 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', + 'path' => $this->bo->lesspath + ), + '..' + ) + ); + $p->set_var($var); + $p->parse('col_headers','column_headers',True); + + $loop_cntr = 2; + + if($this->bo->settings['mime_type']) + { + $var = Array( + 'td_extras' => '', + 'column_header' => 'Directory' + ); + $loop_cntr++; + } + $p->set_var($var); + $p->parse('col_headers','column_headers',True); + + $var = Array( + 'td_extras' => '', + 'column_header' => ' ' + ); + for($i=$loop_cntr;$i<$columns;$i++) + { + $p->set_var($var); + $p->parse('col_headers','column_headers',True); + } + $tr = $this->nextmatchs->alternate_row_color($tr); + $p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"'); + $p->parse('col_row','column_rows',True); + $p->set_var('col_headers',''); + } + + reset($files_array); + $numoffiles = count($files_array); + for($i=0;$i!=$numoffiles;$i++) + { + $files = $files_array[$i]; + $var = Array( + 'td_extras' => '', + 'column_header' => '' + ); + $p->set_var($var); + $p->parse('col_headers','column_headers'); + + 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.$this->bo->dispsep.$files['name'] + ), + ''.$files['name'].'' + ); + break; + default: + $var['column_header'] = $this->link( + Array( + 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view', +// 'op' => 'view', + 'path' => urlencode($this->bo->path), + 'file' => urlencode($files['name']) + ), + ''.$files['name'].'' + ); +// $var['column_header'] = ''.$files['name'].''; + break; + } + 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': + if($files[$internal] && $files[$internal] != '0000-00-00') + { + $year = substr($files[$internal],0,4); + $month = substr($files[$internal],5,2); + $day = substr($files[$internal],8,2); +// echo $files['name'].' : '.$internal.' : '.$year.'.'.$month.'.'.$day.'
'."\n"; + $datetime = mktime(0,0,0,$month,$day,$year); + $var['column_header'] = date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$datetime); + } + else + { + $var['column_header'] = ' '; + } + 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; + } + $p->set_var($var); + $p->parse('col_headers','column_headers',True); + } + } + $tr = $this->nextmatchs->alternate_row_color($tr); + $p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"'); + $p->parse('col_row','column_rows',True); + $p->set_var('col_headers',''); + } + + + $p->pfp('output','index'); + } + } + + function view() + { + + 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 view_file() + { + $file = $this->bo->path.$this->bo->dispsep.$this->bo->file; + if($this->bo->vfs->file_exists($file,Array(RELATIVE_NONE))) + { + Header('Content-length: '.$this->bo->vfs->get_size($file,Array(RELATIVE_NONE))); + Header('Content-type: '.$this->bo->vfs->file_type($file,Array(RELATIVE_NONE))); + Header('Content-disposition: attachment; filename="'.$this->bo->file.'"'); + echo $this->bo->vfs->read($file,Array(RELATIVE_ALL)); + flush(); + } + + $GLOBALS['phpgw']->common->phpgw_exit (); + } + } diff --git a/filemanager/templates/default/errors.tpl b/filemanager/templates/default/errors.tpl new file mode 100755 index 0000000000..976ab6435f --- /dev/null +++ b/filemanager/templates/default/errors.tpl @@ -0,0 +1,6 @@ + +{errors} + + +{error} + diff --git a/filemanager/templates/default/images/folder.gif b/filemanager/templates/default/images/folder.gif new file mode 100755 index 0000000000000000000000000000000000000000..89d4c1f1938af2206da1d06ab88059c58d56f9f6 GIT binary patch literal 1090 zcmZ?wbhEHb6k!lyc+SA!ZlfLMVI1yd)=&_$d1C6Jc{#Hiqx0ij^7HbyZrZSDYR9?> z`TJ+(?wXM~u_CxO!>zu);r;vfckkX^I=yRYXV%WCX&ZW@7q>@Gsf}JaId^e?R(EA| zLqpTIZ{L3W`0?h=o9oxFuV1xvT6=jV&Qt^%=FXcGcB2@7}%p^y$;{=g%KLe0clz?Q7SrojrT@=+UG5_wV1aW5?2^OD46H z7lhhYR8+ov`SQ`DN9WF+J9g~Y;lqay95}FZ=g#HJmrrV~%n!9KEiJou@7|3YH!fek zeCEuVUAuN|-@bk0#*Opm&+lz4%?q)~&o8`m>C%=hTQ+Riuxiz+S+iz!*A?XkTgS&I zY}&Nx^y$+lPoCVjZ{OOrYgevZxp?v7Y15{4))ZuBX12GtFIcc}+qP}XmMvSdWXYsS zliI8E6BCnGtXQ#d;ljSYzP8HTh=|CdqN3*J=9x2RPMCd2GS|aM-p|iJDJi+O zwr;|N3Ekb@M#|zYF0L^#u~k)7O-)U$6*(F*!mKQ;OiV2H_71_pA!*Tp(Jlr`5(4tl z5{i;S|3@BB{K>+|#qgg&hXDvcd4hrCAH#o676FHb1I--5axxAJ8XB3ol>a$Ta5%`s z#w%kpp+mrlg_Bb)U`4`1rZyfaGnXe94jyI~P;}{02t0IzQ$#aFCFbCw)^2fwq!Tk7 z7q|6FTNJ6ZTv*u3E^A%!<-CcV}!~+3VrQv(MmYfA?duVXQnad#RCr}x}B9WE4jU+l3BfPPD}9>lV!|1 z^JJ~dKRmfOxqyGZcI}^zpOc^RE^ugK6I7bJVZuV^noSB!b3Fv-xb|dd=X^<-pyb{q zckm#y=A;iDlhguNg>d#S^`7x1<&j3fWi`LKVhWX~{&oI#3|Q#WtF(0al$F8HSQmLM S%@WlP{wTPusMJ7#!5RQWW}+eh literal 0 HcmV?d00001 diff --git a/filemanager/templates/default/images/folder_home.gif b/filemanager/templates/default/images/folder_home.gif new file mode 100755 index 0000000000000000000000000000000000000000..843874f7224c4475df1975cbb084891ca4400774 GIT binary patch literal 1097 zcmZ?wbhEHb6k!lyc+S9(7-Zw`Y8v6|aDGwjVpU(}ru_*b#%+&9P8~)vz(^eKyQd0Wk$B$2+KD~ec{?)5j2M+9= z(AiQF>roYLTac5P6XkJjPW0`y`9(z~pFe+o@#4j!N008@xpU>pmBWV*x3sjbS+i!| zym`ryK|5;P^YaTne*Ad+_;EL9`^xgNbLY;TIB{a{-o3@eC9BKbb93`PeE1L&5_10h zc|T8=gh1CIH|wgZs)Gj)?%cU^!-fsTC8ev%-LtZ?U%!6+{P}Ye6BBP&`g1hzOiNbDEWrW^z)Zv9YP1u1;KB-2MCa_wU~?BQ4e1+A?FtjEt-5;V|RD=!i5XHyu7AN znZn4(WMgC7+S=ON+nbq{rKzbM6B8R19X%t%PEb%-Ls9_fsu2zpf3h%gG5lxHVE_V9 zo?zhk$MB!?54*yF1I-+QToMio8X8*!{>wT{a5%`s#w){7Bk)nag+oX!U`4`1rZyfa zvw{YWh0g5!@(wKmhD|P#MsjPHv_;X28wVG+ z_scspaXhprIMF5Q5+Pz(#NsKW>OI4x@KERjVWogYH8T`axu$9fuW8uPwDj$MohX%@ zhnJ3?7B}!b)FJ7-tS8<${lb#K&27H3_4Do>=u}?*{-CAXiVG`~pYzSLsrvTe<>TX@ z57;;CV%gNZ+)U1~nZwZVaaDq%bNf35uNJoR(yrYSrbRp#1?Ra>P?DT((s`+9Kl5Ds zRVsgbmwL}wr|x{GNn`Rd-wun?Pa^Xwk2lVDXcaPD^`7~SpyyPh(pUd}x2#xV6yU&M F4FFilnil{7 literal 0 HcmV?d00001 diff --git a/filemanager/templates/default/images/folder_open.gif b/filemanager/templates/default/images/folder_open.gif new file mode 100755 index 0000000000000000000000000000000000000000..c0d8d71ccf3ddffd75667440027694bb786a6126 GIT binary patch literal 1111 zcmcK33sV{d0Kjo{>YSUMo?NH4OJ}#u$8Ke3o3t$O!4SthOF%K-Ad1K_MTbc<1smT~LGV}ui8YHg5 zDC%+D!i>Q>f}9mEpnf4JitDP$Y_H0wEI`BIQKO?{y*=IRVk(7zsV&9mlsV&?d`;J_ zE&;Z)Dpe;TTE;7$nrc@xYz2>yn+8K55GIq!YJIxCwmPWk7YkV2a=coOTbZUVPkpUZ z<}3K=!}Y}FUfL5w^-m*J5@woA*74$v=X-lk=I7_?B|`R{WO-fO>LhV-EWf)sL*0t+ zlV*)Hk}RVYJ=|T8*;$3WmCyOAnwco6PA)CU5?3c_yD|sbvPN6T zP0SP`k$C_9`r+Zhvu9R|W#{3;&84NK5xu@s-p;8kX>631F)30`g0eZKqbj+U8izz8 zr>Cd)_kY{nwLE_OXmiuNx_WPMalvSu8XVO2_p1f`8U`&<$hy(YMDhxdFj%BqF5lkX zGMgW)t*tCAEzHaqCnm;*hO}z6QY7LRr`n&&*644C8vePNV5p zD!-LT>R!jqP6k)!!ti*!PNy>(jdOD|CX?~*-C?bEK&9&I>gtq8B)1E46JsH4LIm#? zf=Vq^C_1%T&Ct-GM)SQ&rIg9q#9~oVVZoP3C<7P9Bf&@{Qh9khpfH5wYj-T zEEdw~#R;hB;uJ8C5SE^frBDjk>{6*zA`%JMY*tDFnw|pT;XlPd{7@(~fk0p|O1NB3 zSy?G53s;#H$;Dm^3Gjr&;Ymq}RO)RqF^h$dVqk(Ud%4-$+1uLMg@;GP+>9b4!6bOV z1y7et=RDr`0v`X*&K=p=I023UmjJK5c>>`03UGYtpOfBWV+==ECwFkmH*}_p{kvc; zc-+>(*~f|UJ0R5Vl$&p?ifj|+;QUUow{`2$i82=-DAzZ2+pYrWk5Xj@E>E3y55&&5 z#2AduXF(L})(?j1aW8O*qerN$jQ1X_);E4aR?cTcw}jJua85#hRA0(W8}79D@<~0- z#tk~}{vmF@0m6qacwWhQYq;>lMNR{VvbQnBxLDH^LVJ1k@XzaKTEHa^uKw6vm$vYV zw*x~rOs+eS8t;hOpz_bpM~R_clY+>57jCjXE_`X{FHpqD;OB$>`UTh>+l`{9ti6uKfp`&0_%o literal 0 HcmV?d00001 diff --git a/filemanager/templates/default/images/folder_up.gif b/filemanager/templates/default/images/folder_up.gif new file mode 100755 index 0000000000000000000000000000000000000000..e8eb8b06e7edc3a7f0c8c1b38fc50a6ebcf7cfe9 GIT binary patch literal 1087 zcmZ?wbhEHb6k!lyc+S9(7-Zw`Y8v6|aDGS5^SJ>x79}5;nfm>3!@pZ|+R7qIN=kqH_|etXwRY{=6DLk2B_(#Y zHkHJBR7KksA>*dX|@$A2@KJsi`S9H&<0vwZFfA@7}$|#U-oD z-E(vEK79DFV#SKZix+EXXc!n6L`O&O+_`hZh7H9frK`%_v$C?EKYxDr?p-r8vk4O> z?B2b5$BrGFHf>tIe0g4eL3(<|qeqYK-@kw3#tjn_lfJ&b&6_u`UcGwJqD5Ibxsj1k zhYugVa^=dUOP7p{jCy){R;^mKWXTe1Yn#T#rY&2x=g6BOV6J_KO-y4!on&o zEv>V&bHRcI3l}b&J$v?~Ns|l>jdF5wX3d&4ZQ3+VO|8Ph!YNax#Ky+8wzl^6_GV^f zX=-Z6#KcBLN6*Nx6BHEIkQDeo3Q$8p@h1x-7sG!B9R?r(UQ|FA0@IMB=? z$R**hprNrv;J>WH1c!r6Y`iiYH3A>yTR4Q&0#+nEWNPD)GAn4{Sm?~oFYnMIVA$ls zDXiwVz+uLsW-d|fh%E&lncR3JjWez|WF)tCNm~@XxN&fCd%wIx6URe~f)iXyu01l2 zlUz;;srk;aX*?8~Afg$(B4lIIQ?6+`QQI0GTw40pUO)aoi=cBkkEBuPsTr2d$MR<> zXIyy(j5y?YtMLu*|35L^ktQ-k#kK fUb8JqKVA9W_@!gML#xo!dp3sxm$0$1FjxZs`uUZ~ literal 0 HcmV?d00001 diff --git a/filemanager/templates/default/images/locked.gif b/filemanager/templates/default/images/locked.gif new file mode 100755 index 0000000000000000000000000000000000000000..aa4cbbe65b70252cd9f8e7d22963c30f24e8d66a GIT binary patch literal 348 zcmZ?wbhEHbFwI=kJA;ZR?g5u3Wit+N5b4Hf*S`ufMdVr?Rqg z|DpXsK|y^J`&O-5rSI>rp<|$}t=-pF85$b8Z`Z!I$~Fflhh@u_fgFbc6o0ZXaxvI5 z=r8~Q$WIJxl?Ub*XsC$ruqzn`2IxreE`7|{>7h2oX{pnn1|B{yRTHj>9jXCoy#}QL znv1wxw)b%TI8+dNYKn=djv}{)8neBqs;-{CfnmR)k(jo{uGVIDWUvMRh;Ew< literal 0 HcmV?d00001 diff --git a/filemanager/templates/default/index.tpl b/filemanager/templates/default/index.tpl new file mode 100755 index 0000000000..2edd7b40a4 --- /dev/null +++ b/filemanager/templates/default/index.tpl @@ -0,0 +1,40 @@ + + + + + + {col_row} + + + +
+ + + + + +
+ {img_up} + {help_up} + + {img_home} + {dir} + {help_home} +
+ +
+ + + {buttons} +
+
+ + + + {col_headers} + + + + {column_header} + + diff --git a/phpgwapi/inc/class.vfs_sql.inc.php b/phpgwapi/inc/class.vfs_sql.inc.php index e39bbee6a8..f6d3fc074b 100644 --- a/phpgwapi/inc/class.vfs_sql.inc.php +++ b/phpgwapi/inc/class.vfs_sql.inc.php @@ -104,8 +104,8 @@ $this->working_id = $GLOBALS['phpgw_info']['user']['account_id']; $this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id); $this->now = date ('Y-m-d'); -// $this->override_acl = 0; - $this->override_acl = 1; + $this->override_acl = 0; +// $this->override_acl = 1; /* File/dir attributes, each corresponding to a database field. Useful for use in loops @@ -116,10 +116,22 @@ */ $this->attributes = array( - 'file_id', 'owner_id', 'createdby_id', 'modifiedby_id', - 'created', 'modified', 'size', 'mime_type', 'deleteable', - 'comment', 'app', 'directory', 'name', - 'link_directory', 'link_name', 'version' + 'file_id', + 'owner_id', + 'createdby_id', + 'modifiedby_id', + 'created', + 'modified', + 'size', + 'mime_type', + 'deleteable', + 'comment', + 'app', + 'directory', + 'name', + 'link_directory', + 'link_name', + 'version' ); /* @@ -648,6 +660,8 @@ */ function path_parts ($string, $relatives = '', $object = True, $nolinks = False) { + static $p_path_parts = Array(); + if (!is_array ($relatives)) { $relatives = array (RELATIVE_CURRENT); @@ -670,6 +684,11 @@ $string = $this->getabsolutepath ($string, array ($relatives[0]), $fake); + if($p_path_parts[$string][$rarray['mask']]) + { + return $p_path_parts[$string][$rarray['mask']]; + } + if ($fake) { $base_sep = '/'; @@ -706,7 +725,7 @@ if ($fake) { - $rarray['real_extra_path'] ? $dispsep = $sep : $dispsep = ''; + $dispsep = ($rarray['real_extra_path'] ? $sep : ''); $rarray['real_full_path'] = $opp_base . $rarray['real_extra_path'] . $dispsep . $rarray['real_name']; if ($extra_path) { @@ -796,10 +815,12 @@ if ($object) { + $p_path_parts[$string][$rarray['mask']] = $robject; return ($robject); } else { + $p_path_parts[$string][$rarray['mask']] = $rarray; return ($rarray); } } @@ -1896,7 +1917,7 @@ { $sql = "INSERT INTO phpgw_vfs($sql_fields) VALUES ($sql_vals)"; } - $query = ($sql?$GLOBALS['phpgw']->db->query ($sql, __LINE__, __FILE__):False); + $query = ($sql?$GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__):False); if ($query) { @@ -1951,6 +1972,46 @@ } } + function get_mime_type($file) + { + static $mimetype = Array(); + + $file=basename($file); + $mimefile=PHPGW_API_INC.'/phpgw_mime.types'; + $fp=fopen($mimefile,'r'); + $contents = explode("\n",fread($fp,filesize($mimefile))); + fclose($fp); + + $parts=explode('.',$file); + $ext=$parts[(sizeof($parts)-1)]; + + if(isset($mimetype[$ext])) + { + return $mimetype[$ext]; + } + + for($i=0;$i= 2) + { + for($j=1;$jdb->query ("SELECT mime_type FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); $GLOBALS['phpgw']->db->next_record (); $mime_type = $GLOBALS['phpgw']->db->Record['mime_type']; - - return ($mime_type); + if(!$mime_type) + { + $mime_type = $this->get_mime_type($file); + if($mime_type) + { + $query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='".$mime_type."' WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + } + } + return $mime_type; } /*! @@ -2005,6 +2073,8 @@ */ function file_exists ($string, $relatives = '') { + static $fexists = Array(); + if (!is_array ($relatives)) { $relatives = array (RELATIVE_CURRENT); @@ -2017,14 +2087,21 @@ return file_exists ($p->real_full_path); } + if(isset($fexists[$p->real_full_path])) + { + return $fexists[$p->real_full_path]; + } + $query = $GLOBALS['phpgw']->db->query ("SELECT name FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); if ($GLOBALS['phpgw']->db->num_rows()) { + $fexists[$p->real_full_path] = True; return True; } else { + $fexists[$p->real_full_path] = False; return False; } } @@ -2088,6 +2165,32 @@ return $size; } + function get_version($file, $relatives = '') + { + static $fversion = Array(); + + if (!is_array ($relatives)) + { + $relatives = array (RELATIVE_CURRENT); + } + + $p = $this->path_parts ($file, array ($relatives[0])); + + if($fversion[$p->real_full_path]) + { + return $fversion[$p->real_full_path]; + } + + $query = $GLOBALS['phpgw']->db->query ("SELECT version FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + + if ($GLOBALS['phpgw']->db->num_rows()) + { + $GLOBALS['phpgw']->db->next_record (); + $fversion[$p->real_full_path] = $GLOBALS['phpgw']->db->Record['version']; + return $fversion[$p->real_full_path]; + } + } + /*! @function checkperms @abstract Check if $this->working_id has write access to create files in $dir @@ -2170,6 +2273,14 @@ reset ($this->attributes); while (list ($num, $attribute) = each ($this->attributes)) { + if($attribute == 'mime_type' && !$record[$attribute]) + { + $record[$attribute] = $this->get_mime_type($p->fake_name_clean); + if($record[$attribute]) + { + $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='".$record[$attribute]."' WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + } + } $rarray[0][$attribute] = $record[$attribute]; } @@ -2249,6 +2360,14 @@ reset ($this->attributes); while (list ($num, $attribute) = each ($this->attributes)) { + if($attribute == 'mime_type' && !$record[$attribute]) + { + $record[$attribute] = $this->get_mime_type($p->real_full_path . SEP . $filename); + if($record[$attribute]) + { + $query = $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='".$record[$attribute]."' WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + } + } $rarray[$i][$attribute] = $record[$attribute]; } } @@ -2439,6 +2558,14 @@ { $mime_type = 'Directory'; } + else + { + $mime_type = $this->get_mime_type($p->fake_name); + if($mime_type) + { + $GLOBALS['phpgw']->db->query ("UPDATE phpgw_vfs SET mime_type='".$mime_type."' WHERE directory='".$p->fake_leading_dirs_clean."' AND name='".$p->fake_name_clean."'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, __FILE__); + } + } $rarray = array( 'directory' => $p->fake_leading_dirs,