ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRepositorySearchGUI Class Reference
+ Collaboration diagram for ilRepositorySearchGUI:

Public Member Functions

 ilRepositorySearchGUI ()
 Constructor public.
 setString ($a_str)
 Set/get search string public.
 getString ()
executeCommand ()
 Control public.
 __clearSession ()
 cancel ()
 start ()
 addUser ()
 setCallback (&$class, $method, $a_add_options=array())
 showSearch ()
 initFormSearch ()
 show ()
 appendSearch ()
 performSearch ()
 Perform a search.
 __performUserSearch ()
 __performGroupSearch ()
 Search groups.
 __performRoleSearch ()
 Search roles.
__parseQueryString ($a_string)
 parse query string, using query parser instance
 __loadQueries ()
 __setSearchType ()
 __updateResults ()
 __appendToStoredResults ($a_usr_ids)
 __storeEntries (&$new_res)
 showSearchResults ()
 userFilter ($a_ref_id, $a_data)

Data Fields

 $search_type = 'usr'

Protected Member Functions

 __performCourseSearch ()
 Search courses.
 addNewSearchButton ()
 Add new search button.
 showSearchUserTable ($a_usr_ids, $a_parent_cmd)
 Show usr table.
 showSearchRoleTable ($a_obj_ids)
 Show usr table.
 showSearchGroupTable ($a_obj_ids)
 showSearchCourseTable ($a_obj_ids)
 listUsers ()
 List users of course/group/roles.
 storedUserList ()
 Called from table sort.

Protected Attributes

 $add_options = array()

Detailed Description

Definition at line 38 of file class.ilRepositorySearchGUI.php.

Member Function Documentation

ilRepositorySearchGUI::__appendToStoredResults (   $a_usr_ids)

Definition at line 495 of file class.ilRepositorySearchGUI.php.

References $_SESSION, and $usr_id.

Referenced by listUsers().

