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"];
137 if(!
$_SESSION[
"mail_search_type_system"] &&
138 !
$_SESSION[
"mail_search_type_addressbook"])
140 $_SESSION[
"mail_search_type_system"] = 1;
141 $_SESSION[
"mail_search_type_addressbook"] = 1;
143 if (strlen(trim(
$_SESSION[
"mail_search_search"])) == 0)
147 else if(strlen(trim(
$_SESSION[
"mail_search_search"])) < 3)
149 $this->lng->loadLanguageModule(
'search');
162 if(
$_GET[
"ref"] !=
"wsp")
165 $title = $this->lng->txt(
'search_recipients');
169 $this->lng->loadLanguageModule(
"wsp");
170 $title = $this->lng->txt(
"wsp_share_search_users");
174 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
177 $form->setId(
'search_rcp');
178 $form->setFormAction($ilCtrl->getFormAction($this,
'search'));
180 $inp =
new ilTextInputGUI($this->lng->txt(
"search_for"),
'search');
182 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
186 $form->addItem($inp);
188 $chb =
new ilCheckboxInputGUI($this->lng->txt(
"mail_search_addressbook"),
'type_addressbook');
189 if (
$_SESSION[
'mail_search_type_addressbook'])
191 $inp->addSubItem($chb);
194 if (
$_SESSION[
'mail_search_type_system'])
196 $inp->addSubItem($chb);
198 $form->addCommandButton(
'search', $this->lng->txt(
"search"));
199 $form->addCommandButton(
'cancel', $this->lng->txt(
"cancel"));
206 global $rbacsystem,
$lng, $ilUser,
$ilCtrl, $rbacreview;
210 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_search.html",
"Services/Contact");
211 $this->tpl->setTitle($this->lng->txt(
"mail"));
213 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
215 $this->tpl->setVariable(
'SEARCHFORM', $form->getHtml());
217 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
222 if (!
$_SESSION[
'mail_search_type_system'] && !
$_SESSION[
'mail_search_type_addressbook'])
224 $this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
228 if (
$_SESSION[
'mail_search_type_addressbook']) $this->tpl->setVariable(
'CHECKED_TYPE_ADDRESSBOOK',
"checked=\"checked\"");
229 if (
$_SESSION[
'mail_search_type_system'])$this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
232 if (
$_SESSION[
'mail_search_type_addressbook'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
238 if(
$_GET[
"ref"] ==
"wsp")
240 foreach($entries as $idx => $entry)
244 unset($entries[$idx]);
252 $tbl_addr->setTitle($lng->txt(
'mail_addressbook'));
253 $tbl_addr->setRowTemplate(
'tpl.mail_search_addr_row.html',
'Services/Contact');
257 foreach ($entries as $entry)
259 if(
$_GET[
"ref"] !=
"wsp")
261 $result[$counter][
'check'] =
ilUtil::formCheckbox(0,
'search_name_to_addr[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
262 ilUtil::formCheckbox(0,
'search_name_cc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
263 ilUtil::formCheckbox(0,
'search_name_bcc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email']));
271 $result[$counter][
'login'] = $entry[
'login'];
272 $result[$counter][
'firstname'] = $entry[
'firstname'];
273 $result[$counter][
'lastname'] = $entry[
'lastname'];
278 $has_mail_addr =
true;
279 $result[$counter][
'email'] = $entry[
'email'];
285 if(
$_GET[
"ref"] !=
"wsp")
287 $tbl_addr->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
291 $tbl_addr->addColumn(
"",
"",
"1%");
293 $tbl_addr->addColumn($this->lng->txt(
'login'),
'login',
"15%");
294 $tbl_addr->addColumn($this->lng->txt(
'firstname'),
'firstname',
"15%");
295 $tbl_addr->addColumn($this->lng->txt(
'lastname'),
'lastname',
"15%");
298 foreach (
$result as $key => $val)
300 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
303 $tbl_addr->addColumn($this->lng->txt(
'email'),
'email',
"15%");
307 $tbl_addr->setDefaultOrderField(
'login');
308 $tbl_addr->setPrefix(
'addr_');
309 $tbl_addr->enable(
'select_all');
310 $tbl_addr->setSelectAllCheckbox(
'search_name_to_addr');
311 $tbl_addr->setFormName(
'recipients');
313 $this->tpl->setVariable(
'TABLE_ADDR', $tbl_addr->getHTML());
316 if (
$_SESSION[
'mail_search_type_system'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
318 include_once
'Services/Search/classes/class.ilQueryParser.php';
319 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
320 include_once
'Services/Search/classes/class.ilSearchResult.php';
326 $query_parser->setMinWordLength(3);
327 $query_parser->parse();
330 $user_search->enableActiveCheck(
true);
331 $user_search->setFields(array(
'login'));
332 $result_obj = $user_search->performSearch();
333 $all_results->mergeEntries($result_obj);
335 $user_search->setFields(array(
'firstname'));
336 $result_obj = $user_search->performSearch();
337 $all_results->mergeEntries($result_obj);
339 $user_search->setFields(array(
'lastname'));
340 $result_obj = $user_search->performSearch();
341 $all_results->mergeEntries($result_obj);
343 $all_results->setMaxHits(100000);
344 $all_results->preventOverwritingMaxhits(
true);
351 include_once
'./Services/User/classes/class.ilUserFilter.php';
358 $tbl_users->setTitle($lng->txt(
'system').
': '.$lng->txt(
'persons'));
359 $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html',
'Services/Contact');
363 foreach ($users as $user)
367 if(
$_GET[
"ref"] !=
"wsp")
377 $result[$counter][
'login'] = $login;
382 $result[$counter][
'firstname'] = $name[
'firstname'];
383 $result[$counter][
'lastname'] = $name[
'lastname'];
387 $result[$counter][
'firstname'] =
'';
388 $result[$counter][
'lastname'] =
'';
393 $has_mail_usr =
true;
400 if(
$_GET[
"ref"] !=
"wsp")
402 $tbl_users->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
406 $tbl_users->addColumn(
"",
"",
"1%");
408 $tbl_users->addColumn($this->lng->txt(
'login'),
'login',
'15%');
409 $tbl_users->addColumn($this->lng->txt(
'firstname'),
'firstname',
'15%');
410 $tbl_users->addColumn($this->lng->txt(
'lastname'),
'lastname',
'15%');
411 if ($has_mail_usr ==
true)
413 foreach (
$result as $key => $val)
415 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
418 $tbl_users->addColumn($this->lng->txt(
'email'),
'email',
'15%');
422 $tbl_users->setDefaultOrderField(
'login');
423 $tbl_users->setPrefix(
'usr_');
424 $tbl_users->enable(
'select_all');
425 $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
426 $tbl_users->setFormName(
'recipients');
428 $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
436 $tbl_grp->setTitle($lng->txt(
'system').
': '.$lng->txt(
'groups'));
437 $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html',
'Services/Contact');
443 foreach ($groups as $grp)
445 if(
$_GET[
"ref"] !=
"wsp")
448 $roles = $rbacreview->getAssignableChildRoles($grp[
'ref_id']);
449 foreach ($roles as $role)
451 if (substr($role[
'title'], 0, 14) ==
'il_grp_member_' ||
452 substr($role[
'title'], 0, 13) ==
'il_grp_admin_')
457 array_push($members,
'#'.$role[
'title']);
460 $str_members = implode(
',',$members);
470 $result[$counter][
'title'] = $grp[
'title'];
471 $result[$counter][
'description'] = $grp[
'description'];
477 if(
$_GET[
"ref"] !=
"wsp")
479 $tbl_grp->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
483 $tbl_grp->addColumn(
"",
"",
"1%");
485 $tbl_grp->addColumn($this->lng->txt(
'title'),
'title',
'15%');
486 $tbl_grp->addColumn($this->lng->txt(
'description'),
'description',
'15%');
488 $tbl_grp->setDefaultOrderField(
'title');
489 $tbl_grp->setPrefix(
'grp_');
490 $tbl_grp->enable(
'select_all');
491 $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
492 $tbl_grp->setFormName(
'recipients');
494 $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
498 if (count($users) || count($groups) || count($entries))
501 $this->tpl->setVariable(
"ALT_ARROW",
'');
503 if(
$_GET[
"ref"] !=
"wsp")
505 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'adopt'));
509 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'wsp_share_with_users'));
512 else if (strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
514 $this->lng->loadLanguageModule(
'search');
518 if(
$_GET[
"ref"] !=
"wsp")
526 if(!is_array($a_obj_ids))
528 $a_obj_ids = array($a_obj_ids);
531 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
533 foreach($a_obj_ids as $object_id)
535 if(!in_array($object_id, $existing))
537 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);