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/Contact/classes/class.ilAddressbook.php";
28 require_once
"Services/Contact/classes/class.ilAddressbookTableGUI.php";
56 $this->tabs_gui =& $ilTabs;
58 $this->ctrl->saveParameter($this,
"mobj_id");
69 $forward_class = $this->ctrl->getNextClass($this);
72 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
74 switch($forward_class)
77 include_once
'Services/Mail/classes/class.ilMailFormGUI.php';
81 case 'ilmailsearchcoursesgui':
82 include_once
'Services/Contact/classes/class.ilMailSearchCoursesGUI.php';
84 $this->tabs_gui->setSubTabActive(
'mail_my_courses');
86 $this->ctrl->setReturn($this,
"showAddressbook");
90 case 'ilmailsearchgroupsgui':
91 include_once
'Services/Contact/classes/class.ilMailSearchGroupsGUI.php';
93 $this->tabs_gui->setSubTabActive(
'mail_my_groups');
95 $this->ctrl->setReturn($this,
"showAddressbook");
99 case 'ilmailinglistsgui':
100 include_once
'Services/Contact/classes/class.ilMailingListsGUI.php';
102 $this->tabs_gui->setSubTabActive(
'mail_my_mailing_lists');
104 $this->ctrl->setReturn($this,
"showAddressbook");
109 $this->tabs_gui->setSubTabActive(
'mail_my_entries');
111 if (!(
$cmd = $this->ctrl->getCmd()))
113 $cmd =
"showAddressbook";
128 if (!strcmp(trim(
$_POST[
"login"]),
"") &&
129 !strcmp(trim(
$_POST[
"email"]),
""))
134 else if (
$_POST[
"login"] !=
"" &&
140 else if (
$_POST[
"email"] &&
148 (($this->existingEntry != $addr_id && $addr_id > 0) || !$addr_id))
154 return $error ?
false :
true;
166 if (
$_GET[
"addr_id"])
203 $addr_ids = ((int)
$_GET[
'addr_id']) ? array((
int)
$_GET[
'addr_id']) :
$_POST[
'addr_id'];
212 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
216 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"performDelete"));
217 $c_gui->setHeaderText($this->lng->txt(
"mail_sure_delete_entry"));
218 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showAddressbook");
219 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"performDelete");
222 foreach($addr_ids as $addr_id)
224 $entry = $this->abook->getEntry($addr_id);
225 $c_gui->addItem(
"addr_id[]", $addr_id, $entry[
"login"] ? $entry[
"login"] : $entry[
"email"]);
228 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
229 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Contact");
230 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
244 if (is_array(
$_POST[
'addr_id']))
246 if ($this->abook->deleteEntries(
$_POST[
'addr_id']))
275 global $rbacsystem,
$lng, $ilUser;
277 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
278 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook_form.html",
"Services/Contact");
280 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
282 $form->setTitle(
$_GET[
'addr_id'] ? $lng->txt(
"mail_edit_entry") : $lng->txt(
"mail_new_entry"));
284 if (
$_GET[
'addr_id'])
286 $this->ctrl->setParameter($this,
'addr_id',
$_GET[
'addr_id']);
289 $entry = $this->abook->getEntry(
$_GET[
'addr_id']);
290 $form->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
292 $formItem =
new ilTextInputGUI($this->lng->txt(
"username"),
"login");
294 $form->addItem($formItem);
296 $formItem =
new ilTextInputGUI($this->lng->txt(
"firstname"),
"firstname");
298 $form->addItem($formItem);
300 $formItem =
new ilTextInputGUI($this->lng->txt(
"lastname"),
"lastname");
302 $form->addItem($formItem);
304 $formItem =
new ilTextInputGUI($this->lng->txt(
"email"),
"email");
306 $form->addItem($formItem);
308 $form->addCommandButton(
'saveEntry',$this->lng->txt(
'save'));
309 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
311 $this->tpl->setVariable(
'FORM', $form->getHTML());
322 if (
$_GET[
'addr_id'] && is_array(
$_GET[
'addr_id']))
323 $addr_ids =
$_GET[
'addr_id'];
324 else if ((
int)
$_GET[
'addr_id'])
325 $addr_ids = array((
int)$_GET[
'addr_id']);
326 else if (
$_POST[
'addr_id'] && is_array(
$_POST[
'addr_id']))
327 $addr_ids =
$_POST[
'addr_id'];
328 else if ((
int)
$_POST[
'addr_id'])
329 $addr_ids = array((
int)$_POST[
'addr_id']);
340 $mail_data = $this->umail->getSavedData();
341 if(!is_array($mail_data))
343 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
347 foreach ($addr_ids as $addr_id)
349 $entry = $this->abook->getEntry($addr_id);
351 if(strlen($entry[
'login']) && !$this->umail->doesRecipientStillExists($entry[
'login'], $mail_data[
'rcp_to'])) {
352 $members[] = $entry[
'login'];
353 }
else if(strlen($entry[
'email']) && !$this->umail->doesRecipientStillExists($entry[
'email'], $mail_data[
'rcp_to'])) {
354 $members[] = $entry[
'email'];
360 $mail_data = $this->umail->appendSearchResult($members,
'to');
361 $this->umail->savePostData(
362 $mail_data[
'user_id'],
363 $mail_data[
'attachments'],
364 $mail_data[
'rcp_to'],
365 $mail_data[
'rcp_cc'],
366 $mail_data[
'rcp_bcc'],
367 $mail_data[
'm_type'],
368 $mail_data[
'm_email'],
369 $mail_data[
'm_subject'],
370 $mail_data[
'm_message'],
371 $mail_data[
'use_placeholders']
392 global $rbacsystem,
$lng, $ilUser,
$ilCtrl, $ilias;
394 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
395 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Contact");
398 include_once
"Services/Mail/classes/class.ilMail.php";
400 $mailing_allowed = $rbacsystem->checkAccess(
'mail_visible',$mail->getMailObjectReferenceId());
403 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
404 include_once
'Services/YUI/classes/class.ilYuiUtil.php';
407 $searchform->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
410 $dsSchema = array(
"resultsList" =>
'response.results',
411 "fields" => array(
'login',
'firstname',
'lastname'));
412 $dsFormatCallback =
'formatAutoCompleteResults';
413 $dsDataLink = $ilCtrl->getLinkTarget($this,
'lookupAddressbookAsync',
'',
true);
415 $inp =
new ilTextInputGUI($this->lng->txt(
'search_for'),
'search_qry');
417 $inp->setDataSourceSchema($dsSchema);
418 $inp->setDataSourceResultFormat($dsFormatCallback);
420 $searchform->addItem($inp);
421 $searchform->addCommandButton(
'search', $this->lng->txt(
"send"));
422 $this->tpl->setVariable(
'SEARCHFORM', $searchform->getHtml());
425 $this->tpl->setVariable(
'ACTION', $this->ctrl->getFormAction($this,
"saveEntry"));
426 $this->tpl->setVariable(
"TXT_SEARCH_FOR",$this->lng->txt(
"search_for"));
427 $this->tpl->setVariable(
"BUTTON_SEARCH",$this->lng->txt(
"send"));
429 if (strlen(trim(
$_SESSION[
"addr_search"])) > 0)
435 $tbl->setTitle($lng->txt(
"mail_addr_entries"));
436 $tbl->setRowTemplate(
"tpl.mail_addressbook_row.html",
"Services/Contact");
438 $tbl->setDefaultOrderField(
'login');
441 $this->abook->setSearchQuery(
$_SESSION[
'addr_search']);
442 $entries = $this->abook->getEntries();
444 $tbl->addColumn(
'',
'check',
'10%',
true);
445 $tbl->addColumn($this->lng->txt(
'login'),
'login',
'20%');
446 $tbl->addColumn($this->lng->txt(
'firstname'),
'firstname',
'20%');
447 $tbl->addColumn($this->lng->txt(
'lastname'),
'lastname',
'20%');
448 $tbl->addColumn($this->lng->txt(
'email'),
'email',
'20%');
449 $tbl->addColumn($this->lng->txt(
'actions'),
'',
'10%');
451 include_once(
"./Services/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
455 $tbl->enable(
'select_all');
456 $tbl->setSelectAllCheckbox(
'addr_id');
459 $chat_active = $ilias->getSetting(
"chat_active");
462 foreach ($entries as $entry)
466 $this->ctrl->setParameter($this,
'addr_id', $entry[
'addr_id']);
468 if ($entry[
"login"] !=
"")
470 if ($mailing_allowed)
472 $result[$counter][
'login_linked_link'] = $this->ctrl->getLinkTarget($this,
'mailToUsers');
473 $result[$counter][
'login_linked_login'] = $entry[
"login"];
476 $result[$counter][
'login_unliked'] = $entry[
"login"];
479 $result[$counter][
'firstname'] = $entry[
"firstname"];
480 $result[$counter][
'lastname'] = $entry[
"lastname"];
482 if (
$_GET[
"baseClass"] ==
"ilMailGUI" && $rbacsystem->checkAccess(
"smtp_mail", $this->umail->getMailObjectReferenceId()))
484 $result[$counter][
'email_linked_email'] = $entry[
"email"];
485 $result[$counter][
'email_linked_link'] = $this->ctrl->getLinkTarget($this,
"mailToUsers");
488 $result[$counter][
'email_unlinked'] = $entry[
"email"] ? $entry[
"email"] :
" ";
491 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
492 $current_selection_list->setId(
"act_".$counter);
494 $current_selection_list->addItem($this->lng->txt(
"edit"),
'', $this->ctrl->getLinkTarget($this,
"showAddressForm"));
496 if ($mailing_allowed)
497 $current_selection_list->addItem($this->lng->txt(
"send_mail_to"),
'', $this->ctrl->getLinkTarget($this,
"mailToUsers"));
499 $current_selection_list->addItem($this->lng->txt(
"delete"),
'', $this->ctrl->getLinkTarget($this,
"confirmDelete"));
502 $current_selection_list->addItem($this->lng->txt(
"invite_to_chat"),
'', $this->ctrl->getLinkTarget($this,
"inviteToChat"));
504 $this->ctrl->clearParameters($this);
506 $result[$counter][
'COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
510 if ($mailing_allowed)
511 $tbl->addMultiCommand(
'mailToUsers', $this->lng->txt(
'send_mail_to'));
513 $tbl->addMultiCommand(
'confirmDelete', $this->lng->txt(
'delete'));
516 $tbl->addMultiCommand(
'inviteToChat', $this->lng->txt(
'invite_to_chat'));
520 $tbl->disable(
'header');
521 $tbl->disable(
'footer');
523 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
528 $tbl->addCommandButton(
'showAddressForm', $this->lng->txt(
'add'));
530 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
547 $addr_ids = ((int)
$_GET[
'addr_id']) ? array((
int)
$_GET[
'addr_id']) :
$_POST[
'addr_id'];
562 foreach($addr_ids as $id)
564 $entry = $this->abook->getEntry($id);
567 if (!$entry[
'login'])
574 if (count($no_login))
576 $message .= $lng->txt(
'chat_users_without_login') .
':<br>';
578 foreach($no_login as $e)
580 $list .=
'<li>'.$this->abook->entryToString($e).
'</li>';
591 include_once
'Modules/Chat/classes/class.ilChatRoom.php';
592 include_once
'Modules/Chat/classes/class.ilObjChat.php';
593 include_once
'Modules/Chat/classes/class.ilObjChatGUI.php';
594 include_once
'Modules/Chat/classes/class.ilChatBlockedUsers.php';
599 foreach($chat_rooms as $room)
607 foreach($rooms as $k => $v) {
608 $titel[$k] = strtolower($v[
'title']);
610 array_multisort($titel, SORT_STRING, $rooms);
613 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
616 $form->setTitle($lng->txt(
"mail_invite_users_to_chat"));
619 foreach($rooms as $room)
625 $options[
$ref_id] = $room[
'title'];
626 foreach($room[
'subrooms'] as $subroom)
629 $options[
$ref_id.
','.$subroom[
'room_id']] =
'+ '.$subroom[
'title'];
633 $form->addItem($psel);
635 $phidden->setValue(join(
',', $addr_ids));
636 $form->addItem($phidden);
637 $form->addCommandButton(
'submitInvitation',$this->lng->txt(
'submit'));
638 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
639 $form->setFormAction($ilCtrl->getFormAction($this));
642 $tpl->setTitle($lng->txt(
'mail_invite_users_to_chat'));
643 $tpl->setContent($form->getHtml());
653 global $ilObjDataCache, $ilUser,
$ilCtrl, $rbacsystem,
$lng, $ilias;
665 $_POST[
'addr_id'] = explode(
',', $_POST[
"addr_ids"]);
671 $ids = explode(
',',
$_POST[
"addr_ids"]);
675 $chat_ids = explode(
',',
$_POST[
'room_id']);
676 $chat_id = (int)$chat_ids[0];
679 if (count($chat_ids) > 0)
681 $room_id = (int)$chat_ids[1];
687 include_once
'Modules/Chat/classes/class.ilChatRoom.php';
688 include_once
'Modules/Chat/classes/class.ilObjChat.php';
689 include_once
'Modules/Chat/classes/class.ilObjChatGUI.php';
690 include_once
'Modules/Chat/classes/class.ilChatBlockedUsers.php';
692 $obj_id = $ilObjDataCache->lookupObjId($chat_id);
696 $room->setRoomId((
int)$room_id);
699 $no_access = array();
705 $valid_users = array();
709 $entry = $this->abook->getEntry($id);
714 $user_id = $ilUser->getUserIdByLogin($entry[
'login']);
716 !$rbacsystem->checkAccessOfUser($user_id,
'read', $chat_id)
724 $valid_users[] = $user_id;
735 if (count($no_access) || count($no_login))
739 if (count($no_access))
741 $message .= $lng->txt(
'chat_users_without_permission') .
':<br>';
743 foreach($no_access as $e)
745 $list .=
'<li>'.$this->abook->entryToString($e).
'</li>';
753 if (count($no_login))
755 $message .= $lng->txt(
'chat_users_without_login') .
':<br>';
757 foreach($no_login as $e)
759 $list .=
'<li>'.$this->abook->entryToString($e).
'</li>';
773 foreach($valid_users as $id)
776 $chatObject->sendMessageForRoom($id, $room);
778 $link =
'<p><a target="chatframe" href="ilias.php?baseClass=ilChatPresentationGUI&ref_id='.$chat_id.
'&room_id='.$room_id.
'">'.$lng->txt(
'goto_invitation_chat').
'</a></p>';
779 ilUtil::sendInfo($lng->txt(
'chat_users_have_been_invited') . $userlist .$link,
true);
780 $link = $ilCtrl->getLinkTarget($this,
'showAddressbook');
786 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
787 include_once
'Services/Contact/classes/class.ilMailAddressbook.php';
789 $search =
"%" . $_REQUEST[
"query"] .
"%";
791 $result->response =
new stdClass();
792 $result->response->results = array();
801 $result = $mailAdrBookObj->getAddressbookAsync($search);
809 $this->tabs_gui->addSubTabTarget(
'mail_my_entries', $this->ctrl->getLinkTarget($this));
810 $this->tabs_gui->addSubTabTarget(
'mail_my_mailing_lists', $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
811 $this->tabs_gui->addSubTabTarget(
'mail_my_courses', $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
812 $this->tabs_gui->addSubTabTarget(
'mail_my_groups', $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));