Completed
Pull Request — master (#313)
by Thomas
18:19 queued 08:41
created
htdocs/okapi/services/users/users.php 1 patch
Braces   +34 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,18 +28,23 @@  discard block
 block discarded – undo
28 28
     public static function call(OkapiRequest $request)
29 29
     {
30 30
         $user_uuids = $request->get_parameter('user_uuids');
31
-        if (!$user_uuids) throw new ParamMissing('user_uuids');
31
+        if (!$user_uuids) {
32
+            throw new ParamMissing('user_uuids');
33
+        }
32 34
         $user_uuids = explode("|", $user_uuids);
33
-        if (count($user_uuids) > 500)
34
-            throw new InvalidParam('user_uuids', "Maximum allowed number of referenced users ".
35
+        if (count($user_uuids) > 500) {
36
+                    throw new InvalidParam('user_uuids', "Maximum allowed number of referenced users ".
35 37
                 "is 500. You provided ".count($user_uuids)." user IDs.");
38
+        }
36 39
         $fields = $request->get_parameter('fields');
37
-        if (!$fields)
38
-            throw new ParamMissing('fields');
40
+        if (!$fields) {
41
+                    throw new ParamMissing('fields');
42
+        }
39 43
         $fields = explode("|", $fields);
40
-        foreach ($fields as $field)
41
-            if (!in_array($field, self::$valid_field_names))
44
+        foreach ($fields as $field) {
45
+                    if (!in_array($field, self::$valid_field_names))
42 46
                 throw new InvalidParam('fields', "'$field' is not a valid field code.");
47
+        }
43 48
         $rs = Db::query("
44 49
             select user_id, uuid, username, admin, latitude, longitude, date_created
45 50
             from user
@@ -48,15 +53,12 @@  discard block
 block discarded – undo
48 53
         $results = array();
49 54
         $id2uuid = array();
50 55
         $uuid2id = array();
51
-        while ($row = Db::fetch_assoc($rs))
52
-        {
56
+        while ($row = Db::fetch_assoc($rs)) {
53 57
             $id2uuid[$row['user_id']] = $row['uuid'];
54 58
             $uuid2id[$row['uuid']] = $row['user_id'];
55 59
             $entry = array();
56
-            foreach ($fields as $field)
57
-            {
58
-                switch ($field)
59
-                {
60
+            foreach ($fields as $field) {
61
+                switch ($field) {
60 62
                     case 'uuid': $entry['uuid'] = $row['uuid']; break;
61 63
                     case 'username': $entry['username'] = $row['username']; break;
62 64
                     case 'profile_url': $entry['profile_url'] = Settings::get('SITE_URL')."viewprofile.php?userid=".$row['user_id']; break;
@@ -99,15 +101,13 @@  discard block
 block discarded – undo
99 101
         # caches_found, caches_notfound, caches_hidden
100 102
 
101 103
         if (in_array('caches_found', $fields) || in_array('caches_notfound', $fields) || in_array('caches_hidden', $fields)
102
-            || in_array('rcmds_given', $fields))
103
-        {
104
+            || in_array('rcmds_given', $fields)) {
104 105
             # We will load all these stats together. Then we may remove these which
105 106
             # the user doesn't need.
106 107
 
107 108
             $extras = array();
108 109
 
109
-            if (Settings::get('OC_BRANCH') == 'oc.pl')
110
-            {
110
+            if (Settings::get('OC_BRANCH') == 'oc.pl') {
111 111
                 # OCPL stores user stats in 'user' table.
112 112
 
113 113
                 $rs = Db::query("
@@ -115,9 +115,7 @@  discard block
 block discarded – undo
115 115
                     from user
116 116
                     where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($id2uuid)))."')
117 117
                 ");
118
-            }
119
-            else
120
-            {
118
+            } else {
121 119
                 # OCDE stores user stats in 'stat_user' table.
122 120
 
123 121
                 $rs = Db::query("
@@ -134,8 +132,7 @@  discard block
 block discarded – undo
134 132
                 ");
135 133
             }
136 134
 
137
-            while ($row = Db::fetch_assoc($rs))
138
-            {
135
+            while ($row = Db::fetch_assoc($rs)) {
139 136
                 $extras[$row['user_id']] = array();;
140 137
                 $extra_ref = &$extras[$row['user_id']];
141 138
                 $extra_ref['caches_found'] = 0 + $row['founds_count'];
@@ -144,8 +141,7 @@  discard block
 block discarded – undo
144 141
             }
145 142
             Db::free_result($rs);
146 143
 
147
-            if (in_array('rcmds_given', $fields))
148
-            {
144
+            if (in_array('rcmds_given', $fields)) {
149 145
                 $rs = Db::query("
150 146
                     select user_id, count(*) as rcmds_given
151 147
                     from cache_rating
@@ -153,30 +149,32 @@  discard block
 block discarded – undo
153 149
                     group by user_id
154 150
                 ");
155 151
                 $rcmds_counts = array();
156
-                while ($row = Db::fetch_assoc($rs))
157
-                    $rcmds_counts[$row['user_id']] = $row['rcmds_given'];
158
-                foreach ($extras as $user_id => &$extra_ref)
159
-                {
152
+                while ($row = Db::fetch_assoc($rs)) {
153
+                                    $rcmds_counts[$row['user_id']] = $row['rcmds_given'];
154
+                }
155
+                foreach ($extras as $user_id => &$extra_ref) {
160 156
                     $extra_ref['rcmds_given'] = isset($rcmds_counts[$user_id]) ? 0 + $rcmds_counts[$user_id] : 0;
161 157
                 }
162 158
             }
163 159
 
164 160
             # "Apply" only those fields which the consumer wanted.
165 161
 
166
-            foreach (array('caches_found', 'caches_notfound', 'caches_hidden', 'rcmds_given') as $field)
167
-            {
168
-                if (!in_array($field, $fields))
169
-                    continue;
170
-                foreach ($results as $uuid => &$result_ref)
171
-                    $result_ref[$field] = $extras[$uuid2id[$uuid]][$field];
162
+            foreach (array('caches_found', 'caches_notfound', 'caches_hidden', 'rcmds_given') as $field) {
163
+                if (!in_array($field, $fields)) {
164
+                                    continue;
165
+                }
166
+                foreach ($results as $uuid => &$result_ref) {
167
+                                    $result_ref[$field] = $extras[$uuid2id[$uuid]][$field];
168
+                }
172 169
             }
173 170
         }
174 171
 
175 172
         # Check which user IDs were not found and mark them with null.
176 173
 
177
-        foreach ($user_uuids as $user_uuid)
178
-            if (!isset($results[$user_uuid]))
174
+        foreach ($user_uuids as $user_uuid) {
175
+                    if (!isset($results[$user_uuid]))
179 176
                 $results[$user_uuid] = null;
177
+        }
180 178
 
181 179
         return Okapi::formatted_response($request, $results);
182 180
     }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_internal_ids.php 1 patch
Braces   +16 added lines, -13 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).
@@ -41,8 +45,7 @@  discard block
 block discarded – undo
41 45
             where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_ids))."')
42 46
         ");
43 47
         $internalid2useruuid = array();
44
-        while ($row = Db::fetch_assoc($rs))
45
-        {
48
+        while ($row = Db::fetch_assoc($rs)) {
46 49
             $internalid2useruuid[$row['user_id']] = $row['uuid'];
47 50
         }
48 51
         Db::free_result($rs);
@@ -55,12 +58,12 @@  discard block
 block discarded – undo
55 58
         # Map user_uuids to internal_ids. Also check which internal_ids were not found
56 59
         # and mark them with null.
57 60
         $results = array();
58
-        foreach ($internal_ids as $internal_id)
59
-        {
60
-            if (!isset($internalid2useruuid[$internal_id]))
61
-                $results[$internal_id] = null;
62
-            else
63
-                $results[$internal_id] = $id_results[$internalid2useruuid[$internal_id]];
61
+        foreach ($internal_ids as $internal_id) {
62
+            if (!isset($internalid2useruuid[$internal_id])) {
63
+                            $results[$internal_id] = null;
64
+            } else {
65
+                            $results[$internal_id] = $id_results[$internalid2useruuid[$internal_id]];
66
+            }
64 67
         }
65 68
 
66 69
         return Okapi::formatted_response($request, $results);
Please login to merge, or discard this patch.
htdocs/okapi/services/users/user.php 1 patch
Braces   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,16 +26,12 @@  discard block
 block discarded – undo
26 26
     public static function call(OkapiRequest $request)
27 27
     {
28 28
         $user_uuid = $request->get_parameter('user_uuid');
29
-        if (!$user_uuid)
30
-        {
31
-            if ($request->token)
32
-            {
29
+        if (!$user_uuid) {
30
+            if ($request->token) {
33 31
                 $tmp = OkapiServiceRunner::call('services/users/by_internal_id', new OkapiInternalRequest(
34 32
                     $request->consumer, null, array('internal_id' => $request->token->user_id, 'fields' => 'uuid')));
35 33
                 $user_uuid = $tmp['uuid'];
36
-            }
37
-            else
38
-            {
34
+            } else {
39 35
                 throw new BadRequest("You must either: 1. supply the user_uuid argument, or "
40 36
                     ."2. sign your request with an Access Token.");
41 37
             }
@@ -49,8 +45,9 @@  discard block
 block discarded – undo
49 45
             $request->consumer, $request->token, array('user_uuids' => $user_uuid,
50 46
             'fields' => $fields)));
51 47
         $result = $results[$user_uuid];
52
-        if ($result == null)
53
-            throw new InvalidParam('user_uuid', "There is no user by this ID.");
48
+        if ($result == null) {
49
+                    throw new InvalidParam('user_uuid', "There is no user by this ID.");
50
+        }
54 51
         return Okapi::formatted_response($request, $result);
55 52
     }
56 53
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_usernames.php 1 patch
Braces   +17 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,14 +24,18 @@  discard block
 block discarded – undo
24 24
     public static function call(OkapiRequest $request)
25 25
     {
26 26
         $usernames = $request->get_parameter('usernames');
27
-        if (!$usernames) throw new ParamMissing('usernames');
27
+        if (!$usernames) {
28
+            throw new ParamMissing('usernames');
29
+        }
28 30
         $usernames = explode("|", $usernames);
29
-        if (count($usernames) > 500)
30
-            throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31
+        if (count($usernames) > 500) {
32
+                    throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31 33
                 "is 500. You provided ".count($usernames)." usernames.");
34
+        }
32 35
         $fields = $request->get_parameter('fields');
33
-        if (!$fields)
34
-            throw new ParamMissing('fields');
36
+        if (!$fields) {
37
+                    throw new ParamMissing('fields');
38
+        }
35 39
 
36 40
         # There's no need to validate the fields parameter as the 'users'
37 41
         # method does this (it will raise a proper exception on invalid values).
@@ -42,16 +46,14 @@  discard block
 block discarded – undo
42 46
             where username collate ".Settings::get('DB_CHARSET')."_general_ci in ('".implode("','", array_map('\okapi\Db::escape_string', $usernames))."')
43 47
         ");
44 48
         $lower_username2useruuid = array();
45
-        while ($row = Db::fetch_assoc($rs))
46
-        {
49
+        while ($row = Db::fetch_assoc($rs)) {
47 50
             $lower_username2useruuid[mb_strtolower($row['username'], 'utf-8')] = $row['uuid'];
48 51
         }
49 52
         Db::free_result($rs);
50 53
 
51 54
         # Retrieve data for the found user_uuids.
52 55
 
53
-        if (count($lower_username2useruuid) > 0)
54
-        {
56
+        if (count($lower_username2useruuid) > 0) {
55 57
             $id_results = OkapiServiceRunner::call('services/users/users', new OkapiInternalRequest(
56 58
                 $request->consumer, $request->token, array('user_uuids' => implode("|", array_values($lower_username2useruuid)),
57 59
                 'fields' => $fields)));
@@ -63,12 +65,12 @@  discard block
 block discarded – undo
63 65
         # and mark them with null.
64 66
 
65 67
         $results = array();
66
-        foreach ($usernames as $username)
67
-        {
68
-            if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')]))
69
-                $results[$username] = null;
70
-            else
71
-                $results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
68
+        foreach ($usernames as $username) {
69
+            if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')])) {
70
+                            $results[$username] = null;
71
+            } else {
72
+                            $results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
73
+            }
72 74
         }
73 75
 
74 76
         return Okapi::formatted_response($request, $results);
Please login to merge, or discard this patch.
htdocs/okapi/services/apiref/issue.php 1 patch
Braces   +9 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@  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);
36
-        if ($result == null)
37
-        {
38
+        if ($result == null) {
38 39
             # Download the number of comments from GitHub Issue Tracker.
39 40
 
40
-            try
41
-            {
41
+            try {
42 42
                 $extra_headers = array();
43 43
                 $extra_headers[] = "Accept: application/vnd.github.v3.html+json";
44 44
                 $extra_headers[] = "User-Agent: https://github.com/opencaching/okapi/";
@@ -55,9 +55,7 @@  discard block
 block discarded – undo
55 55
                 $context = stream_context_create($opts);
56 56
                 $json = file_get_contents("https://api.github.com/repos/opencaching/okapi/issues/$issue_id",
57 57
                     false, $context);
58
-            }
59
-            catch (ErrorException $e)
60
-            {
58
+            } catch (ErrorException $e) {
61 59
                 throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. ".
62 60
                     "This is probably due to a temporary connection problem. Try again later or contact ".
63 61
                     "us if this seems permanent.");
Please login to merge, or discard this patch.
htdocs/okapi/services/apiref/method.php 1 patch
Braces   +51 added lines, -44 removed lines patch added patch discarded remove patch
@@ -102,12 +102,10 @@  discard block
 block discarded – undo
102 102
             case 'methodretref':
103 103
                 $elements = explode('#', $arr[1]);
104 104
                 $result = '';
105
-                if ($elements[0] != '')
106
-                {
105
+                if ($elements[0] != '') {
107 106
                     $result .= Settings::get('SITE_URL')."okapi/".$elements[0].'.html';
108 107
                 }
109
-                if (count($elements) > 1)
110
-                {
108
+                if (count($elements) > 1) {
111 109
                     $result .= '#';
112 110
                     switch ($plugin_name) {
113 111
                         case 'methodargref':
@@ -128,15 +126,19 @@  discard block
 block discarded – undo
128 126
     public static function call(OkapiRequest $request)
129 127
     {
130 128
         $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'.");
129
+        if (!$methodname) {
130
+                    throw new ParamMissing('name');
131
+        }
132
+        if (!preg_match("#^services/[0-9a-z_/]*$#", $methodname)) {
133
+                    throw new InvalidParam('name');
134
+        }
135
+        if (!OkapiServiceRunner::exists($methodname)) {
136
+                    throw new InvalidParam('name', "Method does not exist: '$methodname'.");
137
+        }
137 138
         $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!");
139
+        if (!isset($options['min_auth_level'])) {
140
+                    throw new Exception("Method $methodname is missing a required 'min_auth_level' option!");
141
+        }
140 142
         $docs = simplexml_load_string(OkapiServiceRunner::docs($methodname));
141 143
         $exploded = explode("/", $methodname);
142 144
         $result = array(
@@ -149,45 +151,49 @@  discard block
 block discarded – undo
149 151
                 'oauth_token' => $options['min_auth_level'] >= 3,
150 152
             )
151 153
         );
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).");
154
+        if (!$docs->brief) {
155
+                    throw new Exception("Missing <brief> element in the $methodname.xml file.");
156
+        }
157
+        if ($docs->brief != self::get_inner_xml($docs->brief)) {
158
+                    throw new Exception("The <brief> element may not contain HTML markup ($methodname.xml).");
159
+        }
160
+        if (strlen($docs->brief) > 80) {
161
+                    throw new Exception("The <brief> description may not be longer than 80 characters ($methodname.xml).");
162
+        }
163
+        if (strpos($docs->brief, "\n") !== false) {
164
+                    throw new Exception("The <brief> element may not contain new-lines ($methodname.xml).");
165
+        }
166
+        if (substr(trim($docs->brief), -1) == '.') {
167
+                    throw new Exception("The <brief> element should not end with a dot ($methodname.xml).");
168
+        }
162 169
         $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.");
170
+        if ($docs->{'issue-id'}) {
171
+                    $result['issue_id'] = (string)$docs->{'issue-id'};
172
+        } else {
173
+                    $result['issue_id'] = null;
174
+        }
175
+        if (!$docs->desc) {
176
+                    throw new Exception("Missing <desc> element in the $methodname.xml file.");
177
+        }
169 178
         $result['description'] = self::get_inner_xml($docs->desc);
170 179
         $result['arguments'] = array();
171 180
         foreach ($docs->req as $arg) { $result['arguments'][] = self::arg_desc($arg); }
172 181
         foreach ($docs->opt as $arg) { $result['arguments'][] = self::arg_desc($arg); }
173
-        foreach ($docs->{'import-params'} as $import_desc)
174
-        {
182
+        foreach ($docs->{'import-params'} as $import_desc) {
175 183
             $attrs = $import_desc->attributes();
176 184
             $referenced_methodname = $attrs['method'];
177 185
             $referenced_method_info = OkapiServiceRunner::call('services/apiref/method',
178 186
                 new OkapiInternalRequest(new OkapiInternalConsumer(), null, array('name' => $referenced_methodname)));
179 187
             $include_list = isset($attrs['params']) ? explode("|", $attrs['params']) : null;
180 188
             $exclude_list = isset($attrs['except']) ? explode("|", $attrs['except']) : array();
181
-            foreach ($referenced_method_info['arguments'] as $arg)
182
-            {
183
-                if ($arg['class'] == 'common-formatting')
184
-                    continue;
185
-                if (($include_list === null) && (count($exclude_list) == 0))
186
-                {
189
+            foreach ($referenced_method_info['arguments'] as $arg) {
190
+                if ($arg['class'] == 'common-formatting') {
191
+                                    continue;
192
+                }
193
+                if (($include_list === null) && (count($exclude_list) == 0)) {
187 194
                     $arg['description'] = "<i>Inherited from <a href='".$referenced_method_info['ref_url'].
188 195
                         "#arg_". $arg['name'] . "'>".$referenced_method_info['name']."</a> method.</i>";
189
-                }
190
-                elseif (
196
+                } elseif (
191 197
                     (($include_list === null) || in_array($arg['name'], $include_list))
192 198
                     && (!in_array($arg['name'], $exclude_list))
193 199
                 ) {
@@ -200,8 +206,7 @@  discard block
 block discarded – undo
200 206
                 $result['arguments'][] = $arg;
201 207
             }
202 208
         }
203
-        if ($docs->{'common-format-params'})
204
-        {
209
+        if ($docs->{'common-format-params'}) {
205 210
             $result['arguments'][] = array(
206 211
                 'name' => 'format',
207 212
                 'is_required' => false,
@@ -217,12 +222,14 @@  discard block
 block discarded – undo
217 222
                 'description' => "<i>Standard <a href='".Settings::get('SITE_URL')."okapi/introduction.html#common-formatting'>common formatting</a> argument.</i>"
218 223
             );
219 224
         }
220
-        foreach ($result['arguments'] as &$arg_ref)
221
-            if ($arg_ref['is_deprecated'])
225
+        foreach ($result['arguments'] as &$arg_ref) {
226
+                    if ($arg_ref['is_deprecated'])
222 227
                 $arg_ref['class'] .= " deprecated";
223
-        if (!$docs->returns)
224
-            throw new Exception("Missing <returns> element in the $methodname.xml file. ".
228
+        }
229
+        if (!$docs->returns) {
230
+                    throw new Exception("Missing <returns> element in the $methodname.xml file. ".
225 231
                 "If your method does not return anything, you should document in nonetheless.");
232
+        }
226 233
         $result['returns'] = self::get_inner_xml($docs->returns);
227 234
         return Okapi::formatted_response($request, $result);
228 235
     }
Please login to merge, or discard this patch.
htdocs/okapi/services/apiref/method_index.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,11 +28,9 @@
 block discarded – undo
28 28
         sort($methodnames);
29 29
         $cache_key = "api_ref/method_index#".md5(implode("#", $methodnames));
30 30
         $results = Cache::get($cache_key);
31
-        if ($results == null)
32
-        {
31
+        if ($results == null) {
33 32
             $results = array();
34
-            foreach ($methodnames as $methodname)
35
-            {
33
+            foreach ($methodnames as $methodname) {
36 34
                 $info = OkapiServiceRunner::call('services/apiref/method', new OkapiInternalRequest(
37 35
                     new OkapiInternalConsumer(), null, array('name' => $methodname)));
38 36
                 $results[] = array(
Please login to merge, or discard this patch.
htdocs/okapi/services/apisrv/stats.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
     {
27 27
         $cachekey = "apisrv/stats";
28 28
         $result = Cache::get($cachekey);
29
-        if (!$result)
30
-        {
29
+        if (!$result) {
31 30
             $result = array(
32 31
                 'cache_count' => 0 + Db::select_value("
33 32
                     select count(*) from caches where status in (1,2,3)
Please login to merge, or discard this patch.
htdocs/okapi/services/apisrv/installations.php 1 patch
Braces   +19 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,12 +30,10 @@  discard block
 block discarded – undo
30 30
         $cachekey = 'apisrv/installations';
31 31
         $backupkey = 'apisrv/installations-backup';
32 32
         $results = Cache::get($cachekey);
33
-        if (!$results)
34
-        {
33
+        if (!$results) {
35 34
             # Download the current list of OKAPI servers.
36 35
 
37
-            try
38
-            {
36
+            try {
39 37
                 $opts = array(
40 38
                     'http' => array(
41 39
                         'method' => "GET",
@@ -49,14 +47,11 @@  discard block
 block discarded – undo
49 47
                 if (!$doc) {
50 48
                     throw new ErrorException(); # just to get to the catch block
51 49
                 }
52
-            }
53
-            catch (ErrorException $e)
54
-            {
50
+            } catch (ErrorException $e) {
55 51
                 # GitHub failed on us. Try to respond with a backup list.
56 52
 
57 53
                 $results = Cache::get($backupkey);
58
-                if ($results)
59
-                {
54
+                if ($results) {
60 55
                     Cache::set($cachekey, $results, 12 * 3600); # so to retry no earlier than after 12 hours
61 56
                     return Okapi::formatted_response($request, $results);
62 57
                 }
@@ -77,31 +72,32 @@  discard block
 block discarded – undo
77 72
 
78 73
             $results = array();
79 74
             $i_was_included = false;
80
-            foreach ($doc->installation as $inst)
81
-            {
75
+            foreach ($doc->installation as $inst) {
82 76
                 $site_url = (string)$inst[0]['site_url'];
83
-                if ($inst[0]['okapi_base_url'])
84
-                    $okapi_base_url = (string)$inst[0]['okapi_base_url'];
85
-                else
86
-                    $okapi_base_url = $site_url."okapi/";
87
-                if ($inst[0]['site_name'])
88
-                    $site_name = (string)$inst[0]['site_name'];
89
-                else
90
-                    $site_name = Okapi::get_normalized_site_name($site_url);
77
+                if ($inst[0]['okapi_base_url']) {
78
+                                    $okapi_base_url = (string)$inst[0]['okapi_base_url'];
79
+                } else {
80
+                                    $okapi_base_url = $site_url."okapi/";
81
+                }
82
+                if ($inst[0]['site_name']) {
83
+                                    $site_name = (string)$inst[0]['site_name'];
84
+                } else {
85
+                                    $site_name = Okapi::get_normalized_site_name($site_url);
86
+                }
91 87
                 $results[] = array(
92 88
                     'site_url' => $site_url,
93 89
                     'site_name' => $site_name,
94 90
                     'okapi_base_url' => $okapi_base_url,
95 91
                 );
96
-                if ($site_url == Settings::get('SITE_URL'))
97
-                    $i_was_included = true;
92
+                if ($site_url == Settings::get('SITE_URL')) {
93
+                                    $i_was_included = true;
94
+                }
98 95
             }
99 96
 
100 97
             # If running on a local development installation, then include the local
101 98
             # installation URL.
102 99
 
103
-            if (!$i_was_included)
104
-            {
100
+            if (!$i_was_included) {
105 101
                 $results[] = array(
106 102
                     'site_url' => Settings::get('SITE_URL'),
107 103
                     'site_name' => "DEVELSITE",
Please login to merge, or discard this patch.