Completed
Push — spip-2-stable ( d79e3d )
by cam
30:47 queued 16:59
created

accueil.php ➔ etat_base_accueil()   F

Complexity

Conditions 28
Paths > 20000

Size

Total Lines 108
Code Lines 77

Duplication

Lines 20
Ratio 18.52 %

Importance

Changes 0
Metric Value
cc 28
eloc 77
nc 1331712
nop 0
dl 20
loc 108
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2016                                                *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
10
 *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
13
if (!defined('_ECRIRE_INC_VERSION')) return;
14
15
include_spip('inc/presentation');
16
17
// http://doc.spip.org/@encours_accueil
18
function encours_accueil()
19
{
20
	global $connect_statut, $connect_toutes_rubriques;
21
22
23
	$res = '';
24
25
	// Les articles a valider
26
	//
27
28
	$res .=  afficher_objets('article',_T('info_articles_proposes'), array("WHERE" => "statut='prop'", 'ORDER BY' => "date DESC"));
29
30
	//
31
	// Les breves a valider
32
	//
33
	$res .= afficher_objets('breve',afficher_plus(generer_url_ecrire('breves'))._T('info_breves_valider'), array("FROM" => 'spip_breves', 'WHERE' => "statut='prepa' OR statut='prop'", 'ORDER BY' => "date_heure DESC"), true);
34
35
	//
36
	// Les sites references a valider
37
	//
38
	if ($GLOBALS['meta']['activer_sites'] != 'non') {
39
		$res .= afficher_objets('site',afficher_plus(generer_url_ecrire('sites_tous')).'<b>' . _T('info_site_valider') . '</b>', array("FROM" => 'spip_syndic', 'WHERE' => "statut='prop'", 'ORDER BY'=> "nom_site"));
40
	}
41
42
	if ($connect_statut == '0minirezo') {
43
	//
44
	// Les sites a probleme
45
	//
46
	  if ($GLOBALS['meta']['activer_sites'] != 'non') {
47
		$res .= afficher_objets('site',afficher_plus(generer_url_ecrire('sites_tous')). '<b>' . _T('avis_sites_syndiques_probleme') . '</b>', array('FROM' => 'spip_syndic', 'WHERE' => "(syndication='off' OR syndication='sus') AND statut='publie'", 'ORDER BY' => 'nom_site'));
48
	}
49
50
	// Les articles syndiques en attente de validation
51
		$cpt = sql_countsel("spip_syndic_articles", "statut='dispo'");
52 View Code Duplication
		if ($cpt)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
			$res .= "\n<br /><small><a href='"
54
			. generer_url_ecrire("sites_tous","")
55
			. "' style='color: black;'>"
56
			. $cpt
57
			. " "
58
			. _T('info_liens_syndiques_1')
59
			. " "
60
			. _T('info_liens_syndiques_2')
61
			. "</a></small>";
62
63
	// Les forums en attente de moderation
64
65
		$cpt = sql_countsel("spip_forum", "statut='prop'");
66
		if ($cpt) {
67
		if ($cpt>1)
68
			$lien = _T('info_liens_syndiques_3')." "._T('info_liens_syndiques_4');
69
		else
70
			$lien = _T('info_liens_syndiques_5')." "._T('info_liens_syndiques_6');
71
		$lien = "<small>$cpt $lien " ._T('info_liens_syndiques_7'). "</small>";
72
		if ($connect_toutes_rubriques)
73
			$lien = "<a href='" . generer_url_ecrire("controle_forum","type=prop") . "' style='color: black;'>". $lien . ".</a>";
74
		$res .= "\n<br />" . $lien;
75
		}
76
	}
77
	
78
	$res = pipeline('accueil_encours',$res);
79
80
	if (!$res) return '';
81
82
	return 
83
	"<div style='position:relative;display:inline;'>" 
84
	. debut_cadre_couleur_foncee("",true, "", _T('texte_en_cours_validation')
85
		. (($GLOBALS['meta']['forum_prive_objets'] != 'non')
86
			? ' '._T('texte_en_cours_validation_forum')
87
			: '' )
88
		)
89
	. $res
90
	. bouton_spip_rss('a_suivre')
91
	. fin_cadre_couleur_foncee(true)
92
	. "</div>";
93
}
94
95
//
96
// Raccourcis pour malvoyants
97
//
98
99
// http://doc.spip.org/@colonne_droite_eq4
100
function colonne_droite_eq4($id_rubrique, $activer_breves, $activer_sites, $articles_mots) {
0 ignored issues
show
Unused Code introduced by
The parameter $activer_sites is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $articles_mots is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
	global  $connect_statut, $connect_toutes_rubriques;
102
103
	$res = sql_countsel('spip_rubriques');
104
	if ($res) {
105
		$res = icone_horizontale(_T('icone_ecrire_article'), generer_url_ecrire("articles_edit","new=oui"), "article-24.gif","creer.gif", false);
106
107 View Code Duplication
		if ($activer_breves != "non") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
			$res .= icone_horizontale(_T('icone_nouvelle_breve'), generer_url_ecrire("breves_edit","new=oui"), "breve-24.gif","creer.gif", false);
109
		}
110
	}
111
	else {
112
		if ($connect_statut == '0minirezo') {
113
			$res = "<div class='verdana2'>"._T('info_ecrire_article')."</div>";
114
		}
115
	}
116
	if (autoriser('creerrubriquedans', 'rubrique', $id_rubrique)) {
117
		$res .= icone_horizontale(_T('icone_creer_rubrique_2'), generer_url_ecrire("rubriques_edit","new=oui"), "rubrique-24.gif","creer.gif", false);
118
	}
119
	return  bloc_des_raccourcis($res);
120
 }
121
122
//
123
// Raccourcis pour voyants ...
124
//
125
126
// http://doc.spip.org/@colonne_droite_neq4
127
function colonne_droite_neq4($id_rubrique, $activer_breves, $activer_sites, $articles_mots) {
128
  global  $connect_statut, $connect_id_auteur, $connect_login;
129
130
	$gadget = '';
131
132 View Code Duplication
	if ($id_rubrique > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
133
		$dans_rub = "&id_rubrique=$id_rubrique";
134
		$dans_parent = "&id_parent=$id_rubrique";
0 ignored issues
show
Unused Code introduced by
$dans_parent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
135
	} else $dans_rub = $dans_parent = '';
0 ignored issues
show
Unused Code introduced by
$dans_parent is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
136
137
	if (autoriser('creerrubriquedans', 'rubrique', $id_rubrique)) {
138
		$gadget .= "<td>"
139
			. icone_horizontale(_T('icone_creer_rubrique'), generer_url_ecrire("rubriques_edit","new=oui"), "rubrique-24.gif", "creer.gif", false)
140
			. "</td>";
141
		}
142
	$n = sql_countsel('spip_rubriques');
143
	if ($n) {
144
		$gadget .= "<td>"
145
			. icone_horizontale(_T('icone_ecrire_article'), generer_url_ecrire("articles_edit","new=oui$dans_rub"), "article-24.gif","creer.gif", false)
146
			. "</td>";
147
			
148
		if ($activer_breves != "non") {
149
				$gadget .= "<td>";
150
				$gadget .= icone_horizontale(_T('icone_nouvelle_breve'), generer_url_ecrire("breves_edit","new=oui$dans_rub"), "breve-24.gif","creer.gif", false);
151
				$gadget .= "</td>";
152
			}
153
			
154
		if ($activer_sites == 'oui') {
155
				if ($connect_statut == '0minirezo' OR $GLOBALS['meta']["proposer_sites"] > 0) {
156
					$gadget .= "<td>";
157
					$gadget .= icone_horizontale(_T('info_sites_referencer'), generer_url_ecrire("sites_edit","new=oui$dans_rub"), "site-24.gif","creer.gif", false);
158
					$gadget .= "</td>";
159
				}
160
			} 
161
	}
162
	$gadget = "<table><tr>$gadget</tr></table>\n";
163
164
	if ($connect_statut != "0minirezo") {
165
	
166
		$gadget .= "<table><tr>";
167
	
168
		$cpt = sql_countsel('spip_auteurs_articles', "id_auteur=$connect_id_auteur");
169
		if ($cpt) {
170
			$gadget .= "<td>"
171
			. icone_horizontale (_T('icone_tous_articles'), generer_url_ecrire("articles_page"), "article-24.gif", "", false)
172
			. "</td>";
173
		}
174
	
175
		if ($activer_breves != "non"){
176
			$gadget .= "<td>"
177
			. icone_horizontale (_T('icone_breves'), generer_url_ecrire("breves",""), "breve-24.gif", "", false)
178
			. "</td>";
179
		}
180
	
181
		if ($articles_mots != "non") {
182
			$gadget .= "<td>"
183
			. icone_horizontale  (_T('icone_mots_cles'), generer_url_ecrire("mots_tous",""), "mot-cle-24.gif", "", false)
184
			. "</td>";
185
		}
186
187
		if ($activer_sites<>'non') {
188
			$gadget .= "<td>"
189
			. icone_horizontale  (_T('icone_sites_references'), generer_url_ecrire("sites_tous",""), "site-24.gif", "", false)
190
			. "</td>";
191
		}
192
		$gadget .= "</tr></table>\n";
193
	}
194
	$gadget = pipeline('accueil_gadgets',$gadget);
195
196
	if (strlen($gadget) > 0) {
197
	  $gadget = debut_cadre_trait_couleur('', true)
198
	    . $gadget
199
	    . fin_cadre_trait_couleur(true);
200
	}
201
202
	return $gadget;
203
}
204
205
// Cartouche d'identification, avec les rubriques administrees
206
207
// http://doc.spip.org/@personnel_accueil
208
function personnel_accueil($coockcookie)
209
{
210
	global $spip_lang_left, $connect_id_auteur, $connect_id_rubrique ;
211
212
	$res = '';
213
214
	if (count($connect_id_rubrique)) {
215
216
		$res = sql_allfetsel("R.id_rubrique, R.titre, R.descriptif", "spip_auteurs_rubriques AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique", "A.id_auteur=$connect_id_auteur", "", "titre");
217
218
		foreach ($res as $k => $r) {
219
			$res[$k] = "<a title='" .
220
			  typo($r['descriptif']) .
221
			  "' href='" .
222
			  generer_url_ecrire('naviguer', "id_rubrique=" .$r['id_rubrique']) . "'>" .
223
			  typo($r['titre']) .
224
			  '</a>';
225
		}
226
227
		$res = "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>\n<li>" . join("</li>\n<li>", $res) . "\n</li></ul>";
228
	}
229
230
	//
231
	// Supprimer le cookie, se deconnecter...
232
	//
233
	
234
	if ($coockcookie) {
235
		$lien = generer_url_action('cookie', "cookie_admin=non&url=".rawurlencode('./'. _SPIP_ECRIRE_SCRIPT));
236
		$t = _T('icone_supprimer_cookie');
237
		$lien = icone_horizontale($t, $lien, "cookie-24.gif", "supprimer-sansdanger.gif", false);
238
		if ($GLOBALS['spip_display'] != 1) 
239
			$lien = str_replace('</td></tr></table>', 
240
					 aide("cookie").'</td></tr></table>',
241
					 $lien);
242
	}
243
	//
244
	// Modification du cookie
245
	//
246
247
	else {
248
		$cookie = rawurlencode("@$connect_login");
0 ignored issues
show
Bug introduced by
The variable $connect_login does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
249
		$retour = rawurlencode('./' . _SPIP_ECRIRE_SCRIPT);
250
		$lien = generer_url_action('cookie', "cookie_admin=$cookie&url=$retour");
251
		$lien = 
252
			  _T('info_activer_cookie').
253
			  aide ("cookie").
254
			icone_horizontale(_T('icone_activer_cookie'), $lien,"cookie-24.gif", "", false);
255
	}
256
	
257
	$titre_cadre = afficher_plus(generer_url_ecrire("auteur_infos","id_auteur=$connect_id_auteur"));
258
	$titre_cadre .= majuscules(typo($GLOBALS['visiteur_session']['nom']));
259
	
260
	return debut_cadre_relief("fiche-perso-24.gif",true, '',$titre_cadre)
261
	. $res
262
	. "<div class='info_cookie'>$lien</div>"
263
	. fin_cadre_relief(true);
264
}
265
266
// Cartouche du site, avec le nombre d'articles, breves et messages de forums
267
268
// http://doc.spip.org/@etat_base_accueil
269
function etat_base_accueil()
270
{
271
	global $spip_display, $spip_lang_left, $connect_id_rubrique;
272
273
	$where = count($connect_id_rubrique)
274
	? sql_in('id_rubrique', $connect_id_rubrique)	: '';
275
276
	$res = '';
277
278
	if ($spip_display != 1) {
279
		$chercher_logo = charger_fonction('chercher_logo', 'inc');
280
		if ($r = $chercher_logo(0, 'id_syndic', 'on'))  {
281
			list($fid, $dir, $nom, $format) = $r;
0 ignored issues
show
Unused Code introduced by
The assignment to $dir is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $nom is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
Unused Code introduced by
The assignment to $format is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
282
			include_spip('inc/filtres_images_mini');
283
			$r = image_reduire("<img src='$fid' alt='' />", 170, 170);
284
			if ($r)
285
				$res ="<div style='text-align:center; margin-bottom: 5px;'>$r</div>";
286
		}
287
	}
288
	$res .= "<div class='verdana1'>";
289
290
	$res .= propre($GLOBALS['meta']["descriptif_site"]);
291
292
	$q = sql_select("COUNT(*) AS cnt, statut", 'spip_articles', '', 'statut', '','', "COUNT(*)<>0");
293
  
294
	$cpt = array();
295
	$cpt2 = array();
296
	$defaut = $where ? '0/' : '';
297
	while($row = sql_fetch($q)) {
298
	  $cpt[$row['statut']] = $row['cnt'];
299
	  $cpt2[$row['statut']] = $defaut;
300
	}
301
	if ($cpt) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $cpt of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
302 View Code Duplication
		if ($where) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
303
			$q = sql_select("COUNT(*) AS cnt, statut", 'spip_articles', $where, "statut");
304
			while($row = sql_fetch($q)) {
305
				$r = $row['statut'];
306
				$cpt2[$r] = intval($row['cnt']) . '/';
307
			}
308
		}
