phpgwapi - VFS Class: Notes

Next Previous Contents

## 6. Notes

## 6.1 Database

Data about the files and directories within the virtual root is kept in the SQL database. Currently, this information includes:

- File ID (used internally, primary key for table)
- Owner ID (phpGW account_id)
- Created by ID (phpGW account_id)
- Modified by ID (phpGW account_id)
- Created (date)
- Modified (date)
- Size (bytes)
- MIME type
- Deleteable (Y/N/Other?)
- Comment
- App (appname of application that created the file)
- Directory (directory the file or directory is in)
- Name (name of file or directory)
- Link directory (if the file or directory is linked, what the actual directory is)
- Link name (if the file or directory is linked, what the actual name is)
- Version (numeric version of the file)

The internal names of these (the database column names) are stored in the $GLOBALS['phpgw']->vfs->attributes array, which is useful for loops, and is guaranteed to be up-to-date.

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.

## 6.2 ACL support

ACL support is built into the VFS. vfs->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->override_acl. For example:

    $GLOBALS['phpgw']->vfs->override_acl = 1;
    $GLOBALS['phpgw']->vfs->mkdir (array(
         'string' => $GLOBALS['fakebase']. '/' . $group_array['account_name'],
         'relatives' => array(
              RELATIVE_NONE
         )
    ));
    $GLOBALS['phpgw']->vfs->override_acl = 0;

## 6.3 Function aliases

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 -> actual):

- copy -> cp
- move -> rm
- delete -> rm
- dir -> ls

## 6.4 Fakebase directory (changing /home)

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 '/home' to something else, say '/users' or '/public_html'. The fake base directory name is stored in $GLOBALS['phpgw']->vfs->fakebase, and changing it will transparently change it throughout the VFS and all applications. However, this must be done before 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. Application programmers need to recognize that /home is not absolute, and use $GLOBALS['phpgw']->vfs->fakebase instead. I suggest setting $fakebase = $GLOBALS['phpgw']->vfs->fakebase; right off the bat to keep things neater.

Next Previous Contents