From 5cbbbb7d299c99070e242037f40d41e5d2c33962 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 22 Jul 2005 17:59:09 +0000 Subject: [PATCH] 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 --- phpgwapi/inc/class.vfs.inc.php | 618 +++++++++--------- phpgwapi/inc/class.vfs_dav.inc.php | 980 ++++++++++++++--------------- phpgwapi/inc/class.vfs_sql.inc.php | 436 ++++++------- 3 files changed, 994 insertions(+), 1040 deletions(-) diff --git a/phpgwapi/inc/class.vfs.inc.php b/phpgwapi/inc/class.vfs.inc.php index 6ffca95e2a..0e2da552d1 100644 --- a/phpgwapi/inc/class.vfs.inc.php +++ b/phpgwapi/inc/class.vfs.inc.php @@ -1,31 +1,31 @@ * - * 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) * + * 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'); diff --git a/phpgwapi/inc/class.vfs_dav.inc.php b/phpgwapi/inc/class.vfs_dav.inc.php index d6f59eb2a5..6545136f79 100644 --- a/phpgwapi/inc/class.vfs_dav.inc.php +++ b/phpgwapi/inc/class.vfs_dav.inc.php @@ -1,25 +1,25 @@ * - * This class handles file/dir access for eGroupWare * - * Copyright (C) 2001-2003 Jason Wies, Jonathon Sim * - * -------------------------------------------------------------------------* - * 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 * + * This file written by Jason Wies (Zone) * + * This class handles file/dir access for eGroupWare * + * Copyright (C) 2001-2003 Jason Wies, Jonathon Sim * + * -------------------------------------------------------------------------* + * 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 * + \**************************************************************************/ /*Different aspects of debugging. DEBUG enables debug output for this class @@ -57,25 +57,25 @@ 'publisher_id' => 'owner_id' ); - /*! - @function vfs - @abstract constructor, sets up variables - */ + /** + * constructor, sets up variables + * + */ function vfs () { - $this->basedir = $GLOBALS['phpgw_info']['server']['files_dir']; + $this->basedir = $GLOBALS['egw_info']['server']['files_dir']; $this->fakebase = '/home'; - $this->working_id = $GLOBALS['phpgw_info']['user']['account_id']; - $this->working_lid = $GLOBALS['phpgw']->accounts->id2name($this->working_id); + $this->working_id = $GLOBALS['egw_info']['user']['account_id']; + $this->working_lid = $GLOBALS['egw']->accounts->id2name($this->working_id); $this->now = date ('Y-m-d'); $this->override_acl = 0; /* - 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 = array( @@ -98,39 +98,39 @@ ); /* - 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'); /* We store the linked directories in an array now, so we don't have to make the SQL call again */ - if ($GLOBALS['phpgw_info']['server']['db_type']=='mssql' - || $GLOBALS['phpgw_info']['server']['db_type']=='sybase') + if ($GLOBALS['egw_info']['server']['db_type']=='mssql' + || $GLOBALS['egw_info']['server']['db_type']=='sybase') { - $query = $GLOBALS['phpgw']->db->query ("SELECT directory, name, link_directory, link_name FROM phpgw_vfs WHERE CONVERT(varchar,link_directory) != '' AND CONVERT(varchar,link_name) != ''" . $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__,__FILE__); + $query = $GLOBALS['egw']->db->query ("SELECT directory, name, link_directory, link_name FROM phpgw_vfs WHERE CONVERT(varchar,link_directory) != '' AND CONVERT(varchar,link_name) != ''" . $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__,__FILE__); } else { - $query = $GLOBALS['phpgw']->db->query ("SELECT directory, name, link_directory, link_name FROM phpgw_vfs WHERE (link_directory IS NOT NULL or link_directory != '') AND (link_name IS NOT NULL or link_name != '')" . $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__,__FILE__); + $query = $GLOBALS['egw']->db->query ("SELECT directory, name, link_directory, link_name FROM phpgw_vfs WHERE (link_directory IS NOT NULL or link_directory != '') AND (link_name IS NOT NULL or link_name != '')" . $this->extra_sql (array ('query_type' => VFS_SQL_SELECT)), __LINE__,__FILE__); } $this->linked_dirs = array (); - while ($GLOBALS['phpgw']->db->next_record ()) + while ($GLOBALS['egw']->db->next_record ()) { - $this->linked_dirs[] = $GLOBALS['phpgw']->db->Record; + $this->linked_dirs[] = $GLOBALS['egw']->db->Record; } - $this->repository = $GLOBALS['phpgw_info']['server']['files_dir']; - $this->dav_user=$GLOBALS['phpgw_info']['user']['userid']; - $this->dav_pwd=$GLOBALS['phpgw_info']['user']['passwd']; + $this->repository = $GLOBALS['egw_info']['server']['files_dir']; + $this->dav_user=$GLOBALS['egw_info']['user']['userid']; + $this->dav_pwd=$GLOBALS['egw_info']['user']['passwd']; $parsed_url = parse_url($this->repository); $this->dav_host=$parsed_url['host']; $this->dav_port=@isset($parsed_url['port']) ? $parsed_url['port'] : 80; - $this->dav_client = CreateObject('phpgwapi.http_dav_client'); + $this->dav_client =& CreateObject('phpgwapi.http_dav_client'); $this->dav_client->set_credentials($this->dav_user,$this->dav_pwd); $this->dav_client->set_attributes($this->attributes,$this->vfs_property_map); $result = $this->dav_client->connect($this->dav_host,$this->dav_port); @@ -153,8 +153,8 @@ } */ //Reload the overriden_locks - $app = $GLOBALS['phpgw_info']['flags']['currentapp']; - $session_data = base64_decode($GLOBALS['phpgw']->session->appsession ('vfs_dav',$app)); + $app = $GLOBALS['egw_info']['flags']['currentapp']; + $session_data = base64_decode($GLOBALS['egw']->session->appsession ('vfs_dav',$app)); $this->override_locks = array(); if ($session_data) { @@ -191,22 +191,22 @@ } } - /*! - @function dav_path - @abstract Apaches mod_dav in particular requires that the path sent in a dav request NOT be a URI - */ + /** + * Apaches mod_dav in particular requires that the path sent in a dav request NOT be a URI + * + */ function dav_path($uri) { //$this->debug('DAV path'); $parsed = parse_url($uri); return $parsed['path']; } - /*! - @function glue_url - @abstract glues a parsed url (ie parsed using PHP's parse_url) back - together - @param $url The parsed url (its an array) - */ + /** + * glues a parsed url (ie parsed using PHP's parse_url) back + * + * together + * @param $url The parsed url (its an array) + */ function glue_url ($url){ if (!is_array($url)) { @@ -256,11 +256,11 @@ } - /*! - @function set_relative - @abstract Set path relativity - @param mask Relative bitmask (see RELATIVE_ defines) - */ + /** + * Set path relativity + * + * @param mask Relative bitmask (see RELATIVE_ defines) + */ function set_relative ($data) { if (!is_array ($data)) @@ -278,11 +278,11 @@ } } - /*! - @function get_relative - @abstract Return relativity bitmask - @discussion Returns relativity bitmask, or the default of "completely relative" if unset - */ + /** + * Return relativity bitmask + * + * Returns relativity bitmask, or the default of "completely relative" if unset + */ function get_relative () { if (isset ($this->relative) && $this->relative) @@ -295,15 +295,15 @@ } } - /*! - @function sanitize - @abstract Removes leading .'s from 'string' - @discussion 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 - @param string string to sanitize - @result $string 'string' without it's leading .'s - */ + /** + * Removes leading .'s from 'string' + * + * 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 + * @param string string to sanitize + * @return $string 'string' without it's leading .'s + */ function sanitize ($data) { if (!is_array ($data)) @@ -321,14 +321,14 @@ return (ereg_replace ('^\.+', '', $p->fake_name)); } - /*! - @function securitycheck - @abstract Security check function - @discussion Checks for basic violations such as .. - If securitycheck () fails, run your string through vfs->sanitize () - @param string string to check security of - @result Boolean True/False. True means secure, False means insecure - */ + /** + * Security check function + * + * Checks for basic violations such as .. + * * If securitycheck () fails, run your string through vfs->sanitize () + * @param string string to check security of + * @return Boolean True/False. True means secure, False means insecure + */ function securitycheck ($data) { if (!is_array ($data)) @@ -346,12 +346,12 @@ } } - /*! - @function db_clean - @abstract Clean 'string' for use in database queries - @param string String to clean - @result Cleaned version of 'string' - */ + /** + * Clean 'string' for use in database queries + * + * @param string String to clean + * @return Cleaned version of 'string' + */ function db_clean ($data) { if (!is_array ($data)) @@ -364,115 +364,115 @@ return $string; } - /*! - @function extra_sql - @abstract Return extra SQL code that should be appended 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 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) { //This is purely for SQL 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) { //The journalling dont work :( Ideally this will become "versioning" 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) { return True; } - /*! - @function get_journal - @abstract Retrieve journal entries for $string - @param string File/directory to retrieve journal entries of - @param relatives Relativity array - @param type 0/False = any, 1 = 'journal', 2 = 'journal-deleted' - @result Array of arrays of journal entries - */ + /** + * Retrieve journal entries for $string + * + * @param string File/directory to retrieve journal entries of + * @param relatives Relativity array + * @param type 0/False = any, 1 = 'journal', 2 = 'journal-deleted' + * @return Array of arrays of journal entries + */ function get_journal ($data) { return array(); } - /*! - @function path_parts - @abstract take a real or fake pathname and return an array of its component parts - @param string full real or fake path - @param relatives Relativity array - @param object True returns an object instead of an array - @param nolinks Don't check for links (made with make_link ()). Used internally to prevent recursion - @result $rarray/$robject Array or object containing the fake and real component parts of the path - @discussion Returned values are: - mask - outside - fake_full_path - fake_leading_dirs - fake_extra_path BROKEN - fake_name - real_full_path - real_leading_dirs - real_extra_path BROKEN - real_name - fake_full_path_clean - fake_leading_dirs_clean - fake_extra_path_clean BROKEN - fake_name_clean - real_full_path_clean - real_leading_dirs_clean - real_extra_path_clean BROKEN - real_name_clean - real_uri - "clean" values are run through vfs->db_clean () and - are safe for use in SQL queries that use key='value' - They should be used ONLY for SQL queries, so are used - mostly internally - mask is either RELATIVE_NONE or RELATIVE_NONE|VFS_REAL, - and is used internally - outside is boolean, True if 'relatives' contains VFS_REAL - */ + /** + * take a real or fake pathname and return an array of its component parts + * + * @param string full real or fake path + * @param relatives Relativity array + * @param object True returns an object instead of an array + * @param nolinks Don't check for links (made with make_link ()). Used internally to prevent recursion + * @return $rarray/$robject Array or object containing the fake and real component parts of the path + * Returned values are: + * * mask + * * outside + * * fake_full_path + * * fake_leading_dirs + * * fake_extra_path * BROKEN + * * fake_name + * * real_full_path + * * real_leading_dirs + * * real_extra_path * BROKEN + * * real_name + * * fake_full_path_clean + * * fake_leading_dirs_clean + * * fake_extra_path_clean BROKEN + * * fake_name_clean + * * real_full_path_clean + * * real_leading_dirs_clean + * * real_extra_path_clean BROKEN + * * real_name_clean + * * real_uri + * "clean" values are run through vfs->db_clean () and + * are safe for use in SQL queries that use key='value' + * They should be used ONLY for SQL queries, so are used + * mostly internally + * 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) { $default_values = array @@ -620,8 +620,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); @@ -632,7 +632,7 @@ if ($data['object']) { - $robject = new path_class; + $robject =& new path_class; reset ($rarray); while (list ($key, $value) = each ($rarray)) @@ -663,14 +663,14 @@ } } - /*! - @function getabsolutepath - @abstract get the absolute path - @param string defaults to False, directory/file to get path of, relative to relatives[0] - @param mask Relativity bitmask (see RELATIVE_ defines). RELATIVE_CURRENT means use $this->relative - @param fake Returns the "fake" path, ie /home/user/dir/file (not always possible. use path_parts () instead) - @result $basedir Full fake or real path - */ + /** + * get the absolute path + * + * @param string defaults to False, directory/file to get path of, relative to relatives[0] + * @param mask Relativity bitmask (see RELATIVE_ defines). RELATIVE_CURRENT means use $this->relative + * @param fake Returns the "fake" path, ie /home/user/dir/file (not always possible. use path_parts () instead) + * @return $basedir Full fake or real path + */ function getabsolutepath ($data) { $default_values = array @@ -748,12 +748,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 */ @@ -773,26 +773,26 @@ return $basedir; } - /*! - @function acl_check - @abstract Check ACL access to $file for $GLOBALS['phpgw_info']["user"]["account_id"]; - @param string File to check access of - @discussion To check the access for a file or directory, pass 'string'/'relatives'/'must_exist'. - To check the access to another user or group, pass 'owner_id'. - If 'owner_id' is present, we bypass checks on 'string'/'relatives'/'must_exist' - @param relatives Standard relativity array - @param operation Operation to check access to. In the form of a PHPGW_ACL defines bitmask. Default is read - @param owner_id Owner id to check access of (see discussion above) - @param must_exist Boolean. Set to True if 'string' must exist. Otherwise, we check the parent directory as well - @result Boolean. True if access is ok, False otherwise - */ + /** + * Check ACL access to $file for $GLOBALS['egw_info']["user"]["account_id"]; + * + * @param string File to check access of + * To check the access for a file or directory, pass 'string'/'relatives'/'must_exist'. + * * To check the access to another user or group, pass 'owner_id'. + * * If 'owner_id' is present, we bypass checks on 'string'/'relatives'/'must_exist' + * @param relatives Standard relativity array + * @param operation Operation to check access to. In the form of a EGW_ACL defines bitmask. Default is read + * @param owner_id Owner id to check access of (see discussion above) + * @param must_exist Boolean. Set to True if 'string' must exist. Otherwise, we check the parent directory as well + * @return Boolean. True if access is ok, False otherwise + */ function acl_check ($data) { return True; $default_values = array ( 'relatives' => array (RELATIVE_CURRENT), - 'operation' => PHPGW_ACL_READ, + 'operation' => EGW_ACL_READ, 'must_exist' => False ); @@ -821,7 +821,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; } @@ -878,7 +878,7 @@ $owner_id = 0; } - $user_id = $GLOBALS['phpgw_info']['user']['account_id']; + $user_id = $GLOBALS['egw_info']['user']['account_id']; /* They always have access to their own files */ if ($owner_id == $user_id) @@ -887,7 +887,7 @@ } /* Check if they're in the group */ - $memberships = $GLOBALS['phpgw']->accounts->membership ($user_id); + $memberships = $GLOBALS['egw']->accounts->membership ($user_id); if (is_array ($memberships)) { @@ -902,7 +902,7 @@ } } - $acl = CreateObject ('phpgwapi.acl', $owner_id); + $acl =& CreateObject ('phpgwapi.acl', $owner_id); $acl->account_id = $owner_id; $acl->read_repository (); @@ -924,7 +924,7 @@ } elseif (!$rights && $group_ok) { - $conf = CreateObject('phpgwapi.config', 'phpgwapi'); + $conf =& CreateObject('phpgwapi.config', 'phpgwapi'); $conf->read_repository(); if ($conf->config_data['acl_default'] == 'grant') { @@ -941,14 +941,14 @@ } } - /*! - @function cd - @abstract Change directory - @discussion To cd to the files root '/', use cd ('/', False, array (RELATIVE_NONE)); - @param string default '/'. directory to cd into. if "/" and $relative is True, uses "/home/"; - @param relative default True/relative means add target to current path, else pass $relative as mask to getabsolutepath() - @param relatives Relativity array - */ + /** + * Change directory + * + * To cd to the files root '/', use cd ('/', False, array (RELATIVE_NONE)); + * @param string default '/'. directory to cd into. if "/" and $relative is True, uses "/home/"; + * @param relative default True/relative means add target to current path, else pass $relative as mask to getabsolutepath() + * @param relatives Relativity array + */ function cd ($data = '') { if (!is_array ($data)) @@ -990,7 +990,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]), @@ -1008,17 +1008,17 @@ ); } - $GLOBALS['phpgw']->session->appsession('vfs','',$basedir); + $GLOBALS['egw']->session->appsession('vfs','',$basedir); return True; } - /*! - @function pwd - @abstract current working dir - @param full default True returns full fake path, else just the extra dirs (false strips the leading /) - @result $currentdir currentdir - */ + /** + * current working dir + * + * @param full default True returns full fake path, else just the extra dirs (false strips the leading /) + * @return $currentdir currentdir + */ function pwd ($data = '') { $default_values = array @@ -1028,7 +1028,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']) { @@ -1045,20 +1045,20 @@ return $currentdir; } - /*! - @function read - @abstract return file contents - @param string filename - @param relatives Relativity array - @result $contents Contents of $file, or False if file cannot be read - */ + /** + * return file contents + * + * @param string filename + * @param relatives Relativity array + * @return $contents Contents of $file, or False if file cannot be read + */ function read ($data) { /*If the user really wants to 'view' the file in the browser, it is much smarter simply to redirect them to the files web-accessable url */ -/* $app = $GLOBALS['phpgw_info']['flags']['currentapp']; +/* $app = $GLOBALS['egw_info']['flags']['currentapp']; if ( ! $data['noview'] && ($app == 'phpwebhosting' || $app = 'filemanager' )) { $this->view($data); @@ -1085,7 +1085,7 @@ if (!$this->acl_check (array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), - 'operation' => PHPGW_ACL_READ + 'operation' => EGW_ACL_READ )) ) { @@ -1093,14 +1093,14 @@ } if ($p->outside) { - - if (! $fp = fopen ($p->real_full_path, 'r')) - { - return False; - } - $size=filesize($p->real_full_path); - $buffer=fread($fp, $size); - fclose ($fp); + + if (! $fp = fopen ($p->real_full_path, 'r')) + { + return False; + } + $size=filesize($p->real_full_path); + $buffer=fread($fp, $size); + fclose ($fp); return $buffer; } else @@ -1191,7 +1191,7 @@ $data = array_merge ($this->default_values ($data, $default_values), $data); - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + $ls_array = $GLOBALS['egw']->vfs->ls (array ( 'string' => $data['string'], 'relatives' => $data['relatives'] ) @@ -1228,7 +1228,7 @@ if (!strlen($data['token'])) { - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + $ls_array = $GLOBALS['egw']->vfs->ls (array ( 'string' => $data['string'], 'relatives' => $data['relatives'] ) @@ -1270,7 +1270,7 @@ if (!strlen($data['token'])) { - $ls_array = $GLOBALS['phpgw']->vfs->ls (array ( + $ls_array = $GLOBALS['egw']->vfs->ls (array ( 'string' => $data['string'], 'relatives' => $data['relatives'] ) @@ -1350,14 +1350,14 @@ } } - /*! - @function write - @abstract write to a file - @param string file name - @param relatives Relativity array - @param content content - @result Boolean True/False - */ + /** + * write to a file + * + * @param string file name + * @param relatives Relativity array + * @param content content + * @return Boolean True/False + */ function write ($data) { $default_values = array @@ -1380,12 +1380,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( @@ -1401,8 +1401,8 @@ //umask(000); /* - 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, @@ -1413,13 +1413,13 @@ $size=strlen($data['content']); if ($p->outside) { - if (! $fp = fopen ($p->real_full_path, 'w')) - { - return False; - } - $result = fwrite($fp, $data['content']); - fclose ($fp); - return $result; + if (! $fp = fopen ($p->real_full_path, 'w')) + { + return False; + } + $result = fwrite($fp, $data['content']); + fclose ($fp); + return $result; } else { @@ -1437,13 +1437,13 @@ $this->debug('Put complete, status: '.$status); } } - /*! - @function touch - @abstract Create blank file $file or set the modification time and modified by of $file to current time and user - @param string File to touch or set modifies - @param relatives Relativity array - @result Boolean True/False - */ + /** + * Create blank file $file or set the modification time and modified by of $file to current time and user + * + * @param string File to touch or set modifies + * @param relatives Relativity array + * @return Boolean True/False + */ function touch ($data) { $default_values = array( @@ -1451,23 +1451,23 @@ $this->debug('Put complete, status: '.$status); ); $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'], - 'relatives' => array ($data['relatives'][0]) - ) + 'string' => $data['string'], + 'relatives' => array ($data['relatives'][0]) + ) ); umask (000); /* - 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 */ if($p->outside) { - return @touch($p->real_full_path); + return @touch($p->real_full_path); } elseif ($this->file_exists (array( 'string' => $p->fake_full_path, @@ -1488,14 +1488,14 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), - 'operation' => PHPGW_ACL_ADD + 'operation' => EGW_ACL_ADD )) ) return False; $result = $this->write (array( - 'string' => $data['string'], - 'relatives' => array ($data['relatives'][0]), - 'content' => '' - )); + 'string' => $data['string'], + 'relatives' => array ($data['relatives'][0]), + 'content' => '' + )); $this->set_attributes(array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), @@ -1509,14 +1509,14 @@ $this->debug('Put complete, status: '.$status); return ($result); } - /*! - @function cp - @abstract copy file - @param from from file/directory - @param to to file/directory - @param relatives Relativity array - @result boolean True/False - */ + /** + * copy file + * + * @param from from file/directory + * @param to to file/directory + * @param relatives Relativity array + * @return boolean True/False + */ function cp ($data) { $default_values = array @@ -1526,7 +1526,7 @@ $this->debug('Put complete, status: '.$status); $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'], @@ -1543,7 +1543,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $f->fake_full_path, 'relatives' => array ($f->mask), - 'operation' => PHPGW_ACL_READ + 'operation' => EGW_ACL_READ )) ) { @@ -1556,19 +1556,19 @@ $this->debug('Put complete, status: '.$status); )) ) { - $remote_operation=PHPGW_ACL_EDIT; + $remote_operation=EGW_ACL_EDIT; } else { - $remote_operation=PHPGW_ACL_ADD; + $remote_operation=EGW_ACL_ADD; } if (!$this->acl_check (array( - 'string' => $t->fake_full_path, - 'relatives' => array ($t->mask), - 'operation' => $remote_operation - )) - ) + 'string' => $t->fake_full_path, + 'relatives' => array ($t->mask), + 'operation' => $remote_operation + )) + ) { return False; } @@ -1581,14 +1581,14 @@ $this->debug('Put complete, status: '.$status); )) != 'Directory' ) { - + if ($f->outside && $t->outside) { return copy($f->real_full_path, $t->real_full_url); } elseif ($f->outside || $t->outside) { - $content = $this->read(array( + $content = $this->read(array( 'string' => $f->fake_full_path, 'noview' => true, 'relatives' => array ($f->mask) @@ -1600,15 +1600,15 @@ $this->debug('Put complete, status: '.$status); 'content' => $content ) ); - } + } else { - $status=$this->dav_client->copy($f->real_full_path, $t->real_full_url,True, 'Infinity', $this->override_locks[$p->real_full_path]); - $result = $status == 204 || $status==201; - if (!$result) - { - return False; - } + $status=$this->dav_client->copy($f->real_full_path, $t->real_full_url,True, 'Infinity', $this->override_locks[$p->real_full_path]); + $result = $status == 204 || $status==201; + if (!$result) + { + return False; + } } $this->set_attributes(array( @@ -1627,14 +1627,14 @@ $this->debug('Put complete, status: '.$status); { //if the files are both on server, its just a depth=infinity copy $status=$this->dav_client->copy($f->real_full_path, $t->real_full_url,True, 'infinity', $this->override_locks[$p->real_full_path]); - if($status != 204 && $status!=201) - { - return False; - } - else - { - return True; - } + if($status != 204 && $status!=201) + { + return False; + } + else + { + return True; + } } else /* It's a directory, and one of the files is local */ { @@ -1696,14 +1696,14 @@ $this->debug('Put complete, status: '.$status); return $this->cp ($data); } - /*! - @function mv - @abstract move file/directory - @param from from file/directory - @param to to file/directory - @param relatives Relativity array - @result boolean True/False - */ + /** + * move file/directory + * + * @param from from file/directory + * @param to to file/directory + * @param relatives Relativity array + * @return boolean True/False + */ function mv ($data) { $default_values = array @@ -1713,7 +1713,7 @@ $this->debug('Put complete, status: '.$status); $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'], @@ -1730,12 +1730,12 @@ $this->debug('Put complete, status: '.$status); 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 )) ) { @@ -1745,7 +1745,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $t->fake_full_path, 'relatives' => array ($t->mask), - 'operation' => PHPGW_ACL_ADD + 'operation' => EGW_ACL_ADD )) ) { @@ -1761,7 +1761,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $t->fake_full_path, 'relatives' => array ($t->mask), - 'operation' => PHPGW_ACL_EDIT + 'operation' => EGW_ACL_EDIT )) ) { @@ -1847,7 +1847,7 @@ $this->debug('Put complete, status: '.$status); } else { //we can do a server-side copy if both files are on the server $status=$this->dav_client->move($f->real_full_path, $t->real_full_url,True, 'infinity', $this->override_locks[$p->real_full_path]); - $result = ($status==201 || $status==204); + $result = ($status==201 || $status==204); } if ($result) $this->set_attributes(array( @@ -1876,22 +1876,22 @@ $this->debug('Put complete, status: '.$status); return True; } - /*! - @function move - @abstract shortcut to mv - */ + /** + * shortcut to mv + * + */ function move ($data) { return $this->mv ($data); } - /*! - @function rm - @abstract delete file/directory - @param string file/directory to delete - @param relatives Relativity array - @result boolean True/False - */ + /** + * delete file/directory + * + * @param string file/directory to delete + * @param relatives Relativity array + * @return boolean True/False + */ function rm ($data) { $default_values = array @@ -1909,7 +1909,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), - 'operation' => PHPGW_ACL_DELETE + 'operation' => EGW_ACL_DELETE )) ) { @@ -1986,7 +1986,7 @@ $this->debug('Put complete, status: '.$status); ) ); - $query = $GLOBALS['phpgw']->db->query ("DELETE FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'" . $this->extra_sql (array ('query_type' => VFS_SQL_DELETE)), __LINE__, __FILE__); + $query = $GLOBALS['egw']->db->query ("DELETE FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND name='$p->fake_name_clean'" . $this->extra_sql (array ('query_type' => VFS_SQL_DELETE)), __LINE__, __FILE__); //rmdir ($p->real_full_path); $this->dav_client->delete($p->real_full_path.'/','Infinity', $this->override_locks[$p->real_full_path]); @@ -1995,22 +1995,22 @@ $this->debug('Put complete, status: '.$status); } } - /*! - @function delete - @abstract shortcut to rm - */ + /** + * shortcut to rm + * + */ function delete ($data) { return $this->rm ($data); } - /*! - @function mkdir - @abstract make a new directory - @param string Directory name - @param relatives Relativity array - @result boolean True on success - */ + /** + * make a new directory + * + * @param string Directory name + * @param relatives Relativity array + * @return boolean True on success + */ function mkdir ($data) { if (!is_array ($data)) @@ -2025,8 +2025,8 @@ $this->debug('Put complete, status: '.$status); $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'], @@ -2037,7 +2037,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), - 'operation' => PHPGW_ACL_ADD) + 'operation' => EGW_ACL_ADD) ) ) { @@ -2072,11 +2072,11 @@ $this->debug('Put complete, status: '.$status); $homedir = $this->fakebase.'/'.$this->dav_user; if ( substr($p->fake_leading_dirs, 0, strlen($homedir)) == $homedir) { - $conf = CreateObject('phpgwapi.config', 'phpgwapi'); + $conf =& CreateObject('phpgwapi.config', 'phpgwapi'); $conf->read_repository(); if (!$conf->config_data['acl_default'] == 'grant') { - $htaccess = 'require user '.$GLOBALS['phpgw_info']['user']['account_lid']; + $htaccess = 'require user '.$GLOBALS['egw_info']['user']['account_lid']; if ( ! $this->write(array( 'string' => $p->fake_full_path.'/.htaccess', 'content' => $htaccess, @@ -2095,16 +2095,16 @@ $this->debug('Put complete, status: '.$status); } } - /*! - @function make_link - @abstract Make a link from virtual directory 'vdir' to real directory 'rdir' - @discussion Making a link from 'vdir' to 'rdir' will cause path_parts () to substitute 'rdir' for the real - path variables when presented with 'vdir' - @param vdir Virtual dir to make link from - @param rdir Real dir to make link to - @param relatives Relativity array - @result Boolean True/False - */ + /** + * Make a link from virtual directory 'vdir' to real directory 'rdir' + * + * Making a link from 'vdir' to 'rdir' will cause path_parts () to substitute 'rdir' for the real + * * path variables when presented with 'vdir' + * @param vdir Virtual dir to make link from + * @param rdir Real dir to make link to + * @param relatives Relativity array + * @return Boolean True/False + */ function make_link ($data) { return False; //This code certainly wont work anymore. Does anything use it? @@ -2116,8 +2116,8 @@ $this->debug('Put complete, status: '.$status); $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']; $vp = $this->path_parts (array( 'string' => $data['vdir'], @@ -2134,7 +2134,7 @@ $this->debug('Put complete, status: '.$status); if (!$this->acl_check (array( 'string' => $vp->fake_full_path, 'relatives' => array ($vp->mask), - 'operation' => PHPGW_ACL_ADD + 'operation' => EGW_ACL_ADD )) ) return False; @@ -2177,31 +2177,31 @@ $this->debug('Put complete, status: '.$status); */ } - /*! - @function set_attributes - @abstract Update database entry for 'string' with the attributes in 'attributes' - @param string file/directory to update - @param relatives Relativity array - @param attributes keyed array of attributes. key is attribute name, value is attribute value - @result Boolean True/False - @discussion Valid attributes are: - owner_id - createdby_id - modifiedby_id - created - modified - size - mime_type - deleteable - comment - app - link_directory - link_name - version - name - directory - */ - function set_attributes ($data,$operation=PHPGW_ACL_EDIT) + /** + * Update database entry for 'string' with the attributes in 'attributes' + * + * @param string file/directory to update + * @param relatives Relativity array + * @param attributes keyed array of attributes. key is attribute name, value is attribute value + * @return Boolean True/False + * Valid attributes are: + * * owner_id + * * createdby_id + * * modifiedby_id + * * created + * * modified + * * size + * * mime_type + * * deleteable + * * comment + * * app + * * link_directory + * * link_name + * * version + * * name + * * directory + */ + function set_attributes ($data,$operation=EGW_ACL_EDIT) { /*To get much benefit out of DAV properties we should use some sensible XML namespace. We will use the Dublin Core @@ -2219,19 +2219,19 @@ $this->debug('Put complete, status: '.$status); } if ($id=$data['attributes']['owner_id']) { - $GLOBALS['phpgw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); + $GLOBALS['egw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); $dav_properties['dc:publisher'] = $fname .' '. $lname; $dav_properties['publisher_id'] = $id; } if ($id=$data['attributes']['createdby_id']) { - $GLOBALS['phpgw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); + $GLOBALS['egw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); $dav_properties['dc:creator'] = $fname .' '. $lname; $dav_properties['creator_id'] = $id; } if ($id=$data['attributes']['modifiedby_id']) { - $GLOBALS['phpgw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); + $GLOBALS['egw']->accounts->get_account_name($id,&$lid,&$fname,&$lname); $dav_properties['dc:contributor'] = $fname .' '. $lname; $dav_properties['contributor_id'] = $id; } @@ -2241,13 +2241,13 @@ $this->debug('Put complete, status: '.$status); 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) { $default_values = array @@ -2279,7 +2279,7 @@ $this->debug('correct_attributes: '.$data['string']); 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 @@ -2299,13 +2299,13 @@ $this->debug('correct_attributes: '.$data['string']); return True; } - /*! - @function file_type - @abstract return file/dir type (MIME or other) - @param string File or directory path (/home/user/dir/dir2/dir3, /home/user/dir/dir2/file) - @param relatives Relativity array - @result MIME type, "Directory", or nothing if MIME type is not known - */ + /** + * return file/dir type (MIME or other) + * + * @param string File or directory path (/home/user/dir/dir2/dir3, /home/user/dir/dir2/file) + * @param relatives Relativity array + * @return MIME type, "Directory", or nothing if MIME type is not known + */ function file_type ($data) { $this->debug('file_type'); @@ -2325,15 +2325,15 @@ $this->debug('file_type'); 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 )) ) return False; if ($p->outside) { - if(is_dir($p->real_full_path)) return ('Directory'); - else return $this->get_ext_mime_type(array('string' => $p->real_full_path)); + if(is_dir($p->real_full_path)) return ('Directory'); + else return $this->get_ext_mime_type(array('string' => $p->real_full_path)); } $tmp_prop=$this->dav_client->get_properties($p->real_full_path); @@ -2348,18 +2348,18 @@ $this->debug('file_type: Mime type : '.$mime_type); return $mime_type; } - /*! - @function get_ext_mime_type - @abstract return MIME type based on file extension - @description Authors: skeeter - Internal use only. Applications should call vfs->file_type () - @param string File name, with or without leading paths - @result MIME type based on file extension - */ + /** + * return MIME type based on file extension + * + * Authors: skeeter + * * Internal use only. Applications should call vfs->file_type () + * @param string File name, with or without leading paths + * @return MIME type based on file extension + */ function get_ext_mime_type ($data) { $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); @@ -2390,13 +2390,13 @@ $this->debug('file_type: Mime type : '.$mime_type); - /*! - @function file_exists - @abstract check if file/directory exists - @param string file/directory to check existance of - @param relatives Relativity array - @result Boolean True/False - */ + /** + * check if file/directory exists + * + * @param string file/directory to check existance of + * @param relatives Relativity array + * @return Boolean True/False + */ function file_exists ($data) { $default_values = array @@ -2415,7 +2415,7 @@ $this->debug('vfs->file_exists() data:'.$data['string']); $this->debug('vfs->file_exists() full_path: '.$p->real_full_path); if ($p->outside) { - return file_exists($p->real_full_path); + return file_exists($p->real_full_path); } $path = $p->real_full_path; @@ -2436,14 +2436,14 @@ $this->debug('vfs->file_exists() full_path: '.$p->real_full_path); } } - /*! - @function get_size - @abstract Return size of 'string' - @param string file/directory to get size of - @param relatives Relativity array - @param checksubdirs Boolean, recursively add the size of all sub directories as well? - @result Size of 'string' in bytes - */ + /** + * Return size of 'string' + * + * @param string file/directory to get size of + * @param relatives Relativity array + * @param checksubdirs Boolean, recursively add the size of all sub directories as well? + * @return Size of 'string' in bytes + */ function get_size ($data) { if (!is_array ($data)) @@ -2468,7 +2468,7 @@ $this->debug('vfs->file_exists() full_path: '.$p->real_full_path); 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 )) ) @@ -2477,11 +2477,11 @@ $this->debug('vfs->file_exists() full_path: '.$p->real_full_path); } /* - 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){ - return filesize($p->real_full_path); + return filesize($p->real_full_path); } $ls_array = $this->ls (array( @@ -2495,8 +2495,8 @@ $this->debug('vfs->file_exists() full_path: '.$p->real_full_path); while (list ($num, $file_array) = each ($ls_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)) @@ -2512,14 +2512,14 @@ $this->debug('size:getting size from fs: '.$size); 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)) @@ -2543,7 +2543,7 @@ $this->debug('size:getting size from fs: '.$size); if (!$this->acl_check (array( 'string' => $p->fake_full_path, 'relatives' => array ($p->mask), - 'operation' => PHPGW_ACL_ADD + 'operation' => EGW_ACL_ADD )) ) { @@ -2555,20 +2555,20 @@ $this->debug('size:getting size from fs: '.$size); } } - /*! - @function ls - @abstract get directory listing or info about a single file - @discussion Note: The entries are not guaranteed to be returned in any logical order - Note: The size for directories does not include subfiles/subdirectories. - If you need that, use $this->get_size () - @param string File or Directory - @param relatives Relativity array - @param checksubdirs Boolean, recursively list all sub directories as well? - @param mime_type Only return entries matching MIME-type 'mime_type'. Can be any MIME-type, "Directory" or "\ " for those without MIME types - @param nofiles Boolean. True means you want to return just the information about the directory $dir. If $dir is a file, $nofiles is implied. This is the equivalent of 'ls -ld $dir' - @param orderby How to order results. Note that this only works for directories inside the virtual root - @result array of arrays. Subarrays contain full info for each file/dir. - */ + /** + * get directory listing or info about a single file + * + * Note: The entries are not guaranteed to be returned in any logical order + * * Note: The size for directories does not include subfiles/subdirectories. + * * If you need that, use $this->get_size () + * @param string File or Directory + * @param relatives Relativity array + * @param checksubdirs Boolean, recursively list all sub directories as well? + * @param mime_type Only return entries matching MIME-type 'mime_type'. Can be any MIME-type, "Directory" or "\ " for those without MIME types + * @param nofiles Boolean. True means you want to return just the information about the directory $dir. If $dir is a file, $nofiles is implied. This is the equivalent of 'ls -ld $dir' + * @param orderby How to order results. Note that this only works for directories inside the virtual root + * @return array of arrays. Subarrays contain full info for each file/dir. + */ function ls ($data) { $default_values = array @@ -2717,24 +2717,24 @@ $this->debug('ls:returning 3:'); return $rarray; } - /*! - @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 KNOW WHAT YOU'RE DOING! - This is mostly working, but the command parser needs to be improved to take - files with spaces into consideration (those should be in ""). - @param command_line Unix-style command line with one of the commands in the $args array - @result $result The return value of the actual VFS call - */ + /** + * 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 to be improved to take + * * files with spaces into consideration (those should be in ""). + * @param command_line Unix-style command line with one of the commands in the $args array + * @return $result The return value of the actual VFS call + */ function command_line ($data) { if (!is_array ($data)) @@ -2840,7 +2840,7 @@ $this->debug('ls:returning 3:'); function default_values ($data, $default_values) { - if(!is_array($data)) $data=array(); + if(!is_array($data)) $data=array(); for ($i = 0; list ($key, $value) = each ($default_values); $i++) { if (!isset ($data[$key])) @@ -2904,14 +2904,14 @@ $this->debug('ls:returning 3:'); function save_session() { //Save the overrided locks in the session - $app = $GLOBALS['phpgw_info']['flags']['currentapp']; + $app = $GLOBALS['egw_info']['flags']['currentapp']; $a = array(); foreach ($this->override_locks as $name => $token) { $a[] = $name.';'.$token; } $session_data = implode('\n', $a); - $this->session = $GLOBALS['phpgw']->session->appsession ('vfs_dav',$app, base64_encode($session_data)); + $this->session = $GLOBALS['egw']->session->appsession ('vfs_dav',$app, base64_encode($session_data)); } } diff --git a/phpgwapi/inc/class.vfs_sql.inc.php b/phpgwapi/inc/class.vfs_sql.inc.php index 2a762637e5..06ce7eb6d3 100644 --- a/phpgwapi/inc/class.vfs_sql.inc.php +++ b/phpgwapi/inc/class.vfs_sql.inc.php @@ -1,33 +1,33 @@ * - * 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) * + * 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 '

'.lang('Path to user and group files HAS TO BE OUTSIDE of the webservers document-root!!!')."

\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 )); }