PDA

View Full Version : Miscellaneous Hacks - vbPluginOrder


hambil
30 Mar 2006, 00:15
Keywords: plugin, order, hook

Description:
A simple but potentially very useful tool that allows you to set the order of execution for plugins within the same hook.

Features:

Fully Phrased.
Set the order of plugin execution within the same hook.Install
Download the vbPluginOrder_1.2.zip file.
Unzip and upload the files in the upload directory to your forum root.
Import the product file in your admincp.
Set the order for your plugins if needed and desired.Notes:
If you have Hellcat's real time page compressor installed it must be set as the first plugin in its hook after you activate plugin order.

Version 1.2

Fixed bug causing plugin order not to run on some systems because of cookie settingsVersion 1.1

Fixed nasty sql bug where I forgot to use TABLE_PREFIX for one join. Causes a problem if you have a table prefix (obviously) :)

Paul M
30 Mar 2006, 00:23
Interesting, I will be taking a look at this later. :)

Zia
30 Mar 2006, 05:14
:) helo

plugin order...? does that mean this hack will set the order(no 1,2,3.....) as per my desire?

Ummm whats the benifit of using this hack ?

thnx

hambil
30 Mar 2006, 06:07
:) helo

plugin order...? does that mean this hack will set the order(no 1,2,3.....) as per my desire?

Ummm whats the benifit of using this hack ?

thnx
You can make one plugin run before another in the same hook. You probably won't need it until you really need it - then you'll be glad I wrote it :)

Paul M
30 Mar 2006, 08:50
:)Ummm whats the benifit of using this hack ?
See ;

http://www.vbulletin.org/forum/showthread.php?p=933843#post933843

or

http://www.vbulletin.org/forum/showthread.php?p=935312#post935312

for recent examples.

Snake
30 Mar 2006, 13:55
Good work. This could be useful since I'm having way too many plugins! :)

jazde86
03 Apr 2006, 23:50
Help me, please!

Invalid SQL:

SELECT p.*, po.`order` FROM trillian_pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order;

MySQL-Fehler : Table 'trillian_forum.trillian_pluginorder' doesn't exist

Oh no, my forum is down. What can I do? Its urgent! Thanks for your help.

hambil
03 Apr 2006, 23:54
First, disable the product so your forum isn't down.

hambil
03 Apr 2006, 23:58
Invalid SQL:

SELECT p.*, po.`order` FROM trillian_pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order;

MySQL-Fehler : Table 'trillian_forum.trillian_pluginorder' doesn't exist

It sounds like the table didn't get created for some reason when you installed. Can you look at the database and verify if the table 'pluginorder' exists?

jazde86
04 Apr 2006, 00:08
Cool, thanks for your reply.

In my database trillian_forum exists the table trillian_pluginorder

I've disabled the product and the plugin, but nothing has changed. :(

hambil
04 Apr 2006, 00:11
You've disabled the product and you're still getting an error? Have you tried uninstalling it?

jazde86
04 Apr 2006, 00:16
New Error:

Invalid SQL:

SELECT p.*, po.`order` FROM trillian_pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order;

MySQL-Fehler : Table 'trillian_forum.plugin' doesn't exist

I don't come into the AdminCP to uninstall it, only the database is my my tool to work. The table plugin doesn't exist, thats correct because the correct name of the table is trillian_plugin at database trillian_forum.

Your Product creates the table TABLE_PREFIX . "pluginorder and the problem the problem is with the path. Can it helps disabeling all products and plugins or adapt the path in your product/plugin?

hambil
04 Apr 2006, 00:37
Ah yes. That's a nasty bug. I'll fix and upload right away. Thanks.

jazde86
04 Apr 2006, 00:40
Thank you, thank you, thank you. :) I hope that then everything is well. ;)

hambil
04 Apr 2006, 00:42
Thank you, thank you, thank you. :) I hope that then everything is well. ;)
You're welcome. Updated and ready for download again. Let me know if it solves the problem please :)

jazde86
04 Apr 2006, 00:56
Hmm...

Invalid SQL:

SELECT p.*, po.`order` FROM trillian_pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order;

MySQL-Fehler : Table 'trillian_forum.plugin' doesn't exist

