Completed
Pull Request — master (#313)
by Thomas
18:19 queued 08:41
created
htdocs/okapi/services/attrs/attr_helper.inc.php 1 patch
Braces   +38 added lines, -50 removed lines patch added patch discarded remove patch
@@ -49,21 +49,17 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public static function refresh_now()
51 51
     {
52
-        try
53
-        {
52
+        try {
54 53
             $path = $GLOBALS['rootpath']."okapi/services/attrs/attribute-definitions.xml";
55 54
             $xml = file_get_contents($path);
56 55
             self::refresh_from_string($xml);
57
-        }
58
-        catch (Exception $e)
59
-        {
56
+        } catch (Exception $e) {
60 57
             # Failed to read or parse the file (i.e. after a syntax error was
61 58
             # commited). Let's check when the last successful parse occured.
62 59
 
63 60
             self::init_from_cache(false);
64 61
 
65
-            if (self::$attr_dict === null)
66
-            {
62
+            if (self::$attr_dict === null) {
67 63
                 # That's bad! We don't have ANY copy of the data AND we failed
68 64
                 # to parse it. We will use a fake, empty data.
69 65
 
@@ -99,8 +95,7 @@  discard block
 block discarded – undo
99 95
         # Build cache attributes dictionary
100 96
 
101 97
         $all_internal_ids = array();
102
-        foreach ($doc->attr as $attrnode)
103
-        {
98
+        foreach ($doc->attr as $attrnode) {
104 99
             $attr = array(
105 100
                 'acode' => (string)$attrnode['acode'],
106 101
                 'gc_equivs' => array(),
@@ -109,47 +104,45 @@  discard block
 block discarded – undo
109 104
                 'descriptions' => array(),
110 105
                 'is_discontinued' => true
111 106
             );
112
-            foreach ($attrnode->groundspeak as $gsnode)
113
-            {
107
+            foreach ($attrnode->groundspeak as $gsnode) {
114 108
                 $attr['gc_equivs'][] = array(
115 109
                     'id' => (int)$gsnode['id'],
116 110
                     'inc' => in_array((string)$gsnode['inc'], array("true", "1")) ? 1 : 0,
117 111
                     'name' => (string)$gsnode['name']
118 112
                 );
119 113
             }
120
-            foreach ($attrnode->opencaching as $ocnode)
121
-            {
114
+            foreach ($attrnode->opencaching as $ocnode) {
122 115
                 /* If it is used by at least one OC site, then it's NOT discontinued. */
123 116
                 $attr['is_discontinued'] = false;
124 117
 
125
-                if ((string)$ocnode['schema'] == $my_schema)
126
-                {
118
+                if ((string)$ocnode['schema'] == $my_schema) {
127 119
                     /* It is used by THIS OC site. */
128 120
 
129 121
                     $internal_id = (int)$ocnode['id'];
130
-                    if (isset($all_internal_ids[$internal_id]))
131
-                        throw new Exception("The internal attribute ".$internal_id.
122
+                    if (isset($all_internal_ids[$internal_id])) {
123
+                                            throw new Exception("The internal attribute ".$internal_id.
132 124
                             " has multiple assigments to OKAPI attributes.");
125
+                    }
133 126
                     $all_internal_ids[$internal_id] = true;
134
-                    if (!is_null($attr['internal_id']))
135
-                        throw new Exception("There are multiple internal IDs for the ".
127
+                    if (!is_null($attr['internal_id'])) {
128
+                                            throw new Exception("There are multiple internal IDs for the ".
136 129
                             $attr['acode']." attribute.");
130
+                    }
137 131
                     $attr['internal_id'] = $internal_id;
138 132
                 }
139 133
             }
140
-            foreach ($attrnode->lang as $langnode)
141
-            {
134
+            foreach ($attrnode->lang as $langnode) {
142 135
                 $lang = (string)$langnode['id'];
143
-                foreach ($langnode->name as $namenode)
144
-                {
145
-                    if (isset($attr['names'][$lang]))
146
-                        throw new Exception("Duplicate ".$lang." name of attribute ".$attr['acode']);
136
+                foreach ($langnode->name as $namenode) {
137
+                    if (isset($attr['names'][$lang])) {
138
+                                            throw new Exception("Duplicate ".$lang." name of attribute ".$attr['acode']);
139
+                    }
147 140
                     $attr['names'][$lang] = (string)$namenode;
148 141
                 }
149
-                foreach ($langnode->desc as $descnode)
150
-                {
151
-                    if (isset($attr['descriptions'][$lang]))
152
-                        throw new Exception("Duplicate ".$lang." description of attribute ".$attr['acode']);
142
+                foreach ($langnode->desc as $descnode) {
143
+                    if (isset($attr['descriptions'][$lang])) {
144
+                                            throw new Exception("Duplicate ".$lang." description of attribute ".$attr['acode']);
145
+                    }
153 146
                     $xml = $descnode->asxml(); /* contains "<desc>" and "</desc>" */
154 147
                     $innerxml = preg_replace("/(^[^>]+>)|(<[^<]+$)/us", "", $xml);
155 148
                     $attr['descriptions'][$lang] = self::cleanup_string($innerxml);
@@ -194,25 +187,20 @@  discard block
 block discarded – undo
194 187
      */
195 188
     private static function init_from_cache($allow_refreshing=true)
196 189
     {
197
-        if (self::$attr_dict !== null)
198
-        {
190
+        if (self::$attr_dict !== null) {
199 191
             /* Already initialized. */
200 192
             return;
201 193
         }
202 194
         $cache_key = "attrhelper/dict#".Okapi::$git_revision.self::cache_key_suffix();
203 195
         $cachedvalue = Cache::get($cache_key);
204
-        if ($cachedvalue === null)
205
-        {
196
+        if ($cachedvalue === null) {
206 197
             # I.e. after Okapi::$git_revision is changed, or cache got invalidated.
207 198
 
208
-            if ($allow_refreshing)
209
-            {
199
+            if ($allow_refreshing) {
210 200
                 self::refresh_now();
211 201
                 self::init_from_cache(false);
212 202
                 return;
213
-            }
214
-            else
215
-            {
203
+            } else {
216 204
                 $cachedvalue = array(
217 205
                     'attr_dict' => array(),
218 206
                 );
@@ -244,17 +232,18 @@  discard block
 block discarded – undo
244 232
     public static function get_internal_id_to_acode_mapping()
245 233
     {
246 234
         static $mapping = null;
247
-        if ($mapping !== null)
248
-            return $mapping;
235
+        if ($mapping !== null) {
236
+                    return $mapping;
237
+        }
249 238
 
250 239
         $cache_key = "attrhelper/id2acode/".Okapi::$git_revision.self::cache_key_suffix();
251 240
         $mapping = Cache::get($cache_key);
252
-        if (!$mapping)
253
-        {
241
+        if (!$mapping) {
254 242
             self::init_from_cache();
255 243
             $mapping = array();
256
-            foreach (self::$attr_dict as $acode => &$attr_ref)
257
-                $mapping[$attr_ref['internal_id']] = $acode;
244
+            foreach (self::$attr_dict as $acode => &$attr_ref) {
245
+                            $mapping[$attr_ref['internal_id']] = $acode;
246
+            }
258 247
             Cache::set($cache_key, $mapping, self::ttl());
259 248
         }
260 249
         return $mapping;
@@ -267,18 +256,17 @@  discard block
 block discarded – undo
267 256
     public static function get_acode_to_name_mapping($langpref)
268 257
     {
269 258
         static $mapping = null;
270
-        if ($mapping !== null)
271
-            return $mapping;
259
+        if ($mapping !== null) {
260
+                    return $mapping;
261
+        }
272 262
 
273 263
         $cache_key = md5(serialize(array("attrhelper/acode2name", $langpref,
274 264
             Okapi::$git_revision, self::cache_key_suffix())));
275 265
         $mapping = Cache::get($cache_key);
276
-        if (!$mapping)
277
-        {
266
+        if (!$mapping) {
278 267
             self::init_from_cache();
279 268
             $mapping = array();
280
-            foreach (self::$attr_dict as $acode => &$attr_ref)
281
-            {
269
+            foreach (self::$attr_dict as $acode => &$attr_ref) {
282 270
                 $mapping[$acode] = Okapi::pick_best_language(
283 271
                     $attr_ref['names'], $langpref);
284 272
             }
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attributes.php 1 patch
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,26 +35,35 @@  discard block
 block discarded – undo
35 35
         # Read the parameters.
36 36
 
37 37
         $acodes = $request->get_parameter('acodes');
38
-        if (!$acodes) throw new ParamMissing('acodes');
38
+        if (!$acodes) {
39
+            throw new ParamMissing('acodes');
40
+        }
39 41
         $acodes = explode("|", $acodes);
40 42
 
41 43
         $langpref = $request->get_parameter('langpref');
42
-        if (!$langpref) $langpref = "en";
44
+        if (!$langpref) {
45
+            $langpref = "en";
46
+        }
43 47
         $langpref = explode("|", $langpref);
44 48
 
45 49
         $fields = $request->get_parameter('fields');
46
-        if (!$fields) $fields = "name";
50
+        if (!$fields) {
51
+            $fields = "name";
52
+        }
47 53
         $fields = explode("|", $fields);
48
-        foreach ($fields as $field)
49
-        {
50
-            if (!in_array($field, self::$valid_field_names))
51
-                throw new InvalidParam('fields', "'$field' is not a valid field code.");
54
+        foreach ($fields as $field) {
55
+            if (!in_array($field, self::$valid_field_names)) {
56
+                            throw new InvalidParam('fields', "'$field' is not a valid field code.");
57
+            }
52 58
         }
53 59
 
54 60
         $forward_compatible = $request->get_parameter('forward_compatible');
55
-        if (!$forward_compatible) $forward_compatible = "true";
56
-        if (!in_array($forward_compatible, array("true", "false")))
57
-            throw new InvalidParam('forward_compatible');
61
+        if (!$forward_compatible) {
62
+            $forward_compatible = "true";
63
+        }
64
+        if (!in_array($forward_compatible, array("true", "false"))) {
65
+                    throw new InvalidParam('forward_compatible');
66
+        }
58 67
         $forward_compatible = ($forward_compatible == "true");
59 68
 
60 69
         # Load the attributes (all of them).
@@ -66,8 +75,7 @@  discard block
 block discarded – undo
66 75
         # to the results.
67 76
 
68 77
         $results = array();
69
-        foreach ($acodes as $acode)
70
-        {
78
+        foreach ($acodes as $acode) {
71 79
             /* Please note, that the $attr variable from the $attrdict dictionary
72 80
              * below is NOT fully compatible with the interface of the "attribute"
73 81
              * method. Some of $attr's fields are private and should not be exposed,
@@ -101,8 +109,7 @@  discard block
 block discarded – undo
101 109
         # in the $attrdict because currently we have no way of knowing then they
102 110
         # change.)
103 111
 
104
-        if (in_array('local_icon_url', $fields))
105
-        {
112
+        if (in_array('local_icon_url', $fields)) {
106 113
             $tmp = Db::select_all("
107 114
                 select id, icon_large
108 115
                 from cache_attrib
@@ -133,8 +140,9 @@  discard block
 block discarded – undo
133 140
                 continue;
134 141
             }
135 142
             $clean_row = array();
136
-            foreach ($fields as $field)
137
-                $clean_row[$field] = $attr_ref[$field];
143
+            foreach ($fields as $field) {
144
+                            $clean_row[$field] = $attr_ref[$field];
145
+            }
138 146
             $attr_ref = $clean_row;
139 147
         }
140 148
 
Please login to merge, or discard this patch.
htdocs/okapi/services/attrs/attribute_index.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,13 +30,19 @@  discard block
 block discarded – undo
30 30
         # Read the parameters.
31 31
 
32 32
         $langpref = $request->get_parameter('langpref');
33
-        if (!$langpref) $langpref = "en";
33
+        if (!$langpref) {
34
+            $langpref = "en";
35
+        }
34 36
 
35 37
         $fields = $request->get_parameter('fields');
36
-        if (!$fields) $fields = "name";
38
+        if (!$fields) {
39
+            $fields = "name";
40
+        }
37 41
 
38 42
         $only_locally_used = $request->get_parameter('only_locally_used');
39
-        if (!$only_locally_used) $only_locally_used = "false";
43
+        if (!$only_locally_used) {
44
+            $only_locally_used = "false";
45
+        }
40 46
         $only_locally_used = ($only_locally_used == "true");
41 47
 
42 48
         # Get the list of attributes and filter the A-codes based on the
@@ -45,8 +51,7 @@  discard block
 block discarded – undo
45 51
         require_once 'attr_helper.inc.php';
46 52
         $attrdict = AttrHelper::get_attrdict();
47 53
         $acodes = array();
48
-        foreach ($attrdict as $acode => &$attr_ref)
49
-        {
54
+        foreach ($attrdict as $acode => &$attr_ref) {
50 55
             if ($only_locally_used && ($attr_ref['internal_id'] === null)) {
51 56
                 /* Skip. */
52 57
                 continue;
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/submit.php 1 patch
Braces   +78 added lines, -127 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
  * the Consumer did anything wrong (it's the user who did). This exception shouldn't
21 21
  * be used outside of this file.
22 22
  */
23
-class CannotPublishException extends Exception {}
23
+class CannotPublishException extends Exception
24
+{
25
+}
24 26
 
25 27
 class WebService
26 28
 {
@@ -43,10 +45,14 @@  discard block
 block discarded – undo
43 45
         # "call").
44 46
 
45 47
         $cache_code = $request->get_parameter('cache_code');
46
-        if (!$cache_code) throw new ParamMissing('cache_code');
48
+        if (!$cache_code) {
49
+            throw new ParamMissing('cache_code');
50
+        }
47 51
 
48 52
         $logtype = $request->get_parameter('logtype');
49
-        if (!$logtype) throw new ParamMissing('logtype');
53
+        if (!$logtype) {
54
+            throw new ParamMissing('logtype');
55
+        }
50 56
         if (!in_array($logtype, array(
51 57
             'Found it', "Didn't find it", 'Comment', 'Will attend', 'Attended'
52 58
         ))) {
@@ -54,16 +60,20 @@  discard block
 block discarded – undo
54 60
         }
55 61
 
56 62
         $comment = $request->get_parameter('comment');
57
-        if (!$comment) $comment = "";
63
+        if (!$comment) {
64
+            $comment = "";
65
+        }
58 66
 
59 67
         $comment_format = $request->get_parameter('comment_format');
60
-        if (!$comment_format) $comment_format = "auto";
61
-        if (!in_array($comment_format, array('auto', 'html', 'plaintext')))
62
-            throw new InvalidParam('comment_format', $comment_format);
68
+        if (!$comment_format) {
69
+            $comment_format = "auto";
70
+        }
71
+        if (!in_array($comment_format, array('auto', 'html', 'plaintext'))) {
72
+                    throw new InvalidParam('comment_format', $comment_format);
73
+        }
63 74
 
64 75
         $tmp = $request->get_parameter('when');
65
-        if ($tmp)
66
-        {
76
+        if ($tmp) {
67 77
             $when = strtotime($tmp);
68 78
             if ($when < 1) {
69 79
                 throw new InvalidParam(
@@ -77,8 +87,7 @@  discard block
 block discarded – undo
77 87
                     "the past, but NOT in the future."
78 88
                 ));
79 89
             }
80
-        }
81
-        else {
90
+        } else {
82 91
             $when = time();
83 92
         }
84 93
 
@@ -101,8 +110,7 @@  discard block
 block discarded – undo
101 110
                 "Rating is allowed only for 'Found it' and 'Attended' logtypes."
102 111
             );
103 112
         }
104
-        if ($rating !== null && (Settings::get('OC_BRANCH') == 'oc.de'))
105
-        {
113
+        if ($rating !== null && (Settings::get('OC_BRANCH') == 'oc.de')) {
106 114
             # We will remove the rating request and change the success message
107 115
             # (which will be returned IF the rest of the query will meet all the
108 116
             # requirements).
@@ -115,18 +123,19 @@  discard block
 block discarded – undo
115 123
         }
116 124
 
117 125
         $recommend = $request->get_parameter('recommend');
118
-        if (!$recommend) $recommend = 'false';
119
-        if (!in_array($recommend, array('true', 'false')))
120
-            throw new InvalidParam('recommend', "Unknown option: '$recommend'.");
126
+        if (!$recommend) {
127
+            $recommend = 'false';
128
+        }
129
+        if (!in_array($recommend, array('true', 'false'))) {
130
+                    throw new InvalidParam('recommend', "Unknown option: '$recommend'.");
131
+        }
121 132
         $recommend = ($recommend == 'true');
122
-        if ($recommend && $logtype != 'Found it')
123
-        {
133
+        if ($recommend && $logtype != 'Found it') {
124 134
             if ($logtype != 'Attended') {
125 135
                 throw new BadRequest(
126 136
                     "Recommending is allowed only for 'Found it' and 'Attended' logs."
127 137
                 );
128
-            }
129
-            else if (Settings::get('OC_BRANCH') == 'oc.pl') {
138
+            } else if (Settings::get('OC_BRANCH') == 'oc.pl') {
130 139
 
131 140
                 # We will remove the recommendation request and change the success message
132 141
                 # (which will be returned IF the rest of the query will meet all the
@@ -156,9 +165,7 @@  discard block
 block discarded – undo
156 165
         # Parse $needs_maintenance and get rid of it.
157 166
 
158 167
         if ($needs_maintenance) {
159
-            if ($needs_maintenance == 'true') { $needs_maintenance2 = 'true'; }
160
-            else if ($needs_maintenance == 'false') { $needs_maintenance2 = 'null'; }
161
-            else {
168
+            if ($needs_maintenance == 'true') { $needs_maintenance2 = 'true'; } else if ($needs_maintenance == 'false') { $needs_maintenance2 = 'null'; } else {
162 169
                 throw new InvalidParam(
163 170
                     'needs_maintenance', "Unknown option: '$needs_maintenance'."
164 171
                 );
@@ -208,24 +215,21 @@  discard block
 block discarded – undo
208 215
 
209 216
         # Various integrity checks.
210 217
 
211
-        if ($cache['type'] == 'Event')
212
-        {
218
+        if ($cache['type'] == 'Event') {
213 219
             if (!in_array($logtype, array('Will attend', 'Attended', 'Comment'))) {
214 220
                 throw new CannotPublishException(_(
215 221
                     'This cache is an Event cache. You cannot "Find" it (but '.
216 222
                     'you can attend it, or comment on it)!'
217 223
                 ));
218 224
             }
219
-        }
220
-        else  # type != event
225
+        } else  # type != event
221 226
         {
222 227
             if (in_array($logtype, array('Will attend', 'Attended'))) {
223 228
                 throw new CannotPublishException(_(
224 229
                     'This cache is NOT an Event cache. You cannot "Attend" it '.
225 230
                     '(but you can find it, or comment on it)!'
226 231
                 ));
227
-            }
228
-            else if (!in_array($logtype, array('Found it', "Didn't find it", 'Comment'))) {
232
+            } else if (!in_array($logtype, array('Found it', "Didn't find it", 'Comment'))) {
229 233
                 throw new Exception("Unknown log entry - should be documented here.");
230 234
             }
231 235
         }
@@ -237,8 +241,7 @@  discard block
 block discarded – undo
237 241
 
238 242
         # Password check.
239 243
 
240
-        if (($logtype == 'Found it' || $logtype == 'Attended') && $cache['req_passwd'])
241
-        {
244
+        if (($logtype == 'Found it' || $logtype == 'Attended') && $cache['req_passwd']) {
242 245
             $valid_password = Db::select_value("
243 246
                 select logpw
244 247
                 from caches
@@ -264,8 +267,7 @@  discard block
 block discarded – undo
264 267
         # original format, while still being able to re-create the comment in
265 268
         # its original form.
266 269
 
267
-        if ($comment_format == 'plaintext')
268
-        {
270
+        if ($comment_format == 'plaintext') {
269 271
             # This code is identical to the plaintext processing in OC code,
270 272
             # including a space handling bug: Multiple consecutive spaces will
271 273
             # get semantically lost in the generated HTML.
@@ -273,12 +275,9 @@  discard block
 block discarded – undo
273 275
             $formatted_comment = htmlspecialchars($comment, ENT_COMPAT);
274 276
             $formatted_comment = nl2br($formatted_comment);
275 277
 
276
-            if (Settings::get('OC_BRANCH') == 'oc.de')
277
-            {
278
+            if (Settings::get('OC_BRANCH') == 'oc.de') {
278 279
                 $value_for_text_html_field = 0;
279
-            }
280
-            else
281
-            {
280
+            } else {
282 281
                 # 'text_html' = 0 (false) is broken in OCPL code and has been
283 282
                 # deprecated; OCPL code was changed to always set it to 1 (true).
284 283
                 # For OKAPI, the value has been changed from 0 to 1 with commit
@@ -289,26 +288,21 @@  discard block
 block discarded – undo
289 288
 
290 289
                 $value_for_text_html_field = 1;
291 290
             }
292
-        }
293
-        elseif ($comment_format == 'auto')
294
-        {
291
+        } elseif ($comment_format == 'auto') {
295 292
             # 'Auto' is for backward compatibility. Before the "comment_format"
296 293
             # was introduced, OKAPI used a weird format in between (it allowed
297 294
             # HTML, but applied nl2br too).
298 295
 
299 296
             $formatted_comment = nl2br($comment);
300 297
             $value_for_text_html_field = 1;
301
-        }
302
-        else
303
-        {
298
+        } else {
304 299
             $formatted_comment = $comment;
305 300
 
306 301
             # For user-supplied HTML comments, OC sites require us to do
307 302
             # additional HTML purification prior to the insertion into the
308 303
             # database.
309 304
 
310
-            if (Settings::get('OC_BRANCH') == 'oc.de')
311
-            {
305
+            if (Settings::get('OC_BRANCH') == 'oc.de') {
312 306
                 # NOTICE: We are including EXTERNAL OCDE library here! This
313 307
                 # code does not belong to OKAPI!
314 308
 
@@ -318,9 +312,7 @@  discard block
 block discarded – undo
318 312
 
319 313
                 $purifier = new \OcHTMLPurifier($opt);
320 314
                 $formatted_comment = $purifier->purify($formatted_comment);
321
-            }
322
-            else
323
-            {
315
+            } else {
324 316
                 # TODO: Add OCPL HTML filtering.
325 317
                 # See https://github.com/opencaching/okapi/issues/412.
326 318
             }
@@ -328,8 +320,7 @@  discard block
 block discarded – undo
328 320
             $value_for_text_html_field = 1;
329 321
         }
330 322
 
331
-        if (Settings::get('OC_BRANCH') == 'oc.pl')
332
-        {
323
+        if (Settings::get('OC_BRANCH') == 'oc.pl') {
333 324
             # The HTML processing in OCPL code is broken. Effectively, it
334 325
             # will decode &lt; &gt; and &amp; (and maybe other things?)
335 326
             # before display so that text contents may be interpreted as HTML.
@@ -365,8 +356,7 @@  discard block
 block discarded – undo
365 356
 
366 357
         # Duplicate detection.
367 358
 
368
-        if ($on_duplicate != 'continue')
369
-        {
359
+        if ($on_duplicate != 'continue') {
370 360
             # Attempt to find a log entry made by the same user, for the same cache, with
371 361
             # the same date, type, comment, etc. Note, that these are not ALL the fields
372 362
             # we could check, but should work ok in most cases. Also note, that we
@@ -386,15 +376,11 @@  discard block
 block discarded – undo
386 376
                     ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "and deleted = 0" : "")."
387 377
                 limit 1
388 378
             ");
389
-            if ($duplicate_uuid != null)
390
-            {
391
-                if ($on_duplicate == 'silent_success')
392
-                {
379
+            if ($duplicate_uuid != null) {
380
+                if ($on_duplicate == 'silent_success') {
393 381
                     # Act as if the log has been submitted successfully.
394 382
                     return $duplicate_uuid;
395
-                }
396
-                elseif ($on_duplicate == 'user_error')
397
-                {
383
+                } elseif ($on_duplicate == 'user_error') {
398 384
                     throw new CannotPublishException(_(
399 385
                         "You have already submitted a log entry with exactly ".
400 386
                         "the same contents."
@@ -440,8 +426,7 @@  discard block
 block discarded – undo
440 426
         # user submit a rating for it? Anyway, I will stick to the procedure
441 427
         # found in log.php. On the bright side, it's fail-safe.
442 428
 
443
-        if ($rating)
444
-        {
429
+        if ($rating) {
445 430
             $has_already_rated = Db::select_value("
446 431
                 select 1
447 432
                 from scores
@@ -459,8 +444,7 @@  discard block
 block discarded – undo
459 444
 
460 445
         # If user wants to recommend...
461 446
 
462
-        if ($recommend)
463
-        {
447
+        if ($recommend) {
464 448
             # Do the same "fail-safety" check as we did for the rating.
465 449
 
466 450
             $already_recommended = Db::select_value("
@@ -497,32 +481,26 @@  discard block
 block discarded – undo
497 481
         # If user checked the "needs_maintenance(2)" flag for OCPL, we will shuffle things
498 482
         # a little...
499 483
 
500
-        if (Settings::get('OC_BRANCH') == 'oc.pl' && $needs_maintenance2 == 'true')
501
-        {
484
+        if (Settings::get('OC_BRANCH') == 'oc.pl' && $needs_maintenance2 == 'true') {
502 485
             # If we're here, then we also know that the "Needs maintenance" log
503 486
             # type is supported by this OC site. However, it's a separate log
504 487
             # type, so we might have to submit two log types together:
505 488
 
506
-            if ($logtype == 'Comment')
507
-            {
489
+            if ($logtype == 'Comment') {
508 490
                 # If user submits a "Comment", we'll just change its type to
509 491
                 # "Needs maintenance". Only one log entry will be issued.
510 492
 
511 493
                 $logtype = 'Needs maintenance';
512 494
                 $second_logtype = null;
513 495
                 $second_formatted_comment = null;
514
-            }
515
-            elseif ($logtype == 'Found it')
516
-            {
496
+            } elseif ($logtype == 'Found it') {
517 497
                 # If "Found it", then we'll issue two log entries: one "Found
518 498
                 # it" with the original comment, and second one "Needs
519 499
                 # maintenance" with empty comment.
520 500
 
521 501
                 $second_logtype = 'Needs maintenance';
522 502
                 $second_formatted_comment = "";
523
-            }
524
-            elseif ($logtype == "Didn't find it")
525
-            {
503
+            } elseif ($logtype == "Didn't find it") {
526 504
                 # If "Didn't find it", then we'll issue two log entries, but this time
527 505
                 # we'll do this the other way around. The first "Didn't find it" entry
528 506
                 # will have an empty comment. We will move the comment to the second
@@ -532,22 +510,17 @@  discard block
 block discarded – undo
532 510
                 $second_logtype = 'Needs maintenance';
533 511
                 $second_formatted_comment = $formatted_comment;
534 512
                 $formatted_comment = "";
535
-            }
536
-            else if ($logtype == 'Will attend' || $logtype == 'Attended')
537
-            {
513
+            } else if ($logtype == 'Will attend' || $logtype == 'Attended') {
538 514
                 # OC branches which allow maintenance logs, still don't allow them on
539 515
                 # event caches.
540 516
 
541 517
                 throw new CannotPublishException(_(
542 518
                     "Event caches cannot \"need maintenance\"."
543 519
                 ));
544
-            }
545
-            else {
520
+            } else {
546 521
                 throw new Exception();
547 522
             }
548
-        }
549
-        else
550
-        {
523
+        } else {
551 524
             # User didn't check the "Needs maintenance" flag OR "Needs maintenance"
552 525
             # log type isn't supported by this server.
553 526
 
@@ -567,8 +540,7 @@  discard block
 block discarded – undo
567 540
         );
568 541
         self::increment_cache_stats($cache['internal_id'], $when, $logtype);
569 542
         self::increment_user_stats($user['internal_id'], $logtype);
570
-        if ($second_logtype != null)
571
-        {
543
+        if ($second_logtype != null) {
572 544
             # Reminder: This will only be called for OCPL branch.
573 545
 
574 546
             $log_uuids[] = self::insert_log_row(
@@ -587,8 +559,7 @@  discard block
 block discarded – undo
587 559
 
588 560
         # Save the rating.
589 561
 
590
-        if ($rating)
591
-        {
562
+        if ($rating) {
592 563
             # This code will be called for OCPL branch only. Earlier, we made sure,
593 564
             # to set $rating to null, if we're running on OCDE.
594 565
 
@@ -602,8 +573,7 @@  discard block
 block discarded – undo
602 573
             # but presumably has some deep logic into it. See also here (Polish):
603 574
             # http://wiki.opencaching.pl/index.php/Oceny_skrzynek
604 575
 
605
-            switch ($rating)
606
-            {
576
+            switch ($rating) {
607 577
                 case 1: $db_score = -2.0; break;
608 578
                 case 2: $db_score = -0.5; break;
609 579
                 case 3: $db_score = 0.7; break;
@@ -632,10 +602,8 @@  discard block
 block discarded – undo
632 602
 
633 603
         # Save recommendation.
634 604
 
635
-        if ($recommend)
636
-        {
637
-            if (Db::field_exists('cache_rating', 'rating_date'))
638
-            {
605
+        if ($recommend) {
606
+            if (Db::field_exists('cache_rating', 'rating_date')) {
639 607
                 Db::execute("
640 608
                     insert into cache_rating (user_id, cache_id, rating_date)
641 609
                     values (
@@ -644,9 +612,7 @@  discard block
 block discarded – undo
644 612
                         from_unixtime('".Db::escape_string($when)."')
645 613
                     );
646 614
                 ");
647
-            }
648
-            else
649
-            {
615
+            } else {
650 616
                 Db::execute("
651 617
                     insert into cache_rating (user_id, cache_id)
652 618
                     values (
@@ -680,14 +646,15 @@  discard block
 block discarded – undo
680 646
         # This is the "real" entry point. A wrapper for the _call method.
681 647
 
682 648
         $langpref = $request->get_parameter('langpref');
683
-        if (!$langpref) $langpref = "en";
649
+        if (!$langpref) {
650
+            $langpref = "en";
651
+        }
684 652
 
685 653
         # Error messages thrown via CannotPublishException exceptions should be localized.
686 654
         # They will be delivered for end user to display in his language.
687 655
 
688 656
         Okapi::gettext_domain_init(explode("|", $langpref));
689
-        try
690
-        {
657
+        try {
691 658
             # If appropriate, $success_message might be changed inside the _call.
692 659
             self::$success_message = _("Your cache log entry was posted successfully.");
693 660
             $log_uuids = self::_call($request);
@@ -698,9 +665,7 @@  discard block
 block discarded – undo
698 665
                 'log_uuids' => $log_uuids
699 666
             );
700 667
             Okapi::gettext_domain_restore();
701
-        }
702
-        catch (CannotPublishException $e)
703
-        {
668
+        } catch (CannotPublishException $e) {
704 669
             Okapi::gettext_domain_restore();
705 670
             $result = array(
706 671
                 'success' => false,
@@ -715,17 +680,13 @@  discard block
 block discarded – undo
715 680
 
716 681
     private static function increment_cache_stats($cache_internal_id, $when, $logtype)
717 682
     {
718
-        if (Settings::get('OC_BRANCH') == 'oc.de')
719
-        {
683
+        if (Settings::get('OC_BRANCH') == 'oc.de') {
720 684
             # OCDE handles cache stats updates using triggers. So, they are already
721 685
             # incremented properly.
722
-        }
723
-        else
724
-        {
686
+        } else {
725 687
             # OCPL doesn't use triggers for this. We need to update manually.
726 688
 
727
-            if ($logtype == 'Found it')
728
-            {
689
+            if ($logtype == 'Found it') {
729 690
                 Db::execute("
730 691
                     update caches
731 692
                     set
@@ -736,25 +697,19 @@  discard block
 block discarded – undo
736 697
                         )
737 698
                     where cache_id = '".Db::escape_string($cache_internal_id)."'
738 699
                 ");
739
-            }
740
-            elseif ($logtype == "Didn't find it")
741
-            {
700
+            } elseif ($logtype == "Didn't find it") {
742 701
                 Db::execute("
743 702
                     update caches
744 703
                     set notfounds = notfounds + 1
745 704
                     where cache_id = '".Db::escape_string($cache_internal_id)."'
746 705
                 ");
747
-            }
748
-            elseif ($logtype == 'Comment')
749
-            {
706
+            } elseif ($logtype == 'Comment') {
750 707
                 Db::execute("
751 708
                     update caches
752 709
                     set notes = notes + 1
753 710
                     where cache_id = '".Db::escape_string($cache_internal_id)."'
754 711
                 ");
755
-            }
756
-            else
757
-            {
712
+            } else {
758 713
                 # This log type is not represented in cache stats.
759 714
             }
760 715
         }
@@ -762,17 +717,13 @@  discard block
 block discarded – undo
762 717
 
763 718
     private static function increment_user_stats($user_internal_id, $logtype)
764 719
     {
765
-        if (Settings::get('OC_BRANCH') == 'oc.de')
766
-        {
720
+        if (Settings::get('OC_BRANCH') == 'oc.de') {
767 721
             # OCDE handles cache stats updates using triggers. So, they are already
768 722
             # incremented properly.
769
-        }
770
-        else
771
-        {
723
+        } else {
772 724
             # OCPL doesn't have triggers for this. We need to update manually.
773 725
 
774
-            switch ($logtype)
775
-            {
726
+            switch ($logtype) {
776 727
                 case 'Found it': $field_to_increment = 'founds_count'; break;
777 728
                 case "Didn't find it": $field_to_increment = 'notfounds_count'; break;
778 729
                 case 'Comment': $field_to_increment = 'log_notes_count'; break;
@@ -791,15 +742,15 @@  discard block
 block discarded – undo
791 742
     private static function insert_log_row(
792 743
         $consumer_key, $cache_internal_id, $user_internal_id, $logtype, $when,
793 744
         $formatted_comment, $text_html, $needs_maintenance2
794
-    )
795
-    {
745
+    ) {
796 746
         if (Settings::get('OC_BRANCH') == 'oc.de') {
797 747
             $needs_maintenance_field_SQL = ', needs_maintenance';
798 748
             if ($needs_maintenance2 == 'true') {
799 749
                 $needs_maintenance_SQL = ',2';
800 750
             } else if ($needs_maintenance2 == 'false') {
801 751
                 $needs_maintenance_SQL = ',1';
802
-            } else {  // 'null'
752
+            } else {
753
+// 'null'
803 754
                 $needs_maintenance_SQL = ',0';
804 755
             }
805 756
         } else {
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/entries.php 1 patch
Braces   +32 added lines, -29 removed lines patch added patch discarded remove patch
@@ -31,35 +31,38 @@  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');
35
-        if ($log_uuids === "")
36
-        {
34
+        if ($log_uuids === null) {
35
+            throw new ParamMissing('log_uuids');
36
+        }
37
+        if ($log_uuids === "") {
37 38
             $log_uuids = array();
39
+        } else {
40
+                    $log_uuids = explode("|", $log_uuids);
38 41
         }
39
-        else
40
-            $log_uuids = explode("|", $log_uuids);
41 42
 
42
-        if ((count($log_uuids) > 500) && (!$request->skip_limits))
43
-            throw new InvalidParam('log_uuids', "Maximum allowed number of referenced ".
43
+        if ((count($log_uuids) > 500) && (!$request->skip_limits)) {
44
+                    throw new InvalidParam('log_uuids', "Maximum allowed number of referenced ".
44 45
                 "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).");
46
+        }
47
+        if (count($log_uuids) != count(array_unique($log_uuids))) {
48
+                    throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
49
+        }
47 50
         $fields = $request->get_parameter('fields');
48
-        if (!$fields) $fields = "date|user|type|comment";
51
+        if (!$fields) {
52
+            $fields = "date|user|type|comment";
53
+        }
49 54
         $fields = explode("|", $fields);
50
-        foreach ($fields as $field)
51
-            if (!in_array($field, self::$valid_field_names))
55
+        foreach ($fields as $field) {
56
+                    if (!in_array($field, self::$valid_field_names))
52 57
                 throw new InvalidParam('fields', "'$field' is not a valid field code.");
58
+        }
53 59
 
54
-        if (Settings::get('OC_BRANCH') == 'oc.de')
55
-        {
60
+        if (Settings::get('OC_BRANCH') == 'oc.de') {
56 61
             $teamentry_field = 'cl.oc_team_comment';
57 62
             $ratingdate_condition = 'and cr.rating_date=cl.date';
58 63
             $needs_maintenance_SQL = 'cl.needs_maintenance';
59 64
             $listing_is_outdated_SQL = 'cl.listing_outdated';
60
-        }
61
-        else
62
-        {
65
+        } else {
63 66
             $teamentry_field = '(cl.type=12)';
64 67
             $ratingdate_condition = '';
65 68
             $needs_maintenance_SQL = 'IF(cl.type=5, 2, IF(cl.type=6, 1, 0))';
@@ -96,8 +99,7 @@  discard block
 block discarded – undo
96 99
         $results = array();
97 100
         $log_id2uuid = array(); /* Maps logs' internal_ids to uuids */
98 101
         $flag_options = array('null', 'false', 'true');
99
-        while ($row = Db::fetch_assoc($rs))
100
-        {
102
+        while ($row = Db::fetch_assoc($rs)) {
101 103
             $results[$row['uuid']] = array(
102 104
                 'uuid' => $row['uuid'],
103 105
                 'cache_code' => $row['cache_code'],
@@ -122,8 +124,7 @@  discard block
 block discarded – undo
122 124
 
123 125
         # fetch images
124 126
 
125
-        if (in_array('images', $fields))
126
-        {
127
+        if (in_array('images', $fields)) {
127 128
             # For OCPL log entry images, pictures.seq currently is always = 1,
128 129
             # while OCDE uses it for ordering the images.
129 130
 
@@ -142,8 +143,7 @@  discard block
 block discarded – undo
142 143
             } else {
143 144
                 $object_type_param = '';
144 145
             }
145
-            while ($row = Db::fetch_assoc($rs))
146
-            {
146
+            while ($row = Db::fetch_assoc($rs)) {
147 147
                 $results[$log_id2uuid[$row['object_id']]]['images'][] =
148 148
                     array(
149 149
                         'uuid' => $row['uuid'],
@@ -158,22 +158,25 @@  discard block
 block discarded – undo
158 158
 
159 159
         # Check which UUIDs were not found and mark them with null.
160 160
 
161
-        foreach ($log_uuids as $log_uuid)
162
-            if (!isset($results[$log_uuid]))
161
+        foreach ($log_uuids as $log_uuid) {
162
+                    if (!isset($results[$log_uuid]))
163 163
                 $results[$log_uuid] = null;
164
+        }
164 165
 
165 166
         # Remove unwanted fields.
166 167
 
167
-        foreach (self::$valid_field_names as $field)
168
-            if (!in_array($field, $fields))
168
+        foreach (self::$valid_field_names as $field) {
169
+                    if (!in_array($field, $fields))
169 170
                 foreach ($results as &$result_ref)
170 171
                     unset($result_ref[$field]);
172
+        }
171 173
 
172 174
         # Order the results in the same order as the input codes were given.
173 175
 
174 176
         $ordered_results = array();
175
-        foreach ($log_uuids as $log_uuid)
176
-            $ordered_results[$log_uuid] = $results[$log_uuid];
177
+        foreach ($log_uuids as $log_uuid) {
178
+                    $ordered_results[$log_uuid] = $results[$log_uuid];
179
+        }
177 180
 
178 181
         return Okapi::formatted_response($request, $ordered_results);
179 182
     }
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/userlogs.php 1 patch
Braces   +22 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,21 +24,31 @@  discard block
 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).
@@ -60,8 +70,7 @@  discard block
 block discarded – undo
60 70
             limit $offset, $limit
61 71
         ");
62 72
         $results = array();
63
-        while ($row = Db::fetch_assoc($rs))
64
-        {
73
+        while ($row = Db::fetch_assoc($rs)) {
65 74
             $results[] = array(
66 75
                 'uuid' => $row['uuid'],
67 76
                 'date' => date('c', $row['date']),
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/images/edit.php 1 patch
Braces   +15 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
  * the Consumer did anything wrong (it's the user who did). This exception shouldn't
20 20
  * be used outside of this file.
21 21
  */
22
-class CannotPublishException extends Exception {}
22
+class CannotPublishException extends Exception
23
+{
24
+}
23 25
 
24 26
 class WebService
25 27
 {
@@ -60,8 +62,9 @@  discard block
 block discarded – undo
60 62
 
61 63
         $is_spoiler = $request->get_parameter('is_spoiler');
62 64
         if ($is_spoiler !== null) {
63
-            if (!in_array($is_spoiler, array('true', 'false')))
64
-                throw new InvalidParam('is_spoiler');
65
+            if (!in_array($is_spoiler, array('true', 'false'))) {
66
+                            throw new InvalidParam('is_spoiler');
67
+            }
65 68
         }
66 69
 
67 70
         $position = LogImagesCommon::validate_position($request);
@@ -98,10 +101,8 @@  discard block
 block discarded – undo
98 101
         }
99 102
 
100 103
         # update position
101
-        if ($position !== null)
102
-        {
103
-            if (Settings::get('OC_BRANCH') == 'oc.pl')
104
-            {
104
+        if ($position !== null) {
105
+            if (Settings::get('OC_BRANCH') == 'oc.pl') {
105 106
                 # OCPL as no arbitrary log picture ordering => ignore position parameter
106 107
                 # and return the picture's current position.
107 108
 
@@ -111,9 +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
116
-            {
115
+            } else {
117 116
                 list($position, $seq) = LogImagesCommon::prepare_position(
118 117
                     $log_internal_id,
119 118
                     $position,
@@ -125,8 +124,7 @@  discard block
 block discarded – undo
125 124
                     select seq from pictures where uuid = '".$image_uuid_escaped."'
126 125
                 ");
127 126
 
128
-                if ($seq != $old_seq)
129
-                {
127
+                if ($seq != $old_seq) {
130 128
                     # First move the edited picture to the end, to make space for rotating.
131 129
                     # Remember that we have no transactions at OC.de. If something goes wrong,
132 130
                     # the image will stay at the end of the list.
@@ -204,11 +202,12 @@  discard block
 block discarded – undo
204 202
         # This is the "real" entry point. A wrapper for the _call method.
205 203
 
206 204
         $langpref = $request->get_parameter('langpref');
207
-        if (!$langpref) $langpref = "en";
205
+        if (!$langpref) {
206
+            $langpref = "en";
207
+        }
208 208
         Okapi::gettext_domain_init(explode("|", $langpref));
209 209
 
210
-        try
211
-        {
210
+        try {
212 211
             $position = self::_call($request);
213 212
             $result = array(
214 213
                 'success' => true,
@@ -216,9 +215,7 @@  discard block
 block discarded – undo
216 215
                 'position' => $position
217 216
             );
218 217
             Okapi::gettext_domain_restore();
219
-        }
220
-        catch (CannotPublishException $e)
221
-        {
218
+        } catch (CannotPublishException $e) {
222 219
             Okapi::gettext_domain_restore();
223 220
             $result = array(
224 221
                 'success' => false,
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/images/delete.php 1 patch
Braces   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,12 +41,9 @@
 block discarded – undo
41 41
         # OCDE sequence numbers may have gaps. So we do not need to adjust
42 42
         # any numbers after deleting from table 'pictures'.
43 43
 
44
-        if (Settings::get('OC_BRANCH') == 'oc.de')
45
-        {
44
+        if (Settings::get('OC_BRANCH') == 'oc.de') {
46 45
             # OCDE does all the housekeeping by triggers
47
-        }
48
-        else
49
-        {
46
+        } else {
50 47
             Db::execute("
51 48
                 INSERT INTO removed_objects (
52 49
                     localID, uuid, type, removed_date, node
Please login to merge, or discard this patch.
htdocs/okapi/services/logs/images/log_images_common.inc.php 1 patch
Braces   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
     function validate_image_uuid($request)
21 21
     {
22 22
         $image_uuid = $request->get_parameter('image_uuid');
23
-        if (!$image_uuid)
24
-            throw new ParamMissing('image_uuid');
23
+        if (!$image_uuid) {
24
+                    throw new ParamMissing('image_uuid');
25
+        }
25 26
 
26 27
         # When uploading images, OCPL stores the user_id of the uploader
27 28
         # in the 'pictures' table. This is redundant to cache_logs.user_id,
@@ -91,8 +92,7 @@  discard block
 block discarded – undo
91 92
 
92 93
     static function prepare_position($log_internal_id, $position, $end_offset)
93 94
     {
94
-        if (Settings::get('OC_BRANCH') == 'oc.de' && $position !== null)
95
-        {
95
+        if (Settings::get('OC_BRANCH') == 'oc.de' && $position !== null) {
96 96
             # Prevent race conditions when creating sequence numbers if a
97 97
             # user tries to upload multiple images simultaneously. With a
98 98
             # few picture uploads per hour - most of them probably witout
@@ -107,16 +107,13 @@  discard block
 block discarded – undo
107 107
             where object_type = 1 and object_id = '".Db::escape_string($log_internal_id)."'
108 108
         ");
109 109
 
110
-        if (Settings::get('OC_BRANCH') == 'oc.pl')
111
-        {
110
+        if (Settings::get('OC_BRANCH') == 'oc.pl') {
112 111
             # Ignore the position parameter, always insert at end.
113 112
             # Remember that this function is NOT called when editing OCPL images.
114 113
 
115 114
             $position = $log_images_count;
116 115
             $seq = 1;
117
-        }
118
-        else
119
-        {
116
+        } else {
120 117
             if ($position === null || $position >= $log_images_count) {
121 118
                 $position = $log_images_count - 1 + $end_offset;
122 119
                 $seq = Db::select_value("
Please login to merge, or discard this patch.