I wrote a plugin which hooks into attachment_upload. I get the following error:
PHP Error: Invalid callback function for attachment_upload in rcube_plugin_api.php at line 168.
I checked that add added the hook correctly in my init() function.
I put in some test messages.
Is it possible certain return args need to be specifically set?
Where are the list all values in the args[] array?
Aurora.
Can you post your code?
Posted Code:
1. config-inc.php: $config['plugins'] = array('carryon');
2. carryon.php
class carryon extends rcube_plugin
{
public $container;
public $dbuf;
function init()
{
$this->add_hook('attachment_upload', array($this, 'upload');
}
function upload($args)
{
$temp_dir = rcmail::rcmail::get_instance();
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
$args['id'] = $this->file_id();
$args['path'] = $tmpfname;
$args['status'] = false;
return $args;
}
You need to add "public" before your functions since its in a class, you also are over stacked on your rcmail calls, "rcmail::rcmail::get_instance()" should be "rcmail::get_instance()":
class carryon extends rcube_plugin
{
public $container;
public $dbuf;
public function init()
{
$this->add_hook('attachment_upload', array($this, 'upload');
}
public function upload($args)
{
$temp_dir = rcmail::get_instance();
$tmpfname = tempnam($temp_dir, 'rcmAttmnt');
$args['id'] = $this->file_id();
$args['path'] = $tmpfname;
$args['status'] = false;
return $args;
}