Completed
Branch master (7d3f82)
by Thomas
09:15
created
htdocs/okapi/services/apiref/issue.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6))
32 32
             throw new InvalidParam('issue_id');
33 33
 
34
-        $cache_key = "apiref/issue#".$issue_id;
34
+        $cache_key = "apiref/issue#" . $issue_id;
35 35
         $result = Cache::get($cache_key);
36 36
         if ($result == null)
37 37
         {
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
                 $extra_headers[] = "Accept: application/vnd.github.v3.html+json";
44 44
                 $extra_headers[] = "User-Agent: https://github.com/opencaching/okapi/";
45 45
                 if (Settings::get('GITHUB_ACCESS_TOKEN')) {
46
-                    $extra_headers[] = "Authorization: token ".Settings::get('GITHUB_ACCESS_TOKEN');
46
+                    $extra_headers[] = "Authorization: token " . Settings::get('GITHUB_ACCESS_TOKEN');
47 47
                 }
48 48
                 $opts = array(
49 49
                     'http' => array(
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
             }
59 59
             catch (ErrorException $e)
60 60
             {
61
-                throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. ".
62
-                    "This is probably due to a temporary connection problem. Try again later or contact ".
61
+                throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. " .
62
+                    "This is probably due to a temporary connection problem. Try again later or contact " .
63 63
                     "us if this seems permanent.");
64 64
             }
65 65
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,10 +26,12 @@  discard block
 block discarded – undo
26 26
     public static function call(OkapiRequest $request)
27 27
     {
28 28
         $issue_id = $request->get_parameter('issue_id');
29
-        if (!$issue_id)
30
-            throw new ParamMissing('issue_id');
31
-        if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6))
32
-            throw new InvalidParam('issue_id');
29
+        if (!$issue_id) {
30
+                    throw new ParamMissing('issue_id');
31
+        }
32
+        if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6)) {
33
+                    throw new InvalidParam('issue_id');
34
+        }
33 35
 
34 36
         $cache_key = "apiref/issue#".$issue_id;
35 37
         $result = Cache::get($cache_key);
@@ -55,8 +57,7 @@  discard block
 block discarded – undo
55 57
                 $context = stream_context_create($opts);
56 58
                 $json = file_get_contents("https://api.github.com/repos/opencaching/okapi/issues/$issue_id",
57 59
                     false, $context);
