ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailAddressbook.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 {
11  private $user_id = null;
12 
13  public function __construct()
14  {
15  global $ilUser;
16 
17  $this->user_id = $ilUser->getId();
18  }
19 
20  public function getAddressbookAsync($search)
21  {
22  global $ilDB;
23 
24  $ilDB->setLimit(0,20);
25 
26  $query =
27  'SELECT DISTINCT
28  abook.login login,
29  abook.firstname firstname,
30  abook.lastname lastname
31  FROM addressbook abook
32  WHERE abook.user_id = '.$ilDB->quote($this->user_id, 'integer').'
33  AND ( '. $ilDB->like('abook.login', 'text', $search).'
34  OR '. $ilDB->like('abook.firstname', 'text', $search).'
35  OR '. $ilDB->like('abook.lastname', 'text', $search).'
36  )';
37 
38  $query_res = $ilDB->query($query);
39 
40  $result = new stdClass();
41  $result->response = new stdClass();
42  $result->response->results = array();
43 
44  while ($row = $query_res->fetchRow(DB_FETCHMODE_OBJECT))
45  {
46  $tmp = new stdClass();
47  $tmp->login = $row->login;
48  $tmp->firstname = $row->firstname;
49  $tmp->lastname = $row->lastname;
50  $result->response->results[] = $tmp;
51  }
52  $result->response->total = count($result->response->results);
53 
54  return $result;
55  }
56 }
57 ?>