Index: trunk/web/punbb/admin_categories.php
===================================================================
--- trunk/web/punbb/admin_categories.php	(revision 10)
+++ trunk/web/punbb/admin_categories.php	(revision 1)
@@ -1,23 +1,38 @@
 <?php
-
-/**
- * Copyright (C) 2008-2011 FluxBB
- * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
- */
+/***********************************************************************
+
+  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
+
+  This file is part of PunBB.
+
+  PunBB is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PunBB 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
+
+************************************************************************/
+
 
 // Tell header.php to use the admin template
 define('PUN_ADMIN_CONSOLE', 1);
 
-define('PUN_ROOT', dirname(__FILE__).'/');
+define('PUN_ROOT', './');
 require PUN_ROOT.'include/common.php';
 require PUN_ROOT.'include/common_admin.php';
 
 
-if ($pun_user['g_id'] != PUN_ADMIN)
+if ($pun_user['g_id'] > PUN_ADMIN)
 	message($lang_common['No permission']);
 
-// Load the admin_categories.php language file
-require PUN_ROOT.'lang/'.$admin_language.'/admin_categories.php';
 
 // Add a new category
@@ -26,12 +41,13 @@
 	confirm_referrer('admin_categories.php');
 
-	$new_cat_name = pun_trim($_POST['new_cat_name']);
+	$new_cat_name = trim($_POST['new_cat_name']);
 	if ($new_cat_name == '')
-		message($lang_admin_categories['Must enter name message']);
-
-	$db->query('INSERT INTO '.$db->prefix.'categories (cat_name) VALUES(\''.$db->escape($new_cat_name).'\')') or error('Unable to create category', __FILE__, __LINE__, $db->error());
-
-	redirect('admin_categories.php', $lang_admin_categories['Category added redirect']);
+		message('Vous devez saisir un nom pour la nouvelle catÃ©gorie.');
+
+	$db->query('INSERT INTO '.$db->prefix.'categories (cat_name) VALUES(\''.$db->escape($new_cat_name).'\')') or error('Impossible de crÃ©er la catÃ©gorie', __FILE__, __LINE__, $db->error());
+
+	redirect('admin_categories.php', 'CatÃ©gorie ajoutÃ©e. Redirection ...');
 }
+
 
 // Delete a category
@@ -44,9 +60,9 @@
 		message($lang_common['Bad request']);
 
-	if (isset($_POST['del_cat_comply'])) // Delete a category with all forums and posts
+	if (isset($_POST['del_cat_comply']))	// Delete a category with all forums and posts
 	{
 		@set_time_limit(0);
 
-		$result = $db->query('SELECT id FROM '.$db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
+		$result = $db->query('SELECT id FROM '.$db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Impossible de retrouver la liste des forums', __FILE__, __LINE__, $db->error());
 		$num_forums = $db->num_rows($result);
 
@@ -59,9 +75,9 @@
 
 			// Delete the forum
-			$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
+			$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$cur_forum) or error('Impossible de supprimer le forum', __FILE__, __LINE__, $db->error());
 		}
 
 		// Locate any "orphaned redirect topics" and delete them
-		$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
+		$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Impossible de retrouver les sujets de redirection', __FILE__, __LINE__, $db->error());
 		$num_orphans = $db->num_rows($result);
 
@@ -71,25 +87,22 @@
 				$orphans[] = $db->result($result, $i);
 
-			$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
+			$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Impossible de supprimer les sujets de redirection', __FILE__, __LINE__, $db->error());
 		}
 
 		// Delete the category
