2001-06-20 10:16:13 +02:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
|
|
<HTML>
|
|
|
|
<HEAD>
|
2003-08-28 16:31:11 +02:00
|
|
|
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17">
|
2001-06-20 10:16:13 +02:00
|
|
|
<TITLE>phpgwapi - VFS Class: Basics</TITLE>
|
|
|
|
<LINK HREF="vfs-3.html" REL=next>
|
|
|
|
<LINK HREF="vfs-1.html" REL=previous>
|
|
|
|
<LINK HREF="vfs.html#toc2" REL=contents>
|
|
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
<A HREF="vfs-3.html">Next</A>
|
|
|
|
<A HREF="vfs-1.html">Previous</A>
|
|
|
|
<A HREF="vfs.html#toc2">Contents</A>
|
|
|
|
<HR>
|
|
|
|
<H2><A NAME="sec:basics"></A> <A NAME="s2">2.</A> <A HREF="vfs.html#toc2">Basics</A></H2>
|
|
|
|
|
|
|
|
<H2><A NAME="sec:prerequisites"></A> <A NAME="ss2.1">2.1</A> <A HREF="vfs.html#toc2.1">Prerequisites</A>
|
|
|
|
</H2>
|
|
|
|
|
2002-02-25 09:45:41 +01:00
|
|
|
<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>
|
2001-06-20 10:16:13 +02:00
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw_info']['flags'] = array(
|
2004-05-05 11:59:18 +02:00
|
|
|
'currentapp' => 'filemanaer',
|
2002-02-25 09:45:41 +01:00
|
|
|
'noheader' => False,
|
|
|
|
'noappheader' => False,
|
|
|
|
'enable_vfs_class' => True,
|
|
|
|
'enable_browser_class' => True
|
|
|
|
);
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<H2><A NAME="sec:concepts"></A> <A NAME="ss2.2">2.2</A> <A HREF="vfs.html#toc2.2">Concepts</A>
|
|
|
|
</H2>
|
|
|
|
|
2002-02-25 09:45:41 +01:00
|
|
|
<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>
|
2001-06-20 10:16:13 +02:00
|
|
|
<P>
|
|
|
|
<UL>
|
|
|
|
<LI>Files and directories are synonymous in almost all cases</LI>
|
|
|
|
</UL>
|
|
|
|
</P>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw']->vfs->mv (array(
|
|
|
|
'from' => 'file1',
|
|
|
|
'to' => 'dir/file2'
|
|
|
|
));
|
|
|
|
|
|
|
|
$GLOBALS['phpgw']->vfs->mv (array(
|
|
|
|
'from' => 'dir1',
|
|
|
|
'to' => 'dir/dir1'
|
|
|
|
));
|
|
|
|
|
|
|
|
$GLOBALS['phpgw']->vfs->rm (array(
|
|
|
|
'string' => 'file'
|
|
|
|
));
|
|
|
|
|
|
|
|
$GLOBALS['phpgw']->vfs->rm (array(
|
|
|
|
'string' => 'dir'
|
|
|
|
));
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<P>All work as you would except them to. The major exception is:</P>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw']->vfs->touch (array(
|
|
|
|
'string' => 'file'
|
|
|
|
));
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<P>vs.</P>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw']->vfs->mkdir (array(
|
|
|
|
'string' => 'dir'
|
|
|
|
));
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<P>
|
|
|
|
<UL>
|
2002-02-25 09:45:41 +01:00
|
|
|
<LI>Users and groups are synonymous</LI>
|
2001-06-20 10:16:13 +02:00
|
|
|
</UL>
|
|
|
|
</P>
|
2002-02-25 09:45:41 +01:00
|
|
|
<P>As far as the actual paths are concerned, users and groups are
|
|
|
|
the same. /home/username works the same as /home/groupname.</P>
|
2001-06-20 10:16:13 +02:00
|
|
|
<P>
|
|
|
|
<UL>
|
2002-02-25 09:45:41 +01:00
|
|
|
<LI>You should never have to know the real paths of files</LI>
|
2001-06-20 10:16:13 +02:00
|
|
|
</UL>
|
|
|
|
</P>
|
2002-02-25 09:45:41 +01:00
|
|
|
<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>
|
2001-06-20 10:16:13 +02:00
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw']->vfs->cp (array(
|
2004-05-05 11:59:18 +02:00
|
|
|
'from' => '/var/www/egroupware/files/home/user/file1',
|
|
|
|
'to' => '/var/www/egroupware/files/home/user/file2',
|
2002-02-25 09:45:41 +01:00
|
|
|
'relatives' => array(
|
|
|
|
RELATIVE_NONE|VFS_REAL,
|
|
|
|
RELATIVE_NONE|VFS_REAL
|
|
|
|
)
|
|
|
|
));
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<P>you might use</P>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
2002-02-25 09:45:41 +01:00
|
|
|
$GLOBALS['phpgw']->vfs->cp (array(
|
|
|
|
'from' => '/home/user/file1',
|
|
|
|
'to' => '/home/user/file2',
|
|
|
|
'relatives' => array(
|
|
|
|
RELATIVE_NONE,
|
|
|
|
RELATIVE_NONE
|
|
|
|
)
|
|
|
|
));
|
2001-06-20 10:16:13 +02:00
|
|
|
</PRE>
|
|
|
|
</P>
|
|
|
|
<P>(We'll get to the RELATIVE's in a minute.)</P>
|
2002-02-25 09:45:41 +01:00
|
|
|
<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>
|
2001-06-20 10:16:13 +02:00
|
|
|
<P>
|
|
|
|
<UL>
|
|
|
|
<LI>Relativity is <EM>vital</EM></LI>
|
|
|
|
</UL>
|
|
|
|
</P>
|
2002-02-25 09:45:41 +01:00
|
|
|
<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>
|
2001-06-20 10:16:13 +02:00
|
|
|
<HR>
|
|
|
|
<A HREF="vfs-3.html">Next</A>
|
|
|
|
<A HREF="vfs-1.html">Previous</A>
|
|
|
|
<A HREF="vfs.html#toc2">Contents</A>
|
|
|
|
</BODY>
|
|
|
|
</HTML>
|