stwalkerster /
waca
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /************************************************************************** |
||
| 3 | ********** English Wikipedia Account Request Interface ********** |
||
| 4 | *************************************************************************** |
||
| 5 | ** Wikipedia Account Request Graphic Design by Charles Melbye, ** |
||
| 6 | ** which is licensed under a Creative Commons ** |
||
| 7 | ** Attribution-Noncommercial-Share Alike 3.0 United States License. ** |
||
| 8 | ** ** |
||
| 9 | ** All other code are released under the Public Domain ** |
||
| 10 | ** by the ACC Development Team. ** |
||
| 11 | ** ** |
||
| 12 | ** See CREDITS for the list of developers. ** |
||
| 13 | ***************************************************************************/ |
||
| 14 | |||
| 15 | class StatsInactiveUsers extends StatisticsPage |
||
| 16 | { |
||
| 17 | protected function execute() |
||
|
0 ignored issues
–
show
|
|||
| 18 | { |
||
| 19 | global $smarty; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 20 | |||
| 21 | // this is horrible. |
||
| 22 | // yes, there is business logic in the templates |
||
| 23 | // yes, there was some there before |
||
| 24 | // yes, I have just added to it. |
||
| 25 | // |
||
| 26 | // I'm sorry. |
||
| 27 | // |
||
| 28 | // newinternal will fix this. |
||
| 29 | $date = new DateTime(); |
||
| 30 | $date->modify("-90 days"); |
||
| 31 | |||
| 32 | $smarty->assign('datelimit', $date); |
||
| 33 | |||
| 34 | $showImmune = false; |
||
| 35 | if (isset($_GET['showimmune'])) { |
||
| 36 | $showImmune = true; |
||
| 37 | } |
||
| 38 | $smarty->assign("showImmune", $showImmune); |
||
| 39 | |||
| 40 | $inactiveUsers = User::getAllInactive(gGetDb()); |
||
| 41 | |||
| 42 | $smarty->assign("inactiveUsers", $inactiveUsers); |
||
| 43 | |||
| 44 | return $smarty->fetch("statistics/inactiveusers.tpl"); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getPageName() |
||
| 48 | { |
||
| 49 | return "InactiveUsers"; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getPageTitle() |
||
| 53 | { |
||
| 54 | return "Inactive tool users"; |
||
| 55 | } |
||
| 56 | |||
| 57 | public function isProtected() |
||
| 58 | { |
||
| 59 | return true; |
||
| 60 | } |
||
| 61 | |||
| 62 | public function requiresWikiDatabase() |
||
| 63 | { |
||
| 64 | return false; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: