X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fexec%2Fauteurs.php;h=663ee8451e6fe35d4d53557f6cf95c290d7dc3a8;hp=99c82cce5fe78a8cd9b36f84adf37f87fa0257c8;hb=e99f0878011913365e49b30d90e496c24c301393;hpb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed diff --git a/www/ecrire/exec/auteurs.php b/www/ecrire/exec/auteurs.php index 99c82cc..663ee84 100644 --- a/www/ecrire/exec/auteurs.php +++ b/www/ecrire/exec/auteurs.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2011 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -56,9 +56,14 @@ function exec_auteurs_args($statut, $tri, $debut, $recherche=NULL, $trouve='', $ lettres_d_auteurs(requete_auteurs($tri, $statut, $recherche), $debut, MAX_AUTEURS_PAR_PAGE, $tri); - $recherche = auteurs_tranches(afficher_n_auteurs($auteurs), $debut, $lettre, $tri, $statut, MAX_AUTEURS_PAR_PAGE, $nombre_auteurs,$cherche); + + $arg = ($statut ? ("&statut=" .urlencode($statut)) : '') + . ($cherche ? ("&recherche=" . urlencode($cherche)) : ''); + + $recherche = auteurs_tranches(afficher_n_auteurs($auteurs), $debut, $lettre, $tri, $statut, MAX_AUTEURS_PAR_PAGE, $nombre_auteurs, $arg); if ($cherche){ + $cherche = htmlspecialchars($cherche); if (count($auteurs)) $recherche = "

". _T('info_resultat_recherche')." «$cherche»

" . $recherche; else @@ -79,7 +84,7 @@ function exec_auteurs_args($statut, $tri, $debut, $recherche=NULL, $trouve='', $ $visiteurs ? _T('info_visiteurs') : _T('info_auteurs'), "auteurs","redacteurs"); - echo bandeau_auteurs($tri, $visiteurs); + echo bandeau_auteurs($visiteurs); echo $trouve, "
"; @@ -90,9 +95,9 @@ function exec_auteurs_args($statut, $tri, $debut, $recherche=NULL, $trouve='', $ } // http://doc.spip.org/@bandeau_auteurs -function bandeau_auteurs($tri, $visiteurs) +function bandeau_auteurs($visiteurs) { - global $connect_id_auteur, $connect_statut, $connect_toutes_rubriques; + global $connect_id_auteur; $ret = debut_gauche("auteurs",true) . debut_boite_info(true); @@ -101,16 +106,16 @@ function bandeau_auteurs($tri, $visiteurs) else $ret .= "\n

"._T('info_gauche_auteurs'). '

'; - if ($connect_statut == '0minirezo') + if (autoriser('voir', 'auteur')) $ret .= "\n

". _T('info_gauche_auteurs_exterieurs') . '

'; $ret .= fin_boite_info(true); $ret .= pipeline('affiche_gauche',array('args'=>array('exec'=>'auteurs'),'data'=>'')); - if ($connect_statut == '0minirezo') { + if (autoriser('voir', 'auteur')) { - if ($connect_toutes_rubriques) + if (autoriser('creer', 'auteur')) $res = icone_horizontale(_T('icone_creer_nouvel_auteur'), generer_url_ecrire("auteur_infos", 'new=oui'), "auteur-24.gif", "creer.gif", false); else $res = ''; @@ -173,13 +178,10 @@ function lettres_d_auteurs($query, $debut, $max_par_page, $tri) } // http://doc.spip.org/@auteurs_tranches -function auteurs_tranches($auteurs, $debut, $lettre, $tri, $statut, $max_par_page, $nombre_auteurs, $cherche='') +function auteurs_tranches($auteurs, $debut, $lettre, $tri, $statut, $max_par_page, $nombre_auteurs, $arg='') { global $spip_lang_right; - $arg = ($statut ? ("&statut=" .urlencode($statut)) : '') - . ($cherche ? ("&recherche=" . urlencode($cherche)) : ''); - $res ="\n" . "\n"; @@ -291,37 +293,40 @@ function auteurs_href($clic, $args='', $att='') // http://doc.spip.org/@requete_auteurs function requete_auteurs($tri, $statut, $recherche=NULL) { - global $connect_statut, $spip_lang, $connect_id_auteur; + global $connect_id_auteur; - // - // Construire la requete - // - // si on n'est pas minirezo, ignorer les auteurs sans article // sauf les admins, toujours visibles. // limiter les statuts affiches - if ($connect_statut == '0minirezo') { + if (autoriser('voir', 'auteur')) { if ($statut[0]=='!') { $statut = substr($statut,1); $not = "NOT"; } else $not = ''; $visit = !statut_min_redac($statut); $statut = preg_split('/\W+/', $statut); - $sql_visible = sql_in("aut.statut", $statut, $not); + $where = sql_in("aut.statut", $statut, $not); } else { - $sql_visible = "( + $where = "( aut.statut = '0minirezo' OR aut.id_auteur=$connect_id_auteur OR " . sql_in('art.statut', array('prop', 'publie')) . ')'; $visit = false; } + if ($recherche) $where .= " AND $recherche" ; + return requete_auteurs_tri($tri, $where, $visit); +} + +function requete_auteurs_tri($tri, $where, $visit=false) +{ + global $spip_lang; $sql_sel = ''; $join = $visit ? "" : - (strpos($sql_visible,'art.statut')?("LEFT JOIN spip_auteurs_articles AS lien ON aut.id_auteur=lien.id_auteur" . " LEFT JOIN spip_articles AS art ON (lien.id_article = art.id_article)"):""); + (strpos($where,'art.statut')?("LEFT JOIN spip_auteurs_articles AS lien ON aut.id_auteur=lien.id_auteur" . " LEFT JOIN spip_articles AS art ON (lien.id_article = art.id_article)"):""); // tri switch ($tri) { @@ -331,7 +336,7 @@ function requete_auteurs($tri, $statut, $recherche=NULL) $join = $visit ? "LEFT JOIN spip_forum AS lien ON aut.id_auteur=lien.id_auteur" : ("LEFT JOIN spip_auteurs_articles AS lien ON aut.id_auteur=lien.id_auteur" - . (strpos($sql_visible,'art.statut')?" LEFT JOIN spip_articles AS art ON (lien.id_article = art.id_article)":"")); + . (strpos($where,'art.statut')?" LEFT JOIN spip_articles AS art ON (lien.id_article = art.id_article)":"")); break; case 'site': @@ -360,9 +365,7 @@ function requete_auteurs($tri, $statut, $recherche=NULL) "UPPER(aut.nom) AS unom", $sql_sel),array('',null)), 'FROM' => "spip_auteurs AS aut $join", - 'WHERE' => $sql_visible . ($recherche - ? " AND $recherche" - : ''), + 'WHERE' => $where, 'GROUP BY' => "aut.statut, aut.nom_site, aut.nom, aut.id_auteur", 'ORDER BY' => $sql_order); }