From 984e9727a09866612c62cd4cda76a9767bae2db7 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 26 Sep 2009 14:05:35 -0400
Subject: [PATCH] - call user2email also for login with @ (#1486147)

---
 plugins/filesystem_attachments/filesystem_attachments.php |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php
index 9a6c0a8..fcdcea7 100644
--- a/plugins/filesystem_attachments/filesystem_attachments.php
+++ b/plugins/filesystem_attachments/filesystem_attachments.php
@@ -40,6 +40,7 @@
 
         // Delete all temp files associated with this user
         $this->add_hook('cleanup_attachments', array($this, 'cleanup'));
+        $this->add_hook('kill_session', array($this, 'cleanup'));
     }
 
     /**
@@ -73,21 +74,25 @@
     function save($args)
     {
         $args['status'] = false;
-        $rcmail = rcmail::get_instance();
-        $temp_dir = unslashify($rcmail->config->get('temp_dir'));
-        $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
 
-        if ($fp = fopen($tmp_path, 'w')) {
-            fwrite($fp, $args['data']);
-            fclose($fp);
-            
-            $args['id'] = count($_SESSION['plugins']['filesystem_attachments']['tmp_files'])+1;
-            $args['path'] = $tmp_path;
-            $args['status'] = true;
-            
-            // Note the file for later cleanup
-            $_SESSION['plugins']['filesystem_attachments']['tmp_files'][] = $tmp_path;
+        if (!$args['path']) {
+            $rcmail = rcmail::get_instance();
+            $temp_dir = unslashify($rcmail->config->get('temp_dir'));
+            $tmp_path = tempnam($temp_dir, 'rcmAttmnt');
+
+            if ($fp = fopen($tmp_path, 'w')) {
+                fwrite($fp, $args['data']);
+                fclose($fp);
+                $args['path'] = $tmp_path;
+            } else
+                return $args;
         }
+        
+        $args['id'] = count($_SESSION['plugins']['filesystem_attachments']['tmp_files'])+1;
+        $args['status'] = true;
+            
+        // Note the file for later cleanup
+        $_SESSION['plugins']['filesystem_attachments']['tmp_files'][] = $args['path'];
 
         return $args;
     }

--
Gitblit v1.9.1