hambil
04 Apr 2006, 00:59
Hmm...
Make sure you click 'allow overwrite', or better yet uninstall before you install the new one.

jazde86
04 Apr 2006, 01:08
How can I install it with MySQL? Uninstallation is done by cleaning.

hambil
04 Apr 2006, 01:10
How can I install it with MySQL? Uninstallation is done by cleaning.

You don't have admincp access?

jazde86
04 Apr 2006, 01:12
No :(, thats my problem. Look at forum.trillian-deutsch.de :confused:

Your help is wonderful. :cool:

why there still is the error, although I deleted your plugin?

hambil
04 Apr 2006, 01:15
If you remove the plugin from the plugin table, and you remove the plugin cache from the datastore table, you should have access to your admin cp again. That is, if my plugin is the problem anyway.

jazde86
04 Apr 2006, 01:26
Oh yeah, very nice. Cool, I love you. ;) Great tip and now I'm really happy. :D

hambil
04 Apr 2006, 01:27
Oh yeah, very nice. Cool, I love you. ;) Great tip and now I'm really happy. :D
Glad it worked. Now did the re-install work, or are you afraid to try now? LOL

jazde86
04 Apr 2006, 01:40
Navbar in AdminCP is damaged. Warnung: array_keys(): The first argument should be an array in /includes/adminfunctions_navpanel.php (Zeile 147)

Warnung: implode(): Bad arguments. in /includes/adminfunctions_navpanel.php (Zeile 147)

Warnung: Invalid argument supplied for foreach() in /includes/adminfunctions_navpanel.php (Zeile 150)

And Shoutbox on index lost.

hambil
04 Apr 2006, 02:52
Goto your plugin manager in the admincp, don't change anything, but just click on 'save active status'. That should rebuild the plugin datastore.

jazde86
04 Apr 2006, 09:59
I've in my AdminCP no navbar and don't know the directlink to do it. In ModCP the navigation is ok. Argh, I've done, the navibar is there - but there is only the profilefields in postbit. :(

