Example #1
0
								<?php 
                    if (isset($users[$userId][$correspondance['mail']])) {
                        echo $users[$userId][$correspondance['mail']];
                    }
                    ?>
							</td>
							<td>
								<?php 
                    if (isset($users[$userId][$correspondance['nbEtu']])) {
                        echo $users[$userId][$correspondance['nbEtu']];
                    }
                    ?>
							</td>
							<td>
								<?php 
                    if (isset($users[$userId][$correspondance['promotion']]) && count(checkPromotion($users[$userId][$correspondance['promotion']], array())) == 0) {
                        echo getPromotionData($users[$userId][$correspondance['promotion']])['nom'];
                    }
                    ?>
							</td>
							<td>
								<?php 
                    if (isset($users[$userId][$correspondance['rang']]) && defined('LANG_RANG_VALUE_' . $users[$userId][$correspondance['rang']])) {
                        echo constant('LANG_RANG_VALUE_' . $users[$userId][$correspondance['rang']]);
                    }
                    ?>
							</td>
							<td><?php 
                    displayErreur($userErreur);
                    ?>
</td>
Example #2
0
/**
 * checkUserInsertData - Vérifie la validité des données d'ajout d'un profil utilisateur
 *
 * @category : checkFunction
 * @param array $userData( Données utilisateur à tester
 * @param array $erreur Array contenant la liste des erreurs rencontrées avant execution de la fonction.
 * @return array Array contenant la liste des erreurs rencontrées après execution de la fonction
 *
 * @Author Ali Bellamine
 *	 
 *  $userData : <br>
 *		"nom" => (string) nom de l'utilisateur<br>
 *		"mail" => (array) liste des adresses email de l'utilisateur<br>
 *		"nbEtu" => (string) numéro d'étudiant de l'utilisateur<br>
 *		"rang" => (int) rang de l'utilisateur, compris entre 1 (étudiant) et 2 (invités)
 */
function checkUserInsertData($userData, $erreur)
{
    // On vérifie que les champs obligatoires ont été remplis
    $required = array('nom', 'mail', 'nbEtu', 'rang');
    foreach ($required as $requiredName) {
        if (!isset($userData[$requiredName]) || $userData[$requiredName] == '') {
            $erreur[26] = TRUE;
        }
    }
    // On vérifie si l'utilisateur existe déjà
    if (count(checkUser(getUserIdFromNbEtudiant($userData['nbEtu']), array())) == 0) {
        $erreur['exist'] = TRUE;
    }
    // On récupère les infos sur la promotion
    if (isset($userData['promotion']) && count(checkPromotion($userData['promotion'], array())) != 0) {
        $erreur = checkPromotion($userData['promotion'], $erreur);
    }
    // On vérifie les mails
    if (isset($userData['mail']) && is_array($userData['mail'])) {
        foreach ($userData['mail'] as $email) {
            if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                $erreur[19] = TRUE;
            }
        }
    } else {
        $erreur[19] = TRUE;
    }
    // On vérifie le rang
    if (isset($userData['rang']) && $userData['rang'] != 1 && $userData['rang'] != 2) {
        $erreur[28] = TRUE;
    }
    return $erreur;
}
Example #3
0
    function process_move($ConfigFile, $player_id, $gid, $move)
    {
        if ($gid == "" || $move == "") {
            return "F" . $this->zero_pad($player_id, 8) . $move;
        }
        // TODO, do timeout check for this game.
        $move_stat = "F";
        $next_color = "b";
        $other_player;
        if ($this->check_move($move)) {
            //include config file
            include $ConfigFile;
            // connect to mysql and open database
            $db_my = mysql_connect($conf['database_host'], $conf['database_login'], $conf['database_pass']) or die("Couldn't connect to the database.");
            @mysql_select_db($conf['database_name']) or die("Unable to select database");
            $sti = "SELECT w_player_id, b_player_id, next_move, w_time_used, b_time_used, start_time FROM game WHERE game_id='" . $gid . "'";
            $stireturn = mysql_query($sti) or die(mysql_error());
            $stinum = mysql_numrows($stireturn);
            if ($stinum != 0) {
                if ($player_id == mysql_result($stireturn, 0, "w_player_id")) {
                    $next_color = "b";
                    $other_player = mysql_result($stireturn, 0, "b_player_id");
                } else {
                    $next_color = "w";
                    $other_player = mysql_result($stireturn, 0, "w_player_id");
                }
                $w_time_used = (int) mysql_result($stireturn, 0, 'w_time_used');
                $b_time_used = (int) mysql_result($stireturn, 0, 'b_time_used');
                $start_time = (int) mysql_result($stireturn, 0, 'start_time');
                //castling
                if ($move2 = checkCastling($move, $gid, $ConfigFile)) {
                    $st = "INSERT INTO move_history(game_id,player_id,move,time) VALUES('" . $gid . "'," . $player_id . ",'" . $move2 . "'," . time() . ")";
                    mysql_query($st) or die(mysql_error());
                } elseif ($move2 = checkPromotion($move)) {
                    $st = "INSERT INTO move_history(game_id,player_id,move,time) VALUES('" . $gid . "'," . $player_id . ",'" . $move2 . "'," . time() . ")";
                    mysql_query($st) or die(mysql_error());
                } elseif ($move2 = checkEnpassent($move)) {
                    $st = "INSERT INTO move_history(game_id,player_id,move,time) VALUES('" . $gid . "'," . $player_id . ",'" . $move2 . "'," . time() . ")";
                    mysql_query($st) or die(mysql_error());
                } else {
                    $st = "INSERT INTO move_history(game_id,player_id,move,time) VALUES('" . $gid . "'," . $player_id . ",'" . $move . "'," . time() . ")";
                    mysql_query($st) or die(mysql_error());
                }
                // Get the game timing mode in use, along with any time controls
                //$query = "SELECT * FROM cfm_game_options WHERE o_gameid='" . $gid . "'";
                $query = <<<qq
SELECT cfm_game_options.*, timed_games.moves1, timed_games.time1, timed_games.moves2, timed_games.time2
FROM cfm_game_options
LEFT JOIN timed_games ON cfm_game_options.o_gameid = timed_games.id
WHERE o_gameid = '{$gid}'
qq;
                $return = mysql_query($query) or die(mysql_error());
                $num = mysql_numrows($return);
                $timing_mode = (int) mysql_result($return, 0, "time_mode");
                $m1 = (int) @mysql_result($return, $i, 'moves1');
                $m2 = (int) @mysql_result($return, $i, 'moves2');
                $t1 = (int) @mysql_result($return, $i, 'time1') * 60;
                $t2 = (int) @mysql_result($return, $i, 'time2') * 60;
                //$timing_type = mysql_result($return, 0, "o_timetype");
                $game_update = array();
                if ($timing_mode == 1) {
                    $now = time();
                    //$timetype = substr(trim(strtolower($timing_type)), 2);
                    // If time controls are used, get the number of moves to work out which time control
                    // applies. If a time control has been reached, remove the required time to the player's
                    // 'used' time.
                    if ($m1) {
                        $query = "SELECT count(*) as `count` FROM move_history WHERE game_id = '{$gid}' AND player_id = {$player_id}";
                        $return = mysql_query($query) or die(mysql_error());
                        $move_cnt = mysql_result($return, 0, 'count');
                        if ($move_cnt == $m1) {
                            if ($next_color == 'b') {
                                $w_time_used -= $t1;
                            } elseif ($next_color == 'w') {
                                $b_time_used -= $t1;
                            }
                        } elseif ($move_cnt > $m1) {
                            if (($move_cnt - $m1) % $m2 == 0) {
                                if ($next_color == 'b') {
                                    $w_time_used -= $t2;
                                } elseif ($next_color == 'w') {
                                    $b_time_used -= $t2;
                                }
                            }
                        }
                    }
                    // Get the 2nd last move's time. Subtract the move's time from the current time to work
                    // out how long it took the player to make this move. The first move made doesn't
                    // attract any time usage.
                    $query = "SELECT `time` FROM move_history WHERE game_id = '{$gid}' ORDER BY `time` DESC LIMIT 1,1";
                    $return = mysql_query($query) or die(mysql_error());
                    $num = mysql_numrows($return);
                    if ($num != 0) {
                        $last_move_time = (int) trim(mysql_result($return, 0, "time"));
                    } else {
                        $last_move_time = $now;
                        $game_update[] = "start_time = {$now}";
                    }
                    $diff = $now - $last_move_time;
                    if ($next_color == 'w') {
                        $game_update[] = "b_time_used=" . ($b_time_used + $diff);
                    } else {
                        $game_update[] = "w_time_used=" . ($w_time_used + $diff);
                    }
                }
                $game_update[] = "next_move='{$next_color}'";
                $game_update = implode(', ', $game_update);
                $st = "UPDATE game SET {$game_update} WHERE game_id='" . $gid . "'";
                //echo "run $st";
                //exit();
                mysql_query($st) or die(mysql_error());
                $st = "INSERT INTO message_queue(player_id, message, posted) VALUES(" . $other_player . ",'" . $this->add_header("M", $move_stat . $this->zero_pad($player_id, 8) . $gid . $move, "0") . "'," . time() . ")";
                mysql_query($st) or die(mysql_error());
                //////////////////////////////////////////////
                //Instantiate theCR3DCQuery Class
                $oR3DCQuery = new CR3DCQuery($this->ChessCFGFileLocation);
                $isblack = $oR3DCQuery->IsPlayerBlack($this->ChessCFGFileLocation, $gid, $other_player);
                $isrealtime = $oR3DCQuery->IsRequestRealTime($this->ChessCFGFileLocation, $gid, $isblack);
                if ($oR3DCQuery->MoveNotification($other_player) == true && $isrealtime != "IDS_REAL_TIME") {
                    $requestorname = $oR3DCQuery->GetUserIDByPlayerID($this->ChessCFGFileLocation, $player_id);
                    $otherguysname = $oR3DCQuery->GetUserIDByPlayerID($this->ChessCFGFileLocation, $other_player);
                    $otheremail = $oR3DCQuery->GetEmailByPlayerID($this->ChessCFGFileLocation, $other_player);
                    $subject = $this->GetStringFromStringTable("IDS_CR3DCQUERY_EMAIL_TVST_17", $ConfigFile);
                    $aTags1 = array("['otherguysname']", "['requestorname']", "['gid']", "['move']", "['siteurl']", "['sitename']");
                    $aReplaceTags1 = array($otherguysname, $requestorname, $gid, $move, $this->TrimRSlash($conf['site_url']), $conf['site_name']);
                    $bodyp1 = str_replace($aTags1, $aReplaceTags1, $this->GetStringFromStringTable("IDS_CR3DCQUERY_EMAIL_TVST_18", $ConfigFile));
                    $this->SendEmail($otheremail, $conf['registration_email'], $conf['site_name'], $subject, $bodyp1);
                }
                unset($oR3DCQuery);
                //////////////////////////////////////////////
                //////////////////////////////////////////////
                //Check if the king was killed
                //////////////////////////////////////////////
                $FEN = $this->request_FEN($this->ChessCFGFileLocation, $gid);
                $Moves = "";
                $RestOfSentence = "";
                list($Moves, $RestOfSentence) = preg_split("/ /", $FEN);
                $nwhitek = strpos($Moves, 'k');
                if ($nwhitek === false) {
                    $st = "UPDATE game SET status='C', completion_status='B' WHERE game_id='" . $gid . "'";
                    mysql_query($st) or die(mysql_error());
                }
                $nblackk = strpos($Moves, 'K');
                if ($nblackk === false) {
                    $st = "UPDATE game SET status='C', completion_status='W' WHERE game_id='" . $gid . "'";
                    mysql_query($st) or die(mysql_error());
                }
                //////////////////////////////////////////////
                $move_stat = "S";
            }
        }
        return $move_stat . $this->zero_pad($player_id, 8) . $gid . $move;
    }
Example #4
0
/**
 * getPromotionData - Retourne les informations relatives à une promotion
 *
 * @category userFunction
 * @param int $id Identifiant de la promotion
 * @return array Array contenant les informations relatives à la promotion
 *
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *	['id'] => (int) Identifiant de la promotion<br>
 *	['nom'] => (string) Nom de la promotion<br>
 *	['nb'] => (int) Nombre d'utilisateurs inscrits dans la promotion<br>
 *	['users'][identifiant de l'utilisateur]['id'] => (int) Identifiant d'un utilisateur inscrit dans la promotion<br>
 *	['users'][identifiant de l'utilisateur]['nom'] => (string) Nom de l'utilisateur inscrit dans la promotion<br>
 *	['users'][identifiant de l'utilisateur]['prenom'] => (string) Prénom de l'utilisateur inscrit dans la promotion<br>
 *	['users'][identifiant de l'utilisateur]['nbEtudiant'] => (string) Numéro d'étudiant de l'utilisateur inscrit dans la promotion<br>
 *	['users'][identifiant de l'utilisateur]['rang'] => (int) Rang de l'utilisateur inscrit dans la promotion (entre 0 et 4)<br>
 *
 */
function getPromotionData($id)
{
    global $db;
    // Verification de l'id
    if (count(checkPromotion($id, array())) == 0) {
        $promotion = array();
        $sql = 'SELECT p.id, p.nom, (SELECT count(*) FROM user WHERE promotion = p.id LIMIT 1) nb FROM promotion p WHERE p.id = ? LIMIT 1';
        $res = $db->prepare($sql);
        $res->execute(array($id));
        if ($res_f = $res->fetch()) {
            $promotion['id'] = $res_f['id'];
            $promotion['nom'] = $res_f['nom'];
            $promotion['nb'] = $res_f['nb'];
        }
        // Liste des étudiants inscrits dans le services
        $sql = 'SELECT u.id, u.nom nom, u.prenom prenom, u.rang rang, u.nbEtudiant
						FROM user u
						WHERE u.promotion = ?
						ORDER BY u.nom ASC';
        $res = $db->prepare($sql);
        $res->execute(array($id));
        while ($res_f = $res->fetch()) {
            $promotion['users'][$res_f['id']]['id'] = $res_f['id'];
            $promotion['users'][$res_f['id']]['prenom'] = $res_f['prenom'];
            $promotion['users'][$res_f['id']]['nbEtudiant'] = $res_f['nbEtudiant'];
            $promotion['users'][$res_f['id']]['nom'] = $res_f['nom'];
            $promotion['users'][$res_f['id']]['rang'] = $res_f['rang'];
        }
        return $promotion;
    } else {
        return FALSE;
    }
}
Example #5
0
/**
 * eval_ccpc_checkFilterExistence - Récupère les filtres appliqués à un service sur une période donnée
 *
 * @category : eval_ccpc_functions
 * @param int $service Identifiant du service
 * @param string $debutStage Borne inférieur de l'intervalle temporel considéré, sous forme de timestamp
 * @param string $finStage Borne supérieure de l'intervalle temporel considéré, sous forme de timestamp
 * @param int|boolean $promotion Promotion pour laquelle on s'intéresse aux filtres détectés, FALSE si pas de promotion particulière
 * @return array Array contenant la liste des filtres s'appliquant au service
 * 
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *	[Identifiant du filtre][] => (array) Informations relatives au filtre, voir {@link eval_ccpc_getFilterDetails()}<br>
 *
 */