{
if(!$_SESSION['search_append'])
{
return $_SESSION['rep_search']['usr'] = $a_usr_ids;
}
foreach($a_usr_ids as $usr_id)
{
$_SESSION['rep_search']['usr'][] = $usr_id;
}
return $_SESSION['rep_search']['usr'] ? array_unique($_SESSION['rep_search']['usr']) : array();
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__clearSession ( )

Definition at line 105 of file class.ilRepositorySearchGUI.php.

References $_SESSION.

Referenced by start().

{
unset($_SESSION['rep_search']);
unset($_SESSION['append_results']);
unset($_SESSION['rep_query']);
unset($_SESSION['rep_search_type']);
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__loadQueries ( )

Definition at line 443 of file class.ilRepositorySearchGUI.php.

References $_POST, and $_SESSION.

Referenced by ilRepositorySearchGUI().

{
if(is_array($_POST['rep_query']))
{
$_SESSION['rep_query'] = $_POST['rep_query'];
}
}

+ Here is the caller graph for this function:

& ilRepositorySearchGUI::__parseQueryString (   $a_string)

parse query string, using query parser instance

Returns
object of query parser or error message if an error occured public

Definition at line 426 of file class.ilRepositorySearchGUI.php.

References QP_COMBINATION_OR, and ilUtil\stripSlashes().

Referenced by __performCourseSearch(), __performGroupSearch(), __performRoleSearch(), and __performUserSearch().

{
include_once 'Services/Search/classes/class.ilQueryParser.php';
$query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
$query_parser->setCombination(QP_COMBINATION_OR);
$query_parser->setMinWordLength(1,true);
$query_parser->parse();
if(!$query_parser->validate())
{
return $query_parser->getMessage();
}
return $query_parser;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__performCourseSearch ( )
protected

Search courses.

Returns

Definition at line 378 of file class.ilRepositorySearchGUI.php.

References $_SESSION, __parseQueryString(), __storeEntries(), and ilUtil\sendInfo().

Referenced by performSearch().

{
include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
$query_string = $_SESSION['rep_query']['crs']['title'];
if(!is_object($query_parser = $this->__parseQueryString($query_string)))
{
ilUtil::sendInfo($query_parser,true);
return false;
}
include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
$object_search = new ilLikeObjectSearch($query_parser);
$object_search->setFilter(array('crs'));
$this->__storeEntries($object_search->performSearch());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__performGroupSearch ( )

Search groups.

Returns

Definition at line 355 of file class.ilRepositorySearchGUI.php.

References $_SESSION, __parseQueryString(), __storeEntries(), and ilUtil\sendInfo().

Referenced by performSearch().

{
include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
$query_string = $_SESSION['rep_query']['grp']['title'];
if(!is_object($query_parser = $this->__parseQueryString($query_string)))
{
ilUtil::sendInfo($query_parser,true);
return false;
}
include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
$object_search = new ilLikeObjectSearch($query_parser);
$object_search->setFilter(array('grp'));
$this->__storeEntries($object_search->performSearch());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__performRoleSearch ( )

Search roles.

Returns

Definition at line 401 of file class.ilRepositorySearchGUI.php.

References $_SESSION, __parseQueryString(), __storeEntries(), and ilUtil\sendInfo().

Referenced by performSearch().

{
include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
$query_string = $_SESSION['rep_query']['role']['title'];
if(!is_object($query_parser = $this->__parseQueryString($query_string)))
{
ilUtil::sendInfo($query_parser,true);
return false;
}
// Perform like search
include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
$object_search = new ilLikeObjectSearch($query_parser);
$object_search->setFilter(array('role'));
$this->__storeEntries($object_search->performSearch());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__performUserSearch ( )

Definition at line 305 of file class.ilRepositorySearchGUI.php.

References $_SESSION, $name, __parseQueryString(), __storeEntries(), ilUserSearchOptions\_getSearchableFieldsInfo(), ilObjectSearchFactory\_getUserDefinedFieldSearchInstance(), ilObjectSearchFactory\_getUserSearchInstance(), FIELD_TYPE_SELECT, FIELD_TYPE_TEXT, FIELD_TYPE_UDF_SELECT, FIELD_TYPE_UDF_TEXT, and ilUtil\sendInfo().

Referenced by performSearch().

{
include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
{
$name = $info['db'];
$query_string = $_SESSION['rep_query']['usr'][$name];
// continue if no query string is given
if(!$query_string)
{
continue;
}
if(!is_object($query_parser = $this->__parseQueryString($query_string)))
{
ilUtil::sendInfo($query_parser);
return false;
}
switch($info['type'])
{
$udf_search->setFields(array($name));
$result_obj = $udf_search->performSearch();
// Store entries
$this->__storeEntries($result_obj);
break;
$user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
$user_search->setFields(array($name));
$result_obj = $user_search->performSearch();
// store entries
$this->__storeEntries($result_obj);
break;
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__setSearchType ( )

Definition at line 452 of file class.ilRepositorySearchGUI.php.

References $_POST, and $_SESSION.

Referenced by ilRepositorySearchGUI().

{
// Update search type. Default to user search
if($_POST['search_for'])
{
#echo 1;
$_SESSION['rep_search_type'] = $_POST['search_for'];
}
if(!$_POST['search_for'] and !$_SESSION['rep_search_type'])
{
#echo 2;
$_SESSION['rep_search_type'] = 'usr';
}
$this->search_type = $_SESSION['rep_search_type'];
#echo $this->search_type;
return true;
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__storeEntries ( $new_res)

Definition at line 508 of file class.ilRepositorySearchGUI.php.

Referenced by __performCourseSearch(), __performGroupSearch(), __performRoleSearch(), and __performUserSearch().

{
if($this->stored == false)
{
$this->result_obj->mergeEntries($new_res);
$this->stored = true;
return true;
}
else
{
$this->result_obj->intersectEntries($new_res);
return true;
}
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::__updateResults ( )

Definition at line 473 of file class.ilRepositorySearchGUI.php.

References $_SESSION, $result, and $search_type.

Referenced by performSearch().

{
if(!$_SESSION['search_append'])
{
$_SESSION['rep_search'] = array();
}
foreach($this->result_obj->getResults() as $result)
{
$_SESSION['rep_search'][$this->search_type][] = $result['obj_id'];
}
if(!$_SESSION['rep_search'][$this->search_type])
{
$_SESSION['rep_search'][$this->search_type] = array();
}
else
{
// remove duplicate entries
$_SESSION['rep_search'][$this->search_type] = array_unique($_SESSION['rep_search'][$this->search_type]);
}
return true;
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::addNewSearchButton ( )
protected

Add new search button.

Returns

Definition at line 527 of file class.ilRepositorySearchGUI.php.

Referenced by listUsers(), and showSearchResults().

{
include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
$toolbar = new ilToolbarGUI();
$toolbar->addButton(
$this->lng->txt('search_new'),
$this->ctrl->getLinkTarget($this,'showSearch')
);
$this->tpl->setVariable('ACTION_BUTTONS',$toolbar->getHTML());
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::addUser ( )

Definition at line 129 of file class.ilRepositorySearchGUI.php.

References $_POST, $method, and showSearchResults().

{
// call callback if that function does give a return value => show error message
$class =& $this->callback['class'];
$method = $this->callback['method'];
// listener redirects if everything is ok.
$class->$method($_POST['user']);
}

+ Here is the call graph for this function:

ilRepositorySearchGUI::appendSearch ( )

Definition at line 229 of file class.ilRepositorySearchGUI.php.

References $_SESSION, and performSearch().

{
$_SESSION['search_append'] = true;
$this->performSearch();
}

+ Here is the call graph for this function:

ilRepositorySearchGUI::cancel ( )

Definition at line 114 of file class.ilRepositorySearchGUI.php.

{
$this->ctrl->returnToParent($this);
}
& ilRepositorySearchGUI::executeCommand ( )

Control public.

Definition at line 85 of file class.ilRepositorySearchGUI.php.

References $cmd.

{
global $rbacsystem;
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->ctrl->getCmd();
switch($next_class)
{
default:
if(!$cmd)
{
$cmd = "showSearch";
}
$this->$cmd();
break;
}
return true;
}
ilRepositorySearchGUI::getString ( )

Definition at line 76 of file class.ilRepositorySearchGUI.php.

{
return $this->string;
}
ilRepositorySearchGUI::ilRepositorySearchGUI ( )

Constructor public.

Definition at line 48 of file class.ilRepositorySearchGUI.php.

References $ilCtrl, $lng, $tpl, __loadQueries(), and __setSearchType().

{
global $ilCtrl,$tpl,$lng;
$this->ctrl =& $ilCtrl;
$this->tpl =& $tpl;
$this->lng =& $lng;
$this->lng->loadLanguageModule('search');
$this->lng->loadLanguageModule('crs');
$this->__setSearchType();
$this->__loadQueries();
$this->result_obj = new ilSearchResult();
$this->result_obj->setMaxHits(1000000);
$this->settings =& new ilSearchSettings();
}

+ Here is the call graph for this function:

ilRepositorySearchGUI::initFormSearch ( )

Definition at line 152 of file class.ilRepositorySearchGUI.php.

References ilUserSearchOptions\_getSearchableFieldsInfo(), ilRadioOption\addSubItem(), FIELD_TYPE_SELECT, FIELD_TYPE_TEXT, FIELD_TYPE_UDF_SELECT, FIELD_TYPE_UDF_TEXT, and ilRadioGroupInputGUI\setValue().

Referenced by showSearch().

{
include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
$this->form = new ilPropertyFormGUI();
$this->form->setFormAction($this->ctrl->getFormAction($this,'search'));
$this->form->setTitle($this->lng->txt('add_members_header'));
$this->form->addCommandButton('performSearch', $this->lng->txt('search'));
$this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
$kind = new ilRadioGroupInputGUI($this->lng->txt('search_type'),'search_for');
$kind->setValue($this->search_type);
$this->form->addItem($kind);
// Users
$users = new ilRadioOption($this->lng->txt('search_for_users'),'usr');
// UDF
include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
{
switch($info['type'])
{
$sel = new ilSelectInputGUI($info['lang'],"rep_query[usr][".$info['db']."]");
$sel->setOptions($info['values']);
$users->addSubItem($sel);
break;
$txt = new ilTextInputGUI($info['lang'],"rep_query[usr][".$info['db']."]");
$txt->setSize(30);
$txt->setMaxLength(120);
$users->addSubItem($txt);
break;
}
}
$kind->addOption($users);
// Role
$roles = new ilRadioOption($this->lng->txt('search_for_role_members'),'role');
$role = new ilTextInputGUI($this->lng->txt('search_role_title'),'rep_query[role][title]');
$role->setSize(30);
$role->setMaxLength(120);
$roles->addSubItem($role);
$kind->addOption($roles);
// Course
$groups = new ilRadioOption($this->lng->txt('search_for_crs_members'),'crs');
$group = new ilTextInputGUI($this->lng->txt('search_crs_title'),'rep_query[crs][title]');
$group->setSize(30);
$group->setMaxLength(120);
$groups->addSubItem($group);
$kind->addOption($groups);
// Group
$groups = new ilRadioOption($this->lng->txt('search_for_grp_members'),'grp');
$group = new ilTextInputGUI($this->lng->txt('search_grp_title'),'rep_query[grp][title]');
$group->setSize(30);
$group->setMaxLength(120);
$groups->addSubItem($group);
$kind->addOption($groups);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::listUsers ( )
protected

List users of course/group/roles.

Returns

Definition at line 631 of file class.ilRepositorySearchGUI.php.

References $_GET, $_POST, $_SESSION, $type, __appendToStoredResults(), ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupType(), addNewSearchButton(), ilUtil\sendFailure(), showSearchResults(), and showSearchUserTable().

Referenced by storedUserList().

{
// get parameter is used e.g. in exercises to provide
// "add members of course" link
if ($_GET["list_obj"] != "" && !is_array($_POST['obj']))
{
$_POST['obj'][0] = $_GET["list_obj"];
}
if(!is_array($_POST['obj']) or !$_POST['obj'])
{
ilUtil::sendFailure($this->lng->txt('select_one'));
return false;
}
$_SESSION['rep_search']['objs'] = $_POST['obj'];
// Get all members
$members = array();
foreach($_POST['obj'] as $obj_id)
{
switch($type)
{
case 'crs':
include_once './Modules/Course/classes/class.ilCourseParticipants.php';
$members = array_merge($members, $part->getParticipants());
break;
case 'grp':
include_once './Modules/Group/classes/class.ilGroupParticipants.php';
$members = array_merge($members, $part->getParticipants());
break;
case 'role':
global $rbacreview;
$members = array_merge($members, $rbacreview->assignedUsers($obj_id));
break;
}
}
$members = array_unique((array) $members);
$this->__appendToStoredResults($members);
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.rep_search_result.html','Services/Search');
$this->showSearchUserTable($_SESSION['rep_search']['usr'],'storedUserList');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::performSearch ( )

Perform a search.

Returns

Definition at line 239 of file class.ilRepositorySearchGUI.php.

References $_POST, $_SESSION, __performCourseSearch(), __performGroupSearch(), __performRoleSearch(), __performUserSearch(), __updateResults(), QP_COMBINATION_OR, ilUtil\sendFailure(), ilUtil\sendInfo(), show(), showSearch(), start(), and ilUtil\stripSlashes().

Referenced by appendSearch().

{
$found_query = false;
foreach((array) $_POST['rep_query'][$_POST['search_for']] as $field => $value)
{
if(trim(ilUtil::stripSlashes($value)))
{
$found_query = true;
break;
}
}
if(!$found_query)
{
ilUtil::sendFailure($this->lng->txt('msg_no_search_string'));
$this->start();
return false;
}
// unset search_append if called directly
if($_POST['cmd']['performSearch'])
{
unset($_SESSION['search_append']);
}
switch($this->search_type)
{
case 'usr':
break;
case 'grp':
break;
case 'crs':
break;
case 'role':
break;
default:
echo 'not defined';
}
$this->result_obj->addObserver($this, 'userFilter');
$this->result_obj->filter(ROOT_FOLDER_ID,QP_COMBINATION_OR);
if(!count($this->result_obj->getResults()))
{
ilUtil::sendFailure($this->lng->txt('search_no_match'));
$this->showSearch();
return true;
}
$this->__updateResults();
if($this->result_obj->isLimitReached())
{
$message = sprintf($this->lng->txt('search_limit_reached'),$this->settings->getMaxHits());
ilUtil::sendInfo($message);
return true;
}
// show results
$this->show();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::setCallback ( $class,
  $method,
  $a_add_options = array() 
)

Definition at line 140 of file class.ilRepositorySearchGUI.php.

References $method.

{
$this->callback = array('class' => $class,'method' => $method);
$this->add_options = $a_add_options ? $a_add_options : array();
}
ilRepositorySearchGUI::setString (   $a_str)

Set/get search string public.

Definition at line 72 of file class.ilRepositorySearchGUI.php.

References $_SESSION.

{
$_SESSION['search']['string'] = $this->string = $a_str;
}
ilRepositorySearchGUI::show ( )

Definition at line 224 of file class.ilRepositorySearchGUI.php.

References showSearchResults().

Referenced by performSearch().

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearch ( )

Definition at line 146 of file class.ilRepositorySearchGUI.php.

References initFormSearch().

Referenced by performSearch(), and start().

{
$this->initFormSearch();
$this->tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearchCourseTable (   $a_obj_ids)
protected
Returns
Parameters
array$a_obj_ids

Definition at line 617 of file class.ilRepositorySearchGUI.php.

Referenced by showSearchResults().

{
include_once './Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
$table = new ilRepositoryObjectResultTableGUI($this,'showSearchResults');
$table->parseObjectIds($a_obj_ids);
$this->tpl->setVariable('RES_TABLE',$table->getHTML());
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearchGroupTable (   $a_obj_ids)
protected
Returns
Parameters
array$a_obj_ids

Definition at line 602 of file class.ilRepositorySearchGUI.php.

Referenced by showSearchResults().

{
include_once './Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
$table = new ilRepositoryObjectResultTableGUI($this,'showSearchResults');
$table->parseObjectIds($a_obj_ids);
$this->tpl->setVariable('RES_TABLE',$table->getHTML());
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearchResults ( )

Definition at line 538 of file class.ilRepositorySearchGUI.php.

References $_SESSION, addNewSearchButton(), showSearchCourseTable(), showSearchGroupTable(), showSearchRoleTable(), and showSearchUserTable().

Referenced by addUser(), listUsers(), and show().

{
$counter = 0;
$f_result = array();
$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.rep_search_result.html','Services/Search');
switch($this->search_type)
{
case "usr":
$this->showSearchUserTable($_SESSION['rep_search']['usr'],'showSearchResults');
break;
case 'grp':
$this->showSearchGroupTable($_SESSION['rep_search']['grp']);
break;
case 'crs':
$this->showSearchCourseTable($_SESSION['rep_search']['crs']);
break;
case 'role':
$this->showSearchRoleTable($_SESSION['rep_search']['role']);
break;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearchRoleTable (   $a_obj_ids)
protected

Show usr table.

Returns
Parameters
object$a_usr_ids

Definition at line 587 of file class.ilRepositorySearchGUI.php.

Referenced by showSearchResults().

{
include_once './Services/Search/classes/class.ilRepositoryObjectResultTableGUI.php';
$table = new ilRepositoryObjectResultTableGUI($this,'showSearchResults');
$table->parseObjectIds($a_obj_ids);
$this->tpl->setVariable('RES_TABLE',$table->getHTML());
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::showSearchUserTable (   $a_usr_ids,
  $a_parent_cmd 
)
protected

Show usr table.

Returns
Parameters
object$a_usr_ids

Definition at line 571 of file class.ilRepositorySearchGUI.php.

Referenced by listUsers(), and showSearchResults().

{
include_once './Services/Search/classes/class.ilRepositoryUserResultTableGUI.php';
$table = new ilRepositoryUserResultTableGUI($this,$a_parent_cmd);
$table->initMultiCommands($this->add_options);
$table->parseUserIds($a_usr_ids);
$this->tpl->setVariable('RES_TABLE',$table->getHTML());
}

+ Here is the caller graph for this function:

ilRepositorySearchGUI::start ( )

Definition at line 119 of file class.ilRepositorySearchGUI.php.

References __clearSession(), and showSearch().

Referenced by performSearch().

{
// delete all session info
$this->__clearSession();
$this->showSearch();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRepositorySearchGUI::storedUserList ( )
protected

Called from table sort.

Returns

Definition at line 688 of file class.ilRepositorySearchGUI.php.

References $_POST, $_SESSION, and listUsers().

{
$_POST['obj'] = $_SESSION['rep_search']['objs'];
$this->listUsers();
return true;
}

+ Here is the call graph for this function:

ilRepositorySearchGUI::userFilter (   $a_ref_id,
  $a_data 
)
Parameters
int$a_ref_id
array$a_data
Returns

Definition at line 701 of file class.ilRepositorySearchGUI.php.

{
if($a_data['type'] == 'usr')
{
if($a_data['obj_id'] == ANONYMOUS_USER_ID)
{
return false;
}
}
return true;
}

Field Documentation

ilRepositorySearchGUI::$add_options = array()
protected

Definition at line 40 of file class.ilRepositorySearchGUI.php.

ilRepositorySearchGUI::$search_type = 'usr'

Definition at line 42 of file class.ilRepositorySearchGUI.php.

Referenced by __updateResults().


The documentation for this class was generated from the following file: