ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups 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.
 searchUsers ($a_query_str)
 Search users in addressbook.
 addEntry ($a_login, $a_firstname, $a_lastname, $a_email)
 add entry
 updateEntry ($a_addr_id, $a_login, $a_firstname, $a_lastname, $a_email)
 update entry
 getEntries ()
 get all entries the user
 getEntry ($a_addr_id)
 get all entries the user
 deleteEntries ($a_entries)
 delete some entries of user
 deleteEntry ($a_addr_id)
 delete one entry
 checkEntry ($a_login)
 Check whether an entry with a given login name already exists.
 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 smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilAddressbook.php 16857 2008-06-23 11:35:08Z mjansen

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

Member Function Documentation

ilAddressbook::addEntry (   $a_login,
  $a_firstname,
  $a_lastname,
  $a_email 
)

add entry

Parameters
stringlogin
stringfirstname
stringlastname
stringemail
Returns
boolean public

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

References $res.

{
global $ilDB;
$query = "INSERT INTO $this->table_addr ".
"SET user_id = ".$ilDB->quote($this->user_id).",".
"login = ".$ilDB->quote($a_login).",".
"firstname = ".$ilDB->quote($a_firstname).",".
"lastname = ".$ilDB->quote($a_lastname).",".
"email = ".$ilDB->quote($a_email)."";
$res = $this->ilias->db->query($query);
return true;
}
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 267 of file class.ilAddressbook.php.

References $result.

{
global $ilDB;
if ($a_login != '')
{
$query = $ilDB->prepare("SELECT addr_id FROM ".$this->table_addr." WHERE user_id = ? AND login = ?",
array('integer', 'text'));
$result = $ilDB->execute($query, array($this->user_id, $a_login));
while($record = $ilDB->fetchAssoc($result))
{
return $record['addr_id'];
}
}
return 0;
}
ilAddressbook::checkEntryByLogin (   $a_login)

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

References $result.

{
global $ilDB;
if ($a_login != "")
{
$query = $ilDB->prepare("SELECT addr_id FROM ".$this->table_addr." WHERE user_id = ? AND login = ?",
array('integer', 'text'));
$result = $ilDB->execute($query, array($this->user_id, $a_login));
while($record = $ilDB->fetchAssoc($result))
{
return $record['addr_id'];
}
}
return 0;
}
ilAddressbook::deleteEntries (   $a_entries)

delete some entries of user

Parameters
arrayarray of entry ids
Returns
boolean public

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

References deleteEntry().

{
if(is_array($a_entries))
{
foreach($a_entries as $entry)
{
$this->deleteEntry($entry);
}
}
return true;
}

+ Here is the call graph for this function:

ilAddressbook::deleteEntry (   $a_addr_id)

delete one entry

Parameters
integeraddr id
Returns
boolean public

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

References $res.

Referenced by deleteEntries().

{
global $ilDB;
$query = "DELETE FROM addressbook_mailing_lists_assignments ".
"WHERE addr_id = ".$ilDB->quote($a_addr_id)." ";
$this->ilias->db->query($query);
$query = "DELETE FROM $this->table_addr ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND addr_id = ".$ilDB->quote($a_addr_id)." ";
$res = $this->ilias->db->query($query);
return true;
}

+ Here is the caller graph for this function:

ilAddressbook::getEntries ( )

get all entries the user

Returns
array array of entries found in addressbook public

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

References $res, DB_FETCHMODE_OBJECT, and getSearchQuery().

{
global $ilDB;
$query = "SELECT * FROM $this->table_addr ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ";
if (trim($this->getSearchQuery()) != '')
{
$query .= " AND (login LIKE '%".addslashes(trim($this->getSearchQuery()))."%' ".
"OR firstname LIKE '%".addslashes(trim($this->getSearchQuery()))."%' ".
"OR lastname LIKE '%".addslashes(trim($this->getSearchQuery()))."%' ".
"OR email LIKE '%".addslashes(trim($this->getSearchQuery()))."%') ";
}
$query .= " ORDER BY login,lastname";
$res = $this->ilias->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$entries[] = array(
"addr_id" => $row->addr_id,
"login" => ($row->login),
"firstname" => ($row->firstname),
"lastname" => ($row->lastname),
"email" => ($row->email));
}
return $entries ? $entries : array();
}

+ Here is the call graph for this function:

ilAddressbook::getEntry (   $a_addr_id)

get all entries the user

Parameters
integeraddress id
Returns
array array of entry data public

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

References DB_FETCHMODE_OBJECT.

{
global $ilDB;
$query = "SELECT * FROM $this->table_addr ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND addr_id = ".$ilDB->quote($a_addr_id)." ";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return array(
"addr_id" => $row->addr_id,
"login" => ($row->login),
"firstname" => ($row->firstname),
"lastname" => ($row->lastname),
"email" => ($row->email));
}
ilAddressbook::getSearchQuery ( )

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

Referenced by getEntries().

{
return $this->search_query;
}

+ Here is the caller graph for this function:

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.

{
global $ilias,$lng;
$this->ilias = &$ilias;
$this->lng = &$lng;
$this->user_id = $a_user_id;
$this->table_addr = 'addressbook';
}
ilAddressbook::searchUsers (   $a_query_str)

Search users in addressbook.

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

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

References $res, and DB_FETCHMODE_OBJECT.

Referenced by ilMailSearchGUI\showResults().

{
if($a_query_str)
{
$query = "SELECT * FROM $this->table_addr ".
"WHERE (login LIKE '%".addslashes($a_query_str)."%' ".
"OR firstname LIKE '%".addslashes($a_query_str)."%' ".
"OR lastname LIKE '%".addslashes($a_query_str)."%' ".
"OR email LIKE '%".addslashes($a_query_str)."%') ".
"AND user_id = '".$this->user_id."'";
}
else
{
$query = "SELECT * FROM $this->table_addr ".
"WHERE user_id = '".$this->user_id."'";
}
$res = $this->ilias->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$entries[] = array(
"login" => ($row->login),
"firstname" => ($row->firstname),
"lastname" => ($row->lastname),
"email" => ($row->email));
}
return $entries ? $entries : array();
}

+ Here is the caller graph for this function:

ilAddressbook::setSearchQuery (   $search_query = '')

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

{
$this->search_query = $search_query;
}
ilAddressbook::updateEntry (   $a_addr_id,
  $a_login,
  $a_firstname,
  $a_lastname,
  $a_email 
)

update entry

Parameters
integeraddr_id
stringlogin
stringfirstname
stringlastname
stringemail
Returns
boolean public

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

References $res.

{
global $ilDB;
$query = "UPDATE $this->table_addr ".
"SET login = ".$ilDB->quote($a_login).",".
"firstname = ".$ilDB->quote($a_firstname).",".
"lastname = ".$ilDB->quote($a_lastname).",".
"email = ".$ilDB->quote($a_email)." ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND addr_id = ".$ilDB->quote($a_addr_id)."";
$res = $this->ilias->db->query($query);
return true;
}

Field Documentation

ilAddressbook::$ilias

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

Referenced by ilAddressbook().

ilAddressbook::$lng

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

Referenced by ilAddressbook().

ilAddressbook::$table_addr

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

ilAddressbook::$user_id

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


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