mdaniels5757 /
waca
| 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 | // load the configuration |
||||||
| 16 | require_once 'config.inc.php'; |
||||||
| 17 | |||||||
| 18 | // Get all the classes. |
||||||
| 19 | require_once 'functions.php'; |
||||||
| 20 | initialiseSession(); |
||||||
| 21 | require_once 'includes/PdoDatabase.php'; |
||||||
| 22 | require_once 'includes/SmartyInit.php'; |
||||||
| 23 | require_once 'includes/session.php'; |
||||||
| 24 | |||||||
| 25 | // Check to see if the database is unavailable. |
||||||
| 26 | // Uses the false variable as its the internal interface. |
||||||
| 27 | if (Offline::isOffline()) { |
||||||
| 28 | echo Offline::getOfflineMessage(false); |
||||||
| 29 | die(); |
||||||
| 30 | } |
||||||
| 31 | |||||||
| 32 | // Initialize the class objects. |
||||||
| 33 | $session = new session(); |
||||||
| 34 | |||||||
| 35 | #region User search |
||||||
| 36 | |||||||
| 37 | if (isset($_GET['usersearch'])) { |
||||||
| 38 | $user = User::getByUsername($_GET['usersearch'], gGetDb()); |
||||||
| 39 | |||||||
| 40 | if ($user != false) { |
||||||
| 41 | header("Location: $baseurl/statistics.php?page=Users&user={$user->getId()}"); |
||||||
| 42 | die(); |
||||||
| 43 | } |
||||||
| 44 | } |
||||||
| 45 | |||||||
| 46 | #endregion |
||||||
| 47 | |||||||
| 48 | // Display the header of the interface. |
||||||
| 49 | BootstrapSkin::displayInternalHeader(); |
||||||
| 50 | |||||||
| 51 | // A content block is created if the action is none of the above. |
||||||
| 52 | // This block would later be used to keep all the HTML except the header and footer. |
||||||
| 53 | $out = "<div class=\"row-fluid\"><div id=\"span12\">"; |
||||||
| 54 | BootstrapSkin::pushTagStack("</div>"); |
||||||
| 55 | BootstrapSkin::pushTagStack("</div>"); |
||||||
| 56 | echo $out; |
||||||
| 57 | |||||||
| 58 | #region Checks if the current user has admin rights. |
||||||
| 59 | |||||||
| 60 | if (User::getCurrent()->isCommunityUser()) { |
||||||
| 61 | showlogin(); |
||||||
| 62 | BootstrapSkin::displayInternalFooter(); |
||||||
| 63 | die(); |
||||||
| 64 | } |
||||||
| 65 | |||||||
| 66 | if (!User::getCurrent()->isAdmin()) { |
||||||
| 67 | // Displays both the error message and the footer of the interface. |
||||||
| 68 | BootstrapSkin::displayAlertBox( |
||||||
| 69 | "I'm sorry, but, this page is restricted to administrators only.", |
||||||
| 70 | "alert-error", |
||||||
| 71 | "Access Denied", |
||||||
| 72 | true, |
||||||
| 73 | false); |
||||||
| 74 | BootstrapSkin::displayInternalFooter(); |
||||||
| 75 | die(); |
||||||
| 76 | } |
||||||
| 77 | #endregion |
||||||
| 78 | |||||||
| 79 | #region user access actions |
||||||
| 80 | |||||||
| 81 | if (isset ($_GET['approve'])) { |
||||||
| 82 | $user = User::getById($_GET['approve'], gGetDb()); |
||||||
| 83 | |||||||
| 84 | if ($user == false) { |
||||||
| 85 | BootstrapSkin::displayAlertBox( |
||||||
| 86 | "Sorry, the user you are trying to approve could not be found.", |
||||||
| 87 | "alert-error", |
||||||
| 88 | "Error", |
||||||
| 89 | true, |
||||||
| 90 | false); |
||||||
| 91 | BootstrapSkin::displayInternalFooter(); |
||||||
| 92 | die(); |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | if ($user->isUser() || $user->isAdmin()) { |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
The method
isUser() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 96 | BootstrapSkin::displayAlertBox( |
||||||
| 97 | "Sorry, the user you are trying to approve has already been approved.", |
||||||
| 98 | "alert-error", |
||||||
| 99 | "Error", |
||||||
| 100 | true, |
||||||
| 101 | false); |
||||||
| 102 | BootstrapSkin::displayInternalFooter(); |
||||||
| 103 | die(); |
||||||
| 104 | } |
||||||
| 105 | |||||||
| 106 | $user->approve(); |
||||||
|
0 ignored issues
–
show
The method
approve() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 107 | |||||||
| 108 | BootstrapSkin::displayAlertBox( |
||||||
| 109 | "Approved user " . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'), |
||||||
|
0 ignored issues
–
show
The method
getUsername() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as AntiSpoofCache or User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 110 | "alert-info", |
||||||
| 111 | "", |
||||||
| 112 | false); |
||||||
| 113 | |||||||
| 114 | Notification::userApproved($user); |
||||||
| 115 | |||||||
| 116 | $headers = 'From: [email protected]'; |
||||||
| 117 | // TODO: move to template? |
||||||
| 118 | mail($user->getEmail(), "ACC Account Approved", "Dear " . $user->getOnWikiName() . ",\nYour account " . $user->getUsername() . " has been approved by " . User::getCurrent()->getUsername() . ". To login please go to $baseurl/acc.php.\nPlease note that if you cannot login immediately, we may be updating your identification information in the system. Please let us know if you continue to have issues if you cannot login after 12 hours pass from the time you receive this approval.\n- The English Wikipedia Account Creation Team", $headers); |
||||||
|
0 ignored issues
–
show
The method
getOnWikiName() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
getEmail() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User or Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 119 | BootstrapSkin::displayInternalFooter(); |
||||||
| 120 | die(); |
||||||
| 121 | } |
||||||
| 122 | |||||||
| 123 | if (isset ($_GET['demote'])) { |
||||||
| 124 | $user = User::getById($_GET['demote'], gGetDb()); |
||||||
| 125 | |||||||
| 126 | if ($user == false) { |
||||||
| 127 | BootstrapSkin::displayAlertBox( |
||||||
| 128 | "Sorry, the user you are trying to demote could not be found.", |
||||||
| 129 | "alert-error", |
||||||
| 130 | "Error", |
||||||
| 131 | true, |
||||||
| 132 | false); |
||||||
| 133 | BootstrapSkin::displayInternalFooter(); |
||||||
| 134 | die(); |
||||||
| 135 | } |
||||||
| 136 | |||||||
| 137 | if (!$user->isAdmin()) { |
||||||
| 138 | BootstrapSkin::displayAlertBox( |
||||||
| 139 | "Sorry, the user you are trying to demote is not an admin.", |
||||||
| 140 | "alert-error", |
||||||
| 141 | "Error", |
||||||
| 142 | true, |
||||||
| 143 | false); |
||||||
| 144 | BootstrapSkin::displayInternalFooter(); |
||||||
| 145 | die(); |
||||||
| 146 | } |
||||||
| 147 | |||||||
| 148 | if (!isset($_POST['reason'])) { |
||||||
| 149 | |||||||
| 150 | global $smarty; |
||||||
| 151 | $smarty->assign("user", $user); |
||||||
| 152 | $smarty->assign("status", "User"); |
||||||
| 153 | $smarty->assign("action", "demote"); |
||||||
| 154 | $smarty->display("usermanagement/changelevel-reason.tpl"); |
||||||
| 155 | BootstrapSkin::displayInternalFooter(); |
||||||
| 156 | die(); |
||||||
| 157 | } |
||||||
| 158 | else { |
||||||
| 159 | $user->demote($_POST['reason']); |
||||||
|
0 ignored issues
–
show
The method
demote() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 160 | |||||||
| 161 | BootstrapSkin::displayAlertBox( |
||||||
| 162 | "Changed " . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8') . "'s access to 'User'", |
||||||
| 163 | "alert-info", |
||||||
| 164 | "", |
||||||
| 165 | false); |
||||||
| 166 | |||||||
| 167 | Notification::userDemoted($user, $_POST['reason']); |
||||||
| 168 | |||||||
| 169 | $headers = 'From: [email protected]'; |
||||||
| 170 | |||||||
| 171 | // TODO: move to template? |
||||||
| 172 | mail($user->getEmail(), "ACC Account Demoted", "Dear " . $user->getOnWikiName() . ",\nYour account " . $user->getUsername() . " has been demoted by " . User::getCurrent()->getUsername() . " because " . User::getCurrent()->getUsername() . ". To contest this demotion please email [email protected].\n- The English Wikipedia Account Creation Team", $headers); |
||||||
| 173 | BootstrapSkin::displayInternalFooter(); |
||||||
| 174 | die(); |
||||||
| 175 | } |
||||||
| 176 | } |
||||||
| 177 | |||||||
| 178 | if (isset ($_GET['suspend'])) { |
||||||
| 179 | $user = User::getById($_GET['suspend'], gGetDb()); |
||||||
| 180 | |||||||
| 181 | if ($user == false) { |
||||||
| 182 | BootstrapSkin::displayAlertBox( |
||||||
| 183 | "Sorry, the user you are trying to suspend could not be found.", |
||||||
| 184 | "alert-error", |
||||||
| 185 | "Error", |
||||||
| 186 | true, |
||||||
| 187 | false); |
||||||
| 188 | BootstrapSkin::displayInternalFooter(); |
||||||
| 189 | die(); |
||||||
| 190 | } |
||||||
| 191 | |||||||
| 192 | if ($user->isSuspended()) { |
||||||
|
0 ignored issues
–
show
The method
isSuspended() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 193 | BootstrapSkin::displayAlertBox( |
||||||
| 194 | "Sorry, the user you are trying to suspend is already suspended.", |
||||||
| 195 | "alert-error", |
||||||
| 196 | "Error", |
||||||
| 197 | true, |
||||||
| 198 | false); |
||||||
| 199 | BootstrapSkin::displayInternalFooter(); |
||||||
| 200 | die(); |
||||||
| 201 | } |
||||||
| 202 | elseif (!isset($_POST['reason'])) { |
||||||
| 203 | global $smarty; |
||||||
| 204 | $smarty->assign("user", $user); |
||||||
| 205 | $smarty->assign("status", "Suspended"); |
||||||
| 206 | $smarty->assign("action", "suspend"); |
||||||
| 207 | $smarty->display("usermanagement/changelevel-reason.tpl"); |
||||||
| 208 | BootstrapSkin::displayInternalFooter(); |
||||||
| 209 | die(); |
||||||
| 210 | } |
||||||
| 211 | else { |
||||||
| 212 | $user->suspend($_POST['reason']); |
||||||
|
0 ignored issues
–
show
The method
suspend() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 213 | |||||||
| 214 | Notification::userSuspended($user, $_POST['reason']); |
||||||
| 215 | BootstrapSkin::displayAlertBox( |
||||||
| 216 | "Suspended user " . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'), |
||||||
| 217 | "alert-info", |
||||||
| 218 | "", |
||||||
| 219 | false); |
||||||
| 220 | |||||||
| 221 | $headers = 'From: [email protected]'; |
||||||
| 222 | |||||||
| 223 | // TODO: move to template? |
||||||
| 224 | mail($user->getEmail(), "ACC Account Suspended", "Dear " . $user->getOnWikiName() . ",\nYour account " . $user->getUsername() . " has been suspended by " . User::getCurrent()->getUsername() . " because " . $_POST['reason'] . ". To contest this suspension please email [email protected].\n- The English Wikipedia Account Creation Team", $headers); |
||||||
| 225 | BootstrapSkin::displayInternalFooter(); |
||||||
| 226 | die(); |
||||||
| 227 | } |
||||||
| 228 | } |
||||||
| 229 | |||||||
| 230 | if (isset ($_GET['promote'])) { |
||||||
| 231 | $user = User::getById($_GET['promote'], gGetDb()); |
||||||
| 232 | |||||||
| 233 | if ($user == false) { |
||||||
| 234 | BootstrapSkin::displayAlertBox( |
||||||
| 235 | "Sorry, the user you are trying to promote could not be found.", |
||||||
| 236 | "alert-error", |
||||||
| 237 | "Error", |
||||||
| 238 | true, |
||||||
| 239 | false); |
||||||
| 240 | BootstrapSkin::displayInternalFooter(); |
||||||
| 241 | die(); |
||||||
| 242 | } |
||||||
| 243 | |||||||
| 244 | if ($user->isAdmin()) { |
||||||
| 245 | BootstrapSkin::displayAlertBox( |
||||||
| 246 | "Sorry, the user you are trying to promote has Administrator access.", |
||||||
| 247 | "alert-error", |
||||||
| 248 | "Error", |
||||||
| 249 | true, |
||||||
| 250 | false); |
||||||
| 251 | BootstrapSkin::displayInternalFooter(); |
||||||
| 252 | die(); |
||||||
| 253 | } |
||||||
| 254 | |||||||
| 255 | $user->promote(); |
||||||
|
0 ignored issues
–
show
The method
promote() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 256 | |||||||
| 257 | Notification::userPromoted($user); |
||||||
| 258 | |||||||
| 259 | BootstrapSkin::displayAlertBox( |
||||||
| 260 | htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8') . " promoted to 'Admin'", |
||||||
| 261 | "alert-info", |
||||||
| 262 | "", |
||||||
| 263 | false); |
||||||
| 264 | |||||||
| 265 | $headers = 'From: [email protected]'; |
||||||
| 266 | |||||||
| 267 | // TODO: move to template? |
||||||
| 268 | mail($user->getEmail(), "ACC Account Promoted", "Dear " . $user->getOnWikiName() . ",\nYour account " . $user->getUsername() . " has been promted to admin status by " . User::getCurrent()->getUsername() . ".\n- The English Wikipedia Account Creation Team", $headers); |
||||||
| 269 | die(); |
||||||
| 270 | } |
||||||
| 271 | |||||||
| 272 | if (isset ($_GET['decline'])) { |
||||||
| 273 | $user = User::getById($_GET['decline'], gGetDb()); |
||||||
| 274 | |||||||
| 275 | if ($user == false) { |
||||||
| 276 | BootstrapSkin::displayAlertBox( |
||||||
| 277 | "Sorry, the user you are trying to decline could not be found.", |
||||||
| 278 | "alert-error", |
||||||
| 279 | "Error", |
||||||
| 280 | true, |
||||||
| 281 | false); |
||||||
| 282 | BootstrapSkin::displayInternalFooter(); |
||||||
| 283 | die(); |
||||||
| 284 | } |
||||||
| 285 | |||||||
| 286 | if ($user->isAdmin()) { |
||||||
| 287 | BootstrapSkin::displayAlertBox("Sorry, the user you are trying to decline is not new.", |
||||||
| 288 | "alert-error", |
||||||
| 289 | "Error", |
||||||
| 290 | true, |
||||||
| 291 | false); |
||||||
| 292 | BootstrapSkin::displayInternalFooter(); |
||||||
| 293 | die(); |
||||||
| 294 | } |
||||||
| 295 | |||||||
| 296 | if (!isset($_POST['reason'])) { |
||||||
| 297 | global $smarty; |
||||||
| 298 | $smarty->assign("user", $user); |
||||||
| 299 | $smarty->assign("status", "Declined"); |
||||||
| 300 | $smarty->assign("action", "decline"); |
||||||
| 301 | $smarty->display("usermanagement/changelevel-reason.tpl"); |
||||||
| 302 | BootstrapSkin::displayInternalFooter(); |
||||||
| 303 | die(); |
||||||
| 304 | } |
||||||
| 305 | else { |
||||||
| 306 | $user->decline($_POST['reason']); |
||||||
|
0 ignored issues
–
show
The method
decline() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 307 | |||||||
| 308 | Notification::userDeclined($user, $_POST['reason']); |
||||||
| 309 | |||||||
| 310 | BootstrapSkin::displayAlertBox( |
||||||
| 311 | "Declined user " . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'), |
||||||
| 312 | "alert-info", |
||||||
| 313 | "", |
||||||
| 314 | false); |
||||||
| 315 | |||||||
| 316 | $headers = 'From: [email protected]'; |
||||||
| 317 | |||||||
| 318 | // TODO: move to template? |
||||||
| 319 | mail($user->getEmail(), "ACC Account Declined", "Dear " . $user->getOnWikiName() . ",\nYour account " . $user->getUsername() . " has been declined access to the account creation tool by " . User::getCurrent()->getUsername() . " because " . $_POST['reason'] . ". For more infomation please email [email protected].\n- The English Wikipedia Account Creation Team", $headers); |
||||||
| 320 | BootstrapSkin::displayInternalFooter(); |
||||||
| 321 | die(); |
||||||
| 322 | } |
||||||
| 323 | } |
||||||
| 324 | |||||||
| 325 | #endregion |
||||||
| 326 | |||||||
| 327 | #region renaming |
||||||
| 328 | |||||||
| 329 | if (isset ($_GET['rename'])) { |
||||||
| 330 | $user = User::getById($_GET['rename'], gGetDb()); |
||||||
| 331 | |||||||
| 332 | if ($user == false) { |
||||||
| 333 | BootstrapSkin::displayAlertBox( |
||||||
| 334 | "Sorry, the user you are trying to rename could not be found.", |
||||||
| 335 | "alert-error", |
||||||
| 336 | "Error", |
||||||
| 337 | true, |
||||||
| 338 | false); |
||||||
| 339 | BootstrapSkin::displayInternalFooter(); |
||||||
| 340 | die(); |
||||||
| 341 | } |
||||||
| 342 | |||||||
| 343 | if (!isset($_POST['newname'])) { |
||||||
| 344 | global $smarty; |
||||||
| 345 | $smarty->assign("user", $user); |
||||||
| 346 | $smarty->display("usermanagement/renameuser.tpl"); |
||||||
| 347 | BootstrapSkin::displayInternalFooter(); |
||||||
| 348 | die(); |
||||||
| 349 | } |
||||||
| 350 | else { |
||||||
| 351 | if (!isset($_POST['newname']) || trim($_POST['newname']) == "") { |
||||||
| 352 | BootstrapSkin::displayAlertBox("The new username cannot be empty.", "alert-error", "Error", true, false); |
||||||
| 353 | BootstrapSkin::displayInternalFooter(); |
||||||
| 354 | die(); |
||||||
| 355 | } |
||||||
| 356 | |||||||
| 357 | if (User::getByUsername($_POST['newname'], gGetDb()) != false) { |
||||||
| 358 | BootstrapSkin::displayAlertBox("Username already exists.", "alert-error", "Error", true, false); |
||||||
| 359 | BootstrapSkin::displayInternalFooter(); |
||||||
| 360 | die(); |
||||||
| 361 | } |
||||||
| 362 | |||||||
| 363 | $database = gGetDb(); |
||||||
| 364 | |||||||
| 365 | if (!$database->beginTransaction()) { |
||||||
| 366 | BootstrapSkin::displayAlertBox( |
||||||
| 367 | "Database transaction could not be started.", |
||||||
| 368 | "alert-error", |
||||||
| 369 | "Error", |
||||||
| 370 | true, |
||||||
| 371 | false); |
||||||
| 372 | BootstrapSkin::displayInternalFooter(); |
||||||
| 373 | die(); |
||||||
| 374 | } |
||||||
| 375 | |||||||
| 376 | try { |
||||||
| 377 | $oldname = $user->getUsername(); |
||||||
| 378 | |||||||
| 379 | $user->setUsername($_POST['newname']); |
||||||
|
0 ignored issues
–
show
The method
setUsername() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as AntiSpoofCache or User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 380 | $user->save(); |
||||||
| 381 | |||||||
| 382 | $logentry = serialize(array('old' => $oldname, 'new' => $_POST['newname'])); |
||||||
| 383 | Logger::renamedUser($database, $user, $logentry); |
||||||
| 384 | |||||||
| 385 | BootstrapSkin::displayAlertBox( |
||||||
| 386 | "Changed User " |
||||||
| 387 | . htmlentities($oldname, ENT_COMPAT, 'UTF-8') |
||||||
| 388 | . " name to " |
||||||
| 389 | . htmlentities($_POST['newname'], ENT_COMPAT, 'UTF-8'), |
||||||
| 390 | "alert-info", |
||||||
| 391 | "", |
||||||
| 392 | false); |
||||||
| 393 | } |
||||||
| 394 | catch (Exception $ex) { |
||||||
| 395 | $database->rollBack(); |
||||||
| 396 | BootstrapSkin::displayAlertBox($ex->getMessage(), "alert-error", "Error", true, false); |
||||||
| 397 | BootstrapSkin::displayInternalFooter(); |
||||||
| 398 | die(); |
||||||
| 399 | } |
||||||
| 400 | |||||||
| 401 | $database->commit(); |
||||||
| 402 | |||||||
| 403 | Notification::userRenamed($user, $oldname); |
||||||
| 404 | |||||||
| 405 | BootstrapSkin::displayInternalFooter(); |
||||||
| 406 | die(); |
||||||
| 407 | } |
||||||
| 408 | } |
||||||
| 409 | |||||||
| 410 | #endregion |
||||||
| 411 | |||||||
| 412 | #region edit user |
||||||
| 413 | |||||||
| 414 | if (isset ($_GET['edituser'])) { |
||||||
| 415 | $user = User::getById($_GET['edituser'], gGetDb()); |
||||||
| 416 | |||||||
| 417 | if ($user == false) { |
||||||
| 418 | BootstrapSkin::displayAlertBox( |
||||||
| 419 | "Sorry, the user you are trying to rename could not be found.", |
||||||
| 420 | "alert-error", |
||||||
| 421 | "Error", |
||||||
| 422 | true, |
||||||
| 423 | false); |
||||||
| 424 | BootstrapSkin::displayInternalFooter(); |
||||||
| 425 | die(); |
||||||
| 426 | } |
||||||
| 427 | |||||||
| 428 | if ($_SERVER['REQUEST_METHOD'] != "POST") { |
||||||
| 429 | global $smarty; |
||||||
| 430 | $smarty->assign("user", $user); |
||||||
| 431 | $smarty->display("usermanagement/edituser.tpl"); |
||||||
| 432 | } |
||||||
| 433 | else { |
||||||
| 434 | $database = gGetDb(); |
||||||
| 435 | if (!$database->beginTransaction()) { |
||||||
| 436 | BootstrapSkin::displayAlertBox( |
||||||
| 437 | "Database transaction could not be started.", |
||||||
| 438 | "alert-error", |
||||||
| 439 | "Error", |
||||||
| 440 | true, |
||||||
| 441 | false); |
||||||
| 442 | BootstrapSkin::displayInternalFooter(); |
||||||
| 443 | die(); |
||||||
| 444 | } |
||||||
| 445 | |||||||
| 446 | try { |
||||||
| 447 | $user->setEmail($_POST['user_email']); |
||||||
|
0 ignored issues
–
show
The method
setEmail() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User or Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 448 | |||||||
| 449 | if (!$user->isOAuthLinked()) { |
||||||
|
0 ignored issues
–
show
The method
isOAuthLinked() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 450 | $user->setOnWikiName($_POST['user_onwikiname']); |
||||||
|
0 ignored issues
–
show
The method
setOnWikiName() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 451 | } |
||||||
| 452 | |||||||
| 453 | $user->save(); |
||||||
| 454 | |||||||
| 455 | Logger::userPreferencesChange($database, $user); |
||||||
| 456 | |||||||
| 457 | Notification::userPrefChange($user); |
||||||
| 458 | BootstrapSkin::displayAlertBox("Changes saved.", "alert-info"); |
||||||
| 459 | } |
||||||
| 460 | catch (Exception $ex) { |
||||||
| 461 | $database->rollBack(); |
||||||
| 462 | BootstrapSkin::displayAlertBox($ex->getMessage(), "alert-error", "Error", true, false); |
||||||
| 463 | BootstrapSkin::displayInternalFooter(); |
||||||
| 464 | die(); |
||||||
| 465 | } |
||||||
| 466 | |||||||
| 467 | $database->commit(); |
||||||
| 468 | } |
||||||
| 469 | BootstrapSkin::displayInternalFooter(); |
||||||
| 470 | die(); |
||||||
| 471 | } |
||||||
| 472 | |||||||
| 473 | #endregion |
||||||
| 474 | |||||||
| 475 | // --------------------- USER MANAGEMENT MAIN PAGE ----------------------------------------- |
||||||
| 476 | |||||||
| 477 | echo <<<HTML |
||||||
| 478 | <div class="page-header"> |
||||||
| 479 | <h1>User Management<small> Approve, suspend, promote, demote, etc. <a class="btn btn-primary" href="?showall"><i class="icon-white icon-eye-open"></i> Show all</a></small></h1> |
||||||
| 480 | </div> |
||||||
| 481 | HTML; |
||||||
| 482 | |||||||
| 483 | BootstrapSkin::displayAlertBox( |
||||||
| 484 | "If it says you can do it, you can do it. Please use this responsibly.", |
||||||
| 485 | "alert-warning", |
||||||
| 486 | "This interface is NOT a toy.", |
||||||
| 487 | true, |
||||||
| 488 | false); |
||||||
| 489 | |||||||
| 490 | // assign to user |
||||||
| 491 | $tailscript = getTypeaheadSource(User::getAllUsernames(gGetDb())); |
||||||
| 492 | |||||||
| 493 | echo <<<HTML |
||||||
| 494 | <div class="row-fluid"> |
||||||
| 495 | <form class="form-search"> |
||||||
| 496 | <input type="text" class="input-large username-typeahead" placeholder="Jump to user" data-provide="typeahead" data-items="10" name="usersearch"> |
||||||
| 497 | <button type="submit" class="btn">Search</button> |
||||||
| 498 | </form> |
||||||
| 499 | </div> |
||||||
| 500 | HTML; |
||||||
| 501 | |||||||
| 502 | /** |
||||||
| 503 | * CURRENTLY UNUSED!! |
||||||
| 504 | * |
||||||
| 505 | * Shows A list of users in a table with the relevant buttons for that access level. |
||||||
| 506 | * |
||||||
| 507 | * Uses smarty |
||||||
| 508 | * |
||||||
| 509 | * Different levels may require the use of different data attributes. |
||||||
| 510 | * |
||||||
| 511 | * @param $data An array of arrays (see example) |
||||||
| 512 | * @param $level The user access level |
||||||
|
0 ignored issues
–
show
The type
The was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 513 | * @example showUserList( array( |
||||||
| 514 | * 1 => array( |
||||||
| 515 | * "username" => "foo", |
||||||
| 516 | * "onwikiname" => "foo", |
||||||
| 517 | * ), |
||||||
| 518 | * ) |
||||||
| 519 | * |
||||||
| 520 | */ |
||||||
| 521 | function showUserList($data, $level) |
||||||
| 522 | { |
||||||
| 523 | global $smarty; |
||||||
| 524 | $smarty->assign("listuserlevel", $level); |
||||||
| 525 | $smarty->assign("listuserdata", $data); |
||||||
| 526 | $smarty->display("usermanagement-userlist.tpl"); |
||||||
| 527 | } |
||||||
| 528 | |||||||
| 529 | global $smarty; |
||||||
| 530 | echo '<div class="row-fluid"><div class="span12"><div class="accordion" id="accordion2">'; |
||||||
| 531 | BootstrapSkin::pushTagStack("</div>"); |
||||||
| 532 | BootstrapSkin::pushTagStack("</div>"); |
||||||
| 533 | BootstrapSkin::pushTagStack("</div>"); |
||||||
| 534 | |||||||
| 535 | $database = gGetDb(); |
||||||
| 536 | |||||||
| 537 | $result = User::getAllWithStatus("New", $database); |
||||||
| 538 | |||||||
| 539 | if ($result != false && count($result) != 0) { |
||||||
| 540 | echo <<<HTML |
||||||
| 541 | <div class="accordion-group"> |
||||||
| 542 | <div class="accordion-heading"> |
||||||
| 543 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">Open requests</a> |
||||||
| 544 | </div> |
||||||
| 545 | <div id="collapseOne" class="accordion-body collapse in"><div class="accordion-inner"> |
||||||
| 546 | HTML; |
||||||
| 547 | |||||||
| 548 | $smarty->assign("userlist", $result); |
||||||
| 549 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 550 | echo "</div></div></div>\n"; |
||||||
| 551 | } |
||||||
| 552 | echo <<<HTML |
||||||
| 553 | <div class="accordion-group"> |
||||||
| 554 | <div class="accordion-heading"> |
||||||
| 555 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">Users</a> |
||||||
| 556 | </div> |
||||||
| 557 | <div id="collapseTwo" class="accordion-body collapse"><div class="accordion-inner"> |
||||||
| 558 | HTML; |
||||||
| 559 | |||||||
| 560 | $result = User::getAllWithStatus("User", $database); |
||||||
| 561 | $smarty->assign("userlist", $result); |
||||||
| 562 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 563 | echo <<<HTML |
||||||
| 564 | </div> |
||||||
| 565 | </div></div> |
||||||
| 566 | |||||||
| 567 | <div class="accordion-group"> |
||||||
| 568 | <div class="accordion-heading"> |
||||||
| 569 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">Admins</a> |
||||||
| 570 | </div> |
||||||
| 571 | <div id="collapseThree" class="accordion-body collapse"><div class="accordion-inner"> |
||||||
| 572 | <p class="muted"> |
||||||
| 573 | Please note: Users marked as checkusers automatically get administrative rights, even if they do |
||||||
| 574 | not appear in the tool administrators section. |
||||||
| 575 | </p> |
||||||
| 576 | HTML; |
||||||
| 577 | |||||||
| 578 | $result = User::getAllWithStatus("Admin", $database); |
||||||
| 579 | $smarty->assign("userlist", $result); |
||||||
| 580 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 581 | echo <<<HTML |
||||||
| 582 | </div> |
||||||
| 583 | </div></div> |
||||||
| 584 | |||||||
| 585 | <div class="accordion-group"> |
||||||
| 586 | <div class="accordion-heading"> |
||||||
| 587 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseFour">Tool Checkuser access</a> |
||||||
| 588 | </div> |
||||||
| 589 | <div id="collapseFour" class="accordion-body collapse"><div class="accordion-inner"> |
||||||
| 590 | <p class="muted"> |
||||||
| 591 | Please note: Users marked as checkusers automatically get administrative rights, even if they do |
||||||
| 592 | not appear in the tool administrators section. |
||||||
| 593 | </p> |
||||||
| 594 | HTML; |
||||||
| 595 | |||||||
| 596 | $result = User::getAllCheckusers($database); |
||||||
| 597 | $smarty->assign("userlist", $result); |
||||||
| 598 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 599 | echo '</div></div></div>'; |
||||||
| 600 | |||||||
| 601 | if (isset($_GET['showall'])) { |
||||||
| 602 | echo <<<HTML |
||||||
| 603 | <div class="accordion-group"> |
||||||
| 604 | <div class="accordion-heading"> |
||||||
| 605 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseFive">Suspended accounts</a> |
||||||
| 606 | </div> |
||||||
| 607 | <div id="collapseFive" class="accordion-body collapse"><div class="accordion-inner"> |
||||||
| 608 | HTML; |
||||||
| 609 | |||||||
| 610 | $result = User::getAllWithStatus("Suspended", $database); |
||||||
| 611 | $smarty->assign("userlist", $result); |
||||||
| 612 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 613 | echo <<<HTML |
||||||
| 614 | </div> |
||||||
| 615 | </div></div> |
||||||
| 616 | |||||||
| 617 | <div class="accordion-group"> |
||||||
| 618 | <div class="accordion-heading"> |
||||||
| 619 | <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseSix">Declined accounts</a> |
||||||
| 620 | </div> |
||||||
| 621 | <div id="collapseSix" class="accordion-body collapse"><div class="accordion-inner"> |
||||||
| 622 | HTML; |
||||||
| 623 | |||||||
| 624 | $result = User::getAllWithStatus("Declined", $database); |
||||||
| 625 | $smarty->assign("userlist", $result); |
||||||
| 626 | $smarty->display("usermanagement/userlist.tpl"); |
||||||
| 627 | echo "</div></div></div>"; |
||||||
| 628 | } |
||||||
| 629 | |||||||
| 630 | BootstrapSkin::displayInternalFooter($tailscript); |
||||||
| 631 | die(); |
||||||
| 632 |