@@ -19,179 +19,179 @@ |
||
19 | 19 | |
20 | 20 | class PageEmailManagement 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 | - $this->setHtmlTitle('Close Emails'); |
|
29 | - |
|
30 | - // Get all active email templates |
|
31 | - $activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase()); |
|
32 | - $inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase()); |
|
33 | - |
|
34 | - $this->assign('activeTemplates', $activeTemplates); |
|
35 | - $this->assign('inactiveTemplates', $inactiveTemplates); |
|
36 | - |
|
37 | - $user = User::getCurrent($this->getDatabase()); |
|
38 | - $this->assign('canCreate', $this->barrierTest('create', $user)); |
|
39 | - $this->assign('canEdit', $this->barrierTest('edit', $user)); |
|
40 | - |
|
41 | - $this->setTemplate('email-management/main.tpl'); |
|
42 | - } |
|
43 | - |
|
44 | - protected function view() |
|
45 | - { |
|
46 | - $this->setHtmlTitle('Close Emails'); |
|
47 | - |
|
48 | - $database = $this->getDatabase(); |
|
49 | - $template = $this->getTemplate($database); |
|
50 | - |
|
51 | - $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId(); |
|
52 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
53 | - |
|
54 | - $this->assign('id', $template->getId()); |
|
55 | - $this->assign('emailTemplate', $template); |
|
56 | - $this->assign('createdid', $createdId); |
|
57 | - $this->assign('requeststates', $requestStates); |
|
58 | - |
|
59 | - $this->setTemplate('email-management/view.tpl'); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @param PdoDatabase $database |
|
64 | - * |
|
65 | - * @return EmailTemplate |
|
66 | - * @throws ApplicationLogicException |
|
67 | - */ |
|
68 | - protected function getTemplate(PdoDatabase $database) |
|
69 | - { |
|
70 | - $templateId = WebRequest::getInt('id'); |
|
71 | - if ($templateId === null) { |
|
72 | - throw new ApplicationLogicException('Template not specified'); |
|
73 | - } |
|
74 | - $template = EmailTemplate::getById($templateId, $database); |
|
75 | - if ($template === false || !is_a($template, EmailTemplate::class)) { |
|
76 | - throw new ApplicationLogicException('Template not found'); |
|
77 | - } |
|
78 | - |
|
79 | - return $template; |
|
80 | - } |
|
81 | - |
|
82 | - protected function edit() |
|
83 | - { |
|
84 | - $this->setHtmlTitle('Close Emails'); |
|
85 | - |
|
86 | - $database = $this->getDatabase(); |
|
87 | - $template = $this->getTemplate($database); |
|
88 | - |
|
89 | - $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId(); |
|
90 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
91 | - |
|
92 | - if (WebRequest::wasPosted()) { |
|
93 | - $this->validateCSRFToken(); |
|
94 | - |
|
95 | - $this->modifyTemplateData($template); |
|
96 | - |
|
97 | - $other = EmailTemplate::getByName($template->getName(), $database); |
|
98 | - if ($other !== false && $other->getId() !== $template->getId()) { |
|
99 | - throw new ApplicationLogicException('A template with this name already exists'); |
|
100 | - } |
|
101 | - |
|
102 | - if ($template->getId() === $createdId) { |
|
103 | - $template->setDefaultAction(EmailTemplate::CREATED); |
|
104 | - $template->setActive(true); |
|
105 | - $template->setPreloadOnly(false); |
|
106 | - } |
|
107 | - |
|
108 | - // optimistically lock on load of edit form |
|
109 | - $updateVersion = WebRequest::postInt('updateversion'); |
|
110 | - $template->setUpdateVersion($updateVersion); |
|
111 | - |
|
112 | - $template->save(); |
|
113 | - Logger::editedEmail($database, $template); |
|
114 | - $this->getNotificationHelper()->emailEdited($template); |
|
115 | - SessionAlert::success("Email template has been saved successfully."); |
|
116 | - |
|
117 | - $this->redirect('emailManagement'); |
|
118 | - } |
|
119 | - else { |
|
120 | - $this->assignCSRFToken(); |
|
121 | - $this->assign('id', $template->getId()); |
|
122 | - $this->assign('emailTemplate', $template); |
|
123 | - $this->assign('createdid', $createdId); |
|
124 | - $this->assign('requeststates', $requestStates); |
|
125 | - |
|
126 | - $this->setTemplate('email-management/edit.tpl'); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @param EmailTemplate $template |
|
132 | - * |
|
133 | - * @throws ApplicationLogicException |
|
134 | - */ |
|
135 | - private function modifyTemplateData(EmailTemplate $template) |
|
136 | - { |
|
137 | - $name = WebRequest::postString('name'); |
|
138 | - if ($name === null || $name === '') { |
|
139 | - throw new ApplicationLogicException('Name not specified'); |
|
140 | - } |
|
141 | - |
|
142 | - $template->setName($name); |
|
143 | - |
|
144 | - $text = WebRequest::postString('text'); |
|
145 | - if ($text === null || $text === '') { |
|
146 | - throw new ApplicationLogicException('Text not specified'); |
|
147 | - } |
|
148 | - |
|
149 | - $template->setText($text); |
|
150 | - |
|
151 | - $template->setJsquestion(WebRequest::postString('jsquestion')); |
|
152 | - |
|
153 | - $template->setDefaultAction(WebRequest::postString('defaultaction')); |
|
154 | - $template->setActive(WebRequest::postBoolean('active')); |
|
155 | - $template->setPreloadOnly(WebRequest::postBoolean('preloadonly')); |
|
156 | - } |
|
157 | - |
|
158 | - protected function create() |
|
159 | - { |
|
160 | - $this->setHtmlTitle('Close Emails'); |
|
161 | - |
|
162 | - $database = $this->getDatabase(); |
|
163 | - |
|
164 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
165 | - |
|
166 | - if (WebRequest::wasPosted()) { |
|
167 | - $this->validateCSRFToken(); |
|
168 | - $template = new EmailTemplate(); |
|
169 | - $template->setDatabase($database); |
|
170 | - |
|
171 | - $this->modifyTemplateData($template); |
|
172 | - |
|
173 | - $other = EmailTemplate::getByName($template->getName(), $database); |
|
174 | - if ($other !== false) { |
|
175 | - throw new ApplicationLogicException('A template with this name already exists'); |
|
176 | - } |
|
177 | - |
|
178 | - $template->save(); |
|
179 | - |
|
180 | - Logger::createEmail($database, $template); |
|
181 | - $this->getNotificationHelper()->emailCreated($template); |
|
182 | - |
|
183 | - SessionAlert::success("Email template has been saved successfully."); |
|
184 | - |
|
185 | - $this->redirect('emailManagement'); |
|
186 | - } |
|
187 | - else { |
|
188 | - $this->assignCSRFToken(); |
|
189 | - $this->assign('id', -1); |
|
190 | - $this->assign('emailTemplate', new EmailTemplate()); |
|
191 | - $this->assign('createdid', -2); |
|
192 | - |
|
193 | - $this->assign('requeststates', $requestStates); |
|
194 | - $this->setTemplate('email-management/edit.tpl'); |
|
195 | - } |
|
196 | - } |
|
22 | + /** |
|
23 | + * Main function for this page, when no specific actions are called. |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + protected function main() |
|
27 | + { |
|
28 | + $this->setHtmlTitle('Close Emails'); |
|
29 | + |
|
30 | + // Get all active email templates |
|
31 | + $activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase()); |
|
32 | + $inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase()); |
|
33 | + |
|
34 | + $this->assign('activeTemplates', $activeTemplates); |
|
35 | + $this->assign('inactiveTemplates', $inactiveTemplates); |
|
36 | + |
|
37 | + $user = User::getCurrent($this->getDatabase()); |
|
38 | + $this->assign('canCreate', $this->barrierTest('create', $user)); |
|
39 | + $this->assign('canEdit', $this->barrierTest('edit', $user)); |
|
40 | + |
|
41 | + $this->setTemplate('email-management/main.tpl'); |
|
42 | + } |
|
43 | + |
|
44 | + protected function view() |
|
45 | + { |
|
46 | + $this->setHtmlTitle('Close Emails'); |
|
47 | + |
|
48 | + $database = $this->getDatabase(); |
|
49 | + $template = $this->getTemplate($database); |
|
50 | + |
|
51 | + $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId(); |
|
52 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
53 | + |
|
54 | + $this->assign('id', $template->getId()); |
|
55 | + $this->assign('emailTemplate', $template); |
|
56 | + $this->assign('createdid', $createdId); |
|
57 | + $this->assign('requeststates', $requestStates); |
|
58 | + |
|
59 | + $this->setTemplate('email-management/view.tpl'); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @param PdoDatabase $database |
|
64 | + * |
|
65 | + * @return EmailTemplate |
|
66 | + * @throws ApplicationLogicException |
|
67 | + */ |
|
68 | + protected function getTemplate(PdoDatabase $database) |
|
69 | + { |
|
70 | + $templateId = WebRequest::getInt('id'); |
|
71 | + if ($templateId === null) { |
|
72 | + throw new ApplicationLogicException('Template not specified'); |
|
73 | + } |
|
74 | + $template = EmailTemplate::getById($templateId, $database); |
|
75 | + if ($template === false || !is_a($template, EmailTemplate::class)) { |
|
76 | + throw new ApplicationLogicException('Template not found'); |
|
77 | + } |
|
78 | + |
|
79 | + return $template; |
|
80 | + } |
|
81 | + |
|
82 | + protected function edit() |
|
83 | + { |
|
84 | + $this->setHtmlTitle('Close Emails'); |
|
85 | + |
|
86 | + $database = $this->getDatabase(); |
|
87 | + $template = $this->getTemplate($database); |
|
88 | + |
|
89 | + $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId(); |
|
90 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
91 | + |
|
92 | + if (WebRequest::wasPosted()) { |
|
93 | + $this->validateCSRFToken(); |
|
94 | + |
|
95 | + $this->modifyTemplateData($template); |
|
96 | + |
|
97 | + $other = EmailTemplate::getByName($template->getName(), $database); |
|
98 | + if ($other !== false && $other->getId() !== $template->getId()) { |
|
99 | + throw new ApplicationLogicException('A template with this name already exists'); |
|
100 | + } |
|
101 | + |
|
102 | + if ($template->getId() === $createdId) { |
|
103 | + $template->setDefaultAction(EmailTemplate::CREATED); |
|
104 | + $template->setActive(true); |
|
105 | + $template->setPreloadOnly(false); |
|
106 | + } |
|
107 | + |
|
108 | + // optimistically lock on load of edit form |
|
109 | + $updateVersion = WebRequest::postInt('updateversion'); |
|
110 | + $template->setUpdateVersion($updateVersion); |
|
111 | + |
|
112 | + $template->save(); |
|
113 | + Logger::editedEmail($database, $template); |
|
114 | + $this->getNotificationHelper()->emailEdited($template); |
|
115 | + SessionAlert::success("Email template has been saved successfully."); |
|
116 | + |
|
117 | + $this->redirect('emailManagement'); |
|
118 | + } |
|
119 | + else { |
|
120 | + $this->assignCSRFToken(); |
|
121 | + $this->assign('id', $template->getId()); |
|
122 | + $this->assign('emailTemplate', $template); |
|
123 | + $this->assign('createdid', $createdId); |
|
124 | + $this->assign('requeststates', $requestStates); |
|
125 | + |
|
126 | + $this->setTemplate('email-management/edit.tpl'); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @param EmailTemplate $template |
|
132 | + * |
|
133 | + * @throws ApplicationLogicException |
|
134 | + */ |
|
135 | + private function modifyTemplateData(EmailTemplate $template) |
|
136 | + { |
|
137 | + $name = WebRequest::postString('name'); |
|
138 | + if ($name === null || $name === '') { |
|
139 | + throw new ApplicationLogicException('Name not specified'); |
|
140 | + } |
|
141 | + |
|
142 | + $template->setName($name); |
|
143 | + |
|
144 | + $text = WebRequest::postString('text'); |
|
145 | + if ($text === null || $text === '') { |
|
146 | + throw new ApplicationLogicException('Text not specified'); |
|
147 | + } |
|
148 | + |
|
149 | + $template->setText($text); |
|
150 | + |
|
151 | + $template->setJsquestion(WebRequest::postString('jsquestion')); |
|
152 | + |
|
153 | + $template->setDefaultAction(WebRequest::postString('defaultaction')); |
|
154 | + $template->setActive(WebRequest::postBoolean('active')); |
|
155 | + $template->setPreloadOnly(WebRequest::postBoolean('preloadonly')); |
|
156 | + } |
|
157 | + |
|
158 | + protected function create() |
|
159 | + { |
|
160 | + $this->setHtmlTitle('Close Emails'); |
|
161 | + |
|
162 | + $database = $this->getDatabase(); |
|
163 | + |
|
164 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
165 | + |
|
166 | + if (WebRequest::wasPosted()) { |
|
167 | + $this->validateCSRFToken(); |
|
168 | + $template = new EmailTemplate(); |
|
169 | + $template->setDatabase($database); |
|
170 | + |
|
171 | + $this->modifyTemplateData($template); |
|
172 | + |
|
173 | + $other = EmailTemplate::getByName($template->getName(), $database); |
|
174 | + if ($other !== false) { |
|
175 | + throw new ApplicationLogicException('A template with this name already exists'); |
|
176 | + } |
|
177 | + |
|
178 | + $template->save(); |
|
179 | + |
|
180 | + Logger::createEmail($database, $template); |
|
181 | + $this->getNotificationHelper()->emailCreated($template); |
|
182 | + |
|
183 | + SessionAlert::success("Email template has been saved successfully."); |
|
184 | + |
|
185 | + $this->redirect('emailManagement'); |
|
186 | + } |
|
187 | + else { |
|
188 | + $this->assignCSRFToken(); |
|
189 | + $this->assign('id', -1); |
|
190 | + $this->assign('emailTemplate', new EmailTemplate()); |
|
191 | + $this->assign('createdid', -2); |
|
192 | + |
|
193 | + $this->assign('requeststates', $requestStates); |
|
194 | + $this->setTemplate('email-management/edit.tpl'); |
|
195 | + } |
|
196 | + } |
|
197 | 197 | } |
@@ -16,12 +16,12 @@ |
||
16 | 16 | */ |
17 | 17 | interface IXmlApiAction extends IRoutedTask, IApiAction |
18 | 18 | { |
19 | - /** |
|
20 | - * Method that runs API action |
|
21 | - * |
|
22 | - * @param DOMElement $apiDocument |
|
23 | - * |
|
24 | - * @return DOMElement The modified API document |
|
25 | - */ |
|
26 | - public function executeApiAction(DOMElement $apiDocument); |
|
19 | + /** |
|
20 | + * Method that runs API action |
|
21 | + * |
|
22 | + * @param DOMElement $apiDocument |
|
23 | + * |
|
24 | + * @return DOMElement The modified API document |
|
25 | + */ |
|
26 | + public function executeApiAction(DOMElement $apiDocument); |
|
27 | 27 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | */ |
16 | 16 | interface IJsonApiAction extends IRoutedTask, IApiAction |
17 | 17 | { |
18 | - /** |
|
19 | - * Method that runs API action |
|
20 | - * |
|
21 | - * @return object|array The modified API document |
|
22 | - */ |
|
23 | - public function executeApiAction(); |
|
18 | + /** |
|
19 | + * Method that runs API action |
|
20 | + * |
|
21 | + * @return object|array The modified API document |
|
22 | + */ |
|
23 | + public function executeApiAction(); |
|
24 | 24 | } |
@@ -16,15 +16,15 @@ |
||
16 | 16 | */ |
17 | 17 | class UnknownAction extends HelpAction implements IXmlApiAction |
18 | 18 | { |
19 | - public function executeApiAction(DOMElement $apiDocument) |
|
20 | - { |
|
21 | - $errorText = "Unknown API action specified."; |
|
22 | - $errorNode = $this->document->createElement("error", $errorText); |
|
23 | - $apiDocument->appendChild($errorNode); |
|
19 | + public function executeApiAction(DOMElement $apiDocument) |
|
20 | + { |
|
21 | + $errorText = "Unknown API action specified."; |
|
22 | + $errorNode = $this->document->createElement("error", $errorText); |
|
23 | + $apiDocument->appendChild($errorNode); |
|
24 | 24 | |
25 | - $helpElement = $this->getHelpElement(); |
|
26 | - $apiDocument->appendChild($helpElement); |
|
25 | + $helpElement = $this->getHelpElement(); |
|
26 | + $apiDocument->appendChild($helpElement); |
|
27 | 27 | |
28 | - return $apiDocument; |
|
29 | - } |
|
28 | + return $apiDocument; |
|
29 | + } |
|
30 | 30 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | |
17 | 17 | class JsUsersAction extends JsonApiPageBase implements IJsonApiAction |
18 | 18 | { |
19 | - public function executeApiAction() |
|
20 | - { |
|
21 | - $this->getDatabase(); |
|
19 | + public function executeApiAction() |
|
20 | + { |
|
21 | + $this->getDatabase(); |
|
22 | 22 | |
23 | - $userSearchHelper = UserSearchHelper::get($this->getDatabase()); |
|
23 | + $userSearchHelper = UserSearchHelper::get($this->getDatabase()); |
|
24 | 24 | |
25 | - if (WebRequest::getString('all') === null) { |
|
26 | - $userSearchHelper->byStatus(User::STATUS_ACTIVE); |
|
25 | + if (WebRequest::getString('all') === null) { |
|
26 | + $userSearchHelper->byStatus(User::STATUS_ACTIVE); |
|
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - $dataset = $userSearchHelper->fetchColumn('username'); |
|
31 | - return $dataset; |
|
32 | - } |
|
30 | + $dataset = $userSearchHelper->fetchColumn('username'); |
|
31 | + return $dataset; |
|
32 | + } |
|
33 | 33 | } |
@@ -23,65 +23,65 @@ |
||
23 | 23 | */ |
24 | 24 | class MonitorAction extends XmlApiPageBase implements IXmlApiAction |
25 | 25 | { |
26 | - /** |
|
27 | - * @param DOMElement $apiDocument |
|
28 | - * |
|
29 | - * @return DOMElement |
|
30 | - */ |
|
31 | - public function executeApiAction(DOMElement $apiDocument) |
|
32 | - { |
|
33 | - $now = new DateTime(); |
|
26 | + /** |
|
27 | + * @param DOMElement $apiDocument |
|
28 | + * |
|
29 | + * @return DOMElement |
|
30 | + */ |
|
31 | + public function executeApiAction(DOMElement $apiDocument) |
|
32 | + { |
|
33 | + $now = new DateTime(); |
|
34 | 34 | |
35 | - $old = $this->getOldest(); |
|
36 | - $oldest = new DateTime($old); |
|
35 | + $old = $this->getOldest(); |
|
36 | + $oldest = new DateTime($old); |
|
37 | 37 | |
38 | - $new = $this->getNewest(); |
|
39 | - $newest = new DateTime($new); |
|
38 | + $new = $this->getNewest(); |
|
39 | + $newest = new DateTime($new); |
|
40 | 40 | |
41 | - $monitoringElement = $this->document->createElement("data"); |
|
42 | - $monitoringElement->setAttribute("date", $now->format('c')); |
|
43 | - $monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c')); |
|
44 | - $monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c')); |
|
45 | - $apiDocument->appendChild($monitoringElement); |
|
41 | + $monitoringElement = $this->document->createElement("data"); |
|
42 | + $monitoringElement->setAttribute("date", $now->format('c')); |
|
43 | + $monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c')); |
|
44 | + $monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c')); |
|
45 | + $apiDocument->appendChild($monitoringElement); |
|
46 | 46 | |
47 | - return $apiDocument; |
|
48 | - } |
|
47 | + return $apiDocument; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string|null |
|
52 | - */ |
|
53 | - private function getOldest() |
|
54 | - { |
|
55 | - $statement = $this->getDatabase() |
|
56 | - ->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
57 | - $successful = $statement->execute(array( |
|
58 | - ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
59 | - ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
60 | - )); |
|
50 | + /** |
|
51 | + * @return string|null |
|
52 | + */ |
|
53 | + private function getOldest() |
|
54 | + { |
|
55 | + $statement = $this->getDatabase() |
|
56 | + ->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
57 | + $successful = $statement->execute(array( |
|
58 | + ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
59 | + ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
60 | + )); |
|
61 | 61 | |
62 | - if (!$successful) { |
|
63 | - return null; |
|
64 | - } |
|
62 | + if (!$successful) { |
|
63 | + return null; |
|
64 | + } |
|
65 | 65 | |
66 | - $result = $statement->fetchColumn(); |
|
66 | + $result = $statement->fetchColumn(); |
|
67 | 67 | |
68 | - return $result; |
|
69 | - } |
|
68 | + return $result; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function getNewest() |
|
75 | - { |
|
76 | - $statement = $this->getDatabase() |
|
77 | - ->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
78 | - $statement->execute(array( |
|
79 | - ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
80 | - ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
81 | - )); |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function getNewest() |
|
75 | + { |
|
76 | + $statement = $this->getDatabase() |
|
77 | + ->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
78 | + $statement->execute(array( |
|
79 | + ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
80 | + ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
81 | + )); |
|
82 | 82 | |
83 | - $result = $statement->fetchColumn(0); |
|
83 | + $result = $statement->fetchColumn(0); |
|
84 | 84 | |
85 | - return $result; |
|
86 | - } |
|
85 | + return $result; |
|
86 | + } |
|
87 | 87 | } |
@@ -17,67 +17,67 @@ |
||
17 | 17 | */ |
18 | 18 | class StatusAction extends XmlApiPageBase implements IXmlApiAction |
19 | 19 | { |
20 | - public function executeApiAction(DOMElement $apiDocument) |
|
21 | - { |
|
22 | - $statusElement = $this->document->createElement("status"); |
|
23 | - $apiDocument->appendChild($statusElement); |
|
20 | + public function executeApiAction(DOMElement $apiDocument) |
|
21 | + { |
|
22 | + $statusElement = $this->document->createElement("status"); |
|
23 | + $apiDocument->appendChild($statusElement); |
|
24 | 24 | |
25 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
25 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
26 | 26 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
27 | 27 | FROM request |
28 | 28 | WHERE |
29 | 29 | status = :pstatus |
30 | 30 | AND emailconfirm = 'Confirmed'; |
31 | 31 | SQL |
32 | - ); |
|
32 | + ); |
|
33 | 33 | |
34 | - $availableRequestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
34 | + $availableRequestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
35 | 35 | |
36 | - foreach ($availableRequestStates as $key => $value) { |
|
37 | - $query->bindValue(":pstatus", $key); |
|
38 | - $query->execute(); |
|
39 | - $sus = $query->fetchColumn(); |
|
40 | - $statusElement->setAttribute($value['api'], $sus); |
|
41 | - $query->closeCursor(); |
|
42 | - } |
|
36 | + foreach ($availableRequestStates as $key => $value) { |
|
37 | + $query->bindValue(":pstatus", $key); |
|
38 | + $query->execute(); |
|
39 | + $sus = $query->fetchColumn(); |
|
40 | + $statusElement->setAttribute($value['api'], $sus); |
|
41 | + $query->closeCursor(); |
|
42 | + } |
|
43 | 43 | |
44 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
44 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
45 | 45 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
46 | 46 | FROM ban |
47 | 47 | WHERE |
48 | 48 | (duration > UNIX_TIMESTAMP() OR duration = -1) |
49 | 49 | AND active = 1; |
50 | 50 | SQL |
51 | - ); |
|
51 | + ); |
|
52 | 52 | |
53 | - $query->execute(); |
|
54 | - $sus = $query->fetchColumn(); |
|
55 | - $statusElement->setAttribute("bans", $sus); |
|
56 | - $query->closeCursor(); |
|
53 | + $query->execute(); |
|
54 | + $sus = $query->fetchColumn(); |
|
55 | + $statusElement->setAttribute("bans", $sus); |
|
56 | + $query->closeCursor(); |
|
57 | 57 | |
58 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
58 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
59 | 59 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
60 | 60 | FROM user WHERE status = :ulevel; |
61 | 61 | SQL |
62 | - ); |
|
63 | - $query->bindValue(":ulevel", "Admin"); |
|
64 | - $query->execute(); |
|
65 | - $sus = $query->fetchColumn(); |
|
66 | - $statusElement->setAttribute("useradmin", $sus); |
|
67 | - $query->closeCursor(); |
|
62 | + ); |
|
63 | + $query->bindValue(":ulevel", "Admin"); |
|
64 | + $query->execute(); |
|
65 | + $sus = $query->fetchColumn(); |
|
66 | + $statusElement->setAttribute("useradmin", $sus); |
|
67 | + $query->closeCursor(); |
|
68 | 68 | |
69 | - $query->bindValue(":ulevel", "User"); |
|
70 | - $query->execute(); |
|
71 | - $sus = $query->fetchColumn(); |
|
72 | - $statusElement->setAttribute("user", $sus); |
|
73 | - $query->closeCursor(); |
|
69 | + $query->bindValue(":ulevel", "User"); |
|
70 | + $query->execute(); |
|
71 | + $sus = $query->fetchColumn(); |
|
72 | + $statusElement->setAttribute("user", $sus); |
|
73 | + $query->closeCursor(); |
|
74 | 74 | |
75 | - $query->bindValue(":ulevel", "New"); |
|
76 | - $query->execute(); |
|
77 | - $sus = $query->fetchColumn(); |
|
78 | - $statusElement->setAttribute("usernew", $sus); |
|
79 | - $query->closeCursor(); |
|
75 | + $query->bindValue(":ulevel", "New"); |
|
76 | + $query->execute(); |
|
77 | + $sus = $query->fetchColumn(); |
|
78 | + $statusElement->setAttribute("usernew", $sus); |
|
79 | + $query->closeCursor(); |
|
80 | 80 | |
81 | - return $apiDocument; |
|
82 | - } |
|
81 | + return $apiDocument; |
|
82 | + } |
|
83 | 83 | } |
@@ -15,8 +15,8 @@ |
||
15 | 15 | */ |
16 | 16 | interface IApiAction extends IRoutedTask |
17 | 17 | { |
18 | - /** |
|
19 | - * @return string the XML, or false if an error occurred. |
|
20 | - */ |
|
21 | - public function runApiPage(); |
|
18 | + /** |
|
19 | + * @return string the XML, or false if an error occurred. |
|
20 | + */ |
|
21 | + public function runApiPage(); |
|
22 | 22 | } |
@@ -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 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | $dataList = ''; |
24 | 24 | foreach ($generator() as $dataItem) { |
25 | - $dataList .= '"' . htmlentities($dataItem) . '", '; |
|
25 | + $dataList .= '"'.htmlentities($dataItem).'", '; |
|
26 | 26 | } |
27 | - $dataList = "[" . rtrim($dataList, ", ") . "]"; |
|
27 | + $dataList = "[".rtrim($dataList, ", ")."]"; |
|
28 | 28 | |
29 | 29 | $script = <<<JS |
30 | 30 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | foreach ($this->definedClasses as $class => $js) { |
57 | - $jsBlocks = $js . "\r\n\r\n"; |
|
57 | + $jsBlocks = $js."\r\n\r\n"; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $data = <<<HTML |