Forum - Accepting Code of Conduct v1.03
PHP-Fusion: v7.00.x
original author: muscapaul
email: muscapaul@gmail.com
web: www.muscapaul.com
date: 11 December 2008
--------------------------------------------------
This program is released as free software under the
Affero GPL license. You can redistribute it and/or
modify it under the terms of this license which you
can read by viewing the included agpl.txt or online
at www.gnu.org/licenses/agpl.html. Removal of this
copyright header is strictly prohibited without
written permission from the original author(s).
--------------------------------------------------

FEATURES
--------

* This infusion lets Members read and accept a Code of Conduct before they can post in the Forum (both replies and 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 of Conduct.


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

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


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

1. Open the file ../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 contents of the folder ../files/ to the root of your PHP-Fusion installation.

3. Upload the contents of the folder ../changed-files/ 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. Follow steps 1 and 2 under Automatic Installation.

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

include LOCALE.LOCALESET."forum/main.php";

Immediately AFTER add the following code:

include INFUSIONS."forum_coc/infusion_db.php";


In the same file find (approx. old line 424):

if (iMEMBER && $can_reply && !$fdata['thread_locked']) {

Replace this by the following code:

if (iMEMBER) {
	$member_id = $userdata['user_id'];
	$result = dbquery("SELECT * FROM ".DB_FORUM_COC." WHERE member_id='$member_id'");
	$data = dbarray($result);
	$result1 = dbquery("SELECT * FROM ".DB_FORUM_COC_SETTINGS."");
	$data1 = dbarray($result1);
	$present = time();
}
if (iMEMBER && $can_reply && !$fdata['thread_locked'] && ($data1['fcoc_on'] == '0' OR ($data['coc_status'] == '1' && $present-$data['coc_datestamp']<=$data1['flushcoc_time']))) {

Save the file and close it.


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

require_once INCLUDES."bbcode_include.php";

Immediately AFTER add the following code:

include INFUSIONS."forum_coc/infusion_db.php";


In the same file find (approx. old lines 29-33):

if ($settings['forum_edit_lock'] == 1) {
	$lock_edit = true;
} else {
	$lock_edit = false;
}

Immediately AFTER add the following code:

$member_id = $userdata['user_id'];
$cocresult = dbquery("SELECT * FROM ".DB_FORUM_COC." WHERE member_id='$member_id'");
$data = dbarray($cocresult);
$cocsresult = dbquery("SELECT * FROM ".DB_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 line 115):

require_once THEMES."templates/footer.php";

Immediately BEFORE add the following code:
} else {
	$forum_id = $_GET['forum_id'];
	$thread_id = $_GET['thread_id'];
	redirect(INFUSIONS."forum_coc/forum_coc.php?forum_id=$forum_id&thread_id=$thread_id");
}

Save the file and close it.

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

5. Continue with step 4 under Automatic Installation.

CHANGELOG
---------
v1.03
* Incorrect default value in settings table corrected (thx to Diabelez for reporting the error).

v1.02
* Undefined index error on forum_coc.php for Guest fixed (thx to Diabelez for reporting the error).

v1.01
* Replaced the wrong infusion.php file with the correct one.
* Version number removed from table header in settings page.
* Error fixed: Upgrade script was faulty for updating the admin rights in the admin table. If you experience any problems related to admin rights, please run the code as given in the forum on http://www.muscapaul.com/forum/viewthread.php?thread_id=38.

v1.00
* Completely updated to run under PHP-Fusion v7.

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)