Commit Graph

84 Commits (1ad184641db35b8c20cb374c1c8360ef86af6bc7)

Author SHA1 Message Date
David Goodwin 1ad184641d php7.4 / psalm fixes 4 years ago
David Goodwin 2742849e7b reformat 5 years ago
David Goodwin 034a50836c tighten psalm checks 5 years ago
David Goodwin 74002bbf57 psalm fixes 6 years ago
Christian Boltz d2588a4de2
Fix phpcs whitespace breakage in initStruct etc. 6 years ago
David Goodwin cb34da4f46 phpcs reformat 6 years ago
David Goodwin 5e1855632a allow local aliases - see #134 6 years ago
Adrien Crivelli 15df6c1d7b
Reformat everything with PHP-Cs-Fixer 6 years ago
Jan-Frederik Rieckers 800f07816a
Fix wrong way of check for can_delete 7 years ago
Jan-Frederik Rieckers 7bb36d0bbc
Fix security hole in AliasHandler
Without this fix it is possible to delete a protected alias via editing
the request parameter of the alias to delete.
7 years ago
Christian Boltz 9ba7118d7b AliasHandler: restrict mailbox subquery to requested domains
set_is_mailbox_extrafrom() restricts the domain list to the domain that
needs to be checked (in normal list-virtual listing one domain), and is
then used to restore the default extrafrom.
This improves the performance for most usecases even for superadmins.

Note: Search mode might still be slow because by default it searches in
all domains available to the admin.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1882 a1433add-5e2c-0410-b055-b7f2511e0802
8 years ago
Christian Boltz 40b4fdf61c beautify alias list search parameters
AliasHandler:
- initStruct(): handle __mailbox_username as separate field (needed to
  make it searchable)
- split off a condition_ignore_mailboxes() function (used in getList()
  and getPagebrowser()) to add '__mailbox_username IS NULL' to the search
  condition array. Also, make sure $condition can be an array (preferred)
  or a string with a raw query

list-virtual.php:
- hand over a search array instead of a raw query


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1879 a1433add-5e2c-0410-b055-b7f2511e0802
8 years ago
Christian Boltz bd28fcb194 AliasHandler: restrict __is_mailbox subquery to allowed domains
This improves performance on setups with lots of mailboxes.
Well, except for superadmins because restricting to "all domains"
doesn't really help ;-)

Thanks to gygy for reporting this on IRC, and for testing the patch.



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1877 a1433add-5e2c-0410-b055-b7f2511e0802
8 years ago
Christian Boltz 37bba15625 Use list.tpl to display the alias list
list-virtual.php:
- use list.tpl for aliases
- move show_gen_status handling for aliases to AliasHandler

AliasHandler:
- initStruct():
  - add 'status' column (hidden by default)
  - hide 'created'
  - move 'active' after 'modified' to match old list-virtual.php layout
- initMsg: add list_header
- webformConfig(): if $CONF[show_status], set display_in_list for
  'status' column. Also set a (whitespace) label to make sure it's
  displayed
- db_read_from_db_postprocess(): if 'status' column is requested, call
  gen_show_status() for each row

list-virtual.tpl
- remove alias table header and create alias button (which should have
  been in list-virtual_alias.tpl)

list-virtual_alias.tpl:
- replace code to generate the alias table with {include 'list.tpl'}
  (and some variable assignments)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1777 a1433add-5e2c-0410-b055-b7f2511e0802
9 years ago
Christian Boltz 3a72203de4 AliasHandler:
- initStruct(): replace (wrong) 'editable' with '_can_edit' and '_can_delete'
- read_from_db_postprocess(): disable _can_edit and _can_delete for
  default aliases if special_alias_control is off and not superadmin

list.tpl:
- use $item._can_edit instead of $check_alias_owner

list-virtual.php:
- drop $check_alias_owner variable and check_alias_owner() call
  (replaced by the code added in AliasHandler)
- drop unused $sql_domain

functions.inc.php:
- delete no longer used check_alias_owner() function



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1774 a1433add-5e2c-0410-b055-b7f2511e0802
9 years ago
Christian Boltz 4ce0a57e83 PFAHandler:
- add protected $searchfields = array(); - list of fields to search by
  default, if just a search term is given. This will be done with
  $search['_'], but that code is not implemented yet.
- add $this->msg['show_simple_search'] (true if $searchfields is non-empty)

list.tpl:
- display search input box and search overview only if $searchfields is
  not empty

AliasdomainHandler:
- add 'alias_domain' and 'target_domain' to $searchfields

MailboxHandler:
- add 'username' to $searchfields

AliasHandler:
- add 'address' and 'goto' to $searchfields

This effectively means that the search input box is no longer displayed
in list.php for admin, domain and fetchmail listings.


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1770 a1433add-5e2c-0410-b055-b7f2511e0802
9 years ago
Christian Boltz 313270c00a PFAHandler.php:
- add getPagebrowser() (returns an array of pagebrowser keys)

AliasHandler.php:
- change getList() to work with empty $condition
- add getPagebrowser() to filter out mailboxes

list-virtual.php:
- replace $alias_pagebrowser_query and the create_page_browser() call
  with $handler->getPagebrowser()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1757 a1433add-5e2c-0410-b055-b7f2511e0802
9 years ago
Christian Boltz cc2b157d59 *Handler:
- add $msg['confirm'] (confirmation message when attemping to delete an
  item, displayed by list.php)

*.lang:
- add various confirm_delete_* texts needed by *Handler
- rename confirm_domain to confirm_delete_domain


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1749 a1433add-5e2c-0410-b055-b7f2511e0802
9 years ago
Christian Boltz 7bf5b74a47 MailboxHandler, AliasHandler:
- initStruct: set "display in list" to 1 to allow searching for domain
  with list.php (nevertheless, the domain won't be displayed because
  it doesn't have a column label set)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1735 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 13f1a28b6e PFAHandler:
- read_from_db(), getList(): 
  - add $searchmode parameter (_before_ $limit and $offset!) to be able to 
    use query different query modes, not only "="
  - add a warning that $condition will be changed to array only in the future
- getList(): filter $condition for fields that are available to the user
  to avoid information leaks by using search parameters
  (filter is only applied if $condition is an array!)

functions.inc.php: 
- db_where_clause():
  - add $additional_raw_where parameter for additional query parameters
  - add $searchmode parameter to be able to use query different
    query modes, not only "=" (see $allowed_operators)
  - check for allowed operators in $searchmode
  - split query into WHERE and HAVING (if a parameter has
    $struct[select] set, HAVING is used)

list-virtual.php:
- adopt getList() call to the new syntax

AliasHandler:
- adopt getList() definition and call to the new syntax

 


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1731 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 6ec360b0b7 AliasHandler:
- finally fix alias deletion when using MariaDB. The workaround is
  to add another field from the subquery to the outer SELECT so that
  MariaDB can't optimize the subquery to "always 1"
  http://sourceforge.net/p/postfixadmin/bugs/325/
  (I'll open a MariaDB bugreport and add the link to the bugtracker)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1703 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 46a632ec02 AliasHandler:
- initStruct(): revert the MariaDB workaround because PostfixAdmin now
  "thinks" none of the aliases belong to a mailbox (and displays all of
  them in the alias list, even the mailbox aliases)
  - reverts r1699 + the CHANGELOG entry (part of r1700)
  - reopened https://sourceforge.net/p/postfixadmin/bugs/325/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1702 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz d9ff7ece05 AliasHandler:
- initStruct(): use "SELECT COUNT(1)" instead of "SELECT 1" as workaround
  for a MariaDB problem (bug?)
  https://sourceforge.net/p/postfixadmin/bugs/325/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1700 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz c5de88390e 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



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1684 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 8e5a4551cb AliasHandler:
- fix query in getList(), which caused an empty list on some systems
  https://sourceforge.net/p/postfixadmin/bugs/313/
  Fix by VERSATECH SRL, versatechsrl @SF


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1678 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 566f2845bd AliasHandler:
- setmore(): use old goto values if no new value is given. Fixes
  'Making alias inactive cleans "goto" field'
  https://sourceforge.net/p/postfixadmin/bugs/316/


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1675 a1433add-5e2c-0410-b055-b7f2511e0802
10 years ago
Christian Boltz 801acc6cf2 AliasHandler:
- only allow @domain as target if $this->id is a catchall
- delete commented out version of delete()
- better error messages

languages/*.lang
- add new texts needed for AliasHandler


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1587 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz b3dc3f91ae AliasHandler:
- if parent::init() fails, return false early to avoid warnings about
  undefined $this->result


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1574 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 3b09562fb8 MailboxHandler.php:
- rewrite and simplify delete()
- also cleanup fetchmail, quota	and quota2 tables

AliasHandler.php:
- update delete() to match the workflow in other classes



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1562 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 1b74926afb PFAHandler, *Handler:
- rename _field_$field() to _validate_$field() to make the function name
  more obvious
 


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1555 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 4d9a338eb2 After hunting an "undefined index transport" error in list-domain, I
found out that the 'Config' class is too static - it shares its static
data with the 'Lang' child class. 

This caused a conflict because we have $CONF[transport] and 
$PALANG[transport], and Config::read('transport') returned the $PALANG 
text.

To fix this, all texts are now stored as $CONF[__LANG].
I also dropped the 'Lang' class.


model/Config.php:
- mark the 'Config' class as final to ensure we don't trap into the 
  "too static" problem again.
- bool(): display and log an error message if a $CONF option does not
  contain YES or NO (that would have uncovered this bug much earlier)
- add lang() and lang_f() wrapper functions to get $PALANG texts
- remove unused $__cache and $__objects

model/Lang.php:
- deleted

common.php:
- store $PALANG as $CONF[__LANG]

lots of files:
- replace Lang::read() and Lang::read_f() calls with Config::lang()
  and Config::lang_f()




git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1536 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz bb7a3ff04d model/*Handler.php and various other files
- rename $this->return to $this->result


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1534 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz ade5fd0c24 AliasHandler:
- initStruct(): set default for 'goto' to empty array()
  This fixes a problem with the cli when --goto was not specified				


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1530 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 08c9b4e49f *.lang:
- renamed some $PALANG texts:
  - pOverview_button => go
  - pOverview_mailbox_name => name
  - pSendmail_admin => from
  - pAdminEdit_admin_username => admin
  - pEdit_alias_goto => to 
- deleted obsolete or duplicate $PALANG texts:
  - pOverview_alias_goto
  - pCreate_alias_goto
  - pEdit_alias_button
  - pEdit_mailbox_name
  - pEdit_mailbox_button
  - pViewlog_username
  - pViewlog_button
  - pAdminList_admin_username
  - pAdminList_virtual_button
  - pAdminList_virtual_alias_address
  - pAdminList_virtual_alias_goto
  - pAdminList_virtual_mailbox_name
  - pAdminEdit_domain_button
  - pAdminEdit_admin_button
  - pBroadcast_from
  - pBroadcast_send

model/*, setup.php, templates/*, users/edit-alias.php:
- update to use the renamed $PALANG texts


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1513 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 76f66ac8db *.lang:
- rename some $PALANG variables once more because smarty breaks when
  using "-"
  - add-alias => add_alias
  - add-alias-domain => add_alias_domain
  - add-mailbox => add_mailbox
  - email-address-already-exists => email_address_already_exists
  - change-password => change_password
  - password-again => password_again

model/*, setup.php, templates/*
- update to use the changed $PALANG variables


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1511 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 9c0004a431 *.lang:
- rename various $PALANG texts:
  - pMenu_create_alias => add-alias
  - pMenu_create_alias_domain => add-alias-domain
  - pMenu_create_mailbox => add-mailbox
  - pOverview_get_mailboxes => mailboxes
  - pPassword_button => change-password
  - pAdminList_domain_description => description
  - pAdminList_domain_aliases => aliases
  - pAdminEdit_domain_transport => transport
  - pAdminEdit_admin_password2 => password-again
- remove duplicate or unused $PALANG texts:
  - pOverview_alias_alias_count
  - pOverview_alias_mailbox_count
  - pOverview_get_aliases
  - pCreate_alias_domain_button
  - pCreate_alias_welcome
  - pCreate_alias_button
  - pCreate_mailbox_password2
  - pCreate_mailbox_quota_text_error
  - pCreate_mailbox_button
  - pAdminMenu_viewlog
  - pAdminMenu_create_alias
  - pAdminMenu_create_mailbox
  - pAdminList_domain_mailboxes
  - pAdminList_domain_transport
  - pAdminList_virtual_welcome
  - pAdminList_virtual_alias_alias_count
  - pAdminList_virtual_alias_mailbox_count
  - pAdminList_virtual_mailbox_username
  - pAdminList_virtual_mailbox_quota
  - pAdminEdit_domain_description
  - pAdminEdit_domain_aliases
  - pAdminEdit_domain_mailboxes
  - pAdminEdit_domain_mailboxes_text
  - pUsersMenu_password

model/*, seetup.php, templates/*
- use changed $PALANG texts


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1510 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 7bf10e6b91 *.lang:
- rename $PALANG['pEdit_alias_address'] to $PALANG['alias']
  - remove duplicate $PALANG['pOverview_alias_edit']

model/*, templates/*:
- use $PALANG['alias'] everywhere


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1507 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz c70465f0e3 *.lang:
- rename $PALANG['pCreate_alias_address_text_error2'] to 
  $PALANG['email-address-already-exists']
- delete $PALANG['pCreate_mailbox_username_text_error2']

model/*:
- use new $PALANG names


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1506 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz a1646f84b6 *.lang:
- add $PALANG['active'] = 'Active' to replace various duplicates:
  -$PALANG['pOverview_alias_active']
  -$PALANG['pOverview_alias_domain_active']
  -$PALANG['pOverview_mailbox_active']
  -$PALANG['pCreate_alias_active']
  -$PALANG['pEdit_alias_active']
  -$PALANG['pCreate_mailbox_active']
  -$PALANG['pAdminList_admin_active']
  -$PALANG['pAdminList_domain_active']
  -$PALANG['pAdminList_virtual_mailbox_active']
  -$PALANG['pAdminEdit_domain_active']
  -$PALANG['pAdminEdit_admin_active']

model/*, templates/*:
- use $PALANG['active'] everywhere


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1503 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz fcee414740 *.lang and various other files:
- rename $PALANG['pAdminList_domain_modified'] to $PALANG['last_modified']


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1500 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 9af5a5cc03 *Handler.php:
- set $db_table and $id_field in the class, not inside initStruct()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1483 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 68ae542817 AliasHandler:
- use Config::bool() instead of boolconf()


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1472 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 2d127bdec8 AliasHandler:
- validate_new_id(): store errormessages in 
  $this->errormsg[$this->id_field] instead of $this->errormsg[]


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1459 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 871bcbbe2f functions.inc.php:
- check_domain(), check_email(): instead of calling flash_error(),
  return string with error message - or empty string if everything is ok

model/AdminHandler.php, model/AliasHandler.php,
model/DomainHandler.php, model/MailboxHandler.php,
sendmail.php, users/edit-alias.php:
- adopt to changed check_domain() and check_email() return value


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1451 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz f92a32eae1 PFAHandler.php:
- 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
11 years ago
Christian Boltz 227eca6faf PFAHandler.php:
- introduce public array $infomsg[] (for success messages)
- store(): write successmessage to $this->infomsg[]

edit.php:
- display $handler->infomsg instead of hardcoded success message

AdminHandler.php, AliasHandler.php, AliasdomainHandler.php,
DomainHandler.php, MailboxHandler.php:
- move successmsg from webformConfig() to initMsg()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1428 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz 5388bcf4cd AliasHandler.php:
- add MailboxAliasConfig() and $called_by_MailboxHandler for special
  handling if called by MailboxHandler
- create_allowed(): always allow creating an alias for a mailbox
- remove _missing_on_vacation() and _missing_active() which returned the
  default from $this->struct. This is now done by default, see previous
  change in PFAHandler



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1424 a1433add-5e2c-0410-b055-b7f2511e0802
11 years ago
Christian Boltz a46bcc955c edit.php:
- prefill all $formconf['prefill'] fields from URL parameters (typically
  used for the domain)

model/AliasdomainHandler.php:
- allow to prefill alias_domain and target_domain from URL parameters
 
model/AliasHandler.php:
- allow to prefill domain from URL parameters
- some whitespace changes
- add storemore() with a TODO note

model/MailboxHandler.php:
- allow to prefill domain from URL parameters
- some whitespace changes
- add some TODO notes



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1422 a1433add-5e2c-0410-b055-b7f2511e0802
12 years ago
Christian Boltz ca8c27ae93 AliasHandler.php:
- initStruct(): add 'editable' virtual field
- add various comments

AdminHandler.php:
- add some comments


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1382 a1433add-5e2c-0410-b055-b7f2511e0802
12 years ago
Christian Boltz db8c2df6bc PFAHandler:
- 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
12 years ago