1 | <?php |
---|
2 | /* |
---|
3 | * Plugin En Travaux |
---|
4 | * (c) 2006-2009 Arnaud Ventre, Cedric Morin |
---|
5 | * Distribue sous licence GPL |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #var_dump($GLOBALS['meta']['entravaux_id_auteur']); |
---|
10 | |
---|
11 | /** |
---|
12 | * Autoriser a voir le site en travaux : par defaut tous les webmestre |
---|
13 | * @return mixed |
---|
14 | */ |
---|
15 | function autoriser_travaux_dist(){ return autoriser('webmestre'); } |
---|
16 | |
---|
17 | /** |
---|
18 | * A-t-on active les travaux oui ou non ? |
---|
19 | * @return bool |
---|
20 | */ |
---|
21 | function is_entravaux(){ return (isset($GLOBALS['meta']['entravaux_id_auteur']) AND $GLOBALS['meta']['entravaux_id_auteur']);} |
---|
22 | |
---|
23 | if (is_entravaux()){ |
---|
24 | include_spip('inc/autoriser'); |
---|
25 | |
---|
26 | // dans le site public |
---|
27 | // si auteur pas autorise : placer sur un cache dedie |
---|
28 | // si auteur autorise, desactiver le cache : |
---|
29 | // il voit le site, mais pas de cache car il travaille dessus ! |
---|
30 | if (!test_espace_prive()){ |
---|
31 | if (!autoriser('travaux')){ |
---|
32 | $GLOBALS['marqueur'].= ":en_travaux"; |
---|
33 | } |
---|
34 | else { |
---|
35 | // desactiver le cache sauf si inhibe par define |
---|
36 | if (!defined('_ENTRAVAUX_GARDER_CACHE')) |
---|
37 | define('_NO_CACHE',1); |
---|
38 | } |
---|
39 | } |
---|
40 | else { |
---|
41 | if (!in_array(_request('action'),array('logout')) |
---|
42 | ){ |
---|
43 | if (!autoriser('travaux')){ |
---|
44 | spip_initialisation_suite(); |
---|
45 | $travaux = recuperer_fond("inclure/entravaux",array()); |
---|
46 | // fallback : le fond renvoie parfois du vide ... |
---|
47 | if (!strlen($travaux)){ |
---|
48 | @define('_SPIP_SCRIPT','spip.php'); |
---|
49 | echo "Acces interdit (en travaux) <a href='" |
---|
50 | .generer_url_action('logout',"logout=public",false,true) |
---|
51 | ."'>Deconnexion</a>"; |
---|
52 | } |
---|
53 | else |
---|
54 | echo $travaux; |
---|
55 | die(); |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * Pipeline styliser pour rerouter tous les fonds vers en_travaux |
---|
63 | * sauf si l'auteur connecte est celui qui a active le plugin |
---|
64 | * |
---|
65 | * @param array $flux |
---|
66 | * @return array |
---|
67 | */ |
---|
68 | function entravaux_styliser($flux){ |
---|
69 | if (is_entravaux()){ |
---|
70 | include_spip('inc/autoriser'); |
---|
71 | if (!autoriser('travaux') |
---|
72 | AND !in_array( |
---|
73 | $flux['args']['fond'], |
---|
74 | // les pages exceptions |
---|
75 | array('login_sos','robots.txt','spip_pass', |
---|
76 | ) |
---|
77 | ) |
---|
78 | // et on laisse passer modeles et formulaires, |
---|
79 | // qui ne peuvent etre inclus ou appeles que legitimement |
---|
80 | AND strncmp($flux['args']['fond'],'modeles/',8)!=0 |
---|
81 | AND strncmp($flux['args']['fond'],'formulaires/',12)!=0){ |
---|
82 | $fond = trouver_fond('inclure/entravaux','',true); |
---|
83 | $flux['data'] = $fond['fond']; |
---|
84 | } |
---|
85 | } |
---|
86 | return $flux; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | /** |
---|
91 | * Afficher une icone de travaux sur tout le site public pour que le webmestre n'oublie pas |
---|
92 | * de retablir le site |
---|
93 | * |
---|
94 | * @param <type> $flux |
---|
95 | */ |
---|
96 | function entravaux_affichage_final($flux){ |
---|
97 | if (is_entravaux() |
---|
98 | AND !test_espace_prive() |
---|
99 | AND $GLOBALS['html'] |
---|
100 | AND !_AJAX){ |
---|
101 | include_spip('inc/filtres'); // pour http_img_pack |
---|
102 | $x = '<div id="icone_travaux" style=" |
---|
103 | padding-right: 5px; |
---|
104 | padding-top: 2px; |
---|
105 | padding-bottom: 5px; |
---|
106 | position: absolute; |
---|
107 | left: 26px; |
---|
108 | top: 26px; |
---|
109 | ">' |
---|
110 | . http_img_pack(chemin_image('entravaux-64.png'), _T('entravaux:en_travaux'), '', _T('entravaux:en_travaux')) |
---|
111 | . '</div>'; |
---|
112 | if (!$pos = strpos($flux, '</body>')) |
---|
113 | $pos = strlen($flux); |
---|
114 | $flux = substr_replace($flux, $x, $pos, 0); |
---|
115 | } |
---|
116 | return $flux; |
---|
117 | } |
---|
118 | |
---|
119 | /** |
---|
120 | * Afficher une notice sur l'accueil de ecrire |
---|
121 | * @param array $flux |
---|
122 | * @return array |
---|
123 | */ |
---|
124 | function entravaux_affiche_milieu($flux){ |
---|
125 | if (is_entravaux()){ |
---|
126 | if ($flux['args']['exec']=='accueil'){ |
---|
127 | $notice = recuperer_fond('inclure/entravaux_notice_ecrire',array()); |
---|
128 | if (strlen(trim($notice))) |
---|
129 | $flux['data'] = $notice . $flux['data']; |
---|
130 | } |
---|
131 | } |
---|
132 | if ($flux['args']['exec']=='configurer_identite'){ |
---|
133 | $flux['data'] .= recuperer_fond('prive/squelettes/contenu/configurer_entravaux',array()); |
---|
134 | } |
---|
135 | return $flux; |
---|
136 | } |
---|
137 | |
---|
138 | ?> |
---|