1) phpgw --> egw

2) fixed problem I came across while debuging: $p->fake_full_name --> $p->fake_full_path
3) some improvement dont set empty mime_type
This commit is contained in:
Ralf Becker 2005-07-22 17:59:09 +00:00
parent 7b1229e29a
commit 5cbbbb7d29
3 changed files with 994 additions and 1040 deletions

View File

@ -1,31 +1,31 @@
<?php
/**************************************************************************\
* eGroupWare API - VFS base class *
* This file written by Jason Wies (Zone) <zone@phpgroupware.org> *
* This class handles file/dir access for eGroupWare *
* Copyright (C) 2001 Jason Wies *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* http://www.egroupware.org/api *
* ------------------------------------------------------------------------ *
* 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 *
\**************************************************************************/
/**************************************************************************\
* eGroupWare API - VFS base class *
* This file written by Jason Wies (Zone) <zone@phpgroupware.org> *
* This class handles file/dir access for eGroupWare *
* Copyright (C) 2001 Jason Wies *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* http://www.egroupware.org/api *
* ------------------------------------------------------------------------ *
* 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$ */
/* $Id$ */
if (empty ($GLOBALS['phpgw_info']['server']['file_repository']))
if (empty ($GLOBALS['egw_info']['server']['file_repository']))
{
$GLOBALS['phpgw_info']['server']['file_repository'] = 'sql';
$GLOBALS['egw_info']['server']['file_repository'] = 'sql';
}
/* Relative defines. Used mainly by getabsolutepath () */
@ -47,10 +47,10 @@
define ('VFS_OPERATION_MOVED', 16);
define ('VFS_OPERATION_DELETED', 32);
/*!
* @class path_class
* @abstract helper class for path_parts
*/
/**
* * helper class for path_parts
* *
*/
class path_class
{
var $mask;
@ -73,11 +73,11 @@
var $real_name_clean;
}
/*!
* @class vfs_shared
* @abstract Base class for Virtual File System classes
* @author Zone
*/
/**
* * Base class for Virtual File System classes
* *
* * @author Zone
*/
class vfs_shared
{
/*
@ -142,12 +142,12 @@
'version', /* Version of file. May be 0 */
);
/*!
* @function vfs_shared
* @abstract constructor
* @description All derived classes should call this function in their
/**
* * constructor
* *
* * All derived classes should call this function in their
* constructor ($this->vfs_shared())
*/
*/
function vfs_shared ()
{
}
@ -185,16 +185,16 @@
function add_journal ($data) {}
function flush_journal ($data) {}
/*!
* @function get_journal
* @abstract Get journal entries for a location
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @optional type [0|1|2]
/**
* * Get journal entries for a location
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * type [0|1|2]
* 0 = any journal entries
* 1 = current journal entries
* 2 = deleted journal entries
* @result Array of arrays of journal entries
* * @return Array of arrays of journal entries
* The keys will vary depending on the implementation,
* with most attributes in this->attributes being valid,
* and these keys being mandatory:
@ -203,7 +203,7 @@
* comment - Human readable comment describing the action
* version - May be 0 if the derived class does not support
* versioning
*/
*/
function get_journal ($data) { return array(array()); }
/*
@ -222,24 +222,24 @@
* acl_check() - Check access for a user to a given
*/
/*!
* @function acl_check
* @abstract Check access for a user to a given location
* @discussion If $this->override_acl is set, always return True
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @required operation Operation to check access for. Any combination
* of the PHPGW_ACL_* defines, for example:
* PHPGW_ACL_READ
* PHPGW_ACL_READ|PHPGW_ACL_WRITE
* @optional owner_id phpGW ID to check access for.
* Default: $GLOBALS['phpgw_info']['user']['account_id']
* @optional must_exist If set, string must exist, and acl_check() must
/**
* * Check access for a user to a given location
* *
* * If $this->override_acl is set, always return True
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * operation Operation to check access for. Any combination
* of the EGW_ACL_* defines, for example:
* EGW_ACL_READ
* EGW_ACL_READ|EGW_ACL_WRITE
* * owner_id phpGW ID to check access for.
* * Default: $GLOBALS['egw_info']['user']['account_id']
* * must_exist If set, string must exist, and acl_check() must
* return False if it doesn't. If must_exist isn't
* passed, and string doesn't exist, check the owner_id's
* access to the parent directory, if it exists.
* @result Boolean. True if access is ok, False otherwise.
*/
* * @return Boolean. True if access is ok, False otherwise.
*/
function acl_check ($data) { return True; }
/*
@ -267,26 +267,26 @@
* mkdir - Create directory
*/
/*!
* @function read
* @abstract Retreive file contents
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result String. Contents of 'string', or False on error.
*/
/**
* * Retreive file contents
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return String. Contents of 'string', or False on error.
*/
function read ($data) { return False; }
/*!
@function view
@abstract Views the specified file (does not return!)
@param string filename
@param relatives Relativity array
@result None (doesnt return)
@discussion By default this function just reads the file and
outputs it too the browser, after setting the content-type header
appropriately. For some other VFS implementations though, there
may be some more sensible way of viewing the file.
*/
/**
* Views the specified file (does not return!)
*
* @param string filename
* @param relatives Relativity array
* @return None (doesnt return)
* By default this function just reads the file and
* outputs it too the browser, after setting the content-type header
* appropriately. For some other VFS implementations though, there
* may be some more sensible way of viewing the file.
*/
function view($data)
{
@ -296,10 +296,10 @@
);
$data = array_merge ($this->default_values ($data, $default_values), $data);
$GLOBALS['phpgw_info']['flags']['noheader'] = true;
$GLOBALS['phpgw_info']['flags']['nonavbar'] = true;
$GLOBALS['phpgw_info']['flags']['noappheader'] = true;
$GLOBALS['phpgw_info']['flags']['noappfooter'] = true;
$GLOBALS['egw_info']['flags']['noheader'] = true;
$GLOBALS['egw_info']['flags']['nonavbar'] = true;
$GLOBALS['egw_info']['flags']['noappheader'] = true;
$GLOBALS['egw_info']['flags']['noappfooter'] = true;
$ls_array = $this->ls (array (
'string' => $data['string'],
'relatives' => $data['relatives'],
@ -326,62 +326,62 @@
exit();
}
/*!
* @function write
* @abstract Store file contents
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Store file contents
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function write ($data) { return False; }
/*!
* @function touch
* @abstract Create a file if it doesn't exist.
/**
* * Create a file if it doesn't exist.
* *
* Optionally, update the modified time and
* modified user if the file exists.
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function touch ($data) { return False; }
/*!
* @function cp
* @abstract Copy location
* @required from Path to location to copy from
* @required to Path to location to copy to
* @optional relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Copy location
* *
* * from Path to location to copy from
* * to Path to location to copy to
* * relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function cp ($data) { return False; }
/*!
* @function mv
* @abstract Move location
* @required from Path to location to move from
* @required to Path to location to move to
* @optional relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Move location
* *
* * from Path to location to move from
* * to Path to location to move to
* * relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function mv ($data) { return False; }
/*!
* @function rm
* @abstract Delete location
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Delete location
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function rm ($data) { return False; }
/*!
* @function mkdir
* @abstract Create directory
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Create directory
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function mkdir ($data) { return False; }
/*
@ -401,56 +401,56 @@
* ls - Return detailed information for location(s)
*/
/*!
* @function set_attributes
* @abstract Set attributes for a location
* @discussion Valid attributes are listed in vfs->attributes,
/**
* * Set attributes for a location
* *
* * Valid attributes are listed in vfs->attributes,
* which may be extended by each derived class
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @optional attributes Keyed array of attributes. Key is attribute
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * attributes Keyed array of attributes. Key is attribute
* name, value is attribute value.
* @result Boolean. True on success, False otherwise.
*/
* * @return Boolean. True on success, False otherwise.
*/
function set_attributes ($data) { return False; }
/*!
* @function file_exists
* @abstract Check if a location (file or directory) exists
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True if file exists, False otherwise.
*/
/**
* * Check if a location (file or directory) exists
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True if file exists, False otherwise.
*/
function file_exists ($data) { return False; }
/*!
* @function get_size
* @abstract Determine size of location
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @optional checksubdirs Boolean. If set, include the size of
/**
* * Determine size of location
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * checksubdirs Boolean. If set, include the size of
* all subdirectories recursively.
* @result Integer. Size of location in bytes.
*/
* * @return Integer. Size of location in bytes.
*/
function get_size ($data) { return 0; }
/*!
* @function ls
* @abstract Return detailed information for location(s)
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @optional checksubdirs Boolean. If set, return information for all
/**
* * Return detailed information for location(s)
* *
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * checksubdirs Boolean. If set, return information for all
* subdirectories recursively.
* @optional mime String. Only return information for locations with MIME type
* * mime String. Only return information for locations with MIME type
* specified. VFS classes must recogize these special types:
* "Directory" - Location is a directory
* " " - Location doesn't not have a MIME type
* @optional nofiles Boolean. If set and 'string' is a directory, return
* * nofiles Boolean. If set and 'string' is a directory, return
* information about the directory, not the files in it.
* @result Array of arrays of file information.
* * @return Array of arrays of file information.
* Keys may vary depending on the implementation, but must include
* at least those attributes listed in $this->attributes.
*/
*/
function ls ($data) { return array(array()); }
/*
@ -480,14 +480,14 @@
* make_link - Create a real to virtual directory link
*/
/*!
* @function make_link
* @abstract Create a real to virtual directory link
* @required rdir Real directory to make link from/to
* @required vdir Virtual directory to make link to/from
* @optional relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
/**
* * Create a real to virtual directory link
* *
* * rdir Real directory to make link from/to
* * vdir Virtual directory to make link to/from
* * relatives Relativity array (default: RELATIVE_CURRENT, RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function make_link ($data) { return False; }
/*
@ -503,46 +503,46 @@
* extract - Dearchives a file or set of files of a compressed file
*/
/*!
* @function update_real
* @abstract Ensure that information about a location is up-to-date
* @discussion Some VFS backends store information about locations
/**
* * Ensure that information about a location is up-to-date
* *
* * Some VFS backends store information about locations
* in a secondary location, for example in a database
* or in a cache file. update_real() can be called to
* ensure that the information in the secondary location
* is up-to-date.
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @result Boolean. True on success, False otherwise.
*/
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * @return Boolean. True on success, False otherwise.
*/
function update_real ($data) { return False; }
/*!
* @function compress
* @abstract Creates an archive from a file or a set of files
* @required files File names to be stored in archive (array)
* @required name Name of archive
* @optional type The type of compression, can be 'zip'(default)or 'gz'
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* Note: the last item is the relativity of the dest archive
* @result Boolean. True on success, False otherwise.
*/
/**
* * Creates an archive from a file or a set of files
* *
* * files File names to be stored in archive (array)
* * name Name of archive
* * type The type of compression, can be 'zip'(default)or 'gz'
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * Note: the last item is the relativity of the dest archive
* * @return Boolean. True on success, False otherwise.
*/
function compress ($data) { return False; }
/*!
* @function extract
* @abstract Extracts a file (or files) from archive
* @required name Name of archive
* @required dest The destination path of files to be extracted
* @optional type The type of compression, can be 'zip' or 'gz'. If
* not specified, uses according to the extension
* @optional files Files to be extracted from archive
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* Note: the first item is the relativity of the archive, the last of
* the dest dir
* @result Boolean. True on success, False otherwise.
*/
/**
* * Extracts a file (or files) from archive
* *
* * name Name of archive
* * dest The destination path of files to be extracted
* * type The type of compression, can be 'zip' or 'gz'. If
* * not specified, uses according to the extension
* * files Files to be extracted from archive
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * Note: the first item is the relativity of the archive, the last of
* * the dest dir
* * @return Boolean. True on success, False otherwise.
*/
function extract ($data) { return False; }
@ -610,14 +610,14 @@
/* PRIVATE functions */
/*!
* @function securitycheck
* @abstract Check if location string is ok to use in VFS functions
* @discussion Checks for basic violations such as ..
/**
* * Check if location string is ok to use in VFS functions
* *
* * Checks for basic violations such as ..
* If securitycheck () fails, run your string through $this->sanitize ()
* @required string Path to location
* @result Boolean. True if string is ok, False otherwise.
*/
* * string Path to location
* * @return Boolean. True if string is ok, False otherwise.
*/
function securitycheck ($data)
{
if (!is_array ($data))
@ -635,17 +635,17 @@
}
}
/*!
* @function sanitize
* @abstract Remove any possible security problems from a location
/**
* * Remove any possible security problems from a location
* *
* string (i.e. remove leading '..')
* @discussion You should not pass all filenames through sanitize ()
* * You should not pass all filenames through sanitize ()
* unless you plan on rejecting .files. Instead, pass
* the name through securitycheck () first, and if it fails,
* pass it through sanitize.
* @required string Path to location
* @result String. 'string' with any security problems fixed.
*/
* * string Path to location
* * @return String. 'string' with any security problems fixed.
*/
function sanitize ($data)
{
if (!is_array ($data))
@ -663,16 +663,16 @@
return (ereg_replace ("^\.+", '', $p->fake_name));
}
/*!
* @function clean_string
* @abstract Clean location string. This function is used if
/**
* * Clean location string. This function is used if
* *
* any special characters need to be escaped or removed
* before accessing a database, network protocol, etc.
* The default is to escape characters before doing an SQL
* query.
* @required string Location string to clean
* @result String. Cleaned version of 'string'.
*/
* * string Location string to clean
* * @return String. Cleaned version of 'string'.
*/
function clean_string ($data)
{
if (!is_array ($data))
@ -680,24 +680,24 @@
$data = array ();
}
$string = $GLOBALS['phpgw']->db->db_addslashes ($data['string']);
$string = $GLOBALS['egw']->db->db_addslashes ($data['string']);
return $string;
}
/*!
* @function getabsolutepath
* @abstract Translate a location string depending on the
/**
* * Translate a location string depending on the
* *
* relativity. This is the only function that is
* directly concerned with relativity.
* @optional string Path to location, relative to mask[0].
* Defaults to empty string.
* @optional mask Relativity array (default: RELATIVE_CURRENT)
* @optional fake Boolean. If set, returns the 'fake' path,
* * string Path to location, relative to mask[0].
* * Defaults to empty string.
* * mask Relativity array (default: RELATIVE_CURRENT)
* * fake Boolean. If set, returns the 'fake' path,
* i.e. /home/user/dir/file. This is not always
* possible, use path_parts() instead.
* @result String. Full fake or real path, or False on error.
*/
* * @return String. Full fake or real path, or False on error.
*/
function getabsolutepath ($data)
{
if (!is_array ($data))
@ -780,12 +780,12 @@
if (($data['mask'][0] & RELATIVE_USER) || ($data['mask'][0] & RELATIVE_USER_APP))
{
$basedir = $basedir . $GLOBALS['phpgw_info']['user']['account_lid'] . $sep;
$basedir = $basedir . $GLOBALS['egw_info']['user']['account_lid'] . $sep;
}
if ($data['mask'][0] & RELATIVE_USER_APP)
{
$basedir = $basedir . "." . $GLOBALS['phpgw_info']['flags']['currentapp'] . $sep;
$basedir = $basedir . "." . $GLOBALS['egw_info']['flags']['currentapp'] . $sep;
}
/* Don't add string if it's a /, just for aesthetics */
@ -805,14 +805,14 @@
return $basedir;
}
/*!
* @function get_ext_mime_type
* @abstract Return MIME type based on file extension
* @description Internal use only. Applications should call vfs->file_type ()
* @author skeeter
* @required string Real path to file, with or without leading paths
* @result String. MIME type based on file extension.
*/
/**
* * Return MIME type based on file extension
* *
* * Internal use only. Applications should call vfs->file_type ()
* * @author skeeter
* * string Real path to file, with or without leading paths
* * @return String. MIME type based on file extension.
*/
function get_ext_mime_type ($data)
{
if (!is_array ($data))
@ -821,7 +821,7 @@
}
$file=basename($data['string']);
$mimefile=PHPGW_API_INC.'/phpgw_mime.types';
$mimefile=EGW_API_INC.'/phpgw_mime.types';
$fp=fopen($mimefile,'r');
$contents = explode("\n",fread($fp,filesize($mimefile)));
fclose($fp);
@ -852,14 +852,14 @@
/* PUBLIC functions (mandatory) */
/*!
* @function set_relative
* @abstract Sets the current relativity, the relativity used
/**
* * Sets the current relativity, the relativity used
* *
* when RELATIVE_CURRENT is passed to a function
* @optional mask Relative bitmask. If not set, relativity
* * mask Relative bitmask. If not set, relativity
* will be returned to the default.
* @result Void
*/
* * @return Void
*/
function set_relative ($data)
{
if (!is_array ($data))
@ -877,13 +877,13 @@
}
}
/*!
* @function get_relative
* @abstract Return the current relativity
* @discussion Returns relativity bitmask, or the default
/**
* * Return the current relativity
* *
* * Returns relativity bitmask, or the default
* of "completely relative" if unset
* @result Integer. One of the RELATIVE_* defines.
*/
* * @return Integer. One of the RELATIVE_* defines.
*/
function get_relative ()
{
if (isset ($this->relative) && $this->relative)
@ -896,19 +896,19 @@
}
}
/*!
* @function path_parts
* @abstract Return information about the component parts of a location string
* @discussion Most VFS functions call path_parts() with their 'string' and
/**
* * Return information about the component parts of a location string
* *
* * Most VFS functions call path_parts() with their 'string' and
* 'relatives' arguments before doing their work, in order to
* determine the file/directory to work on.
* @required string Path to location
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
* @optional object If set, return an object instead of an array
* @optional nolinks Don't check for linked directories (made with
* * string Path to location
* * relatives Relativity array (default: RELATIVE_CURRENT)
* * object If set, return an object instead of an array
* * nolinks Don't check for linked directories (made with
* make_link()). Used internally to prevent recursion.
* @result Array or object. Contains the fake and real component parts of the path.
* @discussion Returned values are:
* * @return Array or object. Contains the fake and real component parts of the path.
* * Returned values are:
* mask
* outside
* fake_full_path
@ -934,7 +934,7 @@
* mask is either RELATIVE_NONE or RELATIVE_NONE|VFS_REAL,
* and is used internally
* outside is boolean, True if 'relatives' contains VFS_REAL
*/
*/
function path_parts ($data)
{
if (!is_array ($data))
@ -1084,8 +1084,8 @@
}
/*
We have to count it before because new keys will be added,
which would create an endless loop
We have to count it before because new keys will be added,
which would create an endless loop
*/
$count = count ($rarray);
reset ($rarray);
@ -1096,7 +1096,7 @@
if ($data['object'])
{
$robject = new path_class;
$robject =& new path_class;
reset ($rarray);
while (list ($key, $value) = each ($rarray))
@ -1126,23 +1126,23 @@
}
}
/*!
* @function cd
* @abstract Change current directory. This function is used to store the
/**
* * Change current directory. This function is used to store the
* *
* current directory in a standard way, so that it may be accessed
* throughout phpGroupWare to provide a consistent view for the user.
* @discussion To cd to the root '/', use:
* * To cd to the root '/', use:
* cd (array(
* 'string' => '/',
* 'relative' => False,
* 'relatives' => array (RELATIVE_NONE)
* ));
* @optional string Directory location to cd into. Default is '/'.
* @optional relative If set, add target to current path.
* * string Directory location to cd into. Default is '/'.
* * relative If set, add target to current path.
* Else, pass 'relative' as mask to getabsolutepath()
* Default is True.
* @optional relatives Relativity array (default: RELATIVE_CURRENT)
*/
* * relatives Relativity array (default: RELATIVE_CURRENT)
*/
function cd ($data = '')
{
if (!is_array ($data))
@ -1184,7 +1184,7 @@
}
else
{
$currentdir = $GLOBALS['phpgw']->session->appsession('vfs','');
$currentdir = $GLOBALS['egw']->session->appsession('vfs','');
$basedir = $this->getabsolutepath (array(
'string' => $currentdir . $sep . $data['string'],
'mask' => array ($data['relatives'][0]),
@ -1202,19 +1202,19 @@
);
}
$GLOBALS['phpgw']->session->appsession('vfs','',$basedir);
$GLOBALS['egw']->session->appsession('vfs','',$basedir);
return True;
}
/*!
* @function pwd
* @abstract Return current directory
* @optional full If set, return full fake path, else just
/**
* * Return current directory
* *
* * full If set, return full fake path, else just
* the extra dirs (False strips the leading /).
* Default is True.
* @result String. The current directory.
*/
* * @return String. The current directory.
*/
function pwd ($data = '')
{
if (!is_array ($data))
@ -1229,7 +1229,7 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$currentdir = $GLOBALS['phpgw']->session->appsession('vfs','');
$currentdir = $GLOBALS['egw']->session->appsession('vfs','');
if (!$data['full'])
{
@ -1246,54 +1246,54 @@
return $currentdir;
}
/*!
* @function copy
* @abstract shortcut to cp
*/
/**
* * shortcut to cp
* *
*/
function copy ($data)
{
return $this->cp ($data);
}
/*!
* @function move
* @abstract shortcut to mv
*/
/**
* * shortcut to mv
* *
*/
function move ($data)
{
return $this->mv ($data);
}
/*!
* @function delete
* @abstract shortcut to rm
*/
/**
* * shortcut to rm
* *
*/
function delete ($data)
{
return $this->rm ($data);
}
/*!
* @function dir
* @abstract shortcut to ls
*/
/**
* * shortcut to ls
* *
*/
function dir ($data)
{
return $this->ls ($data);
}
/*!
* @function command_line
* @abstract Process and run a Unix-sytle command line
* @discussion EXPERIMENTAL. DANGEROUS. DO NOT USE THIS UNLESS YOU
/**
* * Process and run a Unix-sytle command line
* *
* * EXPERIMENTAL. DANGEROUS. DO NOT USE THIS UNLESS YOU
* KNOW WHAT YOU'RE DOING!
* This is mostly working, but the command parser needs
* * This is mostly working, but the command parser needs
* to be improved to take files with spaces into
* consideration (those should be in "").
* @required command_line Unix-style command line with one of the
* * command_line Unix-style command line with one of the
* commands in the $args array
* @result The return value of the actual VFS call
*/
* * @return The return value of the actual VFS call
*/
function command_line ($data)
{
if (!is_array ($data))
@ -1412,4 +1412,4 @@
}
include (PHPGW_API_INC . '/class.vfs_' . $GLOBALS['phpgw_info']['server']['file_repository'] . '.inc.php');
include (EGW_API_INC . '/class.vfs_' . $GLOBALS['egw_info']['server']['file_repository'] . '.inc.php');

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,33 @@
<?php
/**************************************************************************\
* eGroupWare API - VFS *
* This file written by Jason Wies (Zone) <zone@phpgroupware.org> *
* This class handles file/dir access for eGroupWare *
* Copyright (C) 2001 Jason Wies *
* Database layer reworked 2005/09/20 by RalfBecker-AT-outdoor-training.de *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* ------------------------------------------------------------------------ *
* 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 *
\**************************************************************************/
/**************************************************************************\
* eGroupWare API - VFS *
* This file written by Jason Wies (Zone) <zone@phpgroupware.org> *
* This class handles file/dir access for eGroupWare *
* Copyright (C) 2001 Jason Wies *
* Database layer reworked 2005/09/20 by RalfBecker-AT-outdoor-training.de *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* ------------------------------------------------------------------------ *
* 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$ */
/* $Id$ */
/*!
@class vfs
@abstract Virtual File System with SQL backend
@description Authors: Zone
*/
/**
* Virtual File System with SQL backend
*
* Authors: Zone
*/
/* These are used in calls to extra_sql () */
define ('VFS_SQL_SELECT', 1);
@ -44,24 +44,24 @@
var $vfs_table = 'egw_vfs';
var $vfs_column_prefix = 'vfs_';
/*!
@function vfs
@abstract constructor, sets up variables
*/
/**
* constructor, sets up variables
*
*/
function vfs ()
{
$this->vfs_shared ();
$this->basedir = $GLOBALS['phpgw_info']['server']['files_dir'];
$this->working_id = $GLOBALS['phpgw_info']['user']['account_id'];
$this->working_lid = $GLOBALS['phpgw_info']['user']['account_lid'];
$this->basedir = $GLOBALS['egw_info']['server']['files_dir'];
$this->working_id = $GLOBALS['egw_info']['user']['account_id'];
$this->working_lid = $GLOBALS['egw_info']['user']['account_lid'];
$this->now = date ('Y-m-d');
/*
File/dir attributes, each corresponding to a database field. Useful for use in loops
If an attribute was added to the table, add it here and possibly add it to
set_attributes ()
File/dir attributes, each corresponding to a database field. Useful for use in loops
If an attribute was added to the table, add it here and possibly add it to
set_attributes ()
set_attributes now uses this array(). 07-Dec-01 skeeter
set_attributes now uses this array(). 07-Dec-01 skeeter
*/
$this->attributes[] = 'deleteable';
@ -74,34 +74,34 @@
$this->attributes[$this->vfs_column_prefix.$attr] = $attr;
}
/*
Decide whether to use any actual filesystem calls (fopen(), fread(),
unlink(), rmdir(), touch(), etc.). If not, then we're working completely
in the database.
Decide whether to use any actual filesystem calls (fopen(), fread(),
unlink(), rmdir(), touch(), etc.). If not, then we're working completely
in the database.
*/
$this->file_actions = $GLOBALS['phpgw_info']['server']['file_store_contents'] == 'filesystem' ||
!$GLOBALS['phpgw_info']['server']['file_store_contents'];
$this->file_actions = $GLOBALS['egw_info']['server']['file_store_contents'] == 'filesystem' ||
!$GLOBALS['egw_info']['server']['file_store_contents'];
// test if the files-dir is inside the document-root, and refuse working if so
//
if ($this->file_actions && $this->in_docroot($this->basedir))
{
$GLOBALS['phpgw']->common->phpgw_header();
if ($GLOBALS['phpgw_info']['flags']['noheader'])
$GLOBALS['egw']->common->egw_header();
if ($GLOBALS['egw_info']['flags']['noheader'])
{
echo parse_navbar();
}
echo '<p align="center"><font color="red"><b>'.lang('Path to user and group files HAS TO BE OUTSIDE of the webservers document-root!!!')."</b></font></p>\n";
$GLOBALS['phpgw']->common->phpgw_exit();
$GLOBALS['egw']->common->egw_exit();
}
/*
These are stored in the MIME-type field and should normally be ignored.
Adding a type here will ensure it is normally ignored, but you will have to
explicitly add it to acl_check (), and to any other SELECT's in this file
These are stored in the MIME-type field and should normally be ignored.
Adding a type here will ensure it is normally ignored, but you will have to
explicitly add it to acl_check (), and to any other SELECT's in this file
*/
$this->meta_types = array ('journal', 'journal-deleted');
$this->db = clone($GLOBALS['phpgw']->db);
$this->db = clone($GLOBALS['egw']->db);
$this->db->set_app('phpgwapi');
/* We store the linked directories in an array now, so we don't have to make the SQL call again */
@ -137,13 +137,13 @@
$this->grants = $GLOBALS['egw']->acl->get_grants('filemanager');
}
/*!
@function in_docroot
@abstract test if $path lies within the webservers document-root
*/
/**
* test if $path lies within the webservers document-root
*
*/
function in_docroot($path)
{
$docroots = array(PHPGW_SERVER_ROOT,$_SERVER['DOCUMENT_ROOT']);
$docroots = array(EGW_SERVER_ROOT,$_SERVER['DOCUMENT_ROOT']);
foreach ($docroots as $docroot)
{
@ -162,12 +162,12 @@
return False;
}
/*!
@function extra_sql
@abstract Return extra SQL code that should be appended (AND'ed) to certain queries
@param query_type The type of query to get extra SQL code for, in the form of a VFS_SQL define
@result Extra SQL code
*/
/**
* Return extra SQL code that should be appended (AND'ed) to certain queries
*
* @param query_type The type of query to get extra SQL code for, in the form of a VFS_SQL define
* @return Extra SQL code
*/
function extra_sql ($data)
{
if (!is_array ($data))
@ -182,31 +182,31 @@
return '';
}
/*!
@function add_journal
@abstract Add a journal entry after (or before) completing an operation,
and increment the version number. This function should be used internally only
@discussion Note that state_one and state_two are ignored for some VFS_OPERATION's, for others
they are required. They are ignored for any "custom" operation
The two operations that require state_two:
operation state_two
VFS_OPERATION_COPIED fake_full_path of copied to
VFS_OPERATION_MOVED fake_full_path of moved to
/**
* Add a journal entry after (or before) completing an operation,
*
* * and increment the version number. This function should be used internally only
* Note that state_one and state_two are ignored for some VFS_OPERATION's, for others
* * they are required. They are ignored for any "custom" operation
* * The two operations that require state_two:
* * operation * state_two
* * VFS_OPERATION_COPIED fake_full_path of copied to
* * VFS_OPERATION_MOVED * fake_full_path of moved to
If deleting, you must call add_journal () before you delete the entry from the database
@param string File or directory to add entry for
@param relatives Relativity array
@param operation The operation that was performed. Either a VFS_OPERATION define or
a non-integer descriptive text string
@param state_one The first "state" of the file or directory. Can be a file name, size,
location, whatever is appropriate for the specific operation
@param state_two The second "state" of the file or directory
@param incversion Boolean True/False. Increment the version for the file? Note that this is
handled automatically for the VFS_OPERATION defines.
i.e. VFS_OPERATION_EDITED would increment the version, VFS_OPERATION_COPIED
would not
@result Boolean True/False
*/
* * If deleting, you must call add_journal () before you delete the entry from the database
* @param string File or directory to add entry for
* @param relatives Relativity array
* @param operation The operation that was performed. Either a VFS_OPERATION define or
* * a non-integer descriptive text string
* @param state_one The first "state" of the file or directory. Can be a file name, size,
* * location, whatever is appropriate for the specific operation
* @param state_two The second "state" of the file or directory
* @param incversion Boolean True/False. Increment the version for the file? Note that this is
* * handled automatically for the VFS_OPERATION defines.
* * i.e. VFS_OPERATION_EDITED would increment the version, VFS_OPERATION_COPIED
* * would not
* @return Boolean True/False
*/
function add_journal ($data)
{
if (!is_array ($data))
@ -224,14 +224,14 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$account_id = $GLOBALS['egw_info']['user']['account_id'];
$p = $this->path_parts (array ('string' => $data['string'], 'relatives' => array ($data['relatives'][0])));
/* We check that they have some sort of access to the file other than read */
if (!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => PHPGW_ACL_WRITE)) &&
!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => PHPGW_ACL_EDIT)) &&
!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => PHPGW_ACL_DELETE)))
if (!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => EGW_ACL_WRITE)) &&
!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => EGW_ACL_EDIT)) &&
!$this->acl_check (array ('string' => $p->fake_full_path, 'relatives' => array ($p->mask), 'operation' => EGW_ACL_DELETE)))
{
return False;
}
@ -330,10 +330,10 @@
}
/*
Let's increment the version for the file itself. We keep the current
version when making the journal entry, because that was the version that
was operated on. The maximum numbers for each part in the version string:
none.99.9.9
Let's increment the version for the file itself. We keep the current
version when making the journal entry, because that was the version that
was operated on. The maximum numbers for each part in the version string:
none.99.9.9
*/
if ($attribute == 'version' && $data['incversion'])
{
@ -394,9 +394,9 @@
}
}
/*
These are some special situations where we need to flush the journal entries
or move the 'journal' entries to 'journal-deleted'. Kind of hackish, but they
provide a consistent feel to the system
These are some special situations where we need to flush the journal entries
or move the 'journal' entries to 'journal-deleted'. Kind of hackish, but they
provide a consistent feel to the system
*/
if ($data['operation'] == VFS_OPERATION_CREATED)
{
@ -429,8 +429,8 @@
if ($data['operation'] == VFS_OPERATION_COPIED)
{
/*
We copy it going the other way as well, so both files show the operation.
The code is a bad hack to prevent recursion. Ideally it would use VFS_OPERATION_COPIED
We copy it going the other way as well, so both files show the operation.
The code is a bad hack to prevent recursion. Ideally it would use VFS_OPERATION_COPIED
*/
$this->add_journal (array(
'string' => $data['state_two'],
@ -458,8 +458,8 @@
),__LINE__,__FILE__);
/*
We create the file in addition to logging the MOVED operation. This is an
advantage because we can now search for 'Create' to see when a file was created
We create the file in addition to logging the MOVED operation. This is an
advantage because we can now search for 'Create' to see when a file was created
*/
$this->add_journal (array(
'string' => $data['state_two'],
@ -473,8 +473,8 @@
$this->db->insert($this->vfs_table,$to_write,false, __LINE__, __FILE__);
/*
If we were to add an option of whether to keep journal entries for deleted files
or not, it would go in the if here
If we were to add an option of whether to keep journal entries for deleted files
or not, it would go in the if here
*/
if ($data['operation'] == VFS_OPERATION_DELETED)
{
@ -490,18 +490,18 @@
return True;
}
/*!
@function flush_journal
@abstract Flush journal entries for $string. Used before adding $string
@discussion flush_journal () is an internal function and should be called from add_journal () only
@param string File/directory to flush journal entries of
@param relatives Realtivity array
@param deleteall Delete all types of journal entries, including the active Create entry.
Normally you only want to delete the Create entry when replacing the file
Note that this option does not effect $deleteonly
@param deletedonly Only flush 'journal-deleted' entries (created when $string was deleted)
@result Boolean True/False
*/
/**
* Flush journal entries for $string. Used before adding $string
*
* flush_journal () is an internal function and should be called from add_journal () only
* @param string File/directory to flush journal entries of
* @param relatives Realtivity array
* @param deleteall Delete all types of journal entries, including the active Create entry.
* * Normally you only want to delete the Create entry when replacing the file
* * Note that this option does not effect $deleteonly
* @param deletedonly Only flush 'journal-deleted' entries (created when $string was deleted)
* @return Boolean True/False
*/
function flush_journal ($data)
{
if (!is_array ($data))
@ -611,7 +611,7 @@
$default_values = array
(
'relatives' => array (RELATIVE_CURRENT),
'operation' => PHPGW_ACL_READ,
'operation' => EGW_ACL_READ,
'must_exist' => False
);
@ -640,7 +640,7 @@
/* Read access is always allowed here, but nothing else is */
if ($data['string'] == '/' || $data['string'] == $this->fakebase)
{
if ($data['operation'] == PHPGW_ACL_READ)
if ($data['operation'] == EGW_ACL_READ)
{
return True;
}
@ -685,8 +685,8 @@
}
/*
We don't use ls () to get owner_id as we normally would,
because ls () calls acl_check (), which would create an infinite loop
We don't use ls () to get owner_id as we normally would,
because ls () calls acl_check (), which would create an infinite loop
*/
$this->db->select($this->vfs_table,'vfs_owner_id',array(
'vfs_directory' => $p2->fake_leading_dirs,
@ -709,44 +709,13 @@
$owner_id = 0;
}
$user_id = $GLOBALS['phpgw_info']['user']['account_id'];
$user_id = $GLOBALS['egw_info']['user']['account_id'];
//echo "user=$user_id, ";
/* They always have access to their own files */
if ($owner_id == $user_id)
{
return True;
}
/* RalfBecker 2005/03/07 using ACL standard function acl::get_grants() now
// Check if they're in the group
$memberships = $GLOBALS['phpgw']->accounts->membership ($user_id);
if (is_array ($memberships))
{
foreach ($memberships as $group_array)
{
if ($owner_id == $group_array['account_id'])
{
$group_ok = 1;
break;
}
}
}
$acl = CreateObject ('phpgwapi.acl', $owner_id);
$acl->account_id = $owner_id;
$acl->read_repository ();
$rights = $acl->get_rights ($user_id);
// Add privileges from the groups this user belongs to
if (is_array ($memberships))
{
foreach ($memberships as $group_array)
{
$rights |= $acl->get_rights ($group_array['account_id']);
}
}
*/
$rights = $this->grants[$owner_id];
//echo "rights=$rights, ";
if ($rights & $data['operation'])
@ -755,7 +724,7 @@
}
elseif (!$rights && $group_ok)
{
return $GLOBALS['phpgw_info']['server']['acl_default'] == 'grant';
return $GLOBALS['egw_info']['server']['acl_default'] == 'grant';
}
else
{
@ -789,7 +758,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_READ
'operation' => EGW_ACL_READ
))
)
{
@ -852,12 +821,12 @@
))
)
{
$acl_operation = PHPGW_ACL_EDIT;
$acl_operation = EGW_ACL_EDIT;
$journal_operation = VFS_OPERATION_EDITED;
}
else
{
$acl_operation = PHPGW_ACL_ADD;
$acl_operation = EGW_ACL_ADD;
}
if (!$this->acl_check (array(
@ -873,8 +842,8 @@
umask(0177);
/*
If 'string' doesn't exist, touch () creates both the file and the database entry
If 'string' does exist, touch () sets the modification time and modified by
If 'string' doesn't exist, touch () creates both the file and the database entry
If 'string' does exist, touch () sets the modification time and modified by
*/
$this->touch (array(
'string' => $p->fake_full_path,
@ -952,8 +921,8 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
$account_id = $GLOBALS['egw_info']['user']['account_id'];
$currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
$p = $this->path_parts (array(
'string' => $data['string'],
@ -966,8 +935,8 @@
if ($this->file_actions)
{
/*
PHP's touch function will automatically decide whether to
create the file or set the modification time
PHP's touch function will automatically decide whether to
create the file or set the modification time
*/
$rr = @touch ($p->real_full_path);
@ -987,7 +956,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_EDIT
'operation' => EGW_ACL_EDIT
)))
{
return False;
@ -1008,7 +977,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_ADD
'operation' => EGW_ACL_ADD
))
)
{
@ -1068,7 +1037,7 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$account_id = $GLOBALS['egw_info']['user']['account_id'];
$f = $this->path_parts (array(
'string' => $data['from'],
@ -1085,7 +1054,7 @@
if (!$this->acl_check (array(
'string' => $f->fake_full_path,
'relatives' => array ($f->mask),
'operation' => PHPGW_ACL_READ
'operation' => EGW_ACL_READ
))
)
{
@ -1101,7 +1070,7 @@
if (!$this->acl_check (array(
'string' => $t->fake_full_path,
'relatives' => array ($t->mask),
'operation' => PHPGW_ACL_EDIT
'operation' => EGW_ACL_EDIT
))
)
{
@ -1113,7 +1082,7 @@
if (!$this->acl_check (array(
'string' => $t->fake_full_path,
'relatives' => array ($t->mask),
'operation' => PHPGW_ACL_ADD
'operation' => EGW_ACL_ADD
))
)
{
@ -1181,18 +1150,6 @@
))
)
{
/* RalfBecker 2004/09/19: for my undetstanding the query does nothing, as it only sets rows already containing these values !!!
$query = $this->db->update($this->vfs_table,array(
'owner_id' => $this->working_id,
'directory' => $t->fake_leading_dirs,
'name' => $t->fake_name,
),array(
'owner_id' => $this->working_id,
'directory' => $t->fake_leading_dirs,
'name' => $t->fake_name,
$this->extra_sql(VFS_SQL_UPDATE)
), __LINE__, __FILE__);
*/
$set_attributes_array = array (
'createdby_id' => $account_id,
'created' => $this->now,
@ -1336,7 +1293,7 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$account_id = $GLOBALS['egw_info']['user']['account_id'];
$f = $this->path_parts (array(
'string' => $data['from'],
@ -1353,12 +1310,12 @@
if (!$this->acl_check (array(
'string' => $f->fake_full_path,
'relatives' => array ($f->mask),
'operation' => PHPGW_ACL_READ
'operation' => EGW_ACL_READ
))
|| !$this->acl_check (array(
'string' => $f->fake_full_path,
'relatives' => array ($f->mask),
'operation' => PHPGW_ACL_DELETE
'operation' => EGW_ACL_DELETE
))
)
{
@ -1368,7 +1325,7 @@
if (!$this->acl_check (array(
'string' => $t->fake_full_path,
'relatives' => array ($t->mask),
'operation' => PHPGW_ACL_ADD
'operation' => EGW_ACL_ADD
))
)
{
@ -1384,7 +1341,7 @@
if (!$this->acl_check (array(
'string' => $t->fake_full_path,
'relatives' => array ($t->mask),
'operation' => PHPGW_ACL_EDIT
'operation' => EGW_ACL_EDIT
))
)
{
@ -1435,8 +1392,8 @@
}
/*
We add the journal entry now, before we delete. This way the mime_type
field will be updated to 'journal-deleted' when the file is actually deleted
We add the journal entry now, before we delete. This way the mime_type
field will be updated to 'journal-deleted' when the file is actually deleted
*/
if (!$f->outside)
{
@ -1451,8 +1408,8 @@
}
/*
If the from file is outside, it won't have a database entry,
so we have to touch it and find the size
If the from file is outside, it won't have a database entry,
so we have to touch it and find the size
*/
if ($f->outside)
{
@ -1503,8 +1460,8 @@
}
/*
This removes the original entry from the database
The actual file is already deleted because of the rename () above
This removes the original entry from the database
The actual file is already deleted because of the rename () above
*/
if ($t->outside)
{
@ -1584,7 +1541,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_DELETE
'operation' => EGW_ACL_DELETE
))
)
{
@ -1751,8 +1708,8 @@
$data = array_merge ($this->default_values ($data, $default_values), $data);
$account_id = $GLOBALS['phpgw_info']['user']['account_id'];
$currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
$account_id = $GLOBALS['egw_info']['user']['account_id'];
$currentapp = $GLOBALS['egw_info']['flags']['currentapp'];
$p = $this->path_parts (array(
'string' => $data['string'],
@ -1763,10 +1720,10 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_ADD)
'operation' => EGW_ACL_ADD)
)
)
{//echo "!acl_check('$p->fake_full_path',PHPGW_ACL_ADD)";
{//echo "!acl_check('$p->fake_full_path',EGW_ACL_ADD)";
return False;
}
@ -1875,7 +1832,7 @@
if (!$this->acl_check (array(
'string' => $vp->fake_full_path,
'relatives' => array ($vp->mask),
'operation' => PHPGW_ACL_ADD
'operation' => EGW_ACL_ADD
))
)
{
@ -1951,13 +1908,13 @@
);
/*
This is kind of trivial, given that set_attributes () can change owner_id,
size, etc.
This is kind of trivial, given that set_attributes () can change owner_id,
size, etc.
*/
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_EDIT
'operation' => EGW_ACL_EDIT
))
)
{
@ -1974,8 +1931,8 @@
}
/*
All this voodoo just decides which attributes to update
depending on if the attribute was supplied in the 'attributes' array
All this voodoo just decides which attributes to update
depending on if the attribute was supplied in the 'attributes' array
*/
$ls_array = $this->ls (array(
@ -1993,8 +1950,8 @@
if (isset ($data['attributes'][$attribute]))
{
/*
Indicate that the EDITED_COMMENT operation needs to be journaled,
but only if the comment changed
Indicate that the EDITED_COMMENT operation needs to be journaled,
but only if the comment changed
*/
if ($attribute == 'comment' && $data['attributes'][$attribute] != $record[$attribute])
{
@ -2027,13 +1984,13 @@
return True;
}
/*!
@function correct_attributes
@abstract Set the correct attributes for 'string' (e.g. owner)
@param string File/directory to correct attributes of
@param relatives Relativity array
@result Boolean True/False
*/
/**
* Set the correct attributes for 'string' (e.g. owner)
*
* @param string File/directory to correct attributes of
* @param relatives Relativity array
* @return Boolean True/False
*/
function correct_attributes ($data)
{
if (!is_array ($data))
@ -2070,7 +2027,7 @@
elseif (preg_match ("+^$this->fakebase\/(.*)$+U", $p->fake_full_path, $matches))
{
$set_attributes_array = Array(
'owner_id' => $GLOBALS['phpgw']->accounts->name2id ($matches[1])
'owner_id' => $GLOBALS['egw']->accounts->name2id ($matches[1])
);
}
else
@ -2081,7 +2038,7 @@
}
$this->set_attributes (array(
'string' => $p->fake_full_name,
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'attributes' => $set_attributes_array
)
@ -2116,7 +2073,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_READ,
'operation' => EGW_ACL_READ,
'must_exist' => True
))
)
@ -2132,14 +2089,14 @@
}
/*
We don't return an empty string here, because it may still match with a database query
because of linked directories
We don't return an empty string here, because it may still match with a database query
because of linked directories
*/
}
/*
We don't use ls () because it calls file_type () to determine if it has been
passed a directory
We don't use ls () because it calls file_type () to determine if it has been
passed a directory
*/
$db2 = clone($this->db);
$db2->select($this->vfs_table,'vfs_mime_type',array(
@ -2149,18 +2106,15 @@
), __LINE__, __FILE__);
$db2->next_record ();
$mime_type = $db2->Record['vfs_mime_type'];
if(!$mime_type)
if(!$mime_type && ($mime_type = $this->get_ext_mime_type (array ('string' => $data['string']))))
{
$mime_type = $this->get_ext_mime_type (array ('string' => $data['string']));
{
$db2->update($this->vfs_table,array(
'vfs_mime_type' => $mime_type
),array(
'vfs_directory' => $p->fake_leading_dirs,
'vfs_name' => $p->fake_name,
$this->extra_sql(array ('query_type' => VFS_SQL_SELECT))
), __LINE__, __FILE__);
}
$db2->update($this->vfs_table,array(
'vfs_mime_type' => $mime_type
),array(
'vfs_directory' => $p->fake_leading_dirs,
'vfs_name' => $p->fake_name,
$this->extra_sql(array ('query_type' => VFS_SQL_SELECT))
), __LINE__, __FILE__);
}
return $mime_type;
}
@ -2232,7 +2186,7 @@
if (!$this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_READ,
'operation' => EGW_ACL_READ,
'must_exist' => True
))
)
@ -2241,8 +2195,8 @@
}
/*
WIP - this should run through all of the subfiles/directories in the directory and tally up
their sizes. Should modify ls () to be able to return a list for files outside the virtual root
WIP - this should run through all of the subfiles/directories in the directory and tally up
their sizes. Should modify ls () to be able to return a list for files outside the virtual root
*/
if ($p->outside)
{
@ -2259,8 +2213,8 @@
)) as $file_array)
{
/*
Make sure the file is in the directory we want, and not
some deeper nested directory with a similar name
Make sure the file is in the directory we want, and not
some deeper nested directory with a similar name
*/
/*
if (@!ereg ('^' . $file_array['directory'], $p->fake_full_path))
@ -2286,14 +2240,14 @@
return $size;
}
/*!
@function checkperms
@abstract Check if $this->working_id has write access to create files in $dir
@discussion Simple call to acl_check
@param string Directory to check access of
@param relatives Relativity array
@result Boolean True/False
*/
/**
* Check if $this->working_id has write access to create files in $dir
*
* Simple call to acl_check
* @param string Directory to check access of
* @param relatives Relativity array
* @return Boolean True/False
*/
function checkperms ($data)
{
if (!is_array ($data))
@ -2317,7 +2271,7 @@
return $this->acl_check (array(
'string' => $p->fake_full_path,
'relatives' => array ($p->mask),
'operation' => PHPGW_ACL_ADD
'operation' => EGW_ACL_ADD
));
}