1
tomodea
How to Handle Office 2007 File Attachments?
  • 2010/3/11 22:21

  • tomodea

  • Just popping in

  • Posts: 47

  • Since: 2008/2/19


I’ve been trying to work out the modifications needed to handle Office 2007 file attachments: docx, xlsx and pptx.

I’ve been working on modifications to a number of modules, testing with a docx file sent to me by someone who is using Word 2007. I have Office 2002.

In summary, I have found that some modified modules:
1. Can handle docx files correctly: xmail, news and liaise
2. Allow you to attach a docx file but you cannot open the file: xhelp and extcal
3. Do not allow you to attach a docx file: smartsection

mimetypes
According to Microsoft (http://technet.microsoft.com/en-us/library/ee309278.aspx) these are the mimetypes:
.docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document
.xlsx - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.pptx - application/vnd.openxmlformats-officedocument.presentationml.presentation


xmail module
Modify include/mimetype.php.

Look for this statement:
"doc" => "application/msword",


Add these statements:
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
         
"ppt" => "application/mspowerpoint",
         
"pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
         
"xls" => "application/msexcel",
         
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",


You then go into xmail admin and select the required filetypes from the list of Allowed Mimetypes.

This modification allows you to attach a docx file and send the email. Once the email has been received, the user can open the docx file. If the user has a version of Office which is earlier than 2007, then the Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 file formats will be required to open the file. The important point is that this modification to xmail will do the trick.


news module
You can update the list of mimetypes in news admin by adding to the list under the heading: Enter authorized Mime Types for upload
application/msword
application
/vnd.openxmlformats-officedocument.wordprocessingml.document
application
/vnd.ms-excel
application
/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application
/vnd.ms-powerpoint
application
/vnd.openxmlformats-officedocument.presentationml.presentation


You can then attach a docx file to a news item. When you open the attached file, the file is converted by the Compatibility Pack and you can work with the file without any problems.


liaise module
The list of allowable file extensions is defined when you use a form element called File upload. In the list of Allowed filename extensions I entered this list:
doc|xls|ppt|docx|xlsx|pptx|pdf


You can then attach a docx file and submit the form. Once the email has been received, the user can open the docx file without any problems.


xhelp module

You can easily add new mimetypes by going into xhelp admin and updating the list of mimetypes. For example:
File Extension – docx
Application Type/Name - Word Document
Mimetypes - application/vnd.openxmlformats-officedocument.wordprocessingml.document

You can then attach a docx file. However, when you try to open the file, you get an error message:
This is a pre-release version of the Compatibility Pack and can open pre-release Office 2007 files only. Do you want to check for a newer version of the Compatibility Pack?

I have the latest version of the Compatibility Pack installed so this message suggests that there is something wrong with the mimetype.


extcal module
Modify the XOOPS file include/mimetypes.inc.php.

Look for:
"doc"        => "application/msword",


Add:
"docx"     => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",


Look for:
"xls"        => "application/vnd.ms-excel",


Add:
"xlsx"     => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",


Look for:
"ppt"        => "application/vnd.ms-powerpoint",


Add:
"pptx"     => "application/vnd.openxmlformats-officedocument.presentationml.presentation",


You then have to update the extcal module for the changes to be applied.

You can then attach a docx file to a calendar item. However, when you try to open the file, you get an error message:
This is a pre-release version of the Compatibility Pack and can open pre-release Office 2007 files only. Do you want to check for a newer version of the Compatibility Pack?

I have the latest version of the Compatibility Pack installed so this message suggests that there is something wrong with the mimetype.


smartsection module
You can easily add new mimetypes by going into smartsection admin and updating the list of mimetypes. For example:
File Extension – docx
Application Type/Name - Word Document
Mimetypes - application/vnd.openxmlformats-officedocument.wordprocessingml.document

When you try to attach a docx file to a smartsection item, you get an error message that says:
An error occured while uploading the File. mimetype must be shorter than 64 characters.


Questions
1. What needs to be done to get smartsection to accept a docx file as a file attachment?
2. What needs to be done to get xhelp to work correctly?
3. What needs to be done to get extcal to work correctly?

2
demian
Re: How to Handle Office 2007 File Attachments?
  • 2010/3/21 4:24

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


thanks for this info..

been trying to figure out how to attach office docs in news module

3
MadFish
Re: How to Handle Office 2007 File Attachments?
  • 2010/3/21 14:26

  • MadFish

  • Friend of XOOPS

  • Posts: 1056

  • Since: 2003/9/27


Thanks, kind of frustrating that we ended up with a new mimetype for this. One work around (not a good one) is to zip the offending 2007 file before you upload it.

4
tomodea
Re: How to Handle Office 2007 File Attachments?
  • 2010/3/24 10:28

  • tomodea

  • Just popping in

  • Posts: 47

  • Since: 2008/2/19


Yes, but the users would not be happy about having to unzip a file to read it.

5
tomodea
Re: How to Handle Office 2007 File Attachments?
  • 2010/3/28 5:25

  • tomodea

  • Just popping in

  • Posts: 47

  • Since: 2008/2/19


As a result of some good advice from Steve, we now have an answer on what to do to get smartsection to work.

In modules/smartsection/class/file.php, you'll find this section

function SmartsectionFile($id null

    
$this->db =& Database::getInstance(); 
    
$this->initVar("fileid"XOBJ_DTYPE_INT0false); 
    
$this->initVar("itemid"XOBJ_DTYPE_INTnulltrue); 
    
$this->initVar("name"XOBJ_DTYPE_TXTBOXnulltrue255); 
    
$this->initVar("description"XOBJ_DTYPE_TXTBOXnullfalse255); 
    
$this->initVar("filename"XOBJ_DTYPE_TXTBOXnulltrue255); 
    
$this->initVar("mimetype"XOBJ_DTYPE_TXTBOXnulltrue64); 
    
$this->initVar("uid"XOBJ_DTYPE_INT0false); 
    
$this->initVar("datesub"XOBJ_DTYPE_INTnullfalse); 
    
$this->initVar("status"XOBJ_DTYPE_INT1false); 
    
$this->initVar("notifypub"XOBJ_DTYPE_INT0false); 
    
$this->initVar("counter"XOBJ_DTYPE_INTnullfalse);


I changed this statement in class/file.php:

$this->initVar("mimetype"XOBJ_DTYPE_TXTBOXnulltrue64);


to this:

$this->initVar("mimetype"XOBJ_DTYPE_TXTBOXnulltrue255);


I also changed the SQL definition for the mimetype column in the smartsection_files table from varchar(64) to varchar(255).

Once I made those changes I was able to upload a docx file and then view it without any problems.

6
fnog
Re: How to Handle Office 2007 File Attachments?
  • 2010/6/23 9:10

  • fnog

  • Just popping in

  • Posts: 4

  • Since: 2002/8/2 2


Tom,

Just made the changes you mentioned.

Patched smartsection/class/file.php
/**
* $Id: file.php,v 1.14 2005/10/10 19:51:14 malanciault Exp $
* Module: SmartSection
* Author: The SmartFactory 
* Licence: GNU
*/


And changed sql table definition:

mysqldesc smartsection_files;
+-------------+-----------------+------+-----+---------+----------------+
Field       Type            Null Key | Default | Extra          |
+-------------+-----------------+------+-----+---------+----------------+
fileid      int(11)         | NO   PRI NULL    auto_increment 
itemid      int(11)         | NO   |     | 0       |                | 
name        varchar(255)    | NO   |     |         |                | 
description text            NO   |     |         |                | 
filename    varchar(255)    | NO   |     |         |                | 
mimetype    varchar(64)     | NO   |     |         |                | 
uid         int(6)          | YES  |     | 0       |                | 
datesub     int(11)         | NO   |     | 0       |                | 
status      int(1)          | NO   |     | -1      |                | 
notifypub   tinyint(1)      | NO   |     | 1       |                | 
counter     int(8unsigned NO   |     | 0       |                | 
+-------------+-----------------+------+-----+---------+----------------+
11 rows in set (0.00 sec)

mysqlALTER TABLE smartsection_files MODIFY COLUMN mimetype varchar(255NOT NULL;


mysqldesc smartsection_files;
+-------------+-----------------+------+-----+---------+----------------+
Field       Type            Null Key | Default | Extra          |
+-------------+-----------------+------+-----+---------+----------------+
fileid      int(11)         | NO   PRI NULL    auto_increment 
itemid      int(11)         | NO   |     | 0       |                | 
name        varchar(255)    | NO   |     |         |                | 
description text            NO   |     |         |                | 
filename    varchar(255)    | NO   |     |         |                | 
mimetype    varchar(255)    | NO   |     |         |                | 
uid         int(6)          | YES  |     | 0       |                | 
datesub     int(11)         | NO   |     | 0       |                | 
status      int(1)          | NO   |     | -1      |                | 
notifypub   tinyint(1)      | NO   |     | 1       |                | 
counter     int(8unsigned NO   |     | 0       |                | 
+-------------+-----------------+------+-----+---------+----------------+
11 rows in set (0.00 sec)


A minor "issue" that has been in my website for a long time, is now solved. (probably a newer version of smartsection already exists with this correction, nevertheless, this topic gets the solution for smartsection 2.1.

Once again, thank you Tom!

Login

Who's Online

328 user(s) are online (258 user(s) are browsing Support Forums)


Members: 0


Guests: 328


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits