ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $cb = new ilCheckboxInputGUI($this->lng->txt('mail_use_pear_mail'), 'pear_mail_enable');
96 $cb->setInfo($this->lng->txt('mail_use_pear_mail_info'));
97 $cb->setValue(1);
98 $this->form->addItem($cb);
99
100 // prevent smtp mails
101 $cb = new ilCheckboxInputGUI($this->lng->txt('mail_prevent_smtp_globally'), 'prevent_smtp_globally');
102 $cb->setValue(1);
103 $this->form->addItem($cb);
104
105 $cron_mail = new ilSelectInputGUI($this->lng->txt('cron_mail_notification'), 'mail_notification');
106 $cron_options = array(
107 0 => $this->lng->txt('cron_mail_notification_never'),
108 1 => $this->lng->txt('cron_mail_notification_cron')
109 );
110
111 $cron_mail->setOptions($cron_options);
112 $cron_mail->setInfo($this->lng->txt('cron_mail_notification_desc'));
113 $this->form->addItem($cron_mail);
114
115 // section header
116 $sh = new ilFormSectionHeaderGUI();
117 $sh->setTitle($this->lng->txt('mail').' ('.$this->lng->txt('internal_system').')');
118 $this->form->addItem($sh);
119
120 // max attachment size
121 $ti = new ilNumberInputGUI($this->lng->txt('mail_maxsize_attach'), 'mail_maxsize_attach');
122 $ti->setSuffix($this->lng->txt('kb'));
123 $ti->setInfo($this->lng->txt('mail_max_size_attachments_total'));
124 $ti->setMaxLength(10);
125 $ti->setSize(10);
126 $this->form->addItem($ti);
127
128 // Course/Group member notification
129 $mn = new ilFormSectionHeaderGUI();
130 $mn->setTitle($this->lng->txt('mail_member_notification'));
131 $this->form->addItem($mn);
132
133 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
136 $this->form,
137 $this
138 );
139
140 $this->form->addCommandButton('save', $this->lng->txt('save'));
141 }
142
143 private function setDefaultValues()
144 {
145 $settings = $this->ilias->getAllSettings();
146 $this->form->setValuesByArray(array(
147 'mail_subject_prefix' => $settings['mail_subject_prefix'] ? $settings['mail_subject_prefix'] : '[ILIAS]',
148 'mail_incoming_mail' => (int)$settings['mail_incoming_mail'],
149 'mail_send_html' => (int)$settings['mail_send_html'],
150 'pear_mail_enable' => $settings['pear_mail_enable'] ? true : false,
151 'mail_external_sender_noreply' => $settings['mail_external_sender_noreply'],
152 'prevent_smtp_globally' => ($settings['prevent_smtp_globally'] == '1') ? true : false,
153 'mail_maxsize_attach' => $settings['mail_maxsize_attach'],
154 'mail_notification' => $settings['mail_notification'],
155 'mail_system_from_name' => $settings['mail_system_sender_name'],
156 'mail_system_return_path' => $settings['mail_system_return_path']
157 ));
158 }
159
160 public function saveObject()
161 {
162 global $rbacsystem, $ilSetting;
163
164 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
165 {
166 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
167 }
168
169 $this->initForm();
170 if($this->form->checkInput())
171 {
172 $this->ilias->setSetting('mail_send_html',$this->form->getInput('mail_send_html'));
173 $this->ilias->setSetting('mail_subject_prefix',$this->form->getInput('mail_subject_prefix'));
174 $this->ilias->setSetting('mail_incoming_mail', (int)$this->form->getInput('mail_incoming_mail'));
175 $this->ilias->setSetting('mail_maxsize_attach', $this->form->getInput('mail_maxsize_attach'));
176 $this->ilias->setSetting('pear_mail_enable', (int)$this->form->getInput('pear_mail_enable'));
177 $this->ilias->setSetting('mail_external_sender_noreply', $this->form->getInput('mail_external_sender_noreply'));
178 $this->ilias->setSetting('prevent_smtp_globally', (int)$this->form->getInput('prevent_smtp_globally'));
179 $this->ilias->setSetting('mail_notification', (int)$this->form->getInput('mail_notification'));
180 $ilSetting->set('mail_system_sender_name', $this->form->getInput('mail_system_from_name'));
181 $ilSetting->set('mail_system_return_path', $this->form->getInput('mail_system_return_path'));
182
183 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
184 }
185 $this->form->setValuesByPost();
186
187 $this->tpl->setContent($this->form->getHTML());
188 }
189
190 function importObject()
191 {
192 global $rbacsystem,$lng;
193
194 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
195 {
196 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
197 }
198 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_import.html", "Services/Mail");
199
200 // GET ALREADY CREATED UPLOADED XML FILE
201 $this->__initFileObject();
202 if($this->file_obj->findXMLFile())
203 {
204 $this->tpl->setVariable("TXT_IMPORTED_FILE",$lng->txt("checked_files"));
205 $this->tpl->setVariable("XML_FILE",basename($this->file_obj->getXMLFile()));
206
207 $this->tpl->setVariable("BTN_IMPORT",$this->lng->txt("import"));
208 }
209
210 $this->tpl->setVariable("FORMACTION",
211 $this->ctrl->getFormAction($this));
212 $this->tpl->setVariable("TXT_IMPORT_MAIL",$this->lng->txt("table_mail_import"));
213 $this->tpl->setVariable("TXT_IMPORT_FILE",$this->lng->txt("mail_import_file"));
214 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
215 $this->tpl->setVariable("BTN_UPLOAD",$this->lng->txt("upload"));
216
217 return true;
218 }
219
221 {
222 global $rbacsystem,$lng;
223
224 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
225 {
226 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
227 }
228 $this->__initFileObject();
229 $this->file_obj->findXMLFile();
230 $this->__initParserObject($this->file_obj->getXMLFile(),"import");
231 $this->parser_obj->startParsing();
232 $number = $this->parser_obj->getCountImported();
233 ilUtil::sendInfo($lng->txt("import_finished")." ".$number,true);
234
235 $this->ctrl->redirect($this, "import");
236 }
237
238
239
240 function uploadObject()
241 {
242 global $rbacsystem,$lng;
243
244 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
245 {
246 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
247 }
248
249 $this->__initFileObject();
250 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"])) // STEP 1 save file in ...import/mail
251 {
252 $this->message = $lng->txt("import_file_not_valid");
253 $this->file_obj->unlinkLast();
254 }
255 else if(!$this->file_obj->unzip())
256 {
257 $this->message = $lng->txt("cannot_unzip_file"); // STEP 2 unzip uplaoded file
258 $this->file_obj->unlinkLast();
259 }
260 else if(!$this->file_obj->findXMLFile()) // STEP 3 getXMLFile
261 {
262 $this->message = $lng->txt("cannot_find_xml");
263 $this->file_obj->unlinkLast();
264 }
265 else if(!$this->__initParserObject($this->file_obj->getXMLFile(),"check"))
266 {
267 $this->message = $lng->txt("error_parser"); // STEP 4 init sax parser
268 }
269 else if(!$this->parser_obj->startParsing())
270 {
271 $this->message = $lng->txt("users_not_imported").":<br/>"; // STEP 5 start parsing
272 $this->message .= $this->parser_obj->getNotAssignableUsers();
273 }
274 // FINALLY CHECK ERROR
275 if(!$this->message)
276 {
277 $this->message = $lng->txt("uploaded_and_checked");
278 }
279 ilUtil::sendInfo($this->message,true);
280
281 $this->ctrl->redirect($this, "import");
282 }
283
284 // PRIVATE
286 {
287 include_once "./Services/Mail/classes/class.ilFileDataImportMail.php";
288
289 $this->file_obj =& new ilFileDataImportMail();
290
291 return true;
292 }
293 function __initParserObject($a_xml,$a_mode)
294 {
295 include_once "Services/Mail/classes/class.ilMailImportParser.php";
296
297 if(!$a_xml)
298 {
299 return false;
300 }
301
302 $this->parser_obj =& new ilMailImportParser($a_xml,$a_mode);
303
304 return true;
305 }
306
307 function &executeCommand()
308 {
312 global $rbacsystem;
313
314 $next_class = $this->ctrl->getNextClass($this);
315 $cmd = $this->ctrl->getCmd();
316 $this->prepareOutput();
317
318 switch($next_class)
319 {
320 case 'ilpermissiongui':
321 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
322 $perm_gui =& new ilPermissionGUI($this);
323 $ret =& $this->ctrl->forwardCommand($perm_gui);
324 break;
325
326 case 'ilmailtemplategui':
327 if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
328 {
329 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
330 }
331
332 require_once 'Services/Mail/classes/class.ilMailTemplateGUI.php';
333 $this->ctrl->forwardCommand(new ilMailTemplateGUI());
334 break;
335
336 default:
337 if(!$cmd)
338 {
339 $cmd = "view";
340 }
341 $cmd .= "Object";
342 $this->$cmd();
343
344 break;
345 }
346 return true;
347 }
348
349 function getAdminTabs(&$tabs_gui)
350 {
351 $this->getTabs($tabs_gui);
352 }
353
357 public function getTabs(ilTabsGUI $tabs_gui)
358 {
362 global $rbacsystem;
363
364 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
365 {
366 $tabs_gui->addTarget("settings",
367 $this->ctrl->getLinkTarget($this, "view"), array("view", 'save', ""), "", "");
368 }
369
370 if($rbacsystem->checkAccess('write', $this->object->getRefId()))
371 {
372 $tabs_gui->addTarget('mail_templates', $this->ctrl->getLinkTargetByClass('ilmailtemplategui', 'showTemplates'), '', 'ilmailtemplategui');
373 }
374
375 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
376 {
377 $tabs_gui->addTarget("perm_settings",
378 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
379 }
380 }
381
385 public static function _goto($a_target)
386 {
387 global $ilAccess, $ilErr, $lng, $rbacsystem;
388
389 require_once 'Services/Mail/classes/class.ilMail.php';
390 $mail = new ilMail($_SESSION["AccountId"]);
391 if($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()))
392 {
393 ilUtil::redirect("ilias.php?baseClass=ilMailGUI");
394 exit;
395 }
396 else
397 {
398 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
399 {
400 $_GET["cmd"] = "frameset";
401 $_GET["target"] = "";
402 $_GET["ref_id"] = ROOT_FOLDER_ID;
403 $_GET["baseClass"] = "ilRepositoryGUI";
404 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
406 include("ilias.php");
407 exit;
408 }
409 }
410 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
411 }
412
413} // END class.ilObjMailGUI
414?>
$_GET["client_id"]
$_SESSION["AccountId"]
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.
Class Mail 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
static _goto($a_target)
goto target group
__initParserObject($a_xml, $a_mode)
getAdminTabs(&$tabs_gui)
administration tabs show only permissions and trash folder
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput()
prepare output
getTabs(&$tabs_gui)
get tabs abstract method.
& 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.
Tabs GUI.
addTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
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.
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options