1 | <?php |
---|
2 | |
---|
3 | function FpipR_affiche_milieu($flux) { |
---|
4 | if(!isset($GLOBALS['FLICKR_API_KEY']) && !isset($GLOBALS['FLICKR_SECRET'])) return $flux; |
---|
5 | |
---|
6 | if($flux['args']['exec'] == 'auteur_infos' && _request('initial') < 0) { |
---|
7 | global $table_prefix, $connect_id_auteur; |
---|
8 | |
---|
9 | include_spip('base/abstract_sql'); |
---|
10 | |
---|
11 | if($connect_id_auteur == $flux['args']['id_auteur']) { |
---|
12 | |
---|
13 | include_spip('inc/presentation'); |
---|
14 | |
---|
15 | $html = '<div> </div>'; |
---|
16 | $html .= '<div style="margin-top: 14px;" class="cadre-r"> |
---|
17 | <div style="position: relative;"> |
---|
18 | <div style="position: absolute; top: -16px; left: 10px;"> |
---|
19 | <img src="'.find_in_path('fpipr.gif').'"/> |
---|
20 | </div> |
---|
21 | </div> |
---|
22 | <div style="overflow: hidden;" class="cadre-padding">'; |
---|
23 | $html .= '<h3>'._T('fpipr:autorisation_titre').'</h3>'; |
---|
24 | include_spip('inc/flickr_api'); |
---|
25 | |
---|
26 | |
---|
27 | $from = array('spip_auteurs'); |
---|
28 | $select = array('flickr_token','flickr_nsid'); |
---|
29 | $where = array('id_auteur='.$flux['args']['id_auteur']); |
---|
30 | $rez = spip_abstract_select($select,$from,$where); |
---|
31 | $row = spip_abstract_fetch($rez); |
---|
32 | $wrong = false; |
---|
33 | if($row['flickr_nsid'] != '' && $row['flickr_token'] != '') { |
---|
34 | $check = flickr_auth_checkToken($row['flickr_token']); |
---|
35 | if($check) { |
---|
36 | $html .= _T('fpipr:identifie_ok',array('user_id'=>'<a href="http://www.flickr.com/photos/'.$row['flickr_nsid'].'">'.$row['flickr_nsid'].'</a>')); |
---|
37 | |
---|
38 | $html .= flickr_bookmarklet_info(); |
---|
39 | } else { |
---|
40 | include_spip('base/abstract_sql'); |
---|
41 | global $table_prefix; |
---|
42 | spip_query("UPDATE ".$table_prefix."_auteurs SET flickr_nsid = '', flickr_token = '' WHERE id_auteur=$connect_id_auteur"); |
---|
43 | $wrong = true; |
---|
44 | } |
---|
45 | } else $wrong = true; |
---|
46 | if($wrong){ |
---|
47 | $infos = flickr_authenticate_get_frob(); |
---|
48 | $html .= '<ol><li>'. |
---|
49 | _T('fpipr:identifie_etape1',array('url'=>$infos['url'])). |
---|
50 | '</li> |
---|
51 | <li>'. |
---|
52 | _T('fpipr:identifie_etape2',array('form'=>generer_action_auteur('flickr_authenticate_end',$infos['frob'], generer_url_ecrire('auteurs_edit','id_auteur='.$connect_id_auteur,true),'<button type="submit">'._T('fpipr:terminer').'</button>'))). |
---|
53 | '</li></ol>'; |
---|
54 | } |
---|
55 | spip_abstract_free($rez); |
---|
56 | $html .= fin_cadre_relief(true); |
---|
57 | $flux['data'].=$html; |
---|
58 | } |
---|
59 | } |
---|
60 | return $flux; |
---|
61 | } |
---|
62 | |
---|
63 | function FpipR_affiche_gauche($flux) { |
---|
64 | global $connect_id_auteur; |
---|
65 | if(!isset($GLOBALS['FLICKR_API_KEY']) && !isset($GLOBALS['FLICKR_SECRET'])) return $flux; |
---|
66 | |
---|
67 | //Verifier les droits des auteurs |
---|
68 | if((($flux['args']['exec'] == 'articles') && ($GLOBALS['meta']["documents_articles"] != 'non')) || (($flux['args']['exec'] == 'naviguer')&& ($GLOBALS['meta']["documents_rubriques"] != 'non')) || (($flux['args']['exec'] == 'breves_edit')&& ($GLOBALS['meta']["documents_breves"] != 'non'))) { |
---|
69 | include_spip('base/abstract_sql'); |
---|
70 | if($flux['args']['exec'] == 'articles') { |
---|
71 | $type = 'article'; |
---|
72 | $id = intval(_request('id_article')); |
---|
73 | $row = spip_abstract_fetsel(array('statut','id_rubrique'),array('spip_articles'),array("id_article=$id")); |
---|
74 | $cnt = spip_abstract_fetsel(array('count(*) as cnt'),array('spip_auteurs_articles'),array("id_article=$id",'id_auteur='.$connect_id_auteur)); |
---|
75 | $acces = acces_rubrique($row['id_rubrique']) || acces_restreint_rubrique($row['id_rubrique']) || (($row['statut'] == 'prepa' || $row['statut'] == 'prop' || $row['statut'] == 'poubelle') && $cnt['cnt'] > 0); |
---|
76 | } else if($flux['args']['exec'] == 'naviguer') { |
---|
77 | $type = 'rubrique'; |
---|
78 | $id = intval(_request('id_rubrique')); |
---|
79 | $acces = acces_rubrique($id_rubrique); |
---|
80 | } /*else if($flux['args']['exec'] == 'breves_edit') { |
---|
81 | $type = 'breve'; |
---|
82 | $id = _request('id_breve'); |
---|
83 | $row = spip_abstract_fetsel(array('statut','id_rubrique'),array('spip_breves'), array('id_breve='.$flux['args']['id_breve'])); |
---|
84 | $acces = true; //si on est arrivé là c'est qu'on a le droit de faire les modifs |
---|
85 | }*/ |
---|
86 | if($acces) { |
---|
87 | $to_ret = '<div> </div>'; |
---|
88 | $to_ret .='<div style="z-index: 1;" class="bandeau_rubriques"> |
---|
89 | <div style="position: relative;"> |
---|
90 | <div style="position: absolute; top: -12px; left: 3px;"> |
---|
91 | <font size="1" face="Verdana,Arial,Sans,sans-serif"> |
---|
92 | <img alt="article-24" src="'.find_in_path('fpipr.gif').'"/> |
---|
93 | </font> |
---|
94 | </div> |
---|
95 | <div class="verdana2" style="border-bottom: 1px solid rgb(68, 68, 68); padding: 3px 3px 3px 30px; background-color: white; color: black;"> |
---|
96 | <font size="1" face="Verdana,Arial,Sans,sans-serif"> |
---|
97 | <b>'._T('fpipr:Flickr').'</b> |
---|
98 | </font> |
---|
99 | </div> |
---|
100 | </div>'; |
---|
101 | $to_ret .= '<div class="plan-articles">'; |
---|
102 | |
---|
103 | $to_ret .= '<a class="thickbox" href="'.generer_url_ecrire('flickr_choix_photos',"type=$type&id=$id",true).'">'._T('fpipr:ajouter_photos').'</a>'; |
---|
104 | $to_ret .= '<a class="thickbox" href="'.generer_url_ecrire('flickr_choix_sets',"type=$type&id=$id",true).'">'._T('fpipr:ajouter_sets').'</a>'; |
---|
105 | $to_ret .= '</div>'; |
---|
106 | $to_ret .= '</div></div>'; |
---|
107 | |
---|
108 | $flux['data'] .= $to_ret; |
---|
109 | |
---|
110 | } |
---|
111 | } |
---|
112 | return $flux; |
---|
113 | } |
---|
114 | |
---|
115 | ?> |
---|