Commit ec0fc4679948cae148e3f0084e6a20b12c159956

Authored by nbm
1 parent 1bf42a07

Use the storage manager to get a copy of the file to add as an

attachment in the email being sent.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4652 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 10 additions and 1 deletions
plugins/ktstandard/KTEmail.php
@@ -107,9 +107,18 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD @@ -107,9 +107,18 @@ function sendEmailDocument($sDestEmailAddress, $sDestUserName, $iDocumentID, $sD
107 $sTitle = "Document: " . $sDocumentName . " from " . $oSendingUser->getName(); 107 $sTitle = "Document: " . $sDocumentName . " from " . $oSendingUser->getName();
108 $oEmail = new Email(); 108 $oEmail = new Email();
109 $oDocument = Document::get($iDocumentID); 109 $oDocument = Document::get($iDocumentID);
110 - $sDocumentPath = $oDocument->getPath(); 110 +
  111 + // Request a standard file path so that it can be attached to the
  112 + // email
  113 + $oStorage =& KTStorageManagerUtil::getSingleton();
  114 + $sDocumentPath = $oStorage->temporaryFile($oDocument);
  115 +
111 $sDocumentFileName = $oDocument->getFileName(); 116 $sDocumentFileName = $oDocument->getFileName();
112 $res = $oEmail->sendAttachment($sDestEmailAddress, $sTitle, $sMessage, $sDocumentPath, $sDocumentFileName); 117 $res = $oEmail->sendAttachment($sDestEmailAddress, $sTitle, $sMessage, $sDocumentPath, $sDocumentFileName);
  118 +
  119 + // Tell the storage we don't need the temporary file anymore.
  120 + $oStorage->freeTemporaryFile($sDocumentPath);
  121 +
113 if (PEAR::isError($res)) { 122 if (PEAR::isError($res)) {
114 $default->log->error($res->getMessage()); 123 $default->log->error($res->getMessage());
115 $aEmailErrors[] = $res->getMessage(); 124 $aEmailErrors[] = $res->getMessage();