Roundcube Community Forum

Miscellaneous => Roundcube Discussion => Topic started by: nlreeftank on November 16, 2012, 07:22:02 AM

Title: How to get variables from $this
Post by: nlreeftank on November 16, 2012, 07:22:02 AM
how do i access these vars contained in $this

                                     [message] => rcube_mail_header Object
                                                (
                                                    [id] => 13
                                                    [uid] => 13

I need the to,from  etc
Title: Re: How to get variables from $this
Post by: nlreeftank on November 16, 2012, 08:02:46 AM
im a total noob with objects in objects.
Can anyone help me get the from,to etc

<?php
/**
 * verander_body
 *
 * Sample plugin to replace emoticons in plain text message body with real icons
 *
 * @version 1.0
 * @author Gerd K
 * @url http://www.domain.com
 */
class verander_body extends rcube_plugin
{

 
 public $task 'mail';
 private $inhoud '';

  function init()
  {
$app rcmail::get_instance ();
$this->add_hook('message_compose_body', array($this'replace'));
  }



  function replace($args,$inhoud)
  {

$args['body'] = print_r($args,1)."|".print_r($this,1);
return 
$args;
  }
}


?>
Title: Re: How to get variables from $this
Post by: nlreeftank on November 16, 2012, 08:40:25 AM
I took the bad way arround

$alles=print_r($this,1);
$b1=explode("[to] => ",$alles);
$b1=explode("[cc]",$b1[1]);
$to=$b1[0];



If someone can explain me how to do this the correct way , i would be very thankful
this eats memory
Title: Re: How to get variables from $this
Post by: JohnDoh on November 17, 2012, 10:00:32 AM
if its the headers you want they you are using the wrong hook, check message_compose is the one you want see http://trac.roundcube.net/wiki/Plugin_Hooks#message_compose you can get the values like $args['param']['to']
Title: Re: How to get variables from $this
Post by: nlreeftank on November 17, 2012, 04:21:31 PM
but then i cant change the body tekst in the reply.
or can i save it before to a session
Title: Re: How to get variables from $this
Post by: JohnDoh on November 18, 2012, 03:58:09 AM
one plugin and use manu hooks so you do what ever you need to do to the headers in one function and then the body in the next.