. */ class PersonsWorkshopSelectID2 extends Persons { private $workshops; /* Constructor * Make sure you set the name, and, when needed, if the field is * compulsory */ public function __construct($dummy=0) { $this->name = "WorkshopSelectID2"; } /* get_print_name() * Return the name of the field (caption) to be shown in the application * form */ public function get_print_name() { return "2nd workshop choice"; } /* get_print_name_short() * Return the name of the field (caption) to be shown in a table */ public function get_print_name_short() { return "2nd workshop"; } /* 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($dummy=0) { global $setup; if( $setup['SetupWSNumber']==0 ) return self::ACCESS_NO; elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_workshopedit", $_SESSION['sess_functions']) ) return self::ACCESS_RW; elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_workshopview", $_SESSION['sess_functions']) ) return self::ACCESS_R; else return self::ACCESS_NO; } public function display($value, $PersonID=0, &$allvalues="") { if( !is_array($this->workshops) ) { $this->workshops = array(); $this->workshops[0] = ""; $query = "SELECT `id`, `title` FROM `workshops`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row=mysql_fetch_array($res) ) { $this->workshops[ $row['id'] ] = $row['title']; } }else { debug("Failed loading workshops"); return $value; } } if( $matches = preg_split("/;/", $value) ) { $r = ""; if( $matches[0]==$matches[1] ) $r .= ""; if( array_key_exists($matches[0], $this->workshops) ) $r .= $this->workshops[ $matches[0] ]; else $r .= $matches[0]; if( $matches[0]==$matches[1] ) $r .= ""; $r .= ""; return $r; }else { return "error"; } } public function sql_columnname() { return "CONCAT(`persons`.`WorkshopID2`, ';', `persons`.`WorkshopIDSlot1`) AS `WorkshopSelectID2`"; } public function is_sqlcolumn() { return false; } public function displayoptions($personId=0) { return " id=\"WorkshopSelectID2_".$personId."\""; } } ?>