private $query_membership;
private $query_staff;
private $query_nomination_process_donations;
+ private $query_nomination_process_gift_receipt;
/**
* Date for determining whether someone may participate in board nomination
parent::__construct($info, $config);
// Make sure that all required parameters are present.
- foreach (['dsn', 'username', 'password', 'query_main', 'query_membership', 'query_staff', 'query_nomination_process_donations', 'nomination_process_contrib_start_date', 'nomination_process_contrib_end_date'] as $param) {
+ foreach (['dsn', 'username', 'password', 'query_main', 'query_membership', 'query_staff', 'query_nomination_process_donations', 'query_nomination_process_gift_receipt', 'nomination_process_contrib_start_date', 'nomination_process_contrib_end_date'] as $param) {
if (!array_key_exists($param, $config)) {
throw new Exception('Missing required attribute \''.$param.
'\' for authentication source '.$this->authId);
$this->query_membership = $config['query_membership'];
$this->query_staff = $config['query_staff'];
$this->query_nomination_process_donations = $config['query_nomination_process_donations'];
+ $this->query_nomination_process_gift_receipt = $config['query_nomination_process_gift_receipt'];
$this->nomination_process_contrib_start_date = $config['nomination_process_contrib_start_date'];
$this->nomination_process_contrib_end_date = $config['nomination_process_contrib_end_date'];
if (isset($config['options'])) {
// query for access to board nomination process
//
- // $all_contribs: whether to include all contrib types in total
- // ... false means only membership donations are counted.
- // $amount: donation total threshold for qualifying
- $meets_a_donation_criterion = function ($all_contribs, $amount) {
+ $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 number $amount Amount to compare result to
+ * @param boolean $all_contribs Pass as 'all_contribs' param. The var may also be null to exclude it
+ * @param boolean $gift_redeem_page Pass as 'gift_redeem_page' param. The var may also be null to exclude it
+ */
+ $meets_a_donation_criterion = function ($query_name, $amount, $all_contribs, $gift_redeem_page)
+ use ($username, $start_date, $end_date, $attributes) {
+
+ $parameters =
+ ['username' => $username,
+ 'start_date' => $start_date,
+ 'end_date' => $end_date];
+
+ if ($all_contribs !== null) {
+ $parameters['all_contribs'] = $all_contribs;
+ }
+ if ($gift_redeem_page !== null) {
+ $parameters['gift_redeem_page'] = $gift_redeem_page;
+ }
- $ranged_membership_donation_total =
- $this->query_db('query_nomination_process_donations',
- ['username' => $username,
- 'start_date' => $nomination_process_contrib_start_date,
- 'end_date' => $nomination_process_contrib_end_date,
- 'all_contribs' => $all_contribs]);
+ $result = $this->query_db($query_name, $parameters);
- foreach ($ranged_membership_donation_total[0] as $key => $value) {
+ foreach ($result[0] as $key => $value) {
if ($value < $amount) {
continue;
- } elseif ($attributes['is_member'][0] == 'true') {
+ } elseif ($attributes['is_member'] == ['true']) {
return true;
}
}
return false;
};
- if ($meets_a_donation_criterion(true, 5) || $meets_a_donation_criterion(false, 5)) {
+ if ($meets_a_donation_criterion('query_nomination_process_donations', 5, true, null)
+ || $meets_a_donation_criterion('query_nomination_process_donations', 5, false, null)
+ || $meets_a_donation_criterion('query_nomination_process_gift_receipt', 1, null, 63)) {
+
$attributes['nomination_process'] = ['true'];
} else {
$attributes['nomination_process'] = ['false'];