| Conditions | 19 |
| Paths | 85 |
| Total Lines | 107 |
| Code Lines | 70 |
| 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 |
||
| 248 | public function doAlter($confirm = false, $msg = '') |
||
| 249 | { |
||
| 250 | $data = $this->misc->getDatabaseAccessor(); |
||
| 251 | |||
| 252 | if ($confirm) { |
||
| 253 | $this->printTrail($this->subject); |
||
| 254 | $this->printTitle($this->lang['stralter'], 'pg.view.alter'); |
||
| 255 | $this->printMsg($msg); |
||
| 256 | |||
| 257 | // Fetch view info |
||
| 258 | $view = $data->getView($_REQUEST[$this->subject]); |
||
| 259 | |||
| 260 | if ($view->recordCount() > 0) { |
||
| 261 | if (!isset($_POST['name'])) { |
||
| 262 | $_POST['name'] = $view->fields['relname']; |
||
| 263 | } |
||
| 264 | |||
| 265 | if (!isset($_POST['owner'])) { |
||
| 266 | $_POST['owner'] = $view->fields['relowner']; |
||
| 267 | } |
||
| 268 | |||
| 269 | if (!isset($_POST['newschema'])) { |
||
| 270 | $_POST['newschema'] = $view->fields['nspname']; |
||
| 271 | } |
||
| 272 | |||
| 273 | if (!isset($_POST['comment'])) { |
||
| 274 | $_POST['comment'] = $view->fields['relcomment']; |
||
| 275 | } |
||
| 276 | |||
| 277 | echo '<form action="' . \SUBFOLDER . "/src/views/viewproperties\" method=\"post\">\n"; |
||
| 278 | echo "<table>\n"; |
||
| 279 | echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>\n"; |
||
| 280 | echo '<td class="data1">'; |
||
| 281 | echo "<input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
| 282 | htmlspecialchars($_POST['name']), "\" /></td></tr>\n"; |
||
| 283 | |||
| 284 | if ($data->isSuperUser()) { |
||
| 285 | // Fetch all users |
||
| 286 | $users = $data->getUsers(); |
||
| 287 | |||
| 288 | echo "<tr><th class=\"data left required\">{$this->lang['strowner']}</th>\n"; |
||
| 289 | echo '<td class="data1"><select name="owner">'; |
||
| 290 | while (!$users->EOF) { |
||
| 291 | $uname = $users->fields['usename']; |
||
| 292 | echo '<option value="', htmlspecialchars($uname), '"', |
||
| 293 | ($uname == $_POST['owner']) ? ' selected="selected"' : '', '>', htmlspecialchars($uname), "</option>\n"; |
||
| 294 | $users->moveNext(); |
||
| 295 | } |
||
| 296 | echo "</select></td></tr>\n"; |
||
| 297 | } |
||
| 298 | |||
| 299 | if ($data->hasAlterTableSchema()) { |
||
| 300 | $schemas = $data->getSchemas(); |
||
| 301 | echo "<tr><th class=\"data left required\">{$this->lang['strschema']}</th>\n"; |
||
| 302 | echo '<td class="data1"><select name="newschema">'; |
||
| 303 | while (!$schemas->EOF) { |
||
| 304 | $schema = $schemas->fields['nspname']; |
||
| 305 | echo '<option value="', htmlspecialchars($schema), '"', |
||
| 306 | ($schema == $_POST['newschema']) ? ' selected="selected"' : '', '>', htmlspecialchars($schema), "</option>\n"; |
||
| 307 | $schemas->moveNext(); |
||
| 308 | } |
||
| 309 | echo "</select></td></tr>\n"; |
||
| 310 | } |
||
| 311 | |||
| 312 | echo "<tr><th class=\"data left\">{$this->lang['strcomment']}</th>\n"; |
||
| 313 | echo '<td class="data1">'; |
||
| 314 | echo '<textarea rows="3" cols="32" name="comment">', |
||
| 315 | htmlspecialchars($_POST['comment']), "</textarea></td></tr>\n"; |
||
| 316 | echo "</table>\n"; |
||
| 317 | echo "<input type=\"hidden\" name=\"action\" value=\"alter\" />\n"; |
||
| 318 | echo '<input type="hidden" name="view" value="', htmlspecialchars($_REQUEST[$this->subject]), "\" />\n"; |
||
| 319 | echo $this->misc->form; |
||
| 320 | echo "<p><input type=\"submit\" name=\"alter\" value=\"{$this->lang['stralter']}\" />\n"; |
||
| 321 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>\n"; |
||
| 322 | echo "</form>\n"; |
||
| 323 | } else { |
||
| 324 | echo "<p>{$this->lang['strnodata']}</p>\n"; |
||
| 325 | } |
||
| 326 | } else { |
||
| 327 | // For databases that don't allow owner change |
||
| 328 | if (!isset($_POST['owner'])) { |
||
| 329 | $_POST['owner'] = ''; |
||
| 330 | } |
||
| 331 | |||
| 332 | if (!isset($_POST['newschema'])) { |
||
| 333 | $_POST['newschema'] = null; |
||
| 334 | } |
||
| 335 | |||
| 336 | $status = $data->alterView($_POST[$this->subject], $_POST['name'], $_POST['owner'], $_POST['newschema'], $_POST['comment']); |
||
| 337 | if (0 == $status) { |
||
| 338 | // If view has been renamed, need to change to the new name and |
||
| 339 | // reload the browser frame. |
||
| 340 | if ($_POST[$this->subject] != $_POST['name']) { |
||
| 341 | // Jump them to the new view name |
||
| 342 | $_REQUEST[$this->subject] = $_POST['name']; |
||
| 343 | // Force a browser reload |
||
| 344 | $this->misc->setReloadBrowser(true); |
||
| 345 | } |
||
| 346 | // If schema has changed, need to change to the new schema and reload the browser |
||
| 347 | if (!empty($_POST['newschema']) && ($_POST['newschema'] != $data->_schema)) { |
||
| 348 | // Jump them to the new sequence schema |
||
| 349 | $this->misc->setCurrentSchema($_POST['newschema']); |
||
| 350 | $this->misc->setReloadBrowser(true); |
||
| 351 | } |
||
| 352 | $this->doDefault($this->lang['strviewaltered']); |
||
| 353 | } else { |
||
| 354 | $this->doAlter(true, $this->lang['strviewalteredbad']); |
||
| 355 | } |
||
| 359 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.