| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /**
- * @var int $id
- * @var string $action
- */
- $controller = new class($id) {
- /** @var User */
- private $user;
- public function __construct(int $id) {
- $this->user = User::get($id);
- }
- public function toggleArchived(): void {
- if($this->user->archived) {
- $this->user->archived = 0;
- Core::addAlert("success", __("User unarchived successfully."));
- }
- else {
- $this->user->archived = 1;
- Core::addAlert("success", __("User archived successfully."));
- }
- $this->user->commit();
- Http::redirect($this->user->getURL());
- }
- };
- switch($action) {
- case "toggle-archived":
- $controller->toggleArchived();
- break;
- default:
- throw new RuntimeException(__("Invalid action."));
- }
|