2011-11-27 19:20:13 +00:00
|
|
|
<?php
|
2013-01-19 19:36:40 +00:00
|
|
|
namespace chat\data\room;
|
2012-02-04 20:57:39 +00:00
|
|
|
use \wcf\system\WCF;
|
2011-11-27 19:20:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides functions to edit chat rooms.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2014-02-27 22:05:09 +00:00
|
|
|
* @copyright 2010-2014 Tim Düsterhus
|
2011-11-27 19:20:13 +00:00
|
|
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2013-01-19 19:36:40 +00:00
|
|
|
* @package be.bastelstu.chat
|
|
|
|
* @subpackage data.room
|
2011-11-27 19:20:13 +00:00
|
|
|
*/
|
2013-01-19 19:36:40 +00:00
|
|
|
class RoomEditor extends \wcf\data\DatabaseObjectEditor implements \wcf\data\IEditableCachedObject {
|
2011-11-27 19:20:13 +00:00
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
|
2011-11-27 19:20:13 +00:00
|
|
|
*/
|
2013-01-19 19:36:40 +00:00
|
|
|
protected static $baseClass = '\chat\data\room\Room';
|
2011-11-27 19:20:13 +00:00
|
|
|
|
2012-06-04 19:10:03 +00:00
|
|
|
|
2012-02-04 20:57:39 +00:00
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @see \wcf\data\DatabaseObjectEditor::deleteAll()
|
2012-02-04 20:57:39 +00:00
|
|
|
*/
|
|
|
|
public static function deleteAll(array $objectIDs = array()) {
|
|
|
|
WCF::getDB()->beginTransaction();
|
|
|
|
foreach ($objectIDs as $objectID) {
|
2013-01-19 19:36:40 +00:00
|
|
|
\wcf\system\language\I18nHandler::getInstance()->remove('chat.room.title'.$objectID);
|
|
|
|
\wcf\system\language\I18nHandler::getInstance()->remove('chat.room.topic'.$objectID);
|
2012-02-04 20:57:39 +00:00
|
|
|
}
|
|
|
|
|
2012-04-16 20:12:44 +00:00
|
|
|
$sql = "SELECT
|
2013-05-23 22:08:33 +00:00
|
|
|
showOrder
|
2012-04-16 20:12:44 +00:00
|
|
|
FROM
|
2013-01-19 19:36:40 +00:00
|
|
|
chat".WCF_N."_room
|
2012-04-16 20:12:44 +00:00
|
|
|
WHERE
|
|
|
|
roomID = ?
|
|
|
|
FOR UPDATE";
|
|
|
|
$select = WCF::getDB()->prepareStatement($sql);
|
|
|
|
|
|
|
|
$sql = "UPDATE
|
2013-01-19 19:36:40 +00:00
|
|
|
chat".WCF_N."_room
|
2012-04-16 20:12:44 +00:00
|
|
|
SET
|
2013-05-23 22:08:33 +00:00
|
|
|
showOrder = showOrder - 1
|
2012-04-16 20:12:44 +00:00
|
|
|
WHERE
|
2013-05-23 22:08:33 +00:00
|
|
|
showOrder > ?";
|
2012-04-16 20:12:44 +00:00
|
|
|
$update = WCF::getDB()->prepareStatement($sql);
|
|
|
|
|
|
|
|
foreach ($objectIDs as $objectID) {
|
|
|
|
$select->execute(array($objectID));
|
|
|
|
$update->execute(array($select->fetchColumn()));
|
|
|
|
}
|
|
|
|
|
2013-03-11 21:33:17 +00:00
|
|
|
$return = parent::deleteAll($objectIDs);
|
|
|
|
WCF::getDB()->commitTransaction();
|
|
|
|
return $return;
|
2012-02-04 20:57:39 +00:00
|
|
|
}
|
2012-03-08 21:07:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the room cache.
|
|
|
|
*/
|
|
|
|
public static function resetCache() {
|
2013-02-04 18:27:03 +00:00
|
|
|
\chat\system\cache\builder\RoomCacheBuilder::getInstance()->reset();
|
|
|
|
\chat\system\cache\builder\PermissionCacheBuilder::getInstance()->reset();
|
2014-02-27 18:14:32 +00:00
|
|
|
\wcf\system\nodePush\NodePushHandler::getInstance()->sendMessage('be.bastelstu.chat.roomChange');
|
2012-03-08 21:07:46 +00:00
|
|
|
}
|
2011-11-27 19:20:13 +00:00
|
|
|
}
|