Commit b57d2540 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

improve notification

parent e2499b70
......@@ -3,30 +3,38 @@ class Notification
{
private $user = '';
public $messNotif = array();
private $db;
private $db=false;
private $time = "";
function __construct()
function __construct($perform_queries=true,$db=false)
{
//Récupération des informaions de base: userid
$this->user = user::getInstance();
//connexion à la BD
$this->db = db::getInstance();
if(!$db){
$this->db = db::getInstance();
}else{
$this->db = $db;
}
$this->perform_queries = $perform_queries;
}
function readNotif()
{
//récupération des messages de notification;
$sql = 'SELECT * FROM `notif` WHERE `userid`="'.$this->user->id.'" ORDER BY `time` DESC';
$result=$this->db->query($sql);
// comptage du nombre de résultats
$nb_result=$result->num_rows;
function is_query_performer(){
return $this->perform_queries;
}
//pour chaque enregistrement:
if ($nb_result > 0)
{ while($res = mysqli_fetch_assoc($result)){
function readNotif(){
if($this->is_query_performer()){
//récupération des messages de notification;
$sql = 'SELECT * FROM `notif` WHERE `userid`="'.$this->user->id.'" ORDER BY `time` DESC';
$result=$this->db->query($sql);
// comptage du nombre de résultats
$nb_result=$result->num_rows;
if($res['emetteur'] != 0){
//pour chaque enregistrement:
if ($nb_result > 0){
while($res = mysqli_fetch_assoc($result)){
if($res['emetteur'] != 0){
$sql = "SELECT `photo` FROM `user` WHERE `userid`=".$res['emetteur'];
$resultat=$this->db->query($sql);
$res2 = mysqli_fetch_assoc($resultat);
......@@ -35,29 +43,71 @@ class Notification
else{
$emetteur = $res["game"];
}
$this->messNotif[$res['id']][$res['state']][$emetteur][$res["time"]] = $res['message'];
}
}
}
}
function addNotif($userid,$notification,$emetteur){
$sql = "INSERT INTO `notif`(`userid`, `message`, `emetteur`) VALUES ($userid,".$this->db->escape($notification).",'$emetteur')";
$result=$this->db->query($sql);
function addNotif($userid,$notification,$emetteur,$type="NULL"){
$sql = "INSERT INTO `notif`(`userid`, `type`, `message`, `emetteur`) VALUES ($userid,$type,".$this->db->escape($notification).",'$emetteur');";
if($this->is_query_performer()){
$result=$this->db->query($sql);
}
else{
$result=$sql;
}
return $result;
}
function addNotifGAME($userid,$notification,$role){
function addNotifGAME($userid,$notification,$role,$type="NULL"){
//add an image to your notification…
$sql = "INSERT INTO `notif` (`userid`, `message`, `emetteur` ,`game`) VALUES ($userid,".$this->db->escape($notification).",0,'".$role."')";
$result=$this->db->query($sql);
$sql = "INSERT INTO `notif` (`userid`, `type`, `message`, `emetteur` ,`game`) VALUES ($userid,$type,".$this->db->escape($notification).",0,'".$role."');";
if($this->is_query_performer()){
$result=$this->db->query($sql);
}
else{
$result=$sql;
}
return $result;
}
function notifRead($id) {
$sql= 'UPDATE `notif` SET `state`=1 WHERE id= $id';
$result=$this->db->query($sql);
$sql= 'UPDATE `notif` SET `state`=1 WHERE id= $id;';
if($this->is_query_performer()){
$result=$this->db->query($sql);
}
else{
$result=$sql;
}
return $result;
}
function cancelNotif($id=false) {
if($id===false){
$id = "@notif_id";
}
$sql= 'DELETE FROM `notif` WHERE `notif`.`id` = $id;';
if($this->is_query_performer()){
$result=$this->db->query($sql);
}
else{
$result=$sql;
}
return $result;
}
function cancelLastNotifOfType($user_id,$type){
$sql= "DELETE FROM `notif` WHERE `notif`.`userid`='$user_id' AND `notif`.`type` = '$type' ORDER BY `notif`.`time` DESC LIMIT 1;";
if($this->is_query_performer()){
$result=$this->db->query($sql);
}
else{
$result=$sql;
}
return $result;
}
}
?>
......@@ -214,6 +214,8 @@ $lang['Card_created'] = "Thank you for creating a card: ";
$lang['Rec_verified'] = "Thank you for verifying the recording of ";
$lang['Oracle_verif'][true] = " verified your recording and thinks you didn't use forbidden words";
$lang['Oracle_verif'][false] = " verified your recording and thinks you used forbidden words";
$lang['Oracle_started'] = "Oracle game started, if you give up the recording you'll lose ";
$lang['Oracle_posted'] = "You took the risk of posting your description, you, brave Oracle!";
$lang['Oracle_devin'][false] = " listened to your recording and didn't find the word…";
$lang['Oracle_devin'][true] = " listened to your recording and found the word!";
$lang['Devin_played'] = "You listened to a recording by ";
......@@ -223,10 +225,6 @@ $lang['Devin_oracle'][false] = "And you did not find the word…";
$lang['druidNotReady'] = "All the required variables for a Druid decision have not been set…";
$lang['page_errors'] = "Error in processing query";
$lang['img_augur'] = "./profil/diviner.jpg";
$lang['img_druid'] = "./profil/druide.jpg";
$lang['img_oracle'] = "./profil/oracle.jpg";
//Erreur upload
$lang['file_unupload'] = 'Attention, the file was not fully uploaded.';
$lang['sizeOfUp'] = 'The uploaded file is too large.';
......
......@@ -197,7 +197,7 @@ $lang['home_miss_lang_game'] = 'Veuillez sélectionner une langue de jeu dans vo
$lang['languePlay'] = 'Vous jouez en ';
$lang['level'] = 'au niveau ';
$lang['levelChange'] = 'Niveau de la prochaine partie :';
$lang['levelChange'] = 'Niveau de la prochaine partie : ';
$lang['Oracle_easy'] = "Un seul mot interdit et 1′30″ d'enregistrement (mise : 10 points).";
$lang['Oracle_medium'] = "Trois mots interdits et 1′ d'enregistrement (mise : 20 points).";
$lang['Oracle_hard'] = "Six mots interdits et 30″ d'enregistrement (mise : 30 points).";
......@@ -208,6 +208,8 @@ $lang['Card_created'] = "Merci d'avoir créé une carte : ";
$lang['Rec_verified'] = "Merci d'avoir vérifié l'enregistrement de ";
$lang['Oracle_verif'][true] = " a vérifié votre enregistrement et pense que vous n'avez pas utilisé de mot interdit";
$lang['Oracle_verif'][false] = " a vérifié votre enregistrement et pense que vous n'avez pas utilisé de mot interdit";
$lang['Oracle_started'] = "Partie “Oracle” commencée, sans dépôt du fichier, vous perdrez ";
$lang['Oracle_posted'] = "Vous avez osé valider votre description, courageux…";
$lang['Oracle_devin'][false] = " a écouté votre enregistrement et n'a pas trouvé le mot…";
$lang['Oracle_devin'][true] = ' a écouté votre enregistrement et a trouvé !';
$lang['Devin_played'] = 'Vous avez écouté un enregistrement de ';
......@@ -217,10 +219,6 @@ $lang['Devin_oracle'][false] = "Mais vous n'avez pas trouvé…";
$lang['druidNotReady'] = "Tous les paramètres nécessaires à la gestion d'une décision n'ont pas été spécifiés…";
$lang['page_errors'] = "Erreur durant le traitement de la requête";
$lang['img_augur'] = './profil/diviner.jpg';
$lang['img_druid'] = './profil/druide.jpg';
$lang['img_oracle'] = './profil/oracle.jpg';
//Erreur upload
$lang['file_unupload'] = 'Attention le fichier a mal été uploadé.';
$lang['sizeOfUp'] = 'La taille du fichier uploadé est trop grande.';
......
<?php
function get_messages($llang){
include 'languages/lang.' . $llang . '.php';
include 'languages/errors.php';
include 'languages/notifs_codes.php';
return $lang;
}
?>
......@@ -8,4 +8,5 @@
include 'languages/lang.' . $userlang . '.php';
}
include 'languages/errors.php';
include 'languages/notifs_codes.php';
?>
<?php
if(isset($lang)){
$lang['notif']['Card_created'] = 1;
$lang['notif']['Rec_verified'] = 2;
$lang['notif']['Oracle_verif'][true] = 3;
$lang['notif']['Oracle_verif'][false] = 4;
$lang['notif']['Oracle_devin'][false] = 5;
$lang['notif']['Oracle_devin'][true] = 6;
$lang['notif']['Devin_played'] = 7;
$lang['notif']['Devin_oracle'][true] = 8;
$lang['notif']['Devin_oracle'][false] = 9;
$lang['notif']['languePlay'] = 10;
$lang['notif']['levelChange'] = 11;
$lang['notif']['languePlay'] = 12;
$lang['notif']['Oracle_started'] = 13;
$lang['notif']['Oracle_posted'] = 14;
$lang['img_augur'] = "./profil/diviner.jpg";
$lang['img_druid'] = "./profil/druide.jpg";
$lang['img_oracle'] = "./profil/oracle.jpg";
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment