Author Topic: How to get variables from $this  (Read 5720 times)

Offline nlreeftank

  • Jr. Member
  • **
  • Posts: 14
How to get variables from $this
« 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

Offline nlreeftank

  • Jr. Member
  • **
  • Posts: 14
Re: How to get variables from $this
« Reply #1 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

Code: [Select]
<?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;
  }
}


?>
« Last Edit: November 16, 2012, 08:05:13 AM by nlreeftank »

Offline nlreeftank

  • Jr. Member
  • **
  • Posts: 14
Re: How to get variables from $this
« Reply #2 on: November 16, 2012, 08:40:25 AM »
I took the bad way arround

Code: [Select]
$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

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,857
Re: How to get variables from $this
« Reply #3 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']
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline nlreeftank

  • Jr. Member
  • **
  • Posts: 14
Re: How to get variables from $this
« Reply #4 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

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,857
Re: How to get variables from $this
« Reply #5 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.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…