summaryrefslogtreecommitdiff
path: root/utils/modules/user.php
diff options
context:
space:
mode:
authordeva <deva>2010-02-27 14:21:02 +0000
committerdeva <deva>2010-02-27 14:21:02 +0000
commit5fac941e3295d4a094795aaf2f0e05c542879465 (patch)
tree150e01720cf7fdcf793eeed578d31bca5f310a97 /utils/modules/user.php
parent39d6dd59160aa8b836309743950e5c5bf9d2a459 (diff)
Added password-changer module (user).
Diffstat (limited to 'utils/modules/user.php')
-rw-r--r--utils/modules/user.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/utils/modules/user.php b/utils/modules/user.php
new file mode 100644
index 0000000..5e9c23b
--- /dev/null
+++ b/utils/modules/user.php
@@ -0,0 +1,59 @@
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+global $UTIL_DIR;
+
+include_once($UTIL_DIR . "/user.php");
+
+class UserAdm {
+ public $users;
+
+ // Admin config
+ public $admin_title = "User";
+ public $admin_submodules = array("Password" => "password");
+
+ public function admin_password($action, $vars)
+ {
+ global $UID;
+
+ switch($action) {
+ case "set":
+ $user = $this->users->findUser($UID);
+ if($user &&
+ $user->setPassword($vars['oldpwd'], $vars['newpwd'], $vars['rptpwd']) == 0) {
+ $this->users->write();
+ }
+
+ default:
+ $form = new Form("set");
+ $form->addWidget(new LineEdit("Old password:", "oldpwd", ""));
+ $form->addWidget(new LineEdit("New password:", "newpwd", ""));
+ $form->addWidget(new LineEdit("Repeat password:", "rptpwd", ""));
+ $form->addWidget(new Button("Update"));
+ $form->render();
+ break;
+ }
+ }
+
+ public function admin($sub, $action, $vars)
+ {
+ switch($sub) {
+ case "password":
+ $this->admin_password($action, $vars);
+ break;
+ }
+ }
+
+
+ public function UserAdm($file)
+ {
+ $this->users = new Users($file);
+ }
+}
+
+function user_init()
+{
+ global $DATA_DIR;
+ return new UserAdm($DATA_DIR . "/users.xml");
+}
+
+?> \ No newline at end of file