ILIAS  release_4-3 Revision
 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 // tab: compose -> search user.
 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
 entryToString ($a_addr_id)
 returns a readable string representation of a given entry
 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 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

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

add entry

Parameters
stringlogin
stringfirstname
stringlastname
stringemail
Returns
boolean public

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

{
global $ilDB;
$nextId = $ilDB->nextId($this->table_addr); //addr_id,
$statement = $ilDB->manipulateF("
INSERT INTO ".$this->table_addr."
(
addr_id,
user_id,
login,
firstname,
lastname,
email
)
VALUES (%s, %s, %s, %s, %s, %s)",
array('integer', 'integer', 'text', 'text', 'text', 'text'),
array($nextId, $this->user_id, $a_login, $a_firstname, $a_lastname, $a_email));
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 332 of file class.ilAddressbook.php.

References $result.

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

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

References $result.

{
global $ilDB;
if ($a_login != "")
{
$result = $ilDB->queryf("SELECT addr_id FROM ".$this->table_addr." WHERE user_id = %s AND login = %s",
array('integer', 'text'), 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 290 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 307 of file class.ilAddressbook.php.

Referenced by deleteEntries().

{
global $ilDB;
$statement = $ilDB->manipulateF('
DELETE FROM addressbook_mlist_ass
WHERE addr_id = %s',
array('integer'), array($a_addr_id));
$statement = $ilDB->manipulateF("
DELETE FROM ".$this->table_addr."
WHERE user_id = %s
AND addr_id = %s",
array('integer', 'integer'),
array($this->user_id, $a_addr_id));
return true;
}

+ Here is the caller graph for this function:

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 260 of file class.ilAddressbook.php.

References $out, and getEntry().

{
$entry = $this->getEntry($a_addr_id);
if (!$entry)
return "???";
else
{
$out = "";
if ($entry['firstname'] && $entry['lastname'])
$out .= $entry['lastname'] . ', ' . $entry['firstname'] . ' ';
else if ($entry['firstname'])
$out .= $entry['firstname'] . ' ';
else if ($entry['lastname'])
$out .= $entry['lastname'] . ' ';
if ($entry['login'])
$out .= '(' . $entry['login'] . ') ';
if ($entry['email'])
$out .= '[' . $entry['email'] . ']';
return $out;
}
}

+ Here is the call graph for this function:

ilAddressbook::getEntries ( )

get all entries the user

Returns
array array of entries found in addressbook public

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

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

{
global $ilDB;
$data_types = array();
$data = array();
$query = ("SELECT * FROM ".$this->table_addr." WHERE user_id = ".$ilDB->quote($this->user_id, 'integer')). " ";
if (trim($this->getSearchQuery()) != '')
{
$sub_query .= " AND ( %s
OR %s
OR %s
OR %s) ";
$query .= sprintf($sub_query, $ilDB->like('login','text','%'.trim($this->getSearchQuery()).'%'),
$ilDB->like('firstname','text','%'.trim($this->getSearchQuery()).'%'),
$ilDB->like('lastname','text','%'.trim($this->getSearchQuery()).'%'),
$ilDB->like('email','text','%'.trim($this->getSearchQuery()).'%')
);
}
$query .= " ORDER BY login, lastname";
$res = $ilDB->query($query, $data_types, $data);
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 233 of file class.ilAddressbook.php.

References $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by entryToString().

{
global $ilDB;
$res = $ilDB->queryf("
SELECT * FROM ".$this->table_addr."
WHERE user_id = %s
AND addr_id = %s",
array('integer', 'integer'),
array($this->user_id, $a_addr_id));
return array(
"addr_id" => $row->addr_id,
"login" => ($row->login),
"firstname" => ($row->firstname),
"lastname" => ($row->lastname),
"email" => ($row->email));
}

+ Here is the caller graph for this function:

ilAddressbook::getSearchQuery ( )

Definition at line 373 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 // 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().

{
global $ilDB;
if($a_query_str)
{
// #14768
$a_query_str = str_replace('%', '\%', $a_query_str);
$a_query_str = str_replace('_', '\_', $a_query_str);
$query = "SELECT * FROM ".$this->table_addr."
WHERE ( " .$ilDB->like('login', 'text', '%'.$a_query_str.'%'). "
OR " .$ilDB->like('firstname', 'text', '%'.$a_query_str.'%'). "
OR " .$ilDB->like('lastname', 'text', '%'.$a_query_str.'%'). "
OR " .$ilDB->like('email', 'text', '%'.$a_query_str.'%'). ")
AND user_id = ".$ilDB->quote($this->user_id, 'integer'). " " ;
$res = $ilDB->query($query);
}
else
{
$res = $ilDB->queryf("
SELECT * FROM ".$this->table_addr." WHERE user_id = %s",
array('integer'),
array($this->user_id)
);
}
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 369 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 166 of file class.ilAddressbook.php.

{
global $ilDB;
$statement = $ilDB->manipulateF(
"UPDATE ".$this->table_addr ."
SET login = %s,
firstname = %s,
lastname = %s,
email = %s
WHERE user_id = %s
AND addr_id = %s",
array('text', 'text', 'text', 'text', 'integer', 'integer'),
array($a_login, $a_firstname, $a_lastname, $a_email, $this->user_id, $a_addr_id));
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: