Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
LoginPage | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
execute | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Pages; |
4 | |
5 | use MediaWiki\SpecialPage\SpecialPage; |
6 | |
7 | /** |
8 | * A simple SecurePoll subpage which handles guest logins from a remote website, |
9 | * starts a session, and then redirects to the voting page. |
10 | */ |
11 | class LoginPage extends ActionPage { |
12 | public function execute( $params ) { |
13 | $out = $this->specialPage->getOutput(); |
14 | |
15 | if ( !count( $params ) ) { |
16 | $out->addWikiMsg( 'securepoll-too-few-params' ); |
17 | |
18 | return; |
19 | } |
20 | |
21 | $electionId = intval( $params[0] ); |
22 | $this->election = $this->context->getElection( $electionId ); |
23 | if ( !$this->election ) { |
24 | $out->addWikiMsg( 'securepoll-invalid-election', $electionId ); |
25 | |
26 | return; |
27 | } |
28 | |
29 | $auth = $this->election->getAuth(); |
30 | $status = $auth->newRequestedSession( $this->election ); |
31 | if ( !$status->isOK() ) { |
32 | $out->addWikiTextAsInterface( $status->getWikiText() ); |
33 | return; |
34 | } |
35 | $votePage = SpecialPage::getTitleFor( 'SecurePoll', 'vote/' . $this->election->getId() ); |
36 | $out->redirect( $votePage->getFullURL() ); |
37 | } |
38 | } |