ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjMailGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Object/classes/class.ilObjectGUI.php";
5
18{
23 public function __construct($a_data,$a_id,$a_call_by_reference)
24 {
25 $this->type = 'mail';
26 parent::__construct($a_data,$a_id,$a_call_by_reference, false);
27
28 $this->lng->loadLanguageModule('mail');
29 }
30
31 public function viewObject()
32 {
33 global $ilAccess;
34
35 if(!$ilAccess->checkAccess('write,read', '', $this->object->getRefId()))
36 {
37 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
38 }
39
40 $this->initForm();
41 $this->setDefaultValues();
42 $this->tpl->setContent($this->form->getHTML());
43 }
44
45 private function initForm()
46 {
47 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
48 $this->form = new ilPropertyFormGUI();
49
50 $this->form->setFormAction($this->ctrl->getFormAction($this, 'save'));
51 $this->form->setTitle($this->lng->txt('general_settings'));
52
53 // Subject prefix
54 $pre = new ilTextInputGUI($this->lng->txt('mail_subject_prefix'),'mail_subject_prefix');
55 $pre->setSize(12);
56 $pre->setMaxLength(32);
57 $pre->setInfo($this->lng->txt('mail_subject_prefix_info'));
58 $this->form->addItem($pre);
59
60 // incoming type
61 include_once 'Services/Mail/classes/class.ilMailOptions.php';
62 $options = array(
63 IL_MAIL_LOCAL => $this->lng->txt('mail_incoming_local'),
64 IL_MAIL_EMAIL => $this->lng->txt('mail_incoming_smtp'),
65 IL_MAIL_BOTH => $this->lng->txt('mail_incoming_both')
66 );
67 $si = new ilSelectInputGUI($this->lng->txt('mail_incoming'), 'mail_incoming_mail');
68 $si->setOptions($options);
69 $this->ctrl->setParameterByClass('ilobjuserfoldergui', 'ref_id', USER_FOLDER_ID);
70 $si->setInfo(sprintf($this->lng->txt('mail_settings_incoming_type_see_also'), $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'settings')));
71 $this->ctrl->clearParametersByClass('ilobjuserfoldergui');
72 $this->form->addItem($si);
73
74 $send_html = new ilCheckboxInputGUI($this->lng->txt('mail_send_html'), 'mail_send_html');
75 $send_html->setInfo($this->lng->txt('mail_send_html_info'));
76 $send_html->setValue(1);
77 $this->form->addItem($send_html);
78
79 // noreply address
80 $ti = new ilTextInputGUI($this->lng->txt('mail_external_sender_noreply'), 'mail_external_sender_noreply');
81 $ti->setInfo($this->lng->txt('info_mail_external_sender_noreply'));
82 $ti->setMaxLength(255);
83 $this->form->addItem($ti);
84
85 $system_from_name = new ilTextInputGUI($this->lng->txt('mail_system_from_name'), 'mail_system_from_name');
86 $system_from_name->setInfo($this->lng->txt('mail_system_from_name_info'));
87 $system_from_name->setMaxLength(255);
88 $this->form->addItem($system_from_name);
89
90 $system_return_path = new ilTextInputGUI($this->lng->txt('mail_system_return_path'), 'mail_system_return_path');
91 $system_return_path->setInfo($this->lng->txt('mail_system_return_path_info'));
92 $system_return_path->setMaxLength(255);
93 $this->form->addItem($system_return_path);
94
95 // prevent smtp mails
96 $cb = new ilCheckboxInputGUI($this->lng->txt('mail_prevent_smtp_globally'), 'prevent_smtp_globally');
97 $cb->setValue(1);
98 $this->form->addItem($cb);
99
100 $cron_mail = new ilSelectInputGUI($this->lng->txt('cron_mail_notification'), 'mail_notification');
101 $cron_options = array(
102 0 => $this->lng->txt('cron_mail_notification_never'),
103 1 => $this->lng->txt('cron_mail_notification_cron')
104 );
105
106 $cron_mail->setOptions($cron_options);
107 $cron_mail->setInfo($this->lng->txt('cron_mail_notification_desc'));
108 $this->form->addItem($cron_mail);
109
110 // section header
111 $sh = new ilFormSectionHeaderGUI();
112 $sh->setTitle($this->lng->txt('mail').' ('.$this->lng->txt('internal_system').')');
113 $this->form->addItem($sh);
114
115 // max attachment size
116 $ti = new ilNumberInputGUI($this->lng->txt('mail_maxsize_attach'), 'mail_maxsize_attach');
117 $ti->setSuffix($this->lng->txt('kb'));
118 $ti->setInfo($this->lng->txt('mail_max_size_attachments_total'));
119 $ti->setMaxLength(10);
120 $ti->setSize(10);
121 $this->form->addItem($ti);
122
123 // Course/Group member notification
124 $mn = new ilFormSectionHeaderGUI();
125 $mn->setTitle($this->lng->txt('mail_member_notification'));
126 $this->form->addItem($mn);
127
128 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
131 $this->form,
132 $this
133 );
134
135 $this->form->addCommandButton('save', $this->lng->txt('save'));
136 }
137
138 private function setDefaultValues()
139 {
140 $settings = $this->ilias->getAllSettings();
141 $this->form->setValuesByArray(array(
142 'mail_subject_prefix' => $settings['mail_subject_prefix'] ? $settings['mail_subject_prefix'] : '[ILIAS]',
143 'mail_incoming_mail' => (int)$settings['mail_incoming_mail'],
144 'mail_send_html' => (int)$settings['mail_send_html'],
145 'mail_external_sender_noreply' => $settings['mail_external_sender_noreply'],
146 'prevent_smtp_globally' => ($settings['prevent_smtp_globally'] == '1') ? true : false,
147 'mail_maxsize_attach' => $settings['mail_maxsize_attach'],
148 'mail_notification' => $settings['mail_notification'],
149 'mail_system_from_name' => $settings['mail_system_sender_name'],
150 'mail_system_return_path' => $settings['mail_system_return_path']
151 ));
152 }
153
154 public function saveObject()
155 {
156 global $rbacsystem, $ilSetting;
157
158 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
159 {
160 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
161 }
162
163 $this->initForm();
164 if($this->form->checkInput())
165 {
166 $this->ilias->setSetting('mail_send_html',$this->form->getInput('mail_send_html'));
167 $this->ilias->setSetting('mail_subject_prefix',$this->form->getInput('mail_subject_prefix'));
168 $this->ilias->setSetting('mail_incoming_mail', (int)$this->form->getInput('mail_incoming_mail'));
169 $this->ilias->setSetting('mail_maxsize_attach', $this->form->getInput('mail_maxsize_attach'));
170 $this->ilias->setSetting('mail_external_sender_noreply', $this->form->getInput('mail_external_sender_noreply'));
171 $this->ilias->setSetting('prevent_smtp_globally', (int)$this->form->getInput('prevent_smtp_globally'));
172 $this->ilias->setSetting('mail_notification', (int)$this->form->getInput('mail_notification'));
173 $ilSetting->set('mail_system_sender_name', $this->form->getInput('mail_system_from_name'));
174 $ilSetting->set('mail_system_return_path', $this->form->getInput('mail_system_return_path'));
175
176 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
177 }
178 $this->form->setValuesByPost();
179
180 $this->tpl->setContent($this->form->getHTML());
181 }
182
183 function importObject()
184 {
185 global $rbacsystem,$lng;
186
187 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
188 {
189 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
190 }
191 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_import.html", "Services/Mail");
192
193 // GET ALREADY CREATED UPLOADED XML FILE
194 $this->__initFileObject();
195 if($this->file_obj->findXMLFile())
196 {
197 $this->tpl->setVariable("TXT_IMPORTED_FILE",$lng->txt("checked_files"));
198 $this->tpl->setVariable("XML_FILE",basename($this->file_obj->getXMLFile()));
199
200 $this->tpl->setVariable("BTN_IMPORT",$this->lng->txt("import"));
201 }
202
203 $this->tpl->setVariable("FORMACTION",
204 $this->ctrl->getFormAction($this));
205 $this->tpl->setVariable("TXT_IMPORT_MAIL",$this->lng->txt("table_mail_import"));
206 $this->tpl->setVariable("TXT_IMPORT_FILE",$this->lng->txt("mail_import_file"));
207 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
208 $this->tpl->setVariable("BTN_UPLOAD",$this->lng->txt("upload"));
209
210 return true;
211 }
212
214 {
215 global $rbacsystem,$lng;
216
217 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
218 {
219 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
220 }
221 $this->__initFileObject();
222 $this->file_obj->findXMLFile();
223 $this->__initParserObject($this->file_obj->getXMLFile(),"import");
224 $this->parser_obj->startParsing();
225 $number = $this->parser_obj->getCountImported();
226 ilUtil::sendInfo($lng->txt("import_finished")." ".$number,true);
227
228 $this->ctrl->redirect($this, "import");
229 }
230
231
232
233 function uploadObject()
234 {
235 global $rbacsystem,$lng;
236
237 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
238 {
239 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
240 }
241
242 $this->__initFileObject();
243 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"])) // STEP 1 save file in ...import/mail
244 {
245 $this->message = $lng->txt("import_file_not_valid");
246 $this->file_obj->unlinkLast();
247 }
248 else if(!$this->file_obj->unzip())
249 {
250 $this->message = $lng->txt("cannot_unzip_file"); // STEP 2 unzip uplaoded file
251 $this->file_obj->unlinkLast();
252 }
253 else if(!$this->file_obj->findXMLFile()) // STEP 3 getXMLFile
254 {
255 $this->message = $lng->txt("cannot_find_xml");
256 $this->file_obj->unlinkLast();
257 }
258 else if(!$this->__initParserObject($this->file_obj->getXMLFile(),"check"))
259 {
260 $this->message = $lng->txt("error_parser"); // STEP 4 init sax parser
261 }
262 else if(!$this->parser_obj->startParsing())
263 {
264 $this->message = $lng->txt("users_not_imported").":<br/>"; // STEP 5 start parsing
265 $this->message .= $this->parser_obj->getNotAssignableUsers();
266 }
267 // FINALLY CHECK ERROR
268 if(!$this->message)
269 {
270 $this->message = $lng->txt("uploaded_and_checked");
271 }
272 ilUtil::sendInfo($this->message,true);
273
274 $this->ctrl->redirect($this, "import");
275 }
276
277 // PRIVATE
279 {
280 include_once "./Services/Mail/classes/class.ilFileDataImportMail.php";
281
282 $this->file_obj = new ilFileDataImportMail();
283
284 return true;
285 }
286 function __initParserObject($a_xml,$a_mode)
287 {
288 include_once "Services/Mail/classes/class.ilMailImportParser.php";
289
290 if(!$a_xml)
291 {
292 return false;
293 }
294
295 $this->parser_obj = new ilMailImportParser($a_xml,$a_mode);
296
297 return true;
298 }
299
300 function executeCommand()
301 {
305 global $rbacsystem;
306
307 $next_class = $this->ctrl->getNextClass($this);
308 $cmd = $this->ctrl->getCmd();
309 $this->prepareOutput();
310
311 switch($next_class)
312 {
313 case 'ilpermissiongui':
314 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
315 $perm_gui = new ilPermissionGUI($this);
316 $ret =& $this->ctrl->forwardCommand($perm_gui);
317 break;
318
319 case 'ilmailtemplategui':
320 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
321 {
322 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
323 }
324
325 require_once 'Services/Mail/classes/class.ilMailTemplateGUI.php';
326 $this->ctrl->forwardCommand(new ilMailTemplateGUI());
327 break;
328
329 default:
330 if(!$cmd)
331 {
332 $cmd = "view";
333 }
334 $cmd .= "Object";
335 $this->$cmd();
336
337 break;
338 }
339 return true;
340 }
341
342 function getAdminTabs()
343 {
344 $this->getTabs();
345 }
346
350 public function getTabs()
351 {
355 global $rbacsystem;
356
357 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
358 {
359 $this->tabs_gui->addTarget("settings",
360 $this->ctrl->getLinkTarget($this, "view"), array("view", 'save', ""), "", "");
361 }
362
363 if($rbacsystem->checkAccess('write', $this->object->getRefId()))
364 {
365 $this->tabs_gui->addTarget('mail_templates', $this->ctrl->getLinkTargetByClass('ilmailtemplategui', 'showTemplates'), '', 'ilmailtemplategui');
366 }
367
368 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
369 {
370 $this->tabs_gui->addTarget("perm_settings",
371 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
372 }
373 }
374
378 public static function _goto($a_target)
379 {
380 global $ilAccess, $ilErr, $lng, $rbacsystem;
381
382 require_once 'Services/Mail/classes/class.ilMail.php';
383 $mail = new ilMail($GLOBALS['DIC']['ilUser']->getId());
384 if($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()))
385 {
386 ilUtil::redirect("ilias.php?baseClass=ilMailGUI");
387 exit;
388 }
389 else
390 {
391 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
392 {
393 $_GET["cmd"] = "frameset";
394 $_GET["target"] = "";
395 $_GET["ref_id"] = ROOT_FOLDER_ID;
396 $_GET["baseClass"] = "ilRepositoryGUI";
397 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
399 include("ilias.php");
400 exit;
401 }
402 }
403 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
404 }
405
406} // END class.ilObjMailGUI
407?>
sprintf('%.4f', $callTime)
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_MAIL_BOTH
const IL_MAIL_LOCAL
const IL_MAIL_EMAIL
const USER_FOLDER_ID
Class ilObjUserFolder.
static addFieldsToForm($a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a checkbox property in a property form.
This class handles all operations on files for the exercise object.
This class represents a section header in a property form.
Class ilMailTemplateGUI.
This class handles base functions for mail handling.
This class represents a number property in a property form.
Class ilObjMailGUI for admin panel.
viewObject()
list childs of current object
__construct($a_data, $a_id, $a_call_by_reference)
Constructor @access public.
saveObject()
save object
getAdminTabs()
administration tabs show only permissions and trash folder
static _goto($a_target)
goto target group
__initParserObject($a_xml, $a_mode)
Class ilObjectGUI Basic methods of all Output classes.
getTabs()
get tabs abstract method.
prepareOutput($a_show_subobjects=true)
prepare output
executeCommand()
execute command
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options