From fd2b4a4880de36178a729f39ec5ab3fddaf290d1 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Wed, 26 Apr 2023 13:05:42 -0400 Subject: [PATCH] allow staff to access board forum --- lib/Auth/Source/FSFDrupalAuth.php | 63 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/lib/Auth/Source/FSFDrupalAuth.php b/lib/Auth/Source/FSFDrupalAuth.php index 1e80d51..a44f5a8 100644 --- a/lib/Auth/Source/FSFDrupalAuth.php +++ b/lib/Auth/Source/FSFDrupalAuth.php @@ -291,6 +291,36 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase */ private function add_more_attributes(&$attributes, $username) { + // + // query on staff + // + + $staff_data = $this->query_db('query_staff', ['username' => $username, 'fsf_org_id' => $this->fsf_org_id]); + + if (count($staff_data) === 0) { + // No rows returned - invalid username + Logger::debug('fsfdrupalauth:'.$this->authId. + ': No rows in result set. Probably not FSF staff.'); + } + + $attributes['is_fsf_staff'] = ['false']; + + foreach ($staff_data as $row) { + foreach ($row as $key => $value) { + + if ($value === null) { + continue; + } + $value = (string) $value; + + if (strtolower($value) === strtolower($username)) { + // they are staff + $attributes['is_fsf_staff'] = ['true']; + break; + } + } + } + // // query on membership // @@ -496,6 +526,9 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase } elseif ($compare_res($donation_query('query_discussion_process_adhoc', $adhoc_params), 1)) { $attributes['discussion_process'] = ['true']; + } elseif ($attributes['is_fsf_staff'] == ['true']) { + $attributes['discussion_process'] = ['true']; + } elseif ($attributes['is_member'] != ['true']) { Logger::debug('fsfdrupalauth:'.$this->authId. ': Not eligible for board nominee discussion process.'); @@ -512,36 +545,6 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase $attributes['discussion_process'] = ['false']; } - // - // query on staff - // - - $staff_data = $this->query_db('query_staff', ['username' => $username, 'fsf_org_id' => $this->fsf_org_id]); - - if (count($staff_data) === 0) { - // No rows returned - invalid username - Logger::debug('fsfdrupalauth:'.$this->authId. - ': No rows in result set. Probably not FSF staff.'); - } - - $attributes['is_fsf_staff'] = ['false']; - - foreach ($staff_data as $row) { - foreach ($row as $key => $value) { - - if ($value === null) { - continue; - } - $value = (string) $value; - - if (strtolower($value) === strtolower($username)) { - // they are staff - $attributes['is_fsf_staff'] = ['true']; - break; - } - } - } - // // aggregate attribute // -- 2.25.1