ajout bouton pour sauvegarder un modele d'autorisation, dans un champ aut_modele de la table spip_auteurs
This commit is contained in:
parent
1f9c6bbbfb
commit
19496d4e20
8 changed files with 165 additions and 9 deletions
|
@ -27,7 +27,7 @@ function auted_upgrade($nom_meta_base_version, $version_cible) {
|
|||
$maj = array();
|
||||
|
||||
$maj['create'] = array(array('maj_tables', array('spip_aut_mods','spip_auteurs')));
|
||||
$maj['1.0.1'] = array(array('maj_tables', array('spip_aut_mods','spip_auteurs')));
|
||||
$maj['1.0.2'] = array(array('maj_tables', array('spip_aut_mods','spip_auteurs')));
|
||||
|
||||
include_spip('base/upgrade');
|
||||
maj_plugin($nom_meta_base_version, $version_cible, $maj);
|
||||
|
|
|
@ -96,6 +96,7 @@ function auted_declarer_tables_objets_sql($tables) {
|
|||
function auted_declarer_tables_principales($tables_principales){
|
||||
|
||||
$tables_principales['spip_auteurs']['field']['autorisations'] = "text NOT NULL";
|
||||
$tables_principales['spip_auteurs']['field']['aut_modele'] = "text NOT NULL";
|
||||
|
||||
return $tables_principales;
|
||||
}
|
||||
|
|
|
@ -9,3 +9,29 @@
|
|||
.formulaire_editer_autorisations table tr:nth-child(even) {
|
||||
background-color: rgb(231, 233, 237);
|
||||
}
|
||||
|
||||
.icone_svg {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
vertical-align: -0.15em;
|
||||
fill: currentColor;
|
||||
overflow: hidden;
|
||||
}
|
||||
.icone_svg.checked {
|
||||
transform: rotate(180deg);
|
||||
fill: green;
|
||||
}
|
||||
|
||||
button[type='button'].toggle_save_modele {
|
||||
float: right;
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
min-width: 20px;
|
||||
padding: 0;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.pas_modele.enregistrer_modele input {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
|
||||
|
||||
|
||||
<form name="formulaire_#FORM" action="#ENV{action}" method="post"><div>
|
||||
#ACTION_FORMULAIRE{#ENV{action}}
|
||||
|
||||
|
@ -22,13 +23,30 @@
|
|||
{pgp ?!IN #ENV{pgp}}
|
||||
{webmestre?}
|
||||
{tout}>
|
||||
[(#SET{nom_modele,#AUT_MODELE|json_decode{true}|table_valeur{name}})]
|
||||
<tr id="auteur-#ID_AUTEUR" data-id_auteur="#ID_AUTEUR">
|
||||
<td>
|
||||
[(#PGP|=={boss}|oui)
|
||||
<img class="boss" src="[(#CHEMIN{img/boss.png})]" alt="boss"/>
|
||||
]
|
||||
#NOM
|
||||
<input type="hidden" name="Tid_auteur[]" value="#ID_AUTEUR">
|
||||
<div>
|
||||
[(#PGP|=={boss}|oui)
|
||||
<img class="boss" src="[(#CHEMIN{img/boss.png})]" alt="boss"/>
|
||||
]
|
||||
#NOM
|
||||
[(#PGP|=={boss}|non)
|
||||
<button class="toggle_save_modele" type="button"
|
||||
title="<:auted:sauvegarder_modele:>"
|
||||
data-id_auteur="#ID_AUTEUR"
|
||||
>
|
||||
<svg class="icone_svg [ (#GET{nom_modele}|oui)checked]" alt="">
|
||||
<title></title>
|
||||
<use xlink:href="[(#CHEMIN{img/toggle.svg})]#toggle" />
|
||||
</svg>
|
||||
</button>
|
||||
]
|
||||
</div>
|
||||
<div class="enregistrer_modele modele-#ID_AUTEUR[ (#GET{nom_modele}|non)pas_modele]">
|
||||
<input id="modele-#ID_AUTEUR" class="" type="text" value="[(#GET{nom_modele})]" name="modele-#ID_AUTEUR"/>
|
||||
</div>
|
||||
<input type="hidden" name="Tid_auteur[]" value="#ID_AUTEUR" placeholder="Nom modèle">
|
||||
</td>
|
||||
<BOUCLE_valeurAuth(DATA){source tableau, #ENV{auth_modele}}>
|
||||
[(#SET{autorisations,#AUTORISATIONS|json_decode{true}|table_valeur{#VALEUR{type}}})]
|
||||
|
@ -46,3 +64,24 @@
|
|||
<p class="boutons"><input type="submit" class="submit" value="Valider" ></p>
|
||||
</div></form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(function() {
|
||||
editer_autorisations();
|
||||
//onAjaxLoad(editer_autorisations);
|
||||
|
||||
function editer_autorisations(){
|
||||
$('.toggle_save_modele').on('click', function(e){
|
||||
e.stopPropagation();
|
||||
var id_auteur = $(this).data('id_auteur');
|
||||
var nom_modele = $('#modele-'+id_auteur).val().trim();
|
||||
if (!nom_modele) {
|
||||
$('.modele-'+id_auteur).toggleClass('pas_modele');
|
||||
$(this).children('svg').toggleClass('checked');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -20,9 +20,11 @@ function formulaires_editer_autorisations_traiter_dist($id_auteur=0, $redirect='
|
|||
include_spip('inc/session');
|
||||
$retour = array();
|
||||
|
||||
|
||||
$Tid_auteur = _request('Tid_auteur');
|
||||
foreach ($Tid_auteur as $id) {
|
||||
$Tauths =_request('id-'.$id);
|
||||
$Tauths = _request('id-' . $id);
|
||||
$nom_modele = _request('modele-' . $id);
|
||||
$Tautorisations = [];
|
||||
|
||||
if (!empty($Tauths)) {
|
||||
|
@ -32,6 +34,15 @@ function formulaires_editer_autorisations_traiter_dist($id_auteur=0, $redirect='
|
|||
}
|
||||
|
||||
$set = [ 'autorisations' => json_encode($Tautorisations) ];
|
||||
|
||||
if ($nom_modele) {
|
||||
$aut_modele = [
|
||||
'name' => $nom_modele,
|
||||
'modele' => $Tautorisations
|
||||
];
|
||||
$set['aut_modele'] = json_encode($aut_modele);
|
||||
}
|
||||
|
||||
sql_updateq('spip_auteurs', $set, 'id_auteur='.intval($id));
|
||||
|
||||
$auteur = sql_fetsel('*', 'spip_auteurs','id_auteur='.intval($id));
|
||||
|
|
53
img/save.svg
Normal file
53
img/save.svg
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
inkscape:version="1.1-dev (6c977cb37d, 2020-02-03)"
|
||||
sodipodi:docname="save.svg"
|
||||
id="save_modele"
|
||||
clip-rule="evenodd"
|
||||
fill-rule="evenodd"
|
||||
y="0px"
|
||||
x="0px"
|
||||
viewBox="0 0 290 316"
|
||||
style="image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"
|
||||
version="1.1"
|
||||
xml:space="preserve"><metadata
|
||||
id="metadata933"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
|
||||
inkscape:current-layer="svg929"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-x="0"
|
||||
inkscape:cy="205.65035"
|
||||
inkscape:cx="146.2519"
|
||||
inkscape:zoom="1.5607595"
|
||||
showgrid="false"
|
||||
id="namedview931"
|
||||
inkscape:window-height="1416"
|
||||
inkscape:window-width="2556"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
guidetolerance="10"
|
||||
gridtolerance="10"
|
||||
objecttolerance="10"
|
||||
borderopacity="1"
|
||||
bordercolor="#666666"
|
||||
pagecolor="#ffffff" /><defs
|
||||
id="defs915"><style
|
||||
id="style913"
|
||||
type="text/css">
|
||||
|
||||
.fil0 {fill:black;fill-rule:nonzero}
|
||||
|
||||
</style></defs><path
|
||||
class="fil0"
|
||||
d="M 60,296 V 181 c 0,-6 5,-10 10,-10 h 150 c 5,0 10,5 10,10 v 115 h 27 c 8,0 13,-8 13,-15 V 96 L 201,20 h -7 v 64 c 0,5 -5,10 -10,10 H 71 C 65,94 60,89 60,84 V 20 H 33 c -8,0 -13,8 -13,15 v 246 c 0,7 5,15 13,15 z m 150,0 V 191 H 80 V 296 Z M 33,0 c 57,0 115,0 172,0 3,0 6,1 8,4 l 74,81 c 2,2 3,5 3,7 v 189 c 0,18 -14,35 -33,35 H 33 C 14,316 0,299 0,281 V 35 C 0,17 14,0 33,0 Z M 174,20 H 80 v 54 h 94 z"
|
||||
id="path917"
|
||||
inkscape:connector-curvature="0" /></svg>
|
After Width: | Height: | Size: 2.2 KiB |
26
img/toggle.svg
Normal file
26
img/toggle.svg
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
id="toggle"
|
||||
xml:space="preserve"
|
||||
enable-background="new 0 0 100 100"
|
||||
viewBox="0 0 87.833 50.546001"
|
||||
y="0px"
|
||||
x="0px"
|
||||
version="1.1"><metadata
|
||||
id="metadata1082"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs1080" /><g
|
||||
transform="translate(-6.083,-24.727)"
|
||||
id="g1070"><path
|
||||
id="path1066"
|
||||
d="M 69.802,24.727 H 30.197 C 16.901,24.727 6.083,36.064 6.083,50 c 0,13.936 10.818,25.273 24.114,25.273 H 69.801 C 83.097,75.273 93.916,63.935 93.916,50 93.917,36.064 83.098,24.727 69.802,24.727 Z m 0,46.868 H 30.197 C 18.929,71.595 9.762,61.908 9.762,50 c 0,-11.907 9.167,-21.595 20.436,-21.595 h 39.604 c 11.269,0 20.437,9.688 20.437,21.595 -0.001,11.908 -9.169,21.595 -20.437,21.595 z" /><circle
|
||||
id="circle1068"
|
||||
r="18.622"
|
||||
cy="50"
|
||||
cx="32.073002" /></g></svg>
|
After Width: | Height: | Size: 1.3 KiB |
|
@ -1,12 +1,12 @@
|
|||
<paquet
|
||||
prefix="auted"
|
||||
categorie="outil"
|
||||
version="1.0.0"
|
||||
version="1.0.2"
|
||||
etat="dev"
|
||||
compatibilite="[3.2.0-dev;3.3.*]"
|
||||
logo="prive/themes/spip/images/auted-64.png"
|
||||
documentation=""
|
||||
schema="1.0.0"
|
||||
schema="1.0.2"
|
||||
>
|
||||
<!--
|
||||
Paquet généré le 2020-02-10 11:18:59
|
||||
|
|
Loading…
Add table
Reference in a new issue