Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom fileds 'ts' type, update event #72

Closed
lexxai opened this issue Sep 4, 2017 · 2 comments
Closed

Custom fileds 'ts' type, update event #72

lexxai opened this issue Sep 4, 2017 · 2 comments

Comments

@lexxai
Copy link

lexxai commented Sep 4, 2017

I try extend custom fields by extend struct hook.
Database filed 'x_expire' is NULL by default value and have type: datatime;

function x_ext_mailbox($struct) {
 $struct['x_expire'] =  pacol(1, 1, 1, 'ts','x_expire','x_expiredate',0);
}
$CONF['mailbox_struct_hook']        = 'x_ext_mailbox';

pf1

How I can control update event, for replace entered empty or 0 value, to NULL record to database ?
For now if db filed have NULL value, used edit form show '0' in , and if i try update user data, have error of update database;

pf2

For search solution I added default value:
$struct['x_expire']['default'] = '2999-12-31';
But it fill at all users data 2999-12-31, instead of NULL.

pf4

And need write custom script that external connect to database and replace value 2999-12-31 to NULL
$CONF['mailbox_postedit_script'] = 'some_shell_script.sh';

How I can update result w/o use external postedit_script?

May be I can have some methods how redefine beforestore() in config.local.php ?

    public function store() {
        if ($this->values_valid == false) {
            $this->errormsg[] = "one or more values are invalid!";
            return false;
        }

        if ( !$this->beforestore() ) {
            return false;
@DavidGoodwin
Copy link
Member

Perhaps https://github.com/postfixadmin/postfixadmin/blob/master/model/PFAHandler.php#L550 needs some special behaviour for 'ts' columns.

@DavidGoodwin
Copy link
Member

your code here -

function x_ext_mailbox($struct) {
 $struct['x_expire'] =  pacol(1, 1, 1, 'ts','x_expire','x_expiredate',0);
}

should probably be passing $struct in as a reference - so perhaps becomes :

function x_ext_mailbox(&$struct) {
 $struct['x_expire'] =  pacol(1, 1, 1, 'ts','x_expire','x_expiredate',0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants