-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdo_candidate.php
67 lines (50 loc) · 2.06 KB
/
do_candidate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php /*
Copyright 2015 Cédric Levieux, Parti Pirate
This file is part of Congressus.
Congressus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Congressus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Congressus. If not, see <http://www.gnu.org/licenses/>.
*/
include_once("config/database.php");
require_once("engine/utils/FormUtils.php");
require_once("engine/bo/CandidateQuestionBo.php");
require_once("engine/bo/CandidateAnswerBo.php");
require_once("engine/utils/SessionUtils.php");
//require_once("engine/utils/LogUtils.php");
session_start();
if (SessionUtils::getUserId($_SESSION)) {
// We sanitize the request fields
xssCleanArray($_REQUEST);
$connection = openConnection();
$candidateId = $_REQUEST["cas_candidature_id"];
$candidateQuestionBo = CandidateQuestionBo::newInstance($connection, $config);
$candidateAnswerBo = CandidateAnswerBo::newInstance($connection, $config);
$candidateQuestions = $candidateQuestionBo->getByFilters(array("cas_candidature_id" => $_REQUEST["cas_candidature_id"]));
//$answers = array();
// Foreach on question-ID
foreach($candidateQuestions as $question) {
$answer = array();
$answer["cas_candidature_id"] = $candidateId;
$answer["cas_question_id"] = $question["cqu_id"];
$answer["cas_id"] = $question["cas_id"];
$answer["cas_answer"] = $_REQUEST["question-" . $question["cqu_id"]];
// $answers[] = $answer;
$candidateAnswerBo->save($answer);
}
}
if (isset($_REQUEST["ajax"])) {
$data = array();
$data["ok"] = "ok";
echo json_encode($data);
}
else {
header('Location: candidate.php?id=' . $_REQUEST["cas_candidature_id"]);
}
?>