mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
Renamed UserHandler to MailboxHandler to make clear it's about mailboxes
(as discussed with GingerDog on IRC yesterday). Also renamed user to mailbox in the CLI. - renamed model/UserHandler.php to MailboxHandler.php - renamed scripts/shells/user.php to mailbox.php - replaced UserHandler / user with MailboxHandler / mailbox in various files - unrelated cleanup: deleted obsolete scripts/models-ext directory git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1019 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
3be13f059d
commit
b89b94cf83
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Simple class to represent a user.
|
||||
*/
|
||||
class UserHandler {
|
||||
class MailboxHandler {
|
||||
|
||||
protected $username = null;
|
||||
|
||||
@ -15,7 +15,7 @@ class UserHandler {
|
||||
}
|
||||
|
||||
public function change_pass($old_password, $new_password) {
|
||||
error_log('UserHandler->change_pass is deprecated. Please use UserHandler->change_pw!');
|
||||
error_log('MailboxHandler->change_pass is deprecated. Please use MailboxHandler->change_pw!');
|
||||
return $this->change_pw($new_password, $old_password);
|
||||
}
|
||||
|
@ -533,11 +533,11 @@ class PostfixAdmin {
|
||||
|
||||
|
||||
return array(
|
||||
'user' => array(
|
||||
'add'=> 'Adds a new user with mailbox.',
|
||||
'update'=> 'Updates a user.',
|
||||
'delete' => 'Deletes a user.',
|
||||
'pw' => 'Changes the PW for a user.',
|
||||
'mailbox' => array(
|
||||
'add'=> 'Adds a new mailbox.',
|
||||
'update'=> 'Updates a mailbox.',
|
||||
'delete' => 'Deletes a mailbox.',
|
||||
'pw' => 'Changes the PW for a mailbox.',
|
||||
),
|
||||
'alias' => array(
|
||||
'add' => 'Adds a new alias.',
|
||||
|
@ -222,8 +222,8 @@ class DeleteTask extends Shell {
|
||||
*/
|
||||
function __handle($address) {
|
||||
|
||||
### TODO: don't use UserHandler, instead add delete function to AliasHandler (if not already there)
|
||||
### using UserHandler for deleting aliases is like taking a sledgehammer to crack a nut
|
||||
### TODO: don't use MailboxHandler, instead add delete function to AliasHandler (if not already there)
|
||||
### using MailboxHandler for deleting aliases is like taking a sledgehammer to crack a nut
|
||||
### (and will probably cause some error messages that I added today ;-)
|
||||
|
||||
### Implemented check it please!
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
class PostfixAdminUser extends Shell {
|
||||
class PostfixAdminMailbox extends Shell {
|
||||
|
||||
/**
|
||||
* Contains tasks to load and instantiate
|
||||
@ -20,18 +20,18 @@ class PostfixAdminUser extends Shell {
|
||||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
$head = "Usage: postfixadmin-cli user <task> [<address>] [] [-m <method>]\n";
|
||||
$head = "Usage: postfixadmin-cli mailbox <task> [<address>] [] [-m <method>]\n";
|
||||
$head .= "-----------------------------------------------\n";
|
||||
$head .= "Parameters:\n\n";
|
||||
|
||||
$commands = array(
|
||||
'task' => "\t<task>\n" .
|
||||
"\t\tAvailable values:\n\n".
|
||||
"\t\t".sprintf("%-20s %s", "view: ", "View an existing user.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "add: ", "Adds a new user with mailbox.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "update: ", "Updates a user.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "delete: ", "Deletes a user")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "password: ", "Changes the PW for a user.")."\n",
|
||||
"\t\t".sprintf("%-20s %s", "view: ", "View an existing mailbox.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "add: ", "Adds a new mailbox.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "update: ", "Updates a mailbox.")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "delete: ", "Deletes a mailbox")."\n".
|
||||
"\t\t".sprintf("%-20s %s", "password: ", "Changes the PW for a mailbox.")."\n",
|
||||
'address' => "\t[<address>]\n" .
|
||||
"\t\tA CakePHP core class name (e.g: Component, HtmlHelper).\n",
|
||||
);
|
||||
@ -138,7 +138,7 @@ class AddTask extends Shell {
|
||||
$pw = $password;
|
||||
}
|
||||
|
||||
$handler = new UserHandler($address);
|
||||
$handler = new MailboxHandler($address);
|
||||
$return = $handler->add($pw, $name, $quota, true, true );
|
||||
#CHECK!
|
||||
if ( !empty($this->params['q']) ) {
|
||||
@ -175,7 +175,7 @@ if ( !empty($this->params['q']) ) {
|
||||
*/
|
||||
function help() {
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user add <address> [<password>] <name> <quota> [-g]");
|
||||
$this->out("Usage: postfixadmin-cli mailbox add <address> [<password>] <name> <quota> [-g]");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out("\n\tadd\n\t\tAdds mailbox in interactive mode.");
|
||||
@ -217,7 +217,7 @@ class UpdateTask extends Shell {
|
||||
function help() {
|
||||
$this->hr();
|
||||
$this->out("Not Implemented yet! If you want to change a password use the password command.");
|
||||
/*$this->out("Usage: postfixadmin-cli user update <args>");
|
||||
/*$this->out("Usage: postfixadmin-cli mailbox update <args>");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out("\n\tmodel\n\t\tbakes model in interactive mode.");
|
||||
@ -274,7 +274,7 @@ class DeleteTask extends Shell {
|
||||
function __handle($address) {
|
||||
|
||||
|
||||
$handler = new UserHandler($address);
|
||||
$handler = new MailboxHandler($address);
|
||||
$status = $handler->delete();
|
||||
if ( ! $status ) {
|
||||
$this->error("Error:", join("\n", $handler->errormsg));
|
||||
@ -292,7 +292,7 @@ class DeleteTask extends Shell {
|
||||
*/
|
||||
function help() {
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user model <arg1>");
|
||||
$this->out("Usage: postfixadmin-cli mailbox model <arg1>");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out("\n\tdelete\n\t\tdeletes mailbox in interactive mode.");
|
||||
@ -391,7 +391,7 @@ class PasswordTask extends Shell {
|
||||
$password = generate_password();
|
||||
}
|
||||
if ($password != NULL) {
|
||||
$handler = new UserHandler($address);
|
||||
$handler = new MailboxHandler($address);
|
||||
|
||||
if ( ! $handler->change_pw($password, NULL, false) ){
|
||||
$this->error("Change Password",join("\n", $handler->errormsg));
|
||||
@ -415,7 +415,7 @@ class PasswordTask extends Shell {
|
||||
function help() {
|
||||
$this->out("");
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user password <address> [<newpw>] [-g]");
|
||||
$this->out("Usage: postfixadmin-cli mailbox password <address> [<newpw>] [-g]");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out("\n\tpassword\n\t\tchanges the password in interactive mode.");
|
||||
@ -466,9 +466,9 @@ class ViewTask extends Shell {
|
||||
function __handle($address) {
|
||||
|
||||
|
||||
$handler = new UserHandler($address);
|
||||
$handler = new MailboxHandler($address);
|
||||
if ( ! $handler->view() ) {
|
||||
$this->error("Not Found!", "The user you have searched could not be found.");
|
||||
$this->error("Not Found!", "The mailbox you have searched could not be found.");
|
||||
}
|
||||
# TODO: offer alternative output formats (based on parameter)
|
||||
# TODO: whitespace fix - 8 lines below
|
||||
@ -492,11 +492,11 @@ class ViewTask extends Shell {
|
||||
function help() {
|
||||
$this->out("");
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user view <address>");
|
||||
$this->out("Usage: postfixadmin-cli mailbox view <address>");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out("\n\tview\n\t\tView user. Select address in interactive mode.");
|
||||
$this->out("\n\tview <address>\n\t\tView user with address <address>");
|
||||
$this->out("\n\tview\n\t\tView mailbox. Select address in interactive mode.");
|
||||
$this->out("\n\tview <address>\n\t\tView mailbox with address <address>");
|
||||
$this->out("");
|
||||
$this->_stop();
|
||||
}
|
@ -51,7 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$fUsername = escape_string ($_POST['fUsername']);
|
||||
$fPassword = escape_string ($_POST['fPassword']);
|
||||
|
||||
if(UserHandler::login($_POST['fUsername'], $_POST['fPassword'])) {
|
||||
if(MailboxHandler::login($_POST['fUsername'], $_POST['fPassword'])) {
|
||||
session_regenerate_id();
|
||||
$_SESSION['sessid'] = array();
|
||||
$_SESSION['sessid']['roles'] = array();
|
||||
|
@ -51,7 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$error += 1;
|
||||
flash_error(sprintf($PALANG['pPasswordTooShort'], $CONF['min_password_length']));
|
||||
}
|
||||
if(!UserHandler::login($username, $fPassword_current)) {
|
||||
if(!MailboxHandler::login($username, $fPassword_current)) {
|
||||
$error += 1;
|
||||
$pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
|
||||
}
|
||||
@ -63,7 +63,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$uh = new UserHandler($username);
|
||||
$uh = new MailboxHandler($username);
|
||||
if($uh->change_pw($fPassword, $fPassword_current) ) {
|
||||
flash_info($PALANG['pPassword_result_success']);
|
||||
header("Location: main.php");
|
||||
|
@ -45,7 +45,7 @@ $server = new Zend_XmlRpc_Server();
|
||||
* @return boolean true on success, else false.
|
||||
*/
|
||||
function login($username, $password) {
|
||||
if(UserHandler::login($username, $password)) {
|
||||
if(MailboxHandler::login($username, $password)) {
|
||||
session_regenerate_id();
|
||||
$_SESSION['authenticated'] = true;
|
||||
$_SESSION['username'] = $username;
|
||||
@ -73,7 +73,7 @@ class UserProxy {
|
||||
* @return boolean true on success
|
||||
*/
|
||||
public function changePassword($old_password, $new_password) {
|
||||
$uh = new UserHandler($_SESSION['username']);
|
||||
$uh = new MailboxHandler($_SESSION['username']);
|
||||
return $uh->change_pw($new_password, $old_password);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class UserProxy {
|
||||
* @return boolean true if successful.
|
||||
*/
|
||||
public function login($username, $password) {
|
||||
$uh = new UserHandler($_SESSION['username']);
|
||||
$uh = new MailboxHandler($_SESSION['username']);
|
||||
return $uh->login($username, $password);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user