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';
54 $this->ctrl->saveParameter($this,
"mobj_id");
61 $forward_class = $this->ctrl->getNextClass($this);
62 switch($forward_class)
65 if (!(
$cmd = $this->ctrl->getCmd()))
79 $recipients = array();
80 $recipients = array_merge($recipients, (array)
$_POST[
'search_name_to_addr']);
81 $recipients = array_merge($recipients, (array)$_POST[
'search_name_to_usr']);
82 $recipients = array_merge($recipients, (array)$_POST[
'search_name_to_grp']);
84 $recipients = array_unique($recipients);
86 $_SESSION[
"mail_search_results_to"] = $recipients;
87 $_SESSION[
"mail_search_results_cc"] = $_POST[
"search_name_cc"];
88 $_SESSION[
"mail_search_results_bcc"] = $_POST[
"search_name_bcc"];
92 $this->ctrl->returnToParent($this);
97 $mail_data = $this->umail->getSavedData();
99 $this->umail->savePostData(
100 $mail_data[
"user_id"],
101 $mail_data[
"attachments"],
102 $mail_data[
"rcp_to"],
103 $mail_data[
"rcp_cc"],
104 $mail_data[
"rcp_bcc"],
105 $mail_data[
"m_type"],
106 $mail_data[
"m_email"],
107 $mail_data[
"m_subject"],
108 $mail_data[
"m_message"],
109 $mail_data[
"use_placeholders"]
115 $this->ctrl->returnToParent($this);
122 $_SESSION[
"mail_search_type_addressbook"] =
$_POST[
"type_addressbook"];
125 if(!
$_SESSION[
"mail_search_type_system"] &&
126 !
$_SESSION[
"mail_search_type_addressbook"])
128 $_SESSION[
"mail_search_type_system"] = 1;
129 $_SESSION[
"mail_search_type_addressbook"] = 1;
131 if (strlen(trim(
$_SESSION[
"mail_search_search"])) == 0)
135 else if(strlen(trim(
$_SESSION[
"mail_search_search"])) < 3)
137 $this->lng->loadLanguageModule(
'search');
148 global $rbacsystem,
$lng, $ilUser,
$ilCtrl, $rbacreview;
152 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_search.html",
"Services/Contact");
153 $this->tpl->setVariable(
"HEADER", $this->lng->txt(
"mail"));
155 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
157 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
159 $form->setTitle($this->lng->txt(
'search_recipients'));
160 $form->setId(
'search_rcp');
161 $form->setFormAction($ilCtrl->getFormAction($this,
'search'));
163 $inp =
new ilTextInputGUI($this->lng->txt(
"search_for"),
'search');
165 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
169 $form->addItem($inp);
171 $chb =
new ilCheckboxInputGUI($this->lng->txt(
"mail_search_addressbook"),
'type_addressbook');
172 if (
$_SESSION[
'mail_search_type_addressbook'])
174 $inp->addSubItem($chb);
177 if (
$_SESSION[
'mail_search_type_system'])
179 $inp->addSubItem($chb);
181 $form->addCommandButton(
'search', $this->lng->txt(
"search"));
182 $form->addCommandButton(
'cancel', $this->lng->txt(
"cancel"));
184 $this->tpl->setVariable(
'SEARCHFORM', $form->getHtml());
187 if (strlen(trim(
$_SESSION[
"mail_search_search"])) > 0)
192 if (!
$_SESSION[
'mail_search_type_system'] && !
$_SESSION[
'mail_search_type_addressbook'])
194 $this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
198 if (
$_SESSION[
'mail_search_type_addressbook']) $this->tpl->setVariable(
'CHECKED_TYPE_ADDRESSBOOK',
"checked=\"checked\"");
199 if (
$_SESSION[
'mail_search_type_system'])$this->tpl->setVariable(
'CHECKED_TYPE_SYSTEM',
"checked=\"checked\"");
202 if (
$_SESSION[
'mail_search_type_addressbook'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
210 $tbl_addr->setTitle($lng->txt(
'mail_addressbook'));
211 $tbl_addr->setRowTemplate(
'tpl.mail_search_addr_row.html',
'Services/Contact');
215 foreach ($entries as $entry)
217 $result[$counter][
'check'] =
ilUtil::formCheckbox(0,
'search_name_to_addr[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
218 ilUtil::formCheckbox(0,
'search_name_cc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email'])) .
219 ilUtil::formCheckbox(0,
'search_name_bcc[]', ($entry[
'login'] ? $entry[
'login'] : $entry[
'email']));
220 $result[$counter][
'login'] = $entry[
'login'];
221 $result[$counter][
'firstname'] = $entry[
'firstname'];
222 $result[$counter][
'lastname'] = $entry[
'lastname'];
227 $has_mail_addr =
true;
228 $result[$counter][
'email'] = $entry[
'email'];
234 $tbl_addr->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
235 $tbl_addr->addColumn($this->lng->txt(
'login'),
'login',
"15%");
236 $tbl_addr->addColumn($this->lng->txt(
'firstname'),
'firstname',
"15%");
237 $tbl_addr->addColumn($this->lng->txt(
'lastname'),
'lastname',
"15%");
240 foreach (
$result as $key => $val)
242 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
245 $tbl_addr->addColumn($this->lng->txt(
'email'),
'email',
"15%");
249 $tbl_addr->setDefaultOrderField(
'login');
250 $tbl_addr->setPrefix(
'addr_');
251 $tbl_addr->enable(
'select_all');
252 $tbl_addr->setSelectAllCheckbox(
'search_name_to_addr');
253 $tbl_addr->setFormName(
'recipients');
255 $this->tpl->setVariable(
'TABLE_ADDR', $tbl_addr->getHTML());
258 if (
$_SESSION[
'mail_search_type_system'] && strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
260 include_once
'Services/Search/classes/class.ilQueryParser.php';
261 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
262 include_once
'Services/Search/classes/class.ilSearchResult.php';
268 $query_parser->setMinWordLength(3);
269 $query_parser->parse();
272 $user_search->enableActiveCheck(
true);
273 $user_search->setFields(array(
'login'));
274 $result_obj = $user_search->performSearch();
275 $all_results->mergeEntries($result_obj);
277 $user_search->setFields(array(
'firstname'));
278 $result_obj = $user_search->performSearch();
279 $all_results->mergeEntries($result_obj);
281 $user_search->setFields(array(
'lastname'));
282 $result_obj = $user_search->performSearch();
283 $all_results->mergeEntries($result_obj);
285 $all_results->setMaxHits(100000);
286 $all_results->preventOverwritingMaxhits(
true);
293 include_once
'./Services/User/classes/class.ilUserFilter.php';
300 $tbl_users->setTitle($lng->txt(
'system').
': '.$lng->txt(
'persons'));
301 $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html',
'Services/Contact');
305 foreach ($users as
$user)
312 $result[$counter][
'login'] = $login;
317 $result[$counter][
'firstname'] = $name[
'firstname'];
318 $result[$counter][
'lastname'] = $name[
'lastname'];
322 $result[$counter][
'firstname'] =
'';
323 $result[$counter][
'lastname'] =
'';
328 $has_mail_usr =
true;
335 $tbl_users->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
336 $tbl_users->addColumn($this->lng->txt(
'login'),
'login',
'15%');
337 $tbl_users->addColumn($this->lng->txt(
'firstname'),
'firstname',
'15%');
338 $tbl_users->addColumn($this->lng->txt(
'lastname'),
'lastname',
'15%');
339 if ($has_mail_usr ==
true)
341 foreach (
$result as $key => $val)
343 if ($val[
'email'] ==
'')
$result[$key][
'email'] =
' ';
346 $tbl_users->addColumn($this->lng->txt(
'email'),
'email',
'15%');
350 $tbl_users->setDefaultOrderField(
'login');
351 $tbl_users->setPrefix(
'usr_');
352 $tbl_users->enable(
'select_all');
353 $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
354 $tbl_users->setFormName(
'recipients');
356 $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
364 $tbl_grp->setTitle($lng->txt(
'system').
': '.$lng->txt(
'groups'));
365 $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html',
'Services/Contact');
371 foreach ($groups as $grp)
374 $roles = $rbacreview->getAssignableChildRoles($grp[
'ref_id']);
375 foreach ($roles as $role)
377 if (substr($role[
'title'], 0, 14) ==
'il_grp_member_' ||
378 substr($role[
'title'], 0, 13) ==
'il_grp_admin_')
383 array_push($members,
'#'.$role[
'title']);
386 $str_members = implode(
',',$members);
391 $result[$counter][
'title'] = $grp[
'title'];
392 $result[$counter][
'description'] = $grp[
'description'];
398 $tbl_grp->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
399 $tbl_grp->addColumn($this->lng->txt(
'title'),
'title',
'15%');
400 $tbl_grp->addColumn($this->lng->txt(
'description'),
'description',
'15%');
402 $tbl_grp->setDefaultOrderField(
'title');
403 $tbl_grp->setPrefix(
'grp_');
404 $tbl_grp->enable(
'select_all');
405 $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
406 $tbl_grp->setFormName(
'recipients');
408 $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
412 if (count($users) || count($groups) || count($entries))
415 $this->tpl->setVariable(
"ALT_ARROW",
'');
416 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'adopt'));
418 else if (strlen(trim(
$_SESSION[
"mail_search_search"])) >= 3)
420 $this->lng->loadLanguageModule(
'search');