To many things deletet yesterday in the datastore-Database?!? :(

hambil
04 Apr 2006, 14:32
I've in my AdminCP no navbar and don't know the directlink to do it. In ModCP the navigation is ok. Argh, I've done, the navibar is there - but there is only the profilefields in postbit. :(

To many things deletet yesterday in the datastore-Database?!? :(
Maybe. The url is yourdomain/admincp/plugin.php?do=modify

jazde86
04 Apr 2006, 14:38
So is it, thx. Menu is very empty now... :-\

hambil
04 Apr 2006, 14:45
So is it, thx. Menu is very empty now... :-\
What menu?

jazde86
04 Apr 2006, 14:49
My Menu (Navigationsbar) in AdminCP, there is now only the field for profilefields in postbits.

hambil
04 Apr 2006, 14:52
What exactly did you delete from the datastore?

jazde86
04 Apr 2006, 15:03
In datastore


products - last line
pluginlist - many lines on the end
pluginlistadmin - many lines on the end


In plugins


2x vbPluginOrder


Delete Table pluginorder

hambil
04 Apr 2006, 15:10
Okay. First, before doing anything else, backup your database. Then, try setting pluginlist and pluginlistadmin to blank, instead of editing them, and then go to the plugin page in admincp and click "update active" like before.

jazde86
04 Apr 2006, 15:23
I cleaned the two things, but nothing has changed yet.

My last backup is from 2006-03-29 22-28... I've asked my webhoster for backup - waiting, waiting, waiting. The rest of my forum is ok.

hambil
04 Apr 2006, 17:14
One little bug, so much trouble... sorry mate.

jazde86
04 Apr 2006, 17:20
Do you have any idea to activate the full menu? Original files to admincp changed nothing.

One bug, everything broken . :( :( :(

hambil
04 Apr 2006, 18:34
Well, it's not the files then, it's the database. Did you get the database restored?

jazde86
04 Apr 2006, 19:05
Yeah, all is ok now! :banana:

I've started a new test forum, installed the products in the same order and copied the data from pluginlist and pluginlistadmin to my database. The cache is the bad thing, I think. Well done and thanks for your great work here.

I'll install your product soon as possible. I'm not so afraid. ;) :D

hambil
04 Apr 2006, 19:06
Okay. Let me think. I have a couple of ideas still.

luroca
07 Apr 2006, 17:14
This can be a very useful hack. I click install for future use :)
Is it working ok now?

Thanks

hambil
07 Apr 2006, 18:54
This can be a very useful hack. I click install for future use :)
Is it working ok now?

Thanks
It seems to be :)

jazde86
11 Apr 2006, 11:39
Sorry, but the plugin makes a lot of trouble. When there are "0" in a field, then other plugins doesn't work anymore, example for that ist the "Who has visited today"-Plugin. The same with "The threadprefix"-Plugin.

I deactivated it.

hambil
11 Apr 2006, 13:52
Sorry, but the plugin makes a lot of trouble. When there are "0" in a field, then other plugins doesn't work anymore, example for that ist the "Who has visited today"-Plugin. The same with "The threadprefix"-Plugin.

I deactivated it.
Hmmmm. Could you be more specific? I tried installing two plugins in the same hook and setting the order of one to "0" and it worked fine.

jazde86
11 Apr 2006, 14:34
Plugin "Members who have visited the forum":

cache_templates -> Members who have visited (1) -> Order "0" The Plugin doesn't shown on forumhome, switch to "1" and ahh, there is it. ;)

forumhome_start -> Members who have visited (2)


Other Plugins in cache_templates:

Post Thank You Hack
Top 'X' Stats by InfiniteWebby
vB Pager 3.0.4
VBGooglemap by StonyArc

robert_2004
20 Apr 2006, 15:41
i can't get the 'plugin order' showing up in my adminCP's left menu pane.

hambil
20 Apr 2006, 16:27
i can't get the 'plugin order' showing up in my adminCP's left menu pane.
Hmmm. You've uploaded all the files? There is an xml file for the cpnav that has to be uploaded.

robert_2004
20 Apr 2006, 18:09
there are no files to upload on this thread mate. only the xml product.

hambil
20 Apr 2006, 18:29
there are no files to upload on this thread mate. only the xml product.
Well, that's a problem. Now I'm wondering what the other people who install this are doing...

Give me a few minutes and I'll fix that and replace with a zip.

Logician
14 May 2006, 10:45
Edit : Hambil fixed the problem below in his pluggin. Thanks!


This hack causes serious problems if your board has table prefixes. If it is installed in a board where tables are prefixed, the board start producing DB errors and it won't even allow you to access admin cp and disable product. So if you dont know what you are doing, you'll get stuck in a very bad position.

Problem & Fix:

This query in the pluggin is problematic:

SELECT p.*, po.`order` FROM " . TABLE_PREFIX . "pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order

It should be:
SELECT p.*, po.`order` FROM " . TABLE_PREFIX . "pluginorder AS po
LEFT JOIN " . TABLE_PREFIX . "plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order

If you installed the hack and stuck with an DB error and you can't even access admin cp here is the fix for you:

Edit includes/init.php, find:
if ($vbulletin->options['enablehooks'] OR defined('FORCE_HOOKS'))

Before that add:
$vbulletin->options['enablehooks'] = FALSE;

Upload init.php.

This will cure DB error and now you can login to admin cp. Go to products and uninstall the product. Now delete the line you edit to init.php, reupload init.php and you are done.

@hambil : Sorry to post this into your thread and I appreciate your sharing your work with other vb members but I feel obligated to post this so that people won't get into trouble. It maybe a good idea to apply the fix I provided to your pluggin. Sorry again!

Boofo
14 May 2006, 10:55
An easier way is to add a disable hooks line to the config.php. That way you could comment it out and use it again if you had to. ;)

define('DISABLE_HOOKS', true);

Marco van Herwaarden
14 May 2006, 11:00
Thanks for providing this solution for members with problems.

Although your solution works, the proper way to disable all plugins from outside the ACP, is to add the following line to yhe includes/config.php:
define('DISABLE_HOOKS', true);

Boofo
14 May 2006, 11:07
That's what I just posted above, sir. ;)

