. */ class ApplPassportExpirationDate extends Appl { public function __construct($appl_id) { $this->appl_id = $appl_id; $this->name = "PassportExpirationDate"; $this->compulsory = false; } public function get_print_name() { return "Passport expiration date"; } public function get_print_name_short() { return "Passport expiration date"; } public function get_print_value($readonly=false) { return show_date($this->name, $this->value, !$readonly, 1, 31, 1, 12, date("Y"), date("Y")+20, false, true); } public function get($oldvalue=false) { if( $oldvalue ) return date("d.m.Y", strtotime($this->oldvalue)); else return date("d.m.Y", strtotime($this->value)); } public function set($value) { if( (isset($_POST['Visa']) && $_POST['Visa']=="yes") ) $this->compulsory = true; if( preg_match("/(^(\d){4}-(\d){2}-(\d){2}$)/", $value) && ((!$this->compulsory && $value=="0000-00-00") || checkdate(substr($value, 5, 2), substr($value, 8, 2), substr($value, 0, 4))) ) { // OK $this->value = $value; return true; }else { // Error if( $_SERVER['REQUEST_METHOD']=="POST" ) $this->error = true; $this->error_txt = "The passport issuing date is invalid"; return false; } } public function check() { $this->error = false; $this->value = $_POST[$this->name."_year"]."-".$_POST[$this->name."_month"]."-".$_POST[$this->name."_day"]; return $this->set( $this->value ); } /* 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'] ) { $this->access = self::ACCESS_RW; return self::ACCESS_RW; } else return self::ACCESS_NO; } public function display($value, $PersonID=0, &$allvalues="") { return date("d.m.Y", strtotime($value)); } } ?>