ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailAttachmentGUI Class Reference
+ Collaboration diagram for ilMailAttachmentGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 saveAttachments ()
 
 cancelSaveAttachments ()
 
 deleteAttachments ()
 
 confirmDeleteAttachments ()
 
 uploadFile ()
 
 showAttachments ()
 

Protected Member Functions

 getToolbarForm ()
 

Protected Attributes

 $user
 
 $toolbar
 

Private Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $umail
 
 $mfile
 

Detailed Description

Author
Jens Conze
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilMailAttachmentGUI::__construct ( )

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

50 {
51 global $DIC;
52
53 $this->tpl = $DIC->ui()->mainTemplate();
54 $this->ctrl = $DIC->ctrl();
55 $this->lng = $DIC->language();
56 $this->user = $DIC->user();
57 $this->toolbar = $DIC->toolbar();
58
59 $this->ctrl->saveParameter($this, 'mobj_id');
60
61 $this->umail = new ilFormatMail($DIC->user()->getId());
62 $this->mfile = new ilFileDataMail($DIC->user()->getId());
63 }
user()
Definition: user.php:4
Class ilFileDataMail.
Class UserMail this class handles user mails.
global $DIC
Definition: saml.php:7

References $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelSaveAttachments()

ilMailAttachmentGUI::cancelSaveAttachments ( )

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

111 {
112 $this->ctrl->setParameter($this, 'type', 'attach');
113 $this->ctrl->returnToParent($this);
114 }

◆ confirmDeleteAttachments()

ilMailAttachmentGUI::confirmDeleteAttachments ( )

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

142 {
143 if (!isset($_POST['filename']) || !is_array($_POST['filename']) || !$_POST['filename']) {
144 ilUtil::sendInfo($this->lng->txt('mail_select_one_mail'));
145 $this->showAttachments();
146 return true;
147 }
148
149 $files = array();
150 foreach ($_POST['filename'] as $value) {
151 $files[] = urldecode($value);
152 }
153
154 if (strlen(($error = $this->mfile->unlinkFiles($files)))) {
155 ilUtil::sendFailure($this->lng->txt('mail_error_delete_file') . ' ' . $error);
156 } else {
157 $mailData = $this->umail->getSavedData();
158 if (is_array($mailData['attachments'])) {
159 $tmp = array();
160 for ($i = 0; $i < count($mailData['attachments']); $i++) {
161 if (!in_array($mailData['attachments'][$i], $files)) {
162 $tmp[] = $mailData['attachments'][$i];
163 }
164 }
165 $this->umail->saveAttachments($tmp);
166 }
167
168 ilUtil::sendSuccess($this->lng->txt('mail_files_deleted'));
169 }
170
171 $this->showAttachments();
172 }
$_POST["username"]
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: disco.tpl.php:19
$files
Definition: metarefresh.php:49

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

+ Here is the call graph for this function:

◆ deleteAttachments()

ilMailAttachmentGUI::deleteAttachments ( )

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

