ILIAS  Release_4_2_x_branch Revision 61807
 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("contacts"));
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("contacts"));
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("contacts"));
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('mail_visible',$mail->getMailObjectReferenceId());
382 
383  // searchbox
384  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
385  include_once 'Services/YUI/classes/class.ilYuiUtil.php';
387  $searchform = new ilPropertyFormGUI();
388  $searchform->setFormAction($this->ctrl->getFormAction($this, "saveEntry"));
389 
390  //$dsSchema = array('response.results', 'login', 'firstname', 'lastname');
391  $dsSchema = array("resultsList" => 'response.results',
392  "fields" => array('login', 'firstname', 'lastname'));
393  $dsFormatCallback = 'formatAutoCompleteResults';
394  $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupAddressbookAsync', '', true, false);
395 
396  $inp = new ilTextInputGUI($this->lng->txt('search_for'), 'search_qry');
397  $inp->setDataSource($dsDataLink);
398  $inp->setDataSourceSchema($dsSchema);
399  $inp->setDataSourceResultFormat($dsFormatCallback);
400 
401  $searchform->addItem($inp);
402  $searchform->addCommandButton('search', $this->lng->txt("send"));
403  $this->tpl->setVariable('SEARCHFORM', $searchform->getHtml());
404 
405 
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"));
409 
410  if (strlen(trim($_SESSION["addr_search"])) > 0)
411  {
412  $this->tpl->setVariable("VALUE_SEARCH_FOR", ilUtil::prepareFormOutput(trim($_SESSION["addr_search"]), true));
413  }
414 
415  $tbl = new ilAddressbookTableGUI($this);
416  $tbl->setTitle($lng->txt("mail_addr_entries"));
417  $tbl->setRowTemplate("tpl.mail_addressbook_row.html", "Services/Contact");
418 
419  $tbl->setDefaultOrderField('login');
420 
421  $result = array();
422  $this->abook->setSearchQuery($_SESSION['addr_search']);
423  $entries = $this->abook->getEntries();
424 
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%');
431 
432  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
433 
434  if (count($entries))
435  {
436  $tbl->enable('select_all');
437  $tbl->setSelectAllCheckbox('addr_id');
438 
439  $chatSettings = new ilSetting('chatroom');
440  $chat_active = $chatSettings->get("chat_enabled", false);
441 
442  $counter = 0;
443 
444  foreach ($entries as $entry)
445  {
446  $result[$counter]['check'] = ilUtil::formCheckbox(0, 'addr_id[]', $entry["addr_id"]);
447 
448  $this->ctrl->setParameter($this, 'addr_id', $entry['addr_id']);
449 
450  if ($entry["login"] != "")
451  {
452  if ($mailing_allowed)
453  {
454  $result[$counter]['login_linked_link'] = $this->ctrl->getLinkTarget($this, 'mailToUsers');
455  $result[$counter]['login_linked_login'] = $entry["login"];
456  }
457  else
458  $result[$counter]['login_unliked'] = $entry["login"];
459  }
460 
461  $result[$counter]['firstname'] = $entry["firstname"];
462  $result[$counter]['lastname'] = $entry["lastname"];
463 
464  if ($_GET["baseClass"] == "ilMailGUI" && $rbacsystem->checkAccess("smtp_mail", $this->umail->getMailObjectReferenceId()))
465  {
466  $result[$counter]['email_linked_email'] = $entry["email"];
467  $result[$counter]['email_linked_link'] = $this->ctrl->getLinkTarget($this, "mailToUsers");
468  }
469  else
470  $result[$counter]['email_unlinked'] = $entry["email"] ? $entry["email"] : "&nbsp;";
471 
472  $current_selection_list = new ilAdvancedSelectionListGUI();
473  $current_selection_list->setListTitle($this->lng->txt("actions"));
474  $current_selection_list->setId("act_".$counter);
475 
476  $current_selection_list->addItem($this->lng->txt("edit"), '', $this->ctrl->getLinkTarget($this, "showAddressForm"));
477 
478  if ($mailing_allowed)
479  $current_selection_list->addItem($this->lng->txt("send_mail_to"), '', $this->ctrl->getLinkTarget($this, "mailToUsers"));
480 
481  $current_selection_list->addItem($this->lng->txt("delete"), '', $this->ctrl->getLinkTarget($this, "confirmDelete"));
482 
483  if ($chat_active)
484  $current_selection_list->addItem($this->lng->txt("invite_to_chat"), '', $this->ctrl->getLinkTarget($this, "inviteToChat"));
485 
486  $this->ctrl->clearParameters($this);
487 
488  $result[$counter]['COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
489  ++$counter;
490  }
491 
492  if ($mailing_allowed)
493  $tbl->addMultiCommand('mailToUsers', $this->lng->txt('send_mail_to'));
494 
495  $tbl->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
496 
497  if ($chat_active)
498  $tbl->addMultiCommand('inviteToChat', $this->lng->txt('invite_to_chat'));
499  }
500  else
501  {
502  $tbl->disable('header');
503  $tbl->disable('footer');
504 
505  $tbl->setNoEntriesText($this->lng->txt('mail_search_no'));
506  }
507 
508  $tbl->setData($result);
509 
510  $tbl->addCommandButton('showAddressForm', $this->lng->txt('add'));
511 
512  $this->tpl->setVariable('TABLE', $tbl->getHTML());
513 
514  $this->tpl->show();
515 
516  unset($_SESSION['addr_search']);
517 
518  return true;
519  }
520 
521 
530  public function inviteToChat()
531  {
532  global $ilUser, $lng, $ilCtrl, $tpl;
533 
534  $addr_ids = ( (int)$_GET['addr_id'] ) ?
535  array( (int)$_GET['addr_id'] ) :
536  $_POST['addr_id'];
537 
538  if( !$addr_ids )
539  {
540  ilUtil::sendInfo($lng->txt('chat_no_users_selected'), true);
542  $ilCtrl->getLinkTarget($this, 'showAddressbook', '', false, false)
543  );
544  exit;
545  }
546 
547  // store userdata for users without ilias login
548  $no_login = array();
549 
550  foreach( $addr_ids as $id )
551  {
552  $entry = $this->abook->getEntry($id);
553 
554  // if login-name available, user has a local account
555  if( !$entry['login'] )
556  {
557  $no_login[] = $id;
558  }
559  }
560 
561  if( count($no_login) )
562  {
563  $message .= $lng->txt('chat_users_without_login') . ':<br>';
564  $list = '';
565 
566  foreach( $no_login as $e )
567  {
568  $list .= '<li>' . $this->abook->entryToString($e) . '</li>';
569  }
570 
571  $message .= '<ul>';
572  $message .= $list;
573  $message .= '</ul>';
574 
575  ilUtil::sendInfo($message);
576  $this->showAddressbook();
577  exit;
578  }
579 
580  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
581 
582  $ilChatroom = new ilChatroom();
583  $chat_rooms = $ilChatroom->getAllRooms( $ilUser->getId() );
584  $subrooms = array();
585 
586  foreach( $chat_rooms as $room_id => $title)
587  {
588  $subrooms[] = $ilChatroom->getPrivateSubRooms( $room_id, $ilUser->getId() );
589  }
590 
591  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
592 
593  $form = new ilPropertyFormGUI();
594  $form->setTitle( $lng->txt("mail_invite_users_to_chat") );
595 
596  $psel = new ilSelectInputGUI( $lng->txt("chat_select_room"), 'room_id' );
597  $options = array();
598 
599  foreach( $chat_rooms as $room_id => $room )
600  {
601  $ref_id = $room_id;
602 
603  if( $ilChatroom->isUserBanned( $ilUser->getId() ) )
604  {
605  continue;
606  }
607 
608  $options[$ref_id] = $room;
609 
610  foreach( $subrooms as $subroom )
611  {
612  foreach( $subroom as $sub_id => $parent_id )
613  {
614  if( $parent_id == $ref_id )
615  {
617  $options[$ref_id . ',' . $sub_id] = '+&nbsp;' . $title;
618  }
619  }
620  }
621  }
622 
623  $psel->setOptions($options);
624  $form->addItem($psel);
625  $phidden = new ilHiddenInputGUI( 'addr_ids' );
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 ) );
631 
632  $tpl->setTitle( $lng->txt( 'mail_invite_users_to_chat' ) );
633  $tpl->setContent( $form->getHtml() );
634  $tpl->show();
635  }
636 
645  public function submitInvitation()
646  {
647  global $ilUser,$ilCtrl, $lng;
648 
649  if( !$_POST["addr_ids"] )
650  {
651  ilUtil::sendInfo( $lng->txt( 'chat_no_users_selected' ), true );
652  $this->showAddressbook();
653  exit;
654  }
655 
656  if( !$_POST["room_id"] )
657  {
658  ilUtil::sendInfo( $lng->txt( 'chat_no_room_selected' ), true );
659  $_POST['addr_id'] = explode( ',', $_POST["addr_ids"] );
660  $this->showAddressbook();
661  exit;
662  }
663 
664  // get selected users (comma seperated user id list)
665  $ids = explode( ',', $_POST["addr_ids"] );
666 
667  // get selected chatroom from POST-String, format: "room_id , scope"
668  $room_ids = explode( ',', $_POST['room_id'] );
669  $room_id = (int)$room_ids[0];
670  $scope = 0;
671 
672  if( count($room_ids) > 0 )
673  {
674  $scope = (int)$room_ids[1];
675  }
676 
677  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
678 
679  $room = ilChatroom::byRoomId( (int)$room_id, true );
680  $no_access = array();
681  $no_login = array();
682  $valid_users = array();
683 
684  foreach( $ids as $id )
685  {
686  $entry = $this->abook->getEntry($id);
687 
688  if( $entry['login'] )
689  {
690  $user_id = $ilUser->getUserIdByLogin($entry['login']);
691  $ref_id = $room->getRefIdByRoomId($room_id);
692 
693  if
694  (
695  !ilChatroom::checkPermissionsOfUser($user_id, 'read', $ref_id )
696  || $room->isUserBanned( $user_id )
697  )
698  {
699  $no_access[] = $id;
700  }
701  else
702  {
703  $valid_users[] = $user_id;
704  }
705  }
706  else
707  {
708  $no_login[] = $id;
709  }
710  }
711 
712  if( count( $no_access ) || count( $no_login ) )
713  {
714  $message = "";
715 
716  if( count($no_access) )
717  {
718  $message .= $lng->txt('chat_users_without_permission') . ':<br>';
719  $list = '';
720 
721  foreach( $no_access as $e )
722  {
723  $list .= '<li>'.$this->abook->entryToString($e).'</li>';
724  }
725 
726  $message .= '<ul>';
727  $message .= $list;
728  $message .= '</ul>';
729  }
730 
731  if( count( $no_login ) )
732  {
733  $message .= $lng->txt('chat_users_without_login') . ':<br>';
734  $list = '';
735 
736  foreach( $no_login as $e )
737  {
738  $list .= '<li>'.$this->abook->entryToString($e).'</li>';
739  }
740 
741  $message .= '<ul>';
742  $message .= $list;
743  $message .= '</ul>';
744  }
745 
746  ilUtil::sendInfo($message);
747  $_POST["addr_id"] = $ids;
748  $this->inviteToChat();
749  exit;
750  }
751 
752  $ref_id = $room->getRefIdByRoomId( $room_id );
753 
754  include_once 'classes/class.ilLink.php';
755 
756  $url = '';
757  if($scope)
758  {
759  $url = ilLink::_getStaticLink($ref_id, 'chta', true, '_'.$scope);
760  }
761  else
762  {
763  $url = ilLink::_getStaticLink($ref_id, 'chta');
764  }
765 
766  $link = '<p><a target="chatframe" href="'.$url.'">' .
767  $lng->txt('goto_invitation_chat') . '</a></p>';
768 
769  foreach( $valid_users as $id )
770  {
771  $room->inviteUserToPrivateRoom( $id, $scope );
772 
773  $room->sendInvitationNotification(
774  null, $ilUser->getId(), $id, (int)$scope, $url
775  );
776  }
777 
779  $lng->txt('chat_users_have_been_invited') . $userlist . $link, true
780  );
781  $link = $ilCtrl->getLinkTarget( $this, 'showAddressbook', '', false, false );
782  ilUtil::redirect( $link );
783  }
784 
785  public function lookupAddressbookAsync()
786  {
787  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
788  include_once 'Services/Contact/classes/class.ilMailAddressbook.php';
789 
790  $search = "%" . $_REQUEST["query"] . "%";
791  $result = new stdClass();
792  $result->response = new stdClass();
793  $result->response->results = array();
794 
795  if( !$search )
796  {
797  $result->response->total = 0;
799  exit;
800  }
801 
802  $mailAdrBookObj = new ilMailAddressbook;
803  $result = $mailAdrBookObj->getAddressbookAsync($search);
804 
806  exit;
807  }
808 
809  function showSubTabs()
810  {
811  if($this->tabs_gui->hasTabs())
812  {
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;
818  }
819  else
820  {
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'));
825  }
826  }
827 
828  function activateTab($a_id)
829  {
830  if($this->has_sub_tabs)
831  {
832  $this->tabs_gui->activateSubTab($a_id);
833  }
834  else
835  {
836  $this->tabs_gui->activateTab($a_id);
837  }
838  }
839 }
840 ?>