Commit ef29af17 authored by Aiguille's avatar Aiguille

add preview button to news edition

parent 5dbe1ed7
......@@ -63,16 +63,19 @@ if ( isset($_REQUEST["id_nouvelle"]) )
}
// Ajout des dates
if ( ($_REQUEST["action"] == "adddate") && $can_edit )
{
if ( $_REQUEST["debut"] && ( $_REQUEST["debut"] < $_REQUEST["fin"] ) )
$news->add_date($_REQUEST["debut"],$_REQUEST["fin"]);
}
// Suppression des dates
else if ( ($_REQUEST["action"] == "delete") && isset($_REQUEST["id_dates_nvl"]) && $can_edit )
{
$news->delete_date($_REQUEST["id_dates_nvl"]);
}
// Suppression de la nouvelle
elseif ( ($_REQUEST["action"] == "delete") && !isset($_REQUEST["id_dates_nvl"]) && $can_edit )
{
if ( $site->is_sure("accueil","Supprimer la nouvelle ?","delnws".$news->id) )
......@@ -83,13 +86,88 @@ elseif ( ($_REQUEST["action"] == "delete") && !isset($_REQUEST["id_dates_nvl"])
"avec succ&egrave;s</p>");
}
}
elseif ( ($_REQUEST["action"] == "save") && $can_edit )
// Visualisation d'une nouvelle
if ( $news->id > 0 && $_REQUEST["action"] != "save" && $_REQUEST["page"] != "edit")
{
if ((!$can_edit) && (!$news->modere))
$site->error_forbidden("accueil");
$site->start_page ("accueil", $news->titre);
$site->set_side_boxes("right",array("calendrier","lastnews"),"news_left");
$cts = $news->get_contents();
$cts->puts("<div class=\"clearboth\"></div>");
if ( $site->user->is_in_group("gestion_ae"))
{
$user1 = new utilisateur($site->db);
$user2 = new utilisateur($site->db);
$user1->load_by_id($news->id_utilisateur);
$user2->load_by_id($news->id_utilisateur_moderateur);
$cts->add_title(2,"");
$cts->add_paragraph("Post&eacute; par : ".$user1->get_html_link());
if ( $user2->is_valid() )
$cts->add_paragraph("Valid&eacute; par : ".$user2->get_html_link());
}
$cts->add(new reactonforum ( $site->db, $site->user, $news->titre, array("id_nouvelle"=>$news->id), $news->id_asso, true ));
$site->add_contents ($cts);
if ( $can_edit )
{
$cts = new contents("Edition");
$cts->add_paragraph("<a href=\"news.php?page=edit&amp;id_nouvelle=".$news->id."\">Modifier</a> (la nouvelle sera de nouveau soumise &agrave; mod&eacute;ration)");
$cts->add_paragraph("<a href=\"news.php?action=delete&amp;id_nouvelle=".$news->id."\">Supprimer</a>");
$site->add_contents($cts);
}
$site->end_page ();
exit();
}
// Page d'erreur
if ( !$site->user->is_valid() )
{
header("Location: 403.php?reason=session");
exit();
}
// Validation ou prévisualisation de la modification d'une nouvelle
elseif ( (($_REQUEST["action"] == "save") && $can_edit) || (isset($_REQUEST["preview"]) && ( $_REQUEST["page"] == "edit") && $can_edit))
{
$modere = false;
$lieu->load_by_id($_REQUEST["id_lieu"]);
// Si le formulaire est valide
if ( $_REQUEST["title"] && $_REQUEST["content"] && $_REQUEST['resume'] )
{
// Prévisualisation de la nouvelle
if (isset($_REQUEST["preview"]))
{
$asso = new asso($site->db);
$asso->load_by_id($_REQUEST["id_asso"]);
$cts = new contents($_REQUEST["title"]);
$img = "data/img/logos/".$asso->nom_unix.".small.png";
if ( !file_exists("/var/www/ae2/".$img) )
$img = "images/default/news.small.png";
$cts->add(new image($asso->nom, $img, "newsimg"));
$cts->add(new wikicontents(false,$_REQUEST["content"]));
if ( $asso->id > 0 )
{
$cts->add_title(2,"");
$cts->add_paragraph($asso->get_html_link());
}
$site->add_contents ($cts);
}
// Sauvegarde de la nouvelle
else
{
$news->save_news(
$_REQUEST['id_asso'],
......@@ -106,14 +184,24 @@ elseif ( ($_REQUEST["action"] == "save") && $can_edit )
}
}
}
}
else
{
$news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";
}
}
// Modification d'une nouvelle
if ( $_REQUEST["page"] == "edit" && $can_edit )
{
$site->start_page ("services", $news->titre);
$cts = new contents("Editer");
$frm = new form ("editnews","news.php",false,"POST","Edition d'une nouvelle");
if ( $news_error )
$frm->error($news_error);
$frm->add_hidden("page","edit");
$frm->add_hidden("action","save");
$frm->add_hidden("id_nouvelle",$news->id);
$frm->add_info("<b>ATTENTION</b> La nouvelle sera soumise &agrave; nouveau &agrave; mod&eacute;ration");
......@@ -136,6 +224,7 @@ if ( $_REQUEST["page"] == "edit" && $can_edit )
if( $site->user->is_in_group("moderateur_site") )
$frm->add_checkbox("automodere", "<b>Auto-modération</b>", true);
$frm->add_submit ("preview","Pr&eacute;visualiser");
$frm->add_submit("valid","Enregistrer");
$site->add_contents ($frm);
......@@ -173,53 +262,6 @@ if ( $_REQUEST["page"] == "edit" && $can_edit )
if ( $news->id > 0 )
{
if ((!$can_edit) && (!$news->modere))
$site->error_forbidden("accueil");
$site->start_page ("accueil", $news->titre);
$site->set_side_boxes("right",array("calendrier","lastnews"),"news_left");
$cts = $news->get_contents();
$cts->puts("<div class=\"clearboth\"></div>");
if ( $site->user->is_in_group("gestion_ae"))
{
$user1 = new utilisateur($site->db);
$user2 = new utilisateur($site->db);
$user1->load_by_id($news->id_utilisateur);
$user2->load_by_id($news->id_utilisateur_moderateur);
$cts->add_title(2,"");
$cts->add_paragraph("Post&eacute; par : ".$user1->get_html_link());
if ( $user2->is_valid() )
$cts->add_paragraph("Valid&eacute; par : ".$user2->get_html_link());
}
$cts->add(new reactonforum ( $site->db, $site->user, $news->titre, array("id_nouvelle"=>$news->id), $news->id_asso, true ));
$site->add_contents ($cts);
if ( $can_edit )
{
$cts = new contents("Edition");
$cts->add_paragraph("<a href=\"news.php?page=edit&amp;id_nouvelle=".$news->id."\">Modifier</a> (la nouvelle sera de nouveau soumise &agrave; mod&eacute;ration)");
$cts->add_paragraph("<a href=\"news.php?action=delete&amp;id_nouvelle=".$news->id."\">Supprimer</a>");
$site->add_contents($cts);
}
$site->end_page ();
exit();
}
if ( !$site->user->is_valid() )
{
header("Location: 403.php?reason=session");
exit();
}
require_once($topdir."include/entities/files.inc.php");
require_once($topdir."include/entities/folder.inc.php");
......@@ -229,8 +271,10 @@ $site->start_page ("accueil", "Accueil Nouvelles");
$suitable = false;
// Si la nouvelle à été soumise ou s'il y a prévisualisation
if ( isset($_REQUEST["preview"]) || isset($_REQUEST["submit"]) )
{
// Gestion du fichier
if ( isset($_FILES['affiche_file']) && $_FILES['affiche_file']['error'] == 0 )
{
$asso = new asso($site->db);
......@@ -263,6 +307,7 @@ if ( isset($_REQUEST["preview"]) || isset($_REQUEST["submit"]) )
}
}
// Vérification des champs du formulaire
if ( !$_REQUEST["title"] || !$_REQUEST["content"] || !$_REQUEST['resume'] )
$news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";
......@@ -305,11 +350,9 @@ if ( isset($_REQUEST["preview"]) || isset($_REQUEST["submit"]) )
else
$suitable = true;
}
// Validation de l'ajout d'une nouvelle
if ( $suitable && isset($_REQUEST["submit"]) )
{
$lieu->load_by_id($_REQUEST["id_lieu"]);
......@@ -357,7 +400,7 @@ if ( $suitable && isset($_REQUEST["submit"]) )
"avec succ&egrave;s</p>"));
}
// Prévisualisation d'une nouvelle
if ( $suitable && isset($_REQUEST["preview"]) )
{
$asso = new asso($site->db);
......@@ -404,6 +447,7 @@ elseif ( !isset($_REQUEST["preview"]) )
$site->add_contents($page->get_contents());
}
// Formulaire d'ajout d'une nouvelle
$frm = new form ("addnews_frm","news.php",false,"POST","Proposition d'une nouvelle");
if ( $news_error )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment