25 global $ilUser, $rbacsystem;
27 $this->allow_smtp = $rbacsystem->checkAccess(
'smtp_mail', MAIL_SETTINGS_ID);
28 $this->user_id = $ilUser->getId();
30 $this->result =
new stdClass();
31 $this->result->response =
new stdClass();
32 $this->result->response->results = array();
45 if(count($this->result->response->results) > $this->max_entries)
50 if (isset($this->setMap[$login]))
53 $tmp =
new stdClass();
55 $tmp->firstname = $firstname;
56 $tmp->lastname = $lastname;
58 $this->result->response->results[] = $tmp;
60 $this->setMap[$login] = 1;
80 abook.firstname firstname,
81 abook.lastname lastname,
83 FROM addressbook abook
84 WHERE abook.user_id = ".$ilDB->quote($this->user_id,
'integer').
"
85 AND abook.login IS NOT NULL
86 AND (". $ilDB->like(
'abook.login',
'text', $a_search).
"
87 OR ".$ilDB->like(
'abook.firstname',
'text', $a_search).
"
88 OR ".$ilDB->like(
'abook.lastname',
'text', $a_search).
"
91 $union_query_1 =
"SELECT DISTINCT
93 abook.firstname firstname,
94 abook.lastname lastname,
96 FROM addressbook abook
97 WHERE abook.user_id = ".$ilDB->quote($this->user_id,
'integer').
"
98 AND abook.login IS NULL
99 AND (".$ilDB->like(
'abook.email',
'text', $a_search).
"
100 OR ".$ilDB->like(
'abook.firstname',
'text', $a_search).
"
101 OR ".$ilDB->like(
'abook.lastname',
'text', $a_search).
"
104 $union_query_2 =
"SELECT DISTINCT
110 WHERE ".$ilDB->like(
'mail.rcp_to',
'text', $a_search).
"
111 AND sender_id = ".$ilDB->quote($this->user_id,
'integer').
"
112 AND mail.sender_id = mail.user_id";
115 'addressbook_1' =>
$query,
116 'mail' => $union_query_2
119 if($this->allow_smtp == 1)
120 $queries[
'addressbook_2'] = $union_query_1;
122 include_once
'Services/Utilities/classes/class.ilStr.php';
127 if($ilDB->getDbType() !=
'oracle')
128 $queries[
'all'] = implode(
' UNION ', $queries);
133 if(
'mail' ==
$type && $ilDB->getDbType() ==
'oracle')
138 $ilDB->setLimit(0,20);
139 $query_res = $ilDB->query(
$query );
141 while(
$row = $ilDB->fetchObject($query_res))
143 if(
$row->type ==
'mail')
145 if(strpos(
$row->login,
',') || strpos(
$row->login,
';'))
147 $parts = preg_split(
"/[ ]*[;,][ ]*/", trim(
$row->login));
148 foreach($parts as $part)
170 $result->response->total = count($this->result->response->results);