1 | <?php |
---|
2 | |
---|
3 | function agenda_ajouter_onglets($flux) { |
---|
4 | if($flux['args']=='calendrier' AND !defined('_DIR_PLUGIN_BANDO')){ |
---|
5 | $flux['data']['agenda']= new Bouton(chemin_image('agenda-24.png'), _T('agenda:agenda'), |
---|
6 | generer_url_ecrire("calendrier","type=semaine")); |
---|
7 | $flux['data']['calendrier']= new Bouton( |
---|
8 | 'cal-rv.png', _T('agenda:activite_editoriale'), |
---|
9 | generer_url_ecrire("calendrier","mode=editorial&type=semaine")); |
---|
10 | } |
---|
11 | return $flux; |
---|
12 | } |
---|
13 | |
---|
14 | function agenda_affiche_milieu($flux) { |
---|
15 | $exec = $flux['args']['exec']; |
---|
16 | $out = ""; |
---|
17 | if ($exec=='rubrique' |
---|
18 | AND $id_rubrique = intval($flux['args']['id_rubrique'])){ |
---|
19 | $activer = true; |
---|
20 | $res = ""; |
---|
21 | $actif = sql_getfetsel('agenda','spip_rubriques','id_rubrique='.intval($id_rubrique)); |
---|
22 | $statut="-32"; |
---|
23 | $voir = ""; |
---|
24 | if (!sql_countsel('spip_rubriques','agenda=1')) |
---|
25 | $res .= _T('agenda:aucune_rubrique_mode_agenda').'<br />'; |
---|
26 | else { |
---|
27 | include_spip('inc/agenda_gestion'); |
---|
28 | if (sql_countsel('spip_rubriques',sql_in('id_rubrique',calcul_hierarchie_in($id_rubrique))." AND agenda=1 AND id_rubrique<>".intval($id_rubrique))){ |
---|
29 | $res .= _T('agenda:rubrique_dans_une_rubrique_mode_agenda').'<br />'; |
---|
30 | $activer = false; |
---|
31 | $statut="-ok-32"; |
---|
32 | $voir = _T('agenda:voir_evenements_rubrique'); |
---|
33 | } |
---|
34 | elseif(!$actif) { |
---|
35 | $res .= _T('agenda:rubrique_sans_gestion_evenement').'<br />'; |
---|
36 | $statut="-non-32"; |
---|
37 | } |
---|
38 | if ($actif){ |
---|
39 | $res .= _T('agenda:rubrique_mode_agenda').'<br />'; |
---|
40 | $statut="-ok-32"; |
---|
41 | $voir = _T('agenda:voir_evenements_rubrique'); |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | if (!$actif){ |
---|
46 | if($activer){ |
---|
47 | $res .= "<a href='".generer_action_auteur('rubrique_activer_agenda',$id_rubrique,self())."'>"._T('agenda:rubrique_activer_agenda').'</a>'; |
---|
48 | } |
---|
49 | } |
---|
50 | else |
---|
51 | $res .= "<a href='".generer_action_auteur('rubrique_activer_agenda',"-$id_rubrique",self())."'>"._T('agenda:rubrique_desactiver_agenda').'</a>'; |
---|
52 | if ($voir) |
---|
53 | $res .= "<p><a href='".generer_url_ecrire('calendrier',"id_rubrique=$id_rubrique")."'>$voir</a></p>"; |
---|
54 | if ($res) |
---|
55 | $out .= "<div class='verdana2'><img src='".chemin_image("agenda$statut.png")."' class='agenda-statut' alt='' />$res<div class='nettoyeur'></div></div>"; |
---|
56 | } |
---|
57 | elseif ($exec=='articles'){ |
---|
58 | $id_article = $flux['args']['id_article']; |
---|
59 | $afficher = autoriser('creerevenementdans','article',$id_article); |
---|
60 | if ($afficher) { |
---|
61 | $contexte = array(); |
---|
62 | foreach($_GET as $key=>$val) |
---|
63 | $contexte[$key] = $val; |
---|
64 | $evenements = recuperer_fond('prive/contenu/evenements_article',$contexte); |
---|
65 | $out .= $evenements; |
---|
66 | } |
---|
67 | } |
---|
68 | elseif ($exec=='mots_edit'){ |
---|
69 | $id_mot = $flux['args']['id_mot']; |
---|
70 | foreach($_GET as $key=>$val) |
---|
71 | $contexte[$key] = $val; |
---|
72 | $evenements = recuperer_fond('prive/contenu/agenda_evenements',$contexte); |
---|
73 | $out .= $evenements; |
---|
74 | } |
---|
75 | if ($out){ |
---|
76 | if ($p=strpos($flux['data'],'<!--affiche_milieu-->')) |
---|
77 | $flux['data'] = substr_replace($flux['data'],$out,$p,0); |
---|
78 | else |
---|
79 | $flux['data'] .= $out; |
---|
80 | } |
---|
81 | return $flux; |
---|
82 | } |
---|
83 | |
---|
84 | function agenda_taches_generales_cron($taches_generales){ |
---|
85 | $taches_generales['agenda_nettoyer_base'] = 3600*48; |
---|
86 | return $taches_generales; |
---|
87 | } |
---|
88 | |
---|
89 | function agenda_editer_contenu_objet($flux){ |
---|
90 | if ($flux['args']['type']=='groupe_mot'){ |
---|
91 | // ajouter l'input sur les evenements |
---|
92 | $checked = in_array('evenements',$flux['args']['contexte']['tables_liees']); |
---|
93 | $checked = $checked?" checked='checked'":''; |
---|
94 | $input = "<div class='choix'><input type='checkbox' class='checkbox' name='tables_liees[]' value='evenements'$checked id='evenements' /><label for='evenements'>"._T('agenda:item_mots_cles_association_evenements')."</label></div>"; |
---|
95 | $flux['data'] = str_replace('<!--choix_tables-->',"$input\n<!--choix_tables-->",$flux['data']); |
---|
96 | } |
---|
97 | return $flux; |
---|
98 | } |
---|
99 | |
---|
100 | function agenda_libelle_association_mots($libelles){ |
---|
101 | $libelles['evenements'] = 'agenda:info_evenements'; |
---|
102 | return $libelles; |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | function agenda_objets_extensibles($objets){ |
---|
107 | return array_merge($objets, array('evenement' => _T('agenda:evenements'))); |
---|
108 | } |
---|
109 | |
---|
110 | function agenda_afficher_nombre_objets_associes_a($flux){ |
---|
111 | if ($flux['args']['objet']=='mot' |
---|
112 | AND $id_mot=$flux['args']['id_objet']){ |
---|
113 | $aff_articles = sql_in('A.statut', ($GLOBALS['connect_statut'] =="0minirezo") ? array('prepa','prop','publie') : array('prop','publie')); |
---|
114 | $nb = sql_countsel("spip_mots_liens AS L LEFT JOIN spip_evenements AS E ON E.id_evenement=L.id_objet AND L.objet='evenement' LEFT JOIN spip_articles AS A ON E.id_article=A.id_article", "L.id_mot=".intval($id_mot)." AND $aff_articles"); |
---|
115 | if ($nb) |
---|
116 | $flux['data'][] = singulier_ou_pluriel($nb, "agenda:info_un_evenement", "agenda:info_nombre_evenements"); |
---|
117 | } |
---|
118 | return $flux; |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * Declarer evenement comme un objet interpretable dans les url |
---|
123 | * ?evenement12 |
---|
124 | * |
---|
125 | * @param array $objets |
---|
126 | * @return array |
---|
127 | */ |
---|
128 | function agenda_declarer_url_objets($objets){ |
---|
129 | $objets[] = 'evenement'; |
---|
130 | return $objets; |
---|
131 | } |
---|
132 | ?> |
---|