Passed
Pull Request — master (#5443)
by David
10:35
created
html/inc/prefs_util.inc 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 }
43 43
 
44 44
 abstract class PREF {
45
-    public $desc;       // short description
46
-    public $tooltip;    // longer description, shown as tooltip
47
-    public $tag;        // the pref's primary XML tag
45
+    public $desc; // short description
46
+    public $tooltip; // longer description, shown as tooltip
47
+    public $tag; // the pref's primary XML tag
48 48
     function __construct($desc, $tooltip, $tag) {
49 49
         $this->desc = $desc;
50 50
         $this->tooltip = $tooltip;
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 
123 123
 class PREF_BOOL extends PREF {
124 124
     public $default;
125
-    public $invert;     // show to user in opposite sense
126
-    function __construct($desc, $tooltip, $tag, $default, $invert=false) {
125
+    public $invert; // show to user in opposite sense
126
+    function __construct($desc, $tooltip, $tag, $default, $invert = false) {
127 127
         $this->default = $default;
128 128
         $this->invert = $invert;
129 129
         parent::__construct($desc, $tooltip, $tag);
130 130
     }
131 131
     function show_value($prefs) {
132 132
         $tag = $this->tag;
133
-        $v = $this->invert?!$prefs->$tag:$prefs->$tag;
133
+        $v = $this->invert ? !$prefs->$tag : $prefs->$tag;
134 134
         echo "<td>".readonly_checkbox($v)."</td>";
135 135
     }
136 136
     function show_form($prefs, $error) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
         echo "<td ".VALUE_ATTRS.">"
144 144
             ."<input type=checkbox name=$this->tag "
145
-            . ($checked?"checked":"")
145
+            . ($checked ? "checked" : "")
146 146
             ."></td>
147 147
         ";
148 148
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     function xml_string($prefs) {
156 156
         $tag = $this->tag;
157 157
         return "<$tag>"
158
-            .($prefs->$tag?"1":"0")
158
+            .($prefs->$tag ? "1" : "0")
159 159
             ."</$tag>\n";
160 160
     }
161 161
     function xml_parse(&$prefs, $name, $text) {
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     public $consent_type_id; // the consent_type_id from the consent_type table
176 176
     public $consent_name; // the consent_name to configure
177 177
     public $default;
178
-    public $invert;     // show to user in opposite sense
178
+    public $invert; // show to user in opposite sense
179 179
 
180
-    function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert=false) {
180
+    function __construct($desc, $tooltip, $tag, $consent_type_id, $consent_name, $default, $invert = false) {
181 181
         $this->consent_type_id = $consent_type_id;
182 182
         $this->consent_name = $consent_name;
183 183
         $this->default = $default;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         } else {
241 241
             $value = false;
242 242
         }
243
-        echo "<td>" . readonly_checkbox($value) . "</td>";
243
+        echo "<td>".readonly_checkbox($value)."</td>";
244 244
     }
245 245
     function show_form($user, $error) {
246 246
         $consent_type_id = $this->consent_type_id;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         }
258 258
         echo "<td ".VALUE_ATTRS.">"
259 259
             ."<input type=checkbox name=$this->tag "
260
-            . ($checked?"checked":"")
260
+            . ($checked ? "checked" : "")
261 261
             ."></td>
262 262
         ";
263 263
     }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             "userid=$user->id AND consent_type_id='$consent_type_id$'"
277 277
         );
278 278
 
279
-        if ((($cr) and ($cr->consent_flag!=$flag)) or (!$cr)) {
279
+        if ((($cr) and ($cr->consent_flag != $flag)) or (!$cr)) {
280 280
             $rc = consent_to_a_policy(
281 281
                 $user, $consent_type_id, $flag, 0, 'Webform', time()
282 282
             );
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         // this is the value if they check the box
317 317
     public $scale;
318 318
 
319
-    function __construct($suffix, $min, $max, $default, $scale=1, $default2=0) {
319
+    function __construct($suffix, $min, $max, $default, $scale = 1, $default2 = 0) {
320 320
         $this->suffix = " $suffix";
321 321
         $this->min = $min;
322 322
         $this->max = $max;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         $v .= "$this->suffix ";
336 336
         return $v;
337 337
     }
338
-    function form_str($tag, $v, $had_error, $disabled=false, $id=null) {
338
+    function form_str($tag, $v, $had_error, $disabled = false, $id = null) {
339 339
         if (is_numeric($v)) {
340 340
             $v /= $this->scale;
341 341
             if (!$had_error && ($v < $this->min || $v > $this->max)) {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             }
344 344
         }
345 345
         if ($disabled) $v = "";
346
-        $i = $id?"id=\"$id\"":"";
346
+        $i = $id ? "id=\"$id\"" : "";
347 347
         return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> &nbsp; $this->suffix ";
348 348
     }
349 349
     function form_convert($in, &$out, &$error) {
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
         $text_id = $this->tag;
467 467
         $default = $this->num_spec->get_default();
468 468
         $val = $prefs->$tag;
469
-        $c = $val?"checked":"";
470
-        $d = $val?"":"disabled";
469
+        $c = $val ? "checked" : "";
470
+        $d = $val ? "" : "disabled";
471 471
         echo "<td $attrs>"
472 472
             ."<input type=checkbox id=$checkbox_id onClick=\"checkbox_clicked('$checkbox_id', '$text_id', $default)\" $c> &nbsp;"
473 473
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id)
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 function hour_select($x, $name, $id, $d) {
581 581
     $s = "";
582 582
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
583
-    for ($i=0; $i<24; $i++) {
584
-        $sel = ($x == $i)?"selected":"";
583
+    for ($i = 0; $i < 24; $i++) {
584
+        $sel = ($x == $i) ? "selected" : "";
585 585
         $s .= "<option value=$i $sel> $i:00";
586 586
     }
587 587
     $s .= "</select>\n";
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 
683 683
 // row_defs - Display a value for all 4 venues in one row
684 684
 //
685
-function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
685
+function row_defs($pre, $item, $post, $type, $prefs, $tooltip = null) {
686 686
     $gen = $prefs->$item;
687 687
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
688 688
     $schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--";
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
         echo "<tr>";
695 695
     }
696 696
     echo "<td ".NAME_ATTRS.">$pre</td>";
697
-    row_field($gen,  $type);
698
-    row_field($hom,  $type);
697
+    row_field($gen, $type);
698
+    row_field($hom, $type);
699 699
     row_field($schl, $type);
700
-    row_field($wrk,  $type);
700
+    row_field($wrk, $type);
701 701
     echo "<td align=left>$post</td></tr>\n";
702 702
 }
703 703
 
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 function row_field($value, $type) {
708 708
     echo "<td>";
709 709
     $type = $value === "--" ? "--" : $type;
710
-    switch($type) {
710
+    switch ($type) {
711 711
     case "yesno":
712
-        echo $value ?tra("yes"):tra("no");
712
+        echo $value ?tra("yes") : tra("no");
713 713
         break;
714 714
     case "noyes":
715
-        echo $value ?tra("no"):tra("yes");
715
+        echo $value ?tra("no") : tra("yes");
716 716
         break;
717 717
     case "limit":
718 718
         $x = max_bytes_display_mode($value);
719
-        $y = "$x " . BYTE_ABBR;
719
+        $y = "$x ".BYTE_ABBR;
720 720
         echo $x ? "$y" : tra("no limit");
721 721
         break;
722 722
     case "minutes":
Please login to merge, or discard this patch.