Table events

Discussion in 'Developers' Forum' started by Óscar M., Jun 8, 2018.

  1. Óscar M.

    Óscar M. New Member

    Hello there!

    I was trying to make a plugin that listens the events of a new table (created manually). Is that posible?

    I tried to make a module with:
    Code:
    var $actions_available = array( testtable_insert',
                    'testtable_update',
                    'testtable_delete');

    Then i anounce the events in the onLoad method:
    Code:
    $app->plugins->announceEvents($this->module_name, $this->actions_available);
    And register the hook:
    Code:
    $app->modules->registerTableHook('testtable', $this->module_name, 'process');
    
    And then raise the event for the plugins.

    In the plugin:

    onLoad():
    Code:
    $app->plugins->registerEvent('testtable_insert', $this->plugin_name, 'insert');

    I think the new module is not loading.

    And I don't know if the table sys_datalog has something to do with this. I've noticed that when I add registers to the new table via interface plugin it does not log anything.


    Thank you,
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Only data that is in the datalog gets processed by the events. So when you use a form in ISPConfig, ensure that you have set:

    $form["db_history"] = "yes";

    in the form file. In case that you insert, update or delete data in your table manually, then use the datalogInsert, datalogUpdate and datalogDeelete methods to modify the data in your table, do not use SQL queries to do this as a SQL query will not trigger an event and it will not add the changes in sys_datalog.
     
  3. Óscar M.

    Óscar M. New Member

    Perfect,
    Thank you till!
     

Share This Page