SF.net SVN: postfixadmin:[1244] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-10-25 21:29:01
|
Revision: 1244 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1244&view=rev Author: christian_boltz Date: 2011-10-25 21:28:55 +0000 (Tue, 25 Oct 2011) Log Message: ----------- 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 :-) Modified Paths: -------------- trunk/functions.inc.php trunk/model/DomainHandler.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2011-10-25 19:08:33 UTC (rev 1243) +++ trunk/functions.inc.php 2011-10-25 21:28:55 UTC (rev 1244) @@ -405,7 +405,7 @@ * @param int $not_in_db * @return array for $struct */ -function pacol($allow_editing, $display_in_form, $display_in_list, $type, $PALANG_label, $PALANG_desc, $default = "", $options = array(), $not_in_db=0, $select="", $extrafrom="") { +function pacol($allow_editing, $display_in_form, $display_in_list, $type, $PALANG_label, $PALANG_desc, $default = "", $options = array(), $not_in_db=0, $dont_write_to_db=0, $select="", $extrafrom="") { if ($PALANG_label != '') $PALANG_label = Lang::Read($PALANG_label); if ($PALANG_desc != '') $PALANG_desc = Lang::Read($PALANG_desc ); @@ -419,6 +419,7 @@ 'default' => $default, 'options' => $options, 'not_in_db' => $not_in_db, + 'dont_write_to_db' => $dont_write_to_db, 'select' => $select, # replaces the field name after SELECT 'extrafrom' => $extrafrom, # added after FROM xy - useful for JOINs etc. ); Modified: trunk/model/DomainHandler.php =================================================================== --- trunk/model/DomainHandler.php 2011-10-25 19:08:33 UTC (rev 1243) +++ trunk/model/DomainHandler.php 2011-10-25 21:28:55 UTC (rev 1244) @@ -95,22 +95,28 @@ # NOTE: (Disabling all of them shouldn't be a problem.) $this->struct=array( - # field name allow display in... type $PALANG label $PALANG description default / options / not in database + # field name allow display in... type $PALANG label $PALANG description default / options / ... # editing? form list 'domain' => pacol( $this->new, 1, 1, 'text', 'pAdminEdit_domain_domain' , '' ), 'description' => pacol( 1, 1, 1, 'text', 'pAdminEdit_domain_description', '' ), 'aliases' => pacol( 1, 1, 1, 'num' , 'pAdminEdit_domain_aliases' , 'pAdminEdit_domain_aliases_text' , Config::read('aliases') ), - 'alias_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', 0, + 'alias_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', + /*not_in_db*/ 0, + /*dont_write_to_db*/ 1, /*select*/ 'coalesce(__alias_count - __mailbox_count,0) as alias_count', /*extrafrom*/ 'left join ( select count(*) as __alias_count, domain as __alias_domain from ' . table_by_key('alias') . ' group by domain) as __alias on domain = __alias_domain'), 'mailboxes' => pacol( 1, 1, 1, 'num' , 'pAdminEdit_domain_mailboxes' , 'pAdminEdit_domain_mailboxes_text' , Config::read('mailboxes') ), - 'mailbox_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', 0, + 'mailbox_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', + /*not_in_db*/ 0, + /*dont_write_to_db*/ 1, /*select*/ 'coalesce(__mailbox_count,0) as mailbox_count', /*extrafrom*/ 'left join ( select count(*) as __mailbox_count, sum(quota) as __total_quota, domain as __mailbox_domain from ' . table_by_key('mailbox') . ' group by domain) as __mailbox on domain = __mailbox_domain'), 'maxquota' => pacol( $quota, $quota, $quota, 'num' , 'pAdminEdit_domain_maxquota' , 'pAdminEdit_domain_maxquota_text' , Config::read('maxquota') ), - 'total_quota' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', 0, + 'total_quota' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '', + /*not_in_db*/ 0, + /*dont_write_to_db*/ 1, /*select*/ 'round(coalesce(__total_quota/' . intval(Config::read('quota_multiplier')) . ',0)) as total_quota' /*extrafrom*//* already in mailbox_count */ ), 'quota' => pacol( $dom_q, $dom_q, $dom_q, 'num' , 'pAdminEdit_domain_quota' , 'pAdminEdit_domain_maxquota_text' , Config::read('domain_quota_default') ), 'transport' => pacol( $transp, $transp,$transp,'enum', 'pAdminEdit_domain_transport' , 'pAdminEdit_domain_transport_text' , Config::read('transport_default') , @@ -221,6 +227,7 @@ # TODO: passwords -> pacrypt() } if ($this->struct[$key]['not_in_db'] == 1) unset ($db_values[$key]); # remove 'not in db' columns + if ($this->struct[$key]['dont_write_to_db'] == 1) unset ($db_values[$key]); # remove 'dont_write_to_db' columns } if ($this->new) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |