8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbModuleDb.php');
21 parent::__construct();
23 $this->_oConfig = $oConfig;
29 if (!isset(
$GLOBALS[
'ch_dol_shoutbox_objects'])) {
30 $GLOBALS[
'ch_dol_shoutbox_objects'] =
$GLOBALS[
'MySQL']->fromCache(
'ch_shoutbox_objects',
'getAllWithKey',
31 'SELECT * FROM `ch_shoutbox_objects`',
'name');
34 return $GLOBALS[
'ch_dol_shoutbox_objects'];
54 if (!isset($this->_aObjects[$sObject])) {
59 $iOwnerId = (int)$iOwnerId;
60 if (!preg_match(
'/^[0-9]+$/', $iIP)) {
67 `{$this -> _aObjects[$sObject]['table']}`
69 `HandlerID` = {$iHandler},
70 `OwnerID` = {$iOwnerId},
71 `Message` = '{$sMessage}',
72 `Date` = TIMESTAMP( NOW() ),
76 return (
int)$this->
query($sQuery) > 0 ? $this->
lastId() :
false;
88 if (!isset($this->_aObjects[$sObject])) {
92 $sQuery =
"SELECT `ID` FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = '{$iHandler}' ORDER BY `ID` DESC LIMIT 1";
93 $iLastId = $this->
getOne($sQuery);
95 return ($iLastId) ? $iLastId : 0;
111 if (!isset($this->_aObjects[$sObject])) {
115 $iLastId = (int)$iLastId;
116 $sQuery =
"SELECT *, UNIX_TIMESTAMP(`Date`) AS `DateTS` FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = '{$iHandler}' AND `ID` > " . (int)$iLastId .
" ORDER BY `ID`";
118 return $this->
getAll($sQuery);
130 if (!isset($this->_aObjects[$sObject])) {
134 $sQuery =
"SELECT COUNT(*) FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = '{$iHandler}'";
136 return $this->
getOne($sQuery);
149 if (!isset($this->_aObjects[$sObject])) {
153 $iMessageId = (int)$iMessageId;
154 $sQuery =
"SELECT * FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = '{$iHandler}' AND `ID` = {$iMessageId}";
168 if (!isset($this->_aObjects[$sObject])) {
172 $iLimit = (int)$iLimit;
173 $sQuery =
"DELETE FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = {$iHandler} ORDER BY `ID` LIMIT {$iLimit}";
174 $this->
query($sQuery);
187 if (!isset($this->_aObjects[$sObject])) {
191 $iMessageId = (int)$iMessageId;
192 $sQuery =
"DELETE FROM `{$this -> _aObjects[$sObject]['table']}` WHERE `HandlerID` = {$iHandler} AND `ID` = {$iMessageId}";
194 return $this->
query($sQuery);
207 if (!isset($this->_aObjects[$sObject])) {
213 foreach ($this->_aObjects
as $a) {
214 $sQuery =
"DELETE FROM `{$a['table']}` WHERE `IP` = {$iIp}";
215 $this->
query($sQuery);
228 foreach ($this->_aObjects
as $a) {
229 $sQuery =
"DELETE FROM `{$a['table']}` WHERE `OwnerID` = {$iProfileId}";
230 $this->
query($sQuery);
242 if (!is_numeric($iLifeTime)) {
246 foreach ($this->_aObjects
as $a) {
247 $sQuery =
"DELETE FROM `{$a['table']}` WHERE FROM_UNIXTIME( UNIX_TIMESTAMP() - {$iLifeTime} ) >= `Date`";
259 return $this->
getOne(
"SELECT `kateg` FROM `sys_options` WHERE `Name` = ?", [
$sName]);
264 foreach ($aData
as $a) {
265 $this->
query(
"INSERT INTO `ch_shoutbox_objects` (`name`, `title`, `table`, `code_allow_use`, `code_allow_delete`, `code_allow_block`) VALUES (?, ?, ?, ?, ?, ?)",
270 $a[
'code_allow_use'],
271 $a[
'code_allow_delete'],
272 $a[
'code_allow_block']
279 foreach ($aData
as $a) {
280 $this->
query(
"DELETE FROM `ch_shoutbox_objects` WHERE `name` = ?", [$a[
'name']]);