diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin/ranks.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/admin/ranks.php Sat Apr 05 23:56:45 2008 -0400 @@ -0,0 +1,302 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('ark_start')) ? eval($hook) : null; + +if ($session->user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + +// Load the admin.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php'; +$GLOBALS['lang_admin'] = $lang_admin; + + +// Add a rank +if (isset($_POST['add_rank'])) +{ + $rank = trim($_POST['new_rank']); + $min_posts = intval($_POST['new_min_posts']); + + if ($rank == '') + message($lang_admin['Title message']); + + if ($min_posts < 0) + message($lang_admin['Min posts message']); + + ($hook = get_hook('ark_add_rank_form_submitted')) ? eval($hook) : null; + + // Make sure there isn't already a rank with the same min_posts value + $query = array( + 'SELECT' => '1', + 'FROM' => 'ranks AS r', + 'WHERE' => 'min_posts='.$min_posts + ); + + ($hook = get_hook('ark_qr_check_rank_collision')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($pun_db->num_rows($result)) + message(sprintf($lang_admin['Min posts occupied message'], $min_posts)); + + $query = array( + 'INSERT' => 'rank, min_posts', + 'INTO' => 'ranks', + 'VALUES' => '\''.$pun_db->escape($rank).'\', '.$min_posts + ); + + ($hook = get_hook('ark_qr_add_rank')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + // Regenerate the ranks cache + require_once PUN_ROOT.'include/cache.php'; + generate_ranks_cache(); + + pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank added'].' '.$lang_admin['Redirect']); +} + + +// Update a rank +else if (isset($_POST['update'])) +{ + $id = intval(key($_POST['update'])); + + $rank = trim($_POST['rank'][$id]); + $min_posts = intval($_POST['min_posts'][$id]); + + if ($rank == '') + message($lang_admin['Title message']); + + if ($min_posts < 0) + message($lang_admin['Min posts message']); + + ($hook = get_hook('ark_update_form_submitted')) ? eval($hook) : null; + + // Make sure there isn't already a rank with the same min_posts value + $query = array( + 'SELECT' => '1', + 'FROM' => 'ranks AS r', + 'WHERE' => 'id!='.$id.' AND min_posts='.$min_posts + ); + + ($hook = get_hook('ark_qr_check_rank_collision2')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + if ($pun_db->num_rows($result)) + message(sprintf($lang_admin['Min posts occupied message'], $min_posts)); + + $query = array( + 'UPDATE' => 'ranks', + 'SET' => 'rank=\''.$pun_db->escape($rank).'\', min_posts='.$min_posts, + 'WHERE' => 'id='.$id + ); + + ($hook = get_hook('ark_qr_update_rank')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + // Regenerate the ranks cache + require_once PUN_ROOT.'include/cache.php'; + generate_ranks_cache(); + + pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank updated'].' '.$lang_admin['Redirect']); +} + + +// Remove a rank +else if (isset($_POST['remove'])) +{ + $id = intval(key($_POST['remove'])); + + ($hook = get_hook('ark_remove_form_submitted')) ? eval($hook) : null; + + $query = array( + 'DELETE' => 'ranks', + 'WHERE' => 'id='.$id + ); + + ($hook = get_hook('ark_qr_delete_rank')) ? eval($hook) : null; + $pun_db->query_build($query) or error(__FILE__, __LINE__); + + // Regenerate the ranks cache + require_once PUN_ROOT.'include/cache.php'; + generate_ranks_cache(); + + pun_redirect(pun_link($pun_url['admin_ranks']), $lang_admin['Rank removed'].' '.$lang_admin['Redirect']); +} + + +// Load the cached ranks +if (file_exists(PUN_CACHE_DIR.'cache_ranks.php')) + include PUN_CACHE_DIR.'cache_ranks.php'; + +if (!defined('PUN_RANKS_LOADED')) +{ + require_once PUN_ROOT.'include/cache.php'; + generate_ranks_cache(); + require PUN_CACHE_DIR.'cache_ranks.php'; +} + + +// Setup the form +$pun_page['fld_count'] = $pun_page['set_count'] = 0; + +// Setup breadcrumbs +$pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + $lang_admin['Ranks'] +); + +($hook = get_hook('ark_pre_header_load')) ? eval($hook) : null; + +define('PUN_PAGE_SECTION', 'users'); +define('PUN_PAGE', 'admin-ranks'); +require PUN_ROOT.'header.php'; + +?> +
+ + + +
+

{ }

+
+ +
+
+

+
+ +
+ +
+ + +
+ +
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+

+
+
+ + $cur_rank) + { + + ?> +
+ + +
+ +
+ +
+ + +
+ +
+ +
+
+ +
+
+

+
+
+
+

+
+
+
+ +
+