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;
147 if (
$_GET[
"addr_id"])
184 $addr_ids = ((int)
$_GET[
'addr_id']) ? array((
int)
$_GET[
'addr_id']) :
$_POST[
'addr_id'];
193 include_once(
"Services/Utilities/classes/class.ilConfirmationGUI.php");
197 $c_gui->setFormAction($this->ctrl->getFormAction($this,
"performDelete"));
198 $c_gui->setHeaderText($this->lng->txt(
"mail_sure_delete_entry"));
199 $c_gui->setCancel($this->lng->txt(
"cancel"),
"showAddressbook");
200 $c_gui->setConfirm($this->lng->txt(
"confirm"),
"performDelete");
203 foreach($addr_ids as $addr_id)
205 $entry = $this->abook->getEntry($addr_id);
206 $c_gui->addItem(
"addr_id[]", $addr_id, $entry[
"login"] ? $entry[
"login"] : $entry[
"email"]);
209 $this->tpl->setTitle($this->lng->txt(
"contacts"));
210 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Contact");
211 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
225 if (is_array(
$_POST[
'addr_id']))
227 if ($this->abook->deleteEntries(
$_POST[
'addr_id']))
256 global $rbacsystem,
$lng, $ilUser;
258 $this->tpl->setTitle($this->lng->txt(
"contacts"));
259 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook_form.html",
"Services/Contact");
261 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
263 $form->setTitle(
$_GET[
'addr_id'] ? $lng->txt(
"mail_edit_entry") : $lng->txt(
"mail_new_entry"));
265 if (
$_GET[
'addr_id'])
267 $this->ctrl->setParameter($this,
'addr_id',
$_GET[
'addr_id']);
270 $entry = $this->abook->getEntry(
$_GET[
'addr_id']);
271 $form->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
273 $formItem =
new ilTextInputGUI($this->lng->txt(
"username"),
"login");
275 $form->addItem($formItem);
277 $formItem =
new ilTextInputGUI($this->lng->txt(
"firstname"),
"firstname");
279 $form->addItem($formItem);
281 $formItem =
new ilTextInputGUI($this->lng->txt(
"lastname"),
"lastname");
283 $form->addItem($formItem);
285 $formItem =
new ilTextInputGUI($this->lng->txt(
"email"),
"email");
287 $form->addItem($formItem);
289 $form->addCommandButton(
'saveEntry',$this->lng->txt(
'save'));
290 $form->addCommandButton(
'cancel',$this->lng->txt(
'cancel'));
292 $this->tpl->setVariable(
'FORM', $form->getHTML());
303 if (
$_GET[
'addr_id'] && is_array(
$_GET[
'addr_id']))
304 $addr_ids =
$_GET[
'addr_id'];
305 else if ((
int)
$_GET[
'addr_id'])
306 $addr_ids = array((
int)$_GET[
'addr_id']);
307 else if (
$_POST[
'addr_id'] && is_array(
$_POST[
'addr_id']))
308 $addr_ids =
$_POST[
'addr_id'];
309 else if ((
int)
$_POST[
'addr_id'])
310 $addr_ids = array((
int)$_POST[
'addr_id']);
321 $mail_data = $this->umail->getSavedData();
322 if(!is_array($mail_data))
324 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
328 foreach ($addr_ids as $addr_id)
330 $entry = $this->abook->getEntry($addr_id);
332 if(strlen($entry[
'login']) && !$this->umail->doesRecipientStillExists($entry[
'login'], $mail_data[
'rcp_to'])) {
333 $members[] = $entry[
'login'];
334 }
else if(strlen($entry[
'email']) && !$this->umail->doesRecipientStillExists($entry[
'email'], $mail_data[
'rcp_to'])) {
335 $members[] = $entry[
'email'];
341 $mail_data = $this->umail->appendSearchResult($members,
'to');
342 $this->umail->savePostData(
343 $mail_data[
'user_id'],
344 $mail_data[
'attachments'],
345 $mail_data[
'rcp_to'],
346 $mail_data[
'rcp_cc'],
347 $mail_data[
'rcp_bcc'],
348 $mail_data[
'm_type'],
349 $mail_data[
'm_email'],
350 $mail_data[
'm_subject'],
351 $mail_data[
'm_message'],
352 $mail_data[
'use_placeholders']
373 global $rbacsystem,
$lng, $ilUser,
$ilCtrl, $ilias;
375 $this->tpl->setTitle($this->lng->txt(
"contacts"));
376 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_addressbook.html",
"Services/Contact");
379 include_once
"Services/Mail/classes/class.ilMail.php";
381 $mailing_allowed = $rbacsystem->checkAccess(
'mail_visible',$mail->getMailObjectReferenceId());
384 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
385 include_once
'Services/YUI/classes/class.ilYuiUtil.php';
388 $searchform->setFormAction($this->ctrl->getFormAction($this,
"saveEntry"));
391 $dsSchema = array(
"resultsList" =>
'response.results',
392 "fields" => array(
'login',
'firstname',
'lastname'));
393 $dsFormatCallback =
'formatAutoCompleteResults';
394 $dsDataLink = $ilCtrl->getLinkTarget($this,
'lookupAddressbookAsync',
'',
true,
false);
396 $inp =
new ilTextInputGUI($this->lng->txt(
'search_for'),
'search_qry');
398 $inp->setDataSourceSchema($dsSchema);
399 $inp->setDataSourceResultFormat($dsFormatCallback);
401 $searchform->addItem($inp);
402 $searchform->addCommandButton(
'search', $this->lng->txt(
"send"));
403 $this->tpl->setVariable(
'SEARCHFORM', $searchform->getHtml());
406 $this->tpl->setVariable(
'ACTION', $this->ctrl->getFormAction($this,
"saveEntry"));
407 $this->tpl->setVariable(
"TXT_SEARCH_FOR",$this->lng->txt(
"search_for"));
408 $this->tpl->setVariable(
"BUTTON_SEARCH",$this->lng->txt(
"send"));
410 if (strlen(trim(
$_SESSION[
"addr_search"])) > 0)
416 $tbl->setTitle($lng->txt(
"mail_addr_entries"));
417 $tbl->setRowTemplate(
"tpl.mail_addressbook_row.html",
"Services/Contact");
419 $tbl->setDefaultOrderField(
'login');
422 $this->abook->setSearchQuery(
$_SESSION[
'addr_search']);
423 $entries = $this->abook->getEntries();
425 $tbl->addColumn(
'',
'check',
'10%',
true);
426 $tbl->addColumn($this->lng->txt(
'login'),
'login',
'20%');
427 $tbl->addColumn($this->lng->txt(
'firstname'),
'firstname',
'20%');
428 $tbl->addColumn($this->lng->txt(
'lastname'),
'lastname',
'20%');
429 $tbl->addColumn($this->lng->txt(
'email'),
'email',
'20%');
430 $tbl->addColumn($this->lng->txt(
'actions'),
'',
'10%');
432 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
436 $tbl->enable(
'select_all');
437 $tbl->setSelectAllCheckbox(
'addr_id');
439 $chatSettings =
new ilSetting(
'chatroom');
440 $chat_active = $chatSettings->get(
"chat_enabled",
false);
444 foreach ($entries as $entry)
448 $this->ctrl->setParameter($this,
'addr_id', $entry[
'addr_id']);
450 if ($entry[
"login"] !=
"")
452 if ($mailing_allowed)
454 $result[$counter][
'login_linked_link'] = $this->ctrl->getLinkTarget($this,
'mailToUsers');
455 $result[$counter][
'login_linked_login'] = $entry[
"login"];
458 $result[$counter][
'login_unliked'] = $entry[
"login"];
461 $result[$counter][
'firstname'] = $entry[
"firstname"];
462 $result[$counter][
'lastname'] = $entry[
"lastname"];
464 if (
$_GET[
"baseClass"] ==
"ilMailGUI" && $rbacsystem->checkAccess(
"smtp_mail", $this->umail->getMailObjectReferenceId()))
466 $result[$counter][
'email_linked_email'] = $entry[
"email"];
467 $result[$counter][
'email_linked_link'] = $this->ctrl->getLinkTarget($this,
"mailToUsers");
470 $result[$counter][
'email_unlinked'] = $entry[
"email"] ? $entry[
"email"] :
" ";
473 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
474 $current_selection_list->setId(
"act_".$counter);
476 $current_selection_list->addItem($this->lng->txt(
"edit"),
'', $this->ctrl->getLinkTarget($this,
"showAddressForm"));
478 if ($mailing_allowed)
479 $current_selection_list->addItem($this->lng->txt(
"send_mail_to"),
'', $this->ctrl->getLinkTarget($this,
"mailToUsers"));
481 $current_selection_list->addItem($this->lng->txt(
"delete"),
'', $this->ctrl->getLinkTarget($this,
"confirmDelete"));
484 $current_selection_list->addItem($this->lng->txt(
"invite_to_chat"),
'', $this->ctrl->getLinkTarget($this,
"inviteToChat"));
486 $this->ctrl->clearParameters($this);
488 $result[$counter][
'COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
492 if ($mailing_allowed)
493 $tbl->addMultiCommand(
'mailToUsers', $this->lng->txt(
'send_mail_to'));
495 $tbl->addMultiCommand(
'confirmDelete', $this->lng->txt(
'delete'));
498 $tbl->addMultiCommand(
'inviteToChat', $this->lng->txt(
'invite_to_chat'));
502 $tbl->disable(
'header');
503 $tbl->disable(
'footer');
505 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
510 $tbl->addCommandButton(
'showAddressForm', $this->lng->txt(
'add'));
512 $this->tpl->setVariable(
'TABLE', $tbl->getHTML());
534 $addr_ids = ( (int)
$_GET[
'addr_id'] ) ?
535 array( (
int)
$_GET[
'addr_id'] ) :
542 $ilCtrl->getLinkTarget($this,
'showAddressbook',
'',
false,
false)
550 foreach( $addr_ids as $id )
552 $entry = $this->abook->getEntry($id);
555 if( !$entry[
'login'] )
561 if( count($no_login) )
563 $message .= $lng->txt(
'chat_users_without_login') .
':<br>';
566 foreach( $no_login as $e )
568 $list .=
'<li>' . $this->abook->entryToString($e) .
'</li>';
580 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
583 $chat_rooms = $ilChatroom->getAllRooms( $ilUser->getId() );
586 foreach( $chat_rooms as $room_id =>
$title)
588 $subrooms[] = $ilChatroom->getPrivateSubRooms( $room_id, $ilUser->getId() );
591 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
594 $form->setTitle( $lng->txt(
"mail_invite_users_to_chat") );
599 foreach( $chat_rooms as $room_id => $room )
603 if( $ilChatroom->isUserBanned( $ilUser->getId() ) )
610 foreach( $subrooms as $subroom )
612 foreach( $subroom as $sub_id => $parent_id )
623 $psel->setOptions($options);
624 $form->addItem($psel);
626 $phidden->setValue( join(
',', $addr_ids ) );
627 $form->addItem( $phidden );
628 $form->addCommandButton(
'submitInvitation', $this->lng->txt(
'submit' ) );
629 $form->addCommandButton(
'cancel', $this->lng->txt(
'cancel' ) );
630 $form->setFormAction( $ilCtrl->getFormAction( $this ) );
632 $tpl->setTitle( $lng->txt(
'mail_invite_users_to_chat' ) );
633 $tpl->setContent( $form->getHtml() );
659 $_POST[
'addr_id'] = explode(
',', $_POST[
"addr_ids"] );
665 $ids = explode(
',',
$_POST[
"addr_ids"] );
668 $room_ids = explode(
',',
$_POST[
'room_id'] );
669 $room_id = (int)$room_ids[0];
672 if( count($room_ids) > 0 )
674 $scope = (int)$room_ids[1];
677 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
680 $no_access = array();
682 $valid_users = array();
684 foreach( $ids as $id )
686 $entry = $this->abook->getEntry($id);
688 if( $entry[
'login'] )
690 $user_id = $ilUser->getUserIdByLogin($entry[
'login']);
691 $ref_id = $room->getRefIdByRoomId($room_id);
696 || $room->isUserBanned( $user_id )
703 $valid_users[] = $user_id;
712 if( count( $no_access ) || count( $no_login ) )
716 if( count($no_access) )
718 $message .= $lng->txt(
'chat_users_without_permission') .
':<br>';
721 foreach( $no_access as $e )
723 $list .=
'<li>'.$this->abook->entryToString($e).
'</li>';
731 if( count( $no_login ) )
733 $message .= $lng->txt(
'chat_users_without_login') .
':<br>';
736 foreach( $no_login as $e )
738 $list .=
'<li>'.$this->abook->entryToString($e).
'</li>';
752 $ref_id = $room->getRefIdByRoomId( $room_id );
754 include_once
'classes/class.ilLink.php';
766 $link =
'<p><a target="chatframe" href="'.$url.
'">' .
767 $lng->txt(
'goto_invitation_chat') .
'</a></p>';
769 foreach( $valid_users as $id )
771 $room->inviteUserToPrivateRoom( $id, $scope );
773 $room->sendInvitationNotification(
774 null, $ilUser->getId(), $id, (int)$scope, $url
779 $lng->txt(
'chat_users_have_been_invited') . $userlist . $link, true
781 $link = $ilCtrl->getLinkTarget( $this,
'showAddressbook',
'',
false,
false );
787 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
788 include_once
'Services/Contact/classes/class.ilMailAddressbook.php';
790 $search =
"%" .
$_REQUEST[
"query"] .
"%";
792 $result->response =
new stdClass();
793 $result->response->results = array();
803 $result = $mailAdrBookObj->getAddressbookAsync($search);
811 if($this->tabs_gui->hasTabs())
813 $this->tabs_gui->addSubTab(
'mail_my_entries', $this->lng->txt(
'mail_my_entries'), $this->ctrl->getLinkTarget($this));
814 $this->tabs_gui->addSubTab(
'mail_my_mailing_lists', $this->lng->txt(
'mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
815 $this->tabs_gui->addSubTab(
'mail_my_courses', $this->lng->txt(
'mail_my_courses'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
816 $this->tabs_gui->addSubTab(
'mail_my_groups', $this->lng->txt(
'mail_my_groups'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));
817 $this->has_sub_tabs =
true;
821 $this->tabs_gui->addTab(
'mail_my_entries', $this->lng->txt(
'mail_my_entries'), $this->ctrl->getLinkTarget($this));
822 $this->tabs_gui->addTab(
'mail_my_mailing_lists', $this->lng->txt(
'mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass(
'ilmailinglistsgui'));
823 $this->tabs_gui->addTab(
'mail_my_courses', $this->lng->txt(
'mail_my_courses'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchcoursesgui'));
824 $this->tabs_gui->addTab(
'mail_my_groups', $this->lng->txt(
'mail_my_groups'), $this->ctrl->getLinkTargetByClass(
'ilmailsearchgroupsgui'));
830 if($this->has_sub_tabs)
832 $this->tabs_gui->activateSubTab($a_id);
836 $this->tabs_gui->activateTab($a_id);