Completed
Pull Request — master (#5)
by Michael
01:57
created

Form::dropdown()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 4
Ratio 33.33 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 3
dl 4
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Smallworld;
4
5
/**
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * SmallWorld
17
 *
18
 * @copyright    The XOOPS Project (https://xoops.org)
19
 * @copyright    2011 Culex
20
 * @license      GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/)
21
 * @package      SmallWorld
22
 * @since        1.0
23
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
24
 */
25
class Form
26
{
27
    /**
28
     * @create a dropdown select
29
     * @param string $name
30
     * @param array  $options
31
     * @param string $selected (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
32
     * @return string
33
     */
34
    public function dropdown($name, array $options, $selected = null)
35
    {
36
        $dropdown = '<select name="' . $name . '" id="' . $name . '">' . '<br>';
37
        $selected = $selected;
0 ignored issues
show
Bug introduced by
Why assign $selected to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
38 View Code Duplication
        foreach ($options as $key => $option) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
            $select   = $selected == $key ? ' selected="yes"' : '';
40
            $dropdown .= '<option value="' . $key . '"' . $select . '>' . $option . '</option>' . '<br>';
41
        }
42
        $dropdown .= '</select>' . '<br>';
43
44
        return $dropdown;
45
    }
46
47
    /**
48
     * @create a radio select
49
     * @param string $name
50
     * @param array  $options
51
     * @param string $selected (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
52
     * @return string
53
     */
54
    public function radio($name, array $options, $selected = null)
55
    {
56
        $selected = $selected;
0 ignored issues
show
Bug introduced by
Why assign $selected to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
57
        $form     = '';
58
        foreach ($options as $value => $option) {
59
            $select = $selected == $value ? ' checked' : ' checked="unchecked"';
60
            $form   .= '<input type="checkbox" name="' . $name . '[]" id="' . $name . '" value="' . $value . '" ' . $select . '> ' . $option . '<br>';
61
        }
62
63
        return $form;
64
    }
65
66
    /**
67
     * @param string $name
68
     * @param array  $options
69
     * @param array  $valuearray
70
     * @param string $selected (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
71
     * @return string
72
     */
73
    public function retrieveRadio($name, $options, $valuearray, $selected = null)
0 ignored issues
show
Unused Code introduced by
The parameter $selected is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
    {
75
        $form = '';
76
        $a    = count($options) - 1;
77
        for ($i = 0; $i <= $a; ++$i) {
78
            if (in_array($i, $valuearray)) {
79
                $form .= '<input type="checkbox" id="' . $name . '-' . $i . '" name="' . $name . '[]" value="' . $i . '" checked>' . $options[$i] . '<br>';
80
            } else {
81
                $form .= '<input type="checkbox" id="' . $name . '-' . $i . '" name="' . $name . '[]" value="' . $i . '" >' . $options[$i] . '<br>';
82
            }
83
        }
84
85
        return $form;
86
    }
87
88
    /**
89
     * @param string $name
90
     * @param string $id
91
     * @param string $class
92
     * @param int    $size   (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $size not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
93
     * @param string $preset (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
94
     * @return string
95
     */
96 View Code Duplication
    public function input($name, $id, $class, $size = null, $preset = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
    {
98
        $s    = $size ?: '50px';
99
        $data = "<input type='text' size='" . $s . "' name='" . $name . "' id='" . $id . "' class='" . $class . "' value='" . $preset . "' >";
100
101
        return $data;
102
    }
103
104
    /**
105
     * @param string $name
106
     * @param string $id
107
     * @param string $preset (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
108
     * @return string
109
     */
110
    public function hidden($name, $id, $preset = null)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
111
    {
112
        $data = "<input type='hidden' name='" . $name . "' value='" . $preset . "' >";
113
114
        return $data;
115
    }
116
117
    /**
118
     * @param string $value
119
     * @return string
120
     */
121
    public function simpleText($value)
122
    {
123
        $data = $value;
124
125
        return $data;
126
    }
127
128
    /**
129
     * @param string  $class
130
     * @param string  $name
131
     * @param         $name2
132
     * @param string  $rel
133
     * @param array   $options
134
     * @param string  $textmore
135
     * @param string  $selected (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
136
     * @param string  $preset   (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
137
     * @return string
138
     */
139
    public function dropdown_add($class, $name, $name2, $rel, array $options, $textmore, $selected = null, $preset = null)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $rel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $textmore is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
140
    {
141
        $dropdown = '<span id="' . $name . '"><input type="text" name="' . $name2 . '[]" value="' . $preset . '">';
142
        $dropdown .= '<select class="smallworld_select" name="' . $name . '[]" id="' . $name . '"></p>' . '<br>';
143 View Code Duplication
        foreach ($options as $key => $option) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
144
            $select   = $selected == $key ? ' selected' : null;
145
            $dropdown .= '<option value="' . $key . '"' . $select . '>' . $option . '</option>' . '<br>';
146
        }
147
        $dropdown .= '</select></span>';
148
149
        return $dropdown;
150
    }
151
152
    /**
153
     * @param string  $class
154
     * @param string  $name
155
     * @param         $name2
156
     * @param string  $rel
157
     * @param int     $size
158
     * @param string  $textmore
159
     * @param string  $preset (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
160
     * @param string  $id     (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $id not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
161
     * @return dynamic|string
162
     */
163 View Code Duplication
    public function input_add($class, $name, $name2, $rel, $size, $textmore, $preset = null, $id = null)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $rel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $textmore is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
164
    {
165
        $s    = $size ?: '50px';
166
        $i    = $id ?: '';
167
        $data = "<span id='" . $name . "'><input type='text' size='" . $s . "' name='" . $name2 . "[]' value='" . $preset . "' id='" . $i . "'></span>";
168
169
        return $data;
170
    }
171
172
    /**
173
     * @param string $name
174
     * @param string $id
175
     * @param string $title
176
     * @param string $rows
177
     * @param string $cols
178
     * @param string $class
179
     * @param string $preset (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
180
     * @return string|textarea
181
     * @return string
182
     */
183
    public function textarea($name, $id, $title, $rows, $cols, $class, $preset = null)
184
    {
185
        return "<textarea name='" . $name . "' id='" . $id . "'  title='" . $title . "' rows='" . $rows . "' cols='" . $cols . "' class='" . $class . "'>" . $preset . '</textarea>';
186
    }
187
188
    /**
189
     * @param string $class
190
     * @param string $name
191
     * @param string $name2
192
     * @param string $rel
193
     * @param array  $options
194
     * @param string $textmore
195
     * @param string $selected      (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selected not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
196
     * @param string $preset        (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $preset not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
197
     * @param string $selectedstart (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selectedstart not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
198
     * @param string $selectedstop  (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selectedstop not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
199
     * @return dynamic|string
200
     */
201
    public function school_add(
202
        $class,
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
203
        $name,
204
        $name2,
205
        $rel,
0 ignored issues
show
Unused Code introduced by
The parameter $rel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
206
        array $options,
207
        $textmore,
0 ignored issues
show
Unused Code introduced by
The parameter $textmore is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
208
        $selected = null,
209
        $preset = null,
210
        $selectedstart = null,
211
        $selectedstop = null
212
    ) {
213
        $dropdown = '<div id="' . $name . '"><p class="smallworld_clonebreaker">' . _SMALLWORLD_SCHOOLNAME . '<input class="school" type="text" value="' . $preset . '" name="' . $name2 . '[]">';
214
        $dropdown .= '<br><br>' . _SMALLWORLD_SCHOOLTYPE . '<select class="school" name="' . $name . '[]" id="' . $name . '"">' . '<br>';
215 View Code Duplication
        foreach ($options as $key => $option) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
            $select   = $selected == $key ? ' selected="selected"' : null;
217
            $dropdown .= '<option  class="school" value="' . $key . '"' . $select . '>' . $option . '</option>' . '<br>';
218
        }
219
        $dropdown .= '</select>';
220
        $dropdown .= '<br><br>';
221
        $dropdown .= _SMALLWORLD_START . '<select class="schooltime" name="schoolstart[]" id="schoolstart">';
222
        $array    = SmallworldGetTimestampsToForm();
223 View Code Duplication
        foreach ($array as $key => $option) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
224
            $selectstart = $selectedstart == $key ? ' selected="selected"' : null;
225
            $dropdown    .= '<option value="' . $key . '"' . $selectstart . '>' . $option . '</option>' . '<br>';
226
        }
