Custom User Rank

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
lot
Berichten: 190
Lid geworden op: 10 feb 2005, 17:03
Contacteer:

Custom User Rank

Bericht door lot » 05 mei 2005, 14:19

Ik heb de Custom User Rank hack geinstalleerd. Hij doet het goed, alleen één ding:

Wanneer je nu in het profiel kijkt is er dropdown menu met de opties. Maar is er altijd één geselecteerd. Dus wanneer ik bijvoorbeeld alleen mijn email adres wil wijzigen wordt automatisch ook de Custom User Rank aangepast. Kan ik in het dropdownmenu een blanke optie hebben?

Dit is de mod:

Code: Selecteer alles

## Hack Title:    Custom User Rank 
## Hack Version:  2.0.9 (ex phpBB 2.0.4)
## Author:        Acid
## Credits:	  Shion Uzuki aka Kage Musha (first 2.x-Script)
##
## Description:   Allow your users to select their own user title.. after reaching
##                a specified amount of posts.
##
## Files to edit: 13
##		  admin/admin_users.php
##		  admin/admin_board.php
##		  language/lang_english/lang_main.php 
##		  language/lang_english/lang_admin.php 
##		  includes/usercp_viewprofile.php 
##		  includes/usercp_register.php
##		  includes/usercp_avatar.php 
##		  viewtopic.php 
##		  templates/xxx/admin/user_edit_body.tpl
##		  templates/xxx/admin/board_config_body.tpl
##		  templates/xxx/profile_add_body.tpl 
##		  templates/xxx/profile_view_body.tpl 
##		  templates/xxx/viewtopic_body.tpl 
## 
##########################################################################################
## 
## Installation/Author Notes:
## First always backup the files/database that you're going to edit.
## 
## This hack adds a new field to the 'config' table and two new columns to 'users'.
##
##########################################################################################
## 
## Versions:
## 
## v.2.0.9
##	- optional part "predefined ranks (dropdown menu)" added
##	- optional part "custom rank can´t be used twice" modified
##	  ("predefined ranks can´t be used" added)
## v.2.0.8
##	- error (if rank is already set and user updates his profile without changing
##	  rank) fixed (only for optional part "custom rank can´t be used twice")
## v.2.0.7
##	- error (if an user has not reached the post limit yet and updates his
##	  profile the custom rank defined by admin in user management gets removed)
##	  fixed
##	- user_title_english_optional.txt modified and missing "user_allow_rank" added
##	- varchar value changed
## v.2.0.6
##	- optional part enhanced (ranks can´t be used twice)
##	- can be deactivated for every single user
## v1.0.1 - 2.0.5
##	- long, long way
## v1.0.0
##	- Release
## 
##########################################################################################
#
#-----[ SQL ]-------------------------------------------
#  
# You have to execute the following queries via phpmyadmin (change prefix)..

ALTER TABLE phpbb_users ADD user_custom_rank VARCHAR(50) AFTER user_rank;
ALTER TABLE phpbb_users ADD user_allow_rank TINYINT(1) default '1' AFTER user_custom_rank;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_custom_rank', '100');

# alternate you can use db_update.php to alter the database automatically
# (just upload to phpBB folder, run the file and delete after successfully installation).
#
##########################################################################################
# 
#-----[ OPEN ]------------------------------------------ 
#
# language/lang_english/lang_main.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
//
// Profiles/Registration
//

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
// Custom Status Rank 
$lang['Custom_Rank'] = 'Custom Rank'; 
$lang['Custom_Rank_Explain'] = 'Define your own rank.'; 



# 
#-----[ OPEN ]------------------------------------------ 
#
# language/lang_english/lang_admin.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
$lang['Add_new_rank'] = 'Add new rank';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
// Custom User Rank Mod 
$lang['Custom_Rank'] = 'User defined rank'; 
$lang['Allow_custom_rank'] = 'Allow user defined rank';
$lang['Allow_custom_rank_explain'] = 'Amount of posts, before an user can select his own rank';
$lang['Allow_rank'] = 'User can choose rank';



# 
#-----[ OPEN ]------------------------------------------ 