akanevsky
14 May 2006, 13:37
Although I could see how this hack could be useful, I'd like to point out two things:
1. It would encourage a bunch of already-lazy coders to NOT care about making their hack in a way that would guarantee absense of conflicts with other hacks.
2. Instead of creating a new table and having to implement a whole new block of code, you should've added a displayorder column to the plugin table and used that.

hambil
14 May 2006, 14:34
Warning:
This hack causes serious problems if your board has table prefixes. If it is installed in a board where tables are prefixed, the board start producing DB errors and it won't even allow you to access admin cp and disable product. So if you dont know what you are doing, you'll get stuck in a very bad position.

Problem & Fix:

This query in the pluggin is problematic:

SELECT p.*, po.`order` FROM " . TABLE_PREFIX . "pluginorder AS po
JOIN plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order
It should be:
SELECT p.*, po.`order` FROM " . TABLE_PREFIX . "pluginorder AS po
LEFT JOIN " . TABLE_PREFIX . "plugin AS p ON(p.pluginid = po.pluginid)
ORDER BY p.hookname, po.order
If you installed the hack and stuck with an DB error and you can't even access admin cp here is the fix for you:

Edit includes/init.php, find:
if ($vbulletin->options['enablehooks'] OR defined('FORCE_HOOKS'))
Before that add:
$vbulletin->options['enablehooks'] = FALSE;
Upload init.php.

This will cure DB error and now you can login to admin cp. Go to products and uninstall the product. Now delete the line you edit to init.php, reupload init.php and you are done.

@hambil : Sorry to post this into your thread and I appreciate your sharing your work with other vb members but I feel obligated to post this so that people won't get into trouble. It maybe a good idea to apply the fix I provided to your pluggin. Sorry again!
This was one of my first hacks. I thought I'd fixed the table prefix issue in this - not sure how it crept back in. Anyway, thanks for pointing out. Perhaps a PM next time? :)

Edit: In fact I know I did - it's in the description of version 1.1. Somehow version 1.0 got reuploaded.

hambil
14 May 2006, 14:37
Although I could see how this hack could be useful, I'd like to point out two things:
1. It would encourage a bunch of already-lazy coders to NOT care about making their hack in a way that would guarantee absense of conflicts with other hacks.

That's silly. You can't possible predict what conflicts your hack might have with other hacks. And this isn't just for conflicts. What if you simply want to re-order things on forum home, for example?


2. Instead of creating a new table and having to implement a whole new block of code, you should've added a displayorder column to the plugin table and used that.
That's your opinion. I prefer not to modify vb core tables if I can help it. The new table is indexed and performance is not an issue.

akanevsky
14 May 2006, 14:45
You can't possible predict what conflicts your hack might have with other hacks.

True, you cannot predict. But you can avoid altering vBulletin core with your hacks, which is what many coders do, and which is what leads to problems.

What if you simply want to re-order things on forum home, for example?

Last time I checked, to re-order things in the front end, you edit the templates. Templates, in their turn, do not have hooks so they have nothing to do with ordering.

That's your opinion. I prefer not to modify vb core tables if I can help it. The new table is indexed and performance is not an issue.

That's not just my opinion, it's a fact. "JOIN" always requires more from the server than a straightforward "SELECT FROM". However, it was only a suggestion. You're the boss of your hack, so you may or may not follow it, depending on what you want...

hambil
14 May 2006, 14:53
True, you cannot predict. But you can avoid altering vBulletin core with your hacks, which is what many coders do, and which is what leads to problems.
Don't like my hack, don't find it useful, don't install it. Fine with me. I don't know why you feel you have to come in here and say so though. I created this hack because people requested, so obviously not all feel as you do. When did we start going into others hacks and publicly criticizing them?

Last time I checked, to re-order things in the front end, you edit the templates. Templates, in their turn, do not have hooks so they have nothing to do with ordering.
And then when you upgrade you have to re-edit all those templates.

That's not just my opinion, it's a fact. "JOIN" always requires more from the server than a straightforward "SELECT FROM". However, it was only a suggestion. You're the boss of your hack, so you may or may not follow it, depending on what you want...
It is most certainly an opinion, not a 'fact'. The cost of a proper join is nearly non-existant, especially compared to the design and maintainence benifits. It's called a relational database because it's designed for related tables, not flat tables.

