Author Topic: Error Message when Implementing a Callback Function using Roundcube Plugin  (Read 3697 times)

Offline Aurora

  • Newbie
  • *
  • Posts: 3
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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Can you post your code?

Offline Aurora

  • Newbie
  • *
  • Posts: 3
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;
  }

         

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
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()":
Code: [Select]
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;
  }