ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 // noreply address
75 $ti = new ilTextInputGUI($this->lng->txt('mail_external_sender_noreply'), 'mail_external_sender_noreply');
76 $ti->setInfo($this->lng->txt('info_mail_external_sender_noreply'));
77 $ti->setMaxLength(255);
78 $this->form->addItem($ti);
79
80 $system_sender_name = new ilTextInputGUI($this->lng->txt('mail_system_sender_name'), 'mail_system_sender_name');
81 $system_sender_name->setInfo($this->lng->txt('mail_system_sender_name_info'));
82 $system_sender_name->setMaxLength(255);
83 $this->form->addItem($system_sender_name);
84
85 $cb = new ilCheckboxInputGUI($this->lng->txt('mail_use_pear_mail'), 'pear_mail_enable');
86 $cb->setInfo($this->lng->txt('mail_use_pear_mail_info'));
87 $cb->setValue(1);
88 $this->form->addItem($cb);
89
90 // prevent smtp mails
91 $cb = new ilCheckboxInputGUI($this->lng->txt('mail_prevent_smtp_globally'), 'prevent_smtp_globally');
92 $cb->setValue(1);
93 $this->form->addItem($cb);
94
95 $cron_mail = new ilSelectInputGUI($this->lng->txt('cron_mail_notification'), 'mail_notification');
96 $cron_options = array(
97 0 => $this->lng->txt('cron_mail_notification_never'),
98 1 => $this->lng->txt('cron_mail_notification_cron')
99 );
100
101 $cron_mail->setOptions($cron_options);
102 $cron_mail->setInfo($this->lng->txt('cron_mail_notification_desc'));
103 $this->form->addItem($cron_mail);
104
105 // section header
106 $sh = new ilFormSectionHeaderGUI();
107 $sh->setTitle($this->lng->txt('mail').' ('.$this->lng->txt('internal_system').')');
108 $this->form->addItem($sh);
109
110 // max attachment size
111 $ti = new ilNumberInputGUI($this->lng->txt('mail_maxsize_attach'), 'mail_maxsize_attach');
112 $ti->setSuffix($this->lng->txt('kb'));
113 $ti->setInfo($this->lng->txt('mail_max_size_attachments_total'));
114 $ti->setMaxLength(10);
115 $ti->setSize(10);
116 $this->form->addItem($ti);
117
118 // Course/Group member notification
119 $mn = new ilFormSectionHeaderGUI();
120 $mn->setTitle($this->lng->txt('mail_member_notification'));
121 $this->form->addItem($mn);
122
123 include_once "Services/Administration/classes/class.ilAdministrationSettingsFormHandler.php";
126 $this->form,
127 $this
128 );
129
130 $this->form->addCommandButton('save', $this->lng->txt('save'));
131 }
132
133 private function setDefaultValues()
134 {
135 $settings = $this->ilias->getAllSettings();
136 $this->form->setValuesByArray(array(
137 'mail_subject_prefix' => $settings['mail_subject_prefix'] ? $settings['mail_subject_prefix'] : '[ILIAS]',
138 'mail_incoming_mail' => (int)$settings['mail_incoming_mail'],
139 'pear_mail_enable' => $settings['pear_mail_enable'] ? true : false,
140 'mail_external_sender_noreply' => $settings['mail_external_sender_noreply'],
141 'prevent_smtp_globally' => ($settings['prevent_smtp_globally'] == '1') ? true : false,
142 'mail_maxsize_attach' => $settings['mail_maxsize_attach'],
143 'mail_notification' => $settings['mail_notification'],
144 'mail_system_sender_name' => $settings['mail_system_sender_name']
145 ));
146 }
147
148 public function saveObject()
149 {
150 global $ilAccess,$ilSetting;
151
152 if(!$ilAccess->checkAccess('write,read', '', $this->object->getRefId()))
153 {
154 $this->ilias->raiseError($this->lng->txt('msg_no_perm_write'), $this->ilias->error_obj->WARNING);
155 }
156
157 $this->initForm();
158 if($this->form->checkInput())
159 {
160 $this->ilias->setSetting('mail_subject_prefix',$this->form->getInput('mail_subject_prefix'));
161 $this->ilias->setSetting('mail_incoming_mail', (int)$this->form->getInput('mail_incoming_mail'));
162 $this->ilias->setSetting('mail_maxsize_attach', $this->form->getInput('mail_maxsize_attach'));
163 $this->ilias->setSetting('pear_mail_enable', (int)$this->form->getInput('pear_mail_enable'));
164 $this->ilias->setSetting('mail_external_sender_noreply', $this->form->getInput('mail_external_sender_noreply'));
165 $this->ilias->setSetting('prevent_smtp_globally', (int)$this->form->getInput('prevent_smtp_globally'));
166 $this->ilias->setSetting('mail_notification', (int)$this->form->getInput('mail_notification'));
167 $ilSetting->set('mail_system_sender_name', $this->form->getInput('mail_system_sender_name'));
168
169 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
170 }
171 $this->form->setValuesByPost();
172
173 $this->tpl->setContent($this->form->getHTML());
174 }
175
176 function importObject()
177 {
178 global $rbacsystem,$lng;
179
180 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
181 {
182 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
183 }
184 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_import.html", "Services/Mail");
185
186 // GET ALREADY CREATED UPLOADED XML FILE
187 $this->__initFileObject();
188 if($this->file_obj->findXMLFile())
189 {
190 $this->tpl->setVariable("TXT_IMPORTED_FILE",$lng->txt("checked_files"));
191 $this->tpl->setVariable("XML_FILE",basename($this->file_obj->getXMLFile()));
192
193 $this->tpl->setVariable("BTN_IMPORT",$this->lng->txt("import"));
194 }
195
196 $this->tpl->setVariable("FORMACTION",
197 $this->ctrl->getFormAction($this));
198 $this->tpl->setVariable("TXT_IMPORT_MAIL",$this->lng->txt("table_mail_import"));
199 $this->tpl->setVariable("TXT_IMPORT_FILE",$this->lng->txt("mail_import_file"));
200 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
201 $this->tpl->setVariable("BTN_UPLOAD",$this->lng->txt("upload"));
202
203 return true;
204 }
205
207 {
208 global $rbacsystem,$lng;
209
210 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
211 {
212 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
213 }
214 $this->__initFileObject();
215 $this->file_obj->findXMLFile();
216 $this->__initParserObject($this->file_obj->getXMLFile(),"import");
217 $this->parser_obj->startParsing();
218 $number = $this->parser_obj->getCountImported();
219 ilUtil::sendInfo($lng->txt("import_finished")." ".$number,true);
220
221 $this->ctrl->redirect($this, "import");
222 }
223
224
225
226 function uploadObject()
227 {
228 global $rbacsystem,$lng;
229
230 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
231 {
232 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
233 }
234
235 $this->__initFileObject();
236 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"])) // STEP 1 save file in ...import/mail
237 {
238 $this->message = $lng->txt("import_file_not_valid");
239 $this->file_obj->unlinkLast();
240 }
241 else if(!$this->file_obj->unzip())
242 {
243 $this->message = $lng->txt("cannot_unzip_file"); // STEP 2 unzip uplaoded file
244 $this->file_obj->unlinkLast();
245 }
246 else if(!$this->file_obj->findXMLFile()) // STEP 3 getXMLFile
247 {
248 $this->message = $lng->txt("cannot_find_xml");
249 $this->file_obj->unlinkLast();
250 }
251 else if(!$this->__initParserObject($this->file_obj->getXMLFile(),"check"))
252 {
253 $this->message = $lng->txt("error_parser"); // STEP 4 init sax parser
254 }
255 else if(!$this->parser_obj->startParsing())
256 {
257 $this->message = $lng->txt("users_not_imported").":<br/>"; // STEP 5 start parsing
258 $this->message .= $this->parser_obj->getNotAssignableUsers();
259 }
260 // FINALLY CHECK ERROR
261 if(!$this->message)
262 {
263 $this->message = $lng->txt("uploaded_and_checked");
264 }
265 ilUtil::sendInfo($this->message,true);
266
267 $this->ctrl->redirect($this, "import");
268 }
269
270 // PRIVATE
272 {
273 include_once "./Services/Mail/classes/class.ilFileDataImportMail.php";
274
275 $this->file_obj =& new ilFileDataImportMail();
276
277 return true;
278 }
279 function __initParserObject($a_xml,$a_mode)
280 {
281 include_once "Services/Mail/classes/class.ilMailImportParser.php";
282
283 if(!$a_xml)
284 {
285 return false;
286 }
287
288 $this->parser_obj =& new ilMailImportParser($a_xml,$a_mode);
289
290 return true;
291 }
292
293 function &executeCommand()
294 {
295 $next_class = $this->ctrl->getNextClass($this);
296 $cmd = $this->ctrl->getCmd();
297 $this->prepareOutput();
298
299 switch($next_class)
300 {
301 case 'ilpermissiongui':
302 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
303 $perm_gui =& new ilPermissionGUI($this);
304 $ret =& $this->ctrl->forwardCommand($perm_gui);
305 break;
306
307 default:
308 if(!$cmd)
309 {
310 $cmd = "view";
311 }
312 $cmd .= "Object";
313 $this->$cmd();
314
315 break;
316 }
317 return true;
318 }
319
320 function getAdminTabs(&$tabs_gui)
321 {
322 $this->getTabs($tabs_gui);
323 }
324
330 function getTabs(&$tabs_gui)
331 {
332 global $rbacsystem;
333
334 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
335 {
336 $tabs_gui->addTarget("settings",
337 $this->ctrl->getLinkTarget($this, "view"), array("view", 'save', ""), "", "");
338 }
339
340 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
341 {
342 $tabs_gui->addTarget("perm_settings",
343 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
344 }
345 }
346
350 public static function _goto($a_target)
351 {
352 global $ilAccess, $ilErr, $lng, $rbacsystem;
353
354 require_once 'Services/Mail/classes/class.ilMail.php';
355 $mail = new ilMail($_SESSION["AccountId"]);
356 if($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId()))
357 {
358 ilUtil::redirect("ilias.php?baseClass=ilMailGUI");
359 exit;
360 }
361 else
362 {
363 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
364 {
365 $_GET["cmd"] = "frameset";
366 $_GET["target"] = "";
367 $_GET["ref_id"] = ROOT_FOLDER_ID;
368 $_GET["baseClass"] = "ilRepositoryGUI";
369 ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
371 include("ilias.php");
372 exit;
373 }
374 }
375 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
376 }
377
378} // END class.ilObjMailGUI
379?>
$_GET["client_id"]
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 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
getTabs(&$tabs_gui)
get tabs @access public
static _goto($a_target)
goto target group
& executeCommand()
execute command
__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
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.
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
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