. */ require_once("./include/csn_check.php"); class ApplCSN extends Appl { private $error_priv; public function __construct($appl_id) { $this->appl_id = $appl_id; $this->name = "CSN"; $this->compulsory = true; } public function get_print_name() { return "CSN (card serial number)"; } public function get_print_name_short() { return "CSN"; } public function get_print_value($readonly=false) { if( $this->value!="-" ) $value = $this->value; else $value = ""; $r = "name."1\" value=\"".substr($value, 0, 6)."\" size=\"6\" maxlength=\"6\""; if( $readonly ) $r .= " disabled=\"disabled\""; $r .= " /> - name."2\" value=\"".substr($value, 7, 6)."\" size=\"6\" maxlength=\"6\""; if( $readonly ) $r .= " disabled=\"disabled\""; $r .= " />
This number is printed on your AEGEE membership card."; if( $this->error ) $r .= "name."_error\" value=\"true\" />"; return $r; } public function set($value) { if( CSN_check($value)!="ok" ) { // Error if( $_SERVER['REQUEST_METHOD']=="POST" ) $this->error = true; $this->error_txt = "The CSN is not valid."; if( strlen($value)==1 ) { // Empty CSN $this->error_txt .= " In case you don't have a membership card, ask your local board for one, this will fasten your application. Submitting again "; $this->error_txt .= "without CSN filled in will be accepted (but is not appreciated)"; if( $this->error_priv ) return true; }else { // Something filled in } return false; }else { $this->value = $value; return true; } } public function check() { $this->error = false; if( $_POST[ $this->name."_error" ]=="true" ) $this->error_priv = true; else $this->error_priv = false; $this->value = strtoupper($_POST[ $this->name."1" ]."-".$_POST[ $this->name."2" ]); 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) { global $setup; if( $setup['ApplShowCSN']==false ) return self::ACCESS_NO; elseif( $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 ) return self::ACCESS_RW; elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] AND !$new ) 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)==Appl::ACCESS_RW ) return array($this->name => $this->value); else return array(); } } ?>