-		$db->query('DELETE FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $db->error());
-
-		// Regenerate the quick jump cache
-		if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
-			require PUN_ROOT.'include/cache.php';
-
+		$db->query('DELETE FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Impossible de supprimer la catÃ©gorie', __FILE__, __LINE__, $db->error());
+
+		// Regenerate the quickjump cache
+		require_once PUN_ROOT.'include/cache.php';
 		generate_quickjump_cache();
 
-		redirect('admin_categories.php', $lang_admin_categories['Category deleted redirect']);
-	}
-	else // If the user hasn't comfirmed the delete
-	{
-		$result = $db->query('SELECT cat_name FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to fetch category info', __FILE__, __LINE__, $db->error());
+		redirect('admin_categories.php', 'CatÃ©gorie supprimÃ©e. Redirection ...');
+	}
+	else	// If the user hasn't comfirmed the delete
+	{
+		$result = $db->query('SELECT cat_name FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Impossible de retrouver les informations de la catÃ©gorie', __FILE__, __LINE__, $db->error());
 		$cat_name = $db->result($result);
 
-		$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']);
-		define('PUN_ACTIVE_PAGE', 'admin');
+		$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / CatÃ©gories';
 		require PUN_ROOT.'header.php';
 
@@ -98,5 +111,5 @@
 ?>
 	<div class="blockform">
-		<h2><span><?php echo $lang_admin_categories['Delete category head'] ?></span></h2>
+		<h2><span>Supprimer une catÃ©gorie</span></h2>
 		<div class="box">
 			<form method="post" action="admin_categories.php">
@@ -104,12 +117,12 @@
 				<input type="hidden" name="cat_to_delete" value="<?php echo $cat_to_delete ?>" />
 					<fieldset>
-						<legend><?php echo $lang_admin_categories['Confirm delete subhead'] ?></legend>
+						<legend>Confirmez la supression de la catÃ©gorie</legend>
 						<div class="infldset">
-							<p><?php printf($lang_admin_categories['Confirm delete info'], pun_htmlspecialchars($cat_name)) ?></p>
-							<p class="warntext"><?php echo $lang_admin_categories['Delete category warn'] ?></p>
+							<p>Ãtes vous sÃ»r de vouloir supprimer la catÃ©gorie "<?php echo $cat_name ?>"&#160;?</p>
+							<p>ATTENTION ! Supprimer cette catÃ©gorie supprimera en mÃªme temps tous les forums et messages (s'il y en a) prÃ©sents dans cette catÃ©gorie&#160;!</p>
 						</div>
 					</fieldset>
 				</div>
-				<p class="buttons"><input type="submit" name="del_cat_comply" value="<?php echo $lang_admin_common['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p>
+				<p><input type="submit" name="del_cat_comply" value=" Supprimer " /><a href="javascript:history.go(-1)">Retour</a></p>
 			</form>
 		</div>
@@ -123,44 +136,45 @@
 }
 
-else if (isset($_POST['update'])) // Change position and name of the categories
+
+else if (isset($_POST['update']))	// Change position and name of the categories
 {
 	confirm_referrer('admin_categories.php');
 
-	$categories = $_POST['cat'];
-	if (empty($categories))
-		message($lang_common['Bad request']);
-
-	foreach ($categories as $cat_id => $cur_cat)
-	{
-		$cur_cat['name'] = pun_trim($cur_cat['name']);
-		$cur_cat['order'] = trim($cur_cat['order']);
-
-		if ($cur_cat['name'] == '')
-			message($lang_admin_categories['Must enter name message']);
-
-		if ($cur_cat['order'] == '' || preg_match('%[^0-9]%', $cur_cat['order']))
-			message($lang_admin_categories['Must enter integer message']);
-
-		$db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cur_cat['name']).'\', disp_position='.$cur_cat['order'].' WHERE id='.intval($cat_id)) or error('Unable to update category', __FILE__, __LINE__, $db->error());
-	}
-
-	// Regenerate the quick jump cache
-	if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
-		require PUN_ROOT.'include/cache.php';
-
+	$cat_order = $_POST['cat_order'];
+	$cat_name = $_POST['cat_name'];
+
+	$result = $db->query('SELECT id, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Impossible de retrouver la liste des catÃ©gories', __FILE__, __LINE__, $db->error());
+	$num_cats = $db->num_rows($result);
+
+	for ($i = 0; $i < $num_cats; ++$i)
+	{
+		if ($cat_name[$i] == '')
+			message('Vous devez saisir un nom de catÃ©gorie.');
+
+		if (!preg_match('#^\d+$#', $cat_order[$i]))
+			message('La position doit Ãªtre un nombre entier.');
+
+		list($cat_id, $position) = $db->fetch_row($result);
+
+		$db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cat_name[$i]).'\', disp_position='.$cat_order[$i].' WHERE id='.$cat_id) or error('Impossible de modifier les catÃ©gories', __FILE__, __LINE__, $db->error());
+	}
+
+	// Regenerate the quickjump cache
+	require_once PUN_ROOT.'include/cache.php';
 	generate_quickjump_cache();
 
-	redirect('admin_categories.php', $lang_admin_categories['Categories updated redirect']);
+	redirect('admin_categories.php', 'CatÃ©gories modifiÃ©es. Redirection ...');
 }
 
+
 // Generate an array with all categories
-$result = $db->query('SELECT id, cat_name, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
+$result = $db->query('SELECT id, cat_name, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Impossible de retrouver la liste des catÃ©gories', __FILE__, __LINE__, $db->error());
 $num_cats = $db->num_rows($result);
 
 for ($i = 0; $i < $num_cats; ++$i)
-	$cat_list[] = $db->fetch_assoc($result);
-
-$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']);
-define('PUN_ACTIVE_PAGE', 'admin');
+	$cat_list[] = $db->fetch_row($result);
+
+
+$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / CatÃ©gories';
 require PUN_ROOT.'header.php';
 
@@ -169,95 +183,73 @@
 ?>
 	<div class="blockform">
-		<h2><span><?php echo $lang_admin_categories['Add categories head'] ?></span></h2>
+		<h2><span>Ajouter/supprimer/modifier les catÃ©gories</span></h2>
 		<div class="box">
-			<form method="post" action="admin_categories.php">
-				<div class="inform">
-					<fieldset>
-						<legend><?php echo $lang_admin_categories['Add categories subhead'] ?></legend>
-						<div class="infldset">
-							<table class="aligntop" cellspacing="0">
-								<tr>
-									<th scope="row"><?php echo $lang_admin_categories['Add category label'] ?><div><input type="submit" name="add_cat" value="<?php echo $lang_admin_categories['Add new submit'] ?>" tabindex="2" /></div></th>
-									<td>
-										<input type="text" name="new_cat_name" size="35" maxlength="80" tabindex="1" />
-										<span><?php printf($lang_admin_categories['Add category help'], '<a href="admin_forums.php">'.$lang_admin_common['Forums'].'</a>') ?></span>
-									</td>
-								</tr>
-							</table>
-						</div>
-					</fieldset>
-				</div>
-			</form>
+		<form method="post" action="admin_categories.php?action=foo">
+			<div class="inform">
+				<fieldset>
+					<legend>Ajouter/supprimer une catÃ©gorie</legend>
+					<div class="infldset">
+						<table class="aligntop" cellspacing="0">
+							<tr>
+								<th scope="row">Ajouter une catÃ©gorie<div><input type="submit" name="add_cat" value=" Ajouter " tabindex="2" /></div></th>
+								<td>
+									<input type="text" name="new_cat_name" size="35" maxlength="80" tabindex="1" />
+									<span>Saisissez le nom de la catÃ©gorie que vous souhaitez ajouter. Vous pourrez modifier ce nom plus tard (voir ci-dessous). Pour ajouter des forums Ã  une nouvelle catÃ©gorie, allez Ã  la page de gestion des <a href="admin_forums.php">Forums</a>.</span>
+								</td>
+							</tr>
+<?php if ($num_cats): ?>							<tr>
+								<th scope="row">Supprimer une catÃ©gorie<div><input type="submit" name="del_cat" value=" Supprimer " tabindex="4" /></div></th>
+								<td>
+									<select name="cat_to_delete" tabindex="3">
+<?php
+
+	while (list(, list($cat_id, $cat_name, ,)) = @each($cat_list))
+		echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cat_id.'">'.pun_htmlspecialchars($cat_name).'</option>'."\n";
+
+?>
+									</select>
+									<span>Choisissez le nom de la catÃ©gorie que vous souhaitez supprimer. Vous serez invitÃ©s Ã  confirmer votre choix de catÃ©gorie Ã  supprimer avant qu'elle ne soit effectivement supprimÃ©e.</span>
+								</td>
+							</tr>
+<?php endif; ?>						</table>
+					</div>
+				</fieldset>
+			</div>
+<?php if ($num_cats): ?>			<div class="inform">
+				<fieldset>
+					<legend>Modifier les catÃ©gories</legend>
+					<div class="infldset">
+						<table id="categoryedit" cellspacing="0" >
+						<thead>
+							<tr>
+								<th class="tcl" scope="col">Nom</th>
+								<th scope="col">Position</th>
+								<th>&#160;</th>
+							</tr>
+						</thead>
+						<tbody>
+<?php
+
+	@reset($cat_list);
+	for ($i = 0; $i < $num_cats; ++$i)
+	{
+		list(, list($cat_id, $cat_name, $position)) = @each($cat_list);
+
+?>
+							<tr><td><input type="text" name="cat_name[<?php echo $i ?>]" value="<?php echo pun_htmlspecialchars($cat_name) ?>" size="35" maxlength="80" /></td><td><input type="text" name="cat_order[<?php echo $i ?>]" value="<?php echo $position ?>" size="3" maxlength="3" /></td><td>&#160;</td></tr>
+<?php
+
+	}
+
+?>
+						</tbody>
+						</table>
+						<div class="fsetsubmit"><input type="submit" name="update" value=" Modifier " /></div>
+					</div>
+				</fieldset>
+			</div>
+<?php endif; ?>		</form>
 		</div>
-
-<?php if ($num_cats): ?>		<h2 class="block2"><span><?php echo $lang_admin_categories['Delete categories head'] ?></span></h2>
-		<div class="box">
-			<form method="post" action="admin_categories.php">
-				<div class="inform">
-					<fieldset>
-						<legend><?php echo $lang_admin_categories['Delete categories subhead'] ?></legend>
-						<div class="infldset">
-							<table class="aligntop" cellspacing="0">
-								<tr>
-									<th scope="row"><?php echo $lang_admin_categories['Delete category label'] ?><div><input type="submit" name="del_cat" value="<?php echo $lang_admin_common['Delete'] ?>" tabindex="4" /></div></th>
-									<td>
-										<select name="cat_to_delete" tabindex="3">
-<?php
-
-	foreach ($cat_list as $cur_cat)
-		echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
-
-?>
-										</select>
-										<span><?php echo $lang_admin_categories['Delete category help'] ?></span>
-									</td>
-								</tr>
-							</table>
-						</div>
-					</fieldset>
-				</div>
-			</form>
-		</div>
-<?php endif; ?>
-
-<?php if ($num_cats): ?>		<h2 class="block2"><span><?php echo $lang_admin_categories['Edit categories head'] ?></span></h2>
-		<div class="box">
-			<form method="post" action="admin_categories.php">
-				<div class="inform">
-					<fieldset>
-						<legend><?php echo $lang_admin_categories['Edit categories subhead'] ?></legend>
-						<div class="infldset">
-							<table id="categoryedit" cellspacing="0" >
-							<thead>
-								<tr>
-									<th class="tcl" scope="col"><?php echo $lang_admin_categories['Category name label'] ?></th>
-									<th scope="col"><?php echo $lang_admin_categories['Category position label'] ?></th>
-								</tr>
-							</thead>
-							<tbody>
-<?php
-
-	foreach ($cat_list as $cur_cat)
-	{
-
-?>
-								<tr>
-									<td class="tcl"><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][name]" value="<?php echo pun_htmlspecialchars($cur_cat['cat_name']) ?>" size="35" maxlength="80" /></td>
-									<td><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][order]" value="<?php echo $cur_cat['disp_position'] ?>" size="3" maxlength="3" /></td>
-								</tr>
-<?php
-
-	}
-
-?>
-							</tbody>
-							</table>
-							<div class="fsetsubmit"><input type="submit" name="update" value="<?php echo $lang_admin_common['Update'] ?>" /></div>
-						</div>
-					</fieldset>
-				</div>
-			</form>
-		</div>
-<?php endif; ?>	</div>
+	</div>
 	<div class="clearer"></div>
 </div>
