From: Andrew Engelbrecht Date: Tue, 19 Apr 2022 21:28:12 +0000 (-0400) Subject: Rename CAS group name based on function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0f1497804a047537176da7af1b47a9672dccdaf2;p=fsfdrupalauth.git Rename CAS group name based on function The check we'll eventually use is more specific than whether they are a long term member, so we shouldn't use that name. --- diff --git a/docs/fsf-drupal-auth.md b/docs/fsf-drupal-auth.md index d9579a1..dc897c2 100644 --- a/docs/fsf-drupal-auth.md +++ b/docs/fsf-drupal-auth.md @@ -10,7 +10,7 @@ SQL queries in `config/authsources.php` should be something like the following: // custom fsf authentication source wrapped by ratelimit auth source 'fsfdrupalauth:FSFDrupalAuth', - 'member_long_term_date' => '2022-01-01', + 'nomination_process_date' => '2022-01-01', 'dsn' => 'mysql:host=example.com;port=3306;dbname=drupal', 'username' => '$DB_USERNAME', 'password' => '$DB_PASSWORD', @@ -18,7 +18,7 @@ SQL queries in `config/authsources.php` should be something like the following: // don't filter with 'and c.is_test = 0' because these may be useful for FSF staff 'query_membership' => "select c.status_id from drupal.users a inner join civicrm.civicrm_uf_match b on a.uid=b.uf_id inner join civicrm.civicrm_membership c on b.contact_id=c.contact_id inner join civicrm.civicrm_contact d on c.contact_id=d.id where a.status = 1 and d.is_deleted = 0 and c.status_id is not NULL and a.name = :username and (c.status_id = 1 or c.status_id = 2 or c.status_id = 3 or c.status_id = 4) order by c.status_id limit 10;", 'query_staff' => "select a.name as is_fsf_staff from drupal.users a inner join civicrm.civicrm_uf_match b on a.uid=b.uf_id inner join civicrm.civicrm_contact c on b.contact_id=c.id inner join civicrm.civicrm_relationship d on c.id=d.contact_id_a where a.name=:username and a.status=1 and c.is_deleted=0 and d.relationship_type_id=4 and d.contact_id_b=FOOBAR and d.is_active=1 and (d.end_date>NOW() or d.end_date is NULL) limit 1;", - 'query_membership_long_term' => "select c.join_date from drupal.users a inner join civicrm.civicrm_uf_match b on a.uid=b.uf_id inner join civicrm.civicrm_membership c on b.contact_id=c.contact_id inner join civicrm.civicrm_contact d on c.contact_id=d.id where a.name = :username and c.status_id is not NULL and (c.status_id = 1 or c.status_id = 2 or c.status_id = 3 or c.status_id = 4) and c.join_date <= :member_long_term_date order by c.join_date limit 1;", + 'query_nomination_process' => "select c.join_date from drupal.users a inner join civicrm.civicrm_uf_match b on a.uid=b.uf_id inner join civicrm.civicrm_membership c on b.contact_id=c.contact_id inner join civicrm.civicrm_contact d on c.contact_id=d.id where a.name = :username and c.status_id is not NULL and (c.status_id = 1 or c.status_id = 2 or c.status_id = 3 or c.status_id = 4) and c.join_date <= :nomination_process_date order by c.join_date limit 1;", ], diff --git a/lib/Auth/Source/FSFDrupalAuth.php b/lib/Auth/Source/FSFDrupalAuth.php index 8ee8f2c..8a0c60e 100644 --- a/lib/Auth/Source/FSFDrupalAuth.php +++ b/lib/Auth/Source/FSFDrupalAuth.php @@ -44,12 +44,13 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase private $query_main; private $query_membership; private $query_staff; - private $query_membership_long_term; + private $query_nomination_process; /** - * Date for determining whether someone is a long-term member or not + * Date for determining whether someone can participate in board nomination + * process */ - private $member_long_term_date; + private $nomination_process_date; /** * Constructor for this authentication source. @@ -66,7 +67,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase parent::__construct($info, $config); // Make sure that all required parameters are present. - foreach (['dsn', 'username', 'password', 'query_main', 'query_membership', 'query_staff', 'query_membership_long_term', 'member_long_term_date'] as $param) { + foreach (['dsn', 'username', 'password', 'query_main', 'query_membership', 'query_staff', 'query_nomination_process', 'nomination_process_date'] as $param) { if (!array_key_exists($param, $config)) { throw new Exception('Missing required attribute \''.$param. '\' for authentication source '.$this->authId); @@ -86,8 +87,8 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase $this->query_main = $config['query_main']; $this->query_membership = $config['query_membership']; $this->query_staff = $config['query_staff']; - $this->query_membership_long_term = $config['query_membership_long_term']; - $this->member_long_term_date = $config['member_long_term_date']; + $this->query_nomination_process = $config['query_nomination_process']; + $this->nomination_process_date = $config['nomination_process_date']; if (isset($config['options'])) { $this->options = $config['options']; } @@ -276,7 +277,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase // query on first membership join date // - $membership_date_data = $this->query_db('query_membership_long_term', ['username' => $username, 'member_long_term_date' => $member_long_term_date]); + $membership_date_data = $this->query_db('query_nomination_process', ['username' => $username, 'nomination_process_date' => $nomination_process_date]); if (count($membership_date_data) === 0) { // No rows returned - no old membership start @@ -284,14 +285,14 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase ': No rows in result set. May only be a short term member.'); } - $attributes['long_term_member'] = ['false']; + $attributes['nomination_process'] = ['false']; foreach ($membership_date_data as $row) { foreach ($row as $key => $value) { if ($value === null) { continue; } elseif ($attributes['is_member'][0] == 'true') { - $attributes['long_term_member'] = ['true']; + $attributes['nomination_process'] = ['true']; } } }