Skip to content
admin_news.php 8.33 KiB
Newer Older
Seblu's avatar
Seblu committed
<?php

function dispAdminNews () {

$MAX_ADMIN_NEWS = 1000;


if ($_SESSION["user_right"] < $GLOBALS["EPTV"] )
{
	return("T'es ouf");
}

$str = '
	<table width="80%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td bgcolor="#000000">
		<table width="100%" border="0" cellspacing="1" cellpadding="2">

			<tr>
			<td>
				<b>
				<font color="#ffffff">
				&nbsp a l l &nbsp n e w s
				</font>
Seblu's avatar
Seblu committed
				</b>
Seblu's avatar
Seblu committed
			</td>
			</tr>
Seblu's avatar
Seblu committed

			<FORM name="new_news" method="post" action="index.php?html=AdminHome&section_admin=AdminAddNews">
Seblu's avatar
Seblu committed
   			<TR>
  			<TD><INPUT class="button" TYPE="submit" NAME="action" VALUE="  NOUVELLE NEWS  "><BR> </TD>
			</TR>
 			</FORM>
Seblu's avatar
Seblu committed
			<tr>
Seblu's avatar
Seblu committed
			<td bgcolor="#303030">
Seblu's avatar
Seblu committed
			<table cellpadding="0" cellspacing="0" width="100%">
				<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="4">


				';
$str .=dispAdminAllNews($MAX_ADMIN_NEWS);

$str .= '
				</TR>
				</table>
				</td>
				</tr>
			</table>
			</td>
			</tr>
		</table>
		</td>
		</tr>
	</table>
Seblu's avatar
Seblu committed
	';

return $str;
}


function dispAdminAllNews($MAX_NEWS){

	$str = '';

Seblu's avatar
Seblu committed
	if ($_SESSION["user_right"] >= $GLOBALS["PRIV_GUEST"] ) {
Seblu's avatar
Seblu committed
		$result = getLastNews(2);
	}
Seblu's avatar
Seblu committed
	else if ($_SESSION["user_right"] >= $GLOBALS["GUEST"] ) {
		$result = getLastNews(1);
Seblu's avatar
Seblu committed
	}
	else {
Seblu's avatar
Seblu committed
		$result = getLastNews(0);
Seblu's avatar
Seblu committed
	}
Seblu's avatar
Seblu committed
	if (mysql_num_rows($result)){
		for ($cpt = 0; $cpt < $MAX_NEWS && $cpt < mysql_numrows($result); $cpt++) {
			$news = mysql_fetch_array($result);
Seblu's avatar
Seblu committed
			$news_id = $news["news_id"];
// DISP NEWS TITLE BY TENDU

			$str .= dispAdminWhenTendu($news["news_tendu"]);
Seblu's avatar
Seblu committed
			$str .= '
				<b>
				'.$news["news_title"].'
				</b>
				</TD>

				</TR>';

Seblu's avatar
Seblu committed
// DISP NEWS CONTENT BY TENDU
Seblu's avatar
Seblu committed
			$str .= dispAdminWhenTendu($news["news_tendu"]);


			$str .= '

				<font class="texte_date">
				<small> &nbsp;
				'.$news["news_date"].'
				<br> </font>
				</small>
				<font class="texte_normal">
				<small>
				'.$news["news_comment"].'
Seblu's avatar
Seblu committed
				</font>
Seblu's avatar
Seblu committed
				</small>
				<br>';


			$result_member = getOneUserByID($news["news_user_id"]);
			$member = mysql_fetch_array($result_member);

Seblu's avatar
Seblu committed
			$str .= '<br>Post&eacute; par:
Seblu's avatar
Seblu committed
				'.$member["user_pseudo"].'
				</td>';

			if ($news["news_user_id"] == $_SESSION["user_id"] || $_SESSION["user_right"] == $GLOBALS["ROOT"]){
				$str .= '
Seblu's avatar
Seblu committed
					<TD width="20%" align="right">
 					 	<FORM name="update_news" method="post" action="index.php?html=AdminHome&section_admin=AdminModifNews&news_id='.$news_id.'">
 					 	<INPUT class="button" TYPE="submit" NAME="action" VALUE="  MODIFIER  ">
Seblu's avatar
Seblu committed
  						</FORM>

Seblu's avatar
Seblu committed
 						<FORM name="supp_news" method="post" action="index.php?html=AdminHome&section_admin=AdminDelNews&news_id='.$news_id.'">
Seblu's avatar
Seblu committed
 						<INPUT class="button" TYPE="submit" NAME="action" VALUE="  SUPPRIMER  ">
						</FORM>
					</TD>
				';
			}

			$str .= '

			</TR>




 			<TR><TD>
  			 <hr width="90%">
			</TD></TR>


		';
		}
	}

	return ($str);
}





function	dispAdminAddNews() {


 $date = get_date();

Seblu's avatar
Seblu committed
 $str = '
Seblu's avatar
Seblu committed
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp a d d &nbsp n e w s &nbsp t o &nbsp d a t a b a s e
			</font>
Seblu's avatar
Seblu committed
			</b>
Seblu's avatar
Seblu committed
		</td>
Seblu's avatar
Seblu committed
		</tr>
Seblu's avatar
Seblu committed
	<tr>
Seblu's avatar
Seblu committed
	<td bgcolor="#303030">
Seblu's avatar
Seblu committed
	<table cellpadding="0" cellspacing="0" width="100%">
Seblu's avatar
Seblu committed
		<tr>
		    <form name="saisie" method="post" action="index.php?html=AdminHome&section_admin=AddNews&news_id='.$news_id.'">
Seblu's avatar
Seblu committed
		    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
Seblu's avatar
Seblu committed
			    <TR><TD> Titre de la News: </TD>
			    <TD> <INPUT TYPE="text" NAME="news_get_title" VALUE="" SIZE="50" MAXLENGTH="52"> </TD>
			    </TR>
Seblu's avatar
Seblu committed
			    <TR><TD> Date : </TD>
			    <TD> <INPUT TYPE="text" NAME="news_get_date" VALUE="'.$date.'" SIZE="8" MAXLENGTH="10"> </TD>
			    </TR>

			    <TR><TD>Commentaire: </TD>
			    <TD>
			    <TEXTAREA rows="3" cols="38" name="news_get_comment" ONFOCUS=""></textarea>
			    </TD>
			    </TR>
Seblu's avatar
Seblu committed
			    <TR><TD>Groupe News</TD>
			    <TD>
			    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
				<TR> <TD>
				    <select name="news_tendu">
				    <option value=0>Public</option>
				    <option value=1>Tendu</option>
				    <option value=2>Priv&eacute;e</option>
				</TD></TR>
			    </TABLE>
			    </TD>
			    </TR>

			    <TR>
				    <TD> </TD>
				    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPLOADER  "> </TD>
			    </TR>
			    <TR>
			 	   <TD> </TD>
				   <TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
			    </TR>
		    </TABLE>
		    </FORM>
		</TR>
	</TABLE>
	</TD>
	</TR>
</TABLE>
';

return ($str);
}


function	dispAdminModifNews() {


Seblu's avatar
Seblu committed
 $news_id =$_GET['news_id'];

 $result = getOneNews($news_id);


Seblu's avatar
Seblu committed
$str = '
Seblu's avatar
Seblu committed
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp m o d i f y &nbsp n e w s
			</font>
Seblu's avatar
Seblu committed
			</b>
Seblu's avatar
Seblu committed
		</td>
Seblu's avatar
Seblu committed
		</tr>
Seblu's avatar
Seblu committed
	<tr>
Seblu's avatar
Seblu committed
	<td bgcolor="#303030">
Seblu's avatar
Seblu committed
	<table cellpadding="0" cellspacing="0" width="100%">
Seblu's avatar
Seblu committed
		<tr>
Seblu's avatar
Seblu committed
	';

  if (mysql_num_rows($result)){
Seblu's avatar
Seblu committed
    $news = mysql_fetch_array($result);
Seblu's avatar
Seblu committed
  }

  $str .= '
Seblu's avatar
Seblu committed
    <form name="saisie" method="post" action="index.php?html=AdminHome&section_admin=ModifNews&news_id='.$news_id.'">
Seblu's avatar
Seblu committed
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
Seblu's avatar
Seblu committed
 		   <TR><TD> News Title: </TD>
		    <TD> <INPUT TYPE="text" NAME="news_get_uptitle" VALUE="'.$news["news_title"].'" SIZE="50" MAXLENGTH="52"> </TD>
		    </TR>
Seblu's avatar
Seblu committed
		    <TR><TD> Date: </TD>
		    <TD> <INPUT TYPE="text" NAME="news_get_date" VALUE="'.$news["news_date"].'" SIZE="8" MAXLENGTH="10"> </TD>
		    </TR>

		    <TR><TD>Commentaire: </TD>
		    <TD>
		    <TEXTAREA rows="3" cols="38" name="news_get_comment" ONFOCUS="">'.$news["news_comment"].'</textarea>
		    </TD>
		    </TR>
Seblu's avatar
Seblu committed
		    <TR><TD>Groupe News</TD>
		    <TD>
		    <TABLE CELLSPACING"0" CELLPADDING="1" BORDER="0">
		    <TR> <TD>
		    <select name="news">
		    <option value="0">Public</option>
		    <option value="1">Tendu</option>
		    <option value="2">Priv&eacute;e</option>
		    </TD></TR>

		    </TABLE>
		    </TD>
		    </TR>';

			$result_member = getOneUserByID($news["news_user_id"]);
			$member = mysql_fetch_array($result_member);

			$str .= '<TR>
Seblu's avatar
Seblu committed
					<TD>Post&eacute;e par:</TD>
Seblu's avatar
Seblu committed
					<TD>'.$member["user_pseudo"].'</TD>
				</TR>

	    <TR>
	    <TD> </TD>
	    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  UPDATE  "> </TD>
	    </TR>
	    <TR>
	    <TD> </TD>
	    <TD> <INPUT class="button" TYPE="reset" NAME="action" VALUE=" RESET "> </TD>
	    </TR>
Seblu's avatar
Seblu committed
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>
Seblu's avatar
Seblu committed
';


return ($str);
}


function	dispAdminDelNews() {

$news_id =$_GET['news_id'];

$result = getOneNews($news_id);

Seblu's avatar
Seblu committed
$str = '
Seblu's avatar
Seblu committed
<table width="80%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td bgcolor="#000000">
	<table width="100%" border="0" cellspacing="1" cellpadding="2">
		<tr>
		<td>
			<b>
			<font color="#ffffff">
			&nbsp d e l e t e &nbsp n e w s
			</font>
Seblu's avatar
Seblu committed
			</b>
Seblu's avatar
Seblu committed
		</td>
Seblu's avatar
Seblu committed
		</tr>
Seblu's avatar
Seblu committed
	<tr>
Seblu's avatar
Seblu committed
	<td bgcolor="#303030">
Seblu's avatar
Seblu committed
	<table cellpadding="0" cellspacing="0" width="100%">
Seblu's avatar
Seblu committed
		<tr>
Seblu's avatar
Seblu committed
	';

	  if (mysql_num_rows($result)){
Seblu's avatar
Seblu committed
	    $news = mysql_fetch_array($result);
Seblu's avatar
Seblu committed
	  }

	  $str .= '
Seblu's avatar
Seblu committed
	    <form name="saisie" method="post" action="index.php?html=AdminHome&section_admin=DelNews&news_id='.$news_id.'">
Seblu's avatar
Seblu committed
	    <TABLE CELLSPACING="0" CELLPADDING="10" BORDER="0">
Seblu's avatar
Seblu committed
		    <TR><TD> Titre de la News: </TD>
		    <TD>'.$news["news_title"].'</TD>
		    </TR>
Seblu's avatar
Seblu committed
		    <TR><TD> Date: </TD>
		    <TD> '.$news["news_date"].'   '.$news["news_time"] .' </TD>
		    </TR>

		    <TR><TD>Commentaire: </TD>
		    <TD>
		    '.$news["news_comment"].'
		    </TD>
		    </TR>
Seblu's avatar
Seblu committed
		    <TR><TD>Groupe News: </TD>
		    <TD>';

		  if ($news["news_tendu"] == 0){
		    $str .= 'Public</TD></TR>';
		  }
		  else if ($news["news_tendu"] == 1){
		    $str .= 'Tendu</TD></TR>';
		  }
		  else if ($news["news_tendu"] == 2){
		    $str .= 'Priv&eacute;e</TD></TR>';
		  }


		$result_member = getOneUserByID($news["news_user_id"]);
		$member = mysql_fetch_array($result_member);

		$str .= '<TR>
Seblu's avatar
Seblu committed
				<TD>Post&eacute; par:</TD>
Seblu's avatar
Seblu committed
				<TD>'.$member["user_pseudo"].'</TD>
			</TR>

		    <TR>
		    <TD> </TD>
		    <TD> <INPUT class="button" TYPE="submit" NAME="action" VALUE="  SUPPRIMER  "> </TD>
Seblu's avatar
Seblu committed
		    </TR>
Seblu's avatar
Seblu committed
    	</TABLE>
	</FORM>
	</TR>
   </TABLE>
   </TD>
   </TR>
</TABLE>
';

return ($str);
}


?>