Updated to include arrayized parameters, single quotes, GLOBALS, and other changes

This commit is contained in:
Zone 2002-02-25 08:45:41 +00:00
parent c4feb39f23
commit 3363aea3bc
11 changed files with 1459 additions and 3765 deletions

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Introduction and Purpose</TITLE> <TITLE>phpgwapi - VFS Class: Introduction and Purpose</TITLE>
<LINK HREF="vfs-2.html" REL=next> <LINK HREF="vfs-2.html" REL=next>
@ -14,11 +14,12 @@ Previous
<HR> <HR>
<H2><A NAME="sec:introduction"></A> <A NAME="s1">1.</A> <A HREF="vfs.html#toc1">Introduction and Purpose</A></H2> <H2><A NAME="sec:introduction"></A> <A NAME="s1">1.</A> <A HREF="vfs.html#toc1">Introduction and Purpose</A></H2>
<P>The latest version of the VFS for phpGroupWare combines actual file system <P>The latest version of the VFS for phpGroupWare combines actual
manipulation with fully integrated database support. It features nearly transparent file system manipulation with fully integrated database support.
handling of files and directories, as well as files inside and outside the It features nearly transparent handling of files and directories,
virtual root. This document is intended to provide API and application developers as well as files inside and outside the virtual root. This document
with a guide to incorporating the VFS into their work.</P> is intended to provide API and application developers with a guide
to incorporating the VFS into their work.</P>
<HR> <HR>
<A HREF="vfs-2.html">Next</A> <A HREF="vfs-2.html">Next</A>
Previous Previous

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Basics</TITLE> <TITLE>phpgwapi - VFS Class: Basics</TITLE>
<LINK HREF="vfs-3.html" REL=next> <LINK HREF="vfs-3.html" REL=next>
<LINK HREF="vfs-1.html" REL=previous> <LINK HREF="vfs-1.html" REL=previous>
@ -17,24 +17,28 @@
<H2><A NAME="sec:prerequisites"></A> <A NAME="ss2.1">2.1</A> <A HREF="vfs.html#toc2.1">Prerequisites</A> <H2><A NAME="sec:prerequisites"></A> <A NAME="ss2.1">2.1</A> <A HREF="vfs.html#toc2.1">Prerequisites</A>
</H2> </H2>
<P>You must explicitly enable the VFS class. To do this, set "enable_vfs_class" <P>You must explicitly enable the VFS class. To do this, set 'enable_vfs_class'
to True in $phpgw_info[&quot;flags&quot;]. An example:</P> to True in $GLOBALS['phpgw_info']['flags'].
An example:</P>
<P> <P>
<PRE> <PRE>
$phpgw_info[&quot;flags&quot;] = array(&quot;currentapp&quot; =&gt; &quot;phpwebhosting&quot;, $GLOBALS['phpgw_info']['flags'] = array(
&quot;noheader&quot; =&gt; False, 'currentapp' =&gt; 'phpwebhosting',
&quot;noappheader&quot; =&gt; False, 'noheader' =&gt; False,
&quot;enable_vfs_class&quot; =&gt; True, 'noappheader' =&gt; False,
&quot;enable_browser_class&quot; =&gt; True); 'enable_vfs_class' =&gt; True,
'enable_browser_class' =&gt; True
);
</PRE> </PRE>
</P> </P>
<H2><A NAME="sec:concepts"></A> <A NAME="ss2.2">2.2</A> <A HREF="vfs.html#toc2.2">Concepts</A> <H2><A NAME="sec:concepts"></A> <A NAME="ss2.2">2.2</A> <A HREF="vfs.html#toc2.2">Concepts</A>
</H2> </H2>
<P>The VFS in located in phpgwapi/inc/class.vfs.inc.php. You can look over <P>The VFS in located in phpgwapi/inc/class.vfs_sql.inc.php. You
it, but I don't suggest trying to understand how it works. It isn't necessary can look over it, but I don't suggest trying to understand how it
to know its internals to use it, but you may find the inline comments helpful. works. It isn't necessary to know its internals to use it, but you
The basic things to keep in mind:</P> may find the inline comments helpful. The basic things to keep in
mind:</P>
<P> <P>
<UL> <UL>
<LI>Files and directories are synonymous in almost all cases</LI> <LI>Files and directories are synonymous in almost all cases</LI>
@ -42,64 +46,95 @@ The basic things to keep in mind:</P>
</P> </P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;mv ("file1", "dir/file2"); $GLOBALS['phpgw']-&gt;vfs-&gt;mv (array(
$phpgw-&gt;vfs-&gt;mv ("dir1", "dir/dir1"); 'from' =&gt; 'file1',
$phpgw-&gt;vfs-&gt;rm ("file"); 'to' =&gt; 'dir/file2'
$phpgw-&gt;vfs-&gt;rm ("dir"); ));
$GLOBALS['phpgw']-&gt;vfs-&gt;mv (array(
'from' =&gt; 'dir1',
'to' =&gt; 'dir/dir1'
));
$GLOBALS['phpgw']-&gt;vfs-&gt;rm (array(
'string' =&gt; 'file'
));
$GLOBALS['phpgw']-&gt;vfs-&gt;rm (array(
'string' =&gt; 'dir'
));
</PRE> </PRE>
</P> </P>
<P>All work as you would except them to. The major exception is:</P> <P>All work as you would except them to. The major exception is:</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;touch ("file"); $GLOBALS['phpgw']-&gt;vfs-&gt;touch (array(
'string' =&gt; 'file'
));
</PRE> </PRE>
</P> </P>
<P>vs.</P> <P>vs.</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;mkdir ("dir"); $GLOBALS['phpgw']-&gt;vfs-&gt;mkdir (array(
'string' =&gt; 'dir'
));
</PRE> </PRE>
</P> </P>
<P> <P>
<UL> <UL>
<LI>Users and groups and synonymous</LI> <LI>Users and groups are synonymous</LI>
</UL> </UL>
</P> </P>
<P>As far as the actual paths are concerned, users and groups are the same. <P>As far as the actual paths are concerned, users and groups are
The VFS has no built in ACL support, so /home/username works the same as /home/groupname. the same. /home/username works the same as /home/groupname.</P>
See the note on ACL support in the Notes section.</P>
<P> <P>
<UL> <UL>
<LI>You should never have to know the real path of files</LI> <LI>You should never have to know the real paths of files</LI>
</UL> </UL>
</P> </P>
<P>One of the VFS's responsibilities is to translate paths for you. While <P>One of the VFS's responsibilities is to translate paths for you.
you certainly <EM>can</EM> operate using full paths, it is much simpler to use the virtual While you certainly <EM>can</EM> operate using full paths, it is much simpler
paths. For example, instead of using:</P> to use the virtual paths. For example, instead of using:</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;cp ("/var/www/phpgroupware/files/home/user/file1", "/var/www/phpgroupware/files/home/user/file2", array (RELATIVE_NONE|VFS_REAL, RELATIVE_NONE|VFS_REAL)); $GLOBALS['phpgw']-&gt;vfs-&gt;cp (array(
'from' =&gt; '/var/www/phpgroupware/files/home/user/file1',
'to' =&gt; '/var/www/phpgroupware/files/home/user/file2',
'relatives' =&gt; array(
RELATIVE_NONE|VFS_REAL,
RELATIVE_NONE|VFS_REAL
)
));
</PRE> </PRE>
</P> </P>
<P>you might use</P> <P>you might use</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;cp ("/home/user/file1", "/home/user/file2", array (RELATIVE_NONE, RELATIVE_NONE)); $GLOBALS['phpgw']-&gt;vfs-&gt;cp (array(
'from' =&gt; '/home/user/file1',
'to' =&gt; '/home/user/file2',
'relatives' =&gt; array(
RELATIVE_NONE,
RELATIVE_NONE
)
));
</PRE> </PRE>
</P> </P>
<P>(We'll get to the RELATIVE's in a minute.)</P> <P>(We'll get to the RELATIVE's in a minute.)</P>
<P>Site administrators should be able to move their files dir around on their <P>Site administrators should be able to move their files dir around
system and know that everything will continue to work smoothly.</P> on their system and know that everything will continue to work smoothly.</P>
<P> <P>
<UL> <UL>
<LI>Relativity is <EM>vital</EM></LI> <LI>Relativity is <EM>vital</EM></LI>
</UL> </UL>
</P> </P>
<P>Relativity is a new feature in the VFS, and its importance cannot be stressed <P>Relativity is a new feature in the VFS, and its importance cannot
enough. It will make your life much easier, especially for file system intensive be stressed enough. It will make your life much easier, especially
applications, but it will take some getting used to. If something doesn't work for file system intensive applications, but it will take some getting
right the first time, chances are great it has to do with incorrect relativity used to. If something doesn't work right the first time, chances
settings. We will deal with relativity in depth in the Relativity section.</P> are great it has to do with incorrect relativity settings. We will
deal with relativity in depth in the Relativity section.</P>
<HR> <HR>
<A HREF="vfs-3.html">Next</A> <A HREF="vfs-3.html">Next</A>
<A HREF="vfs-1.html">Previous</A> <A HREF="vfs-1.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Basic Functions</TITLE> <TITLE>phpgwapi - VFS Class: Basic Functions</TITLE>
<LINK HREF="vfs-4.html" REL=next> <LINK HREF="vfs-4.html" REL=next>
<LINK HREF="vfs-2.html" REL=previous> <LINK HREF="vfs-2.html" REL=previous>
@ -14,23 +14,28 @@
<HR> <HR>
<H2><A NAME="sec:basic_functions"></A> <A NAME="s3">3.</A> <A HREF="vfs.html#toc3">Basic Functions</A></H2> <H2><A NAME="sec:basic_functions"></A> <A NAME="s3">3.</A> <A HREF="vfs.html#toc3">Basic Functions</A></H2>
<P>These are two functions you'll need to know before we get into relativity.</P> <P>These are two functions you'll need to know before we get into
relativity.</P>
<H2><A NAME="sec:path_parts"></A> <A NAME="ss3.1">3.1</A> <A HREF="vfs.html#toc3.1">path_parts ()</A> <H2><A NAME="sec:path_parts"></A> <A NAME="ss3.1">3.1</A> <A HREF="vfs.html#toc3.1">path_parts ()</A>
</H2> </H2>
<P>The job of path_parts () is to translate any given file location into its <P>The job of path_parts () is to translate any given file location
many component parts for any relativity. The prototype for path_parts () is:</P> into its many component parts for any relativity. The values passed
to path_parts () are:</P>
<P> <P>
<PRE> <PRE>
function path_parts ($string, $relatives = array (RELATIVE_CURRENT), $object = True) string
relatives
object
</PRE> </PRE>
</P> </P>
<P>$string is the path you want to translate, $relatives is <P>'string' is the path you want to translate, 'relatives' is the
the standard relativity array, and $object specifies how you would like standard relativity array, and 'object' specifies how you would like
the return value: if $object is True, an object will be returned; if the return value: if 'object' is True, an object will be returned;
$object is False, an array will be returned. I think you'll find the if 'object' is False, an array will be returned. I think you'll find
object easier to deal with, and we'll be using it throughout this document. the object easier to deal with, and we'll be using it throughout
The most important returned values (but not all) for path_parts () are:</P> this document. The most important returned values (but not all) for
path_parts () are:</P>
<P> <P>
<PRE> <PRE>
fake_full_path fake_full_path
@ -43,15 +48,21 @@ real_extra_path
real_name real_name
</PRE> </PRE>
</P> </P>
<P>Just like you would think, fake_full_path contains the full virtual path <P>Just like you would think, fake_full_path contains the full virtual
of $string, and real_full_path contains the full real path of $string. path of 'string', and real_full_path contains the full real path
The fake_name and real_name variables should always be the same, and contain of 'string'. The fake_name and real_name variables should always
the final file or directory name. The leading_dirs contain everything except be the same, and contain the final file or directory name. The leading_dirs
the name, and the extra_path is everything from the / before "home" to the end contain everything except the name, and the extra_path is everything
of the leading_dirs. To better illustrate, here is an example:</P> from the / before "home" to the end of the leading_dirs. To better
illustrate, here is an example:</P>
<P> <P>
<PRE> <PRE>
$p = $phpgw-&gt;vfs-&gt;path_parts ("/home/jason/dir/file", array (RELATIVE_NONE)); $p = $GLOBALS['phpgw']-&gt;vfs-&gt;path_parts (array(
'string' =&gt; '/home/jason/dir/file',
'relatives' =&gt; array(
RELATIVE_NONE
)
));
</PRE> </PRE>
</P> </P>
<P> <P>
@ -67,31 +78,48 @@ $p = $phpgw-&gt;vfs-&gt;path_parts ("/home/jason/dir/file", array (RELATIVE_NONE
<LI>$p-&gt;real_name - file</LI> <LI>$p-&gt;real_name - file</LI>
</UL> </UL>
</P> </P>
<P>As you can see, path_parts () is a very useful function and will save you <P>As you can see, path_parts () is a very useful function and will
from doing those darn substr ()'s yourself. For those of you used to the prior save you from doing those darn substr ()'s yourself. For those of
VFS, note that <EM>getabsolutepath () is depreciated</EM>. getabsolutepath () still you used to the prior VFS, note that <EM>getabsolutepath () is depreciated</EM>.
exists (albeit in a much different form), and is responsible for some of the getabsolutepath () still exists (albeit in a much different form),
path translation, but it is an <EM>internal</EM> function only. Applications should and is responsible for some of the path translation, but it is an
only use path_parts (). We have shown you how to use path_parts () so you can <EM>internal</EM> function only. Applications should only use path_parts ().
experiment with it using different paths and relativities as we explore relativity.</P> We have shown you how to use path_parts () so you can experiment
with it using different paths and relativities as we explore relativity.</P>
<H2><A NAME="sec:cd"></A> <A NAME="ss3.2">3.2</A> <A HREF="vfs.html#toc3.2">cd ()</A> <H2><A NAME="sec:cd"></A> <A NAME="ss3.2">3.2</A> <A HREF="vfs.html#toc3.2">cd ()</A>
</H2> </H2>
<P>Part of the overall goal for the VFS in phpGroupWare is to give the user <P>Part of the overall goal for the VFS in phpGroupWare is to give
a seamless experience during their session. For example, if they upload a file the user a seamless experience during their session. For example,
using a file manager to /home/my_group/project1, and then go to download an if they upload a file using a file manager to the directory /home/my_group/project1,
email attachment, the default directory will be /home/my_group/project1. This and then go to download an email attachment, the default directory
is accomplished using the cd () function. The prototype and examples: </P> will be /home/my_group/project1. This is accomplished using the cd
() function. Examples: </P>
<P> <P>
<PRE> <PRE>
function cd ($target = &quot;/&quot;, $relative = True, $relatives = array (RELATIVE_CURRENT)) /* cd to their home directory */
$phpgw-&gt;vfs-&gt;cd ("/"); /* cd to their home directory */ $GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
$phpgw-&gt;vfs-&gt;cd ("/home/jason/dir", False, array (RELATIVE_NONE)); /* cd to /home/jason/dir */ 'string' =&gt; '/'
$phpgw-&gt;vfs-&gt;cd ("dir2", True); /* When following the above, cd's to /home/jason/dir/dir2 */ ));
/* cd to /home/jason/dir */
$GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
'string' =&gt; '/home/jason/dir',
'relative' =&gt; False,
'relatives' =&gt; array(
RELATIVE_NONE
)
));
/* When following the above, cd's to /home/jason/dir/dir2 */
$GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
'string' =&gt; 'dir2',
'relative' =&gt; True
));
</PRE> </PRE>
</P> </P>
<P>If $relatives is True, the $target is simply appended to <P>If 'relative' is True, the 'string' is simply appended to the
the current path. If you want to know what the current path is, use $phpgw-&gt;vfs-&gt;pwd current path. If you want to know what the current path is, use $GLOBALS['phpgw']-&gt;vfs-&gt;pwd
().</P> ().</P>
<P>Now you're ready for relativity.</P> <P>Now you're ready for relativity.</P>
<HR> <HR>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Relativity</TITLE> <TITLE>phpgwapi - VFS Class: Relativity</TITLE>
<LINK HREF="vfs-5.html" REL=next> <LINK HREF="vfs-5.html" REL=next>
<LINK HREF="vfs-3.html" REL=previous> <LINK HREF="vfs-3.html" REL=previous>
@ -14,34 +14,42 @@
<HR> <HR>
<H2><A NAME="sec:relativity"></A> <A NAME="s4">4.</A> <A HREF="vfs.html#toc4">Relativity</A></H2> <H2><A NAME="sec:relativity"></A> <A NAME="s4">4.</A> <A HREF="vfs.html#toc4">Relativity</A></H2>
<P>Ok, just one last thing before we get into relativity. You will notice <P>Ok, just one last thing before we get into relativity. You will
throughout the examples the use of $fakebase. $phpgw-&gt;vfs&gt;fakebase notice throughout the examples the use of $fakebase. $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase
is by default "/home". The old VFS was hard-coded to use "/home", but the naming is by default '/home'. The old VFS was hard-coded to use '/home',
choice for this is now up to administrators. See the "Notes - Fakebase directory" but the naming choice for this is now up to administrators. See the
section for more information. Throughout the rest of this document, you will <A HREF="vfs-6.html#sec:fakebase">Fakebase directory (changing /home)</A> section for more information. Throughout the rest of this document,
see $fakebase used in calls to the VFS, and /home used in actual paths. you will see $fakebase used in calls to the VFS, and /home
<EM>You should always use $fakebase when making applications. </EM>I suggest used in actual paths. <EM>You should always use $fakebase when
doing $fakebase = $phpgw-&gt;vfs-&gt;fakebase; right off the making applications. </EM>I suggest doing $fakebase = $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase;
bat to keep things neater.</P> right off the bat to keep things neater.</P>
<H2><A NAME="ss4.1">4.1</A> <A HREF="vfs.html#toc4.1">What is it and how does it work?</A> <H2><A NAME="ss4.1">4.1</A> <A HREF="vfs.html#toc4.1">What is it and how does it work?</A>
</H2> </H2>
<P>One of the design challenges for a Virtual File System is to try to figure <P>One of the design challenges for a Virtual File System is to
out whether the calling application is referring to a file inside or outside try to figure out whether the calling application is referring to
the virtual root, and if inside, exactly where. To solve this problem, the a file inside or outside the virtual root, and if inside, exactly
phpGroupWare VFS uses RELATIVE defines that are used in bitmasks passed to where. To solve this problem, the phpGroupWare VFS uses RELATIVE
each function. The result is that any set of different relativities can be defines that are used in bitmasks passed to each function. The result
used in combination with each other. Let's look at a few examples. Say you is that any set of different relativities can be used in combination
want to move "logo.png" from the user's home directory to the current directory.</P> with each other. Let's look at a few examples. Say you want to move
'logo.png' from the user's home directory to the current directory.</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;mv ("logo.png", "", array (RELATIVE_USER, RELATIVE_ALL)); $GLOBALS['phpgw']-&gt;vfs-&gt;mv (array(
'from' =&gt; 'logo.png',
'to' =&gt; 'logo.png',
'relatives' =&gt; array(
RELATIVE_USER,
RELATIVE_ALL
)
));
</PRE> </PRE>
</P> </P>
<P>RELATIVE_USER means relative to the user's home directory. RELATIVE_ALL <P>RELATIVE_USER means relative to the user's home directory. RELATIVE_ALL
means relative to the current directory, as set by cd () and as reported by means relative to the current directory, as set by cd () and as reported
pwd (). So if the current directory was "$fakebase/my_group/project1", by pwd (). So if the current directory was "$fakebase/my_group/project1",
the call to mv () would be processed as:</P> the call to mv () would be processed as:</P>
<P> <P>
<PRE> <PRE>
@ -51,102 +59,140 @@ MOVE "$fakebase/jason/logo.png" TO "$fakebase/my_group/project1/logo.png"
<P>and the actual file system call would be:</P> <P>and the actual file system call would be:</P>
<P> <P>
<PRE> <PRE>
rename ("/var/www/phpgroupware/files/home/jason/logo.php", "/var/www/phpgroupware/files/home/my_group/project1/logo.png"); rename ('/var/www/phpgroupware/files/home/jason/logo.php', '/var/www/phpgroupware/files/home/my_group/project1/logo.png');
</PRE> </PRE>
</P> </P>
<P>Those used to the old VFS will note that you do not have to translate the <P>Those used to the old VFS will note that you do not have to translate
path beforehand. Let's look at another example. Suppose you were moving an the path beforehand. Let's look at another example. Suppose you were
email attachment stored in phpGroupWare's temporary directory to the "attachments" moving an email attachment stored in phpGroupWare's temporary directory
directory within the user's home directory (we're assuming the attachments to the 'attachments' directory within the user's home directory (we're
directory exists). Note that the temporary directory is <EM>outside</EM> the virtual assuming the attachments directory exists). Note that the temporary
root.</P> directory is <EM>outside</EM> the virtual root.</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;mv ("$phpgw_info[server][temp_dir]/$randomdir/$randomfile", "attachments/actual_name.ext", array (RELATIVE_NONE|VFS_REAL, RELATIVE_USER)); $GLOBALS['phpgw']-&gt;vfs-&gt;mv (array(
'from' =&gt; $GLOBALS['phpgw_info']['server']['temp_dir'] . '/' . $randomdir . '/' . $randomfile,
'to' =&gt; 'attachments/actual_name.ext',
'relatives' =&gt; array(
RELATIVE_NONE|VFS_REAL,
RELATIVE_USER
)
));
</PRE> </PRE>
</P> </P>
<P>$randomdir and $randomfile are what the directory and file <P>$randomdir and $randomfile are what the directory
might be called before they are given a proper name by the user, which is actual_name.ext and file might be called before they are given a proper name by the
in this example. RELATIVE_NONE is the define for using full path names. However, user, which is actual_name.ext in this example. RELATIVE_NONE is
RELATIVE_NONE is still relative to the virtual root, so we pass along VFS_REAL the define for using full path names. However, RELATIVE_NONE is still
as well, to say that the file is <EM>outside</EM> the virtual root, somewhere else in relative to the virtual root, so we pass along VFS_REAL as well,
the file system. Once again, RELATIVE_USER means relative to the user's home to say that the file is <EM>outside</EM> the virtual root, somewhere else
directory. So the actual file system call might look like this (keep in mind in the file system. Once again, RELATIVE_USER means relative to the
that $randomdir and $randomfile are just random strings):</P> user's home directory. So the actual file system call might look
like this (keep in mind that $randomdir and $randomfile
are just random strings):</P>
<P> <P>
<PRE> <PRE>
rename ("/var/www/phpgroupware/tmp/0ak5adftgh7/jX42sC9M", "/var/www/phpgroupware/files/home/jason/attachments/actual_name.ext"); rename ('/var/www/phpgroupware/tmp/0ak5adftgh7/jX42sC9M', '/var/www/phpgroupware/files/home/jason/attachments/actual_name.ext');
</PRE> </PRE>
</P> </P>
<P>Of course you don't have to know that, nor should you be concerned with <P>Of course you don't have to know that, nor should you be concerned
it; you can take it for granted that the VFS will translate the paths correctly. with it; you can take it for granted that the VFS will translate
Let's take a look at one more example, this time using the RELATIVE_USER_APP the paths correctly. Let's take a look at one more example, this
define. RELATIVE_USER_APP is used to store quasi-hidden application files, time using the RELATIVE_USER_APP define. RELATIVE_USER_APP is used
similar to the Unix convention of ~/.appname. It simply appends .appname to store quasi-hidden application files, similar to the Unix convention
to the user's home directory. For example, if you were making an HTML editor of ~/.appname. It simply appends .appname to the user's home
application named htmledit, and wanted to keep a backup file in case something directory. For example, if you were making an HTML editor application
goes wrong, you would use RELATIVE_USER_APP to store it:</P> named 'htmledit', and wanted to keep a backup file in case something
goes wrong, you could use RELATIVE_USER_APP to store it:</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;write ("file.name~", array (RELATIVE_USER_APP), $contents); $GLOBALS['phpgw']-&gt;vfs-&gt;write (array(
'string' =&gt; 'file.name~',
'relatives' =&gt; array(
RELATIVE_USER_APP
),
'content' =&gt; $contents
));
</PRE> </PRE>
</P> </P>
<P>This assumes that ~/.htmledit exists of course. The backup file "file.name~" <P>This assumes that ~/.htmledit exists of course. The backup
would then be written in $fakebase/jason/.htmledit/file.name~. file "file.name~" would then be written in $fakebase/jason/.htmledit/file.name~.
Note that storing files like this might not be as good of a solution as storing Note that storing files like this might not be as good of a solution
them in the temporary directory or in the database. But it is there in case as storing them in the temporary directory or in the database. But
you need it.</P> it is there in case you need it.</P>
<H2><A NAME="sec:relatives_complete_list"></A> <A NAME="ss4.2">4.2</A> <A HREF="vfs.html#toc4.2">Complete List</A> <H2><A NAME="sec:relatives_complete_list"></A> <A NAME="ss4.2">4.2</A> <A HREF="vfs.html#toc4.2">Complete List</A>
</H2> </H2>
<P>Here is the complete list of RELATIVE defines, and what they do:</P> <P>Here is the complete list of RELATIVE defines, and what they
do:</P>
<P> <P>
<DL> <DL>
<DT><B>RELATIVE_ROOT</B><DD><P>Don't translate the path at all. Just prepends a /. <DT><B>RELATIVE_ROOT</B><DD><P>Don't translate the path at all. Just prepends
You'll probably want to use RELATIVE_NONE though, which handles both virtual a /. You'll probably want to use RELATIVE_NONE though, which handles
and real files.</P> both virtual and real files.</P>
<DT><B>RELATIVE_USER</B><DD><P>User's home directory</P> <DT><B>RELATIVE_USER</B><DD><P>User's home directory</P>
<DT><B>RELATIVE_CURR_USER</B><DD><P>Current user's home directory. If the current <DT><B>RELATIVE_CURR_USER</B><DD><P>Current user's home directory. If the
directory is $fakebase/my_group/project1, this will return is $fakebase/my_group</P> current directory is $fakebase/my_group/project1, this will
<DT><B>RELATIVE_USER_APP</B><DD><P>Append .appname to the user's home directory, where return is $fakebase/my_group</P>
appname is the current application's appname</P> <DT><B>RELATIVE_USER_APP</B><DD><P>Append .appname to the user's home directory,
<DT><B>RELATIVE_PATH</B><DD><P>DO NOT USE. Relative to the current directory, used where appname is the current application's appname</P>
in RELATIVE_ALL</P> <DT><B>RELATIVE_PATH</B><DD><P>DO NOT USE. Relative to the current directory,
<DT><B>RELATIVE_NONE</B><DD><P>Not relative to anything. Use this with VFS_REAL for used in RELATIVE_ALL</P>
files outside the virtual root. Note that using RELATIVE_NONE by itself still <DT><B>RELATIVE_NONE</B><DD><P>Not relative to anything. Use this with VFS_REAL
means relative to the virtual root</P> for files outside the virtual root. Note that using RELATIVE_NONE
<DT><B>RELATIVE_CURRENT</B><DD><P>An alias for the currently set RELATIVE define, by itself still means relative to the virtual root</P>
or RELATIVE_ALL if none is set (see the Defaults section)</P> <DT><B>RELATIVE_CURRENT</B><DD><P>An alias for the currently set RELATIVE
<DT><B>VFS_REAL</B><DD><P>File is outside of the virtual root. Usually used with RELATIVE_NONE</P> define, or RELATIVE_ALL if none is set (see the Defaults section)</P>
<DT><B>VFS_REAL</B><DD><P>File is outside of the virtual root. Usually used
with RELATIVE_NONE</P>
<DT><B>RELATIVE_ALL</B><DD><P>Relative to the current directory. Use RELATIVE_ALL<EM></EM>instead of RELATIVE_PATH</P> <DT><B>RELATIVE_ALL</B><DD><P>Relative to the current directory. Use RELATIVE_ALL<EM></EM>instead of RELATIVE_PATH</P>
</DL> </DL>
</P> </P>
<H2><A NAME="sec:relatives_defaults"></A> <A NAME="ss4.3">4.3</A> <A HREF="vfs.html#toc4.3">Defaults</A> <H2><A NAME="sec:relatives_defaults"></A> <A NAME="ss4.3">4.3</A> <A HREF="vfs.html#toc4.3">Defaults</A>
</H2> </H2>
<P>You might be thinking to yourself that passing along RELATIVE defines with <P>You might be thinking to yourself that passing along RELATIVE
every VFS call is overkill, especially if your application always uses the defines with every VFS call is overkill, especially if your application
same relativity. The default RELATIVE define for all VFS calls is RELATIVE_CURRENT. always uses the same relativity. The default RELATIVE define for
RELATIVE_CURRENT itself defaults to RELATIVE_ALL (relative to the current path), all VFS calls is RELATIVE_CURRENT. RELATIVE_CURRENT itself defaults
<EM>unless</EM> your application sets a specific relativity. If your application requires to RELATIVE_ALL (relative to the current path), <EM>unless</EM> your application
most of the work to be done outside of the virtual root, you may wish to set sets a specific relativity. If your application requires most of
RELATIVE_CURRENT to RELATIVE_NONE|VFS_REAL. set_relative () is the function the work to be done outside of the virtual root, you may wish to
to do this. For example:</P> set RELATIVE_CURRENT to RELATIVE_NONE|VFS_REAL. set_relative () is
the function to do this. For example:</P>
<P> <P>
<PRE> <PRE>
$phpgw-&gt;vfs-&gt;set_relative (RELATIVE_NONE|VFS_REAL); $GLOBALS['phpgw']-&gt;vfs-&gt;set_relative (array(
$phpgw-&gt;vfs-&gt;read ("/etc/passwd"); 'mask' =&gt; RELATIVE_NONE|VFS_REAL
$phpgw-&gt;vfs-&gt;cp ("/usr/include/stdio.h", "/tmp/stdio.h"); ));
$phpgw-&gt;vfs-&gt;cp ("/usr/share/pixmaps/yes.xpm", "icons/yes.xpm", array (RELATIVE_CURRENT, RELATIVE_USER));
$GLOBALS['phpgw']-&gt;vfs-&gt;read (array(
'string' =&gt; '/etc/passwd'
));
$GLOBALS['phpgw']-&gt;vfs-&gt;cp (array(
'from' =&gt; '/usr/include/stdio.h',
'to' =&gt; '/tmp/stdio.h'
));
$GLOBALS['phpgw']-&gt;vfs-&gt;cp (array(
'from' =&gt; '/usr/share/pixmaps/yes.xpm',
'to' =&gt; 'icons/yes.xpm',
'relatives' =&gt; array(
RELATIVE_CURRENT,
RELATIVE_USER
)
));
</PRE> </PRE>
</P> </P>
<P>You should notice that no relativity array is needed in the other calls <P>You should notice that no relativity array is needed in the other
that refer to files outside the virtual root, but one is needed for calls that calls that refer to files outside the virtual root, but one is needed
include files inside the virtual root. Any RELATIVE define can be set as the for calls that include files inside the virtual root. Any RELATIVE
default and works in the same fashion. To retrieve the currently set define, define can be set as the default and works in the same fashion. To
use get_relative (). Note that the relativity is reset after each page request; retrieve the currently set define, use get_relative (). Note that
that is, it's good only for the life of the current page loading, and is not the relativity is reset after each page request; that is, it's good
stored in session management.</P> only for the life of the current page loading, and is not stored
in session management.</P>
<HR> <HR>
<A HREF="vfs-5.html">Next</A> <A HREF="vfs-5.html">Next</A>
<A HREF="vfs-3.html">Previous</A> <A HREF="vfs-3.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Function reference</TITLE> <TITLE>phpgwapi - VFS Class: Function reference</TITLE>
<LINK HREF="vfs-6.html" REL=next> <LINK HREF="vfs-6.html" REL=next>
<LINK HREF="vfs-4.html" REL=previous> <LINK HREF="vfs-4.html" REL=previous>
@ -14,395 +14,9 @@
<HR> <HR>
<H2><A NAME="sec:function_reference"></A> <A NAME="s5">5.</A> <A HREF="vfs.html#toc5">Function reference</A></H2> <H2><A NAME="sec:function_reference"></A> <A NAME="s5">5.</A> <A HREF="vfs.html#toc5">Function reference</A></H2>
<H2><A NAME="sec:function_reference_about"></A> <A NAME="ss5.1">5.1</A> <A HREF="vfs.html#toc5.1">About</A> <P>To view the function reference for the VFS, use the doc/inlinedocparser.php
</H2> script that comes with phpGroupWare, ie
<A HREF="http://localhost/doc/inlinedocparser.php?fn=class.vfs_sql.inc.php">http://localhost/doc/inlinedocparser.php?fn=class.vfs_sql.inc.php</A>.</P>
<P>This function reference is periodically auto-generated from the inline
comments in phpgwapi/inc/class.vfs.inc.php. For the most up-to-date (and nicer
looking) reference, see class.vfs.inc.php. This reference is created as a separate
DocBook document (using the inline2lyx.pl script), so it might look a bit out
of place.</P>
<H2><A NAME="sec: class vfs"></A> <A NAME="ss5.2">5.2</A> <A HREF="vfs.html#toc5.2">class vfs</A>
</H2>
<P>abstract: virtual file system</P>
<P>description: Authors: Zone, Seek3r</P>
<H2><A NAME="sec: class path_class"></A> <A NAME="ss5.3">5.3</A> <A HREF="vfs.html#toc5.3">class path_class</A>
</H2>
<P>abstract: helper class for path_parts</P>
<H2><A NAME="sec: vfs"></A> <A NAME="ss5.4">5.4</A> <A HREF="vfs.html#toc5.4">vfs</A>
</H2>
<P>abstract: constructor, sets up variables</P>
<P>
<PRE>
function vfs ()
</PRE>
</P>
<H2><A NAME="sec: set_relative"></A> <A NAME="ss5.5">5.5</A> <A HREF="vfs.html#toc5.5">set_relative</A>
</H2>
<P>abstract: Set path relativity</P>
<P>param: $mask Relative bitmask (see RELATIVE_ defines)</P>
<P>
<PRE>
function set_relative ($mask)
</PRE>
</P>
<H2><A NAME="sec: get_relative"></A> <A NAME="ss5.6">5.6</A> <A HREF="vfs.html#toc5.6">get_relative</A>
</H2>
<P>abstract: Return relativity bitmask</P>
<P>discussion: Returns relativity bitmask, or the default of &quot;completely
relative&quot; if unset</P>
<P>
<PRE>
function get_relative ()
</PRE>
</P>
<H2><A NAME="sec: sanitize"></A> <A NAME="ss5.7">5.7</A> <A HREF="vfs.html#toc5.7">sanitize</A>
</H2>
<P>abstract: Removes leading .'s from $string</P>
<P>discussion: You should not pass all filenames through sanitize () unless
you plan on rejecting</P>
<P>.files. Instead, pass the name through securitycheck () first, and if
it fails,</P>
<P>pass it through sanitize</P>
<P>param: $string string to sanitize</P>
<P>result: $string without it's leading .'s</P>
<P>
<PRE>
function sanitize ($string)
</PRE>
</P>
<H2><A NAME="sec: securitycheck"></A> <A NAME="ss5.8">5.8</A> <A HREF="vfs.html#toc5.8">securitycheck</A>
</H2>
<P>abstract: Security check function</P>
<P>discussion: Checks for basic violations such as ..</P>
<P>If securitycheck () fails, run your string through vfs-&gt;sanitize ()</P>
<P>param: $string string to check security of</P>
<P>result: Boolean True/False. True means secure, False means insecure</P>
<P>
<PRE>
function securitycheck ($string)
</PRE>
</P>
<H2><A NAME="sec: db_clean"></A> <A NAME="ss5.9">5.9</A> <A HREF="vfs.html#toc5.9">db_clean</A>
</H2>
<P>abstract: Clean $string for use in database queries</P>
<P>param: $string String to clean</P>
<P>result: Cleaned version of $string</P>
<P>
<PRE>
function db_clean ($string)
</PRE>
</P>
<H2><A NAME="sec: path_parts"></A> <A NAME="ss5.10">5.10</A> <A HREF="vfs.html#toc5.10">path_parts</A>
</H2>
<P>abstract: take a real or fake pathname and return an array of its component
parts</P>
<P>param: $string full real or fake path</P>
<P>param: $relatives Relativity array</P>
<P>param: $object True returns an object instead of an array</P>
<P>result: $rarray/$robject Array or object containing the fake
and real component parts of the path</P>
<P>discussion: Returned values are:</P>
<P>mask</P>
<P>outside</P>
<P>fake_full_path</P>
<P>fake_leading_dirs</P>
<P>fake_extra_path</P>
<P>fake_name</P>
<P>real_full_path</P>
<P>real_leading_dirs</P>
<P>real_extra_path</P>
<P>real_name</P>
<P>fake_full_path_clean</P>
<P>fake_leading_dirs_clean</P>
<P>fake_extra_path_clean</P>
<P>fake_name_clean</P>
<P>real_full_path_clean</P>
<P>real_leading_dirs_clean</P>
<P>real_extra_path_clean</P>
<P>real_name_clean</P>
<P>&quot;clean&quot; values are run through vfs-&gt;db_clean () and</P>
<P>are safe for use in SQL queries that use key='value'</P>
<P>They should be used ONLY for SQL queries, so are used</P>
<P>mostly internally</P>
<P>mask is either RELATIVE_NONE or RELATIVE_NONE|VFS_REAL,</P>
<P>and is used internally</P>
<P>outside is boolean, True if $relatives contains VFS_REAL</P>
<P>
<PRE>
function path_parts ($string, $relatives = array (RELATIVE_CURRENT), $object = True)
</PRE>
</P>
<H2><A NAME="sec: getabsolutepath"></A> <A NAME="ss5.11">5.11</A> <A HREF="vfs.html#toc5.11">getabsolutepath</A>
</H2>
<P>abstract: get the absolute path</P>
<P>param: $target defaults to False, directory/file to get path of,
relative to $relatives[0]</P>
<P>param: $mask Relativity bitmask (see RELATIVE_ defines). RELATIVE_CURRENT
means use $this-&gt;relative</P>
<P>param: $fake Returns the &quot;fake&quot; path, ie /home/user/dir/file
(not always possible. use path_parts () instead)</P>
<P>result: $basedir Full fake or real path</P>
<P>
<PRE>
function getabsolutepath ($target = False, $relatives = array (RELATIVE_CURRENT), $fake = True)
</PRE>
</P>
<H2><A NAME="sec: cd"></A> <A NAME="ss5.12">5.12</A> <A HREF="vfs.html#toc5.12">cd</A>
</H2>
<P>abstract: Change directory</P>
<P>discussion: To cd to the files root &quot;/&quot;, use cd (&quot;/&quot;,
False, array (RELATIVE_NONE));</P>
<P>param: $target default &quot;/&quot;. directory to cd into. if
&quot;/&quot; and $relative is True, uses &quot;/home/&lt;working_lid&gt;&quot;;</P>
<P>param: $relative default True/relative means add target to current
path, else pass $relative as mask to getabsolutepath()</P>
<P>
<PRE>
function cd ($target = &quot;/&quot;, $relative = True, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: pwd"></A> <A NAME="ss5.13">5.13</A> <A HREF="vfs.html#toc5.13">pwd</A>
</H2>
<P>abstract: current working dir</P>
<P>param: $full default True returns full fake path, else just the
extra dirs (false strips the leading /)</P>
<P>result: $currentdir currentdir</P>
<P>
<PRE>
function pwd ($full = True)
</PRE>
</P>
<H2><A NAME="sec: read"></A> <A NAME="ss5.14">5.14</A> <A HREF="vfs.html#toc5.14">read</A>
</H2>
<P>abstract: return file contents</P>
<P>param: $file filename</P>
<P>param: $relatives Relativity array</P>
<P>result: $contents Contents of $file, or False if file cannot
be read</P>
<P>
<PRE>
function read ($file, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: write"></A> <A NAME="ss5.15">5.15</A> <A HREF="vfs.html#toc5.15">write</A>
</H2>
<P>abstract: write to a file</P>
<P>param: $file file name</P>
<P>param: $relatives Relativity array</P>
<P>param: $contents contents</P>
<P>result: Boolean True/False</P>
<P>
<PRE>
function write ($file, $relatives = array (RELATIVE_CURRENT), $contents)
</PRE>
</P>
<H2><A NAME="sec: touch"></A> <A NAME="ss5.16">5.16</A> <A HREF="vfs.html#toc5.16">touch</A>
</H2>
<P>abstract: Create blank file $file or set the modification time and
modified by of $file to current time and user</P>
<P>param: $file File to touch or set modifies</P>
<P>param: $relatives Relativity array</P>
<P>result: Boolean True/False</P>
<P>
<PRE>
function touch ($file, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: cp"></A> <A NAME="ss5.17">5.17</A> <A HREF="vfs.html#toc5.17">cp</A>
</H2>
<P>abstract: copy file</P>
<P>param: $from from file/directory</P>
<P>param: $to to file/directory</P>
<P>param: $relatives Relativity array</P>
<P>result: boolean True/False</P>
<P>
<PRE>
function cp ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: mv"></A> <A NAME="ss5.18">5.18</A> <A HREF="vfs.html#toc5.18">mv</A>
</H2>
<P>abstract: move file/directory</P>
<P>param: $from from file/directory</P>
<P>param: $to to file/directory</P>
<P>param: $relatives Relativity array</P>
<P>result: boolean True/False</P>
<P>
<PRE>
function mv ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: move"></A> <A NAME="ss5.19">5.19</A> <A HREF="vfs.html#toc5.19">move</A>
</H2>
<P>abstract: shortcut to mv</P>
<P>
<PRE>
function move ($from, $to, $relatives = array (RELATIVE_CURRENT, RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: rm"></A> <A NAME="ss5.20">5.20</A> <A HREF="vfs.html#toc5.20">rm</A>
</H2>
<P>abstract: delete file/directory</P>
<P>param: $string file/directory to delete</P>
<P>param: $relatives Relativity array</P>
<P>result: boolean True/False</P>
<P>
<PRE>
function rm ($string, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: delete"></A> <A NAME="ss5.21">5.21</A> <A HREF="vfs.html#toc5.21">delete</A>
</H2>
<P>abstract: shortcut to rm</P>
<P>
<PRE>
function delete ($string, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: mkdir"></A> <A NAME="ss5.22">5.22</A> <A HREF="vfs.html#toc5.22">mkdir</A>
</H2>
<P>abstract: make a new directory</P>
<P>param: $dir Directory name</P>
<P>param: $relatives Relativity array</P>
<P>result: boolean True on success</P>
<P>
<PRE>
function mkdir ($dir, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: set_attributes"></A> <A NAME="ss5.23">5.23</A> <A HREF="vfs.html#toc5.23">set_attributes</A>
</H2>
<P>abstract: Update database entry for $file with the attributes in
$attributes</P>
<P>param: $file file/directory to update</P>
<P>param: $relatives Relativity array</P>
<P>param: $attributes keyed array of attributes. key is attribute
name, value is attribute value</P>
<P>result: Boolean True/False</P>
<P>discussion: Valid attributes are:</P>
<P>owner_id</P>
<P>createdby_id</P>
<P>modifiedby_id</P>
<P>created</P>
<P>modified</P>
<P>size</P>
<P>mime_type</P>
<P>deleteable</P>
<P>comment</P>
<P>app</P>
<P>
<PRE>
function set_attributes ($file, $relatives = array (RELATIVE_CURRENT), $attributes = array ())
</PRE>
</P>
<H2><A NAME="sec: correct_attributes"></A> <A NAME="ss5.24">5.24</A> <A HREF="vfs.html#toc5.24">correct_attributes</A>
</H2>
<P>abstract: Set the correct attributes for $string (e.g. owner)</P>
<P>param: $string File/directory to correct attributes of</P>
<P>param: $relatives Relativity array</P>
<P>result: Boolean True/False</P>
<P>
<PRE>
function correct_attributes ($string, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: file_type"></A> <A NAME="ss5.25">5.25</A> <A HREF="vfs.html#toc5.25">file_type</A>
</H2>
<P>abstract: return file/dir type (MIME or other)</P>
<P>param: $file File or directory path (/home/user/dir/dir2/dir3, /home/user/dir/dir2/file)</P>
<P>param: $relatives Relativity array</P>
<P>result: MIME type, &quot;Directory&quot;, or nothing if MIME type is not
known</P>
<P>
<PRE>
function file_type ($file, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: file_exists"></A> <A NAME="ss5.26">5.26</A> <A HREF="vfs.html#toc5.26">file_exists</A>
</H2>
<P>abstract: check if file/directory exists</P>
<P>param: $string file/directory to check existance of</P>
<P>param: $relatives Relativity array</P>
<P>result: Boolean True/False</P>
<P>
<PRE>
function file_exists ($string, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: checkperms"></A> <A NAME="ss5.27">5.27</A> <A HREF="vfs.html#toc5.27">checkperms</A>
</H2>
<P>abstract: Check if you have write access to create files in $dir</P>
<P>discussion: This isn't perfect, because vfs-&gt;touch () returns True even</P>
<P>if only the database entry worked. ACLs need to be</P>
<P>implemented for better permission checking. It's</P>
<P>also pretty slow, so I wouldn't recommend using it</P>
<P>often</P>
<P>param: $dir Directory to check access of</P>
<P>param: $relatives Relativity array</P>
<P>result: Boolean True/False</P>
<P>
<PRE>
function checkperms ($dir, $relatives = array (RELATIVE_CURRENT))
</PRE>
</P>
<H2><A NAME="sec: ls"></A> <A NAME="ss5.28">5.28</A> <A HREF="vfs.html#toc5.28">ls</A>
</H2>
<P>abstract: get directory listing</P>
<P>discussion: Note: the entries are not guaranteed to be returned in any
logical order</P>
<P>param: $dir Directory</P>
<P>param: $relatives Relativity array</P>
<P>param: $checksubdirs Boolean, recursively list all sub directories
as well?</P>
<P>param: $mime_type Only return entries matching MIME-type $mime_type.
Can be &quot;Directory&quot; or &quot;\&quot; for those without MIME
types</P>
<P>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'</P>
<P>result: array of arrays. Subarrays contain full info for each file/dir.</P>
<P>
<PRE>
function ls ($dir = False, $relatives = array (RELATIVE_CURRENT), $checksubdirs = True, $mime_type = False, $nofiles = False)
</PRE>
</P>
<H2><A NAME="sec: dir"></A> <A NAME="ss5.29">5.29</A> <A HREF="vfs.html#toc5.29">dir</A>
</H2>
<P>abstract: shortcut to ls</P>
<P>
<PRE>
function dir ($dir = False, $relatives = array (RELATIVE_CURRENT), $checksubdirs = True, $mime_type = False, $nofiles = False)
</PRE>
</P>
<HR> <HR>
<A HREF="vfs-6.html">Next</A> <A HREF="vfs-6.html">Next</A>
<A HREF="vfs-4.html">Previous</A> <A HREF="vfs-4.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: Notes</TITLE> <TITLE>phpgwapi - VFS Class: Notes</TITLE>
<LINK HREF="vfs-7.html" REL=next> <LINK HREF="vfs-7.html" REL=next>
<LINK HREF="vfs-5.html" REL=previous> <LINK HREF="vfs-5.html" REL=previous>
@ -17,8 +17,8 @@
<H2><A NAME="sec:database"></A> <A NAME="ss6.1">6.1</A> <A HREF="vfs.html#toc6.1">Database</A> <H2><A NAME="sec:database"></A> <A NAME="ss6.1">6.1</A> <A HREF="vfs.html#toc6.1">Database</A>
</H2> </H2>
<P>Data about the files and directories within the virtual root is kept in <P>Data about the files and directories within the virtual root
the SQL database. Currently, this information includes:</P> is kept in the SQL database. Currently, this information includes:</P>
<P> <P>
<UL> <UL>
<LI>File ID (used internally, primary key for table)</LI> <LI>File ID (used internally, primary key for table)</LI>
@ -34,73 +34,51 @@ the SQL database. Currently, this information includes:</P>
<LI>App (appname of application that created the file)</LI> <LI>App (appname of application that created the file)</LI>
<LI>Directory (directory the file or directory is in)</LI> <LI>Directory (directory the file or directory is in)</LI>
<LI>Name (name of file or directory)</LI> <LI>Name (name of file or directory)</LI>
<LI>Link directory (if the file or directory is linked, what the
actual directory is)</LI>
<LI>Link name (if the file or directory is linked, what the actual
name is)</LI>
<LI>Version (numeric version of the file)</LI>
</UL> </UL>
</P> </P>
<P>The internal names of these (the database column names) are stored in the <P>The internal names of these (the database column names) are stored
$phpgw-&gt;vfs-&gt;attributes array, which is useful for loops, and in the $GLOBALS['phpgw']-&gt;vfs-&gt;attributes
is guaranteed to be up-to-date.</P> array, which is useful for loops, and is guaranteed to be up-to-date.</P>
<P>Note that no information is kept about files outside the virtual
root. If a file is moved outside, all records of it are deleted from
<P>Note that no information is kept about files outside the virtual root. the database (other than the journaling records). If a file is moved
If a file is moved outside, all records of it are delete from the database. into the virtual root, some information, specifically MIME-type,
If a file is moved into the virtual root, some information, specifically MIME-type, is not always stored in the database. The vital information has defaults:
is not stored in the database. The vital information has defaults: owner is owner is based on where the file is being stored; size is correctly
based on where the file is being stored; size is correctly read; deleteable read; deleteable is set to Y.</P>
is set to Y.</P>
<H2><A NAME="sec:acl_support"></A> <A NAME="ss6.2">6.2</A> <A HREF="vfs.html#toc6.2">ACL support</A> <H2><A NAME="sec:acl_support"></A> <A NAME="ss6.2">6.2</A> <A HREF="vfs.html#toc6.2">ACL support</A>
</H2> </H2>
<P>Because of the many different ways the VFS can be used, complete ACL support <P>ACL support is built into the VFS. vfs-&gt;acl_check () does
is not built in. There is a bit of access control built in, just because of the actual checking, and is called from all VFS functions as needed.
the way database queries are made. However, that is a discussion beyond the If the file or directory sent to acl_check () doesn't exist, the
scope of this document. Full ACL support may be added at a later time. For permissions for the parent directory are used to determine access.
now, it is fairly easy to add basic access control to your application by matching ACL checking can be overridden at any time by setting vfs-&gt;override_acl.
path expressions. The VFS always follows the same naming convention of $fakebase/userorgroup. For example:</P>
So if you need to check if a user has access to $fakebase/whatever/dir/file,
you need only know if they their username is 'whatever' or if they belong to
the group 'whatever', and that the group has access to your application. Here
is an example from PHPWebHosting:</P>
<P> <P>
<PRE> <PRE>
### $GLOBALS['phpgw']-&gt;vfs-&gt;override_acl = 1;
# First we get their memberships $GLOBALS['phpgw']-&gt;vfs-&gt;mkdir (array(
### 'string' =&gt; $GLOBALS['fakebase']. '/' . $group_array['account_name'],
'relatives' =&gt; array(
$memberships = $phpgw-&gt;accounts-&gt;memberships ($account_id); RELATIVE_NONE
)
### ));
# We determine if they're in their home directory or a group's directory $GLOBALS['phpgw']-&gt;vfs-&gt;override_acl = 0;
# If they request a group's directory, we ensure they have access to the group,
# and the group has access to the app
###
if ((preg_match (&quot;+^$fakebase\/(.*)(\/|$)+U&quot;, $path, $matches)) &amp;&amp; $matches[1] != $account_lid)
{
$phpgw-&gt;vfs-&gt;working_id = $phpgw-&gt;accounts-&gt;name2id ($matches[1]);
reset ($memberships);
while (list ($num, $group_array) = each ($memberships))
{
if ($matches[1] == $group_array[&quot;account_name&quot;])
{
$group_ok = 1;
break;
}
}
if (!$group_ok)
{
echo $phpgw-&gt;common-&gt;error_list (array (&quot;You do not have access to group/directory $matches[1]&quot;));
exit;
}
}
</PRE> </PRE>
</P> </P>
<P>You should also check if the group has access to your appilcation.</P>
<H2><A NAME="sec:function_aliases"></A> <A NAME="ss6.3">6.3</A> <A HREF="vfs.html#toc6.3">Function aliases</A> <H2><A NAME="sec:function_aliases"></A> <A NAME="ss6.3">6.3</A> <A HREF="vfs.html#toc6.3">Function aliases</A>
</H2> </H2>
<P>You might have noticed there are some functions that just pass the arguments <P>You might have noticed there are some functions that just pass
on to other functions. These are provided in part because of legacy and in the arguments on to other functions. These are provided in part because
part for convenience. You can use either. Here is the list (alias -&gt; actual):</P> of legacy and in part for convenience. You can use either. Here is
the list (alias -&gt; actual):</P>
<P> <P>
<UL> <UL>
<LI>copy -&gt; cp</LI> <LI>copy -&gt; cp</LI>
@ -112,17 +90,18 @@ part for convenience. You can use either. Here is the list (alias -&gt; actual):
<H2><A NAME="sec:fakebase"></A> <A NAME="ss6.4">6.4</A> <A HREF="vfs.html#toc6.4">Fakebase directory (changing /home)</A> <H2><A NAME="sec:fakebase"></A> <A NAME="ss6.4">6.4</A> <A HREF="vfs.html#toc6.4">Fakebase directory (changing /home)</A>
</H2> </H2>
<P>The old VFS was hard-coded to use &quot;/home&quot; as the fake base directory, <P>The old VFS was hard-coded to use '/home' as the fake base directory,
even though the user never saw it. With the new system, crafty administrators even though the user never saw it. With the new system, crafty administrators
may wish to change &quot;/home&quot; to something else, say &quot;/users&quot; may wish to change '/home' to something else, say '/users' or '/public_html'.
or &quot;/public_html&quot;. The fake base directory name is stored in $phpgw-&gt;vfs-&gt;fakebase, The fake base directory name is stored in $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase,
and changing it will transparently change it throughout the VFS and all applications. and changing it will transparently change it throughout the VFS and
However, this must be done <EM>before</EM> any data is in the VFS database. If you wish all applications. However, this must be done <EM>before</EM> any data is in
to change it afterwords, you'll have to manually update the database, replacing the VFS database. If you wish to change it afterwords, you'll have
the old value with the new value. <EM>Application programmers need to recognize to manually update the database, replacing the old value with the
that /home is not absolute, and use $phpgw-&gt;vfs-&gt;fakebase instead</EM>. new value. <EM>Application programmers need to recognize that /home is
I suggest setting $fakebase = $phpgw-&gt;vfs-&gt;fakebase; right not absolute, and use $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase
off the bat to keep things neater.</P> instead</EM>. I suggest setting $fakebase = $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase;
right off the bat to keep things neater.</P>
<HR> <HR>
<A HREF="vfs-7.html">Next</A> <A HREF="vfs-7.html">Next</A>
<A HREF="vfs-5.html">Previous</A> <A HREF="vfs-5.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class: About this Document</TITLE> <TITLE>phpgwapi - VFS Class: About this Document</TITLE>
<LINK HREF="vfs-6.html" REL=previous> <LINK HREF="vfs-6.html" REL=previous>
<LINK HREF="vfs.html#toc7" REL=contents> <LINK HREF="vfs.html#toc7" REL=contents>
@ -16,23 +16,26 @@ Next
<H2><A NAME="ss7.1">7.1</A> <A HREF="vfs.html#toc7.1">Copyright and License</A> <H2><A NAME="ss7.1">7.1</A> <A HREF="vfs.html#toc7.1">Copyright and License</A>
</H2> </H2>
<P>Copyright (c) 2001 Jason Wies</P> <P>Copyright (c) 2001, 2002 Jason Wies</P>
<P>Permission is granted to copy, distribute and/or modify this document under <P>Permission is granted to copy, distribute and/or modify this
the terms of the GNU Free Documentation License, Version 1.1 or any later version document under the terms of the GNU Free Documentation License, Version
published by the Free Software Foundation; with no Invarient Sections, with 1.1 or any later version published by the Free Software Foundation;
no Front-Cover Texts, and no Back-Cover Texts.</P> with no Invarient Sections, with no Front-Cover Texts, and no Back-Cover
Texts.</P>
<P>A copy of the license is available at <P>A copy of the license is available at
<A HREF="http://www.gnu.org/copyleft/fdl.html">http://www.gnu.org/copyleft/fdl.html</A>.</P> <A HREF="http://www.gnu.org/copyleft/fdl.html">http://www.gnu.org/copyleft/fdl.html</A>.</P>
<H2><A NAME="ss7.2">7.2</A> <A HREF="vfs.html#toc7.2">History</A> <H2><A NAME="ss7.2">7.2</A> <A HREF="vfs.html#toc7.2">History</A>
</H2> </H2>
<P>Original document released in June 2001 by Jason Wies.</P> <P>Original document released in June 2001 by Jason Wies.</P>
<P>Updated February 2002 to include arrayized parameters, single
quotes, and GLOBALS.</P>
<H2><A NAME="ss7.3">7.3</A> <A HREF="vfs.html#toc7.3">Contributing</A> <H2><A NAME="ss7.3">7.3</A> <A HREF="vfs.html#toc7.3">Contributing</A>
</H2> </H2>
<P>Contributions are always welcome. Please send to the current maintainer, <P>Contributions are always welcome. Please send to the current
Jason Wies, maintainer, Jason Wies,
<A HREF="mailto:zone@users.sourceforge.net">zone@users.sourceforge.net</A>.</P> <A HREF="mailto:zone@phpgroupware.org">zone@phpgroupware.org</A>.</P>
<HR> <HR>
Next Next
<A HREF="vfs-6.html">Previous</A> <A HREF="vfs-6.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HTML>
<HEAD> <HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.7.4"> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
<TITLE>phpgwapi - VFS Class</TITLE> <TITLE>phpgwapi - VFS Class</TITLE>
<LINK HREF="vfs-1.html" REL=next> <LINK HREF="vfs-1.html" REL=next>
@ -14,9 +14,10 @@ Contents
<HR> <HR>
<H1>phpgwapi - VFS Class</H1> <H1>phpgwapi - VFS Class</H1>
<H2>Jason Wies</H2>June 2001 <H2>Jason Wies</H2>June 2001, February 2002
<HR> <HR>
<EM>The VFS, or Virtual File System, handles all file system activity for phpGroupWare.</EM> <EM>The VFS, or Virtual File System, handles all file system activity
for phpGroupWare.</EM>
<HR> <HR>
<P> <P>
<H2><A NAME="toc1">1.</A> <A HREF="vfs-1.html">Introduction and Purpose</A></H2> <H2><A NAME="toc1">1.</A> <A HREF="vfs-1.html">Introduction and Purpose</A></H2>
@ -46,37 +47,6 @@ Contents
<P> <P>
<H2><A NAME="toc5">5.</A> <A HREF="vfs-5.html">Function reference</A></H2> <H2><A NAME="toc5">5.</A> <A HREF="vfs-5.html">Function reference</A></H2>
<UL>
<LI><A NAME="toc5.1">5.1</A> <A HREF="vfs-5.html#ss5.1">About</A>
<LI><A NAME="toc5.2">5.2</A> <A HREF="vfs-5.html#ss5.2">class vfs</A>
<LI><A NAME="toc5.3">5.3</A> <A HREF="vfs-5.html#ss5.3">class path_class</A>
<LI><A NAME="toc5.4">5.4</A> <A HREF="vfs-5.html#ss5.4">vfs</A>
<LI><A NAME="toc5.5">5.5</A> <A HREF="vfs-5.html#ss5.5">set_relative</A>
<LI><A NAME="toc5.6">5.6</A> <A HREF="vfs-5.html#ss5.6">get_relative</A>
<LI><A NAME="toc5.7">5.7</A> <A HREF="vfs-5.html#ss5.7">sanitize</A>
<LI><A NAME="toc5.8">5.8</A> <A HREF="vfs-5.html#ss5.8">securitycheck</A>
<LI><A NAME="toc5.9">5.9</A> <A HREF="vfs-5.html#ss5.9">db_clean</A>
<LI><A NAME="toc5.10">5.10</A> <A HREF="vfs-5.html#ss5.10">path_parts</A>
<LI><A NAME="toc5.11">5.11</A> <A HREF="vfs-5.html#ss5.11">getabsolutepath</A>
<LI><A NAME="toc5.12">5.12</A> <A HREF="vfs-5.html#ss5.12">cd</A>
<LI><A NAME="toc5.13">5.13</A> <A HREF="vfs-5.html#ss5.13">pwd</A>
<LI><A NAME="toc5.14">5.14</A> <A HREF="vfs-5.html#ss5.14">read</A>
<LI><A NAME="toc5.15">5.15</A> <A HREF="vfs-5.html#ss5.15">write</A>
<LI><A NAME="toc5.16">5.16</A> <A HREF="vfs-5.html#ss5.16">touch</A>
<LI><A NAME="toc5.17">5.17</A> <A HREF="vfs-5.html#ss5.17">cp</A>
<LI><A NAME="toc5.18">5.18</A> <A HREF="vfs-5.html#ss5.18">mv</A>
<LI><A NAME="toc5.19">5.19</A> <A HREF="vfs-5.html#ss5.19">move</A>
<LI><A NAME="toc5.20">5.20</A> <A HREF="vfs-5.html#ss5.20">rm</A>
<LI><A NAME="toc5.21">5.21</A> <A HREF="vfs-5.html#ss5.21">delete</A>
<LI><A NAME="toc5.22">5.22</A> <A HREF="vfs-5.html#ss5.22">mkdir</A>
<LI><A NAME="toc5.23">5.23</A> <A HREF="vfs-5.html#ss5.23">set_attributes</A>
<LI><A NAME="toc5.24">5.24</A> <A HREF="vfs-5.html#ss5.24">correct_attributes</A>
<LI><A NAME="toc5.25">5.25</A> <A HREF="vfs-5.html#ss5.25">file_type</A>
<LI><A NAME="toc5.26">5.26</A> <A HREF="vfs-5.html#ss5.26">file_exists</A>
<LI><A NAME="toc5.27">5.27</A> <A HREF="vfs-5.html#ss5.27">checkperms</A>
<LI><A NAME="toc5.28">5.28</A> <A HREF="vfs-5.html#ss5.28">ls</A>
<LI><A NAME="toc5.29">5.29</A> <A HREF="vfs-5.html#ss5.29">dir</A>
</UL>
<P> <P>
<H2><A NAME="toc6">6.</A> <A HREF="vfs-6.html">Notes</A></H2> <H2><A NAME="toc6">6.</A> <A HREF="vfs-6.html">Notes</A></H2>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff