. */ class CandSex extends Cand { public function __construct($candidate_id) { $this->candidate_id = $candidate_id; $this->name = "Sex"; $this->compulsory = true; } public function get_print_name() { return "Gender"; } public function get_print_name_short() { return "Gender"; } public function get_print_value($readonly=false) { if( $readonly ) $d="disabled=\"disabled\""; else $d=""; $r = "name."_male\" name=\"".$this->name."\" value=\"male\" $d"; if( $this->value=="male" ) $r .= " checked=\"checked\""; $r .= ">   name."_female\" name=\"".$this->name."\" value=\"female\" $d"; if( $this->value=="female" ) $r .= " checked=\"checked\""; $r .= ">"; return $r; } public function set($value) { if( $value!="male" AND $value!="female" ) { // Error $this->error = true; $this->error_txt = "The gender is invalid"; return false; }else { $this->value = $value; return true; } } /* The default access for a field is that 'admin', 'chair', 'localorg' and 'edit' people can edit the field, as well as a logged in user. * Users with only 'view' can only view the field, and all others are denied access * Override this function if you want different access */ public function get_access($new=true) { if( isset($_SESSION['sess_functions']) && in_array("candidate_edit", $_SESSION['sess_functions']) ) return self::ACCESS_RW; elseif( isset($_SESSION['sess_functions']) && in_array("candidate_viewlist", $_SESSION['sess_functions']) ) return self::ACCESS_R; elseif( is_anon() && $new ) return self::ACCESS_RW; elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] && $new && !$this->set($this->value) ) return self::ACCESS_RW; elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] ) return self::ACCESS_R; else return self::ACCESS_NO; } /* Normally a field is saved to MySQL. If you don't want to save it, or want to do something else before data is saved, override this function. * Make sure you return an array (can be empty) */ public function get_sql($new=true) { // Return when making new application or when there is write access if( $this->get_access($new)==Cand::ACCESS_RW OR $new ) return array($this->name => $this->value); else return array(); } public function get_accesspublic() { return true; } } ?>