.
*/
class ApplVisa extends Appl {
public function __construct($appl_id) {
$this->appl_id = $appl_id;
$this->name = "Visa";
$this->compulsory = true;
}
public function get_print_name() {
return "Visa invitation needed";
}
public function get_print_name_short() {
return "Visa";
}
public function get_print_value($readonly=false) {
if( $readonly ) $d="disabled=\"disabled\""; else $d="";
$r = "name."_yes\" name=\"".$this->name."\" value=\"yes\" $d";
if( $this->value=="yes" ) $r .= " checked=\"checked\"";
$r .= " /> name."_no\" name=\"".$this->name."\" value=\"no\" $d";
if( $this->value=="no" ) $r .= " checked=\"checked\"";
$r .= " />";
if( $readonly )
$r .= " The deadline for visas has passed. Applying when you need a visa is not possible any more.";
else
$r .= " If yes: Please provide postal address, nationality and passport number!";
return $r;
}
public function get($oldvalue=false) {
if( $oldvalue ) return ucwords($this->oldvalue);
return ucwords($this->value);
}
public function set($value) {
if( $value!="yes" AND $value!="no" ) {
// Error
$this->error = true;
$this->error_txt = "You did not fill in if you need a visa.";
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_visaedit", $_SESSION['sess_functions']) ) return self::ACCESS_RW;
elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_visaview", $_SESSION['sess_functions']) ) return self::ACCESS_R;
elseif( is_before("EventDateAppEndVisa") && is_anon() AND $new ) return self::ACCESS_RW;
elseif( is_before("EventDateAppEndVisa") && isset($_SESSION['access_user']) && $_SESSION['access_user'] ) return self::ACCESS_RW;
elseif( !is_before("EventDateAppEndVisa") && is_anon() AND $new ) { $this->value="no"; return self::ACCESS_R; }
elseif( !is_before("EventDateAppEndVisa") && isset($_SESSION['access_user']) && $_SESSION['access_user'] ) { $this->value="no"; 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() {
// return array();
//}
}
?>