Commit 48b33393 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

./adminCards.php to remove cards (no link) needs login

parent fca7be04
......@@ -53,9 +53,12 @@ CREATE TABLE IF NOT EXISTS `cartes` (
`idDruide` int(16) unsigned NOT NULL COMMENT 'auteur',
`mot` varchar(128) NOT NULL,
`dateCreation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`dateSuppression` timestamp NULL DEFAULT NULL,
`idEraser` int(16) DEFAULT NULL COMMENT 'Id de la personne qui a supprimé la carte',
PRIMARY KEY (`idCarte`),
KEY `idDruide` (`idDruide`),
KEY `langue` (`langue`)
KEY `langue` (`langue`),
KEY `idEraser` (`idEraser`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Les cartes, attention nécessitent jointures' AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
......
......@@ -31,8 +31,5 @@ else{
$card->set_view("./views/card.inline.admin.display.php");
echo $card;
}
echo "<script>$('.close').click(function() {
$( this ).slideUp();
});</script>";
}
?>
?>
\ No newline at end of file
<?php
session_start();
require_once("../sys/db.class.php");
require_once("../models/user.class.php");
require('../languages/language.php');
$user = user::getInstance();
if(($user->id == $_GET['user_id']) && isset($_GET['card_id'])){
$db = db::getInstance();
$db->query("UPDATE `GoW`.`cartes` SET `dateSuppression` = CURRENT_TIMESTAMP, `idEraser` = '".$user->id."' WHERE `cartes`.`idCarte` = '".$_GET['card_id']."';");
if($db->affected_rows() == 1){
echo "OK";
}
else{
echo $db->affected_rows()." enregistrements affectés (≠1, pourquoi?)";
}
}
else{
print_r($lang);
echo $user->id." ≠ ".$_GET['user_id']." : Problème de connexion, vous n'êtes plus vous-même…";
}
?>
\ No newline at end of file
<script>
function error(cardId, message){
$("#carte"+cardId+" .tabous").show().after(message);
$("#carte"+cardId+" .overlay-loader").fadeOut(500);
}
function deleteCard(elt){
var cardId = $(elt).attr('data-id'),
url = "./controllers/hide.card.php?user_id="+$(elt).attr('data-user')+"&card_id="+cardId,
req = new XMLHttpRequest();
req.open("GET", url, true);
$("#carte"+cardId+" .tabous").hide();
$("#carte"+cardId+" .overlay-loader").fadeIn(500);
req.onreadystatechange = function(aEvt){
if (req.readyState == 4) {
if(req.status == 200){
if(req.responseText=="OK"){
$("#carte"+cardId+" .tabous").after("Carte supprimée");
$("#carte"+cardId).fadeOut(2000, function(){$(this).remove();});
}
else{
error(cardId, "<p>"+req.responseText+"</p>");
}
}
else{
error(cardId, "<p>erreur de suppression</p>");
}
}
};
req.send(null);
}
function init(){
$('.close').click(function(){deleteCard(this);});
$('.overlay-loader').hide();
}
window.onload = init;
</script>
\ No newline at end of file
......@@ -205,5 +205,4 @@ $lang['same_lang'] = ' You have chosen twice the same language in langues parlé
//Administration cartes
$lang['admin'] = "Administration: Press cross to delete card";
?>
......@@ -197,4 +197,4 @@ $lang['uploadProb'] = 'Le fichier n\'a pas été uploadé...';
//
$lang['same_lang'] = 'Vous avez choisi deux fois la même langue dans langues parlées ';
//Administration cartes
$lang['admin'] = "Administration&nbsp;: Cliquer sur la croix pour supprimer la carte";
$lang['admin'] = "Administration&nbsp;: Cliquer sur la croix pour supprimer la carte";
\ No newline at end of file
......@@ -44,10 +44,11 @@ class ItemFactory //a quick and dirty class…
}
switch ($queryType) {
case self::CARD_NOT_ME:
$this->query = "SELECT `cartes`.`idCarte` as `zeId` FROM `cartes` WHERE
`cartes`.`langue`='$this->lang'
AND `cartes`.`idDruide` != '$this->user_id'
AND `cartes`.`idCarte` NOT IN (
$this->query = "SELECT `cartes`.`idCarte` as `zeId` FROM `cartes`
WHERE `cartes`.`idEraser` IS NULL
AND `cartes`.`langue`='$this->lang'
AND `cartes`.`idDruide` != '$this->user_id'
AND `cartes`.`idCarte` NOT IN (
SELECT `enregistrement`.`carteID` as`cardId` FROM `enregistrement` WHERE `enregistrement`.`idOracle`='$this->user_id'
UNION SELECT `enregistrement`.`carteID` as`cardId` FROM `arbitrage`,`enregistrement` WHERE `arbitrage`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `arbitrage`.`idDruide`='$this->user_id'
UNION SELECT `enregistrement`.`carteID` as`cardId` FROM `parties`,`enregistrement` WHERE `parties`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `parties`.`idDevin`='$this->user_id'
......@@ -61,8 +62,9 @@ class ItemFactory //a quick and dirty class…
SELECT `enregistrement`.`carteID` FROM `enregistrement`,`arbitrage` WHERE `enregistrement`.`enregistrementID`=`arbitrage`.`enregistrementID` AND `arbitrage`.`idDruide` = '$this->user_id'
UNION SELECT `enregistrement`.`carteID` FROM `enregistrement`,`parties` WHERE `enregistrement`.`enregistrementID`=`parties`.`enregistrementID` AND `parties`.`idDevin` = '$this->user_id'
),1,0) as `poids`
FROM `enregistrement`,`cartes` WHERE
`enregistrement`.`idOracle` != '$this->user_id'
FROM `enregistrement`,`cartes`
WHERE `cartes`.`idEraser` IS NULL
AND `enregistrement`.`idOracle` != '$this->user_id'
AND `enregistrement`.`validation` = 'limbo'
AND `enregistrement`.`carteID` = `cartes`.`idCarte`
AND `cartes`.`langue` = '$this->lang'
......@@ -70,23 +72,25 @@ class ItemFactory //a quick and dirty class…
break;
case self::VALID_RECORDING_NOT_ME:
$this->query = "SELECT `enregistrement`.* FROM `enregistrement`,`cartes` WHERE
`cartes`.`langue`='$this->lang'
AND `cartes`.`idCarte` = `enregistrement`.`carteID`
AND `cartes`.`idDruide` != '$this->user_id'
AND `enregistrement`.`validation` = 'valid'
AND `enregistrement`.`idOracle` != '$this->user_id'
AND `enregistrement`.`carteID` NOT IN (
$this->query = "SELECT `enregistrement`.* FROM `enregistrement`,`cartes`
WHERE `cartes`.`idEraser` IS NULL
AND `cartes`.`langue`='$this->lang'
AND `cartes`.`idCarte` = `enregistrement`.`carteID`
AND `cartes`.`idDruide` != '$this->user_id'
AND `enregistrement`.`validation` = 'valid'
AND `enregistrement`.`idOracle` != '$this->user_id'
AND `enregistrement`.`carteID` NOT IN (
SELECT `enregistrement`.`carteID` as`cardId` FROM `arbitrage`,`enregistrement` WHERE `arbitrage`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `arbitrage`.`idDruide`='$this->user_id'
UNION SELECT `enregistrement`.`carteID` as`cardId` FROM `parties`,`enregistrement` WHERE `parties`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `parties`.`idDevin`='$this->user_id'
) ORDER BY RAND() $forOne;";
break;
case self::CARD_FROM_LEXICON: //ICITE tester la requête l'intégrer à innova class pour pouvoir allouer la variable de session et faire l'affichage en fonction de son existence(disabled ou non) et de celle du dico (pas d'affichage)
if(isset($parameter)){
$this->query = "SELECT `cartes`.`idCarte` as `zeId` FROM `cartes` WHERE
`cartes`.`langue`='$this->lang'
AND `cartes`.`idDruide` != '$this->user_id'
AND `cartes`.`idCarte` NOT IN (
$this->query = "SELECT `cartes`.`idCarte` as `zeId` FROM `cartes`
WHERE `cartes`.`idEraser` IS NULL
AND `cartes`.`langue`='$this->lang'
AND `cartes`.`idDruide` != '$this->user_id'
AND `cartes`.`idCarte` NOT IN (
SELECT `enregistrement`.`carteID` as`cardId` FROM `enregistrement` WHERE `enregistrement`.`idOracle`='$this->user_id'
UNION SELECT `enregistrement`.`carteID` as`cardId` FROM `arbitrage`,`enregistrement` WHERE `arbitrage`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `arbitrage`.`idDruide`='$this->user_id'
UNION SELECT `enregistrement`.`carteID` as`cardId` FROM `parties`,`enregistrement` WHERE `parties`.`enregistrementID` = `enregistrement`.`enregistrementID` AND `parties`.`idDevin`='$this->user_id'
......@@ -102,7 +106,7 @@ class ItemFactory //a quick and dirty class…
case self::ALL_CARDS:
//partir sur cette piste ce serait peut être mieux : SELECT `cartes`.*, GROUP_CONCAT(`mots_interdits`.`mot` SEPARATOR '|') as `interdits` FROM `cartes`,`mots_interdits` WHERE `cartes`.`idCarte`=`mots_interdits`.`idCarte` GROUP BY `mots_interdits`.`idCarte` ORDER BY `cartes`.`langue`, `cartes`.`idCarte`
//mais c'est un peu fatiguant…
$this->query = "SELECT `idCarte` as `zeId` FROM `cartes` ORDER BY `langue`, `idCarte` $forOne";//le forOne servira pas, pour la cohérence
$this->query = "SELECT `idCarte` as `zeId` FROM `cartes` WHERE `cartes`.`idEraser` IS NULL ORDER BY `langue`, `idCarte` $forOne";//le forOne servira pas, pour la cohérence
break;
default:
$res = false;
......
<?php /* Global $card sent by Card class (models/card.class.php) → $res used then in Card class*/
include('./languages/language.php');
echo "<style>.lacarte{margin-left:0.5em; margin-right:0.5em;margin-bottom:1em;padding:3px; position:relative;background-color:lightgrey;display: flex;flex-direction: column;justify-content:space-between;width:250px;float:left}
.lacarte div{margin:0;padding-bottom:4px; padding-top:4px; padding-left:1em; padding-right:1em;}
.lacarte>div{padding:0;}
div.lalangue{font-weight:bold; background-color:grey;color:white;margin-right:16px}
.niveauMin{text-align: right; color:white; position:absolute;top:3px;right:16px; background-color:black;padding:0;}
.categoriecat{background-color:white; margin-bottom:3px}
.motCleCle{text-align:center;font-size:larger;}
.motVedette{font-weight:bold; background-color:#93CEDE}
.thethemes div{font-weight:bold}
.lacarte header{font-weight:normal;font-size:small;text-align:left;}
.auteur{background-color:white; text-align:left;}
.lacarte .close{position:absolute; top:3px; right:3px;padding:0;}</style>";
$res = "<div class='lacarte'>
require_once('./controllersJS/card.inline.admin.js');
include_once('./views/card.inline.admin.display.style.html');
$res = "<div class='lacarte' id='carte".$card->get_id()."'>
<div>
<div class='niveauMin'>".$card->get_level()."</div>
<div class='lalangue'>ID&nbsp;: ".$card->get_id()." (".$card->get_lang().")</div>
<div class='close'>×</div>
<div class='close' data-user='".$user->id."' data-id='".$card->get_id()."'>×</div>
<!--div class='categoriecat'>".$card->get_cat()."</div-->
<div class='thethemes'>
<header>".$lang['theme']."&nbsp;:</header>";
<header>".$lang['theme']."&nbsp;:</header><div>";
foreach($card->get_themes() as $theme){
$res .= "<div>$theme</div>";
$res .= "<span>$theme</span>";
}
$res.="</div>
$res.="</div></div>
</div>
<div>
......@@ -35,8 +26,19 @@ $res = "<div class='lacarte'>
foreach($card->get_forbidden_words() as $word){
$res .= "<div class='motCleCle'>$word</div>\n";
}
$res .= "</div>
</div>
$res .= "</div>".
"<div class='overlay-loader'>
<div class='loader'>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>".
"</div>
<!--div>TODO
<div class='auteur'>".$card->get_author()." (".$card->get_time().")</div>
</div-->
......
<style>
.lacarte{margin-left:0.5em; margin-right:0.5em;margin-bottom:1em;padding:3px; position:relative;background-color:lightgrey;display: block;width:250px;float:left;height:400px;}
.lacarte div{margin:0;padding-bottom:4px; padding-top:4px; padding-left:1em; padding-right:1em;}
.lacarte>div{padding:0;}
div.lalangue{font-weight:bold; background-color:grey;color:white;margin-right:16px}
.niveauMin{text-align: right; color:white; position:absolute;top:3px;right:16px; background-color:black;padding:0;}
.categoriecat{background-color:white; margin-bottom:3px}
.motCleCle{text-align:center;font-size:larger;}
.motVedette{font-weight:bold; background-color:#93CEDE}
.thethemes{height:55px;}
.thethemes div{font-weight:bold;text-align:center;}
.lacarte header{font-weight:normal;font-size:small;text-align:left;}
.auteur{background-color:white; text-align:left;}
.lacarte .close{position:absolute; top:3px; right:3px;padding:0;}
/*thank you http://codepen.io/Terramaster/pen/bVpxGE ↓ */
.overlay-loader {
display: block;
margin: auto;
width: 125px;
height: 125px;
position: relative;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.loader {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 125px;
height: 125px;
animation-name: rotateAnim;
-o-animation-name: rotateAnim;
-ms-animation-name: rotateAnim;
-webkit-animation-name: rotateAnim;
-moz-animation-name: rotateAnim;
animation-duration: 0.93s;
-o-animation-duration: 0.93s;
-ms-animation-duration: 0.93s;
-webkit-animation-duration: 0.93s;
-moz-animation-duration: 0.93s;
animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
animation-timing-function: linear;
-o-animation-timing-function: linear;
-ms-animation-timing-function: linear;
-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear;
}
.loader div {
width: 10px;
height: 10px;
border-radius: 50%;
border: 1px solid rgba(147,206,222,0.71);
position: absolute;
top: 3px;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.loader div:nth-child(odd) {
border-top: none;
border-left: none;
}
.loader div:nth-child(even) {
border-bottom: none;
border-right: none;
}
.loader div:nth-child(2) {
border-width: 3px;
left: 0px;
top: -5px;
width: 15px;
height: 15px;
}
.loader div:nth-child(3) {
border-width: 3px;
left: -1px;
top: 4px;
width: 23px;
height: 23px;
}
.loader div:nth-child(4) {
border-width: 4px;
left: -1px;
top: -5px;
width: 30px;
height: 30px;
}
.loader div:nth-child(5) {
border-width: 4px;
left: -1px;
top: 5px;
width: 40px;
height: 40px;
}
.loader div:nth-child(6) {
border-width: 5px;
left: 0px;
top: -5px;
width: 50px;
height: 50px;
}
.loader div:nth-child(7) {
border-width: 5px;
left: 0px;
top: 8px;
width: 63px;
height: 63px;
}
@keyframes rotateAnim {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0deg);
}
}
@-o-keyframes rotateAnim {
from {
-o-transform: rotate(360deg);
}
to {
-o-transform: rotate(0deg);
}
}
@-ms-keyframes rotateAnim {
from {
-ms-transform: rotate(360deg);
}
to {
-ms-transform: rotate(0deg);
}
}
@-webkit-keyframes rotateAnim {
from {
-webkit-transform: rotate(360deg);
}
to {
-webkit-transform: rotate(0deg);
}
}
@-moz-keyframes rotateAnim {
from {
-moz-transform: rotate(360deg);
}
to {
-moz-transform: rotate(0deg);
}
}
</style>
\ No newline at end of file
Supports Markdown
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