summaryrefslogtreecommitdiff
path: root/src/views/pages/users/include.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/pages/users/include.php')
-rw-r--r--src/views/pages/users/include.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/views/pages/users/include.php b/src/views/pages/users/include.php
new file mode 100644
index 0000000..6e8c90b
--- /dev/null
+++ b/src/views/pages/users/include.php
@@ -0,0 +1,60 @@
+<?php global $mm;
+
+require_once('User.class.php');
+
+/**
+ * This will take care of possibly updating and displaying a value in the
+ * 'users' table.
+ */
+function inputText($user, $name, $label, $hint='') {
+ if ($user->canEdit()) {
+ if (isset($_POST["user_$name"])) {
+ $user->setConf($name, $_POST["user_$name"]);
+ }
+ }
+
+ $current_setting = $user->getConf($name);
+
+ global $mm;
+ $t = $mm->template();
+ $t->inputText("user_$name", $label, $hint, $current_setting,
+ !$user->canEdit());
+}
+
+function inputArray($user, $name, $arr) {
+ global $mm;
+ $t = $mm->template();
+
+ if (isset($_POST[$name]) && is_array($_POST[$name])) {
+ $user->setConfArray($name, $_POST[$name]);
+ }
+ $defaults = $user->getConfArray($name);
+
+ foreach ($arr as $value => $label) {
+ $t->inputBool($name, $value, $label,
+ in_array($value, $defaults), !$user->canEdit());
+ }
+}
+
+function inputNewPassword($user, $name, $label) {
+ @$password1 = $_POST[$name ];
+ @$password2 = $_POST[$name.'_verify'];
+
+ // Check the verify box, not main box, so that we don't get tripped by
+ // browsers annoyingly autocompleting the password.
+ $is_set = ($password2 != '');
+
+ global $mm;
+ $t = $mm->template();
+
+ if ($is_set) {
+ $matches = ( $password1 == $password2 );
+ if ($matches) {
+ $user->setPassword($password1);
+ $t->inputP('Password successfully updated.');
+ } else {
+ $t->inputP("Passwords don't match.", true);
+ }
+ }
+ $t->inputNewPassword($name, $label);
+}