You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
PHTML
32 lines
1.1 KiB
PHTML
2 years ago
|
<?php
|
||
|
namespace Isekai\UserPoints\Quests\Api;
|
||
|
|
||
|
use ApiBase;
|
||
|
use Isekai\UserPoints\Quests\QuestsUtils;
|
||
|
use MediaWiki\Session\SessionManager;
|
||
|
|
||
|
class ApiUserQuestsGetNotification extends ApiBase {
|
||
|
public function __construct( $main, $method ) {
|
||
|
parent::__construct( $main->getMain(), $method );
|
||
|
}
|
||
|
|
||
|
public function execute() {
|
||
|
$user = $this->getUser();
|
||
|
|
||
|
if (!$user->isRegistered()) {
|
||
|
$this->dieWithError('apierror-mustbeloggedin-generic', 'login-required');
|
||
|
}
|
||
|
|
||
|
$sesssionManager = SessionManager::getGlobalSession();
|
||
|
if ($sesssionManager->exists(QuestsUtils::SESSION_KEY_QUEST_COMPLETE_NOTIFICATION)) {
|
||
|
$notificationData = $sesssionManager->get(QuestsUtils::SESSION_KEY_QUEST_COMPLETE_NOTIFICATION);
|
||
|
$this->getResult()->addValue(['userquestsgetnotification'], 'notification', $notificationData);
|
||
|
} else {
|
||
|
$this->getResult()->addValue(['userquestsgetnotification'], 'notification', null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function isInternal() {
|
||
|
return true;
|
||
|
}
|
||
|
}
|