117 {
118 if (!isset($_POST['filename']) || !is_array($_POST['filename']) || !$_POST['filename']) {
119 ilUtil::sendFailure($this->lng->txt('mail_select_one_file'));
120 $this->showAttachments();
121 return;
122 }
123
124 $this->tpl->setTitle($this->lng->txt('mail'));
125
126 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
127 $confirmation = new ilConfirmationGUI();
128 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmDeleteAttachments'));
129 $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmDeleteAttachments');
130 $confirmation->setCancel($this->lng->txt('cancel'), 'showAttachments');
131 $confirmation->setHeaderText($this->lng->txt('mail_sure_delete_file'));
132
133 foreach ($_POST['filename'] as $filename) {
134 $confirmation->addItem('filename[]', ilUtil::stripSlashes($filename), ilUtil::stripSlashes(urldecode($filename)));
135 }
136
137 $this->tpl->setContent($confirmation->getHtml());
138 $this->tpl->show();
139 }
$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 $_POST, $filename, ilUtil\sendFailure(), showAttachments(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ executeCommand()

ilMailAttachmentGUI::executeCommand ( )

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

66 {
67 $forward_class = $this->ctrl->getNextClass($this);
68 switch ($forward_class) {
69 default:
70 if (!($cmd = $this->ctrl->getCmd())) {
71 $cmd = 'showAttachments';
72 }
73
74 $this->$cmd();
75 break;
76 }
77 return true;
78 }

◆ getToolbarForm()

ilMailAttachmentGUI::getToolbarForm ( )
protected
Returns
ilPropertyFormGUI

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

178 {
179 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
180 $form = new ilPropertyFormGUI();
181 $attachment = new ilFileInputGUI($this->lng->txt('upload'), 'userfile');
182 $attachment->setRequired(true);
183 $attachment->setSize(20);
184 $form->addItem($attachment);
185 return $form;
186 }
This class represents a file property in a property form.
This class represents a property form user interface.
if(isset($_POST['submit'])) $form

References $form.

Referenced by uploadFile().

+ Here is the caller graph for this function:

◆ saveAttachments()

ilMailAttachmentGUI::saveAttachments ( )

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

81 {
82 $files = array();
83
84 // Important: Do not check for uploaded files here, otherwise it is no more possible to remove files (please ignore bug reports like 10137)
85
86 $size_of_selected_files = 0;
87 if (is_array($_POST['filename']) && count($_POST['filename']) > 0) {
88 foreach ($_POST['filename'] as $file) {
89 if (file_exists($this->mfile->getMailPath() . '/' . basename($this->user->getId() . '_' . urldecode($file)))) {
90 $files[] = urldecode($file);
91 $size_of_selected_files += filesize($this->mfile->getMailPath() . '/' . basename($this->user->getId() . '_' . urldecode($file)));
92 }
93 }
94 }
95
96 if (
97 null !== $this->mfile->getAttachmentsTotalSizeLimit() &&
98 $files && $size_of_selected_files > $this->mfile->getAttachmentsTotalSizeLimit()
99 ) {
100 ilUtil::sendFailure($this->lng->txt('mail_max_size_attachments_total_error') . ' ' . ilUtil::formatSize($this->mfile->getAttachmentsTotalSizeLimit()));
101 $this->showAttachments();
102 return;
103 }
104
105 $this->umail->saveAttachments($files);
106
107 $this->ctrl->returnToParent($this);
108 }
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.

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

+ Here is the call graph for this function:

◆ showAttachments()

ilMailAttachmentGUI::showAttachments ( )

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

210 {
211 $this->tpl->setTitle($this->lng->txt('mail'));
212
213 require_once 'Services/Form/classes/class.ilFileInputGUI.php';
214 $attachment = new ilFileInputGUI($this->lng->txt('upload'), 'userfile');
215 $attachment->setRequired(true);
216 $attachment->setSize(20);
217 $this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'uploadFile'), true);
218 $this->toolbar->addInputItem($attachment);
219 $this->toolbar->addFormButton($this->lng->txt('upload'), 'uploadFile');
220
221 require_once 'Services/Mail/classes/class.ilMailAttachmentTableGUI.php';
222 $table = new ilMailAttachmentTableGUI($this, 'showAttachments');
223
224 $mailData = $this->umail->getSavedData();
225 $files = $this->mfile->getUserFilesData();
226 $data = array();
227 $counter = 0;
228 foreach ($files as $file) {
229 $checked = false;
230 if (is_array($mailData['attachments']) && in_array($file['name'], $mailData['attachments'])) {
231 $checked = true;
232 }
233
234 $data[$counter] = array(
235 'checked' => $checked,
236 'filename' => $file['name'],
237 'filesize' => (int) $file['size'],
238 'filecreatedate' => (int) $file['ctime']
239 );
240
241 ++$counter;
242 }
243 $table->setData($data);
244
245 $this->tpl->setContent($table->getHtml());
246 $this->tpl->show();
247 }
if(empty($password)) $table
Definition: pwgen.php:24
$data
Definition: bench.php:6

References $data, $files, and $table.

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

+ Here is the caller graph for this function:

◆ uploadFile()

ilMailAttachmentGUI::uploadFile ( )

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

189 {
190 if (strlen(trim($_FILES['userfile']['name']))) {
191 $form = $this->getToolbarForm();
192 if ($form->checkInput()) {
193 $this->mfile->storeUploadedFile($_FILES['userfile']);
194 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
195 } else {
196 if ($form->getItemByPostVar('userfile')->getAlert() != $this->lng->txt("form_msg_file_size_exceeds")) {
197 ilUtil::sendFailure($form->getItemByPostVar('userfile')->getAlert());
198 } else {
199 ilUtil::sendFailure($this->lng->txt('mail_maxsize_attachment_error') . ' ' . ilUtil::formatSize($this->mfile->getUploadLimit()));
200 }
201 }
202 } else {
203 ilUtil::sendFailure($this->lng->txt('mail_select_one_file'));
204 }
205
206 $this->showAttachments();
207 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilMailAttachmentGUI::$ctrl
private

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

◆ $lng

ilMailAttachmentGUI::$lng
private

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

◆ $mfile

ilMailAttachmentGUI::$mfile
private

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

◆ $toolbar

ilMailAttachmentGUI::$toolbar
protected

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

◆ $tpl

ilMailAttachmentGUI::$tpl
private

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

◆ $umail

ilMailAttachmentGUI::$umail
private

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

◆ $user

ilMailAttachmentGUI::$user
protected

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


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