NOTE: I speak spanish and it's too hard to me write in english... sorry!
I need to write a plugin. This plugin must parse a mail subject and puts a link or a button to open another website. this link/button should be inserted in the mailbox list and in the preview header.
I'm reading a lot of pages and a lot of code, but I can't write something that works... Any suggestion?
Thanks in advence!
--
Luis
Take a look at the message_headers_output hook http://trac.roundcube.net/wiki/Plugin_Hooks#Taskmail and read the plugin documentation http://trac.roundcube.net/wiki/Doc_Plugins
I really appreciate your help.
I wrote a tiny pluggin and it's working now! But I have a little problem:
When I add a new header, it's not displayed if the 'larry' skin is in use, but if you're using the 'clasic' skin the header is displayed :o
Any idea? :D
What your code?
This is my plugin... I'm a php beginner too ;D
<?php
class myFirstPlugin extends rcube_plugin
{
public $task = 'mail';
function init()
{
$rcmail = rcmail::get_instance();
if (!$rcmail->action || in_array($rcmail->action, array('list', 'show', 'preview')))
$this->add_hook( 'message_headers_output' , array($this, 'addHeaders') );
}
function addHeaders( $p )
{
$rcmail = rcmail::get_instance();
$link = "";
$LEcode = $this->parseCode( (string)$p['output']['subject']['value'] );
if ( isset ( $LEcode['opEcod'] ) && isset( $LEcode['opType'] ) && isset ( $LEcode['opID'] ) && isset($LEcode['opCK']) )
{
$start = fmod(floatval($LEcode['opEcod'] . $LEcode['opType'] . $LEcode['opID']), 23);
if ( $validator = substr( 'GMYXTRWABHLCNJZSQVFPDKE' , $start , 1 ) )
{
if ( $validator == $LEcode['opCK'] )
{
$link = $this->createLink( 'http://google.com/' , 'Open op.: ' . $LEcode['opID'] , 'Click to visit op. ' . $LEcode['opID'] );
// Here I add the new header that is showed if clasic skin is in use
$p['output']['MyPlugin'] = array('title' => 'Open Op.', 'value' => $link, 'html' => true) ;
}
}
}
return $p;
}
function parseCode ( $code )
{
$code = strtoupper( $code );
$regex = '|.*OPERATION\.(?P<opEcod>[0-9]+)\.(?P<opType>[0-9]+)\.(?P<opID>[0-9]+)\.(?P<opCK>[A-Z]).*|i';
preg_match( $regex , $code , $LEarray );
if ( !isset( $LEarray ) )
$LEarray = null;
return ( $LEarray );
}
function createLink ( $href, $text, $title )
{
$a = html::a( array( 'href' => $href , 'target' => '_blank' , 'title' => $title ) , $text );
return($a);
}
}
Many thanks! :D
HI! ;D
I solved the problem writing a plugin to add a new button in the toolbar. It solves the skin problem...
Please, close this topic :)