summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/modules.php2
-rw-r--r--utils/modules/user.php59
2 files changed, 61 insertions, 0 deletions
diff --git a/utils/modules.php b/utils/modules.php
index 36b9dd3..2c4df69 100644
--- a/utils/modules.php
+++ b/utils/modules.php
@@ -34,6 +34,8 @@ function loadAllModules()
loadModule("downloads");
loadModule("newsletter");
loadModule("pressrelease");
+ loadModule("user");
+ // loadModule("users");
}
function getModuleParams($code)
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