.
*/
class ApplSex extends Appl {
public function __construct($appl_id) {
$this->appl_id = $appl_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( $this->access>=0 ) return $this->access;
elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_personaledit", $_SESSION['sess_functions']) ) return self::ACCESS_RW;
elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_personalview", $_SESSION['sess_functions']) ) return self::ACCESS_R;
elseif( is_anon() AND $new ) return self::ACCESS_RW;
elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] AND $new AND !$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;
}
public function get_sql($new=true) {
// Return when making new application or when there is write access
if( $this->get_access($new)==Appl::ACCESS_RW OR $new ) return array($this->name => $this->value);
else return array();
}
}
?>