. */ include("./include/include.php"); include("./include/Cand.php"); include("./include/CandidateUI.php"); require_once("./include/Popup.php"); define("POPUP_HEIGHT", 600); define("POPUP_WIDTH", 550); define("POPUP_TOP", 50); define("POPUP_TITLE", "View all candidate data"); if( !in_array("candidate_viewdetail", $_SESSION['sess_functions']) ) { $popup = new Popup(POPUP_TITLE, "You are not authorized to see this page."); $popup->setHeight(POPUP_HEIGHT)->setWidth(POPUP_WIDTH)->setTop(POPUP_TOP); echo $popup->createPopup(); }else { $content = ""; // Load the values from MySQL in case we are editing $values = array(); $query="SELECT * FROM `candidates` WHERE `id`=".addslashes(get_int('id')); if( @mysql_num_rows( $res=doquery($query) )==1 ) { $values = mysql_fetch_array($res); }else { $content .= "

Failed loading candidature. Editing not possible.

"; } // Read extra questions $extraQuestions = array(); $query = "SELECT `id`, `question`, `maxlength` FROM `cand_extraquestions` WHERE `candidatepost_id` = " . addslashes($values['Position']) . " ORDER BY `order`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { while( $row = mysql_fetch_assoc($res) ) { $extraQuestions[$row['id']] = $row; } } if( get_int('id') > 0 ) { $query = "SELECT `question_id`, `answer` FROM `cand_extraanswers` WHERE `cand_id` = " . addslashes(get_int('id')); if( @mysql_num_rows( $res=doquery($query) )>0 ) { $extraAnswers = array(); while( $row = mysql_fetch_assoc($res) ) { $extraAnswers[$row['question_id']] = $row['answer']; } } } // Read the files from ./include/CandFields/*.php and add them to $fields; $fields = array(); $sepfields = array(); // All fields including separators $dir = dirname($_SERVER["SCRIPT_FILENAME"])."/include/CandFields/*.php"; if( is_dir(dirname($dir)) ) { foreach( glob($dir) as $file ) { if( is_file($file) ) { $field = substr(basename($file, ".php"), 3); if( $field != "Separator" ) { include($file); if( $field == "ExtraQuestion" ) { foreach( array_keys($extraQuestions) as $questionId ) { $fields[] = $field . "_" . $questionId; } }else { $fields[] = $field; } } if( $field == "ExtraQuestion" ) { foreach( array_keys($extraQuestions) as $questionId ) { $sepfields[] = $field . "_" . $questionId; } }else { $sepfields[] = $field; } } } }else { debug(dirname($dir)." does not exist, failed loading application form fields"); } // Create user interface $ui = new CandidateUI(get_int('id'), $values['Position']); // Create the classes, add a value from MySQL $person = array(); for( $i=0; $iinit($extraAnswers[$questionId]); } }else { $class="Cand".$fields[$i]; $person[ $fields[$i] ] = new $class(get_int('id')); if( isset($values[ $fields[$i] ]) ) $person[ $fields[$i] ]->init($values[ $fields[$i] ]); } } ### Show form ### $content .= $ui->Open(); $content .= $ui->Add("Created", get_date($values['Created'])); $content .= $ui->Add("Modified", get_date($values['Modified'])); $content .= $ui->Add("Account", $values['username']); $content .= $ui->Add("Approved", $values['Approved']); $content .= $ui->Separator(); for( $i=0; $iSeparator(); }else { if( $person[ $sepfields[$i] ]->get_access( false )!=Cand::ACCESS_NO ) { // Show field $content .= $ui->Add( $person[ $sepfields[$i] ]->get_print_name(), $person[ $sepfields[$i] ]->get(), false, $person[ $sepfields[$i] ]->get_compulsory()); } } } $content .= $ui->Close(); $content .= "Close window"; $popup = new Popup(POPUP_TITLE, $content); $popup->setHeight(POPUP_HEIGHT)->setWidth(POPUP_WIDTH)->setTop(POPUP_TOP); echo $popup->createPopup(); } ?>