Skip to content

Commit

Permalink
Create new_mailbox_hook function (#864)
Browse files Browse the repository at this point in the history
* Add new postcreate mailbox hook ( mailbox_postcreation_hook ) - which can be called after a mailbox is created (similar to mailbox_postcreation_script). 

Thanks @gianlucagiacometti !
  • Loading branch information
gianlucagiacometti authored Nov 9, 2024
1 parent 989b0a2 commit bfebea5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,20 @@ function x_struct_admin_modify($struct) {
$CONF['dkim_struct_hook'] = '';
$CONF['dkim_signing_struct_hook'] = '';

/*
mailbox_postcreation_hook example function
Function called right after mailbox is created if $CONF['mailbox_postcreation_hook'] == '<name_of_the_function>', in the form:
function x_mailbox_postcreation_action($id, $values) {
}
$CONF['mailbox_postcreation_hook '] = 'x_mailbox_postcreation_action';
where:
$id is the username
$values contains the values of the mailbox record created
*/
$CONF['mailbox_postcreation_hook '] = '';

// Default Domain Values
// Specify your default values below. Quota in MB.
Expand Down
5 changes: 5 additions & 0 deletions model/MailboxHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ protected function postSave(): bool
if (!$this->create_mailbox_subfolders()) {
$this->infomsg[] = Config::lang_f('pCreate_mailbox_result_succes_nosubfolders', $this->id);
}

$mailbox_postcreation_hook = Config::read('mailbox_postcreation_hook ');
if (!empty($mailbox_postcreation_hook ) && is_string($mailbox_postcreation_hook ) && function_exists($mailbox_postcreation_hook )) {
$mailbox_postcreation_hook($this->id, $this->values);
}
} else { # edit mode
# alias active status is updated in before_store()

Expand Down

0 comments on commit bfebea5

Please sign in to comment.