Skip to content

Commit

Permalink
Synchro options utilisatauers / admin
Browse files Browse the repository at this point in the history
[Ajout] Synchronisation de la langue avec tout les utilisateurs
[Ajout] Synchronisation du thème avec tout les utilisateurs
  • Loading branch information
JeromeDevome committed Dec 16, 2018
1 parent cc1e5ba commit a716656
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 36 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -20,6 +20,8 @@ Version en cours de développement sur GitHUB (4.0.0)
[Ajout] Changement de mot passe à la prochaine connexion
[Ajout] Possibilité lors de l'importation des utilisateurs par csv de demander de changer de mot de passe
[Ajout] Personnalisations de la couleur du texte par type de réservation
[Ajout] Synchronisation de la langue avec tout les utilisateurs
[Ajout] Synchronisation du thème avec tout les utilisateurs
[Correction] Déconnexion utilisateur lorsque une connexion externe est activée
[Modification] Administration : passage sous twig
[Modification] Administration : Theme AdminLTE
Expand Down
19 changes: 18 additions & 1 deletion admin/controleurs/admin_config6.php
Expand Up @@ -23,6 +23,24 @@
get_vocab_admin("admin_config5");
get_vocab_admin("admin_config6");

$msg = '';

if (isset($_GET['sync'])) {
if ($_GET['sync'] == 1) {
$sql = "UPDATE ".TABLE_PREFIX."_utilisateurs SET default_style=''"; // Vide = choix admin
if (grr_sql_command($sql) < 0)
fatal_error(0, grr_sql_error());
else
$msg .= "Synchronisation terminée !<br />";
} elseif ($_GET['sync'] == 2) {
$sql = "UPDATE ".TABLE_PREFIX."_utilisateurs SET default_language='".Settings::get('default_language')."'";
if (grr_sql_command($sql) < 0)
fatal_error(0, grr_sql_error());
else
$msg .= "Synchronisation terminée !<br />";
}
}


if (isset($_POST['show_courrier'])) {
if (!Settings::set('show_courrier', $_POST['show_courrier'])) {
Expand Down Expand Up @@ -242,7 +260,6 @@
}
}
//echo $_POST['default_area']."<br />";
$msg = '';