hambil
14 May 2006, 14:56
I removed the old 1.0 zip and reuploaded the 1.1. zip. That should take care of the table_prefix problem.

akanevsky
14 May 2006, 14:58
Don't like my hack, don't find it useful, don't install it. Fine with me. I don't know why you feel you have to come in here and say so though. I created this hack because people requested, so obviously not all feel as you do. When did we start going into others hacks and publicly criticizing them?

To ensure that you aren't going to be criticized, don't release hacks.
Just to point out, however, I did say that I find how this hack could be useful.

And then when you upgrade you have to re-edit all those templates.

That, once again, has nothing to do with plugins.

It is most certainly an opinion, not a 'fact'. The cost of a proper join is nearly non-existant, especially compared to the design and maintainence benifits. It's called a relational database because it's designed for related tables, not flat tables.

I am not going to argue about it, I am just going to say that in my opinion, creating an extra field for just one table is a waste.

hambil
14 May 2006, 14:59
I am only giving you suggestions. If you don't like people giving you suggestions, let everyone know publicly to rid yourself of it. Thanks for understanding.
Sorry if I over-reacted. I'm always open to suggestions. :)

I am not going to argue about it, I am just going to say that in my opinion, creating an extra field for just one table is a waste.
So noted :)

Logician
14 May 2006, 18:03
Anyway, thanks for pointing out. Perhaps a PM next time? :)

Sorry I didn't want to offend at all! The reason I posted publicly was to post the fix in case some people got stuck after installation. If you updated the hack and prefer better I can delete my post, it is np.

hambil
14 May 2006, 18:06
Sorry I didn't want to offend at all! The reason I posted publicly was to post the fix in case some people got stuck after installation. If you updated the hack and prefer better I can delete my post, it is np.
Nah. I deserve a little public humilation for 1) leaving out the table prefix in the first place and 2) screwing up and uploading the wrong version of the zipfile. :) That'll learn me!

jazde86
14 May 2006, 23:51
hambil is very nice and at any time friendly. I like him. :cool: Thank you for updating it. :)

MThornback
21 May 2006, 06:54
IE Error:

Fatal error: Call to undefined function: can_administer() in ../forum/index.php(485) : eval()'d code on line 220

Plugin Manager causes this on forumhome for IE, not FF for some reason....thats a switch eh?

hambil
21 May 2006, 07:25
IE Error:

Fatal error: Call to undefined function: can_administer() in ../forum/index.php(485) : eval()'d code on line 220

Plugin Manager causes this on forumhome for IE, not FF for some reason....thats a switch eh?
Can I get access to your forum so I can try to debug this?

MThornback
21 May 2006, 07:26
I have a guaest admin for just such an ocasion....PM your way shortly!

hambil
21 May 2006, 14:52
I have a guaest admin for just such an ocasion....PM your way shortly!
Okay, it seems to be working all okay now. Let me know if you have any more problems.

I fixed a bug that was causing plugin order not to run.

The random numbers you where getting where due to Hellcats page compressor. I moved it to the first plugin in its hook and that seems to have fixed that.

MThornback
25 May 2006, 10:42
I have good news hambil :p remember how I told you no dice? Well all of a sudden today it started working with this hack :cool: I told ya it would all work out in the end :D

hambil
25 May 2006, 17:15
I have good news hambil :p remember how I told you no dice? Well all of a sudden today it started working with this hack :cool: I told ya it would all work out in the end :D
Woot! Thanks for the update :)

nowrap
10 Jul 2006, 14:15
hello!

just installed the 1.2 release of this plugin. it killed me server due to high load.
the reason is quite simple. with this product activated it runs deactive plugins! without the deactivated plugins aren't executed!

did i made something wrong? uploading the 2 files and importing the product.xml

regards
.nowrap

hambil
28 Aug 2006, 03:18
This hack is being retired and no longer supported, as it is included in 3.6.

hambil
13 Apr 2007, 01:48
This hack has had the file removed, as it is not stable and the functionality already exists not in 3.6. Most likely this thread will get deleted for having no files when someone gets around to noticing :) If you really want it PM me.