- initStruct(): add some comments
- add calledBy() and protected $called_by - calledBy() should be called if one
*Handler class calls another one (to avoid loops etc.)
AliasHandler.php:
- replace $called_by_MailboxHandler / MailboxAliasConfig() with $called_by
(code moved to PFAHandler->calledBy())
MailboxHandler.php:
- beforestore(): update alias active status on edit
(contains some whitespace changes - basically I removed "if ($this->new)"
around most parts of the code)
- use calledBy() instead of MailboxAliasConfig()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1449 a1433add-5e2c-0410-b055-b7f2511e0802
edit.php:
- call $handler->prefill for all prefill fields
- refresh $form_fields after handling prefill fields
model/PFAHandler.php:
- add prefill() to handle prefill fields. If $this->_prefill_$field()
exists, it will be called
model/MailboxHandler.php:
- init(): error out early if parent::init fails (no need to check the
available quota if $this->id is invalid ;-)
- move updating the allowed quota to updateMaxquota()
- update the available quota based on the prefill domain. If no prefill
domain is given, default to the first domain.
- new method _prefill_domain()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1426 a1433add-5e2c-0410-b055-b7f2511e0802
- set(): if a field is not set and there's no _missing_$field() method
for it, take default value from $this->struct
(side effect: this automagically fixes CLI create domain)
- store(): add a beforestore() hook that is called at the beginning of
store()
- add empty beforestore() (will be overwritten by MailboxHandler)
- some comment updates
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1423 a1433add-5e2c-0410-b055-b7f2511e0802
- make PFAHandler an "abstract class"
- add functions that must be implemented by every *Handler class
as abstract functions:
- abstract protected function initStruct();
- abstract protected function initMsg();
- abstract public function webformConfig();
- abstract protected function validate_new_id();
- lots of additional comments
AdminHandler, AliasdomainHandler, DomainHandler, MailboxHandler:
- remove comments that are now in PFAHandler
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1385 a1433add-5e2c-0410-b055-b7f2511e0802
- add lots of comments
- sort variables into categories
- public variables (currently only errorMsg)
- must be defined in *Handler classes
- set by methods
- (no "real" code changes)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1383 a1433add-5e2c-0410-b055-b7f2511e0802
- set(): call $this->_missing_$fieldname() if a field is not set on $new
- new function set_default_value() - typically called from
_missing_$fieldname to set the default from $struct
AliasHandler:
- set default values on $new:
- on_vacation and active from $struct default
- localpart and domain based on address
scripts/shells/alias.php:
- convert AddTask to *Handler syntax. It was broken before, see
https://sourceforge.net/tracker/?func=detail&aid=3232719&group_id=191583&atid=937964
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1364 a1433add-5e2c-0410-b055-b7f2511e0802
- add function compare_password_fields() - compares if two fields contain
the same password (based on _field_password2() from AdminHandler)
and use pEdit_mailbox_password_text_error as error message because it
doesn't contain "... or empty"
AdminHandler:
- replace _field_password2() with a call to $this->compare_password_fields()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1361 a1433add-5e2c-0410-b055-b7f2511e0802
- add support for LIMIT/OFFSET to getList()
AliasHandler:
- overload getList() to only return non-mailbox aliases
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1353 a1433add-5e2c-0410-b055-b7f2511e0802
(TODO: catchall handling, mailbox and vacation aliases)
AliasHandler.php
- drop unused $username
- set $domain_field
- initStruct():
- use correct labels
- set 'domain' field options to allowed domains
- add (virtual) 'localpart' field
- add comments for more virtual fields
- add webformConfig() (note: modifies $struct on $new - otherwise we
couldn't use the domain dropdown in the web interface)
- add mergeId to merge localpart and domain to address (called by
edit.php _before_ ->init)
- add validate_new_id() (doesn't work for catchall yet)
- add setmore() to
- fill 'domain' based on 'address'
- convert $values[goto] from array to comma-separated string
- add read_from_db_postprocess to split goto to an array
(TODO: handling of mailbox and vacation aliases)
- add _field_goto() validator
- add empty, commented dummy delete() that will replace the "old"
delete function one day
- make hasAliasRecord() private (only used internally)
- mark all "old" functions as obsolete
edit.php:
- add handling of txtl field (convert textarea to array)
- call $handler->mergeId if $id_field is editable, but not displayed
in form (usecase: merge localpart + domain to address)
editform.tpl:
- add handling of txtl fields (textarea, filled by array)
PFAHandler.php:
- add setmore() hook function - runs at the end of set()
AdminHandler.php:
- add a comment for 'txtl' (array of one line texts, like alias goto)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1311 a1433add-5e2c-0410-b055-b7f2511e0802
- store unchecked input values given to set() in $this->RAWvalues before
running the validation functions. This is needed to make comparing
password and password2 possible.
(uppercase RAW intentional to make usage harder - hopefully hard enough
to give everybody who wants to use it some time to think over secure
programming when working with unchecked input ;-)
AdminHandler.php:
- compare password and password2
This commit means AdminHandler is complete :-)
(Note: db_log can't handle the admin-related log actions yet.)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1297 a1433add-5e2c-0410-b055-b7f2511e0802
- fix field type for skipping password fields (must be 'pass', not 'password')
- implement validation of 'pass' fields with validate_password()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1293 a1433add-5e2c-0410-b055-b7f2511e0802
- also include column in SELECT if display_in_form != 0
- call read_from_db_postprocess() hook before returning data
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1287 a1433add-5e2c-0410-b055-b7f2511e0802
- split code to handle domain_field == "" && admin_username != ""
from __construct() to no_domain_field().
Default behaviour stays to die(), but AdminHandler will override it
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1286 a1433add-5e2c-0410-b055-b7f2511e0802
allow restriction to an admin's domain permissions
- new protected variables:
$admin_username - if set, restrict $allowed_domains to this admin
$domain_field - column containing the domain
$allowed_domains - if $domain_field is set, this is an array with
the domain list
- __construct: new optional parameter $admin_username to restrict
allowed domains to this admin's permissions
- read_from_db(): handle $allowed_domains
- read_from_db(): fix query if $condition == ""
PS: Yes, I know some people would like to kill me for including
permission stuff in PFAHandler, but it's the best (and shortest,
only +20 lines) way to handle it.
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1266 a1433add-5e2c-0410-b055-b7f2511e0802
- move definition of public and protected variables to DomainHandler.php
- move lots of functions from DomainHandler.php to PFAHandler.php:
- __construct()
- init()
- set()
- store()
- read_from_db()
- view()
- getList()
- getStruct()
- getId_field()
All functions and comments were moved without any modification.
See the history of DomainHandler.php if you need to find out something
about the history of the functions listed above.
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1254 a1433add-5e2c-0410-b055-b7f2511e0802
- new file
- generic edit form template that uses $struct to render the form
templates/admin_edit-domain.tpl:
- deleted, obsoleted by editform.tpl
create-domain.php
- use new editform.tpl
- use $errormsg array instead of join't $errortext
- store/move errors related to a display_in_form field in $fielderror
(they will be displayed next to the field)
- display remaining error messages (not related to a field) with
flash_error()
- use "value_$key" instead of "t$Key" as smarty variable name for field
values
model/DomainHandler.php
- store error messages in $this->errormsg[$field] (instead of $this->errormsg[])
- fix label for default_aliases
model/PFAHandler.php:
- store error messages in $this->errormsg[$field] (instead of $this->errormsg[])
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1252 a1433add-5e2c-0410-b055-b7f2511e0802
create-domain.php
- replace old $form_fields with $handler->getStruct()
- rewrite handling POST data to make it easier to understand
- move reading POST input to the section handling POST
- remove condition on POST (we are in the POST block now)
- check if editing of a field is allowed (use default value if not)
- move validation of 'enum' fields to PFAHandler
- allow changing the "active" state (instead of hardcoding it)
model/PFAHandler.php:
- add check for 'enum' fields
model/DomainHandler.php:
- change default for "active" and "default_aliases" to 1
templates/admin_edit-domain.tpl:
- don't hide the "Active" checkbox on new
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1220 a1433add-5e2c-0410-b055-b7f2511e0802
- split add() function to
- set() (validate values) and
- store() (write to database)
- set():
- replace $checked with $this->values
- store validation summary in $this->values_valid
PFAHandler.php:
- change _inp_* functions to return true/false if value is (in)valid
instead if the sanitized value. They now also set $this->errormsg[]
(not the final solution, but works for now)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1210 a1433add-5e2c-0410-b055-b7f2511e0802
easy-to-edit field lists. With lots of inspiration from fetchmail.php
and a base class I started 2.5 years ago.
model/DomainHandler.php
- base on PFAHandler (see below)
- new protected variables
- $id_field (column that contains $username)
- $struct (field list)
- $defaults (default values, option lists)
- $new (switch between new and edit mode)
- change $username to protected (preparation for move to PFAHandler)
- add optional $new parameter to __construct. Targets (not yet implemented):
- early validation of $username (domain name in this case)
- if $new == 1, check that item does NOT exist and is a valid domain
- else: check if item exists. error out if not.
- new function initStruct to fill $id_field, $struct, $defaults
- add():
- use an array as parameter instead of single parameters
Advantage: this makes it easy to add another field
- use _inp_* base validation
- create default aliases only in create mode, not in edit mode
- view(): fix error message
- added various TODO notes. Some affect design questions - feedback welcome ;-)
scripts/shells/domain.php:
- change $handler->add call to array usage
- add some TODO notes
- some whitespace fixes in execute()
model/PFAHandler.php:
- new base class for *Handler classes
- contains only some generic input validation for now
- more code will be moved from DomainHandler to PFAHandler later
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@978 a1433add-5e2c-0410-b055-b7f2511e0802