24 require_once
'./Services/User/classes/class.ilObjUser.php';
25 require_once
"Services/Mail/classes/class.ilMailbox.php";
26 require_once
"Services/Mail/classes/class.ilFormatMail.php";
27 require_once
"Services/Mail/classes/class.ilAddressbook.php";
28 require_once
"Services/Mail/classes/class.ilAddressbookTableGUI.php";
55 $this->tabs_gui =& $ilTabs;
57 $this->ctrl->saveParameter($this,
"mobj_id");
67 $forward_class = $this->ctrl->getNextClass($this);
68 switch($forward_class)
71 include_once
'Services/Mail/classes/class.ilMailFormGUI.php';
76 case 'ilmailsearchcoursesgui':
77 include_once
'Services/Mail/classes/class.ilMailSearchCoursesGUI.php';
79 $this->tabs_gui->setSubTabActive(
'mail_my_courses');
81 $this->ctrl->setReturn($this,
"showAddressbook");
85 case 'ilmailsearchgroupsgui':
86 include_once
'Services/Mail/classes/class.ilMailSearchGroupsGUI.php';
88 $this->tabs_gui->setSubTabActive(
'mail_my_groups');
90 $this->ctrl->setReturn($this,
"showAddressbook");
94 case 'ilmailinglistsgui':
95 include_once
'Services/Mail/classes/class.ilMailingListsGUI.php';
97 $this->tabs_gui->setSubTabActive(
'mail_my_mailing_lists');
99 $this->ctrl->setReturn($this,
"showAddressbook");
104 $this->tabs_gui->setSubTabActive(
'mail_my_entries');
106 if (!(
$cmd = $this->ctrl->getCmd()))
108 $cmd =
"showAddressbook";
123 if (!strcmp(trim($_POST[
"login"]),
"") &&
124 !strcmp(trim($_POST[
"email"]),
""))
129 else if ($_POST[
"login"] !=
"" &&
135 else if ($_POST[
"email"] &&
142 if (($this->existingEntry = $this->abook->checkEntryByLogin(
ilUtil::stripSlashes($_POST[
"login"]))) > 0 &&
143 (($this->existingEntry != $addr_id && $addr_id > 0) || !$addr_id))
149 return $error ?
false :
true;
161 if (
$_GET[
"addr_id"])
198 if (!isset($_POST[
'addr_id']))
205 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
209 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"performDelete"));
210 $c_gui->setHeaderText($this->lng->txt(
"mail_sure_delete_entry"));
211 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showAddressbook");
212 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"performDelete");
215 foreach($_POST[
"addr_id"] as $addr_id)
217 $entry = $this->abook->getEntry($addr_id);
218 $c_gui->addItem(
"addr_id[]", $addr_id, $entry[
"login"] ? $entry[
"login"] : $entry[
"email"]);
221 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
222 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Mail");
223 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
237 if (is_array($_POST[
'addr_id']))
239 if ($this->abook->deleteEntries($_POST[
'addr_id']))
268 global $rbacsystem,
$lng, $ilUser;
270 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
271 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook_form.html",
"Services/Mail");
273 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
275 $form->setTitle(
$_GET[
'addr_id'] ? $lng->txt(
"mail_edit_entry") : $lng->txt(
"mail_new_entry"));
277 if (
$_GET[
'addr_id'])
279 $this->ctrl->setParameter($this,
'addr_id',
$_GET[
'addr_id']);
282 $entry = $this->abook->getEntry(
$_GET[
'addr_id']);
283 $form->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
285 $formItem =
new ilTextInputGUI($this->lng->txt(
"username"),
"login");
287 $form->addItem($formItem);
289 $formItem =
new ilTextInputGUI($this->lng->txt(
"firstname"),
"firstname");
291 $form->addItem($formItem);
293 $formItem =
new ilTextInputGUI($this->lng->txt(
"lastname"),
"lastname");
295 $form->addItem($formItem);
297 $formItem =
new ilTextInputGUI($this->lng->txt(
"email"),
"email");
299 $form->addItem($formItem);
301 $form->addCommandButton(
'saveEntry',$this->lng->txt(
'save'));
302 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
304 $this->tpl->setVariable(
'FORM', $form->getHTML());
315 if (!isset($_POST[
'addr_id']))
322 $mail_data = $this->umail->getSavedData();
323 if(!is_array($mail_data))
325 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
329 foreach ($_POST[
'addr_id'] as $addr_id)
331 $entry = $this->abook->getEntry($addr_id);
333 if(strlen($entry[
'login']) && !$this->umail->doesRecipientStillExists($entry[
'login'], $mail_data[
'rcp_to'])) {
334 $members[] = $entry[
'login'];
335 }
else if(strlen($entry[
'email']) && !$this->umail->doesRecipientStillExists($entry[
'email'], $mail_data[
'rcp_to'])) {
336 $members[] = $entry[
'email'];
342 $mail_data = $this->umail->appendSearchResult($members,
'to');
343 $this->umail->savePostData(
344 $mail_data[
'user_id'],
345 $mail_data[
'attachments'],
346 $mail_data[
'rcp_to'],
347 $mail_data[
'rcp_cc'],
348 $mail_data[
'rcp_bcc'],
349 $mail_data[
'm_type'],
350 $mail_data[
'm_email'],
351 $mail_data[
'm_subject'],
352 $mail_data[
'm_message'],
353 $mail_data[
'use_placeholders']
362 $_SESSION[
'addr_search'] = $_POST[
'search_qry'];
374 global $rbacsystem,
$lng, $ilUser;
376 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
377 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Mail");
379 $this->tpl->setVariable(
'ACTION', $this->ctrl->getFormAction($this,
"saveEntry"));
380 $this->tpl->setVariable(
"TXT_SEARCH_FOR",$this->lng->txt(
"search_for"));
381 $this->tpl->setVariable(
"BUTTON_SEARCH",$this->lng->txt(
"send"));
382 $this->tpl->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"reset"));
383 if (strlen(trim(
$_SESSION[
"addr_search"])) > 0)
388 $this->ctrl->setParameter($this,
"cmd",
"post");
390 $tbl->setTitle($lng->txt(
"mail_addr_entries"));
391 $tbl->setRowTemplate(
"tpl.mail_addressbook_row.html",
"Services/Mail");
393 $tbl->setDefaultOrderField(
'login');
396 $this->abook->setSearchQuery(
$_SESSION[
'addr_search']);
397 $entries = $this->abook->getEntries();
399 $tbl->addColumn(
'',
'check',
'10%');
400 $tbl->addColumn($this->lng->txt(
'login'),
'login',
'20%');
401 $tbl->addColumn($this->lng->txt(
'firstname'),
'firstname',
'20%');
402 $tbl->addColumn($this->lng->txt(
'lastname'),
'lastname',
'20%');
403 $tbl->addColumn($this->lng->txt(
'email'),
'email',
'20%');
404 $tbl->addColumn(
'',
'edit',
'10%');
408 $tbl->enable(
'select_all');
409 $tbl->setSelectAllCheckbox(
'addr_id');
412 foreach ($entries as $entry)
416 if ($entry[
"login"] !=
"")
418 $this->ctrl->setParameterByClass(
"ilmailformgui",
"type",
"address");
419 $this->ctrl->setParameterByClass(
"ilmailformgui",
"rcp", urlencode($entry[
"login"]));
420 $result[$counter][
'login'] =
"<a class=\"navigation\" href=\"" . $this->ctrl->getLinkTargetByClass(
"ilmailformgui") .
"\">" . $entry[
"login"] .
"</a>";
421 $this->ctrl->clearParametersByClass(
"ilmailformgui");
424 $result[$counter][
'firstname'] = $entry[
"firstname"];
425 $result[$counter][
'lastname'] = $entry[
"lastname"];
427 if ($rbacsystem->checkAccess(
"smtp_mail", $this->umail->getMailObjectReferenceId()))
429 $this->ctrl->setParameterByClass(
"ilmailformgui",
"type",
"address");
430 $this->ctrl->setParameterByClass(
"ilmailformgui",
"rcp", urlencode($entry[
"email"]));
431 $result[$counter][
'email'] =
"<a class=\"navigation\" href=\"" . $this->ctrl->getLinkTargetByClass(
"ilmailformgui") .
"\">" . $entry[
"email"] .
"</a>";
432 $this->ctrl->clearParametersByClass(
"ilmailformgui");
436 $result[$counter][
'email'] = $entry[
"email"];
439 $this->ctrl->setParameter($this,
'addr_id', $entry[
'addr_id']);
440 $result[$counter][
'edit_text'] = $this->lng->txt(
"edit");
441 $result[$counter][
'edit_url'] = $this->ctrl->getLinkTarget($this,
"showAddressForm");
446 $tbl->addMultiCommand(
'mailToUsers', $this->lng->txt(
'send_mail_to'));
447 $tbl->addMultiCommand(
'confirmDelete', $this->lng->txt(
'delete'));
451 $tbl->disable(
'header');
452 $tbl->disable(
'footer');
454 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
459 $tbl->addCommandButton(
'showAddressForm', $this->lng->txt(
'add'));
461 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
470 $this->tabs_gui->addSubTabTarget(
'mail_my_entries',
471 $this->ctrl->getLinkTarget($this));
472 $this->tabs_gui->addSubTabTarget(
'mail_my_mailing_lists',
473 $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
474 $this->tabs_gui->addSubTabTarget(
'mail_my_courses',
475 $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
476 $this->tabs_gui->addSubTabTarget(
'mail_my_groups',
477 $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));