news.php 19.3 KB
Newer Older
Skia's avatar
Skia committed
1
2
<?php

Ayolo's avatar
Ayolo committed
3
4
5
6
7
8
9
10
/* Copyright 2006
 * - Julien Etelain < julien at pmad dot net >
 * - Pierre Mauduit
 *
 * Ce fichier fait partie du site de l'Association des Étudiants de
 * l'UTBM, http://ae.utbm.fr.
 *
 * This program is free software; you can redistribute it and/or
Ayolo's avatar
Ayolo committed
11
 * modify it under the terms of the GNU General Public License a
Ayolo's avatar
Ayolo committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

$topdir = "./";
require_once($topdir . "include/site.inc.php");
require_once($topdir . "include/cts/sqltable.inc.php");
require_once($topdir . "include/cts/newsflow.inc.php");
require_once($topdir."include/cts/react.inc.php");

require_once($topdir . "include/entities/news.inc.php");
require_once($topdir . "include/entities/asso.inc.php");
require_once($topdir . "include/entities/lieu.inc.php");
Feu's avatar
fix    
Feu committed
35
require_once($topdir . "include/entities/page.inc.php");
Ayolo's avatar
Ayolo committed
36
37
38
39

$site = new site();
$site->add_css("css/doku.css");

Feu's avatar
Feu committed
40
$news = new nouvelle($site->db, $site->dbrw);
Ayolo's avatar
Ayolo committed
41
42
43
44
45
$lieu = new lieu($site->db);

$can_edit = false;

$site->add_box("lastnews",new newslist ( "Deni&egrave;res nouvelles", $site->db ) );
Ayolo's avatar
Ayolo committed
46
$site->set_side_boxes("right",array("calendrier","lastnews","alerts","connexion"),"news_left");
Ayolo's avatar
Ayolo committed
47
48
49
50
51
52

if ( isset($_REQUEST["id_nouvelle"]) )
{
  $news->load_by_id($_REQUEST["id_nouvelle"]);
  if ( $news->id < 1 )
    {
53
      $site->error_not_found("accueil");
Ayolo's avatar
Ayolo committed
54
55
56
57
58
59
60
61
62
63
64
65
66
      exit();
    }

  $asso = new asso($site->db);
  $asso->load_by_id($news->id_asso);

  $can_edit = $site->user->is_in_group("moderateur_site") || ($news->id_utilisateur == $site->user->id);

  if ( $asso->id > 0 )
    $can_edit = $can_edit || $asso->is_member_role($site->user->id,ROLEASSO_MEMBREBUREAU);

}

Aiguille's avatar
Aiguille committed
67
// Ajout des dates
Ayolo's avatar
Ayolo committed
68
69
70
71
72
73
if ( ($_REQUEST["action"] == "adddate") && $can_edit )
{
  if ( $_REQUEST["debut"] && ( $_REQUEST["debut"]  < $_REQUEST["fin"] ) )
    $news->add_date($_REQUEST["debut"],$_REQUEST["fin"]);

}
Aiguille's avatar
Aiguille committed
74
// Suppression des dates
Ayolo's avatar
Ayolo committed
75
76
77
78
else    if ( ($_REQUEST["action"] == "delete") && isset($_REQUEST["id_dates_nvl"]) && $can_edit )
{
  $news->delete_date($_REQUEST["id_dates_nvl"]);
}
Aiguille's avatar
Aiguille committed
79
// Suppression de la nouvelle
Ayolo's avatar
Ayolo committed
80
81
82
83
84
85
86
87
88
89
90
elseif ( ($_REQUEST["action"] == "delete") && !isset($_REQUEST["id_dates_nvl"]) && $can_edit )
{
  if ( $site->is_sure("accueil","Supprimer la nouvelle ?","delnws".$news->id) )
    {
      $news->delete();
      $cts_success = new contents("Suppression de nouvelles",
                                  "<p>Votre nouvelle a &eacute;t&eacute; supprim&eacute;e ".
                                  "avec succ&egrave;s</p>");
    }
}

Aiguille's avatar
Aiguille committed
91
92
// Visualisation d'une nouvelle
if ( $news->id > 0 && $_REQUEST["action"] != "save" && $_REQUEST["page"]  != "edit")
Ayolo's avatar
Ayolo committed
93
{
Aiguille's avatar
Aiguille committed
94
95
	if ((!$can_edit) && (!$news->modere))
	$site->error_forbidden("accueil");
Ayolo's avatar
Ayolo committed
96

Aiguille's avatar
Aiguille committed
97
98
99
	$site->start_page ("accueil", $news->titre);
	$site->set_side_boxes("right",array("calendrier","lastnews"),"news_left");
	$cts = $news->get_contents();
Ayolo's avatar
Ayolo committed
100

Aiguille's avatar
Aiguille committed
101
	$cts->puts("<div class=\"clearboth\"></div>");
Ayolo's avatar
Ayolo committed
102

Aiguille's avatar
Aiguille committed
103
104
105
106
107
108
	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);
Ayolo's avatar
Ayolo committed
109

Aiguille's avatar
Aiguille committed
110
111
	$cts->add_title(2,"");
	$cts->add_paragraph("Post&eacute; par : ".$user1->get_html_link());
Ayolo's avatar
Ayolo committed
112

Aiguille's avatar
Aiguille committed
113
114
115
	if ( $user2->is_valid() )
	  $cts->add_paragraph("Valid&eacute; par : ".$user2->get_html_link());
	}
Ayolo's avatar
Ayolo committed
116

Aiguille's avatar
Aiguille committed
117
	$cts->add(new reactonforum ( $site->db, $site->user, $news->titre, array("id_nouvelle"=>$news->id), $news->id_asso, true ));
Ayolo's avatar
Ayolo committed
118

Aiguille's avatar
Aiguille committed
119
	$site->add_contents ($cts);
Ayolo's avatar
Ayolo committed
120

Aiguille's avatar
Aiguille committed
121
122
123
124
125
126
127
	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);
	}
Ayolo's avatar
Ayolo committed
128

Aiguille's avatar
Aiguille committed
129
130
131
	$site->end_page ();
	exit();
}
Ayolo's avatar
Ayolo committed
132

Aiguille's avatar
Aiguille committed
133
134
135
136
// Page d'erreur
if ( !$site->user->is_valid() )
{
  header("Location: 403.php?reason=session");
Ayolo's avatar
Ayolo committed
137
138
  exit();
}
Aiguille's avatar
Aiguille committed
139
140
// Validation ou prévisualisation de la modification d'une nouvelle
elseif ( (($_REQUEST["action"] == "save") && $can_edit) || (isset($_REQUEST["preview"]) && ( $_REQUEST["page"]  == "edit") && $can_edit))
Ayolo's avatar
Ayolo committed
141
{
Aiguille's avatar
Aiguille committed
142
143
  $modere = false;
  $lieu->load_by_id($_REQUEST["id_lieu"]);
Ayolo's avatar
Ayolo committed
144

Aiguille's avatar
Aiguille committed
145
146
	// Si le formulaire est valide
  if ( $_REQUEST["title"] && $_REQUEST["content"] && $_REQUEST['resume'] )
Ayolo's avatar
Ayolo committed
147
  {
Aiguille's avatar
Aiguille committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	  // 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'],
						 $_REQUEST['title'],
						 $_REQUEST['resume'],
						 $_REQUEST['content'],
						 false,null,$_REQUEST["type"],$lieu->id,NEWS_CANAL_SITE);
		$news->set_tags($_REQUEST["tags"]);

		if ( isset($_REQUEST['automodere']) ) {
		  if ($site->user->is_in_group("moderateur_site") && $_REQUEST['automodere'] ) {
			$news->validate($site->user->id);
			nouvelle::expire_cache_content ();
		  }
		}
	}
Ayolo's avatar
Ayolo committed
188
  }
Aiguille's avatar
Aiguille committed
189
  else
Ayolo's avatar
Ayolo committed
190
  {
Aiguille's avatar
Aiguille committed
191
	  $news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";
Ayolo's avatar
Ayolo committed
192
193
  }
}
Aiguille's avatar
Aiguille committed
194
195
// Modification d'une nouvelle
if ( $_REQUEST["page"]  == "edit" && $can_edit )
Ayolo's avatar
Ayolo committed
196
{
Aiguille's avatar
Aiguille committed
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
	$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");

	$frm->add_select_field ("type",
						  "Type de nouvelle",
						  array(NEWS_TYPE_APPEL => "Appel/concours",
								NEWS_TYPE_EVENT => "Événement ponctuel",
								NEWS_TYPE_HEBDO => "Séance hebdomadaire",
								NEWS_TYPE_NOTICE => "Info/resultat")
						  ,$news->type);
217
218
219
220
221
222
223
224
225
226
227
	// Prévisualisation
	if (isset($_REQUEST["preview"]))
	{
		$frm->add_text_field("title", "Titre de la nouvelle", $_REQUEST["title"], true);
		$frm->add_entity_select("id_asso", "Association concern&eacute;e", $site->db, "asso",$_REQUEST["id_asso"],true);
		$frm->add_entity_select("id_lieu", "Lieu", $site->db, "lieu",false,true);
		$frm->add_text_field("tags", "Tags",$_REQUEST["tags"]);
		$frm->add_text_area ("resume","Resum&eacute;",$_REQUEST["resume"], 40, 3, true);
		$frm->add_dokuwiki_toolbar('content');
		$frm->add_text_area ("content", "Contenu",$_REQUEST["content"],80,10,true);
	}
Aiguille's avatar
Aiguille committed
228
229
230
231
232
233
234
235
236
237
	else
	{
		$frm->add_text_field("title", "Titre",$news->titre,true);
		$frm->add_entity_select("id_asso", "Association concern&eacute;e", $site->db, "asso",$news->id_asso,true);
		$frm->add_entity_select("id_lieu", "Lieu", $site->db, "lieu",$news->id_lieu,true);
		$frm->add_text_field("tags", "Tags",$news->get_tags());
		$frm->add_text_area ("resume","Resume",$news->resume);
		$frm->add_dokuwiki_toolbar('content');
		$frm->add_text_area ("content", "Contenu",$news->contenu,80,10,true);
	}
Aiguille's avatar
Aiguille committed
238
239
240
241
242
243
244
245
246
247
248
	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);


	$req = new requete ( $site->db,"SELECT * FROM nvl_dates WHERE id_nouvelle='".$news->id."' ORDER BY date_debut_eve");

249
	// Dates
Aiguille's avatar
Aiguille committed
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
	$cts = new contents("Dates");

	if ( $req->lines > 0 )
	{
	  $tbl = new sqltable(
						  "listsalles",
						  "Liste actuelle", $req, "news.php?page=edit&id_nouvelle=".$news->id,
						  "id_dates_nvl",
						  array("date_debut_eve"=>"De","date_fin_eve"=>"Au"),
						  array("delete"=>"Supprimer"), array(),array()
						  );
	  $cts->add($tbl,true);
	}

	$frm = new form("selectdateresa","news.php?page=edit&id_nouvelle=".$news->id,false,"POST","Associer une date");
	$frm->add_hidden("action","adddate");
	$frm->add_datetime_field("debut","Date et heure de d&eacute;but");
	$frm->add_datetime_field("fin","Date et heure de fin");
	$frm->add_submit("valid","Ajouter");
	$cts->add($frm,true);

	$site->add_contents($cts);

	$site->add_contents (new wikihelp());
	$site->end_page ();
	exit();
Ayolo's avatar
Ayolo committed
276
277
}

Aiguille's avatar
Aiguille committed
278
279


Ayolo's avatar
Ayolo committed
280
281
282
283
284
require_once($topdir."include/entities/files.inc.php");
require_once($topdir."include/entities/folder.inc.php");

$file = new dfile($site->db, $site->dbrw);

285
$site->start_page ("accueil", "Accueil Nouvelles");
Ayolo's avatar
Ayolo committed
286
287
288

$suitable = false;

Aiguille's avatar
Aiguille committed
289
// Si la nouvelle à été soumise ou s'il y a prévisualisation
Ayolo's avatar
Ayolo committed
290
291
if ( isset($_REQUEST["preview"]) || isset($_REQUEST["submit"]) )
{
Aiguille's avatar
Aiguille committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
	// Gestion du fichier
	if ( isset($_FILES['affiche_file']) && $_FILES['affiche_file']['error'] == 0 )
	{
		$asso = new asso($site->db);
		$asso->load_by_id($_REQUEST["id_asso"]);
		$folder= new dfolder ($site->db, $site->dbrw);
		$folder->create_or_load ( "Affiches", $asso->id );
		if ( $folder->is_valid() )
		{
		  $file->herit($folder);
		  $file->id_utilisateur = $site->user->id;
		  $file->add_file ( $_FILES["affiche_file"], $_REQUEST["title"], $folder->id, "Affiche de ".$_REQUEST["title"], $asso->id );
		}
		else
		  $news_error = "Erreur interne lors de la creation du dossier \"Affiches\".";
	}
	elseif ( $_FILES['affiche_file']['error'] != UPLOAD_ERR_NO_FILE )
	$news_error = "Erreur lors du transfert de l'affiche.";

	elseif ( isset($_REQUEST["id_file"]) )
	$file->load_by_id($_REQUEST["id_file"]);

	if ( $file->is_valid() )
	{
		$_REQUEST["content"] = str_replace("{{@affiche|","{{dfile://".$file->id."/preview|",$_REQUEST["content"]);
		$_REQUEST["content"] = str_replace("[[@affiche|","[[dfile://".$file->id."]",$_REQUEST["content"]);

		if ( !ereg("\{\{dfile\:\/\/([0-9]*)\/preview\|(.*)\}\}",$_REQUEST["content"]) )
		{
		  $_REQUEST["content"] .= "\n\n{{dfile://".$file->id."/preview|Affiche}}\n\n[[dfile://".$file->id."|Version HD de l'affiche]]";
		}
	}

	// 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";

	elseif ( $_REQUEST["type"] == 3 &&
		   (!$_REQUEST["t3_debut"] || !$_REQUEST["t3_fin"]) )
	$news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";

	elseif ( $_REQUEST["type"] == 1 &&
		   (!$_REQUEST["t1_debut"] || !$_REQUEST["t1_fin"]) )
	$news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";

	elseif ( $_REQUEST["type"] == 2 &&
		   (!$_REQUEST["t2_debut"] || !$_REQUEST["t2_fin"] || !$_REQUEST["t2_until"]) )
	$news_error = "Un ou plusieurs champs obligatoires n'ont pas &eacute;t&eacute; remplis";

	elseif ( $_REQUEST["type"] == 3 && ( $_REQUEST["t3_debut"]  >= $_REQUEST["t3_fin"] ) )
	$news_error = "Date de debut et date de fin erron&eacute;s";
	elseif ( $_REQUEST["type"] == 1 && ( $_REQUEST["t1_debut"]  >= $_REQUEST["t1_fin"] ) )
	$news_error = "Date de debut et date de fin erron&eacute;s";
	elseif ( $_REQUEST["type"] == 2 && ( $_REQUEST["t2_debut"]  >= $_REQUEST["t2_fin"] ) )
	$news_error = "Date de debut et date de fin erron&eacute;s";
	elseif ( $_REQUEST["type"] == 2 && ( $_REQUEST["t2_fin"] >= $_REQUEST["t2_until"] ) )
	$news_error = "Dates invalides";
	elseif ( $_REQUEST["type"] == 2 && $_REQUEST["seldates"] != 1 )
	{
	  $h = intval(date("H",$_REQUEST["t2_debut"]));
	  for($debut=$_REQUEST["t2_debut"];$debut<$_REQUEST["t2_until"];$debut+=60*60*24*7)
		{
		  $debut += ($h-intval(date("H",$debut)))*(60*60);
		  $fin = $debut+($_REQUEST["t2_fin"]-$_REQUEST["t2_debut"]);
		  $_REQUEST["t2_dates"]["$debut:$fin"] = true;
		}
	}
	elseif ( $_REQUEST["type"] == 1 && $_REQUEST["t1_vpi"] != 1 )
Skia's avatar
Skia committed
360
	$news_error = "Veuillez vérifier avec la salle avec le RS avant de poster la nouvelle";
Aiguille's avatar
Aiguille committed
361
	elseif ( $_REQUEST["type"] == 2 && $_REQUEST["t2_vpi"] != 1 )
Skia's avatar
Skia committed
362
	$news_error = "Veuillez vérifier avec la salle avec le RS avant de poster la nouvelle";
Aiguille's avatar
Aiguille committed
363
364
365
366
367
	elseif ( $_REQUEST["type"] == 1 && $_REQUEST["t1_doublon"] != 1 )
	$news_error = "Veuillez vérifier qu'il n'y a pas de doublon avant de poster la nouvelle";

	else
	$suitable = true;
Ayolo's avatar
Ayolo committed
368
369
}

Aiguille's avatar
Aiguille committed
370
// Validation de l'ajout d'une nouvelle
Ayolo's avatar
Ayolo committed
371
372
if ( $suitable && isset($_REQUEST["submit"]) )
{
Aiguille's avatar
Aiguille committed
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
	$lieu->load_by_id($_REQUEST["id_lieu"]);


	$news->add_news($site->user->id,
				  $_REQUEST['id_asso'],
				  $_REQUEST['title'],
				  $_REQUEST['resume'],
				  $_REQUEST['content'],
				  $_REQUEST['type'],$lieu->id,NEWS_CANAL_SITE);

	$news->set_tags($_REQUEST["tags"]);

	if ( $_REQUEST["type"] == 3  )
	$news->add_date($_REQUEST["t3_debut"],$_REQUEST["t3_fin"]);
	elseif ( $_REQUEST["type"] == 1  )
	$news->add_date($_REQUEST["t1_debut"],$_REQUEST["t1_fin"]);
	elseif ( $_REQUEST["type"] == 2 )
	{
	  foreach ( $_REQUEST["t2_dates"] as $seq => $on )
		{
		  list($debut,$fin)=explode(":",$seq);
		  $news->add_date($debut,$fin);
		}
	}

	if ( isset($_REQUEST['automodere']) ) {
	if ($site->user->is_in_group("moderateur_site") && $_REQUEST['automodere']) {
	  $news->validate($site->user->id);
	  nouvelle::expire_cache_content ();
	}
	}

	unset($_REQUEST["dates"]);
	unset($_REQUEST["debut"]);
	unset($_REQUEST["fin"]);
	unset($_REQUEST["id_asso"]);
	unset($_REQUEST["title"]);
	unset($_REQUEST["resume"]);
	unset($_REQUEST["content"]);
	unset($_REQUEST["type"]);
	$site->add_contents(new contents("Ajout de nouvelles",
							  "<p>Votre nouvelle a &eacute;t&eacute; ajout&eacute;e ".
							  "avec succ&egrave;s</p>"));
Ayolo's avatar
Ayolo committed
416
417
}

Aiguille's avatar
Aiguille committed
418
// Prévisualisation d'une nouvelle
Ayolo's avatar
Ayolo committed
419
420
421
422
423
424
425
if ( $suitable && isset($_REQUEST["preview"]) )
{
  $asso = new asso($site->db);
  $asso->load_by_id($_REQUEST["id_asso"]);

  $cts = new contents($_REQUEST["title"]);

Antoine Tenart's avatar
fix    
Antoine Tenart committed
426
  $img = "data/img/logos/".$asso->nom_unix.".small.png";
Antoine Tenart's avatar
kwain    
Antoine Tenart committed
427
  if ( !file_exists("/var/www/ae2/".$img) )
Ayolo's avatar
Ayolo committed
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
    $img = "images/default/news.small.png";

  $cts->add(new image($asso->nom, $img, "newsimg"));
  $cts->add(new wikicontents(false,$_REQUEST["content"]));

  if ( isset($_REQUEST["dates"]) )
    {
      $cts->add_paragraph("Dates :");
      $lst = new itemlist();
      foreach ( $_REQUEST["dates"] as $seq => $on )
        {
          list($debut,$fin)=explode(":",$seq);
          $lst->add("Le ".textual_plage_horraire($debut,$fin));
        }
      $cts->add($lst);
    }
  elseif ( $_REQUEST["debut"] && $_REQUEST["fin"] )
    {
      $cts->add_paragraph("Date : le ".textual_plage_horraire($_REQUEST["debut"],$_REQUEST["fin"]));
    }

  if ( $asso->id > 0 )
    {
      $cts->add_title(2,"");
452
      $cts->add_paragraph($asso->get_html_link());
Ayolo's avatar
Ayolo committed
453
454
455
456
457
458
    }
  $site->add_contents ($cts);

}
elseif ( !isset($_REQUEST["preview"]) )
{
459
460
461
462
  $page = new page ($site->db);
  $page->load_by_pagename("info:news");
  if ( $page->is_valid() )
    $site->add_contents($page->get_contents());
Ayolo's avatar
Ayolo committed
463
464
}

Aiguille's avatar
Aiguille committed
465
// Formulaire d'ajout d'une nouvelle
Ayolo's avatar
Ayolo committed
466
467
468
469
470
$frm = new form ("addnews_frm","news.php",false,"POST","Proposition d'une nouvelle");

if ( $news_error )
  $frm->error($news_error);

Feu's avatar
fix    
Feu committed
471
472
473
if ( isset($_REQUEST["type"]) )
  $type = $_REQUEST["type"];
else
Ayolo's avatar
Ayolo committed
474
  $type=1;
475

Ayolo's avatar
Ayolo committed
476
477
$sfrm = new form("type",null,null,null,"Nouvelle sur un concours, un appel &agrave; canditure : longue dur&eacute;e");
$sfrm->add_datetime_field("t3_debut","Date et heure de d&eacute;but",time());
478
$sfrm->add_datetime_field("t3_fin","Date et heure de fin",$_REQUEST['t3_fin']);
Ayolo's avatar
Ayolo committed
479
480
481
$frm->add($sfrm,false,true, $type==3 ,3 ,false,true);

$sfrm = new form("type",null,null,null,"Nouvelle sur un &eacute;v&eacute;nement ponctuel associ&eacute; &agrave; une date");
482
483
$sfrm->add_datetime_field("t1_debut","Date et heure de d&eacute;but",$_REQUEST['t1_debut']);
$sfrm->add_datetime_field("t1_fin","Date et heure de fin",$_REQUEST['t1_fin']);
mbriand's avatar
mbriand committed
484
$sfrm->add_checkbox("t1_doublon", "J'ai vérifié qu'il n'existe pas encore de nouvelle pour cet évènement", $_REQUEST["t1_doublon"]);
Skia's avatar
Skia committed
485
$sfrm->add_checkbox("t1_vpi", "J'ai vu avec le RS pour la réservation de salle avant de poster cette nouvelle", $_REQUEST["t1_vpi"]);
Ayolo's avatar
Ayolo committed
486
487
488
489
490
491
492
493
494
495
496
497
498
499
$frm->add($sfrm,false,true, $type==1 ,1 ,false,true);

$sfrm = new form("type",null,null,null,"Nouvelle sur une s&eacute;ance ou une r&eacute;union hebdomadaire");
if ( isset($_REQUEST["t2_dates"]) )
{
  $ssfrm = new form("seldates",null,null,null,"Veuillez selectionner les dates r&eacute;elles");
  foreach ( $_REQUEST["t2_dates"] as $seq => $on )
    {
      list($debut,$fin)=explode(":",$seq);
      $ssfrm->add_checkbox("t2_dates|$debut:$fin","Le ".textual_plage_horraire($debut,$fin),true);
    }
  $sfrm->add($ssfrm,false,true, true , 1 ,false,true);

  $ssfrm = new form("seldates",null,null,null,"ou changer la p&eacute;riode");
500
501
502
  $ssfrm->add_datetime_field("t2_debut","Date et heure de d&eacute;but",$_REQUEST['t2_debut']);
  $ssfrm->add_datetime_field("t2_fin","Date et heure de fin",$_REQUEST['t2_fin']);
  $ssfrm->add_datetime_field("t2_until","... jusqu'au",$_REQUEST['t2_until']);
Ayolo's avatar
Ayolo committed
503
504
505
506
  $sfrm->add($ssfrm,false,true, false , 2 ,false,true);
}
else
{
507
508
509
  $sfrm->add_datetime_field("t2_debut","Date et heure de d&eacute;but",$_REQUEST['t2_debut']);
  $sfrm->add_datetime_field("t2_fin","Date et heure de fin",$_REQUEST['t2_fin']);
  $sfrm->add_datetime_field("t2_until","... jusqu'au",$_REQUEST['t2_until']);
Ayolo's avatar
Ayolo committed
510
}
Skia's avatar
Skia committed
511
$sfrm->add_checkbox("t2_vpi", "J'ai vu avec le RS pour la réservation de salle avant de poster cette nouvelle", $_REQUEST["t2_vpi"]);
Ayolo's avatar
Ayolo committed
512
513
514
515
516
$frm->add($sfrm,false,true, $type==2 ,2 ,false,true);

$sfrm = new form("type",null,null,null,"Information, resultat d'&eacute;lection - sans date");
$frm->add($sfrm,false,true, $type==0 ,0 ,false,true);

517
518
519
520
521
522
$title = "";
if (isset($_REQUEST["title"]))
  $title = $_REQUEST["title"];
else if ($_REQUEST["id_asso"])
{
  $asso = new asso($site->db);
mbriand's avatar
mbriand committed
523
  $asso->load_by_id($_REQUEST["id_asso"]);
524
525
526
527
528
529

  if ( $asso->id > 0 )
  $title = $asso->nom." :";
}

$frm->add_text_field("title", "Titre de la nouvelle", $title, true);
Ayolo's avatar
Ayolo committed
530
531
$frm->add_entity_select("id_asso", "Association concern&eacute;e", $site->db, "asso",$_REQUEST["id_asso"],true);
$frm->add_entity_select("id_lieu", "Lieu", $site->db, "lieu",false,true);
532
$frm->add_text_field("tags", "Tags",$_REQUEST["tags"]);
mbriand's avatar
mbriand committed
533
$frm->add_text_area ("resume","Resum&eacute;",$_REQUEST["resume"], 40, 3, true);
Feu's avatar
Feu committed
534
$frm->add_dokuwiki_toolbar('content');
Ayolo's avatar
Ayolo committed
535
536
537
538
$frm->add_text_area ("content", "Contenu",$_REQUEST["content"],80,10,true);

if ( $file->id > 0 )
{
539
  $frm->add_info("Affiche enregistr&eacute;e : ".$file->get_html_link().".");
Ayolo's avatar
Ayolo committed
540
541
542
543
544
  $frm->add_hidden("id_file",$file->id);
}
else
$frm->add_file_field("affiche_file","Affiche");

Feu's avatar
fix    
Feu committed
545
$frm->add_info("L'affiche sera automatiquement ajoutée en bas de la news.");
Ayolo's avatar
Ayolo committed
546

Antoine Tenart's avatar
GNHA    
Antoine Tenart committed
547
if( $site->user->is_in_group("moderateur_site") && $suitable )
Antoine Tenart's avatar
Antoine Tenart committed
548
  $frm->add_checkbox("automodere", "<b>Auto-modération</b>", $_REQUEST['automodere']);
Antoine Tenart's avatar
Antoine Tenart committed
549

Ayolo's avatar
Ayolo committed
550
551
552
553
554
555
556
557
558
559
560
$frm->add_submit ("preview","Pr&eacute;visualiser");

if ( $suitable )
  $frm->add_submit ("submit","Proposer la nouvelle");

$site->add_contents ($frm);

$site->add_contents (new wikihelp());

$site->end_page ();

Ayolo's avatar
Ayolo committed
561
?>