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 include_once
'Services/Table/classes/class.ilTable2GUI.php';
28 include_once
'Services/Search/classes/class.ilQueryParser.php';
29 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
30 include_once
'Services/Search/classes/class.ilSearchResult.php';
69 public function __construct($wsp_access_handler = null, $wsp_node_id = null)
73 $this->tpl = $DIC[
'tpl'];
74 $this->ctrl = $DIC[
'ilCtrl'];
75 $this->lng = $DIC[
'lng'];
76 $this->rbacreview = $DIC[
'rbacreview'];
77 $this->object_data_cache = $DIC[
'ilObjDataCache'];
80 $this->wsp_access_handler = $wsp_access_handler;
81 $this->wsp_node_id = $wsp_node_id;
83 $this->ctrl->saveParameter($this,
"mobj_id");
84 $this->ctrl->saveParameter($this,
"ref");
91 $forward_class = $this->ctrl->getNextClass($this);
92 switch ($forward_class) {
94 if (!($cmd = $this->ctrl->getCmd())) {
107 $recipients = array();
108 $recipients = array_merge($recipients, (array)
$_POST[
'search_name_to_addr']);
109 $recipients = array_merge($recipients, (array) $_POST[
'search_name_to_usr']);
110 $recipients = array_merge($recipients, (array) $_POST[
'search_name_to_grp']);
112 $recipients = array_unique($recipients);
114 $_SESSION[
"mail_search_results_to"] = $recipients;
115 $_SESSION[
"mail_search_results_cc"] = $_POST[
"search_name_cc"];
116 $_SESSION[
"mail_search_results_bcc"] = $_POST[
"search_name_bcc"];
118 if (
$_GET[
"ref"] !=
"wsp") {
124 $this->ctrl->returnToParent($this);
129 $mail_data = $this->umail->getSavedData();
131 $this->umail->savePostData(
132 $mail_data[
"user_id"],
133 $mail_data[
"attachments"],
134 $mail_data[
"rcp_to"],
135 $mail_data[
"rcp_cc"],
136 $mail_data[
"rcp_bcc"],
137 $mail_data[
"m_email"],
138 $mail_data[
"m_subject"],
139 $mail_data[
"m_message"],
140 $mail_data[
"use_placeholders"],
141 $mail_data[
'tpl_ctx_id'],
142 $mail_data[
'tpl_ctx_params']
148 $this->ctrl->returnToParent($this);
155 if (strlen(trim(
$_SESSION[
"mail_search_search"])) == 0) {
157 } elseif (strlen(trim(
$_SESSION[
"mail_search_search"])) < 3) {
158 $this->lng->loadLanguageModule(
'search');
169 if (
$_GET[
"ref"] !=
"wsp") {
171 $title = $this->lng->txt(
'search_recipients');
173 $this->lng->loadLanguageModule(
"wsp");
174 $title = $this->lng->txt(
"wsp_share_search_users");
178 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
180 $form->setTitle($title);
181 $form->setId(
'search_rcp');
182 $form->setFormAction($this->ctrl->getFormAction($this,
'search'));
184 $inp =
new ilTextInputGUI($this->lng->txt(
"search_for"),
'search');
186 $dsDataLink = $this->ctrl->getLinkTarget($this,
'lookupRecipientAsync',
'',
true,
false);
187 $inp->setDataSource($dsDataLink);
190 isset(
$_SESSION[
"mail_search_search"]) &&
191 is_string(
$_SESSION[
"mail_search_search"]) &&
192 strlen(trim(
$_SESSION[
"mail_search_search"])) > 0
196 $form->addItem($inp);
198 $form->addCommandButton(
'search', $this->lng->txt(
"search"));
199 $form->addCommandButton(
'cancel', $this->lng->txt(
"cancel"));
206 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
207 include_once
'Services/Mail/classes/class.ilMailForm.php';
208 include_once
'Services/Utilities/classes/class.ilStr.php';
211 if (isset(
$_GET[
"term"]) && is_string(
$_GET[
"term"])) {
212 $search =
$_GET[
"term"];
214 if (isset(
$_POST[
"term"]) && is_string(
$_POST[
"term"])) {
218 $search = trim($search);
228 $quoted = str_replace(
'%',
'\%', $quoted);
229 $quoted = str_replace(
'_',
'\_', $quoted);
231 $search_recipients = (
$_GET[
"ref"] !=
"wsp");
245 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.mail_search.html",
"Services/Contact");
246 $this->tpl->setVariable(
"ACTION", $this->ctrl->getFormAction($this));
247 $this->tpl->setTitle($this->lng->txt(
"mail"));
248 $this->tpl->setVariable(
'SEARCHFORM', $form->getHtml());
252 !isset(
$_SESSION[
"mail_search_search"]) ||
253 !is_string(
$_SESSION[
"mail_search_search"]) ||
254 strlen(trim(
$_SESSION[
"mail_search_search"])) < 3
256 if (
$_GET[
"ref"] !=
"wsp") {
257 $this->tpl->printToStdout();
262 require_once
'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
264 if (count($relations)) {
269 $query_parser->setMinWordLength(3);
270 $query_parser->parse();
273 $user_search->enableActiveCheck(
true);
274 $user_search->setFields(array(
'login'));
275 $result_obj = $user_search->performSearch();
276 $contacts_search_result->mergeEntries($result_obj);
278 $user_search->setFields(array(
'firstname'));
279 $result_obj = $user_search->performSearch();
280 $contacts_search_result->mergeEntries($result_obj);
282 $user_search->setFields(array(
'lastname'));
283 $result_obj = $user_search->performSearch();
284 $contacts_search_result->mergeEntries($result_obj);
286 $contacts_search_result->setMaxHits(100000);
287 $contacts_search_result->preventOverwritingMaxhits(
true);
288 $contacts_search_result->filter(ROOT_FOLDER_ID,
true);
291 include_once
'Services/User/classes/class.ilUserFilter.php';
293 $users = array_intersect($users, $relations->getKeys());
296 $tbl_contacts->setTitle($this->lng->txt(
'mail_addressbook'));
297 $tbl_contacts->setRowTemplate(
'tpl.mail_search_addr_row.html',
'Services/Contact');
299 $has_mail_addr =
false;
302 foreach ($users as $user) {
305 if (
$_GET[
'ref'] ==
'wsp') {
316 $has_mail_addr =
true;
325 $result[$counter][
'firstname'] =
'';
326 $result[$counter][
'lastname'] =
'';
332 if (
$_GET[
'ref'] ==
'wsp') {
333 $tbl_contacts->addColumn(
"",
"",
"1%",
true);
335 $tbl_contacts->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
337 $tbl_contacts->addColumn($this->lng->txt(
'login'),
'login',
'15%');
338 $tbl_contacts->addColumn($this->lng->txt(
'firstname'),
'firstname',
'15%');
339 $tbl_contacts->addColumn($this->lng->txt(
'lastname'),
'lastname',
'15%');
340 if ($has_mail_addr) {
341 foreach (
$result as $key => $val) {
342 if ($val[
'email'] ==
'') {
343 $result[$key][
'email'] =
' ';
347 $tbl_contacts->addColumn($this->lng->txt(
'email'),
'email',
"15%");
349 $tbl_contacts->setData(
$result);
351 $tbl_contacts->setDefaultOrderField(
'login');
352 $tbl_contacts->setPrefix(
'addr_');
353 $tbl_contacts->enable(
'select_all');
354 $tbl_contacts->setSelectAllCheckbox(
'search_name_to_addr');
355 $tbl_contacts->setFormName(
'recipients');
357 $this->tpl->setVariable(
'TABLE_ADDR', $tbl_contacts->getHTML());
364 $query_parser->setMinWordLength(3);
365 $query_parser->parse();
368 $user_search->enableActiveCheck(
true);
369 $user_search->setFields(array(
'login'));
370 $result_obj = $user_search->performSearch();
371 $all_results->mergeEntries($result_obj);
373 $user_search->setFields(array(
'firstname'));
374 $result_obj = $user_search->performSearch();
375 $all_results->mergeEntries($result_obj);
377 $user_search->setFields(array(
'lastname'));
378 $result_obj = $user_search->performSearch();
379 $all_results->mergeEntries($result_obj);
381 $all_results->setMaxHits(100000);
382 $all_results->preventOverwritingMaxhits(
true);
383 $all_results->filter(ROOT_FOLDER_ID,
true);
386 include_once
'Services/User/classes/class.ilUserFilter.php';
390 $tbl_users->setTitle($this->lng->txt(
'system') .
': ' . $this->lng->txt(
'persons'));
391 $tbl_users->setRowTemplate(
'tpl.mail_search_users_row.html',
'Services/Contact');
395 foreach ($users as $user) {
398 if (
$_GET[
"ref"] !=
"wsp") {
412 $result[$counter][
'firstname'] =
'';
413 $result[$counter][
'lastname'] =
'';
417 $has_mail_usr =
true;
424 if (
$_GET[
"ref"] !=
"wsp") {
425 $tbl_users->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
427 $tbl_users->addColumn(
"",
"",
"1%");
429 $tbl_users->addColumn($this->lng->txt(
'login'),
'login',
'15%');
430 $tbl_users->addColumn($this->lng->txt(
'firstname'),
'firstname',
'15%');
431 $tbl_users->addColumn($this->lng->txt(
'lastname'),
'lastname',
'15%');
432 if ($has_mail_usr ==
true) {
433 foreach (
$result as $key => $val) {
434 if ($val[
'email'] ==
'') {
435 $result[$key][
'email'] =
' ';
439 $tbl_users->addColumn($this->lng->txt(
'email'),
'email',
'15%');
443 $tbl_users->setDefaultOrderField(
'login');
444 $tbl_users->setPrefix(
'usr_');
445 $tbl_users->enable(
'select_all');
446 $tbl_users->setSelectAllCheckbox(
'search_name_to_usr');
447 $tbl_users->setFormName(
'recipients');
449 $this->tpl->setVariable(
'TABLE_USERS', $tbl_users->getHTML());
452 include_once
'Services/Search/classes/class.ilQueryParser.php';
453 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
454 include_once
'Services/Search/classes/class.ilSearchResult.php';
455 include_once
'Services/Membership/classes/class.ilParticipants.php';
461 $query_parser->setMinWordLength(3);
462 $query_parser->parse();
465 $search->setFilter(array(
'grp'));
466 $result = $search->performSearch();
467 $group_results->mergeEntries(
$result);
468 $group_results->setMaxHits(PHP_INT_MAX);
469 $group_results->preventOverwritingMaxhits(
true);
470 $group_results->setRequiredPermission(
'read');
471 $group_results->filter(ROOT_FOLDER_ID,
true);
473 $visible_groups = array();
474 if ($group_results->getResults()) {
476 $tbl_grp->setTitle($this->lng->txt(
'system') .
': ' . $this->lng->txt(
'groups'));
477 $tbl_grp->setRowTemplate(
'tpl.mail_search_groups_row.html',
'Services/Contact');
482 $this->object_data_cache->preloadReferenceCache(array_keys($group_results->getResults()));
484 $groups = $group_results->getResults();
485 foreach ($groups as $grp) {
490 if (
$_GET[
"ref"] !=
"wsp") {
492 $roles = $this->rbacreview->getAssignableChildRoles($grp[
'ref_id']);
493 foreach ($roles as $role) {
494 if (substr($role[
'title'], 0, 14) ==
'il_grp_member_' ||
495 substr($role[
'title'], 0, 13) ==
'il_grp_admin_' 498 array_push($members,
'#' . $role[
'title']);
501 $str_members = implode(
',', $members);
510 $result[$counter][
'title'] = $this->object_data_cache->lookupTitle($grp[
'obj_id']);
511 $result[$counter][
'description'] = $this->object_data_cache->lookupDescription($grp[
'obj_id']);
514 $visible_groups[] = $grp;
517 if ($visible_groups) {
520 if (
$_GET[
"ref"] !=
"wsp") {
521 $tbl_grp->addColumn($this->lng->txt(
'mail_to') .
'/' . $this->lng->txt(
'cc') .
'/' . $this->lng->txt(
'bc'),
'check',
'10%');
523 $tbl_grp->addColumn(
"",
"",
"1%");
525 $tbl_grp->addColumn($this->lng->txt(
'title'),
'title',
'15%');
526 $tbl_grp->addColumn($this->lng->txt(
'description'),
'description',
'15%');
528 $tbl_grp->setDefaultOrderField(
'title');
529 $tbl_grp->setPrefix(
'grp_');
530 $tbl_grp->enable(
'select_all');
531 $tbl_grp->setSelectAllCheckbox(
'search_name_to_grp');
532 $tbl_grp->setFormName(
'recipients');
534 $this->tpl->setVariable(
'TABLE_GRP', $tbl_grp->getHTML());
538 if (count($users) || count($visible_groups) || count($relations)) {
540 $this->tpl->setVariable(
"ALT_ARROW",
'');
542 if (
$_GET[
"ref"] !=
"wsp") {
543 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'adopt'));
545 $this->tpl->setVariable(
'BUTTON_ADOPT', $this->lng->txt(
'wsp_share_with_users'));
548 $this->lng->loadLanguageModule(
'search');
552 if (
$_GET[
"ref"] !=
"wsp") {
553 $this->tpl->printToStdout();
559 if (!is_array($a_obj_ids)) {
560 $a_obj_ids = array($a_obj_ids);
563 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
565 foreach ($a_obj_ids as $object_id) {
566 if (!in_array($object_id, $existing)) {
567 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
572 ilUtil::sendSuccess($this->lng->txt(
"wsp_share_success"),
true);
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getInstanceByGlobalUser()
__construct($wsp_access_handler=null, $wsp_node_id=null)
static getInstance()
Singelton get instance.
static hasParticipantListAccess($a_obj_id, $a_usr_id=null)
Check if (current) user has access to the participant list.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
addPermission($a_obj_ids)
static _lookupEmail($a_user_id)
Lookup email.
static _lookupPref($a_usr_id, $a_keyword)
static _getObjectSearchInstance($query_parser)
get reference of ilFulltext/LikeObjectSearch.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public