Skip to content
Extraits de code Groupes Projets
Valider 1ddc72ff rédigé par esj's avatar esj
Parcourir les fichiers

Prendre des valeurs par défaut plutot que de provoquer des erreurs SQL dans...

Prendre des valeurs par défaut plutot que de provoquer des erreurs SQL dans les tests automatiques du validateur.
parent 21d1db8d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -25,13 +25,14 @@ function exec_dater_args($id, $type) ...@@ -25,13 +25,14 @@ function exec_dater_args($id, $type)
include_spip('inc/minipres'); include_spip('inc/minipres');
echo minipres(); echo minipres();
} else { } else {
$table = table_objet_sql($type); $table = 'spip_documents_' . $type . 's';
if (!$table) { if (!id_table_objet($table)) {
spip_log("dater, type inconnu: $type"); spip_log("dater: $type table inconnue");
$type = 'article'; $type = 'article';
$table = table_objet_sql($type); $table = 'spip_documents_' . $type . 's';
} }
$row = sql_fetsel("*", $table, "id_$type=$id"); $prim = 'id_' . $type;
$row = sql_fetsel("*", $table, "$prim=$id");
$statut = $row['statut']; $statut = $row['statut'];
$date = $row[($type!='breve')?"date":"date_heure"]; $date = $row[($type!='breve')?"date":"date_heure"];
$date_redac = isset($row["date_redac"]) ? $row["date_redac"] : ''; $date_redac = isset($row["date_redac"]) ? $row["date_redac"] : '';
......
...@@ -17,13 +17,13 @@ function exec_legender_dist() ...@@ -17,13 +17,13 @@ function exec_legender_dist()
{ {
exec_legender_args(intval(_request('id_document')), exec_legender_args(intval(_request('id_document')),
_request('type'), _request('type'),
intval(_request('id')),
_request('ancre'), _request('ancre'),
_request('script'), _request('script'));
intval(_request('id')));
} }
// http://doc.spip.org/@exec_legender_args // http://doc.spip.org/@exec_legender_args
function exec_legender_args($id_document, $type, $ancre, $script, $id) function exec_legender_args($id_document, $type, $id, $ancre, $script)
{ {
if (!$id_document OR !autoriser('joindredocument',$type, $id)) { if (!$id_document OR !autoriser('joindredocument',$type, $id)) {
include_spip('inc/minipres'); include_spip('inc/minipres');
......
...@@ -19,10 +19,12 @@ include_spip('inc/date'); ...@@ -19,10 +19,12 @@ include_spip('inc/date');
// http://doc.spip.org/@exec_message_edit_dist // http://doc.spip.org/@exec_message_edit_dist
function exec_message_edit_dist() function exec_message_edit_dist()
{ {
exec_message_edit_args(intval(_request('id_message')), intval(_request('dest')), _request('new')); exec_message_edit_args(intval(_request('id_message')),
_request('new'),
intval(_request('dest')));
} }
// http://doc.spip.org/@exec_message_edit_args // http://doc.spip.org/@exec_message_edit_args
function exec_message_edit_args($id_message,$dest, $new) function exec_message_edit_args($id_message, $new, $dest)
{ {
global $connect_id_auteur, $connect_statut; global $connect_id_auteur, $connect_statut;
......
...@@ -26,10 +26,12 @@ function inc_documenter_dist( ...@@ -26,10 +26,12 @@ function inc_documenter_dist(
$appelant ='' # pour le rappel (cf plugin) $appelant ='' # pour le rappel (cf plugin)
) { ) {
$table = 'spip_documents_' . $type . 's'; $table = 'spip_documents_' . $type . 's';
$prim = id_table_objet($table); if (!id_table_objet($table)) {
if (!$prim) return ''; spip_log("documenter: $type table inconnue");
$type = 'article';
$table = 'spip_documents_' . $type . 's';
}
$prim = 'id_' . $type; $prim = 'id_' . $type;
if (is_int($doc)) { if (is_int($doc)) {
if ($ancre == 'portfolio') { if ($ancre == 'portfolio') {
$lies = sql_select("D.id_document, D.id_vignette, D.extension, D.titre, D.date, D.descriptif, D.fichier, D.taille, D.largeur, D.hauteur, D.mode, D.distant, l.vu, l." .$prim, "spip_documents AS D, $table AS l", "l.$prim=$doc AND l.id_document=D.id_document AND D.mode='document' AND D.extension IN ('gif', 'jpg', 'png')",'', "0+D.titre, D.date"); $lies = sql_select("D.id_document, D.id_vignette, D.extension, D.titre, D.date, D.descriptif, D.fichier, D.taille, D.largeur, D.hauteur, D.mode, D.distant, l.vu, l." .$prim, "spip_documents AS D, $table AS l", "l.$prim=$doc AND l.id_document=D.id_document AND D.mode='document' AND D.extension IN ('gif', 'jpg', 'png')",'', "0+D.titre, D.date");
......
...@@ -24,12 +24,13 @@ include_spip('inc/date'); ...@@ -24,12 +24,13 @@ include_spip('inc/date');
// http://doc.spip.org/@inc_legender_dist // http://doc.spip.org/@inc_legender_dist
function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre, $deplier=false) { function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre, $deplier=false) {
// + securite (avec le script exec=legender ca vient de dehors)
$table = 'spip_documents_' . $type . 's'; $table = 'spip_documents_' . $type . 's';
$prim = id_table_objet($table); if (!id_table_objet($table)) {
if (!$prim) return ''; spip_log("legender: $type table inconnue");
$type = 'article';
$table = 'spip_documents_' . $type . 's';
}
$prim = 'id_' . $type; $prim = 'id_' . $type;
// premier appel // premier appel
if ($document) { if ($document) {
$flag = $deplier; $flag = $deplier;
...@@ -44,7 +45,7 @@ function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre, ...@@ -44,7 +45,7 @@ function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre,
$flag = 'ajax'; $flag = 'ajax';
} }
else else
return; return '';
$descriptif = $document['descriptif']; $descriptif = $document['descriptif'];
$titre = $document['titre']; $titre = $document['titre'];
......
...@@ -1355,23 +1355,24 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=NULL, $aj ...@@ -1355,23 +1355,24 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=NULL, $aj
global $spip_lang_right, $spip_lang_left; global $spip_lang_right, $spip_lang_left;
include_spip('inc/afficher_objets'); include_spip('inc/afficher_objets');
if (!($table = table_objet_sql($type))) { $table = table_objet_sql($type);
if (!id_table_objet($table)) {
spip_log("meme_rubrique: $type table inconnue"); spip_log("meme_rubrique: $type table inconnue");
$type = 'article'; $type = 'article';
$table = table_objet_sql($type); $table = 'spip_articles';
} }
$prim = 'id_' . $type;
if (!$limit) $limit = 10; if (!$limit) $limit = 10;
$titre = ($type!='syndic'?'titre':'nom_site'); $titre = ($type!='syndic'?'titre':'nom_site');
$exec = array('article'=>'articles','breve'=>'breves_voir','syndic'=>'sites'); $exec = array('article'=>'articles','breve'=>'breves_voir','syndic'=>'sites');
$key = 'id_' . $type;
$where = (($GLOBALS['auteur_session']['statut'] == '0minirezo') $where = (($GLOBALS['auteur_session']['statut'] == '0minirezo')
? '' ? ''
: "(statut = 'publie' OR statut = 'prop') AND ") : "(statut = 'publie' OR statut = 'prop') AND ")
. "id_rubrique=$id_rubrique AND ($key != $id)"; . "id_rubrique=$id_rubrique AND ($prim != $id)";
$select = "$key AS id, $titre AS titre, statut"; $select = "$prim AS id, $titre AS titre, statut";
$n = sql_countsel($table, $where); $n = sql_countsel($table, $where);
...@@ -1386,11 +1387,11 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=NULL, $aj ...@@ -1386,11 +1387,11 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=NULL, $aj
while($row = sql_fetch($voss)) { while($row = sql_fetch($voss)) {
$id = $row['id']; $id = $row['id'];
$num = afficher_numero_edit($id, $key, $type); $num = afficher_numero_edit($id, $prim, $type);
$statut = $row['statut']; $statut = $row['statut'];
$statut = $fstatut($id, $statut, $id_rubrique, $type); $statut = $fstatut($id, $statut, $id_rubrique, $type);
$href = "<a class='verdana1' href='" $href = "<a class='verdana1' href='"
. generer_url_ecrire($exec[$type],"$key=$id") . generer_url_ecrire($exec[$type],"$prim=$id")
. "'>" . "'>"
. sinon(typo($row['titre']), _T('info_sans_titre')) . sinon(typo($row['titre']), _T('info_sans_titre'))
. "</a>"; . "</a>";
......
...@@ -27,8 +27,7 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type) ...@@ -27,8 +27,7 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type)
} }
$table = 'spip_documents_' . $type . 's'; $table = 'spip_documents_' . $type . 's';
$prim = id_table_objet($table); if (!id_table_objet($table)) {
if (!$prim) {
spip_log("tourner: $type table inconnue"); spip_log("tourner: $type table inconnue");
$type = 'article'; $type = 'article';
$table = 'spip_documents_' . $type . 's'; $table = 'spip_documents_' . $type . 's';
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter