[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc/class.vfs_sql.inc.php, 1.28
From: |
nomail |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc/class.vfs_sql.inc.php, 1.28 |
Date: |
Thu, 30 Dec 2004 10:00:31 +0100 |
Update of /phpgwapi/inc
Modified Files:
Branch:
class.vfs_sql.inc.php
date: 2004/12/30 09:00:31; author: skwashd; state: Exp; lines: +46 -217
Log Message:
vfs and dav fixes - patch #3525
=====================================================================
Index: phpgwapi/inc/class.vfs_sql.inc.php
diff -u phpgwapi/inc/class.vfs_sql.inc.php:1.27
phpgwapi/inc/class.vfs_sql.inc.php:1.28
--- phpgwapi/inc/class.vfs_sql.inc.php:1.27 Thu Dec 30 06:47:31 2004
+++ phpgwapi/inc/class.vfs_sql.inc.php Thu Dec 30 09:00:31 2004
@@ -36,10 +36,6 @@
*/
class vfs extends vfs_shared
{
- var $working_id;
- var $working_lid;
- var $meta_types;
- var $now;
var $file_actions;
/*!
@@ -49,11 +45,6 @@
function vfs ()
{
$this->vfs_shared ();
- $this->basedir =
$GLOBALS['phpgw_info']['server']['files_dir'];
- $this->working_id =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->working_lid =
$GLOBALS['phpgw']->accounts->id2name($this->working_id);
- $this->now = date ('Y-m-d');
-
/*
File/dir attributes, each corresponding to a
database field. Useful for use in loops
If an attribute was added to the table, add it here
and possibly add it to
@@ -93,13 +84,6 @@
echo '<p align="center"><font
color="red"><b>'.lang('Path to user and group files HAS TO BE OUTSIDE of the
webservers document-root!!!')."</b></font></p>\n";
$GLOBALS['phpgw']->common->phpgw_exit();
}
- /*
- These are stored in the MIME-type field and should
normally be ignored.
- Adding a type here will ensure it is normally
ignored, but you will have to
- explicitly add it to acl_check (), and to any other
SELECT's in this file
- */
-
- $this->meta_types = array ('journal',
'journal-deleted');
/* We store the linked directories in an array now, so
we don't have to make the SQL call again */
if ($GLOBALS['phpgw_info']['server']['db_type']=='mssql'
@@ -247,6 +231,7 @@
$sql = 'INSERT INTO phpgw_vfs (';
$sql2 .= ' VALUES (';
+ $morethanone = False;
for ($i = 0; list ($attribute, $value) = each
($file_array); $i++)
{
@@ -359,19 +344,19 @@
$version_parts[0]++;
}
- for ($i = 0; $i < $newnumofparts; $i++)
+ for ($j = 0; $j < $newnumofparts; $j++)
{
- if (!isset ($version_parts[$i]))
+ if (!isset ($version_parts[$j]))
{
break;
}
- if ($i)
+ if ($j)
{
$newversion .= '.';
}
- $newversion .=
$version_parts[$i];
+ $newversion .=
$version_parts[$j];
}
$this->set_attributes (array(
@@ -383,20 +368,22 @@
)
);
}
-
if (isset ($value))
{
- if ($i > 1)
+ if ($morethanone)
{
$sql .= ', ';
$sql2 .= ', ';
}
-
+ else
+ {
+ $morethanone = True;
+ }
$sql .= "$attribute";
$sql2 .= "'" . $this->clean_string
(array ('string' => $value)) . "'";
}
}
-
+ unset($morethanone);
$sql .= ')';
$sql2 .= ')';
@@ -1348,7 +1335,6 @@
$data = array_merge ($this->default_values ($data,
$default_values), $data);
$account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
-
$f = $this->path_parts (array(
'string' => $data['from'],
'relatives' => array
($data['relatives'][0])
@@ -1360,7 +1346,6 @@
'relatives' => array
($data['relatives'][1])
)
);
-
if (!$this->acl_check (array(
'string' => $f->fake_full_path,
'relatives' => array ($f->mask),
@@ -1418,7 +1403,6 @@
return False;
}
}
-
if ($this->file_exists (array(
'string' => $f->fake_full_path,
'relatives' => array ($f->mask)
@@ -1468,7 +1452,11 @@
if ($f->outside)
{
$size = filesize ($f->real_full_path);
-
+ if ( $size === False )
+ {
+ _debug_array($f);
+ $size = 1;
+ }
$this->touch (array(
'string' =>
$t->fake_full_path,
'relatives' =>
array ($t->mask)
@@ -2024,92 +2012,39 @@
}
}
- $sql .= " WHERE file_id='$record[file_id]'";
- $sql .= $this->extra_sql (array ('query_type' =>
VFS_SQL_UPDATE));
+ if ( $change_attributes )
+ {
+ $sql .= " WHERE file_id='$record[file_id]'";
+ $sql .= $this->extra_sql (array ('query_type'
=> VFS_SQL_UPDATE));
- $query = $GLOBALS['phpgw']->db->query ($sql, __LINE__,
__FILE__);
+ $query = $GLOBALS['phpgw']->db->query ($sql,
__LINE__, __FILE__);
+ if ($query)
+ {
+ if ($edited_comment)
+ {
+ $this->add_journal (array(
+ 'string'
=> $p->fake_full_path,
+ 'relatives'
=> array ($p->mask),
+ 'operation'
=> VFS_OPERATION_EDITED_COMMENT
+ )
+ );
+ }
- if ($query)
- {
- if ($edited_comment)
+ return True;
+ }
+ else
{
- $this->add_journal (array(
- 'string' =>
$p->fake_full_path,
- 'relatives' =>
array ($p->mask),
- 'operation' =>
VFS_OPERATION_EDITED_COMMENT
- )
- );
+ return False;
}
-
- return True;
- }
- else
- {
- return False;
- }
- }
-
- /*!
- @function correct_attributes
- @abstract Set the correct attributes for 'string' (e.g. owner)
- @param string File/directory to correct attributes of
- @param relatives Relativity array
- @result Boolean True/False
- */
- function correct_attributes ($data)
- {
- if (!is_array ($data))
- {
- $data = array ();
- }
-
- $default_values = array
- (
- 'relatives' => array
(RELATIVE_CURRENT)
- );
-
- $data = array_merge ($this->default_values ($data,
$default_values), $data);
-
- $p = $this->path_parts (array(
- 'string' => $data['string'],
- 'relatives' => array
($data['relatives'][0])
- )
- );
-
- if ($p->fake_leading_dirs != $this->fakebase &&
$p->fake_leading_dirs != '/')
- {
- $ls_array = $this->ls (array(
- 'string' =>
$p->fake_leading_dirs,
- 'relatives' => array
($p->mask),
- 'checksubdirs' => False,
- 'nofiles' => True
- )
- );
- $set_attributes_array = Array(
- 'owner_id' => $ls_array[0]['owner_id']
- );
- }
- elseif (preg_match ("+^$this->fakebase\/(.*)$+U",
$p->fake_full_path, $matches))
- {
- $set_attributes_array = Array(
- 'owner_id' =>
$GLOBALS['phpgw']->accounts->name2id ($matches[1])
- );
}
else
{
- $set_attributes_array = Array(
- 'owner_id' => 0
- );
+ //Nothing was done, because nothing required !
+ //This is a kind of bug isn't it ?
+ //So I let people choose to debug here :/
+ //FIXME : decide what we are doing here !
+ return True;
}
-
- $this->set_attributes (array(
- 'string' => $p->fake_full_name,
- 'relatives' => array ($p->mask),
- 'attributes' => $set_attributes_array
- )
- );
-
- return True;
}
/*
@@ -2226,124 +2161,19 @@
*/
function get_size ($data)
{
- if (!is_array ($data))
- {
- $data = array ();
- }
-
- $default_values = array
- (
- 'relatives' => array
(RELATIVE_CURRENT),
- 'checksubdirs' => True
- );
-
- $data = array_merge ($this->default_values ($data,
$default_values), $data);
-
- $p = $this->path_parts (array(
- 'string' => $data['string'],
- 'relatives' => array
($data['relatives'][0])
- )
- );
-
- if (!$this->acl_check (array(
- 'string' => $p->fake_full_path,
- 'relatives' => array ($p->mask),
- 'operation' => PHPGW_ACL_READ,
- 'must_exist' => True
- ))
- )
- {
- return False;
- }
-
- /*
- WIP - this should run through all of the
subfiles/directories in the directory and tally up
- their sizes. Should modify ls () to be able to
return a list for files outside the virtual root
- */
- if ($p->outside)
- {
- $size = filesize ($p->real_full_path);
-
- return $size;
- }
-
- $ls_array = $this->ls (array(
- 'string' => $p->fake_full_path,
- 'relatives' => array ($p->mask),
- 'checksubdirs' =>
$data['checksubdirs'],
- 'nofiles' =>
!$data['checksubdirs']
- )
- );
-
- while (list ($num, $file_array) = each ($ls_array))
- {
- /*
- Make sure the file is in the directory we
want, and not
- some deeper nested directory with a similar
name
- */
-/*
- if (@!ereg ('^' . $file_array['directory'],
$p->fake_full_path))
- {
- continue;
- }
-*/
-
- $size += $file_array['size'];
- }
-
- if ($data['checksubdirs'])
+ $size = parent::get_size($data);
+ /*XXX Caeies : Not sure about this, but ... */
+ /* If the virtual size is always 4096, we don't need
this ... */
+/* if ($data['checksubdirs'])
{
$query = $GLOBALS['phpgw']->db->query ("SELECT
size FROM phpgw_vfs WHERE directory='".$p->fake_leading_dirs_clean."' AND
name='".$p->fake_name_clean."'" . $this->extra_sql (array ('query_text' =>
VFS_SQL_SELECT)));
$GLOBALS['phpgw']->db->next_record ();
$size += $GLOBALS['phpgw']->db->Record[0];
}
-
+*/
return $size;
}
- /*!
- @function checkperms
- @abstract Check if $this->working_id has write access to create
files in $dir
- @discussion Simple call to acl_check
- @param string Directory to check access of
- @param relatives Relativity array
- @result Boolean True/False
- */
- function checkperms ($data)
- {
- if (!is_array ($data))
- {
- $data = array ();
- }
-
- $default_values = array
- (
- 'relatives' => array
(RELATIVE_CURRENT)
- );
-
- $data = array_merge ($this->default_values ($data,
$default_values), $data);
-
- $p = $this->path_parts (array(
- 'string' => $data['string'],
- 'relatives' => array
($data['relatives'][0])
- )
- );
-
- if (!$this->acl_check (array(
- 'string' => $p->fake_full_path,
- 'relatives' => array ($p->mask),
- 'operation' => PHPGW_ACL_ADD
- ))
- )
- {
- return False;
- }
- else
- {
- return True;
- }
- }
-
/*
* See vfs_shared
*/
@@ -2371,7 +2201,6 @@
)
);
$dir = $p->fake_full_path;
-
/* If they pass us a file or 'nofiles' is set, return
the info for $dir only */
if (((($type = $this->file_type (array(
'string' => $dir,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc/class.vfs_sql.inc.php, 1.28,
nomail <=