[opw-web] Add an explicit control for whether program participants can accept contracts



commit 17104a448fee964aa245523bc5a8c7a57c930fea
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu May 14 14:23:32 2015 -0400

    Add an explicit control for whether program participants can accept contracts
    
    Since the contracts for a program might not be finalized until after the
    selection deadline, have an explicit checkbox in the program configuration
    to enable the ability for users to accept contracts, and hide the
    "Review contract" link until that checkbox is set.

 lang/en-gb.php                                     |    1 +
 modules/mod_contract.php                           |    4 +++-
 modules/mod_manage_programs.php                    |    6 +++++-
 modules/mod_user_profile.php                       |    2 +-
 schema.sql                                         |    2 ++
 .../html/tpl_manage_programs_editor.html           |   11 +++++++++--
 6 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 2a94ea1..50b4eef 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -112,6 +112,7 @@ $lang_data = array(
     'student_contract'      => 'Intern agreement',
     'mentor_contract'       => 'Mentor agreement',
     'sample_contract_link'  => 'Link to sample agreement',
+    'enable_contracts'      => 'Users can accept agreements',
     'dl_student'            => 'Application deadline',
     'dl_mentor'             => 'Selection deadline',
     'show_deadlines'        => 'Show deadlines',
diff --git a/modules/mod_contract.php b/modules/mod_contract.php
index 3560b00..a264da9 100644
--- a/modules/mod_contract.php
+++ b/modules/mod_contract.php
@@ -111,7 +111,9 @@ if ($action == 'edit_student' || $action == 'edit_mentor') {
 
 
         $user->restrict($role_data['has_project']);
-        $user->restrict($program_data['is_active'] && $core->timestamp > $program_data['dl_mentor']);
+        $user->restrict($program_data['is_active'] &&
+                        $program_data['contracts_active'] &&
+                        $core->timestamp > $program_data['dl_mentor']);
 
         $is_student = $role_data['role'] == 's';
         $is_mentor = $role_data['role'] == 'm';
diff --git a/modules/mod_manage_programs.php b/modules/mod_manage_programs.php
index 6a5d9cc..b7ad50c 100644
--- a/modules/mod_manage_programs.php
+++ b/modules/mod_manage_programs.php
@@ -17,6 +17,7 @@ $end_date = $core->variable('end_date', '', false, true);
 $dl_student_date = $core->variable('dl_student', '', false, true);
 $dl_mentor_date = $core->variable('dl_mentor', '', false, true);
 $active = $core->variable('active', '') == "on" ? 1 : 0;
+$contracts_active = $core->variable('contracts_active', '') == "on" ? 1 : 0;
 $page = $core->variable('pg', 1);
 $limit_start = ($page - 1) * $config->per_page;
 
@@ -108,6 +109,7 @@ else if ($action == 'editor')
                             'dl_student' => $dl_student,
                             'dl_mentor' => $dl_mentor,
                             'active' => $active,
+                            'contracts_active' => $contracts_active,
                             'deadline' => $deadline,
                             'complete' => $complete);
 
@@ -121,7 +123,8 @@ else if ($action == 'editor')
                        "    end_time = :end_time, " .
                        "    dl_student = :dl_student, " .
                        "    dl_mentor = :dl_mentor, " .
-                       "    is_active = :active " .
+                       "    is_active = :active, " .
+                       "    contracts_active = :contracts_active " .
                        "WHERE id = :id";
                 $db->query($sql, $params);
 
@@ -194,6 +197,7 @@ else if ($action == 'editor')
         'mentor_contract_edit' => "?q=contract&amp;a=edit_mentor&amp;prg={$id}",
         'mentor_contract_sample' => "?q=contract&amp;a=sample_mentor&amp;prg={$id}",
         'active_checked'    => $skin->checked($active == 1),
+        'contracts_active_checked' => $skin->checked($contracts_active == 1),
         'error_message'     => isset($error_message) ? $error_message : '',
         'error_visibility'  => $skin->visibility(isset($error_message)),
         'delete_visibility' => $skin->visibility($id > 0),
diff --git a/modules/mod_user_profile.php b/modules/mod_user_profile.php
index 11da775..6e5140d 100644
--- a/modules/mod_user_profile.php
+++ b/modules/mod_user_profile.php
@@ -202,7 +202,7 @@ if ($action == 'view') {
                     $view_contract_visibility = false;
 
                     if ($is_self && $program['contract_accepted_time'] == 0) {
-                        $review_contract_visibility = $program['is_active'];
+                        $review_contract_visibility = $program['is_active'] && $program['contracts_active'];
                     } else if ($program['contract_accepted_time'] != 0) {
                         $view_contract_visibility = true;
                     }
diff --git a/schema.sql b/schema.sql
index 9ef9e2b..729f7db 100644
--- a/schema.sql
+++ b/schema.sql
@@ -6,6 +6,7 @@ INSERT INTO `opw_cron` (
   `timestamp`
 ) VALUES (0);
 
+/* alter table opw_programs add `contracts_active` tinyint(1) NOT NULL DEFAULT 0 ; */
 CREATE TABLE `opw_programs` (
   `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
   `title` varchar(255) NOT NULL DEFAULT '',
@@ -15,6 +16,7 @@ CREATE TABLE `opw_programs` (
   `dl_student` int(11) unsigned NOT NULL,
   `dl_mentor` int(11) unsigned NOT NULL,
   `is_active` tinyint(1) NOT NULL DEFAULT 0,
+  `contracts_active` tinyint(1) NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
diff --git a/skins/easterngreen/html/tpl_manage_programs_editor.html 
b/skins/easterngreen/html/tpl_manage_programs_editor.html
index 3ff6570..fd9b731 100644
--- a/skins/easterngreen/html/tpl_manage_programs_editor.html
+++ b/skins/easterngreen/html/tpl_manage_programs_editor.html
@@ -53,6 +53,13 @@
 </div>
 
 <div class="control-group">
+    <label class="control-label">{{active}} &nbsp;</label>
+    <div class="controls">
+        <input type="checkbox" name="active" [[active_checked]] />
+    </div>
+</div>
+
+<div class="control-group">
     <label class="control-label">{{mentor_contract}}</label>
     <div class="controls">
         <a href="[[student_contract_edit]]" target="edit_contract">{{edit_contract}}</a><br />
@@ -69,9 +76,9 @@
 </div>
 
 <div class="control-group">
-    <label class="control-label">{{active}} &nbsp;</label>
+    <label class="control-label">{{enable_contracts}} &nbsp;</label>
     <div class="controls">
-        <input type="checkbox" name="active" [[active_checked]] />
+        <input type="checkbox" name="contracts_active" [[contracts_active_checked]] />
     </div>
 </div>
 


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