# includes/usercp_viewprofile.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
//
// Generate page
//
$page_title = $lang['Viewing_profile'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
if( $profiledata['user_custom_rank'] )
{
        $poster_custom_rank = ( $profiledata['user_custom_rank'] ) ? $profiledata['user_custom_rank'] : ' ';
        $poster_rank = '';
}
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if( count($orig_word) )
{
        $poster_custom_rank = preg_replace($orig_word, $replacement_word, $poster_custom_rank);
}

# 
#-----[ FIND ]---------------------------------------------------
# 
	'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ',

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	'CUSTOM_RANK' => $poster_custom_rank,



# 
#-----[ OPEN ]------------------------------------------ 
#
# includes/usercp_register.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
$strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests'); 

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
'interests' => 'interests'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, 'custom_rank' => 'custom_rank'

# 
#-----[ FIND (2x) ]---------------------------------------------------
# 
		$interests = stripslashes($interests);

# 
#-----[ always BELOW ADD ]---------------------------------------------------
# 
		$custom_rank = stripslashes($custom_rank); 

# 
#-----[ FIND ]---------------------------------------------------
# 
if ($mode == 'register' && ($userdata['session_logged_in'] || $username == $userdata['username']))
{
	message_die(GENERAL_MESSAGE, $lang['Username_taken'], '', __LINE__, __FILE__);
}

# 
#-----[ BELOW, ADD ]---------------------------------------------------
# 
if( $userdata['user_posts'] >= $board_config['allow_custom_rank'] && $userdata['session_logged_in'] && $mode != 'register' && $userdata['user_allow_rank'] == '1' )
{
        $allow_custom_rank = TRUE;
}

# 
#-----[ FIND (just a quote) ]---------------------------------------------------
# 
			$sql = "UPDATE " . USERS_TABLE . "

# 
#-----[ ABOVE ADD ]---------------------------------------------------
# 
			$user_title = ( $allow_custom_rank ) ? ', user_custom_rank = \''.str_replace("\'", "''", $custom_rank).'\'' : '';

# 
#-----[ FIND again (just a quote) ]---------------------------------------------------
# 
			$sql = "UPDATE " . USERS_TABLE . "

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
user_interests = '" . str_replace("\'", "''", $interests) . "'

# 
#-----[ AFTER ADD (before , ) ]---------------------------------------------------
# 
 $user_title

# 
#-----[ FIND ]---------------------------------------------------
# 
	$interests = $userdata['user_interests'];

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	$custom_rank = $userdata['user_custom_rank'];

# 
#-----[ FIND ]---------------------------------------------------
# 
display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat, $userdata['session_id']);

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
$interests

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, $custom_rank

# 
#-----[ FIND ]---------------------------------------------------
# 
		'S_FORM_ENCTYPE' => $form_enctype,
		'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
	);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	if( $allow_custom_rank )
	{
	        $template->assign_block_vars('custom_rank', array(
	                'CUSTOM_RANK' => $custom_rank,
	                'L_CUSTOM_RANK' => $lang['Custom_Rank'],
	                'L_CUSTOM_RANK_EXPLAIN' => $lang['Custom_Rank_Explain'],
	        ));
	}



# 
#-----[ OPEN ]------------------------------------------ 
#
# includes/usercp_avatar.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat, &$session_id)

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
&$interests

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, &$custom_rank

# 
#-----[ FIND ]---------------------------------------------------
# 
$params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); 

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
'interests'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, 'custom_rank'



# 
#-----[ OPEN ]------------------------------------------ 
#
# viewtopic.php 
# 
#-----[ FIND (just a quote ]---------------------------------------------------
# 
$sql = "SELECT u.username, u.user_id

# 
#-----[ FIND in this line ]---------------------------------------------------
# 
u.user_rank

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, u.user_custom_rank

# 
#-----[ FIND ]---------------------------------------------------
# 
	$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	$poster_custom_rank = ( $postrow[$i]['user_custom_rank'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $postrow[$i]['user_custom_rank'] : '';

# 
#-----[ FIND ]---------------------------------------------------
# 
	$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
	$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	if( $postrow[$i]['user_custom_rank'] )
	{
                  $poster_custom_rank = ( $postrow[$i]['user_custom_rank'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $postrow[$i]['user_custom_rank'] : '';
                  $poster_rank = '';
                  $rank_image = '';
	}
	if( count($orig_word) )
	{
                  $poster_custom_rank = preg_replace($orig_word, $replacement_word, $poster_custom_rank);
	}

# 
#-----[ FIND ]---------------------------------------------------
# 
		'RANK_IMAGE' => $rank_image,

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		'CUSTOM_RANK' => $poster_custom_rank,



# 
#-----[ OPEN ]------------------------------------------ 
#
# admin/admin_users.php
# 
#-----[ FIND ]---------------------------------------------------
# 
		$interests = ( !empty($HTTP_POST_VARS['interests']) ) ? trim(strip_tags( $HTTP_POST_VARS['interests'] ) ): ''; 

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		$custom_rank = ( !empty($HTTP_POST_VARS['custom_rank']) ) ? trim(strip_tags( $HTTP_POST_VARS['custom_rank'] ) ) : ''; 
		$allow_rank = ( isset( $HTTP_POST_VARS['allow_rank']) ) ? ( ( $HTTP_POST_VARS['allow_rank'] ) ? TRUE : 0 ) : 0;

# 
#-----[ FIND (2x) ]---------------------------------------------------
# 
			$interests = htmlspecialchars(stripslashes($interests));

# 
#-----[ always BELOW ADD ]---------------------------------------------------
# 
			$custom_rank = htmlspecialchars(stripslashes($custom_rank));

# 
#-----[ FIND (just a quote) ]---------------------------------------------------
# 
			$sql = "UPDATE " . USERS_TABLE . "

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
user_interests = '" . str_replace("\'", "''", $interests) . "'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, user_custom_rank = '" . str_replace("\'", "''", $custom_rank) . "', user_allow_rank = '$allow_rank'

# 
#-----[ FIND ]---------------------------------------------------
# 
		$interests = htmlspecialchars($this_userdata['user_interests']);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		$custom_rank = htmlspecialchars($this_userdata['user_custom_rank']);
		$allow_rank = $this_userdata['user_allow_rank'];

# 
#-----[ FIND ]---------------------------------------------------
# 
			$s_hidden_fields .= '<input type="hidden" name="interests" value="' . str_replace("\"", """, $interests) . '" />';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
			$s_hidden_fields .= '<input type="hidden" name="custom_rank" value="'. str_replace("\"", """, $custom_rank) .'" />';
			$s_hidden_fields .= '<input type="hidden" name="allow_rank" value="'. $allow_rank .'" />';

# 
#-----[ FIND ]---------------------------------------------------
# 
			'INTERESTS' => $interests,

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
			'CUSTOM_RANK' => $custom_rank,
			'ALLOW_RANK_YES' => ( $allow_rank ) ? 'checked="checked"' : '',
			'ALLOW_RANK_NO' => ( !$allow_rank ) ? 'checked="checked"' : '',
			'L_CUSTOM_RANK' => $lang['Custom_Rank'],
			'L_ALLOW_RANK' => $lang['Allow_rank'],



# 
#-----[ OPEN ]------------------------------------------ 
#
# admin/admin_board.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
	"NAMECHANGE_YES" => $namechange_yes,
	"NAMECHANGE_NO" => $namechange_no,

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	"CUSTOM_RANK" => $new['allow_custom_rank'], 
	"L_ALLOW_CUSTOM_RANK" => $lang['Allow_custom_rank'],
	"L_ALLOW_CUSTOM_RANK_EXPLAIN" => $lang['Allow_custom_rank_explain'],



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/profile_add_body.tpl 
# 
#-----[ FIND ]---------------------------------------------------
# 
	<tr> 
		<td class="row1"><span class="gen">{L_EMAIL_ADDRESS}: *</span></td>
		<td class="row2"><input type="text" class="post" style="width:200px" name="email" size="25" maxlength="255" value="{EMAIL}" /></td>
	</tr>

# 
#-----[ ABOVE ADD ]---------------------------------------------------
# 
	<!-- BEGIN custom_rank -->
	<tr>
		<td class="row1"><span class="gen">{custom_rank.L_CUSTOM_RANK}:</span><br /><span class="gensmall">{custom_rank.L_CUSTOM_RANK_EXPLAIN}</span></td>
		<td class="row2"><input type="text" class="post"style="width: 200px" name="custom_rank" size="35" maxlength="50" value="{custom_rank.CUSTOM_RANK}" /></td>
	</tr>
	<!-- END custom_rank -->



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/profile_view_body.tpl 
# 
#-----[ FIND ]---------------------------------------------------
# 
 {POSTER_RANK}

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
 {CUSTOM_RANK}



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/viewtopic_body.tpl 
# 
#-----[ FIND ]---------------------------------------------------
# 
{postrow.POSTER_RANK} 

# 
#-----[ BEFORE ADD ]---------------------------------------------------
# 
{postrow.CUSTOM_RANK} 



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/admin/user_edit_body.tpl 
# 
#-----[ FIND ]---------------------------------------------------
# 
        <tr> 
                <td class="row1"><span class="gen">{L_SELECT_RANK}</span></td> 
                <td class="row2"><select name="user_rank">{RANK_SELECT_BOX}</select></td> 
        </tr> 

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	<tr>
		<td class="row1"><span class="gen">{L_ALLOW_RANK}</span></td>
		<td class="row2"><span class="gen"><input type="radio" name="allow_rank" value="1" {ALLOW_RANK_YES} />{L_YES}&nbsp;&nbsp;
				   <input type="radio" name="allow_rank" value="0" {ALLOW_RANK_NO} />{L_NO}</span></td>
	</tr>
	<tr>
		<td class="row1"><span class="gen">{L_CUSTOM_RANK}</span></td>
		<td class="row2"><input type="text" name="custom_rank" size="35" maxlength="50" value="{CUSTOM_RANK}" class="post" /></td>
	</tr>



# 
#-----[ OPEN ]------------------------------------------ 
#
# templates/xxx/admin/board_config_body.tpl 
# 
#-----[ FIND ]---------------------------------------------------
# 
	<tr>
		<td class="row1">{L_ALLOW_NAME_CHANGE}</td>
		<td class="row2"><input type="radio" name="allow_namechange" value="1" {NAMECHANGE_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="allow_namechange" value="0" {NAMECHANGE_NO} /> {L_NO}</td>
	</tr>

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	<tr>
		<td class="row1"><span class="genmed">{L_ALLOW_CUSTOM_RANK}</span><br /><span class="gensmall">{L_ALLOW_CUSTOM_RANK_EXPLAIN}</span></td>
		<td class="row2"><input class="post" type="text" size="5" maxlength="10" name="allow_custom_rank" value="{CUSTOM_RANK}" /></td>
	</tr>
en dit is de optie om dat dropdown menu toe te voegen:

Code: Selecteer alles

# 
#-----[ OPEN ]------------------------------------------
#
# language/lang_english/lang_main.php
# 
#-----[ FIND ]---------------------------------------------------
# 
$lang['Custom_Rank'] = 'Custom Rank'; 

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
## if you´re going to edit the part do not delete the single quotes (').

$lang['Rank_choice'] = array('rank 1','rank 2','rank 3','rank 4');


# 
#-----[ OPEN ]------------------------------------------
#  
# includes/usercp_register.php
# 
#-----[ FIND ]---------------------------------------------------
# 
	$template->set_filenames(array(
		'body' => 'profile_add_body.tpl')
	);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	$s_custom_rank = '<select name="custom_rank">';
	for($i = 0; $i < count($lang['Rank_choice']); $i++ )
	{
	        $s_custom_rank .= '<option value="'. $lang['Rank_choice'][$i] .'">'. $lang['Rank_choice'][$i] .'</option>';
	}
	$s_custom_rank .= '</select>'; 
	$s_custom_rank = str_replace('value="'. $custom_rank .'">', 'value="'. $custom_rank .'" SELECTED>', $s_custom_rank);

# 
#-----[ FIND ]---------------------------------------------------
# 
	                'CUSTOM_RANK' => $custom_rank,

# 
#-----[ REPLACE WITH ]---------------------------------------------------
# 
	                'S_CUSTOM_RANK' => $s_custom_rank,


# 
#-----[ OPEN ]------------------------------------------
#  
# admin/admin_users.php
# 
#-----[ FIND ]---------------------------------------------------
# 
		$template->set_filenames(array(
			"body" => "admin/user_edit_body.tpl")
		);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		$s_custom_rank = '<select name="custom_rank">';
		for($i = 0; $i < count($lang['Rank_choice']); $i++ )
		{
		        $s_custom_rank .= '<option value="'. $lang['Rank_choice'][$i] .'">'. $lang['Rank_choice'][$i] .'</option>';
		}
		$s_custom_rank .= '</select>'; 
		$s_custom_rank = str_replace('value="'. $custom_rank .'">', 'value="'. $custom_rank .'" SELECTED>', $s_custom_rank);

# 
#-----[ FIND ]---------------------------------------------------
# 
		'CUSTOM_RANK' => $custom_rank,

# 
#-----[ REPLACE WITH ]---------------------------------------------------
# 
		'S_CUSTOM_RANK' => $s_custom_rank,


# 
#-----[ OPEN ]------------------------------------------
#  
# templates/xxx/profile_add_body.tpl
# 
#-----[ FIND ]---------------------------------------------------
# 
		<td class="row2"><input type="text" name="custom_rank" size="35" maxlength="50" value="{custom_rank.CUSTOM_RANK}" class="post" /></td>

# 
#-----[ REPLACE WITH ]---------------------------------------------------
# 
		<td class="row2">{custom_rank.S_CUSTOM_RANK}</td>


# 
#-----[ OPEN ]------------------------------------------
#  
# templates/xxx/admin/user_edit_body.tpl
# 
#-----[ FIND ]---------------------------------------------------
# 
		<td class="row2"><input type="text" name="custom_rank" size="35" maxlength="50" value="{CUSTOM_RANK}" class="post" /></td>

# 
#-----[ REPLACE WITH ]---------------------------------------------------
# 
		<td class="row2">{S_CUSTOM_RANK}</td>
Bij mij staat er nu administrator onder mijn username bij alle posts, wanneer ik nu in mijn profiel iets wijzig dan krijg ik automatisch een Custom Rank mee en dat wil ik niet, kan dat eruit ?

Lotte

Gebruikersavatar
Luuk
Berichten: 7311
Lid geworden op: 22 okt 2003, 10:07
Locatie: Delft

Bericht door Luuk » 06 mei 2005, 16:09

Probeer eens door beide keren

Code: Selecteer alles

$s_custom_rank = '<select name="custom_rank">';
te vervangen met

Code: Selecteer alles

$s_custom_rank = '<select name="custom_rank"><option value="">--------</option>';
Afbeelding

Gesloten