[PLUGINS] +acces restreint
[ptitvelo/web/www.git] / www / plugins / accesrestreint_3_5 / formulaires / configurer_accesrestreint.php
1 <?php
2 /**
3 * Plugin Acces Restreint 3.0 pour Spip 2.0
4 * Licence GPL (c) 2006-2008 Cedric Morin
5 *
6 */
7
8 if (!defined("_ECRIRE_INC_VERSION")) return;
9
10 function formulaires_configurer_accesrestreint_charger_dist(){
11 $valeurs = array(
12 'accesrestreint_proteger_documents' => isset($GLOBALS['meta']["accesrestreint_proteger_documents"])?$GLOBALS['meta']["accesrestreint_proteger_documents"]:'non',
13 'creer_htpasswd' => $GLOBALS['meta']["creer_htpasswd"]?$GLOBALS['meta']["creer_htpasswd"]:'non',
14 );
15
16 return $valeurs;
17 }
18
19 function formulaires_configurer_accesrestreint_traiter_dist(){
20
21 $champs = array('accesrestreint_proteger_documents','creer_htpasswd');
22 $current = $GLOBALS['meta']["accesrestreint_proteger_documents"];
23
24 foreach($champs as $c)
25 ecrire_meta($c,_request($c)=='oui'?'oui':'non');
26
27 // generer/supprimer les fichiers htaccess qui vont bien
28 include_spip("inc/accesrestreint_documents");
29 accesrestreint_gerer_htaccess($GLOBALS['meta']["accesrestreint_proteger_documents"]=="oui");
30
31 // si le reglage du htaccess a change, purger le cache
32 if ($GLOBALS['meta']["accesrestreint_proteger_documents"]!==$current) {
33 $purger = charger_fonction("purger","action");
34 $purger("cache");
35 }
36
37 return array('message_ok'=>_T('config_info_enregistree'),'editable'=>true);
38 }