[opw-web] Ask for and record the full name when someone accepts a contract



commit 244467265cf960f90a8dc25182b4684653ac2a6a
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu May 14 14:01:12 2015 -0400

    Ask for and record the full name when someone accepts a contract

 lang/en-gb.php                            |    5 +++--
 modules/mod_contract.php                  |   11 ++++++++---
 schema.sql                                |    2 ++
 skins/easterngreen/html/tpl_contract.html |   20 +++++++++++++-------
 4 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 35d3b04..2a94ea1 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -363,9 +363,10 @@ $lang_data = array(
     'contract_sign_message'     => 'Make sure that you have <span class="alert-emphasis">initialed each 
page</span> and signed and dated the last page',
 
     /* Module: contract */
-    'review_contract_notice_student'   => 'Please review the following terms of participation as an intern 
in Outreachy. If they are acceptable to you, please click on "Accept Agreement" at the bottom of the page.',
-    'review_contract_notice_mentor'    => 'Please review the following terms of participation as a mentor in 
Outreachy. If they are acceptable to you, please click on "Accept Agreement" at the bottom of the page.',
+    'review_contract_notice_student'   => 'Please review the following terms of participation as an intern 
in Outreachy. If they are acceptable to you, please type your full name then click on "Accept Agreement" at 
the bottom of the page.',
+    'review_contract_notice_mentor'    => 'Please review the following terms of participation as a mentor in 
Outreachy. If they are acceptable to you, please type your full name then click on "Accept Agreement" at the 
bottom of the page.',
     'view_contract_notice'      => 'You accepted the following agreement on: ',
+    'type_your_name'            => 'Please type your full name',
     'accept_contract'           => "Accept Agreement",
 
     'edit_contract'             => "Edit agreement",
diff --git a/modules/mod_contract.php b/modules/mod_contract.php
index f5ec1af..3560b00 100644
--- a/modules/mod_contract.php
+++ b/modules/mod_contract.php
@@ -146,17 +146,22 @@ if ($action == 'edit_student' || $action == 'edit_mentor') {
     if ($accept_contract) {
         $user->check_csrf();
 
+        $contract_name = trim($core->variable('contract_name', ''));
+        $user->restrict($contract_name != '');
+
         if (!$is_sample) {
             $sql = "UPDATE {$db->prefix}roles " .
                       "SET contract_accepted_time = UNIX_TIMESTAMP(), " .
-                      "    contract_id = :contract_id " .
+                      "    contract_id = :contract_id, " .
+                      "    contract_entered_name = :contract_name " .
                     "WHERE username = :username " .
                       "AND program_id = :program_id";
 
             $db->query($sql,
                        array('username' => $username,
                              'program_id' => $program_id,
-                             'contract_id' => $contract_id));
+                             'contract_id' => $contract_id,
+                             'contract_name' => $contract_name));
         }
 
         if ($return_url != '')
@@ -175,7 +180,7 @@ if ($action == 'edit_student' || $action == 'edit_mentor') {
                  ));
 
     // Output the module
-    $module_title = $lang->get('view_contract');
+    $module_title = $lang->get($has_accepted ? 'view_contract' : 'review_contract');
     $module_data = $skin->output('tpl_contract');
 }
 
diff --git a/schema.sql b/schema.sql
index d32d44e..30319e6 100644
--- a/schema.sql
+++ b/schema.sql
@@ -82,6 +82,7 @@ CREATE TABLE `opw_participants` (
 /* alter table opw_roles add `contract_accepted_time` int(11) NOT NULL DEFAULT 0 ; */
 /* alter table opw_roles add `contract_id` mediumint(10) unsigned ; */
 /* alter table opw_roles add foreign key (`contract_id`) references opw_contracts(id) ; */
+/* alter table opw_roles add `contract_entered_name` varchar(255) NOT NULL DEFAULT '' ; */
 CREATE TABLE `opw_roles` (
   `id` mediumint(10) NOT NULL AUTO_INCREMENT,
   `username` varchar(255) NOT NULL DEFAULT '',
@@ -90,6 +91,7 @@ CREATE TABLE `opw_roles` (
   `role` char(1) NOT NULL DEFAULT 's',
   `contract_approved` tinyint(1) NOT NULL DEFAULT 0,
   `contract_accepted_time` int(11) unsigned NOT NULL DEFAULT 0,
+  `contract_entered_name` varchar(255) NOT NULL DEFAULT '',
   `contract_id` mediumint(10) unsigned,
   PRIMARY KEY (`id`),
   FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`),
diff --git a/skins/easterngreen/html/tpl_contract.html b/skins/easterngreen/html/tpl_contract.html
index 9d64c22..ee25f53 100644
--- a/skins/easterngreen/html/tpl_contract.html
+++ b/skins/easterngreen/html/tpl_contract.html
@@ -9,18 +9,24 @@
 <div class="alert [[view_visibility]]">
   {{view_contract_notice}} [[contract_accepted_time]]
 </div>
-<div id="contractText" class="contract-text" onscroll="checkScroll()">[[contract_html]]</div>
+<div id="contractText" class="contract-text" onscroll="checkSensitive()">[[contract_html]]</div>
 <div class="[[review_visibility]]">
-<button disabled id="acceptContractButton" type="submit" name="accept_contract"  class="btn btn-primary">
+{{type_your_name}}: <input id="contractName" name="contract_name" oninput="checkSensitive()"><br />
+<button disabled id="acceptContractButton" type="submit" name="accept_contract" class="btn btn-primary">
     {{accept_contract}}
 </button>
 <script type="text/javascript">
-function checkScroll() {
+var scrolledToBottom = false;
+function checkSensitive() {
    var scrollDiv = document.getElementById("contractText");
-   if (scrollDiv.scrollTop >= scrollDiv.scrollHeight - scrollDiv.clientHeight - 5) {
-       document.getElementById("acceptContractButton").removeAttribute("disabled");
-   }
+   var nameInput = document.getElementById("contractName");
+   if (scrollDiv.scrollTop >= scrollDiv.scrollHeight - scrollDiv.clientHeight - 5)
+       scrolledToBottom = true;
+
+   console.log(!scrolledToBottom || /^\s*$/.test(nameInput.value));
+
+   document.getElementById("acceptContractButton").disabled = !scrolledToBottom || 
/^\s*$/.test(nameInput.value);
 }
-checkScroll();
+checkSensitive();
 </script>
 </div>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]