Re: [Postfixadmin-devel] custom field in domainview from other table?
Brought to you by:
christian_boltz,
gingerdog
|
From: Christian B. <pos...@cb...> - 2019-11-24 21:07:17
|
Hello,
Am Mittwoch, 13. November 2019, 13:10:21 schrieb Przemysław Orzechowski:
> I'm trying to create a custom field visible in domain pane that gets
> its value from different table
>
> I created custom domain hook and it works if thew field is in domains
> table but how do i get the field from custom table ?
>
> The table has a field name which i can
>
> This is the struct for a field in domains table
>
> $struct['x_password_expiry'] = pacol(0, 1, 1,
> 'int','x_expire','x_password_expiry',"",[],0,1);
>
> how can i get the qerry to go to custom table?
>
> whith name substituted for domain in the query?
You'll need some additional parameters for pacol() ;-)
See for example how DomainHandler gets the number of existing aliases
for a domain:
'alias_count' => pacol(0, 0, 1, 'vnum', '' , '' , '', array(),
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*select*/ 'coalesce(__alias_count,0) - coalesce(__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'),
Your case is easier:
- "select" will ideally just be your field name (coalesce to prevent
NULL never hurts)
- for "extrafrom", you'll need to have a "join", but probably without
all the magic that does the counting in the example above
BTW: the "vnum" field type is meant for a "virtual" number coming from
joins etc. - probably exactly what you need ;-)
(the comment for initStruct() in PFAHandler has a list of field types)
pacol() supports some more parameters, see the function definition in
functions.inc.php for details.
BTW: looking at your query and field names, I wonder if you noticed
that we support a password expiry date in the latest version.
Regards,
Christian Boltz
--
Kinners, die guten alten Zeiten sind schon sehr, sehr lange vorbei.
Kohl wurde durch Merkel ersetzt und zwischendrin gab es den light-Kohl
von den Sozen inklusive grünem Beiwagen. ;) [Lars Müller in opensuse-de]
|