vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   v3arcade Favorites Mod (https://vborg.vbsupport.ru/showthread.php?t=101862)

amykhar 11-28-2005 10:00 PM

v3arcade Favorites Mod
 
As written, the favorites list is generated by the number of times a game is played. This modification changes that behavior so that users can select their own favorite games. It includes the ability to add and remove games from the favorites list.

I am not offering support for this modification. It is provided as-is. It is working fine for me, but I'm not guaranteeing that it will work for you.

yoyoyoyo 11-29-2005 01:24 PM

nice work as usual

Snake 11-29-2005 01:58 PM

Oh yes. Thanks for the hack amy.

amykhar 11-29-2005 03:21 PM

No problem. I write stuff that I need and don't mind sharing :)

monstergamer 11-29-2005 03:31 PM

sorry i get Parse error: parse error in /home/httpd/vhosts/monstergamer.net/httpdocs/vb/arcade.php on line 518

Vizionz 11-29-2005 03:39 PM

i get a parse error on line 518
was there an update to the arcade i dont know about ? that could be the reason for that error now

amykhar 11-29-2005 03:56 PM

Get the new zip. There was an else{ missing and the first installers probably knew enough php (as they should) to fix it themselves ;)

Gizmo5h1t3 11-29-2005 03:58 PM

sorry amy, this just doesnt work.

installed EXACTLY as stated...
all seems ok, till u actually click on the "add to favourtes" link
then u get a blank page....

Oblivion Knight 11-29-2005 05:29 PM

[high]* Oblivion Knight gives Amy a hug!
[/high]
Thank you! This is much better than the current default.. :D

michaelbenson 11-29-2005 06:08 PM

Thanks this looks like a brilliant addition.
Would it be possible for say the Favourites category to be displayed as defualt instead of the Random category instead

amykhar 11-29-2005 06:26 PM

Sure it would Michael. You just have to change the code to make that happen. ;)

FleaBag 11-29-2005 06:30 PM

LOL. :D Nice work.

amykhar 11-29-2005 06:40 PM

This is why I hate releasing code :D I always forget stuff in the directions. I left out the code chunk from the top of the file.

Code:

Find:
---------
$footer = construct_phrase($vbphrase['arcade_end'], $vbulletin->options['arcadeimages']) . $footer;
----------
Add After:
---------
if ($_REQUEST['do']=='addfav')
{
                $vbulletin->input->clean_array_gpc('r', array(
          'gameid' => TYPE_INT
        ));
       
        $favuser = $vbulletin->userinfo[userid];
        $favgame = $vbulletin->GPC['gameid'];
        if($favuser AND $favgame)
        {
                // Make sure it's not in the user's favorites
                $eaalreadythere = $db->query_first("SELECT gameid FROM " .TABLE_PREFIX."eaarcade_favorites WHERE userid=$favuser and gameid=$favgame");
                if(!$eaalreadythere)
                {
                  $db->query_write("INSERT INTO " . TABLE_PREFIX . "eaarcade_favorites (userid, gameid) VALUES ($favuser,$favgame)");
          }
        }
        // Go to the favorites page
        $vbulletin->url = 'arcade.php?categoryid=2';
  standard_redirect($vbphrase['favorite_added'], true);
}

if ($_REQUEST['do']=='delfav')
{
                $vbulletin->input->clean_array_gpc('r', array(
          'gameid' => TYPE_INT
        ));
       
        $favuser = $vbulletin->userinfo[userid];
        $favgame = $vbulletin->GPC['gameid'];
        if($favuser AND $favgame)
        {
                // Make sure it's in the user's favorites
                $eaalreadythere = $db->query_first("SELECT * FROM " .TABLE_PREFIX."eaarcade_favorites WHERE userid=$favuser AND gameid=$favgame");
                if($eaalreadythere)
                {
                  $db->query_write("DELETE FROM " . TABLE_PREFIX . "eaarcade_favorites WHERE userid=$favuser AND gameid=$favgame");
          }
        }
        // Go to the favorites page
        $vbulletin->url = 'arcade.php?categoryid=2';
  standard_redirect($vbphrase['favorite_removed'], true);
}

---------


Vizionz 11-29-2005 07:02 PM

now it works perfect thanks amy

monstergamer 11-29-2005 07:51 PM

worrks now

...installed...

nintendo 11-29-2005 08:48 PM

Quote:

Originally Posted by Oblivion Knight
[high]* Oblivion Knight gives Amy a hug!
[/high]
Thank you! This is much better than the current default.. :D

Try to get John to make this the default version. This is what we all wanted, not the current crummy one that's not a favorites section at all.

Vizionz 11-29-2005 08:51 PM

yeah this and the users online you did oblivion should be default settings

Vizionz 11-29-2005 08:53 PM

it would be also nice to have a stats page where it shows the most played games the top gamers and top ten most played players. < that one i mean total games played in the arcade by that user.

amykhar 11-30-2005 12:33 AM

You guys do realize that John's probably never going to read this thread and it might be better to discuss your arcade wish list somewhere John'll read it, right?

Lea Verou 11-30-2005 01:21 AM

Installed and works flawlessly. Thank you :)

On little suggestion: Check if the user has added the game when he is browsing other categories and display the remove link instead of the add one even if the game is already added ;)

amykhar 11-30-2005 01:23 AM

I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.

Vizionz 11-30-2005 01:25 AM

Quote:

Originally Posted by amykhar
You guys do realize that John's probably never going to read this thread and it might be better to discuss your arcade wish list somewhere John'll read it, right?

i know that :) but i like you to see ideas too since your a great coder amy :) and maybe you would find use in something and decide to do it for yourself then shair the code like usual :P

Lea Verou 11-30-2005 01:27 AM

Quote:

Originally Posted by amykhar
I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.

I suspected that :) You could add it as an option though so that smaller forums can take advantage of it :)

Oblivion Knight 11-30-2005 06:28 AM

Quote:

Originally Posted by amykhar
I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.

I remember trying to handle that with a cache in the 3.0.x version, but it was an absolute nightmare.. :speechless:

Gizmo5h1t3 11-30-2005 06:11 PM

might be wise to add that this wont work with the alternative layout hack released on here......

amykhar 11-30-2005 11:22 PM

I guess you just added that :D I haven't seen the alternative layout mod.

wcbryant 12-01-2005 06:54 AM

Does anyone have this working in v3a 1.0.2 with OK's "Who's Online" and the "Leader Board" hacks? I know that's a stretch, but thought I'd try. I seem to get a blank white page, and wonder if it's a conflict with any of the above.

amykhar 12-01-2005 12:55 PM

A bit of experimentation on my site shows that performance isn't taking a big hit when I do this. So... I have updated the code to dynamically show if a game is a favorite or not on the category lists.

If you have already installed the mod, here is how to upgrade:

