Firefox PHP

Control Center hook cc_panel and OKMSG

Posted by Phil Connolly 
Control Center hook cc_panel and OKMSG
February 10, 2010 09:49PM
I am trying to use the cc_panel hook. I don't want to completely override a CC panel, I am just introducing some additional processing. So my module would prefer to keep $hook_info["handled"] = false so that control.php will continue processing the panel as normal.

But, as part of the processing I might set $hook_info["okmsg"] to a custom message. Which gets over-written by the core processing for the panel. It seems the only way I can get my own okmsg onto the panel is to completely over-ride the panel processing, but I don't really want to do that because then the panel's core processing won't perform its tasks.

So... I did find a workaround. Although it works, it seems like there should be a better way than to trick the core like this. If I could suggest a change it would be that control.php would honor the module's status messages regardless of whether or not the handled flag is set within the cc_panel hook.

Language: PHP
function phorum_mod_foo_cc_panel($data) { global $PHORUM;   // Working on the Signature panel if ($data["panel"] == PHORUM_CC_SIGNATURE) { // We are intercepting the form post if ( conditions_are_met() ) { // My custom actions are handled list($error,$okmsg) = mod_foo_custom_actions();   // Mad Hack so that we can force Phorum to process the panel, yet keep // our own UI status messages. $panel = PHORUM_CC_SIGNATURE; // sig.php expects this variable to be in scope $data["handled"] = true; $data["template"] = "cc_usersettings"; include "./include/controlcenter/sig.php";   $data["okmsg"] = $okmsg; $data["error"] = $error; } } return $data; }

-phil.



Edited 2 time(s). Last edit at 02/10/2010 09:59PM by Phil Connolly.
Re: Control Center hook cc_panel and OKMSG
February 10, 2010 10:00PM
the panels can't just always use your status messages as they have to determine the status on their own.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Control Center hook cc_panel and OKMSG
February 10, 2010 10:19PM
So as you say, "always" may not be appropriate. But maybe the hook could allow the module developer to choose when the module's message gets displayed rather than the core stock message. There is currently an assumption that the only time a mod developer would want his own CC panel messages is when completely over-riding a panel's processing. This leads to the ugly hack I posted above. So maybe I *can* hack around the design, but then that is not my preferred architectural choice.

-phil.
Re: Control Center hook cc_panel and OKMSG
February 16, 2010 05:04PM
As I was working in this area today I implemented an option for that.
[trac.phorum.org] should get you going.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Control Center hook cc_panel and OKMSG
February 16, 2010 06:45PM
nice. Simple and clean solution. Thanks!

-phil.
Sorry, only registered users may post in this forum.

Click here to login