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)
333 if(!
$_SESSION[
'rep_search'][$this->search_type])
349 if(
$_POST[
'cmd'][
'performSearch'])
354 switch($this->search_type)
373 if(!count($this->result_obj->getResults()))
377 #$ilErr->raiseError($this->lng->txt('search_no_match'),$ilErr->MESSAGE);
380 if($this->result_obj->isLimitReached())
382 $message = sprintf($this->lng->txt(
'search_limit_reached'),$this->settings->getMaxHits());
386 if (
$_SESSION[
"usr_search_mode"] ==
"extended")
394 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
395 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
401 $active_status =
$_SESSION[
'usr_query_active'];
414 switch($info[
'type'])
419 $udf_search->setFields(array(
$name));
420 $result_obj = $udf_search->performSearch();
429 $user_search->setFields(array(
$name));
431 if ($active_status == 1)
432 $user_search->enableActiveCheck(
true);
433 elseif ($active_status == 2)
434 $user_search->enableInactiveCheck(
true);
436 $result_obj = $user_search->performSearch();
447 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
449 $query_string =
$_SESSION[
'rep_query'][
'grp'][
'title'];
456 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
458 $object_search->setFilter(array(
'grp'));
466 include_once
'Services/Search/classes/class.ilObjectSearchFactory.php';
468 $query_string =
$_SESSION[
'rep_query'][
'role'][
'title'];
476 include_once
'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
478 $object_search->setFilter(array(
'role'));
491 include_once
'Services/Search/classes/class.ilQueryParser.php';
495 $query_parser->setMinWordLength(1,
true);
496 $query_parser->parse();
498 if(!$query_parser->validate())
500 return $query_parser->getMessage();
502 return $query_parser;
509 if(is_array(
$_POST[
'rep_query']))
531 $this->search_type =
$_SESSION[
'rep_search_type'];
532 #echo $this->search_type;
541 include_once
'Services/Search/classes/class.ilUserSearchOptions.php';
544 $values = array(
'0' => $lng->txt(
'please_choose'),
545 '1' => $lng->txt(
'active'),
546 '2' => $lng->txt(
'inactive'));
548 $this->tpl->setCurrentBlock(
"select_field");
549 $this->tpl->setVariable(
"SELECT_NAME",$lng->txt(
'active'));
556 $this->tpl->parseCurrentBlock();
560 switch($info[
'type'])
564 $this->tpl->setCurrentBlock(
"select_field");
565 $this->tpl->setVariable(
"SELECT_NAME",$info[
'lang']);
569 "rep_query[usr][$name]",
573 $this->tpl->parseCurrentBlock();
578 $this->tpl->setCurrentBlock(
"text_field");
579 $this->tpl->setVariable(
"TEXT_NAME",$info[
'lang']);
582 $this->tpl->setVariable(
"USR_NAME",
"rep_query[usr][$name]");
583 $this->tpl->setVariable(
"USR_VALUE",
$_SESSION[
'rep_query'][
'usr'][$name]);
584 $this->tpl->parseCurrentBlock();
587 $this->tpl->setCurrentBlock(
"usr_rows");
588 $this->tpl->parseCurrentBlock();
599 foreach($this->result_obj->getResults() as
$result)
603 if(!
$_SESSION[
'rep_search'][$this->search_type])
619 return $_SESSION[
'rep_search'][
'usr'] = $a_usr_ids;
625 return $_SESSION[
'rep_search'][
'usr'] ? array_unique(
$_SESSION[
'rep_search'][
'usr']) : array();
630 if($this->stored ==
false)
632 $this->result_obj->mergeEntries($new_res);
633 $this->stored =
true;
638 $this->result_obj->intersectEntries($new_res);
645 $user_ids = $user_ids ? $user_ids : array();
660 if ($tmp_obj->getActive())
662 if ($tmp_obj->getTimeLimitUnlimited())
664 $txt_access = $this->lng->txt(
"access_unlimited");
666 elseif ($tmp_obj->getTimeLimitUntil() < time())
668 $txt_access = $this->lng->txt(
"access_expired");
677 $txt_access = $this->lng->txt(
"inactive");
681 $f_result[$counter][] = $tmp_obj->getLogin();
682 $f_result[$counter][] = $tmp_obj->getFirstname();
683 $f_result[$counter][] = $tmp_obj->getLastname();
684 $f_result[$counter][] = $tmp_obj->getEmail();
685 $f_result[$counter][] = $txt_access;
686 $f_result[$counter][] = $tmp_obj->getLastLogin();
687 $f_result[$counter][] =
$usr_id;
692 return $f_result ? $f_result : array();
697 $group_ids = $group_ids ? $group_ids : array();
700 foreach($group_ids as $group_id)
707 $grp_ids[$counter] = $group_id;
710 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
711 $f_result[$counter][] = $tmp_obj->getCountMembers();
716 return $f_result ? $f_result : array();
721 $role_ids = $role_ids ? $role_ids : array();
724 foreach($role_ids as $role_id)
727 if ($role_id == ANONYMOUS_ROLE_ID)
736 if ($tmp_obj->getCountMembers() == 0)
740 $role_ids[$counter] = $role_id;
743 $f_result[$counter][] = array($tmp_obj->getTitle(),$tmp_obj->getDescription());
744 $f_result[$counter][] = $tmp_obj->getCountMembers();
749 return $f_result ? $f_result : array();
757 switch($this->search_type)
776 if(
$_SESSION[
'search_append'] and $this->search_type !=
'usr')
791 $tpl =& $tbl->getTemplateObject();
794 $tpl->setCurrentBlock(
"tbl_form_header");
795 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
796 $tpl->parseCurrentBlock();
799 array(
"name" =>
"delete",
"lng" =>
"delete"),
800 array(
"name" =>
"activate",
"lng" =>
"activate"),
801 array(
"name" =>
"deactivate",
"lng" =>
"deactivate"),
802 array(
"name" =>
"accessRestrict",
"lng" =>
"accessRestrict"),
803 array(
"name" =>
"accessFree",
"lng" =>
"accessFree"),
804 array(
"name" =>
"export",
"lng" =>
"export")
807 if (count($operations) > 0)
809 $select =
"<select name=\"selectedAction\">\n";
810 foreach ($operations as $val)
812 $select .=
"<option value=\"" . $val[
"name"] .
"\"";
813 if (strcmp(
$_POST[
"selectedAction"], $val[
"name"]) == 0)
815 $select .=
" selected=\"selected\"";
818 $select .= $this->lng->txt($val[
"lng"]);
819 $select .=
"</option>";
821 $select .=
"</select>";
822 $tpl->setCurrentBlock(
"tbl_action_select");
823 $tpl->setVariable(
"SELECT_ACTION", $select);
824 $tpl->setVariable(
"BTN_NAME",
"userAction");
825 $tpl->setVariable(
"BTN_VALUE", $this->lng->txt(
"submit"));
826 $tpl->parseCurrentBlock();
829 $tpl->setCurrentBlock(
"tbl_action_row");
830 $tpl->setVariable(
"COLUMN_COUNTS",7);
832 $tpl->parseCurrentBlock();
834 $tbl->setTitle($this->lng->txt(
"search_results"),
"icon_usr.gif",$this->lng->txt(
"search_results"));
835 $tbl->setHeaderNames(array(
"",
836 $this->lng->txt(
"username"),
837 $this->lng->txt(
"firstname"),
838 $this->lng->txt(
"lastname"),
839 $this->lng->txt(
"email"),
840 $this->lng->txt(
"access_until"),
841 $this->lng->txt(
"last_login")));
842 $tbl->setHeaderVars(array(
"",
849 array(
"ref_id" =>
$_GET[
'ref_id'],
850 "cmd" => (
$_SESSION[
'usr_search_mode'] ==
'extended') ?
'showExtended' :
'show',
851 "cmdClass" =>
"iladminusersearchgui",
852 "cmdNode" =>
$_GET[
"cmdNode"],
853 "baseClass" =>
"ilAdministrationGUI"));
855 $tbl->setColumnWidth(array(
"",
"15%",
"15%",
"15%",
"20%",
"15%",
"20%"));
860 $this->tpl->setVariable($tpl_var,$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",
"listUsersGroup");
881 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
882 $tpl->parseCurrentBlock();
884 if (!empty($a_grp_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_grp.gif",$this->lng->txt(
"crs_header_edit_members"));
898 $tbl->setHeaderNames(array(
"",
899 $this->lng->txt(
"obj_grp"),
900 $this->lng->txt(
"crs_count_members")));
901 $tbl->setHeaderVars(array(
"",
904 array(
"ref_id" =>
$_GET[
'ref_id'],
906 "cmdClass" =>
"ilsearchgui",
907 "cmdNode" =>
$_GET[
"cmdNode"]));
909 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
915 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
927 $tpl =& $tbl->getTemplateObject();
929 $tpl->setCurrentBlock(
"tbl_form_header");
930 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
931 $tpl->parseCurrentBlock();
933 $tpl->setCurrentBlock(
"tbl_action_btn");
934 $tpl->setVariable(
"BTN_NAME",
"listUsersRole");
935 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
"crs_list_users"));
936 $tpl->parseCurrentBlock();
938 if (!empty($a_role_ids))
940 $tpl->setCurrentBlock(
"tbl_select_all");
941 $tpl->setVariable(
"COLUMN_COUNTS",4);
942 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
943 $tpl->parseCurrentBlock();
946 $tpl->setCurrentBlock(
"tbl_action_row");
947 $tpl->setVariable(
"COLUMN_COUNTS",5);
949 $tpl->parseCurrentBlock();
951 $tbl->setTitle($this->lng->txt(
"crs_header_edit_members"),
"icon_role.gif",$this->lng->txt(
"crs_header_edit_members"));
952 $tbl->setHeaderNames(array(
"",
953 $this->lng->txt(
"objs_role"),
954 $this->lng->txt(
"crs_count_members")));
955 $tbl->setHeaderVars(array(
"",
958 array(
"ref_id" =>
$_GET[
'ref_id'],
960 "cmdClass" =>
"iladminusersearchgui",
961 "cmdNode" =>
$_GET[
"cmdNode"]));
963 $tbl->setColumnWidth(array(
"",
"80%",
"19%"));
966 $tbl->disable(
"auto_sort");
969 $this->tpl->setVariable(
"RES_TABLE",$tbl->tpl->get());
977 global $rbacsystem,$tree;
981 if(!is_array(
$_POST[
"group"]))
993 foreach(
$_POST[
"group"] as $group_id)
999 $members = array_merge($tmp_obj->getGroupMemberIds(),$members);
1012 global $rbacsystem,$rbacreview,$tree;
1016 if(!is_array(
$_POST[
"role"]))
1028 foreach(
$_POST[
"role"] as $role_id)
1030 $members = array_merge($rbacreview->assignedUsers($role_id),$members);
1049 $offset =
$_GET[
"offset"];
1050 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1051 $direction =
$_GET[
"sort_order"];
1052 $tbl->setLimit(1000000);
1056 $offset =
$_GET[
"offset"];
1057 $order =
$_GET[
"sort_by"] ?
$_GET[
"sort_by"] :
"title";
1058 $direction =
$_GET[
"sort_order"];
1059 $tbl->setLimit(1000000);
1063 $offset =
$_GET[
"offset"];
1065 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1067 $_GET[
"sort_by"] =
"login";
1069 $order =
$_GET[
"sort_by"];
1070 $direction =
$_GET[
"sort_order"];
1071 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1075 $tbl->setOrderColumn($order);
1076 $tbl->setOrderDirection($direction);
1077 $tbl->setOffset($offset);
1078 $tbl->setMaxCount(count($result_set));
1079 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1080 $tbl->setData($result_set);
1085 include_once
"./Services/Table/classes/class.ilTableGUI.php";
1095 $_SESSION[
"usr_search_link"] = $this->ctrl->getLinkTarget($this,
'show');
1097 $tbl->disable(
"auto_sort");
1098 $tbl->enable(
"select_all");
1099 $tbl->setFormName(
"cmd");
1100 $tbl->setSelectAllCheckbox(
"id");
1102 $offset =
$_GET[
"offset"];
1104 if (
$_GET[
"sort_by"] ==
"title" or empty(
$_GET[
"sort_by"]))
1106 $_GET[
"sort_by"] =
"login";
1108 $order =
$_GET[
"sort_by"];
1109 $direction =
$_GET[
"sort_order"];
1110 $tbl->setLimit($ilUser->getPref(
'hits_per_page'));
1112 $tbl->setOrderColumn($order);
1113 $tbl->setOrderDirection($direction);
1114 $tbl->setOffset($offset);
1115 $tbl->setMaxCount(count($result_set));
1116 $tbl->setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1120 foreach ($tbl->header_vars as
$key => $val)
1131 $result_set = array_slice($result_set,$offset,$ilUser->getPref(
'hits_per_page'));
1134 foreach ($result_set as $i =>
$row)
1143 $this->ctrl->setParameterByClass(
"ilobjusergui",
"ref_id",
"7");
1144 $this->ctrl->setParameterByClass(
"ilobjusergui",
"obj_id",
$row[7]);
1145 $this->ctrl->setParameterByClass(
"ilobjusergui",
"search",
"1");
1146 $link = $this->ctrl->getLinkTargetByClass(array(
"iladministrationgui",
"ilobjusergui"),
"view");
1147 $result_set[$i][
$key] =
"<a href=\"".$link.
"\">".$cell.
"</a>";
1152 if ($cell == $this->lng->txt(
"access_unlimited"))
1154 $result_set[$i][
$key] =
"<span class=\"smallgreen\">".$cell.
"</span>";
1156 elseif (in_array($cell, array($this->lng->txt(
"access_expired"), $this->lng->txt(
"inactive"))))
1158 $result_set[$i][
$key] =
"<span class=\"smallred\">".$cell.
"</span>";
1162 $result_set[$i][
$key] =
"<span class=\"small\">".$cell.
"</span>";
1166 unset($result_set[$i][7]);
1170 $tbl->setData($result_set);
1175 $this->callback_class = $class;
1185 session_unregister(
"saved_post");
1186 $class =& $this->callback_class;
1188 $script = $class->ctrl->getLinkTargetByClass(
'ilAdminUserSearchGUI',
'show');
1196 $_SESSION[
'user_" . $method . "_search'] =
true;
1197 $class =& $this->callback_class;
1198 $class->showActionConfirmation(
$method);
1206 $class =& $this->callback_class;
1208 $class->deleteObject();
1215 $this->ctrl->returnToParent($this);
1221 $ilTabs->addSubTab(
"searchform", $lng->txt(
"search"),
1222 $ilCtrl->getLinkTarget($this,
"showExtended"));
1226 $ilTabs->addSubTab(
"searchresults", $lng->txt(
"search_results"),
1227 $ilCtrl->getLinkTarget($this,
"show"));