@@ -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,95 +82,95 @@ 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 | - // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 116 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | - // confirmation du deplacement |
|
| 118 | - if ( |
|
| 119 | - sql_table_exists('spip_breves') |
|
| 120 | - and ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet))) |
|
| 121 | - and ($contient_breves > 0) |
|
| 122 | - ) { |
|
| 123 | - // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 124 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 125 | - $scb = _T( |
|
| 126 | - 'avis_deplacement_rubrique', |
|
| 127 | - [ |
|
| 128 | - 'contient_breves' => $contient_breves, |
|
| 129 | - 'scb' => $scb |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 133 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 134 | - . $scb . |
|
| 135 | - "</label></div></div>\n"; |
|
| 136 | - } else { |
|
| 137 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - $form .= $confirm; |
|
| 141 | - if ($actionable) { |
|
| 142 | - if (strpos($form, '<select') !== false) { |
|
| 143 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 144 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 145 | - . '</div>'; |
|
| 146 | - } |
|
| 147 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 148 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 149 | - $form = generer_action_auteur( |
|
| 150 | - "editer_$objet", |
|
| 151 | - $id_objet, |
|
| 152 | - self(), |
|
| 153 | - $form, |
|
| 154 | - " method='post' class='submit_plongeur'" |
|
| 155 | - ); |
|
| 156 | - } else { |
|
| 157 | - $form = generer_action_auteur( |
|
| 158 | - 'editer_objet', |
|
| 159 | - "$objet/$id_objet", |
|
| 160 | - self(), |
|
| 161 | - $form, |
|
| 162 | - " method='post' class='submit_plongeur'" |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ($retour_sans_cadre) { |
|
| 168 | - return $form; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - include_spip('inc/presentation'); |
|
| 172 | - |
|
| 173 | - 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 | + // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 116 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | + // confirmation du deplacement |
|
| 118 | + if ( |
|
| 119 | + sql_table_exists('spip_breves') |
|
| 120 | + and ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet))) |
|
| 121 | + and ($contient_breves > 0) |
|
| 122 | + ) { |
|
| 123 | + // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 124 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 125 | + $scb = _T( |
|
| 126 | + 'avis_deplacement_rubrique', |
|
| 127 | + [ |
|
| 128 | + 'contient_breves' => $contient_breves, |
|
| 129 | + 'scb' => $scb |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 133 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 134 | + . $scb . |
|
| 135 | + "</label></div></div>\n"; |
|
| 136 | + } else { |
|
| 137 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + $form .= $confirm; |
|
| 141 | + if ($actionable) { |
|
| 142 | + if (strpos($form, '<select') !== false) { |
|
| 143 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 144 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 145 | + . '</div>'; |
|
| 146 | + } |
|
| 147 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 148 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 149 | + $form = generer_action_auteur( |
|
| 150 | + "editer_$objet", |
|
| 151 | + $id_objet, |
|
| 152 | + self(), |
|
| 153 | + $form, |
|
| 154 | + " method='post' class='submit_plongeur'" |
|
| 155 | + ); |
|
| 156 | + } else { |
|
| 157 | + $form = generer_action_auteur( |
|
| 158 | + 'editer_objet', |
|
| 159 | + "$objet/$id_objet", |
|
| 160 | + self(), |
|
| 161 | + $form, |
|
| 162 | + " method='post' class='submit_plongeur'" |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ($retour_sans_cadre) { |
|
| 168 | + return $form; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + include_spip('inc/presentation'); |
|
| 172 | + |
|
| 173 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
@@ -184,24 +184,24 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function avoir_visiteurs($past = false, $accepter = true) { |
| 187 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 188 | - return true; |
|
| 189 | - } |
|
| 190 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 191 | - return true; |
|
| 192 | - } |
|
| 193 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 194 | - return true; |
|
| 195 | - } |
|
| 196 | - if (!$past) { |
|
| 197 | - return false; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return sql_countsel( |
|
| 201 | - 'spip_auteurs', |
|
| 202 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 187 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 188 | + return true; |
|
| 189 | + } |
|
| 190 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 193 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 194 | + return true; |
|
| 195 | + } |
|
| 196 | + if (!$past) { |
|
| 197 | + return false; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return sql_countsel( |
|
| 201 | + 'spip_auteurs', |
|
| 202 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 203 | 203 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 204 | - ); |
|
| 204 | + ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,18 +217,18 @@ discard block |
||
| 217 | 217 | * @return array |
| 218 | 218 | */ |
| 219 | 219 | function statuts_articles_visibles($statut_auteur) { |
| 220 | - static $auth = []; |
|
| 221 | - if (!isset($auth[$statut_auteur])) { |
|
| 222 | - $auth[$statut_auteur] = []; |
|
| 223 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 224 | - foreach ($statuts as $s) { |
|
| 225 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 226 | - $auth[$statut_auteur][] = $s; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - return $auth[$statut_auteur]; |
|
| 220 | + static $auth = []; |
|
| 221 | + if (!isset($auth[$statut_auteur])) { |
|
| 222 | + $auth[$statut_auteur] = []; |
|
| 223 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 224 | + foreach ($statuts as $s) { |
|
| 225 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 226 | + $auth[$statut_auteur][] = $s; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + return $auth[$statut_auteur]; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -242,38 +242,38 @@ discard block |
||
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | 244 | function traduire_statut_auteur($statut, $attente = '') { |
| 245 | - $plus = ''; |
|
| 246 | - if ($statut == 'nouveau') { |
|
| 247 | - if ($attente) { |
|
| 248 | - $statut = $attente; |
|
| 249 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 250 | - } else { |
|
| 251 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $recom = [ |
|
| 256 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 257 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 258 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 259 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 260 | - ]; |
|
| 261 | - if (isset($recom[$statut])) { |
|
| 262 | - return $recom[$statut] . $plus; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - // retrouver directement par le statut sinon |
|
| 266 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 267 | - if (isset($recom[$t])) { |
|
| 268 | - return $recom[$t] . $plus; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - return _T($t) . $plus; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 275 | - // c'est toujours plus informatif que rien du tout |
|
| 276 | - return $statut; |
|
| 245 | + $plus = ''; |
|
| 246 | + if ($statut == 'nouveau') { |
|
| 247 | + if ($attente) { |
|
| 248 | + $statut = $attente; |
|
| 249 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 250 | + } else { |
|
| 251 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $recom = [ |
|
| 256 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 257 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 258 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 259 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 260 | + ]; |
|
| 261 | + if (isset($recom[$statut])) { |
|
| 262 | + return $recom[$statut] . $plus; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + // retrouver directement par le statut sinon |
|
| 266 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 267 | + if (isset($recom[$t])) { |
|
| 268 | + return $recom[$t] . $plus; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + return _T($t) . $plus; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 275 | + // c'est toujours plus informatif que rien du tout |
|
| 276 | + return $statut; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,29 +284,29 @@ discard block |
||
| 284 | 284 | * @return string |
| 285 | 285 | */ |
| 286 | 286 | function afficher_qui_edite($id_objet, $objet): string { |
| 287 | - static $qui = []; |
|
| 288 | - if (isset($qui[$objet][$id_objet])) { |
|
| 289 | - return $qui[$objet][$id_objet]; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - include_spip('inc/config'); |
|
| 293 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 294 | - return $qui[$objet][$id_objet] = ''; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - include_spip('inc/drapeau_edition'); |
|
| 298 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 299 | - if (!$modif) { |
|
| 300 | - return $qui[$objet][$id_objet] = ''; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - include_spip('base/objets'); |
|
| 304 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 305 | - if (isset($infos['texte_signale_edition'])) { |
|
| 306 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 287 | + static $qui = []; |
|
| 288 | + if (isset($qui[$objet][$id_objet])) { |
|
| 289 | + return $qui[$objet][$id_objet]; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + include_spip('inc/config'); |
|
| 293 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 294 | + return $qui[$objet][$id_objet] = ''; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + include_spip('inc/drapeau_edition'); |
|
| 298 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 299 | + if (!$modif) { |
|
| 300 | + return $qui[$objet][$id_objet] = ''; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + include_spip('base/objets'); |
|
| 304 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 305 | + if (isset($infos['texte_signale_edition'])) { |
|
| 306 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -324,53 +324,53 @@ discard block |
||
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | 326 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 327 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 328 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - switch ($quoi) { |
|
| 332 | - case 'redacteurs': |
|
| 333 | - $statut = AUTEURS_MIN_REDAC; |
|
| 334 | - $statut = explode(',', $statut); |
|
| 335 | - if ($en_base) { |
|
| 336 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 337 | - $retire = array_diff($statut, $check); |
|
| 338 | - $statut = array_diff($statut, $retire); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return array_unique($statut); |
|
| 342 | - |
|
| 343 | - case 'visiteurs': |
|
| 344 | - $statut = []; |
|
| 345 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 346 | - $exclus = explode(',', $exclus); |
|
| 347 | - if (!$en_base) { |
|
| 348 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 349 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 350 | - } |
|
| 351 | - $s_complement = array_column( |
|
| 352 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 353 | - 'statut' |
|
| 354 | - ); |
|
| 355 | - |
|
| 356 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 357 | - |
|
| 358 | - default: |
|
| 359 | - case 'tous': |
|
| 360 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | - $s_complement = array_column( |
|
| 362 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 363 | - 'statut' |
|
| 364 | - ); |
|
| 365 | - $statut = array_merge($statut, $s_complement); |
|
| 366 | - if ($en_base) { |
|
| 367 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 368 | - $retire = array_diff($statut, $check); |
|
| 369 | - $statut = array_diff($statut, $retire); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - return array_unique($statut); |
|
| 373 | - } |
|
| 327 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 328 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + switch ($quoi) { |
|
| 332 | + case 'redacteurs': |
|
| 333 | + $statut = AUTEURS_MIN_REDAC; |
|
| 334 | + $statut = explode(',', $statut); |
|
| 335 | + if ($en_base) { |
|
| 336 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 337 | + $retire = array_diff($statut, $check); |
|
| 338 | + $statut = array_diff($statut, $retire); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return array_unique($statut); |
|
| 342 | + |
|
| 343 | + case 'visiteurs': |
|
| 344 | + $statut = []; |
|
| 345 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 346 | + $exclus = explode(',', $exclus); |
|
| 347 | + if (!$en_base) { |
|
| 348 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 349 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 350 | + } |
|
| 351 | + $s_complement = array_column( |
|
| 352 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 353 | + 'statut' |
|
| 354 | + ); |
|
| 355 | + |
|
| 356 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 357 | + |
|
| 358 | + default: |
|
| 359 | + case 'tous': |
|
| 360 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | + $s_complement = array_column( |
|
| 362 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 363 | + 'statut' |
|
| 364 | + ); |
|
| 365 | + $statut = array_merge($statut, $s_complement); |
|
| 366 | + if ($en_base) { |
|
| 367 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 368 | + $retire = array_diff($statut, $check); |
|
| 369 | + $statut = array_diff($statut, $retire); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + return array_unique($statut); |
|
| 373 | + } |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -386,28 +386,28 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 388 | 388 | |
| 389 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 390 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 391 | - ? '' |
|
| 392 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | - |
|
| 394 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 395 | - if ($objet == 'rubrique') { |
|
| 396 | - $id_rubrique = 0; |
|
| 397 | - } else { |
|
| 398 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 402 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 403 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 404 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 405 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return $id_rubrique; |
|
| 389 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 390 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 391 | + ? '' |
|
| 392 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | + |
|
| 394 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 395 | + if ($objet == 'rubrique') { |
|
| 396 | + $id_rubrique = 0; |
|
| 397 | + } else { |
|
| 398 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 402 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 403 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 404 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 405 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return $id_rubrique; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -418,12 +418,12 @@ discard block |
||
| 418 | 418 | * @return string |
| 419 | 419 | */ |
| 420 | 420 | function lien_article_virtuel($virtuel) { |
| 421 | - include_spip('inc/lien'); |
|
| 422 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 423 | - return ''; |
|
| 424 | - } |
|
| 421 | + include_spip('inc/lien'); |
|
| 422 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 423 | + return ''; |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - return propre('[->' . $virtuel . ']'); |
|
| 426 | + return propre('[->' . $virtuel . ']'); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | |
@@ -446,11 +446,11 @@ discard block |
||
| 446 | 446 | * @filtre |
| 447 | 447 | */ |
| 448 | 448 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 449 | - include_spip('inc/acces'); |
|
| 450 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 449 | + include_spip('inc/acces'); |
|
| 450 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 451 | 451 | |
| 452 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 453 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 452 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 453 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | |
@@ -462,76 +462,76 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | function alertes_auteur($id_auteur): string { |
| 464 | 464 | |
| 465 | - $alertes = []; |
|
| 466 | - |
|
| 467 | - if ( |
|
| 468 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 469 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 470 | - ) { |
|
| 471 | - include_spip('genie/maintenance'); |
|
| 472 | - if ($msg = message_crash_tables()) { |
|
| 473 | - $alertes[] = $msg; |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - if ( |
|
| 478 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 479 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 480 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 481 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 482 | - ) { |
|
| 483 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 484 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 488 | - if ( |
|
| 489 | - $a |
|
| 490 | - and is_array($a = unserialize($a)) |
|
| 491 | - and count($a) |
|
| 492 | - ) { |
|
| 493 | - $update = false; |
|
| 494 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 495 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 496 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 497 | - $update = true; |
|
| 498 | - } |
|
| 499 | - if (isset($a[''])) { |
|
| 500 | - $alertes = array_merge($alertes, $a['']); |
|
| 501 | - unset($a['']); |
|
| 502 | - $update = true; |
|
| 503 | - } |
|
| 504 | - if ($update) { |
|
| 505 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - if ( |
|
| 510 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 511 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 512 | - ) { |
|
| 513 | - include_spip('inc/plugin'); |
|
| 514 | - $alertes[] = plugin_donne_erreurs(); |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - $alertes = pipeline( |
|
| 518 | - 'alertes_auteur', |
|
| 519 | - [ |
|
| 520 | - 'args' => [ |
|
| 521 | - 'id_auteur' => $id_auteur, |
|
| 522 | - 'exec' => _request('exec'), |
|
| 523 | - ], |
|
| 524 | - 'data' => $alertes |
|
| 525 | - ] |
|
| 526 | - ); |
|
| 527 | - |
|
| 528 | - if ($alertes = array_filter($alertes)) { |
|
| 529 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 530 | - join(' | ', $alertes) |
|
| 531 | - . '</div></div>'; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - return ''; |
|
| 465 | + $alertes = []; |
|
| 466 | + |
|
| 467 | + if ( |
|
| 468 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 469 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 470 | + ) { |
|
| 471 | + include_spip('genie/maintenance'); |
|
| 472 | + if ($msg = message_crash_tables()) { |
|
| 473 | + $alertes[] = $msg; |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + if ( |
|
| 478 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 479 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 480 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 481 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 482 | + ) { |
|
| 483 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 484 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 488 | + if ( |
|
| 489 | + $a |
|
| 490 | + and is_array($a = unserialize($a)) |
|
| 491 | + and count($a) |
|
| 492 | + ) { |
|
| 493 | + $update = false; |
|
| 494 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 495 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 496 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 497 | + $update = true; |
|
| 498 | + } |
|
| 499 | + if (isset($a[''])) { |
|
| 500 | + $alertes = array_merge($alertes, $a['']); |
|
| 501 | + unset($a['']); |
|
| 502 | + $update = true; |
|
| 503 | + } |
|
| 504 | + if ($update) { |
|
| 505 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + if ( |
|
| 510 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 511 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 512 | + ) { |
|
| 513 | + include_spip('inc/plugin'); |
|
| 514 | + $alertes[] = plugin_donne_erreurs(); |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + $alertes = pipeline( |
|
| 518 | + 'alertes_auteur', |
|
| 519 | + [ |
|
| 520 | + 'args' => [ |
|
| 521 | + 'id_auteur' => $id_auteur, |
|
| 522 | + 'exec' => _request('exec'), |
|
| 523 | + ], |
|
| 524 | + 'data' => $alertes |
|
| 525 | + ] |
|
| 526 | + ); |
|
| 527 | + |
|
| 528 | + if ($alertes = array_filter($alertes)) { |
|
| 529 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 530 | + join(' | ', $alertes) |
|
| 531 | + . '</div></div>'; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + return ''; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | 543 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 544 | - include_spip('inc/presenter_enfants'); |
|
| 544 | + include_spip('inc/presenter_enfants'); |
|
| 545 | 545 | |
| 546 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 546 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | - $titre = attribut_html($titre); |
|
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | - |
|
| 568 | - if (!$titre_lien) { |
|
| 569 | - return $icone; |
|
| 570 | - } else { |
|
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | - } |
|
| 564 | + $titre = attribut_html($titre); |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | + |
|
| 568 | + if (!$titre_lien) { |
|
| 569 | + return $icone; |
|
| 570 | + } else { |
|
| 571 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | |
@@ -588,20 +588,20 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 591 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 593 | - return []; |
|
| 594 | - } |
|
| 595 | - $r = reset($res); |
|
| 596 | - $colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'); |
|
| 597 | - if (isset($r['rang_lien'])) { |
|
| 598 | - $l = array_column($res, 'rang_lien', $colonne_id); |
|
| 599 | - asort($l); |
|
| 600 | - $l = array_keys($l); |
|
| 601 | - } else { |
|
| 602 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 603 | - // Sinon c'est dans "id_objet" |
|
| 604 | - $l = array_column($res, $colonne_id); |
|
| 605 | - } |
|
| 606 | - return $l; |
|
| 591 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 593 | + return []; |
|
| 594 | + } |
|
| 595 | + $r = reset($res); |
|
| 596 | + $colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'); |
|
| 597 | + if (isset($r['rang_lien'])) { |
|
| 598 | + $l = array_column($res, 'rang_lien', $colonne_id); |
|
| 599 | + asort($l); |
|
| 600 | + $l = array_keys($l); |
|
| 601 | + } else { |
|
| 602 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 603 | + // Sinon c'est dans "id_objet" |
|
| 604 | + $l = array_column($res, $colonne_id); |
|
| 605 | + } |
|
| 606 | + return $l; |
|
| 607 | 607 | } |