Commit Graph

1021 Commits (72441d7dd6bde656adbc769b8e7685bd5b87c650)
 

Author SHA1 Message Date
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 7b15c4b47d functions.inc.php:
- pacol(): use Lang::read instead of global $PALANG (which is undefined
  when called from a *Handler class)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1234 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 40dfc881c2 es.lang:
- updated translation for pCreate_mailbox_mail

Patch by Jordi Llonch (llonchj@SF),
https://sourceforge.net/tracker/?func=detail&atid=937966&aid=3427631&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1233 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 3a419a3246 list-domain.php:
- use DomainHander->getList()
  - line count: 126 -> 85 = 41 less :-)
- preselect correct username in admin dropdown



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1231 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 7ed7c67fbe functions.inc.php - smtp_mail():
- error_log() the error message if fsockopen() fails


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1227 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 2f52a8402d edit-domain.php:
- deleted (obsoleted by create-domain.php)

create-domain.php:
- fixed wrong variable name that broke saving an edited domain

configs/menu.conf, templates/adminlistdomain.tpl
- changed to use create-domain.php?edit= instead of edit-domain?domain=



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1226 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 24836cf3ad Add edit mode to create-domain.php
create-domain.php:
- add edit mode (use ?edit=example.com)
- use $id_field instead of hardcoded 'domain'
- redirect to list-domain after saving in edit mode
- rename some variables

edit-domain.php:
- rename some smarty variables

templates/admin_edit-domain.tpl:
- rename some smarty variables
- add two hidden fields "edit" and "domain", both contain $tDomain
  (only in edit mode)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1225 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 53d720a569 functions.inc.php:
- db_get_boolean(): allow 0 and 1 as parameters, not only boolean true/false


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1222 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 7fd57740cd create-domain.php:
- assign $values to smarty in a foreach loop

edit-domain.php, templates/admin_edit-domain.tpl:
- rename some smarty variables to match column name


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1221 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 5c5c79e8a9 Make create-domain.php shorter (164 -> 109 lines) ;-)
create-domain.php:
- rename "fField" form fields to just "field" to match the column names 
  in the database
- remove list of template and POST variables in the header - the code is
  self-documenting on this, one useless comment block less to maintain ;-)
- rename $default to $field - matches the usage better
- use $values[$key] instead $$key (this also avoids the need to fill
  $values before calling $handler->set)
- remove some validation that is already done in DomainHandler
- use $handler->set even if creating $handler results in an error to
  make error messages for all fields visible
- set $values to defaults at the end of the file if $error == 0 (and
  use a foreach loop) instead of doing it for GET at the beginning and
  again after successful POST
- remove some unused variables
- various other changes

edit-domain.php, templates/admin_edit-domain.tpl:
- rename "fField" form fields to just "field" to match the column names 
  in the database



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1218 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz a11d8c3dda Sometimes short commit messages are the best ones - see the message
for create-domain.php...

create-domain.php:
- finally: use DomainHandler :-))

edit-domain.php, create-domain.php, 
templates/admin_edit-domain.tpl:
- use 0/1 instead of off/on for checkboxes



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1217 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 646c790371 common.php, scripts/postfixadmin-cli.php:
- init Lang and Config classes in common.php instead of postfixadmin-cli.php -
  they need to be available in the web interface also


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1215 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 4611b111e3 common.php:
- merge with scripts/common.php
- don't start/use session in CLI mode
- don't load smarty.inc.php in CLI mode
- hardcode language to 'en' in CLI mode (was done in postfixadmin-cli.php before)

scripts/postfixadmin-cli.php - __bootstrap():
- use common.php instead of scripts/common.php
- don't load languages/language.php and languages/en.lang (already
  done via common.php)
- don't call language_hook (already done via common.php)

