From 0782e0aa7bc3a4ee05ae562d9c1777bf72fb8c98 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Tue, 25 Apr 2023 12:39:57 -0400 Subject: [PATCH] simplification for nomination process access --- lib/Auth/Source/FSFDrupalAuth.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/Auth/Source/FSFDrupalAuth.php b/lib/Auth/Source/FSFDrupalAuth.php index 2acdc65..c3f0445 100644 --- a/lib/Auth/Source/FSFDrupalAuth.php +++ b/lib/Auth/Source/FSFDrupalAuth.php @@ -300,12 +300,9 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase } // - // query for access to board nomination process + // helper functions for access to board nomination / discussion process // - $start_date = $this->nomination_process_contrib_start_date; - $end_date = $this->nomination_process_contrib_end_date; - /** * @param string $query_name Name of query in authsources * @param array $extra_params Associative array of parameters to include in query @@ -337,7 +334,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase // the time window with a single donation. this approximates whether // the person was, or would have been, a member during the configured // time window. - $analyze_history = function ($selective_donations_history) + $nomination_process_analyze_history = function ($selective_donations_history) use ($start_date, $end_date) { $eligible = false; @@ -381,14 +378,24 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase return false; }; + // + // nomination form participation specific checks + // + + $start_date = $this->nomination_process_contrib_start_date; + $end_date = $this->nomination_process_contrib_end_date; + $donation_params = ['start_date' => $start_date, 'end_date' => $end_date]; $gift_member_params = ['start_date' => $start_date, 'end_date' => $end_date, 'gift_redeem_page_id' => intval($this->gift_redeem_page_id)]; $adhoc_params = ['adhoc_access_group_id' => intval($this->nomination_process_adhoc_access_group_id)]; if ($this->nomination_process_active == 'true' ) { - if ($compare_res($donation_query('query_nomination_process_adhoc', $adhoc_params), 1) || ($attributes['is_member'] == ['true'] - && ($analyze_history($donation_query('query_nomination_process_donations', $donation_params)) - || $compare_res($donation_query('query_nomination_process_gift_receipt', $gift_member_params), 1)))) { + if ($compare_res($donation_query('query_nomination_process_adhoc', $adhoc_params), 1)) { + $attributes['nomination_process'] = ['true']; + + } elseif ($attributes['is_member'] == ['true'] + && ($nomination_process_analyze_history($donation_query('query_nomination_process_donations', $donation_params)) + || $compare_res($donation_query('query_nomination_process_gift_receipt', $gift_member_params), 1))) { $attributes['nomination_process'] = ['true']; } else { -- 2.25.1