Wednesday, March 24, 2010

vBulletin users list in AdminCP Options

I intended to write about this for a while but I haven't had time. This is pretty cool stuff. When ever you want to have a users list for your plugin? Let's say you want to give some members a special permission to use the plugin. What's the best way to do that? Well, adding a field into `users` table is not really good. Setting up a new bitfield permission is interesting but if some other coder use the same bitfield value, disaster! Hmm, the most secure thing will be a separate table to store authorized userid, really good but slow and costly (and stupid somehow), nobody implements a new table just to store those userids! Many coders will use vBulletin Core Options system, create a free type input box, ask the Administrator to input userids, seperated by comma, etc... That's a good approach I think since it's quick and easy, most Administrators have enough knowledge to get the correct userids. But well, if we can make it better, why not? That's why I came up with this idea: use vBulletin Options system to store and load that piece of data but I will display usernames along with userids. That's really useful but then I think why don't I improve it even more? Store user basic information in an array, serialize it to store in database, unserialize when needed. Administrator can now input usernames to add to the list and remove a user from the list if they want. Piece of cake!

Ok. That's enough of talking. I'm going to the main points now.

First you will need to have the option

Use the hook location named "admin_options_print". This will print out our interface

Ok. Now is the part where we parse thing and store information

Huray! See if it work or not

You may want to grab the plugin here. It does nothing except this beautiful users list. Have a nice day.

No comments:

Post a Comment