ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailAttachmentGUI Class Reference
+ Collaboration diagram for ilMailAttachmentGUI:

Public Member Functions

 __construct ()
 ilMailAttachmentGUI constructor. More...
 
 executeCommand ()
 
 saveAttachments ()
 
 cancelSaveAttachments ()
 
 deleteAttachments ()
 
 confirmDeleteAttachments ()
 
 uploadFile ()
 
 showAttachments ()
 

Protected Member Functions

 getToolbarForm ()
 

Private Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $user
 
 $toolbar
 
 $umail
 
 $mfile
 
 $request
 

Detailed Description

Author
Jens Conze
Version
$Id$

Definition at line 9 of file class.ilMailAttachmentGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailAttachmentGUI::__construct ( )

ilMailAttachmentGUI constructor.

Definition at line 38 of file class.ilMailAttachmentGUI.php.

39 {
40 global $DIC;
41
42 $this->tpl = $DIC->ui()->mainTemplate();
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $this->user = $DIC->user();
46 $this->toolbar = $DIC->toolbar();
47 $this->request = $DIC->http()->request();
48
49 $this->ctrl->saveParameter($this, 'mobj_id');
50
51 $this->umail = new ilFormatMail($DIC->user()->getId());
52 $this->mfile = new ilFileDataMail($DIC->user()->getId());
53 }
user()
Definition: user.php:4
Class ilFileDataMail.
Class UserMail this class handles user mails.
global $DIC
Definition: goto.php:24

References $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelSaveAttachments()

ilMailAttachmentGUI::cancelSaveAttachments ( )

Definition at line 98 of file class.ilMailAttachmentGUI.php.

98 : void
99 {
100 $this->ctrl->setParameter($this, 'type', 'attach');
101 $this->ctrl->returnToParent($this);
102 }

◆ confirmDeleteAttachments()

ilMailAttachmentGUI::confirmDeleteAttachments ( )

Definition at line 133 of file class.ilMailAttachmentGUI.php.

133 : void
134 {
135 $files = (array) ($this->request->getParsedBody()['filename'] ?? []);
136 if (0 === count($files)) {
137 ilUtil::sendInfo($this->lng->txt('mail_select_one_mail'));
138 $this->showAttachments();
139 return;
140 }
141
142 $decodedFiles = [];
143 foreach ($files as $value) {
144 $decodedFiles[] = urldecode($value);
145 }
146
147 $error = $this->mfile->unlinkFiles($decodedFiles);
148 if (strlen($error) > 0) {
149 ilUtil::sendFailure($this->lng->txt('mail_error_delete_file') . ' ' . $error);
150 } else {
151 $mailData = $this->umail->getSavedData();
152 if (is_array($mailData['attachments'])) {
153 $tmp = array();
154 for ($i = 0; $i < count($mailData['attachments']); $i++) {
155 if (!in_array($mailData['attachments'][$i], $decodedFiles)) {
156 $tmp[] = $mailData['attachments'][$i];
157 }
158 }
159 $this->umail->saveAttachments($tmp);
160 }
161
162 ilUtil::sendSuccess($this->lng->txt('mail_files_deleted'));
163 }
164
165 $this->showAttachments();
166 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$i
Definition: metadata.php:24

References $i, ilUtil\sendFailure(), ilUtil\sendInfo(), and showAttachments().

+ Here is the call graph for this function:

◆ deleteAttachments()

ilMailAttachmentGUI::deleteAttachments ( )

Definition at line 104 of file class.ilMailAttachmentGUI.php.

104 : void
105 {
106 $files = (array) ($this->request->getParsedBody()['filename'] ?? []);
107 if (0 === count($files)) {
108 ilUtil::sendFailure($this->lng->txt('mail_select_one_file'));
109 $this->showAttachments();
110 return;
111 }
112
113 $this->tpl->setTitle($this->lng->txt('mail'));
114
115 $confirmation = new ilConfirmationGUI();
116 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteAttachments'));
117 $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteAttachments');
118 $confirmation->setCancel($this->lng->txt('cancel'), 'showAttachments');
119 $confirmation->setHeaderText($this->lng->txt('mail_sure_delete_file'));
120
121 foreach ($files as $filename) {
122 $confirmation->addItem(
123 'filename[]',
126 );
127 }
128
129 $this->tpl->setContent($confirmation->getHtml());
130 $this->tpl->printToStdout();
131 }
$filename
Definition: buildRTE.php:89
Confirmation screen class.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $filename, ilUtil\sendFailure(), showAttachments(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailAttachmentGUI::executeCommand ( )

Definition at line 55 of file class.ilMailAttachmentGUI.php.

55 : void
56 {
57 $forward_class = $this->ctrl->getNextClass($this);
58 switch ($forward_class) {
59 default:
60 if (!($cmd = $this->ctrl->getCmd())) {
61 $cmd = 'showAttachments';
62 }
63
64 $this->$cmd();
65 break;
66 }
67 }

◆ getToolbarForm()

ilMailAttachmentGUI::getToolbarForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 171 of file class.ilMailAttachmentGUI.php.

172 {
173 $form = new ilPropertyFormGUI();
174
175 $attachment = new ilFileInputGUI($this->lng->txt('upload'), 'userfile');
176 $attachment->setRequired(true);
177 $attachment->setSize(20);
178 $form->addItem($attachment);
179
180 return $form;
181 }
This class represents a file property in a property form.
This class represents a property form user interface.

Referenced by uploadFile().

+ Here is the caller graph for this function:

◆ saveAttachments()

ilMailAttachmentGUI::saveAttachments ( )

Definition at line 69 of file class.ilMailAttachmentGUI.php.

69 : void
70 {
71 $files = [];
72
73 // Important: Do not check for uploaded files here, otherwise it is no more possible to remove files (please ignore bug reports like 10137)
74
75 $sizeOfSelectedFiles = 0;
76 $filesOfRequest = (array) ($this->request->getParsedBody()['filename'] ?? []);
77 foreach ($filesOfRequest as $file) {
78 if (file_exists($this->mfile->getMailPath() . '/' . basename($this->user->getId() . '_' . urldecode($file)))) {
79 $files[] = urldecode($file);
80 $sizeOfSelectedFiles += filesize($this->mfile->getMailPath() . '/' . basename($this->user->getId() . '_' . urldecode($file)));
81 }
82 }
83
84 if (
85 null !== $this->mfile->getAttachmentsTotalSizeLimit() &&
86 $files && $sizeOfSelectedFiles > $this->mfile->getAttachmentsTotalSizeLimit()
87 ) {
88 ilUtil::sendFailure($this->lng->txt('mail_max_size_attachments_total_error') . ' ' . ilUtil::formatSize($this->mfile->getAttachmentsTotalSizeLimit()));
89 $this->showAttachments();
90 return;
91 }
92
93 $this->umail->saveAttachments($files);
94
95 $this->ctrl->returnToParent($this);
96 }
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.

References ilUtil\formatSize(), ilUtil\sendFailure(), showAttachments(), and user().

+ Here is the call graph for this function:

◆ showAttachments()

ilMailAttachmentGUI::showAttachments ( )

Definition at line 202 of file class.ilMailAttachmentGUI.php.

202 : void
203 {
204 $this->tpl->setTitle($this->lng->txt('mail'));
205
206 $attachment = new ilFileInputGUI($this->lng->txt('upload'), 'userfile');
207 $attachment->setRequired(true);
208 $attachment->setSize(20);
209 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'uploadFile'), true);
210 $this->toolbar->addInputItem($attachment);
211 $this->toolbar->addFormButton($this->lng->txt('upload'), 'uploadFile');
212
213 $table = new ilMailAttachmentTableGUI($this, 'showAttachments');
214
215 $mailData = $this->umail->getSavedData();
216 $files = $this->mfile->getUserFilesData();
217 $data = array();
218 $counter = 0;
219 foreach ($files as $file) {
220 $checked = false;
221 if (is_array($mailData['attachments']) && in_array($file['name'], $mailData['attachments'])) {
222 $checked = true;
223 }
224
225 $data[$counter] = array(
226 'checked' => $checked,
227 'filename' => $file['name'],
228 'filesize' => (int) $file['size'],
229 'filecreatedate' => (int) $file['ctime']
230 );
231
232 ++$counter;
233 }
234 $table->setData($data);
235
236 $this->tpl->setContent($table->getHtml());
237 $this->tpl->printToStdout();
238 }
$data
Definition: storeScorm.php:23

References $data.

Referenced by confirmDeleteAttachments(), deleteAttachments(), saveAttachments(), and uploadFile().

+ Here is the caller graph for this function:

◆ uploadFile()

ilMailAttachmentGUI::uploadFile ( )

Definition at line 183 of file class.ilMailAttachmentGUI.php.

183 : void
184 {
185 if (strlen(trim($_FILES['userfile']['name']))) {
186 $form = $this->getToolbarForm();
187 if ($form->checkInput()) {
188 $this->mfile->storeUploadedFile($_FILES['userfile']);
189 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
190 } elseif ($form->getItemByPostVar('userfile')->getAlert() !== $this->lng->txt("form_msg_file_size_exceeds")) {
191 ilUtil::sendFailure($form->getItemByPostVar('userfile')->getAlert());
192 } else {
193 ilUtil::sendFailure($this->lng->txt('mail_maxsize_attachment_error') . ' ' . ilUtil::formatSize($this->mfile->getUploadLimit()));
194 }
195 } else {
196 ilUtil::sendFailure($this->lng->txt('mail_select_one_file'));
197 }
198
199 $this->showAttachments();
200 }

References ilUtil\formatSize(), getToolbarForm(), ilUtil\sendFailure(), and showAttachments().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMailAttachmentGUI::$ctrl
private

Definition at line 15 of file class.ilMailAttachmentGUI.php.

◆ $lng

ilMailAttachmentGUI::$lng
private

Definition at line 18 of file class.ilMailAttachmentGUI.php.

◆ $mfile

ilMailAttachmentGUI::$mfile
private

Definition at line 30 of file class.ilMailAttachmentGUI.php.

◆ $request

ilMailAttachmentGUI::$request
private

Definition at line 33 of file class.ilMailAttachmentGUI.php.

◆ $toolbar

ilMailAttachmentGUI::$toolbar
private

Definition at line 24 of file class.ilMailAttachmentGUI.php.

◆ $tpl

ilMailAttachmentGUI::$tpl
private

Definition at line 12 of file class.ilMailAttachmentGUI.php.

◆ $umail

ilMailAttachmentGUI::$umail
private

Definition at line 27 of file class.ilMailAttachmentGUI.php.

◆ $user

ilMailAttachmentGUI::$user
private

Definition at line 21 of file class.ilMailAttachmentGUI.php.


The documentation for this class was generated from the following file: