Changeset 3 for branches/rsr.v5.1.dev/web/punbb/admin_ranks.php
- Timestamp:
- Nov 14, 2011, 11:17:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rsr.v5.1.dev/web/punbb/admin_ranks.php
r1 r3 1 1 <?php 2 /***********************************************************************3 2 4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) 5 6 This file is part of PunBB. 7 8 PunBB is free software; you can redistribute it and/or modify it 9 under the terms of the GNU General Public License as published 10 by the Free Software Foundation; either version 2 of the License, 11 or (at your option) any later version. 12 13 PunBB is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 MA 02111-1307 USA 22 23 ************************************************************************/ 24 3 /** 4 * Copyright (C) 2008-2011 FluxBB 5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB 6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher 7 */ 25 8 26 9 // Tell header.php to use the admin template 27 10 define('PUN_ADMIN_CONSOLE', 1); 28 11 29 define('PUN_ROOT', './');12 define('PUN_ROOT', dirname(__FILE__).'/'); 30 13 require PUN_ROOT.'include/common.php'; 31 14 require PUN_ROOT.'include/common_admin.php'; 32 15 33 16 34 if ($pun_user['g_id'] >PUN_ADMIN)17 if ($pun_user['g_id'] != PUN_ADMIN) 35 18 message($lang_common['No permission']); 36 19 20 // Load the admin_ranks.php language file 21 require PUN_ROOT.'lang/'.$admin_language.'/admin_ranks.php'; 37 22 38 23 // Add a rank … … 41 26 confirm_referrer('admin_ranks.php'); 42 27 43 $rank = trim($_POST['new_rank']);44 $min_posts = $_POST['new_min_posts'];28 $rank = pun_trim($_POST['new_rank']); 29 $min_posts = trim($_POST['new_min_posts']); 45 30 46 31 if ($rank == '') 47 message( 'Vous devez saisir un titre au rang.');32 message($lang_admin_ranks['Must enter title message']); 48 33 49 if ( !preg_match('#^\d+$#', $min_posts))50 message( 'Le nombre minimum de messages doit être un entier positif.');34 if ($min_posts == '' || preg_match('%[^0-9]%', $min_posts)) 35 message($lang_admin_ranks['Must be integer message']); 51 36 52 37 // Make sure there isn't already a rank with the same min_posts value 53 38 $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE min_posts='.$min_posts) or error('Unable to fetch rank info', __FILE__, __LINE__, $db->error()); 54 39 if ($db->num_rows($result)) 55 message( 'Il y a déjà un rang avec un nombre minimum de '.$min_posts.'messages.');40 message(sprintf($lang_admin_ranks['Dupe min posts message'], $min_posts)); 56 41 57 $db->query('INSERT INTO '.$db->prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($rank).'\', '.$min_posts.')') or error(' Impossible d\'ajouter le rang', __FILE__, __LINE__, $db->error());42 $db->query('INSERT INTO '.$db->prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($rank).'\', '.$min_posts.')') or error('Unable to add rank', __FILE__, __LINE__, $db->error()); 58 43 59 44 // Regenerate the ranks cache 60 require_once PUN_ROOT.'include/cache.php'; 45 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 46 require PUN_ROOT.'include/cache.php'; 47 61 48 generate_ranks_cache(); 62 49 63 redirect('admin_ranks.php', 'Rang ajouté. Redirection ...');50 redirect('admin_ranks.php', $lang_admin_ranks['Rank added redirect']); 64 51 } 65 52 … … 72 59 $id = intval(key($_POST['update'])); 73 60 74 $rank = trim($_POST['rank'][$id]);61 $rank = pun_trim($_POST['rank'][$id]); 75 62 $min_posts = trim($_POST['min_posts'][$id]); 76 63 77 64 if ($rank == '') 78 message( 'You must enter a rank title.');65 message($lang_admin_ranks['Must enter title message']); 79 66 80 if ( !preg_match('#^\d+$#', $min_posts))81 message( 'Le nombre minimum de messages doit être un entier positif.');67 if ($min_posts == '' || preg_match('%[^0-9]%', $min_posts)) 68 message($lang_admin_ranks['Must be integer message']); 82 69 83 70 // Make sure there isn't already a rank with the same min_posts value 84 $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE id!='.$id.' && min_posts='.$min_posts) or error('Impossible de retrouver les informations des rangs', __FILE__, __LINE__, $db->error());71 $result = $db->query('SELECT 1 FROM '.$db->prefix.'ranks WHERE id!='.$id.' AND min_posts='.$min_posts) or error('Unable to fetch rank info', __FILE__, __LINE__, $db->error()); 85 72 if ($db->num_rows($result)) 86 message( 'Il y a déjà un rang avec un nombre minimum de '.$min_posts.' messages.');73 message(sprintf($lang_admin_ranks['Dupe min posts message'], $min_posts)); 87 74 88 $db->query('UPDATE '.$db->prefix.'ranks SET rank=\''.$db->escape($rank).'\', min_posts='.$min_posts.' WHERE id='.$id) or error(' Impossible de modifier les rangs', __FILE__, __LINE__, $db->error());75 $db->query('UPDATE '.$db->prefix.'ranks SET rank=\''.$db->escape($rank).'\', min_posts='.$min_posts.' WHERE id='.$id) or error('Unable to update rank', __FILE__, __LINE__, $db->error()); 89 76 90 77 // Regenerate the ranks cache 91 require_once PUN_ROOT.'include/cache.php'; 78 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 79 require PUN_ROOT.'include/cache.php'; 80 92 81 generate_ranks_cache(); 93 82 94 redirect('admin_ranks.php', 'Rangs modifiés. Redirection ...');83 redirect('admin_ranks.php', $lang_admin_ranks['Rank updated redirect']); 95 84 } 96 85 … … 103 92 $id = intval(key($_POST['remove'])); 104 93 105 $db->query('DELETE FROM '.$db->prefix.'ranks WHERE id='.$id) or error(' Impossible de supprimer le rang', __FILE__, __LINE__, $db->error());94 $db->query('DELETE FROM '.$db->prefix.'ranks WHERE id='.$id) or error('Unable to delete rank', __FILE__, __LINE__, $db->error()); 106 95 107 96 // Regenerate the ranks cache 108 require_once PUN_ROOT.'include/cache.php'; 97 if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) 98 require PUN_ROOT.'include/cache.php'; 99 109 100 generate_ranks_cache(); 110 101 111 redirect('admin_ranks.php', 'Rang supprimé. Redirection ...');102 redirect('admin_ranks.php', $lang_admin_ranks['Rank removed redirect']); 112 103 } 113 104 114 115 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Rangs'; 105 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Ranks']); 116 106 $focus_element = array('ranks', 'new_rank'); 107 define('PUN_ACTIVE_PAGE', 'admin'); 117 108 require PUN_ROOT.'header.php'; 118 109 … … 121 112 ?> 122 113 <div class="blockform"> 123 <h2><span> Rangs</span></h2>114 <h2><span><?php echo $lang_admin_ranks['Ranks head'] ?></span></h2> 124 115 <div class="box"> 125 <form id="ranks" method="post" action="admin_ranks.php ?action=foo">116 <form id="ranks" method="post" action="admin_ranks.php"> 126 117 <div class="inform"> 127 118 <fieldset> 128 <legend> Ajouter un rang</legend>119 <legend><?php echo $lang_admin_ranks['Add rank subhead'] ?></legend> 129 120 <div class="infldset"> 130 <p> Saisissez un titre de rang et un nombre minimum de messages que l'utilisateur devra atteindre afin d'obtenir ce rang. Plusieurs rangs ne peuvent avoir le même nombre minimum de messages. Si un titre est donné à un utilisateur, le titre sera affiché à la place du rang. <strong>Les rangs utilisateurs doivent êtres activés à la page <a href="admin_options.php#ranks">Options</a> pour qu'ils aient un quelconque effet.</strong></p>131 <table 121 <p><?php echo $lang_admin_ranks['Add rank info'].' '.($pun_config['o_ranks'] == '1' ? sprintf($lang_admin_ranks['Ranks enabled'], '<a href="admin_options.php#ranks">'.$lang_admin_common['Options'].'</a>') : sprintf($lang_admin_ranks['Ranks disabled'], '<a href="admin_options.php#ranks">'.$lang_admin_common['Options'].'</a>')) ?></p> 122 <table cellspacing="0"> 132 123 <thead> 133 124 <tr> 134 <th class="tcl" scope="col"> Titre du rang</th>135 <th class="tc2" scope="col"> Nombre minimum de messages</th>136 <th class="hidehead" scope="col"> Action</th>125 <th class="tcl" scope="col"><?php echo $lang_admin_ranks['Rank title label'] ?></th> 126 <th class="tc2" scope="col"><?php echo $lang_admin_ranks['Minimum posts label'] ?></th> 127 <th class="hidehead" scope="col"><?php echo $lang_admin_ranks['Actions label'] ?></th> 137 128 </tr> 138 129 </thead> 139 130 <tbody> 140 131 <tr> 141 <td ><input type="text" name="new_rank" size="24" maxlength="50" tabindex="1" /></td>142 <td ><input type="text" name="new_min_posts" size="7" maxlength="7" tabindex="2" /></td>143 <td><input type="submit" name="add_rank" value=" Ajouter" tabindex="3" /></td>132 <td class="tcl"><input type="text" name="new_rank" size="24" maxlength="50" tabindex="1" /></td> 133 <td class="tc2"><input type="text" name="new_min_posts" size="7" maxlength="7" tabindex="2" /></td> 134 <td><input type="submit" name="add_rank" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="3" /></td> 144 135 </tr> 145 136 </tbody> … … 150 141 <div class="inform"> 151 142 <fieldset> 152 <legend> Modifier/supprimer les rangs</legend>143 <legend><?php echo $lang_admin_ranks['Edit remove subhead'] ?></legend> 153 144 <div class="infldset"> 154 145 <?php 155 146 156 $result = $db->query('SELECT id, rank, min_posts FROM '.$db->prefix.'ranks ORDER BY min_posts') or error(' Impossible de retrouver la liste des rangs', __FILE__, __LINE__, $db->error());147 $result = $db->query('SELECT id, rank, min_posts FROM '.$db->prefix.'ranks ORDER BY min_posts') or error('Unable to fetch rank list', __FILE__, __LINE__, $db->error()); 157 148 if ($db->num_rows($result)) 158 149 { 159 150 160 151 ?> 161 <table 152 <table cellspacing="0"> 162 153 <thead> 163 154 <tr> 164 <th class="tcl" scope="col">< strong>Titre du rang</strong></th>165 <th class="tc2" scope="col">< strong>Nombre minimum de messages</strong></th>166 <th class="hidehead" scope="col"> Actions</th>155 <th class="tcl" scope="col"><?php echo $lang_admin_ranks['Rank title label'] ?></th> 156 <th class="tc2" scope="col"><?php echo $lang_admin_ranks['Minimum posts label'] ?></th> 157 <th class="hidehead" scope="col"><?php echo $lang_admin_ranks['Actions label'] ?></th> 167 158 </tr> 168 159 </thead> … … 171 162 172 163 while ($cur_rank = $db->fetch_assoc($result)) 173 echo "\t\t\t\t\t\t\t\t".'<tr><td ><input type="text" name="rank['.$cur_rank['id'].']" value="'.pun_htmlspecialchars($cur_rank['rank']).'" size="24" maxlength="50" /></td><td><input type="text" name="min_posts['.$cur_rank['id'].']" value="'.$cur_rank['min_posts'].'" size="7" maxlength="7" /></td><td><input type="submit" name="update['.$cur_rank['id'].']" value="Modifier" /> <input type="submit" name="remove['.$cur_rank['id'].']" value="Supprimer" /></td></tr>'."\n";164 echo "\t\t\t\t\t\t\t\t".'<tr><td class="tcl"><input type="text" name="rank['.$cur_rank['id'].']" value="'.pun_htmlspecialchars($cur_rank['rank']).'" size="24" maxlength="50" /></td><td class="tc2"><input type="text" name="min_posts['.$cur_rank['id'].']" value="'.$cur_rank['min_posts'].'" size="7" maxlength="7" /></td><td><input type="submit" name="update['.$cur_rank['id'].']" value="'.$lang_admin_common['Update'].'" /> <input type="submit" name="remove['.$cur_rank['id'].']" value="'.$lang_admin_common['Remove'].'" /></td></tr>'."\n"; 174 165 175 166 ?> … … 180 171 } 181 172 else 182 echo "\t\t\t\t\t\t\t".'<p> Aucun rang dans la liste.</p>'."\n";173 echo "\t\t\t\t\t\t\t".'<p>'.$lang_admin_ranks['No ranks in list'].'</p>'."\n"; 183 174 184 175 ?>
Note: See TracChangeset
for help on using the changeset viewer.