Some starting help with developing a plugin

Discussion in 'Developers' Forum' started by rst, Apr 7, 2015.

  1. rst

    rst New Member HowtoForge Supporter

    Hi all,

    I would like to develop a plugin for ISPConfig, where you can provide per mail domain what the outgoing IP address / host name that Postfix uses for sending mails should be (much like is described over here http://wied.it/blog/sender-dependent-default-transport-maps-with-postfix-the-easy-way.html) . I am new to developing for ISPConfig, though I do have quite some experience with PHP.

    I already found http://docs.ispconfig.org/development/interface/ , however this focuses mainly on adding an entirely new module. I would like to do the following things:
    - add a new subitem within the mail module where configurations can be made. I figure I can work this out from the how to set up a module in ISPConfig link I mentioned above.
    - have an extra dropdown in the add/edit domain function where the right configuration can be chosen
    - after the domain has been added/updated, automatically call a script which rebuilds the transport maps

    Any pointers you can give me about how to go about developing this, would be much welcome. I am looking for ways to make this easy plugable, so without me having to overwrite existing ISPConfig files (otherwise all changes will be gone after the next update). Also I'm wondering how I can hook into the existing add/save domain functionality so that my file is generated and postfix is restarted.

    Kind regards,
    Robin
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You will have to edit the interface/web/mail/lib/module.conf file for that.

    Therefor you will have to edit the interface/web/mail/form/mail_domain.tform.php file and the corresponding html form file.

    This is done by a new server side plugin that you attach to the mail insert, update and delete events so that it gets fired when the mail domain is edited. Take a look at the server side mail* plugins in server/plugins-available/ folder for an example and activate it with a symlink in plugins-enabled folder.
     
  3. rst

    rst New Member HowtoForge Supporter

    Hi Till,

    I created the first part, but something went wrong. I think ISPConfig tried to create the new table that I defined in the .tform.php, but this failed (since I don't see the table in the database). But it seems like ISPConfig is now convinced that it actually does exist. How do I let ISPConfig recreate the table?

    Kind regards,
    Robin
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Delete the html template file. It might be that you have to gibe the ispconfig mysql user additional permissions to create tables.
     
  5. rst

    rst New Member HowtoForge Supporter

    Hi Till,
    I gave the ispconfig additional permissions. Now the table is created (although with some fields that I currently have no need for).
    However now when adding a new item, I fill in all records and it is not saved to the database. How can I debug this?
    Kind regards,
    Robin
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    The interafce does not has the same advanced debugging features of the server part yet. the problem is most likely sql related, so you could e.g. add a echo statement in the tform_actions class inside the onInsert function right after the line:

    $sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'INSERT', $this->id, $ext_where);

    that outputs the content of the $sql variable and then check if that sql is correct.
     

Share This Page