ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAddressbook Class Reference

Mail Box class Base class for creating and handling mail boxes. More...

+ Collaboration diagram for ilAddressbook:

Public Member Functions

 ilAddressbook ($a_user_id=0)
 Constructor. More...
 
 searchUsers ($a_query_str)
 Search users in addressbook // tab: compose -> search user. More...
 
 addEntry ($a_login, $a_firstname, $a_lastname, $a_email, $a_auto_update=0)
 add entry More...
 
 updateEntry ($a_addr_id, $a_login, $a_firstname, $a_lastname, $a_email, $a_auto_update=0)
 update entry More...
 
 getEntries ()
 get all entries the user More...
 
 getEntry ($a_addr_id)
 get all entries the user More...
 
 entryToString ($a_addr_id)
 returns a readable string representation of a given entry More...
 
 deleteEntries ($a_entries)
 delete some entries of user More...
 
 deleteEntry ($a_addr_id)
 delete one entry More...
 
 checkEntry ($a_login)
 Check whether an entry with a given login name already exists. More...
 
 checkEntryByLogin ($a_login)
 
 setSearchQuery ($search_query='')
 
 getSearchQuery ()
 

Data Fields

 $ilias
 
 $lng
 
 $user_id
 
 $table_addr
 

Detailed Description

Mail Box class Base class for creating and handling mail boxes.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilAddressbook.php.

Member Function Documentation

◆ addEntry()

ilAddressbook::addEntry (   $a_login,
  $a_firstname,
  $a_lastname,
  $a_email,
  $a_auto_update = 0 
)

add entry

Parameters
stringlogin
stringfirstname
stringlastname
stringemail
int$a_auto_update
Returns
boolean public

Definition at line 135 of file class.ilAddressbook.php.

136  {
137  global $ilDB;
138 
139  $nextId = $ilDB->nextId($this->table_addr); //addr_id,
140  $ilDB->manipulateF("
141  INSERT INTO ".$this->table_addr."
142  (
143  addr_id,
144  user_id,
145  login,
146  firstname,
147  lastname,
148  email,
149  auto_update
150  )
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));
154 
155  return true;
156  }

◆ checkEntry()

ilAddressbook::checkEntry (   $a_login)

Check whether an entry with a given login name already exists.

Parameters
stringlogin name
Returns
int number of entries found public

Definition at line 340 of file class.ilAddressbook.php.

References $result.

341  {
342  global $ilDB;
343 
344  if ($a_login != '')
345  {
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));
348 
349  while($record = $ilDB->fetchAssoc($result))
350  {
351  return $record['addr_id'];
352  }
353  }
354 
355  return 0;
356  }
$result

◆ checkEntryByLogin()

ilAddressbook::checkEntryByLogin (   $a_login)

Definition at line 359 of file class.ilAddressbook.php.

References $result.

360  {
361  global $ilDB;
362 
363  if ($a_login != "")
364  {
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));
367 
368  while($record = $ilDB->fetchAssoc($result))
369  {
370  return $record['addr_id'];
371  }
372  }
373 
374  return 0;
375  }
$result

◆ deleteEntries()

ilAddressbook::deleteEntries (   $a_entries)

delete some entries of user

Parameters
arrayarray of entry ids
Returns
boolean public

Definition at line 298 of file class.ilAddressbook.php.

References deleteEntry().

299  {
300  if(is_array($a_entries))
301  {
302  foreach($a_entries as $entry)
303  {
304  $this->deleteEntry($entry);
305  }
306  }
307  return true;
308  }
deleteEntry($a_addr_id)
delete one entry
+ Here is the call graph for this function:

◆ deleteEntry()

ilAddressbook::deleteEntry (   $a_addr_id)

delete one entry

Parameters
integeraddr id
Returns
boolean public

Definition at line 315 of file class.ilAddressbook.php.

Referenced by deleteEntries().

316  {
317  global $ilDB;
318 
319  $statement = $ilDB->manipulateF('
320  DELETE FROM addressbook_mlist_ass
321  WHERE addr_id = %s',
322  array('integer'), array($a_addr_id));
323 
324  $statement = $ilDB->manipulateF("
325  DELETE FROM ".$this->table_addr."
326  WHERE user_id = %s
327  AND addr_id = %s",
328  array('integer', 'integer'),
329  array($this->user_id, $a_addr_id));
330 
331  return true;
332  }
+ Here is the caller graph for this function:

◆ entryToString()

ilAddressbook::entryToString (   $a_addr_id)

returns a readable string representation of a given entry

Parameters
integeraddress_id
Returns
string formated string public

Definition at line 268 of file class.ilAddressbook.php.

References $out, and getEntry().

269  {
270  $entry = $this->getEntry($a_addr_id);
271  if (!$entry)
272  return "???";
273  else
274  {
275  $out = "";
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'] . ' ';
282 
283  if ($entry['login'])
284  $out .= '(' . $entry['login'] . ') ';
285 
286  if ($entry['email'])
287  $out .= '[' . $entry['email'] . ']';
288  return $out;
289  }
290  }
getEntry($a_addr_id)
get all entries the user
+ Here is the call graph for this function:

◆ getEntries()

ilAddressbook::getEntries ( )

get all entries the user

Returns
array array of entries found in addressbook public

Definition at line 192 of file class.ilAddressbook.php.

References $data, $query, $res, $row, and getSearchQuery().

193  {
194  global $ilDB;
195 
196  $data_types = array();
197  $data = array();
198  $query = ("SELECT * FROM ".$this->table_addr." WHERE user_id = ".$ilDB->quote($this->user_id, 'integer')). " ";
199 
200  if (trim($this->getSearchQuery()) != '')
201  {
202  $sub_query .= " AND ( %s
203  OR %s
204  OR %s
205  OR %s) ";
206 
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()).'%'),
210  $ilDB->like('email','text','%'.trim($this->getSearchQuery()).'%')
211  );
212 
213 
214  }
215 
216  $query .= " ORDER BY login, lastname";
217 
218  $res = $ilDB->query($query, $data_types, $data);
219 
220  while($row = $ilDB->fetchObject($res))
221  {
222  $entries[] = array(
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
229  );
230  }
231  return $entries ? $entries : array();
232  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ getEntry()

ilAddressbook::getEntry (   $a_addr_id)

get all entries the user

Parameters
integeraddress id
Returns
array array of entry data public

Definition at line 239 of file class.ilAddressbook.php.

References $res, and $row.

Referenced by entryToString().

240  {
241  global $ilDB;
242 
243  $res = $ilDB->queryf("
244  SELECT * FROM ".$this->table_addr."
245  WHERE user_id = %s
246  AND addr_id = %s",
247  array('integer', 'integer'),
248  array($this->user_id, $a_addr_id));
249 
250  $row = $ilDB->fetchObject($res);
251 
252  return array(
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
259  );
260  }
+ Here is the caller graph for this function:

◆ getSearchQuery()

ilAddressbook::getSearchQuery ( )

Definition at line 381 of file class.ilAddressbook.php.

References ilObjUser\getLogin().

Referenced by getEntries().

382  {
383  return $this->search_query;
384  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilAddressbook()

ilAddressbook::ilAddressbook (   $a_user_id = 0)

Constructor.

Parameters
integeruser_id of mailbox public

Definition at line 69 of file class.ilAddressbook.php.

References $ilias, and $lng.

70  {
71  global $ilias,$lng;
72 
73  $this->ilias = &$ilias;
74  $this->lng = &$lng;
75  $this->user_id = $a_user_id;
76 
77  $this->table_addr = 'addressbook';
78  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ searchUsers()

ilAddressbook::searchUsers (   $a_query_str)

Search users in addressbook // tab: compose -> search user.

Parameters
stringquery string
Returns
array array of entries found in addressbook public

Definition at line 86 of file class.ilAddressbook.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilMailSearchGUI\showResults().

87  {
88  global $ilDB;
89 
90  if($a_query_str)
91  {
92  // #14768
93  $a_query_str = str_replace('%', '\%', $a_query_str);
94  $a_query_str = str_replace('_', '\_', $a_query_str);
95 
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'). " " ;
102 
103 
104  $res = $ilDB->query($query);
105  }
106  else
107  {
108  $res = $ilDB->queryf("
109  SELECT * FROM ".$this->table_addr." WHERE user_id = %s",
110  array('integer'),
111  array($this->user_id)
112  );
113  }
114 
115  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
116  {
117  $entries[] = array(
118  "login" => ($row->login),
119  "firstname" => ($row->firstname),
120  "lastname" => ($row->lastname),
121  "email" => ($row->email));
122  }
123  return $entries ? $entries : array();
124  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ setSearchQuery()

ilAddressbook::setSearchQuery (   $search_query = '')

Definition at line 377 of file class.ilAddressbook.php.

378  {
379  $this->search_query = $search_query;
380  }

◆ updateEntry()

ilAddressbook::updateEntry (   $a_addr_id,
  $a_login,
  $a_firstname,
  $a_lastname,
  $a_email,
  $a_auto_update = 0 
)

update entry

Parameters
integeraddr_id
stringlogin
stringfirstname
stringlastname
stringemail
int$a_auto_update
Returns
boolean public

Definition at line 169 of file class.ilAddressbook.php.

170  {
171  global $ilDB;
172  $statement = $ilDB->manipulateF(
173  "UPDATE ".$this->table_addr ."
174  SET login = %s,
175  firstname = %s,
176  lastname = %s,
177  email = %s,
178  auto_update = %s
179  WHERE user_id = %s
180  AND addr_id = %s",
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));
183 
184  return true;
185  }

Field Documentation

◆ $ilias

ilAddressbook::$ilias

Definition at line 41 of file class.ilAddressbook.php.

Referenced by ilAddressbook().

◆ $lng

ilAddressbook::$lng

Definition at line 48 of file class.ilAddressbook.php.

Referenced by ilAddressbook().

◆ $table_addr

ilAddressbook::$table_addr

Definition at line 62 of file class.ilAddressbook.php.

◆ $user_id

ilAddressbook::$user_id

Definition at line 55 of file class.ilAddressbook.php.


The documentation for this class was generated from the following file: