phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.vfs_dav.inc.php


From: Caeies
Subject: [Phpgroupware-cvs] phpgwapi/inc class.vfs_dav.inc.php
Date: Sun, 10 Sep 2006 16:46:03 +0000

CVSROOT:        /cvsroot/phpgwapi
Module name:    phpgwapi
Changes by:     Caeies <Caeies> 06/09/10 16:46:03

Modified files:
        inc            : class.vfs_dav.inc.php 

Log message:
        fix for E_ALL, partial support of particularities of svn (wait for the 
final patch review :)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.vfs_dav.inc.php?cvsroot=phpgwapi&r1=1.9&r2=1.10

Patches:
Index: class.vfs_dav.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.vfs_dav.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- class.vfs_dav.inc.php       16 Aug 2006 14:18:45 -0000      1.9
+++ class.vfs_dav.inc.php       10 Sep 2006 16:46:03 -0000      1.10
@@ -7,7 +7,7 @@
        * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License
        * @package phpgwapi
        * @subpackage vfs
-       * @version $Id: class.vfs_dav.inc.php,v 1.9 2006/08/16 14:18:45 skwashd 
Exp $
+       * @version $Id: class.vfs_dav.inc.php,v 1.10 2006/09/10 16:46:03 Caeies 
Exp $
        */
 
        /**
@@ -41,9 +41,12 @@
        class vfs extends vfs_shared
        {
                /*
-               * The repository
+               * That's the history add to the path !
                */
-               var $repository = '';
+               var $svn_history_path = '/!svn/bc/';
+               //This is a usefull add for svn case :
+               //Usable only in this case !
+               var $svn_repository_path = '';
                
                /*
                * the whole dav needed infos
@@ -94,17 +97,32 @@
 //                     $this->attributes[] = '#NAMEHERE#';
 
                        /* Dav properties */
-                       $this->repository = 
$GLOBALS['phpgw_info']['server']['files_dir'];
-                       
$this->dav_user=$GLOBALS['phpgw_info']['user']['userid'];
-                       $this->dav_pwd=$GLOBALS['phpgw_info']['user']['passwd'];
-                       $parsed_url = parse_url($this->repository);
-                       $this->dav_host=$parsed_url['host'];
-                       $this->address@hidden($parsed_url['port']) ? 
$parsed_url['port'] : '';
+                       //First check if we are asked to use svn ...
+                       $use_svn = false;
+                       if(ereg('svn[s:][:/]/', $this->basedir))
+                       {
+                               $use_svn = true;
+                               //so the 's' is kept
+                               $this->basedir = preg_replace('/^svn/', 'http', 
$this->basedir);
+                       }
+                       $this->dav_user = 
isset($GLOBALS['phpgw_info']['user']['userid']) ? (string) 
$GLOBALS['phpgw_info']['user']['userid'] : '';
+                       $this->dav_pwd = 
isset($GLOBALS['phpgw_info']['user']['passwd']) ? (string) 
$GLOBALS['phpgw_info']['user']['passwd'] : '';
+                       $parsed_url = parse_url($this->basedir);
+                       $this->dav_host = $parsed_url['host'];
+                       $this->dav_port = isset($parsed_url['port']) ? 
$parsed_url['port'] : '';
                        $this->dav_root = $parsed_url['scheme'].'://';
                        $this->dav_root .= $this->dav_host;
                        $this->dav_root .= (empty($this->dav_port)) ? '' : 
':'.$this->dav_port;
 
-                       $this->dav_client =& 
CreateObject('phpgwapi.http_dav_client');
+                       if($use_svn)
+                       {
+                               $this->dav_client = 
CreateObject('phpgwapi.http_svn_client');
+                               $this->svn_repository_path = 
$parsed_url['path'];
+                       }
+                       else
+                       {
+                               $this->dav_client = 
CreateObject('phpgwapi.http_dav_client');
+                       }
                        
$this->dav_client->set_credentials($this->dav_user,$this->dav_pwd);
                        
$this->dav_client->set_attributes($this->attributes,$this->vfs_property_map);
                        $result = 
$this->dav_client->connect($this->dav_host,$this->dav_port,$parsed_url['scheme']
 == 'https');
@@ -187,8 +205,26 @@
                        // port 
                        $port = (!empty($url['port'])) ? ':'.$url['port'] : '';
                        $uri .= $port; 
+                       //reposistory
+                       if(isset($url['repos']))
+                       {
+                               $uri .= $url['repos'];
+                       }
+                       //path his
+                       if(isset($url['pathhis']))
+                       {
+                               $uri .= $url['pathhis']; 
+                       }
+                       //revision
+                       if(isset($url['rev']))
+                       {
+                               $uri .= $url['rev'];
+                       }
                        // path 
+                       if(isset($url['path']))
+                       {
                        $uri .= $url['path'];
+                       }
                        // fragment or query
                        if (isset($url['fragment']))
                        {
@@ -259,7 +295,46 @@
                */
                function get_journal ($data)
                {
-                       return array();
+                       $default_values = array
+                       (
+                               'relatives'     => array (RELATIVE_CURRENT),
+                               'type'  => False
+                       );
+
+                       $data = array_merge ($this->default_values ($data, 
$default_values), $data);
+                       $from_rev=isset($data['from_rev']) ? $data['from_rev'] 
: 0;
+                       $to_rev=isset($data['to_rev']) ? $data['to_rev'] : 0;
+                       $version=isset($data['vers']) ? $data['vers'] : 0; 
+                       $collapse=isset($data['collapse']) ? $data['collapse'] 
: false;
+               
+                       if(!$from_rev || ! $to_rev) 
+                       {               
+                               $from_rev=0;
+                               $to_rev=$version;
+                       }
+
+                       $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)
+                               )))
+                       {
+                               return False;
+                       }
+                       $rarray=array();
+                       
$result=$this->dav_client->getVersions($this->svn_repository_path.$p->fake_full_path,$from_rev,$to_rev);
+                       $rarray=$result;
+                       if(isset($collapse) && $collapse && count($rarray)>0)
+                       {
+                               $rarray=$this->dav_client->collapse($result);
+                       }
+                       $rrarray=$this->dav_client->revert($rarray);
+                       return $rrarray;
                }
 
                /*
@@ -310,7 +385,7 @@
                                return True;
                        }
 
-                       if (!$data['owner_id'])
+                       if (!isset($data['owner_id']) || !$data['owner_id'])
                        {
                                $p = $this->path_parts (array(
                                                'string'        => 
$data['string'],
@@ -377,9 +452,12 @@
                                }
                                if ( is_array($prop[$p2->real_full_path]) )
                                {
+                                       
if(isset($prop[$p2->real_full_path]['owner_id']))
+                                       {
                                        $owner_id = 
$prop[$p2->real_full_path]['owner_id'];
                                }
                        }
+                       }
                        else
                        {
                                $owner_id = $data['owner_id'];
@@ -415,7 +493,7 @@
                                }
                        }
 
-                       $acl =& CreateObject ('phpgwapi.acl', $owner_id);
+                       $acl = CreateObject ('phpgwapi.acl', $owner_id);
                        $acl->account_id = $owner_id;
                        $acl->read_repository ();
 
@@ -437,7 +515,7 @@
                        }
                        elseif (!$rights && $group_ok)
                        {
-                               $conf =& CreateObject('phpgwapi.config', 
'phpgwapi');
+                               $conf = CreateObject('phpgwapi.config', 
'phpgwapi');
                                $conf->read_repository();
                                if ($conf->config_data['acl_default'] == 
'grant')
                                {
@@ -525,7 +603,7 @@
                                return False;
                        }
                        $props = $this->get_properties($p->real_full_path,0);
-                       $locks =& 
$props[$p->real_full_path]['locks']['activelock'];
+                       $locks = 
$props[$p->real_full_path]['locks']['activelock'];
                        foreach ($locks as $lock)
                        {
                                if ( !$dontcareowner )
@@ -707,9 +785,16 @@
                        );
                        $parsed_url = parse_url($p->real_full_path);
                        $parsed_url['user'] = $this->dav_user;
+                       if(isset($data['rev']))
+                       {
+                               $parsed_url['path'] = $p->fake_full_path;
+                               $parsed_url['pathhis'] =$this->svn_history_path;
+                               $parsed_url['repos'] = 
$this->svn_repository_path;
+                               $parsed_url['rev'] = $data['rev'];
+                       }
                        //XXX Do we need to include the user password here ?
                        //Do it a server config perhaps ?
-                       if ( $GLOBALS['phpgw_info']['server']['include_pwd'] )
+                       if ( 
isset($GLOBALS['phpgw_info']['server']['include_pwd']) && 
$GLOBALS['phpgw_info']['server']['include_pwd'] )
                        {
                                $parsed_url['pwd'] = $this->dav_pwd;
                        }
@@ -777,7 +862,7 @@
                        }
                        else
                        {
-                               $token =  
$this->override_locks[$p->real_full_path];
+                               $token = 
isset($this->override_locks[$p->real_full_path]) ? 
$this->override_locks[$p->real_full_path] : '';
                                
$status=$this->dav_client->put($this->dav_path($p->real_full_path),$data['content'],$token);
 $this->debug('Put complete,  status: '.$status);
                                if(intval($status) != 201 && intval($status) != 
204) 
@@ -1382,7 +1467,7 @@
                        );
 
                        if (!$this->acl_check (array(
-                                       'string'        => $p->fake_full_path,
+                                       'string'        => 
$p->fake_leading_dirs,
                                        'relatives'     => array ($p->mask),
                                        'operation'     => PHPGW_ACL_ADD)
                                )
@@ -1396,6 +1481,7 @@
                        {
                                return False;
                        }
+                       $lock = 
isset($this->override_locks[$p->real_full_path]) ? 
$this->override_locks[$p->real_full_path] : '';
                        if ($p->outside)
                        {
                                if (file_exists($p->real_full_path))
@@ -1410,7 +1496,7 @@
                                        return False;
                                }
                        }
-                       else 
if($this->dav_client->mkcol($this->dav_path($p->real_full_path), 
$this->override_locks[$p->real_full_path]) != 201) 
+                       else 
if($this->dav_client->mkcol($this->dav_path($p->real_full_path), $lock) != 201) 
                        {
                                return False;
                        }
@@ -1456,7 +1542,7 @@
                                $homedir = $this->fakebase.'/'.$this->dav_user; 
                                if ( substr($p->fake_leading_dirs, 0, 
strlen($homedir)) == $homedir)
                                { 
-                                       $conf =& 
CreateObject('phpgwapi.config', 'phpgwapi');
+                                       $conf = CreateObject('phpgwapi.config', 
'phpgwapi');
                                        $conf->read_repository();
                                        if ($conf->config_data['acl_default'] 
!= 'grant')
                                        {
@@ -1568,6 +1654,12 @@
                */
                function set_attributes 
($data,$operation=PHPGW_ACL_EDIT,$is_dir=False)
                {
+                       if(!isset($data['attributes']))
+                       {
+                               _debug_array(debug_backtrace());
+                               _debug_array('Set_attributes with no attributes 
??? what else ?');
+                               return false;
+                       }
                        /*To get much benefit out of DAV properties we should 
use 
                        some sensible XML namespace.  We will use the Dublin 
Core 
                        metadata specification (http://dublincore.org/) here 
where 
@@ -1578,29 +1670,33 @@
                                ));
                        $dav_properties = array();
                        $lid=''; $fname = ''; $lname='';
-                       if ($data['attributes']['comment'])
+                       if(!isset($data['attributes']['owner_id']) && 
isset($data['attributes']['createdby_id']))
+                       {
+                               $data['attributes']['owner_id'] = 
$data['attributes']['createdby_id'];
+                       }
+                       if (isset($data['attributes']['comment']))
                        {
                                $dav_properties['dc:description'] = 
$data['attributes']['comment'];
                        }
-                       if ($id=$data['attributes']['owner_id'])
+                       if (isset($data['attributes']['owner_id']) && 
$id=$data['attributes']['owner_id'])
                        {
                                
$GLOBALS['phpgw']->accounts->get_account_name($id,$lid,$fname,$lname);
                                $dav_properties['dc:publisher'] = $fname .' '. 
$lname;
                                $dav_properties['publisher_id'] = $id;
                        }
-                       if ($id=$data['attributes']['createdby_id'])
+                       if (isset($data['attributes']['createdby_id']) && 
$id=$data['attributes']['createdby_id'])
                        {
                                
$GLOBALS['phpgw']->accounts->get_account_name($id,$lid,$fname,$lname);
                                $dav_properties['dc:creator'] = $fname .' '. 
$lname;
                                $dav_properties['creator_id'] = $id;
                        }
-                       if ($id=$data['attributes']['modifiedby_id'])
+                       if (isset($data['attributes']['modifiedby_id']) && 
$id=$data['attributes']['modifiedby_id'])
                        {
                                
$GLOBALS['phpgw']->accounts->get_account_name($id,$lid,$fname,$lname);
                                $dav_properties['dc:contributor'] = $fname .' 
'. $lname;
                                $dav_properties['contributor_id'] = $id;
                        }
-                       if ($id=$data['attributes']['app'])
+                       if (isset($data['attributes']['app']) && 
$id=$data['attributes']['app'])
                        {
                                $dav_properties['dc:source'] = $id;
                        }
@@ -1608,7 +1704,8 @@
                        $xmlns = 'xmlns:dc="http://purl.org/dc/elements/1.1/";';
                        if ( !$p->outside )
                        {
-                               
$this->dav_client->proppatch($this->dav_path($p->real_full_path), 
$dav_properties, $xmlns, $this->override_locks[$p->real_full_path]);
+                               $lock = 
isset($this->override_locks[$p->real_full_path]) ? 
$this->override_locks[$p->real_full_path] : '';
+                               
$this->dav_client->proppatch($this->dav_path($p->real_full_path), 
$dav_properties, $xmlns, $lock);
                        }
                        else
                        {
@@ -1697,7 +1794,7 @@
                                $this->debug('found but denied');
                                return True;
                        }
-                       if ($props[$path])
+                       if (isset($props[$path]))
                        {
                                $this->debug('found');
                                return True;
@@ -1766,7 +1863,7 @@
                                $prop=$this->get_properties($p->real_full_path, 
0, $type == 'Directory');
                                if(!is_array($prop))
                                {
-                                       return array(); // Don't exist or 
access denied (check with file_exists
+                                       return array(); // Don't exist or 
access denied (check with file_exists)
                                }
                                $rarray = array ();
 
@@ -1819,7 +1916,21 @@
                        }
 $this->debug('ls branch 3',DEBUG_LS);
                        /* $dir's not a file, is inside the virtual root, and 
they want to check subdirs */
+                       if(isset($data['rev']))
+                       {
+                               $parsed_url = parse_url($p->real_full_path);
+                               $parsed_url['path'] = $p->fake_full_path;
+                               $parsed_url['pathhis'] =$this->svn_history_path;
+                               $parsed_url['repos'] = 
$this->svn_repository_path;    
+                               $parsed_url['rev'] = $data['rev'];
+                               $location = $this->glue_url($parsed_url);
+                               $prop=$this->get_properties($location,1,true);
+                               unset($prop[$location]);                        
        
+                       }
+                       else
+                       {
                        $prop=$this->get_properties($p->real_full_path,1,true);
+                       }       
                        if ( !is_array($prop) )
                        {
                                return array();
@@ -1834,7 +1945,14 @@
                                foreach ( $prop as $key=>$value)
                                {
                                        $id++;
+                                       if(isset($value[$data['orderby']]))
+                                       {
                                        $new_key =  
substr($value[$data['orderby']].'        ',0, 8);
+                                       }
+                                       else
+                                       {
+                                               $new_key = 
substr($value['name'].'        ',0, 8);
+                                       }
                                        $tmp_prop[strtolower($new_key).'_'.$id] 
= $value;
                                }
                        }
@@ -1851,7 +1969,7 @@
                        $datanew['relatives'][0]=RELATIVE_NONE;
                        foreach($tmp_prop as $idx => $value)
                        {       
-                               if ( $data['checksubdirs'] && $value['is_dir'] )
+                               if ( $data['checksubdirs'] && 
isset($value['is_dir']) && $value['is_dir'])
                                {
                                        /* We have the choice between an 
infinite propfind 
                                        * or goind directory under directory : 
this is better 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]