SF.net SVN: postfixadmin:[1684] trunk/model
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2014-09-12 09:22:11
|
Revision: 1684 http://sourceforge.net/p/postfixadmin/code/1684 Author: christian_boltz Date: 2014-09-12 09:22:09 +0000 (Fri, 12 Sep 2014) Log Message: ----------- 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 Modified Paths: -------------- trunk/model/AliasHandler.php trunk/model/MailboxHandler.php trunk/model/PFAHandler.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2014-09-11 22:17:59 UTC (rev 1683) +++ trunk/model/AliasHandler.php 2014-09-12 09:22:09 UTC (rev 1684) @@ -138,6 +138,11 @@ 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'); Modified: trunk/model/MailboxHandler.php =================================================================== --- trunk/model/MailboxHandler.php 2014-09-11 22:17:59 UTC (rev 1683) +++ trunk/model/MailboxHandler.php 2014-09-12 09:22:09 UTC (rev 1684) @@ -51,19 +51,22 @@ 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 Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2014-09-11 22:17:59 UTC (rev 1683) +++ trunk/model/PFAHandler.php 2014-09-12 09:22:09 UTC (rev 1684) @@ -51,6 +51,10 @@ # 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 @@ } 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; } /** @@ -211,6 +219,21 @@ 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) * @param string - field @@ -367,7 +390,7 @@ $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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |