Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
(63) |
Nov
(79) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(15) |
Feb
(8) |
Mar
(8) |
Apr
(44) |
May
(18) |
Jun
(20) |
Jul
(35) |
Aug
(21) |
Sep
(8) |
Oct
(9) |
Nov
(21) |
Dec
(14) |
2009 |
Jan
(53) |
Feb
(13) |
Mar
(36) |
Apr
(40) |
May
(22) |
Jun
(10) |
Jul
(18) |
Aug
(18) |
Sep
(7) |
Oct
(26) |
Nov
(32) |
Dec
(13) |
2010 |
Jan
(6) |
Feb
(7) |
Mar
(12) |
Apr
(2) |
May
(12) |
Jun
(8) |
Jul
(9) |
Aug
(12) |
Sep
(12) |
Oct
(7) |
Nov
(9) |
Dec
(42) |
2011 |
Jan
(10) |
Feb
(35) |
Mar
(43) |
Apr
(39) |
May
(8) |
Jun
(8) |
Jul
(83) |
Aug
(20) |
Sep
(20) |
Oct
(63) |
Nov
(33) |
Dec
(20) |
2012 |
Jan
(28) |
Feb
(3) |
Mar
(1) |
Apr
(37) |
May
(16) |
Jun
(7) |
Jul
(3) |
Aug
|
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(4) |
2013 |
Jan
(6) |
Feb
(16) |
Mar
(9) |
Apr
(11) |
May
(9) |
Jun
(30) |
Jul
(17) |
Aug
(6) |
Sep
(2) |
Oct
(30) |
Nov
(41) |
Dec
(26) |
2014 |
Jan
(16) |
Feb
(20) |
Mar
(5) |
Apr
(4) |
May
(14) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(8) |
Oct
(18) |
Nov
(26) |
Dec
|
2015 |
Jan
(4) |
Feb
(9) |
Mar
(12) |
Apr
(26) |
May
(3) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
(15) |
Oct
(13) |
Nov
|
Dec
(1) |
2016 |
Jan
(1) |
Feb
(5) |
Mar
(4) |
Apr
(3) |
May
(19) |
Jun
|
Jul
|
Aug
(3) |
Sep
(16) |
Oct
(4) |
Nov
(5) |
Dec
(5) |
2017 |
Jan
(1) |
Feb
(8) |
Mar
|
Apr
(7) |
May
(3) |
Jun
(16) |
Jul
(13) |
Aug
(16) |
Sep
(6) |
Oct
(4) |
Nov
(10) |
Dec
(7) |
2018 |
Jan
(16) |
Feb
(17) |
Mar
(11) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
|
3
|
4
(3) |
5
|
6
|
7
|
8
|
9
(1) |
10
|
11
|
12
(1) |
13
|
14
|
15
|
16
(1) |
17
|
18
|
19
(5) |
20
|
21
|
22
(2) |
23
|
24
|
25
(2) |
26
(1) |
27
|
28
|
|
|
From: <christian_boltz@us...> - 2013-02-04 23:18:04
|
Revision: 1425 http://sourceforge.net/p/postfixadmin/code/1425 Author: christian_boltz Date: 2013-02-04 23:18:01 +0000 (Mon, 04 Feb 2013) Log Message: ----------- MailboxHandler.php: add (nearly) everything for creating a mailbox (TODO: generating random passwords - when this is done, MailboxHandler can replace create-mailbox.php) - initStruct(): - make 'username' a 'mail' field (doesn't really change anything at the moment) - make 'maildir' editable on $new - init(): minor cleanup - validate_new_id(): error out early if check_email() fails - beforestore(): - convert quota from MB to bytes - previously in setmore() - on $new, create mailbox alias - storemore(): run mailbox_postcreation(), send_welcome_mail() and create_mailbox_subfolders() on $new - add send_welcome_mail() - _field_quota(): return true on success (otherwise it's interpreted as invalid value) - add _missing_local_part(), _missing_domain() and _missing_maildir() to fill those fields on $new - remove add() because all the code moved to the functions mentioned above. Known regression: this breaks CLI create mailbox for now Modified Paths: -------------- trunk/model/MailboxHandler.php Modified: trunk/model/MailboxHandler.php =================================================================== --- trunk/model/MailboxHandler.php 2013-02-04 22:33:45 UTC (rev 1424) +++ trunk/model/MailboxHandler.php 2013-02-04 23:18:01 UTC (rev 1425) @@ -16,13 +16,13 @@ $this->struct=array( # field name allow display in... type $PALANG label $PALANG description default / options / ... # editing? form list - 'username' => pacol( $this->new, 1, 1, 'text', 'pEdit_mailbox_username' , '' , '' ), + 'username' => pacol( $this->new, 1, 1, 'mail', 'pEdit_mailbox_username' , '' , '' ), 'local_part' => pacol( $this->new, 0, 0, 'text', 'pEdit_mailbox_username' , '' , '' ), 'domain' => pacol( $this->new, 0, 0, 'enum', '' , '' , '', /*options*/ $this->allowed_domains ), # TODO: maildir: display in list is needed to include maildir in SQL result (for post_edit hook) # TODO: (not a perfect solution, but works for now - maybe we need a separate "include in SELECT query" field?) - 'maildir' => pacol( 0, 0, 1, 'text', '' , '' , '' ), + 'maildir' => pacol( $this->new, 0, 1, 'text', '' , '' , '' ), 'password' => pacol( 1, 1, 0, 'pass', 'pCreate_mailbox_password' , 'pCreate_mailbox_password_text' , '' ), 'password2' => pacol( 1, 1, 0, 'pass', 'pCreate_mailbox_password2' , '' , '', /*options*/ '', @@ -46,10 +46,8 @@ public function init($id) { $retval = parent::init($id); - @list($local_part,$domain) = explode ('@', $id); # supress error message if $id doesn't contain '@' - if ($this->new) { - # TODO + # handled in validate_new_id() } else { # show max allowed quota in quota field description list(/*NULL*/,$domain) = explode('@', $this->id); @@ -102,8 +100,12 @@ return false; } - list($local_part,$domain) = explode ('@', $this->id); + if ( !check_email($this->id) ) { # TODO: check_email should return error message instead of using flash_error itsself + return false; + } + list(/*NULL*/,$domain) = explode ('@', $this->id); + if(!$this->create_allowed($domain)) { $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error3'); return false; @@ -116,7 +118,7 @@ return false; } - return check_email($this->id); # TODO: check_email should return error message instead of using flash_error itsself + return true; # still here? good! } /** @@ -156,22 +158,72 @@ } - protected function setmore($values) { - $this->values['quota'] = multiply_quota($values['quota']); # convert quota from MB to bytes + protected function beforestore() { + + if ( isset($this->values['quota']) && $this->values['quota'] != -1 ) { + $this->values['quota'] = $this->values['quota'] * Config::read('quota_multiplier'); # convert quota from MB to bytes + } + + if ($this->new) { + $ah = new AliasHandler(1, $this->admin_username); + + $ah->MailboxAliasConfig(); + + if ( !$ah->init($this->id) ) { + $this->errormsg[] = $ah->errormsg[0]; + return false; + } + + $alias_data = array( + # 'goto_mailbox' = 1; # would be technically correct, but setting 'goto' is easier + 'goto' => array($this->id), + 'active' => $this->values['active'], + ); + + if (!$ah->set($alias_data)) { + $this->errormsg[] = $ah->errormsg[0]; + return false; + } + + if (!$ah->store()) { + $this->errormsg[] = $ah->errormsg[0]; + return false; + } + } + + return true; # still here? good! } - + protected function storemore() { if ($this->new) { -# TODO: create alias -# TODO: postcreate hook -# TODO: send welcome mail -# TODO: create mailbox subfolders -# TODO: --- most of this is probably already in $this->add() already --- - } else { -# TODO: update alias (active status) + list(/*NULL*/,$domain) = explode('@', $this->id); + + if ( !mailbox_postcreation($this->id,$domain,$this->values['maildir'], $this->values['quota']) ) { + $this->errormsg[] = Lang::read('pCreate_mailbox_result_error') . " ($this->id)"; + # return false; # TODO: should this be fatal? + } + + if ($this->values['welcome_mail'] == true) { + if ( !$this->send_welcome_mail() ) { + # return false; # TODO: should this be fatal? + } + } + + if ( !create_mailbox_subfolders($this->id,$this->values['password'])) { + # TODO: implement $tShowpass + flash_info(Lang::read('pCreate_mailbox_result_succes_nosubfolders') . " ($fUsername$tShowpass)"); # TODO: don't use flash_info + } else { # everything ok + # TODO: implement $tShowpass + # flash_info(Lang::read('pCreate_mailbox_result_success']) . " ($fUsername$tShowpass)*"); # TODO: don't use flash_info + # TODO: currently edit.php displays the default success message from webformConfig + } + + } else { # edit mode + # TODO: update alias (active status) + # postedit hook -# TODO: implement a poststore() function? - would make handling of old and new values much easier... + # TODO: implement a poststore() function? - would make handling of old and new values much easier... list(/*NULL*/,$domain) = explode('@', $this->id); $old_mh = new MailboxHandler(); @@ -217,6 +269,7 @@ $this->errormsg[$field] = Lang::Read('pEdit_mailbox_quota_text_error'); return false; } + return true; } /** @@ -228,7 +281,69 @@ } +# TODO: generate password if $new, no password specified and $CONF['generate_password'] is set + /** + * on $this->new, set localpart based on address + */ + protected function _missing_local_part ($field) { + list($local_part,$domain) = explode ('@', $this->id); + if (count($parts) == 2) $this->RAWvalues['localpart'] = $local_part; + } + + /** + * on $this->new, set domain based on address + */ + protected function _missing_domain ($field) { + list($local_part,$domain) = explode ('@', $this->id); + if (count($parts) == 2) $this->RAWvalues['domain'] = $domain; + } + + + /** + * calculate maildir path for the mailbox + */ + protected function _missing_maildir($field) { + list($local_part,$domain) = explode('@', $this->id); + + #TODO: 2nd clause should be the first for self explaining code. + #TODO: When calling config::Read with parameter we sould be right that read return false if the parameter isn't in our config file. + + if(Config::read('maildir_name_hook') != 'NO' && function_exists(Config::read('maildir_name_hook')) ) { + $hook_func = $CONF['maildir_name_hook']; + $maildir = $hook_func ($domain, $this->id); + } elseif (Config::read('domain_path') == "YES") { + if (Config::read('domain_in_mailbox') == "YES") { + $maildir = $domain . "/" . $this->id . "/"; + } else { + $maildir = $domain . "/" . $local_part . "/"; + } + } else { + # If $CONF['domain_path'] is set to NO, $CONF['domain_in_mailbox] is forced to YES. + # Otherwise user@... and user@... would be mixed up in the same maildir "user/". + $maildir = $this->id . "/"; + } + $this->RAWvalues['maildir'] = $maildir; + } + + private function send_welcome_mail() { + $fTo = $this->id; + $fFrom = smtp_get_admin_email(); + if(empty($fFrom) || $fFrom == 'CLI') $fFrom = $this->id; + $fSubject = Lang::read('pSendmail_subject_text'); + $fBody = Config::read('welcome_text'); + + if (!smtp_mail ($fTo, $fFrom, $fSubject, $fBody)) { + $this->errormsg[] = Lang::read('pSendmail_result_error'); + return false; + } else { +# TODO flash_info($PALANG['pSendmail_result_success']); + } + + return true; + } + + /******************************************************************************************************************** old functions - we'll see what happens to them (at least they should use the *Handler functions instead of doing SQL) @@ -294,14 +409,8 @@ } return false; } -/** - * Add mailbox - * @param password string password of account - * @param gen boolean - * @param name string - * - */ - public function add($password, $name = '', $quota = -999, $active = true, $mail = true ) { + +# remaining comments from add(): # FIXME: default value of $quota (-999) is intentionally invalid. Add fallback to default quota. # Solution: Invent an sub config class with additional informations about domain based configs like default qouta. # FIXME: Should the parameters be optional at all? @@ -309,28 +418,9 @@ # TODO: most code should live in a separate function that can be used by add and edit. # TODO: On the longer term, the web interface should also use this class. -# TODO: copy/move all checks and validations from create-mailbox.php here - $username = $this->id; - list($local_part,$domain) = explode ('@', $username); - - #TODO: more self explaining language strings! - if(!check_mailbox ($domain)) { - $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error3'); - return false; - } - # check if an alias with this name already exists - $result = db_query ("SELECT * FROM " . table_by_key('alias') . " WHERE address='" . escape_string($username) . "'"); - if ($result['rows'] == 1) { - $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error2'); - return false; - } - - $plain = $password; - $password = pacrypt ($password); - # TODO: if we want to have the encryption method in the encrypted password string, it should be done in pacrypt(). No special handling here! # if ( preg_match("/^dovecot:/", Config::read('encrypt')) ) { # $split_method = preg_split ('/:/', Config::read('encrypt')); @@ -338,83 +428,6 @@ # $password = '{' . $method . '}' . $password; # } -#TODO: 2nd clause should be the first for self explaining code. -#TODO: When calling config::Read with parameter we sould be right that read return false if the parameter isn't in our config file. - if(Config::read('maildir_name_hook') != 'NO' && function_exists(Config::read('maildir_name_hook')) ) { - $hook_func = $CONF['maildir_name_hook']; - $maildir = $hook_func ($fDomain, $fUsername); - } elseif (Config::read('domain_path') == "YES") { - if (Config::read('domain_in_mailbox') == "YES") { - $maildir = $domain . "/" . $username . "/"; - } else { - $maildir = $domain . "/" . $local_part . "/"; - } - } else { - # If $CONF['domain_path'] is set to NO, $CONF['domain_in_mailbox] is forced to YES. - # Otherwise user@... and user@... would be mixed up in the same maildir "user/". - $maildir = $username . "/"; - } - - db_begin(); - - $active = db_get_boolean($active); - $quota = multiply_quota ($quota); - - $alias_data = array( - 'address' => $username, - 'goto' => $username, - 'domain' => $domain, - 'active' => $active, - ); - - $result = db_insert('alias', $alias_data); -#MARK: db_insert returns true/false?? - if ($result != 1) { - $this->errormsg[] = Lang::read('pAlias_result_error') . "\n($username -> $username)\n"; - return false; - } - - $mailbox_data = array( - 'username' => $username, - 'password' => $password, - 'name' => $name, - 'maildir' => $maildir, - 'local_part' => $local_part, - 'quota' => $quota, - 'domain' => $domain, - 'active' => $active, - ); - $result = db_insert('mailbox', $mailbox_data); -#MARK: Same here! - if ($result != 1 || !mailbox_postcreation($username,$domain,$maildir, $quota)) { - $this->errormsg[] = Lang::read('pCreate_mailbox_result_error') . "\n($username)\n"; - db_rollback(); - return false; - } else { - db_commit(); - db_log ($domain, 'create_mailbox', $username); - - - if ($mail == true) { - # TODO: move "send the mail" to a function - $fTo = $username; - $fFrom = smtp_get_admin_email(); - if(empty($fFrom) || $fFrom == 'CLI') $fFrom = $this->id; - $fSubject = Lang::read('pSendmail_subject_text'); - $fBody = Config::read('welcome_text'); - - if (!smtp_mail ($fTo, $fFrom, $fSubject, $fBody)) { - $this->errormsg[] = Lang::read('pSendmail_result_error'); - return false; - } - } - - create_mailbox_subfolders($username,$plain); - } - return true; - } - - public function delete() { $username = $this->id; list(/*$local_part*/,$domain) = explode ('@', $username); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <christian_boltz@us...> - 2013-02-04 22:33:48
|
Revision: 1424 http://sourceforge.net/p/postfixadmin/code/1424 Author: christian_boltz Date: 2013-02-04 22:33:45 +0000 (Mon, 04 Feb 2013) Log Message: ----------- 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 Modified Paths: -------------- trunk/model/AliasHandler.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2013-02-04 21:38:59 UTC (rev 1423) +++ trunk/model/AliasHandler.php 2013-02-04 22:33:45 UTC (rev 1424) @@ -9,6 +9,8 @@ class AliasHandler extends PFAHandler { protected $domain_field = 'domain'; + + protected $called_by_MailboxHandler = false; /** * @@ -101,6 +103,12 @@ ); } + /** + * set a special flag if called by MailboxHandler + */ + public function MailboxAliasConfig() { + $this->called_by_MailboxHandler = true; + } /** * AliasHandler needs some special handling in init() and therefore overloads the function. @@ -168,6 +176,8 @@ * check number of existing aliases for this domain - is one more allowed? */ private function create_allowed($domain) { + if ($this->called_by_MailboxHandler) return true; # always allow creating an alias for a mailbox + $limit = get_domain_properties ($domain); if ($limit['aliases'] == 0) return true; # unlimited @@ -311,9 +321,6 @@ } } - protected function _missing_on_vacation($field) { return $this->set_default_value($field); } - protected function _missing_active ($field) { return $this->set_default_value($field); } - /** * on $this->new, set localpart based on address */ @@ -325,7 +332,7 @@ } /** - * on $this->new, set localpart based on address + * on $this->new, set domain based on address */ protected function _missing_domain ($field) { if (isset($this->RAWvalues['address'])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <christian_boltz@us...> - 2013-02-04 21:39:05
|
Revision: 1423 http://sourceforge.net/p/postfixadmin/code/1423 Author: christian_boltz Date: 2013-02-04 21:38:59 +0000 (Mon, 04 Feb 2013) Log Message: ----------- PFAHandler.php: - set(): if a field is not set and there's no _missing_$field() method for it, take default value from $this->struct (side effect: this automagically fixes CLI create domain) - store(): add a beforestore() hook that is called at the beginning of store() - add empty beforestore() (will be overwritten by MailboxHandler) - some comment updates Modified Paths: -------------- trunk/model/PFAHandler.php Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2013-01-27 19:52:19 UTC (rev 1422) +++ trunk/model/PFAHandler.php 2013-02-04 21:38:59 UTC (rev 1423) @@ -201,11 +201,19 @@ if ($this->new) { foreach($this->struct as $key=>$row) { if ($row['editable'] && !isset($values[$key]) ) { - # if a field is editable and not set, call $this->_missing_$fieldname() - # (if the method exists - otherwise the field won't be set, resulting in an error later) + /** + * when creating a new item: + * if a field is editable and not set, + * - if $this->_missing_$fieldname() exists, call it + * (it can set $this->RAWvalues[$fieldname] - or do nothing if it can't set a useful value) + * - otherwise use the default value from $this->struct + * (if you don't want this, create an empty _missing_$fieldname() function) + */ $func="_missing_".$key; if (method_exists($this, $func) ) { - $this->{$func}($key); # function can set $this->RAWvalues[$key] (or do nothing if it can't set a useful value) + $this->{$func}($key); # call _missing_$fieldname() + } else { + $this->set_default_value($key); # take default value from $this->struct } } } @@ -225,6 +233,7 @@ } else { # field is editable if (isset($values[$key])) { if ($row['type'] != "pass" || strlen($values[$key]) > 0 || $this->new == 1) { # skip on empty (aka unchanged) password on edit +# TODO: do not skip "password2" if "password" is filled, but "password2" is empty $valid = true; # trust input unless validator objects # validate based on field type ($this->_inp_$type) @@ -287,6 +296,10 @@ return false; } + if ( !$this->beforestore() ) { + return false; + } + $db_values = $this->values; foreach(array_keys($db_values) as $key) { @@ -321,6 +334,14 @@ } /** + * called by $this->store() before storing the values in the database + * @return bool - if false, store() will abort + */ + protected function beforestore() { + return true; # do nothing, successfully ;-) + } + + /** * called by $this->store() after storing $this->values in the database * can be used to update additional tables, call scripts etc. */ @@ -505,7 +526,6 @@ /** * set field to default value - * typically called from _missing_$fieldname() * @param string $field - fieldname */ protected function set_default_value($field) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |