summaryrefslogtreecommitdiff
path: root/apps/um/views/pages/users/individual.html.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-01-07 08:21:00 -0800
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-01-07 10:22:21 -0800
commit83e460cdc3fc09867a3adb48c3d0894579dd3050 (patch)
tree0771bd935b30971bf2c244b6f158ed7496b644e5 /apps/um/views/pages/users/individual.html.php
parent3d64793a1ee45857856be1cd71c3a0a040a3e869 (diff)
Refactor to separate the framework from the app; drop message stuff, this app is just user management. Add a json view for individual users
Diffstat (limited to 'apps/um/views/pages/users/individual.html.php')
-rw-r--r--apps/um/views/pages/users/individual.html.php147
1 files changed, 147 insertions, 0 deletions
diff --git a/apps/um/views/pages/users/individual.html.php b/apps/um/views/pages/users/individual.html.php
new file mode 100644
index 0000000..39360b7
--- /dev/null
+++ b/apps/um/views/pages/users/individual.html.php
@@ -0,0 +1,147 @@
+<?php global $VARS, $CONTACT_METHODS;
+$t = $VARS['template'];
+$users = $VARS['users'];
+$username = $VARS['username'];
+
+function inputText($user, $key, $label, $hint='') {
+ global $VARS; $t = $VARS['template'];
+ $current_setting = $user->getConf($key);
+ $t->inputText("user_$key", $label, $hint, $current_setting,
+ !$user->canEdit());
+}
+function inputTextarea($user, $key, $label, $hint='') {
+ global $VARS; $t = $VARS['template'];
+ $current_setting = $user->getConf($key);
+ $t->inputTextarea("user_$key", $label, $hint, $current_setting,
+ !$user->canEdit());
+}
+
+function inputBool($user, $key, $label, $hint='') {
+ global $VARS; $t = $VARS['template'];
+ $current_setting = $user->getConf($key)=='true';
+ $t->inputBool("user_$key", $label, $hint, $current_setting,
+ !$user->canEdit());
+}
+
+function inputArray($user, $key, $arr) {
+ global $VARS; $t = $VARS['template'];
+ $defaults = $user->getConfArray($key);
+
+ foreach ($arr as $value => $label) {
+ $t->inputBoolArray($key, $value, $label,
+ in_array($value, $defaults), !$user->canEdit());
+ }
+}
+
+function inputField($user, $arr) {
+ $fieldname = $arr[0];
+ $fieldlabel = $arr[1];
+ $fieldtype = $arr[2];
+
+ switch ($fieldtype) {
+ case 'text':
+ inputText($user, $fieldname, $fieldlabel, '');
+ break;
+ case 'textarea':
+ inputTextarea($user, $fieldname, $fieldlabel, '');
+ break;
+ case 'paragraph':
+ global $VARS; $t = $VARS['template'];
+ $t->inputP($fieldlabel);
+ break;
+ case 'checkbox':
+ inputBool($user, $fieldname, $fieldlabel, '');
+ break;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+if (count($users)>1) {
+ $t->header("Users: $username");
+} else {
+ $t->header("User: $username");
+}
+
+foreach($users as $user) {
+$username = $user->getName();
+
+$t->tag('h1', array(), ($user->canEdit()?'Edit':'View')." User <q>$username</q> (UID: ".$user->getUID().")");
+
+if ($user->canEdit()) {
+ $t->openTag('form', array('method'=>'post',
+ 'action'=>$t->url("users/$username")));
+} else {
+ $t->openTag('form');
+}
+
+$t->openFieldset("Login / Authentication");
+// Username ////////////////////////////////////////////////////////////////////
+if (isset($VARS['changed name']) && !$VARS['changed name']) {
+ $t->inputP("Error setting username to ".
+ "<q>$new_name</q>. This is probably because".
+ " a user with that name already exists.",
+ true);
+}
+$t->inputText('auth_name','Username',
+ "This is the name you use to log in, but it is also a ".
+ "short name that is used in various places, think of it ".
+ "as a sort of <q>Twitter name</q>.",
+ $user->getName(), !$user->canEdit());
+// Password ////////////////////////////////////////////////////////////////////
+if (@$VARS['pw_updated']===true) {
+ $t->inputP('Password successfully updated.');
+}
+if (@$VARS['pw mixmatch']===true) {
+ $t->inputP("Passwords don't match.", true);
+}
+if ($user->canEdit()) $t->inputNewPassword('auth_password','Reset Password');
+////////////////////////////////////////////////////////////////////////////////
+$t->closeFieldset();
+
+$t->openFieldset("Contact");
+// TODO: I should make this a setting for admins to set.
+$hints = array('email'=>
+ "Right now you can only have one email address, ".
+ "but I'm working on making it so you can have ".
+ "multiple.",
+ 'phone'=>
+ "A home phone number isn't much use here because it is ".
+ "used to text-message you (if you enable it), and ".
+ "contact you at competition."
+ );
+$use_arr = array();
+foreach ($CONTACT_METHODS as $method) {
+ inputText($user,
+ $method->addr_slug,
+ ucwords($method->addr_text),
+ $hints[$method->addr_slug]);
+ $use_arr[$method->verb_slug] = ucwords($method->verb_text);
+}
+
+$t->inputP("When I recieve a message, notify me using the following methods:");
+inputArray($user, 'use', $use_arr);
+$t->closeFieldSet();
+
+foreach ($VARS['config_options'] as $groupname=>$options) {
+ $t->openFieldset($groupname);
+ foreach ($options as $option) {
+ inputField($user, $option);
+ }
+ $t->closeFieldset();
+}
+
+$t->openFieldSet('Groups');
+$group_arr = array();
+foreach ($VARS['groups'] as $group_name) {
+ $group_arr[$group_name] = ucwords($group_name);
+}
+inputArray($user, 'groups', $group_arr);
+$t->closeFieldset();
+
+if ($user->canEdit()) {
+ $t->tag('input', array('type'=>'submit', 'value'=>'Save'));
+}
+$t->closeTag('form');
+}
+$t->footer();