. */ class ApplJoinStatutory extends Appl { /* Constructor * Make sure you set the name, and, when needed, if the field is * compulsory */ public function __construct($appl_id) { $this->appl_id = $appl_id; $this->name = "JoinStatutory"; $this->compulsory = true; $this->value = true; } /* get_print_name() * Return the name of the field (caption) to be shown in the application * form */ public function get_print_name() { global $setup; return "Participation ".$setup['SetupEventType']; } /* get_print_name_short() * Return the name of the field (caption) to be shown in a table */ public function get_print_name_short() { global $setup; return $setup['SetupEventType']; } /* get_print_value($readonly) * Return the value to be printed in the form (with text boxes etc) * @param: readonly: if the field can be changed (false) or not (true) */ public function get_print_value($readonly=false) { global $setup; $r = "name."\" name=\"".$this->name."\""; if( $this->value ) $r .= " checked=\"checked\""; if( $readonly ) $r .= " readonly=\"readonly\""; $r .= " />"; return $r; } /* set($value) * Check the supplied value and assign it if ok (return true), otherwise * set an error and return false * @param: value: the value to be assigned and checked * @return: true on ok, false on error */ public function set($value) { global $setup; if( $value!=true ) { // Error $this->error = true; $this->error_txt = "If you do not want to participate in this ".$setup['SetupEventType']." there is no reason to fill in this form"; return false; }else { $this->value = $value; return true; } } public function init($value) { $this->value = ($value=="yes"); $this->oldvalue = ($value=="yes"); } public function check() { global $setup; $this->value = isset($_POST[ $this->name ]); if( !isset($_POST[ $this->name ]) ) { $this->error = true; $this->error_txt = "If you do not want to participate in this ".$setup['SetupEventType']." there is no reason to fill in this form"; return false; }else { return true; } } /* get() * Return the value of this field. * Normally the plain value is returned, if you need different behaviour, * override this function */ public function get($oldvalue=false) { if( $oldvalue ) { if( $this->oldvalue ) return "Yes"; else return "No"; }else { if( $this->value ) return "Yes"; else return "No"; } } /* 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_participateedit", $_SESSION['sess_functions']) ) return self::ACCESS_RW; elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_participateview", $_SESSION['sess_functions']) ) return self::ACCESS_R; elseif( is_before("EventDateAppEndReal") && is_anon() && $new ) return self::ACCESS_RW; elseif( is_before("EventDateAppEndReal") && isset($_SESSION['access_user']) && $_SESSION['access_user'] ) return self::ACCESS_RW; elseif( !is_before("EventDateAppEndReal") && is_anon() && $new ) return self::ACCESS_R; elseif( !is_before("EventDateAppEndReal") && 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) { if( $this->get_access($new)==Appl::ACCESS_RW AND $this->value ) return array($this->name => "yes"); elseif( $this->get_access($new)==Appl::ACCESS_RW AND !$this->value ) return array($this->name => "no"); else return array(); } } ?>