Public Member Functions | Data Fields

ilAddressbook Class Reference

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

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 <smeyer@databay.de>
Version:
Id:
class.ilAddressbook.php 16149 2008-03-04 08:49:15Z 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:
string login
string firstname
string lastname
string email
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:
string login name
Returns:
int number of entries found public

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

        {
                global $ilDB;
                
                if ($a_login != "")
                {
                        $query = "SELECT addr_id FROM $this->table_addr ".
                                     "WHERE user_id = ".$ilDB->quote($this->user_id)." 
                      AND login = ".$ilDB->quote($a_login)." ";
                        return $this->ilias->db->getOne($query);
                }
                
                return 0;
        }

ilAddressbook::checkEntryByLogin ( a_login  ) 

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

        {
                global $ilDB;
                
                if ($a_login != "")
                {
                        $query = "SELECT addr_id FROM $this->table_addr ".
                                "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                                "AND login = ".$ilDB->quote($a_login)." ";
                        return $this->ilias->db->getOne($query);
                }
                
                return 0;
        }

ilAddressbook::deleteEntries ( a_entries  ) 

delete some entries of user

Parameters:
array array 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:
integer addr 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, 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:
integer address id
Returns:
array array of entry data public

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

        {
                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 302 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:
integer user_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:
string query string
Returns:
array array of entries found in addressbook public

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

References $res.

        {
                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();
        }

ilAddressbook::setSearchQuery ( search_query = ''  ) 

Definition at line 298 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:
integer addr_id
string login
string firstname
string lastname
string email
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: