From: Andrew Engelbrecht Date: Wed, 26 Apr 2023 17:05:42 +0000 (-0400) Subject: allow staff to access board forum X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fd2b4a4880de36178a729f39ec5ab3fddaf290d1;p=fsfdrupalauth.git allow staff to access board forum --- 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 //