ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailAddressbookGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
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";
10 
11 
21 {
22  private $tpl = null;
23  private $ctrl = null;
24  private $lng = null;
25  private $tabs_gui = null;
26 
27  private $umail = null;
28  private $abook = null;
29 
30  public function __construct()
31  {
32  global $tpl, $ilCtrl, $lng, $ilUser, $ilTabs;
33 
34  $this->tpl = $tpl;
35  $this->ctrl = $ilCtrl;
36  $this->lng = $lng;
37  $this->tabs_gui =& $ilTabs;
38 
39  $this->ctrl->saveParameter($this, "mobj_id");
40 
41  $this->umail = new ilFormatMail($ilUser->getId());
42  $this->abook = new ilAddressbook($ilUser->getId());
43  }
44 
45  public function executeCommand()
46  {
47  global $ilUser;
48  $this->showSubTabs();
49 
50  $forward_class = $this->ctrl->getNextClass($this);
51 
52  // delete all stored maildata
53  $this->umail->savePostData($ilUser->getId(), array(), '', '', '', '', '', '', '', '');
54 
55  switch($forward_class)
56  {
57  case 'ilmailformgui':
58  include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
59  $this->ctrl->forwardCommand(new ilMailFormGUI());
60  break;
61 
62  case 'ilmailsearchcoursesgui':
63  include_once 'Services/Contact/classes/class.ilMailSearchCoursesGUI.php';
64 
65  $this->activateTab('mail_my_courses');
66 
67  $this->ctrl->setReturn($this, "showAddressbook");
68  $this->ctrl->forwardCommand(new ilMailSearchCoursesGUI());
69  break;
70 
71  case 'ilmailsearchgroupsgui':
72  include_once 'Services/Contact/classes/class.ilMailSearchGroupsGUI.php';
73 
74  $this->activateTab('mail_my_groups');
75 
76  $this->ctrl->setReturn($this, "showAddressbook");
77  $this->ctrl->forwardCommand(new ilMailSearchGroupsGUI());
78  break;
79 
80  case 'ilmailinglistsgui':
81  include_once 'Services/Contact/classes/class.ilMailingListsGUI.php';
82 
83  $this->activateTab('mail_my_mailing_lists');
84 
85  $this->ctrl->setReturn($this, "showAddressbook");
86  $this->ctrl->forwardCommand(new ilMailingListsGUI());
87  break;
88 
89  default:
90  $this->activateTab('mail_my_entries');
91 
92  if (!($cmd = $this->ctrl->getCmd()))
93  {
94  $cmd = "showAddressbook";
95  }
96 
97  $this->$cmd();
98  break;
99  }
100  return true;
101  }
102 
106  function checkInput($addr_id = 0)
107  {
108  // check if user login and e-mail-address are empty
109  if (!strcmp(trim($_POST["login"]), "") &&
110  !strcmp(trim($_POST["email"]), ""))
111  {
112  ilUtil::sendInfo($this->lng->txt("mail_enter_login_or_email_addr"));
113  $error = true;
114  }
115  else if ($_POST["login"] != "" &&
117  {
118  ilUtil::sendInfo($this->lng->txt("mail_enter_valid_login"));
119  $error = true;
120  }
121  else if ($_POST["email"] &&
122  !(ilUtil::is_email($_POST["email"])))
123  {
124  ilUtil::sendInfo($this->lng->txt("mail_enter_valid_email_addr"));
125  $error = true;
126  }
127 
128  if (($this->existingEntry = $this->abook->checkEntryByLogin(ilUtil::stripSlashes($_POST["login"]))) > 0 &&
129  (($this->existingEntry != $addr_id && $addr_id > 0) || !$addr_id))
130  {
131  ilUtil::sendInfo($this->lng->txt("mail_entry_exists"));
132  $error = true;
133  }
134 
135  return $error ? false : true;
136  }
137 
141  public function saveEntry()
142  {
143  global $lng;
144 
145  if ($this->checkInput($_GET["addr_id"]))
146  {
147  if ($_GET["addr_id"])
148  {
149  $this->abook->updateEntry(ilUtil::stripSlashes($_GET["addr_id"]),
150  ilUtil::stripSlashes($_POST["login"]),
151  ilUtil::stripSlashes($_POST["firstname"]),
152  ilUtil::stripSlashes($_POST["lastname"]),
153  ilUtil::stripSlashes($_POST["email"]));
154  ilUtil::sendInfo($lng->txt("mail_entry_changed"));
155  }
156  else
157  {
158  $this->abook->addEntry(ilUtil::stripSlashes($_POST["login"]),
159  ilUtil::stripSlashes($_POST["firstname"]),
160  ilUtil::stripSlashes($_POST["lastname"]),
161  ilUtil::stripSlashes($_POST["email"]));
162  ilUtil::sendInfo($lng->txt("mail_entry_added"));
163  }
164 
165  unset($_SESSION['addr_search']);
166 
167  $this->showAddressbook();
168  }
169  else
170  {
171  $this->showAddressForm();
172  }
173 
174  return true;
175  }
176 
180  function confirmDelete()
181  {
182  global $lng;
183 
184  $addr_ids = ((int)$_GET['addr_id']) ? array((int)$_GET['addr_id']) : $_POST['addr_id'];
185 
186  if (!$addr_ids)
187  {
188  ilUtil::sendInfo($this->lng->txt('mail_select_one_entry'));
189  $this->showAddressbook();
190  return true;
191  }
192 
193  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
194  $c_gui = new ilConfirmationGUI();
195 
196  // set confirm/cancel commands
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");
201 
202  // add items to delete
203  foreach($addr_ids as $addr_id)
204  {
205  $entry = $this->abook->getEntry($addr_id);
206  $c_gui->addItem("addr_id[]", $addr_id, $entry["login"] ? $entry["login"] : $entry["email"]);
207  }
208 
209  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
210  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_addressbook.html", "Services/Contact");
211  $this->tpl->setVariable('DELETE_CONFIRMATION', $c_gui->getHTML());
212 
213  $this->tpl->show();
214 
215  return true;
216  }
217 
221  function performDelete()
222  {
223  global $lng;
224 
225  if (is_array($_POST['addr_id']))
226  {
227  if ($this->abook->deleteEntries($_POST['addr_id']))
228  {
229  ilUtil::sendInfo($lng->txt("mail_deleted_entry"));
230  }
231  else
232  {
233  ilUtil::sendInfo($lng->txt("mail_delete_error"));
234  }
235  }
236  else
237  {
238  ilUtil::sendInfo($lng->txt("mail_delete_error"));
239  }
240 
241  $this->showAddressbook();
242 
243  return true;
244  }
245 
249  function cancel()
250  {
251  $this->showAddressbook();
252  }
253 
254  public function showAddressForm()
255  {
256  global $rbacsystem, $lng, $ilUser;
257 
258  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
259  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_addressbook_form.html", "Services/Contact");
260 
261  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
262  $form = new ilPropertyFormGUI();
263  $form->setTitle($_GET['addr_id'] ? $lng->txt("mail_edit_entry") : $lng->txt("mail_new_entry"));
264 
265  if ($_GET['addr_id'])
266  {
267  $this->ctrl->setParameter($this, 'addr_id', $_GET['addr_id']);
268  }
269 
270  $entry = $this->abook->getEntry($_GET['addr_id']);
271  $form->setFormAction($this->ctrl->getFormAction($this, "saveEntry"));
272 
273  $formItem = new ilTextInputGUI($this->lng->txt("username"), "login");
274  $formItem->setValue(isset($_POST['login']) ? ilUtil::prepareFormOutput($_POST['login'], true) : ilUtil::prepareFormOutput($entry['login']));
275  $form->addItem($formItem);
276 
277  $formItem = new ilTextInputGUI($this->lng->txt("firstname"), "firstname");
278  $formItem->setValue(isset($_POST['firstname']) ? ilUtil::prepareFormOutput($_POST['firstname'], true) : ilUtil::prepareFormOutput($entry['firstname']));
279  $form->addItem($formItem);
280 
281  $formItem = new ilTextInputGUI($this->lng->txt("lastname"), "lastname");
282  $formItem->setValue(isset($_POST['lastname']) ? ilUtil::prepareFormOutput($_POST['lastname'], true) : ilUtil::prepareFormOutput($entry['lastname']));
283  $form->addItem($formItem);
284 
285  $formItem = new ilTextInputGUI($this->lng->txt("email"), "email");
286  $formItem->setValue(isset($_POST['email']) ? ilUtil::prepareFormOutput($_POST['email'], true) : ilUtil::prepareFormOutput($entry['email']));
287  $form->addItem($formItem);
288 
289  $form->addCommandButton('saveEntry',$this->lng->txt('save'));
290  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
291 
292  $this->tpl->setVariable('FORM', $form->getHTML());
293 
294  $this->tpl->show();
295 
296  return true;
297  }
298 
299  public function mailToUsers()
300  {
301  global $ilUser;
302 
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']);
311 
312 // $addr_ids = ((int)$_GET['addr_id']) ? array((int)$_GET['addr_id']) : $_POST['addr_id'];
313 
314  if (!$addr_ids)
315  {
316  ilUtil::sendInfo($this->lng->txt('mail_select_one_entry'));
317  $this->showAddressbook();
318  return true;
319  }
320 
321  $mail_data = $this->umail->getSavedData();
322  if(!is_array($mail_data))
323  {
324  $this->umail->savePostData($ilUser->getId(), array(), '', '', '', '', '', '', '', '');
325  }
326 
327  $members = array();
328  foreach ($addr_ids as $addr_id)
329  {
330  $entry = $this->abook->getEntry($addr_id);
331 
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'];
336  }
337  }
338 
339  if(count($members))
340  {
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']
353  );
354  }
355 
356  ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
357  }
358 
359  public function search()
360  {
361  $_SESSION['addr_search'] = $_POST['search_qry'];
362 
363  $this->showAddressbook();
364 
365  return true;
366  }
367 
371  public function showAddressbook()
372  {
373  global $rbacsystem, $lng, $ilUser, $ilCtrl, $ilias;
374 
375  $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
376  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_addressbook.html", "Services/Contact");
377 
378  // check if current user may send mails
379  include_once "Services/Mail/classes/class.ilMail.php";
380  $mail = new ilMail($_SESSION["AccountId"]);
381  $mailing_allowed = $rbacsystem->checkAccess('internal_mail',$mail->getMailObjectReferenceId());
382 
383  // searchbox
384  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
385  $searchform = new ilPropertyFormGUI();
386  $searchform->setFormAction($this->ctrl->getFormAction($this, "saveEntry"));
387 
388  $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupAddressbookAsync', '', true, false);
389  $inp = new ilTextInputGUI($this->lng->txt('search_for'), 'search_qry');
390  $inp->setDataSource($dsDataLink);
391 
392  $searchform->addItem($inp);
393  $searchform->addCommandButton('search', $this->lng->txt("send"));
394  $this->tpl->setVariable('SEARCHFORM', $searchform->getHtml());
395 
396 
397  $this->tpl->setVariable('ACTION', $this->ctrl->getFormAction($this, "saveEntry"));
398  $this->tpl->setVariable("TXT_SEARCH_FOR",$this->lng->txt("search_for"));
399  $this->tpl->setVariable("BUTTON_SEARCH",$this->lng->txt("send"));
400 
401  if (strlen(trim($_SESSION["addr_search"])) > 0)
402  {
403  $this->tpl->setVariable("VALUE_SEARCH_FOR", ilUtil::prepareFormOutput(trim($_SESSION["addr_search"]), true));
404  }
405 
406  $tbl = new ilAddressbookTableGUI($this);
407  $tbl->setTitle($lng->txt("mail_addr_entries"));
408  $tbl->setRowTemplate("tpl.mail_addressbook_row.html", "Services/Contact");
409 
410  $tbl->setDefaultOrderField('login');
411 
412  $result = array();
413  $this->abook->setSearchQuery($_SESSION['addr_search']);
414  $entries = $this->abook->getEntries();
415 
416  $tbl->addColumn('', 'check', '10%', true);
417  $tbl->addColumn($this->lng->txt('login'), 'login', '20%');
418  $tbl->addColumn($this->lng->txt('firstname'), 'firstname', '20%');
419  $tbl->addColumn($this->lng->txt('lastname'), 'lastname', '20%');
420  $tbl->addColumn($this->lng->txt('email'), 'email', '20%');
421  $tbl->addColumn($this->lng->txt('actions'), '', '10%');
422 
423  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
424 
425  if (count($entries))
426  {
427  $tbl->enable('select_all');
428  $tbl->setSelectAllCheckbox('addr_id');
429 
430  $chatSettings = new ilSetting('chatroom');
431  $chat_active = $chatSettings->get("chat_enabled", false);
432 
433  $counter = 0;
434 
435  foreach ($entries as $entry)
436  {
437  $result[$counter]['check'] = ilUtil::formCheckbox(0, 'addr_id[]', $entry["addr_id"]);
438 
439  $this->ctrl->setParameter($this, 'addr_id', $entry['addr_id']);
440 
441  $result[$counter]['login'] = '';
442  if($entry["login"] != "")
443  {
444  if($mailing_allowed)
445  {
446  $result[$counter]['login_linked_link'] = $this->ctrl->getLinkTarget($this, 'mailToUsers');
447  $result[$counter]['login'] = $result[$counter]['login_linked_login'] = $entry["login"];
448  }
449  else
450  {
451  $result[$counter]['login'] = $result[$counter]['login_unliked'] = $entry["login"];
452  }
453  }
454 
455  $result[$counter]['firstname'] = $entry["firstname"];
456  $result[$counter]['lastname'] = $entry["lastname"];
457 
458  if($_GET["baseClass"] == "ilMailGUI" && $rbacsystem->checkAccess("smtp_mail", $this->umail->getMailObjectReferenceId()))
459  {
460  $result[$counter]['email'] = $result[$counter]['email_linked_email'] = $entry["email"];
461  $result[$counter]['email_linked_link'] = $this->ctrl->getLinkTarget($this, "mailToUsers");
462  }
463  else
464  {
465  $result[$counter]['email'] = $result[$counter]['email_unlinked'] = $entry["email"];
466  }
467 
468  $current_selection_list = new ilAdvancedSelectionListGUI();
469  $current_selection_list->setListTitle($this->lng->txt("actions"));
470  $current_selection_list->setId("act_".$counter);
471 
472  $current_selection_list->addItem($this->lng->txt("edit"), '', $this->ctrl->getLinkTarget($this, "showAddressForm"));
473 
474  if ($mailing_allowed)
475  $current_selection_list->addItem($this->lng->txt("send_mail_to"), '', $this->ctrl->getLinkTarget($this, "mailToUsers"));
476 
477  $current_selection_list->addItem($this->lng->txt("delete"), '', $this->ctrl->getLinkTarget($this, "confirmDelete"));
478 
479  if ($chat_active)
480  $current_selection_list->addItem($this->lng->txt("invite_to_chat"), '', $this->ctrl->getLinkTarget($this, "inviteToChat"));
481 
482  $this->ctrl->clearParameters($this);
483 
484  $result[$counter]['COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
485  ++$counter;
486  }
487 
488  if ($mailing_allowed)
489  $tbl->addMultiCommand('mailToUsers', $this->lng->txt('send_mail_to'));
490 
491  $tbl->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
492 
493  if ($chat_active)
494  $tbl->addMultiCommand('inviteToChat', $this->lng->txt('invite_to_chat'));
495  }
496  else
497  {
498  $tbl->disable('header');
499  $tbl->disable('footer');
500 
501  $tbl->setNoEntriesText($this->lng->txt('mail_search_no'));
502  }
503 
504  $tbl->setData($result);
505 
506  $tbl->addCommandButton('showAddressForm', $this->lng->txt('add'));
507 
508  $this->tpl->setVariable('TABLE', $tbl->getHTML());
509 
510  $this->tpl->show();
511 
512  unset($_SESSION['addr_search']);
513 
514  return true;
515  }
516 
517 
521  public function inviteToChat()
522  {
529  global $ilUser, $lng, $ilCtrl, $tpl;
530 
531  $lng->loadLanguageModule('chatroom');
532 
533  $addr_ids = ((int)$_GET['addr_id']) ? array((int)$_GET['addr_id']) : $_POST['addr_id'];
534 
535  if(!$addr_ids)
536  {
537  ilUtil::sendFailure($lng->txt('select_one'), true);
538  $ilCtrl->redirect($this, 'showAddressbook');
539  }
540 
541  $no_login = array();
542 
543  foreach($addr_ids as $id)
544  {
545  $entry = $this->abook->getEntry($id);
546  if(!$entry['login'])
547  {
548  $no_login[] = $id;
549  }
550  }
551 
552  if(count($no_login))
553  {
554  $message = $lng->txt('chat_users_without_login') . ':<br>';
555  $list = '';
556 
557  foreach($no_login as $e)
558  {
559  $list .= '<li>' . $this->abook->entryToString($e) . '</li>';
560  }
561 
562  $message .= '<ul>';
563  $message .= $list;
564  $message .= '</ul>';
565 
566  ilUtil::sendFailure($message, true);
567  $ilCtrl->redirect($this, 'showAddressbook');
568  }
569 
570  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
571 
572  $ilChatroom = new ilChatroom();
573  $chat_rooms = $ilChatroom->getAllRooms($ilUser->getId());
574  $subrooms = array();
575 
576  foreach($chat_rooms as $room_id => $title)
577  {
578  $subrooms[] = $ilChatroom->getPrivateSubRooms($room_id, $ilUser->getId());
579  }
580 
581  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
582 
583  $form = new ilPropertyFormGUI();
584  $form->setTitle($lng->txt('mail_invite_users_to_chat'));
585 
586  $psel = new ilSelectInputGUI($lng->txt('chat_select_room'), 'room_id');
587  $options = array();
588 
589  foreach($chat_rooms as $room_id => $room)
590  {
591  $ref_id = $room_id;
592 
593  if($ilChatroom->isUserBanned($ilUser->getId()))
594  {
595  continue;
596  }
597 
598  $options[$ref_id] = $room;
599 
600  foreach($subrooms as $subroom)
601  {
602  foreach($subroom as $sub_id => $parent_id)
603  {
604  if($parent_id == $ref_id)
605  {
607  $options[$ref_id . ',' . $sub_id] = '+&nbsp;' . $title;
608  }
609  }
610  }
611  }
612 
613  $psel->setOptions($options);
614  $form->addItem($psel);
615  $phidden = new ilHiddenInputGUI('addr_ids');
616  $phidden->setValue(implode(',', $addr_ids));
617  $form->addItem($phidden);
618  $form->addCommandButton('submitInvitation', $this->lng->txt('submit'));
619  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
620  $form->setFormAction($ilCtrl->getFormAction($this));
621 
622  $tpl->setTitle($lng->txt('mail_invite_users_to_chat'));
623  $tpl->setContent($form->getHtml());
624  $tpl->show();
625  }
626 
631  public function submitInvitation()
632  {
638  global $ilUser, $ilCtrl, $lng;
639 
640  if(!$_POST['addr_ids'])
641  {
642  ilUtil::sendFailure($lng->txt('select_one'), true);
643  $ilCtrl->redirect($this, 'showAddressbook');
644  }
645 
646  if(!$_POST['room_id'])
647  {
648  ilUtil::sendFailure($lng->txt('select_one'));
649  $_POST['addr_id'] = explode(',', $_POST['addr_ids']);
650  $this->inviteToChat();
651  return;
652  }
653 
654  // get selected users (comma seperated user id list)
655  $ids = explode(',', $_POST['addr_ids']);
656 
657  // get selected chatroom from POST-String, format: "room_id , scope"
658  $room_ids = explode(',', $_POST['room_id']);
659  $room_id = (int)$room_ids[0];
660  $scope = 0;
661 
662  if(count($room_ids) > 0)
663  {
664  $scope = (int)$room_ids[1];
665  }
666 
667  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
668 
669  $room = ilChatroom::byRoomId((int)$room_id, true);
670  $no_access = array();
671  $no_login = array();
672  $valid_users = array();
673  $valid_user_to_login_map = array();
674 
675  foreach($ids as $id)
676  {
677  $entry = $this->abook->getEntry($id);
678 
679  if($entry['login'])
680  {
681  $user_id = $ilUser->getUserIdByLogin($entry['login']);
682  if(!$user_id)
683  {
684  $no_login[] = $id;
685  continue;
686  }
687  $ref_id = $room->getRefIdByRoomId($room_id);
688 
689  if
690  (
691  !ilChatroom::checkPermissionsOfUser($user_id, 'read', $ref_id) ||
692  $room->isUserBanned($user_id)
693  )
694  {
695  $no_access[] = $id;
696  }
697  else
698  {
699  $valid_users[] = $user_id;
700  $valid_user_to_login_map[$user_id] = $entry['login'];
701  }
702  }
703  else
704  {
705  $no_login[] = $id;
706  }
707  }
708 
709  if(count($no_access) || count($no_login))
710  {
711  $message = '';
712 
713  if(count($no_access))
714  {
715  $message .= $lng->txt('chat_users_without_permission') . ':<br>';
716  $list = '';
717 
718  foreach($no_access as $e)
719  {
720  $list .= '<li>' . $this->abook->entryToString($e) . '</li>';
721  }
722 
723  $message .= '<ul>';
724  $message .= $list;
725  $message .= '</ul>';
726  }
727 
728  if(count($no_login))
729  {
730  $message .= $lng->txt('chat_users_without_login') . ':<br>';
731  $list = '';
732 
733  foreach($no_login as $e)
734  {
735  $list .= '<li>' . $this->abook->entryToString($e) . '</li>';
736  }
737 
738  $message .= '<ul>';
739  $message .= $list;
740  $message .= '</ul>';
741  }
742 
743  ilUtil::sendFailure($message);
744  $_POST['addr_id'] = $ids;
745  $this->inviteToChat();
746  return;
747  }
748 
749  $ref_id = $room->getRefIdByRoomId($room_id);
750 
751  $url = '';
752  include_once 'Services/Link/classes/class.ilLink.php';
753  if($scope)
754  {
755  $url = ilLink::_getStaticLink($ref_id, 'chta', true, '_'.$scope);
756  }
757  else
758  {
759  $url = ilLink::_getStaticLink($ref_id, 'chta');
760  }
761  $link = '<p><a target="chatframe" href="' . $url . '" title="' . $lng->txt('goto_invitation_chat') . '">' .$lng->txt('goto_invitation_chat') . '</a></p>';
762 
763  $userlist = array();
764  foreach($valid_users as $id)
765  {
766  $room->inviteUserToPrivateRoom($id, $scope);
767  $room->sendInvitationNotification(
768  null, $ilUser->getId(), $id, (int)$scope, $url
769  );
770  $userlist[] = '<li>'.$valid_user_to_login_map[$id].'</li>';
771  }
772 
773  if($userlist)
774  {
775  ilUtil::sendSuccess($lng->txt('chat_users_have_been_invited') . '<ul>'.implode('', $userlist).'</ul>' . $link, true);
776  }
777  $ilCtrl->redirect($this, 'showAddressbook');
778  }
779 
780  public function lookupAddressbookAsync()
781  {
782  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
783  include_once 'Services/Contact/classes/class.ilMailAddressbook.php';
784 
785  $search = "%" . $_REQUEST["term"] . "%";
786  $result = array();
787 
788  if( !$search )
789  {
791  exit;
792  }
793 
794  $mailAdrBookObj = new ilMailAddressbook;
795  $result = $mailAdrBookObj->getAddressbookAsync($search);
796 
798  exit;
799  }
800 
801  function showSubTabs()
802  {
803  global $ilHelp;
804 
805  if($this->tabs_gui->hasTabs())
806  {
807  $this->tabs_gui->addSubTab('mail_my_entries', $this->lng->txt('mail_my_entries'), $this->ctrl->getLinkTarget($this));
808  $this->tabs_gui->addSubTab('mail_my_mailing_lists', $this->lng->txt('mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass('ilmailinglistsgui'));
809  $this->tabs_gui->addSubTab('mail_my_courses', $this->lng->txt('mail_my_courses'), $this->ctrl->getLinkTargetByClass('ilmailsearchcoursesgui'));
810  $this->tabs_gui->addSubTab('mail_my_groups', $this->lng->txt('mail_my_groups'), $this->ctrl->getLinkTargetByClass('ilmailsearchgroupsgui'));
811  $this->has_sub_tabs = true;
812  }
813  else
814  {
815  $ilHelp->setScreenIdComponent("contacts");
816 
817  $this->tabs_gui->addTab('mail_my_entries', $this->lng->txt('mail_my_entries'), $this->ctrl->getLinkTarget($this));
818  $this->tabs_gui->addTab('mail_my_mailing_lists', $this->lng->txt('mail_my_mailing_lists'), $this->ctrl->getLinkTargetByClass('ilmailinglistsgui'));
819  $this->tabs_gui->addTab('mail_my_courses', $this->lng->txt('mail_my_courses'), $this->ctrl->getLinkTargetByClass('ilmailsearchcoursesgui'));
820  $this->tabs_gui->addTab('mail_my_groups', $this->lng->txt('mail_my_groups'), $this->ctrl->getLinkTargetByClass('ilmailsearchgroupsgui'));
821  }
822  }
823 
824  function activateTab($a_id)
825  {
826  if($this->has_sub_tabs)
827  {
828  $this->tabs_gui->activateSubTab($a_id);
829  }
830  else
831  {
832  $this->tabs_gui->activateTab($a_id);
833  }
834  }
835 }
836 ?>