diff --git a/core/util.php b/core/util.php
index 71e2a6dc..3fda6459 100644
--- a/core/util.php
+++ b/core/util.php
@@ -1,6 +1,15 @@
"command_example"],
+ PRE($ex),
+ P($desc)
+ );
+}
+
+function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
+{
+ if (is_string($foot)) {
+ $foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot]))));
+ }
+ $form = SHM_FORM(make_link($target));
+ $form->appendChild(P(
+ INPUT(["type"=>'hidden', "name"=>'id', "value"=>$duser->id]),
+ TABLE(
+ ["class"=>"form"],
+ THEAD(TR(TH(["colspan"=>"2"], $title))),
+ $body,
+ $foot
+ )
+ ));
+ return $form;
+}
diff --git a/ext/user/theme.php b/ext/user/theme.php
index 437040cf..b6349037 100644
--- a/ext/user/theme.php
+++ b/ext/user/theme.php
@@ -1,5 +1,20 @@
"2"], INPUT(["type"=>"submit", "value"=>"Create Account"])))
+ TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>"Create Account"])))
)
)
);
@@ -133,41 +148,35 @@ class UserPageTheme extends Themelet
$page->add_block(new Block("Login", $html, "left", 90));
}
+ private function _ip_list(string $name, array $ips)
+ {
+ $td = TD("$name: ");
+ $n = 0;
+ foreach ($ips as $ip => $count) {
+ $td->appendChild(BR());
+ $td->appendChild("$ip ($count)");
+ if (++$n >= 20) {
+ $td->appendChild(BR());
+ $td->appendChild("...");
+ break;
+ }
+ }
+ return $td;
+ }
+
public function display_ip_list(Page $page, array $uploads, array $comments, array $events)
{
- $html = "
";
- $html .= "Uploaded from: ";
- $n = 0;
- foreach ($uploads as $ip => $count) {
- $html .= ' '.$ip.' ('.$count.')';
- if (++$n >= 20) {
- $html .= " ...";
- break;
- }
- }
-
- $html .= " | Commented from:";
- $n = 0;
- foreach ($comments as $ip => $count) {
- $html .= ' '.$ip.' ('.$count.')';
- if (++$n >= 20) {
- $html .= " ...";
- break;
- }
- }
-
- $html .= " | Logged Events:";
- $n = 0;
- foreach ($events as $ip => $count) {
- $html .= ' '.$ip.' ('.$count.')';
- if (++$n >= 20) {
- $html .= " ...";
- break;
- }
- }
-
- $html .= " |
";
- $html .= "(Most recent at top) |
";
+ $html = TABLE(
+ ["id"=>"ip-history"],
+ TR(
+ $this->_ip_list("Uploaded from", $uploads),
+ $this->_ip_list("Commented from", $comments),
+ $this->_ip_list("Logged Events", $events)
+ ),
+ TR(
+ TD(["colspan"=>"3"], "(Most recent at top)")
+ )
+ );
$page->add_block(new Block("IPs", $html, "main", 70));
}
@@ -187,92 +196,84 @@ class UserPageTheme extends Themelet
public function build_options(User $duser, UserOptionsBuildingEvent $event)
{
global $config, $user;
- $html = "";
- if ($duser->id != $config->get_int('anon_id')) { //justa fool-admin protection so they dont mess around with anon users.
+ $html = emptyHTML();
+ // just a fool-admin protection so they dont mess around with anon users.
+ if ($duser->id != $config->get_int('anon_id')) {
if ($user->can(Permissions::EDIT_USER_NAME)) {
- $html .= "
- ".make_form(make_link("user_admin/change_name"))."
-
-
-
- ";
+ $html->appendChild(SHM_USER_FORM(
+ $duser,
+ "user_admin/change_name",
+ "Change Name",
+ TBODY(TR(
+ TH("New name"),
+ TD(INPUT(["type"=>'text', "name"=>'name', "value"=>$duser->name]))
+ )),
+ "Set"
+ ));
}
- $html .= "
- ".make_form(make_link("user_admin/change_pass"))."
-
-
-
-
- ".make_form(make_link("user_admin/change_email"))."
-
-
-
- ";
+ $html->appendChild(SHM_USER_FORM(
+ $duser,
+ "user_admin/change_pass",
+ "Change Password",
+ TBODY(
+ TR(
+ TH("Password"),
+ TD(INPUT(["type"=>'password', "name"=>'pass1', "autocomplete"=>'new-password']))
+ ),
+ TR(
+ TH("Repeat Password"),
+ TD(INPUT(["type"=>'password', "name"=>'pass2', "autocomplete"=>'new-password']))
+ ),
+ ),
+ "Set"
+ ));
- $i_user_id = int_escape($duser->id);
+ $html->appendChild(SHM_USER_FORM(
+ $duser,
+ "user_admin/change_email",
+ "Change Email",
+ TBODY(TR(
+ TH("Address"),
+ TD(INPUT(["type"=>'text', "name"=>'address', "value"=>$duser->email, "autocomplete"=>'email', "inputmode"=>'email']))
+ )),
+ "Set"
+ ));
if ($user->can(Permissions::EDIT_USER_CLASS)) {
global $_shm_user_classes;
- $class_html = "";
+ $select = SELECT(["name"=>"class"]);
foreach ($_shm_user_classes as $name => $values) {
- $h_name = html_escape($name);
- $h_title = html_escape(ucwords($name));
- $h_selected = ($name == $duser->class->name ? " selected" : "");
- $class_html .= "\n";
+ $select->appendChild(
+ OPTION(["value"=>$name, "selected"=>$name == $duser->class->name], ucwords($name))
+ );
}
- $html .= "
- ".make_form(make_link("user_admin/change_class"))."
-
-
-
- ";
+ $html->appendChild(SHM_USER_FORM(
+ $duser,
+ "user_admin/change_class",
+ "Change Class",
+ TBODY(TR(TD($select))),
+ "Set"
+ ));
}
if ($user->can(Permissions::DELETE_USER)) {
- $html .= "
- ".make_form(make_link("user_admin/delete_user"))."
-
-
-
- ";
+ $html->appendChild(SHM_USER_FORM(
+ $duser,
+ "user_admin/delete_user",
+ "Delete User",
+ TBODY(
+ TR(TD(INPUT(["type"=>'checkbox', "name"=>'with_images'], "Delete images"))),
+ TR(TD(INPUT(["type"=>'checkbox', "name"=>'with_comments'], "Delete comments"))),
+ ),
+ TFOOT(
+ TR(TD(INPUT(["type"=>'button', "class"=>'shm-unlocker', "data-unlock-sel"=>'.deluser', "value"=>'Unlock']))),
+ TR(TD(INPUT(["type"=>'submit', "class"=>'deluser', "value"=>'Delete User', "disabled"=>'true']))),
+ )
+ ));
}
+
foreach ($event->parts as $part) {
$html .= $part;
}
@@ -283,25 +284,21 @@ class UserPageTheme extends Themelet
public function get_help_html()
{
global $user;
- $output = 'Search for images posted by particular individuals.
-
-
poster=username
-
Returns images posted by "username".
-
-
-
poster_id=123
-
Returns images posted by user 123.
-
- ';
-
+ $output = emptyHTML(P("Search for images posted by particular individuals."));
+ $output->appendChild(SHM_COMMAND_EXAMPLE(
+ "poster=username",
+ 'Returns images posted by "username".'
+ ));
+ $output->appendChild(SHM_COMMAND_EXAMPLE(
+ "poster_id=123",
+ 'Returns images posted by user 123.'
+ ));
if ($user->can(Permissions::VIEW_IP)) {
- $output .="
-
-
poster_ip=127.0.0.1
-
Returns images posted from IP 127.0.0.1.
-
- ";
+ $output->appendChild(SHM_COMMAND_EXAMPLE(
+ "poster_ip=127.0.0.1",
+ "Returns images posted from IP 127.0.0.1."
+ ));
}
return $output;
}