Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: bhu1st on September 16, 2011, 07:41:51 AM

Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on September 16, 2011, 07:41:51 AM
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.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: SKaero on September 17, 2011, 02:13:29 AM
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.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on September 20, 2011, 04:00:27 AM
Quote from: skaero;36631The best way would be to code a plugin, I think you could use the message_sent hook Plugin_Hooks (http://trac.roundcube.net/wiki/Plugin_Hooks#message_sent) 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.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: rosali on September 21, 2011, 03:34:37 AM
@bhu1st:

I've mailed you a solution. Please post your testing results when done.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on September 21, 2011, 05:19:37 AM
Thanks a lot Rosali.
Code you sent worked great.

Plugin Class:

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:
----------------------





<businessservice:object name="pagetitle" />








 


   

 



Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: rosali on September 21, 2011, 11:23:52 AM
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(...)
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on September 21, 2011, 01:10:29 PM
Thanks  :)
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on September 30, 2011, 01:36:09 AM
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 ?
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on November 03, 2011, 12:57:25 AM
Is anyone having similar issue in Js redirection in IE ?
Please help me.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: rosali on November 03, 2011, 01:15:47 AM
Works for me with IE9.
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: bhu1st on November 04, 2011, 12:45:08 PM
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 ?
Title: Help : display "your message has been sent page" instead of inbox after sending email
Post by: rosali on November 06, 2011, 01:11:53 AM
It works for me on IE8 as well.

Do you have a test account for me (myroundcube at mail4us dot net)?