punbb/admin/ranks.php
author Dan
Sat, 05 Apr 2008 23:56:45 -0400
changeset 6 5e1f1e916419
permissions -rw-r--r--
Big upgrade to 1.3 beta. Basic things are working.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     1
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     2
/***********************************************************************
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     3
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     4
  Copyright (C) 2002-2008  PunBB.org
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     5
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     6
  This file is part of PunBB.
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     7
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     8
  PunBB is free software; you can redistribute it and/or modify it
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
     9
  under the terms of the GNU General Public License as published
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    10
  by the Free Software Foundation; either version 2 of the License,
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    11
  or (at your option) any later version.
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    12
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    13
  PunBB is distributed in the hope that it will be useful, but
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    14
  WITHOUT ANY WARRANTY; without even the implied warranty of
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    16
  GNU General Public License for more details.
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    17
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    18
  You should have received a copy of the GNU General Public License
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    19
  along with this program; if not, write to the Free Software
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    20
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    21
  MA  02111-1307  USA
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    22
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    23
************************************************************************/
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    24
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    25
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    26
// if (!defined('PUN_ROOT'))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    27
// 	define('PUN_ROOT', '../');
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    28
// require PUN_ROOT.'include/common.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    29
require PUN_ROOT.'include/common_admin.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    30
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    31
// import globals (I really hope this isn't dangerous)
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    32
foreach ( $GLOBALS as $key => $_ )
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    33
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    34
  $$key =& $GLOBALS[$key];
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    35
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    36
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    37
($hook = get_hook('ark_start')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    38
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    39
if ($session->user_level < USER_LEVEL_ADMIN)
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    40
	message($lang_common['No permission']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    41
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    42
// Load the admin.php language file
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    43
require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    44
$GLOBALS['lang_admin'] = $lang_admin;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    45
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    46
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    47
// Add a rank
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    48
if (isset($_POST['add_rank']))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    49
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    50
	$rank = trim($_POST['new_rank']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    51
	$min_posts = intval($_POST['new_min_posts']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    52
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    53
	if ($rank == '')
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    54
		message($lang_admin['Title message']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    55
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    56
	if ($min_posts < 0)
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    57
		message($lang_admin['Min posts message']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    58
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    59
	($hook = get_hook('ark_add_rank_form_submitted')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    60
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    61
	// Make sure there isn't already a rank with the same min_posts value
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    62
	$query = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    63
		'SELECT'	=> '1',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    64
		'FROM'		=> 'ranks AS r',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    65
		'WHERE'		=> 'min_posts='.$min_posts
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    66
	);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    67
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    68
	($hook = get_hook('ark_qr_check_rank_collision')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    69
	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    70
	if ($pun_db->num_rows($result))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    71
		message(sprintf($lang_admin['Min posts occupied message'], $min_posts));
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    72
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    73
	$query = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    74
		'INSERT'	=> 'rank, min_posts',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    75
		'INTO'		=> 'ranks',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    76
		'VALUES'	=> '\''.$pun_db->escape($rank).'\', '.$min_posts
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    77
	);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    78
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    79
	($hook = get_hook('ark_qr_add_rank')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    80
	$pun_db->query_build($query) or error(__FILE__, __LINE__);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    81
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    82
	// Regenerate the ranks cache
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    83
	require_once PUN_ROOT.'include/cache.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    84
	generate_ranks_cache();
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    85
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    86
	pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank added'].' '.$lang_admin['Redirect']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    87
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    88
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    89
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    90
// Update a rank
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    91
else if (isset($_POST['update']))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    92
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    93
	$id = intval(key($_POST['update']));
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    94
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    95
	$rank = trim($_POST['rank'][$id]);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    96
	$min_posts = intval($_POST['min_posts'][$id]);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    97
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    98
	if ($rank == '')
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
    99
		message($lang_admin['Title message']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   100
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   101
	if ($min_posts < 0)
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   102
		message($lang_admin['Min posts message']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   103
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   104
	($hook = get_hook('ark_update_form_submitted')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   105
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   106
	// Make sure there isn't already a rank with the same min_posts value
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   107
	$query = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   108
		'SELECT'	=> '1',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   109
		'FROM'		=> 'ranks AS r',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   110
		'WHERE'		=> 'id!='.$id.' AND min_posts='.$min_posts
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   111
	);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   112
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   113
	($hook = get_hook('ark_qr_check_rank_collision2')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   114
	$result = $pun_db->query_build($query) or error(__FILE__, __LINE__);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   115
	if ($pun_db->num_rows($result))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   116
		message(sprintf($lang_admin['Min posts occupied message'], $min_posts));
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   117
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   118
	$query = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   119
		'UPDATE'	=> 'ranks',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   120
		'SET'		=> 'rank=\''.$pun_db->escape($rank).'\', min_posts='.$min_posts,
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   121
		'WHERE'		=> 'id='.$id
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   122
	);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   123
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   124
	($hook = get_hook('ark_qr_update_rank')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   125
	$pun_db->query_build($query) or error(__FILE__, __LINE__);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   126
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   127
	// Regenerate the ranks cache
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   128
	require_once PUN_ROOT.'include/cache.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   129
	generate_ranks_cache();
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   130
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   131
	pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank updated'].' '.$lang_admin['Redirect']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   132
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   133
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   134
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   135
// Remove a rank
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   136
else if (isset($_POST['remove']))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   137
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   138
	$id = intval(key($_POST['remove']));
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   139
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   140
	($hook = get_hook('ark_remove_form_submitted')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   141
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   142
	$query = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   143
		'DELETE'	=> 'ranks',
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   144
		'WHERE'		=> 'id='.$id
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   145
	);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   146
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   147
	($hook = get_hook('ark_qr_delete_rank')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   148
	$pun_db->query_build($query) or error(__FILE__, __LINE__);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   149
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   150
	// Regenerate the ranks cache
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   151
	require_once PUN_ROOT.'include/cache.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   152
	generate_ranks_cache();
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   153
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   154
	pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank removed'].' '.$lang_admin['Redirect']);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   155
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   156
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   157
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   158
// Load the cached ranks
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   159
if (file_exists(PUN_CACHE_DIR.'cache_ranks.php'))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   160
	include PUN_CACHE_DIR.'cache_ranks.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   161
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   162
if (!defined('PUN_RANKS_LOADED'))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   163
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   164
	require_once PUN_ROOT.'include/cache.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   165
	generate_ranks_cache();
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   166
	require PUN_CACHE_DIR.'cache_ranks.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   167
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   168
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   169
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   170
// Setup the form
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   171
$pun_page['fld_count'] = $pun_page['set_count'] = 0;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   172
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   173
// Setup breadcrumbs
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   174
$pun_page['crumbs'] = array(
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   175
	array($pun_config['o_board_title'], pun_link($pun_url['index'])),
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   176
	array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])),
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   177
	$lang_admin['Ranks']
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   178
);
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   179
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   180
($hook = get_hook('ark_pre_header_load')) ? eval($hook) : null;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   181
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   182
define('PUN_PAGE_SECTION', 'users');
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   183
define('PUN_PAGE', 'admin-ranks');
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   184
require PUN_ROOT.'header.php';
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   185
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   186
?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   187
<div id="pun-main" class="main sectioned admin">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   188
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   189
<?php echo generate_admin_menu(); ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   190
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   191
	<div class="main-head">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   192
		<h1><span>{ <?php echo end($pun_page['crumbs']) ?> }</span></h1>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   193
	</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   194
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   195
	<div class="main-content frm">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   196
		<div class="frm-head">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   197
			<h2><span><?php echo $lang_admin['Add new rank'] ?></span></h2>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   198
		</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   199
		<div class="frm-info">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   200
			<p><?php printf($lang_admin['Add rank intro'], '<strong><a href="'.pun_link($pun_url['admin_options_features']).'#fs4">'.$lang_admin['Settings'].' - '.$lang_admin['Features'].'</a></strong>') ?></p>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   201
		</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   202
		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_ranks']) ?>&amp;action=foo">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   203
			<div class="hidden">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   204
				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_ranks']).'&action=foo') ?>" />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   205
			</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   206
			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   207
				<legend class="frm-legend"><strong><?php echo $lang_admin['Add rank legend'] ?></strong></legend>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   208
<?php ($hook = get_hook('ark_add_rank_pre_rank')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   209
				<div class="frm-fld text">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   210
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   211
					<span class="fld-label"><?php echo $lang_admin['Rank title'] ?></span><br />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   212
					<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="new_rank" size="24" maxlength="50" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   213
					</label>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   214
				</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   215
<?php ($hook = get_hook('ark_add_rank_pre_min_posts')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   216
				<div class="frm-fld">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   217
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   218
						<span class="fld-label"><?php echo $lang_admin['Min posts'] ?></span><br />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   219
						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="new_min_posts" size="7" maxlength="7" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   220
					</label>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   221
				</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   222
<?php ($hook = get_hook('ark_add_rank_end')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   223
			</fieldset>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   224
			<div class="frm-buttons">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   225
				<span class="submit"><input type="submit" name="add_rank" value="<?php echo $lang_admin['Add rank'] ?>" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   226
			</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   227
		</form>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   228
	</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   229
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   230
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   231
if (!empty($pun_ranks))
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   232
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   233
	// Reset fieldset counter
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   234
	$pun_page['set_count'] = 0;
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   235
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   236
?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   237
	<div class="main-content frm">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   238
		<div class="frm-head">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   239
			<h2><span><?php echo $lang_admin['Existing ranks intro'] ?></span></h2>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   240
		</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   241
		<form class="frm-form" method="post" accept-charset="utf-8" action="<?php echo pun_link($pun_url['admin_ranks']) ?>&amp;action=foo">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   242
			<div class="hidden">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   243
				<input type="hidden" name="csrf_token" value="<?php echo generate_form_token(pun_link($pun_url['admin_ranks']).'&action=foo') ?>" />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   244
			</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   245
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   246
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   247
	foreach ($pun_ranks as $rank_key => $cur_rank)
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   248
	{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   249
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   250
	?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   251
			<fieldset class="frm-set set<?php echo ++$pun_page['set_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   252
				<legend class="frm-legend"><span><?php echo $lang_admin['Rank'].' '.($rank_key + 1) ?></span></legend>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   253
<?php ($hook = get_hook('ark_edit_rank_pre_rank')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   254
				<div class="frm-fld text">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   255
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   256
						<span class="fld-label"><?php echo $lang_admin['Rank title'] ?></span><br />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   257
						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="rank[<?php echo $cur_rank['id'] ?>]" value="<?php echo htmlspecialchars($cur_rank['rank']) ?>" size="24" maxlength="50" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   258
					</label>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   259
				</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   260
<?php ($hook = get_hook('ark_edit_rank_pre_min_posts')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   261
				<div class="frm-fld text">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   262
					<label for="fld<?php echo ++$pun_page['fld_count'] ?>">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   263
						<span class="fld-label"><?php echo $lang_admin['Min posts'] ?></span><br />
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   264
						<span class="fld-input"><input type="text" id="fld<?php echo $pun_page['fld_count'] ?>" name="min_posts[<?php echo $cur_rank['id'] ?>]" value="<?php echo $cur_rank['min_posts'] ?>" size="7" maxlength="7" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   265
					</label>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   266
					<span class="submit"><input type="submit" name="update[<?php echo $cur_rank['id'] ?>]" value="<?php echo $lang_admin['Update'] ?>" /> <input type="submit" name="remove[<?php echo $cur_rank['id'] ?>]" value="<?php echo $lang_admin['Remove'] ?>" /></span>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   267
				</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   268
<?php ($hook = get_hook('ark_edit_rank_end')) ? eval($hook) : null; ?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   269
			</fieldset>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   270
	<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   271
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   272
	}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   273
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   274
?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   275
		</form>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   276
	</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   277
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   278
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   279
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   280
else
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   281
{
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   282
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   283
?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   284
	<div class="main-content frm">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   285
		<div class="frm-head">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   286
			<h2><span><?php echo $lang_admin['Existing ranks intro'] ?></span></h2>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   287
		</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   288
		<div class="frm-form">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   289
			<div class="frm-info">
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   290
				<p><?php echo $lang_admin['No ranks'] ?></p>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   291
			</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   292
		</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   293
	</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   294
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   295
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   296
}
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   297
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   298
?>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   299
</div>
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   300
<?php
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   301
5e1f1e916419 Big upgrade to 1.3 beta. Basic things are working.
Dan
parents:
diff changeset
   302
require PUN_ROOT.'footer.php';