@@ -13,37 +13,37 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class AutoLoader |
| 15 | 15 | { |
| 16 | - public static function load($class) |
|
| 17 | - { |
|
| 18 | - // handle namespaces sensibly |
|
| 19 | - if (strpos($class, "Waca") !== false) { |
|
| 20 | - // strip off the initial namespace |
|
| 21 | - $class = str_replace("Waca\\", "", $class); |
|
| 16 | + public static function load($class) |
|
| 17 | + { |
|
| 18 | + // handle namespaces sensibly |
|
| 19 | + if (strpos($class, "Waca") !== false) { |
|
| 20 | + // strip off the initial namespace |
|
| 21 | + $class = str_replace("Waca\\", "", $class); |
|
| 22 | 22 | |
| 23 | - // swap backslashes for forward slashes to map to directory names |
|
| 24 | - $class = str_replace("\\", "/", $class); |
|
| 25 | - } |
|
| 23 | + // swap backslashes for forward slashes to map to directory names |
|
| 24 | + $class = str_replace("\\", "/", $class); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - $paths = array( |
|
| 28 | - __DIR__ . '/' . $class . ".php", |
|
| 29 | - __DIR__ . '/DataObjects/' . $class . ".php", |
|
| 30 | - __DIR__ . '/Providers/' . $class . ".php", |
|
| 31 | - __DIR__ . '/Providers/Interfaces/' . $class . ".php", |
|
| 32 | - __DIR__ . '/Validation/' . $class . ".php", |
|
| 33 | - __DIR__ . '/Helpers/' . $class . ".php", |
|
| 34 | - __DIR__ . '/Helpers/Interfaces/' . $class . ".php", |
|
| 35 | - __DIR__ . '/' . $class . ".php", |
|
| 36 | - ); |
|
| 27 | + $paths = array( |
|
| 28 | + __DIR__ . '/' . $class . ".php", |
|
| 29 | + __DIR__ . '/DataObjects/' . $class . ".php", |
|
| 30 | + __DIR__ . '/Providers/' . $class . ".php", |
|
| 31 | + __DIR__ . '/Providers/Interfaces/' . $class . ".php", |
|
| 32 | + __DIR__ . '/Validation/' . $class . ".php", |
|
| 33 | + __DIR__ . '/Helpers/' . $class . ".php", |
|
| 34 | + __DIR__ . '/Helpers/Interfaces/' . $class . ".php", |
|
| 35 | + __DIR__ . '/' . $class . ".php", |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - foreach ($paths as $file) { |
|
| 39 | - if (file_exists($file)) { |
|
| 40 | - /** @noinspection PhpIncludeInspection */ |
|
| 41 | - require_once($file); |
|
| 42 | - } |
|
| 38 | + foreach ($paths as $file) { |
|
| 39 | + if (file_exists($file)) { |
|
| 40 | + /** @noinspection PhpIncludeInspection */ |
|
| 41 | + require_once($file); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if (class_exists($class)) { |
|
| 45 | - return; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 44 | + if (class_exists($class)) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | class RequestStatus |
| 12 | 12 | { |
| 13 | - const HOSPITAL = 'Hospital'; |
|
| 14 | - const JOBQUEUE = 'JobQueue'; |
|
| 15 | - const CLOSED = 'Closed'; |
|
| 13 | + const HOSPITAL = 'Hospital'; |
|
| 14 | + const JOBQUEUE = 'JobQueue'; |
|
| 15 | + const CLOSED = 'Closed'; |
|
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -18,71 +18,71 @@ |
||
| 18 | 18 | |
| 19 | 19 | trait RequestListData |
| 20 | 20 | { |
| 21 | - // function imports from InternalPageBase etc. |
|
| 22 | - protected abstract function getDatabase(); |
|
| 23 | - |
|
| 24 | - protected abstract function getXffTrustProvider(); |
|
| 25 | - |
|
| 26 | - protected abstract function getSiteConfiguration(); |
|
| 27 | - |
|
| 28 | - protected abstract function barrierTest($action, User $user, $pageName = null); |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @param Request[] $requests |
|
| 32 | - * |
|
| 33 | - * @return RequestList |
|
| 34 | - */ |
|
| 35 | - protected function prepareRequestData(array $requests) : RequestList |
|
| 36 | - { |
|
| 37 | - $requestList = new RequestList(); |
|
| 38 | - $requestList->requests = $requests; |
|
| 39 | - |
|
| 40 | - $userIds = array_map( |
|
| 41 | - function(Request $entry) { |
|
| 42 | - return $entry->getReserved(); |
|
| 43 | - }, |
|
| 44 | - $requests |
|
| 45 | - ); |
|
| 46 | - |
|
| 47 | - $requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username'); |
|
| 48 | - |
|
| 49 | - $requestList->requestTrustedIp = []; |
|
| 50 | - $requestList->relatedIpRequests = []; |
|
| 51 | - $requestList->relatedEmailRequests = []; |
|
| 52 | - |
|
| 53 | - foreach ($requests as $request) { |
|
| 54 | - $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
| 55 | - $request->getIp(), |
|
| 56 | - $request->getForwardedIp() |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - RequestSearchHelper::get($this->getDatabase()) |
|
| 60 | - ->byIp($trustedIp) |
|
| 61 | - ->withConfirmedEmail() |
|
| 62 | - ->excludingPurgedData($this->getSiteConfiguration()) |
|
| 63 | - ->excludingRequest($request->getId()) |
|
| 64 | - ->getRecordCount($ipCount); |
|
| 65 | - |
|
| 66 | - RequestSearchHelper::get($this->getDatabase()) |
|
| 67 | - ->byEmailAddress($request->getEmail()) |
|
| 68 | - ->withConfirmedEmail() |
|
| 69 | - ->excludingPurgedData($this->getSiteConfiguration()) |
|
| 70 | - ->excludingRequest($request->getId()) |
|
| 71 | - ->getRecordCount($emailCount); |
|
| 72 | - |
|
| 73 | - $requestList->requestTrustedIp[$request->getId()] = $trustedIp; |
|
| 74 | - $requestList->relatedEmailRequests[$request->getId()] = $emailCount; |
|
| 75 | - $requestList->relatedIpRequests[$request->getId()] = $ipCount; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $currentUser = User::getCurrent($this->getDatabase()); |
|
| 79 | - |
|
| 80 | - $requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class); |
|
| 81 | - $requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class); |
|
| 82 | - $requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData'); |
|
| 83 | - $requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail(); |
|
| 84 | - $requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp(); |
|
| 85 | - |
|
| 86 | - return $requestList; |
|
| 87 | - } |
|
| 21 | + // function imports from InternalPageBase etc. |
|
| 22 | + protected abstract function getDatabase(); |
|
| 23 | + |
|
| 24 | + protected abstract function getXffTrustProvider(); |
|
| 25 | + |
|
| 26 | + protected abstract function getSiteConfiguration(); |
|
| 27 | + |
|
| 28 | + protected abstract function barrierTest($action, User $user, $pageName = null); |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @param Request[] $requests |
|
| 32 | + * |
|
| 33 | + * @return RequestList |
|
| 34 | + */ |
|
| 35 | + protected function prepareRequestData(array $requests) : RequestList |
|
| 36 | + { |
|
| 37 | + $requestList = new RequestList(); |
|
| 38 | + $requestList->requests = $requests; |
|
| 39 | + |
|
| 40 | + $userIds = array_map( |
|
| 41 | + function(Request $entry) { |
|
| 42 | + return $entry->getReserved(); |
|
| 43 | + }, |
|
| 44 | + $requests |
|
| 45 | + ); |
|
| 46 | + |
|
| 47 | + $requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username'); |
|
| 48 | + |
|
| 49 | + $requestList->requestTrustedIp = []; |
|
| 50 | + $requestList->relatedIpRequests = []; |
|
| 51 | + $requestList->relatedEmailRequests = []; |
|
| 52 | + |
|
| 53 | + foreach ($requests as $request) { |
|
| 54 | + $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
| 55 | + $request->getIp(), |
|
| 56 | + $request->getForwardedIp() |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + RequestSearchHelper::get($this->getDatabase()) |
|
| 60 | + ->byIp($trustedIp) |
|
| 61 | + ->withConfirmedEmail() |
|
| 62 | + ->excludingPurgedData($this->getSiteConfiguration()) |
|
| 63 | + ->excludingRequest($request->getId()) |
|
| 64 | + ->getRecordCount($ipCount); |
|
| 65 | + |
|
| 66 | + RequestSearchHelper::get($this->getDatabase()) |
|
| 67 | + ->byEmailAddress($request->getEmail()) |
|
| 68 | + ->withConfirmedEmail() |
|
| 69 | + ->excludingPurgedData($this->getSiteConfiguration()) |
|
| 70 | + ->excludingRequest($request->getId()) |
|
| 71 | + ->getRecordCount($emailCount); |
|
| 72 | + |
|
| 73 | + $requestList->requestTrustedIp[$request->getId()] = $trustedIp; |
|
| 74 | + $requestList->relatedEmailRequests[$request->getId()] = $emailCount; |
|
| 75 | + $requestList->relatedIpRequests[$request->getId()] = $ipCount; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $currentUser = User::getCurrent($this->getDatabase()); |
|
| 79 | + |
|
| 80 | + $requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class); |
|
| 81 | + $requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class); |
|
| 82 | + $requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData'); |
|
| 83 | + $requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail(); |
|
| 84 | + $requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp(); |
|
| 85 | + |
|
| 86 | + return $requestList; |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -38,7 +38,8 @@ |
||
| 38 | 38 | $requestList->requests = $requests; |
| 39 | 39 | |
| 40 | 40 | $userIds = array_map( |
| 41 | - function(Request $entry) { |
|
| 41 | + function(Request $entry) |
|
| 42 | + { |
|
| 42 | 43 | return $entry->getReserved(); |
| 43 | 44 | }, |
| 44 | 45 | $requests |
@@ -25,48 +25,48 @@ |
||
| 25 | 25 | |
| 26 | 26 | trait NavigationMenuAccessControl |
| 27 | 27 | { |
| 28 | - protected abstract function assign($name, $value); |
|
| 28 | + protected abstract function assign($name, $value); |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return SecurityManager |
|
| 32 | - */ |
|
| 33 | - protected abstract function getSecurityManager(); |
|
| 30 | + /** |
|
| 31 | + * @return SecurityManager |
|
| 32 | + */ |
|
| 33 | + protected abstract function getSecurityManager(); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param $currentUser |
|
| 37 | - */ |
|
| 38 | - protected function setupNavMenuAccess($currentUser) |
|
| 39 | - { |
|
| 40 | - $this->assign('nav__canRequests', $this->getSecurityManager() |
|
| 41 | - ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 35 | + /** |
|
| 36 | + * @param $currentUser |
|
| 37 | + */ |
|
| 38 | + protected function setupNavMenuAccess($currentUser) |
|
| 39 | + { |
|
| 40 | + $this->assign('nav__canRequests', $this->getSecurityManager() |
|
| 41 | + ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 42 | 42 | |
| 43 | - $this->assign('nav__canLogs', $this->getSecurityManager() |
|
| 44 | - ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 45 | - $this->assign('nav__canUsers', $this->getSecurityManager() |
|
| 46 | - ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 47 | - $this->assign('nav__canSearch', $this->getSecurityManager() |
|
| 48 | - ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 49 | - $this->assign('nav__canStats', $this->getSecurityManager() |
|
| 50 | - ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 43 | + $this->assign('nav__canLogs', $this->getSecurityManager() |
|
| 44 | + ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 45 | + $this->assign('nav__canUsers', $this->getSecurityManager() |
|
| 46 | + ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 47 | + $this->assign('nav__canSearch', $this->getSecurityManager() |
|
| 48 | + ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 49 | + $this->assign('nav__canStats', $this->getSecurityManager() |
|
| 50 | + ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 51 | 51 | |
| 52 | - $this->assign('nav__canBan', $this->getSecurityManager() |
|
| 53 | - ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 54 | - $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
| 55 | - ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
| 56 | - $currentUser) === SecurityManager::ALLOWED); |
|
| 57 | - $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
| 58 | - ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
| 59 | - $currentUser) === SecurityManager::ALLOWED); |
|
| 60 | - $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
| 61 | - ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 62 | - $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
| 63 | - ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
| 64 | - $currentUser) === SecurityManager::ALLOWED); |
|
| 65 | - $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
| 66 | - ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
| 67 | - $currentUser) === SecurityManager::ALLOWED); |
|
| 52 | + $this->assign('nav__canBan', $this->getSecurityManager() |
|
| 53 | + ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 54 | + $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
| 55 | + ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
| 56 | + $currentUser) === SecurityManager::ALLOWED); |
|
| 57 | + $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
| 58 | + ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
| 59 | + $currentUser) === SecurityManager::ALLOWED); |
|
| 60 | + $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
| 61 | + ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 62 | + $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
| 63 | + ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
| 64 | + $currentUser) === SecurityManager::ALLOWED); |
|
| 65 | + $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
| 66 | + ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
| 67 | + $currentUser) === SecurityManager::ALLOWED); |
|
| 68 | 68 | |
| 69 | - $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
| 70 | - ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 71 | - } |
|
| 69 | + $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
| 70 | + ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file |
@@ -12,21 +12,21 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class TypeAheadHelper implements ITypeAheadHelper |
| 14 | 14 | { |
| 15 | - private $definedClasses = array(); |
|
| 15 | + private $definedClasses = array(); |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @param string $class CSS class to apply this typeahead to. |
|
| 19 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 20 | - */ |
|
| 21 | - public function defineTypeAheadSource($class, callable $generator) |
|
| 22 | - { |
|
| 23 | - $dataList = ''; |
|
| 24 | - foreach ($generator() as $dataItem) { |
|
| 25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
| 26 | - } |
|
| 27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
| 17 | + /** |
|
| 18 | + * @param string $class CSS class to apply this typeahead to. |
|
| 19 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 20 | + */ |
|
| 21 | + public function defineTypeAheadSource($class, callable $generator) |
|
| 22 | + { |
|
| 23 | + $dataList = ''; |
|
| 24 | + foreach ($generator() as $dataItem) { |
|
| 25 | + $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
| 26 | + } |
|
| 27 | + $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
| 28 | 28 | |
| 29 | - $script = <<<JS |
|
| 29 | + $script = <<<JS |
|
| 30 | 30 | |
| 31 | 31 | $('.{$class}').typeahead({ |
| 32 | 32 | hint: true, |
@@ -39,32 +39,32 @@ discard block |
||
| 39 | 39 | }) |
| 40 | 40 | ; |
| 41 | 41 | JS; |
| 42 | - $this->definedClasses[$class] = $script; |
|
| 43 | - } |
|
| 42 | + $this->definedClasses[$class] = $script; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
| 47 | - */ |
|
| 48 | - public function getTypeAheadScriptBlock() |
|
| 49 | - { |
|
| 50 | - $jsBlocks = ''; |
|
| 45 | + /** |
|
| 46 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
| 47 | + */ |
|
| 48 | + public function getTypeAheadScriptBlock() |
|
| 49 | + { |
|
| 50 | + $jsBlocks = ''; |
|
| 51 | 51 | |
| 52 | - if (count($this->definedClasses) === 0) { |
|
| 53 | - return ''; |
|
| 54 | - } |
|
| 52 | + if (count($this->definedClasses) === 0) { |
|
| 53 | + return ''; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - foreach ($this->definedClasses as $class => $js) { |
|
| 57 | - $jsBlocks = $js . "\r\n\r\n"; |
|
| 58 | - } |
|
| 56 | + foreach ($this->definedClasses as $class => $js) { |
|
| 57 | + $jsBlocks = $js . "\r\n\r\n"; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $data = <<<HTML |
|
| 60 | + $data = <<<HTML |
|
| 61 | 61 | <script type="text/javascript"> |
| 62 | 62 | {$jsBlocks} |
| 63 | 63 | </script> |
| 64 | 64 | HTML; |
| 65 | 65 | |
| 66 | - $this->definedClasses = array(); |
|
| 66 | + $this->definedClasses = array(); |
|
| 67 | 67 | |
| 68 | - return $data; |
|
| 69 | - } |
|
| 68 | + return $data; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -14,50 +14,50 @@ |
||
| 14 | 14 | |
| 15 | 15 | class RequestEmailHelper |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var IEmailHelper |
|
| 19 | - */ |
|
| 20 | - private $emailHelper; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * RequestEmailHelper constructor. |
|
| 24 | - * |
|
| 25 | - * @param IEmailHelper $emailHelper |
|
| 26 | - */ |
|
| 27 | - public function __construct(IEmailHelper $emailHelper) |
|
| 28 | - { |
|
| 29 | - $this->emailHelper = $emailHelper; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param Request $request |
|
| 34 | - * @param string $mailText |
|
| 35 | - * @param User $currentUser |
|
| 36 | - * @param boolean $ccMailingList |
|
| 37 | - */ |
|
| 38 | - public function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
| 39 | - { |
|
| 40 | - $headers = array( |
|
| 41 | - 'X-ACC-Request' => $request->getId(), |
|
| 42 | - 'X-ACC-UserID' => $currentUser->getId(), |
|
| 43 | - ); |
|
| 44 | - |
|
| 45 | - if ($ccMailingList) { |
|
| 46 | - $headers['Cc'] = '[email protected]'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - $helper = $this->emailHelper; |
|
| 50 | - |
|
| 51 | - $emailSig = $currentUser->getEmailSig(); |
|
| 52 | - if ($emailSig !== '' || $emailSig !== null) { |
|
| 53 | - $emailSig = "\n\n" . $emailSig; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - $subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
|
| 57 | - $content = $mailText . $emailSig; |
|
| 58 | - |
|
| 59 | - $helper->sendMail($request->getEmail(), $subject, $content, $headers); |
|
| 60 | - |
|
| 61 | - $request->setEmailSent(true); |
|
| 62 | - } |
|
| 17 | + /** |
|
| 18 | + * @var IEmailHelper |
|
| 19 | + */ |
|
| 20 | + private $emailHelper; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * RequestEmailHelper constructor. |
|
| 24 | + * |
|
| 25 | + * @param IEmailHelper $emailHelper |
|
| 26 | + */ |
|
| 27 | + public function __construct(IEmailHelper $emailHelper) |
|
| 28 | + { |
|
| 29 | + $this->emailHelper = $emailHelper; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param Request $request |
|
| 34 | + * @param string $mailText |
|
| 35 | + * @param User $currentUser |
|
| 36 | + * @param boolean $ccMailingList |
|
| 37 | + */ |
|
| 38 | + public function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
| 39 | + { |
|
| 40 | + $headers = array( |
|
| 41 | + 'X-ACC-Request' => $request->getId(), |
|
| 42 | + 'X-ACC-UserID' => $currentUser->getId(), |
|
| 43 | + ); |
|
| 44 | + |
|
| 45 | + if ($ccMailingList) { |
|
| 46 | + $headers['Cc'] = '[email protected]'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + $helper = $this->emailHelper; |
|
| 50 | + |
|
| 51 | + $emailSig = $currentUser->getEmailSig(); |
|
| 52 | + if ($emailSig !== '' || $emailSig !== null) { |
|
| 53 | + $emailSig = "\n\n" . $emailSig; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + $subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
|
| 57 | + $content = $mailText . $emailSig; |
|
| 58 | + |
|
| 59 | + $helper->sendMail($request->getEmail(), $subject, $content, $headers); |
|
| 60 | + |
|
| 61 | + $request->setEmailSent(true); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -16,95 +16,95 @@ |
||
| 16 | 16 | |
| 17 | 17 | class OAuthProtocolHelper implements Interfaces\IOAuthProtocolHelper |
| 18 | 18 | { |
| 19 | - private $oauthClient; |
|
| 20 | - |
|
| 21 | - private $mediawikiWebServiceEndpoint; |
|
| 22 | - |
|
| 23 | - private $authUrl; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * OAuthHelper constructor. |
|
| 27 | - * |
|
| 28 | - * @param string $oauthEndpoint |
|
| 29 | - * @param string $consumerKey |
|
| 30 | - * @param string $consumerSecret |
|
| 31 | - * @param string $mediawikiWebServiceEndpoint |
|
| 32 | - */ |
|
| 33 | - public function __construct( |
|
| 34 | - $oauthEndpoint, |
|
| 35 | - $consumerKey, |
|
| 36 | - $consumerSecret, |
|
| 37 | - $mediawikiWebServiceEndpoint |
|
| 38 | - ) { |
|
| 39 | - $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 40 | - |
|
| 41 | - $oauthClientConfig = new ClientConfig($oauthEndpoint); |
|
| 42 | - $oauthClientConfig->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
|
| 43 | - |
|
| 44 | - $this->oauthClient = new Client($oauthClientConfig); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @inheritDoc |
|
| 49 | - */ |
|
| 50 | - public function getRequestToken() |
|
| 51 | - { |
|
| 52 | - /** @var Token $requestToken */ |
|
| 53 | - list($authUrl, $requestToken) = $this->oauthClient->initiate(); |
|
| 54 | - $this->authUrl = $authUrl; |
|
| 55 | - return $requestToken; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @inheritDoc |
|
| 60 | - */ |
|
| 61 | - public function getAuthoriseUrl($requestToken) |
|
| 62 | - { |
|
| 63 | - return $this->authUrl; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @inheritDoc |
|
| 68 | - */ |
|
| 69 | - public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
|
| 70 | - { |
|
| 71 | - $requestToken = new Token($oauthRequestToken, $oauthRequestSecret); |
|
| 72 | - |
|
| 73 | - return $this->oauthClient->complete($requestToken, $oauthVerifier); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @inheritDoc |
|
| 78 | - */ |
|
| 79 | - public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
|
| 80 | - { |
|
| 81 | - return $this->oauthClient->identify(new Token($oauthAccessToken, $oauthAccessSecret)); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @inheritDoc |
|
| 86 | - */ |
|
| 87 | - public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET') |
|
| 88 | - { |
|
| 89 | - $userToken = new Token($accessToken, $accessSecret); |
|
| 90 | - |
|
| 91 | - $apiParams['format'] = 'json'; |
|
| 92 | - |
|
| 93 | - if ($apiParams === null || ! is_array($apiParams)) { |
|
| 94 | - throw new CurlException("Invalid API call"); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $url = $this->mediawikiWebServiceEndpoint; |
|
| 98 | - $isPost = ($method === 'POST'); |
|
| 99 | - |
|
| 100 | - if ($method === 'GET') { |
|
| 101 | - $query = http_build_query($apiParams); |
|
| 102 | - $url .= '?' . $query; |
|
| 103 | - $apiParams = null; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $data = $this->oauthClient->makeOAuthCall($userToken, $url, $isPost, $apiParams); |
|
| 107 | - |
|
| 108 | - return json_decode($data); |
|
| 109 | - } |
|
| 19 | + private $oauthClient; |
|
| 20 | + |
|
| 21 | + private $mediawikiWebServiceEndpoint; |
|
| 22 | + |
|
| 23 | + private $authUrl; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * OAuthHelper constructor. |
|
| 27 | + * |
|
| 28 | + * @param string $oauthEndpoint |
|
| 29 | + * @param string $consumerKey |
|
| 30 | + * @param string $consumerSecret |
|
| 31 | + * @param string $mediawikiWebServiceEndpoint |
|
| 32 | + */ |
|
| 33 | + public function __construct( |
|
| 34 | + $oauthEndpoint, |
|
| 35 | + $consumerKey, |
|
| 36 | + $consumerSecret, |
|
| 37 | + $mediawikiWebServiceEndpoint |
|
| 38 | + ) { |
|
| 39 | + $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 40 | + |
|
| 41 | + $oauthClientConfig = new ClientConfig($oauthEndpoint); |
|
| 42 | + $oauthClientConfig->setConsumer(new Consumer($consumerKey, $consumerSecret)); |
|
| 43 | + |
|
| 44 | + $this->oauthClient = new Client($oauthClientConfig); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @inheritDoc |
|
| 49 | + */ |
|
| 50 | + public function getRequestToken() |
|
| 51 | + { |
|
| 52 | + /** @var Token $requestToken */ |
|
| 53 | + list($authUrl, $requestToken) = $this->oauthClient->initiate(); |
|
| 54 | + $this->authUrl = $authUrl; |
|
| 55 | + return $requestToken; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @inheritDoc |
|
| 60 | + */ |
|
| 61 | + public function getAuthoriseUrl($requestToken) |
|
| 62 | + { |
|
| 63 | + return $this->authUrl; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @inheritDoc |
|
| 68 | + */ |
|
| 69 | + public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
|
| 70 | + { |
|
| 71 | + $requestToken = new Token($oauthRequestToken, $oauthRequestSecret); |
|
| 72 | + |
|
| 73 | + return $this->oauthClient->complete($requestToken, $oauthVerifier); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @inheritDoc |
|
| 78 | + */ |
|
| 79 | + public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
|
| 80 | + { |
|
| 81 | + return $this->oauthClient->identify(new Token($oauthAccessToken, $oauthAccessSecret)); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @inheritDoc |
|
| 86 | + */ |
|
| 87 | + public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET') |
|
| 88 | + { |
|
| 89 | + $userToken = new Token($accessToken, $accessSecret); |
|
| 90 | + |
|
| 91 | + $apiParams['format'] = 'json'; |
|
| 92 | + |
|
| 93 | + if ($apiParams === null || ! is_array($apiParams)) { |
|
| 94 | + throw new CurlException("Invalid API call"); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $url = $this->mediawikiWebServiceEndpoint; |
|
| 98 | + $isPost = ($method === 'POST'); |
|
| 99 | + |
|
| 100 | + if ($method === 'GET') { |
|
| 101 | + $query = http_build_query($apiParams); |
|
| 102 | + $url .= '?' . $query; |
|
| 103 | + $apiParams = null; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $data = $this->oauthClient->makeOAuthCall($userToken, $url, $isPost, $apiParams); |
|
| 107 | + |
|
| 108 | + return json_decode($data); |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | \ No newline at end of file |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | |
| 91 | 91 | $apiParams['format'] = 'json'; |
| 92 | 92 | |
| 93 | - if ($apiParams === null || ! is_array($apiParams)) { |
|
| 93 | + if ($apiParams === null || !is_array($apiParams)) { |
|
| 94 | 94 | throw new CurlException("Invalid API call"); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -16,135 +16,135 @@ |
||
| 16 | 16 | |
| 17 | 17 | class BotMediaWikiClient implements IMediaWikiClient |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var HttpHelper |
|
| 21 | - */ |
|
| 22 | - private $httpHelper; |
|
| 23 | - /** @var string */ |
|
| 24 | - private $mediawikiWebServiceEndpoint; |
|
| 25 | - /** @var string */ |
|
| 26 | - private $creationBotUsername; |
|
| 27 | - /** @var string */ |
|
| 28 | - private $creationBotPassword; |
|
| 29 | - /** @var bool */ |
|
| 30 | - private $knownLoggedIn = false; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * BotMediaWikiClient constructor. |
|
| 34 | - * |
|
| 35 | - * @param SiteConfiguration $siteConfiguration |
|
| 36 | - */ |
|
| 37 | - public function __construct(SiteConfiguration $siteConfiguration) |
|
| 38 | - { |
|
| 39 | - $this->mediawikiWebServiceEndpoint = $siteConfiguration->getMediawikiWebServiceEndpoint(); |
|
| 40 | - |
|
| 41 | - $this->creationBotUsername = $siteConfiguration->getCreationBotUsername(); |
|
| 42 | - $this->creationBotPassword = $siteConfiguration->getCreationBotPassword(); |
|
| 43 | - |
|
| 44 | - $this->httpHelper = new HttpHelper( |
|
| 45 | - $siteConfiguration, |
|
| 46 | - $siteConfiguration->getCurlCookieJar() |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function doApiCall($apiParams, $method = 'GET') |
|
| 51 | - { |
|
| 52 | - $this->ensureLoggedIn(); |
|
| 53 | - $apiParams['assert'] = 'user'; |
|
| 54 | - |
|
| 55 | - return $this->callApi($apiParams, $method); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - private function ensureLoggedIn() |
|
| 59 | - { |
|
| 60 | - if ($this->knownLoggedIn) { |
|
| 61 | - return; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - $userinfoResult = $this->callApi(array('action' => 'query', 'meta' => 'userinfo'), 'GET'); |
|
| 65 | - if (isset($userinfoResult->query->userinfo->anon)) { |
|
| 66 | - // not logged in. |
|
| 67 | - $this->logIn(); |
|
| 68 | - |
|
| 69 | - // retest |
|
| 70 | - $userinfoResult = $this->callApi(array('action' => 'query', 'meta' => 'userinfo'), 'GET'); |
|
| 71 | - if (isset($userinfoResult->query->userinfo->anon)) { |
|
| 72 | - throw new MediaWikiApiException('Unable to log in.'); |
|
| 73 | - } |
|
| 74 | - else { |
|
| 75 | - $this->knownLoggedIn = true; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - else { |
|
| 79 | - $this->knownLoggedIn = true; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param $apiParams |
|
| 85 | - * @param $method |
|
| 86 | - * |
|
| 87 | - * @return mixed |
|
| 88 | - * @throws ApplicationLogicException |
|
| 89 | - * @throws CurlException |
|
| 90 | - */ |
|
| 91 | - private function callApi($apiParams, $method) |
|
| 92 | - { |
|
| 93 | - $apiParams['format'] = 'json'; |
|
| 94 | - |
|
| 95 | - if ($method == 'GET') { |
|
| 96 | - $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams); |
|
| 97 | - } |
|
| 98 | - elseif ($method == 'POST') { |
|
| 99 | - $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams); |
|
| 100 | - } |
|
| 101 | - else { |
|
| 102 | - throw new ApplicationLogicException('Unsupported HTTP Method'); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if ($data === false) { |
|
| 106 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $result = json_decode($data); |
|
| 110 | - |
|
| 111 | - return $result; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - private function logIn() |
|
| 115 | - { |
|
| 116 | - // get token |
|
| 117 | - $tokenParams = array( |
|
| 118 | - 'action' => 'query', |
|
| 119 | - 'meta' => 'tokens', |
|
| 120 | - 'type' => 'login', |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - $response = $this->callApi($tokenParams, 'POST'); |
|
| 124 | - |
|
| 125 | - if (isset($response->error)) { |
|
| 126 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $token = $response->query->tokens->logintoken; |
|
| 130 | - |
|
| 131 | - if ($token === null) { |
|
| 132 | - throw new MediaWikiApiException('Edit token could not be acquired'); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - $params = array( |
|
| 136 | - 'action' => 'login', |
|
| 137 | - 'lgname' => $this->creationBotUsername, |
|
| 138 | - 'lgpassword' => $this->creationBotPassword, |
|
| 139 | - 'lgtoken' => $token, |
|
| 140 | - ); |
|
| 141 | - |
|
| 142 | - $loginResponse = $this->callApi($params, 'POST'); |
|
| 143 | - |
|
| 144 | - if($loginResponse->login->result == 'Success'){ |
|
| 145 | - return; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - throw new ApplicationLogicException(json_encode($loginResponse)); |
|
| 149 | - } |
|
| 19 | + /** |
|
| 20 | + * @var HttpHelper |
|
| 21 | + */ |
|
| 22 | + private $httpHelper; |
|
| 23 | + /** @var string */ |
|
| 24 | + private $mediawikiWebServiceEndpoint; |
|
| 25 | + /** @var string */ |
|
| 26 | + private $creationBotUsername; |
|
| 27 | + /** @var string */ |
|
| 28 | + private $creationBotPassword; |
|
| 29 | + /** @var bool */ |
|
| 30 | + private $knownLoggedIn = false; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * BotMediaWikiClient constructor. |
|
| 34 | + * |
|
| 35 | + * @param SiteConfiguration $siteConfiguration |
|
| 36 | + */ |
|
| 37 | + public function __construct(SiteConfiguration $siteConfiguration) |
|
| 38 | + { |
|
| 39 | + $this->mediawikiWebServiceEndpoint = $siteConfiguration->getMediawikiWebServiceEndpoint(); |
|
| 40 | + |
|
| 41 | + $this->creationBotUsername = $siteConfiguration->getCreationBotUsername(); |
|
| 42 | + $this->creationBotPassword = $siteConfiguration->getCreationBotPassword(); |
|
| 43 | + |
|
| 44 | + $this->httpHelper = new HttpHelper( |
|
| 45 | + $siteConfiguration, |
|
| 46 | + $siteConfiguration->getCurlCookieJar() |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function doApiCall($apiParams, $method = 'GET') |
|
| 51 | + { |
|
| 52 | + $this->ensureLoggedIn(); |
|
| 53 | + $apiParams['assert'] = 'user'; |
|
| 54 | + |
|
| 55 | + return $this->callApi($apiParams, $method); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + private function ensureLoggedIn() |
|
| 59 | + { |
|
| 60 | + if ($this->knownLoggedIn) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + $userinfoResult = $this->callApi(array('action' => 'query', 'meta' => 'userinfo'), 'GET'); |
|
| 65 | + if (isset($userinfoResult->query->userinfo->anon)) { |
|
| 66 | + // not logged in. |
|
| 67 | + $this->logIn(); |
|
| 68 | + |
|
| 69 | + // retest |
|
| 70 | + $userinfoResult = $this->callApi(array('action' => 'query', 'meta' => 'userinfo'), 'GET'); |
|
| 71 | + if (isset($userinfoResult->query->userinfo->anon)) { |
|
| 72 | + throw new MediaWikiApiException('Unable to log in.'); |
|
| 73 | + } |
|
| 74 | + else { |
|
| 75 | + $this->knownLoggedIn = true; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + else { |
|
| 79 | + $this->knownLoggedIn = true; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param $apiParams |
|
| 85 | + * @param $method |
|
| 86 | + * |
|
| 87 | + * @return mixed |
|
| 88 | + * @throws ApplicationLogicException |
|
| 89 | + * @throws CurlException |
|
| 90 | + */ |
|
| 91 | + private function callApi($apiParams, $method) |
|
| 92 | + { |
|
| 93 | + $apiParams['format'] = 'json'; |
|
| 94 | + |
|
| 95 | + if ($method == 'GET') { |
|
| 96 | + $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams); |
|
| 97 | + } |
|
| 98 | + elseif ($method == 'POST') { |
|
| 99 | + $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams); |
|
| 100 | + } |
|
| 101 | + else { |
|
| 102 | + throw new ApplicationLogicException('Unsupported HTTP Method'); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if ($data === false) { |
|
| 106 | + throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $result = json_decode($data); |
|
| 110 | + |
|
| 111 | + return $result; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + private function logIn() |
|
| 115 | + { |
|
| 116 | + // get token |
|
| 117 | + $tokenParams = array( |
|
| 118 | + 'action' => 'query', |
|
| 119 | + 'meta' => 'tokens', |
|
| 120 | + 'type' => 'login', |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + $response = $this->callApi($tokenParams, 'POST'); |
|
| 124 | + |
|
| 125 | + if (isset($response->error)) { |
|
| 126 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $token = $response->query->tokens->logintoken; |
|
| 130 | + |
|
| 131 | + if ($token === null) { |
|
| 132 | + throw new MediaWikiApiException('Edit token could not be acquired'); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + $params = array( |
|
| 136 | + 'action' => 'login', |
|
| 137 | + 'lgname' => $this->creationBotUsername, |
|
| 138 | + 'lgpassword' => $this->creationBotPassword, |
|
| 139 | + 'lgtoken' => $token, |
|
| 140 | + ); |
|
| 141 | + |
|
| 142 | + $loginResponse = $this->callApi($params, 'POST'); |
|
| 143 | + |
|
| 144 | + if($loginResponse->login->result == 'Success'){ |
|
| 145 | + return; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + throw new ApplicationLogicException(json_encode($loginResponse)); |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | |
| 142 | 142 | $loginResponse = $this->callApi($params, 'POST'); |
| 143 | 143 | |
| 144 | - if($loginResponse->login->result == 'Success'){ |
|
| 144 | + if ($loginResponse->login->result == 'Success') { |
|
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -70,12 +70,10 @@ discard block |
||
| 70 | 70 | $userinfoResult = $this->callApi(array('action' => 'query', 'meta' => 'userinfo'), 'GET'); |
| 71 | 71 | if (isset($userinfoResult->query->userinfo->anon)) { |
| 72 | 72 | throw new MediaWikiApiException('Unable to log in.'); |
| 73 | - } |
|
| 74 | - else { |
|
| 73 | + } else { |
|
| 75 | 74 | $this->knownLoggedIn = true; |
| 76 | 75 | } |
| 77 | - } |
|
| 78 | - else { |
|
| 76 | + } else { |
|
| 79 | 77 | $this->knownLoggedIn = true; |
| 80 | 78 | } |
| 81 | 79 | } |
@@ -94,11 +92,9 @@ discard block |
||
| 94 | 92 | |
| 95 | 93 | if ($method == 'GET') { |
| 96 | 94 | $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams); |
| 97 | - } |
|
| 98 | - elseif ($method == 'POST') { |
|
| 95 | + } elseif ($method == 'POST') { |
|
| 99 | 96 | $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams); |
| 100 | - } |
|
| 101 | - else { |
|
| 97 | + } else { |
|
| 102 | 98 | throw new ApplicationLogicException('Unsupported HTTP Method'); |
| 103 | 99 | } |
| 104 | 100 | |
@@ -141,7 +137,7 @@ discard block |
||
| 141 | 137 | |
| 142 | 138 | $loginResponse = $this->callApi($params, 'POST'); |
| 143 | 139 | |
| 144 | - if($loginResponse->login->result == 'Success'){ |
|
| 140 | + if($loginResponse->login->result == 'Success') { |
|
| 145 | 141 | return; |
| 146 | 142 | } |
| 147 | 143 | |
@@ -15,245 +15,245 @@ |
||
| 15 | 15 | |
| 16 | 16 | class MediaWikiHelper |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var IMediaWikiClient |
|
| 20 | - */ |
|
| 21 | - private $mediaWikiClient; |
|
| 22 | - /** |
|
| 23 | - * @var SiteConfiguration |
|
| 24 | - */ |
|
| 25 | - private $siteConfiguration; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * MediaWikiHelper constructor. |
|
| 29 | - * |
|
| 30 | - * @param IMediaWikiClient $mediaWikiClient |
|
| 31 | - * @param SiteConfiguration $siteConfiguration |
|
| 32 | - */ |
|
| 33 | - public function __construct(IMediaWikiClient $mediaWikiClient, SiteConfiguration $siteConfiguration) |
|
| 34 | - { |
|
| 35 | - $this->mediaWikiClient = $mediaWikiClient; |
|
| 36 | - $this->siteConfiguration = $siteConfiguration; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @todo handle override antispoof and titleblacklist issues |
|
| 41 | - * |
|
| 42 | - * @param string $username |
|
| 43 | - * @param string $emailAddress |
|
| 44 | - * @param string $reason |
|
| 45 | - * |
|
| 46 | - * @throws Exception |
|
| 47 | - * @throws MediaWikiApiException |
|
| 48 | - */ |
|
| 49 | - public function createAccount($username, $emailAddress, $reason) |
|
| 50 | - { |
|
| 51 | - // get token |
|
| 52 | - $tokenParams = array( |
|
| 53 | - 'action' => 'query', |
|
| 54 | - 'meta' => 'tokens', |
|
| 55 | - 'type' => 'createaccount', |
|
| 56 | - ); |
|
| 57 | - |
|
| 58 | - $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
| 59 | - |
|
| 60 | - if (isset($response->error)) { |
|
| 61 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - $token = $response->query->tokens->createaccounttoken; |
|
| 65 | - |
|
| 66 | - $callback = $this->siteConfiguration->getBaseUrl() . '/internal.php/oauth/createCallback'; |
|
| 67 | - |
|
| 68 | - $checkboxFields = array(); |
|
| 69 | - $requiredFields = array(); |
|
| 70 | - $this->getCreationFieldData($requiredFields, $checkboxFields); |
|
| 71 | - |
|
| 72 | - $apiCallData = array( |
|
| 73 | - 'action' => 'createaccount', |
|
| 74 | - 'createreturnurl' => $callback, |
|
| 75 | - 'createtoken' => $token, |
|
| 76 | - 'createmessageformat' => 'html', |
|
| 77 | - ); |
|
| 78 | - |
|
| 79 | - $createParams = array_fill_keys($requiredFields, '') + $apiCallData; |
|
| 80 | - |
|
| 81 | - $createParams['username'] = $username; |
|
| 82 | - $createParams['mailpassword'] = true; |
|
| 83 | - $createParams['email'] = $emailAddress; |
|
| 84 | - $createParams['reason'] = $reason; |
|
| 85 | - |
|
| 86 | - $createResponse = $this->mediaWikiClient->doApiCall($createParams, 'POST'); |
|
| 87 | - |
|
| 88 | - if (isset($createResponse->error)) { |
|
| 89 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if (!isset($createResponse->createaccount) || !isset($createResponse->createaccount->status)) { |
|
| 93 | - throw new MediaWikiApiException('Unknown error creating account'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($createResponse->createaccount->status === 'FAIL') { |
|
| 97 | - throw new MediaWikiApiException($createResponse->createaccount->message); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - if ($createResponse->createaccount->status === 'PASS') { |
|
| 101 | - // success! |
|
| 102 | - return; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - throw new Exception('API result reported status of ' . $createResponse->createaccount->status); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @param string $username |
|
| 110 | - * @param string $title |
|
| 111 | - * @param $summary |
|
| 112 | - * @param string $message |
|
| 113 | - * @param bool $createOnly |
|
| 114 | - * |
|
| 115 | - * @throws MediaWikiApiException |
|
| 116 | - */ |
|
| 117 | - public function addTalkPageMessage($username, $title, $summary, $message, $createOnly = true) |
|
| 118 | - { |
|
| 119 | - // get token |
|
| 120 | - $tokenParams = array( |
|
| 121 | - 'action' => 'query', |
|
| 122 | - 'meta' => 'tokens', |
|
| 123 | - 'type' => 'csrf', |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
| 127 | - |
|
| 128 | - if (isset($response->error)) { |
|
| 129 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - $token = $response->query->tokens->csrftoken; |
|
| 133 | - |
|
| 134 | - if ($token === null) { |
|
| 135 | - throw new MediaWikiApiException('Edit token could not be acquired'); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $editParameters = array( |
|
| 139 | - 'action' => 'edit', |
|
| 140 | - 'title' => 'User talk:' . $username, |
|
| 141 | - 'section' => 'new', |
|
| 142 | - 'sectiontitle' => $title, |
|
| 143 | - 'summary' => $summary, |
|
| 144 | - 'text' => $message, |
|
| 145 | - 'token' => $token, |
|
| 146 | - ); |
|
| 147 | - |
|
| 148 | - if ($createOnly) { |
|
| 149 | - $editParameters['createonly'] = true; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $response = $this->mediaWikiClient->doApiCall($editParameters, 'POST'); |
|
| 153 | - |
|
| 154 | - if (!isset($response->edit)) { |
|
| 155 | - if (isset($response->error)) { |
|
| 156 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - throw new MediaWikiApiException('Unknown error encountered during editing.'); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $editResponse = $response->edit; |
|
| 163 | - if ($editResponse->result === "Success") { |
|
| 164 | - return; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - throw new MediaWikiApiException('Edit status unsuccessful: ' . $editResponse->result); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - public function getCreationFieldData(&$requiredFields, &$checkboxFields) |
|
| 171 | - { |
|
| 172 | - // get token |
|
| 173 | - $params = array( |
|
| 174 | - 'action' => 'query', |
|
| 175 | - 'meta' => 'authmanagerinfo', |
|
| 176 | - 'amirequestsfor' => 'create', |
|
| 177 | - ); |
|
| 178 | - |
|
| 179 | - $response = $this->mediaWikiClient->doApiCall($params, 'GET'); |
|
| 180 | - |
|
| 181 | - if (isset($response->error)) { |
|
| 182 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $requests = $response->query->authmanagerinfo->requests; |
|
| 186 | - |
|
| 187 | - // We don't want to deal with these providers ever. |
|
| 188 | - $discardList = array( |
|
| 189 | - // Requires a username and password |
|
| 190 | - 'MediaWiki\\Auth\\PasswordAuthenticationRequest', |
|
| 191 | - ); |
|
| 192 | - |
|
| 193 | - // We require these providers to function |
|
| 194 | - $requireList = array( |
|
| 195 | - 'MediaWiki\\Auth\\TemporaryPasswordAuthenticationRequest', |
|
| 196 | - 'MediaWiki\\Auth\\UsernameAuthenticationRequest', |
|
| 197 | - 'MediaWiki\\Auth\\UserDataAuthenticationRequest', |
|
| 198 | - 'MediaWiki\\Auth\\CreationReasonAuthenticationRequest', |
|
| 199 | - ); |
|
| 200 | - |
|
| 201 | - $requiredFields = array(); |
|
| 202 | - // Keep checkbox fields separate, since "required" actually means optional as absent == false. |
|
| 203 | - $checkboxFields = array(); |
|
| 204 | - |
|
| 205 | - foreach ($requests as $req) { |
|
| 206 | - // Immediately discard anything that is on the discard list. |
|
| 207 | - if (in_array($req->id, $discardList)) { |
|
| 208 | - continue; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $required = false; |
|
| 212 | - |
|
| 213 | - if ($req->required === 'primary-required' && !in_array($req->id, $requireList)) { |
|
| 214 | - // Only want one. |
|
| 215 | - continue; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if (in_array($req->id, $requireList)) { |
|
| 219 | - unset($requireList[$req->id]); |
|
| 220 | - $required = true; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - if ($req->required === 'required') { |
|
| 224 | - $required = true; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - if ($required) { |
|
| 228 | - foreach ($req->fields as $name => $data) { |
|
| 229 | - if ($data->type === 'checkbox') { |
|
| 230 | - $checkboxFields[] = $name; |
|
| 231 | - } |
|
| 232 | - else { |
|
| 233 | - $requiredFields[] = $name; |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @param string $username |
|
| 242 | - * @return bool |
|
| 243 | - */ |
|
| 244 | - public function checkAccountExists($username) { |
|
| 245 | - $parameters = array( |
|
| 246 | - 'action' => 'query', |
|
| 247 | - 'list' => 'users', |
|
| 248 | - 'format' => 'php', |
|
| 249 | - 'ususers' => $username, |
|
| 250 | - ); |
|
| 251 | - |
|
| 252 | - $apiResult = $this->mediaWikiClient->doApiCall($parameters, 'GET'); |
|
| 253 | - |
|
| 254 | - $entry = $apiResult->query->users[0]; |
|
| 255 | - $exists = !isset($entry->missing); |
|
| 256 | - |
|
| 257 | - return $exists; |
|
| 258 | - } |
|
| 18 | + /** |
|
| 19 | + * @var IMediaWikiClient |
|
| 20 | + */ |
|
| 21 | + private $mediaWikiClient; |
|
| 22 | + /** |
|
| 23 | + * @var SiteConfiguration |
|
| 24 | + */ |
|
| 25 | + private $siteConfiguration; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * MediaWikiHelper constructor. |
|
| 29 | + * |
|
| 30 | + * @param IMediaWikiClient $mediaWikiClient |
|
| 31 | + * @param SiteConfiguration $siteConfiguration |
|
| 32 | + */ |
|
| 33 | + public function __construct(IMediaWikiClient $mediaWikiClient, SiteConfiguration $siteConfiguration) |
|
| 34 | + { |
|
| 35 | + $this->mediaWikiClient = $mediaWikiClient; |
|
| 36 | + $this->siteConfiguration = $siteConfiguration; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @todo handle override antispoof and titleblacklist issues |
|
| 41 | + * |
|
| 42 | + * @param string $username |
|
| 43 | + * @param string $emailAddress |
|
| 44 | + * @param string $reason |
|
| 45 | + * |
|
| 46 | + * @throws Exception |
|
| 47 | + * @throws MediaWikiApiException |
|
| 48 | + */ |
|
| 49 | + public function createAccount($username, $emailAddress, $reason) |
|
| 50 | + { |
|
| 51 | + // get token |
|
| 52 | + $tokenParams = array( |
|
| 53 | + 'action' => 'query', |
|
| 54 | + 'meta' => 'tokens', |
|
| 55 | + 'type' => 'createaccount', |
|
| 56 | + ); |
|
| 57 | + |
|
| 58 | + $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
| 59 | + |
|
| 60 | + if (isset($response->error)) { |
|
| 61 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + $token = $response->query->tokens->createaccounttoken; |
|
| 65 | + |
|
| 66 | + $callback = $this->siteConfiguration->getBaseUrl() . '/internal.php/oauth/createCallback'; |
|
| 67 | + |
|
| 68 | + $checkboxFields = array(); |
|
| 69 | + $requiredFields = array(); |
|
| 70 | + $this->getCreationFieldData($requiredFields, $checkboxFields); |
|
| 71 | + |
|
| 72 | + $apiCallData = array( |
|
| 73 | + 'action' => 'createaccount', |
|
| 74 | + 'createreturnurl' => $callback, |
|
| 75 | + 'createtoken' => $token, |
|
| 76 | + 'createmessageformat' => 'html', |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + $createParams = array_fill_keys($requiredFields, '') + $apiCallData; |
|
| 80 | + |
|
| 81 | + $createParams['username'] = $username; |
|
| 82 | + $createParams['mailpassword'] = true; |
|
| 83 | + $createParams['email'] = $emailAddress; |
|
| 84 | + $createParams['reason'] = $reason; |
|
| 85 | + |
|
| 86 | + $createResponse = $this->mediaWikiClient->doApiCall($createParams, 'POST'); |
|
| 87 | + |
|
| 88 | + if (isset($createResponse->error)) { |
|
| 89 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if (!isset($createResponse->createaccount) || !isset($createResponse->createaccount->status)) { |
|
| 93 | + throw new MediaWikiApiException('Unknown error creating account'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($createResponse->createaccount->status === 'FAIL') { |
|
| 97 | + throw new MediaWikiApiException($createResponse->createaccount->message); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + if ($createResponse->createaccount->status === 'PASS') { |
|
| 101 | + // success! |
|
| 102 | + return; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + throw new Exception('API result reported status of ' . $createResponse->createaccount->status); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @param string $username |
|
| 110 | + * @param string $title |
|
| 111 | + * @param $summary |
|
| 112 | + * @param string $message |
|
| 113 | + * @param bool $createOnly |
|
| 114 | + * |
|
| 115 | + * @throws MediaWikiApiException |
|
| 116 | + */ |
|
| 117 | + public function addTalkPageMessage($username, $title, $summary, $message, $createOnly = true) |
|
| 118 | + { |
|
| 119 | + // get token |
|
| 120 | + $tokenParams = array( |
|
| 121 | + 'action' => 'query', |
|
| 122 | + 'meta' => 'tokens', |
|
| 123 | + 'type' => 'csrf', |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
| 127 | + |
|
| 128 | + if (isset($response->error)) { |
|
| 129 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + $token = $response->query->tokens->csrftoken; |
|
| 133 | + |
|
| 134 | + if ($token === null) { |
|
| 135 | + throw new MediaWikiApiException('Edit token could not be acquired'); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $editParameters = array( |
|
| 139 | + 'action' => 'edit', |
|
| 140 | + 'title' => 'User talk:' . $username, |
|
| 141 | + 'section' => 'new', |
|
| 142 | + 'sectiontitle' => $title, |
|
| 143 | + 'summary' => $summary, |
|
| 144 | + 'text' => $message, |
|
| 145 | + 'token' => $token, |
|
| 146 | + ); |
|
| 147 | + |
|
| 148 | + if ($createOnly) { |
|
| 149 | + $editParameters['createonly'] = true; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $response = $this->mediaWikiClient->doApiCall($editParameters, 'POST'); |
|
| 153 | + |
|
| 154 | + if (!isset($response->edit)) { |
|
| 155 | + if (isset($response->error)) { |
|
| 156 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + throw new MediaWikiApiException('Unknown error encountered during editing.'); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $editResponse = $response->edit; |
|
| 163 | + if ($editResponse->result === "Success") { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + throw new MediaWikiApiException('Edit status unsuccessful: ' . $editResponse->result); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + public function getCreationFieldData(&$requiredFields, &$checkboxFields) |
|
| 171 | + { |
|
| 172 | + // get token |
|
| 173 | + $params = array( |
|
| 174 | + 'action' => 'query', |
|
| 175 | + 'meta' => 'authmanagerinfo', |
|
| 176 | + 'amirequestsfor' => 'create', |
|
| 177 | + ); |
|
| 178 | + |
|
| 179 | + $response = $this->mediaWikiClient->doApiCall($params, 'GET'); |
|
| 180 | + |
|
| 181 | + if (isset($response->error)) { |
|
| 182 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $requests = $response->query->authmanagerinfo->requests; |
|
| 186 | + |
|
| 187 | + // We don't want to deal with these providers ever. |
|
| 188 | + $discardList = array( |
|
| 189 | + // Requires a username and password |
|
| 190 | + 'MediaWiki\\Auth\\PasswordAuthenticationRequest', |
|
| 191 | + ); |
|
| 192 | + |
|
| 193 | + // We require these providers to function |
|
| 194 | + $requireList = array( |
|
| 195 | + 'MediaWiki\\Auth\\TemporaryPasswordAuthenticationRequest', |
|
| 196 | + 'MediaWiki\\Auth\\UsernameAuthenticationRequest', |
|
| 197 | + 'MediaWiki\\Auth\\UserDataAuthenticationRequest', |
|
| 198 | + 'MediaWiki\\Auth\\CreationReasonAuthenticationRequest', |
|
| 199 | + ); |
|
| 200 | + |
|
| 201 | + $requiredFields = array(); |
|
| 202 | + // Keep checkbox fields separate, since "required" actually means optional as absent == false. |
|
| 203 | + $checkboxFields = array(); |
|
| 204 | + |
|
| 205 | + foreach ($requests as $req) { |
|
| 206 | + // Immediately discard anything that is on the discard list. |
|
| 207 | + if (in_array($req->id, $discardList)) { |
|
| 208 | + continue; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $required = false; |
|
| 212 | + |
|
| 213 | + if ($req->required === 'primary-required' && !in_array($req->id, $requireList)) { |
|
| 214 | + // Only want one. |
|
| 215 | + continue; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if (in_array($req->id, $requireList)) { |
|
| 219 | + unset($requireList[$req->id]); |
|
| 220 | + $required = true; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + if ($req->required === 'required') { |
|
| 224 | + $required = true; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + if ($required) { |
|
| 228 | + foreach ($req->fields as $name => $data) { |
|
| 229 | + if ($data->type === 'checkbox') { |
|
| 230 | + $checkboxFields[] = $name; |
|
| 231 | + } |
|
| 232 | + else { |
|
| 233 | + $requiredFields[] = $name; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @param string $username |
|
| 242 | + * @return bool |
|
| 243 | + */ |
|
| 244 | + public function checkAccountExists($username) { |
|
| 245 | + $parameters = array( |
|
| 246 | + 'action' => 'query', |
|
| 247 | + 'list' => 'users', |
|
| 248 | + 'format' => 'php', |
|
| 249 | + 'ususers' => $username, |
|
| 250 | + ); |
|
| 251 | + |
|
| 252 | + $apiResult = $this->mediaWikiClient->doApiCall($parameters, 'GET'); |
|
| 253 | + |
|
| 254 | + $entry = $apiResult->query->users[0]; |
|
| 255 | + $exists = !isset($entry->missing); |
|
| 256 | + |
|
| 257 | + return $exists; |
|
| 258 | + } |
|
| 259 | 259 | } |
@@ -228,8 +228,7 @@ discard block |
||
| 228 | 228 | foreach ($req->fields as $name => $data) { |
| 229 | 229 | if ($data->type === 'checkbox') { |
| 230 | 230 | $checkboxFields[] = $name; |
| 231 | - } |
|
| 232 | - else { |
|
| 231 | + } else { |
|
| 233 | 232 | $requiredFields[] = $name; |
| 234 | 233 | } |
| 235 | 234 | } |
@@ -241,7 +240,8 @@ discard block |
||
| 241 | 240 | * @param string $username |
| 242 | 241 | * @return bool |
| 243 | 242 | */ |
| 244 | - public function checkAccountExists($username) { |
|
| 243 | + public function checkAccountExists($username) |
|
| 244 | + { |
|
| 245 | 245 | $parameters = array( |
| 246 | 246 | 'action' => 'query', |
| 247 | 247 | 'list' => 'users', |