Passed
Pull Request — master (#753)
by Matthew
04:17
created

PageManuallyConfirm::main()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 10
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\Pages\RequestAction;
10
11
use Waca\Exceptions\ApplicationLogicException;
12
use Waca\Exceptions\OptimisticLockFailedException;
13
use Waca\Helpers\Logger;
14
15
class PageManuallyConfirm extends RequestActionBase
16
{
17
    /**
18
     * This endpoint manually confirms a request, bypassing email confirmation.
19
     *
20
     * Only administrators are allowed to do this, for obvious reasons.
21
     *
22
     * @throws ApplicationLogicException|OptimisticLockFailedException
23
     */
24
    protected function main()
25
    {
26
        // This method throws an error if we don't post
27
        $this->checkPosted();
28
29
        // Retrieve the database.
30
        $database = $this->getDatabase();
31
32
        // Find the request
33
        // This method throws exceptions if there is an error with the request.
34
        $request = $this->getRequest($database);
35
36
        // Mark the request as confirmed.
37
        $request->setEmailConfirm("Confirmed");
38
        $request->save();
39
40
        // Log that the request was manually confirmed
41
        Logger::manuallyConfirmRequest($database, $request);
42
43
        // Notify the IRC channel
44
        $this->getNotificationHelper()->requestReceived($request);
45
46
        // Redirect back to the main request, now it should show the request.
47
        $this->redirect('viewRequest', null, array('id' => $request->getId()));
48
    }
49
}
50