MOD: force acceptance on terms and conditions when uploading MOD: force acceptance on terms and conditions when uploading
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

MOD: force acceptance on terms and conditions when uploading

Started by divestoclimb, August 13, 2008, 09:27:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

divestoclimb

I'm setting up a Coppermine gallery integrated with vBulletin, but this means users will never see Coppermine's registration terms. My company needed to make sure users accepted some terms of use--in a nutshell, that we can reuse the pics they upload elsewhere.

The mod works in the same manner as uploading photos to Facebook: the user is asked to check a box when they upload photos and, if the box wasn't checked, the upload fails. The terms are a custom item in the language file; they are not the ones agreed to during registration.

If you want to add this to a future version, what's missing is translating the messages into other languages and adding a configuration option to turn this behavior on and off (but I assume that's trivial? I don't know, I just started hacking Coppermine this morning...). I'd love to see this in a future version because that means I don't have to maintain more custom code on my site :)

I'm a UNIX guy so here's the patch against Coppermine 1.4.19. I removed the terms I put into lang/english.php because they're specific to my organization.
diff -urN coppermine-orig/lang/english.php coppermine/lang/english.php
--- coppermine-orig/lang/english.php 2008-05-01 09:25:00.000000000 -0400
+++ coppermine/lang/english.php 2008-08-13 14:34:06.226401600 -0400
@@ -99,6 +99,7 @@
   'zip_type' => 'You do not have permission to upload ZIP files.',
   'database_query' => 'There was an error while processing a database query', //cpg1.4
   'non_exist_comment' => 'The selected comment does not exist', //cpg1.4
+  'tc_not_agreed' => 'In order to upload images, you must agree to the gallery\'s <a href="terms.php" target="_blank">Terms and Conditions</a> by checking the box on the upload form.', // termsandconditions added by BDR 20080813
);

$lang_bbcode_help_title = 'bbcode help'; //cpg1.4
@@ -1485,6 +1486,16 @@
By clicking 'I agree' below you agree to be bound by these conditions.
EOT;

+$lang_terms = <<<EOT
+[insert your terms and conditions here]
+EOT;
+
$lang_register_php = array(
   'page_title' => 'User registration',
   'term_cond' => 'Terms and conditions',
@@ -1799,6 +1810,7 @@
   'close' => 'Close', //cpg1.4
   'no_keywords' => 'Sorry, no keywords available!', //cpg1.4
   'regenerate_dictionary' => 'Regenerate Dictionary', //cpg1.4
+  'tc_agree' => 'By checking this box, I agree to the gallery\'s <a href="terms.php" target="_blank">Terms and Conditions</a>.', // termsandconditions added by BDR 20080813
);

// ------------------------------------------------------------------------- //
diff -urN coppermine-orig/terms.php coppermine/terms.php
--- coppermine-orig/terms.php 1969-12-31 19:00:00.000000000 -0500
+++ coppermine/terms.php 2008-08-13 14:25:45.582177600 -0400
@@ -0,0 +1,37 @@
+<?php
+/*************************
+  Coppermine Photo Gallery
+  ************************
+  Copyright (c) 2003-2008 Dev Team
+  v1.1 originally written by Gregory DEMAR
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 3
+  as published by the Free Software Foundation.
+  
+**********************************************/
+
+
define('IN_COPPERMINE'true);
+
define('REGISTER_PHP'true);
+
+require(
'include/init.inc.php');
+require(
'include/mailer.inc.php');
+
+
pageheader($lang_register_php['term_cond']);
+
starttable(-1$lang_register_php['term_cond']);
+echo <<<EOT
+        <tr>
+                <td class="tableb">
+
+EOT;
+echo 
$lang_terms;
+
+echo <<<EOT
+                </td>
+        </tr>
+EOT;
+endtable();
+pagefooter();
+ob_end_flush();
+
+?>

diff -urN coppermine-orig/upload.php coppermine/upload.php
--- coppermine-orig/upload.php 2008-08-13 12:00:21.621167100 -0400
+++ coppermine/upload.php 2008-08-13 14:56:31.856196800 -0400
@@ -117,6 +117,24 @@
     }
}

+// BDR 20080813:
+// The check box function. Take the label and the field name as arguments.
+// This could be done using <label> tags, however for the application of a
+// Terms and Conditions checkbox this would be a bad idea since clicking on
+// a link inside that label will check the box, an unintended action.
+function checkbox_input($text, $name) {
+    echo <<<EOT
+ <tr>
+     <td width="40%" class="tableb">&nbsp;</td>
+     <td width="60%" class="tableb" vlaign="top">
+ <input type="checkbox" id="check_$name" name="$name" />
+ $text
+     </td>
+ </tr>
+
+EOT;
+}
+
// The file input function. Takes the label, field name, and number of iterations as arguments.
function file_input($text, $name, $iterations) {

@@ -255,6 +273,7 @@
// 2 => album list
// 3 => text area input
// 4 => hidden input
+// 5 => check box input [BDR 20080813]
function create_form(&$data) {

     global $CONFIG, $lang_upload_php;
@@ -306,6 +325,13 @@
                     hidden_input($element[0], $element[1]);
                     break;

+ // BDR 20080813: If the type is a check box
+ case 5 :
+
+     // Call the check box function
+     checkbox_input($element[0], $element[1]);
+     break;
+
                 // If the type is not present, kill the script.
                 default:
                     cpg_die(ERROR, $lang_upload_php['reg_instr_1'], __FILE__, __LINE__);
@@ -779,6 +805,10 @@

         echo "{$lang_upload_php['cust_instr_7']}<br /><br />";
         echo "</td></tr>";
+
+ // BDR 20080813: add the check box to accept Terms & Conditions
+ array_push($data, array($lang_upload_php['tc_agree'], 'agree', 5));
+
         create_form($data);
         close_form($lang_continue);
         endtable();
@@ -988,6 +1018,9 @@

             }

+     // BDR 20080813: add the check box to accept Terms & Conditions
+     array_push($form_array, array($lang_upload_php['tc_agree'], 'agree', 5));
+
             // Add the control device.
             $form_array[] = array('control', 'phase_1', 4);

@@ -1067,6 +1100,20 @@

         }

+ // BDR 20080813: Check if the user agreed to the terms and conditions
+ if($_POST["agree"] != "on") {
+     pageheader($lang_error);
+     msg_box($lang_error, $lang_errors['tc_not_agreed'], $lang_continue, "upload.php", "100%");
+
+     // Create the footer and flush the output buffer.
+     pagefooter();
+     ob_end_flush();
+
+     // Exit the script.
+
+     exit;
+ }
+
         for ($counter = 0; $counter < $file_upload_count; $counter++) {

             // Check for error code support. Set the error code.

Joachim Müller

Thanks for your readiness to share. Sadly, the majority of our users is not familiar with diffs, so we'd appreciate it if you could create the usual instructions (edit foo.bar, find bla, replace with whatever).

divestoclimb

Okay here goes: (I'm leaving out the comments)

Open lang/english.php

Find the line $lang_errors = array(
Just before the next line with a ");", add this line:'tc_not_agreed' => 'In order to upload images, you must agree to the gallery\'s <a href="terms.php" target="_blank">Terms and Conditions</a> by checking the box on the upload form.',

Find the line beginning with $lang_register_disclaimer, then after the next line with a "EOT;", add this:$lang_terms = <<<EOT
[your terms and conditions go here]
EOT;


Find the line that looks like this:if (defined('UPLOAD_PHP')) $lang_upload_php = array(
Just before the next line with a ");", add this line:'tc_agree' => 'By checking this box, I agree to the gallery\'s <a href="terms.php" target="_blank">Terms and Conditions</a>.',

Now close english.php and create a file called terms.php. Put the following in it:

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.
  
**********************************************/

define('IN_COPPERMINE'true);
define('REGISTER_PHP'true);

require(
'include/init.inc.php');
require(
'include/mailer.inc.php');

pageheader($lang_register_php['term_cond']);
starttable(-1$lang_register_php['term_cond']);
echo <<<EOT
        <tr>
                <td class="tableb">

EOT;
echo 
$lang_terms;

echo <<<EOT
                </td>
        </tr>
EOT;
endtable();
pagefooter();
ob_end_flush();

?>



Now open upload.php.

Find the line that begins with "function text_box_input..." and look for the next line that starts with a } (no spaces before it). After that line add the following:

function checkbox_input($text, $name) {
    echo <<<EOT
<tr>
    <td width="40%" class="tableb">&nbsp;</td>
    <td width="60%" class="tableb" vlaign="top">
<input type="checkbox" id="check_$name" name="$name" />
$text
    </td>
</tr>

EOT;
}


Now search for these lines:

                    // Call the hidden input funtion.
                    hidden_input($element[0], $element[1]);
                    break;

And after them, add this:

case 5 :

    checkbox_input($element[0], $element[1]);
    break;


Look for this:

        create_form($data);

And add this before it:

        array_push($data, array($lang_upload_php['tc_agree'], 'agree', 5));


Look for this:


            // Add the control device.
            $form_array[] = array('control', 'phase_1', 4);

And add this before it:

    array_push($form_array, array($lang_upload_php['tc_agree'], 'agree', 5));


Look for this:

            // We have error support.
            $error_support = 'TRUE';

        }

And add this after it:

if($_POST["agree"] != "on") {
    pageheader($lang_error);
    msg_box($lang_error, $lang_errors['tc_not_agreed'], $lang_continue, "upload.php", "100%");

    // Create the footer and flush the output buffer.
    pagefooter();
    ob_end_flush();

    // Exit the script.

    exit;
}


And that's it!  :P

midas

I made the edits to both both upload.php and english.php but got an "illegal form creation" error (luckily I backed up the original files).

I double checked the edits I made.  They seemed to follow the instructions.  I'm using version 1.4.19.  Is it a fault with the code listed in the "do-this-do-that" post (immediately above this)?

Are there any other ways to add an upload check-box for T's and C's?

divestoclimb

I'm new to the software but I'm not familiar with that error message.

I may be able to help if you:
- copy and paste the exact error message you're seeing
- copy and paste the sections of PHP code that you modified. If there was a mistake in my instructions that should help me notice and correct it.

midas

Quote from: divestoclimb on September 09, 2008, 05:47:21 PM
I'm new to the software but I'm not familiar with that error message.

I may be able to help if you:
- copy and paste the exact error message you're seeing
- copy and paste the sections of PHP code that you modified. If there was a mistake in my instructions that should help me notice and correct it.

Divestoclimb,

I've just re-edited the upload.php and english.php files to include your modifications.  The code works fine.  I'd missed out "case 5" in this bit

Quotecase 5 :

          checkbox_input($element[0], $element[1]);
          break;

Sorry for raising a false alarm.  Thank you for providing you code too  :)

Kindest Regards,

Midas/

divestoclimb