vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Major Additions - Point Market System 3.1x (https://vborg.vbsupport.ru/showthread.php?t=232676)

nishant.soni 05-12-2010 09:41 PM

AWESOME MODE... really great work..

2 questions though:

1.How can i have big smilies by default, because small smilies look a bit smaller then they should be in my theme.
2. Does not display avatar :(

Thanks.

kurios 05-12-2010 10:56 PM

First of all, awesome mod! We use it on a fairly large forum (500k users, nearly 2M posts), and it's given our users something new to play with.

With that said; I've had to modify a few things to make it more usable on bigger boards, and more happy with custom postbit_legacy users.

The first thing we changed was in the following plugin (Point Market: Postbit Adjustments):

PHP Code:

if ($post['market_username_subscript']) {
    
$post[username] = "<s>$post[username]</s>";
}
if (
$post['market_username_color']) {
    
$post[username] = "<span style='color: #$post[market_username_color]'>$post[username]</span>";
}
if (
$post['market_username_glow']) {
    
$post[username] = "<span style='font-weight: bold;text-shadow: 0 0 4px #$post[market_ct_glow]'>$post[username]</span>";
}

if (
$post['market_usertitle_subscript']) {
    
$post[usertitle] = "<s>$post[usertitle]</s>";
}
if (
$post['market_ct_color'] AND $post[customtitle] == 1) {
    
$post[usertitle] = "<span style='color: #$post[market_ct_color]'>$post[usertitle]</span>";
}
if (
$post['market_ct_color'] AND $post[customtitle] != 1) {
    
$new_usertitle "<span style='color: #$post[market_ct_color]'>$post[usertitle]</span>";
}
if (
$post['market_ct_glow'] AND $post[customtitle] == 1) {
    
$post[usertitle] = "<span style='font-weight: bold;text-shadow: 0 0 4px #$post[market_ct_glow]'>$post[usertitle]</span>";
}
if (
$post['market_ct_glow'] AND $post[customtitle] != 1) {
    
$new_usertitle "<span style='font-weight: bold;text-shadow: 0 0 4px #$post[market_ct_glow]'>$post[usertitle]</span>";
}
if (
$post['market_ct_glow'] AND $post[customtitle] != AND $post[market_ct_color]) {
    
$new_usertitle "<span style='font-weight: bold;text-shadow: 0 0 4px #$post[market_ct_glow]'><span style='color: #$post[market_ct_color]'>$post[usertitle]</span></span>";
}

if (
$new_usertitle != "") {
    
$post[usertitle] = $new_usertitle;


That simply makes sure that we only set the user's title, and not append it to the username. However, doing that caused the title to not always display correctly. The fix was to move the hook location to postbit_display_complete.

It also allows us to add far more color options in the template for item_buy (and our custom template for username colors) without having to also modify the CSS files to include the glows.

Further down in that hook, is a potentially server-intensive set of queries that was causing certain threads to have query counts in the 400s which is unacceptable.

The potentially bad code is as follows:

PHP Code:

$gift_tran$vbulletin->db->query_read("SELECT reason, userid, affecteduser, gift_id, gift_customid from " TABLE_PREFIX "market_transactions where `affecteduser`='$post[userid]' AND (gift_id > 0 OR gift_customid > 0)");

while (
$gift$vbulletin->db->fetch_array($gift_tran)) {

if (
$gift[gift_customid]) {
$gift[gift_id] = $gift[gift_customid];
}

$gift_info $vbulletin->db->fetch_array($vbulletin->db->query_read("SELECT icon_small, name from " TABLE_PREFIX "market_gifts where `giftid`='$gift[gift_id]'"));

        if (
$gift[userid] != $gift[affecteduser]) {
$grab_name $vbulletin->db->fetch_array($vbulletin->db->query_read("SELECT username from " TABLE_PREFIX "user where `userid`='$gift[userid]'"));
        } else {
$grab_name "";
        }

$reason ". Reason: ".stripslashes($gift[reason])."";
        
$templater vB_Template::create('market_gifts_bit');
            
$templater->register('icon_big'$gift_info[icon_small]);
            
$templater->register('name'$gift_info[name]);
            
$templater->register('givenby'$grab_name[username]);
            
$templater->register('gift_reason'$reason);
        
$market_gifts_bit .= $templater->render();



This has the potential of 1 + (giftcount*2) queries, which can cause quite a few unnecessary queries.

Since we don't display who gave the gift, and why, in the postbit (we leave that to the member profiles to cut down on page sizes) I could change the above code to the following, to drop the query count down to 1 per post, which is acceptable.

PHP Code:

 $gift_tran$vbulletin->db->query_read("SELECT ".TABLE_PREFIX."market_gifts.icon_small AS icon_small,
                                                    "
.TABLE_PREFIX."market_gifts.name AS name
                                            FROM "
.TABLE_PREFIX."market_transactions, ".TABLE_PREFIX."market_gifts
                                            WHERE "
.TABLE_PREFIX."market_transactions.affecteduser=$post[userid] 
                                                AND ("
.TABLE_PREFIX."market_transactions.gift_id > 0 OR ".TABLE_PREFIX."market_transactions.gift_customid > 0) 
                                                AND ("
.TABLE_PREFIX."market_gifts.giftid=".TABLE_PREFIX."market_transactions.gift_id 
                                                  OR "
.TABLE_PREFIX."market_gifts.giftid=".TABLE_PREFIX."market_transactions.gift_customid)
                                                "
);
                                            
    
    while (
$gift$vbulletin->db->fetch_array($gift_tran)) 
    {
        
$templater vB_Template::create('market_gifts_bit');
        
$templater->register('icon_big'$gift[icon_small]);
        
$templater->register('name'$gift[name]);
        
$market_gifts_bit .= $templater->render();
    } 

I'm no SQL guru, but 1 query vs potentially hundreds is a vast improvement.

Other changes include actually setting the message to use the [COLOR][B][I] BBCode tags, instead of wrapping them in HTML for display. (Which messes with quotes, and other tags inside the posts) I simply modified your plugin code for that to the following:

PHP Code:

if($vbulletin->GPC['wysiwyg'])
{
    if (
$vbulletin->userinfo['market_post_bold']) {
        
$vbulletin->GPC['message'] = "<b>".$vbulletin->GPC['message']."</b>";
    }
    if (
$vbulletin->userinfo['market_post_italics']) {
        
$vbulletin->GPC['message'] = "<i>".$vbulletin->GPC['message']."</i>";
    }
    if (
$vbulletin->userinfo['market_post_fontface']) {
        
$vbulletin->GPC['message'] = "<span style='font-family: ".$vbulletin->userinfo['market_post_fontface'].";'>".$vbulletin->GPC['message']."</span>";
    }
    if (
$vbulletin->userinfo['market_post_color']) {
        
$vbulletin->GPC['message'] = "<span style='color: #".$vbulletin->userinfo['market_post_color']."'>".$vbulletin->GPC['message']."</span>";
    }
}
else
{
    if (
$vbulletin->userinfo['market_post_bold']) {
        
$vbulletin->GPC['message'] = "[B]".$vbulletin->GPC[message]."[/B]";
    }
    if (
$vbulletin->userinfo['market_post_italics']) {
        
$vbulletin->GPC['message'] = "[I]".$vbulletin->GPC['message']."[/I]";
    }
    if (
$vbulletin->userinfo['market_post_fontface']) {
        
$vbulletin->GPC['message'] = "[FONT='".$vbulletin->userinfo[market_post_fontface]."']".$vbulletin->GPC['message']."[/FONT]";
    }
    if (
$vbulletin->userinfo['market_post_color']) {
        
$vbulletin->GPC['message'] = "[COLOR=#".$vbulletin->userinfo[market_post_color]."]".$vbulletin->GPC['message']."[/COLOR]";
    }


And added that to a hook on newreply_post_start, which effectively wraps it properly, instead of wrapping it for display. (It sends the formatted message to the DB, where the colors can be edited later by the user if they want)

We also had to change the way username/title coloring is handled, since we want certain colors unavailable for usernames, but still available for titles/posts.

There are various other things we've changed, but overall, great mod!

I'd personally like to see a bit easier-to-use item adding system, so I don't have to manually insert things into the DB and add the code later. (An eval() type system would be awesome)

TheMayhem 05-13-2010 04:30 AM

Interesting changes you've done there. Kurios is right on how I have written some of the queries in the hook locations for the gifts is a bit database intensive and I might apply one or more of a fix to the next version before I release.

As far as the user title changes you applied, I'm very unsure of that... The user title bug issues is one of three bugs I haven't fixed and want to before the next version so I will look into what you suggested and see if I can come up with a better way of doing it then I currently have so that the usernames & usertitles can still be purchased with the items I currently offer without having to do template edits. Having no template edits is a very important part of this product that I refuse to ever change.

Now as far as the final thing about manually editing the database for items. As I've previously stated if you ever plan on applying any upgrades of this product never ever-ever-ever start adding new items to the market_items table in the database. With how I have it coded it just won't work. Instead use one of the predefined market items I have included in the 2.0.1 series or one of the predefined categories that have no functionality but are available for custom coding and modify the coding with how you wish. Just don't insert anything new on the table. The reason I did that is so I can still have some control over the reported bugs and errors without having much 3rd party issues coming into play on why things don't work. I'm not saying I won't change that in the future but it all depends on how popular this mod becomes.

Finally, I'm only 3 bugs away from releasing 2.1.0. I can safely say version 3.0.0 will be the next release which will majorly rework the design of purchasing items and I plan on introducing a new major feature that will greatly work with vbcredits when it comes out to allow multiple currencies for purchase and for users to be able to determine if multiple currencies are needed for each item to purchase or if a user can choose what to charge their account and how much of each. More will be available on that after I release this in the next day or two.

Footman 05-13-2010 12:35 PM

Quote:

Originally Posted by TheMayhem (Post 2036120)

Now as far as the final thing about manually editing the database for items. As I've previously stated if you ever plan on applying any upgrades of this product never ever-ever-ever start adding new items to the market_items table in the database. With how I have it coded it just won't work. Instead use one of the predefined market items I have included in the 2.0.1 series or one of the predefined categories that have no functionality but are available for custom coding and modify the coding with how you wish. Just don't insert anything new on the table. The reason I did that is so I can still have some control over the reported bugs and errors without having much 3rd party issues coming into play on why things don't work. I'm not saying I won't change that in the future but it all depends on how popular this mod becomes.

Ah, ok, so I gather it's possible to offer different things then what you've pre-written so long as we do it within your structure, is that correct? If so that's great. Just the ability to tailor the items a bit more to different specific needs is great.

The other thought I personally had regarding 'items' was for actual 'things' like a t-shirt or hat with the sites logo, or even put the points towards their next years membership for example. I'm assuming the best way to do that is manually subtracting the points from a members profile if they order something like that.

kurios 05-13-2010 01:34 PM

Quote:

Originally Posted by TheMayhem (Post 2036120)
As far as the user title changes you applied, I'm very unsure of that... The user title bug issues is one of three bugs I haven't fixed and want to before the next version so I will look into what you suggested and see if I can come up with a better way of doing it then I currently have so that the usernames & usertitles can still be purchased with the items I currently offer without having to do template edits. Having no template edits is a very important part of this product that I refuse to ever change.

That's why I had to move the location of the hook to postbit_display_complete, and set the execution order as high as it will go. If it was left where it was, it simply became URL encoded by other mods (namely VBSEO and another one I couldn't bother hunting down). It doesn't seem to cause any issues by changing the location and order.

Also; the only template edit we did, was to let us quickly add/remove colors for the color purchases. There are some colors we want off-limits for usernames. (It's simply 'appending' colors to the selection box, if it's not the username color item)

As for the actual template edits, we needed to add/remove some colors due to our skin, as some are very very hard to read on our style, so we didn't want our members to have the ability to purchase them at all. (Thus, saving us the headache of having to manually change their color)

The changes for that are as follows:

PHP Code:

$templater vB_Template::create('market_itembuy');
$templater->register('market_gift_list'$market_gift_list);
$templater->register('name'$itembuy[name]);
$templater->register('item_id'$itembuy[marketid]);
$templater->register('item_type'$item_type);
$templater->register('amount'$item_amount);
$templater->register('new_amount'number_format($item_new_amount2'.'','));
$templater->register('current_points'$current_points);
$templater->register('discount_percentage'number_format($discount_percentage2'.'''));
$templater->register('remaining'$remaining);
$templater->register('image'$image);
$templater->register('disabled'$disabled);
$templater->register('maxchar'$maxchar);
$templater->register('instructions'$instructions);
$templater->register('gift_minimum'$permissions['market_gift_minimum']);
$templater->register('gift_maximum'$permissions['market_gift_maximum']);
if (
$itembuy[type] == 4) {
$templater->register('max_donate'$max_donate);
}

/** Begin Custom Color Selection **/

// Check if this is a colorized template we need to use
if ($itembuy['type'] == 3)
{
    
// These are the username colors. Which we can effectively exclude.
    
if ($itembuy['parentid'] != 12)
    {
        
// market_item_buy_color_posttitle simply has a bunch of extra <option="#COLOR">COLOR</option>
        // lines defined, to allow more color options. extra_color_selections is defined right before the
        // closing </selection> tag in the market_item_buy template.
        
$templater->register('extra_color_selections'vB_Template::create('market_item_buy_color_posttitle')->render());
    }
}

/** End Custom Color Selection **/

$market_itembuy .= $templater->render(); 



Quote:

Originally Posted by TheMayhem (Post 2036120)
Now as far as the final thing about manually editing the database for items. As I've previously stated if you ever plan on applying any upgrades of this product never ever-ever-ever start adding new items to the market_items table in the database. With how I have it coded it just won't work. Instead use one of the predefined market items I have included in the 2.0.1 series or one of the predefined categories that have no functionality but are available for custom coding and modify the coding with how you wish. Just don't insert anything new on the table. The reason I did that is so I can still have some control over the reported bugs and errors without having much 3rd party issues coming into play on why things don't work. I'm not saying I won't change that in the future but it all depends on how popular this mod becomes.

They're easily removed for updates, and can be added back in afterwards. :)

Since you're still working on bugs; there are quite a few ways to 'force' buying items without having to pay for them. (You can open multiple tabs at the actual purchase screen for different items, and purchase an item in each tab. You'll only be deducted points for certain items.)

The gambling stuff has a nasty bug that doesn't even check if you have enough points to play the games at all. You can effectively buy 10 million lotto tickets, nearly making your chances of winning 100%. (You go into the far negatives for points, but you can still win the Lotto and make all your points back, plus whatever else was in the pot)

And lastly; we had to add a small little onclick handler to disable the 'Purchase' button after clicking it once, or you could accidentally buy more than 1 of the same item (if applicable).

TheMayhem 05-13-2010 03:12 PM

Very well done on findings... I'm upset that some of those bugs exist but very well done :) Check your private messages.


Also, I have done a lot of investigating on why user's are having issues with the Group By function while most other users are not. The only answer I can come up with is an out of date mysql version of 4.1 when the majority of users of this script and vBulletin use the 5x series. I am looking into alternatives on how to redo the Group By function, which is used on the statistics page within the Admin CP AND the Market home page.

nishant.soni 05-13-2010 07:52 PM

Quote:

Originally Posted by nishant.soni (Post 2035987)
AWESOME MODE... really great work..

2 questions though:

1.How can i have big smilies by default, because small smilies look a bit smaller then they should be in my theme.
2. Does not display avatar :(

Thanks.


CAN SOMEONE ANSWER THAT?

3. more question, what would have to be edited if i want to change the name of the tab that says "Market" which is created under the banner and next to forum?

Thanks.

SoulStealer 05-14-2010 01:03 AM

i am getting error when it try to open my forum's market.php ? how can i increase my own point from admincp and what is point field incorrect error? help

Quote:

The Points Market is currently disabled. This can occur for a number of reasons. The most likely reason is that you currently do not have any earned points. In order to access the Point Market you must have at least 1 point. Another reason you could be seeing this error is the point field entered into the Point Market Control Panel is incorrect or was not found.

TheMayhem 05-14-2010 05:04 AM

Quote:

Originally Posted by SoulStealer (Post 2036682)
i am getting error when it try to open my forum's market.php ? how can i increase my own point from admincp and what is point field incorrect error? help

Do you have a point system such as uCash, vbcredits, or vbookie installed? If you do use whatever the point field is for them so for example for uCash it would be ucash. If you don't you can always use the reputation system or other numerical values within the user table.

SoulStealer 05-14-2010 06:21 AM

oh thanks , its working now using ucash :) ~marked


All times are GMT. The time now is 07:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03045 seconds
  • Memory Usage 1,892KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (5)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete