diff options
Diffstat (limited to 'src/controllers/Users.class.php')
-rw-r--r-- | src/controllers/Users.class.php | 54 |
1 files changed, 50 insertions, 4 deletions
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; } } |