Hi, I search to add a feature to my ispconfig. When i add or edit a domain mail, i want to update my barracuda spam firewall. So I edit this two file for add "Barracuda" checkbox mail_domain_tform.php Code: 'barracuda' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', 'value' => array(0 => 'n', 1 => 'y') ), mail_domain_edit.htm Code: <div class="ctrlHolder"> <p class="label">{tmpl_var name='barracuda_txt'}</p> <div class="multiField"> {tmpl_var name='barracuda'} </div> </div> Adding a row "barracuda" in mail_domain table (on mailhost and ispserver) I know how to use barracuda api, it's not a problem. But i don't know how to add my "barracuda function" for execut it when we save the form. I think it's on mail_domain_edit.php but where ? Additionnal informations: Ispconfig multiserver (version 3.0.5.4p3) Debian 7.6 Thanks Gody
Yes, thats one option. Add your code in the onAfterInsert and onAfterUpdate functions. An alternative is to add a interface plugin (see interface/lib/plugins/) and bind it to the events " and "mail:mail_domainn_after_update". Please bote, new plugins get loaded once after login, so if you want to try that approach, logout and then login again to ispconfig to ensure that your plugin is loaded.
Hi Till, Thanks for your response. And sure, the plugin is the best way! I can try this solution. If i undestand i have something like this: PHP: <?php class mail_domain_barracuda_plugin { var $plugin_name = 'mail_domain_barracuda_plugin'; var $class_name = 'mail_domain_barracuda_plugin'; /* This function is called when the plugin is loaded */ function onLoad() { global $app; /* Register for the events */ $app->plugin->registerEvent('mail:mail_domain:on_after_insert', 'mail_domain_barracuda_plugin', 'mail_domain_barracuda_edit'); $app->plugin->registerEvent('mail:mail_domain:on_after_update', 'mail_domain_barracuda_plugin', 'mail_domain_barracuda_edit'); $app->plugin->registerEvent('mail:mail_domain:on_after_delete', 'mail_domain_barracuda_plugin', 'mail_domain_barracuda_del'); } /* function to create and edit domain into barracuda by api */ function mail_domain_barracuda_edit(){ global $app, $conf; // my code to edit the barracuda domain } function mail_domain_barracuda_del(){ global $app, $conf; // my code to delete the barracuda domain } } // end class
Okay, Thanks again, How my function in this class was called by ispconfig when i update/edit or delete? Gody
thats part of the ispconfig form framework. by registering the evnt, ispconfig knows that your plugin wants to be called. just ensure that you logout and login again, as the plugin list is cached and only read once for a user when he logs in.
Till!!! I have another question! My barracuda plugins work fine if i hard code all variable (for test) But now how to pass the form variable to my function? I try with $page_form bit not working ...
you can access your variables directly with $_POST. But ensure to sanitize it correctly. But $page_form->dataRecord[...] should also work, did you try to do a print_r($page_form->dataRecord) to see if its in there?
Hello, Yes i try but nothing. For my test i try to insert value of domain mail form to another databases. But when i see on my database after insert, the filed is empty. PHP: function mail_domain_barracuda_edit($event_name,$page_form){ global $app, $conf; //my code to edit the barracuda domain $domain = $page_form->dataRecord["domain"] ; $resultat= $db_verif->prepare("INSERT INTO database_test SET table_test = :var "); $resultat->bindValue(':var', $domain ); $resultat->execute(); } If y replace $domain = $page_form->dataRecord["domain"] ; by $domain = "test_insert"; It's work fine. Maybe i dont use the good variable?
Hi, THanks. Yes by $_POST i retreive value of form, but i think it's not the best way ... Edit: I found ... adding $event_name on the function declaration... $domain = $page_form->dataRecord["domain"] ; $server_id = $page_form->dataRecord["server_id"] ; Thanks for your time!
Hi Till, My plugin works fine ! He call the barracuda api for create one entree on it! I have another question, It's possible tu use this plugin with isp api? Actually when i call api function mail_domain_add(), He create domain into ISPconfig but not on the barracuda. Thanks Again!
Normally that should work.But it is possible that there is an issue with the api that the plugin is not triggered, I ill have to check that.