Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 12-16-2004, 04:21 AM
Tbird66 Tbird66 is offline
 
Join Date: Dec 2004
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had a functionality requirement similiar to btappan's, but I needed the custom field to only be visible to those users who had permissions to view private custom fields.

To accomplish this, I modified KirbyDE's hack. I'm reposting Kirby's hack with my modifications (I hope this is proper procedure - this is the first time I've posted code) - thanks KirbyDE!!

The following steps will set up your Member List to display the Company Name (user field 5 in this example) as the first column and sort by it if the user has permissions to see private custom fields (assuming that user field 5 is a private custom field of course ), and display the default Member List if the user does not have permissions to see private custom fields.

In memberlist.php FIND
PHP Code:
// set defaults and sensible values 

if ($sortfield == ''

        
$sortfield 'username'

REPLACE that WITH
PHP Code:
// set defaults and sensible values

if ($sortfield == '')
{
    if (
$permissions['genericpermissions'] & CANSEEHIDDENCUSTOMFIELDS)
    {
        
$sortfield 'companyname';
    }
    else
    {
        
$sortfield 'username';
    }

then FIND
PHP Code:
switch ($sortfield

         case 
'username'
                 
$sqlsort 'user.username'
                 break; 
BELOW that ADD
PHP Code:
case 'companyname'
                 
$sqlsort 'userfield.field5'
                 break; 
Revert to the original versions of your memberlist and memberlist_resultsbit templates.

Set your Company Name field to NOT show up on members list

In template memberlist FIND
Code:
<td class="thead" align="$stylevar[left]" nowrap="nowrap"><a href="$sorturl&amp;order=ASC&amp;sort=username&amp;pp=$perpage&amp;ltr=$  ltr$usergrouplink">$vbphrase[username]</a> $sortarrow[username]</td>
ABOVE that ADD
Code:
<if condition="$permissions['genericpermissions'] & CANSEEHIDDENCUSTOMFIELDS">
<td class="thead" align="$stylevar[left]" nowrap="nowrap"><a href="$sorturl&amp;order=ASC&amp;sort=companyname&amp;pp=$perpage&amp;ltr=$ltr$usergrouplink">Company Name</a> $sortarrow[companyname]
</td></if>
In template memberlist_resultsbit FIND
Code:
<td class="alt1Active" align="$stylevar[left]" id="u$userinfo[userid]">
		<a href="member.php?$session[sessionurl]u=$userinfo[userid]">$userinfo[musername]</a>
		<if condition="$show['usertitlecol']"><div class="smallfont">$userinfo[usertitle]</div></if>
	</td>
ABOVE that ADD
Code:
<if condition="$permissions['genericpermissions'] & CANSEEHIDDENCUSTOMFIELDS">
<td class="alt2Active" align="$stylevar[left]"> $userinfo[field5]
</td></if>
EDIT:
The following will allow the alpha search at the top of the memberlist page to sort by the added userfield.
In memberlist.php FIND
PHP Code:
    if ($ltr != '')
    {
        if (
$ltr == '#')
        {
            
$condition "username NOT REGEXP(\"^[a-zA-Z]\")";
        }
        else
        {
            
$ltr chr(intval(ord($ltr)));
            
$condition 'username LIKE("' addslashes_like($ltr) . '%")';
        }
    } 
REPLACE that WITH
PHP Code:
    if ($ltr != '')
    {
        if (
$ltr == '#')
        {
            if ((
$sortfield == 'companyname') OR ($sortfield != 'username' AND ($permissions['genericpermissions'] & CANSEEHIDDENCUSTOMFIELDS))) 
            {
                
$condition "field5 NOT REGEXP(\"^[a-zA-Z]\")";
            }
            else
            {
                
$condition "username NOT REGEXP(\"^[a-zA-Z]\")";
            }
        }
        else
        {
            
$ltr chr(intval(ord($ltr)));

            if ((
$sortfield == 'companyname') OR ($sortfield != 'username' AND ($permissions['genericpermissions'] & CANSEEHIDDENCUSTOMFIELDS))) 
            {
                
$condition 'field5 LIKE("' addslashes_like($ltr) . '%")';
            }
            else
            {    
                
$condition 'username LIKE("' addslashes_like($ltr) . '%")';
            }
        }
    } 
Reply With Quote
  #12  
Old 12-20-2004, 09:57 PM
Tbird66 Tbird66 is offline
 
Join Date: Dec 2004
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I figured out how to get the alpha search at the top of the memberlist page to sort by the added userfield, check my previous post for the new code...
Reply With Quote
  #13  
Old 01-09-2005, 11:43 PM
steven s's Avatar
steven s steven s is offline
 
Join Date: Aug 2004
Location: Greenville, SC
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

On these same lines I want to sort by additional profile fields in the membership list.

I have one field named Membership Number and one membership renewal date.
Using phpMyAdmin I see 'vb3_profilefield'
If I browse profileid
id #5 is Membership Number and id#6 is Membership renewal.

How would I apply
Code:
switch ($sortfield)
{
         case 'username':
                 $sqlsort = 'user.username';
                 break;
to do what I want?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:35 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04179 seconds
  • Memory Usage 2,214KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete