Page MenuHomeWickedGov Phorge

SecurePollHookHandler.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

SecurePollHookHandler.php

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Extension\CentralAuth\Hooks\Handlers;
use MediaWiki\Extension\CentralAuth\User\CentralAuthUser;
use MediaWiki\Extension\SecurePoll\Hooks\SecurePoll_GetUserParamsHook;
use MediaWiki\Extension\SecurePoll\User\LocalAuth;
use MediaWiki\Title\NamespaceInfo;
use MediaWiki\User\User;
use MediaWiki\WikiMap\WikiMap;
class SecurePollHookHandler implements SecurePoll_GetUserParamsHook {
private NamespaceInfo $namespaceInfo;
public function __construct( NamespaceInfo $namespaceInfo ) {
$this->namespaceInfo = $namespaceInfo;
}
/**
* @param LocalAuth $localAuth Unused
* @param User $user
* @param array &$params
* @return bool
*/
public function onSecurePoll_GetUserParams( LocalAuth $localAuth, User $user, array &$params ) {
if ( !$user->isRegistered() ) {
return true;
}
$centralUser = CentralAuthUser::getInstance( $user );
if ( !( $centralUser->exists() && $centralUser->isAttached() ) ) {
return true;
}
$wikiID = $centralUser->getHomeWiki();
if ( strval( $wikiID ) === '' ) {
return true;
}
$wiki = WikiMap::getWiki( $wikiID );
$wikiUrl = $wiki->getUrl( '' );
$parts = explode( '/', $wikiUrl );
if ( isset( $parts[2] ) ) {
$params['properties']['ca-local-domain'] = $params['domain'];
$params['domain'] = $parts[2];
}
$params['properties']['ca-local-url'] = $params['url'];
$params['url'] = $wiki->getUrl(
$this->namespaceInfo->getCanonicalName( NS_USER ) . ':' . $user->getTitleKey()
);
return true;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 18:20 (3 h, 12 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f2/44/129e43b119472fcacb3e9d85b3fb
Default Alt Text
SecurePollHookHandler.php (2 KB)

Event Timeline