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

chat/classes/class.ilChatBlockedUsers.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 
00033 class ilChatBlockedUsers
00034 {
00035         var $id;
00036         var $db;
00037 
00038         var $blocked = array();
00039 
00046         function ilChatBlockedUsers($a_id)
00047         {
00048                 global $ilDB;
00049 
00050                 $this->db =& $ilDB;
00051                 $this->id = $a_id;
00052 
00053                 $this->__read();
00054         }
00055 
00056         function getBlockedUsers()
00057         {
00058                 return $this->blocked ? $this->blocked : array();
00059         }
00060 
00061         function isBlocked($a_usr_id)
00062         {
00063                 return in_array($a_usr_id,$this->blocked) ? true : false;
00064         }
00065         function block($a_usr_id)
00066         {
00067                 if(in_array((int) $a_usr_id,$this->blocked) or !((int) $a_usr_id))
00068                 {
00069                         return false;
00070                 }
00071                 $query = "INSERT INTO chat_blocked ".
00072                         "SET chat_id = '".$this->id."', ".
00073                         "usr_id = '".(int) $a_usr_id."'";
00074 
00075                 $this->db->query($query);
00076                 $this->__read();
00077 
00078                 return true;
00079         }
00080 
00081         function unblock($a_usr_id)
00082         {
00083                 if(!in_array((int) $a_usr_id,$this->blocked))
00084                 {
00085                         return false;
00086                 }
00087                 $query = "DELETE FROM chat_blocked ".
00088                         "WHERE chat_id = '".$this->id."' ".
00089                         "AND usr_id = '".(int) $a_usr_id."'";
00090 
00091                 $this->db->query($query);
00092                 $this->__read();
00093 
00094                 return true;
00095         }
00096                 
00097 
00098                 
00099         // Static
00100         function _isBlocked($a_chat_id,$a_usr_id)
00101         {
00102                 global $ilDB;
00103 
00104                 $query = "SELECT * FROM chat_blocked ".
00105                         "WHERE chat_id = '".$a_chat_id."' ".
00106                         "AND usr_id = '".$a_usr_id."'";
00107 
00108                 $res = $ilDB->query($query);
00109 
00110                 return $res->numRows() ? true : false;
00111         }
00112 
00113 
00114         function _deleteUser($a_usr_id)
00115         {
00116                 global $ilDB;
00117 
00118                 $query = "DELETE FROM chat_blocked ".
00119                         "WHERE usr_id = '".(int) $a_usr_id."'";
00120 
00121                 $ilDB->query($query);
00122 
00123                 return true;
00124         }
00125         function _deleteChat($a_chat_id)
00126         {
00127                 global $ilDB;
00128 
00129                 $query = "DELETE FROM chat_blocked ".
00130                         "WHERE chat_id = '".(int) $a_chat_id."'";
00131 
00132                 $ilDB->query($query);
00133 
00134                 return true;
00135         }               
00136 
00137 
00138         // Private
00139         function __read()
00140         {
00141                 $this->blocked = array();
00142 
00143                 $query = "SELECT * FROM chat_blocked ".
00144                         "WHERE chat_id = '".$this->id."'";
00145 
00146                 $res = $this->db->query($query);
00147                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00148                 {
00149                         $this->blocked[] = $row->usr_id;
00150                 }
00151                 return true;
00152         }
00153 
00154 } // END class.ilBlockedUsers
00155 ?>

Generated on Fri Dec 13 2013 13:52:06 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1