75 $this->user_id = $a_user_id;
77 $this->table_addr =
'addressbook';
93 $query =
"SELECT * FROM ".$this->table_addr.
"
94 WHERE ( " .$ilDB->like(
'login',
'text',
'%'.$a_query_str.
'%').
"
95 OR " .$ilDB->like(
'firstname',
'text',
'%'.$a_query_str.
'%').
"
96 OR " .$ilDB->like(
'lastname',
'text',
'%'.$a_query_str.
'%').
"
97 OR " .$ilDB->like(
'email',
'text',
'%'.$a_query_str.
'%').
")
98 AND user_id = ".$ilDB->quote($this->user_id,
'integer').
" " ;
105 $res = $ilDB->queryf(
"
106 SELECT * FROM ".$this->table_addr.
" WHERE user_id = %s",
107 array(
'text',
'integer'),
108 array($this->table_addr, $this->user_id));
114 "login" => (
$row->login),
115 "firstname" => (
$row->firstname),
116 "lastname" => (
$row->lastname),
117 "email" => (
$row->email));
119 return $entries ? $entries : array();
130 function addEntry($a_login,$a_firstname,$a_lastname,$a_email)
134 $nextId = $ilDB->nextId($this->table_addr);
135 $statement = $ilDB->manipulateF(
"
136 INSERT INTO ".$this->table_addr.
"
145 VALUES (%s, %s, %s, %s, %s, %s)",
146 array(
'integer',
'integer',
'text',
'text',
'text',
'text'),
147 array($nextId, $this->user_id, $a_login, $a_firstname, $a_lastname, $a_email));
162 function updateEntry($a_addr_id,$a_login,$a_firstname,$a_lastname,$a_email)
165 $statement = $ilDB->manipulateF(
166 "UPDATE ".$this->table_addr .
"
173 array(
'text',
'text',
'text',
'text',
'integer',
'integer'),
174 array($a_login, $a_firstname, $a_lastname, $a_email, $this->user_id, $a_addr_id));
188 $data_types = array();
190 $query = (
"SELECT * FROM ".$this->table_addr.
" WHERE user_id = ".$ilDB->quote($this->user_id,
'integer')).
" ";
194 $sub_query .=
" AND ( %s
199 $query .= sprintf($sub_query, $ilDB->like(
'login',
'text',
'%'.trim($this->getSearchQuery()).
'%'),
200 $ilDB->like(
'firstname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
201 $ilDB->like(
'lastname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
208 $query .=
" ORDER BY login, lastname";
215 "addr_id" =>
$row->addr_id,
216 "login" => (
$row->login),
217 "firstname" => (
$row->firstname),
218 "lastname" => (
$row->lastname),
219 "email" => (
$row->email));
221 return $entries ? $entries : array();
233 $res = $ilDB->queryf(
"
234 SELECT * FROM ".$this->table_addr.
"
237 array(
'integer',
'integer'),
238 array($this->user_id, $a_addr_id));
243 "addr_id" =>
$row->addr_id,
244 "login" => (
$row->login),
245 "firstname" => (
$row->firstname),
246 "lastname" => (
$row->lastname),
247 "email" => (
$row->email));
258 $entry = $this->
getEntry($a_addr_id);
264 if ($entry[
'firstname'] && $entry[
'lastname'])
265 $out .= $entry[
'lastname'] .
', ' . $entry[
'firstname'] .
' ';
266 else if ($entry[
'firstname'])
267 $out .= $entry[
'firstname'] .
' ';
268 else if ($entry[
'lastname'])
269 $out .= $entry[
'lastname'] .
' ';
272 $out .=
'(' . $entry[
'login'] .
') ';
275 $out .=
'[' . $entry[
'email'] .
']';
288 if(is_array($a_entries))
290 foreach($a_entries as $entry)
307 $statement = $ilDB->manipulateF(
'
308 DELETE FROM addressbook_mlist_ass
310 array(
'integer'), array($a_addr_id));
312 $statement = $ilDB->manipulateF(
"
313 DELETE FROM ".$this->table_addr.
"
316 array(
'integer',
'integer'),
317 array($this->user_id, $a_addr_id));
334 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
335 array(
'integer',
'text'), array($this->user_id, $a_login));
337 while($record = $ilDB->fetchAssoc(
$result))
339 return $record[
'addr_id'];
353 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
354 array(
'integer',
'text'), array($this->user_id, $a_login));
356 while($record = $ilDB->fetchAssoc(
$result))
358 return $record[
'addr_id'];
367 $this->search_query = $search_query;
371 return $this->search_query;