Author Topic: Help : display "your message has been sent page" instead of inbox after sending email  (Read 7305 times)

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Hi,

First of all thanks for this awesome app.

I need some help to show "your message has been sent page" after user sends email instead of redirecting flow to inbox.
I am going through the code base for few days now but couldn't figure out way to do it.

Is it doable ?
How can we accomplish this?

Thanks in advance.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
The best way would be to code a plugin, I think you could use the message_sent hook http://trac.roundcube.net/wiki/Plugin_Hooks#message_sent and some javascript to redirect to a "message sent" page.

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Quote from: skaero;36631
The best way would be to code a plugin, I think you could use the message_sent hook Plugin_Hooks and some javascript to redirect to a "message sent" page.


Thanks for the reply.

$this->add_hook('message_sent', array($this, 'show_msgsent'));

public function show_msgsent($args)
    {
        $rcmail = rcmail::get_instance();
        $rcmail->output->send("custompages.msgsent");
        return $args;
     }

This doesn't shows msgsent page, I couldn't understand where & how to use Js.
Please help.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
@bhu1st:

I've mailed you a solution. Please post your testing results when done.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Thanks a lot Rosali.
Code you sent worked great.

Plugin Class:

Code: [Select]
class message_sent extends rcube_plugin {
   
    function init() {
       
        $rcmail = rcmail::get_instance();        

        //add a plugin hook "message_sent"
        //Details: [url=http://trac.roundcube.net/wiki/Plugin_Hooks#message_sent]Plugin_Hooks[/url]
        $this->add_hook('message_sent', array($this, 'show_msgsent'));

        //register a custom action - plugin.msgsent
        $this->register_action('plugin.msgsent', array($this, 'redirect'));

        //handlers to processes the placeholder tags in message sent template
        $this->register_handler('plugin.body', array($this, 'get_body'));        
    }

    /**
     * Get content to display
     *
     * @param void
     *
     * @return string content
     */  
    function get_body() {
        return "Your message has been sent!";
    }

    /**
     * Action displays message sent template
     *
     * @param void
     *
     * @return void
     */    
    public function redirect() {
       
        $rcmail = rcmail::get_instance();
        $rcmail->output->set_pagetitle('Message Sent');
        $rcmail->output->send('message_sent.msgsent');

    }

    /**
     * Callback redirects to plugin.msgsent action
     *
     * @param array $args Default hook parameters.
     *
     * @return void
     */
    public function show_msgsent($args) {

        $rcmail = rcmail::get_instance();
        echo '<script type=&quot;text/javascript&quot;> parent.location.href=&quot;./?_task=mail&_action=plugin.msgsent&quot; </script>';
        //abort
        $rcmail->output->send('iframe');


    }
 

}


msgsent.html template:
----------------------

Code: [Select]




<businessservice:object name="pagetitle" />








 


   

 




Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Was it just fast coding or did you miss localization?

I would not use hard coded localizations ('Message Sent' / 'Your message has been sent!') ...
$this->add_texts('localization', [true ... if labels should be passed to GUI || false]); ... $this-gettext(...)
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Thanks  :)

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Hi,

This code works fine in Chrome and Firefox however it is giving me "Permission Denied" error in IE 8

Function.js (/skins/default/function.js Line : 509 Char: 3).
var doc = this.contentDocument ? this.contentDocument : this.contentWindow ? this.contentWindow.document : null;

Message is sent but page freezes at compose action.

How to fix this ?

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Is anyone having similar issue in Js redirection in IE ?
Please help me.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
Works for me with IE9.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline bhu1st

  • Newbie
  • *
  • Posts: 7
Thanks for the reply,

I am having problem in IE8 - roundcube just freezes.
Could you suggest what's wrong in the above code in IE8 please ?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
It works for me on IE8 as well.

Do you have a test account for me (myroundcube at mail4us dot net)?
Regards,
Rosali
__________________
MyRoundcube Project (commercial)