Hi
I've got another small modification request...
When using hooks to modify the behaviour of an existing action, there is currently no way to generate an error message other than the default "An error occurred while saving", which is shown if you set the abort flag. This is a problem for us because we need to perform additional validation, such as ensuring the user owns the domain for which he is trying to create an email address (ie in create_identity).
My suggestion is simply to add an "abort_message" element to the $args array, which can be checked by each of the action scripts. For example, in save_identity.inc we just need to replace each occurrence of this...
else if ($plugin['abort'] || $DB->is_error()) $OUTPUT->show_message('errorsaving', 'error', null, false);
...with this...
} else if ($plugin['abort'] || $DB->is_error()) { if (isset($plugin['abort_message']) && $plugin['abort_message'] != '') { $OUTPUT->command('display_message', $plugin['abort_message'], 'error', false); } else { $OUTPUT->show_message('errorsaving', 'error', null, false); } }
However, this still has the problem that error messages can¹t be made persistent (which I don¹t need, but which should be included for consistency). So, a better method would be to only display the default message if the messages array is empty - but I haven¹t looked into this yet.
If there¹s another way to achieve this, I¹d be very grateful if someone could let me know. I¹d also be grateful if someone could make the change to the javascript functions requested in my previous email below.
Thanks
Marcus
Hi
I'd like to suggest a small alteration to app.js in order to allow persistent messages to be generated when using rcmail::output::command() within a page-generating callback function.
The rcube_webmail::display_message() function already accepts a "hold" parameter, but this doesn't get stored in $pending_message if the page hasn't yet loaded, so it gets lost. My suggestion is simply to add this extra parameter to $pending_message and then pass it back to display_message() within init().
So, on line 4323, I'd like to replace this...
this.pending_message = new Array(msg, type);
...with this...
this.pending_message = new Array(msg, type, hold);
And, on line 385, I'd like to replace this...
this.display_message(this.pending_message[0], this.pending_message[1]);
..with this...
this.display_message(this.pending_message[0], this.pending_message[1], this.pending_message[2]);
As a result of this change, I can now make messages persistent by calling rcmail::output::command() like this:
$this->rcmail->output->command( 'display_message', '[message_text]', '[message_type]', true );
Thanks
Marcus
Marcus Don Senior Manager Research and Development DadaPro
Main Line: +44 (0)845 363 3630 Main Fax: +44 (0)845 363 3631 Tech Support: +44 (0)845 363 3634 Email: mdon@names.co.uk Website: http://www.names.co.uk Address: Acton House, Perdiswell Park, Worcester WR3 7GD
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender immediately. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
List info: http://lists.roundcube.net/dev/
On 25.06.2010 17:58, Marcus Don wrote:
My suggestion is simply to add an "abort_message" element to the $args array, which can be checked by each of the action scripts. For example, in save_identity.inc we just need to replace each occurrence of this...
else if ($plugin['abort'] || $DB->is_error()) $OUTPUT->show_message('errorsaving', 'error', null, false);
...with this...
} else if ($plugin['abort'] || $DB->is_error()) { if (isset($plugin['abort_message']) && $plugin['abort_message'] != '') { $OUTPUT->command('display_message', $plugin['abort_message'], 'error', false); } else { $OUTPUT->show_message('errorsaving', 'error', null, false); } }
Maybe we just shouldn't display error messages when plugin uses abort? Plugin writers could call $OUTPUT->show_message() from the plugin. So
if ($plugin['abort'] || $DB->is_error()) { if (!$plugin['abort']) $OUTPUT->show_message('errorsaving', 'error', null, false); ... }
Ive always wondered how RC would handle a situation where you'd have say 3 plugins in 1 section, and 1 plugin has a save error, but the other 2 dont, and the user modified settings in all 3 plugins.
Cor
List info: http://lists.roundcube.net/dev/
Hi Alec
Thanks for your input. Did you see my later suggestion - ie to only populate pending_message if it's not already defined?
The only potential drawback of your method I can see is that the plugin would always be responsible for generating the error (ie there would be no default), but I think this is reasonable. So, I have no preference - I'd just like someone to update the source code so I don't have to maintain another branch :)
Thanks
Marcus
Maybe we just shouldn't display error messages when plugin uses abort? Plugin writers could call $OUTPUT->show_message() from the plugin. So
if ($plugin['abort'] || $DB->is_error()) { if (!$plugin['abort']) $OUTPUT->show_message('errorsaving', 'error', null, false); ... }
My suggestion is simply to add an "abort_message" element to the $args array, which can be checked by each of the action scripts. For example, in save_identity.inc we just need to replace each occurrence of this...
else if ($plugin['abort'] || $DB->is_error()) $OUTPUT->show_message('errorsaving', 'error', null, false);
...with this...
} else if ($plugin['abort'] || $DB->is_error()) { if (isset($plugin['abort_message']) && $plugin['abort_message'] != '') { $OUTPUT->command('display_message', $plugin['abort_message'], 'error', false); } else { $OUTPUT->show_message('errorsaving', 'error', null, false); } }
List info: http://lists.roundcube.net/dev/