diff options
author | deva <deva> | 2010-02-27 14:21:02 +0000 |
---|---|---|
committer | deva <deva> | 2010-02-27 14:21:02 +0000 |
commit | 5fac941e3295d4a094795aaf2f0e05c542879465 (patch) | |
tree | 150e01720cf7fdcf793eeed578d31bca5f310a97 | |
parent | 39d6dd59160aa8b836309743950e5c5bf9d2a459 (diff) |
Added password-changer module (user).
-rw-r--r-- | utils/modules.php | 2 | ||||
-rw-r--r-- | utils/modules/user.php | 59 |
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 |