From dc2acf4428c0659e44054ce8ff2df5a3bfb31159 Mon Sep 17 00:00:00 2001
From: Klaus Leithoff <kl@stylite.de>
Date: Tue, 31 Jul 2007 13:58:15 +0000
Subject: [PATCH] added OpenOffice Fileextensions to class.mime_magic.inc.php;
 fixed a problem for the refreshing of a directory: mime_types got lost, when
 refreshing and the mime type could not be determined by get_real_info. the
 fix uses the phpgwapi.mime_magic.ext2mime function to determine the mime_type
 if the common method fails to find one.

---
 phpgwapi/inc/class.mime_magic.inc.php | 6 ++++++
 phpgwapi/inc/class.vfs_sql.inc.php    | 9 +++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/phpgwapi/inc/class.mime_magic.inc.php b/phpgwapi/inc/class.mime_magic.inc.php
index 07cffe8a9f..baa3dd32a1 100644
--- a/phpgwapi/inc/class.mime_magic.inc.php
+++ b/phpgwapi/inc/class.mime_magic.inc.php
@@ -235,6 +235,7 @@
 		* MIME types.
 		*
 		* Original array taken from http://horde.org
+		* added OpenOffice Extensions by KL@stylite.de
 		*
 		* @author skwashd
 		*
@@ -331,6 +332,11 @@
 				'mxu'	=> 'video/vnd.mpegurl',
 				'nc'	=> 'application/x-netcdf',
 				'oda'	=> 'application/oda',
+				'odb'	=> 'application/vnd.oasis.opendocument.database',
+				'odg'   => 'application/vnd.oasis.opendocument.graphics',
+				'odt'   => 'application/vnd.oasis.opendocument.text',
+				'odp'   => 'application/vnd.oasis.opendocument.presentation',
+				'ods'   => 'application/vnd.oasis.opendocument.spreadsheet',
 				'patch'	=> 'text/diff',
 				'pbm'	=> 'image/x-portable-bitmap',
 				'pdb'	=> 'chemical/x-pdb',
diff --git a/phpgwapi/inc/class.vfs_sql.inc.php b/phpgwapi/inc/class.vfs_sql.inc.php
index 1db06b34fb..ea1b5d24c5 100644
--- a/phpgwapi/inc/class.vfs_sql.inc.php
+++ b/phpgwapi/inc/class.vfs_sql.inc.php
@@ -2590,7 +2590,12 @@
 						'string'	=> $p->fake_name
 					)
 				);
-
+				if (!$mime_type)
+				{
+                                        $parts = explode('.',$p->fake_name);
+                                        $_ext = array_pop($parts);
+                                        $mime_type = ExecMethod('phpgwapi.mime_magic.ext2mime',$_ext);
+ 				}
 				if($mime_type)
 				{
 					$this->db->update($this->vfs_table,array(
@@ -2614,4 +2619,4 @@
 			return $rarray;
 		}
 	}
-?>
\ No newline at end of file
+?>