@@ -10,19 +10,19 @@ |
||
| 10 | 10 | |
| 11 | 11 | class PageRegisterStandard extends PageRegisterBase |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @return string |
|
| 15 | - */ |
|
| 16 | - protected function getRegistrationTemplate() |
|
| 17 | - { |
|
| 18 | - return "registration/register.tpl"; |
|
| 19 | - } |
|
| 13 | + /** |
|
| 14 | + * @return string |
|
| 15 | + */ |
|
| 16 | + protected function getRegistrationTemplate() |
|
| 17 | + { |
|
| 18 | + return "registration/register.tpl"; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - protected function getDefaultRole() |
|
| 25 | - { |
|
| 26 | - return 'user'; |
|
| 27 | - } |
|
| 21 | + /** |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + protected function getDefaultRole() |
|
| 25 | + { |
|
| 26 | + return 'user'; |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -15,37 +15,37 @@ |
||
| 15 | 15 | |
| 16 | 16 | class PageSiteNotice extends InternalPageBase |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Main function for this page, when no specific actions are called. |
|
| 20 | - * @return void |
|
| 21 | - */ |
|
| 22 | - protected function main() |
|
| 23 | - { |
|
| 24 | - $this->setHtmlTitle('Site Notice'); |
|
| 25 | - |
|
| 26 | - $database = $this->getDatabase(); |
|
| 27 | - |
|
| 28 | - /** @var SiteNotice $siteNoticeMessage */ |
|
| 29 | - $siteNoticeMessage = SiteNotice::getById(1, $database); |
|
| 30 | - |
|
| 31 | - // Dual-mode |
|
| 32 | - if (WebRequest::wasPosted()) { |
|
| 33 | - $this->validateCSRFToken(); |
|
| 34 | - |
|
| 35 | - $siteNoticeMessage->setContent(WebRequest::postString('mailtext')); |
|
| 36 | - $siteNoticeMessage->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
| 37 | - $siteNoticeMessage->save(); |
|
| 38 | - |
|
| 39 | - Logger::siteNoticeEdited($database, $siteNoticeMessage); |
|
| 40 | - $this->getNotificationHelper()->siteNoticeEdited(); |
|
| 41 | - |
|
| 42 | - $this->redirect(); |
|
| 43 | - } |
|
| 44 | - else { |
|
| 45 | - $this->assignCSRFToken(); |
|
| 46 | - |
|
| 47 | - $this->setTemplate('site-notice/edit-form.tpl'); |
|
| 48 | - $this->assign('message', $siteNoticeMessage); |
|
| 49 | - } |
|
| 50 | - } |
|
| 18 | + /** |
|
| 19 | + * Main function for this page, when no specific actions are called. |
|
| 20 | + * @return void |
|
| 21 | + */ |
|
| 22 | + protected function main() |
|
| 23 | + { |
|
| 24 | + $this->setHtmlTitle('Site Notice'); |
|
| 25 | + |
|
| 26 | + $database = $this->getDatabase(); |
|
| 27 | + |
|
| 28 | + /** @var SiteNotice $siteNoticeMessage */ |
|
| 29 | + $siteNoticeMessage = SiteNotice::getById(1, $database); |
|
| 30 | + |
|
| 31 | + // Dual-mode |
|
| 32 | + if (WebRequest::wasPosted()) { |
|
| 33 | + $this->validateCSRFToken(); |
|
| 34 | + |
|
| 35 | + $siteNoticeMessage->setContent(WebRequest::postString('mailtext')); |
|
| 36 | + $siteNoticeMessage->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
| 37 | + $siteNoticeMessage->save(); |
|
| 38 | + |
|
| 39 | + Logger::siteNoticeEdited($database, $siteNoticeMessage); |
|
| 40 | + $this->getNotificationHelper()->siteNoticeEdited(); |
|
| 41 | + |
|
| 42 | + $this->redirect(); |
|
| 43 | + } |
|
| 44 | + else { |
|
| 45 | + $this->assignCSRFToken(); |
|
| 46 | + |
|
| 47 | + $this->setTemplate('site-notice/edit-form.tpl'); |
|
| 48 | + $this->assign('message', $siteNoticeMessage); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | $this->getNotificationHelper()->siteNoticeEdited(); |
| 41 | 41 | |
| 42 | 42 | $this->redirect(); |
| 43 | - } |
|
| 44 | - else { |
|
| 43 | + } else { |
|
| 45 | 44 | $this->assignCSRFToken(); |
| 46 | 45 | |
| 47 | 46 | $this->setTemplate('site-notice/edit-form.tpl'); |
@@ -135,8 +135,7 @@ discard block |
||
| 135 | 135 | SessionAlert::success("Template successfully created."); |
| 136 | 136 | |
| 137 | 137 | $this->redirect('welcomeTemplates'); |
| 138 | - } |
|
| 139 | - else { |
|
| 138 | + } else { |
|
| 140 | 139 | $this->assignCSRFToken(); |
| 141 | 140 | $this->setTemplate("welcome-template/add.tpl"); |
| 142 | 141 | } |
@@ -182,8 +181,7 @@ discard block |
||
| 182 | 181 | $this->getNotificationHelper()->welcomeTemplateEdited($template); |
| 183 | 182 | |
| 184 | 183 | $this->redirect('welcomeTemplates'); |
| 185 | - } |
|
| 186 | - else { |
|
| 184 | + } else { |
|
| 187 | 185 | $this->assignCSRFToken(); |
| 188 | 186 | $this->assign('template', $template); |
| 189 | 187 | $this->setTemplate('welcome-template/edit.tpl'); |
@@ -19,223 +19,223 @@ |
||
| 19 | 19 | |
| 20 | 20 | class PageWelcomeTemplateManagement extends InternalPageBase |
| 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 | - $templateList = WelcomeTemplate::getAll($this->getDatabase()); |
|
| 29 | - |
|
| 30 | - $this->assignCSRFToken(); |
|
| 31 | - |
|
| 32 | - $user = User::getCurrent($this->getDatabase()); |
|
| 33 | - $this->assign('canEdit', $this->barrierTest('edit', $user)); |
|
| 34 | - $this->assign('canAdd', $this->barrierTest('add', $user)); |
|
| 22 | + /** |
|
| 23 | + * Main function for this page, when no specific actions are called. |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + protected function main() |
|
| 27 | + { |
|
| 28 | + $templateList = WelcomeTemplate::getAll($this->getDatabase()); |
|
| 29 | + |
|
| 30 | + $this->assignCSRFToken(); |
|
| 31 | + |
|
| 32 | + $user = User::getCurrent($this->getDatabase()); |
|
| 33 | + $this->assign('canEdit', $this->barrierTest('edit', $user)); |
|
| 34 | + $this->assign('canAdd', $this->barrierTest('add', $user)); |
|
| 35 | 35 | |
| 36 | - $this->assign('templateList', $templateList); |
|
| 37 | - $this->setTemplate('welcome-template/list.tpl'); |
|
| 38 | - } |
|
| 36 | + $this->assign('templateList', $templateList); |
|
| 37 | + $this->setTemplate('welcome-template/list.tpl'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Handles the requests for selecting a template to use. |
|
| 42 | - * |
|
| 43 | - * @throws ApplicationLogicException |
|
| 44 | - */ |
|
| 45 | - protected function select() |
|
| 46 | - { |
|
| 47 | - // get rid of GETs |
|
| 48 | - if (!WebRequest::wasPosted()) { |
|
| 49 | - $this->redirect('welcomeTemplates'); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $this->validateCSRFToken(); |
|
| 53 | - |
|
| 54 | - $user = User::getCurrent($this->getDatabase()); |
|
| 55 | - |
|
| 56 | - if (WebRequest::postBoolean('disable')) { |
|
| 57 | - $user->setWelcomeTemplate(null); |
|
| 58 | - $user->save(); |
|
| 59 | - |
|
| 60 | - SessionAlert::success('Disabled automatic user welcoming.'); |
|
| 61 | - $this->redirect('welcomeTemplates'); |
|
| 62 | - |
|
| 63 | - return; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $database = $this->getDatabase(); |
|
| 40 | + /** |
|
| 41 | + * Handles the requests for selecting a template to use. |
|
| 42 | + * |
|
| 43 | + * @throws ApplicationLogicException |
|
| 44 | + */ |
|
| 45 | + protected function select() |
|
| 46 | + { |
|
| 47 | + // get rid of GETs |
|
| 48 | + if (!WebRequest::wasPosted()) { |
|
| 49 | + $this->redirect('welcomeTemplates'); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $this->validateCSRFToken(); |
|
| 53 | + |
|
| 54 | + $user = User::getCurrent($this->getDatabase()); |
|
| 55 | + |
|
| 56 | + if (WebRequest::postBoolean('disable')) { |
|
| 57 | + $user->setWelcomeTemplate(null); |
|
| 58 | + $user->save(); |
|
| 59 | + |
|
| 60 | + SessionAlert::success('Disabled automatic user welcoming.'); |
|
| 61 | + $this->redirect('welcomeTemplates'); |
|
| 62 | + |
|
| 63 | + return; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $database = $this->getDatabase(); |
|
| 67 | 67 | |
| 68 | - $templateId = WebRequest::postInt('template'); |
|
| 69 | - /** @var false|WelcomeTemplate $template */ |
|
| 70 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
| 68 | + $templateId = WebRequest::postInt('template'); |
|
| 69 | + /** @var false|WelcomeTemplate $template */ |
|
| 70 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
| 71 | 71 | |
| 72 | - if ($template === false || $template->isDeleted()) { |
|
| 73 | - throw new ApplicationLogicException('Unknown template'); |
|
| 74 | - } |
|
| 72 | + if ($template === false || $template->isDeleted()) { |
|
| 73 | + throw new ApplicationLogicException('Unknown template'); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $user->setWelcomeTemplate($template->getId()); |
|
| 77 | - $user->save(); |
|
| 76 | + $user->setWelcomeTemplate($template->getId()); |
|
| 77 | + $user->save(); |
|
| 78 | 78 | |
| 79 | - SessionAlert::success("Updated selected welcome template for automatic welcoming."); |
|
| 79 | + SessionAlert::success("Updated selected welcome template for automatic welcoming."); |
|
| 80 | 80 | |
| 81 | - $this->redirect('welcomeTemplates'); |
|
| 82 | - } |
|
| 81 | + $this->redirect('welcomeTemplates'); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Handles the requests for viewing a template. |
|
| 86 | - * |
|
| 87 | - * @throws ApplicationLogicException |
|
| 88 | - */ |
|
| 89 | - protected function view() |
|
| 90 | - { |
|
| 91 | - $database = $this->getDatabase(); |
|
| 84 | + /** |
|
| 85 | + * Handles the requests for viewing a template. |
|
| 86 | + * |
|
| 87 | + * @throws ApplicationLogicException |
|
| 88 | + */ |
|
| 89 | + protected function view() |
|
| 90 | + { |
|
| 91 | + $database = $this->getDatabase(); |
|
| 92 | 92 | |
| 93 | - $templateId = WebRequest::getInt('template'); |
|
| 93 | + $templateId = WebRequest::getInt('template'); |
|
| 94 | 94 | |
| 95 | - /** @var WelcomeTemplate $template */ |
|
| 96 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
| 95 | + /** @var WelcomeTemplate $template */ |
|
| 96 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
| 97 | 97 | |
| 98 | - if ($template === false) { |
|
| 99 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
| 100 | - } |
|
| 98 | + if ($template === false) { |
|
| 99 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode()); |
|
| 102 | + $templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode()); |
|
| 103 | 103 | |
| 104 | - $this->assign('templateHtml', $templateHtml); |
|
| 105 | - $this->assign('template', $template); |
|
| 106 | - $this->setTemplate('welcome-template/view.tpl'); |
|
| 107 | - } |
|
| 104 | + $this->assign('templateHtml', $templateHtml); |
|
| 105 | + $this->assign('template', $template); |
|
| 106 | + $this->setTemplate('welcome-template/view.tpl'); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Handler for the add action to create a new welcome template |
|
| 111 | - * |
|
| 112 | - * @throws Exception |
|
| 113 | - */ |
|
| 114 | - protected function add() |
|
| 115 | - { |
|
| 116 | - if (WebRequest::wasPosted()) { |
|
| 117 | - $this->validateCSRFToken(); |
|
| 118 | - $database = $this->getDatabase(); |
|
| 109 | + /** |
|
| 110 | + * Handler for the add action to create a new welcome template |
|
| 111 | + * |
|
| 112 | + * @throws Exception |
|
| 113 | + */ |
|
| 114 | + protected function add() |
|
| 115 | + { |
|
| 116 | + if (WebRequest::wasPosted()) { |
|
| 117 | + $this->validateCSRFToken(); |
|
| 118 | + $database = $this->getDatabase(); |
|
| 119 | 119 | |
| 120 | - $userCode = WebRequest::postString('usercode'); |
|
| 121 | - $botCode = WebRequest::postString('botcode'); |
|
| 120 | + $userCode = WebRequest::postString('usercode'); |
|
| 121 | + $botCode = WebRequest::postString('botcode'); |
|
| 122 | 122 | |
| 123 | - $this->validate($userCode, $botCode); |
|
| 123 | + $this->validate($userCode, $botCode); |
|
| 124 | 124 | |
| 125 | - $template = new WelcomeTemplate(); |
|
| 126 | - $template->setDatabase($database); |
|
| 127 | - $template->setUserCode($userCode); |
|
| 128 | - $template->setBotCode($botCode); |
|
| 129 | - $template->save(); |
|
| 125 | + $template = new WelcomeTemplate(); |
|
| 126 | + $template->setDatabase($database); |
|
| 127 | + $template->setUserCode($userCode); |
|
| 128 | + $template->setBotCode($botCode); |
|
| 129 | + $template->save(); |
|
| 130 | 130 | |
| 131 | - Logger::welcomeTemplateCreated($database, $template); |
|
| 131 | + Logger::welcomeTemplateCreated($database, $template); |
|
| 132 | 132 | |
| 133 | - $this->getNotificationHelper()->welcomeTemplateCreated($template); |
|
| 133 | + $this->getNotificationHelper()->welcomeTemplateCreated($template); |
|
| 134 | 134 | |
| 135 | - SessionAlert::success("Template successfully created."); |
|
| 135 | + SessionAlert::success("Template successfully created."); |
|
| 136 | 136 | |
| 137 | - $this->redirect('welcomeTemplates'); |
|
| 138 | - } |
|
| 139 | - else { |
|
| 140 | - $this->assignCSRFToken(); |
|
| 141 | - $this->setTemplate("welcome-template/add.tpl"); |
|
| 142 | - } |
|
| 143 | - } |
|
| 137 | + $this->redirect('welcomeTemplates'); |
|
| 138 | + } |
|
| 139 | + else { |
|
| 140 | + $this->assignCSRFToken(); |
|
| 141 | + $this->setTemplate("welcome-template/add.tpl"); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Handler for editing templates |
|
| 147 | - */ |
|
| 148 | - protected function edit() |
|
| 149 | - { |
|
| 150 | - $database = $this->getDatabase(); |
|
| 145 | + /** |
|
| 146 | + * Handler for editing templates |
|
| 147 | + */ |
|
| 148 | + protected function edit() |
|
| 149 | + { |
|
| 150 | + $database = $this->getDatabase(); |
|
| 151 | 151 | |
| 152 | - $templateId = WebRequest::getInt('template'); |
|
| 152 | + $templateId = WebRequest::getInt('template'); |
|
| 153 | 153 | |
| 154 | - /** @var WelcomeTemplate $template */ |
|
| 155 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
| 154 | + /** @var WelcomeTemplate $template */ |
|
| 155 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
| 156 | 156 | |
| 157 | - if ($template === false) { |
|
| 158 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
| 159 | - } |
|
| 157 | + if ($template === false) { |
|
| 158 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - if ($template->isDeleted()) { |
|
| 162 | - throw new ApplicationLogicException('The specified template has been deleted'); |
|
| 163 | - } |
|
| 161 | + if ($template->isDeleted()) { |
|
| 162 | + throw new ApplicationLogicException('The specified template has been deleted'); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - if (WebRequest::wasPosted()) { |
|
| 166 | - $this->validateCSRFToken(); |
|
| 165 | + if (WebRequest::wasPosted()) { |
|
| 166 | + $this->validateCSRFToken(); |
|
| 167 | 167 | |
| 168 | - $userCode = WebRequest::postString('usercode'); |
|
| 169 | - $botCode = WebRequest::postString('botcode'); |
|
| 168 | + $userCode = WebRequest::postString('usercode'); |
|
| 169 | + $botCode = WebRequest::postString('botcode'); |
|
| 170 | 170 | |
| 171 | - $this->validate($userCode, $botCode); |
|
| 171 | + $this->validate($userCode, $botCode); |
|
| 172 | 172 | |
| 173 | - $template->setUserCode($userCode); |
|
| 174 | - $template->setBotCode($botCode); |
|
| 175 | - $template->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
| 176 | - $template->save(); |
|
| 173 | + $template->setUserCode($userCode); |
|
| 174 | + $template->setBotCode($botCode); |
|
| 175 | + $template->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
| 176 | + $template->save(); |
|
| 177 | 177 | |
| 178 | - Logger::welcomeTemplateEdited($database, $template); |
|
| 178 | + Logger::welcomeTemplateEdited($database, $template); |
|
| 179 | 179 | |
| 180 | - SessionAlert::success("Template updated."); |
|
| 180 | + SessionAlert::success("Template updated."); |
|
| 181 | 181 | |
| 182 | - $this->getNotificationHelper()->welcomeTemplateEdited($template); |
|
| 182 | + $this->getNotificationHelper()->welcomeTemplateEdited($template); |
|
| 183 | 183 | |
| 184 | - $this->redirect('welcomeTemplates'); |
|
| 185 | - } |
|
| 186 | - else { |
|
| 187 | - $this->assignCSRFToken(); |
|
| 188 | - $this->assign('template', $template); |
|
| 189 | - $this->setTemplate('welcome-template/edit.tpl'); |
|
| 190 | - } |
|
| 191 | - } |
|
| 184 | + $this->redirect('welcomeTemplates'); |
|
| 185 | + } |
|
| 186 | + else { |
|
| 187 | + $this->assignCSRFToken(); |
|
| 188 | + $this->assign('template', $template); |
|
| 189 | + $this->setTemplate('welcome-template/edit.tpl'); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - protected function delete() |
|
| 194 | - { |
|
| 195 | - $this->redirect('welcomeTemplates'); |
|
| 193 | + protected function delete() |
|
| 194 | + { |
|
| 195 | + $this->redirect('welcomeTemplates'); |
|
| 196 | 196 | |
| 197 | - if (!WebRequest::wasPosted()) { |
|
| 198 | - return; |
|
| 199 | - } |
|
| 197 | + if (!WebRequest::wasPosted()) { |
|
| 198 | + return; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $this->validateCSRFToken(); |
|
| 201 | + $this->validateCSRFToken(); |
|
| 202 | 202 | |
| 203 | - $database = $this->getDatabase(); |
|
| 203 | + $database = $this->getDatabase(); |
|
| 204 | 204 | |
| 205 | - $templateId = WebRequest::postInt('template'); |
|
| 206 | - $updateVersion = WebRequest::postInt('updateversion'); |
|
| 205 | + $templateId = WebRequest::postInt('template'); |
|
| 206 | + $updateVersion = WebRequest::postInt('updateversion'); |
|
| 207 | 207 | |
| 208 | - /** @var WelcomeTemplate $template */ |
|
| 209 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
| 208 | + /** @var WelcomeTemplate $template */ |
|
| 209 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
| 210 | 210 | |
| 211 | - if ($template === false || $template->isDeleted()) { |
|
| 212 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
| 213 | - } |
|
| 211 | + if ($template === false || $template->isDeleted()) { |
|
| 212 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - // set the update version to the version sent by the client (optimisticly lock from initial page load) |
|
| 216 | - $template->setUpdateVersion($updateVersion); |
|
| 215 | + // set the update version to the version sent by the client (optimisticly lock from initial page load) |
|
| 216 | + $template->setUpdateVersion($updateVersion); |
|
| 217 | 217 | |
| 218 | - $database |
|
| 219 | - ->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;") |
|
| 220 | - ->execute(array(":id" => $templateId)); |
|
| 218 | + $database |
|
| 219 | + ->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;") |
|
| 220 | + ->execute(array(":id" => $templateId)); |
|
| 221 | 221 | |
| 222 | - Logger::welcomeTemplateDeleted($database, $template); |
|
| 222 | + Logger::welcomeTemplateDeleted($database, $template); |
|
| 223 | 223 | |
| 224 | - $template->delete(); |
|
| 224 | + $template->delete(); |
|
| 225 | 225 | |
| 226 | - SessionAlert::success( |
|
| 227 | - "Template deleted. Any users who were using this template have had automatic welcoming disabled."); |
|
| 228 | - $this->getNotificationHelper()->welcomeTemplateDeleted($templateId); |
|
| 229 | - } |
|
| 226 | + SessionAlert::success( |
|
| 227 | + "Template deleted. Any users who were using this template have had automatic welcoming disabled."); |
|
| 228 | + $this->getNotificationHelper()->welcomeTemplateDeleted($templateId); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - private function validate($userCode, $botCode) |
|
| 232 | - { |
|
| 233 | - if ($userCode === null) { |
|
| 234 | - throw new ApplicationLogicException('User code cannot be null'); |
|
| 235 | - } |
|
| 231 | + private function validate($userCode, $botCode) |
|
| 232 | + { |
|
| 233 | + if ($userCode === null) { |
|
| 234 | + throw new ApplicationLogicException('User code cannot be null'); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - if ($botCode === null) { |
|
| 238 | - throw new ApplicationLogicException('Bot code cannot be null'); |
|
| 239 | - } |
|
| 240 | - } |
|
| 237 | + if ($botCode === null) { |
|
| 238 | + throw new ApplicationLogicException('Bot code cannot be null'); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | 241 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class StatsMonthlyStats extends InternalPageBase |
| 15 | 15 | { |
| 16 | - public function main() |
|
| 17 | - { |
|
| 18 | - $this->setHtmlTitle('Monthly Stats :: Statistics'); |
|
| 16 | + public function main() |
|
| 17 | + { |
|
| 18 | + $this->setHtmlTitle('Monthly Stats :: Statistics'); |
|
| 19 | 19 | |
| 20 | - $query = <<<SQL |
|
| 20 | + $query = <<<SQL |
|
| 21 | 21 | SELECT |
| 22 | 22 | COUNT(DISTINCT id) AS closed, |
| 23 | 23 | YEAR(timestamp) AS year, |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | ORDER BY YEAR(timestamp) , MONTH(timestamp) ASC; |
| 29 | 29 | SQL; |
| 30 | 30 | |
| 31 | - $database = $this->getDatabase(); |
|
| 32 | - $statement = $database->query($query); |
|
| 33 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 31 | + $database = $this->getDatabase(); |
|
| 32 | + $statement = $database->query($query); |
|
| 33 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 34 | 34 | |
| 35 | - $this->assign('dataTable', $data); |
|
| 36 | - $this->assign('statsPageTitle', 'Monthly Statistics'); |
|
| 37 | - $this->setTemplate('statistics/monthly-stats.tpl'); |
|
| 38 | - } |
|
| 35 | + $this->assign('dataTable', $data); |
|
| 36 | + $this->assign('statsPageTitle', 'Monthly Statistics'); |
|
| 37 | + $this->setTemplate('statistics/monthly-stats.tpl'); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -12,99 +12,99 @@ |
||
| 12 | 12 | |
| 13 | 13 | class StatsMain extends InternalPageBase |
| 14 | 14 | { |
| 15 | - public function main() |
|
| 16 | - { |
|
| 17 | - $this->setHtmlTitle('Statistics'); |
|
| 18 | - |
|
| 19 | - $this->assign('statsPageTitle', 'Account Creation Statistics'); |
|
| 20 | - |
|
| 21 | - $statsPages = array( |
|
| 22 | - 'fastCloses' => 'Requests closed less than 30 seconds after reservation in the past 3 months', |
|
| 23 | - 'inactiveUsers' => 'Inactive tool users', |
|
| 24 | - 'monthlyStats' => 'Monthly Statistics', |
|
| 25 | - 'reservedRequests' => 'All currently reserved requests', |
|
| 26 | - 'templateStats' => 'Template Stats', |
|
| 27 | - 'topCreators' => 'Top Account Creators', |
|
| 28 | - 'users' => 'Account Creation Tool users', |
|
| 29 | - ); |
|
| 30 | - |
|
| 31 | - $this->generateSmallStatsTable(); |
|
| 32 | - |
|
| 33 | - $this->assign('statsPages', $statsPages); |
|
| 34 | - |
|
| 35 | - $graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month'); |
|
| 36 | - $this->assign('graphList', $graphList); |
|
| 37 | - |
|
| 38 | - $this->setTemplate('statistics/main.tpl'); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Gets the relevant statistics from the database for the small statistics table |
|
| 43 | - */ |
|
| 44 | - private function generateSmallStatsTable() |
|
| 45 | - { |
|
| 46 | - $database = $this->getDatabase(); |
|
| 47 | - $requestsQuery = <<<'SQL' |
|
| 15 | + public function main() |
|
| 16 | + { |
|
| 17 | + $this->setHtmlTitle('Statistics'); |
|
| 18 | + |
|
| 19 | + $this->assign('statsPageTitle', 'Account Creation Statistics'); |
|
| 20 | + |
|
| 21 | + $statsPages = array( |
|
| 22 | + 'fastCloses' => 'Requests closed less than 30 seconds after reservation in the past 3 months', |
|
| 23 | + 'inactiveUsers' => 'Inactive tool users', |
|
| 24 | + 'monthlyStats' => 'Monthly Statistics', |
|
| 25 | + 'reservedRequests' => 'All currently reserved requests', |
|
| 26 | + 'templateStats' => 'Template Stats', |
|
| 27 | + 'topCreators' => 'Top Account Creators', |
|
| 28 | + 'users' => 'Account Creation Tool users', |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + $this->generateSmallStatsTable(); |
|
| 32 | + |
|
| 33 | + $this->assign('statsPages', $statsPages); |
|
| 34 | + |
|
| 35 | + $graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month'); |
|
| 36 | + $this->assign('graphList', $graphList); |
|
| 37 | + |
|
| 38 | + $this->setTemplate('statistics/main.tpl'); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Gets the relevant statistics from the database for the small statistics table |
|
| 43 | + */ |
|
| 44 | + private function generateSmallStatsTable() |
|
| 45 | + { |
|
| 46 | + $database = $this->getDatabase(); |
|
| 47 | + $requestsQuery = <<<'SQL' |
|
| 48 | 48 | SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed'; |
| 49 | 49 | SQL; |
| 50 | - $requestsStatement = $database->prepare($requestsQuery); |
|
| 50 | + $requestsStatement = $database->prepare($requestsQuery); |
|
| 51 | 51 | |
| 52 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
| 52 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
| 53 | 53 | |
| 54 | - $requestStateData = array(); |
|
| 54 | + $requestStateData = array(); |
|
| 55 | 55 | |
| 56 | - foreach ($requestStates as $statusName => $data) { |
|
| 57 | - $requestsStatement->execute(array(':status' => $statusName)); |
|
| 58 | - $requestCount = $requestsStatement->fetchColumn(); |
|
| 59 | - $requestsStatement->closeCursor(); |
|
| 60 | - $headerText = $data['header']; |
|
| 61 | - $requestStateData[$headerText] = $requestCount; |
|
| 62 | - } |
|
| 56 | + foreach ($requestStates as $statusName => $data) { |
|
| 57 | + $requestsStatement->execute(array(':status' => $statusName)); |
|
| 58 | + $requestCount = $requestsStatement->fetchColumn(); |
|
| 59 | + $requestsStatement->closeCursor(); |
|
| 60 | + $headerText = $data['header']; |
|
| 61 | + $requestStateData[$headerText] = $requestCount; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $this->assign('requestCountData', $requestStateData); |
|
| 64 | + $this->assign('requestCountData', $requestStateData); |
|
| 65 | 65 | |
| 66 | - // Unconfirmed requests |
|
| 67 | - $unconfirmedStatement = $database->query(<<<SQL |
|
| 66 | + // Unconfirmed requests |
|
| 67 | + $unconfirmedStatement = $database->query(<<<SQL |
|
| 68 | 68 | SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != ''; |
| 69 | 69 | SQL |
| 70 | - ); |
|
| 71 | - $unconfirmed = $unconfirmedStatement->fetchColumn(); |
|
| 72 | - $unconfirmedStatement->closeCursor(); |
|
| 73 | - $this->assign('statsUnconfirmed', $unconfirmed); |
|
| 74 | - |
|
| 75 | - $userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;'); |
|
| 76 | - |
|
| 77 | - // Admin users |
|
| 78 | - $userStatusStatement->execute(array(':status' => 'Admin')); |
|
| 79 | - $adminUsers = $userStatusStatement->fetchColumn(); |
|
| 80 | - $userStatusStatement->closeCursor(); |
|
| 81 | - $this->assign('statsAdminUsers', $adminUsers); |
|
| 82 | - |
|
| 83 | - // Users |
|
| 84 | - $userStatusStatement->execute(array(':status' => 'User')); |
|
| 85 | - $users = $userStatusStatement->fetchColumn(); |
|
| 86 | - $userStatusStatement->closeCursor(); |
|
| 87 | - $this->assign('statsUsers', $users); |
|
| 88 | - |
|
| 89 | - // Suspended users |
|
| 90 | - $userStatusStatement->execute(array(':status' => 'Suspended')); |
|
| 91 | - $suspendedUsers = $userStatusStatement->fetchColumn(); |
|
| 92 | - $userStatusStatement->closeCursor(); |
|
| 93 | - $this->assign('statsSuspendedUsers', $suspendedUsers); |
|
| 94 | - |
|
| 95 | - // New users |
|
| 96 | - $userStatusStatement->execute(array(':status' => 'New')); |
|
| 97 | - $newUsers = $userStatusStatement->fetchColumn(); |
|
| 98 | - $userStatusStatement->closeCursor(); |
|
| 99 | - $this->assign('statsNewUsers', $newUsers); |
|
| 100 | - |
|
| 101 | - // Most comments on a request |
|
| 102 | - $mostCommentsStatement = $database->query(<<<SQL |
|
| 70 | + ); |
|
| 71 | + $unconfirmed = $unconfirmedStatement->fetchColumn(); |
|
| 72 | + $unconfirmedStatement->closeCursor(); |
|
| 73 | + $this->assign('statsUnconfirmed', $unconfirmed); |
|
| 74 | + |
|
| 75 | + $userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;'); |
|
| 76 | + |
|
| 77 | + // Admin users |
|
| 78 | + $userStatusStatement->execute(array(':status' => 'Admin')); |
|
| 79 | + $adminUsers = $userStatusStatement->fetchColumn(); |
|
| 80 | + $userStatusStatement->closeCursor(); |
|
| 81 | + $this->assign('statsAdminUsers', $adminUsers); |
|
| 82 | + |
|
| 83 | + // Users |
|
| 84 | + $userStatusStatement->execute(array(':status' => 'User')); |
|
| 85 | + $users = $userStatusStatement->fetchColumn(); |
|
| 86 | + $userStatusStatement->closeCursor(); |
|
| 87 | + $this->assign('statsUsers', $users); |
|
| 88 | + |
|
| 89 | + // Suspended users |
|
| 90 | + $userStatusStatement->execute(array(':status' => 'Suspended')); |
|
| 91 | + $suspendedUsers = $userStatusStatement->fetchColumn(); |
|
| 92 | + $userStatusStatement->closeCursor(); |
|
| 93 | + $this->assign('statsSuspendedUsers', $suspendedUsers); |
|
| 94 | + |
|
| 95 | + // New users |
|
| 96 | + $userStatusStatement->execute(array(':status' => 'New')); |
|
| 97 | + $newUsers = $userStatusStatement->fetchColumn(); |
|
| 98 | + $userStatusStatement->closeCursor(); |
|
| 99 | + $this->assign('statsNewUsers', $newUsers); |
|
| 100 | + |
|
| 101 | + // Most comments on a request |
|
| 102 | + $mostCommentsStatement = $database->query(<<<SQL |
|
| 103 | 103 | SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1; |
| 104 | 104 | SQL |
| 105 | - ); |
|
| 106 | - $mostComments = $mostCommentsStatement->fetchColumn(); |
|
| 107 | - $mostCommentsStatement->closeCursor(); |
|
| 108 | - $this->assign('mostComments', $mostComments); |
|
| 109 | - } |
|
| 105 | + ); |
|
| 106 | + $mostComments = $mostCommentsStatement->fetchColumn(); |
|
| 107 | + $mostCommentsStatement->closeCursor(); |
|
| 108 | + $this->assign('mostComments', $mostComments); |
|
| 109 | + } |
|
| 110 | 110 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class StatsFastCloses extends InternalPageBase |
| 15 | 15 | { |
| 16 | - public function main() |
|
| 17 | - { |
|
| 18 | - $this->setHtmlTitle('Fast Closes :: Statistics'); |
|
| 16 | + public function main() |
|
| 17 | + { |
|
| 18 | + $this->setHtmlTitle('Fast Closes :: Statistics'); |
|
| 19 | 19 | |
| 20 | - $query = <<<SQL |
|
| 20 | + $query = <<<SQL |
|
| 21 | 21 | SELECT |
| 22 | 22 | log_closed.objectid AS request, |
| 23 | 23 | user.username AS user, |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | ORDER BY TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) ASC |
| 43 | 43 | ; |
| 44 | 44 | SQL; |
| 45 | - $database = $this->getDatabase(); |
|
| 46 | - $statement = $database->query($query); |
|
| 47 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 48 | - $this->assign('dataTable', $data); |
|
| 49 | - $this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months'); |
|
| 50 | - $this->setTemplate('statistics/fast-closes.tpl'); |
|
| 51 | - } |
|
| 45 | + $database = $this->getDatabase(); |
|
| 46 | + $statement = $database->query($query); |
|
| 47 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 48 | + $this->assign('dataTable', $data); |
|
| 49 | + $this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months'); |
|
| 50 | + $this->setTemplate('statistics/fast-closes.tpl'); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -128,8 +128,7 @@ |
||
| 128 | 128 | |
| 129 | 129 | if ($logCount === 0) { |
| 130 | 130 | $this->assign('accountlog', array()); |
| 131 | - } |
|
| 132 | - else { |
|
| 131 | + } else { |
|
| 133 | 132 | list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
| 134 | 133 | |
| 135 | 134 | $this->assign("accountlog", $logData); |
@@ -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,34 +44,34 @@ 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 | 73 | |
| 74 | - $activitySummary = $database->prepare(<<<SQL |
|
| 74 | + $activitySummary = $database->prepare(<<<SQL |
|
| 75 | 75 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
| 76 | 76 | FROM log |
| 77 | 77 | INNER JOIN user ON log.user = user.id |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | WHERE user.username = :username |
| 80 | 80 | GROUP BY action; |
| 81 | 81 | SQL |
| 82 | - ); |
|
| 83 | - $activitySummary->execute(array(":username" => $user->getUsername())); |
|
| 84 | - $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
| 82 | + ); |
|
| 83 | + $activitySummary->execute(array(":username" => $user->getUsername())); |
|
| 84 | + $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
| 85 | 85 | |
| 86 | - $this->assign("user", $user); |
|
| 87 | - $this->assign("activity", $activitySummaryData); |
|
| 86 | + $this->assign("user", $user); |
|
| 87 | + $this->assign("activity", $activitySummaryData); |
|
| 88 | 88 | |
| 89 | - $usersCreatedQuery = $database->prepare(<<<SQL |
|
| 89 | + $usersCreatedQuery = $database->prepare(<<<SQL |
|
| 90 | 90 | SELECT log.timestamp time, request.name name, request.id id |
| 91 | 91 | FROM log |
| 92 | 92 | INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request') |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
| 98 | 98 | ORDER BY log.timestamp; |
| 99 | 99 | SQL |
| 100 | - ); |
|
| 101 | - $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
| 102 | - $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
| 103 | - $this->assign("created", $usersCreated); |
|
| 100 | + ); |
|
| 101 | + $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
| 102 | + $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
| 103 | + $this->assign("created", $usersCreated); |
|
| 104 | 104 | |
| 105 | - $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
| 105 | + $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
| 106 | 106 | SELECT log.timestamp time, request.name name, request.id id |
| 107 | 107 | FROM log |
| 108 | 108 | JOIN request ON request.id = log.objectid AND log.objecttype = 'Request' |
@@ -113,54 +113,54 @@ discard block |
||
| 113 | 113 | AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0') |
| 114 | 114 | ORDER BY log.timestamp; |
| 115 | 115 | SQL |
| 116 | - ); |
|
| 117 | - $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
| 118 | - $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
| 119 | - $this->assign("notcreated", $usersNotCreated); |
|
| 120 | - |
|
| 121 | - /** @var Log[] $logs */ |
|
| 122 | - $logs = LogSearchHelper::get($database) |
|
| 123 | - ->byObjectType('User') |
|
| 124 | - ->byObjectId($user->getId()) |
|
| 125 | - ->getRecordCount($logCount) |
|
| 126 | - ->fetch(); |
|
| 127 | - |
|
| 128 | - if ($logCount === 0) { |
|
| 129 | - $this->assign('accountlog', array()); |
|
| 130 | - } |
|
| 131 | - else { |
|
| 132 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
| 133 | - |
|
| 134 | - $this->assign("accountlog", $logData); |
|
| 135 | - $this->assign("users", $users); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $currentUser = User::getCurrent($database); |
|
| 139 | - $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
| 140 | - $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
| 141 | - $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
| 142 | - $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
| 143 | - $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
| 144 | - $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
| 145 | - |
|
| 146 | - $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
| 147 | - $this->assign('oauth', $oauth); |
|
| 148 | - |
|
| 149 | - if($user->getForceIdentified() === null) { |
|
| 150 | - $idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase()); |
|
| 151 | - $this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing'); |
|
| 152 | - } else { |
|
| 153 | - $this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off'); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - if ($oauth->isFullyLinked()) { |
|
| 157 | - $this->assign('identity', $oauth->getIdentity(true)); |
|
| 158 | - $this->assign('identityExpired', $oauth->identityExpired()); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
| 162 | - |
|
| 163 | - $this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics'); |
|
| 164 | - $this->setTemplate("statistics/userdetail.tpl"); |
|
| 165 | - } |
|
| 116 | + ); |
|
| 117 | + $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
| 118 | + $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
| 119 | + $this->assign("notcreated", $usersNotCreated); |
|
| 120 | + |
|
| 121 | + /** @var Log[] $logs */ |
|
| 122 | + $logs = LogSearchHelper::get($database) |
|
| 123 | + ->byObjectType('User') |
|
| 124 | + ->byObjectId($user->getId()) |
|
| 125 | + ->getRecordCount($logCount) |
|
| 126 | + ->fetch(); |
|
| 127 | + |
|
| 128 | + if ($logCount === 0) { |
|
| 129 | + $this->assign('accountlog', array()); |
|
| 130 | + } |
|
| 131 | + else { |
|
| 132 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
| 133 | + |
|
| 134 | + $this->assign("accountlog", $logData); |
|
| 135 | + $this->assign("users", $users); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $currentUser = User::getCurrent($database); |
|
| 139 | + $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
| 140 | + $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
| 141 | + $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
| 142 | + $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
| 143 | + $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
| 144 | + $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
| 145 | + |
|
| 146 | + $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
| 147 | + $this->assign('oauth', $oauth); |
|
| 148 | + |
|
| 149 | + if($user->getForceIdentified() === null) { |
|
| 150 | + $idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase()); |
|
| 151 | + $this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing'); |
|
| 152 | + } else { |
|
| 153 | + $this->assign('identificationStatus', $user->getForceIdentified() == 1 ? 'forced-on' : 'forced-off'); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + if ($oauth->isFullyLinked()) { |
|
| 157 | + $this->assign('identity', $oauth->getIdentity(true)); |
|
| 158 | + $this->assign('identityExpired', $oauth->identityExpired()); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
| 162 | + |
|
| 163 | + $this->setHtmlTitle('{$user->getUsername()|escape} :: Users :: Statistics'); |
|
| 164 | + $this->setTemplate("statistics/userdetail.tpl"); |
|
| 165 | + } |
|
| 166 | 166 | } |
@@ -146,7 +146,7 @@ |
||
| 146 | 146 | $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
| 147 | 147 | $this->assign('oauth', $oauth); |
| 148 | 148 | |
| 149 | - if($user->getForceIdentified() === null) { |
|
| 149 | + if ($user->getForceIdentified() === null) { |
|
| 150 | 150 | $idVerifier = new IdentificationVerifier($this->getHttpHelper(), $this->getSiteConfiguration(), $this->getDatabase()); |
| 151 | 151 | $this->assign('identificationStatus', $idVerifier->isUserIdentified($user->getOnWikiName()) ? 'detected' : 'missing'); |
| 152 | 152 | } else { |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class StatsTemplateStats extends InternalPageBase |
| 15 | 15 | { |
| 16 | - public function main() |
|
| 17 | - { |
|
| 18 | - $this->setHtmlTitle('Template Stats :: Statistics'); |
|
| 16 | + public function main() |
|
| 17 | + { |
|
| 18 | + $this->setHtmlTitle('Template Stats :: Statistics'); |
|
| 19 | 19 | |
| 20 | - $query = <<<SQL |
|
| 20 | + $query = <<<SQL |
|
| 21 | 21 | SELECT |
| 22 | 22 | t.id AS templateid, |
| 23 | 23 | t.usercode AS usercode, |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | GROUP BY welcome_template |
| 46 | 46 | ) u2 ON u2.allid = t.id; |
| 47 | 47 | SQL; |
| 48 | - $database = $this->getDatabase(); |
|
| 49 | - $statement = $database->query($query); |
|
| 50 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 51 | - $this->assign('dataTable', $data); |
|
| 52 | - $this->assign('statsPageTitle', 'Template Stats'); |
|
| 53 | - $this->setTemplate('statistics/welcome-template-usage.tpl'); |
|
| 54 | - } |
|
| 48 | + $database = $this->getDatabase(); |
|
| 49 | + $statement = $database->query($query); |
|
| 50 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 51 | + $this->assign('dataTable', $data); |
|
| 52 | + $this->assign('statsPageTitle', 'Template Stats'); |
|
| 53 | + $this->setTemplate('statistics/welcome-template-usage.tpl'); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class StatsTopCreators extends InternalPageBase |
| 15 | 15 | { |
| 16 | - public function main() |
|
| 17 | - { |
|
| 18 | - $this->setHtmlTitle('Top Creators :: Statistics'); |
|
| 16 | + public function main() |
|
| 17 | + { |
|
| 18 | + $this->setHtmlTitle('Top Creators :: Statistics'); |
|
| 19 | 19 | |
| 20 | - // Retrieve all-time stats |
|
| 21 | - $queryAllTime = <<<SQL |
|
| 20 | + // Retrieve all-time stats |
|
| 21 | + $queryAllTime = <<<SQL |
|
| 22 | 22 | SELECT |
| 23 | 23 | /* StatsTopCreators::execute()/queryAllTime */ |
| 24 | 24 | COUNT(*) count, |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | ORDER BY COUNT(*) DESC; |
| 36 | 36 | SQL; |
| 37 | 37 | |
| 38 | - // Retrieve all-time stats for active users only |
|
| 39 | - $queryAllTimeActive = <<<SQL |
|
| 38 | + // Retrieve all-time stats for active users only |
|
| 39 | + $queryAllTimeActive = <<<SQL |
|
| 40 | 40 | SELECT |
| 41 | 41 | /* StatsTopCreators::execute()/queryAllTimeActive */ |
| 42 | 42 | COUNT(*) count, |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | ORDER BY COUNT(*) DESC; |
| 54 | 54 | SQL; |
| 55 | 55 | |
| 56 | - // Retrieve today's stats (so far) |
|
| 57 | - $queryToday = <<<SQL |
|
| 56 | + // Retrieve today's stats (so far) |
|
| 57 | + $queryToday = <<<SQL |
|
| 58 | 58 | SELECT |
| 59 | 59 | /* StatsTopCreators::execute()/top5out */ |
| 60 | 60 | COUNT(*) count, |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | ORDER BY COUNT(*) DESC; |
| 71 | 71 | SQL; |
| 72 | 72 | |
| 73 | - // Retrieve Yesterday's stats |
|
| 74 | - $queryYesterday = <<<SQL |
|
| 73 | + // Retrieve Yesterday's stats |
|
| 74 | + $queryYesterday = <<<SQL |
|
| 75 | 75 | SELECT |
| 76 | 76 | /* StatsTopCreators::execute()/top5yout */ |
| 77 | 77 | COUNT(*) count, |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | ORDER BY COUNT(*) DESC; |
| 88 | 88 | SQL; |
| 89 | 89 | |
| 90 | - // Retrieve last 7 days |
|
| 91 | - $queryLast7Days = <<<SQL |
|
| 90 | + // Retrieve last 7 days |
|
| 91 | + $queryLast7Days = <<<SQL |
|
| 92 | 92 | SELECT |
| 93 | 93 | /* StatsTopCreators::execute()/top5wout */ |
| 94 | 94 | COUNT(*) count, |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | ORDER BY COUNT(*) DESC; |
| 105 | 105 | SQL; |
| 106 | 106 | |
| 107 | - // Retrieve last month's stats |
|
| 108 | - $queryLast28Days = <<<SQL |
|
| 107 | + // Retrieve last month's stats |
|
| 108 | + $queryLast28Days = <<<SQL |
|
| 109 | 109 | SELECT |
| 110 | 110 | /* StatsTopCreators::execute()/top5mout */ |
| 111 | 111 | COUNT(*) count, |
@@ -121,24 +121,24 @@ discard block |
||
| 121 | 121 | ORDER BY COUNT(*) DESC; |
| 122 | 122 | SQL; |
| 123 | 123 | |
| 124 | - // Put it all together |
|
| 125 | - $queries = array( |
|
| 126 | - 'queryAllTime' => $queryAllTime, |
|
| 127 | - 'queryAllTimeActive' => $queryAllTimeActive, |
|
| 128 | - 'queryToday' => $queryToday, |
|
| 129 | - 'queryYesterday' => $queryYesterday, |
|
| 130 | - 'queryLast7Days' => $queryLast7Days, |
|
| 131 | - 'queryLast28Days' => $queryLast28Days, |
|
| 132 | - ); |
|
| 124 | + // Put it all together |
|
| 125 | + $queries = array( |
|
| 126 | + 'queryAllTime' => $queryAllTime, |
|
| 127 | + 'queryAllTimeActive' => $queryAllTimeActive, |
|
| 128 | + 'queryToday' => $queryToday, |
|
| 129 | + 'queryYesterday' => $queryYesterday, |
|
| 130 | + 'queryLast7Days' => $queryLast7Days, |
|
| 131 | + 'queryLast28Days' => $queryLast28Days, |
|
| 132 | + ); |
|
| 133 | 133 | |
| 134 | - $database = $this->getDatabase(); |
|
| 135 | - foreach ($queries as $name => $sql) { |
|
| 136 | - $statement = $database->query($sql); |
|
| 137 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 138 | - $this->assign($name, $data); |
|
| 139 | - } |
|
| 134 | + $database = $this->getDatabase(); |
|
| 135 | + foreach ($queries as $name => $sql) { |
|
| 136 | + $statement = $database->query($sql); |
|
| 137 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 138 | + $this->assign($name, $data); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $this->assign('statsPageTitle', 'Top Account Creators'); |
|
| 142 | - $this->setTemplate('statistics/top-creators.tpl'); |
|
| 143 | - } |
|
| 141 | + $this->assign('statsPageTitle', 'Top Account Creators'); |
|
| 142 | + $this->setTemplate('statistics/top-creators.tpl'); |
|
| 143 | + } |
|
| 144 | 144 | } |