5 require_once
'./Services/User/classes/class.ilObjUser.php';
6 require_once
"Services/Mail/classes/class.ilMailbox.php";
7 require_once
"Services/Mail/classes/class.ilFormatMail.php";
8 require_once
"Services/Contact/classes/class.ilAddressbook.php";
9 require_once
"Services/Contact/classes/class.ilAddressbookTableGUI.php";
37 $this->tabs_gui =& $ilTabs;
39 $this->ctrl->saveParameter($this,
"mobj_id");
50 $forward_class = $this->ctrl->getNextClass($this);
53 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
55 switch($forward_class)
58 include_once
'Services/Mail/classes/class.ilMailFormGUI.php';
62 case 'ilmailsearchcoursesgui':
63 include_once
'Services/Contact/classes/class.ilMailSearchCoursesGUI.php';
67 $this->ctrl->setReturn($this,
"showAddressbook");
71 case 'ilmailsearchgroupsgui':
72 include_once
'Services/Contact/classes/class.ilMailSearchGroupsGUI.php';
76 $this->ctrl->setReturn($this,
"showAddressbook");
80 case 'ilmailinglistsgui':
81 include_once
'Services/Contact/classes/class.ilMailingListsGUI.php';
85 $this->ctrl->setReturn($this,
"showAddressbook");
92 if (!(
$cmd = $this->ctrl->getCmd()))
94 $cmd =
"showAddressbook";
109 if (!strcmp(trim(
$_POST[
"login"]),
"") &&
110 !strcmp(trim(
$_POST[
"email"]),
""))
115 else if (
$_POST[
"login"] !=
"" &&
121 else if (
$_POST[
"email"] &&
129 (($this->existingEntry != $addr_id && $addr_id > 0) || !$addr_id))
135 return $error ?
false :
true;
141 public function saveEntry()
149 $autoupdate = (int)
$_POST[
'auto_update'];
150 if(!$ilSetting->get(
'cron_upd_adrbook', 0))
186 $this->showAddressbook();
190 $this->showAddressForm();
203 $addr_ids = ((int)
$_GET[
'addr_id']) ? array((
int)
$_GET[
'addr_id']) :
$_POST[
'addr_id'];
208 $this->showAddressbook();
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->setTitle($this->lng->txt(
"mail_addressbook"));
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']))
260 $this->showAddressbook();
270 $this->showAddressbook();
273 public function showAddressForm()
281 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
282 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook_form.html",
"Services/Contact");
284 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
286 $form->setTitle(
$_GET[
'addr_id'] ? $lng->txt(
"mail_edit_entry") : $lng->txt(
"mail_new_entry"));
288 if (
$_GET[
'addr_id'])
290 $this->ctrl->setParameter($this,
'addr_id',
$_GET[
'addr_id']);
293 $entry = $this->abook->getEntry(
$_GET[
'addr_id']);
294 $form->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
296 $login =
new ilTextInputGUI($this->lng->txt(
"username"),
"login");
298 $login->setDataSource($this->ctrl->getLinkTarget($this,
'lookupUsersAsync',
'',
true));
299 $form->addItem($login);
301 if($ilSetting->get(
'cron_upd_adrbook', 0))
305 $formItem->setInfo($this->lng->txt(
'cron_update_addressbook'));
307 $login->addSubItem($formItem);
310 $formItem =
new ilTextInputGUI($this->lng->txt(
"firstname"),
"firstname");
312 $form->addItem($formItem);
314 $formItem =
new ilTextInputGUI($this->lng->txt(
"lastname"),
"lastname");
316 $form->addItem($formItem);
318 $formItem =
new ilTextInputGUI($this->lng->txt(
"email"),
"email");
320 $formItem->setDataSource($this->ctrl->getLinkTarget($this,
'lookupEmailsAsync',
'',
true));
321 $form->addItem($formItem);
323 $form->addCommandButton(
'saveEntry',$this->lng->txt(
'save'));
324 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
326 $this->tpl->setVariable(
'FORM', $form->getHTML());
337 if (
$_GET[
'addr_id'] && is_array(
$_GET[
'addr_id']))
338 $addr_ids =
$_GET[
'addr_id'];
339 else if ((
int)
$_GET[
'addr_id'])
340 $addr_ids = array((
int)$_GET[
'addr_id']);
341 else if (
$_POST[
'addr_id'] && is_array(
$_POST[
'addr_id']))
342 $addr_ids =
$_POST[
'addr_id'];
343 else if ((
int)
$_POST[
'addr_id'])
344 $addr_ids = array((
int)$_POST[
'addr_id']);
351 $this->showAddressbook();
355 $mail_data = $this->umail->getSavedData();
356 if(!is_array($mail_data))
358 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
362 foreach ($addr_ids as $addr_id)
364 $entry = $this->abook->getEntry($addr_id);
366 if(strlen($entry[
'login']) && !$this->umail->doesRecipientStillExists($entry[
'login'], $mail_data[
'rcp_to'])) {
367 $members[] = $entry[
'login'];
368 }
else if(strlen($entry[
'email']) && !$this->umail->doesRecipientStillExists($entry[
'email'], $mail_data[
'rcp_to'])) {
369 $members[] = $entry[
'email'];
375 $mail_data = $this->umail->appendSearchResult($members,
'to');
376 $this->umail->savePostData(
377 $mail_data[
'user_id'],
378 $mail_data[
'attachments'],
379 $mail_data[
'rcp_to'],
380 $mail_data[
'rcp_cc'],
381 $mail_data[
'rcp_bcc'],
382 $mail_data[
'm_type'],
383 $mail_data[
'm_email'],
384 $mail_data[
'm_subject'],
385 $mail_data[
'm_message'],
386 $mail_data[
'use_placeholders']
397 $this->showAddressbook();
405 public function showAddressbook()
415 $this->tpl->setTitle($this->lng->txt(
"mail_addressbook"));
416 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Contact");
419 include_once
"Services/Mail/classes/class.ilMail.php";
421 $mailing_allowed = $rbacsystem->checkAccess(
'internal_mail',$mail->getMailObjectReferenceId());
423 $chatSettings =
new ilSetting(
'chatroom');
424 $chat_active = $chatSettings->get(
"chat_enabled",
false);
427 $smtp_mailing_allowed = $rbacsystem->checkAccess(
"smtp_mail", $this->umail->getMailObjectReferenceId());
430 $tbl->setSmtpMailingAllowed($smtp_mailing_allowed);
432 $this->abook->setSearchQuery($tbl->getFilterQuery());
433 $entries = $this->abook->getEntries();
435 $tbl->setData($entries);
437 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
450 public function inviteToChat()
460 $lng->loadLanguageModule(
'chatroom');
462 $addr_ids = ((int)
$_GET[
'addr_id']) ? array((
int)
$_GET[
'addr_id']) :
$_POST[
'addr_id'];
467 $ilCtrl->redirect($this,
'showAddressbook');
472 foreach($addr_ids as $id)
474 $entry = $this->abook->getEntry($id);
483 $message = $lng->txt(
'chat_users_without_login') .
':<br>';
486 foreach($no_login as $e)
488 $list .=
'<li>' . $this->abook->entryToString($e) .
'</li>';
496 $ilCtrl->redirect($this,
'showAddressbook');
499 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
502 $chat_rooms = $ilChatroom->getAllRooms($ilUser->getId());
505 foreach($chat_rooms as $room_id => $title)
507 $subrooms[] = $ilChatroom->getPrivateSubRooms($room_id, $ilUser->getId());
510 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
513 $form->setTitle($lng->txt(
'mail_invite_users_to_chat'));
518 foreach($chat_rooms as $room_id => $room)
522 if($ilChatroom->isUserBanned($ilUser->getId()))
529 foreach($subrooms as $subroom)
531 foreach($subroom as $sub_id => $parent_id)
536 $options[
$ref_id .
',' . $sub_id] =
'+ ' . $title;
543 $form->addItem($psel);
545 $phidden->setValue(implode(
',', $addr_ids));
546 $form->addItem($phidden);
547 $form->addCommandButton(
'submitInvitation', $this->lng->txt(
'submit'));
548 $form->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
549 $form->setFormAction($ilCtrl->getFormAction($this));
551 $tpl->setTitle($lng->txt(
'mail_invite_users_to_chat'));
552 $tpl->setContent($form->getHtml());
560 public function submitInvitation()
572 $ilCtrl->redirect($this,
'showAddressbook');
578 $_POST[
'addr_id'] = explode(
',', $_POST[
'addr_ids']);
579 $this->inviteToChat();
584 $ids = explode(
',',
$_POST[
'addr_ids']);
587 $room_ids = explode(
',',
$_POST[
'room_id']);
588 $room_id = (int)$room_ids[0];
591 if(count($room_ids) > 0)
593 $scope = (int)$room_ids[1];
596 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
599 $no_access = array();
601 $valid_users = array();
602 $valid_user_to_login_map = array();
606 $entry = $this->abook->getEntry($id);
610 $user_id = $ilUser->getUserIdByLogin($entry[
'login']);
616 $ref_id = $room->getRefIdByRoomId($room_id);
621 $room->isUserBanned($user_id)
628 $valid_users[] = $user_id;
629 $valid_user_to_login_map[$user_id] = $entry[
'login'];
638 if(count($no_access) || count($no_login))
642 if(count($no_access))
644 $message .= $lng->txt(
'chat_users_without_permission') .
':<br>';
647 foreach($no_access as $e)
649 $list .=
'<li>' . $this->abook->entryToString($e) .
'</li>';
659 $message .= $lng->txt(
'chat_users_without_login') .
':<br>';
662 foreach($no_login as $e)
664 $list .=
'<li>' . $this->abook->entryToString($e) .
'</li>';
674 $this->inviteToChat();
678 $ref_id = $room->getRefIdByRoomId($room_id);
681 include_once
'Services/Link/classes/class.ilLink.php';
690 $link =
'<p><a target="chatframe" href="' . $url .
'" title="' . $lng->txt(
'goto_invitation_chat') .
'">' .$lng->txt(
'goto_invitation_chat') .
'</a></p>';
693 foreach($valid_users as $id)
695 $room->inviteUserToPrivateRoom($id, $scope);
696 $room->sendInvitationNotification(
697 null, $ilUser->getId(), $id, (int)$scope, $url
699 $userlist[] =
'<li>'.$valid_user_to_login_map[$id].
'</li>';
704 ilUtil::sendSuccess($lng->txt(
'chat_users_have_been_invited') .
'<ul>'.implode(
'', $userlist).
'</ul>' . $link,
true);
706 $ilCtrl->redirect($this,
'showAddressbook');
711 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
712 include_once
'Services/Contact/classes/class.ilMailAddressbook.php';
724 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
725 include_once
'Services/Contact/classes/class.ilMailAddressbook.php';
737 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
738 include_once
'Services/Contact/classes/class.ilMailAddressbook.php';
752 if($this->tabs_gui->hasTabs())
754 $this->tabs_gui->addSubTab(
'mail_my_entries', $this->lng->txt(
'mail_my_entries'), $this->ctrl->getLinkTarget($this));
755 $this->tabs_gui->addSubTab(
'mail_my_mailing_lists', $this->lng->txt(
'mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
756 $this->tabs_gui->addSubTab(
'mail_my_courses', $this->lng->txt(
'mail_my_courses'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
757 $this->tabs_gui->addSubTab(
'mail_my_groups', $this->lng->txt(
'mail_my_groups'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));
758 $this->has_sub_tabs =
true;
762 $ilHelp->setScreenIdComponent(
"contacts");
764 $this->tabs_gui->addTab(
'mail_my_entries', $this->lng->txt(
'mail_my_entries'), $this->ctrl->getLinkTarget($this));
765 $this->tabs_gui->addTab(
'mail_my_mailing_lists', $this->lng->txt(
'mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
766 $this->tabs_gui->addTab(
'mail_my_courses', $this->lng->txt(
'mail_my_courses'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
767 $this->tabs_gui->addTab(
'mail_my_groups', $this->lng->txt(
'mail_my_groups'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));
773 if($this->has_sub_tabs)
775 $this->tabs_gui->activateSubTab($a_id);
779 $this->tabs_gui->activateTab($a_id);
786 $table->resetOffset();
787 $table->writeFilterToSession();
788 $this->showAddressbook();
794 $table->resetOffset();
795 $table->resetFilter();
796 $this->showAddressbook();