scripts/common.php:
- deleted
- dropped helper functions low(), up(), r() and pr() which were just
  shortnames for existing PHP functions


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1214 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 7bcd041d45 scripts/shells/*.php:
- use strtolower()/strtoupper() instead of low()/up() shortnames.
  This makes the code slightly longer, but easier to understand because
  strtolower()/strtoupper() are well-known function names



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1213 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 23e6dee1b2 shells/domain.php:
- *Task / __handle(): check $handler->result after calling "new"
- AddTask / __handle():
  - don't set domain in $values - it's already included in the "new" call
  - hardcode "active" to 1 - before, it accidently got the value of "aliases"
  - use $handler->set() and $handler->store instead of $handler->add()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1211 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 da21a4cae2 functions.inc.php:
- new function db_boolean_to_int() to convert boolean values from the 
  database to integer (0 or 1)
- db_get_boolean(): error out on unknown $CONF[database_type]


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1208 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 e88a7afdc2 *.lang:
- new error message: 
  $PALANG['domain_does_not_exist'] = 'This domain does not exist!';


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1206 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 6becdbba4a *.lang:
- $PALANG['pCreate_mailbox_mail'] = 'Send welcome mail', but some 
  translations mean "create mailbox".
  Added a note for translators to update it.

Reported by Segeja in #postfixadmin


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1202 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 8b636bd1ee create-mailbox:
- always display correct available quota (using allowed_quota())

Patch by Dale Blount (lnxus@SF),
https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3421296&group_id=191583


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1201 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 8b3976272f list-virtual.php:
- delivery to mailbox with a recipient delimiter (mailbox+foo@domain)
  was marked as "forward only"

This fixes 
https://sourceforge.net/tracker/?func=detail&aid=3420440&group_id=191583&atid=937964
reported by <stderr1> on #postfixadmin


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1198 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 88a840690b create-mailbox.php:
- use smtp_get_admin_email() instead of the admin's username as sender
  for the welcome mail

This fixes 
http://sourceforge.net/tracker/?func=detail&aid=2958684&group_id=191583&atid=937964
reported by mrfrenzy on IRC


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1197 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 3589514932 list-virtual.php:
- better error message if no domains exist or a domain admin doesn't
  have permissions for any domain. That's less confusing than the
  "Invalid parameter" message

*.lang:
- new (error) messages
  - $PALANG['no_domains_for_this_admin']
  - $PALANG['no_domains_exist']
 


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1195 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 83ec3e0cab create-mailbox.php:
- check password with validate_password
- cleanup password validation
- cleanup/merge duplicate assignment of $t* variables

This fixes the remaining 50% of
https://sourceforge.net/tracker/?func=detail&aid=1951979&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1194 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz d6d4fb4748 functions.inc.php - create_admin()
- check password with validate_password()
- cleanup the handling of the success message

This fixes 50% of
https://sourceforge.net/tracker/?func=detail&aid=1951979&group_id=191583&atid=937964


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1193 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 69b3df10e4 config.inc.php
- new config option $CONF['password_validation'] - array with regular
  expressions to check if a password is valid/good enough.
  The default configuration enforces:
  - minimum length 5 characters/digits/whatever
  - at least 2 characters
  - at least 2 digits
- removed $CONF['min_password_length'] - it's now handled in /.{5}/ in
  $CONF['password_validation']

functions.inc.php
- new function validate_password to check a given password against
  $CONF['password_validation']
- generate_password: generated password is always 8 chars long
  (instead of $CONF['min_password_length'])

edit-admin.php, users/password.php, edit-mailbox.php, setup.php:
- use validate_password instead of $CONF['min_password_length']

This implements
https://sourceforge.net/tracker/?func=detail&aid=1785513&group_id=191583&atid=937967


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1192 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz e38ba1f7cf users/password.php, edit-admin.php, edit-mailbox.php, *.lang:
- rename $PALANG['pPasswordTooShort'] to $PALANG['password_too_short']

*.lang:
- add $PALANG['password_no_characters'] and $PALANG['password_no_digits']
  (will be used by my next commit)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1191 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 9f2a0db106 create_admin() cleanup
functions.inc.php:
- create_admin(): use db_insert instead of INSERT queries
  (this includes automatic escaping of all values)

create-admin.php:
- use safepost instead of isset($_POST[...])
- don't escape_string post values - it's done inside create_admin now
- remove superfluous emptying of empty $tDomains for GET
- allow htmlentities-escaping for pAdminCreate_admin_username_text
- some whitespace / linebreak changes

setup.php:
- load config.inc.php only once (loading it twice will break if custom
  hook functions exist in config.*.php - "can't redefine function ...")
- use safepost instead of isset($_POST[...])
- don't escape_string post values - it's done inside create_admin now
- escape $tUsername with htmlentities() instead of escape_string



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1190 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz dc54de1657 smarty.inc.php - select_options():
- escape $val with htmlentities() (function result will/must be used
  unescaped later)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1189 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz bd4889a7c2 functions.inc.php - check_email():
- replace $CONF[vacation_domain] only at the end of the mail address


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1188 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 9d1f79c495 create-admin.php:
- fix SQL injection (only exploitable by superadmins)

Reported by Matthias Bethke (msbethke@SF),
https://sourceforge.net/tracker/?func=detail&atid=937964&aid=3412484&group_id=191583

Note: this fix is (intentionally) different from the fix in the 2.3 branch
and includes a TODO note for some bigger changes that we should do.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1186 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 8f805af202 de.lang:
- fix typo


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1182 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz 536b7ac688 config.inc.php:
- several comments for the language_hook function:
  - x_* naming policy for custom texts
  - note that custom texts must appear in all blocks
  - note that translation fixes should be reported in the bugtracker


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1177 a1433add-5e2c-0410-b055-b7f2511e0802
13 years ago
Christian Boltz a5f3cb9b96 config.inc.php:
- new config option $CONF['language_hook']
  Hook function to override or add translations to $PALANG.
  Example hook function included (commented out).

common.php:
- honor $CONF['language_hook']

scripts/postfixadmin-cli.php:
- honor $CONF['language_hook']
- add TODO - language shouldn't be hardcoded to english

This implements my feature request at
http://sourceforge.net/tracker/?func=detail&aid=3292408&group_id=191583&atid=937967


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