root/_plugins_/acces_restreint/acces_restreint_pipelines.php

Revision 38939, 2.5 KB (checked in by marcimat@…, 6 weeks ago)

Autoriser les champs extras sur les zones restreintes...

Line 
1<?php
2/**
3 * Plugin Acces Restreint 3.0 pour Spip 2.0
4 * Licence GPL (c) 2006-2008 Cedric Morin
5 *
6 */
7
8if (!defined("_ECRIRE_INC_VERSION")) return;
9
10
11/**
12 * Ajouter le bouton de menu config si on a le droit
13 *
14 * @param unknown_type $boutons_admin
15 * @return unknown
16 */
17function accesrestreint_ajouter_boutons($boutons_admin) {
18        // si on est admin
19        if (autoriser('administrer','zone')) {
20                $menu = "configuration";
21                $icone = "img_pack/zones-acces-24.gif";
22                if (isset($boutons_admin['bando_configuration'])){
23                        $menu = "bando_configuration";
24                        $icone = "img_pack/zones-acces-24.gif";
25                }
26          // on voit le bouton dans la barre "naviguer"
27                $boutons_admin[$menu]->sousmenu['acces_restreint']= new Bouton(
28                _DIR_PLUGIN_ACCESRESTREINT.$icone,  // icone
29                _T('accesrestreint:icone_menu_config')  // titre
30                );
31        }
32        return $boutons_admin;
33}
34
35/**
36 * Ajouter la boite des zones sur la fiche auteur
37 *
38 * @param string $flux
39 * @return string
40 */
41function accesrestreint_affiche_milieu($flux){
42        switch($flux['args']['exec']) {
43                case 'auteur_infos':
44                        $id_auteur = $flux['args']['id_auteur'];
45                       
46                        $flux['data'] .= 
47                        recuperer_fond('prive/editer/affecter_zones',array('id_auteur'=>$id_auteur));
48                        break;
49        }
50        return $flux;
51}
52
53/**
54 * Detecter les demande d'acces aux pages restreintes
55 * et re-orienter vers une 401 si necessaire
56 *
57 * @param <type> $contexte
58 * @return <type>
59 */
60function accesrestreint_page_indisponible($contexte){
61        if ($contexte['status']=='404' AND isset($contexte['type'])){
62                $objet = $contexte['type'];
63                $table_sql = table_objet_sql($objet);
64                $id_table_objet = id_table_objet($objet);
65                if ($id = intval($contexte[$id_table_objet])){
66
67                        $publie = true;
68                        $restreint = false;
69
70                        $trouver_table = charger_fonction('trouver_table','base');
71                        $desc = $trouver_table($table_sql);
72                        if (isset($desc['field']['statut'])){
73                                $statut = sql_getfetsel('statut', $table_sql, "$id_table_objet=".intval($id));
74                                if ($statut!='publie')
75                                        $publie = false;
76                        }
77                       
78                        include_spip('inc/autoriser');
79                        if ($publie AND !autoriser('voir',$objet,$id)){
80                                // c'est un contenu restreint
81                                $contexte['status'] = '401';
82                                $contexte['code'] = '401 Unauthorized';
83                                $contexte['fond'] = '401';
84                                $contexte['erreur'] = _T('accesrestreint:info_acces_restreint');
85                                $contexte['cible'] = self();
86                        }
87                }
88        }
89        return $contexte;
90}
91
92/**
93 * Permettre l'ajout de champs extras via le plugin Champs Extras 2
94 *
95 * @param
96 * @return
97**/
98function accesrestreint_objets_extensibles($objets){
99                return array_merge($objets, array('zone' => _T('accesrestreint:titre_zones_acces')));
100}
101
102?>
Note: See TracBrowser for help on using the browser.