From c352a96a91dc6da810f7c7b5b47f4e76a2e036a2 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Fri, 12 Jan 2007 17:52:56 +0000
Subject: [PATCH] =?UTF-8?q?Tache=20#605=20et=20d=C3=A9couverte=20d'un=20bu?=
 =?UTF-8?q?g=20=C3=A0=20corriger.=20En=20migrant=20les=20spip=5Fquery(UPDA?=
 =?UTF-8?q?TE..)=20dans=20editer=5Fsites,=20et=20donc=20en=20rempla=C3=A7a?=
 =?UTF-8?q?nt=20generer=5Furl=5Fpost=20en=20generer=5Faction,=20il=20est?=
 =?UTF-8?q?=20apparu=20que=20le=20''Cas=20d'un=20site=20ayant=20un=20feedf?=
 =?UTF-8?q?inder=20detecte''=20avait=20encore=20son=20generer=5Furl=5Fpost?=
 =?UTF-8?q?=20mais=20que=20le=20code=20ne=20prenait=20plus=20en=20compte?=
 =?UTF-8?q?=20cet=20appel=20de=20exec/sites.=20Remplacement=20par=20le=20g?=
 =?UTF-8?q?enerer=5Faction=20ad=20hoc,=20mais=20action/editer=5Fsite=20ne?=
 =?UTF-8?q?=20fait=20pas=20mieux.=20Est-ce=20du=20code=20mort=20=3F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/action/editer_site.php |  28 +++++-
 ecrire/exec/sites.php         | 169 ++++++++++++++--------------------
 2 files changed, 96 insertions(+), 101 deletions(-)

diff --git a/ecrire/action/editer_site.php b/ecrire/action/editer_site.php
index 15ca917570..45290e2c0e 100644
--- a/ecrire/action/editer_site.php
+++ b/ecrire/action/editer_site.php
@@ -19,12 +19,15 @@ function action_editer_site_dist() {
 	$securiser_action = charger_fonction('securiser_action', 'inc');
 	$arg = $securiser_action();
 
+	if (preg_match(',options/(\d+),',$arg, $r)) {
+		$id_syndic = $r[1];
+		editer_site_options($id_syndic);
 	// Envoi depuis le formulaire d'edition d'un site existant
-	if ($id_syndic = intval($arg)) {
+	} else if ($id_syndic = intval($arg)) {
 
 		// reload si on change une des valeurs de syndication
 		if (
-		(_request('url_syndic') OR _request('syndication')  OR _request('resume') OR _request('syndication'))
+		(_request('url_syndic') OR _request('resume') OR _request('syndication'))
 		AND $s = spip_query("SELECT url_syndic,syndication,resume FROM spip_syndic WHERE id_syndic="._q($id_syndic))
 		AND $t = spip_fetch_array($s)
 		AND (
@@ -325,4 +328,25 @@ function analyser_site($url) {
 	return $result;
 }
 
+function editer_site_options($id_syndic)
+{
+	$moderation = _request('moderation');
+	$miroir = _request('miroir');
+	$oubli = _request('oubli');
+	$resume = _request('resume');
+
+	if ($moderation == 'oui' OR $moderation == 'non')
+		spip_query("UPDATE spip_syndic SET moderation='$moderation' WHERE id_syndic=$id_syndic");
+	if ($miroir == 'oui' OR $miroir == 'non')
+		spip_query("UPDATE spip_syndic SET miroir='$miroir'	WHERE id_syndic=$id_syndic");
+	if ($oubli == 'oui' OR $oubli == 'non')
+		spip_query("UPDATE spip_syndic SET oubli='$oubli' WHERE id_syndic=$id_syndic");
+
+	if ($resume == 'oui' OR $resume == 'non') {
+		spip_query("UPDATE spip_syndic SET resume='$resume'	WHERE id_syndic=$id_syndic");
+		include_spip('inc/syndic');
+		syndic_a_jour($id_syndic);
+	}
+}
+
 ?>
diff --git a/ecrire/exec/sites.php b/ecrire/exec/sites.php
index 3fc00c3d96..c4645c370c 100644
--- a/ecrire/exec/sites.php
+++ b/ecrire/exec/sites.php
@@ -32,18 +32,10 @@ function exec_sites_dist()
   global   $connect_statut,   $options,   $spip_lang_left,  $spip_lang_right, $spip_display;
 
   global
-  $cherche_mot,
-  $select_groupe, 
-  $id_syndic,
-  $miroir,
-  $moderation,
-  $oubli,
-  $resume,
-  $syndication,
-  $syndication_old,
-  $url,
-  $url_site,
-  $url_syndic;
+    $cherche_mot,
+    $select_groupe, 
+    $id_parent,
+    $id_syndic;
 
   $id_rubrique = intval($id_parent); // pas toujours present, mais tant pis.
   $id_syndic = intval($id_syndic);
@@ -244,15 +236,6 @@ if ($flag_administrable) {
  }
 
 
-# appliquer les choix concernant le resume (a passer dans editer_site)
-if ($flag_editable AND ($resume == 'oui' OR $resume == 'non')) {
-	spip_query("UPDATE spip_syndic SET resume='$resume'	WHERE id_syndic=$id_syndic");
-	include_spip('inc/syndication');
-	syndic_a_jour($id_syndic);
-} else $resume = '';
-if (!$resume AND !$resume = $row['resume']) $resume = 'oui';
-
-
 if ($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") {
 	echo "<p class='verdana1 spip_medium'><a href='".htmlspecialchars($url_syndic)."'>",	http_img_pack('feed.png', 'RSS', ''),	'</a> <b>'._T('info_site_syndique').'</b></p>';
 
@@ -299,106 +282,94 @@ if ($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") {
 	// Options
 	if ($flag_administrable && $options=='avancees') {
 
-		debut_cadre_relief('feed.png', false, "", _T('syndic_options').aide('artsyn'));
-		echo  generer_url_post_ecrire("sites",("id_syndic=$id_syndic"));
-
-		// modifier la moderation
-		if ($moderation == 'oui' OR $moderation == 'non')
-			spip_query("UPDATE spip_syndic SET moderation='$moderation' WHERE id_syndic=$id_syndic");
-		else
-			$moderation = $mod;
+		$moderation = $mod;
 		if ($moderation != 'oui') $moderation='non';
 
-		echo "<div align='".$GLOBALS['spip_lang_left']."'>",
-		  _T('syndic_choix_moderation');
-		echo "<div style='padding-$spip_lang_left: 40px;'>";
-		echo afficher_choix('moderation', $moderation,
+		$res .= "<div align='".$GLOBALS['spip_lang_left']."'>".
+		  _T('syndic_choix_moderation')
+		. "<div style='padding-$spip_lang_left: 40px;'>"
+		. afficher_choix('moderation', $moderation,
 			array(
-			'non' => _T('info_publier')
-				.' ('._T('bouton_radio_modere_posteriori').')',
-			'oui' => _T('info_bloquer')
-				.' ('._T('bouton_radio_modere_priori').')'
-			));
-		echo "</div></div>\n";
+			'non' => _T('info_publier') .' ('._T('bouton_radio_modere_posteriori').')',
+			'oui' => _T('info_bloquer') .' ('._T('bouton_radio_modere_priori').')' ))
+		. "</div></div>\n";
 		
 		// Oublier les vieux liens ?
 		// Depublier les liens qui ne figurent plus ?
-		# appliquer les choix
-		if ($miroir == 'oui' OR $miroir == 'non')
-			spip_query("UPDATE spip_syndic SET miroir='$miroir'	WHERE id_syndic=$id_syndic");
-		if ($oubli == 'oui' OR $oubli == 'non')
-			spip_query("UPDATE spip_syndic SET oubli='$oubli' WHERE id_syndic=$id_syndic");
-
-		echo "\n<div>&nbsp;</div>";
-		echo "\n<div align='".$GLOBALS['spip_lang_left']."'>"._T('syndic_choix_oublier'), '</div>';
-
-		echo "\n<ul align='".$GLOBALS['spip_lang_left']."'>\n";
 
-		# miroir
-		if (!$miroir AND !$miroir = $row['miroir']) $miroir = 'non';
-		echo "\n<li>"._T('syndic_option_miroir').' ';
-		echo afficher_choix('miroir', $miroir,
-			array('oui' => _T('item_oui'), 'non' => _T('item_non')),
-			" &nbsp;\n");
-		echo "</li>\n";
+		$res .= "\n<div>&nbsp;</div>"
+		. "\n<div align='".$GLOBALS['spip_lang_left']."'>"._T('syndic_choix_oublier'). '</div>'
+		. "\n<ul align='".$GLOBALS['spip_lang_left']."'>\n";
 
-		# oubli
-		if (!$oubli AND !$oubli = $row['oubli']) $oubli = 'non';
-		echo "\n<li>"._T('syndic_option_oubli', array('mois' => 2)).' ';
-		echo afficher_choix('oubli', $oubli,
-			array('oui' => _T('item_oui'), 'non' => _T('item_non')),
-			" &nbsp; ");
-		echo "</li>\n";
-
-		echo "</ul>\n";
+		$on = array('oui' => _T('item_oui'), 'non' => _T('item_non'));
+		if (!$miroir = $row['miroir']) $miroir = 'non';
+		$res .= "\n<li>"._T('syndic_option_miroir').' '
+		. afficher_choix('miroir', $miroir, $on, " &nbsp; ")
+		. "</li>\n";
 
+		if (!$oubli = $row['oubli']) $oubli = 'non';
+		$res .= "\n<li>"
+		. _T('syndic_option_oubli', array('mois' => 2)).' '
+		. afficher_choix('oubli', $oubli, $on," &nbsp; ")
+		. "</li>\n"
+		. "</ul>\n";
 
 		// Prendre les resumes ou le texte integral ?
-		# choix appliques plus haut (a passer dans editer_site)
-		echo "\n<div align='$spip_lang_left'>"
-			. _T('syndic_choix_resume') ;
-		echo "\n<div style='padding-$spip_lang_left: 40px;'>";		
-		echo afficher_choix('resume', $resume,
-			array(
-				'oui' => _T('syndic_option_resume_oui'),
-				'non' => _T('syndic_option_resume_non')
-			));
-		echo "</div></div>\n";
-
+		if (!$resume = $row['resume']) $resume = 'oui';
+		$res .= "\n<div align='$spip_lang_left'>"
+		.  _T('syndic_choix_resume') 
+		. "\n<div style='padding-$spip_lang_left: 40px;'>"
+		. afficher_choix('resume', $resume,
+			array(	'oui' => _T('syndic_option_resume_oui'),
+				'non' => _T('syndic_option_resume_non')	))
+		. "</div></div>\n";
 
 		// Bouton "Valider"
-		echo "\n<div style='text-align:$spip_lang_right'><input type='submit' value='"._T('bouton_valider')."' class='fondo' /></div>\n</form>\n";
-
-		fin_cadre_relief();
+		$res .= "\n<div style='text-align:$spip_lang_right'><input type='submit' value='"._T('bouton_valider')."' class='fondo' /></div>\n";
+		echo debut_cadre_relief('feed.png', false, "", _T('syndic_options').aide('artsyn')),	
+		  redirige_action_auteur('editer_site',
+					 "options/$id_syndic",
+					 'sites',
+					 '',
+					 $res,
+					 " method='post'"),
+		  fin_cadre_relief();
 	}
-}
+ }
 // Cas d'un site ayant un feedfinder detecte
-else if (preg_match(',^\s*select: (.*),', $url_syndic, $regs)) {
-	echo "<br /><br />\n";
-	echo   generer_url_post_ecrire("sites",("id_syndic=$id_syndic"));
+// Bug: action/editer_site ne le voit pas passer.
+ else if (preg_match(',^\s*select: (.*),', $url_syndic, $regs)) {
 
+	$res = "<br /><br />\n";
 	foreach (
 		array('id_rubrique', 'nom_site', 'url_site', 'descriptif', 'statut')
 	as $var) {
-		echo "<input type='hidden' name='$var' value=\"".entites_html($$var)."\" />";
+		$res .= "<input type='hidden' name='$var' value=\"".entites_html($$var)."\" />\n";
 	}
-	echo debut_cadre_relief();
-	echo "<div align='$spip_lang_left'>\n";
-	echo "<input type='radio' name='syndication' value='non' id='syndication_non' checked='checked'>";
-	echo " <b><label for='syndication_non'>"._T('bouton_radio_non_syndication')."</label></b><p>";
-	echo "<input type='radio' name='syndication' value='oui' id='syndication_oui'>";
-	echo " <b><label for='syndication_oui'>"._T('bouton_radio_syndication')."</label></b> &nbsp;";
-
-	$feeds = explode(' ',$regs[1]);
-	echo "<select name='url_syndic'>\n";
-	foreach ($feeds as $feed) {
-		echo '<option value="'.entites_html($feed).'">'.$feed."</option>\n";
+
+	$res .= "<div align='$spip_lang_left'>\n";
+	$res .= "<input type='radio' name='syndication' value='non' id='syndication_non' checked='checked' />";
+	$res .= " <b><label for='syndication_non'>"._T('bouton_radio_non_syndication')."</label></b>";
+	$res .= "<input type='radio' name='syndication' value='oui' id='syndication_oui' />";
+	$res .= " <b><label for='syndication_oui'>"._T('bouton_radio_syndication')."</label></b> &nbsp;";
+
+	$res .= "<select name='url_syndic'>\n";
+	foreach (explode(' ',$regs[1]) as $feed) {
+		$res .= '<option value="'.entites_html($feed).'">'.$feed."</option>\n";
 	}
-	echo "</select>\n";
-	echo aide("rubsyn");
-	echo "<div align='$spip_lang_right'><input type='submit' value='"._T('bouton_valider')."' class='fondo'></div>\n";
+	$res .= "</select>\n";
+	$res .= aide("rubsyn");
+	$res .= "<div align='$spip_lang_right'><input type='submit' value='"._T('bouton_valider')."' class='fondo' /></div>\n";
+	$res .= "</div>\n";
+	echo debut_cadre_relief();
+	echo redirige_action_auteur('editer_site',
+		$id_syndic,
+		'sites',
+		'',
+		$res,
+		" method='post'");
 	echo fin_cadre_relief();
-	echo "</div></form>\n";
+
 }
 
 
-- 
GitLab