58
-            }
59
-            catch (ErrorException $e)
60
+            } catch (ErrorException $e)
60 61
             {
61 62
                 throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. ".
62 63
                     "This is probably due to a temporary connection problem. Try again later or contact ".
Please login to merge, or discard this patch.
htdocs/okapi/services/apiref/method_index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
     {
27 27
         $methodnames = OkapiServiceRunner::$all_names;
28 28
         sort($methodnames);
29
-        $cache_key = "api_ref/method_index#".md5(implode("#", $methodnames));
29
+        $cache_key = "api_ref/method_index#" . md5(implode("#", $methodnames));
30 30
         $results = Cache::get($cache_key);
31 31
         if ($results == null)
32 32
         {
Please login to merge, or discard this patch.
htdocs/okapi/services/apiref/method.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             'is_deprecated' => (isset($attrs['class']) && (strpos($attrs['class'], 'deprecated') !== false)),
31 31
             'class' => 'public',
32 32
             'description' =>
33
-                (isset($attrs['default']) ? ("<p>Default value: <b>".$attrs['default']."</b></p>") : "").
33
+                (isset($attrs['default']) ? ("<p>Default value: <b>" . $attrs['default'] . "</b></p>") : "") .
34 34
                 self::get_inner_xml($arg_node),
35 35
 
36 36
         );
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         switch ($plugin_name) {
97 97
             case 'docurl':
98 98
                 $fragment = $arr[1];
99
-                return Settings::get('SITE_URL')."okapi/introduction.html#".$fragment;
99
+                return Settings::get('SITE_URL') . "okapi/introduction.html#" . $fragment;
100 100
             case 'methodref':
101 101
             case 'methodargref':
102 102
             case 'methodretref':
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 $result = '';
105 105
                 if ($elements[0] != '')
106 106
                 {
107
-                    $result .= Settings::get('SITE_URL')."okapi/".$elements[0].'.html';
107
+                    $result .= Settings::get('SITE_URL') . "okapi/" . $elements[0] . '.html';
108 108
                 }
109 109
                 if (count($elements) > 1)
110 110
                 {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 }
122 122
                 return $result;
123 123
             default:
124
-                throw new Exception("Unknown plugin: ".$input);
124
+                throw new Exception("Unknown plugin: " . $input);
125 125
         }
126 126
     }
127 127
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $result = array(
143 143
             'name' => $methodname,
144 144
             'short_name' => end($exploded),
145
-            'ref_url' => Settings::get('SITE_URL')."okapi/$methodname.html",
145
+            'ref_url' => Settings::get('SITE_URL') . "okapi/$methodname.html",
146 146
             'auth_options' => array(
147 147
                 'min_auth_level' => $options['min_auth_level'],
148 148
                 'oauth_consumer' => $options['min_auth_level'] >= 2,
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
                     continue;
185 185
                 if (($include_list === null) && (count($exclude_list) == 0))
186 186
                 {
187
-                    $arg['description'] = "<i>Inherited from <a href='".$referenced_method_info['ref_url'].
188
-                        "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>";
187
+                    $arg['description'] = "<i>Inherited from <a href='" . $referenced_method_info['ref_url'] .
188
+                        "#arg_" . $arg['name'] . "'>" . $referenced_method_info['name'] . "</a> method.</i>";
189 189
                 }
190 190
                 elseif (
191 191
                     (($include_list === null) || in_array($arg['name'], $include_list))
192 192
                     && (!in_array($arg['name'], $exclude_list))
193 193
                 ) {
194
-                    $arg['description'] = "<i>Same as in the <a href='".$referenced_method_info['ref_url'].
195
-                        "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>";
194
+                    $arg['description'] = "<i>Same as in the <a href='" . $referenced_method_info['ref_url'] .
195
+                        "#arg_" . $arg['name'] . "'>" . $referenced_method_info['name'] . "</a> method.</i>";
196 196
                 } else {
197 197
                     continue;
198 198
                 }
@@ -207,21 +207,21 @@  discard block
 block discarded – undo
207 207
                 'is_required' => false,
208 208
                 'is_deprecated' => false,
209 209
                 'class' => 'common-formatting',
210
-                'description' => "<i>Standard <a href='".Settings::get('SITE_URL')."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
210
+                'description' => "<i>Standard <a href='" . Settings::get('SITE_URL') . "okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
211 211
             );
212 212
             $result['arguments'][] = array(
213 213
                 'name' => 'callback',
214 214
                 'is_required' => false,
215 215
                 'is_deprecated' => false,
216 216
                 'class' => 'common-formatting',
217
-                'description' => "<i>Standard <a href='".Settings::get('SITE_URL')."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
217
+                'description' => "<i>Standard <a href='" . Settings::get('SITE_URL') . "okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
218 218
             );
219 219
         }
220 220
         foreach ($result['arguments'] as &$arg_ref)
221 221
             if ($arg_ref['is_deprecated'])
222 222
                 $arg_ref['class'] .= " deprecated";
223 223
         if (!$docs->returns)
224
-            throw new Exception("Missing <returns> element in the $methodname.xml file. ".
224
+            throw new Exception("Missing <returns> element in the $methodname.xml file. " .
225 225
                 "If your method does not return anything, you should document in nonetheless.");
226 226
         $result['returns'] = self::get_inner_xml($docs->returns);
227 227
         return Okapi::formatted_response($request, $result);
Please login to merge, or discard this patch.
Braces   +45 added lines, -32 removed lines patch added patch discarded remove patch
@@ -128,15 +128,19 @@  discard block
 block discarded – undo
128 128
     public static function call(OkapiRequest $request)
129 129
     {
130 130
         $methodname = $request->get_parameter('name');
131
-        if (!$methodname)
132
-            throw new ParamMissing('name');
133
-        if (!preg_match("#^services/[0-9a-z_/]*$#", $methodname))
134
-            throw new InvalidParam('name');
135
-        if (!OkapiServiceRunner::exists($methodname))
136
-            throw new InvalidParam('name', "Method does not exist: '$methodname'.");
131
+        if (!$methodname) {
132
+                    throw new ParamMissing('name');
133
+        }
134
+        if (!preg_match("#^services/[0-9a-z_/]*$#", $methodname)) {
135
+                    throw new InvalidParam('name');
136
+        }
137
+        if (!OkapiServiceRunner::exists($methodname)) {
138
+                    throw new InvalidParam('name', "Method does not exist: '$methodname'.");
139
+        }
137 140
         $options = OkapiServiceRunner::options($methodname);
138
-        if (!isset($options['min_auth_level']))
139
-            throw new Exception("Method $methodname is missing a required 'min_auth_level' option!");
141
+        if (!isset($options['min_auth_level'])) {
142
+                    throw new Exception("Method $methodname is missing a required 'min_auth_level' option!");
143
+        }
140 144
         $docs = simplexml_load_string(OkapiServiceRunner::docs($methodname));
141 145
         $exploded = explode("/", $methodname);
142 146
         $result = array(
@@ -149,23 +153,30 @@  discard block
 block discarded – undo
149 153
                 'oauth_token' => $options['min_auth_level'] >= 3,
150 154
             )
151 155
         );
152
-        if (!$docs->brief)
153
-            throw new Exception("Missing <brief> element in the $methodname.xml file.");
154
-        if ($docs->brief != self::get_inner_xml($docs->brief))
155
-            throw new Exception("The <brief> element may not contain HTML markup ($methodname.xml).");
156
-        if (strlen($docs->brief) > 80)
157
-            throw new Exception("The <brief> description may not be longer than 80 characters ($methodname.xml).");
158
-        if (strpos($docs->brief, "\n") !== false)
159
-            throw new Exception("The <brief> element may not contain new-lines ($methodname.xml).");
160
-        if (substr(trim($docs->brief), -1) == '.')
161
-            throw new Exception("The <brief> element should not end with a dot ($methodname.xml).");
156
+        if (!$docs->brief) {
157
+                    throw new Exception("Missing <brief> element in the $methodname.xml file.");
158
+        }
159
+        if ($docs->brief != self::get_inner_xml($docs->brief)) {
160
+                    throw new Exception("The <brief> element may not contain HTML markup ($methodname.xml).");
161
+        }
162
+        if (strlen($docs->brief) > 80) {
163
+                    throw new Exception("The <brief> description may not be longer than 80 characters ($methodname.xml).");
164
+        }
165
+        if (strpos($docs->brief, "\n") !== false) {
166
+                    throw new Exception("The <brief> element may not contain new-lines ($methodname.xml).");
167
+        }
168
+        if (substr(trim($docs->brief), -1) == '.') {
169
+                    throw new Exception("The <brief> element should not end with a dot ($methodname.xml).");
170
+        }
162 171
         $result['brief_description'] = self::get_inner_xml($docs->brief);
163
-        if ($docs->{'issue-id'})
164
-            $result['issue_id'] = (string)$docs->{'issue-id'};
165
-        else
166
-            $result['issue_id'] = null;
167
-        if (!$docs->desc)
168
-            throw new Exception("Missing <desc> element in the $methodname.xml file.");
172
+        if ($docs->{'issue-id'}) {
173
+                    $result['issue_id'] = (string)$docs->{'issue-id'};
174
+        } else {
175
+                    $result['issue_id'] = null;
176
+        }
177
+        if (!$docs->desc) {
178
+                    throw new Exception("Missing <desc> element in the $methodname.xml file.");
179
+        }
169 180
         $result['description'] = self::get_inner_xml($docs->desc);
170 181
         $result['arguments'] = array();
171 182
         foreach ($docs->req as $arg) { $result['arguments'][] = self::arg_desc($arg); }
@@ -180,14 +191,14 @@  discard block
 block discarded – undo
180 191
             $exclude_list = isset($attrs['except']) ? explode("|", $attrs['except']) : array();
181 192
             foreach ($referenced_method_info['arguments'] as $arg)
182 193
             {
183
-                if ($arg['class'] == 'common-formatting')
184
-                    continue;
194
+                if ($arg['class'] == 'common-formatting') {
195
+                                    continue;
196
+                }
185 197
                 if (($include_list === null) && (count($exclude_list) == 0))
186 198
                 {
187 199
                     $arg['description'] = "<i>Inherited from <a href='".$referenced_method_info['ref_url'].
188 200
                         "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>";
189
-                }
190
-                elseif (
201
+                } elseif (
191 202
                     (($include_list === null) || in_array($arg['name'], $include_list))
192 203
                     && (!in_array($arg['name'], $exclude_list))
193 204
                 ) {
@@ -217,12 +228,14 @@  discard block
 block discarded – undo
217 228
                 'description' => "<i>Standard <a href='".Settings::get('SITE_URL')."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
218 229
             );
219 230
         }
220
-        foreach ($result['arguments'] as &$arg_ref)
221
-            if ($arg_ref['is_deprecated'])
231
+        foreach ($result['arguments'] as &$arg_ref) {
232
+                    if ($arg_ref['is_deprecated'])
222 233
                 $arg_ref['class'] .= " deprecated";
223
-        if (!$docs->returns)
224
-            throw new Exception("Missing <returns> element in the $methodname.xml file. ".
234
+        }
235
+        if (!$docs->returns) {
236
+                    throw new Exception("Missing <returns> element in the $methodname.xml file. ".
225 237
                 "If your method does not return anything, you should document in nonetheless.");
238
+        }
226 239
         $result['returns'] = self::get_inner_xml($docs->returns);
227 240
         return Okapi::formatted_response($request, $result);
228 241
     }
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/userlogs.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@
 block discarded – undo
52 52
                 c.wp_oc as cache_code
53 53
             from cache_logs cl, caches c
54 54
             where
55
-                cl.user_id = '".Db::escape_string($user['internal_id'])."'
56
-                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true")."
55
+                cl.user_id = '".Db::escape_string($user['internal_id']) . "'
56
+                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true") . "
57 57
                 and c.status in (1,2,3)
58 58
                 and cl.cache_id = c.cache_id
59 59
             order by cl.date desc
Please login to merge, or discard this patch.
Braces   +21 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,21 +24,31 @@
 block discarded – undo
24 24
     public static function call(OkapiRequest $request)
25 25
     {
26 26
         $user_uuid = $request->get_parameter('user_uuid');
27
-        if (!$user_uuid) throw new ParamMissing('user_uuid');
27
+        if (!$user_uuid) {
28
+            throw new ParamMissing('user_uuid');
29
+        }
28 30
         $limit = $request->get_parameter('limit');
29
-        if (!$limit) $limit = "20";
30
-        if (!is_numeric($limit))
31
-            throw new InvalidParam('limit', "'$limit'");
31
+        if (!$limit) {
32
+            $limit = "20";
33
+        }
34
+        if (!is_numeric($limit)) {
35
+                    throw new InvalidParam('limit', "'$limit'");
36
+        }
32 37
         $limit = intval($limit);
33
-        if (($limit < 1) || ($limit > 1000))
34
-            throw new InvalidParam('limit', "Has to be in range 1..1000.");
38
+        if (($limit < 1) || ($limit > 1000)) {
39
+                    throw new InvalidParam('limit', "Has to be in range 1..1000.");
40
+        }
35 41
         $offset = $request->get_parameter('offset');
36
-        if (!$offset) $offset = "0";
37
-        if (!is_numeric($offset))
38
-            throw new InvalidParam('offset', "'$offset'");
42
+        if (!$offset) {
43
+            $offset = "0";
44
+        }
45
+        if (!is_numeric($offset)) {
46
+                    throw new InvalidParam('offset', "'$offset'");
47
+        }
39 48
         $offset = intval($offset);
40
-        if ($offset < 0)
41
-            throw new InvalidParam('offset', "'$offset'");
49
+        if ($offset < 0) {
50
+                    throw new InvalidParam('offset', "'$offset'");
51
+        }
42 52
 
43 53
         # Check if user exists and retrieve user's ID (this will throw
44 54
         # a proper exception on invalid UUID).
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/entry.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,16 +21,21 @@
 block discarded – undo
21 21
     public static function call(OkapiRequest $request)
22 22
     {
23 23
         $log_uuid = $request->get_parameter('log_uuid');
24
-        if (!$log_uuid) throw new ParamMissing('log_uuid');
24
+        if (!$log_uuid) {
25
+            throw new ParamMissing('log_uuid');
26
+        }
25 27
         $fields = $request->get_parameter('fields');
26
-        if (!$fields) $fields = "date|user|type|comment";
28
+        if (!$fields) {
29
+            $fields = "date|user|type|comment";
30
+        }
27 31
 
28 32
         $results = OkapiServiceRunner::call('services/logs/entries', new OkapiInternalRequest(
29 33
             $request->consumer, $request->token, array('log_uuids' => $log_uuid,
30 34
             'fields' => $fields)));
31 35
         $result = $results[$log_uuid];
32
-        if ($result == null)
33
-            throw new InvalidParam('log_uuid', "This log entry does not exist.");
36
+        if ($result == null) {
37
+                    throw new InvalidParam('log_uuid', "This log entry does not exist.");
38
+        }
34 39
         return Okapi::formatted_response($request, $result);
35 40
     }
36 41
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/logs.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
             select uuid
51 51
             from cache_logs
52 52
             where
53
-                cache_id = '".Db::escape_string($cache['internal_id'])."'
54
-                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true")."
53
+                cache_id = '".Db::escape_string($cache['internal_id']) . "'
54
+                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true") . "
55 55
             order by date desc
56 56
             limit $offset, $limit
57 57
         ");
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             && Settings::get('OCPL_ENABLE_GEOCACHE_ACCESS_LOGS')
75 75
             && (count($log_uuids) > 0)
76 76
         ) {
77
-            require_once($GLOBALS['rootpath'].'okapi/lib/ocpl_access_logs.php');
77
+            require_once($GLOBALS['rootpath'] . 'okapi/lib/ocpl_access_logs.php');
78 78
             \okapi\OCPLAccessLogs::log_geocache_access($request, $cache['internal_id']);
79 79
         }
80 80
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,19 +24,31 @@  discard block
 block discarded – undo
24 24
     public static function call(OkapiRequest $request)
25 25
     {
26 26
         $cache_code = $request->get_parameter('cache_code');
27
-        if (!$cache_code) throw new ParamMissing('cache_code');
27
+        if (!$cache_code) {
28
+            throw new ParamMissing('cache_code');
29
+        }
28 30
         $fields = $request->get_parameter('fields');
29
-        if (!$fields) $fields = "uuid|date|user|type|comment";
31
+        if (!$fields) {
32
+            $fields = "uuid|date|user|type|comment";
33
+        }
30 34
 
31 35
         $offset = $request->get_parameter('offset');
32
-        if (!$offset) $offset = "0";
33
-        if ((((int)$offset) != $offset) || ((int)$offset) < 0)
34
-            throw new InvalidParam('offset', "Expecting non-negative integer.");
36
+        if (!$offset) {
37
+            $offset = "0";
38
+        }
39
+        if ((((int)$offset) != $offset) || ((int)$offset) < 0) {
40
+                    throw new InvalidParam('offset', "Expecting non-negative integer.");
41
+        }
35 42
         $limit = $request->get_parameter('limit');
36
-        if (!$limit) $limit = "none";
37
-        if ($limit == "none") $limit = "999999999";
38
-        if ((((int)$limit) != $limit) || ((int)$limit) < 0)
39
-            throw new InvalidParam('limit', "Expecting non-negative integer or 'none'.");
43
+        if (!$limit) {
44
+            $limit = "none";
45
+        }
46
+        if ($limit == "none") {
47
+            $limit = "999999999";
48
+        }
49
+        if ((((int)$limit) != $limit) || ((int)$limit) < 0) {
50
+                    throw new InvalidParam('limit', "Expecting non-negative integer or 'none'.");
51
+        }
40 52
 
41 53
         # Check if code exists and retrieve cache ID (this will throw
42 54
         # a proper exception on invalid code).
@@ -64,8 +76,9 @@  discard block
 block discarded – undo
64 76
         $internal_request->skip_limits = true;
65 77
         $logs = OkapiServiceRunner::call('services/logs/entries', $internal_request);
66 78
         $results = array();
67
-        foreach ($log_uuids as $log_uuid)
68
-            $results[] = $logs[$log_uuid];
79
+        foreach ($log_uuids as $log_uuid) {
80
+                    $results[] = $logs[$log_uuid];
81
+        }
69 82
 
70 83
         /* Handle OCPL's "access logs" feature. */
71 84
 
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/images/edit.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
         if ($caption !== null) {
82 82
             Db::execute("
83 83
                 update pictures
84
-                set title = '".Db::escape_string($caption)."'
85
-                where uuid = '".$image_uuid_escaped."'
84
+                set title = '".Db::escape_string($caption) . "'
85
+                where uuid = '".$image_uuid_escaped . "'
86 86
             ");
87 87
             $log_entry_modified = true;
88 88
         }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
         if ($is_spoiler !== null) {
92 92
             Db::execute("
93 93
                 update pictures
94
-                set spoiler = ".($is_spoiler == 'true' ? 1 : 0)."
95
-                where uuid = '".$image_uuid_escaped."'
94
+                set spoiler = ".($is_spoiler == 'true' ? 1 : 0) . "
95
+                where uuid = '".$image_uuid_escaped . "'
96 96
             ");
97 97
             $log_entry_modified = true;
98 98
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
                 $image_uuids = Db::select_column("
109 109
                     select uuid from pictures
110
-                    where object_type = 1 and object_id = '".Db::escape_string($log_internal_id)."'
110
+                    where object_type = 1 and object_id = '".Db::escape_string($log_internal_id) . "'
111 111
                     order by date_created
112 112
                 ");
113 113
                 $position = array_search($image_uuid, $image_uuids);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
                 # For OCDE the pictures table is write locked now.
123 123
 
124 124
                 $old_seq = DB::select_value("
125
-                    select seq from pictures where uuid = '".$image_uuid_escaped."'
125
+                    select seq from pictures where uuid = '".$image_uuid_escaped . "'
126 126
                 ");
127 127
 
128 128
                 if ($seq != $old_seq)
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
                     $max_seq = Db::select_value("
135 135
                         select max(seq)
136 136
                         from pictures
137
-                        where object_type = 1 and object_id = '".Db::escape_string($log_internal_id)."'
137
+                        where object_type = 1 and object_id = '".Db::escape_string($log_internal_id) . "'
138 138
                     ");
139 139
 
140 140
                     Db::query("
141 141
                         update pictures
142
-                        set seq = '".Db::escape_string($max_seq + 1)."'
143
-                        where uuid = '".$image_uuid_escaped."'
142
+                        set seq = '".Db::escape_string($max_seq + 1) . "'
143
+                        where uuid = '".$image_uuid_escaped . "'
144 144
                     ");
145 145
 
146 146
                     # now move the pictures inbetween
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             set seq = seq + 1
151 151
                             where
152 152
                                 object_type = 1
153
-                                and object_id = '".Db::escape_string($log_internal_id)."'
154
-                                and seq >= '".Db::escape_string($seq)."'
155
-                                and seq < '".Db::escape_string($old_seq)."'
153
+                                and object_id = '".Db::escape_string($log_internal_id) . "'
154
+                                and seq >= '".Db::escape_string($seq) . "'
155
+                                and seq < '".Db::escape_string($old_seq) . "'
156 156
                             order by seq desc
157 157
                         ");
158 158
                     } else {
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
                             set seq = seq - 1
162 162
                             where
163 163
                                 object_type = 1
164
-                                and object_id = '".Db::escape_string($log_internal_id)."'
165
-                                and seq <= '".Db::escape_string($seq)."'
166
-                                and seq > '".Db::escape_string($old_seq)."'
164
+                                and object_id = '".Db::escape_string($log_internal_id) . "'
165
+                                and seq <= '".Db::escape_string($seq) . "'
166
+                                and seq > '".Db::escape_string($old_seq) . "'
167 167
                             order by seq asc
168 168
                         ");
169 169
                     }
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
                     # and finally move the edited picture into place
172 172
                     Db::query("
173 173
                         update pictures
174
-                        set seq = '".Db::escape_string($seq)."'
175
-                        where uuid = '".$image_uuid_escaped."'
174
+                        set seq = '".Db::escape_string($seq) . "'
175
+                        where uuid = '".$image_uuid_escaped . "'
176 176
                     ");
177 177
                 }
178 178
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             Db::query("
189 189
                 update cache_logs
190 190
                 set last_modified = NOW()
191
-                where id = '".Db::escape_string($log_internal_id)."'
191
+                where id = '".Db::escape_string($log_internal_id) . "'
192 192
             ");
193 193
 
194 194
             # OCPL code currently does not update pictures.last_modified when
Please login to merge, or discard this patch.
Braces   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 
61 61
         $is_spoiler = $request->get_parameter('is_spoiler');
62 62
         if ($is_spoiler !== null) {
63
-            if (!in_array($is_spoiler, array('true', 'false')))
64
-                throw new InvalidParam('is_spoiler');
63
+            if (!in_array($is_spoiler, array('true', 'false'))) {
64
+                            throw new InvalidParam('is_spoiler');
65
+            }
65 66
         }
66 67
 
67 68
         $position = LogImagesCommon::validate_position($request);
@@ -111,8 +112,7 @@  discard block
 block discarded – undo
111 112
                     order by date_created
112 113
                 ");
113 114
                 $position = array_search($image_uuid, $image_uuids);
114
-            }
115
-            else
115
+            } else
116 116
             {
117 117
                 list($position, $seq) = LogImagesCommon::prepare_position(
118 118
                     $log_internal_id,
@@ -204,7 +204,9 @@  discard block
 block discarded – undo
204 204
         # This is the "real" entry point. A wrapper for the _call method.
205 205
 
206 206
         $langpref = $request->get_parameter('langpref');
207
-        if (!$langpref) $langpref = "en";
207
+        if (!$langpref) {
208
+            $langpref = "en";
209
+        }
208 210
         Okapi::gettext_domain_init(explode("|", $langpref));
209 211
 
210 212
         try
@@ -216,8 +218,7 @@  discard block
 block discarded – undo
216 218
                 'position' => $position
217 219
             );
218 220
             Okapi::gettext_domain_restore();
219
-        }
220
-        catch (CannotPublishException $e)
221
+        } catch (CannotPublishException $e)
221 222
         {
222 223
             Okapi::gettext_domain_restore();
223 224
             $result = array(
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/entries.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
             $log_uuids = explode("|", $log_uuids);
41 41
 
42 42
         if ((count($log_uuids) > 500) && (!$request->skip_limits))
43
-            throw new InvalidParam('log_uuids', "Maximum allowed number of referenced ".
44
-                "log entries is 500. You provided ".count($log_uuids)." UUIDs.");
43
+            throw new InvalidParam('log_uuids', "Maximum allowed number of referenced " .
44
+                "log entries is 500. You provided " . count($log_uuids) . " UUIDs.");
45 45
         if (count($log_uuids) != count(array_unique($log_uuids)))
46 46
             throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
47 47
         $fields = $request->get_parameter('fields');
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
         $rs = Db::query("
69 69
             select
70 70
                 cl.id, c.wp_oc as cache_code, cl.uuid, cl.type,
71
-                ".$teamentry_field." as oc_team_entry,
72
-                ".$needs_maintenance_SQL." as needs_maintenance2,
73
-                ".$listing_is_outdated_SQL." as listing_is_outdated,
71
+                ".$teamentry_field . " as oc_team_entry,
72
+                ".$needs_maintenance_SQL . " as needs_maintenance2,
73
+                ".$listing_is_outdated_SQL . " as listing_is_outdated,
74 74
                 unix_timestamp(cl.date) as date, cl.text,
75 75
                 u.uuid as user_uuid, u.username, u.user_id,
76 76
                 if(cr.user_id is null, 0, 1) as was_recommended
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
                 left join cache_rating cr
82 82
                     on cr.user_id = u.user_id
83 83
                     and cr.cache_id = c.cache_id
84
-                    ".$ratingdate_condition."
84
+                    ".$ratingdate_condition . "
85 85
                     and cl.type in (
86
-                        ".Okapi::logtypename2id("Found it").",
87
-                        ".Okapi::logtypename2id("Attended")."
86
+                        ".Okapi::logtypename2id("Found it") . ",
87
+                        ".Okapi::logtypename2id("Attended") . "
88 88
                     )
89 89
             where
90
-                cl.uuid in ('".implode("','", array_map('\okapi\Db::escape_string', $log_uuids))."')
91
-                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true")."
90
+                cl.uuid in ('".implode("','", array_map('\okapi\Db::escape_string', $log_uuids)) . "')
91
+                and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true") . "
92 92
                 and cl.user_id = u.user_id
93 93
                 and c.cache_id = cl.cache_id
94 94
                 and c.status in (1,2,3)
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 'user' => array(
106 106
                     'uuid' => $row['user_uuid'],
107 107
                     'username' => $row['username'],
108
-                    'profile_url' => Settings::get('SITE_URL')."viewprofile.php?userid=".$row['user_id'],
108
+                    'profile_url' => Settings::get('SITE_URL') . "viewprofile.php?userid=" . $row['user_id'],
109 109
                 ),
110 110
                 'type' => Okapi::logtypeid2name($row['type']),
111 111
                 'was_recommended' => $row['was_recommended'] ? true : false,
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                 from pictures
133 133
                 where
134 134
                     object_type = 1
135
-                    and object_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($log_id2uuid)))."')
135
+                    and object_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($log_id2uuid))) . "')
136 136
                     and display = 1   /* currently is always 1 for logpix */
137 137
                     and unknown_format = 0
138 138
                 order by seq, date_created
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                     array(
149 149
                         'uuid' => $row['uuid'],
150 150
                         'url' => $row['url'],
151
-                        'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?'.$object_type_param.'uuid=' . $row['uuid'],
151
+                        'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?' . $object_type_param . 'uuid=' . $row['uuid'],
152 152
                         'caption' => $row['title'],
153 153
                         'is_spoiler' => ($row['spoiler'] ? true : false),
154 154
                     );
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,25 +31,32 @@  discard block
 block discarded – undo
31 31
     public static function call(OkapiRequest $request)
32 32
     {
33 33
         $log_uuids = $request->get_parameter('log_uuids');
34
-        if ($log_uuids === null) throw new ParamMissing('log_uuids');
34
+        if ($log_uuids === null) {
35
+            throw new ParamMissing('log_uuids');
36
+        }
35 37
         if ($log_uuids === "")
36 38
         {
37 39
             $log_uuids = array();
40
+        } else {
41
+                    $log_uuids = explode("|", $log_uuids);
38 42
         }
39
-        else
40
-            $log_uuids = explode("|", $log_uuids);
41 43
 
42
-        if ((count($log_uuids) > 500) && (!$request->skip_limits))
43
-            throw new InvalidParam('log_uuids', "Maximum allowed number of referenced ".
44
+        if ((count($log_uuids) > 500) && (!$request->skip_limits)) {
45
+                    throw new InvalidParam('log_uuids', "Maximum allowed number of referenced ".
44 46
                 "log entries is 500. You provided ".count($log_uuids)." UUIDs.");
45
-        if (count($log_uuids) != count(array_unique($log_uuids)))
46
-            throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
47
+        }
48
+        if (count($log_uuids) != count(array_unique($log_uuids))) {
49
+                    throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
50
+        }
47 51
         $fields = $request->get_parameter('fields');
48
-        if (!$fields) $fields = "date|user|type|comment";
52
+        if (!$fields) {
53
+            $fields = "date|user|type|comment";
54
+        }
49 55
         $fields = explode("|", $fields);
50
-        foreach ($fields as $field)
51
-            if (!in_array($field, self::$valid_field_names))
56
+        foreach ($fields as $field) {
57
+                    if (!in_array($field, self::$valid_field_names))
52 58
                 throw new InvalidParam('fields', "'$field' is not a valid field code.");
59
+        }
53 60
 
54 61
         if (Settings::get('OC_BRANCH') == 'oc.de')
55 62
         {
@@ -57,8 +64,7 @@  discard block
 block discarded – undo
57 64
             $ratingdate_condition = 'and cr.rating_date=cl.date';
58 65
             $needs_maintenance_SQL = 'cl.needs_maintenance';
59 66
             $listing_is_outdated_SQL = 'cl.listing_outdated';
60
-        }
61
-        else
67
+        } else
62 68
         {
63 69
             $teamentry_field = '(cl.type=12)';
64 70
             $ratingdate_condition = '';
@@ -158,22 +164,25 @@  discard block
 block discarded – undo
158 164
 
159 165
         # Check which UUIDs were not found and mark them with null.
160 166
 
161
-        foreach ($log_uuids as $log_uuid)
162
-            if (!isset($results[$log_uuid]))
167
+        foreach ($log_uuids as $log_uuid) {
168
+                    if (!isset($results[$log_uuid]))
163 169
                 $results[$log_uuid] = null;
170
+        }
164 171
 
165 172
         # Remove unwanted fields.
166 173
 
167
-        foreach (self::$valid_field_names as $field)
168
-            if (!in_array($field, $fields))
174
+        foreach (self::$valid_field_names as $field) {
175
+                    if (!in_array($field, $fields))
169 176
                 foreach ($results as &$result_ref)
170 177
                     unset($result_ref[$field]);
178
+        }
171 179
 
172 180
         # Order the results in the same order as the input codes were given.
173 181
 
174 182
         $ordered_results = array();
175
-        foreach ($log_uuids as $log_uuid)
176
-            $ordered_results[$log_uuid] = $results[$log_uuid];
183
+        foreach ($log_uuids as $log_uuid) {
184
+                    $ordered_results[$log_uuid] = $results[$log_uuid];
185
+        }
177 186
 
178 187
         return Okapi::formatted_response($request, $ordered_results);
179 188
     }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_internal_ids.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
         if (!$internal_ids) throw new ParamMissing('internal_ids');
27 27
         $internal_ids = explode("|", $internal_ids);
28 28
         if (count($internal_ids) > 500)
29
-            throw new InvalidParam('internal_ids', "Maximum allowed number of referenced users ".
30
-                "is 500. You provided ".count($internal_ids)." references.");
29
+            throw new InvalidParam('internal_ids', "Maximum allowed number of referenced users " .
30
+                "is 500. You provided " . count($internal_ids) . " references.");
31 31
         $fields = $request->get_parameter('fields');
32 32
         if (!$fields)
33 33
             throw new ParamMissing('fields');
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $rs = Db::query("
39 39
             select user_id, uuid
40 40
             from user
41
-            where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_ids))."')
41
+            where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_ids)) . "')
42 42
         ");
43 43
         $internalid2useruuid = array();
44 44
         while ($row = Db::fetch_assoc($rs))
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,14 +23,18 @@  discard block
 block discarded – undo
23 23
     public static function call(OkapiRequest $request)
24 24
     {
25 25
         $internal_ids = $request->get_parameter('internal_ids');
26
-        if (!$internal_ids) throw new ParamMissing('internal_ids');
26
+        if (!$internal_ids) {
27
+            throw new ParamMissing('internal_ids');
28
+        }
27 29
         $internal_ids = explode("|", $internal_ids);
28
-        if (count($internal_ids) > 500)
29
-            throw new InvalidParam('internal_ids', "Maximum allowed number of referenced users ".
30
+        if (count($internal_ids) > 500) {
31
+                    throw new InvalidParam('internal_ids', "Maximum allowed number of referenced users ".
30 32
                 "is 500. You provided ".count($internal_ids)." references.");
33
+        }
31 34
         $fields = $request->get_parameter('fields');
32
-        if (!$fields)
33
-            throw new ParamMissing('fields');
35
+        if (!$fields) {
36
+                    throw new ParamMissing('fields');
37
+        }
34 38
 
35 39
         # There's no need to validate the fields parameter as the 'users'
36 40
         # method does this (it will raise a proper exception on invalid values).
@@ -57,10 +61,11 @@  discard block
 block discarded – undo
57 61
         $results = array();
58 62
         foreach ($internal_ids as $internal_id)
59 63
         {
60
-            if (!isset($internalid2useruuid[$internal_id]))
61
-                $results[$internal_id] = null;
62
-            else
63
-                $results[$internal_id] = $id_results[$internalid2useruuid[$internal_id]];
64
+            if (!isset($internalid2useruuid[$internal_id])) {
65
+                            $results[$internal_id] = null;
66
+            } else {
67
+                            $results[$internal_id] = $id_results[$internalid2useruuid[$internal_id]];
68
+            }
64 69
         }
65 70
 
66 71
         return Okapi::formatted_response($request, $results);
Please login to merge, or discard this patch.