Forum - Accepting Code of Conduct v0.21
PHP-Fusion: v6.01.10
original author: muscapaul
email: muscapaul@gmail.com
web: www.muscapaul.com
date: 25 May 2007
--------------------------------------------------
Copyright: Released under the terms and conditions
of the GNU General Public License (Version 2)
--------------------------------------------------

FEATURES
--------

* This infusion lets Members read and accept a Code of Conduct before they can post in the Forum (either replies or new threads).
* Option to make Members read the Code of Conduct and accept it again after one month, three months or a year (default is one month).
* Option to disable the system without defusing it (enabled by default).
* Option to empty the table that holds the data of who accepted the Code of Conduct. This is useful, for example, when the Code of Conduct is updated and Members have to accept the new Code.
* The Code of Conduct is read from a separate text file that can easily be edited or exchanged for another. The txt file needs to be placed in the ../infusions/forum_coc folder and the name of the file needs be entered in the Settings Panel of the Infusion. A general example is given for the Code of Conduct but this should be updated for your site because every forum is unique. The default setting in the database is 'coc.txt' and an example file with that name is given in the ../infusions/forum_coc folder (exactly the same as the file example_coc.txt in the root of this folder).
* A link to the Forum - Code of Conduct is automatically added to the Navigation Panel. Members who have not yet accepted the code will automatically get the opportunity to accept it. Non-members will just see the Code.


CHANGED FILES
-------------

../forum/post.php
../forum/viewthread.php


AUTOMATIC INSTALLATION
----------------------

1. Open the file ../php-files/infusions/forum_coc/coc.txt in a text editor of your choice and draft your own Forum - Code of Conduct. Save and close the file. Alternatively you can search for another Code of Conduct that appeals to you and save it in coc.txt or in a txt file with a name of your own choice. Please note that any formatting (line breaks, bold, italics, etc.) should be done using html code.

2. Upload the folder php-files/infusions/to the root of your PHP-Fusion installation.

3. Upload the folder changed-files/forum to the root of your PHP-Fusion installation.

4. Go to Admin Panel -> System Admin -> Infusions. Choose Forum CoC from the Infusions drop-down menu and click 'Infuse'.

5. Go to Admin Panel -> Infusions -> Forum - Accepting Code of Conduct and set the frequence for re-accepting the Code of Conduct. If you chose another file name for the Code of Conduct in step 1 you should set it now, too. Save the settings.


MANUAL INSTALLATION
-------------------

1. Open the file ../forum/viewthread.php in a text editor of your choice and find (approx on line 289):

if (iMEMBER && $can_post && !$tdata['thread_locked']) {

Replace this code with:
$member_id = $userdata['user_id'];
$result = dbquery("SELECT * FROM ".DB_PREFIX."forum_coc WHERE member_id='$member_id'");
$data = dbarray($result);
$result1 = dbquery("SELECT * FROM ".DB_PREFIX."forum_coc_settings");//line added
$data1 = dbarray($result1);
$present = time();
if (iMEMBER && $can_post && !$tdata['thread_locked'] && ($data1['fcoc_on'] == '0' OR ($data['coc_status'] == '1' && $present-$data['coc_datestamp']<=$data1['flushcoc_time'])))

Save and close the file.


2. Open the file ../forum/post.php in a text editor of your choice and find (approx. on line 18):

if (!FUSION_QUERY || !isset($forum_id) || !isNum($forum_id)) fallback("index.php");

Immediately after add the following code:

$member_id = $userdata['user_id'];
$cocresult = dbquery("SELECT * FROM ".DB_PREFIX."forum_coc WHERE member_id='$member_id'");
$data = dbarray($cocresult);
$cocsresult = dbquery("SELECT * FROM ".DB_PREFIX."forum_coc_settings");
$data1 = dbarray($cocsresult);
$present = time();

if (($data1['fcoc_on'] == '0') OR ($data['coc_status'] == '1' AND $present-$data['coc_datestamp']<=$data1['flushcoc_time'])) {


In the same file find (approx. old lines 65-67):

} else {
	header("Location: index.php");
}

Immediately after add the following code:

} else {
redirect(INFUSIONS."forum_coc/forum_coc.php?forum_id=$forum_id&thread_id=$thread_id"); }

3. Upload the files ../forum/viewthread.php and ../forum/post.php to the ../forum folder on your server.

4. Continue with step 4 under Automatic Installation.

CHANGELOG
---------
v0.21
* Bug fixed: Update query to store re-acceptance of Forum - CoC did not store data in database.

v0.20
* Bug fixed: Tick box and Accept / Refuse buttons for re-accepting the Forum - COC did not show up after the set amount of time when a user had to re-accept.

* Note added after Accept / Refuse buttons to notify users when the Forum - COC needs to be accepted again.

v0.10
* None (first release)