• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilAddressbook.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00035 class ilAddressbook
00036 {
00042         var $ilias;
00043 
00049         var $lng;
00050 
00056         var $user_id;
00057 
00063         var $table_addr;
00064 
00070         function ilAddressbook($a_user_id = 0)
00071         {
00072                 global $ilias,$lng;
00073 
00074                 $this->ilias = &$ilias;
00075                 $this->lng = &$lng;
00076                 $this->user_id = $a_user_id;
00077 
00078                 $this->table_addr = 'addressbook';
00079         }
00086         function searchUsers($a_query_str)
00087         {
00088                 if($a_query_str)
00089                 {
00090                         $query = "SELECT * FROM $this->table_addr ".
00091                                 "WHERE (login LIKE '%".$a_query_str."%' ".
00092                                 "OR firstname LIKE '%".$a_query_str."%' ".
00093                                 "OR lastname LIKE '%".$a_query_str."%' ".
00094                                 "OR email LIKE '%".$a_query_str."%') ".
00095                                 "AND user_id = '".$this->user_id."'";
00096                 }
00097                 else
00098                 {
00099                         $query = "SELECT * FROM $this->table_addr ".
00100                                 "WHERE user_id = '".$this->user_id."'";
00101                 }
00102                 $res = $this->ilias->db->query($query);
00103                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00104                 {
00105                         $entries[] = array(
00106                                 "login"      => stripslashes($row->login),
00107                                 "firstname"  => stripslashes($row->firstname),
00108                                 "lastname"   => stripslashes($row->lastname),
00109                                 "email"      => stripslashes($row->email));
00110                 }
00111                 return $entries ? $entries : array();
00112         }
00122         function addEntry($a_login,$a_firstname,$a_lastname,$a_email)
00123         {
00124                 $query = "INSERT INTO $this->table_addr ".
00125                         "SET user_id = '".$this->user_id."',".
00126                         "login = '".addslashes($a_login)."',".
00127                         "firstname = '".addslashes($a_firstname)."',".
00128                         "lastname = '".addslashes($a_lastname)."',".
00129                         "email = '".addslashes($a_email)."'";
00130 
00131                 $res = $this->ilias->db->query($query);
00132 
00133                 return true;
00134         }
00135 
00146         function updateEntry($a_addr_id,$a_login,$a_firstname,$a_lastname,$a_email)
00147         {
00148                 $query = "UPDATE $this->table_addr ".
00149                         "SET login = '".addslashes($a_login)."',".
00150                         "firstname = '".addslashes($a_firstname)."',".
00151                         "lastname = '".addslashes($a_lastname)."',".
00152                         "email = '".addslashes($a_email)."' ".
00153                         "WHERE user_id = '".$this->user_id."' ".
00154                         "AND addr_id = '".$a_addr_id."'";
00155 
00156                 $res = $this->ilias->db->query($query);
00157 
00158                 return true;
00159         }
00160 
00166         function getEntries()
00167         {
00168                 $query = "SELECT * FROM $this->table_addr ".
00169                         "WHERE user_id = '".$this->user_id."' ".
00170                         "ORDER BY login,lastname";
00171 
00172                 $res = $this->ilias->db->query($query);
00173                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00174                 {
00175                         $entries[] = array(
00176                                 "addr_id"    => $row->addr_id,
00177                                 "login"      => stripslashes($row->login),
00178                                 "firstname"  => stripslashes($row->firstname),
00179                                 "lastname"   => stripslashes($row->lastname),
00180                                 "email"      => stripslashes($row->email));
00181                 }
00182                 return $entries ? $entries : array();
00183         }
00190         function getEntry($a_addr_id)
00191         {
00192                 $query = "SELECT * FROM $this->table_addr ".
00193                         "WHERE user_id = '".$this->user_id."' ".
00194                         "AND addr_id = '".$a_addr_id."'";
00195 
00196                 $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
00197 
00198                 return array(
00199                         "addr_id"    => $row->addr_id,
00200                         "login"      => stripslashes($row->login),
00201                         "firstname"  => stripslashes($row->firstname),
00202                         "lastname"   => stripslashes($row->lastname),
00203                         "email"      => stripslashes($row->email));
00204         }
00205 
00212         function deleteEntries($a_entries)
00213         {
00214                 if(is_array($a_entries))
00215                 {
00216                         foreach($a_entries as $entry)
00217                         {
00218                                 $this->deleteEntry($entry);
00219                         }
00220                 }
00221                 return true;
00222         }
00229         function deleteEntry($a_addr_id)
00230         {
00231                 $query = "DELETE FROM $this->table_addr ".
00232                         "WHERE user_id = '".$this->user_id."' ".
00233                         "AND addr_id = '".$a_addr_id."'";
00234                 $res = $this->ilias->db->query($query);
00235 
00236                 return true;
00237         }
00238 }
00239 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1