@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,28 +280,28 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet) { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 289 | - return $qui[$objet][$id_objet] = ''; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - include_spip('inc/drapeau_edition'); |
|
| 293 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 294 | - if (!$modif) { |
|
| 295 | - return $qui[$objet][$id_objet] = ''; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - include_spip('base/objets'); |
|
| 299 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 300 | - if (isset($infos['texte_signale_edition'])) { |
|
| 301 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 289 | + return $qui[$objet][$id_objet] = ''; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + include_spip('inc/drapeau_edition'); |
|
| 293 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 294 | + if (!$modif) { |
|
| 295 | + return $qui[$objet][$id_objet] = ''; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + include_spip('base/objets'); |
|
| 299 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 300 | + if (isset($infos['texte_signale_edition'])) { |
|
| 301 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -319,53 +319,53 @@ discard block |
||
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | 321 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 322 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 323 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - switch ($quoi) { |
|
| 327 | - case 'redacteurs': |
|
| 328 | - $statut = AUTEURS_MIN_REDAC; |
|
| 329 | - $statut = explode(',', $statut); |
|
| 330 | - if ($en_base) { |
|
| 331 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 332 | - $retire = array_diff($statut, $check); |
|
| 333 | - $statut = array_diff($statut, $retire); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return array_unique($statut); |
|
| 337 | - |
|
| 338 | - case 'visiteurs': |
|
| 339 | - $statut = []; |
|
| 340 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 341 | - $exclus = explode(',', $exclus); |
|
| 342 | - if (!$en_base) { |
|
| 343 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 344 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 345 | - } |
|
| 346 | - $s_complement = array_column( |
|
| 347 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 348 | - 'statut' |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 352 | - |
|
| 353 | - default: |
|
| 354 | - case 'tous': |
|
| 355 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 356 | - $s_complement = array_column( |
|
| 357 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 358 | - 'statut' |
|
| 359 | - ); |
|
| 360 | - $statut = array_merge($statut, $s_complement); |
|
| 361 | - if ($en_base) { |
|
| 362 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 363 | - $retire = array_diff($statut, $check); |
|
| 364 | - $statut = array_diff($statut, $retire); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - return array_unique($statut); |
|
| 368 | - } |
|
| 322 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 323 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + switch ($quoi) { |
|
| 327 | + case 'redacteurs': |
|
| 328 | + $statut = AUTEURS_MIN_REDAC; |
|
| 329 | + $statut = explode(',', $statut); |
|
| 330 | + if ($en_base) { |
|
| 331 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 332 | + $retire = array_diff($statut, $check); |
|
| 333 | + $statut = array_diff($statut, $retire); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + return array_unique($statut); |
|
| 337 | + |
|
| 338 | + case 'visiteurs': |
|
| 339 | + $statut = []; |
|
| 340 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 341 | + $exclus = explode(',', $exclus); |
|
| 342 | + if (!$en_base) { |
|
| 343 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 344 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 345 | + } |
|
| 346 | + $s_complement = array_column( |
|
| 347 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 348 | + 'statut' |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 352 | + |
|
| 353 | + default: |
|
| 354 | + case 'tous': |
|
| 355 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 356 | + $s_complement = array_column( |
|
| 357 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 358 | + 'statut' |
|
| 359 | + ); |
|
| 360 | + $statut = array_merge($statut, $s_complement); |
|
| 361 | + if ($en_base) { |
|
| 362 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 363 | + $retire = array_diff($statut, $check); |
|
| 364 | + $statut = array_diff($statut, $retire); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + return array_unique($statut); |
|
| 368 | + } |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -381,28 +381,28 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 383 | 383 | |
| 384 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 385 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 386 | - ? '' |
|
| 387 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 388 | - |
|
| 389 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 390 | - if ($objet == 'rubrique') { |
|
| 391 | - $id_rubrique = 0; |
|
| 392 | - } else { |
|
| 393 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 397 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 398 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 399 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 400 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - return $id_rubrique; |
|
| 384 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 385 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 386 | + ? '' |
|
| 387 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 388 | + |
|
| 389 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 390 | + if ($objet == 'rubrique') { |
|
| 391 | + $id_rubrique = 0; |
|
| 392 | + } else { |
|
| 393 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 397 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 398 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 399 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 400 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + return $id_rubrique; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -413,12 +413,12 @@ discard block |
||
| 413 | 413 | * @return string |
| 414 | 414 | */ |
| 415 | 415 | function lien_article_virtuel($virtuel) { |
| 416 | - include_spip('inc/lien'); |
|
| 417 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 418 | - return ''; |
|
| 419 | - } |
|
| 416 | + include_spip('inc/lien'); |
|
| 417 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 418 | + return ''; |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | - return propre('[->' . $virtuel . ']'); |
|
| 421 | + return propre('[->' . $virtuel . ']'); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | * @filtre |
| 442 | 442 | */ |
| 443 | 443 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 444 | - include_spip('inc/acces'); |
|
| 445 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 444 | + include_spip('inc/acces'); |
|
| 445 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 446 | 446 | |
| 447 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 448 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 447 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 448 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | |
@@ -457,76 +457,76 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function alertes_auteur($id_auteur): string { |
| 459 | 459 | |
| 460 | - $alertes = []; |
|
| 461 | - |
|
| 462 | - if ( |
|
| 463 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 464 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 465 | - ) { |
|
| 466 | - include_spip('genie/maintenance'); |
|
| 467 | - if ($msg = message_crash_tables()) { |
|
| 468 | - $alertes[] = $msg; |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - if ( |
|
| 473 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 474 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 475 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 476 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 477 | - ) { |
|
| 478 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 479 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 483 | - if ( |
|
| 484 | - $a |
|
| 485 | - and is_array($a = unserialize($a)) |
|
| 486 | - and count($a) |
|
| 487 | - ) { |
|
| 488 | - $update = false; |
|
| 489 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - $update = true; |
|
| 493 | - } |
|
| 494 | - if (isset($a[''])) { |
|
| 495 | - $alertes = array_merge($alertes, $a['']); |
|
| 496 | - unset($a['']); |
|
| 497 | - $update = true; |
|
| 498 | - } |
|
| 499 | - if ($update) { |
|
| 500 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - if ( |
|
| 505 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | - ) { |
|
| 508 | - include_spip('inc/plugin'); |
|
| 509 | - $alertes[] = plugin_donne_erreurs(); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - $alertes = pipeline( |
|
| 513 | - 'alertes_auteur', |
|
| 514 | - [ |
|
| 515 | - 'args' => [ |
|
| 516 | - 'id_auteur' => $id_auteur, |
|
| 517 | - 'exec' => _request('exec'), |
|
| 518 | - ], |
|
| 519 | - 'data' => $alertes |
|
| 520 | - ] |
|
| 521 | - ); |
|
| 522 | - |
|
| 523 | - if ($alertes = array_filter($alertes)) { |
|
| 524 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | - join(' | ', $alertes) |
|
| 526 | - . '</div></div>'; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return ''; |
|
| 460 | + $alertes = []; |
|
| 461 | + |
|
| 462 | + if ( |
|
| 463 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 464 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 465 | + ) { |
|
| 466 | + include_spip('genie/maintenance'); |
|
| 467 | + if ($msg = message_crash_tables()) { |
|
| 468 | + $alertes[] = $msg; |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + if ( |
|
| 473 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 474 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 475 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 476 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 477 | + ) { |
|
| 478 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 479 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 483 | + if ( |
|
| 484 | + $a |
|
| 485 | + and is_array($a = unserialize($a)) |
|
| 486 | + and count($a) |
|
| 487 | + ) { |
|
| 488 | + $update = false; |
|
| 489 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + $update = true; |
|
| 493 | + } |
|
| 494 | + if (isset($a[''])) { |
|
| 495 | + $alertes = array_merge($alertes, $a['']); |
|
| 496 | + unset($a['']); |
|
| 497 | + $update = true; |
|
| 498 | + } |
|
| 499 | + if ($update) { |
|
| 500 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + if ( |
|
| 505 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | + ) { |
|
| 508 | + include_spip('inc/plugin'); |
|
| 509 | + $alertes[] = plugin_donne_erreurs(); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + $alertes = pipeline( |
|
| 513 | + 'alertes_auteur', |
|
| 514 | + [ |
|
| 515 | + 'args' => [ |
|
| 516 | + 'id_auteur' => $id_auteur, |
|
| 517 | + 'exec' => _request('exec'), |
|
| 518 | + ], |
|
| 519 | + 'data' => $alertes |
|
| 520 | + ] |
|
| 521 | + ); |
|
| 522 | + |
|
| 523 | + if ($alertes = array_filter($alertes)) { |
|
| 524 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | + join(' | ', $alertes) |
|
| 526 | + . '</div></div>'; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return ''; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | * @return string |
| 537 | 537 | */ |
| 538 | 538 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 539 | - include_spip('inc/presenter_enfants'); |
|
| 539 | + include_spip('inc/presenter_enfants'); |
|
| 540 | 540 | |
| 541 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 541 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -556,15 +556,15 @@ discard block |
||
| 556 | 556 | * @return string |
| 557 | 557 | */ |
| 558 | 558 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 559 | - $titre = attribut_html($titre); |
|
| 560 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | - |
|
| 563 | - if (!$titre_lien) { |
|
| 564 | - return $icone; |
|
| 565 | - } else { |
|
| 566 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | - } |
|
| 559 | + $titre = attribut_html($titre); |
|
| 560 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | + |
|
| 563 | + if (!$titre_lien) { |
|
| 564 | + return $icone; |
|
| 565 | + } else { |
|
| 566 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | + } |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -583,22 +583,22 @@ discard block |
||
| 583 | 583 | * @return array |
| 584 | 584 | */ |
| 585 | 585 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 586 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | - return []; |
|
| 589 | - } |
|
| 590 | - $r = reset($res); |
|
| 591 | - if (isset($r['rang_lien'])) { |
|
| 592 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 593 | - asort($l); |
|
| 594 | - $l = array_keys($l); |
|
| 595 | - } else { |
|
| 596 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 597 | - // Sinon c'est dans "id_objet" |
|
| 598 | - $l = array_column( |
|
| 599 | - $res, |
|
| 600 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 601 | - ); |
|
| 602 | - } |
|
| 603 | - return $l; |
|
| 586 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | + return []; |
|
| 589 | + } |
|
| 590 | + $r = reset($res); |
|
| 591 | + if (isset($r['rang_lien'])) { |
|
| 592 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 593 | + asort($l); |
|
| 594 | + $l = array_keys($l); |
|
| 595 | + } else { |
|
| 596 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 597 | + // Sinon c'est dans "id_objet" |
|
| 598 | + $l = array_column( |
|
| 599 | + $res, |
|
| 600 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 601 | + ); |
|
| 602 | + } |
|
| 603 | + return $l; |
|
| 604 | 604 | } |