July 23, 2004

Changing poll to ALL in phpBB

I've been experimenting with phpBB polls, and noticed something very annoying. Despite repeated setting poll voting to ALL (from REG - for registered), the system reports no error and yet sets the poll voting back to REG. Basically, 40-some people have visited my laminate flooring survey with no way to vote. Arrrr.... Fortunately, there is a MOD called guestvote_mod that will fix this problem. Remember that this is beta software, so use at your own risk. Also, you will have to get your hands dirty to install this, so have some paper towels handy.

Let's do it.
  1. Download the latest version of guestvote_mod.zip. In the archive you will find two php files and a txt file containing the instructions, which I will outline below.
  2. Copy guestvote.php and guestvote_config.php into your phpBB directory.
  3. In the same directory, make backup copies of posting.php, viewtopic.php and viewforum.php. As you can see below, the next steps are a lot of work. If you trust me and have a fresh copy of phpBB, just replace the files with the ones found here, otherwise...
  4. Open up posting.php with your favorite editor, e.g., XEmacs, and make the following changes:

    After

    include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
    append
    // begin guestvote mod
    include($phpbb_root_path . 'guestvote.'.$phpEx);
    include($phpbb_root_path . 'guestvote_config.'.$phpEx);
    // end guestvote mod
    This will give posting.php access to the guestvote functions.

    Comment out

                    $is_auth_type = 'auth_vote';
    (line 160) and replace it with
    // begin guestvote mod
                    $is_auth_type = guestvote_auth_type();
    // end guestvote mod

    Comment out

                            $sql = "SELECT *
                                    FROM " . VOTE_USERS_TABLE . "
                                    WHERE vote_id = $vote_id
                                            AND vote_user_id = " . $userdata['user_id'];
    (line 482) and replace it with

    Comment out

    			if ( !($row = $db->sql_fetchrow($result2)) )
    (line 494) and replace it with
    // begin guestvote mod
                            if ( !($row = $db->sql_fetchrow($result2)) && !(guestvote_already_voted_by_cookie()) )
    // end guestvote mod

    Comment out

                                    $sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip)
                                            VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip')";
                                    if ( !$db->sql_query($sql, END_TRANSACTION) )
                                    {
                                            message_die(GENERAL_ERROR, "Could not insert user_id for poll", "", __LINE__, __FILE__,$sql);
                                    }
    (line 508) and replace it with
    // begin guestvote mod
                                    if ($guestvote_logging == 1 || $guestvote_logging == 3)
                                    {
                                            $sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip)
                                                    VALUES ($vote_id, " . $userdata['user_id'] . ", '$user_ip')";
                                            if ( !$db->sql_query($sql, END_TRANSACTION) )
                                            {
                                                    message_die(GENERAL_ERROR, "Could not insert user_id for poll", "", __LINE__, __FILE__, $sql);
                                            }
                                    }
                                    guestvote_set_cookie();
    // end guestvote mod
  5. Open up viewtopic.php and make the following changes:

    After

    include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
    append
    // begin guestvote mod
    include($phpbb_root_path . 'guestvote.'.$phpEx);
    include($phpbb_root_path . 'guestvote_config.'.$phpEx);
    // end guestvote mod

    After

    //
    // User authorisation levels output
    //
    (line 581) append
    // begin guestvote mod
    if ($userdata['user_id'] == ANONYMOUS && guestvote_allowed())
    {
    	$is_auth['auth_vote'] = TRUE;
    }
    // end guestvote mod

    Comment out

                    $sql = "SELECT vote_id
                            FROM " . VOTE_USERS_TABLE . "
                            WHERE vote_id = $vote_id
                                    AND vote_user_id = " . intval($userdata['user_id']);
    (line 708) and replace it with
    // begin guestvote mod
                    $is_auth_type = guestvote_auth_type();
    // end guestvote mod

    Comment out

                    $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
    (line 720) and replace it with
    // begin guestvote mod
                    $user_voted = $user_voted || guestvote_already_voted_by_cookie();
    // end guestvote mod
  6. Open up viewforum.php and make the following changes:

    After

    include($phpbb_root_path . 'common.'.$phpEx);
    append
    // begin guestvote mod
    include($phpbb_root_path . 'guestvote.'.$phpEx);
    include($phpbb_root_path . 'guestvote_config.'.$phpEx);
    // end guestvote mod

    After

    //
    // User authorisation levels output
    //
    (line 367) append
    // begin guestvote mod
    if ($userdata['user_id'] == ANONYMOUS && guestvote_allowed())
    {
    	$is_auth['auth_vote'] = TRUE;
    }
    // end guestvote mod
Posted by torque at July 23, 2004 9:28 AM | TrackBack
Comments

Thank you! This was exactly what I was looking for; one small correction -- on the posting above, it says:

Comment out

$sql = "SELECT * FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];

(line 482) and replace it with

and the replacement is not given. The correct information is in the readme file in the package. It says that you are to replace with the following:

// begin guestvote mod
$sql = guestvote_sql();
// end guestvote mod

Thanks again,

Ben Chapman

Posted by: Ben Chapman at October 12, 2004 6:53 AM

adult chat rooms - http://www.fooadultchat.com/

Posted by: adult chat rooms at December 4, 2006 2:11 AM
Post a comment









Remember personal info?