| Conditions | 7 |
| Paths | 36 |
| Total Lines | 129 |
| Code Lines | 63 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 140 | function show_manage_user_form($user) { |
||
| 141 | global $special_user_bitfield; |
||
| 142 | $Nbf = sizeof($special_user_bitfield); |
||
| 143 | |||
| 144 | admin_page_head("Management $user->name"); |
||
| 145 | |||
| 146 | if (!defined("POST_REPORT_EMAILS")) { |
||
| 147 | echo "<p><font color='RED'> |
||
| 148 | There is no administrative email address defined for reporting problems |
||
| 149 | or abuse in the forums. Please define POST_REPORT_EMAILS in project.inc |
||
| 150 | </font></p>\n"; |
||
| 151 | } |
||
| 152 | |||
| 153 | echo "<form name='manage_user' action=manage_user.php method='POST'> |
||
| 154 | <input type='hidden' name='userid' value='". $user->id."'> |
||
| 155 | "; |
||
| 156 | |||
| 157 | start_table(); |
||
| 158 | |||
| 159 | |||
| 160 | row1("<b>User: </b> $user->name <div align='right'> |
||
| 161 | <input class=\"btn btn-danger\" name=\"delete_user\" type=\"submit\" value=\"Delete user\"> |
||
| 162 | </div>" |
||
| 163 | ); |
||
| 164 | |||
| 165 | show_user_summary_public($user); |
||
| 166 | show_profile_link_ops($user); |
||
| 167 | row2("Email:", "$user->email_addr"); |
||
| 168 | project_user_summary($user); |
||
| 169 | end_table(); |
||
| 170 | project_user_page_private($user); |
||
| 171 | |||
| 172 | echo "</form>\n"; |
||
| 173 | |||
| 174 | |||
| 175 | // Special User status: |
||
| 176 | |||
| 177 | echo "\n\n<P> |
||
| 178 | <table width='100%'><tr> |
||
| 179 | <td width='50%' valign='TOP'> \n"; |
||
| 180 | |||
| 181 | echo "<form name='special_user' action=manage_user.php method=\"POST\"> |
||
| 182 | <input type='hidden' name='userid' value='".$user->id."'> |
||
| 183 | "; |
||
| 184 | |||
| 185 | start_table(); |
||
| 186 | row1("Special User Status"); |
||
| 187 | |||
| 188 | echo "<tr>\n"; |
||
| 189 | for ($i=0; $i<$Nbf; $i++) { |
||
| 190 | $bit = substr($user->prefs->special_user, $i, 1); |
||
| 191 | echo "<tr><td><input type='checkbox'' name='special_user_".$i."' value='1'"; |
||
| 192 | if ($bit == 1) { |
||
| 193 | echo " checked='checked'"; |
||
| 194 | } |
||
| 195 | echo ">". $special_user_bitfield[$i] ."</td></tr>\n"; |
||
| 196 | } |
||
| 197 | echo "</tr>"; |
||
| 198 | |||
| 199 | echo "</tr><td colspan=$Nbf align='RIGHT'> |
||
| 200 | <input name='special_user' type='SUBMIT' value='Update'> |
||
| 201 | </td></tr> |
||
| 202 | "; |
||
| 203 | end_table(); |
||
| 204 | echo "</form>\n"; |
||
| 205 | |||
| 206 | echo "\n\n</td><td valign='TOP'>\n\n"; |
||
| 207 | |||
| 208 | |||
| 209 | // Suspended posting privileges |
||
| 210 | |||
| 211 | echo "<form name='banishment' action=manage_user.php method=\"POST\"> |
||
| 212 | <input type='hidden' name='userid' value='".$user->id."'> |
||
| 213 | "; |
||
| 214 | start_table(); |
||
| 215 | row1("Suspension"); |
||
| 216 | |||
| 217 | if ($user->prefs->banished_until) { |
||
| 218 | $dt = $user->prefs->banished_until - time(); |
||
| 219 | if ($dt > 0) { |
||
| 220 | $x = " Suspended until " . time_str($user->prefs->banished_until) |
||
| 221 | ."<br/> (Expires in " . time_diff($dt) .")" ; |
||
| 222 | } else { |
||
| 223 | $x = " last suspended " . time_str($user->prefs->banished_until); |
||
| 224 | } |
||
| 225 | row1($x); |
||
| 226 | } else { |
||
| 227 | $dt = 0; |
||
| 228 | } |
||
| 229 | |||
| 230 | echo "<tr><td> |
||
| 231 | Suspend user for: |
||
| 232 | <blockquote> |
||
| 233 | <input type='radio' name='suspend_for' value='3600'> 1 hour <br/> |
||
| 234 | <input type='radio' name='suspend_for' value='7200'> 2 hours <br/> |
||
| 235 | <input type='radio' name='suspend_for' value='18000'> 6 hours <br/> |
||
| 236 | <input type='radio' name='suspend_for' value='36000'> 12 hours <br/> |
||
| 237 | <input type='radio' name='suspend_for' value='86400'> 24 hours <br/> |
||
| 238 | "; |
||
| 239 | echo " |
||
| 240 | <input type='radio' name='suspend_for' value='172800'> 48 hours <br/> |
||
| 241 | <input type='radio' name='suspend_for' value='",86400*7,"'> 1 week <br/> |
||
| 242 | <input type='radio' name='suspend_for' value='",86400*14,"'> 2 weeks <br/> |
||
| 243 | "; |
||
| 244 | |||
| 245 | if ($dt>0) { |
||
| 246 | echo " |
||
| 247 | <input type='radio' name='suspend_for' value='-1'> <b>unsuspend</b> <br/>"; |
||
| 248 | } |
||
| 249 | echo " |
||
| 250 | </blockquote> |
||
| 251 | |||
| 252 | "; |
||
| 253 | |||
| 254 | echo "<P>Reason (required):\n"; |
||
| 255 | echo "<textarea name='suspend_reason' cols='40' rows='4'></textarea>"; |
||
| 256 | echo "<br><font size='-2' >The reason will be sent to both the user |
||
| 257 | and to the project administrators.</font>\n"; |
||
| 258 | |||
| 259 | |||
| 260 | echo "<p align='RIGHT'><input name='suspend_submit' type='SUBMIT' value='Update'></P>\n"; |
||
| 261 | echo " </td></tr>\n"; |
||
| 262 | |||
| 263 | end_table(); |
||
| 264 | echo "</form>\n"; |
||
| 265 | |||
| 266 | echo "</td></tr> </table>\n"; |
||
| 267 | |||
| 268 | admin_page_tail(); |
||
| 269 | } |
||
| 310 |