PFAHandler.php:

fix logging - log the domain instead of $this->id
- add protected $domain (used for logging)
- add function domain_from_id()
- http://sourceforge.net/p/postfixadmin/bugs/317/

AliasHandler.php:
- add function domain_from_id()

MailboxHandler.php:
- add function domain_from_id()
- init(): use $this->domain instead of splitting $this-id again



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1684 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 10 years ago
parent 3f62a577a4
commit c5de88390e

@ -138,6 +138,11 @@ class AliasHandler extends PFAHandler {
return $retval;
}
protected function domain_from_id() {
list(/*NULL*/,$domain) = explode('@', $this->id);
return $domain;
}
protected function validate_new_id() {
if ($this->id == '') {
$this->errormsg[$this->id_field] = Config::lang('pCreate_alias_address_text_error1');

@ -51,19 +51,22 @@ class MailboxHandler extends PFAHandler {
return false;
}
list(/*NULL*/,$domain) = explode('@', $this->id);
if ($this->new) {
$currentquota = 0;
} else {
$currentquota = $this->result['quotabytes']; # parent::init called ->view()
}
$this->updateMaxquota($domain, $currentquota);
$this->updateMaxquota($this->domain, $currentquota);
return true; # still here? good.
}
protected function domain_from_id() {
list(/*NULL*/,$domain) = explode('@', $this->id);
return $domain;
}
/**
* show max allowed quota in quota field description
* @param string - domain

@ -51,6 +51,10 @@ abstract class PFAHandler {
# filled in init()
protected $id = null;
# the domain of the current item (used for logging)
# filled in domain_from_id() via init()
protected $domain = null;
# structure of the database table, list, edit form etc.
# filled in initStruct()
protected $struct = array();
@ -189,17 +193,21 @@ abstract class PFAHandler {
} elseif (!$this->validate_new_id() ) {
# errormsg filled by validate_new_id()
return false;
} else {
return true;
# } else {
# return true;
}
} else { # edit mode
if (!$exists) {
$this->errormsg[$this->id_field] = Config::lang($this->msg['error_does_not_exist']);
return false;
} else {
return true;
# } else {
# return true;
}
}
$this->domain = $this->domain_from_id();
return true;
}
/**
@ -210,6 +218,21 @@ abstract class PFAHandler {
*/
abstract protected function validate_new_id();
/**
* called by init() if $this->id != $this->domain_field
* must be overridden if $id_field != $domain_field
* @return string the domain to use for logging
*/
protected function domain_from_id() {
if ($this->id_field == $this->domain_field) {
return $this->id;
} elseif ($this->domain_field == "") {
return "";
} else {
die('You must override domain_from_id()!');
}
}
/**
* web interface can prefill some fields
* if a _prefill_$field method exists, call it (it can for example modify $struct)
@ -367,7 +390,7 @@ abstract class PFAHandler {
$result = $this->storemore();
# db_log() even if storemore() failed
db_log ($this->id, $this->msg['logname'], "");
db_log ($this->domain, $this->msg['logname'], $this->id);
if ($result) {
# return success message

Loading…
Cancel
Save