309
		$res .= afficher_plus(generer_url_ecrire("articles_page",""))."<b>"._T('info_articles')."</b>";
310
		$res .= "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>";
311
		if (isset($cpt['prepa'])) $res .= "<li>"._T("texte_statut_en_cours_redaction").": ".$cpt2['prepa'] . $cpt['prepa'] .'</li>';
312 View Code Duplication
		if (isset($cpt['prop'])) $res .= "<li>"._T("texte_statut_attente_validation").": ".$cpt2['prop'] . $cpt['prop'] . '</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
313 View Code Duplication
		if (isset($cpt['publie'])) $res .= "<li><b>"._T("texte_statut_publies").": ".$cpt2['publie'].$cpt['publie'] ."</b>" . '</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
314
		$res .= "</ul>";
315
	}
316
317
	$q = sql_select("COUNT(*) AS cnt, statut", 'spip_breves', '', 'statut', '','', "COUNT(*)<>0");
318
319
	$cpt = array();
320
	$cpt2 = array();
321
	$defaut = $where ? '0/' : '';
322
	while($row = sql_fetch($q)) {
323
	  $cpt[$row['statut']] = $row['cnt'];
324
	  $cpt2[$row['statut']] = $defaut;
325
	}
326
 
327
	if ($cpt) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $cpt of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
328 View Code Duplication
		if ($where) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
329
			$q = sql_select("COUNT(*) AS cnt, statut", 'spip_breves', $where, "statut");
330
			while($row = sql_fetch($q)) {
331
				$r = $row['statut'];
332
				$cpt2[$r] = intval($row['cnt']) . '/';
333
			}
334
		}
335
		$res .= afficher_plus(generer_url_ecrire("breves",""))."<b>"._T('info_breves_02')."</b>";
336
		$res .= "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>";
337 View Code Duplication
		if (isset($cpt['prop'])) $res .= "<li>"._T("texte_statut_attente_validation").": ".$cpt2['prop'].$cpt['prop'] . '</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
338 View Code Duplication
		if (isset($cpt['publie'])) $res .= "<li><b>"._T("texte_statut_publies").": ".$cpt2['publie'] .$cpt['publie'] . "</b>" .'</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
339
		$res .= "</ul>";
340
	}
341
342
	$q = sql_select('COUNT(*) AS cnt, statut', 'spip_forum', sql_in('statut', array('publie', 'prop')), 'statut', '','', "COUNT(*)<>0");
343
344
	$cpt = array();
345
	$cpt2 = array();
346
	$defaut = $where ? '0/' : '';
347
	while($row = sql_fetch($q)) {
348
	  $cpt[$row['statut']] = $row['cnt'];
349
	  $cpt2[$row['statut']] = $defaut;
350
	}
351
352
	if ($cpt) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $cpt of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
353
		if ($where) {
354
		  include_spip('inc/forum');
355
		  list($f, $w) = critere_statut_controle_forum('public');
356
		  $q = sql_select("COUNT(*) AS cnt, F.statut", "$f", "$w ", "F.statut");
357
		  while($row = sql_fetch($q)) {
358
				$r = $row['statut'];
359
				$cpt2[$r] = intval($row['cnt']) . '/';
360
			}
361
		}
362
363
		if (autoriser('modererforum'))
364
			$res .= afficher_plus(generer_url_ecrire("controle_forum",""));
365
		$res .= "<b>" ._T('onglet_messages_publics') ."</b>";
366
		$res .= "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>";
367 View Code Duplication
		if (isset($cpt['prop'])) $res .= "<li>"._T("texte_statut_attente_validation").": ".$cpt2['prop'] .$cpt['prop'] . '</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
368 View Code Duplication
		if (isset($cpt['publie'])) $res .= "<li><b>"._T("texte_statut_publies").": ".$cpt2['publie'] .$cpt['publie'] . "</b>" .'</li>';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
369
		$res .= "</ul>";
370
	}
371
	
372
	$res .= accueil_liste_participants()
373
	. "</div>";
374
375
	return pipeline('accueil_informations',$res) ;
376
}
377
378
379
// http://doc.spip.org/@accueil_liste_participants
380
function accueil_liste_participants()
381
{
382
	global $spip_lang_left;
383
384
	$q = sql_select("COUNT(*) AS cnt, statut", 'spip_auteurs', sql_in("statut", $GLOBALS['liste_des_statuts']), 'statut', '','', "COUNT(*)<>0");
385
386
	$cpt = array();
387
	while($row=sql_fetch($q)) $cpt[$row['statut']] = $row['cnt']; 
388
389
	if (!$cpt) return '';
0 ignored issues
show
Bug Best Practice introduced by
The expression $cpt of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
390
391
	       
392
	$res = afficher_plus(generer_url_ecrire("auteurs"))."<b>"._T('icone_auteurs')."</b>"
393
	. "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>";
394
		
395
	foreach($GLOBALS['liste_des_statuts'] as $k => $v) {
396
	  if (isset($cpt[$v])) $res .= "<li>" . _T($k) . ": " .$cpt[$v] . '</li>';
397
	}
398
399
	$res .= "</ul>";
400
401
	return $res; 
402
}
403
404
// http://doc.spip.org/@exec_accueil_dist
405
function exec_accueil_dist()
406
{
407
  global $id_rubrique, $connect_statut, $connect_id_auteur, $spip_display, $connect_id_rubrique;
408
409
	$id_rubrique =  intval($id_rubrique);
410
 	pipeline('exec_init',array('args'=>array('exec'=>'accueil','id_rubrique'=>$id_rubrique),'data'=>''));
411
412
	$commencer_page = charger_fonction('commencer_page', 'inc');
413
	echo $commencer_page(_T('titre_page_index'), "accueil", "accueil");
414
415
	echo debut_gauche("",true);
416
417
	if ($spip_display != 4) {
418
		echo personnel_accueil(@$_COOKIE['spip_admin']);
419
		echo pipeline('affiche_gauche',array('args'=>array('exec'=>'accueil','id_rubrique'=>$id_rubrique),'data'=>''));
420
421
		$nom = typo($GLOBALS['meta']["nom_site"]);
422
		if (!$nom) $nom=  _T('info_mon_site_spip');
423
		echo debut_cadre_relief("racine-site-24.gif", true, "", $nom),
424
		  etat_base_accueil(),
425
		  fin_cadre_relief(true);
426
	}
427
428
	echo creer_colonne_droite("", true);
429
	list($evtm, $evtt, $evtr) = http_calendrier_messages(date("Y"), date("m"), date("d")," 23:59:59");
430
431
	echo $evtt, $evtm, $evtr;
432
433
	echo pipeline('affiche_droite',array('args'=>array('exec'=>'accueil','id_rubrique'=>$id_rubrique),'data'=>''));
434
435
	echo debut_droite("", true);
436
437
	if ($GLOBALS['meta']["post_dates"] == "non"
438
	AND $connect_statut == '0minirezo')
439
		echo afficher_objets('article',_T('info_article_a_paraitre'), array("WHERE" => "statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')), 'ORDER BY' => "date"));
440
441
442
	// Les articles recents
443
	//
444
	echo afficher_objets('article',
445
	#afficher_plus(generer_url_ecrire('articles_page')) .
446
	_T('articles_recents'), array("WHERE" => "statut='publie'" .($GLOBALS['meta']["post_dates"] == "non"
447
		? " AND date<=".sql_quote(date('Y-m-d H:i:s')) : ''),
448
		'ORDER BY' => "date DESC", 'LIMIT' => '0,4'));
449
450
//
451
// Vos articles en cours 
452
//
453
454
	echo afficher_objets('article',afficher_plus(generer_url_ecrire('articles_page'))._T('info_en_cours_validation'),	array('FROM' => "spip_articles AS articles, spip_auteurs_articles AS lien", "WHERE" => "articles.id_article=lien.id_article AND lien.id_auteur=$connect_id_auteur AND articles.statut='prepa'", "ORDER BY" => "articles.date DESC"));
455
456
	if ($spip_display == 4)
457
	  echo colonne_droite_eq4($id_rubrique,
458
			 $GLOBALS['meta']["activer_breves"],
459
			 $GLOBALS['meta']["activer_sites"],
460
			 $GLOBALS['meta']['articles_mots']);
461
	else {
462
	  echo colonne_droite_neq4($id_rubrique,
463
			 $GLOBALS['meta']["activer_breves"],
464
			 $GLOBALS['meta']["activer_sites"],
465
			 $GLOBALS['meta']['articles_mots']);
466
467
	  echo encours_accueil();
468
	}
469
470
	include_spip('inc/presenter_enfants');
471
	if (!$connect_id_rubrique)
472
		echo afficher_enfant_rub(0, false, true) . "<div class='nettoyeur'></div>";
473
474
 	echo pipeline('affiche_milieu',array('args'=>array('exec'=>'accueil'),'data'=>''));
475
476
	// Dernieres modifications d'articles
477
	if (($GLOBALS['meta']['articles_versions'] == 'oui')) {
478
		include_spip('inc/suivi_versions');
479
		echo afficher_suivi_versions (0, 0, false, "", true);
480
	}
481
482
	echo fin_gauche(), fin_page();
483
}
484
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
485