if (!Settings::load()) {
die('Erreur chargement settings');
Expand Down
99 changes: 67 additions & 32 deletions admin/templates/admin_config6.twig
Expand Up @@ -55,19 +55,22 @@
<hr>
<div class="form-group col-sm-12">
<label class="col-sm-6" for="default_css">{{ trad.explain_css }}</label>
<div class="col-sm-6">
<div class="col-sm-5">
<select class="form-control" name="default_css">
{{ trad.dOptionTheme | raw }}
</select>
</div>
<div class="col-sm-1"><button type="button" class="btn btn-warning btn-md" data-toggle="modal" data-target="#modal-warning" data-texte="Confirmer la synchronisation du thème avec tout les utilisateurs ?" data-idsup="1"><i class="icon fa fa-sync"></i></button>
</div>
<hr>
<div class="form-group col-sm-12">
<label class="col-sm-6" for="default_language">{{ trad.choose_language }}</label>
<div class="col-sm-6">
<div class="col-sm-5">
<select class="form-control" name="default_language">
{{ trad.dOptionLangue | raw }}
</select>
</div>
<div class="col-sm-1"><button type="button" class="btn btn-warning btn-md" data-toggle="modal" data-target="#modal-warning" data-texte="Confirmer la synchronisation de la langue avec tout les utilisateurs ?" data-idsup="2"><i class="icon fa fa-sync"></i></button>
</div>
</section>

Expand Down Expand Up @@ -140,22 +143,6 @@
</section>

<hr>
<!--
<section id="descriptionbreve">
<h4 class="page-header">{{ trad.display_short_description_msg }}</h4>
<input type="radio" name="display_short_description" value="0" id="label_4a" {% if settings.display_short_description == '0' %} checked {% endif %} /> <label for="label_4a">{{ trad.display_short_description0 }}</label><br>
<input type="radio" name="display_short_description" value="1" id="label_4b" {% if settings.display_short_description == '1' %} checked {% endif %} /> <label for="label_4b">{{ trad.display_short_description1 }}</label><br>
</section>
<hr>
<section id="descriptioncomple">
<h4 class="page-header">{{ trad.display_full_description_msg }}</h4>
<input type="radio" name="display_full_description" value="0" id="label_5a" {% if settings.display_full_description == '0' %} checked {% endif %} /> <label for="label_5a">{{ trad.display_full_description0 }}</label><br>
<input type="radio" name="display_full_description" value="1" id="label_5b" {% if settings.display_full_description == '1' %} checked {% endif %} /> <label for="label_5b">{{ trad.display_full_description1 }}</label><br>
</section>
-->
<hr>

<section id="liensemail">
<h4 class="page-header">{{ trad.display_level_email_msg1 }}</h4>
Expand Down Expand Up @@ -230,23 +217,9 @@
</table>

</section>
<!--
<section id="legende">
<h4 class="page-header">{{ trad.legend_msg }}</h4>
<input type="radio" name="legend" value="0" id="label_1a" {% if settings.legend == '0' %} checked {% endif %} /> <label for="label_1a">{{ trad.YES }}</label><br>
<input type="radio" name="legend" value="1" id="label_1b" {% if settings.legend == '1' %} checked {% endif %} /> <label for="label_1b">{{ trad.NO }}</label><br>
</section>

<hr>

<section id="imprimante">
<h4 class="page-header">{{ trad.imprimante_msg }}</h4>
<input type="radio" name="imprimante" value="0" id="label_1a" {% if settings.imprimante == '0' %} checked {% endif %} /> <label for="label_1a">{{ trad.YES }}</label><br>
<input type="radio" name="imprimante" value="1" id="label_1b" {% if settings.imprimante == '1' %} checked {% endif %} /> <label for="label_1b">{{ trad.NO }}</label><br>
</section>
-->
<hr>

<section id="periodicite">
<h4 class="page-header">{{ trad.periodicite_msg }}</h4>
<input type="radio" name="periodicite" value="y" id="label_1a" {% if settings.periodicite == 'y' %} checked {% endif %} /> <label for="label_1a">{{ trad.YES }}</label><br>
Expand Down Expand Up @@ -308,6 +281,27 @@
<!-- /.col -->
</div>

<div class="modal modal-warning fade" id="modal-warning">
<form action="?p=admin_config6">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Synchronisation</h4>
</div>
<div class="modal-body">
<span id="modal-texte"></span><span id="modal-idsup" class="hidden"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline pull-left" data-dismiss="modal">{{trad.NO}}</button>
<button type="submit" id="liensup" class="btn btn-outline">{{trad.YES}}</button>
</div>
</div>
</div>
</form>
</div>

{% endblock %}

{% block javascript %}
Expand Down Expand Up @@ -353,6 +347,47 @@
}
modifier_liste_domaines();
modifier_liste_ressources(1);
// MODAL
// data-* attributes to scan when populating modal values
var ATTRIBUTES = ['texte', 'idsup'];
$('[data-toggle="modal"]').on('click', function (e) {
// convert target (e.g. the button) to jquery object
var $target = $(e.target);
// modal targeted by the button
var modalSelector = $target.data('target');
// iterate over each possible data-* attribute
ATTRIBUTES.forEach(function (attributeName) {
// retrieve the dom element corresponding to current attribute
var $modalAttribute = $(modalSelector + ' #modal-' + attributeName);
var dataValue = $target.data(attributeName);
// if the attribute value is empty, $target.data() will return undefined.
// In JS boolean expressions return operands and are not coerced into
// booleans. That way is dataValue is undefined, the left part of the following
// Boolean expression evaluate to false and the empty string will be returned
$modalAttribute.text(dataValue || '');
});
});
$(function(){
$('form').submit(function(e) {
e.preventDefault()
var $form = $(this)
var v=document.getElementById('modal-idsup').innerHTML
$.post($form.attr('action'), $form.serialize())
.done(function(data) {
$('#html').html(data);
$('#modal-warning').modal('hide');
document.location.href='?p=admin_config6&sync='+v;
})
.fail(function() {
alert('Une erreur est survenue : GRRJS')
})
})
})
</script>

{% endblock %}
6 changes: 3 additions & 3 deletions admin/templates/admin_type.twig
Expand Up @@ -53,7 +53,7 @@
</div>
</div>

<div class="modal modal-warning fade" id="modal-warning">
<div class="modal modal-warning fade" id="modal-warning">
<form action="?p=admin_type">
<div class="modal-dialog">
<div class="modal-content">
Expand All @@ -71,8 +71,8 @@
</div>
</div>
</div>
</form>
</div>
</form>
</div>
{% endblock %}

{% block javascript %}
Expand Down

0 comments on commit a716656

Please sign in to comment.