From ad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 4 Sep 2011 21:13:47 -0400 Subject: Screw it, I'm tired of trying to break this into individual commits --- src/controllers/Users.class.php | 54 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'src/controllers/Users.class.php') diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php index 617c57a..9781ab0 100644 --- a/src/controllers/Users.class.php +++ b/src/controllers/Users.class.php @@ -84,8 +84,14 @@ class Users extends Controller { } break; } + + $config_options = array(); + $mm->pluginManager()->callHook('userConfig', &$config_options); + + $vars['config_options'] = $config_options; $vars['user'] = $user; $vars['groups'] = $mm->listGroupNames(); + require_once('ContactMethod.class.php'); $this->showView('users/individual', $vars); } } @@ -179,10 +185,20 @@ class Users extends Controller { } // Change information ////////////////////////////////////////// + global $mm; + $config_options = array(); + $mm->pluginManager()->callHook('userConfig', &$config_options); + + foreach ($config_options as $group=>$options) { + foreach ($options as $option) { + $this->confText($user, $option[0]); + } + } + /* $this->confText($user, 'firstname'); $this->confText($user, 'lastname'); $this->confText($user, 'hsclass'); - + */ // Change contact info ///////////////////////////////////////// global $CONTACT_METHODS; foreach ($CONTACT_METHODS as $method) { @@ -213,7 +229,15 @@ class Users extends Controller { * This will parse POST (really, PUT) data to update multiple users. */ private function update_users() { - // TODO + $attribs = $this->getIndexAttribs(); + foreach ($attribs as $attrib) { + $key = $attrib['key']; + if (isset($_POST[$key]) && is_array($_POST[$key])) { + foreach ($_POST[$key] as $uid => $value) { + $this->setConf($uid, $key, $value); + } + } + } } /** @@ -264,8 +288,9 @@ class Users extends Controller { $editable = $editable && $logged_in_user->isAdmin(); $value = $user->isAdmin(); break; - default: + default: $value = $user->getConf($key); + if ($value===false) $value=''; break; } @@ -273,6 +298,27 @@ class Users extends Controller { 'post_key'=>$post_key, 'editable'=>$editable); } + private function setConf($uid, $key, $value) { + // So, this rocks because we don't have to check permissions, + // the User object does that. + global $mm; + $user = $mm->getAuthObj($uid); + + switch ($key) { + case 'auth_name': + $user->setName($value); + break; + case 'auth_user': + $user->setUser($value=='true'); + break; + case 'auth_admin': + $user->setAdmin($value=='true'); + break; + default: + $user->setConf($key, $value); + break; + } + } function attrib($key, $name) { return array('key'=>$key, 'name'=>$name); @@ -286,6 +332,6 @@ class Users extends Controller { $this->attrib('email','Email'), $this->attrib('auth_name', 'Username'), ); - return $attrib; + return $attribs; } } -- cgit v1.2.3-2-g168b