Passed
Push — dependabot/composer/newinterna... ( 13eb18 )
by
unknown
04:37
created
includes/Session.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
  */
18 18
 class Session
19 19
 {
20
-    public static function start()
21
-    {
22
-        ini_set('session.cookie_httponly', 1);
20
+	public static function start()
21
+	{
22
+		ini_set('session.cookie_httponly', 1);
23 23
 
24
-        if (WebRequest::isHttps()) {
25
-            ini_set('session.cookie_secure', 1);
26
-        }
24
+		if (WebRequest::isHttps()) {
25
+			ini_set('session.cookie_secure', 1);
26
+		}
27 27
 
28
-        session_start();
29
-    }
28
+		session_start();
29
+	}
30 30
 
31
-    public static function destroy()
32
-    {
33
-        session_destroy();
34
-    }
31
+	public static function destroy()
32
+	{
33
+		session_destroy();
34
+	}
35 35
 
36
-    public static function restart()
37
-    {
38
-        self::destroy();
39
-        self::start();
40
-    }
36
+	public static function restart()
37
+	{
38
+		self::destroy();
39
+		self::start();
40
+	}
41 41
 }
Please login to merge, or discard this patch.
includes/Helpers/DebugHelper.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,53 +13,53 @@
 block discarded – undo
13 13
  */
14 14
 class DebugHelper
15 15
 {
16
-    /**
17
-     * Internal mockable method wrapper for debug_backtrace.
18
-     *
19
-     * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive
20
-     * cascade until the runtime explodes.
21
-     *
22
-     * Instead, we mock this method, which allows debug_backtrace to still be called correctly.
23
-     *
24
-     * @return array
25
-     */
26
-    public function get_debug_backtrace()
27
-    {
28
-        return debug_backtrace();
29
-    }
16
+	/**
17
+	 * Internal mockable method wrapper for debug_backtrace.
18
+	 *
19
+	 * As mocking out debug_backtrace uses debug_backtrace internally, we need this in order to not cause a recursive
20
+	 * cascade until the runtime explodes.
21
+	 *
22
+	 * Instead, we mock this method, which allows debug_backtrace to still be called correctly.
23
+	 *
24
+	 * @return array
25
+	 */
26
+	public function get_debug_backtrace()
27
+	{
28
+		return debug_backtrace();
29
+	}
30 30
 
31
-    /**
32
-     * Returns a string representation of the current backtrace for display.
33
-     *
34
-     * Note that this explicitly excludes the top two frames, which will be methods from this class.
35
-     *
36
-     * @return string
37
-     */
38
-    public function getBacktrace()
39
-    {
40
-        $backtrace = $this->get_debug_backtrace();
31
+	/**
32
+	 * Returns a string representation of the current backtrace for display.
33
+	 *
34
+	 * Note that this explicitly excludes the top two frames, which will be methods from this class.
35
+	 *
36
+	 * @return string
37
+	 */
38
+	public function getBacktrace()
39
+	{
40
+		$backtrace = $this->get_debug_backtrace();
41 41
 
42
-        $output = "";
42
+		$output = "";
43 43
 
44
-        $count = 0;
45
-        foreach ($backtrace as $line) {
46
-            if ($count <= 1) {
47
-                $count++;
48
-                continue;
49
-            }
44
+		$count = 0;
45
+		foreach ($backtrace as $line) {
46
+			if ($count <= 1) {
47
+				$count++;
48
+				continue;
49
+			}
50 50
 
51
-            $output .= "#{$count}: ";
51
+			$output .= "#{$count}: ";
52 52
 
53
-            if (isset($line['type']) && $line['type'] != "") {
54
-                $output .= $line['class'] . $line['type'];
55
-            }
53
+			if (isset($line['type']) && $line['type'] != "") {
54
+				$output .= $line['class'] . $line['type'];
55
+			}
56 56
 
57
-            $output .= $line['function'] . "(...)";
58
-            $output .= " [{$line['file']}#{$line['line']}\r\n";
57
+			$output .= $line['function'] . "(...)";
58
+			$output .= " [{$line['file']}#{$line['line']}\r\n";
59 59
 
60
-            $count++;
61
-        }
60
+			$count++;
61
+		}
62 62
 
63
-        return $output;
64
-    }
63
+		return $output;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
includes/Helpers/FakeBlacklistHelper.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 
13 13
 class FakeBlacklistHelper implements IBlacklistHelper
14 14
 {
15
-    /**
16
-     * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist
17
-     *
18
-     * @param string $username
19
-     *
20
-     * @return bool
21
-     */
22
-    public function isBlacklisted($username)
23
-    {
24
-        // Short-circuit
25
-        return false;
26
-    }
15
+	/**
16
+	 * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist
17
+	 *
18
+	 * @param string $username
19
+	 *
20
+	 * @return bool
21
+	 */
22
+	public function isBlacklisted($username)
23
+	{
24
+		// Short-circuit
25
+		return false;
26
+	}
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Helpers/BanHelper.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,49 +14,49 @@
 block discarded – undo
14 14
 
15 15
 class BanHelper implements IBanHelper
16 16
 {
17
-    /**
18
-     * @var PdoDatabase
19
-     */
20
-    private $database;
17
+	/**
18
+	 * @var PdoDatabase
19
+	 */
20
+	private $database;
21 21
 
22
-    public function __construct(PdoDatabase $database)
23
-    {
24
-        $this->database = $database;
25
-    }
22
+	public function __construct(PdoDatabase $database)
23
+	{
24
+		$this->database = $database;
25
+	}
26 26
 
27
-    /**
28
-     * Summary of nameIsBanned
29
-     *
30
-     * @param string $name The name to test if is banned.
31
-     *
32
-     * @return Ban
33
-     */
34
-    public function nameIsBanned($name)
35
-    {
36
-        return Ban::getBanByTarget($name, "Name", $this->database);
37
-    }
27
+	/**
28
+	 * Summary of nameIsBanned
29
+	 *
30
+	 * @param string $name The name to test if is banned.
31
+	 *
32
+	 * @return Ban
33
+	 */
34
+	public function nameIsBanned($name)
35
+	{
36
+		return Ban::getBanByTarget($name, "Name", $this->database);
37
+	}
38 38
 
39
-    /**
40
-     * Summary of emailIsBanned
41
-     *
42
-     * @param string $email
43
-     *
44
-     * @return Ban
45
-     */
46
-    public function emailIsBanned($email)
47
-    {
48
-        return Ban::getBanByTarget($email, "EMail", $this->database);
49
-    }
39
+	/**
40
+	 * Summary of emailIsBanned
41
+	 *
42
+	 * @param string $email
43
+	 *
44
+	 * @return Ban
45
+	 */
46
+	public function emailIsBanned($email)
47
+	{
48
+		return Ban::getBanByTarget($email, "EMail", $this->database);
49
+	}
50 50
 
51
-    /**
52
-     * Summary of ipIsBanned
53
-     *
54
-     * @param string $ip
55
-     *
56
-     * @return Ban
57
-     */
58
-    public function ipIsBanned($ip)
59
-    {
60
-        return Ban::getBanByTarget($ip, "IP", $this->database);
61
-    }
51
+	/**
52
+	 * Summary of ipIsBanned
53
+	 *
54
+	 * @param string $ip
55
+	 *
56
+	 * @return Ban
57
+	 */
58
+	public function ipIsBanned($ip)
59
+	{
60
+		return Ban::getBanByTarget($ip, "IP", $this->database);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
includes/Helpers/LogHelper.php 2 patches
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -26,366 +26,366 @@
 block discarded – undo
26 26
 
27 27
 class LogHelper
28 28
 {
29
-    /**
30
-     * Summary of getRequestLogsWithComments
31
-     *
32
-     * @param int             $requestId
33
-     * @param PdoDatabase     $db
34
-     * @param SecurityManager $securityManager
35
-     *
36
-     * @return \Waca\DataObject[]
37
-     */
38
-    public static function getRequestLogsWithComments($requestId, PdoDatabase $db, SecurityManager $securityManager)
39
-    {
40
-        $logs = LogSearchHelper::get($db)->byObjectType('Request')->byObjectId($requestId)->fetch();
41
-
42
-        $currentUser = User::getCurrent($db);
43
-        $securityResult = $securityManager->allows('RequestData', 'seeRestrictedComments', $currentUser);
44
-        $showAllComments = $securityResult === SecurityManager::ALLOWED;
45
-
46
-        $comments = Comment::getForRequest($requestId, $db, $showAllComments, $currentUser->getId());
47
-
48
-        $items = array_merge($logs, $comments);
49
-
50
-        /**
51
-         * @param DataObject $item
52
-         *
53
-         * @return int
54
-         */
55
-        $sortKey = function(DataObject $item) {
56
-            if ($item instanceof Log) {
57
-                return $item->getTimestamp()->getTimestamp();
58
-            }
59
-
60
-            if ($item instanceof Comment) {
61
-                return $item->getTime()->getTimestamp();
62
-            }
63
-
64
-            return 0;
65
-        };
66
-
67
-        do {
68
-            $flag = false;
69
-
70
-            $loopLimit = (count($items) - 1);
71
-            for ($i = 0; $i < $loopLimit; $i++) {
72
-                // are these two items out of order?
73
-                if ($sortKey($items[$i]) > $sortKey($items[$i + 1])) {
74
-                    // swap them
75
-                    $swap = $items[$i];
76
-                    $items[$i] = $items[$i + 1];
77
-                    $items[$i + 1] = $swap;
78
-
79
-                    // set a flag to say we've modified the array this time around
80
-                    $flag = true;
81
-                }
82
-            }
83
-        }
84
-        while ($flag);
85
-
86
-        return $items;
87
-    }
88
-
89
-    /**
90
-     * Summary of getLogDescription
91
-     *
92
-     * @param Log $entry
93
-     *
94
-     * @return string
95
-     */
96
-    public static function getLogDescription(Log $entry)
97
-    {
98
-        $text = "Deferred to ";
99
-        if (substr($entry->getAction(), 0, strlen($text)) == $text) {
100
-            // Deferred to a different queue
101
-            // This is exactly what we want to display.
102
-            return $entry->getAction();
103
-        }
104
-
105
-        $text = "Closed custom-n";
106
-        if ($entry->getAction() == $text) {
107
-            // Custom-closed
108
-            return "closed (custom reason - account not created)";
109
-        }
110
-
111
-        $text = "Closed custom-y";
112
-        if ($entry->getAction() == $text) {
113
-            // Custom-closed
114
-            return "closed (custom reason - account created)";
115
-        }
116
-
117
-        $text = "Closed 0";
118
-        if ($entry->getAction() == $text) {
119
-            // Dropped the request - short-circuit the lookup
120
-            return "dropped request";
121
-        }
122
-
123
-        $text = "Closed ";
124
-        if (substr($entry->getAction(), 0, strlen($text)) == $text) {
125
-            // Closed with a reason - do a lookup here.
126
-            $id = substr($entry->getAction(), strlen($text));
127
-            /** @var EmailTemplate $template */
128
-            $template = EmailTemplate::getById((int)$id, $entry->getDatabase());
129
-
130
-            if ($template != false) {
131
-                return "closed (" . $template->getName() . ")";
132
-            }
133
-        }
134
-
135
-        // Fall back to the basic stuff
136
-        $lookup = array(
137
-            'Reserved'        => 'reserved',
138
-            'Email Confirmed' => 'email-confirmed',
139
-            'Unreserved'      => 'unreserved',
140
-            'Approved'        => 'approved',
141
-            'Suspended'       => 'suspended',
142
-            'RoleChange'      => 'changed roles',
143
-            'Banned'          => 'banned',
144
-            'Edited'          => 'edited interface message',
145
-            'Declined'        => 'declined',
146
-            'EditComment-c'   => 'edited a comment',
147
-            'EditComment-r'   => 'edited a comment',
148
-            'Unbanned'        => 'unbanned',
149
-            'Promoted'        => 'promoted to tool admin',
150
-            'BreakReserve'    => 'forcibly broke the reservation',
151
-            'Prefchange'      => 'changed user preferences',
152
-            'Renamed'         => 'renamed',
153
-            'Demoted'         => 'demoted from tool admin',
154
-            'ReceiveReserved' => 'received the reservation',
155
-            'SendReserved'    => 'sent the reservation',
156
-            'EditedEmail'     => 'edited email',
157
-            'DeletedTemplate' => 'deleted template',
158
-            'EditedTemplate'  => 'edited template',
159
-            'CreatedEmail'    => 'created email',
160
-            'CreatedTemplate' => 'created template',
161
-            'SentMail'        => 'sent an email to the requestor',
162
-            'Registered'      => 'registered a tool account',
163
-        );
164
-
165
-        if (array_key_exists($entry->getAction(), $lookup)) {
166
-            return $lookup[$entry->getAction()];
167
-        }
168
-
169
-        // OK, I don't know what this is. Fall back to something sane.
170
-        return "performed an unknown action ({$entry->getAction()})";
171
-    }
172
-
173
-    /**
174
-     * @param PdoDatabase $database
175
-     *
176
-     * @return array
177
-     */
178
-    public static function getLogActions(PdoDatabase $database)
179
-    {
180
-        $lookup = array(
181
-            'Reserved'        => 'reserved',
182
-            'Email Confirmed' => 'email-confirmed',
183
-            'Unreserved'      => 'unreserved',
184
-            'Approved'        => 'approved',
185
-            'Suspended'       => 'suspended',
186
-            'RoleChange'      => 'changed roles',
187
-            'Banned'          => 'banned',
188
-            'Edited'          => 'edited interface message',
189
-            'Declined'        => 'declined',
190
-            'EditComment-c'   => 'edited a comment (by comment ID)',
191
-            'EditComment-r'   => 'edited a comment (by request)',
192
-            'Unbanned'        => 'unbanned',
193
-            'Promoted'        => 'promoted to tool admin',
194
-            'BreakReserve'    => 'forcibly broke the reservation',
195
-            'Prefchange'      => 'changed user preferences',
196
-            'Renamed'         => 'renamed',
197
-            'Demoted'         => 'demoted from tool admin',
198
-            'ReceiveReserved' => 'received the reservation',
199
-            'SendReserved'    => 'sent the reservation',
200
-            'EditedEmail'     => 'edited email',
201
-            'DeletedTemplate' => 'deleted template',
202
-            'EditedTemplate'  => 'edited template',
203
-            'CreatedEmail'    => 'created email',
204
-            'CreatedTemplate' => 'created template',
205
-            'SentMail'        => 'sent an email to the requestor',
206
-            'Registered'      => 'registered a tool account',
207
-            'Closed 0'        => 'dropped request',
208
-        );
209
-
210
-        $statement = $database->query(<<<SQL
29
+	/**
30
+	 * Summary of getRequestLogsWithComments
31
+	 *
32
+	 * @param int             $requestId
33
+	 * @param PdoDatabase     $db
34
+	 * @param SecurityManager $securityManager
35
+	 *
36
+	 * @return \Waca\DataObject[]
37
+	 */
38
+	public static function getRequestLogsWithComments($requestId, PdoDatabase $db, SecurityManager $securityManager)
39
+	{
40
+		$logs = LogSearchHelper::get($db)->byObjectType('Request')->byObjectId($requestId)->fetch();
41
+
42
+		$currentUser = User::getCurrent($db);
43
+		$securityResult = $securityManager->allows('RequestData', 'seeRestrictedComments', $currentUser);
44
+		$showAllComments = $securityResult === SecurityManager::ALLOWED;
45
+
46
+		$comments = Comment::getForRequest($requestId, $db, $showAllComments, $currentUser->getId());
47
+
48
+		$items = array_merge($logs, $comments);
49
+
50
+		/**
51
+		 * @param DataObject $item
52
+		 *
53
+		 * @return int
54
+		 */
55
+		$sortKey = function(DataObject $item) {
56
+			if ($item instanceof Log) {
57
+				return $item->getTimestamp()->getTimestamp();
58
+			}
59
+
60
+			if ($item instanceof Comment) {
61
+				return $item->getTime()->getTimestamp();
62
+			}
63
+
64
+			return 0;
65
+		};
66
+
67
+		do {
68
+			$flag = false;
69
+
70
+			$loopLimit = (count($items) - 1);
71
+			for ($i = 0; $i < $loopLimit; $i++) {
72
+				// are these two items out of order?
73
+				if ($sortKey($items[$i]) > $sortKey($items[$i + 1])) {
74
+					// swap them
75
+					$swap = $items[$i];
76
+					$items[$i] = $items[$i + 1];
77
+					$items[$i + 1] = $swap;
78
+
79
+					// set a flag to say we've modified the array this time around
80
+					$flag = true;
81
+				}
82
+			}
83
+		}
84
+		while ($flag);
85
+
86
+		return $items;
87
+	}
88
+
89
+	/**
90
+	 * Summary of getLogDescription
91
+	 *
92
+	 * @param Log $entry
93
+	 *
94
+	 * @return string
95
+	 */
96
+	public static function getLogDescription(Log $entry)
97
+	{
98
+		$text = "Deferred to ";
99
+		if (substr($entry->getAction(), 0, strlen($text)) == $text) {
100
+			// Deferred to a different queue
101
+			// This is exactly what we want to display.
102
+			return $entry->getAction();
103
+		}
104
+
105
+		$text = "Closed custom-n";
106
+		if ($entry->getAction() == $text) {
107
+			// Custom-closed
108
+			return "closed (custom reason - account not created)";
109
+		}
110
+
111
+		$text = "Closed custom-y";
112
+		if ($entry->getAction() == $text) {
113
+			// Custom-closed
114
+			return "closed (custom reason - account created)";
115
+		}
116
+
117
+		$text = "Closed 0";
118
+		if ($entry->getAction() == $text) {
119
+			// Dropped the request - short-circuit the lookup
120
+			return "dropped request";
121
+		}
122
+
123
+		$text = "Closed ";
124
+		if (substr($entry->getAction(), 0, strlen($text)) == $text) {
125
+			// Closed with a reason - do a lookup here.
126
+			$id = substr($entry->getAction(), strlen($text));
127
+			/** @var EmailTemplate $template */
128
+			$template = EmailTemplate::getById((int)$id, $entry->getDatabase());
129
+
130
+			if ($template != false) {
131
+				return "closed (" . $template->getName() . ")";
132
+			}
133
+		}
134
+
135
+		// Fall back to the basic stuff
136
+		$lookup = array(
137
+			'Reserved'        => 'reserved',
138
+			'Email Confirmed' => 'email-confirmed',
139
+			'Unreserved'      => 'unreserved',
140
+			'Approved'        => 'approved',
141
+			'Suspended'       => 'suspended',
142
+			'RoleChange'      => 'changed roles',
143
+			'Banned'          => 'banned',
144
+			'Edited'          => 'edited interface message',
145
+			'Declined'        => 'declined',
146
+			'EditComment-c'   => 'edited a comment',
147
+			'EditComment-r'   => 'edited a comment',
148
+			'Unbanned'        => 'unbanned',
149
+			'Promoted'        => 'promoted to tool admin',
150
+			'BreakReserve'    => 'forcibly broke the reservation',
151
+			'Prefchange'      => 'changed user preferences',
152
+			'Renamed'         => 'renamed',
153
+			'Demoted'         => 'demoted from tool admin',
154
+			'ReceiveReserved' => 'received the reservation',
155
+			'SendReserved'    => 'sent the reservation',
156
+			'EditedEmail'     => 'edited email',
157
+			'DeletedTemplate' => 'deleted template',
158
+			'EditedTemplate'  => 'edited template',
159
+			'CreatedEmail'    => 'created email',
160
+			'CreatedTemplate' => 'created template',
161
+			'SentMail'        => 'sent an email to the requestor',
162
+			'Registered'      => 'registered a tool account',
163
+		);
164
+
165
+		if (array_key_exists($entry->getAction(), $lookup)) {
166
+			return $lookup[$entry->getAction()];
167
+		}
168
+
169
+		// OK, I don't know what this is. Fall back to something sane.
170
+		return "performed an unknown action ({$entry->getAction()})";
171
+	}
172
+
173
+	/**
174
+	 * @param PdoDatabase $database
175
+	 *
176
+	 * @return array
177
+	 */
178
+	public static function getLogActions(PdoDatabase $database)
179
+	{
180
+		$lookup = array(
181
+			'Reserved'        => 'reserved',
182
+			'Email Confirmed' => 'email-confirmed',
183
+			'Unreserved'      => 'unreserved',
184
+			'Approved'        => 'approved',
185
+			'Suspended'       => 'suspended',
186
+			'RoleChange'      => 'changed roles',
187
+			'Banned'          => 'banned',
188
+			'Edited'          => 'edited interface message',
189
+			'Declined'        => 'declined',
190
+			'EditComment-c'   => 'edited a comment (by comment ID)',
191
+			'EditComment-r'   => 'edited a comment (by request)',
192
+			'Unbanned'        => 'unbanned',
193
+			'Promoted'        => 'promoted to tool admin',
194
+			'BreakReserve'    => 'forcibly broke the reservation',
195
+			'Prefchange'      => 'changed user preferences',
196
+			'Renamed'         => 'renamed',
197
+			'Demoted'         => 'demoted from tool admin',
198
+			'ReceiveReserved' => 'received the reservation',
199
+			'SendReserved'    => 'sent the reservation',
200
+			'EditedEmail'     => 'edited email',
201
+			'DeletedTemplate' => 'deleted template',
202
+			'EditedTemplate'  => 'edited template',
203
+			'CreatedEmail'    => 'created email',
204
+			'CreatedTemplate' => 'created template',
205
+			'SentMail'        => 'sent an email to the requestor',
206
+			'Registered'      => 'registered a tool account',
207
+			'Closed 0'        => 'dropped request',
208
+		);
209
+
210
+		$statement = $database->query(<<<SQL
211 211
 SELECT CONCAT('Closed ', id) AS k, CONCAT('closed (',name,')') AS v
212 212
 FROM emailtemplate;
213 213
 SQL
214
-        );
215
-        foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
216
-            $lookup[$row['k']] = $row['v'];
217
-        }
218
-
219
-        return $lookup;
220
-    }
221
-
222
-    public static function getObjectTypes()
223
-    {
224
-        return array(
225
-            'Ban'             => 'Ban',
226
-            'Comment'         => 'Comment',
227
-            'EmailTemplate'   => 'Email template',
228
-            'Request'         => 'Request',
229
-            'SiteNotice'      => 'Site notice',
230
-            'User'            => 'User',
231
-            'WelcomeTemplate' => 'Welcome template',
232
-        );
233
-    }
234
-
235
-    /**
236
-     * This returns a HTML
237
-     *
238
-     * @param string            $objectId
239
-     * @param string            $objectType
240
-     * @param PdoDatabase       $database
241
-     * @param SiteConfiguration $configuration
242
-     *
243
-     * @return null|string
244
-     * @category Security-Critical
245
-     */
246
-    private static function getObjectDescription(
247
-        $objectId,
248
-        $objectType,
249
-        PdoDatabase $database,
250
-        SiteConfiguration $configuration
251
-    ) {
252
-        if ($objectType == '') {
253
-            return null;
254
-        }
255
-
256
-        $baseurl = $configuration->getBaseUrl();
257
-
258
-        switch ($objectType) {
259
-            case 'Ban':
260
-                /** @var Ban $ban */
261
-                $ban = Ban::getById($objectId, $database);
262
-
263
-                if ($ban === false) {
264
-                    return 'Ban #' . $objectId . "</a>";
265
-                }
266
-
267
-                return 'Ban #' . $objectId . " (" . htmlentities($ban->getTarget()) . ")</a>";
268
-            case 'EmailTemplate':
269
-                /** @var EmailTemplate $emailTemplate */
270
-                $emailTemplate = EmailTemplate::getById($objectId, $database);
271
-                $name = htmlentities($emailTemplate->getName(), ENT_COMPAT, 'UTF-8');
272
-
273
-                return <<<HTML
214
+		);
215
+		foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
216
+			$lookup[$row['k']] = $row['v'];
217
+		}
218
+
219
+		return $lookup;
220
+	}
221
+
222
+	public static function getObjectTypes()
223
+	{
224
+		return array(
225
+			'Ban'             => 'Ban',
226
+			'Comment'         => 'Comment',
227
+			'EmailTemplate'   => 'Email template',
228
+			'Request'         => 'Request',
229
+			'SiteNotice'      => 'Site notice',
230
+			'User'            => 'User',
231
+			'WelcomeTemplate' => 'Welcome template',
232
+		);
233
+	}
234
+
235
+	/**
236
+	 * This returns a HTML
237
+	 *
238
+	 * @param string            $objectId
239
+	 * @param string            $objectType
240
+	 * @param PdoDatabase       $database
241
+	 * @param SiteConfiguration $configuration
242
+	 *
243
+	 * @return null|string
244
+	 * @category Security-Critical
245
+	 */
246
+	private static function getObjectDescription(
247
+		$objectId,
248
+		$objectType,
249
+		PdoDatabase $database,
250
+		SiteConfiguration $configuration
251
+	) {
252
+		if ($objectType == '') {
253
+			return null;
254
+		}
255
+
256
+		$baseurl = $configuration->getBaseUrl();
257
+
258
+		switch ($objectType) {
259
+			case 'Ban':
260
+				/** @var Ban $ban */
261
+				$ban = Ban::getById($objectId, $database);
262
+
263
+				if ($ban === false) {
264
+					return 'Ban #' . $objectId . "</a>";
265
+				}
266
+
267
+				return 'Ban #' . $objectId . " (" . htmlentities($ban->getTarget()) . ")</a>";
268
+			case 'EmailTemplate':
269
+				/** @var EmailTemplate $emailTemplate */
270
+				$emailTemplate = EmailTemplate::getById($objectId, $database);
271
+				$name = htmlentities($emailTemplate->getName(), ENT_COMPAT, 'UTF-8');
272
+
273
+				return <<<HTML
274 274
 <a href="{$baseurl}/internal.php/emailManagement/view?id={$objectId}">Email Template #{$objectId} ({$name})</a>
275 275
 HTML;
276
-            case 'SiteNotice':
277
-                return "<a href=\"{$baseurl}/internal.php/siteNotice\">the site notice</a>";
278
-            case 'Request':
279
-                /** @var Request $request */
280
-                $request = Request::getById($objectId, $database);
281
-                $name = htmlentities($request->getName(), ENT_COMPAT, 'UTF-8');
282
-
283
-                return <<<HTML
276
+			case 'SiteNotice':
277
+				return "<a href=\"{$baseurl}/internal.php/siteNotice\">the site notice</a>";
278
+			case 'Request':
279
+				/** @var Request $request */
280
+				$request = Request::getById($objectId, $database);
281
+				$name = htmlentities($request->getName(), ENT_COMPAT, 'UTF-8');
282
+
283
+				return <<<HTML
284 284
 <a href="{$baseurl}/internal.php/viewRequest?id={$objectId}">Request #{$objectId} ({$name})</a>
285 285
 HTML;
286
-            case 'User':
287
-                /** @var User $user */
288
-                $user = User::getById($objectId, $database);
289
-                $username = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8');
290
-
291
-                return "<a href=\"{$baseurl}/internal.php/statistics/users/detail?user={$objectId}\">{$username}</a>";
292
-            case 'WelcomeTemplate':
293
-                /** @var WelcomeTemplate $welcomeTemplate */
294
-                $welcomeTemplate = WelcomeTemplate::getById($objectId, $database);
295
-
296
-                // some old templates have been completely deleted and lost to the depths of time.
297
-                if ($welcomeTemplate === false) {
298
-                    return "Welcome template #{$objectId}";
299
-                }
300
-                else {
301
-                    $userCode = htmlentities($welcomeTemplate->getUserCode(), ENT_COMPAT, 'UTF-8');
302
-
303
-                    return "<a href=\"{$baseurl}/internal.php/welcomeTemplates/view?template={$objectId}\">{$userCode}</a>";
304
-                }
305
-            default:
306
-                return '[' . $objectType . " " . $objectId . ']';
307
-        }
308
-    }
309
-
310
-    /**
311
-     * @param    Log[]          $logs
312
-     * @param     PdoDatabase   $database
313
-     * @param SiteConfiguration $configuration
314
-     *
315
-     * @return array
316
-     * @throws Exception
317
-     */
318
-    public static function prepareLogsForTemplate($logs, PdoDatabase $database, SiteConfiguration $configuration)
319
-    {
320
-        $userIds = array();
321
-
322
-        /** @var Log $logEntry */
323
-        foreach ($logs as $logEntry) {
324
-            if (!$logEntry instanceof Log) {
325
-                // if this happens, we've done something wrong with passing back the log data.
326
-                throw new Exception('Log entry is not an instance of a Log, this should never happen.');
327
-            }
328
-
329
-            $user = $logEntry->getUser();
330
-            if ($user === -1) {
331
-                continue;
332
-            }
333
-
334
-            if (!array_search($user, $userIds)) {
335
-                $userIds[] = $user;
336
-            }
337
-        }
338
-
339
-        $users = UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username');
340
-        $users[-1] = User::getCommunity()->getUsername();
341
-
342
-        $logData = array();
343
-
344
-        /** @var Log $logEntry */
345
-        foreach ($logs as $logEntry) {
346
-            $objectDescription = self::getObjectDescription($logEntry->getObjectId(), $logEntry->getObjectType(),
347
-                $database, $configuration);
348
-
349
-            switch ($logEntry->getAction()) {
350
-                case 'Renamed':
351
-                    $renameData = unserialize($logEntry->getComment());
352
-                    $oldName = htmlentities($renameData['old'], ENT_COMPAT, 'UTF-8');
353
-                    $newName = htmlentities($renameData['new'], ENT_COMPAT, 'UTF-8');
354
-                    $comment = 'Renamed \'' . $oldName . '\' to \'' . $newName . '\'.';
355
-                    break;
356
-                case 'RoleChange':
357
-                    $roleChangeData = unserialize($logEntry->getComment());
358
-
359
-                    $removed = array();
360
-                    foreach ($roleChangeData['removed'] as $r) {
361
-                        $removed[] = htmlentities($r, ENT_COMPAT, 'UTF-8');
362
-                    }
363
-
364
-                    $added = array();
365
-                    foreach ($roleChangeData['added'] as $r) {
366
-                        $added[] = htmlentities($r, ENT_COMPAT, 'UTF-8');
367
-                    }
368
-
369
-                    $reason = htmlentities($roleChangeData['reason'], ENT_COMPAT, 'UTF-8');
370
-
371
-                    $roleDelta = 'Removed [' . implode(', ', $removed) . '], Added [' . implode(', ', $added) . ']';
372
-                    $comment = $roleDelta . ' with comment: ' . $reason;
373
-                    break;
374
-                default:
375
-                    $comment = $logEntry->getComment();
376
-                    break;
377
-            }
378
-
379
-            $logData[] = array(
380
-                'timestamp'         => $logEntry->getTimestamp(),
381
-                'userid'            => $logEntry->getUser(),
382
-                'username'          => $users[$logEntry->getUser()],
383
-                'description'       => self::getLogDescription($logEntry),
384
-                'objectdescription' => $objectDescription,
385
-                'comment'           => $comment,
386
-            );
387
-        }
388
-
389
-        return array($users, $logData);
390
-    }
286
+			case 'User':
287
+				/** @var User $user */
288
+				$user = User::getById($objectId, $database);
289
+				$username = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8');
290
+
291
+				return "<a href=\"{$baseurl}/internal.php/statistics/users/detail?user={$objectId}\">{$username}</a>";
292
+			case 'WelcomeTemplate':
293
+				/** @var WelcomeTemplate $welcomeTemplate */
294
+				$welcomeTemplate = WelcomeTemplate::getById($objectId, $database);
295
+
296
+				// some old templates have been completely deleted and lost to the depths of time.
297
+				if ($welcomeTemplate === false) {
298
+					return "Welcome template #{$objectId}";
299
+				}
300
+				else {
301
+					$userCode = htmlentities($welcomeTemplate->getUserCode(), ENT_COMPAT, 'UTF-8');
302
+
303
+					return "<a href=\"{$baseurl}/internal.php/welcomeTemplates/view?template={$objectId}\">{$userCode}</a>";
304
+				}
305
+			default:
306
+				return '[' . $objectType . " " . $objectId . ']';
307
+		}
308
+	}
309
+
310
+	/**
311
+	 * @param    Log[]          $logs
312
+	 * @param     PdoDatabase   $database
313
+	 * @param SiteConfiguration $configuration
314
+	 *
315
+	 * @return array
316
+	 * @throws Exception
317
+	 */
318
+	public static function prepareLogsForTemplate($logs, PdoDatabase $database, SiteConfiguration $configuration)
319
+	{
320
+		$userIds = array();
321
+
322
+		/** @var Log $logEntry */
323
+		foreach ($logs as $logEntry) {
324
+			if (!$logEntry instanceof Log) {
325
+				// if this happens, we've done something wrong with passing back the log data.
326
+				throw new Exception('Log entry is not an instance of a Log, this should never happen.');
327
+			}
328
+
329
+			$user = $logEntry->getUser();
330
+			if ($user === -1) {
331
+				continue;
332
+			}
333
+
334
+			if (!array_search($user, $userIds)) {
335
+				$userIds[] = $user;
336
+			}
337
+		}
338
+
339
+		$users = UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username');
340
+		$users[-1] = User::getCommunity()->getUsername();
341
+
342
+		$logData = array();
343
+
344
+		/** @var Log $logEntry */
345
+		foreach ($logs as $logEntry) {
346
+			$objectDescription = self::getObjectDescription($logEntry->getObjectId(), $logEntry->getObjectType(),
347
+				$database, $configuration);
348
+
349
+			switch ($logEntry->getAction()) {
350
+				case 'Renamed':
351
+					$renameData = unserialize($logEntry->getComment());
352
+					$oldName = htmlentities($renameData['old'], ENT_COMPAT, 'UTF-8');
353
+					$newName = htmlentities($renameData['new'], ENT_COMPAT, 'UTF-8');
354
+					$comment = 'Renamed \'' . $oldName . '\' to \'' . $newName . '\'.';
355
+					break;
356
+				case 'RoleChange':
357
+					$roleChangeData = unserialize($logEntry->getComment());
358
+
359
+					$removed = array();
360
+					foreach ($roleChangeData['removed'] as $r) {
361
+						$removed[] = htmlentities($r, ENT_COMPAT, 'UTF-8');
362
+					}
363
+
364
+					$added = array();
365
+					foreach ($roleChangeData['added'] as $r) {
366
+						$added[] = htmlentities($r, ENT_COMPAT, 'UTF-8');
367
+					}
368
+
369
+					$reason = htmlentities($roleChangeData['reason'], ENT_COMPAT, 'UTF-8');
370
+
371
+					$roleDelta = 'Removed [' . implode(', ', $removed) . '], Added [' . implode(', ', $added) . ']';
372
+					$comment = $roleDelta . ' with comment: ' . $reason;
373
+					break;
374
+				default:
375
+					$comment = $logEntry->getComment();
376
+					break;
377
+			}
378
+
379
+			$logData[] = array(
380
+				'timestamp'         => $logEntry->getTimestamp(),
381
+				'userid'            => $logEntry->getUser(),
382
+				'username'          => $users[$logEntry->getUser()],
383
+				'description'       => self::getLogDescription($logEntry),
384
+				'objectdescription' => $objectDescription,
385
+				'comment'           => $comment,
386
+			);
387
+		}
388
+
389
+		return array($users, $logData);
390
+	}
391 391
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,8 @@  discard block
 block discarded – undo
52 52
          *
53 53
          * @return int
54 54
          */
55
-        $sortKey = function(DataObject $item) {
55
+        $sortKey = function(DataObject $item)
56
+        {
56 57
             if ($item instanceof Log) {
57 58
                 return $item->getTimestamp()->getTimestamp();
58 59
             }
@@ -296,8 +297,7 @@  discard block
 block discarded – undo
296 297
                 // some old templates have been completely deleted and lost to the depths of time.
297 298
                 if ($welcomeTemplate === false) {
298 299
                     return "Welcome template #{$objectId}";
299
-                }
300
-                else {
300
+                } else {
301 301
                     $userCode = htmlentities($welcomeTemplate->getUserCode(), ENT_COMPAT, 'UTF-8');
302 302
 
303 303
                     return "<a href=\"{$baseurl}/internal.php/welcomeTemplates/view?template={$objectId}\">{$userCode}</a>";
Please login to merge, or discard this patch.
includes/Helpers/BlacklistHelper.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -13,91 +13,91 @@
 block discarded – undo
13 13
 
14 14
 class BlacklistHelper implements IBlacklistHelper
15 15
 {
16
-    /** @var HttpHelper */
17
-    private $httpHelper;
18
-    /**
19
-     * Cache of previously requested usernames
20
-     * @var array
21
-     */
22
-    private $cache = array();
23
-    /** @var string */
24
-    private $mediawikiWebServiceEndpoint;
16
+	/** @var HttpHelper */
17
+	private $httpHelper;
18
+	/**
19
+	 * Cache of previously requested usernames
20
+	 * @var array
21
+	 */
22
+	private $cache = array();
23
+	/** @var string */
24
+	private $mediawikiWebServiceEndpoint;
25 25
 
26
-    /**
27
-     * BlacklistHelper constructor.
28
-     *
29
-     * @param HttpHelper $httpHelper
30
-     * @param string     $mediawikiWebServiceEndpoint
31
-     */
32
-    public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint)
33
-    {
34
-        $this->httpHelper = $httpHelper;
35
-        $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
36
-    }
26
+	/**
27
+	 * BlacklistHelper constructor.
28
+	 *
29
+	 * @param HttpHelper $httpHelper
30
+	 * @param string     $mediawikiWebServiceEndpoint
31
+	 */
32
+	public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint)
33
+	{
34
+		$this->httpHelper = $httpHelper;
35
+		$this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
36
+	}
37 37
 
38
-    /**
39
-     * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist
40
-     *
41
-     * @param string $username
42
-     *
43
-     * @return false|string False if the username is not blacklisted, else the blacklist entry.
44
-     */
45
-    public function isBlacklisted($username)
46
-    {
47
-        if (isset($this->cache[$username])) {
48
-            $result = $this->cache[$username];
49
-            if ($result === false) {
50
-                return false;
51
-            }
38
+	/**
39
+	 * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist
40
+	 *
41
+	 * @param string $username
42
+	 *
43
+	 * @return false|string False if the username is not blacklisted, else the blacklist entry.
44
+	 */
45
+	public function isBlacklisted($username)
46
+	{
47
+		if (isset($this->cache[$username])) {
48
+			$result = $this->cache[$username];
49
+			if ($result === false) {
50
+				return false;
51
+			}
52 52
 
53
-            return $result['line'];
54
-        }
53
+			return $result['line'];
54
+		}
55 55
 
56
-        try {
57
-            $result = $this->performWikiLookup($username);
58
-        }
59
-        catch (CurlException $ex) {
60
-            // LOGME log this, but fail gracefully.
61
-            return false;
62
-        }
56
+		try {
57
+			$result = $this->performWikiLookup($username);
58
+		}
59
+		catch (CurlException $ex) {
60
+			// LOGME log this, but fail gracefully.
61
+			return false;
62
+		}
63 63
 
64
-        if ($result['result'] === 'ok') {
65
-            // not blacklisted
66
-            $this->cache[$username] = false;
64
+		if ($result['result'] === 'ok') {
65
+			// not blacklisted
66
+			$this->cache[$username] = false;
67 67
 
68
-            return false;
69
-        }
70
-        else {
71
-            $this->cache[$username] = $result;
68
+			return false;
69
+		}
70
+		else {
71
+			$this->cache[$username] = $result;
72 72
 
73
-            return $result['line'];
74
-        }
75
-    }
73
+			return $result['line'];
74
+		}
75
+	}
76 76
 
77
-    /**
78
-     * Performs a fetch to MediaWiki for the relevant title blacklist entry
79
-     *
80
-     * @param string $username The username to look up
81
-     *
82
-     * @return array
83
-     * @throws CurlException
84
-     */
85
-    private function performWikiLookup($username)
86
-    {
87
-        $endpoint = $this->mediawikiWebServiceEndpoint;
77
+	/**
78
+	 * Performs a fetch to MediaWiki for the relevant title blacklist entry
79
+	 *
80
+	 * @param string $username The username to look up
81
+	 *
82
+	 * @return array
83
+	 * @throws CurlException
84
+	 */
85
+	private function performWikiLookup($username)
86
+	{
87
+		$endpoint = $this->mediawikiWebServiceEndpoint;
88 88
 
89
-        $parameters = array(
90
-            'action'       => 'titleblacklist',
91
-            'format'       => 'php',
92
-            'tbtitle'      => $username,
93
-            'tbaction'     => 'new-account',
94
-            'tbnooverride' => true,
95
-        );
89
+		$parameters = array(
90
+			'action'       => 'titleblacklist',
91
+			'format'       => 'php',
92
+			'tbtitle'      => $username,
93
+			'tbaction'     => 'new-account',
94
+			'tbnooverride' => true,
95
+		);
96 96
 
97
-        $apiResult = $this->httpHelper->get($endpoint, $parameters);
97
+		$apiResult = $this->httpHelper->get($endpoint, $parameters);
98 98
 
99
-        $data = unserialize($apiResult);
99
+		$data = unserialize($apiResult);
100 100
 
101
-        return $data['titleblacklist'];
102
-    }
101
+		return $data['titleblacklist'];
102
+	}
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@
 block discarded – undo
66 66
             $this->cache[$username] = false;
67 67
 
68 68
             return false;
69
-        }
70
-        else {
69
+        } else {
71 70
             $this->cache[$username] = $result;
72 71
 
73 72
             return $result['line'];
Please login to merge, or discard this patch.
includes/Helpers/OAuthHelper.php 2 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -21,231 +21,231 @@
 block discarded – undo
21 21
 
22 22
 class OAuthHelper implements IOAuthHelper
23 23
 {
24
-    private $oauthConsumer;
25
-    /**
26
-     * @var string
27
-     */
28
-    private $oauthEndpoint;
29
-    /**
30
-     * @var string
31
-     */
32
-    private $consumerToken;
33
-    /**
34
-     * @var string
35
-     */
36
-    private $consumerSecret;
37
-    /**
38
-     * @var HttpHelper
39
-     */
40
-    private $httpHelper;
41
-    /**
42
-     * @var string
43
-     */
44
-    private $mediawikiWebServiceEndpoint;
45
-
46
-    /**
47
-     * OAuthHelper constructor.
48
-     *
49
-     * @param string     $oauthEndpoint
50
-     * @param string     $consumerKey
51
-     * @param string     $consumerSecret
52
-     * @param HttpHelper $httpHelper
53
-     * @param string     $mediawikiWebServiceEndpoint
54
-     */
55
-    public function __construct(
56
-        $oauthEndpoint,
57
-        $consumerKey,
58
-        $consumerSecret,
59
-        HttpHelper $httpHelper,
60
-        $mediawikiWebServiceEndpoint
61
-    ) {
62
-        $this->oauthEndpoint = $oauthEndpoint;
63
-        $this->consumerToken = $consumerKey;
64
-        $this->consumerSecret = $consumerSecret;
65
-        $this->httpHelper = $httpHelper;
66
-
67
-        $this->oauthConsumer = new OAuthConsumer($this->consumerToken, $this->consumerSecret);
68
-        $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
69
-    }
70
-
71
-    /**
72
-     * @return stdClass
73
-     *
74
-     * @throws Exception
75
-     * @throws CurlException
76
-     */
77
-    public function getRequestToken()
78
-    {
79
-        $endpoint = $this->oauthEndpoint . '/initiate&format=json&oauth_callback=oob';
80
-
81
-        $parsedUrl = parse_url($endpoint);
82
-        $urlParameters = array();
83
-        parse_str($parsedUrl['query'], $urlParameters);
84
-
85
-        $req_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, null, 'GET', $endpoint, $urlParameters);
86
-        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
87
-        $req_req->sign_request($hmac_method, $this->oauthConsumer, null);
88
-
89
-        $targetUrl = (string)$req_req;
90
-
91
-        $data = $this->httpHelper->get($targetUrl, null);
92
-
93
-        if ($data === false) {
94
-            throw new Exception('Curl error: ' . $this->httpHelper->getError());
95
-        }
96
-
97
-        $token = json_decode($data);
98
-
99
-        if (!isset($token)) {
100
-            throw new Exception('Unknown error encountered getting request token while decoding json data.');
101
-        }
102
-
103
-        if (isset($token->error)) {
104
-            throw new Exception('Error encountered while getting request token: ' . $token->error);
105
-        }
106
-
107
-        return $token;
108
-    }
109
-
110
-    /**
111
-     * @param string $requestToken
112
-     *
113
-     * @return string
114
-     */
115
-    public function getAuthoriseUrl($requestToken)
116
-    {
117
-        return "{$this->oauthEndpoint}/authorize&oauth_token={$requestToken}&oauth_consumer_key={$this->consumerToken}";
118
-    }
119
-
120
-    /**
121
-     * @param string $oauthRequestToken
122
-     * @param string $oauthRequestSecret
123
-     * @param string $oauthVerifier
124
-     *
125
-     * @return stdClass
126
-     * @throws CurlException
127
-     * @throws Exception
128
-     */
129
-    public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier)
130
-    {
131
-        $endpoint = $this->oauthEndpoint . '/token&format=json';
132
-
133
-        $requestConsumer = new OAuthConsumer($oauthRequestToken, $oauthRequestSecret);
134
-
135
-        $parsedUrl = parse_url($endpoint);
136
-        parse_str($parsedUrl['query'], $urlParameters);
137
-        $urlParameters['oauth_verifier'] = trim($oauthVerifier);
138
-
139
-        $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $requestConsumer, 'GET', $endpoint,
140
-            $urlParameters);
141
-        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
142
-        $acc_req->sign_request($hmac_method, $this->oauthConsumer, $requestConsumer);
143
-
144
-        $targetUrl = (string)$acc_req;
145
-
146
-        $data = $this->httpHelper->get($targetUrl, null);
147
-
148
-        if ($data === false) {
149
-            throw new Exception('Curl error: ' . $this->httpHelper->getError());
150
-        }
151
-
152
-        $token = json_decode($data);
153
-
154
-        if (!isset($token)) {
155
-            throw new Exception('Unknown error encountered getting access token while decoding json data.');
156
-        }
157
-
158
-        if (isset($token->error)) {
159
-            throw new Exception('Error encountered while getting access token: ' . $token->error);
160
-        }
161
-
162
-        return $token;
163
-    }
164
-
165
-    /**
166
-     * @param string $oauthAccessToken
167
-     * @param string $oauthAccessSecret
168
-     *
169
-     * @return JWT
170
-     * @throws CurlException
171
-     * @throws Exception
172
-     */
173
-    public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret)
174
-    {
175
-        $endpoint = $this->oauthEndpoint . '/identify&format=json';
176
-
177
-        $oauthToken = new OAuthToken($oauthAccessToken, $oauthAccessSecret);
178
-
179
-        $parsedUrl = parse_url($endpoint);
180
-        parse_str($parsedUrl['query'], $urlParameters);
181
-
182
-        $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $oauthToken, 'GET', $endpoint,
183
-            $urlParameters);
184
-        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
185
-        $acc_req->sign_request($hmac_method, $this->oauthConsumer, $oauthToken);
186
-
187
-        $targetUrl = (string)$acc_req;
188
-
189
-        $data = $this->httpHelper->get($targetUrl, null);
190
-
191
-        if ($data === false) {
192
-            throw new Exception('Curl error: ' . $this->httpHelper->getError());
193
-        }
194
-
195
-        $decodedData = json_decode($data);
196
-
197
-        if (isset($decodedData->error)) {
198
-            throw new Exception($decodedData->error);
199
-        }
200
-
201
-        $identity = JWT::decode($data, $this->consumerSecret);
202
-
203
-        return $identity;
204
-    }
205
-
206
-    /**
207
-     * @param array  $apiParams    array of parameters to send to the API
208
-     * @param string $accessToken  user's access token
209
-     * @param string $accessSecret user's secret
210
-     * @param string $method       HTTP method
211
-     *
212
-     * @return stdClass
213
-     * @throws ApplicationLogicException
214
-     * @throws CurlException
215
-     * @throws Exception
216
-     */
217
-    public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET')
218
-    {
219
-        $userToken = new OAuthToken($accessToken, $accessSecret);
220
-
221
-        $apiParams['format'] = 'json';
222
-
223
-        $api_req = OAuthRequest::from_consumer_and_token(
224
-            $this->oauthConsumer, // Consumer
225
-            $userToken, // User Access Token
226
-            $method, // HTTP Method
227
-            $this->mediawikiWebServiceEndpoint, // Endpoint url
228
-            $apiParams    // Extra signed parameters
229
-        );
230
-
231
-        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
24
+	private $oauthConsumer;
25
+	/**
26
+	 * @var string
27
+	 */
28
+	private $oauthEndpoint;
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private $consumerToken;
33
+	/**
34
+	 * @var string
35
+	 */
36
+	private $consumerSecret;
37
+	/**
38
+	 * @var HttpHelper
39
+	 */
40
+	private $httpHelper;
41
+	/**
42
+	 * @var string
43
+	 */
44
+	private $mediawikiWebServiceEndpoint;
45
+
46
+	/**
47
+	 * OAuthHelper constructor.
48
+	 *
49
+	 * @param string     $oauthEndpoint
50
+	 * @param string     $consumerKey
51
+	 * @param string     $consumerSecret
52
+	 * @param HttpHelper $httpHelper
53
+	 * @param string     $mediawikiWebServiceEndpoint
54
+	 */
55
+	public function __construct(
56
+		$oauthEndpoint,
57
+		$consumerKey,
58
+		$consumerSecret,
59
+		HttpHelper $httpHelper,
60
+		$mediawikiWebServiceEndpoint
61
+	) {
62
+		$this->oauthEndpoint = $oauthEndpoint;
63
+		$this->consumerToken = $consumerKey;
64
+		$this->consumerSecret = $consumerSecret;
65
+		$this->httpHelper = $httpHelper;
66
+
67
+		$this->oauthConsumer = new OAuthConsumer($this->consumerToken, $this->consumerSecret);
68
+		$this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint;
69
+	}
70
+
71
+	/**
72
+	 * @return stdClass
73
+	 *
74
+	 * @throws Exception
75
+	 * @throws CurlException
76
+	 */
77
+	public function getRequestToken()
78
+	{
79
+		$endpoint = $this->oauthEndpoint . '/initiate&format=json&oauth_callback=oob';
80
+
81
+		$parsedUrl = parse_url($endpoint);
82
+		$urlParameters = array();
83
+		parse_str($parsedUrl['query'], $urlParameters);
84
+
85
+		$req_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, null, 'GET', $endpoint, $urlParameters);
86
+		$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
87
+		$req_req->sign_request($hmac_method, $this->oauthConsumer, null);
88
+
89
+		$targetUrl = (string)$req_req;
90
+
91
+		$data = $this->httpHelper->get($targetUrl, null);
92
+
93
+		if ($data === false) {
94
+			throw new Exception('Curl error: ' . $this->httpHelper->getError());
95
+		}
96
+
97
+		$token = json_decode($data);
98
+
99
+		if (!isset($token)) {
100
+			throw new Exception('Unknown error encountered getting request token while decoding json data.');
101
+		}
102
+
103
+		if (isset($token->error)) {
104
+			throw new Exception('Error encountered while getting request token: ' . $token->error);
105
+		}
106
+
107
+		return $token;
108
+	}
109
+
110
+	/**
111
+	 * @param string $requestToken
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function getAuthoriseUrl($requestToken)
116
+	{
117
+		return "{$this->oauthEndpoint}/authorize&oauth_token={$requestToken}&oauth_consumer_key={$this->consumerToken}";
118
+	}
119
+
120
+	/**
121
+	 * @param string $oauthRequestToken
122
+	 * @param string $oauthRequestSecret
123
+	 * @param string $oauthVerifier
124
+	 *
125
+	 * @return stdClass
126
+	 * @throws CurlException
127
+	 * @throws Exception
128
+	 */
129
+	public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier)
130
+	{
131
+		$endpoint = $this->oauthEndpoint . '/token&format=json';
132
+
133
+		$requestConsumer = new OAuthConsumer($oauthRequestToken, $oauthRequestSecret);
134
+
135
+		$parsedUrl = parse_url($endpoint);
136
+		parse_str($parsedUrl['query'], $urlParameters);
137
+		$urlParameters['oauth_verifier'] = trim($oauthVerifier);
138
+
139
+		$acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $requestConsumer, 'GET', $endpoint,
140
+			$urlParameters);
141
+		$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
142
+		$acc_req->sign_request($hmac_method, $this->oauthConsumer, $requestConsumer);
143
+
144
+		$targetUrl = (string)$acc_req;
145
+
146
+		$data = $this->httpHelper->get($targetUrl, null);
147
+
148
+		if ($data === false) {
149
+			throw new Exception('Curl error: ' . $this->httpHelper->getError());
150
+		}
151
+
152
+		$token = json_decode($data);
153
+
154
+		if (!isset($token)) {
155
+			throw new Exception('Unknown error encountered getting access token while decoding json data.');
156
+		}
157
+
158
+		if (isset($token->error)) {
159
+			throw new Exception('Error encountered while getting access token: ' . $token->error);
160
+		}
161
+
162
+		return $token;
163
+	}
164
+
165
+	/**
166
+	 * @param string $oauthAccessToken
167
+	 * @param string $oauthAccessSecret
168
+	 *
169
+	 * @return JWT
170
+	 * @throws CurlException
171
+	 * @throws Exception
172
+	 */
173
+	public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret)
174
+	{
175
+		$endpoint = $this->oauthEndpoint . '/identify&format=json';
176
+
177
+		$oauthToken = new OAuthToken($oauthAccessToken, $oauthAccessSecret);
178
+
179
+		$parsedUrl = parse_url($endpoint);
180
+		parse_str($parsedUrl['query'], $urlParameters);
181
+
182
+		$acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $oauthToken, 'GET', $endpoint,
183
+			$urlParameters);
184
+		$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
185
+		$acc_req->sign_request($hmac_method, $this->oauthConsumer, $oauthToken);
186
+
187
+		$targetUrl = (string)$acc_req;
188
+
189
+		$data = $this->httpHelper->get($targetUrl, null);
190
+
191
+		if ($data === false) {
192
+			throw new Exception('Curl error: ' . $this->httpHelper->getError());
193
+		}
194
+
195
+		$decodedData = json_decode($data);
196
+
197
+		if (isset($decodedData->error)) {
198
+			throw new Exception($decodedData->error);
199
+		}
200
+
201
+		$identity = JWT::decode($data, $this->consumerSecret);
202
+
203
+		return $identity;
204
+	}
205
+
206
+	/**
207
+	 * @param array  $apiParams    array of parameters to send to the API
208
+	 * @param string $accessToken  user's access token
209
+	 * @param string $accessSecret user's secret
210
+	 * @param string $method       HTTP method
211
+	 *
212
+	 * @return stdClass
213
+	 * @throws ApplicationLogicException
214
+	 * @throws CurlException
215
+	 * @throws Exception
216
+	 */
217
+	public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET')
218
+	{
219
+		$userToken = new OAuthToken($accessToken, $accessSecret);
220
+
221
+		$apiParams['format'] = 'json';
222
+
223
+		$api_req = OAuthRequest::from_consumer_and_token(
224
+			$this->oauthConsumer, // Consumer
225
+			$userToken, // User Access Token
226
+			$method, // HTTP Method
227
+			$this->mediawikiWebServiceEndpoint, // Endpoint url
228
+			$apiParams    // Extra signed parameters
229
+		);
230
+
231
+		$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
232 232
 
233
-        $api_req->sign_request($hmac_method, $this->oauthConsumer, $userToken);
234
-
235
-        if ($method == 'GET') {
236
-            $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams);
237
-        }
238
-        elseif ($method == 'POST') {
239
-            $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams);
240
-        }
241
-        else {
242
-            throw new ApplicationLogicException('Unsupported HTTP Method');
243
-        }
244
-
245
-        if ($data === false) {
246
-            throw new Exception('Curl error: ' . $this->httpHelper->getError());
247
-        }
248
-
249
-        return json_decode($data);
250
-    }
233
+		$api_req->sign_request($hmac_method, $this->oauthConsumer, $userToken);
234
+
235
+		if ($method == 'GET') {
236
+			$data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams);
237
+		}
238
+		elseif ($method == 'POST') {
239
+			$data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams);
240
+		}
241
+		else {
242
+			throw new ApplicationLogicException('Unsupported HTTP Method');
243
+		}
244
+
245
+		if ($data === false) {
246
+			throw new Exception('Curl error: ' . $this->httpHelper->getError());
247
+		}
248
+
249
+		return json_decode($data);
250
+	}
251 251
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -234,11 +234,9 @@
 block discarded – undo
234 234
 
235 235
         if ($method == 'GET') {
236 236
             $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams);
237
-        }
238
-        elseif ($method == 'POST') {
237
+        } elseif ($method == 'POST') {
239 238
             $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams);
240
-        }
241
-        else {
239
+        } else {
242 240
             throw new ApplicationLogicException('Unsupported HTTP Method');
243 241
         }
244 242
 
Please login to merge, or discard this patch.
includes/Helpers/Logger.php 1 patch
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -30,318 +30,318 @@
 block discarded – undo
30 30
  */
31 31
 class Logger
32 32
 {
33
-    /**
34
-     * @param PdoDatabase $database
35
-     * @param Request     $object
36
-     */
37
-    public static function emailConfirmed(PdoDatabase $database, Request $object)
38
-    {
39
-        self::createLogEntry($database, $object, "Email Confirmed", null, User::getCommunity());
40
-    }
41
-
42
-    /**
43
-     * @param PdoDatabase $database
44
-     * @param DataObject  $object
45
-     * @param string      $logAction
46
-     * @param null|string $comment
47
-     * @param User        $user
48
-     *
49
-     * @throws Exception
50
-     */
51
-    private static function createLogEntry(
52
-        PdoDatabase $database,
53
-        DataObject $object,
54
-        $logAction,
55
-        $comment = null,
56
-        $user = null
57
-    ) {
58
-        if ($user == null) {
59
-            $user = User::getCurrent($database);
60
-        }
61
-
62
-        $objectType = get_class($object);
63
-        if (strpos($objectType, 'Waca\\DataObjects\\') !== false) {
64
-            $objectType = str_replace('Waca\\DataObjects\\', '', $objectType);
65
-        }
66
-
67
-        $log = new Log();
68
-        $log->setDatabase($database);
69
-        $log->setAction($logAction);
70
-        $log->setObjectId($object->getId());
71
-        $log->setObjectType($objectType);
72
-        $log->setUser($user);
73
-        $log->setComment($comment);
74
-        $log->save();
75
-    }
76
-
77
-    #region Users
78
-
79
-    /**
80
-     * @param PdoDatabase $database
81
-     * @param User        $user
82
-     */
83
-    public static function newUser(PdoDatabase $database, User $user)
84
-    {
85
-        self::createLogEntry($database, $user, 'Registered', null, User::getCommunity());
86
-    }
87
-
88
-    /**
89
-     * @param PdoDatabase $database
90
-     * @param User        $object
91
-     */
92
-    public static function approvedUser(PdoDatabase $database, User $object)
93
-    {
94
-        self::createLogEntry($database, $object, "Approved");
95
-    }
96
-
97
-    /**
98
-     * @param PdoDatabase $database
99
-     * @param User        $object
100
-     * @param string      $comment
101
-     */
102
-    public static function declinedUser(PdoDatabase $database, User $object, $comment)
103
-    {
104
-        self::createLogEntry($database, $object, "Declined", $comment);
105
-    }
106
-
107
-    /**
108
-     * @param PdoDatabase $database
109
-     * @param User        $object
110
-     * @param string      $comment
111
-     */
112
-    public static function suspendedUser(PdoDatabase $database, User $object, $comment)
113
-    {
114
-        self::createLogEntry($database, $object, "Suspended", $comment);
115
-    }
116
-
117
-    /**
118
-     * @param PdoDatabase $database
119
-     * @param User        $object
120
-     * @param string      $comment
121
-     */
122
-    public static function demotedUser(PdoDatabase $database, User $object, $comment)
123
-    {
124
-        self::createLogEntry($database, $object, "Demoted", $comment);
125
-    }
126
-
127
-    /**
128
-     * @param PdoDatabase $database
129
-     * @param User        $object
130
-     */
131
-    public static function promotedUser(PdoDatabase $database, User $object)
132
-    {
133
-        self::createLogEntry($database, $object, "Promoted");
134
-    }
135
-
136
-    /**
137
-     * @param PdoDatabase $database
138
-     * @param User        $object
139
-     * @param string      $comment
140
-     */
141
-    public static function renamedUser(PdoDatabase $database, User $object, $comment)
142
-    {
143
-        self::createLogEntry($database, $object, "Renamed", $comment);
144
-    }
145
-
146
-    /**
147
-     * @param PdoDatabase $database
148
-     * @param User        $object
149
-     */
150
-    public static function userPreferencesChange(PdoDatabase $database, User $object)
151
-    {
152
-        self::createLogEntry($database, $object, "Prefchange");
153
-    }
154
-
155
-    /**
156
-     * @param PdoDatabase $database
157
-     * @param User        $object
158
-     * @param string      $reason
159
-     * @param array       $added
160
-     * @param array       $removed
161
-     */
162
-    public static function userRolesEdited(PdoDatabase $database, User $object, $reason, $added, $removed)
163
-    {
164
-        $logData = serialize(array(
165
-            'added'   => $added,
166
-            'removed' => $removed,
167
-            'reason'  => $reason,
168
-        ));
169
-
170
-        self::createLogEntry($database, $object, "RoleChange", $logData);
171
-    }
172
-
173
-    #endregion
174
-
175
-    /**
176
-     * @param PdoDatabase $database
177
-     * @param SiteNotice  $object
178
-     */
179
-    public static function siteNoticeEdited(PdoDatabase $database, SiteNotice $object)
180
-    {
181
-        self::createLogEntry($database, $object, "Edited");
182
-    }
183
-
184
-    #region Welcome Templates
185
-
186
-    /**
187
-     * @param PdoDatabase     $database
188
-     * @param WelcomeTemplate $object
189
-     */
190
-    public static function welcomeTemplateCreated(PdoDatabase $database, WelcomeTemplate $object)
191
-    {
192
-        self::createLogEntry($database, $object, "CreatedTemplate");
193
-    }
194
-
195
-    /**
196
-     * @param PdoDatabase     $database
197
-     * @param WelcomeTemplate $object
198
-     */
199
-    public static function welcomeTemplateEdited(PdoDatabase $database, WelcomeTemplate $object)
200
-    {
201
-        self::createLogEntry($database, $object, "EditedTemplate");
202
-    }
203
-
204
-    /**
205
-     * @param PdoDatabase     $database
206
-     * @param WelcomeTemplate $object
207
-     */
208
-    public static function welcomeTemplateDeleted(PdoDatabase $database, WelcomeTemplate $object)
209
-    {
210
-        self::createLogEntry($database, $object, "DeletedTemplate");
211
-    }
212
-
213
-    #endregion
214
-
215
-    #region Bans
216
-
217
-    /**
218
-     * @param PdoDatabase $database
219
-     * @param Ban         $object
220
-     * @param string      $reason
221
-     */
222
-    public static function banned(PdoDatabase $database, Ban $object, $reason)
223
-    {
224
-        self::createLogEntry($database, $object, "Banned", $reason);
225
-    }
226
-
227
-    /**
228
-     * @param PdoDatabase $database
229
-     * @param Ban         $object
230
-     * @param string      $reason
231
-     */
232
-    public static function unbanned(PdoDatabase $database, Ban $object, $reason)
233
-    {
234
-        self::createLogEntry($database, $object, "Unbanned", $reason);
235
-    }
236
-
237
-    #endregion
238
-
239
-    #region Requests
240
-
241
-    /**
242
-     * @param PdoDatabase $database
243
-     * @param Request     $object
244
-     * @param string      $target
245
-     */
246
-    public static function deferRequest(PdoDatabase $database, Request $object, $target)
247
-    {
248
-        self::createLogEntry($database, $object, "Deferred to $target");
249
-    }
250
-
251
-    /**
252
-     * @param PdoDatabase $database
253
-     * @param Request     $object
254
-     * @param integer     $target
255
-     * @param string      $comment
256
-     */
257
-    public static function closeRequest(PdoDatabase $database, Request $object, $target, $comment)
258
-    {
259
-        self::createLogEntry($database, $object, "Closed $target", $comment);
260
-    }
261
-
262
-    /**
263
-     * @param PdoDatabase $database
264
-     * @param Request     $object
265
-     */
266
-    public static function reserve(PdoDatabase $database, Request $object)
267
-    {
268
-        self::createLogEntry($database, $object, "Reserved");
269
-    }
270
-
271
-    /**
272
-     * @param PdoDatabase $database
273
-     * @param Request     $object
274
-     */
275
-    public static function breakReserve(PdoDatabase $database, Request $object)
276
-    {
277
-        self::createLogEntry($database, $object, "BreakReserve");
278
-    }
279
-
280
-    /**
281
-     * @param PdoDatabase $database
282
-     * @param Request     $object
283
-     */
284
-    public static function unreserve(PdoDatabase $database, Request $object)
285
-    {
286
-        self::createLogEntry($database, $object, "Unreserved");
287
-    }
288
-
289
-    /**
290
-     * @param PdoDatabase $database
291
-     * @param Comment     $object
292
-     * @param Request     $request
293
-     */
294
-    public static function editComment(PdoDatabase $database, Comment $object, Request $request)
295
-    {
296
-        self::createLogEntry($database, $request, "EditComment-r");
297
-        self::createLogEntry($database, $object, "EditComment-c");
298
-    }
299
-
300
-    /**
301
-     * @param PdoDatabase $database
302
-     * @param Request     $object
303
-     * @param User        $target
304
-     */
305
-    public static function sendReservation(PdoDatabase $database, Request $object, User $target)
306
-    {
307
-        self::createLogEntry($database, $object, "SendReserved");
308
-        self::createLogEntry($database, $object, "ReceiveReserved", null, $target);
309
-    }
310
-
311
-    /**
312
-     * @param PdoDatabase $database
313
-     * @param Request     $object
314
-     * @param string      $comment
315
-     */
316
-    public static function sentMail(PdoDatabase $database, Request $object, $comment)
317
-    {
318
-        self::createLogEntry($database, $object, "SentMail", $comment);
319
-    }
320
-    #endregion
321
-
322
-    #region Email templates
323
-
324
-    /**
325
-     * @param PdoDatabase   $database
326
-     * @param EmailTemplate $object
327
-     */
328
-    public static function createEmail(PdoDatabase $database, EmailTemplate $object)
329
-    {
330
-        self::createLogEntry($database, $object, "CreatedEmail");
331
-    }
332
-
333
-    /**
334
-     * @param PdoDatabase   $database
335
-     * @param EmailTemplate $object
336
-     */
337
-    public static function editedEmail(PdoDatabase $database, EmailTemplate $object)
338
-    {
339
-        self::createLogEntry($database, $object, "EditedEmail");
340
-    }
341
-
342
-    #endregion
343
-
344
-    #region Display
345
-
346
-    #endregion
33
+	/**
34
+	 * @param PdoDatabase $database
35
+	 * @param Request     $object
36
+	 */
37
+	public static function emailConfirmed(PdoDatabase $database, Request $object)
38
+	{
39
+		self::createLogEntry($database, $object, "Email Confirmed", null, User::getCommunity());
40
+	}
41
+
42
+	/**
43
+	 * @param PdoDatabase $database
44
+	 * @param DataObject  $object
45
+	 * @param string      $logAction
46
+	 * @param null|string $comment
47
+	 * @param User        $user
48
+	 *
49
+	 * @throws Exception
50
+	 */
51
+	private static function createLogEntry(
52
+		PdoDatabase $database,
53
+		DataObject $object,
54
+		$logAction,
55
+		$comment = null,
56
+		$user = null
57
+	) {
58
+		if ($user == null) {
59
+			$user = User::getCurrent($database);
60
+		}
61
+
62
+		$objectType = get_class($object);
63
+		if (strpos($objectType, 'Waca\\DataObjects\\') !== false) {
64
+			$objectType = str_replace('Waca\\DataObjects\\', '', $objectType);
65
+		}
66
+
67
+		$log = new Log();
68
+		$log->setDatabase($database);
69
+		$log->setAction($logAction);
70
+		$log->setObjectId($object->getId());
71
+		$log->setObjectType($objectType);
72
+		$log->setUser($user);
73
+		$log->setComment($comment);
74
+		$log->save();
75
+	}
76
+
77
+	#region Users
78
+
79
+	/**
80
+	 * @param PdoDatabase $database
81
+	 * @param User        $user
82
+	 */
83
+	public static function newUser(PdoDatabase $database, User $user)
84
+	{
85
+		self::createLogEntry($database, $user, 'Registered', null, User::getCommunity());
86
+	}
87
+
88
+	/**
89
+	 * @param PdoDatabase $database
90
+	 * @param User        $object
91
+	 */
92
+	public static function approvedUser(PdoDatabase $database, User $object)
93
+	{
94
+		self::createLogEntry($database, $object, "Approved");
95
+	}
96
+
97
+	/**
98
+	 * @param PdoDatabase $database
99
+	 * @param User        $object
100
+	 * @param string      $comment
101
+	 */
102
+	public static function declinedUser(PdoDatabase $database, User $object, $comment)
103
+	{
104
+		self::createLogEntry($database, $object, "Declined", $comment);
105
+	}
106
+
107
+	/**
108
+	 * @param PdoDatabase $database
109
+	 * @param User        $object
110
+	 * @param string      $comment
111
+	 */
112
+	public static function suspendedUser(PdoDatabase $database, User $object, $comment)
113
+	{
114
+		self::createLogEntry($database, $object, "Suspended", $comment);
115
+	}
116
+
117
+	/**
118
+	 * @param PdoDatabase $database
119
+	 * @param User        $object
120
+	 * @param string      $comment
121
+	 */
122
+	public static function demotedUser(PdoDatabase $database, User $object, $comment)
123
+	{
124
+		self::createLogEntry($database, $object, "Demoted", $comment);
125
+	}
126
+
127
+	/**
128
+	 * @param PdoDatabase $database
129
+	 * @param User        $object
130
+	 */
131
+	public static function promotedUser(PdoDatabase $database, User $object)
132
+	{
133
+		self::createLogEntry($database, $object, "Promoted");
134
+	}
135
+
136
+	/**
137
+	 * @param PdoDatabase $database
138
+	 * @param User        $object
139
+	 * @param string      $comment
140
+	 */
141
+	public static function renamedUser(PdoDatabase $database, User $object, $comment)
142
+	{
143
+		self::createLogEntry($database, $object, "Renamed", $comment);
144
+	}
145
+
146
+	/**
147
+	 * @param PdoDatabase $database
148
+	 * @param User        $object
149
+	 */
150
+	public static function userPreferencesChange(PdoDatabase $database, User $object)
151
+	{
152
+		self::createLogEntry($database, $object, "Prefchange");
153
+	}
154
+
155
+	/**
156
+	 * @param PdoDatabase $database
157
+	 * @param User        $object
158
+	 * @param string      $reason
159
+	 * @param array       $added
160
+	 * @param array       $removed
161
+	 */
162
+	public static function userRolesEdited(PdoDatabase $database, User $object, $reason, $added, $removed)
163
+	{
164
+		$logData = serialize(array(
165
+			'added'   => $added,
166
+			'removed' => $removed,
167
+			'reason'  => $reason,
168
+		));
169
+
170
+		self::createLogEntry($database, $object, "RoleChange", $logData);
171
+	}
172
+
173
+	#endregion
174
+
175
+	/**
176
+	 * @param PdoDatabase $database
177
+	 * @param SiteNotice  $object
178
+	 */
179
+	public static function siteNoticeEdited(PdoDatabase $database, SiteNotice $object)
180
+	{
181
+		self::createLogEntry($database, $object, "Edited");
182
+	}
183
+
184
+	#region Welcome Templates
185
+
186
+	/**
187
+	 * @param PdoDatabase     $database
188
+	 * @param WelcomeTemplate $object
189
+	 */
190
+	public static function welcomeTemplateCreated(PdoDatabase $database, WelcomeTemplate $object)
191
+	{
192
+		self::createLogEntry($database, $object, "CreatedTemplate");
193
+	}
194
+
195
+	/**
196
+	 * @param PdoDatabase     $database
197
+	 * @param WelcomeTemplate $object
198
+	 */
199
+	public static function welcomeTemplateEdited(PdoDatabase $database, WelcomeTemplate $object)
200
+	{
201
+		self::createLogEntry($database, $object, "EditedTemplate");
202
+	}
203
+
204
+	/**
205
+	 * @param PdoDatabase     $database
206
+	 * @param WelcomeTemplate $object
207
+	 */
208
+	public static function welcomeTemplateDeleted(PdoDatabase $database, WelcomeTemplate $object)
209
+	{
210
+		self::createLogEntry($database, $object, "DeletedTemplate");
211
+	}
212
+
213
+	#endregion
214
+
215
+	#region Bans
216
+
217
+	/**
218
+	 * @param PdoDatabase $database
219
+	 * @param Ban         $object
220
+	 * @param string      $reason
221
+	 */
222
+	public static function banned(PdoDatabase $database, Ban $object, $reason)
223
+	{
224
+		self::createLogEntry($database, $object, "Banned", $reason);
225
+	}
226
+
227
+	/**
228
+	 * @param PdoDatabase $database
229
+	 * @param Ban         $object
230
+	 * @param string      $reason
231
+	 */
232
+	public static function unbanned(PdoDatabase $database, Ban $object, $reason)
233
+	{
234
+		self::createLogEntry($database, $object, "Unbanned", $reason);
235
+	}
236
+
237
+	#endregion
238
+
239
+	#region Requests
240
+
241
+	/**
242
+	 * @param PdoDatabase $database
243
+	 * @param Request     $object
244
+	 * @param string      $target
245
+	 */
246
+	public static function deferRequest(PdoDatabase $database, Request $object, $target)
247
+	{
248
+		self::createLogEntry($database, $object, "Deferred to $target");
249
+	}
250
+
251
+	/**
252
+	 * @param PdoDatabase $database
253
+	 * @param Request     $object
254
+	 * @param integer     $target
255
+	 * @param string      $comment
256
+	 */
257
+	public static function closeRequest(PdoDatabase $database, Request $object, $target, $comment)
258
+	{
259
+		self::createLogEntry($database, $object, "Closed $target", $comment);
260
+	}
261
+
262
+	/**
263
+	 * @param PdoDatabase $database
264
+	 * @param Request     $object
265
+	 */
266
+	public static function reserve(PdoDatabase $database, Request $object)
267
+	{
268
+		self::createLogEntry($database, $object, "Reserved");
269
+	}
270
+
271
+	/**
272
+	 * @param PdoDatabase $database
273
+	 * @param Request     $object
274
+	 */
275
+	public static function breakReserve(PdoDatabase $database, Request $object)
276
+	{
277
+		self::createLogEntry($database, $object, "BreakReserve");
278
+	}
279
+
280
+	/**
281
+	 * @param PdoDatabase $database
282
+	 * @param Request     $object
283
+	 */
284
+	public static function unreserve(PdoDatabase $database, Request $object)
285
+	{
286
+		self::createLogEntry($database, $object, "Unreserved");
287
+	}
288
+
289
+	/**
290
+	 * @param PdoDatabase $database
291
+	 * @param Comment     $object
292
+	 * @param Request     $request
293
+	 */
294
+	public static function editComment(PdoDatabase $database, Comment $object, Request $request)
295
+	{
296
+		self::createLogEntry($database, $request, "EditComment-r");
297
+		self::createLogEntry($database, $object, "EditComment-c");
298
+	}
299
+
300
+	/**
301
+	 * @param PdoDatabase $database
302
+	 * @param Request     $object
303
+	 * @param User        $target
304
+	 */
305
+	public static function sendReservation(PdoDatabase $database, Request $object, User $target)
306
+	{
307
+		self::createLogEntry($database, $object, "SendReserved");
308
+		self::createLogEntry($database, $object, "ReceiveReserved", null, $target);
309
+	}
310
+
311
+	/**
312
+	 * @param PdoDatabase $database
313
+	 * @param Request     $object
314
+	 * @param string      $comment
315
+	 */
316
+	public static function sentMail(PdoDatabase $database, Request $object, $comment)
317
+	{
318
+		self::createLogEntry($database, $object, "SentMail", $comment);
319
+	}
320
+	#endregion
321
+
322
+	#region Email templates
323
+
324
+	/**
325
+	 * @param PdoDatabase   $database
326
+	 * @param EmailTemplate $object
327
+	 */
328
+	public static function createEmail(PdoDatabase $database, EmailTemplate $object)
329
+	{
330
+		self::createLogEntry($database, $object, "CreatedEmail");
331
+	}
332
+
333
+	/**
334
+	 * @param PdoDatabase   $database
335
+	 * @param EmailTemplate $object
336
+	 */
337
+	public static function editedEmail(PdoDatabase $database, EmailTemplate $object)
338
+	{
339
+		self::createLogEntry($database, $object, "EditedEmail");
340
+	}
341
+
342
+	#endregion
343
+
344
+	#region Display
345
+
346
+	#endregion
347 347
 }
Please login to merge, or discard this patch.
includes/Helpers/Interfaces/ITypeAheadHelper.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
 
11 11
 interface ITypeAheadHelper
12 12
 {
13
-    /**
14
-     * @param string   $class     CSS class to apply this typeahead to.
15
-     * @param callable $generator Generator function taking no arguments to return an array of strings.
16
-     *
17
-     * @return void
18
-     */
19
-    public function defineTypeAheadSource($class, callable $generator);
13
+	/**
14
+	 * @param string   $class     CSS class to apply this typeahead to.
15
+	 * @param callable $generator Generator function taking no arguments to return an array of strings.
16
+	 *
17
+	 * @return void
18
+	 */
19
+	public function defineTypeAheadSource($class, callable $generator);
20 20
 
21
-    /**
22
-     * @return string HTML fragment containing a JS block for typeaheads.
23
-     */
24
-    public function getTypeAheadScriptBlock();
21
+	/**
22
+	 * @return string HTML fragment containing a JS block for typeaheads.
23
+	 */
24
+	public function getTypeAheadScriptBlock();
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.