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

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

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1