ajout de la suppression d'une ligne d'un objet

This commit is contained in:
Christophe 2022-03-31 10:36:15 +02:00
parent ff03183fd6
commit 08ed7119e0
3 changed files with 57 additions and 7 deletions

View file

@ -0,0 +1,32 @@
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
function action_supprimer_gamuform_dist() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
list($id_objet,$objet) = explode('/', $arg);
include_spip('gamuform_fonctions');
if (
intval($id_objet)
and gamuform_objet_autoriser($objet)
) {
$id_objet = (int) $id_objet;
include_spip('inc/autoriser');
if (! autoriser('supprimer', 'gamuform', $id_objet, '', ['objet' => $objet])) {
return false;
}
$table = table_objet_sql($objet);
$id = id_table_objet($objet);
sql_delete($table, "$id=" . $id_objet);
include_spip('inc/invalideur');
suivre_invalideur("id='"."$id_objet"."/1");
}
}

View file

@ -44,3 +44,11 @@ function autoriser_gamuform_creer_dist($faire, $type, $id, $qui, $opt) {
return autoriser('webmestre');
}
function autoriser_gamuform_supprimer_dist($faire, $type, $id, $qui, $opt) {
if (!empty($opt['objet'])) {
return autoriser('voir', $opt['objet'], $id, $qui, []);
}
return autoriser('webmestre');
}

View file

@ -5,9 +5,10 @@
"header":{
"id": "id",
"edit": "",
<BOUCLE_header(DATA){source table,#GET{header}}{','}>
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
<BOUCLE_header(DATA){source table,#GET{header}}>
[(#CLE|json_encode)] : [(#VALEUR|json_encode)],
</BOUCLE_header>
"sup": ""
},
"crayons":{
},
@ -15,7 +16,8 @@
},
"classes" : {
"id": "w80p",
"edit": "w80p"
"edit": "w50p",
"sup": "w50p"
}
}
<B_gamuform>
@ -29,20 +31,28 @@
|parametre_url{redirect,gamutable})]">
<i class="fas fa-edit"></i>
</a> })]
[(#SET{sup,
<a class="url_action" href="[(#URL_ACTION_AUTEUR{supprimer_gamuform,#GET{ligne/id}/#ENV{objet},#SELF})]"
data-confirm="Confirmez vous la suppression de cette ligne ?"
>
<i class="fas fa-trash"></i>
</a>})]
{
"html": {
"id": #GET{ligne/id},
"edit": [(#GET{edit}|json_encode)],
<BOUCLE_headerB(DATA){source table,#GET{header}}{','}>
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|json_encode)]
<BOUCLE_headerB(DATA){source table,#GET{header}}>
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|json_encode)],
</BOUCLE_headerB>
"sup": [(#GET{sup}|json_encode)]
},
"search": {
"id": #GET{ligne/id},
"edit": "",
<BOUCLE_headerC(DATA){source table,#GET{header}}{','}>
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)]
<BOUCLE_headerC(DATA){source table,#GET{header}}>
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)],
</BOUCLE_headerC>
"sup":""
}
}
</BOUCLE_gamuform>