summaryrefslogtreecommitdiff
path: root/utils/modules/user.php
diff options
context:
space:
mode:
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