1. Find:
Code:

        else if ($vbulletin->GPC['categoryid']==2)
        {
                // Favorites
    $gamecountquery = ("SELECT * FROM " . TABLE_PREFIX."eaarcade_favorites
    WHERE userid=" . $vbulletin->userinfo['userid'] . "
    GROUP BY userid ASC");
                $gamecount = $db->num_rows($gamecountquery);

                $perpage =  $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);

                // set defaults
                sanitize_pageresults($gamecount, $pagenumber, $perpage, 100, $vbulletin->options['gamesperpage']);

                $start = (int)($perpage*$pagenumber)-$perpage;

                $pagenav = construct_page_nav($pagenumber, $perpage, $gamecount, 'arcade.php?' . $vbulletin->session->vars['sessionurl'], ""
                . (!empty($vbulletin->GPC['categoryid']) ? "&amp;categoryid=" . $vbulletin->GPC['categoryid'] : "")
                . (!empty($vbulletin->GPC['perpage']) ? "&amp;pp=$perpage" : "")
                );

                        $games = $db->query_read("SELECT eaarcade_favorites.gameid, arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "eaarcade_favorites AS eaarcade_favorites
                  LEFT JOIN " . TABLE_PREFIX . "arcade_games AS arcade_games ON (arcade_games.gameid=eaarcade_favorites.gameid)
                  LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
                  LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categoryid)
                  WHERE eaarcade_favorites.userid=" . $vbulletin->userinfo['userid'] . " AND arcade_games.title IS NOT NULL
                " . iif($bitfieldcheck, "AND $bitfieldcheck") . "
                  ORDER BY eaarcade_favorites.gameid DESC
                  LIMIT $start,".$vbulletin->options['gamesperpage']);
        } else        {

Replace with:
-----------
Code:

        else if ($vbulletin->GPC['categoryid']==2)
        {
                // Favorites
    $gamecountquery = ("SELECT * FROM " . TABLE_PREFIX."eaarcade_favorites
    WHERE userid=" . $vbulletin->userinfo['userid'] . "
    GROUP BY userid ASC");
                $gamecount = $db->num_rows($gamecountquery);

                $perpage =  $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);

                // set defaults
                sanitize_pageresults($gamecount, $pagenumber, $perpage, 100, $vbulletin->options['gamesperpage']);

                $start = (int)($perpage*$pagenumber)-$perpage;

                $pagenav = construct_page_nav($pagenumber, $perpage, $gamecount, 'arcade.php?' . $vbulletin->session->vars['sessionurl'], ""
                . (!empty($vbulletin->GPC['categoryid']) ? "&amp;categoryid=" . $vbulletin->GPC['categoryid'] : "")
                . (!empty($vbulletin->GPC['perpage']) ? "&amp;pp=$perpage" : "")
                );

                        $games = $db->query_read("SELECT eaarcade_favorites.*, arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "eaarcade_favorites AS eaarcade_favorites
                  LEFT JOIN " . TABLE_PREFIX . "arcade_games AS arcade_games ON (arcade_games.gameid=eaarcade_favorites.gameid)
                  LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
                  LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categoryid)
                  WHERE eaarcade_favorites.userid=" . $vbulletin->userinfo['userid'] . " AND arcade_games.title IS NOT NULL
                " . iif($bitfieldcheck, "AND $bitfieldcheck") . "
                  ORDER BY eaarcade_favorites.gameid DESC
                  LIMIT $start,".$vbulletin->options['gamesperpage']);
        } else        {

-----------

Find:
Code:

        $games = $db->query_read("SELECT arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "arcade_games AS arcade_games
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
                LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categoryid)
                " . iif($vbulletin->GPC['categoryid']!=-1, "WHERE arcade_games.categoryid=" . $vbulletin->GPC['categoryid'] . iif($bitfieldcheck, " AND $bitfieldcheck"), iif($bitfieldcheck, "WHERE $bitfieldcheck")) . "
                ORDER BY title ASC
                LIMIT $start, " . $vbulletin->options['gamesperpage']);

Replace with:
Code:

                $games = $db->query_read("SELECT arcade_games.*, favorites.favid AS favid, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "arcade_games AS arcade_games
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
                LEFT JOIN " . TABLE_PREFIX . "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid)
                LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categoryid)
                " . iif($vbulletin->GPC['categoryid']!=-1, "WHERE favorites.userid=". $vbulletin->userinfo[userid]." AND arcade_games.categoryid=" . $vbulletin->GPC['categoryid'] . iif($bitfieldcheck, " AND $bitfieldcheck"), iif($bitfieldcheck, "WHERE $bitfieldcheck")) . "
                ORDER BY title ASC
                LIMIT $start, " . $vbulletin->options['gamesperpage']);

In your arcade_game_bit template, Replace the code block you added previously with:
Code:

<br /> <if condition="$game[favid]"><a href="arcade.php?do=delfav&gameid=$game[gameid]">$vbphrase[arcadedelfav]</a><else /><a href="arcade.php?do=addfav&gameid=$game[gameid]">$vbphrase[arcadeaddfav]</a></if>
(Note: only the conditional changed in the template.)

Maagic 12-01-2005 02:28 PM

I'm getting

Parse error: parse error, unexpected T_ELSE in /home/(deleted)/public_html/forum/arcade.php on line 442

Oblivion Knight 12-01-2005 05:35 PM

Quote:

Originally Posted by wcbryant
Does anyone have this working in v3a 1.0.2 with OK's "Who's Online" and the "Leader Board" hacks? I know that's a stretch, but thought I'd try. I seem to get a blank white page, and wonder if it's a conflict with any of the above.

Nope, this works fine with the Who's Online and Leader Board addons.. ;)


Quote:

Originally Posted by Gizmo5h1t3
might be wise to add that this wont work with the alternative layout hack released on here......

Once I've updated the Alternative Layout mod, I'll provide some instructions for adding this mod to it..

vedman 12-03-2005 07:15 PM

Quote:

Originally Posted by Gizmo5h1t3
might be wise to add that this wont work with the alternative layout hack released on here......

I take it you're not referring to the template addition? :) That can be mangled to suit the alternate layout hack...

I use the alternate layout.. and games don't show up at all in specific categories (though "All" and "Random" games do appear).

Looks like it's this specific query in arcade.php:

PHP Code:

$games $db->query_read("SELECT arcade_games.*, favorites.favid AS favid, user.username, arcade_categories.catname FROM " TABLE_PREFIX "arcade_games AS arcade_games
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (arcade_games.highscorerid=user.userid)
        LEFT JOIN " 
TABLE_PREFIX "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid)
        LEFT JOIN " 
TABLE_PREFIX "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categoryid)
        " 
iif($vbulletin->GPC['categoryid']!=-1"WHERE favorites.userid="$vbulletin->userinfo[userid]." AND arcade_games.categoryid=" $vbulletin->GPC['categoryid'] . iif($bitfieldcheck" AND $bitfieldcheck"), iif($bitfieldcheck"WHERE $bitfieldcheck")) . "
        ORDER BY title ASC
        LIMIT 
$start, " $vbulletin->options['gamesperpage']); 

I'm guessing it's this...

PHP Code:

LEFT JOIN " . TABLE_PREFIX . "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid

Since there are no games in the favorites table initially, wouldn't that mean it doesn't match any games in the games table (and thus, none are displayed)? I don't know a lot about sql joins, but if they're anything like where conditions, if part of it doesn't match, it won't return any rows.

I'm sure it's something I'm doing wrong, since this mod obviously works for some people. One strange thing though - I don't see how it relates to the alternative layout mod (since that mod doesn't alter the "get games for specific category" query, above).

Despite all of that, it looks like a great mod, it makes v3arcade even more awesome (I'm an ibPro convert). Thanks a ton! Can't wait to get it working.

vedman 12-03-2005 10:02 PM

Ok, got it fixed. Hopefully this is useful to someone who has the same issue I had.

I downloaded the zip file this morning and installed it as is, so any additional code in this thread is not taken into account.

This is only for those using the alternate layout, and whose games are not showing up in any user-defined categories, after installing the Favorites mod.

However, I did add a line to arcadeadmin.php which deletes favorites whenever a game is removed... I guess anyone could use that. :nervous:

This is the first time I've written instructions for a hack, hopefully it makes sense.

.

dan35 12-06-2005 04:17 AM

I don't use the alternate layout, but the games are not showing up in specific categories after installing the Favorites mod.

Use your fix and it works ;)

Thanks Amy and Vedman!

FROGGYJ 12-08-2005 10:03 PM

installed~

Snake 12-09-2005 08:32 AM

Is this going to work fine on v3.5.2?

amykhar 12-09-2005 10:35 AM

Given that it doesn't change anything about VB, yes. This only changes arcade code.

Snake 12-09-2005 10:50 AM

Ah alright then.

dieselpowered 12-11-2005 07:21 PM

Quote:

Originally Posted by vedman
Ok, got it fixed. Hopefully this is useful to someone who has the same issue I had.

I downloaded the zip file this morning and installed it as is, so any additional code in this thread is not taken into account.

This is only for those using the alternate layout, and whose games are not showing up in any user-defined categories, after installing the Favorites mod.

However, I did add a line to arcadeadmin.php which deletes favorites whenever a game is removed... I guess anyone could use that. :nervous:

This is the first time I've written instructions for a hack, hopefully it makes sense.

.

Forgive this ignorant question, however, are we supposed to do this fix as well as the edits from the hack Amy posted?

I wonder why not not everyone reported that the games were not showing up in their specific categories...wouldn't that have affected everyone?

vedman 12-11-2005 09:04 PM

Quote:

Originally Posted by xtremeoff-road
Forgive this ignorant question, however, are we supposed to do this fix as well as the edits from the hack Amy posted?

My fix is based on the mod zip file only. The edits from the mod that were posted change it up a little, but not much.

My hack basically sets the $games query (for specific categories) back to the original code, and adds a small query to get the favorites seperately. It doesn't change what is called in the template, so it would actually fix the category problems with those not using the alt. layout mod, as long as you don't touch the template change.

Unless you understand PHP and see what changed, I'd recommend going one route or the other.

Quote:

Originally Posted by xtremeoff-road
I wonder why not not everyone reported that the games were not showing up in their specific categories...wouldn't that have affected everyone?

That's a good question. I installed this mod right after installing v3arcade, so maybe the fact that none of my games had been played had something to do with it?

dieselpowered 12-11-2005 09:27 PM

Thanks for the response...ok well I had already done the edits from the zip...and then saw you fix, so I did the edits you specified, therefore, I have edits from your file as well as Amy's. Should I upload a fresh arcade.php and only do your edits?


All times are GMT. The time now is 06:13 PM.

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.01271 seconds
  • Memory Usage 1,865KB
  • 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
  • (6)bbcode_code_printable
  • (2)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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