Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
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 }
00160 ?>