Odyssey
CreditUnionGate.i
1 <?php
2 require_once(dirname(__FILE__) . '/../library/FeatureGate.i');
3 
4 /**
5  * Class to apply the credit union code to a feature gate
6  *
7  */
8 
9 class CreditUnionGate extends FeatureGate {
10  // Add possible constants that match the feature string in the table
11  const LOG_PASSTHROUGH_TICKET_FEATURE = 'logPssTckt';
12  const LOG_TICKET_CHECK_FEATURE = 'logTcktChk';
13  const LOGIN_PROCESS = 'LOGIN';
14  const MIR_HANDLER = 'mirHandler';
15 
16  /**
17  * Check the credit union code to allow through gate.
18  *
19  * $params can be "username" (the username to test)
20  *
21  * @param String $creditUnion Credit union to check the gate for
22  * @param array $params Extra params for the gate check
23  * @return bool
24  */
25  protected function DeterminePass(String $creditUnion, array $params = null):bool {
26  $featurePass = $this->DetermineCreditUnionPass($creditUnion);
27 
28  if ( $featurePass ) {
29  // see what params we are checking
30  if ( is_array($params) && array_key_exists("username", $params) ) {
31  // check if this user is allowed
32  $featureParams = $this->GetFeatureParams( $creditUnion );
33 
34  // use must exist if usernames are listed (no username or empty list means all users are allowed)
35  if ( is_array($featureParams) && array_key_exists("usernames", $featureParams) ) {
36  if ( count( $featureParams["usernames"] ) > 0 ) {
37  // there are names, so ours must exist; assume doesn't pass
38  $featurePass = false;
39 
40  // case insensitive check
41  for ( $i = 0; $i < count( $featureParams["usernames"] ); $i++ ) {
42  if ( strcasecmp($params["username"], $featureParams["usernames"][$i]) == 0 ) {
43  // found it
44  $featurePass = true;
45  break;
46  }
47  }
48  }
49  }
50  }
51  }
52 
53  return $featurePass;
54  }
55 
56 }
GetFeatureParams(String $creditUnion)
Definition: FeatureGate.i:79
DetermineCreditUnionPass(String $creditUnion)
Definition: FeatureGate.i:48
DeterminePass(String $creditUnion, array $params=null)