Completed
Pull Request — master (#312)
by
unknown
26:01 queued 18:06
created
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.
htdocs/okapi/services/users/by_username.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         # Catch pipe chars here, because services/users/by_usernames would split up the name.
33 33
         # OC databases do not contain user names with pipe chars.
34 34
 
35
-        if (strstr($username,'|'))
35
+        if (strstr($username, '|'))
36 36
             throw new InvalidParam('username', "There is no user by this username.");
37 37
         $fields = $request->get_parameter('fields');
38 38
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,14 +26,17 @@  discard block
 block discarded – undo
26 26
     public static function call(OkapiRequest $request)
27 27
     {
28 28
         $username = $request->get_parameter('username');
29
-        if (!$username) throw new ParamMissing('username');
29
+        if (!$username) {
30
+            throw new ParamMissing('username');
31
+        }
30 32
 
31 33
         # Fix for issue 339:
32 34
         # Catch pipe chars here, because services/users/by_usernames would split up the name.
33 35
         # OC databases do not contain user names with pipe chars.
34 36
 
35
-        if (strstr($username,'|'))
36
-            throw new InvalidParam('username', "There is no user by this username.");
37
+        if (strstr($username,'|')) {
38
+                    throw new InvalidParam('username', "There is no user by this username.");
39
+        }
37 40
         $fields = $request->get_parameter('fields');
38 41
 
39 42
         # There's no need to validate the fields parameter.
@@ -42,8 +45,9 @@  discard block
 block discarded – undo
42 45
             $request->consumer, $request->token, array('usernames' => $username,
43 46
             'fields' => $fields)));
44 47
         $result = $results[$username];
45
-        if ($result == null)
46
-            throw new InvalidParam('username', "There is no user by this username.");
48
+        if ($result == null) {
49
+                    throw new InvalidParam('username', "There is no user by this username.");
50
+        }
47 51
         return Okapi::formatted_response($request, $result);
48 52
     }
49 53
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_internal_id.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
     public static function call(OkapiRequest $request)
24 24
     {
25 25
         $internal_id = $request->get_parameter('internal_id');
26
-        if (!$internal_id) throw new ParamMissing('internal_id');
26
+        if (!$internal_id) {
27
+            throw new ParamMissing('internal_id');
28
+        }
27 29
         $fields = $request->get_parameter('fields');
28 30
 
29 31
         # There's no need to validate the fields parameter.
@@ -32,8 +34,9 @@  discard block
 block discarded – undo
32 34
             $request->consumer, $request->token, array('internal_ids' => $internal_id,
33 35
             'fields' => $fields)));
34 36
         $result = $results[$internal_id];
35
-        if ($result == null)
36
-            throw new InvalidParam('internal_id', "There is no user by this internal_id.");
37
+        if ($result == null) {
38
+                    throw new InvalidParam('internal_id', "There is no user by this internal_id.");
39
+        }
37 40
         return Okapi::formatted_response($request, $result);
38 41
     }
39 42
 }
Please login to merge, or discard this patch.
htdocs/okapi/services/users/by_usernames.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
         if (!$usernames) throw new ParamMissing('usernames');
28 28
         $usernames = explode("|", $usernames);
29 29
         if (count($usernames) > 500)
30
-            throw new InvalidParam('usernames', "Maximum allowed number of referenced users ".
31
-                "is 500. You provided ".count($usernames)." usernames.");
30
+            throw new InvalidParam('usernames', "Maximum allowed number of referenced users " .
31
+                "is 500. You provided " . count($usernames) . " usernames.");
32 32
         $fields = $request->get_parameter('fields');
33 33
         if (!$fields)
34 34
             throw new ParamMissing('fields');
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $rs = Db::query("
40 40
             select username, uuid
41 41
             from user
42
-            where username collate ".Settings::get('DB_CHARSET')."_general_ci in ('".implode("','", array_map('\okapi\Db::escape_string', $usernames))."')
42
+            where username collate ".Settings::get('DB_CHARSET') . "_general_ci in ('" . implode("','", array_map('\okapi\Db::escape_string', $usernames)) . "')
43 43
         ");
44 44
         $lower_username2useruuid = array();
45 45
         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
@@ -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).
@@ -65,10 +69,11 @@  discard block
 block discarded – undo
65 69
         $results = array();
66 70
         foreach ($usernames as $username)
67 71
         {
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')]];
72
+            if (!isset($lower_username2useruuid[mb_strtolower($username, 'utf-8')])) {
73
+                            $results[$username] = null;
74
+            } else {
75
+                            $results[$username] = $id_results[$lower_username2useruuid[mb_strtolower($username, 'utf-8')]];
76
+            }
72 77
         }
73 78
 
74 79
         return Okapi::formatted_response($request, $results);
Please login to merge, or discard this patch.
htdocs/okapi/services/users/user.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
                 $tmp = OkapiServiceRunner::call('services/users/by_internal_id', new OkapiInternalRequest(
34 34
                     $request->consumer, null, array('internal_id' => $request->token->user_id, 'fields' => 'uuid')));
35 35
                 $user_uuid = $tmp['uuid'];
36
-            }
37
-            else
36
+            } else
38 37
             {
39 38
                 throw new BadRequest("You must either: 1. supply the user_uuid argument, or "
40 39
                     ."2. sign your request with an Access Token.");
@@ -49,8 +48,9 @@  discard block
 block discarded – undo
49 48
             $request->consumer, $request->token, array('user_uuids' => $user_uuid,
50 49
             'fields' => $fields)));
51 50
         $result = $results[$user_uuid];
52
-        if ($result == null)
53
-            throw new InvalidParam('user_uuid', "There is no user by this ID.");
51
+        if ($result == null) {
52
+                    throw new InvalidParam('user_uuid', "There is no user by this ID.");
53
+        }
54 54
         return Okapi::formatted_response($request, $result);
55 55
     }
56 56
 }
Please login to merge, or discard this patch.