--------------------------------------------------------
Forum Polls v1.23
Author: xandra 
Email: xknaff@hotpop.com
--------------------------------------------------------


PHP-Fusion Copyright  2002 - 2005 Nick Jones
Released under the terms & conditions of v2 of the GNU General Public License. For details refer to the included gpl.txt file or visit http://gnu.org


--------------------------------------------------------
Description:
--------------------------------------------------------

This allows users to add polls in the forum.

Key Features:
    * Ability to add a poll through either a new thread post or a reply post - 1 poll per thread limit
    * Ability to edit or delete polls - authors can only edit polls while there are no votes... Mods and Super Admins can edit anytime
    * Polls can be set to run a certain number of days or to run indefinitely by setting the running time to 0
    * Polls are positioned at the top of each page, so users can vote from any page in the thread

--------------------------------------------------------
Questions?
--------------------------------------------------------

Post them at http://beta.phpfusion-mods.com or http://phpfusion-mods.com.

--------------------------------------------------------
Installation Instructions:
--------------------------------------------------------

Core files used in this mod:
    * forum/postedit.php
    * forum/postnewthread.php
    * forum/postreply.php
    * forum/viewforum.php
    * forum/viewthread.php
    * infusions/forum_threads_list_panel/forum_threads_list_panel.php
    * infusions/forum_threads_list_panel/my_posts.php
    * infusions/forum_threads_list_panel/my_threads.php
    * infusions/forum_threads_list_panel/new_posts.php
    * infusions/forum_threads_panel/forum_threads_panel.php


Instructions are provided for the following:
    * New Installation
    * Upgrade - v1.20 or greater
    * Upgrade - v1.12 or less

--------------------------------------------------------
New Installation:
--------------------------------------------------------
Backup your website before uploading or modifying any files.

Step 1: Upload the contents of the php-files folder to the appropriate directory.

Step 2: If you have not modified any of the above core files on your site, you should be able to use the included files without any problems. Check the 'mod' folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site. If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.

Step 3: Go to infusions admin and infuse Forum Polls.

--------------------------------------------------------
Upgrade - v1.20 or greater:
--------------------------------------------------------
Backup your website before uploading or modifying any files.

Step 1: Upload the contents of the 'php-files' folder to the appropriate directory.

Step 2: If you have not modified any of the above core files on your site, you should be able to use the included files without any problems. Check the 'mod' folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site. If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.

Step 3: Go to infusions admin and infuse Forum Polls - Do Not defuse it, infuse only.

--------------------------------------------------------
Upgrade - v1.12 or less:
--------------------------------------------------------
Backup your website before uploading or modifying any files.

Note: This new version contains changes to the forum polls table structure and it's very important to backup your database before attempting to upgrade.

Step 1: Backup your database. DO NOT skip this step!

Step 2: In admin, add the following to a custom page and preview it. Don't save it... preview only.


<?php

$result = dbquery("ALTER TABLE ".$db_prefix."forum_polls RENAME TO ".$db_prefix."forum_polls_old");
if ($result) {
	echo "<center><b>Forum Polls</b> table has been renamed.<br><br>";
	$result = dbquery("ALTER TABLE ".$db_prefix."forum_votes RENAME TO ".$db_prefix."forum_votes_old");
	if ($result) {
		echo "<b>Forum Votes</b> table has been renamed.</center>";
	} else {
		echo "<font color='red'>ERROR: <b>Forum Votes</b> table was not renamed.<br><br>Report the error on the <a href='http://beta.phpfusion-mods.com'>beta site</a></font></center>";
	}
} else {
	echo "<center><font color='red'>ERROR: <b>Forum Polls</b> table was not renamed.<br><br>Report the error on the <a href='http://beta.phpfusion-mods.com'>beta site</a>.</font></center>";
}

?>


If the tables were renamed and you didn't receive an error, move onto the next step.

Step 3: Go to infusions admin and defuse Forum Polls.

Step 4: Upload the contents of the 'php-files' and 'upgrade' folders to the appropriate directory.

Step 5: If you have not modified any of the above core files on your site, you should be able to use the included files without any problems. Check the 'mod' folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site. If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.

Step 6: Go to infusions admin and infuse Forum Polls.

Step 7: Go to infusions/forum_polls/upgrade.php and click the Upgrade button. The script will convert all of the old forum polls to the new table structure. If you don't receive any errors, click the delete tables button to drop the old forum poll tables from the database.

Step 8: Delete the upgrade file (infusions/forum_polls/upgrade.php) from your website.


--------------------------------------------------------
Mod Instructions:
--------------------------------------------------------

The instructions below are for PHP-Fusion v6.01.500, but may work on other versions.

Files to be modified:
    * forum/postedit.php
    * forum/postnewthread.php
    * forum/postreply.php
    * forum/viewforum.php
    * forum/viewthread.php
    * infusions/forum_threads_list_panel/forum_threads_list_panel.php
    * infusions/forum_threads_list_panel/my_posts.php
    * infusions/forum_threads_list_panel/my_threads.php
    * infusions/forum_threads_list_panel/new_posts.php
    * infusions/forum_threads_panel/forum_threads_panel.php

