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();
135 public function addEntry($a_login,$a_firstname,$a_lastname,$a_email, $a_auto_update = 0)
139 $nextId = $ilDB->nextId($this->table_addr);
141 INSERT INTO ".$this->table_addr.
"
151 VALUES (%s, %s, %s, %s, %s, %s, %s)",
152 array(
'integer',
'integer',
'text',
'text',
'text',
'text',
'integer'),
153 array($nextId, $this->user_id, $a_login, $a_firstname, $a_lastname, $a_email, $a_auto_update));
169 public function updateEntry($a_addr_id,$a_login,$a_firstname,$a_lastname,$a_email, $a_auto_update = 0)
172 $statement = $ilDB->manipulateF(
173 "UPDATE ".$this->table_addr .
"
181 array(
'text',
'text',
'text',
'text',
'integer',
'integer',
'integer'),
182 array($a_login, $a_firstname, $a_lastname, $a_email, $a_auto_update, $this->user_id, $a_addr_id));
196 $data_types = array();
198 $query = (
"SELECT * FROM ".$this->table_addr.
" WHERE user_id = ".$ilDB->quote($this->user_id,
'integer')).
" ";
202 $sub_query .=
" AND ( %s
207 $query .= sprintf($sub_query, $ilDB->like(
'login',
'text',
'%'.trim($this->getSearchQuery()).
'%'),
208 $ilDB->like(
'firstname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
209 $ilDB->like(
'lastname',
'text',
'%'.trim($this->
getSearchQuery()).
'%'),
216 $query .=
" ORDER BY login, lastname";
218 $res = $ilDB->query(
$query, $data_types, $data);
220 while(
$row = $ilDB->fetchObject(
$res))
223 "addr_id" =>
$row->addr_id,
224 "login" => (
$row->login),
225 "firstname" => (
$row->firstname),
226 "lastname" => (
$row->lastname),
227 "email" => (
$row->email),
228 "auto_update"=>
$row->auto_update
231 return $entries ? $entries : array();
243 $res = $ilDB->queryf(
"
244 SELECT * FROM ".$this->table_addr.
"
247 array(
'integer',
'integer'),
248 array($this->user_id, $a_addr_id));
253 "addr_id" =>
$row->addr_id,
254 "login" => (
$row->login),
255 "firstname" => (
$row->firstname),
256 "lastname" => (
$row->lastname),
257 "email" => (
$row->email),
258 "auto_update"=>
$row->auto_update
270 $entry = $this->
getEntry($a_addr_id);
276 if ($entry[
'firstname'] && $entry[
'lastname'])
277 $out .= $entry[
'lastname'] .
', ' . $entry[
'firstname'] .
' ';
278 else if ($entry[
'firstname'])
279 $out .= $entry[
'firstname'] .
' ';
280 else if ($entry[
'lastname'])
281 $out .= $entry[
'lastname'] .
' ';
284 $out .=
'(' . $entry[
'login'] .
') ';
287 $out .=
'[' . $entry[
'email'] .
']';
300 if(is_array($a_entries))
302 foreach($a_entries as $entry)
319 $statement = $ilDB->manipulateF(
'
320 DELETE FROM addressbook_mlist_ass
322 array(
'integer'), array($a_addr_id));
324 $statement = $ilDB->manipulateF(
"
325 DELETE FROM ".$this->table_addr.
"
328 array(
'integer',
'integer'),
329 array($this->user_id, $a_addr_id));
346 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
347 array(
'integer',
'text'), array($this->user_id, $a_login));
349 while($record = $ilDB->fetchAssoc(
$result))
351 return $record[
'addr_id'];
365 $result = $ilDB->queryf(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = %s AND login = %s",
366 array(
'integer',
'text'), array($this->user_id, $a_login));
368 while($record = $ilDB->fetchAssoc(
$result))
370 return $record[
'addr_id'];
379 $this->search_query = $search_query;
383 return $this->search_query;
389 public static function onUserDeletion(
ilObjUser $usr)
397 'UPDATE addressbook SET login = NULL, auto_update = %s WHERE login = %s AND email IS NOT NULL',
398 array(
'integer',
'text'),
403 'DELETE FROM addressbook_mlist_ass WHERE addr_id IN(
404 SELECT addr_id FROM addressbook WHERE login = %s AND email IS NULL
411 'DELETE FROM addressbook WHERE login = %s AND email IS NULL',
421 public static function onLoginNameChange($from, $to)
429 'UPDATE addressbook SET login = %s WHERE login = %s',
430 array(
'text',
'text'),