PDA

View Full Version : [developers] Custom datastore support for products


Brad
02-09-2006, 10:00 PM
Custom datastore support for products

Author: Andreas (https://vborg.vbsupport.ru/member.php?u=47102)
Maintained By: Brad

This modification is an attempt to make adding datastore items to plug-ins and products easier on both the end users and modification authors.

The problem we hope to solve

The plug-in system relies on the datastore to function, this means we can not use datastore items unless they are called by vBulletin by default. The only work around for it is hacking the files. Due to this many hack authors have resorted to hacking the files in their own ways to load custom datastore items.

How we have currently 'solved' the problem

There is no way around hacking the files, so this hack does the next best thing. Only one file edit is required, and that is at the very end of ./includes/config.php :)

On the admincp side there is a new page in the plug-in manager. The 'Datastore Item Manager' allows you to map certain datastore items to a product, and restrict what area of the board it will be loaded on (The Forum, Admin cp, Mod cp, or Archive) and what script it will be loaded on (index, showthread, newreply, online etc. etc.). All of this is done to avoid extra overhead that would be caused by fetching data from the datastore that is not required for certain pages.

Once you've mapped your datastore items you can export a product like you normally would, it will include all the info needed to fetch the datastore items for you.

This is a community developed project

As this is something that will hopefully be used by a large number of developers here I encourage you all to assist us in developing this hack. There are a few guidelines to what you can do however:

1) Do not break old product files. - for example if version 1.1 of this hack is released, products made using version 1.0 should still work on the new version. I understand this may be impossible to do if something big needs to be changed down the line, but don't go out of your way to break the thing. :)
2) Try to keep all development discussion in this thread.
3) Do not re-distribute this code without the author's permission outside of this thread (The author is Andreas (https://vborg.vbsupport.ru/member.php?u=47102)). There is however some leeway to this rule, given the nature of this hack.
4) You are allowed and encouraged to include the files/instructions required for the 'end user' install in your own hacks zip file. This will not only make it easier on the end user but it will keep general support questions out of this thread.
5) Try to have fun with it! ;)

Hack alters/adds:

1 SQL Query (global)
1 New Table to the Database
1 File edit to ./includes/config.php

Installation instructions - Developers


Download the zip file: ds4p[dev][1.0.0].zip
Upload productrequirement.php to ./vbroot/admincp/
Upload class_datastore_pluginsupport.php to ./vbroot/includes/
Upload cpnav_ds4p.xml to ./vbroot/includes/xml/
Import the product (product-ds4p.xml) via the admin cp
Edit the file ./vbroot/includes/config.php

Find:

?>

Above that add:

require_once(CWD . '/includes/class_datastore_pluginsupport.php');



Using the hack

In the Admin CP you'll find a new link in the left nav frame, under the Plugin System section click 'Datastore Item Manager'. On this page you'll find a link to add a new datastore item.

You should be familiar with this but here is a quick overview of what is on the add datastore item page:

Product: The product you want to associate the datastore item with.
Script: Allows you to select which php file the item will be included on. For example if your code only needs to run on member.php then you would select 'member' from the drop down.
Site Area: Similar to Script, but only restricts loading to a certain section of the software (forum, admincp, modcp, and archive).
Datastore Item: The name of the datastore item you want to fetch.

Once you have your datastore item set-up, you can get to the item in a plug-in like so:

$vbulletin->datastore->do_fetch('custom_item');

From here it's the normal routine, export the product and you're done. :)

Installation instructions - End Users


Download the zip file: ds4p[dev][1.0.0].zip
Upload class_datastore_pluginsupport.php to ./vbroot/includes/
Import the product (product-ds4p.xml) via the admin cp
Edit the file ./vbroot/includes/config.php

Find:

?>

Above that add:

require_once(CWD . '/includes/class_datastore_pluginsupport.php');



At this point the end user is done, he just imports your product like he normally would.

Big Thanks To:

Andreas (https://vborg.vbsupport.ru/member.php?u=47102) - taking the time to write this php code and allowing me to release it.
MarcoH64 (https://vborg.vbsupport.ru/member.php?u=59998) - for addressing the problem, sparking community interests in the problem and witting POC code.

Blaine0002
02-10-2006, 01:05 AM
Nice! first post!

The Chief
02-10-2006, 02:15 AM
hope this helps all the mods out there :)

Brad
02-10-2006, 02:44 AM
Small update.

If you installed this modification before I made this post be aware that I have released a new version dubbed 1.0.0a.

This was a minor update that fixed a bug when adding new datastore items, instead of redirecting the user to the correct page they would get stuck.

To upgrade, Upload productrequirement.php to ./vbroot/admincp/ and import the new product.xml file.

Barakat
02-10-2006, 11:14 AM
i tried to upload the xml file but its telling me "XML Error: unknown at Line 0 "

Developer
02-10-2006, 11:34 AM
oh nice mod i like it and gonna install it tonight especially for me :D :rolleyes:

amykhar
02-10-2006, 11:58 AM
Thanks for doing this guys. When I get a chance, I'll start playing with it.

Snake
02-10-2006, 01:16 PM
Brad, thank you very much for the hack. ^_^

Brad
02-10-2006, 08:25 PM
i tried to upload the xml file but its telling me "XML Error: unknown at Line 0 "

Are you sure you uploaded the correct .xml? Maybe you tried to import the .xml for the nav panel in the admin cp?

Barakat
02-10-2006, 09:31 PM
its the xml file which i upload . !!! not the ather one in the admin cp .

see the attachments ?

Brad
02-10-2006, 10:59 PM
Hmmm for some reason my localhost is messed up, as a result my admincp was not exporting products correctly.

Attached is a fixed version of the file, I just tested it and it will import without error.

I've updated the zip file.

Barakat
02-11-2006, 02:09 AM
i faced some error while uploading the xml file !! i have duplicated table for productrequirement and after droping it and upload again the xml i faced that error also :-


Warning: mysql_real_escape_string(): 7 is not a valid MySQL-Link resource in /home/jerusalem/public_html/gti/includes/class_core.php on line 666

Warning: mysql_query(): 7 is not a valid MySQL-Link resource in /home/jerusalem/public_html/gti/includes/class_core.php on line 404

Warning: mysql_error(): 7 is not a valid MySQL-Link resource in /home/jerusalem/public_html/gti/includes/class_core.php on line 846

Warning: mysql_errno(): 7 is not a valid MySQL-Link resource in /home/jerusalem/public_html/gti/includes/class_core.php on line 864

Code Monkey
03-05-2006, 04:11 PM
???

Is this the same as Andreas' earlier hack?
By that I mean, I have been using his since he released it prior. So does this version now under your control have any changes from that earlier release?

Allan
03-05-2006, 08:44 PM
Screen or demo please ?

naseermughal
03-09-2006, 07:36 AM
from where i can add new product

link in admin section... plz

naseermughal
03-09-2006, 08:11 AM
i have found the new product link...

but now i didnot find the link mentioned in the following para.

In the Admin CP you'll find a new link in the left nav frame, under the Plugin System section click 'Datastore Item Manager'. On this page you'll find a link to add a new datastore item.

from where i will get this.

Reference image is attached that my admincp have....

Code Monkey
03-12-2006, 02:27 PM
You need to be in debug mode.

Atakan KOC
03-13-2006, 11:06 AM
Screen please ?

Carnage
03-15-2006, 12:14 AM
This should probably be added to vb as a stock feature, would deffinatly make plugins alot more powerful

Paul M
03-15-2006, 12:26 AM
Hmm, first I've seen of this. Looks interesting.

Andreas
03-17-2006, 03:28 AM
???

Is this the same as Andreas' earlier hack?
By that I mean, I have been using his since he released it prior. So does this version now under your control have any changes from that earlier release?
It is, with some minor changes.

thincom2000
01-06-2007, 09:01 PM
Does 3.6.x do this automatically? If not, sounds like something that would be useful :)