75 $this->user_id = $a_user_id;
77 $this->table_addr =
'addressbook';
89 $query =
"SELECT * FROM $this->table_addr ".
90 "WHERE (login LIKE '%".addslashes($a_query_str).
"%' ".
91 "OR firstname LIKE '%".addslashes($a_query_str).
"%' ".
92 "OR lastname LIKE '%".addslashes($a_query_str).
"%' ".
93 "OR email LIKE '%".addslashes($a_query_str).
"%') ".
94 "AND user_id = '".$this->user_id.
"'";
98 $query =
"SELECT * FROM $this->table_addr ".
99 "WHERE user_id = '".$this->user_id.
"'";
101 $res = $this->ilias->db->query($query);
105 "login" => ($row->login),
106 "firstname" => ($row->firstname),
107 "lastname" => ($row->lastname),
108 "email" => ($row->email));
110 return $entries ? $entries : array();
121 function addEntry($a_login,$a_firstname,$a_lastname,$a_email)
125 $query =
"INSERT INTO $this->table_addr ".
126 "SET user_id = ".$ilDB->quote($this->user_id).
",".
127 "login = ".$ilDB->quote($a_login).
",".
128 "firstname = ".$ilDB->quote($a_firstname).
",".
129 "lastname = ".$ilDB->quote($a_lastname).
",".
130 "email = ".$ilDB->quote($a_email).
"";
132 $res = $this->ilias->db->query($query);
147 function updateEntry($a_addr_id,$a_login,$a_firstname,$a_lastname,$a_email)
151 $query =
"UPDATE $this->table_addr ".
152 "SET login = ".$ilDB->quote($a_login).
",".
153 "firstname = ".$ilDB->quote($a_firstname).
",".
154 "lastname = ".$ilDB->quote($a_lastname).
",".
155 "email = ".$ilDB->quote($a_email).
" ".
156 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
157 "AND addr_id = ".$ilDB->quote($a_addr_id).
"";
159 $res = $this->ilias->db->query($query);
173 $query =
"SELECT * FROM $this->table_addr ".
174 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ";
178 $query .=
" AND (login LIKE '%".addslashes(trim($this->
getSearchQuery())).
"%' ".
179 "OR firstname LIKE '%".addslashes(trim($this->
getSearchQuery())).
"%' ".
180 "OR lastname LIKE '%".addslashes(trim($this->
getSearchQuery())).
"%' ".
181 "OR email LIKE '%".addslashes(trim($this->
getSearchQuery())).
"%') ";
184 $query .=
" ORDER BY login,lastname";
186 $res = $this->ilias->db->query($query);
190 "addr_id" => $row->addr_id,
191 "login" => ($row->login),
192 "firstname" => ($row->firstname),
193 "lastname" => ($row->lastname),
194 "email" => ($row->email));
196 return $entries ? $entries : array();
208 $query =
"SELECT * FROM $this->table_addr ".
209 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
210 "AND addr_id = ".$ilDB->quote($a_addr_id).
" ";
215 "addr_id" => $row->addr_id,
216 "login" => ($row->login),
217 "firstname" => ($row->firstname),
218 "lastname" => ($row->lastname),
219 "email" => ($row->email));
230 if(is_array($a_entries))
232 foreach($a_entries as $entry)
249 $query =
"DELETE FROM addressbook_mailing_lists_assignments ".
250 "WHERE addr_id = ".$ilDB->quote($a_addr_id).
" ";
251 $this->ilias->db->query($query);
253 $query =
"DELETE FROM $this->table_addr ".
254 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
255 "AND addr_id = ".$ilDB->quote($a_addr_id).
" ";
256 $res = $this->ilias->db->query($query);
273 $query = $ilDB->prepare(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = ? AND login = ?",
274 array(
'integer',
'text'));
276 $result = $ilDB->execute($query, array($this->user_id, $a_login));
277 while($record = $ilDB->fetchAssoc(
$result))
279 return $record[
'addr_id'];
293 $query = $ilDB->prepare(
"SELECT addr_id FROM ".$this->table_addr.
" WHERE user_id = ? AND login = ?",
294 array(
'integer',
'text'));
296 $result = $ilDB->execute($query, array($this->user_id, $a_login));
297 while($record = $ilDB->fetchAssoc(
$result))
299 return $record[
'addr_id'];
308 $this->search_query = $search_query;
312 return $this->search_query;