function eval_ccpc_checkFilterExistence($service, $debutStage, $finStage, $promotion = FALSE)
{
    if (isset($service) && count(checkService($service, array())) == 0 && isset($debutStage) && isset($finStage)) {
        global $db;
        $filtres = array();
        // Contient la liste des filtres
        $sqlData = array('service' => $service, 'debutStage' => TimestampToDatetime($debutStage), 'finStage' => TimestampToDatetime($finStage));
        // Array utilisé dans la requête préparée
        if (isset($promotion) && is_numeric($promotion) && count(checkPromotion($promotion, array())) == 0) {
            $sqlData['promotion'] = $promotion;
            $sql = 'SELECT id_filtre id FROM eval_ccpc_filtres_detected WHERE id_service = :service AND debutStage = :debutStage AND finStage = :finStage AND (promotion = :promotion OR promotion IS NULL)';
        } else {
            $sql = 'SELECT id_filtre filtre FROM eval_ccpc_filtres_detected WHERE id_service = :service AND debutStage = :debutStage AND finStage = :finStage';
        }
        echo $sql;
        $res = $db->prepare($sql);
        $res->execute($sqlData);
        while ($res_f = $res->fetch()) {
            $filtres[$res_f['id']] = eval_ccpc_getFilterDetails($res_f['id']);
        }
        print_r($filtres);
        exit;
        return $filtres;
    } else {
        return FALSE;
    }
}
Example #6
0
            }
        }
        $orderSQL = ' ORDER BY u.nom, u.prenom';
    } else {
        if ($typeUser == 'enseignant') {
            $sql = 'SELECT u.nom nom, u.prenom prenom, u.id id
					FROM user u
					WHERE u.rang > 1 ';
            /*
            	On crée le $whereSQL
            */
            $whereSQL = '';
            if (isset($_POST['filtres'])) {
                if (isset($_POST['filtres']['promotion'])) {
                    foreach ($_POST['filtres']['promotion'] as $promotionId => $promotionValue) {
                        if (count(checkPromotion($promotionId, array())) == 0) {
                            $whereSQL .= ' AND (SELECT count(*) FROM user INNER JOIN affectationexterne ON user.id =  affectationexterne.userId INNER JOIN service ON service.id = affectationexterne.service WHERE user.promotion = ' . $promotionId . ' AND service.chef = u.id  AND affectationexterne.dateDebut <= "' . TimestampToDatetime(time()) . '" AND affectationexterne.dateFin >= "' . TimestampToDatetime(time()) . '"  LIMIT 1) = 1 ';
                        }
                    }
                }
                if (isset($_POST['filtres']['certificat']) && count($_POST['filtres']['certificat']) > 0) {
                    $whereSQL .= ' AND (';
                    $addOR = FALSE;
                    foreach ($_POST['filtres']['certificat'] as $certificatId => $certificatValue) {
                        if (count(checkCertificat($certificatId, array())) == 0) {
                            if ($addOR) {
                                $whereSQL .= ' OR ';
                            } else {
                                $addOR = TRUE;
                            }
                            $whereSQL .= ' (SELECT count(*) FROM service INNER JOIN servicecertificat ON servicecertificat.idService = service.id WHERE service.chef = u.id AND servicecertificat.idCertificat = ' . $certificatId . ' LIMIT 1) = 1';
Example #7
0
if ($action == 'list' || $action == 'dl') {
    if (isset($_GET['order'])) {
        $order = $_GET['order'];
    } else {
        $order = 'nom';
    }
    if (isset($_GET['desc'])) {
        $desc = true;
    } else {
        $desc = false;
    }
    $listePromotions = getPromotionList($order, $desc);
} else {
    if ($action == 'view' || $action == 'delete' || $action == 'edit') {
        // On récupère les données sur la promotion
        if (count(checkPromotion($_GET['id'], array())) == 0) {
            $promotionData = getPromotionData($_GET['id']);
        } else {
            header('Location: ' . ROOT . CURRENT_FILE . '?page=' . $_GET['page']);
        }
    }
}
// On retourne la liste au format CSV si $action == 'dl'
if ($action == 'dl') {
    /*
    	Création de l'array à retourner
    */
    $promotionsCSV = array(array('id', LANG_ADMIN_PROMOTION_NOM_TITRE));
    foreach ($listePromotions as $promotion) {
        $promotionsCSV[] = array($promotion['id'], $promotion['nom']);
    }
Example #8
0
 /*
 	Préparation des données : on crée un array contenant toutes les données, ce dernier sera ensuite parcouru pour créer la requête SQL qui sera préparée
 */
 if ($action == 'edit' || $action == 'delete') {
     $sqlData['id'] = $certificatData['id'];
     // Id de l'utilisateur
 }
 if ($action == 'edit' || $action == 'add') {
     foreach ($_POST as $key => $value) {
         if ($key == 'nom') {
             if ($value != '' && (isset($specialiteData) && $value != $specialiteData[$key] || !isset($specialiteData))) {
                 $sqlData[$key] = htmLawed($value);
             }
         } else {
             if ($key == 'promotion') {
                 if (is_numeric($value) && count(checkPromotion($value, array())) == 0) {
                     $sqlData[$key] = $value;
                 }
             }
         }
     }
 }
 /**
 			On lance les enregistrement dans la BDD
 		**/
 $sqlInsert = FALSE;
 // Enregistre la bonne réussite des requêtes
 /**
 			Pour les ajouts
 		**/
 if ($action == 'add') {
Example #9
0
             // On vérifie chaque adresse email
             foreach ($tempMail as $email) {
                 if (filter_var($email, FILTER_VALIDATE_EMAIL) && !in_array($email, $tempMailArray)) {
                     $tempMailArray[] = $email;
                 }
             }
             if (isset($tempMailArray) && is_array($tempMailArray)) {
                 $sqlData[$key] = serialize($tempMailArray);
             } else {
                 $erreur[19] = true;
             }
         } else {
             if ($key == 'rang' && is_numeric($value) && ($action == 'edit' && $value != $userInfo['rang'] || $action == 'add') && $value <= $_SESSION['rang']) {
                 $sqlData[$key] = $value;
             } else {
                 if ($key == 'promotion' && is_numeric($value) && $action == 'edit' && $value != $userInfo[$key] && count(checkPromotion($value, array())) == 0) {
                     $sqlData[$key] = $value;
                 } else {
                     if ($key == 'affectation' && $action == 'edit') {
                         $sqlAffectationData = array();
                         foreach ($_POST['affectation'] as $affectationId => $affectationValue) {
                             if (is_numeric($affectationId) && $affectationValue != $userInfo['service'][$affectationId]['id'] && count(checkService($affectationValue, array())) == 0) {
                                 $sqlAffectationData[$affectationId] = array('id' => $affectationId, 'service' => $affectationValue);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #10
0
/**
 * getEvaluationCCPCFullData - Récupère l'intégralité des données d'évaluation de stage
 *
 * @category : eval_ccpc_functions
 * @param int $id Identifiant du service pour lequel on récupère les données
 * @param int|boolean $promotion Identifiant de la promotion pour laquelle on récupère les données, FALSE si elles sont récupérés indifférement de la promotion
 * @param string $dateMin Borne inférieure de la période pour laquelle on récupère les données d'évaluation, sous forme de Timestamp
 * @param string $dateMax Borne supérieure de la période pour laquelle on récupère les données d'évaluation, sous forme de Timestamp
 * @param boolean $modere si TRUE on affiche les commentaires modérés, si FALSE on ne les affiche pas
 * @return array Array contenant les résultats d'évaluation pour un service durant une période donnée et pour une promotion donnée
 * 
 * @Author Ali Bellamine
 *
 * Contenu de l'array retourné :<br>
 *     Contient l'intégralité des données retournés par {@link getEvaluationCCPCPartialData()}<br>
 * 	['donnees'][identifiant de l'évaluation][categorie de la question][nom du champs dans la BDD] => (int) Valeur de la réponse à la question, toutes les données y apparaissent<br>
 * 	[Catégorie des données][Nom du champs dans la BDD]['nb'][valeur] => (int) Nombre d'occurence de chaque valeur<br>
 * 	[Catégorie des données][Nom du champs dans la BDD]['nbTotal'] => (int) Nombre total de réponses pour le champs donné<br>
 * 	[Catégorie des données][Nom du champs dans la BDD][] => (string) Pour champs texte uniquement, contient toutes les réponses données dans le champs
 *
 */
function getEvaluationCCPCFullData($id, $promotion, $dateMin, $dateMax, $modere = FALSE)
{
    global $db;
    global $bypasslimit;
    // On récupère des données de la page d'accueil
    $evaluationData = getEvaluationCCPCPartialData($id, $promotion, $dateMin, $dateMax);
    if (!isset($evaluationData) || $evaluationData == FALSE) {
        return FALSE;
    }
    /**
    			Récupération des toutes les évaluations  de type différent de select concernant le service dans la base de donnée
    		**/
    $listEvaluationItems = array();
    $listTextItems = array();
    // Liste des champs à ne pas dénombrer
    $listChamp = array();
    if (is_file(PLUGIN_PATH . 'formulaire.xml')) {
        if ($form = simplexml_load_file(PLUGIN_PATH . 'formulaire.xml')) {
            foreach ($form->categorie as $categorie) {
                $listChamp[(string) $categorie['nom']] = array();
                foreach ($categorie->input as $input) {
                    if ($input['type'] == 'select') {
                        $listChamp[(string) $categorie['nom']][] = (string) $input['nomBDD'];
                    }
                    if ($input['type'] == 'radio' || $input['type'] == 'textarea') {
                        $listChamp[(string) $categorie['nom']][] = (string) $input['nomBDD'];
                        $listEvaluationItems[(string) $input['nomBDD']]['type'] = (string) $categorie['nom'];
                        if ($input['type'] == 'radio') {
                            $listEvaluationItems[(string) $input['nomBDD']]['value'] = array();
                            foreach ($input->radio as $radio) {
                                $listEvaluationItems[(string) $input['nomBDD']]['value'][] = (string) $radio['value'];
                            }
                        }
                        if ($input['type'] == 'textarea') {
                            $listTextItems[(string) $input['nomBDD']] = (string) $categorie['nom'];
                        }
                    } else {
                        if ($input['type'] == 'checkbox') {
                            foreach ($input->checkbox as $checkbox) {
                                $listChamp[(string) $categorie['nom']][] = (string) $checkbox['nomBDD'];
                                $listEvaluationItems[(string) $checkbox['nomBDD']]['type'] = (string) $categorie['nom'];
                                $listEvaluationItems[(string) $checkbox['nomBDD']]['value'] = array(0, 1);
                            }
                        } else {
                            if ($input['type'] == 'text') {
                                foreach ($input->text as $text) {
                                    $listChamp[(string) $categorie['nom']][] = (string) $text['nomBDD'];
                                    $listTextItems[(string) $text['nomBDD']] = (string) $categorie['nom'];
                                    $listEvaluationItems[(string) $text['nomBDD']]['type'] = (string) $categorie['nom'];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    /**
    			On récupère les données non récupérés dans getEvaluationCCPCPartialData
    		**/
    $sqlData = array('id' => $id);
    $sql = 'SELECT e.id evaluationId, e.moderation moderation';
    foreach ($listEvaluationItems as $key => $value) {
        $sql .= ', e.' . $key . ' ' . $key . ' ';
    }
    $sql .= 'FROM eval_ccpc_resultats e
					INNER JOIN service s ON e.service = s.id
					 WHERE e.service = :id ';
    if ($dateMin != 0 && $dateMax != 0) {
        $sql .= 'AND e.debutStage >= :dateMin AND e.finStage <= :dateMax ';
        $sqlData['dateMin'] = TimestampToDatetime($dateMin);
        $sqlData['dateMax'] = TimestampToDatetime($dateMax);
    }
    if (isset($promotion) && is_numeric($promotion) && count(checkPromotion($promotion, array())) == 0) {
        $sql .= 'AND e.promotion = :promotion ';
        $sqlData['promotion'] = $promotion;
    }
    // Si il s'agit d'un étudiant, on affiche que les évaluations vielles de + de 30 jours
    if ($_SESSION['rang'] <= 1 && $bypasslimit == FALSE) {
        if (defined('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') && is_numeric(constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL')) && constant('CONFIG_EVAL_CCPC_DELAIDISPOEVAL') >= 0) {
            $nbJourAllowedDate = CONFIG_EVAL_CCPC_DELAIDISPOEVAL;
        } else {
            $nbJourAllowedDate = 30;
        }
        $allowedDate = TimestampToDatetime(time() - $nbJourAllowedDate * 24 * 3600);
        $sql .= ' AND e.date <= "' . $allowedDate . '" ';
    }
    /*
    	Ne pas afficher les évaluations des autres services aux chef de service
    */
    if ($_SESSION['rang'] == 2 && defined('CONFIG_EVAL_CCPC_RESTRICTEVALUATIONACCESSSERVICE') && CONFIG_EVAL_CCPC_RESTRICTEVALUATIONACCESSSERVICE == TRUE && $bypasslimit == FALSE) {
        $sql .= ' AND s.chef = "' . $_SESSION['id'] . '"';
    }
    $res = $db->prepare($sql);
    $res->execute($sqlData);
    while ($res_f = $res->fetch()) {
        // On récupére la liste des champs textes modérés
        if (isset($res_f['moderation']) && unserialize($res_f['moderation'])) {
            $moderationArray = unserialize($res_f['moderation']);
        } else {
            $moderationArray = array();
        }
        // On remplit l'array de résultats
        foreach ($res_f as $key => $value) {
            // On enregistre l'évaluation
            if (isset($listEvaluationItems[$key]) && $value != '') {
                $evaluationData['donnees'][$res_f['evaluationId']][$listEvaluationItems[$key]['type']][$key] = $value;
            }
            // On stocke à part les évaluation de type text
            if (isset($listTextItems[$key])) {
                if ($value != '') {
                    // On enregistre le fait que ça soit modéré
                    if (isset($moderationArray[$key])) {
                        $evaluationData['donnees'][$res_f['evaluationId']]['Moderation'][$key] = TRUE;
                    }
                    if (!isset($moderationArray[$key]) || $modere) {
                        $evaluationData[$listTextItems[$key]][$key][$res_f['evaluationId']] = $value;
                    } else {
                        $evaluationData[$listTextItems[$key]][$key][$res_f['evaluationId']] = LANG_FORM_CCPC_QUESTION_TEXT_MODERATE;
                    }
                }
            }
        }
    }
    /**
    			On compte les réponses et on enregistre combien il y a de chaque réponse
    		**/
    foreach ($evaluationData['donnees'] as $id => $valeur) {
        foreach ($listChamp as $champType => $champValeur) {
            foreach ($champValeur as $champ) {
                if (!isset($listTextItems[$champ]) && isset($valeur[$champType][$champ])) {
                    /*
                    	On compte l'item
                    */
                    if (!isset($evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]]) || !is_numeric($evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]])) {
                        $evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]] = 1;
                    } else {
                        $evaluationData[$champType][$champ]['nb'][$valeur[$champType][$champ]]++;
                    }
                    /*
                    	On calcul le total
                    */
                    if (!isset($evaluationData[$champType][$champ]['nbTotal']) || !is_numeric($evaluationData[$champType][$champ]['nbTotal'])) {
                        $evaluationData[$champType][$champ]['nbTotal'] = 1;
                    } else {
                        $evaluationData[$champType][$champ]['nbTotal']++;
                    }
                }
            }
        }
    }
    /**
    			On corrige met 0 aux valeurs non cochés pour les questions où les réponses possibles sont exhaustives
    		**/
    foreach ($listEvaluationItems as $listFixQuestionName => $listFixQuestionValue) {
        if (isset($listFixQuestionValue['value'])) {
            foreach ($listFixQuestionValue['value'] as $listFixQuestionPossibilite) {
                if (!isset($evaluationData[$listFixQuestionValue['type']][$listFixQuestionName]['nb'][$listFixQuestionPossibilite])) {
                    $evaluationData[$listFixQuestionValue['type']][$listFixQuestionName]['nb'][$listFixQuestionPossibilite] = 0;
                }
            }
        }
    }
    return $evaluationData;
}
Example #11
0
     } else {
         $whereSqlFilter .= ' AND ';
     }
     if ($whereSqlContent == '') {
         $whereSqlContent .= 'WHERE ';
     } else {
         $whereSqlContent .= ' AND ';
     }
     $whereSqlFilter .= ' (h.nom LIKE :search OR h.alias LIKE :search OR sp.nom LIKE :search OR s.nom LIKE :search OR c.nom LIKE :search OR c.prenom LIKE :search OR CONCAT(c.nom, " ", c.prenom) LIKE :search OR CONCAT(c.prenom, " ", c.nom) LIKE :search) ';
     $whereSqlContent .= ' (h.nom LIKE :search OR h.alias LIKE :search OR sp.nom LIKE :search OR s.nom LIKE :search OR c.nom LIKE :search OR c.prenom LIKE :search OR CONCAT(c.nom, " ", c.prenom) LIKE :search OR CONCAT(c.prenom, " ", c.nom) LIKE :search) ';
 }
 /*
 	Promotions
 */
 if (isset($_GET['FILTER']['promotion']) && is_numeric($_GET['FILTER']['promotion'])) {
     $erreur = checkPromotion($_GET['FILTER']['promotion'], $erreur);
     if (count($erreur) == 0) {
         $preparedValue['promotion'] = $_GET['FILTER']['promotion'];
         $filtrePromotion = $_GET['FILTER']['promotion'];
         if ($whereSqlFilter == '') {
             $whereSqlFilter .= 'WHERE ';
         } else {
             $whereSqlFilter .= ' AND ';
         }
         if ($whereSqlContent == '') {
             $whereSqlContent .= 'WHERE ';
         } else {
             $whereSqlContent .= ' AND ';
         }
         $whereSqlFilter .= ' p.id = :promotion ';
         $whereSqlContent .= ' p.id = :promotion ';
Example #12
0
                            }
                            eval_ccpc_applyFilter($serviceDetectedData['service']['id'], $serviceDetectedData['promotion'], $serviceDetectedData['date']['debut'], $serviceDetectedData['date']['fin']);
                        }
                    }
                }
            }
            header('Location: ' . ROOT . CURRENT_FILE . '?' . http_build_query($tempGet));
        }
    }
}
// Téléchargement des fiches PDF
if (isset($_GET['dateDebut']) && isset($_GET['dateFin']) && isset($_GET['serviceId']) && ($_GET['serviceId'] == 'all' && isset($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']]) || is_numeric($_GET['serviceId']) && isset($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']][$_GET['serviceId']]) && count($filtreData['detected'][$_GET['dateFin']][$_GET['dateDebut']][$_GET['serviceId']]) > 0)) {
    if (isset($_GET['download']) && isset($allowedDownloadAction[$_GET['download']])) {
        $action = $allowedDownloadAction[$_GET['download']];
        $serviceId = $_GET['serviceId'];
        if (isset($filtreData['promotion']) && count(checkPromotion($filtreData['promotion'], array())) == 0) {
            $promotion = $filtreData['promotion'];
        } else {
            $promotion = FALSE;
        }
        // Pour un service sélectionné
        if (is_numeric($serviceId) && count(checkService($serviceId, array())) == 0) {
            // On crée le fichier
            if ($action['type'] == 'CSV') {
                downloadFILE(generateCSV(getEvaluationCCPCFullData($serviceId, $promotion, $_GET['dateDebut'], $_GET['dateFin'], $action['moderation']), TRUE)['csvPath'], getServiceInfo($serviceId)['FullName'] . '.csv');
            } else {
                if ($action['type'] == 'PDF') {
                    downloadFILE(generatePDF(getEvaluationCCPCFullData($serviceId, $promotion, $_GET['dateDebut'], $_GET['dateFin'], $action['moderation']), $action['comment'], TRUE)['pdfPath'], getServiceInfo($serviceId)['FullName'] . '.pdf');
                }
            }
        } else {