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 include_once
'Services/Table/classes/class.ilTable2GUI.php';
46 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
55 $this->wsp_access_handler = $wsp_access_handler;
56 $this->wsp_node_id = $wsp_node_id;
58 $this->ctrl->saveParameter($this,
"mobj_id");
59 $this->ctrl->saveParameter($this,
"ref");
66 $forward_class = $this->ctrl->getNextClass($this);
67 switch($forward_class)
70 if (!(
$cmd = $this->ctrl->getCmd()))
84 $recipients = array();
85 $recipients = array_merge($recipients, (array)
$_POST[
'search_name_to_addr']);
86 $recipients = array_merge($recipients, (array)$_POST[
'search_name_to_usr']);
87 $recipients = array_merge($recipients, (array)$_POST[
'search_name_to_grp']);
89 $recipients = array_unique($recipients);
91 $_SESSION[
"mail_search_results_to"] = $recipients;
92 $_SESSION[
"mail_search_results_cc"] = $_POST[
"search_name_cc"];
93 $_SESSION[
"mail_search_results_bcc"] = $_POST[
"search_name_bcc"];
95 if(
$_GET[
"ref"] !=
"wsp")
104 $this->ctrl->returnToParent($this);
109 $mail_data = $this->umail->getSavedData();
111 $this->umail->savePostData(
112 $mail_data[
"user_id"],
113 $mail_data[
"attachments"],
114 $mail_data[
"rcp_to"],
115 $mail_data[
"rcp_cc"],
116 $mail_data[
"rcp_bcc"],
117 $mail_data[
"m_type"],
118 $mail_data[
"m_email"],
119 $mail_data[
"m_subject"],
120 $mail_data[
"m_message"],
121 $mail_data[
"use_placeholders"]
127 $this->ctrl->returnToParent($this);
134 $_SESSION[
"mail_search_type_addressbook"] =
$_POST[
"type_addressbook"];
136 if (strlen(trim(
$_SESSION[
"mail_search_search"])) == 0)
140 else if(strlen(trim(
$_SESSION[
"mail_search_search"])) < 3)
142 $this->lng->loadLanguageModule(
'search');
155 if(
$_GET[
"ref"] !=
"wsp")
158 $title = $this->lng->txt(
'search_recipients');
162 $this->lng->loadLanguageModule(
"wsp");
163 $title = $this->lng->txt(
"wsp_share_search_users");
167 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
170 $form->setId(
'search_rcp');
171 $form->setFormAction($ilCtrl->getFormAction($this,
'search'));
173 $inp =
new ilTextInputGUI($this->lng->txt(
"search_for"),
'search');
175 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
179 $form->addItem($inp);
181 $chb =
new ilCheckboxInputGUI($this->lng->txt(
"mail_search_addressbook"),
'type_addressbook');
182 if (
$_SESSION[
'mail_search_type_addressbook'])
184 $inp->addSubItem($chb);
187 if (
$_SESSION[
'mail_search_type_system'])
189 $inp->addSubItem($chb);
191 $form->addCommandButton(
'search', $this->lng->txt(
"search"));
192 $form->addCommandButton(
'cancel', $this->lng->txt(
"cancel"));
203 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_search.html",
"Services/Contact");
204 $this->tpl->setTitle($this->lng->txt(
"mail"));
206 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
208 $this->tpl->setVariable(
'SEARCHFORM', $form->getHtml());
211 if(strlen(
$_SESSION[
'mail_search_search']) < 3)
213 if(
$_GET[
"ref"] !=
"wsp")
220 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
225 if (
$_SESSION[
'mail_search_type_addressbook']) $this->tpl->setVariable(
'CHECKED_TYPE_ADDRESSBOOK',
"checked=\"checked\"");
226 if (
$_SESSION[
'mail_search_type_system'])$this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
228 if (
$_SESSION[
'mail_search_type_addressbook'] == NULL &&
$_SESSION[
'mail_search_type_system'] == NULL)
230 $this->lng->loadLanguageModule(
'search');
234 if (
$_SESSION[
'mail_search_type_addressbook'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
240 if(
$_GET[
"ref"] ==
"wsp")
242 foreach($entries as $idx => $entry)
246 unset($entries[$idx]);
254 $tbl_addr->setTitle($lng->txt(
'mail_addressbook'));
255 $tbl_addr->setRowTemplate(
'tpl.mail_search_addr_row.html',
'Services/Contact');
259 foreach ($entries as $entry)
261 if(
$_GET[
"ref"] !=
"wsp")
263 $result[$counter][
'check'] =
ilUtil::formCheckbox(0,
'search_name_to_addr[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
264 ilUtil::formCheckbox(0,
'search_name_cc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
265 ilUtil::formCheckbox(0,
'search_name_bcc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email']));
273 $result[$counter][
'login'] = $entry[
'login'];
274 $result[$counter][
'firstname'] = $entry[
'firstname'];
275 $result[$counter][
'lastname'] = $entry[
'lastname'];
280 $has_mail_addr =
true;
281 $result[$counter][
'email'] = $entry[
'email'];
287 if(
$_GET[
"ref"] !=
"wsp")
289 $tbl_addr->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
293 $tbl_addr->addColumn(
"",
"",
"1%");
295 $tbl_addr->addColumn($this->lng->txt(
'login'),
'login',
"15%");
296 $tbl_addr->addColumn($this->lng->txt(
'firstname'),
'firstname',
"15%");
297 $tbl_addr->addColumn($this->lng->txt(
'lastname'),
'lastname',
"15%");
300 foreach (
$result as $key => $val)
302 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
305 $tbl_addr->addColumn($this->lng->txt(
'email'),
'email',
"15%");
309 $tbl_addr->setDefaultOrderField(
'login');
310 $tbl_addr->setPrefix(
'addr_');
311 $tbl_addr->enable(
'select_all');
312 $tbl_addr->setSelectAllCheckbox(
'search_name_to_addr');
313 $tbl_addr->setFormName(
'recipients');
315 $this->tpl->setVariable(
'TABLE_ADDR', $tbl_addr->getHTML());
318 if (
$_SESSION[
'mail_search_type_system'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
320 include_once
'Services/Search/classes/class.ilQueryParser.php';
321 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
322 include_once
'Services/Search/classes/class.ilSearchResult.php';
328 $query_parser->setMinWordLength(3);
329 $query_parser->parse();
332 $user_search->enableActiveCheck(
true);
333 $user_search->setFields(array(
'login'));
334 $result_obj = $user_search->performSearch();
335 $all_results->mergeEntries($result_obj);
337 $user_search->setFields(array(
'firstname'));
338 $result_obj = $user_search->performSearch();
339 $all_results->mergeEntries($result_obj);
341 $user_search->setFields(array(
'lastname'));
342 $result_obj = $user_search->performSearch();
343 $all_results->mergeEntries($result_obj);
345 $all_results->setMaxHits(100000);
346 $all_results->preventOverwritingMaxhits(
true);
347 $all_results->filter(ROOT_FOLDER_ID,
true);
353 include_once
'./Services/User/classes/class.ilUserFilter.php';
360 $tbl_users->setTitle($lng->txt(
'system').
': '.$lng->txt(
'persons'));
361 $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html',
'Services/Contact');
365 foreach ($users as $user)
369 if(
$_GET[
"ref"] !=
"wsp")
379 $result[$counter][
'login'] = $login;
384 $result[$counter][
'firstname'] = $name[
'firstname'];
385 $result[$counter][
'lastname'] = $name[
'lastname'];
389 $result[$counter][
'firstname'] =
'';
390 $result[$counter][
'lastname'] =
'';
395 $has_mail_usr =
true;
402 if(
$_GET[
"ref"] !=
"wsp")
404 $tbl_users->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
408 $tbl_users->addColumn(
"",
"",
"1%");
410 $tbl_users->addColumn($this->lng->txt(
'login'),
'login',
'15%');
411 $tbl_users->addColumn($this->lng->txt(
'firstname'),
'firstname',
'15%');
412 $tbl_users->addColumn($this->lng->txt(
'lastname'),
'lastname',
'15%');
413 if ($has_mail_usr ==
true)
415 foreach (
$result as $key => $val)
417 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
420 $tbl_users->addColumn($this->lng->txt(
'email'),
'email',
'15%');
424 $tbl_users->setDefaultOrderField(
'login');
425 $tbl_users->setPrefix(
'usr_');
426 $tbl_users->enable(
'select_all');
427 $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
428 $tbl_users->setFormName(
'recipients');
430 $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
433 include_once
'Services/Search/classes/class.ilQueryParser.php';
434 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
435 include_once
'Services/Search/classes/class.ilSearchResult.php';
436 include_once
'Services/Membership/classes/class.ilParticipants.php';
442 $query_parser->setMinWordLength(3);
443 $query_parser->parse();
446 $search->setFilter(array(
'grp'));
447 $result = $search->performSearch();
448 $group_results->mergeEntries(
$result);
449 $group_results->setMaxHits(PHP_INT_MAX);
450 $group_results->preventOverwritingMaxhits(
true);
451 $group_results->setRequiredPermission(
'read');
452 $group_results->filter(ROOT_FOLDER_ID,
true);
454 $visible_groups = array();
455 if($group_results->getResults())
458 $tbl_grp->setTitle($lng->txt(
'system').
': '.$lng->txt(
'groups'));
459 $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html',
'Services/Contact');
464 $ilObjDataCache->preloadReferenceCache(array_keys($group_results->getResults()));
466 $groups = $group_results->getResults();
467 foreach ($groups as $grp)
474 if(
$_GET[
"ref"] !=
"wsp")
477 $roles = $rbacreview->getAssignableChildRoles($grp[
'ref_id']);
478 foreach ($roles as $role)
480 if (substr($role[
'title'], 0, 14) ==
'il_grp_member_' ||
481 substr($role[
'title'], 0, 13) ==
'il_grp_admin_')
486 array_push($members,
'#'.$role[
'title']);
489 $str_members = implode(
',',$members);
499 $result[$counter][
'title'] = $ilObjDataCache->lookupTitle($grp[
'obj_id']);
500 $result[$counter][
'description'] = $ilObjDataCache->lookupDescription($grp[
'obj_id']);
501 $visible_groups[] = $grp;
509 if(
$_GET[
"ref"] !=
"wsp")
511 $tbl_grp->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
515 $tbl_grp->addColumn(
"",
"",
"1%");
517 $tbl_grp->addColumn($this->lng->txt(
'title'),
'title',
'15%');
518 $tbl_grp->addColumn($this->lng->txt(
'description'),
'description',
'15%');
520 $tbl_grp->setDefaultOrderField(
'title');
521 $tbl_grp->setPrefix(
'grp_');
522 $tbl_grp->enable(
'select_all');
523 $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
524 $tbl_grp->setFormName(
'recipients');
526 $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
531 if (count($users) || count($visible_groups) || count($entries))
534 $this->tpl->setVariable(
"ALT_ARROW",
'');
536 if(
$_GET[
"ref"] !=
"wsp")
538 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'adopt'));
542 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'wsp_share_with_users'));
545 else if (strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3
546 && (
$_SESSION[
'mail_search_type_addressbook'] != NULL ||
$_SESSION[
'mail_search_type_system'] != NULL))
548 $this->lng->loadLanguageModule(
'search');
552 if(
$_GET[
"ref"] !=
"wsp")
560 if(!is_array($a_obj_ids))
562 $a_obj_ids = array($a_obj_ids);
565 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
567 foreach($a_obj_ids as $object_id)
569 if(!in_array($object_id, $existing))
571 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);