227
        $dropdown .= '</select>';
228
        $dropdown .= '<br><br>';
229
        $dropdown .= _SMALLWORLD_STOP . '<select class="schooltime" name="schoolstop[]" id="schoolstop">';
230
        $array    = SmallworldGetTimestampsToForm();
231 View Code Duplication
        foreach ($array as $key => $option) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
232
            $selectstop = $selectedstop == $key ? ' selected="selected"' : null;
233
            $dropdown   .= '<option value="' . $key . '"' . $selectstop . '>' . $option . '</option>' . '<br>';
234
        }
235
        $dropdown .= '</select><br></p></div>';
236
237
        return $dropdown;
238
    }
239
240
    /**
241
     * @param string  $class
242
     * @param string  $name
243
     * @param         $name2
244
     * @param string  $rel
245
     * @param string  $textmore
246
     * @param string  $employer      (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $employer not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
247
     * @param string  $position      (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $position not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
248
     * @param string  $selectedstart (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selectedstart not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
249
     * @param string  $selectedstop  (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $selectedstop not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
250
     * @param string  $description   (optional)
0 ignored issues
show
Documentation introduced by
Should the type for parameter $description not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
251
     * @return dynamic|string
252
     */
253
    public function job(
254
        $class,
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
255
        $name,
256
        $name2,
0 ignored issues
show
Unused Code introduced by
The parameter $name2 is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
257
        $rel,
0 ignored issues
show
Unused Code introduced by
The parameter $rel is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
258
        $textmore,
0 ignored issues
show
Unused Code introduced by
The parameter $textmore is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
259
        $employer = null,
260
        $position = null,
261
        $selectedstart = null,
262
        $selectedstop = null,
263
        $description = null
264
    ) {
265
        $text = '<div id="' . $name . '"><p class="smallworld_clonebreaker">' . _SMALLWORLD_EMPLOYER . '<input class="job" id="job" value="' . $employer . '" type="text" name="employer[]">';
266
        $text .= '<br><br>' . _SMALLWORLD_POSITION . '<input class="job" type="text" value="' . $position . '" name="position[]">';
267
        $text .= '<br><br>' . _SMALLWORLD_JOBSTART . '<input class="jobstart" type="text" value="' . $selectedstart . '" name="jobstart[]">';
268
        $text .= '<br><br>' . _SMALLWORLD_JOBSTOP . '<input class="jobstop" value="' . $selectedstop . '" type="text" name="jobstop[]">';
269
        $text .= '<br><br><span class="jobdescText">' . _SMALLWORLD_DESCRIPTION . '</span><textarea class="jobdesc" name="description[]" rows="20" cols="20">' . $description . '</textarea><br></p></div>';
270
        $text .= '' . '<br>';
271
272
        return $text;
273
    }
274
275
    /**
276
     * @param int $userID
277
     * @return file|string
278
     * @return string
279
     */
280
    public function uploadform($userID)
0 ignored issues
show
Unused Code introduced by
The parameter $userID is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
281
    {
282
        $text = '<form action="../imgupload.php" method="POST" enctype="multipart/form-data">';
283
        $text .= '<input type="file" name="file[]" multiple>';
284
        $text .= '<button type="submit">' . _SMALLWORLD_UPLOADTEXT . '</button>';
285
        $text .= '<span class="file_upload_label">' . _SMALLWORLD_UPLOADFILESTEXT . '</span>';
286
        $text .= '</form>';
287
288
        return $text;
289
    }
290
291
    /**
292
     * @param int    $userID
293
     * @param string $imgurl
294
     * @param string $imgdesc
295
     * @param string $id
296
     * @return dynamic|string
297
     * @return string
298
     */
299
    public function edit_images($userID, $imgurl, $imgdesc, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $userID is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
300
    {
301
        global $xoopsUser;
302
        $text = '<p class="smallworld_clonebreaker"><br>';
303
        $text .= '<table class="smallworld_table" border="0" cellspacing="0" cellpadding="0">';
304
        $text .= '<tr>';
305
        $text .= '<td><img class="smallworld_edit_image" src="' . $imgurl . '" height="100px" width="80px;"></td>';
306
        $text .= '<td><span class="smallworld_editTextSpan">' . _SMALLWORLD_UPLOADDESC . '</span><br><br><textarea class="smallworld_edit_desc" name="imgdesc[]" rows="1" cols="1">' . stripslashes($imgdesc) . '</textarea><br><br></td>';
307
        $text .= '<input value="' . $id . '" type="hidden" name="id[]"></p>';
308
        $text .= '</tr></table>';
309
310
        return $text;
311
    }
312
313
    /**
314
     * @create a radio select
315
     * @param $userid
316
     * @return string
317
     */
318
    public function usersettings($userid)
319
    {
320
        global $xoopsUser, $xoopsDB;
321
322
        $form = "<div style='display:none'><div class='smallworld_usersetings'>";
323
        $form .= '<fieldset><legend>' . _SMALLWORLD_SHOWIFPUBLICORPRIVATE . '</legend>';
324
        $form .= "<form id='perset'>";
325
        if ($xoopsUser) {
326
            $sql    = 'SELECT value FROM ' . $xoopsDB->prefix('smallworld_settings') . ' WHERE userid = ' . (int)$userid;
327
            $result = $xoopsDB->queryF($sql);
328
            $i      = $xoopsDB->getRowsNum($result);
329
            $v      = [];
0 ignored issues
show
Unused Code introduced by
$v is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
330
            if ($i >= 1) {
331
                while (false !== ($row = $xoopsDB->fetchArray($result))) {
332
                    $v    = unserialize(stripslashes($row['value']));
333
                    $pv   = ('1' == $v['posts']) ? ' checked' : '';
334
                    $cv   = ('1' == $v['comments']) ? ' checked' : '';
335
                    $nv   = ('1' == $v['notify']) ? ' checked' : '';
336
                    $form .= '<input type="checkbox" name="usersettings[]" id="posts" value="' . $v['posts'] . '" ' . $pv . '> ' . _SMALLWORLD_SHOWMYPOSTS . '<br>';
337
                    $form .= '<input type="checkbox" name="usersettings[]" id="comments" value="' . $v['comments'] . '" ' . $cv . '> ' . _SMALLWORLD_SHOWMYCOMMENTS . '<br>';
338
                    $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="' . $v['notify'] . '" ' . $nv . '> ' . _SMALLWORLD_NOTIFYME . '<br>';
339
                }
340
            } else {
341
                $form .= '<input type="checkbox" name="usersettings[]" id="posts" value="0"> ' . _SMALLWORLD_SHOWMYPOSTS . '<br>';
342
                $form .= '<input type="checkbox" name="usersettings[]" id="comments" value="0"> ' . _SMALLWORLD_SHOWMYCOMMENTS . '<br>';
343
                $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="0"> ' . _SMALLWORLD_NOTIFYME . '<br>';
344
            }
345
        }
346
        $form .= "<br><input type='submit' id='smallworld_privsave' value='" . _SMALLWORLD_SUBMIT . "' class='smallworld_finish'>";
347
        $form .= '</form></fieldset></div></div>';
348
349
        return $form;
350
    }
351
}
352