Commit Graph

76 Commits (161c9b1ed2c218ea4f2ad641ff0d9db23e4fc2bc)

Author SHA1 Message Date
Christian Boltz 161c9b1ed2 scripts/shells/domain.php:
- 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
13 years ago
Christian Boltz 8dda511cd5 scripts/shells/domain.php / AddTask:
- 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
13 years ago
Christian Boltz e4fc3623cc PFAHandler.php:
- add/update several comments



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1255 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz ae52f243e5 PFAHandler.php, DomainHandler.php:
- 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
13 years ago
Christian Boltz 7a236d401c DomainHandler.php:
- rename $this->username to $this->id
- rename function validate_id() to validate_new_id()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1253 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 7ac37cfbff templates/editform.tpl:
- 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
13 years ago
Christian Boltz 102d4c8c32 DomainHandler.php:
- whitespace fixes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1250 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz eac2564c40 DomainHandler.php:
- 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
13 years ago
Christian Boltz a03a020095 MailboxHandler.php:
- delete(): use escaped $E_domain instead of $domain in some queries


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1247 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz a8e626fe7f functions.inc.php:
- 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
13 years ago
Christian Boltz a1dba20aff model/DomainHandler:
- 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
13 years ago
David Goodwin 5a18a1e48b postgresql fixes for DomainHandler perhaps
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1240 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
David Goodwin 563e401c92 make Config.php a php5 compatible object; remove strict standards warnings
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1236 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 72441d7dd6 create-domain.php:
- 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
13 years ago
Christian Boltz a1fdd87360 MailboxHandler.php:
- add comment about forcing $CONF['domain_in_mailbox] = YES if 
  $CONF['domain_path'] == NO. 
  
Without this comment, the code might look buggy - confirmed ;-) in
https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3427498&group_id=191583



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1232 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 7f9d947e8f model/DomainHandler.php:
- 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
13 years ago
Christian Boltz 532712303a model/DomainHandler.php:
- 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
13 years ago
Christian Boltz 429ef27031 functions.inc.php:
- 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
13 years ago
Christian Boltz 7a237c98f4 DomainHandler:
- new function getId_field()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1224 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz c87a0b97f4 DomainHandler.php:
- 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
13 years ago
Christian Boltz 95bf0161c6 Make create-domain.php even shorter (109 -> 89 lines) ;-)
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
13 years ago
Christian Boltz f8fb724dcf model/DomainHandler.php:
- 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
13 years ago
Christian Boltz 1aeae661af DomainHandler.php:
- 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
13 years ago
Christian Boltz 1a4bd35e08 Move the classes "Config" and "Lang" to scripts/common.php to model/
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
13 years ago
Christian Boltz 78d15b084d DomainHandler.php:
- 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
13 years ago
Christian Boltz 8ed7747a81 DomainHandler.php:
- 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
13 years ago
Christian Boltz bf2d5e0f4b DomainHandler.php:
- 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
13 years ago
Christian Boltz 7a9a993083 PFAHandler, AliasHandler:
- move result() from AliasHandler to PFAHandler
- AliasHandler now extends PFAHandler


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1205 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 14c5433faf DomainHandler:
- use ' instead of " for $struct keys
- whitespace changes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1204 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 1e601ce4d4 DomainHandler.php:
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
13 years ago
Christian Boltz ed7019ff5c MailboxHandler:
- whitespace changes


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1200 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz d09ae9e360 model/DomainHandler.php:
- 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
13 years ago
Christian Boltz c4fd99baa7 MailboxHandler.php:
- 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
13 years ago
Christian Boltz 931a375255 VacationHandler:
- 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
13 years ago
Christian Boltz 9f94438a78 model/DomainHandler.php:
- replace $domain with $this->username in add()
- comment cleanup


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1047 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 19bf885fa9 model/DomainHandler.php:
- allow editing and viewing of "quota" (domain-level quota) field.
  Otherwise the CLI can't set it ;-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1044 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 562f1ac5b8 model/DomainHandler.php:
- get default domain quota from $CONF
- remove unused from "quota" field - it's used now ;-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1043 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 721ee60e8d DomainHandler.php:
- convert domain name to lowercase

This is a follow-up to
https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3287965&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1038 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz b89b94cf83 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
13 years ago
Christian Boltz c75022ad50 VacationHandler.php:
- 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
14 years ago
Valkum 179f195bf1 *fixed db_insert - duplicate $timestamp
*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
14 years ago
Christian Boltz 51262b7675 DomainHander: on the way to a common interface for all classes and
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
14 years ago
Christian Boltz 6225e555f4 model/AliasHandler.php:
- fix comment for delete() - it no longer has a param

model/*:
- add svn $Id line


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@975 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago
Christian Boltz c97e5224dc Remove $username parameter from db_log()
functions.inc.php:
- remove $username parameter from function db_log()
  (now auto-detected with authentication_get_username())

various files:
- remove hardcoded username ('CONSOLE', $username etc.) in db_log() calls


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@966 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago
Christian Boltz 07c21cfa07 VacationHandler.php:
- replaced deprecated split() call with explode()
  https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3179951&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@962 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago
Christian Boltz 1de551320b DomainHandler.php:
- 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
14 years ago
Christian Boltz 562842f154 DomainHandler.php:
- return true/false instead of shell-style 0/1


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@959 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago
Christian Boltz d21bf2e82d DomainHandler.php: proofreading results: various small changes
- 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
14 years ago
Christian Boltz cebf126eff AliasHandler.php:
- escape $address in is_mailbox_alias()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@956 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago
Christian Boltz 02391146b2 AliasHandler.php: fix false positives in is_mailbox_alias and various
small fixes and cleanups

- get(): whitespace fix
- is_mailbox_alias(): avoid false positives if $address is a mailbox,
- is_mailbox_alias(): remove disabled (commented) old code
- update(): remove unused variable $true
- delete(): removed superfluous parameter in $this->get() call
- delete(): removed outdated FIXME note


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@939 a1433add-5e2c-0410-b055-b7f2511e0802
14 years ago