2018-08-16 22:30:59 +00:00
|
|
|
<?php
|
2022-03-04 17:10:24 +00:00
|
|
|
|
2018-08-16 22:30:59 +00:00
|
|
|
/*
|
2022-03-04 17:10:24 +00:00
|
|
|
* Copyright (c) 2010-2022 Tim Düsterhus.
|
2018-08-16 22:30:59 +00:00
|
|
|
*
|
|
|
|
* Use of this software is governed by the Business Source License
|
|
|
|
* included in the LICENSE file.
|
|
|
|
*
|
2022-03-10 17:56:18 +00:00
|
|
|
* Change Date: 2026-03-10
|
2018-08-16 22:30:59 +00:00
|
|
|
*
|
|
|
|
* On the date above, in accordance with the Business Source
|
|
|
|
* License, use of this software will be governed by version 2
|
|
|
|
* or later of the General Public License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chat\system\condition\room;
|
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
use chat\data\room\RoomList;
|
|
|
|
use wcf\data\DatabaseObjectList;
|
|
|
|
use wcf\system\condition\AbstractCheckboxCondition;
|
|
|
|
use wcf\system\condition\IObjectListCondition;
|
|
|
|
use wcf\system\exception\ParentClassException;
|
2018-08-16 22:30:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Condition implementation for rooms to only include non-empty rooms in lists.
|
|
|
|
*/
|
2022-03-04 18:32:19 +00:00
|
|
|
final class RoomFilledCondition extends AbstractCheckboxCondition implements IObjectListCondition
|
2022-03-04 17:10:24 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected $fieldName = 'chatRoomIsFilled';
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected $label = 'chat.room.condition.isFilled';
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData)
|
|
|
|
{
|
|
|
|
if (!($objectList instanceof RoomList)) {
|
|
|
|
throw new ParentClassException(\get_class($objectList), RoomList::class);
|
|
|
|
}
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 20:13:40 +00:00
|
|
|
$objectList->getConditionBuilder()->add(
|
|
|
|
"
|
|
|
|
EXISTS (
|
|
|
|
SELECT 1
|
|
|
|
FROM chat" . WCF_N . "_room_to_user r2u
|
|
|
|
WHERE r2u.roomID = room.roomID
|
|
|
|
AND active = ?
|
|
|
|
)",
|
|
|
|
[ 1 ]
|
|
|
|
);
|
2022-03-04 17:10:24 +00:00
|
|
|
}
|
2018-08-16 22:30:59 +00:00
|
|
|
}
|