24 include_once
'Services/Search/classes/class.ilSearchResult.php';
25 include_once
'Services/Search/classes/class.ilSearchSettings.php';
26 include_once
'./Services/Search/classes/class.ilRepositorySearchGUI.php';
52 $this->
setTitle($this->lng->txt(
'search_user_extended'));
87 $_SESSION[
"usr_search_mode"] =
"extended";
98 $ilTabs->activateSubTab(
"searchform");
100 $_SESSION[
"usr_search_mode"] =
"extended";
103 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
126 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
129 $ilTabs->activateSubTab(
"searchresults");
150 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.usr_search_simple.html',
'Services/Search');
152 $this->ctrl->setParameter($this,
'search',
'1');
154 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startSimple'));
155 $this->tpl->setVariable(
"TXT_SEARCH",$this->lng->txt(
"search"));
156 if(count(
$_SESSION[
'rep_search'][
'usr']))
157 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
'append_results'));
159 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search_user"));
164 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.rep_search.html',
'Services/Search');
165 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startExtended'));
167 $this->tpl->setVariable(
"ALT_IMG",$this->lng->txt(
'obj_usr'));
168 $this->tpl->setVariable(
"SEARCH_MEMBERS_HEADER",$this->lng->txt(
"search_user_extended"));
172 $this->tpl->setVariable(
"SEARCH_ASSIGN_USR",$this->lng->txt(
"search_for_users"));
173 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_USER",
ilUtil::formRadioButton($this->search_type ==
'usr',
"search_for",
"usr"));
178 $this->tpl->setVariable(
"SEARCH_ROW_TXT_GROUP",$this->lng->txt(
"search_for_grp_members"));
179 $this->tpl->setVariable(
"GROUP_TERM",$this->lng->txt(
'search_grp_title'));
180 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_GROUP",
ilUtil::formRadioButton($this->search_type ==
'grp',
"search_for",
"grp"));
181 $this->tpl->setVariable(
"GRP_VALUE",
$_SESSION[
'rep_query'][
'grp'][
'title']);
185 $this->tpl->setVariable(
"SEARCH_ROW_TXT_ROLE",$this->lng->txt(
"search_for_role_members"));
186 $this->tpl->setVariable(
"ROLE_TERM",$this->lng->txt(
'search_role_title'));
187 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_ROLE",
ilUtil::formRadioButton($this->search_type ==
'role',
"search_for",
"role"));
188 $this->tpl->setVariable(
"ROLE_VALUE",
$_SESSION[
'rep_query'][
'role'][
'title']);
191 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
"cancel"));
192 if(count(
$_SESSION[
'rep_search'][
'usr']))
194 $this->tpl->setVariable(
"BTN3_VALUE",$this->lng->txt(
'append_results'));
196 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search"));
216 if(
$_POST[
'cmd'][
'performSearchSimple'])
222 $_POST[
"search_fields"] = array (
"username",
"firstname",
"lastname",
"email");
227 $_POST[
"search_string"] = trim(
$_POST[
"search_string"]) ? trim(
$_POST[
"search_string"]) : trim(urldecode(
$_GET[
"search_string"]));
231 if (empty(
$_POST[
"search_string"]))
233 $_POST[
"search_string"] =
"%";
239 if (
$_POST[
"search_string"] ==
"%")
241 $_POST[
"search_string"] =
"";
244 $msg = $this->lng->txt(
"msg_no_search_result");
246 if (
$_POST[
"search_string"] !=
"")
248 $msg .=
" ".$this->lng->txt(
"with").
" '".htmlspecialchars(
$_POST[
"search_string"]).
"'";
254 $ilErr->raiseError($msg,$ilErr->MESSAGE);
259 $this->ctrl->setParameterByClass(
"ilobjuserfoldergui",
"user_filter",
$_GET[
"user_filter"]);
260 $this->ctrl->redirectByClass(
"ilobjuserfoldergui",
"view");
266 $_SESSION[
'rep_search'][
'usr'] = array();
269 foreach($search_result as
$result)
274 if(!
$_SESSION[
'rep_search'][$this->search_type])
290 if(
$_POST[
'cmd'][
'performSearch'])
295 switch($this->search_type)
312 $this->result_obj->addObserver($this,
'userFilter');
315 if(!count($this->result_obj->getResults()))
319 #$ilErr->raiseError($this->lng->txt('search_no_match'),$ilErr->MESSAGE);
322 if($this->result_obj->isLimitReached())
324 $message = sprintf($this->lng->txt(
'search_limit_reached'),$this->settings->getMaxHits());
328 if (
$_SESSION[
"usr_search_mode"] ==
"extended")
336 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
337 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
342 $query_string =
$_SESSION[
'rep_query'][
'usr'][$name];
343 $active_status =
$_SESSION[
'usr_query_active'];
356 switch($info[
'type'])
361 $udf_search->setFields(array($name));
362 $result_obj = $udf_search->performSearch();
371 $user_search->setFields(array($name));
373 if ($active_status == 1)
374 $user_search->enableActiveCheck(
true);
375 elseif ($active_status == 2)
376 $user_search->enableInactiveCheck(
true);
378 $result_obj = $user_search->performSearch();
389 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
391 $query_string =
$_SESSION[
'rep_query'][
'grp'][
'title'];
398 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
400 $object_search->setFilter(array(
'grp'));
408 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
410 $query_string =
$_SESSION[
'rep_query'][
'role'][
'title'];
418 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
420 $object_search->setFilter(array(
'role'));
433 include_once
'Services/Search/classes/class.ilQueryParser.php';
437 $query_parser->setMinWordLength(1,
true);
438 $query_parser->parse();
440 if(!$query_parser->validate())
442 return $query_parser->getMessage();
444 return $query_parser;
451 if(is_array(
$_POST[
'rep_query']))
473 $this->search_type =
$_SESSION[
'rep_search_type'];
474 #echo $this->search_type;
483 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
486 $values = array(
'0' => $lng->txt(
'please_choose'),
487 '1' => $lng->txt(
'active'),
488 '2' => $lng->txt(
'inactive'));
490 $this->tpl->setCurrentBlock(
"select_field");
491 $this->tpl->setVariable(
"SELECT_NAME",$lng->txt(
'active'));
498 $this->tpl->parseCurrentBlock();
502 switch($info[
'type'])
506 $this->tpl->setCurrentBlock(
"select_field");
507 $this->tpl->setVariable(
"SELECT_NAME",$info[
'lang']);
511 "rep_query[usr][$name]",
515 $this->tpl->parseCurrentBlock();
520 $this->tpl->setCurrentBlock(
"text_field");
521 $this->tpl->setVariable(
"TEXT_NAME",$info[
'lang']);
524 $this->tpl->setVariable(
"USR_NAME",
"rep_query[usr][$name]");
525 $this->tpl->setVariable(
"USR_VALUE",
$_SESSION[
'rep_query'][
'usr'][$name]);
526 $this->tpl->parseCurrentBlock();
529 $this->tpl->setCurrentBlock(
"usr_rows");
530 $this->tpl->parseCurrentBlock();
541 foreach($this->result_obj->getResults() as
$result)
545 if(!
$_SESSION[
'rep_search'][$this->search_type])
561 return $_SESSION[
'rep_search'][
'usr'] = $a_usr_ids;
567 return $_SESSION[
'rep_search'][
'usr'] ? array_unique(
$_SESSION[
'rep_search'][
'usr']) : array();
572 if($this->stored ==
false)
574 $this->result_obj->mergeEntries($new_res);
575 $this->stored =
true;
580 $this->result_obj->intersectEntries($new_res);
587 $user_ids = $user_ids ? $user_ids : array();
602 if ($tmp_obj->getActive())
604 if ($tmp_obj->getTimeLimitUnlimited())
606 $txt_access = $this->lng->txt(
"access_unlimited");
608 elseif ($tmp_obj->getTimeLimitUntil() < time())
610 $txt_access = $this->lng->txt(
"access_expired");
619 $txt_access = $this->lng->txt(
"inactive");
623 $f_result[$counter][] = $tmp_obj->getLogin();
624 $f_result[$counter][] = $tmp_obj->getFirstname();
625 $f_result[$counter][] = $tmp_obj->getLastname();
626 $f_result[$counter][] = $tmp_obj->getEmail();
627 $f_result[$counter][] = $txt_access;
628 $f_result[$counter][] = $tmp_obj->getLastLogin();
629 $f_result[$counter][] =
$usr_id;
634 return $f_result ? $f_result : array();
639 $group_ids = $group_ids ? $group_ids : array();
642 foreach($group_ids as $group_id)
649 $grp_ids[$counter] = $group_id;
652 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
653 $f_result[$counter][] = $tmp_obj->getCountMembers();
658 return $f_result ? $f_result : array();
663 $role_ids = $role_ids ? $role_ids : array();
666 foreach($role_ids as $role_id)
669 if ($role_id == ANONYMOUS_ROLE_ID)
678 if ($tmp_obj->getCountMembers() == 0)
682 $role_ids[$counter] = $role_id;
685 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
686 $f_result[$counter][] = $tmp_obj->getCountMembers();
691 return $f_result ? $f_result : array();
699 switch($this->search_type)
718 if(
$_SESSION[
'search_append'] and $this->search_type !=
'usr')
733 $tpl =& $tbl->getTemplateObject();
736 $tpl->setCurrentBlock(
"tbl_form_header");
737 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
738 $tpl->parseCurrentBlock();
741 array(
"name" =>
"delete",
"lng" =>
"delete"),
742 array(
"name" =>
"activate",
"lng" =>
"activate"),
743 array(
"name" =>
"deactivate",
"lng" =>
"deactivate"),
744 array(
"name" =>
"accessRestrict",
"lng" =>
"accessRestrict"),
745 array(
"name" =>
"accessFree",
"lng" =>
"accessFree"),
746 array(
"name" =>
"export",
"lng" =>
"export")
749 if (count($operations) > 0)
751 $select =
"<select name=\"selectedAction\">\n";
752 foreach ($operations as $val)
754 $select .=
"<option value=\"" . $val[
"name"] .
"\"";
755 if (strcmp(
$_POST[
"selectedAction"], $val[
"name"]) == 0)
757 $select .=
" selected=\"selected\"";
760 $select .= $this->lng->txt($val[
"lng"]);
761 $select .=
"</option>";
763 $select .=
"</select>";
764 $tpl->setCurrentBlock(
"tbl_action_select");
765 $tpl->setVariable(
"SELECT_ACTION", $select);
766 $tpl->setVariable(
"BTN_NAME",
"userAction");
767 $tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"submit"));
768 $tpl->parseCurrentBlock();
771 $tpl->setCurrentBlock(
"tbl_action_row");
772 $tpl->setVariable(
"COLUMN_COUNTS",7);
774 $tpl->parseCurrentBlock();
776 $tbl->setTitle($this->lng->txt(
"search_results"),
"icon_usr.gif",$this->lng->txt(
"search_results"));
777 $tbl->setHeaderNames(array(
"",
778 $this->lng->txt(
"username"),
779 $this->lng->txt(
"firstname"),
780 $this->lng->txt(
"lastname"),
781 $this->lng->txt(
"email"),
782 $this->lng->txt(
"access_until"),
783 $this->lng->txt(
"last_login")));
784 $tbl->setHeaderVars(array(
"",
791 array(
"ref_id" =>
$_GET[
'ref_id'],
792 "cmd" => (
$_SESSION[
'usr_search_mode'] ==
'extended') ?
'showExtended' :
'show',
793 "cmdClass" =>
"iladminusersearchgui",
794 "cmdNode" =>
$_GET[
"cmdNode"],
795 "baseClass" =>
"ilAdministrationGUI"));
797 $tbl->setColumnWidth(array(
"",
"15%",
"15%",
"15%",
"20%",
"15%",
"20%"));
802 $this->tpl->setVariable($tpl_var,$tbl->tpl->get());
815 $tpl =& $tbl->getTemplateObject();
817 $tpl->setCurrentBlock(
"tbl_form_header");
818 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
819 $tpl->parseCurrentBlock();
821 $tpl->setCurrentBlock(
"tbl_action_btn");
822 $tpl->setVariable(
"BTN_NAME",
"listUsersGroup");
823 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
824 $tpl->parseCurrentBlock();
826 if (!empty($a_grp_ids))
828 $tpl->setCurrentBlock(
"tbl_select_all");
829 $tpl->setVariable(
"COLUMN_COUNTS",4);
830 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
831 $tpl->parseCurrentBlock();
834 $tpl->setCurrentBlock(
"tbl_action_row");
835 $tpl->setVariable(
"COLUMN_COUNTS",5);
837 $tpl->parseCurrentBlock();
839 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_grp.gif",$this->lng->txt(
"crs_header_edit_members"));
840 $tbl->setHeaderNames(array(
"",
841 $this->lng->txt(
"obj_grp"),
842 $this->lng->txt(
"crs_count_members")));
843 $tbl->setHeaderVars(array(
"",
846 array(
"ref_id" =>
$_GET[
'ref_id'],
848 "cmdClass" =>
"iladminusersearchgui",
849 "cmdNode" =>
$_GET[
"cmdNode"],
850 'baseClass' =>
'ilAdministrationGUI'
855 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
861 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
873 $tpl =& $tbl->getTemplateObject();
875 $tpl->setCurrentBlock(
"tbl_form_header");
876 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
877 $tpl->parseCurrentBlock();
879 $tpl->setCurrentBlock(
"tbl_action_btn");
880 $tpl->setVariable(
"BTN_NAME",
"listUsersRole");
881 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
882 $tpl->parseCurrentBlock();
884 if (!empty($a_role_ids))
886 $tpl->setCurrentBlock(
"tbl_select_all");
887 $tpl->setVariable(
"COLUMN_COUNTS",4);
888 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
889 $tpl->parseCurrentBlock();
892 $tpl->setCurrentBlock(
"tbl_action_row");
893 $tpl->setVariable(
"COLUMN_COUNTS",5);
895 $tpl->parseCurrentBlock();
897 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_role.gif",$this->lng->txt(
"crs_header_edit_members"));
898 $tbl->setHeaderNames(array(
"",
899 $this->lng->txt(
"objs_role"),
900 $this->lng->txt(
"crs_count_members")));
901 $tbl->setHeaderVars(array(
"",
904 array(
"ref_id" =>
$_GET[
'ref_id'],
906 "cmdClass" =>
"iladminusersearchgui",
907 "cmdNode" =>
$_GET[
"cmdNode"]));
909 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
912 $tbl->disable(
"auto_sort");
915 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
923 global $rbacsystem,$tree;
927 if(!is_array(
$_POST[
"group"]))
939 foreach(
$_POST[
"group"] as $group_id)
945 $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
958 global $rbacsystem,$rbacreview,$tree;
962 if(!is_array(
$_POST[
"role"]))
974 foreach(
$_POST[
"role"] as $role_id)
976 $members = array_merge($rbacreview->assignedUsers($role_id),$members);
995 $offset =
$_GET[
"offset"];
996 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
997 $direction =
$_GET[
"sort_order"];
998 $tbl->setLimit(1000000);
1002 $offset =
$_GET[
"offset"];
1003 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1004 $direction =
$_GET[
"sort_order"];
1005 $tbl->setLimit(1000000);
1009 $offset =
$_GET[
"offset"];
1011 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1013 $_GET[
"sort_by"] =
"login";
1015 $order =
$_GET[
"sort_by"];
1016 $direction =
$_GET[
"sort_order"];
1017 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1021 $tbl->setOrderColumn($order);
1022 $tbl->setOrderDirection($direction);
1023 $tbl->setOffset($offset);
1024 $tbl->setMaxCount(count($result_set));
1025 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1026 $tbl->setData($result_set);
1031 include_once
"./Services/Table/classes/class.ilTableGUI.php";
1041 $_SESSION[
"usr_search_link"] = $this->ctrl->getLinkTarget($this,
'show');
1043 $tbl->disable(
"auto_sort");
1044 $tbl->enable(
"select_all");
1045 $tbl->setFormName(
"cmd");
1046 $tbl->setSelectAllCheckbox(
"id");
1048 $offset =
$_GET[
"offset"];
1050 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1052 $_GET[
"sort_by"] =
"login";
1054 $order =
$_GET[
"sort_by"];
1055 $direction =
$_GET[
"sort_order"];
1056 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1058 $tbl->setOrderColumn($order);
1059 $tbl->setOrderDirection($direction);
1060 $tbl->setOffset($offset);
1061 $tbl->setMaxCount(count($result_set));
1062 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1066 foreach ($tbl->header_vars as $key => $val)
1077 $result_set = array_slice($result_set,$offset,$ilUser->getPref(
'hits_per_page'));
1080 foreach ($result_set as $i =>
$row)
1082 foreach (
$row as $key => $cell)
1089 $this->ctrl->setParameterByClass(
"ilobjusergui",
"ref_id",
"7");
1090 $this->ctrl->setParameterByClass(
"ilobjusergui",
"obj_id",
$row[7]);
1091 $this->ctrl->setParameterByClass(
"ilobjusergui",
"search",
"1");
1092 $link = $this->ctrl->getLinkTargetByClass(array(
"iladministrationgui",
"ilobjusergui"),
"view");
1093 $result_set[$i][$key] =
"<a href=\"".$link.
"\">".$cell.
"</a>";
1098 if ($cell == $this->lng->txt(
"access_unlimited"))
1100 $result_set[$i][$key] =
"<span class=\"smallgreen\">".$cell.
"</span>";
1102 elseif (in_array($cell, array($this->lng->txt(
"access_expired"), $this->lng->txt(
"inactive"))))
1104 $result_set[$i][$key] =
"<span class=\"smallred\">".$cell.
"</span>";
1108 $result_set[$i][$key] =
"<span class=\"small\">".$cell.
"</span>";
1112 unset($result_set[$i][7]);
1116 $tbl->setData($result_set);
1121 $_SESSION[
'user_" . $method . "_search'] =
true;
1122 call_user_func(array($this->callback[
"class"], $this->callback[
"method"]),
1129 $ilTabs->addSubTab(
"searchform", $lng->txt(
"search"),
1130 $ilCtrl->getLinkTarget($this,
"showExtended"));
1134 $ilTabs->addSubTab(
"searchresults", $lng->txt(
"search_results"),
1135 $ilCtrl->getLinkTarget($this,
"show"));
1147 if($a_data[
'type'] ==
'usr')
1149 if($a_data[
'obj_id'] == ANONYMOUS_USER_ID)