. */ class Fee { private $bodies; public function __construct() { $this->bodies = ""; } public function __destruct() { } public function get_fee($body, $participanttype, $fee=-1) { global $setup; if( $fee>-1 ) { // Fee is pre-defined (this can be used for easier coding, but no need to ask this function when fee is set to something else than -1 (default) return $fee; }elseif( $this->load_bodies() ) { if( !array_key_exists($body, $this->bodies) ) return false; if( strtolower($participanttype)=="observer" ) $participanttype = "envoy"; // handle observers as envoy $participanttype = ucwords(strtolower($participanttype)); if( !in_array($participanttype, array("Delegate", "Envoy", "Visitor")) ) return false; switch( $this->bodies[$body]['BodyCategoryOrder'] ) { case 0: // Comite Directeur case 1: // Liaison Office case 2: // Commissions // No fee return 0; break; case 3: // Honorary Members case 4: // Alumni Network case 5: // Working Groups case 6: // Projects // Unknown country return false; break; case 7: // Locals case 8: // Contacts case 9: // Connections if( !isset($setup[ $participanttype . ucwords(strtolower( $this->bodies[$body]['Fee'] )) ]) ) return false; else return $setup[ $participanttype . ucwords(strtolower( $this->bodies[$body]['Fee'] )) ]; break; default: return false; } }else { return false; } } private function load_bodies() { if( is_array($this->bodies) ) { return true; }else { // Bodies not loaded, do now $query = "SELECT `ab_bodies`.`BodyCode` AS `BodyCode`, `ab_bodies`.`BodyCategoryOrder` AS `BodyCategoryOrder`, `countrycodes`.`Fee` AS `Fee` FROM `ab_bodies` LEFT JOIN `countrycodes` ON `ab_bodies`.`CountryCode`=`countrycodes`.`Postal`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { $this->bodies = array(); while( $row = mysql_fetch_array($res) ) { $this->bodies[ $row['BodyCode'] ]['BodyCategoryOrder'] = $row['BodyCategoryOrder']; $this->bodies[ $row['BodyCode'] ]['Fee'] = $row['Fee']; } return true; }else { return false; } } } } ?>