phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] projects/inc/class.attachedFiles.inc.php, 1.2


From: nomail
Subject: [Phpgroupware-cvs] projects/inc/class.attachedFiles.inc.php, 1.2
Date: Fri, 11 Jun 2004 00:36:11 +0200

Update of /projects/inc
Modified Files:
        Branch: 
          class.attachedFiles.inc.php

date: 2004/06/10 22:36:11;  author: ceb;  state: Exp;  lines: +22 -11

Log Message:
update
=====================================================================
Index: projects/inc/class.attachedFiles.inc.php
diff -u projects/inc/class.attachedFiles.inc.php:1.1 
projects/inc/class.attachedFiles.inc.php:1.2
--- projects/inc/class.attachedFiles.inc.php:1.1        Wed Apr 28 13:34:46 2004
+++ projects/inc/class.attachedFiles.inc.php    Thu Jun 10 22:36:11 2004
@@ -6,7 +6,7 @@
        *                                                                   *
        * Written by Lars Piepho address@hidden                   *
        * -----------------------------------------------                   *
-       * Copyright 2004 Free Software Foundation, Inc.                     *
+       * Copyright 2000 - 2004 Free Software Foundation, Inc.              *
        *                                                                   *
        * This program is free software; you can redistribute it and/or     *
        * modify it under the terms of the GNU General Public License as    *
@@ -22,6 +22,7 @@
        * along with this program; if not, write to the Free Software       *
        * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         *
        \*******************************************************************/
+
        /* $Id$ */
 
        
@@ -70,7 +71,7 @@
                        $GLOBALS['phpgw']->common->phpgw_exit ();
                }
                
-               function save_file($project_id)
+               function save_file($project_id, $source = "", $destination = "")
                {
                        //Check if home/groupdirectory exists. If not, we 
create it
                        $basedir = $GLOBALS['basedir'] . "/projects";
@@ -85,16 +86,25 @@
                                
                        $attdir = $basedir . "/" . $project_id;                 
 
-                       $this->vfs->override_acl = 1;
-                       $this->vfs->mkdir (array (
-                                               'string' => $attdir,
-                                               'relatives' => array 
(RELATIVE_ALL)));
-                       $this->vfs->override_acl = 0;
+                       if (!file_exists($attdir))
+                       {
+                               $this->vfs->override_acl = 1;
+                               $this->vfs->mkdir (array (
+                                                       'string' => $attdir,
+                                                       'relatives' => array 
(RELATIVE_ALL)));
+                               $this->vfs->override_acl = 0;
+                       }
+                       
+                       if(!$source || !$destination)
+                       {
+                               $source = $_FILES['attachment']['tmp_name'];
+                               $destination = $_FILES['attachment']['name'];
+                       }
                                                
                        $this->vfs->override_acl = 1;
                        $this->vfs->cp(array (
-                                               'from'  => 
$_FILES['attachment']['tmp_name'],
-                                               'to'    => $attdir . '/' . 
$_FILES['attachment']['name'],
+                                               'from'  => $source,
+                                               'to'    => $attdir . '/' . 
$destination,
                                                'relatives'     => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)));
                        $this->vfs->override_acl = 0;
                }
@@ -103,7 +113,7 @@
                {
                        $basedir = $GLOBALS['basedir'] . "/projects";
                        
-                       if(!$this->file)
+                       if(!$this->file && file_exists($basedir . "/" . 
$project_id))
                        {
                                $this->vfs->override_acl = 1;
                                $this->vfs->delete(array (
@@ -111,7 +121,7 @@
                                                'relatives' => array 
(RELATIVE_ALL)));
                                $this->vfs->override_acl = 0;
                        }
-                       else
+                       elseif($this->file)
                        {
                                $this->vfs->override_acl = 1;
                                $this->vfs->rm(array (
@@ -156,5 +166,6 @@
                        }                                       
                        return ($attLink);
                }
+               
        }
 ?>




reply via email to

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