38 include_once
'Services/Search/classes/class.ilSearchResult.php';
39 include_once
'Services/Search/classes/class.ilSearchSettings.php';
56 $this->lng->loadLanguageModule(
'search');
57 $this->lng->loadLanguageModule(
'crs');
63 $this->result_obj->setMaxHits(1000000);
75 $_SESSION[
'search'][
'string'] = $this->
string = $a_str;
90 $next_class = $this->ctrl->getNextClass($this);
91 $cmd = $this->ctrl->getCmd();
96 include_once(
'./Services/User/classes/class.ilObjUserGUI.php');
98 $this->gui_obj->setBackTarget($this->lng->txt(
"search_results"),
99 $this->ctrl->getLinkTarget($this,
"show"));
100 $ret =& $this->ctrl->forwardCommand($this->gui_obj);
146 $_SESSION[
"usr_search_mode"] =
"extended";
157 $ilTabs->activateSubTab(
"searchform");
159 $_SESSION[
"usr_search_mode"] =
"extended";
162 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
185 $this->tpl->addBlockfile(
"BUTTONS",
"buttons",
"tpl.buttons.html");
188 $ilTabs->activateSubTab(
"searchresults");
209 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.usr_search_simple.html',
'Services/Search');
211 $this->ctrl->setParameter($this,
'search',
'1');
213 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startSimple'));
214 $this->tpl->setVariable(
"TXT_SEARCH",$this->lng->txt(
"search"));
215 if(count(
$_SESSION[
'rep_search'][
'usr']))
216 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
'append_results'));
218 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search_user"));
223 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.rep_search.html',
'Services/Search');
224 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
'startExtended'));
226 $this->tpl->setVariable(
"ALT_IMG",$this->lng->txt(
'obj_usr'));
227 $this->tpl->setVariable(
"SEARCH_MEMBERS_HEADER",$this->lng->txt(
"search_user_extended"));
231 $this->tpl->setVariable(
"SEARCH_ASSIGN_USR",$this->lng->txt(
"search_for_users"));
232 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_USER",
ilUtil::formRadioButton($this->search_type ==
'usr',
"search_for",
"usr"));
237 $this->tpl->setVariable(
"SEARCH_ROW_TXT_GROUP",$this->lng->txt(
"search_for_grp_members"));
238 $this->tpl->setVariable(
"GROUP_TERM",$this->lng->txt(
'search_grp_title'));
239 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_GROUP",
ilUtil::formRadioButton($this->search_type ==
'grp',
"search_for",
"grp"));
240 $this->tpl->setVariable(
"GRP_VALUE",
$_SESSION[
'rep_query'][
'grp'][
'title']);
244 $this->tpl->setVariable(
"SEARCH_ROW_TXT_ROLE",$this->lng->txt(
"search_for_role_members"));
245 $this->tpl->setVariable(
"ROLE_TERM",$this->lng->txt(
'search_role_title'));
246 $this->tpl->setVariable(
"SEARCH_ROW_CHECK_ROLE",
ilUtil::formRadioButton($this->search_type ==
'role',
"search_for",
"role"));
247 $this->tpl->setVariable(
"ROLE_VALUE",
$_SESSION[
'rep_query'][
'role'][
'title']);
250 $this->tpl->setVariable(
"BTN2_VALUE",$this->lng->txt(
"cancel"));
251 if(count(
$_SESSION[
'rep_search'][
'usr']))
253 $this->tpl->setVariable(
"BTN3_VALUE",$this->lng->txt(
'append_results'));
255 $this->tpl->setVariable(
"BTN1_VALUE",$this->lng->txt(
"search"));
275 if(
$_POST[
'cmd'][
'performSearchSimple'])
281 $_POST[
"search_fields"] = array (
"username",
"firstname",
"lastname",
"email");
286 $_POST[
"search_string"] = trim(
$_POST[
"search_string"]) ? trim(
$_POST[
"search_string"]) : trim(urldecode(
$_GET[
"search_string"]));
290 if (empty(
$_POST[
"search_string"]))
292 $_POST[
"search_string"] =
"%";
298 if (
$_POST[
"search_string"] ==
"%")
300 $_POST[
"search_string"] =
"";
303 $msg = $this->lng->txt(
"msg_no_search_result");
305 if (
$_POST[
"search_string"] !=
"")
307 $msg .=
" ".$this->lng->txt(
"with").
" '".htmlspecialchars(
$_POST[
"search_string"]).
"'";
313 $ilErr->raiseError($msg,$ilErr->MESSAGE);
318 $this->ctrl->setParameterByClass(
"ilobjuserfoldergui",
"user_filter",
$_GET[
"user_filter"]);
319 $this->ctrl->redirectByClass(
"ilobjuserfoldergui",
"view");
325 $_SESSION[
'rep_search'][
'usr'] = array();
328 foreach($search_result as $result)
330 $_SESSION[
'rep_search'][
'usr'][] = $result;
333 if(!
$_SESSION[
'rep_search'][$this->search_type])
349 if(
$_POST[
'cmd'][
'performSearch'])
354 switch($this->search_type)
371 $this->result_obj->addObserver($this,
'userFilter');
374 if(!count($this->result_obj->getResults()))
378 #$ilErr->raiseError($this->lng->txt('search_no_match'),$ilErr->MESSAGE);
381 if($this->result_obj->isLimitReached())
383 $message = sprintf($this->lng->txt(
'search_limit_reached'),$this->settings->getMaxHits());
387 if (
$_SESSION[
"usr_search_mode"] ==
"extended")
395 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
396 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
402 $active_status =
$_SESSION[
'usr_query_active'];
415 switch($info[
'type'])
420 $udf_search->setFields(array(
$name));
421 $result_obj = $udf_search->performSearch();
430 $user_search->setFields(array(
$name));
432 if ($active_status == 1)
433 $user_search->enableActiveCheck(
true);
434 elseif ($active_status == 2)
435 $user_search->enableInactiveCheck(
true);
437 $result_obj = $user_search->performSearch();
448 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
450 $query_string =
$_SESSION[
'rep_query'][
'grp'][
'title'];
457 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
459 $object_search->setFilter(array(
'grp'));
467 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
469 $query_string =
$_SESSION[
'rep_query'][
'role'][
'title'];
477 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
479 $object_search->setFilter(array(
'role'));
492 include_once
'Services/Search/classes/class.ilQueryParser.php';
496 $query_parser->setMinWordLength(1,
true);
497 $query_parser->parse();
499 if(!$query_parser->validate())
501 return $query_parser->getMessage();
503 return $query_parser;
510 if(is_array(
$_POST[
'rep_query']))
532 $this->search_type =
$_SESSION[
'rep_search_type'];
533 #echo $this->search_type;
542 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
545 $values = array(
'0' => $lng->txt(
'please_choose'),
546 '1' => $lng->txt(
'active'),
547 '2' => $lng->txt(
'inactive'));
549 $this->tpl->setCurrentBlock(
"select_field");
550 $this->tpl->setVariable(
"SELECT_NAME",$lng->txt(
'active'));
557 $this->tpl->parseCurrentBlock();
561 switch($info[
'type'])
565 $this->tpl->setCurrentBlock(
"select_field");
566 $this->tpl->setVariable(
"SELECT_NAME",$info[
'lang']);
570 "rep_query[usr][$name]",
574 $this->tpl->parseCurrentBlock();
579 $this->tpl->setCurrentBlock(
"text_field");
580 $this->tpl->setVariable(
"TEXT_NAME",$info[
'lang']);
583 $this->tpl->setVariable(
"USR_NAME",
"rep_query[usr][$name]");
584 $this->tpl->setVariable(
"USR_VALUE",
$_SESSION[
'rep_query'][
'usr'][$name]);
585 $this->tpl->parseCurrentBlock();
588 $this->tpl->setCurrentBlock(
"usr_rows");
589 $this->tpl->parseCurrentBlock();
600 foreach($this->result_obj->getResults() as $result)
604 if(!
$_SESSION[
'rep_search'][$this->search_type])
620 return $_SESSION[
'rep_search'][
'usr'] = $a_usr_ids;
626 return $_SESSION[
'rep_search'][
'usr'] ? array_unique(
$_SESSION[
'rep_search'][
'usr']) : array();
631 if($this->stored ==
false)
633 $this->result_obj->mergeEntries($new_res);
634 $this->stored =
true;
639 $this->result_obj->intersectEntries($new_res);
646 $user_ids = $user_ids ? $user_ids : array();
661 if ($tmp_obj->getActive())
663 if ($tmp_obj->getTimeLimitUnlimited())
665 $txt_access = $this->lng->txt(
"access_unlimited");
667 elseif ($tmp_obj->getTimeLimitUntil() < time())
669 $txt_access = $this->lng->txt(
"access_expired");
678 $txt_access = $this->lng->txt(
"inactive");
682 $f_result[$counter][] = $tmp_obj->getLogin();
683 $f_result[$counter][] = $tmp_obj->getFirstname();
684 $f_result[$counter][] = $tmp_obj->getLastname();
685 $f_result[$counter][] = $tmp_obj->getEmail();
686 $f_result[$counter][] = $txt_access;
687 $f_result[$counter][] = $tmp_obj->getLastLogin();
688 $f_result[$counter][] =
$usr_id;
693 return $f_result ? $f_result : array();
698 $group_ids = $group_ids ? $group_ids : array();
701 foreach($group_ids as $group_id)
708 $grp_ids[$counter] = $group_id;
711 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
712 $f_result[$counter][] = $tmp_obj->getCountMembers();
717 return $f_result ? $f_result : array();
722 $role_ids = $role_ids ? $role_ids : array();
725 foreach($role_ids as $role_id)
728 if ($role_id == ANONYMOUS_ROLE_ID)
737 if ($tmp_obj->getCountMembers() == 0)
741 $role_ids[$counter] = $role_id;
744 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
745 $f_result[$counter][] = $tmp_obj->getCountMembers();
750 return $f_result ? $f_result : array();
758 switch($this->search_type)
777 if(
$_SESSION[
'search_append'] and $this->search_type !=
'usr')
792 $tpl =& $tbl->getTemplateObject();
795 $tpl->setCurrentBlock(
"tbl_form_header");
796 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
797 $tpl->parseCurrentBlock();
800 array(
"name" =>
"delete",
"lng" =>
"delete"),
801 array(
"name" =>
"activate",
"lng" =>
"activate"),
802 array(
"name" =>
"deactivate",
"lng" =>
"deactivate"),
803 array(
"name" =>
"accessRestrict",
"lng" =>
"accessRestrict"),
804 array(
"name" =>
"accessFree",
"lng" =>
"accessFree"),
805 array(
"name" =>
"export",
"lng" =>
"export")
808 if (count($operations) > 0)
810 $select =
"<select name=\"selectedAction\">\n";
811 foreach ($operations as $val)
813 $select .=
"<option value=\"" . $val[
"name"] .
"\"";
814 if (strcmp(
$_POST[
"selectedAction"], $val[
"name"]) == 0)
816 $select .=
" selected=\"selected\"";
819 $select .= $this->lng->txt($val[
"lng"]);
820 $select .=
"</option>";
822 $select .=
"</select>";
823 $tpl->setCurrentBlock(
"tbl_action_select");
824 $tpl->setVariable(
"SELECT_ACTION", $select);
825 $tpl->setVariable(
"BTN_NAME",
"userAction");
826 $tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"submit"));
827 $tpl->parseCurrentBlock();
830 $tpl->setCurrentBlock(
"tbl_action_row");
831 $tpl->setVariable(
"COLUMN_COUNTS",7);
833 $tpl->parseCurrentBlock();
835 $tbl->setTitle($this->lng->txt(
"search_results"),
"icon_usr.gif",$this->lng->txt(
"search_results"));
836 $tbl->setHeaderNames(array(
"",
837 $this->lng->txt(
"username"),
838 $this->lng->txt(
"firstname"),
839 $this->lng->txt(
"lastname"),
840 $this->lng->txt(
"email"),
841 $this->lng->txt(
"access_until"),
842 $this->lng->txt(
"last_login")));
843 $tbl->setHeaderVars(array(
"",
850 array(
"ref_id" =>
$_GET[
'ref_id'],
851 "cmd" => (
$_SESSION[
'usr_search_mode'] ==
'extended') ?
'showExtended' :
'show',
852 "cmdClass" =>
"iladminusersearchgui",
853 "cmdNode" =>
$_GET[
"cmdNode"],
854 "baseClass" =>
"ilAdministrationGUI"));
856 $tbl->setColumnWidth(array(
"",
"15%",
"15%",
"15%",
"20%",
"15%",
"20%"));
861 $this->tpl->setVariable($tpl_var,$tbl->tpl->get());
874 $tpl =& $tbl->getTemplateObject();
876 $tpl->setCurrentBlock(
"tbl_form_header");
877 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
878 $tpl->parseCurrentBlock();
880 $tpl->setCurrentBlock(
"tbl_action_btn");
881 $tpl->setVariable(
"BTN_NAME",
"listUsersGroup");
882 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
883 $tpl->parseCurrentBlock();
885 if (!empty($a_grp_ids))
887 $tpl->setCurrentBlock(
"tbl_select_all");
888 $tpl->setVariable(
"COLUMN_COUNTS",4);
889 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
890 $tpl->parseCurrentBlock();
893 $tpl->setCurrentBlock(
"tbl_action_row");
894 $tpl->setVariable(
"COLUMN_COUNTS",5);
896 $tpl->parseCurrentBlock();
898 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_grp.gif",$this->lng->txt(
"crs_header_edit_members"));
899 $tbl->setHeaderNames(array(
"",
900 $this->lng->txt(
"obj_grp"),
901 $this->lng->txt(
"crs_count_members")));
902 $tbl->setHeaderVars(array(
"",
905 array(
"ref_id" =>
$_GET[
'ref_id'],
907 "cmdClass" =>
"iladminusersearchgui",
908 "cmdNode" =>
$_GET[
"cmdNode"],
909 'baseClass' =>
'ilAdministrationGUI'
914 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
920 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
932 $tpl =& $tbl->getTemplateObject();
934 $tpl->setCurrentBlock(
"tbl_form_header");
935 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
936 $tpl->parseCurrentBlock();
938 $tpl->setCurrentBlock(
"tbl_action_btn");
939 $tpl->setVariable(
"BTN_NAME",
"listUsersRole");
940 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
941 $tpl->parseCurrentBlock();
943 if (!empty($a_role_ids))
945 $tpl->setCurrentBlock(
"tbl_select_all");
946 $tpl->setVariable(
"COLUMN_COUNTS",4);
947 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
948 $tpl->parseCurrentBlock();
951 $tpl->setCurrentBlock(
"tbl_action_row");
952 $tpl->setVariable(
"COLUMN_COUNTS",5);
954 $tpl->parseCurrentBlock();
956 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_role.gif",$this->lng->txt(
"crs_header_edit_members"));
957 $tbl->setHeaderNames(array(
"",
958 $this->lng->txt(
"objs_role"),
959 $this->lng->txt(
"crs_count_members")));
960 $tbl->setHeaderVars(array(
"",
963 array(
"ref_id" =>
$_GET[
'ref_id'],
965 "cmdClass" =>
"iladminusersearchgui",
966 "cmdNode" =>
$_GET[
"cmdNode"]));
968 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
971 $tbl->disable(
"auto_sort");
974 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
982 global $rbacsystem,$tree;
986 if(!is_array(
$_POST[
"group"]))
998 foreach(
$_POST[
"group"] as $group_id)
1004 $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
1017 global $rbacsystem,$rbacreview,$tree;
1021 if(!is_array(
$_POST[
"role"]))
1033 foreach(
$_POST[
"role"] as $role_id)
1035 $members = array_merge($rbacreview->assignedUsers($role_id),$members);
1054 $offset =
$_GET[
"offset"];
1055 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1056 $direction =
$_GET[
"sort_order"];
1057 $tbl->setLimit(1000000);
1061 $offset =
$_GET[
"offset"];
1062 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1063 $direction =
$_GET[
"sort_order"];
1064 $tbl->setLimit(1000000);
1068 $offset =
$_GET[
"offset"];
1070 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1072 $_GET[
"sort_by"] =
"login";
1074 $order =
$_GET[
"sort_by"];
1075 $direction =
$_GET[
"sort_order"];
1076 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1080 $tbl->setOrderColumn($order);
1081 $tbl->setOrderDirection($direction);
1082 $tbl->setOffset($offset);
1083 $tbl->setMaxCount(count($result_set));
1084 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1085 $tbl->setData($result_set);
1090 include_once
"./Services/Table/classes/class.ilTableGUI.php";
1100 $_SESSION[
"usr_search_link"] = $this->ctrl->getLinkTarget($this,
'show');
1102 $tbl->disable(
"auto_sort");
1103 $tbl->enable(
"select_all");
1104 $tbl->setFormName(
"cmd");
1105 $tbl->setSelectAllCheckbox(
"id");
1107 $offset =
$_GET[
"offset"];
1109 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1111 $_GET[
"sort_by"] =
"login";
1113 $order =
$_GET[
"sort_by"];
1114 $direction =
$_GET[
"sort_order"];
1115 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1117 $tbl->setOrderColumn($order);
1118 $tbl->setOrderDirection($direction);
1119 $tbl->setOffset($offset);
1120 $tbl->setMaxCount(count($result_set));
1121 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1125 foreach ($tbl->header_vars as $key => $val)
1136 $result_set = array_slice($result_set,$offset,$ilUser->getPref(
'hits_per_page'));
1139 foreach ($result_set as $i =>
$row)
1141 foreach (
$row as $key => $cell)
1148 $this->ctrl->setParameterByClass(
"ilobjusergui",
"ref_id",
"7");
1149 $this->ctrl->setParameterByClass(
"ilobjusergui",
"obj_id",
$row[7]);
1150 $this->ctrl->setParameterByClass(
"ilobjusergui",
"search",
"1");
1151 $link = $this->ctrl->getLinkTargetByClass(array(
"iladministrationgui",
"ilobjusergui"),
"view");
1152 $result_set[$i][$key] =
"<a href=\"".$link.
"\">".$cell.
"</a>";
1157 if ($cell == $this->lng->txt(
"access_unlimited"))
1159 $result_set[$i][$key] =
"<span class=\"smallgreen\">".$cell.
"</span>";
1161 elseif (in_array($cell, array($this->lng->txt(
"access_expired"), $this->lng->txt(
"inactive"))))
1163 $result_set[$i][$key] =
"<span class=\"smallred\">".$cell.
"</span>";
1167 $result_set[$i][$key] =
"<span class=\"small\">".$cell.
"</span>";
1171 unset($result_set[$i][7]);
1175 $tbl->setData($result_set);
1180 $this->callback_class = $class;
1190 session_unregister(
"saved_post");
1191 $class =& $this->callback_class;
1193 $script = $class->ctrl->getLinkTargetByClass(
'ilAdminUserSearchGUI',
'show',
'',
false,
false);
1200 $method =
$_POST[
"selectedAction"];
1201 $_SESSION[
'user_" . $method . "_search'] =
true;
1202 $class =& $this->callback_class;
1203 $class->showActionConfirmation($method);
1211 $class =& $this->callback_class;
1213 $class->deleteObject();
1220 $this->ctrl->returnToParent($this);
1226 $ilTabs->addSubTab(
"searchform", $lng->txt(
"search"),
1227 $ilCtrl->getLinkTarget($this,
"showExtended"));
1231 $ilTabs->addSubTab(
"searchresults", $lng->txt(
"search_results"),
1232 $ilCtrl->getLinkTarget($this,
"show"));
1244 if($a_data[
'type'] ==
'usr')
1246 if($a_data[
'obj_id'] == ANONYMOUS_USER_ID)