1 <?php
2 /* --------------------------------------------------------------
3 AttachmentsHandlerInterface.inc.php 2015-07-21 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 /**
13 * Class AttachmentsHandlerInterface
14 *
15 * @category System
16 * @package Email
17 * @subpackage Interfaces
18 */
19 interface AttachmentsHandlerInterface
20 {
21 /**
22 * Upload an attachment to "uploads/tmp" directory.
23 *
24 * This method takes the uploaded file information and places it in the "uploads/tmp" directory
25 * as a temporary place, until the "uploadEmailCollection" moves it to the final destination.
26 *
27 * @param EmailAttachmentInterface $attachment Contains the file information (path is required).
28 *
29 * @return EmailAttachment Returns an EmailAttachment instance with the new attachment path.
30 */
31 public function uploadAttachment(EmailAttachmentInterface $attachment);
32
33
34 /**
35 * Removes a single email attachment.
36 *
37 * @param EmailAttachmentInterface $attachment E-Mail attachment.
38 */
39 public function deleteAttachment(EmailAttachmentInterface $attachment);
40
41
42 /**
43 * Process attachments for each email in collection.
44 *
45 * Important! Use this method after you save the emails into the database. The reason is that
46 * this property separates each attachment file by its email ID, a value that is only accessible
47 * after the email is already saved.
48 *
49 * @param EmailCollectionInterface $collection Passed by reference, contains emails of which the
50 * attachments must be processed.
51 *
52 * @deprecated Since v2.3.3.0 this method is marked as deprecated and will be removed from the class.
53 */
54 public function uploadEmailCollection(EmailCollectionInterface $collection);
55
56
57 /**
58 * Delete attachments for each email in collection.
59 *
60 * Every email has its own attachments directory. When emails are deleted we need
61 * to remove their respective attachments.
62 *
63 * @param EmailCollectionInterface $collection Contains email records to be deleted.
64 *
65 * @deprecated Since v2.3.3.0 this method is marked as deprecated and will be removed from the class.
66 */
67 public function deleteEmailCollection(EmailCollectionInterface $collection);
68
69
70 /**
71 * Get attachments directory file size in bytes.
72 *
73 * @return int Returns the size in bytes.
74 */
75 public function getAttachmentsSize();
76
77
78 /**
79 * Delete old attachments prior to removal date.
80 *
81 * This method will remove all the files and directories that are prior to the given date.
82 * It will return removal information so that user can see how much disc spaces was set free.
83 *
84 * @param DateTime $removalDate From this date and before the attachment files will be removed.
85 *
86 * @return array Returns an array which contains the "count" and "size" values or the operation.
87 */
88 public function deleteOldAttachments(DateTime $removalDate);
89
90
91 /**
92 * Process email attachments.
93 *
94 * This method will move all the email attachments to the "uploads/attachments" directory
95 * and store them there for future reference and history navigation purposes. The email needs
96 * to be saved first because the email ID will be used to distinguish the emails.
97 *
98 * @param EmailInterface $email Passed by reference, contains the email data.
99 */
100 public function backupEmailAttachments(EmailInterface &$email);
101
102
103 /**
104 * Deletes email attachments.
105 *
106 * This method will remove all the email attachments from the server.
107 *
108 * @param EmailInterface $email Contains the email information.
109 */
110 public function deleteEmailAttachments(EmailInterface $email);
111
112
113 /**
114 * Removes all files within the "uploads/tmp" directory.
115 *
116 * There might be cases where old unused files are left within the "tmp" directory and they
117 * need to be deleted. This function will remove all these files.
118 */
119 public function emptyTempDirectory();
120 }