Public Member Functions | Data Fields

ilAddressbook Class Reference

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)

Data Fields

 $ilias
 $lng
 $user_id
 $table_addr

Detailed Description

Definition at line 35 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 122 of file class.ilAddressbook.php.

References $query, and $res.

        {
                $query = "INSERT INTO $this->table_addr ".
                        "SET user_id = '".$this->user_id."',".
                        "login = '".addslashes($a_login)."',".
                        "firstname = '".addslashes($a_firstname)."',".
                        "lastname = '".addslashes($a_lastname)."',".
                        "email = '".addslashes($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 245 of file class.ilAddressbook.php.

References $query.

        {
                if ($a_login != "")
                {
                        $query = "SELECT addr_id FROM $this->table_addr ".
                                "WHERE login = '".ilUtil::addSlashes($a_login)."'";
                        return $this->ilias->db->getOne($query);
                }
                
                return 0;
        }

ilAddressbook::checkEntryByLogin ( a_login  ) 

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

References $q, and $query.

        {
                global $ilDB;
                
                if ($a_login != "")
                {
                        $query = "SELECT addr_id FROM $this->table_addr ".
                                "WHERE user_id = '".ilUtil::addSlashes($this->user_id)."' ".
                                "AND login = '".ilUtil::addSlashes($a_login)."' ";
                                echo $q;
                        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 212 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 229 of file class.ilAddressbook.php.

References $query, and $res.

Referenced by deleteEntries().

        {
                $query = "DELETE FROM $this->table_addr ".
                        "WHERE user_id = '".$this->user_id."' ".
                        "AND addr_id = '".$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 166 of file class.ilAddressbook.php.

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

        {
                $query = "SELECT * FROM $this->table_addr ".
                        "WHERE user_id = '".$this->user_id."' ".
                        "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"      => stripslashes($row->login),
                                "firstname"  => stripslashes($row->firstname),
                                "lastname"   => stripslashes($row->lastname),
                                "email"      => stripslashes($row->email));
                }
                return $entries ? $entries : array();
        }

ilAddressbook::getEntry ( a_addr_id  ) 

get all entries the user

Parameters:
integer address id
Returns:
array array of entry data public

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

References $query, and $row.

        {
                $query = "SELECT * FROM $this->table_addr ".
                        "WHERE user_id = '".$this->user_id."' ".
                        "AND addr_id = '".$a_addr_id."'";

                $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);

                return array(
                        "addr_id"    => $row->addr_id,
                        "login"      => stripslashes($row->login),
                        "firstname"  => stripslashes($row->firstname),
                        "lastname"   => stripslashes($row->lastname),
                        "email"      => stripslashes($row->email));
        }

ilAddressbook::ilAddressbook ( a_user_id = 0  ) 

Constructor.

Parameters:
integer user_id of mailbox public

Definition at line 70 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 86 of file class.ilAddressbook.php.

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

        {
                if($a_query_str)
                {
                        $query = "SELECT * FROM $this->table_addr ".
                                "WHERE (login LIKE '%".$a_query_str."%' ".
                                "OR firstname LIKE '%".$a_query_str."%' ".
                                "OR lastname LIKE '%".$a_query_str."%' ".
                                "OR email LIKE '%".$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"      => stripslashes($row->login),
                                "firstname"  => stripslashes($row->firstname),
                                "lastname"   => stripslashes($row->lastname),
                                "email"      => stripslashes($row->email));
                }
                return $entries ? $entries : array();
        }

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

References $query, and $res.

        {
                $query = "UPDATE $this->table_addr ".
                        "SET login = '".addslashes($a_login)."',".
                        "firstname = '".addslashes($a_firstname)."',".
                        "lastname = '".addslashes($a_lastname)."',".
                        "email = '".addslashes($a_email)."' ".
                        "WHERE user_id = '".$this->user_id."' ".
                        "AND addr_id = '".$a_addr_id."'";

                $res = $this->ilias->db->query($query);

                return true;
        }


Field Documentation

ilAddressbook::$ilias

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

Referenced by ilAddressbook().

ilAddressbook::$lng

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

Referenced by ilAddressbook().

ilAddressbook::$table_addr

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

ilAddressbook::$user_id

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


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