phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: infolog/inc class.bolink.inc.php,1.10,1.11 class


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: infolog/inc class.bolink.inc.php,1.10,1.11 class.solink.inc.php,1.9,1.10 class.uiinfolog.inc.php,1.54,1.55 class.vfs.inc.php,1.6,1.7
Date: Sun, 20 Oct 2002 11:05:52 -0400

Update of /cvsroot/phpgroupware/infolog/inc
In directory subversions:/tmp/cvs-serv15400

Modified Files:
        class.bolink.inc.php class.solink.inc.php 
        class.uiinfolog.inc.php class.vfs.inc.php 
Log Message:
Got fileattachments working as links:
- link-widget and infolog/link-class can attach files now
- changed the value of the file-widget (it's an array now)

Index: class.bolink.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.bolink.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** class.bolink.inc.php        17 Oct 2002 23:32:14 -0000      1.10
--- class.bolink.inc.php        20 Oct 2002 15:05:50 -0000      1.11
***************
*** 67,72 ****
                                ),
                                'view_id' => 'action_id',
!                       )
                );
  
                function bolink( )
--- 67,76 ----
                                ),
                                'view_id' => 'action_id',
!                       ),
                );
+               var $vfs;
+               var $vfs_basedir='/infolog';
+               var $valid_pathes = array();
+               var $send_file_ips = array();
  
                function bolink( )
***************
*** 76,81 ****
                                'query' => True,
                                'title' => True,
!                               'view'  => True
                        );
                }
  
--- 80,96 ----
                                'query' => True,
                                'title' => True,
!                               'view'  => True,
!                               'vfs_view' => True
                        );
+                       $this->vfs = CreateObject('infolog.vfs');
+ 
+                       $config = CreateObject('phpgwapi.config');
+                       $config->read_repository();
+                       if (is_array($config->config_data))
+                       {
+                               $this->link_pathes   = 
$config->config_data['link_pathes'];
+                               $this->send_file_ips = 
$config->config_data['send_file_ips'];
+                       }
+                       unset($config);
                }
  
***************
*** 86,91 ****
                @abstract creats a link between $app1,$id1 and $app2,$id2 - 
$id1 does NOT need to exist yet
                @param $app1 app of $id1
!               @param $id1 id of item to linkto or 0 if item not yet created 
or array with links of not created item
                @param $app2 app of 2.linkend or array with links ($id2 not 
used)
                @param $remark Remark to be saved with the link (defaults to '')
                @param $owner Owner of the link (defaults to user)
--- 101,115 ----
                @abstract creats a link between $app1,$id1 and $app2,$id2 - 
$id1 does NOT need to exist yet
                @param $app1 app of $id1
!               @param $id1 id of item to linkto or 0 if item not yet created 
or array with links 
!                       of not created item or $file-array if $app1 == 'vfs' 
(see below)
                @param $app2 app of 2.linkend or array with links ($id2 not 
used)
+               @param $id2 id of 2. item of $file-array if $app2 == 'vfs' (see 
below)
+               @param $file array with informations about the file in format 
of the etemplate file-type
+               @param $file['name'] name of the file (no directory)
+               @param $file['type'] mine-type of the file
+               @param $file['tmp_name'] name of the uploaded file (incl. 
directory)
+               @param $file['path'] path of the file on the client computer
+               @param $file['ip'] of the client
+               @discussion path and ip are only needed if u want a symlink (if 
possible)
                @param $remark Remark to be saved with the link (defaults to '')
                @param $owner Owner of the link (defaults to user)
***************
*** 127,134 ****
                                while ($link_id && list(,$link) = each($app2))
                                {
!                                       $link_id = 
solink::link($app1,$id1,$link['app'],$link['id'],$link['remark'],$link['owner'],$link['lastmod']);
                                }
                                return $link_id;
                        }
                        return 
solink::link($app1,$id1,$app2,$id2,$remark,$owner);
                }
--- 151,174 ----
                                while ($link_id && list(,$link) = each($app2))
                                {
!                                       if ($link['app'] == 'vfs')
!                                       {
!                                               $link_id = 
-intval($this->attach_file($app1,$id1,$link['id'],$link['remark']));
!                                       }
!                                       else
!                                       {
!                                               $link_id = 
solink::link($app1,$id1,$link['app'],$link['id'],
!                                                       
$link['remark'],$link['owner'],$link['lastmod']);
!                                       }
                                }
                                return $link_id;
                        }
+                       if ($app1 == 'vfs')
+                       {
+                               return 
-intval($this->attach_file($app2,$id2,$id1,$remark));
+                       }
+                       elseif ($app2 == 'vfs')
+                       {
+                               return 
-intval($this->attach_file($app1,$id1,$id2,$remark));
+                       }
                        return 
solink::link($app1,$id1,$app2,$id2,$remark,$owner);
                }
***************
*** 168,172 ****
                                return $ids;
                        }
!                       return solink::get_links($app,$id,$only_app,$order);
                }
  
--- 208,222 ----
                                return $ids;
                        }
!                       $ids = solink::get_links($app,$id,$only_app,$order);
! 
!                       if (empty($only_apps) || $only_apps == 'vfs' ||
!                           ($only_app[0] == '!' && $only_app != '!vfs'))
!                       {
!                               if ($vfs_ids = $this->list_attached($app,$id))
!                               {
!                                       $ids += $vfs_ids;
!                               }
!                       }
!                       return $ids;
                }
  
***************
*** 191,194 ****
--- 241,256 ----
                                return False;
                        }
+                       if (intval($app_link_id) < 0 || $app_link_id == 'vfs' 
|| $app2 == 'vfs')
+                       {
+                               if (intval($app_link_id) < 0)   // vfs link_id ?
+                               {
+                                       return 
$this->fileinfo2link(-$app_link_id);
+                               }
+                               if ($app_link_id == 'vfs')
+                               {
+                                       return 
$this->info_attached($app2,$id2,$id);
+                               }
+                               return 
$this->info_attached($app_link_id,$id,$id2);
+                       }
                        return solink::get_link($app_link_id,$id,$app2,$id2);
                }
***************
*** 207,210 ****
--- 269,284 ----
                function 
unlink($link_id,$app='',$id='',$owner='',$app2='',$id2='')
                {
+                       if ($link_id < 0)       // vfs-link?
+                       {
+                               return $this->delete_attached(-$link_id);
+                       }
+                       elseif ($app == 'vfs')
+                       {
+                               return $this->delete_attached($app2,$id2,$id);
+                       }
+                       elseif ($app2 == 'vfs')
+                       {
+                               return $this->delete_attached($app,$id,$id2);
+                       }
                        if ($link_id > 0 || !is_array($id))
                        {
***************
*** 239,247 ****
                }
  
-               function check_method($method,&$class,&$func)
-               {
-                       // Idea: check if method exist and cache the class
-               }
- 
                /*!
                @function query
--- 313,316 ----
***************
*** 273,278 ****
                @result the title
                */
!               function title($app,$id)
                {
                        if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['title']))
                        {
--- 342,371 ----
                @result the title
                */
!               function title($app,$id,$link='')
                {
+                       if ($this->debug)
+                       {
+                               echo "<p>bolink::title('$app','$id')</p>\n";
+                       }
+                       if ($app == 'vfs')
+                       {
+                               if (is_array($link))
+                               {
+                                       $size = $link['size'];
+                                       if ($size_k = intval($size / 1024))
+                                       {
+                                               if (intval($size_k / 1024))
+                                               {
+                                                       $size = 
sprintf('%3.1dM',doubleval($size_k)/1024.0);
+                                               }
+                                               else
+                                               {
+                                                       $size = $size_k.'k';
+                                               }
+                                       }
+                                       $size = ' '.$size;
+                               }
+                               return $id.$size;
+                       }
                        if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['title']))
                        {
***************
*** 291,296 ****
                @result array with name-value pairs for link to view-methode of 
$app to view $id
                */
!               function view($app,$id)
                {
                        if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
                        {
--- 384,393 ----
                @result array with name-value pairs for link to view-methode of 
$app to view $id
                */
!               function view($app,$id,$link='')
                {
+                       if ($app == 'vfs' && !empty($id) && is_array($link))
+                       {
+                               return $this->vfs_view($link);
+                       }
                        if ($app == '' || !is_array($reg = 
$this->app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id']))
                        {
***************
*** 313,316 ****
--- 410,742 ----
                        }
                        return $view;
+               }
+               
+               function vfs_view($link='')
+               {
+                       if (is_array($link))
+                       {
+                               return array(
+                                       'menuaction' => 
'infolog.bolink.vfs_view',
+                                       'app' => $link['app2'],
+                                       'id'  => $link['id2'],
+                                       'filename' => $link['id']
+                               );
+                       }
+                       $app = get_var('app','GET');
+                       $id  = get_var('id','GET');
+                       $filename = get_var('filename','GET');
+ 
+                       if (empty($app) || empty($id) || empty($filename) /* || 
!$this->bo->check_access($info_id,PHPGW_ACL_READ)*/)
+                       {
+                               Header('Location: ' .  
$GLOBALS['phpgw']->link('/'));
+                               exit();
+                       }
+                       $browser = CreateObject('phpgwapi.browser');
+ 
+                       $local = $this->attached_local($app,$id,$filename,
+                               
get_var('REMOTE_ADDR',Array('SERVER')),$browser->is_windows());
+                       
+                       if ($local)
+                       {
+                               Header('Location: ' . $local);
+                               exit();
+                       }
+                       $info = $this->info_attached($app,$id,$filename);
+                       $browser->content_header($filename,$info['mime_type']);
+                       echo $this->read_attached($app,$id,$filename);
+                       
+                       exit();
+               }
+ 
+               /*!
+               @function vfs_path
+               @syntax vfs_path ( $app,$id,$file='' )
+               @abstract path to the attached files of $app/$ip
+               @discussion All link-files are based in the vfs-subdir 
'infolog'. For other apps
+               @discussion separate subdirs with name app are created.
+               */
+               function vfs_path($app,$id='',$file='')
+               {
+                       $path = $this->vfs_basedir . ($app == '' || $app == 
'infolog' ? '' : '/'.$app) .
+                               ($id != '' ? '/' . $id : '') . ($file != '' ? 
'/' . $file : '');
+                       
+                       if ($this->debug)
+                       {
+                               echo "<p>bolink::vfs_path('$app','$id','$file') 
= '$path'</p>\n";
+                       }
+                       return $path;
+               }
+ 
+               /*!
+               @function vfs_path
+               @syntax vfs_path ( $app,$id,$file='' )
+               @abstract Put a file to the corrosponding place in the VFS and 
set the attributes
+               @param $app/$id entry which should the file should be linked 
with
+               @param $file array with informations about the file in format 
of the etemplate file-type
+               @param $file['name'] name of the file (no directory)
+               @param $file['type'] mine-type of the file
+               @param $file['tmp_name'] name of the uploaded file (incl. 
directory)
+               @param $file['path'] path of the file on the client computer
+               @param $file['ip'] of the client
+               @discussion path and ip are only needed if u want a symlink (if 
possible)
+               */
+               function attach_file($app,$id,$file,$comment='')
+               {
+                       if ($this->debug)
+                       {
+                               echo "<p>attach_file: app='$app', id='$id', 
tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', 
type='$file[type]', path='$file[path]', ip='$file[ip]', 
comment='$comment'</p>\n";
+                       }
+                       // create the root for attached files in infolog, if it 
does not exists
+                       if 
(!($this->vfs->file_exists($this->vfs_basedir,array(RELATIVE_ROOT))))
+                       {
+                               $this->vfs->override_acl = 1;
+                               
$this->vfs->mkdir($this->vfs_basedir,array(RELATIVE_ROOT));
+                               $this->vfs->override_acl = 0;
+                       }
+ 
+                       $dir=$this->vfs_path($app);
+                       if 
(!($this->vfs->file_exists($dir,array(RELATIVE_ROOT))))
+                       {
+                               $this->vfs->override_acl = 1;
+                               $this->vfs->mkdir($dir,array(RELATIVE_ROOT));
+                               $this->vfs->override_acl = 0;
+                       }
+                       $dir=$this->vfs_path($app,$id);
+                       if 
(!($this->vfs->file_exists($dir,array(RELATIVE_ROOT))))
+                       {
+                               $this->vfs->override_acl = 1;
+                               $this->vfs->mkdir($dir,array(RELATIVE_ROOT));
+                               $this->vfs->override_acl = 0;
+                       }
+                       $fname = $this->vfs_path($app,$id,$file['name']);
+                       $tfname = '';
+                       if (!empty($file['path']))
+                       {
+                               $file['path'] = 
str_replace('\\\\','/',$file['path']);  // vfs uses only '/'
+                               @reset($this->link_pathes);
+                               while ((list($valid,$trans) = 
@each($this->link_pathes)) && !$tfname)
+                               {  // check case-insensitive for WIN etc.
+                                       $check = $valid[0] == '\\' || 
strstr(':',$valid) ? 'eregi' : 'ereg';
+                                       $valid2 = str_replace('\\','/',$valid);
+                                       //echo "<p>attach_file: 
ereg('".$this->send_file_ips[$valid]."', 
'$file[ip]')=".ereg($this->send_file_ips[$valid],$file['ip'])."</p>\n";
+                                       if 
($check('^('.$valid2.')(.*)$',$file['path'],$parts) &&
+                                           
ereg($this->send_file_ips[$valid],$file['ip']) &&     // right IP
+                                           
$this->vfs->file_exists($trans.$parts[2],array(RELATIVE_NONE|VFS_REAL)))
+                                       {
+                                               $tfname = $trans.$parts[2];
+                                       }
+                                       //echo "<p>attach_file: 
full_fname='$file[path]', valid2='$valid2', trans='$trans', check=$check, 
tfname='$tfname', parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
+                               }
+                               if ($tfname && 
!$this->vfs->securitycheck($tfname))
+                               {
+                                       return False; //lang('Invalid 
filename').': '.$tfname;
+                               }
+                       }
+                       $this->vfs->override_acl = 1;
+                       if ($tfname)    // file is local
+                       {
+                               
$this->vfs->symlink($tfname,$fname,array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT));
+                       }
+                       else
+                       {
+                               
$this->vfs->cp($file['tmp_name'],$fname,array(RELATIVE_NONE|VFS_REAL,RELATIVE_ROOT));
+                       }
+                       $this->vfs->set_attributes ($fname, array 
(RELATIVE_ROOT),
+                               array ('mime_type' => $file['type'],
+                                                'comment' => stripslashes 
($comment),
+                                                'app' => $app));
+                       $this->vfs->override_acl = 0;
+ 
+                       $link = $this->info_attached($app,$id,$file['name']);
+                       return is_array($link) ? $link['file_id'] : False;
+               }
+ 
+               /*!
+               @function delete_attached
+               @syntax delete_attached( $app,$id,$filename )
+               @author ralfbecker
+               @abstract deletes an attached file
+               @param $app > 0: file_id of an attchemnt or $app/$id entry 
which linked to
+               @param $filename
+               */
+               function delete_attached($app,$id='',$fname = '')
+               {
+                       if (intval($app) > 0)   // is file_id
+                       {
+                               $link  = $this->fileinfo2link($file_id=$app);
+                               $app   = $link['app2'];
+                               $id    = $link['id2'];
+                               $fname = $link['id'];
+                       }
+                       if ($this->debug)
+                       {
+                               echo 
"<p>bolink::delete_attached('$app','$id','$fname') file_id=$file_id</p>\n";
+                       }
+                       if (empty($app) || empty($id))
+                       {
+                               return False;   // dont delete more than all 
attachments of an entry
+                       }
+                       $file = $this->vfs_path($app,$id,$fname);
+ 
+                       if ($this->vfs->file_exists($file,array(RELATIVE_ROOT)))
+                       {
+                               $this->vfs->override_acl = 1;
+                               $Ok = 
$this->vfs->delete($file,array(RELATIVE_ROOT));
+                               $this->vfs->override_acl = 0;
+                               return $Ok;
+                       }
+                       return False;
+               }
+ 
+               /*!
+               @function info_attached
+               @syntax info_attached( $app,$id,$filename )
+               @author ralfbecker
+               @abstract converts the infos vfs has about a file into a link
+               @param $app/$id entry which linked to
+               @param $filename
+               @returns a 'kind' of link-array
+               */
+               function info_attached($app,$id,$filename)
+               {
+                       $this->vfs->override_acl = 1;
+                       $attachments = 
$this->vfs->ls($this->vfs_path($app,$id,$filename),array(REALTIVE_NONE));
+                       $this->vfs->override_acl = 0;
+ 
+                       if (!count($attachments) || !$attachments[0]['name'])
+                       {
+                               return False;
+                       }
+                       return $this->fileinfo2link($attachments[0]);
+               }
+ 
+               /*!
+               @function fileinfo2link
+               @syntax fileinfo2link( $fileinfo )
+               @author ralfbecker
+               @abstract converts a fileinfo (row in the vfs-db-table) in a 
link
+               @param $fileinfo a row from the vfs-db-table (eg. returned by 
the vfs ls function)
+                       or a file_id of that table
+               @returns a 'kind' of link-array
+               */
+               function fileinfo2link($fileinfo)
+               {
+                       if (!is_array($fileinfo))
+                       {
+                               $fileinfo = $this->vfs->fileinfo($fileinfo);
+                               list(,$fileinfo) = each($fileinfo);
+ 
+                               if (!is_array($fileinfo))
+                               {
+                                       return False;
+                               }
+                       }
+                       $lastmod = $fileinfo[!empty($fileinfo['modified']) ? 
'modified' : 'created'];
+                       list($y,$m,$d) = explode('-',$lastmod);
+                       $lastmod = mktime(0,0,0,$m,$d,$y);
+                       
+                       $dir_parts = 
array_reverse(explode('/',$fileinfo['directory']));
+ 
+                       return array(
+                               'app'       => 'vfs',
+                               'id'        => $fileinfo['name'],
+                               'app2'      => $dir_parts[1],
+                               'id2'       => $dir_parts[0],
+                               'remark'    => $fileinfo['comment'],
+                               'owner'     => $fileinfo['owner_id'],
+                               'link_id'   => -$fileinfo['file_id'],
+                               'lastmod'   => $lastmod,
+                               'size'      => $fileinfo['size'],
+                               'mime_type' => $fileinfo['mime_type']
+                       );
+               }
+ 
+               /*!
+               @function list_attached
+               @syntax list_attached( $app,$id )
+               @author ralfbecker
+               @abstract lists all attachments to $app/$id
+               @returns a 'kind' of link-array
+               */
+               function list_attached($app,$id)
+               {
+                       $this->vfs->override_acl = 1;
+                       $attachments = 
$this->vfs->ls($this->vfs_path($app,$id),array(REALTIVE_NONE));
+                       $this->vfs->override_acl = 0;
+ 
+                       if (!count($attachments) || !$attachments[0]['name'])
+                       {
+                               return False;
+                       }
+                       while (list(,$fileinfo) = each($attachments))
+                       {
+                               $link = $this->fileinfo2link($fileinfo);
+                               $attached[$link['link_id']] = $link;
+                       }
+                       return $attached;
+               }
+ 
+               /*!
+               @function is_win_path
+               @syntax is_win_path( $path )
+               @author ralfbecker
+               @abstract checks if path starts with a '\\' or has a ':' in it
+               */
+               function is_win_path($path)
+               {
+                       return $path[0] == '\\' || strstr($path,':');
+               }
+ 
+               /*!
+               @function read_attached
+               @syntax read_attached($app,$id,$filename)
+               @author ralfbecker
+               @abstract reads the attached file and returns the content
+               */
+               function read_attached($app,$id,$filename)
+               {
+                       if (empty($app) || !$id || empty($filename) /*|| 
!$this->check_access($info_id,PHPGW_ACL_READ)*/)
+                       {
+                               return False;
+                       }
+                       $this->vfs->override_acl = 1;
+                       return 
$this->vfs->read($this->vfs_path($app,$id,$filename),array(RELATIVE_ROOT));
+               }
+ 
+               /*!
+               @function attached_local
+               @syntax attached_local($app,$id,$filename,$ip,$win_user)
+               @author ralfbecker
+               @abstract Checks if filename should be local availible and if 
so returns
+               @abstract 'file:/path' for HTTP-redirect else return False
+               */
+               function attached_local($app,$id,$filename,$ip,$win_user)
+               {
+                       //echo "<p>attached_local(app=$app, id='$id', 
filename='$filename', ip='$ip', win_user='$win_user', 
count(send_file_ips)=".count($this->send_file_ips).")</p>\n";
+ 
+                       if (!$id || !$filename || /* 
!$this->check_access($info_id,PHPGW_ACL_READ) || */
+                           !count($this->send_file_ips))
+                       {
+                               return False;
+                       }
+                       $link = $this->vfs->readlink 
($this->vfs_path($app,$id,$filename), array (RELATIVE_ROOT));
+ 
+                       if ($link)
+                       {
+                               reset($this->link_pathes); $fname = '';
+                               while ((list($valid,$trans) = 
each($this->link_pathes)) && !$fname)
+                               {
+                                       if (!$this->is_win_path($valid) == 
!$win_user && // valid for this OS
+                                           
eregi('^'.$trans.'(.*)$',$link,$parts)  &&    // right path
+                                           
ereg($this->send_file_ips[$valid],$ip))      // right IP
+                                       {
+                                               $fname = $valid . $parts[1];
+                                               $fname = !$win_user ? 
str_replace('\\','/',$fname) : str_replace('/','\\',$fname);
+                                               return 'file:'.($win_user ? 
'//' : '' ).$fname;
+                                       }
+                                       // echo "<p>attached_local: link=$link, 
valid=$valid, trans='$trans', fname='$fname', 
parts=(x,'${parts[1]}','${parts[2]}')</p>\n";
+                               }
+                       }
+                       return False;
                }
  

Index: class.solink.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.solink.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.solink.inc.php        18 Oct 2002 20:20:35 -0000      1.9
--- class.solink.inc.php        20 Oct 2002 15:05:50 -0000      1.10
***************
*** 62,66 ****
                function link( 
$app1,$id1,$app2,$id2,$remark='',$owner=0,$lastmod=0 )
                {
!                       //if ($this->debug)
                        {
                                echo 
"<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";
--- 62,66 ----
                function link( 
$app1,$id1,$app2,$id2,$remark='',$owner=0,$lastmod=0 )
                {
!                       if ($this->debug)
                        {
                                echo 
"<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n";

Index: class.uiinfolog.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.uiinfolog.inc.php,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -r1.54 -r1.55
*** class.uiinfolog.inc.php     19 Oct 2002 11:17:24 -0000      1.54
--- class.uiinfolog.inc.php     20 Oct 2002 15:05:50 -0000      1.55
***************
*** 76,82 ****
                                're'      => 'Re:'
                        );
-                       //$this->html = CreateObject('etemplate.html');
-                       //$this->categories = 
CreateObject('phpgwapi.categories');
-                       //$this->nextmatchs = 
CreateObject('phpgwapi.nextmatchs');
                        $this->link = &$this->bo->link;
                        
--- 76,79 ----
***************
*** 1440,1444 ****
                        if(get_var('save',Array('POST')))
                        {
!                               $this->bo->link_pathes = array(); 
$this->bo->send_file_ips = array();
  
                                $valid = get_var('valid',Array('POST'));
--- 1437,1441 ----
                        if(get_var('save',Array('POST')))
                        {
!                               $this->bo->link_pathes = 
$this->bo->send_file_ips = array();
  
                                $valid = get_var('valid',Array('POST'));
***************
*** 1470,1474 ****
                                'text' => lang('<b>file-attachments via 
symlinks</b> instead of uploads and retrieval via file:/path for direct 
lan-clients'),
                                'action_url'  => 
$this->html->link('/index.php',$this->menuaction('admin')),
!                               'bg_h_color'  => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
                                'save_button' => 
$this->html->submit_button('save','Save'),
                                'done_button' => 
$this->html->submit_button('done','Done'),
--- 1467,1471 ----
                                'text' => lang('<b>file-attachments via 
symlinks</b> instead of uploads and retrieval via file:/path for direct 
lan-clients'),
                                'action_url'  => 
$this->html->link('/index.php',$this->menuaction('admin')),
!                               'bg_h_color'  => 'th',
                                'save_button' => 
$this->html->submit_button('save','Save'),
                                'done_button' => 
$this->html->submit_button('done','Done'),
***************
*** 1482,1486 ****
                                list($valid,$trans) = 
@each($this->bo->link_pathes);
                                $GLOBALS['phpgw']->template->set_var(array(
!                                       'bg_nm_color' => 
$this->nextmatchs->alternate_row_color(),
                                        'num'       => $i+1,
                                        'val_valid' => 
$this->html->input("valid[$i]",$valid),
--- 1479,1483 ----
                                list($valid,$trans) = 
@each($this->bo->link_pathes);
                                $GLOBALS['phpgw']->template->set_var(array(
!                                       'bg_nm_color' => $i & 1 ? 'row_off' : 
'row_on',
                                        'num'       => $i+1,
                                        'val_valid' => 
$this->html->input("valid[$i]",$valid),
***************
*** 1497,1502 ****
                function preferences( )
                {
-                       global $save;
- 
                        $prefs = array(
                                'homeShowEvents'        => 'Show open Events: 
Tasks/Calls/Notes on main screen',
--- 1494,1497 ----
***************
*** 1511,1515 ****
                        $GLOBALS['phpgw']->preferences->read_repository();
  
!                       if ($save)
                        {
                                while (list($pref,$lang) = each($prefs))
--- 1506,1510 ----
                        $GLOBALS['phpgw']->preferences->read_repository();
  
!                       if ($GLOBALS['HTTP_POST_VARS']['save'])
                        {
                                while (list($pref,$lang) = each($prefs))
***************
*** 1532,1543 ****
                                'text' => '&nbsp;',
                                'action_url' => 
$this->html->link('/index.php',$this->menuaction('preferences')),
!                               'bg_h_color' => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
                                'save_button' => 
$this->html->submit_button('save','Save')
                        );
                        $GLOBALS['phpgw']->template->set_var($vars);
  
!                       while (list($pref,$lang) = each($prefs))
                        {
!                               
$GLOBALS['phpgw']->template->set_var('bg_nm_color',$this->nextmatchs->alternate_row_color());
                                
$GLOBALS['phpgw']->template->set_var('field',lang($lang));
  
--- 1527,1538 ----
                                'text' => '&nbsp;',
                                'action_url' => 
$this->html->link('/index.php',$this->menuaction('preferences')),
!                               'bg_h_color' => 'th',
                                'save_button' => 
$this->html->submit_button('save','Save')
                        );
                        $GLOBALS['phpgw']->template->set_var($vars);
  
!                       for ($n=0; list($pref,$lang) = each($prefs); ++$n)
                        {
!                               
$GLOBALS['phpgw']->template->set_var('bg_nm_color',$n & 1 ? 'row_off':'row_on');
                                
$GLOBALS['phpgw']->template->set_var('field',lang($lang));
  

Index: class.vfs.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/inc/class.vfs.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.vfs.inc.php   2 Sep 2002 21:46:11 -0000       1.6
--- class.vfs.inc.php   20 Oct 2002 15:05:50 -0000      1.7
***************
*** 26,31 ****
        /*!
        @class vfs
-       @author ralfbecker
-       @author ralfbecker
        @abstract Virtual File System
        @description Authors: Zone
--- 26,29 ----
***************
*** 58,63 ****
        /*!
        @class path_class
-       @author ralfbecker
-       @author ralfbecker
        @abstract helper class for path_parts
        */
--- 56,59 ----
***************
*** 1305,1308 ****
--- 1301,1308 ----
                        }
  
+                       if ($this->debug)
+                       {
+                               echo 
"<p>vfs::$cmd('$from','$to',$relatives[0],$relatives[1])</p>\n";
+                       }
                        $account_id = 
$GLOBALS['phpgw_info']['user']['account_id'];
  
***************
*** 1339,1342 ****
--- 1339,1347 ----
                        if ($this->file_type ($f->fake_full_path, array 
($f->mask)) != 'Directory')
                        {
+                               if ($this->debug)
+                               {
+                                       echo 
"<p>$cmd('$f->read_full_path','$t->real_full_path')</p>\n";
+                               }
+ 
                                if (!$cmd ($f->real_full_path, 
$t->real_full_path))
                                {
***************
*** 1395,1398 ****
--- 1400,1407 ----
                        else    /* It's a directory */
                        {
+                               if ($this->debug)
+                               {
+                                       echo 
"<p>mkdir('$t->real_full_path')</p>\n";
+                               }
                                /* First, make the initial directory */
                                $this->mkdir ($to, array ($relatives[1]));
***************
*** 1453,1457 ****
  
                /*!
!               @function readlink
                @abstract read linkdata (target path) for symlink created by 
symlink
                @param $path vfs file/directory
--- 1462,1467 ----
  
                /*!
!               @function readlink  
!               @syntax readlink( $file,$relatives )
                @abstract read linkdata (target path) for symlink created by 
symlink
                @param $path vfs file/directory
***************
*** 1462,1466 ****
                function readlink($file,$relatives = '')
                {
!                       $pp = $this->path_parts ($file, array (RELATIVE_ROOT));
  
                        return @readlink($pp->real_full_path);
--- 1472,1480 ----
                function readlink($file,$relatives = '')
                {
!                       if (!is_array($relatives))
!                       {
!                               $relatives = array (RELATIVE_ROOT);
!                       }
!                       $pp = $this->path_parts ($file,$relatives);
  
                        return @readlink($pp->real_full_path);
***************
*** 1468,1471 ****
--- 1482,1503 ----
  
                /*!
+               @function fileinfo
+               @syntax readlink( $file_id )
+               @abstract read infos (row in the db) about a file
+               @param $file_id identifying the file
+               @result array with row from db or False
+               */
+               function fileinfo($file_id)
+               {
+                       $GLOBALS['phpgw']->db->query ($sql="SELECT * FROM 
phpgw_vfs WHERE file_id=$file_id", __LINE__, __FILE__);
+ 
+                       if (!$GLOBALS['phpgw']->db->next_record())
+                       {
+                               return False;
+                       }
+                       return array($file_id => $GLOBALS['phpgw']->db->Record);
+               }
+ 
+               /*!
                @function mv
                @abstract move file/directory
***************
*** 2002,2005 ****
--- 2034,2041 ----
                        $p = $this->path_parts ($file, array ($relatives[0]));
  
+                       if ($this->debug)
+                       {
+                               echo "<p>vfs::file_type('$file',$relatives[0]) 
p = "; _debug_array($p);
+                       }
                        if (!$this->acl_check ($p->fake_full_path, array 
($p->mask), PHPGW_ACL_READ, True))
                        {
***************
*** 2036,2040 ****
                @param $string file/directory to check existance of
                @param $relatives Relativity array
!               @result Boolean True/False
                */
                function file_exists ($string, $relatives = '')
--- 2072,2076 ----
                @param $string file/directory to check existance of
                @param $relatives Relativity array
!               @result file_id or False
                */
                function file_exists ($string, $relatives = '')
***************
*** 2055,2059 ****
  
                        $query = $GLOBALS['phpgw']->db->query ("SELECT name 
FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND 
name='$p->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, 
__FILE__);
! 
                        if ($GLOBALS['phpgw']->db->next_record ())
                        {
--- 2091,2095 ----
  
                        $query = $GLOBALS['phpgw']->db->query ("SELECT name 
FROM phpgw_vfs WHERE directory='$p->fake_leading_dirs_clean' AND 
name='$p->fake_name_clean'" . $this->extra_sql (VFS_SQL_SELECT), __LINE__, 
__FILE__);
!                       
                        if ($GLOBALS['phpgw']->db->next_record ())
                        {





reply via email to

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