/** * Handles attachments in a generalized manner in situations where * an email message must span several requests. Called from the * constructor when attachments are enabled. */ function _handleAttachments($userId) { import('file.TemporaryFileManager'); $temporaryFileManager = new TemporaryFileManager(); $this->attachmentsEnabled = true; $this->persistAttachments = array(); $deleteAttachment = Request::getUserVar('deleteAttachment'); if (Request::getUserVar('persistAttachments') != null) { foreach (Request::getUserVar('persistAttachments') as $fileId) { $temporaryFile = $temporaryFileManager->getFile($fileId, $userId); if (!empty($temporaryFile)) { if ($deleteAttachment != $temporaryFile->getId()) { $this->persistAttachments[] = $temporaryFile; } else { // This file is being deleted. $temporaryFileManager->deleteFile($temporaryFile->getId(), $userId); } } } } if (Request::getUserVar('addAttachment') && $temporaryFileManager->uploadedFileExists('newAttachment')) { $user =& Request::getUser(); $this->persistAttachments[] = $temporaryFileManager->handleUpload('newAttachment', $user->getId()); } }