Completed
Push — bootstrap4 ( 27a441...7cff64 )
by Simon
05:47
created
includes/Offline.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
  */
17 17
 class Offline
18 18
 {
19
-    /**
20
-     * Determines if the tool is offline
21
-     * @return bool
22
-     */
23
-    public static function isOffline()
24
-    {
25
-        global $dontUseDb;
19
+	/**
20
+	 * Determines if the tool is offline
21
+	 * @return bool
22
+	 */
23
+	public static function isOffline()
24
+	{
25
+		global $dontUseDb;
26 26
 
27
-        return (bool)$dontUseDb;
28
-    }
27
+		return (bool)$dontUseDb;
28
+	}
29 29
 
30
-    /**
31
-     * Gets the offline message
32
-     *
33
-     * @param bool $external
34
-     * @param null $message
35
-     *
36
-     * @return string
37
-     */
38
-    public static function getOfflineMessage($external, $message = null)
39
-    {
40
-        global $dontUseDbCulprit, $dontUseDbReason, $baseurl;
30
+	/**
31
+	 * Gets the offline message
32
+	 *
33
+	 * @param bool $external
34
+	 * @param null $message
35
+	 *
36
+	 * @return string
37
+	 */
38
+	public static function getOfflineMessage($external, $message = null)
39
+	{
40
+		global $dontUseDbCulprit, $dontUseDbReason, $baseurl;
41 41
 
42
-        $smarty = new Smarty();
43
-        $smarty->assign("baseurl", $baseurl);
44
-        $smarty->assign("alerts", []);
45
-        $smarty->assign("toolversion", Environment::getToolVersion());
42
+		$smarty = new Smarty();
43
+		$smarty->assign("baseurl", $baseurl);
44
+		$smarty->assign("alerts", []);
45
+		$smarty->assign("toolversion", Environment::getToolVersion());
46 46
 
47
-        if (!headers_sent()) {
48
-            header("HTTP/1.1 503 Service Unavailable");
49
-        }
47
+		if (!headers_sent()) {
48
+			header("HTTP/1.1 503 Service Unavailable");
49
+		}
50 50
 
51
-        if ($external) {
52
-            return $smarty->fetch("offline/external.tpl");
53
-        }
54
-        else {
55
-            $hideCulprit = true;
51
+		if ($external) {
52
+			return $smarty->fetch("offline/external.tpl");
53
+		}
54
+		else {
55
+			$hideCulprit = true;
56 56
 
57
-            // Use the provided message if possible
58
-            if ($message === null) {
59
-                $hideCulprit = false;
60
-                $message = $dontUseDbReason;
61
-            }
57
+			// Use the provided message if possible
58
+			if ($message === null) {
59
+				$hideCulprit = false;
60
+				$message = $dontUseDbReason;
61
+			}
62 62
 
63
-            $smarty->assign("hideCulprit", $hideCulprit);
64
-            $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
65
-            $smarty->assign("dontUseDbReason", $message);
66
-            $smarty->assign("alerts", array());
67
-            $smarty->assign('currentUser', User::getCommunity());
63
+			$smarty->assign("hideCulprit", $hideCulprit);
64
+			$smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
65
+			$smarty->assign("dontUseDbReason", $message);
66
+			$smarty->assign("alerts", array());
67
+			$smarty->assign('currentUser', User::getCommunity());
68 68
 
69
-            return $smarty->fetch("offline/internal.tpl");
70
-        }
71
-    }
69
+			return $smarty->fetch("offline/internal.tpl");
70
+		}
71
+	}
72 72
 }
Please login to merge, or discard this patch.
includes/Pages/PageEmailManagement.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -19,179 +19,179 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.