summaryrefslogtreecommitdiffstats
path: root/app/view
diff options
context:
space:
mode:
Diffstat (limited to 'app/view')
-rw-r--r--app/view/settings.php147
-rw-r--r--app/view/stdpage.php7
2 files changed, 151 insertions, 3 deletions
diff --git a/app/view/settings.php b/app/view/settings.php
new file mode 100644
index 0000000..0d7d011
--- /dev/null
+++ b/app/view/settings.php
@@ -0,0 +1,147 @@
+<?php
+
+/*
+ * SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For more information, please refer to UNLICENSE
+ */
+
+namespace settings;
+
+require_once "view/formctrl.php";
+require_once "view/datalsts.php";
+require_once "class/obj.class.php";
+require_once "class/user.class.php";
+
+?>
+<?php function settings() : void { ?>
+
+ <div id="settingsModal" class="modal fade" tabindex="-1" role="dialog">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">
+ <span aria-hidden="true">&times;</span>
+ </button>
+
+ <h4 class="modal-title">
+ <span class="glyphicon glyphicon-cog"></span> Settings
+ </h4>
+ </div>
+
+ <div class="modal-body">
+ <?php $s = false; ?>
+ <?php $u = \user::getCurrent(); ?>
+
+ <ul class="nav nav-tabs" role="tablist">
+ <li class="<?=oneStr("active", $s)?>">
+ <a href="#settingsUserTab" data-toggle="tab">
+ <span class="glyphicon glyphicon-user"></span> <?=$u->getDisplayName()?>
+ </a>
+ </li>
+ </ul>
+
+ <?php $s = false; ?>
+
+ <div class="tab-content">
+ <div class="tab-pane fade <?=oneStr("in active", $s)?>" id="settingsUserTab">
+ <?=userTab($u)?>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+<?php } ?>
+<?php function image(\obj $obj, string $type, string $label) : void { ?>
+
+ <div class="col-md-6 text-center">
+ <?php if ($type == "head") { ?>
+ <?=\datalsts\objHeadCircle($obj, 100)?>
+ <?php $d = (!$obj->hasHeadImg() ? "disabled" : ""); ?>
+ <?php } else { ?>
+ <?=\datalsts\objBgPrev($obj, 100)?>
+ <?php $d = (!$obj->getBgImg() ? "disabled" : ""); ?>
+ <?php } ?>
+
+ <br />
+ <br />
+
+ <button type="button" class="btn btn-default btn-xs" data-toggle="collapse" data-target="#setimgCollapse-<?=$obj->guid?>-<?=$type?>">
+ <span class="glyphicon glyphicon-camera"></span> Upload new image
+ </button>
+
+ <br />
+
+ <button type="submit" name="input[rmImg-<?=$type?>]" class="btn btn-danger btn-xs" <?=$d?> onclick="return assertconfirm()">
+ <span class="glyphicon glyphicon-remove"></span> Remove image
+ </button>
+
+ <br />
+ <br />
+
+ <div class="collapse" id="setimgCollapse-<?=$obj->guid?>-<?=$type?>">
+ <?=\formctrl\file($label, "img-".$type)?>
+ </div>
+ </div>
+
+<?php } ?>
+<?php function userTab(\user $u) : void { ?>
+
+ <form method="post" action="<?=ap()?>" enctype="multipart/form-data">
+ <?=\formctrl\formname( "settings-user" )?>
+ <?=\formctrl\hidden( "guid", $u->guid )?>
+
+ <p>&nbsp;</p>
+
+ <div class="row">
+ <?=image($u, "head", "User Image")?>
+ <?=image($u, "bg", "Background Image")?>
+ </div>
+
+ <p>&nbsp;</p>
+
+ <?php if ($u->admin == 1) { ?>
+ <p class="pull-right">
+ <span class="glyphicon glyphicon-sunglasses"></span> <?=$u->getDisplayName()?> is a Scrott Administrator
+ </p>
+ <?php } ?>
+
+ <?=\formctrl\text( "Username", "", $u->name, "", false, true )?>
+ <?=\formctrl\checkbox( "Change Password", "setpasswd", false, false, "#setpasswdCollapse-".$u->guid )?>
+
+ <div class="collapse" id="setpasswdCollapse-<?=$u->guid?>">
+ <?=\formctrl\password( "Current Password", "curpasswd", false )?>
+ <?=\formctrl\password( "New Password", "passwd", false )?>
+ <?=\formctrl\password( "Confirm Password", "cpasswd", false )?>
+ </div>
+
+ <?=\formctrl\text( "Alias", "alias", $u->alias, "", false )?>
+ <?=\formctrl\text( "Email", "email", $u->email, "", false, false, ($u->emailConf == 1 ? "has-success" : "") )?>
+
+ <?php if ($u->email != "" && $u->emailConf == 0) { ?>
+ <?=\formctrl\text( "Email Verification Key", "emailVer", "", "", false, false, "has-warning", "You have not confirmed ownership of your email address" )?>
+ <?php } ?>
+
+ <div class="btn-group pull-right">
+ <button type="submit" class="btn btn-success">
+ <span class="glyphicon glyphicon-ok"></span> Save Changes
+ </button>
+
+ <a href="<?=ar()?>/deleteaccount" class="btn btn-danger">
+ <span class="glyphicon glyphicon-trash"></span> Delete Account
+ </a>
+ </div>
+
+ <h6>Created <?=$u->created?></h6>
+ <h6>Updated <?=$u->updated?></h6>
+ </form>
+
+<?php } ?>
diff --git a/app/view/stdpage.php b/app/view/stdpage.php
index 1629dbf..acd1ba2 100644
--- a/app/view/stdpage.php
+++ b/app/view/stdpage.php
@@ -17,6 +17,7 @@ namespace stdpage;
require_once "class/globals.php";
require_once "class/user.class.php";
require_once "view/datamods.php";
+require_once "view/settings.php";
?>
<?php function head(?string $title = NULL) : void { ?>
@@ -166,6 +167,7 @@ require_once "view/datamods.php";
<?=about()?>
<?php if (\user::getCurrent()) { ?>
+ <?=\settings\settings()?>
<?=\datamods\newGroup()?>
<?=\datamods\newPad()?>
<?php } ?>
@@ -224,10 +226,9 @@ require_once "view/datamods.php";
</a>
<ul class="dropdown-menu">
- <li><a href="#">TODO</a></li>
- <li><a href="#">TODO</a></li>
<li><a href="#" data-toggle="modal" data-target="#aboutModal">About Scrott</a></li>
- <li><a href="#">TODO</a></li>
+ <li><a href="#" data-toggle="modal" data-target="#settingsModal">Settings</a></li>
+ <li><a href="<?=ar()?>/logout">Log out</a></li>
</ul>
</li>
</ul>