. */ class CandPosition extends Cand { public function __construct($candidate_id) { $this->candidate_id = $candidate_id; $this->name = "Position"; $this->compulsory = true; } public function get_print_name() { return "Position"; } public function get_print_name_short() { return "Position"; } public function get_print_value($readonly=false) { $r = ""; $r .= "
You can only select a position which is still open."; if( $readonly ) $r .= "
You cannot change position, write a new candidature for a new position."; return $r; } public function init($value) { $this->value = $value; $this->oldvalue = $value; return true; } public function set($value) { $posts = $this->get_openpositions(); if( isset($posts[$value]) ) { $this->value = $value; return true; }else { $this->error = true; $this->error_txt = "The position specified is not valid. Make sure you select one from the list.\n"; return false; } } public function get($oldvalue=false) { $query="SELECT `position` FROM `candidatepost` "; if( $oldvalue ) $query .= "WHERE `id`=".addslashes($this->oldvalue); else $query .= "WHERE `id`=".addslashes($this->value); if( $row=@mysql_fetch_array( doquery($query) ) ) { return $row['position']; }else { return "!ERROR!"; } } public function get_access($new=true) { if( isset($_SESSION['sess_functions']) && in_array("candidate_edit", $_SESSION['sess_functions']) ) return self::ACCESS_R; elseif( isset($_SESSION['sess_functions']) && in_array("candidate_viewdetail", $_SESSION['sess_functions']) ) return self::ACCESS_R; elseif( is_anon() && $new ) return self::ACCESS_RW; elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] && $new ) return self::ACCESS_RW; elseif( isset($_SESSION['access_user']) && $_SESSION['access_user'] && !$new ) return self::ACCESS_R; else return self::ACCESS_NO; } public function get_id() { return $this->value; } private function get_positions() { global $setup; $query = "SELECT `id`, `position`, `places` FROM `candidatepost` ORDER BY `position`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { $r = array(); while( $row = mysql_fetch_array($res) ) { $r[ $row['id'] ] = $row['position']; } return $r; }else { echoln("Could not find any position.

"); } return false; } private function get_openpositions() { global $setup; $query = "SELECT `id`, `position` FROM `candidatepost` WHERE `deadline`!='closed' ORDER BY `position`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { $r = array(); while( $row = mysql_fetch_array($res) ) { if( candidate_status($row['id'])=="open" ) { $r[ $row['id'] ] = $row['position']; } } return $r; }else { echoln("Could not find any position.

"); } return false; } } ?>