--------------------------------------------------------
Open forum/postedit.php

Find...
--------------------------------------------------------

if (!defined("IN_FUSION")) { header("Location: ../index.php"); exit; }

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include INFUSIONS."forum_polls/includes/post.php"; // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<table cellspacing='0' cellpadding='0' border='0' width='100%' class='tbl-border'>

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_preview(); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

if (isset($_POST['delete'])) {

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

fpm_delete(); // Forum Poll Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

$attach = $_FILES['attach'];

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_save($post_id); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

if (!isset($_POST['previewchanges'])) {

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

if (!isset($_POST['previewchanges']) && !isset($_POST['fpm']['add_options'])) {

--------------------------------------------------------
Find...
--------------------------------------------------------

</table>
<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

</table>";
	fpm_form(); // Forum Polls Mod
	echo "<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
Find...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>
<input type='submit' name='previewchanges' value='".$locale['405']."' class='button'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>";
	fpm_add(); // Forum Polls Mod
	echo "<input type='submit' name='previewchanges' value='".$locale['405']."' class='button'>

--------------------------------------------------------
Save and close.

Open forum/postnewthread.php

Find...
--------------------------------------------------------

if (!defined("IN_FUSION")) { header("Location: ../index.php"); exit; }

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include INFUSIONS."forum_polls/includes/post.php"; // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<table cellspacing='0' cellpadding='0' border='0' width='100%' class='tbl-border'>

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_preview(); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

$attach = $_FILES['attach'];

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_save($post_id); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

if (!isset($_POST['previewpost'])) {

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

if (!isset($_POST['previewpost']) && !isset($_POST['fpm']['add_options'])) {

--------------------------------------------------------
Find...
--------------------------------------------------------

</table>
<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

</table>";
	fpm_form(); // Forum Polls Mod
	echo "<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
Find...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>
<input type='submit' name='previewpost' value='".$locale['400']."' class='button'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>";
	fpm_add(); // Forum Polls Mod
	echo "<input type='submit' name='previewpost' value='".$locale['400']."' class='button'>

--------------------------------------------------------
Save and close.

Open forum/postnewthread.php

Find...
--------------------------------------------------------

if (!defined("IN_FUSION")) { header("Location: ../index.php"); exit; }

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include INFUSIONS."forum_polls/includes/post.php"; // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<table cellpadding='0' cellspacing='0' width='100%' class='tbl-border'>

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_preview(); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

$attach = $_FILES['attach'];

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_save($newpost_id); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

if (!isset($_POST['previewreply'])) {

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

if (!isset($_POST['previewreply']) && !isset($_POST['fpm']['add_options'])) {

--------------------------------------------------------
Find...
--------------------------------------------------------

</table>
<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

</table>";
	fpm_form(); // Forum Polls Mod
	echo "<table cellpadding='0' cellspacing='0' width='100%'>

--------------------------------------------------------
Find...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>
<input type='submit' name='previewreply' value='".$locale['402']."' class='button'>

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

<td align='center' colspan='2' class='tbl1'>";
	fpm_add(); // Forum Polls Mod
	echo "<input type='submit' name='previewreply' value='".$locale['402']."' class='button'>

--------------------------------------------------------
Save and close.

Open forum/viewforum.php

Find...
--------------------------------------------------------

opentable($locale['450']);

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

include INFUSIONS."forum_polls/includes/view.php"; // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<td class='tbl1'><img src='".THEME."forum/stickythread.gif' alt='".$locale['560']."' style='vertical-align:middle;'>

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

$threadsubject .= fpm_poll_exists();

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<td class='tbl1'>$threadsubject</td>

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

$threadsubject .= fpm_poll_exists();

--------------------------------------------------------
Save and close.

Open forum/viewthread.php

Find...
--------------------------------------------------------

opentable($locale['500']);

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

include INFUSIONS."forum_polls/includes/view.php"; // Forum Polls Mod
fpm_vote(); // Forum Polls Mod

--------------------------------------------------------
Find...
--------------------------------------------------------

echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n";

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

fpm_view(); // Forum Polls Mod

--------------------------------------------------------
Save and close.

Open infusions/forum_threads_list_panel/forum_threads_list_panel.php

Find...
--------------------------------------------------------

if (!defined("IN_FUSION")) { header("Location:../../index.php"); exit; }

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include_once INFUSIONS."forum_polls/includes/panels.php";

--------------------------------------------------------
Find...
--------------------------------------------------------

if ($theme_width == "100%") {

--------------------------------------------------------
ADD above it...
--------------------------------------------------------

$fpm_append = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);

--------------------------------------------------------
Find... (this appears four times, so find and replace all)
--------------------------------------------------------

$data['thread_subject']

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

$data['thread_subject'].$fpm_append

--------------------------------------------------------
Save and close.

Open infusions/forum_threads_list_panel/my_posts.php

Find...
--------------------------------------------------------

if (!iMEMBER) fallback("../../index.php");

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include_once INFUSIONS."forum_polls/includes/panels.php";

--------------------------------------------------------
Find...
--------------------------------------------------------

while ($data = dbarray($result)) {

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

$fpm_append = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);

--------------------------------------------------------
Find... (this appears twice, so find and replace both)
--------------------------------------------------------

$data['post_subject']

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

$data['post_subject'].$fpm_append

--------------------------------------------------------
Save and close. 

Open infusions/forum_threads_list_panel/my_threads.php

Find...
--------------------------------------------------------

if (!iMEMBER) fallback("../../index.php");

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include_once INFUSIONS."forum_polls/includes/panels.php";

--------------------------------------------------------
Find...
--------------------------------------------------------

while ($data = dbarray($result)) {

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

$fpm_append = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);

--------------------------------------------------------
Find... (this appears four times, so find and replace all)
--------------------------------------------------------

$data['thread_subject']

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

$data['thread_subject'].$fpm_append

--------------------------------------------------------
Save and close. 

Open infusions/forum_threads_list_panel/new_posts.php

Find...
--------------------------------------------------------

if (!iMEMBER) fallback("../../index.php");

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include_once INFUSIONS."forum_polls/includes/panels.php";

--------------------------------------------------------
Find...
--------------------------------------------------------

while ($data = dbarray($result)) {

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

$fpm_append = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);

--------------------------------------------------------
Find...
--------------------------------------------------------

$data['post_subject']

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

$data['post_subject'].$fpm_append

--------------------------------------------------------
Save and close.

Open infusions/forum_threads_panel/forum_threads_panel.php

Find...
--------------------------------------------------------

if (!defined("IN_FUSION")) { header("Location: ../../index.php"); exit; }

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

include_once INFUSIONS."forum_polls/includes/panels.php";

--------------------------------------------------------
Find... (this appears twice, so find and add twice)
--------------------------------------------------------

while ($data = dbarray($result)) {

--------------------------------------------------------
ADD below it...
--------------------------------------------------------

$fpm_append = fpm_panels_poll_exists($data['forum_id'], $data['thread_id']);

--------------------------------------------------------
Find... (this appears four times, so find and replace all)
--------------------------------------------------------

$data['thread_subject']

--------------------------------------------------------
REPLACE with...
--------------------------------------------------------

$data['thread_subject'].$fpm_append

--------------------------------------------------------
Save and close.
--------------------------------------------------------


--------------------------------------------------------
Change Log:
--------------------------------------------------------

- v1.23
	* Added guest permissions

- v1.22
    *  Added pre-modded files and mod instructions for... --> reported missing by ozzWANTED
          o infusions/forum_threads_list_panel/forum_threads_list_panel.php
          o infusions/forum_threads_list_panel/my_posts.php
          o infusions/forum_threads_list_panel/my_threads.php
          o infusions/forum_threads_list_panel/new_posts.php
          o infusions/forum_threads_panel/forum_threads_panel.php
    * Fixed bug that caused all poll questions to be altered by editing a single poll
    * Fixed options max bug in infusions/forum_polls/includes/post.php --> reported by ozzWANTED
    * Fixed (I hope) time/date problems --> reported by ozzWANTED
    * Fixed duplicate voting bug --> reported by ozzWANTED
    * Fixed bug that prevented use of other languages in the add/remove poll button --> reported by dtommy79

- v1.21
	* Fixed 'Use Thread Subject' when replying bug --> reported by BadBoy
	* Fixed poll editing permissions bug --> reported by BadBoy

- v1.20
	* Completely re-written
    * Changed the forum polls database table structure
    * Added the ability for admins to set seperate poll settings for each forum - limited options for now
    * Added the ability to enable/disable the polls
    * Added the ability to have more than 10 option fields per poll
    * Added the ability to easily remove a poll from a post
    * Moved most of the mod code to seperate 'inlcude' files to make modding easier

- v1.12
    * Added pre-modded files for PHP-Fusion v6.01.300

- v1.11
    * Added the ability to initially hide the poll creation form

- v1.10
    * Updated for PHP-Fusion v6.01.200

- v1.01
    * Fixed a forum attachments problem that affected the premodded files

- v1.00
      These changes took place over several un-numbered releases in this thread on the mods site...
	  http://phpfusion-mods.com/forum/viewthread.php?forum_id=8&thread_id=1255
    * Updated for PHP-Fusion v6
    * Fixed some minor bugs
    * Fixed a database error in admin area
    * Added a checkbox so the post's subject can automatically be used as the poll question
    * Changed the poll duration from a selection dropdown to a textbox
    * Added the poll to message posting preview
    * Added the ability to create polls that run indefinately
    * Added the ability to edit the polls
    * Added the ability to start a new poll in a reply post
    * Moved the forum poll from the post's message area to the top of the page

- v0.9 Beta
    * Original mod made for PHP-Fusion v5 by Daniel Zschintzsch
