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">
<HTML>
<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>
<LINK HREF="vfs-2.html" REL=next>
@ -14,11 +14,12 @@ Previous
<HR>
<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
manipulation with fully integrated database support. It features nearly transparent
handling of files and directories, as well as files inside and outside the
virtual root. This document is intended to provide API and application developers
with a guide to incorporating the VFS into their work.</P>
<P>The latest version of the VFS for phpGroupWare combines actual
file system manipulation with fully integrated database support.
It features nearly transparent handling of files and directories,
as well as files inside and outside the virtual root. This document
is intended to provide API and application developers with a guide
to incorporating the VFS into their work.</P>
<HR>
<A HREF="vfs-2.html">Next</A>
Previous

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<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>
<LINK HREF="vfs-6.html" REL=next>
<LINK HREF="vfs-4.html" REL=previous>
@ -14,395 +14,9 @@
<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_about"></A> <A NAME="ss5.1">5.1</A> <A HREF="vfs.html#toc5.1">About</A>
</H2>
<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>
<P>To view the function reference for the VFS, use the doc/inlinedocparser.php
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>
<HR>
<A HREF="vfs-6.html">Next</A>
<A HREF="vfs-4.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<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>
<LINK HREF="vfs-7.html" REL=next>
<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>
<P>Data about the files and directories within the virtual root is kept in
the SQL database. Currently, this information includes:</P>
<P>Data about the files and directories within the virtual root
is kept in the SQL database. Currently, this information includes:</P>
<P>
<UL>
<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>Directory (directory the file or directory is in)</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>
</P>
<P>The internal names of these (the database column names) are stored in the
$phpgw-&gt;vfs-&gt;attributes 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 delete from the database.
If a file is moved into the virtual root, some information, specifically MIME-type,
is not stored in the database. The vital information has defaults: owner is
based on where the file is being stored; size is correctly read; deleteable
is set to Y.</P>
<P>The internal names of these (the database column names) are stored
in the $GLOBALS['phpgw']-&gt;vfs-&gt;attributes
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
the database (other than the journaling records). 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:
owner is based on where the file is being stored; size is correctly
read; deleteable 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>
<P>Because of the many different ways the VFS can be used, complete ACL support
is not built in. There is a bit of access control built in, just because of
the way database queries are made. However, that is a discussion beyond the
scope of this document. Full ACL support may be added at a later time. For
now, it is fairly easy to add basic access control to your application by matching
path expressions. The VFS always follows the same naming convention of $fakebase/userorgroup.
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>ACL support is built into the VFS. vfs-&gt;acl_check () does
the actual checking, and is called from all VFS functions as needed.
If the file or directory sent to acl_check () doesn't exist, the
permissions for the parent directory are used to determine access.
ACL checking can be overridden at any time by setting vfs-&gt;override_acl.
For example:</P>
<P>
<PRE>
###
# First we get their memberships
###
$memberships = $phpgw-&gt;accounts-&gt;memberships ($account_id);
###
# We determine if they're in their home directory or a group's directory
# 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;
}
}
$GLOBALS['phpgw']-&gt;vfs-&gt;override_acl = 1;
$GLOBALS['phpgw']-&gt;vfs-&gt;mkdir (array(
'string' =&gt; $GLOBALS['fakebase']. '/' . $group_array['account_name'],
'relatives' =&gt; array(
RELATIVE_NONE
)
));
$GLOBALS['phpgw']-&gt;vfs-&gt;override_acl = 0;
</PRE>
</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>
<P>You might have noticed there are some functions that just pass the arguments
on to other functions. These are provided in part because of legacy and in
part for convenience. You can use either. Here is the list (alias -&gt; actual):</P>
<P>You might have noticed there are some functions that just pass
the arguments on to other functions. These are provided in part because
of legacy and in part for convenience. You can use either. Here is
the list (alias -&gt; actual):</P>
<P>
<UL>
<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>
<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
may wish to change &quot;/home&quot; to something else, say &quot;/users&quot;
or &quot;/public_html&quot;. The fake base directory name is stored in $phpgw-&gt;vfs-&gt;fakebase,
and changing it will transparently change it throughout the VFS and all applications.
However, this must be done <EM>before</EM> any data is in the VFS database. If you wish
to change it afterwords, you'll have to manually update the database, replacing
the old value with the new value. <EM>Application programmers need to recognize
that /home is not absolute, and use $phpgw-&gt;vfs-&gt;fakebase instead</EM>.
I suggest setting $fakebase = $phpgw-&gt;vfs-&gt;fakebase; right
off the bat to keep things neater.</P>
may wish to change '/home' to something else, say '/users' or '/public_html'.
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. However, this must be done <EM>before</EM> any data is in
the VFS database. If you wish to change it afterwords, you'll have
to manually update the database, replacing the old value with the
new value. <EM>Application programmers need to recognize that /home is
not absolute, and use $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase
instead</EM>. I suggest setting $fakebase = $GLOBALS['phpgw']-&gt;vfs-&gt;fakebase;
right off the bat to keep things neater.</P>
<HR>
<A HREF="vfs-7.html">Next</A>
<A HREF="vfs-5.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<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>
<LINK HREF="vfs-6.html" REL=previous>
<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>
<P>Copyright (c) 2001 Jason Wies</P>
<P>Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.1 or any later version
published by the Free Software Foundation; with no Invarient Sections, with
no Front-Cover Texts, and no Back-Cover Texts.</P>
<P>Copyright (c) 2001, 2002 Jason Wies</P>
<P>Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version
1.1 or any later version published by the Free Software Foundation;
with no Invarient Sections, with no Front-Cover Texts, and no Back-Cover
Texts.</P>
<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>
<H2><A NAME="ss7.2">7.2</A> <A HREF="vfs.html#toc7.2">History</A>
</H2>
<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>
<P>Contributions are always welcome. Please send to the current maintainer,
Jason Wies,
<A HREF="mailto:zone@users.sourceforge.net">zone@users.sourceforge.net</A>.</P>
<P>Contributions are always welcome. Please send to the current
maintainer, Jason Wies,
<A HREF="mailto:zone@phpgroupware.org">zone@phpgroupware.org</A>.</P>
<HR>
Next
<A HREF="vfs-6.html">Previous</A>

View File

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<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>
<LINK HREF="vfs-1.html" REL=next>
@ -14,9 +14,10 @@ Contents
<HR>
<H1>phpgwapi - VFS Class</H1>
<H2>Jason Wies</H2>June 2001
<H2>Jason Wies</H2>June 2001, February 2002
<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>
<P>
<H2><A NAME="toc1">1.</A> <A HREF="vfs-1.html">Introduction and Purpose</A></H2>
@ -46,37 +47,6 @@ Contents
<P>
<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>
<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