ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSearchAutoComplete Class Reference

Search Auto Completion Application Class. More...

+ Collaboration diagram for ilSearchAutoComplete:

Static Public Member Functions

static getList ($a_str)
 Get completion list.
static checkObjectPermission ($a_obj_id)
 Checks read permission on obj id.

Detailed Description

Search Auto Completion Application Class.

Definition at line 10 of file class.ilSearchAutoComplete.php.

Member Function Documentation

static ilSearchAutoComplete::checkObjectPermission (   $a_obj_id)
static

Checks read permission on obj id.

Definition at line 97 of file class.ilSearchAutoComplete.php.

References ilObject\_getAllReferences().

Referenced by getList().

{
global $ilAccess;
$refs = ilObject::_getAllReferences($a_obj_id);
foreach ($refs as $ref)
{
if ($ilAccess->checkAccess("read", "", $ref))
{
return true;
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSearchAutoComplete::getList (   $a_str)
static

Get completion list.

Definition at line 15 of file class.ilSearchAutoComplete.php.

References $ilDB, $l, checkObjectPermission(), and ilJsonUtil\encode().

Referenced by ilSearchGUI\autoComplete(), and ilSearchBaseGUI\autoComplete().

{
global $ilDB;
include_once './Services/JSON/classes/class.ilJsonUtil.php';
$result = new stdClass();
$result->response = new stdClass();
$result->response->results = array();
if (strlen($a_str) < 3)
{
return ilJsonUtil::encode($result);
}
$a_str = str_replace('"', "", $a_str);
$settings = new ilSearchSettings();
$object_types = array('cat','dbk','crs','fold','grp','lm','sahs','glo','mep','htlm','exc','file','qpl','tst','svy','spl',
'icrs','icla','webr','mcst','sess','pg','st');
$set = $ilDB->query("SELECT title, obj_id FROM object_data WHERE "
.$ilDB->like('title', 'text', $a_str."%")." AND "
.$ilDB->in('type', $object_types, false, 'text')." ORDER BY title");
$max = ($settings->getAutoCompleteLength() > 0)
? $settings->getAutoCompleteLength()
: 10;
$cnt = 0;
$list = array();
$checked = array();
$lim = "";
while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max)
{
if (!in_array($rec["title"], $list) && !in_array($rec["obj_id"], $checked))
{
{
if (strpos($rec["title"], " ") > 0 || strpos($rec["title"], "-") > 0)
{
$rec["title"] = '"'.$rec["title"].'"';
}
$list[] = $lim.$rec["title"];
$cnt++;
}
$checked[] = $rec["obj_id"];
}
}
$set = $ilDB->query("SELECT rbac_id,obj_id,obj_type, keyword FROM il_meta_keyword WHERE "
.$ilDB->like('keyword', 'text', $a_str."%")." AND "
.$ilDB->in('obj_type', $object_types, false, 'text')." ORDER BY keyword");
while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max)
{
if (!in_array($rec["keyword"], $list) && !in_array($rec["rbac_id"], $checked))
{
{
if (strpos($rec["keyword"], " ") > 0)
{
$rec["keyword"] = '"'.$rec["keyword"].'"';
}
$list[] = $lim.$rec["keyword"];
$cnt++;
}
}
$checked[] = $rec["rbac_id"];
}
$i = 0;
foreach ($list as $l)
{
$result->response->results[$i] = new stdClass();
$result->response->results[$i]->term = $l;
$i++;
}
return ilJsonUtil::encode($result);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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