.
*/
if( !isset($candidate_id) ) {
exit();
}
include("./include/Cand.php");
include("./include/CandidateUI.php");
include("./include/CandidateMail.php");
$candidateStatus = candidate_status($Position);
if( $setup['CandidateAdminOpen']==false ) {
// Candidatures locked by admin
echoln("The candidatures have been locked by the webmaster, as it is not ready to be used yet.");
echoln("
Before the candidatures can open, the Juridical Commission has to finalize the setup first, please be a bit patient.");
}elseif( $candidate_id == 0 && !is_before("CandidateEndReal") ) {
// Candidatures deadline passed
echoln("The candidature deadline passed, you cannot candidate any more.");
echoln("
The deadline to candidate for any position was on ".$setup['CandidateEndReal'].". For next time you are suggested to candidate well before the deadline.");
}elseif( $candidate_id == 0 && $candidateStatus != "open" ) {
if( $candidateStatus == "closed" ) {
echoln("The candidature deadline passed, you cannot candidate any more.");
echoln("
The deadline to candidate for any position was on ".$setup['CandidateDeadline'].". After this date, only candidatures are possible for positions where there are not enough candidates yet. For next time you are suggested to candidate well before the deadline.");
}else {
echoln("Candidating for this position is temporally closed.");
echoln("
The deadline to candidate for any position was on ".$setup['CandidateDeadline'].". After this date, only candidatures are possible for positions where there are not enough candidates yet. For this position, there are enough candidatures, but they are not all approved yet. In case some are rejected, candidating for this position will open again.");
}
}else {
// Read extra questions
$extraQuestions = array();
$query = "SELECT `id`, `question`, `maxlength` FROM `cand_extraquestions` WHERE `candidatepost_id` = " . addslashes($Position) . " ORDER BY `order`";
if( @mysql_num_rows( $res=doquery($query) )>0 ) {
while( $row = mysql_fetch_assoc($res) ) {
$extraQuestions[$row['id']] = $row;
}
}
if( $candidate_id > 0 ) {
$query = "SELECT `question_id`, `answer` FROM `cand_extraanswers` WHERE `cand_id` = " . addslashes($candidate_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 candidature form fields");
}
// Load the values from MySQL in case we are editing
$values = array();
if( $candidate_id>0 ) {
$query="SELECT * FROM `candidates` WHERE `id`=".addslashes($candidate_id);
if( @mysql_num_rows( $res=doquery($query) )==1 ) {
$values = mysql_fetch_assoc($res);
}else {
echoln("Failed loading your candidature. Editing not possible. Switching back to a new candidature.
");
$candidate_id=0;
}
}
// Create user interface
$ui = new CandidateUI($candidate_id, $Position);
// Create the classes, add a value (from aegee.org account (new) or from MySQL (edit))
$person = array();
for( $i=0; $i ");
$_SERVER['REQUEST_METHOD']="GET";
}else {
########################
### Form OK, save it ###
########################
$data = array();
$candvalues = array();
$candvalues['old']['username'] = (isset($values['username']) ? $values['username'] : "");
$candvalues['old']['Approved'] = (isset($values['Approved']) ? $values['Approved'] : "");
for( $i=0; $i ");
flush();
$postSaveResult = true;
for( $i=0; $i ... ready ");
echoln("Your candidature has been processed. If you want to edit your candidature, come back to this page and log in with your ".$ldap->getSystemName()." account.");
if( is_anon() || (isset($_SESSION['access_user']) && $_SESSION['access_user']) ) echoln(" Back");
else echoln(" Close window");
}else {
echoln("Failed saving your candidature.");
$_SERVER['REQUEST_METHOD']="GET";
}
#debug(nl2br(strtr(print_r($candvalues, true), array(" " => " "))));
#debug(nl2br(strtr(print_r($data, true), array(" " => " "))));
#debug($query);
}
}
#################
### Show form ###
#################
if( $_SERVER['REQUEST_METHOD']=="GET" OR isset($_REQUEST['login']) ) {
// Show the form
echoln($ui->Open(true));
for( $i=0; $i");
if( $error_duplicate ) {
echoln("
");
}
if( $candidate_id==0 ) $cand_mail = new CandidateMail($candvalues['old'], $candvalues['new'], true, getinsertid());
else $cand_mail = new CandidateMail($candvalues['old'], $candvalues['new'], false, $candidate_id);
$cand_mail->Send();
echoln("
Your candidature has been saved successfully.");
echoln("