PDA

View Full Version : [How-To] Add Messages to the Admin Message System


derekivey
23 Sep 2006, 19:02
[How-To] Add Messages to the Admin Message System

This how-to explains how you can insert a message to the new admin message system feature that was introduced in vBulletin 3.6.0 Beta 2.

I wanted to add this to a few of my hacks with a message on what to do when installed, so I looked in vB's files to see how they did it. It is actually done with a simple SQL query.


$db->hide_errors();

$db->query_write("INSERT INTO " . TABLE_PREFIX . "adminmessage
(varname, dismissable, script, action, execurl, method, dateline, status)
VALUES
('varname_of_phrase', 1, 'script.php', 'some_action', 'script.php?do=some_action', 'get', " . TIMENOW . ", 'undone')
");

$db->show_errors();



varname - varname of the phrase that is to be shown for the message. It looks like vB is using an error phrase for this.
dismissable - whether or not to allow the user to dismiss the message without addressing it (1 = yes, 0 = no).
script - the script that the user will be redirected to when they address the issue.
action - the "do" action that will be used.
execurl - the url to the file that the user is redirected to (script.php?do=some_action).
method - get or post.
dateline - date message was added, you can add the current date/time with the TIMENOW constant.
status - status of message (undone, done, dismissed), this should be set to undone most of the time.You should be able to add the above code into your product install code, just remember that these messages will only show if the user installing your product has at least 3.6.0 beta 2 running.

Hope this helps some people. I know it will definitely be useful for me!

Derek