@@ -12,21 +12,21 @@ |
||
12 | 12 | |
13 | 13 | interface IRoutedTask extends ITask |
14 | 14 | { |
15 | - /** |
|
16 | - * Sets the route the request will take. Only should be called from the request router. |
|
17 | - * |
|
18 | - * @param $routeName string |
|
19 | - * |
|
20 | - * @return void |
|
21 | - * |
|
22 | - * @throws Exception |
|
23 | - * @category Security-Critical |
|
24 | - */ |
|
25 | - public function setRoute($routeName); |
|
15 | + /** |
|
16 | + * Sets the route the request will take. Only should be called from the request router. |
|
17 | + * |
|
18 | + * @param $routeName string |
|
19 | + * |
|
20 | + * @return void |
|
21 | + * |
|
22 | + * @throws Exception |
|
23 | + * @category Security-Critical |
|
24 | + */ |
|
25 | + public function setRoute($routeName); |
|
26 | 26 | |
27 | - /** |
|
28 | - * Gets the name of the route that has been passed from the request router. |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function getRouteName(); |
|
27 | + /** |
|
28 | + * Gets the name of the route that has been passed from the request router. |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function getRouteName(); |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -16,97 +16,97 @@ |
||
16 | 16 | |
17 | 17 | abstract class ApiPageBase extends TaskBase implements IRoutedTask, IApiAction |
18 | 18 | { |
19 | - /** |
|
20 | - * API result document |
|
21 | - * @var DOMDocument |
|
22 | - */ |
|
23 | - protected $document; |
|
24 | - |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->document = new DOMDocument('1.0'); |
|
28 | - } |
|
29 | - |
|
30 | - final public function execute() |
|
31 | - { |
|
32 | - $this->main(); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @param string $routeName |
|
37 | - */ |
|
38 | - public function setRoute($routeName) |
|
39 | - { |
|
40 | - // no-op |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getRouteName() |
|
47 | - { |
|
48 | - return 'main'; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Main function for this page, when no specific actions are called. |
|
53 | - * |
|
54 | - * @throws ApiException |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - final protected function main() |
|
58 | - { |
|
59 | - if (headers_sent()) { |
|
60 | - throw new ApiException('Headers have already been sent - this indicates a bug in the application!'); |
|
61 | - } |
|
62 | - |
|
63 | - header("Content-Type: text/xml"); |
|
64 | - |
|
65 | - // javascript access control |
|
66 | - $httpOrigin = WebRequest::origin(); |
|
67 | - |
|
68 | - if ($httpOrigin !== null) { |
|
69 | - $CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts(); |
|
70 | - |
|
71 | - if (in_array($httpOrigin, $CORSallowed)) { |
|
72 | - header("Access-Control-Allow-Origin: " . $httpOrigin); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - $responseData = $this->runApiPage(); |
|
77 | - |
|
78 | - ob_end_clean(); |
|
79 | - print($responseData); |
|
80 | - ob_start(); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Method that runs API action |
|
85 | - * |
|
86 | - * @param DOMElement $apiDocument |
|
87 | - * |
|
88 | - * @return DOMElement |
|
89 | - */ |
|
90 | - abstract public function executeApiAction(DOMElement $apiDocument); |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - final public function runApiPage() |
|
96 | - { |
|
97 | - $apiDocument = $this->document->createElement("api"); |
|
98 | - |
|
99 | - try { |
|
100 | - $apiDocument = $this->executeApiAction($apiDocument); |
|
101 | - } |
|
102 | - catch (ApiException $ex) { |
|
103 | - $exception = $this->document->createElement("error"); |
|
104 | - $exception->setAttribute("message", $ex->getMessage()); |
|
105 | - $apiDocument->appendChild($exception); |
|
106 | - } |
|
107 | - |
|
108 | - $this->document->appendChild($apiDocument); |
|
109 | - |
|
110 | - return $this->document->saveXML(); |
|
111 | - } |
|
19 | + /** |
|
20 | + * API result document |
|
21 | + * @var DOMDocument |
|
22 | + */ |
|
23 | + protected $document; |
|
24 | + |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->document = new DOMDocument('1.0'); |
|
28 | + } |
|
29 | + |
|
30 | + final public function execute() |
|
31 | + { |
|
32 | + $this->main(); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @param string $routeName |
|
37 | + */ |
|
38 | + public function setRoute($routeName) |
|
39 | + { |
|
40 | + // no-op |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getRouteName() |
|
47 | + { |
|
48 | + return 'main'; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Main function for this page, when no specific actions are called. |
|
53 | + * |
|
54 | + * @throws ApiException |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + final protected function main() |
|
58 | + { |
|
59 | + if (headers_sent()) { |
|
60 | + throw new ApiException('Headers have already been sent - this indicates a bug in the application!'); |
|
61 | + } |
|
62 | + |
|
63 | + header("Content-Type: text/xml"); |
|
64 | + |
|
65 | + // javascript access control |
|
66 | + $httpOrigin = WebRequest::origin(); |
|
67 | + |
|
68 | + if ($httpOrigin !== null) { |
|
69 | + $CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts(); |
|
70 | + |
|
71 | + if (in_array($httpOrigin, $CORSallowed)) { |
|
72 | + header("Access-Control-Allow-Origin: " . $httpOrigin); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + $responseData = $this->runApiPage(); |
|
77 | + |
|
78 | + ob_end_clean(); |
|
79 | + print($responseData); |
|
80 | + ob_start(); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Method that runs API action |
|
85 | + * |
|
86 | + * @param DOMElement $apiDocument |
|
87 | + * |
|
88 | + * @return DOMElement |
|
89 | + */ |
|
90 | + abstract public function executeApiAction(DOMElement $apiDocument); |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + final public function runApiPage() |
|
96 | + { |
|
97 | + $apiDocument = $this->document->createElement("api"); |
|
98 | + |
|
99 | + try { |
|
100 | + $apiDocument = $this->executeApiAction($apiDocument); |
|
101 | + } |
|
102 | + catch (ApiException $ex) { |
|
103 | + $exception = $this->document->createElement("error"); |
|
104 | + $exception->setAttribute("message", $ex->getMessage()); |
|
105 | + $apiDocument->appendChild($exception); |
|
106 | + } |
|
107 | + |
|
108 | + $this->document->appendChild($apiDocument); |
|
109 | + |
|
110 | + return $this->document->saveXML(); |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | \ No newline at end of file |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts(); |
70 | 70 | |
71 | 71 | if (in_array($httpOrigin, $CORSallowed)) { |
72 | - header("Access-Control-Allow-Origin: " . $httpOrigin); |
|
72 | + header("Access-Control-Allow-Origin: ".$httpOrigin); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 |
@@ -10,21 +10,21 @@ |
||
10 | 10 | |
11 | 11 | abstract class PublicInterfacePageBase extends PageBase |
12 | 12 | { |
13 | - /** |
|
14 | - * PublicInterfaceInternalPageBase constructor. |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - $this->template = 'publicbase.tpl'; |
|
19 | - } |
|
13 | + /** |
|
14 | + * PublicInterfaceInternalPageBase constructor. |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + $this->template = 'publicbase.tpl'; |
|
19 | + } |
|
20 | 20 | |
21 | - final public function execute() |
|
22 | - { |
|
23 | - parent::execute(); |
|
24 | - } |
|
21 | + final public function execute() |
|
22 | + { |
|
23 | + parent::execute(); |
|
24 | + } |
|
25 | 25 | |
26 | - final public function finalisePage() |
|
27 | - { |
|
28 | - parent::finalisePage(); |
|
29 | - } |
|
26 | + final public function finalisePage() |
|
27 | + { |
|
28 | + parent::finalisePage(); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -15,55 +15,55 @@ |
||
15 | 15 | */ |
16 | 16 | class Offline |
17 | 17 | { |
18 | - /** |
|
19 | - * Determines if the tool is offline |
|
20 | - * @return bool |
|
21 | - */ |
|
22 | - public static function isOffline() |
|
23 | - { |
|
24 | - global $dontUseDb; |
|
18 | + /** |
|
19 | + * Determines if the tool is offline |
|
20 | + * @return bool |
|
21 | + */ |
|
22 | + public static function isOffline() |
|
23 | + { |
|
24 | + global $dontUseDb; |
|
25 | 25 | |
26 | - return (bool)$dontUseDb; |
|
27 | - } |
|
26 | + return (bool)$dontUseDb; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Gets the offline message |
|
31 | - * |
|
32 | - * @param bool $external |
|
33 | - * @param null $message |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public static function getOfflineMessage($external, $message = null) |
|
38 | - { |
|
39 | - global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
29 | + /** |
|
30 | + * Gets the offline message |
|
31 | + * |
|
32 | + * @param bool $external |
|
33 | + * @param null $message |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public static function getOfflineMessage($external, $message = null) |
|
38 | + { |
|
39 | + global $dontUseDbCulprit, $dontUseDbReason, $baseurl; |
|
40 | 40 | |
41 | - $smarty = new Smarty(); |
|
42 | - $smarty->assign("baseurl", $baseurl); |
|
43 | - $smarty->assign("toolversion", Environment::getToolVersion()); |
|
41 | + $smarty = new Smarty(); |
|
42 | + $smarty->assign("baseurl", $baseurl); |
|
43 | + $smarty->assign("toolversion", Environment::getToolVersion()); |
|
44 | 44 | |
45 | - if (!headers_sent()) { |
|
46 | - header("HTTP/1.1 503 Service Unavailable"); |
|
47 | - } |
|
45 | + if (!headers_sent()) { |
|
46 | + header("HTTP/1.1 503 Service Unavailable"); |
|
47 | + } |
|
48 | 48 | |
49 | - if ($external) { |
|
50 | - return $smarty->fetch("offline/external.tpl"); |
|
51 | - } |
|
52 | - else { |
|
53 | - $hideCulprit = true; |
|
49 | + if ($external) { |
|
50 | + return $smarty->fetch("offline/external.tpl"); |
|
51 | + } |
|
52 | + else { |
|
53 | + $hideCulprit = true; |
|
54 | 54 | |
55 | - // Use the provided message if possible |
|
56 | - if ($message === null) { |
|
57 | - $hideCulprit = false; |
|
58 | - $message = $dontUseDbReason; |
|
59 | - } |
|
55 | + // Use the provided message if possible |
|
56 | + if ($message === null) { |
|
57 | + $hideCulprit = false; |
|
58 | + $message = $dontUseDbReason; |
|
59 | + } |
|
60 | 60 | |
61 | - $smarty->assign("hideCulprit", $hideCulprit); |
|
62 | - $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
63 | - $smarty->assign("dontUseDbReason", $message); |
|
64 | - $smarty->assign("alerts", array()); |
|
61 | + $smarty->assign("hideCulprit", $hideCulprit); |
|
62 | + $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit); |
|
63 | + $smarty->assign("dontUseDbReason", $message); |
|
64 | + $smarty->assign("alerts", array()); |
|
65 | 65 | |
66 | - return $smarty->fetch("offline/internal.tpl"); |
|
67 | - } |
|
68 | - } |
|
66 | + return $smarty->fetch("offline/internal.tpl"); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | */ |
20 | 20 | protected function main() |
21 | 21 | { |
22 | - $path = $this->getSiteConfiguration()->getFilePath() . '/team.json'; |
|
22 | + $path = $this->getSiteConfiguration()->getFilePath().'/team.json'; |
|
23 | 23 | $json = file_get_contents($path); |
24 | 24 | |
25 | 25 | $teamData = json_decode($json, true); |
@@ -12,31 +12,31 @@ |
||
12 | 12 | |
13 | 13 | class PageTeam extends InternalPageBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Main function for this page, when no specific actions are called. |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - protected function main() |
|
20 | - { |
|
21 | - $path = $this->getSiteConfiguration()->getFilePath() . '/team.json'; |
|
22 | - $json = file_get_contents($path); |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $path = $this->getSiteConfiguration()->getFilePath() . '/team.json'; |
|
22 | + $json = file_get_contents($path); |
|
23 | 23 | |
24 | - $teamData = json_decode($json, true); |
|
24 | + $teamData = json_decode($json, true); |
|
25 | 25 | |
26 | - $active = array(); |
|
27 | - $inactive = array(); |
|
26 | + $active = array(); |
|
27 | + $inactive = array(); |
|
28 | 28 | |
29 | - foreach ($teamData as $name => $item) { |
|
30 | - if (count($item['Role']) == 0) { |
|
31 | - $inactive[$name] = $item; |
|
32 | - } |
|
33 | - else { |
|
34 | - $active[$name] = $item; |
|
35 | - } |
|
36 | - } |
|
29 | + foreach ($teamData as $name => $item) { |
|
30 | + if (count($item['Role']) == 0) { |
|
31 | + $inactive[$name] = $item; |
|
32 | + } |
|
33 | + else { |
|
34 | + $active[$name] = $item; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - $this->assign('developer', $active); |
|
39 | - $this->assign('inactiveDeveloper', $inactive); |
|
40 | - $this->setTemplate('team/team.tpl'); |
|
41 | - } |
|
38 | + $this->assign('developer', $active); |
|
39 | + $this->assign('inactiveDeveloper', $inactive); |
|
40 | + $this->setTemplate('team/team.tpl'); |
|
41 | + } |
|
42 | 42 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
65 | - $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
65 | + $this->setHtmlTitle($safeUsername.' :: Users :: Statistics'); |
|
66 | 66 | |
67 | 67 | $activitySummary = $database->prepare(<<<SQL |
68 | 68 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | class StatsUsers extends InternalPageBase |
24 | 24 | { |
25 | - public function main() |
|
26 | - { |
|
27 | - $this->setHtmlTitle('Users :: Statistics'); |
|
25 | + public function main() |
|
26 | + { |
|
27 | + $this->setHtmlTitle('Users :: Statistics'); |
|
28 | 28 | |
29 | - $database = $this->getDatabase(); |
|
29 | + $database = $this->getDatabase(); |
|
30 | 30 | |
31 | - $query = <<<SQL |
|
31 | + $query = <<<SQL |
|
32 | 32 | SELECT |
33 | 33 | u.id |
34 | 34 | , u.username |
@@ -44,36 +44,36 @@ discard block |
||
44 | 44 | WHERE u.status = 'Active' |
45 | 45 | SQL; |
46 | 46 | |
47 | - $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
48 | - $this->assign('users', $users); |
|
47 | + $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
48 | + $this->assign('users', $users); |
|
49 | 49 | |
50 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
51 | - $this->setTemplate("statistics/users.tpl"); |
|
52 | - } |
|
50 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
51 | + $this->setTemplate("statistics/users.tpl"); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Entry point for the detail action. |
|
56 | - * |
|
57 | - * @throws ApplicationLogicException |
|
58 | - */ |
|
59 | - protected function detail() |
|
60 | - { |
|
61 | - $userId = WebRequest::getInt('user'); |
|
62 | - if ($userId === null) { |
|
63 | - throw new ApplicationLogicException("User not found"); |
|
64 | - } |
|
54 | + /** |
|
55 | + * Entry point for the detail action. |
|
56 | + * |
|
57 | + * @throws ApplicationLogicException |
|
58 | + */ |
|
59 | + protected function detail() |
|
60 | + { |
|
61 | + $userId = WebRequest::getInt('user'); |
|
62 | + if ($userId === null) { |
|
63 | + throw new ApplicationLogicException("User not found"); |
|
64 | + } |
|
65 | 65 | |
66 | - $database = $this->getDatabase(); |
|
66 | + $database = $this->getDatabase(); |
|
67 | 67 | |
68 | - $user = User::getById($userId, $database); |
|
69 | - if ($user == false) { |
|
70 | - throw new ApplicationLogicException('User not found'); |
|
71 | - } |
|
68 | + $user = User::getById($userId, $database); |
|
69 | + if ($user == false) { |
|
70 | + throw new ApplicationLogicException('User not found'); |
|
71 | + } |
|
72 | 72 | |
73 | - $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
74 | - $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
73 | + $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
74 | + $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
75 | 75 | |
76 | - $activitySummary = $database->prepare(<<<SQL |
|
76 | + $activitySummary = $database->prepare(<<<SQL |
|
77 | 77 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
78 | 78 | FROM log |
79 | 79 | INNER JOIN user ON log.user = user.id |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | WHERE user.username = :username |
82 | 82 | GROUP BY action; |
83 | 83 | SQL |
84 | - ); |
|
85 | - $activitySummary->execute(array(":username" => $user->getUsername())); |
|
86 | - $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
84 | + ); |
|
85 | + $activitySummary->execute(array(":username" => $user->getUsername())); |
|
86 | + $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
87 | 87 | |
88 | - $this->assign("user", $user); |
|
89 | - $this->assign("activity", $activitySummaryData); |
|
88 | + $this->assign("user", $user); |
|
89 | + $this->assign("activity", $activitySummaryData); |
|
90 | 90 | |
91 | - $usersCreatedQuery = $database->prepare(<<<SQL |
|
91 | + $usersCreatedQuery = $database->prepare(<<<SQL |
|
92 | 92 | SELECT log.timestamp time, request.name name, request.id id |
93 | 93 | FROM log |
94 | 94 | INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request') |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
100 | 100 | ORDER BY log.timestamp; |
101 | 101 | SQL |
102 | - ); |
|
103 | - $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
104 | - $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
105 | - $this->assign("created", $usersCreated); |
|
102 | + ); |
|
103 | + $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
104 | + $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
105 | + $this->assign("created", $usersCreated); |
|
106 | 106 | |
107 | - $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
107 | + $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
108 | 108 | SELECT log.timestamp time, request.name name, request.id id |
109 | 109 | FROM log |
110 | 110 | JOIN request ON request.id = log.objectid AND log.objecttype = 'Request' |
@@ -115,45 +115,45 @@ discard block |
||
115 | 115 | AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0') |
116 | 116 | ORDER BY log.timestamp; |
117 | 117 | SQL |
118 | - ); |
|
119 | - $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
120 | - $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
121 | - $this->assign("notcreated", $usersNotCreated); |
|
122 | - |
|
123 | - /** @var Log[] $logs */ |
|
124 | - $logs = LogSearchHelper::get($database) |
|
125 | - ->byObjectType('User') |
|
126 | - ->byObjectId($user->getId()) |
|
127 | - ->getRecordCount($logCount) |
|
128 | - ->fetch(); |
|
129 | - |
|
130 | - if ($logCount === 0) { |
|
131 | - $this->assign('accountlog', array()); |
|
132 | - } |
|
133 | - else { |
|
134 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
135 | - |
|
136 | - $this->assign("accountlog", $logData); |
|
137 | - $this->assign("users", $users); |
|
138 | - } |
|
139 | - |
|
140 | - $currentUser = User::getCurrent($database); |
|
141 | - $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
142 | - $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
143 | - $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
144 | - $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
145 | - $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
146 | - $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
147 | - |
|
148 | - $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
149 | - $this->assign('oauth', $oauth); |
|
150 | - |
|
151 | - if ($oauth->isFullyLinked()) { |
|
152 | - $this->assign('identity', $oauth->getIdentity(true)); |
|
153 | - $this->assign('identityExpired', $oauth->identityExpired()); |
|
154 | - } |
|
155 | - |
|
156 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
157 | - $this->setTemplate("statistics/userdetail.tpl"); |
|
158 | - } |
|
118 | + ); |
|
119 | + $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
120 | + $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
121 | + $this->assign("notcreated", $usersNotCreated); |
|
122 | + |
|
123 | + /** @var Log[] $logs */ |
|
124 | + $logs = LogSearchHelper::get($database) |
|
125 | + ->byObjectType('User') |
|
126 | + ->byObjectId($user->getId()) |
|
127 | + ->getRecordCount($logCount) |
|
128 | + ->fetch(); |
|
129 | + |
|
130 | + if ($logCount === 0) { |
|
131 | + $this->assign('accountlog', array()); |
|
132 | + } |
|
133 | + else { |
|
134 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
135 | + |
|
136 | + $this->assign("accountlog", $logData); |
|
137 | + $this->assign("users", $users); |
|
138 | + } |
|
139 | + |
|
140 | + $currentUser = User::getCurrent($database); |
|
141 | + $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
142 | + $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
143 | + $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
144 | + $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
145 | + $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
146 | + $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
147 | + |
|
148 | + $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
149 | + $this->assign('oauth', $oauth); |
|
150 | + |
|
151 | + if ($oauth->isFullyLinked()) { |
|
152 | + $this->assign('identity', $oauth->getIdentity(true)); |
|
153 | + $this->assign('identityExpired', $oauth->identityExpired()); |
|
154 | + } |
|
155 | + |
|
156 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
157 | + $this->setTemplate("statistics/userdetail.tpl"); |
|
158 | + } |
|
159 | 159 | } |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | class PageEmailConfirmationRequired extends PublicInterfacePageBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Main function for this page, when no specific actions are called. |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - protected function main() |
|
20 | - { |
|
21 | - $this->setTemplate('request/email-confirmation.tpl'); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $this->setTemplate('request/email-confirmation.tpl'); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -19,150 +19,150 @@ |
||
19 | 19 | |
20 | 20 | class PageRequestAccount extends PublicInterfacePageBase |
21 | 21 | { |
22 | - /** |
|
23 | - * Main function for this page, when no specific actions are called. |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - protected function main() |
|
27 | - { |
|
28 | - // dual mode page |
|
29 | - if (WebRequest::wasPosted()) { |
|
30 | - $request = $this->createNewRequest(); |
|
31 | - |
|
32 | - $validationErrors = $this->validateRequest($request); |
|
33 | - |
|
34 | - if (count($validationErrors) > 0) { |
|
35 | - foreach ($validationErrors as $validationError) { |
|
36 | - SessionAlert::error($validationError->getErrorMessage()); |
|
37 | - } |
|
38 | - |
|
39 | - // Preserve the data after an error |
|
40 | - WebRequest::setSessionContext('accountReq', |
|
41 | - array( |
|
42 | - 'username' => WebRequest::postString('name'), |
|
43 | - 'email' => WebRequest::postEmail('email'), |
|
44 | - 'comments' => WebRequest::postString('comments'), |
|
45 | - ) |
|
46 | - ); |
|
47 | - |
|
48 | - // Validation error, bomb out early. |
|
49 | - $this->redirect(); |
|
50 | - |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - // actually save the request to the database |
|
55 | - if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) { |
|
56 | - $this->saveAsEmailConfirmation($request); |
|
57 | - } |
|
58 | - else { |
|
59 | - $this->saveWithoutEmailConfirmation($request); |
|
60 | - } |
|
61 | - } |
|
62 | - else { |
|
63 | - // set the form values from the session context |
|
64 | - $context = WebRequest::getSessionContext('accountReq'); |
|
65 | - if ($context !== null && is_array($context)) { |
|
66 | - $this->assign('username', $context['username']); |
|
67 | - $this->assign('email', $context['email']); |
|
68 | - $this->assign('comments', $context['comments']); |
|
69 | - } |
|
70 | - |
|
71 | - // Clear it for a refresh |
|
72 | - WebRequest::setSessionContext('accountReq', null); |
|
73 | - |
|
74 | - $this->setTemplate('request/request-form.tpl'); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return Request |
|
80 | - */ |
|
81 | - protected function createNewRequest() |
|
82 | - { |
|
83 | - $request = new Request(); |
|
84 | - $request->setDatabase($this->getDatabase()); |
|
85 | - |
|
86 | - $request->setName(WebRequest::postString('name')); |
|
87 | - $request->setEmail(WebRequest::postEmail('email')); |
|
88 | - $request->setComment(WebRequest::postString('comments')); |
|
89 | - |
|
90 | - $request->setIp(WebRequest::remoteAddress()); |
|
91 | - $request->setForwardedIp(WebRequest::forwardedAddress()); |
|
92 | - |
|
93 | - $request->setUserAgent(WebRequest::userAgent()); |
|
94 | - |
|
95 | - return $request; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param Request $request |
|
100 | - * |
|
101 | - * @return ValidationError[] |
|
102 | - */ |
|
103 | - protected function validateRequest($request) |
|
104 | - { |
|
105 | - $validationHelper = new RequestValidationHelper( |
|
106 | - new BanHelper($this->getDatabase()), |
|
107 | - $request, |
|
108 | - WebRequest::postEmail('emailconfirm'), |
|
109 | - $this->getDatabase(), |
|
110 | - $this->getAntiSpoofProvider(), |
|
111 | - $this->getXffTrustProvider(), |
|
112 | - $this->getHttpHelper(), |
|
113 | - $this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
114 | - $this->getSiteConfiguration()->getTitleBlacklistEnabled(), |
|
115 | - $this->getTorExitProvider()); |
|
116 | - |
|
117 | - // These are arrays of ValidationError. |
|
118 | - $nameValidation = $validationHelper->validateName(); |
|
119 | - $emailValidation = $validationHelper->validateEmail(); |
|
120 | - $otherValidation = $validationHelper->validateOther(); |
|
121 | - |
|
122 | - $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation); |
|
123 | - |
|
124 | - return $validationErrors; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @param Request $request |
|
129 | - * |
|
130 | - * @throws Exception |
|
131 | - */ |
|
132 | - protected function saveAsEmailConfirmation(Request $request) |
|
133 | - { |
|
134 | - $request->generateEmailConfirmationHash(); |
|
135 | - $request->save(); |
|
136 | - |
|
137 | - $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
138 | - $request->getIp(), |
|
139 | - $request->getForwardedIp()); |
|
140 | - |
|
141 | - $this->assign("ip", $trustedIp); |
|
142 | - $this->assign("id", $request->getId()); |
|
143 | - $this->assign("hash", $request->getEmailConfirm()); |
|
144 | - |
|
145 | - // Sends the confirmation email to the user. |
|
146 | - $this->getEmailHelper()->sendMail( |
|
147 | - $request->getEmail(), |
|
148 | - "[ACC #{$request->getId()}] English Wikipedia Account Request", |
|
149 | - $this->fetchTemplate('request/confirmation-mail.tpl')); |
|
150 | - |
|
151 | - $this->redirect('emailConfirmationRequired'); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param Request $request |
|
156 | - * |
|
157 | - * @throws Exception |
|
158 | - */ |
|
159 | - protected function saveWithoutEmailConfirmation(Request $request) |
|
160 | - { |
|
161 | - $request->setEmailConfirm(0); // fixme Since it can't be null |
|
162 | - $request->save(); |
|
163 | - |
|
164 | - $this->getNotificationHelper()->requestReceived($request); |
|
165 | - |
|
166 | - $this->redirect('requestSubmitted'); |
|
167 | - } |
|
22 | + /** |
|
23 | + * Main function for this page, when no specific actions are called. |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + protected function main() |
|
27 | + { |
|
28 | + // dual mode page |
|
29 | + if (WebRequest::wasPosted()) { |
|
30 | + $request = $this->createNewRequest(); |
|
31 | + |
|
32 | + $validationErrors = $this->validateRequest($request); |
|
33 | + |
|
34 | + if (count($validationErrors) > 0) { |
|
35 | + foreach ($validationErrors as $validationError) { |
|
36 | + SessionAlert::error($validationError->getErrorMessage()); |
|
37 | + } |
|
38 | + |
|
39 | + // Preserve the data after an error |
|
40 | + WebRequest::setSessionContext('accountReq', |
|
41 | + array( |
|
42 | + 'username' => WebRequest::postString('name'), |
|
43 | + 'email' => WebRequest::postEmail('email'), |
|
44 | + 'comments' => WebRequest::postString('comments'), |
|
45 | + ) |
|
46 | + ); |
|
47 | + |
|
48 | + // Validation error, bomb out early. |
|
49 | + $this->redirect(); |
|
50 | + |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + // actually save the request to the database |
|
55 | + if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) { |
|
56 | + $this->saveAsEmailConfirmation($request); |
|
57 | + } |
|
58 | + else { |
|
59 | + $this->saveWithoutEmailConfirmation($request); |
|
60 | + } |
|
61 | + } |
|
62 | + else { |
|
63 | + // set the form values from the session context |
|
64 | + $context = WebRequest::getSessionContext('accountReq'); |
|
65 | + if ($context !== null && is_array($context)) { |
|
66 | + $this->assign('username', $context['username']); |
|
67 | + $this->assign('email', $context['email']); |
|
68 | + $this->assign('comments', $context['comments']); |
|
69 | + } |
|
70 | + |
|
71 | + // Clear it for a refresh |
|
72 | + WebRequest::setSessionContext('accountReq', null); |
|
73 | + |
|
74 | + $this->setTemplate('request/request-form.tpl'); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return Request |
|
80 | + */ |
|
81 | + protected function createNewRequest() |
|
82 | + { |
|
83 | + $request = new Request(); |
|
84 | + $request->setDatabase($this->getDatabase()); |
|
85 | + |
|
86 | + $request->setName(WebRequest::postString('name')); |
|
87 | + $request->setEmail(WebRequest::postEmail('email')); |
|
88 | + $request->setComment(WebRequest::postString('comments')); |
|
89 | + |
|
90 | + $request->setIp(WebRequest::remoteAddress()); |
|
91 | + $request->setForwardedIp(WebRequest::forwardedAddress()); |
|
92 | + |
|
93 | + $request->setUserAgent(WebRequest::userAgent()); |
|
94 | + |
|
95 | + return $request; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param Request $request |
|
100 | + * |
|
101 | + * @return ValidationError[] |
|
102 | + */ |
|
103 | + protected function validateRequest($request) |
|
104 | + { |
|
105 | + $validationHelper = new RequestValidationHelper( |
|
106 | + new BanHelper($this->getDatabase()), |
|
107 | + $request, |
|
108 | + WebRequest::postEmail('emailconfirm'), |
|
109 | + $this->getDatabase(), |
|
110 | + $this->getAntiSpoofProvider(), |
|
111 | + $this->getXffTrustProvider(), |
|
112 | + $this->getHttpHelper(), |
|
113 | + $this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
114 | + $this->getSiteConfiguration()->getTitleBlacklistEnabled(), |
|
115 | + $this->getTorExitProvider()); |
|
116 | + |
|
117 | + // These are arrays of ValidationError. |
|
118 | + $nameValidation = $validationHelper->validateName(); |
|
119 | + $emailValidation = $validationHelper->validateEmail(); |
|
120 | + $otherValidation = $validationHelper->validateOther(); |
|
121 | + |
|
122 | + $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation); |
|
123 | + |
|
124 | + return $validationErrors; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @param Request $request |
|
129 | + * |
|
130 | + * @throws Exception |
|
131 | + */ |
|
132 | + protected function saveAsEmailConfirmation(Request $request) |
|
133 | + { |
|
134 | + $request->generateEmailConfirmationHash(); |
|
135 | + $request->save(); |
|
136 | + |
|
137 | + $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
138 | + $request->getIp(), |
|
139 | + $request->getForwardedIp()); |
|
140 | + |
|
141 | + $this->assign("ip", $trustedIp); |
|
142 | + $this->assign("id", $request->getId()); |
|
143 | + $this->assign("hash", $request->getEmailConfirm()); |
|
144 | + |
|
145 | + // Sends the confirmation email to the user. |
|
146 | + $this->getEmailHelper()->sendMail( |
|
147 | + $request->getEmail(), |
|
148 | + "[ACC #{$request->getId()}] English Wikipedia Account Request", |
|
149 | + $this->fetchTemplate('request/confirmation-mail.tpl')); |
|
150 | + |
|
151 | + $this->redirect('emailConfirmationRequired'); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param Request $request |
|
156 | + * |
|
157 | + * @throws Exception |
|
158 | + */ |
|
159 | + protected function saveWithoutEmailConfirmation(Request $request) |
|
160 | + { |
|
161 | + $request->setEmailConfirm(0); // fixme Since it can't be null |
|
162 | + $request->save(); |
|
163 | + |
|
164 | + $this->getNotificationHelper()->requestReceived($request); |
|
165 | + |
|
166 | + $this->redirect('requestSubmitted'); |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | class PageRequestSubmitted extends PublicInterfacePageBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Main function for this page, when no specific actions are called. |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - protected function main() |
|
20 | - { |
|
21 | - $this->setTemplate('request/email-confirmed.tpl'); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $this->setTemplate('request/email-confirmed.tpl'); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |