75 $this->user_id = $a_user_id;
77 $this->table_addr =
'addressbook';
93 $a_query_str = str_replace(
'%',
'\%', $a_query_str);
94 $a_query_str = str_replace(
'_',
'\_', $a_query_str);
96 $query =
"SELECT * FROM ".$this->table_addr.
"
97 WHERE ( " .$ilDB->like(
'login',
'text',
'%'.$a_query_str.
'%').
"
98 OR " .$ilDB->like(
'firstname',
'text',
'%'.$a_query_str.
'%').
"
99 OR " .$ilDB->like(
'lastname',
'text',
'%'.$a_query_str.
'%').
"
100 OR " .$ilDB->like(
'email',
'text',
'%'.$a_query_str.
'%').
")
101 AND user_id = ".$ilDB->quote($this->user_id,
'integer').
" " ;
108 $res = $ilDB->queryf(
"
109 SELECT * FROM ".$this->table_addr.
" WHERE user_id = %s",
111 array($this->user_id)
118 "login" => (
$row->login),
119 "firstname" => (
$row->firstname),
120 "lastname" => (
$row->lastname),
121 "email" => (
$row->email));
123 return $entries ? $entries : array();
134 function addEntry($a_login,$a_firstname,$a_lastname,$a_email)
138 $nextId = $ilDB->nextId($this->table_addr);
139 $statement = $ilDB->manipulateF(
"
140 INSERT INTO ".$this->table_addr.
"
149 VALUES (%s, %s, %s, %s, %s, %s)",
150 array(
'integer',
'integer',
'text',
'text',
'text',
'text'),
151 array($nextId, $this->user_id, $a_login, $a_firstname, $a_lastname, $a_email));
166 function updateEntry($a_addr_id,$a_login,$a_firstname,$a_lastname,$a_email)
169 $statement = $ilDB->manipulateF(
170 "UPDATE ".$this->table_addr .
"
177 array(
'text',
'text',
'text',
'text',
'integer',
'integer'),
178 array($a_login, $a_firstname, $a_lastname, $a_email, $this->user_id, $a_addr_id));
192 $data_types = array();
194 $query = (
"SELECT * FROM ".$this->table_addr.
" WHERE user_id = ".$ilDB->quote($this->user_id,
'integer')).
" ";
198 $sub_query .=
" AND ( %s
203 $query .= sprintf($sub_query, $ilDB->like(
'login',
'text',
'%'.trim($this->getSearchQuery()).
'%'),
204 $ilDB->like(
'firstname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
205 $ilDB->like(
'lastname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
212 $query .=
" ORDER BY login, lastname";
219 "addr_id" =>
$row->addr_id,
220 "login" => (
$row->login),
221 "firstname" => (
$row->firstname),
222 "lastname" => (
$row->lastname),
223 "email" => (
$row->email));
225 return $entries ? $entries : array();
237 $res = $ilDB->queryf(
"
238 SELECT * FROM ".$this->table_addr.
"
241 array(
'integer',
'integer'),
242 array($this->user_id, $a_addr_id));
247 "addr_id" =>
$row->addr_id,
248 "login" => (
$row->login),
249 "firstname" => (
$row->firstname),
250 "lastname" => (
$row->lastname),
251 "email" => (
$row->email));
262 $entry = $this->
getEntry($a_addr_id);
268 if ($entry[
'firstname'] && $entry[
'lastname'])
269 $out .= $entry[
'lastname'] .
', ' . $entry[
'firstname'] .
' ';
270 else if ($entry[
'firstname'])
271 $out .= $entry[
'firstname'] .
' ';
272 else if ($entry[
'lastname'])
273 $out .= $entry[
'lastname'] .
' ';
276 $out .=
'(' . $entry[
'login'] .
') ';
279 $out .=
'[' . $entry[
'email'] .
']';
292 if(is_array($a_entries))
294 foreach($a_entries as $entry)
311 $statement = $ilDB->manipulateF(
'
312 DELETE FROM addressbook_mlist_ass
314 array(
'integer'), array($a_addr_id));
316 $statement = $ilDB->manipulateF(
"
317 DELETE FROM ".$this->table_addr.
"
320 array(
'integer',
'integer'),
321 array($this->user_id, $a_addr_id));
338 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
339 array(
'integer',
'text'), array($this->user_id, $a_login));
341 while($record = $ilDB->fetchAssoc(
$result))
343 return $record[
'addr_id'];
357 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
358 array(
'integer',
'text'), array($this->user_id, $a_login));
360 while($record = $ilDB->fetchAssoc(
$result))
362 return $record[
'addr_id'];
371 $this->search_query = $search_query;
375 return $this->search_query;