Thread: vB Staff Titles
View Single Post
  #143  
Old 02-08-2006, 02:45 PM
Wild-Wing Wild-Wing is offline
 
Join Date: Dec 2005
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ill release the code here
admin cp code
Code:
<?php

/*======================================================================*\
|| #################################################################### ||
|| # Staff Titles Hack Version 1.0.0                                      # ||
|| # ---------------------------------------------------------------- # ||
|| #                           # ||
|| # PHP Code by:  Wild-Wing                                # ||
|| #   ||
|| #                        # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'staff_titles_admin');
define('STAFFTITLE_VERSION', '1.0.0');

// #################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array('');

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');

// ############################# LOG ACTION ###############################
//log_admin_action();
log_admin_action(($_REQUEST['usergroupid'] != 0 ? "usergroupid = ".$_REQUEST['usergroupid'] : ''));

print_cp_header("Staff Title  ".STAFFTITLE_VERSION." Admin");

if (!isset($_REQUEST['do']) || empty($_REQUEST['do'])) {
	$_REQUEST['do'] = "dotitles";
}

// ##################### LIST ALL STAFF TITLES ########################
if ($_REQUEST['do'] == "dotitles") {
	
	
	print_form_header('staff_titles_admin', 'nowhere');
	print_table_header("Staff Titles Admin");
	print_description_row("You can change usergroup staff titles here.");
	$grouptitle = $db->query_read("SELECT usergroupid, title, staffrank AS stafftitle, staffrank_opentag AS opentag, staffrank_closetag AS closetag FROM ".TABLE_PREFIX."usergroup order by usergroupid asc");
	while ($groupstitle = $db->fetch_array($grouptitle)) {
		print_form_header('staff_titles_admin', 'set_update');
		construct_hidden_code('usergroupid', $groupstitle['usergroupid']);
		construct_hidden_code('usergroup', $groupstitle['title']);
		print_table_header($groupstitle['title']." ID: ". $groupstitle['usergroupid']);
	//	print_yes_no_row($vbphrase['enable_staff_title'], 'groupstitle[isstaffrank]', $groupstitle['isstaffrank']);
		print_input_row($vbphrase['staff_title'], 'staffrank', $groupstitle['stafftitle']);
		print_label_row($vbphrase['staff_title_markup'],
        '<span style="white-space:nowrap">
        <input size="15" type="text" class="bginput" name="opentag" value="' . htmlspecialchars_uni($groupstitle['opentag']) . '" tabindex="1" />
        <input size="15" type="text" class="bginput" name="closetag" value="' . htmlspecialchars_uni($groupstitle['closetag']) . '" tabindex="1" />
        </span>', '', 'top', 'htmltags');
		print_submit_row("Set Usergroup Staff Title");
	}
	print_table_footer();
}

if ($_REQUEST['do'] == "set_update") {
$staffrank = $_REQUEST['staffrank'];
$opentag = $_REQUEST['opentag'];
$closetag = $_REQUEST['closetag'];
if ($opentag == ""){
$opentag ="";}
else{
$opentag =", staffrank_opentag='".$opentag."',";}
if ($closetag == ""){
$closetag ="";}
else{
$closetag ="staffrank_closetag='".$closetag."'";}
	$db->query_write("UPDATE ".TABLE_PREFIX."usergroup SET staffrank='$staffrank' $opentag $closetag where usergroupid =$_REQUEST[usergroupid]");//usergroup update
	$uStaff = $db->query_read("SELECT usergroupid, username, isstaffrank, staffrank AS stafftitle, staffrank_opentag AS opentag, staffrank_closetag AS closetag FROM ".TABLE_PREFIX."user where usergroupid = $_REQUEST[usergroupid]");
	while ($uStaffT = $db->fetch_array($uStaff)) {
	if ($uStaffT['isstaffrank']==0){
	$db->query_write("UPDATE ".TABLE_PREFIX."user SET staffrank='$staffrank' $opentag $closetag");//user update
	}
	else{
	$uStaffTs .= "<b>$uStaffT[username]</b>: could not be updated you have chosen to give them their own Staff Title.<br />\n";
	}
	}
	print "$_REQUEST[usergroup] Staff Title Updated and Users";
	print "<br />\n$uStaffTs";
	$_REQUEST['do'] = "dotitles";
}

//################## LIST ALL CUSTOM STAFF TITLES ######################
if ($_REQUEST['do'] == "custom") {
	print_form_header('staff_titles_admin', 'set_update');
	print_table_header("View Custom Admin Set Staff Titles");
	$userstaff = $db->query_read("SELECT userid, username, staffrank AS stafftitle, staffrank_opentag AS opentag, staffrank_closetag AS closetag FROM ".TABLE_PREFIX."user where isstaffrank = 1 order by userid asc");
	while ($userstafftitle = $db->fetch_array($userstaff)) {
	$userstafftitles .= "$userstafftitle[username] has the Staff Title of : ".$userstafftitle['opentag'].$userstafftitle['stafftitle'].$userstafftitle['closetag']."<br />\n";
	}
	print_description_row("$userstafftitles");
	print_table_footer();
}

//print_description_row();
print_cp_footer();


?>
sql note:this is comming from straight from the xml file
Code:
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "usergroup ADD (staffrank VARCHAR(250) NOT NULL DEFAULT '')");
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "usergroup ADD (staffrank_opentag  VARCHAR(250) NOT NULL DEFAULT '')");
$db->query_write("ALTER TABLE " . TABLE_PREFIX . "usergroup ADD (staffrank_closetag  VARCHAR(250) NOT NULL DEFAULT '')");
oh yea the nav group
Code:
<navgroups product="livewires_staff_titles">

	<navgroup text="Staff Titles" permissions="canadminpermissions" displayorder="121">

		<navoption displayorder="10">
			<text>Set Usergroup Staff Titles</text>
			<link>staff_titles_admin.php?do=dotitles</link>
		</navoption>
		
		<navoption displayorder="20">
			<text>View Custom Set Staff Titles</text>
			<link>staff_titles_admin.php?do=custom</link>
		</navoption>
		
	</navgroup>

</navgroups>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01842 seconds
  • Memory Usage 1,790KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete