Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: mgbdk on December 28, 2011, 10:38:51 PM

Title: message_compose hook not fired
Post by: mgbdk on December 28, 2011, 10:38:51 PM
Hi all,
I have spend the day writing a little plugin to change 'special folders' per identity.
I have written most of the plugin now, but I can not seem to get my message_compose hook to fire.
I am running rc 0.6 and here is the snippet of code that is keeping me up all night.


class identity_folders extends rcube_plugin
{
  public $task = 'settings|mail';
  private $rcmail;
  function init() {
    $this->rcmail = rcmail::get_instance();
    $this->load_config();
    //...
    $this->add_hook('message_compose', array($this, 'message_compose'));
  }
//...
  function message_compose ($args) {
    $params = array(
      'param'       => array(),
      'attachments' => array()
    );
    $params['param']['body'] = 'blah';
    return $params;
  }
}


I am successfully running functions under other hooks only message_compose is giving me problems.

The function is never executed

Looking at this file

// program/steps/mail/compose.inc
//...
  if (!is_array($_SESSION['compose']))
    //...
    $plugin = $RCMAIL->plugins->exec_hook('message_compose', $_SESSION['compose']);
   //...
  }
//...

I can not seem to compose a mail in such a manor that $_SESSION['compose'] is not an array.

Can anyone confirm this as a bug or show me the correct way to do this?
Title: message_compose hook not fired
Post by: SKaero on December 28, 2011, 11:46:41 PM
I believe that is a bug it should work with RoundCube 0.7.
Title: message_compose hook not fired
Post by: mgbdk on December 29, 2011, 07:19:02 AM
Thanks. I was relying on my distros package system to inform me of updates.
just did a quick test with 0.7 and it seems to work there - will finish my plugin and release it into the wild for testing soon :)