|
| 1 | +<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */ |
| 2 | +namespace BNETDocs\Templates\User; |
| 3 | +use \BNETDocs\Models\User\Delete as DeleteModel; |
| 4 | +use \CarlBennett\MVC\Libraries\Pair; |
| 5 | +$title = 'Delete User'; |
| 6 | +$description = 'This page confirms if the user wishes to delete another user.'; |
| 7 | +$this->opengraph->attach(new Pair('url', '/user/delete')); |
| 8 | +$this->opengraph->attach(new Pair('type', 'article')); |
| 9 | +switch ($this->getContext()->error) |
| 10 | +{ |
| 11 | + case DeleteModel::ERROR_ACL_NOT_SET: $message = 'You do not have the privilege to delete users.'; break; |
| 12 | + case DeleteModel::ERROR_NOT_FOUND: $message = 'Cannot find user by that id.'; break; |
| 13 | + case DeleteModel::ERROR_NOT_LOGGED_IN: $message = 'You must be logged in to delete users.'; break; |
| 14 | + case DeleteModel::ERROR_INTERNAL_ERROR: $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break; |
| 15 | + default: $message = $this->getContext()->error; |
| 16 | +} |
| 17 | +$target_id = $this->getContext()->target_id; |
| 18 | +$target_user = $this->getContext()->target_user; |
| 19 | +if ($target_user) |
| 20 | +{ |
| 21 | + $target_user_avatar = $target_user->getAvatarURI(22); |
| 22 | + $target_user_id = $target_user->getId(); |
| 23 | + $target_user_name = $target_user->getName(); |
| 24 | + $target_user_url = $target_user->getURI(); |
| 25 | +} |
| 26 | +require('./header.inc.phtml'); ?> |
| 27 | +<div class="container"> |
| 28 | +<? if (is_null($this->getContext()->error)) { ?> |
| 29 | + |
| 30 | + <h2 class="text-danger">Delete User</h2> |
| 31 | + <p class="text-danger">Are you sure you wish to delete this user?</p> |
| 32 | + <form method="POST" action="?id=<?=rawurlencode($target_id)?>"> |
| 33 | + <table class="table table-striped text-white-50"><tbody> |
| 34 | + <tr><td><a href="<?=$target_user_url?>"><img class="avatar" src="<?=$target_user_avatar?>"/> <?=filter_var($target_user_name, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></a></td></tr> |
| 35 | + </tbody></table> |
| 36 | + <a class="btn btn-primary" href="javascript:history.go(-1);">Back</a> |
| 37 | + <input class="btn btn-danger" type="submit" value="Delete" tabindex="1" autofocus="autofocus"/> |
| 38 | + </form> |
| 39 | + |
| 40 | +<? } else if ($this->getContext()->error === false) { ?> |
| 41 | + |
| 42 | + <h2 class="text-success">Delete User</h2> |
| 43 | + <div class="alert alert-success"> |
| 44 | + <p class="mb-0"><strong>The user was successfully deleted!</strong></p> |
| 45 | + </div> |
| 46 | + <a class="btn btn-primary" href="<?=\CarlBennett\MVC\Libraries\Common::relativeUrlToAbsolute('/user/index')?>">Back</a> |
| 47 | + |
| 48 | +<? } else { ?> |
| 49 | + |
| 50 | + <h2 class="text-danger">Delete User</h2> |
| 51 | + <div class="alert alert-danger"> |
| 52 | + <p class="mb-0"><strong>An error occurred while attempting to delete the user:</strong></p> |
| 53 | + <p class="mb-0"><?=$message?></p> |
| 54 | + </div> |
| 55 | +<? if (isset($target_user_url) && !empty($target_user_url)) { ?> |
| 56 | + <a class="btn btn-primary" href="<?=$target_user_url?>">Back</a> |
| 57 | +<? } ?> |
| 58 | + |
| 59 | +<? } ?> |
| 60 | +</div> |
| 61 | +<? require('./footer.inc.phtml'); ?> |
0 commit comments