- 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
- start rewrite based on PFAHandler
- add initStruct(), initMsg(), webformConfig(), validate_new_id(),
create_allowed()
- drop old __construct() and view()
- replace $this->username with $this->id
- replace check of old password in change_pw() with $this->login
users/password.php:
- adopt to *Handler syntax
scripts/shells/mailbox.php:
- adopt to *Handler view() syntax
- add TODO - maildir column isn't displayed
xmlrpc.php:
- adopt to *Handler syntax
Note: as usual, the changes in xmlrpc.php are untested ;-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1360 a1433add-5e2c-0410-b055-b7f2511e0802
- move getVacationAlias to AliasHandler (the only code that uses it)
AliasHandler:
- insert (and rewrite) function getVacationAlias()
- change $vh->getVacationAlias() calls to $this->getVacationAlias.
This also means we don't need to call VacationHandler anymore to get
the vacation alias.
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1359 a1433add-5e2c-0410-b055-b7f2511e0802
AliasHandler.php:
- remove obsolete functions update(), is_mailbox_alias(),
is_vacation_address(), hasAliasRecord()
- updated delete() to use new *Handler syntax (most of it should be
moved to PFAHandler, but that's another story ;-)
users/edit-alias.php:
- replace $ah->update with $ah->set / $ah->store
- use 0/1 for $fForward_and_store instead of YES/NO
- use safepost instead of isset()
templates/users_edit-alias.tpl:
- use 0/1 for $fForward_and_store instead of YES/NO
xmlrpc.php:
- replace $ah->update with new *Handler syntax
Note: the changes in xmlrpc.php are untested again ;-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1358 a1433add-5e2c-0410-b055-b7f2511e0802
- remove deprecated functions get() and hasStoreAndForward()
scripts/shells/alias.php:
- ViewTask: switch to *Handler syntax
- ViewTask: display is_mailbox, goto_mailbox and on_vacation status
users/edit-alias.php:
- replace $ah->get() and $ah->hasStoreAndForward() with *Handler syntax
- remove outdated comment in header
xmlrpc.php:
- switch get() and hasStoreAndForward() to *Handler syntax
Note: the changes in xmlrpc.php are untested!
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1357 a1433add-5e2c-0410-b055-b7f2511e0802
- use new *Handler syntax to add/remove vacation alias
(implemented as function updateAlias() to avoid code duplication)
AliasHandler:
- setmore(): only use $oldvalues if no new on_vacation value is given
- setmore(): fix "undefined index" warning
edit.php:
- only set $values if a field is editable and displayed in the form
- do not set default values in $values
(without those changes, the vacation alias was always removed when
editing an alias)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1356 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
- setmore(): keep/(re-)add vacation and mailbox alias to goto
- hide 'goto_mailbox' if the alias does not belong to a mailbox
(done in initStruct for $new, otherwise in init())
edit.php:
- set $form_fields and $id_field later (after $hander->init()) - needed
for AliasHandler to decide if goto_mailbox should be displayed
With this commit, AliasHandler is feature-complete for usage with
edit.php. We even get a "deliver to local mailbox" checkbox :-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1348 a1433add-5e2c-0410-b055-b7f2511e0802
- $struct: add is_mailbox (does the alias belong to a mailbox?)
- $struct: add goto_mailbox (if the alias is a mailbox, does it point
to the mailbox or is it forward-only?)
- set goto_mailbox in read_from_db_postprocess()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1347 a1433add-5e2c-0410-b055-b7f2511e0802
- initStruct(): add 'on_vacation'
- read_from_db_postprocess(): split off vacation alias from $goto
and store vacation status in on_vacation (honors the vacation alias
only, not the details from the vacation table)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1344 a1433add-5e2c-0410-b055-b7f2511e0802
- override init() - change '*@domain' -> '@domain', then call parent::init()
- validate_new_id(): allow catchall ('@domain'), check only domain in this case
- create_allowed(): copy of check_alias() from functions.inc.php, with
superfluous { ... } removed
- remove forgotten debugging from mergeId()
- _field_goto():
- allow '@domain' targets (domain-wide forward)
- use an array to collect error messages - that avoids 'uninitialized'
warnings and allows to easily change the join() glue if needed
Overall status:
- create-alias is now fully supported
- handling of vacation and mailbox aliases is still on my TODO list, which
means we still need edit-alias for now
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1316 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
- add initStruct() (not the final version, but works for now)
- add initMsg()
- replace $this->username with $this->id everywhere
- drop __construct() - default __construct will be used now
users/edit-alias.php, xmlrpc.php, VacationHandler.php, scripts/shells/alias.php:
- use default init sequence for AliasHandler (new, then ->init())
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1310 a1433add-5e2c-0410-b055-b7f2511e0802
- add rewritten function create_admin() (now using AdminHandler,
which means 25 instead of 80 lines)
- various follow-up changes to match the rewritten function create_admin()
functions.inc.php:
- delete function create_admin() - setup.php was the last file calling it
- honor POSTFIXADMIN_SETUP in authentification_get_username() to avoid
a redirect to login.php after creating an admin with setup.php and to
get "SETUP.PHP" for db_log()
model/AdminHandler.php:
- add TODO: implement generate_password
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1301 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
- add empty no_domain_field() to disable default die() from PFAHandler
- $struct:
- changed 'superadmin' to normal bool field (+ TODO note)
- changed 'password2' to be an alias of password in SELECT
- init 'domains' default with array() and options with list_domains(),
- storemore():
- implement storing domains in domain_admins table
- implement storing ALL in domain_admins table for superadmins to
keep the database backwards-compatible with 2.3.x for now
- add read_from_db_postprocess() to convert the domains list to an array
This makes AdminHandler working with edit.php?table=admin
(Some fine-tuning at various places/files is still missing.)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1291 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
(yes, we get edit mode "for free")
model/AliasdomainHandler.php:
- add webformConfig()
configs/menu.conf:
- change url_create_alias_domain to edit.php?table=aliasdomain
templates/list-virtual_alias_domain.tpl
- change ?target_domain to &target_domain
(TODO: this is currently ignored by edit.php)
- add edit link (TODO: add log action to avoid the error message)
create-alias-domain.php:
- deleted :-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1275 a1433add-5e2c-0410-b055-b7f2511e0802
- set $domain_field to enable permission handling (and to get a list of
allowed/available domains)
- fill $this->struct['alias_domain']['options'] and
$this->struct['target_domain']['options'] with available domains that
are not yet used as alias domain
- override init() to get "All domains are already aliased" error message
out as early as possible (and let init() fail in this case)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1269 a1433add-5e2c-0410-b055-b7f2511e0802
- set $domain_field to enable domain permission handling
list-domain.php:
- use permission handling of DomainHandler. This means:
- no need to call list_domains_for_admin()
- no longer hand over SQL sniplets
- much easier handling for superadmins and "simulate admin" mode
- 14 lines less code for permission handling etc.
- remove superfluous/outdated header comments
- move $smarty_assign('select_options') to global section (it's the
same code for domain admins and superadmins)
Note: don't try to read the diff of list-domain.php.
Read the complete file instead ;-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1267 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
- AddTask:
- use $values[$field] instead of a short variable name for input
- hand over $values array to __handle as array instead of dozens of variables
- ViewTask: use $struct for printing the output
model/DomainHandler.php:
- use 'created' as label for created
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1259 a1433add-5e2c-0410-b055-b7f2511e0802
- read transport options from $handler->getStruct
(instead of $handler->getTransports())
- convert selected transport to to transport name directly
(instead of using $handler->getTransport)
model/DomainHandler.php:
- init_struct: read transport options with Conf::read directly
(instead of using $this->getTransports()
- delete no longer used functions getTransports() and getTransport()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1256 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
- initStruct(): fix alias_count ("something - NULL" is always NULL, now
enforces integer 0 for each JOINt in field with NULL value)
- set() now checks if $this->_field_$fieldname exists and calls it as
additional validator
- split store() into store() (stores $this->values in the database) and
storemore() (stores additional things and/or calls scripts)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1249 a1433add-5e2c-0410-b055-b7f2511e0802
- pacol(): new parameter $dont_write_to_db - needed to skip JOINt in
columns which (of course) aren't available on INSERT or UPDATE
model/DomainHandler.php:
- initStruct(): mark JOINt in columns with the dont_write_to_db flag
- store(): skip columns with the dont_write_to_db flag set (not_in_db
columns are also/still skipped)
In non-technical terms: create-domain works now :-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1244 a1433add-5e2c-0410-b055-b7f2511e0802
- read_from_db(): provide a working $colformat['ts'] for postgresql
_and_ mysql (the only mysql/pgsql-specific code in DomainHandler,
everything else works with both)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1242 a1433add-5e2c-0410-b055-b7f2511e0802
- assign smarty values only for fields that have the display_in_form flag
model/DomainHandler.php:
- initStruct(): make default_aliases display_in_form dependant on $this->new
(it's useless in edit mode)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1235 a1433add-5e2c-0410-b055-b7f2511e0802
- use a new SELECT query syntax (sub-SELECTs) that gets all needed
information (including alias count, mailbox count and total quota)
in one query and is fast as light.
Better don't ask how long it took me to write this query, and I
seriously hope it works with postgresql. Otherwise...!
- add alias_count, mailbox_count and total_quota (including the required
SQL magic) to $struct
- add support for funny[tm] query tricks in $struct:
- replacement for field name in SELECT statement
- additional SQL after the FROM xy clause - useful for JOINs
- new function getList($condition) to get a list of domains
- order SELECT results by $this->id_field (needed for getList)
- add comment about the values used in $struct[*][type]
functions.inc.php:
- add two more optional parameters to pacrypt(): $select and $extrafrom
scripts/shells/domain.php:
- display number of existing aliases and mailboxes
- display quota sum
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1230 a1433add-5e2c-0410-b055-b7f2511e0802
- split view() into
- read_from_db (with param $condition, can also be used with other
conditions than "domain = $this->username")
- view() - fetches one row
(as preparation before implementing a function to list all domains)
- read_from_db():
- replace $bool_fields with $colformat['bool'] - now the database
results for bool fields are always 0/1 (by using CASE in the query),
and have an additional _$field with yes/no
- resultset is now an array of rows (instead of a single row)
- use db_assoc() instead of db_array()
- view(): use read_from_db()
- store(): change a comment that confused vim autofolding
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1229 a1433add-5e2c-0410-b055-b7f2511e0802
- new function db_where_clause($condition, $struct) to create a WHERE clause.
bool values are converted with db_get_boolean() based on $struct
model/DomainHandler.php - view():
- build WHERE clause with db_where_clause()
- new array $colformat for columns which need special handling in the field list
(that's more readable than tons of elseif on the long term, and allows easier
customization (hook/$CONF value?))
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1228 a1433add-5e2c-0410-b055-b7f2511e0802
- store() can now handle INSERT and UPDATE (depending on $this->new) :-)
- store some texts in $this->msg[] (replaced several $this->variable)
to make functions easier reuseable
- new function initMsg to fill $this->msg[] (can depend on $this->new)
- convert values to a DB-understandable format in store(), not in set()
(affects only bool for now, another candidate is pacrypt()ing passwords)
- check if all fields are set (on new)
- unset all not_in_db fields in $db_values in foreach loop
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1223 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 __construct to
- __construct($new=0) - init $struct etc. and
- init($username) - validate $username
This allows reading of $struct before doing any check on the username,
and will also avoid problems when I implement a function to list all
domains
- init(): use direct return values instead of $this->return
scripts/shells/domain.php, create-domain.php
- update to use new DomainHandler->init()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1219 a1433add-5e2c-0410-b055-b7f2511e0802
- new: public function getStruct()
- make store() public explicitely
- store domain_postcreation error message in $this->errormsg
- use existing error message instead of "invalid domain"
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1216 a1433add-5e2c-0410-b055-b7f2511e0802
Class Lang uses exactly the same code as Class Config - therefore
I replaced its code with a simple "extends Config".
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1212 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
- view():
- auto-generate field list based on $this->struct
- use date_format() for timestamp fields in the sql query
- convert bool fields to integer 0/1 (postgresql uses t/f internally)
to make the result database independent
- enable "display in list" for "created" column to avoid error in
CLI view domain
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1209 a1433add-5e2c-0410-b055-b7f2511e0802
- validate $username (domain name in this case) in __construct
(using the new function validate_id)
- make initStruct protected (was private)
- additional parameter for view() to supress error messages
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1207 a1433add-5e2c-0410-b055-b7f2511e0802
various fixes, implemented some TODOs
- move table name into variable $this->db_table
- use correct config option to detect if quota support is enabled
- fix (virtual) column name for default aliases
- use type 'ts' (timestamp) for created and modified
- fill non-editable rows with defaults if $this->new
- read values from $values instead of safepost()
- unset $db_values['default_aliases'] before writing to database
- some other minor changes
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1203 a1433add-5e2c-0410-b055-b7f2511e0802
- integrate $defaults in $struct to have everything in one place
- integrate field labels, descriptions etc. in $struct
- $struct now has named keys and is filled with the new pacal() helper function
- replaced TODO comments with new ones ;-)
functions.inc.php:
- new function pacol() to fill $struct with an associative array
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1145 a1433add-5e2c-0410-b055-b7f2511e0802
- use smtp_get_admin_email() to get the sender for the welcome mail
- add a check for empty (shouldn't happen in theory) or 'CLI' username
and use the mailbox address as fallback
This is based on Dale's patch, but completely rewritten (what a big word
for two lines of code ;-) Dale had only added the line
if(empty($fFrom)) $fFrom = $this->username;
My version is tested with CLI with both $CONF[admin_email] set and empty.
This commit is part of the huge cleanup patch by Dale Blount (lnxus@SF),
https://sourceforge.net/tracker/?func=detail&atid=937966&aid=3370510&group_id=191583
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1127 a1433add-5e2c-0410-b055-b7f2511e0802
- check_vacation() used outdated syntax $ah->get() which nowadays only
returns true/false. Fixed to fetch $ah->result() and added at least
basic error handling.
Indirectly ;-) reported by supa_user on IRC
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1075 a1433add-5e2c-0410-b055-b7f2511e0802
(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
- set_away() killed the existing aliases and replaced them with the vacation
alias instead of adding it. Fixed.
- remove array() from db_update calls for vacation table (introduced by valkum
in r981) - the vacation table has created/modified columns since r945
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@988 a1433add-5e2c-0410-b055-b7f2511e0802
*fixed VacationHandler.php
*changed edit-vacation to us VacationHandler
*added todopoint to upgrade.php
*fixed problem in AliasHandler
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@981 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
- implement delete()
Note that this is a dummy function at the moment. It doesn't work,
it just errors out with "not implemented yet" ;-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@961 a1433add-5e2c-0410-b055-b7f2511e0802
- use $this->username for the domain name (I know the variable name is
confusing, but I'd like to be consistent with the other classes)
- remove $domain parameter in add() and view(), use $this->username instead
- escape domain in view() for select query
- removed unused "global $config" in view()
- remove superfluous created/modified arrays in db_insert calls
- added some TODO notes
- changed db_log to 'CONSOLE' instead of $this-username for consistency
with other classes. Long-term fix is to remove the first parameter of
db_log and let it detect the username automatically.
- various whitespace fixes
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@958 a1433add-5e2c-0410-b055-b7f2511e0802
- added several TODO notes
- use db_insert/db_update/db_delete instead of raw queries
- get_details(): error check first (for better readable code),
whitespace fix
- getVacationAlias: str_replace is enough
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@938 a1433add-5e2c-0410-b055-b7f2511e0802
column and value are separate parameters now
functions.inc.php:
- changed function db_update() parameters - column name and value for the WHERE
condition are now two separate parameters. This means we don't need to
escape_string(), add quotes etc. for most UPDATE queries.
Example call: db_update('alias', 'address', $this->username, $values_array)
- the previous db_update() is now called db_update_q()
model/UserHandler.php:
- changed db_update call to the new parameters
- removed now unused variables
- renamed $username to $E_username
- call pacrypt directly when setting the $set array, no need for $new_db_password
model/AliasHandler.php
- changed db_update call to the new parameters
edit-mailbox.php
- switched to db_update_q()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@931 a1433add-5e2c-0410-b055-b7f2511e0802
shells/alias.php:
- execute still called help() instead of __handle()
model/AliasHandler.php - delete():
- remove useless $address parameter from delete() (we have $this->username)
- added error messages
- fixed variable names for db_log
Reason for the "mostly":
The $this->is_mailbox_alias() in delete() always returns true and therefore
forbids deletion.
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@930 a1433add-5e2c-0410-b055-b7f2511e0802
- moved scripts/models-ext/DomainHandler.php to model/
- deleted redirect scripts in scripts/models-ext/ (UserHandler.php,
AliasHandler.php)
- changed scripts/common.php to include the files from ../model/
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@925 a1433add-5e2c-0410-b055-b7f2511e0802
-added alias delete function
-remove silly password function in domain and alias
-changed some $this->err to $this->error
-error ends with stop(1) which returns 1 in *unix shells
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@920 a1433add-5e2c-0410-b055-b7f2511e0802
- if you want to verify the old password, you should compare it against
the OLD and not the NEW password ;-)
- fix database calls
In other words: changing the password in users/password.php works again ;-)
users/password.php:
- switch from obsolete change_pass() to change_pw()
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@916 a1433add-5e2c-0410-b055-b7f2511e0802
- pass $username through strtolower()
- get(): error check first for better readability (avoids long if block)
- get(): fixed a forgotten return behaviour change
- get(): renamed $new_list to $filtered_list (self-explaining code)
- update(): migrated to new return behaviour of get()
- update(): use db_update etc.
- some minor changes
- added various TODO notes
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@915 a1433add-5e2c-0410-b055-b7f2511e0802
changed behaviour of get()
- get() now returns only true (success) / false (failure) instead of
the alias list
(result of partly merging in scripts/models-ext/AliasHandler.php)
- new method result() to get the real result (alias targets)
- added TODO on if(sizeof($addresses) == 0) - this should never happen
model/VacationHandler.php:
- updated for new AliasHandler bevaviour
xmlrpc.php:
- updated for new AliasHandler bevaviour
- switched from obsolete change_pass to change_pw method
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@912 a1433add-5e2c-0410-b055-b7f2511e0802
- change_pass() now returns the return value of change_pw()
- made most variables un-escaped (as expected by db_insert/db_update/
db_delete). This means they HAVE TO BE ESCAPED when using them in a
hand-written query. (Error messages also need escaping - the
backslashes from escape_string wouldn't help there anyways.)
- escaped variables renamed to $E_whatever
- changed all return values to true (success) and false (failure)
instead of shell-like 0 (success) and 1 (failure)
- removed unused global $config at various places
- removed timestamp columns from db_insert and db_update call where they
match the default
- added db_log() for some (but not all) failures
- honor $CONF[maildir_name_hook] when creating a mailbox
- splitting a mail address is now done with list(...) = explode(...)
- switched to db_begin(), db_commit(), db_rollback()
- let smtp_mail create the mail header
- added missing db_commit in delete()
- various minor fixes, code cleanup, comments and TODO notes
To sum it up: all code in UserHandler.php that does not have a TODO
attached should be fine :-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@908 a1433add-5e2c-0410-b055-b7f2511e0802
- merged in all new functions and changes (by valkum + some bugfixes
and notes from me) - for details see r831, r888 and r891 of
scripts/models-ext/UserHandler.php
- re-added change_pass() function (was removed/renamed by valkum) for
backward compatibility.
IMPORTANT: change_pass will only exist temporarily and is deprecated.
Besides that, the new implementation has different return values etc.
so existing code might break already.
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@896 a1433add-5e2c-0410-b055-b7f2511e0802
- hand over $search to smarty templates
templates/list-virtual_alias.tpl, templates/list-virtual_alias_domain.tpl:
- add search result highlighting
templates/list-virtual_mailbox.tpl:
- add search result highlighting
- move output of "Mailbox" / "Forward only" outside the foreach loop
(was displayed once per mailbox alias target)
css/default.css:
- add style for ".searchresult"
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@868 a1433add-5e2c-0410-b055-b7f2511e0802
- remove session_start() - the session is already started in common.php
model/UserHandler.php:
- db_log() used undefined variable $USERID_USERNAME - use $username instead
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@625 a1433add-5e2c-0410-b055-b7f2511e0802