. */ require_once("./include/numparticipants_func.php"); class ApplBodyCode extends Appl { private $bodies; public function __construct($appl_id) { $this->appl_id = $appl_id; $this->name = "BodyCode"; $this->compulsory = true; $this->bodies = false; } public function get_print_name() { return "Body name"; } public function get_print_name_short() { return "Body name"; } public function get_print_value($readonly=false) { $r = ""; if( $readonly ) $r .= "
To change your body, please contact the organizers OR the chair team."; return $r; } public function set($value) { $query="SELECT `BodyCode`, `BodyCategoryOrder`, `BodyStatus`, `NoDelegates`, `NoEnvoys`, `NoVisitors`, `NoObservers` FROM `ab_bodies` WHERE `BodyCode`='".addslashes($value)."'"; if( $row=@mysql_fetch_array( doquery($query) ) ) { if( $row['BodyCode']==$value ) { $nums = getParticipantNum($row); if( ($nums['NoDelegates'] + $nums['NoEnvoys'] + $nums['NoVisitors'] + $nums['NoObservers'])>0 ) { $this->value = $value; return true; }else { // This body does not have any place $this->error = true; $this->error_txt = "The body name specified is not valid. Make sure you select one from the list.\n"; return false; } }else { // Body not in database $this->error = true; $this->error_txt = "The body name specified is not valid. Make sure you select one from the list.\n"; return false; } }else { // Query error $this->error = true; $this->error_txt = "The body name specified is not valid. Make sure you select one from the list.\n"; return false; } } public function get($oldvalue=false) { $query="SELECT `BodyName` FROM `ab_bodies` "; if( $oldvalue ) $query .= "WHERE `BodyCode`='".addslashes($this->oldvalue)."'"; else $query .= "WHERE `BodyCode`='".addslashes($this->value)."'"; if( $row=@mysql_fetch_array( doquery($query) ) ) { return $row['BodyName']; }else { return "!ERROR!"; } } public function get_access($new=true) { if( $this->access>=0 ) return $this->access; elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_bodyedit", $_SESSION['sess_functions']) ) return self::ACCESS_RW; elseif( isset($_SESSION['sess_functions']) && in_array("applicationfield_bodyview", $_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; } public function get_sql($new=true) { if( $this->get_access($new)==Appl::ACCESS_RW ) { if( $this->oldvalue!=$this->value ) return array($this->name => $this->value, "ParticipantType" => "-"); else return array($this->name => $this->value); }elseif( $new ) { return array($this->name => $this->value); }else { return array(); } } public function display($value, $ApplicationID=0, &$allvalues="") { if( !is_array($this->bodies) ) { $this->bodies = array(); $query = "SELECT `BodyCode`, `BodyName` FROM `ab_bodies`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row=mysql_fetch_array($res) ) { $this->bodies[ $row['BodyCode'] ] = $row['BodyName']; } }else { debug("Failed loading bodies"); return $value; } } if( array_key_exists($value, $this->bodies) ) return $this->bodies[$value]; else return $value; } } ?>