[opw-web] Restrict which programs contracts can be accepted for



commit 3df18f045689600403ee29beb9838f850a1e4949
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue May 12 21:03:28 2015 -0400

    Restrict which programs contracts can be accepted for
    
    Only allow the contracts to be accepted for active programs after the
    selection deadline has passed.

 modules/mod_contract.php     |    1 +
 modules/mod_user_profile.php |   19 ++++++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/modules/mod_contract.php b/modules/mod_contract.php
index c8a4895..f5ec1af 100644
--- a/modules/mod_contract.php
+++ b/modules/mod_contract.php
@@ -111,6 +111,7 @@ 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']);
 
         $is_student = $role_data['role'] == 's';
         $is_mentor = $role_data['role'] == 'm';
diff --git a/modules/mod_user_profile.php b/modules/mod_user_profile.php
index 6a7a9b7..11da775 100644
--- a/modules/mod_user_profile.php
+++ b/modules/mod_user_profile.php
@@ -198,22 +198,23 @@ if ($action == 'view') {
                 }
 
                 if ($is_self) {
-                    $contract_action = "view";
                     $review_contract_visibility = false;
                     $view_contract_visibility = false;
 
                     if ($is_self && $program['contract_accepted_time'] == 0) {
-                        $review_contract_visibility = true;
+                        $review_contract_visibility = $program['is_active'];
                     } else if ($program['contract_accepted_time'] != 0) {
                         $view_contract_visibility = true;
                     }
-                    $contract_url = "?q=contract&prg={$program['id']}&r={$contract_return}";
-                    $skin->assign(array(
-                                      'contract_url' => htmlspecialchars($contract_url),
-                                      'review_contract_visibility' => 
$skin->visibility($review_contract_visibility),
-                                      'view_contract_visibility' => 
$skin->visibility($view_contract_visibility),
-                                 ));
-                    $contracts_list .= $skin->output('tpl_user_profile_contract_footer');
+                    if ($review_contract_visibility || $view_contract_visibility) {
+                        $contract_url = "?q=contract&prg={$program['id']}&r={$contract_return}";
+                        $skin->assign(array(
+                                          'contract_url' => htmlspecialchars($contract_url),
+                                          'review_contract_visibility' => 
$skin->visibility($review_contract_visibility),
+                                          'view_contract_visibility' => 
$skin->visibility($view_contract_visibility),
+                                          ));
+                        $contracts_list .= $skin->output('tpl_user_profile_contract_footer');
+                    }
                 }
 
                 if ($user->is_admin && count($contracts_by_program[$program['id']]) > 0) {


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