Skip to content

Commit

Permalink
change to AbstractEventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Oct 19, 2024
1 parent 1378a56 commit efaf69f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,46 @@
use wcf\system\WCF;
use wcf\util\HeaderUtil;

final class HaModeratedUserGroupListPageListener implements IParameterizedEventListener
final class HaModeratedUserGroupListPageListener extends AbstractEventListener
{
public function execute($eventObj, $className, $eventName, array &$parameters)
protected function onAfterInitObjectList($eventObj)
{
if ($eventName == 'afterInitObjectList') {
if (isset($_POST['haGroupName'])) {
$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($_POST['haGroupName']) . '%']
);

WCF::getSession()->register('haGroupName', $_POST['haGroupName']);

WCF::getTpl()->assign([
'haGroupName' => $_POST['haGroupName'],
]);
} elseif (!empty(WCF::getSession()->getVar('haGroupName'))) {
$haGroupName = WCF::getSession()->getVar('haGroupName');

$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($haGroupName) . '%']
);

WCF::getTpl()->assign([
'haGroupName' => $haGroupName,
]);
}
} elseif ($eventName == 'countItems') {
if ($eventObj->objectList->countObjects() == 0 && !empty(WCF::getSession()->getVar('haGroupName'))) {
WCF::getSession()->unregister('haGroupName');

HeaderUtil::delayedRedirect(
LinkHandler::getInstance()->getLink('ModeratedUserGroupList'),
WCF::getLanguage()->getDynamicVariable('wcf.moderated.hanashi.noResult')
);

exit;
}
if (isset($_POST['haGroupName'])) {
$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($_POST['haGroupName']) . '%']
);

WCF::getSession()->register('haGroupName', $_POST['haGroupName']);

WCF::getTpl()->assign([
'haGroupName' => $_POST['haGroupName'],
]);
} elseif (!empty(WCF::getSession()->getVar('haGroupName'))) {
$haGroupName = WCF::getSession()->getVar('haGroupName');

$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($haGroupName) . '%']
);

WCF::getTpl()->assign([
'haGroupName' => $haGroupName,
]);
}
}

protected function onCountItems($eventObj)
{
if ($eventObj->objectList->countObjects() == 0 && !empty(WCF::getSession()->getVar('haGroupName'))) {
WCF::getSession()->unregister('haGroupName');

HeaderUtil::delayedRedirect(
LinkHandler::getInstance()->getLink('ModeratedUserGroupList'),
WCF::getLanguage()->getDynamicVariable('wcf.moderated.hanashi.noResult')
);

exit;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,46 @@
use wcf\system\WCF;
use wcf\util\HeaderUtil;

final class HaUserGroupListPageListener implements IParameterizedEventListener
final class HaUserGroupListPageListener extends AbstractEventListener
{
public function execute($eventObj, $className, $eventName, array &$parameters)
protected function onAfterInitObjectList($eventObj)
{
if ($eventName == 'afterInitObjectList') {
if (isset($_POST['haUserGroupName'])) {
$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($_POST['haUserGroupName']) . '%']
);

WCF::getSession()->register('haUserGroupName', $_POST['haUserGroupName']);

WCF::getTpl()->assign([
'haUserGroupName' => $_POST['haUserGroupName'],
]);
} elseif (!empty(WCF::getSession()->getVar('haUserGroupName'))) {
$haUserGroupName = WCF::getSession()->getVar('haUserGroupName');

$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($haUserGroupName) . '%']
);

WCF::getTpl()->assign([
'haUserGroupName' => $haUserGroupName,
]);
}
} elseif ($eventName == 'countItems') {
if ($eventObj->objectList->countObjects() == 0 && !empty(WCF::getSession()->getVar('haUserGroupName'))) {
WCF::getSession()->unregister('haUserGroupName');

HeaderUtil::delayedRedirect(
LinkHandler::getInstance()->getLink('UserGroupList'),
WCF::getLanguage()->getDynamicVariable('wcf.moderated.hanashi.noResult')
);

exit;
}
if (isset($_POST['haUserGroupName'])) {
$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($_POST['haUserGroupName']) . '%']
);

WCF::getSession()->register('haUserGroupName', $_POST['haUserGroupName']);

WCF::getTpl()->assign([
'haUserGroupName' => $_POST['haUserGroupName'],
]);
} elseif (!empty(WCF::getSession()->getVar('haUserGroupName'))) {
$haUserGroupName = WCF::getSession()->getVar('haUserGroupName');

$eventObj->objectList->getConditionBuilder()->add(
'user_group.groupName LIKE ?',
['%' . WCF::getDB()->escapeLikeValue($haUserGroupName) . '%']
);

WCF::getTpl()->assign([
'haUserGroupName' => $haUserGroupName,
]);
}
}

protected function onCountItems($eventObj)
{
if ($eventObj->objectList->countObjects() == 0 && !empty(WCF::getSession()->getVar('haUserGroupName'))) {
WCF::getSession()->unregister('haUserGroupName');

HeaderUtil::delayedRedirect(
LinkHandler::getInstance()->getLink('UserGroupList'),
WCF::getLanguage()->getDynamicVariable('wcf.moderated.hanashi.noResult')
);

exit;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use wcf\system\WCF;

final class HaUserGroupManageMemberListPageListener implements IParameterizedEventListener
final class HaUserGroupManageMemberListPageListener extends AbstractEventListener
{
public function execute($eventObj, $className, $eventName, array &$parameters)
protected function onAfterInitObjectList($eventObj)
{
if (isset($_POST['haMemberName'])) {
$eventObj->objectList->getConditionBuilder()->add(
Expand Down

0 comments on commit efaf69f

Please sign in to comment.