Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 09-29-2009, 05:27 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Auto-assign thread prefix when posting a new thread

Evening all,

I was wondering if there's a method of automatically assigning a thread prefix to a new thread when it is submitted. I don't want the user to select a prefix, I want a default one to be assigned.

Reason:
I'm creating a forum with 3 prefixes. Accepted, Rejected and Pending.
I want "Pending" to be appended onto any thread that is submitted in that forum so I can sort through the pending/accepted/rejected by sorting the prefixes.

I am guessing it would be possible on the newthread_complete hook; however any help is greatly appreciated.

Thanks.
Reply With Quote
  #2  
Old 09-29-2009, 07:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I'd use a hook and add it in there. I would use newthead_post_complete hook as you suggested since it is after the prefix would be defined for the thread (so you can over-ride what is entered) and before the post is saved. You can read the code right before that hook to see how to set it.
Reply With Quote
  #3  
Old 09-29-2009, 08:03 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello again,

I have the following code:
PHP Code:
if($foruminfo['forumid'] == 41){
$newpost['prefixid'] = 'Pending';

Yes my prefix ID is "Pending". I am using the newthread_post_complete hook.

Line 443 is:
PHP Code:
$prefix_options fetch_prefix_html($foruminfo['forumid'], $newpost['prefixid'], true); 
So I am guessing I am using the right syntax.

The hook I am using is line 271 and the $newpost['prefixid'] is defined on line 170:
PHP Code:
    if (can_use_prefix($vbulletin->GPC['prefixid']))
    {
        
$newpost['prefixid'] =& $vbulletin->GPC['prefixid'];
    } 
Could someone help me out?

Thanks again.


EDIT: I have made sure that the prefix is assigned to that forum, so the issue isn't that the prefix isn't there.
Reply With Quote
  #4  
Old 09-29-2009, 10:16 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Whoops... I just took another look and the post is actually guild on line 213 (how did I miss that?), so you need to set it prior to that line, so I guess newthread_post_start instead.
Reply With Quote
  #5  
Old 09-30-2009, 01:48 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply Lynne. I still have the issue of the prefix not appending though. Using the same above code.

There doesn't seem to be a variable for the prefix before line 143 (the hook)? Except in the phrasegroups.

I will have another look around, thanks for anything you can dig up though.
Reply With Quote
  #6  
Old 09-30-2009, 02:18 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you use newthread_post_start, then you actually will have to do something like this so it doesn't get overwritten (add your condition):
PHP Code:
$vbulletin->GPC['prefixid'] = 'Pending'
Reply With Quote
  #7  
Old 09-30-2009, 02:25 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne!

I do have another issue however:
If I have set regular users not able to use prefixes in that forum, it doesn't append a prefix.

Any way around this?
Reply With Quote
  #8  
Old 09-30-2009, 03:11 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this (with your condition around it)...

PHP Code:
$vbulletin->GPC['prefixid'] = 'Pending'
$newpost['prefixid'] =& $vbulletin->GPC['prefixid']; 

This way, the prefixid gets set here, and then it can be rewritten later on if they have privs. If they don't have privs, it doesn't get set in that other line, but you made sure it was set here anyway. Hopefully that works.
Reply With Quote
  #9  
Old 09-30-2009, 03:55 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne! You're truly a star
Reply With Quote
  #10  
Old 09-30-2009, 04:35 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got it working!
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:21 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.05931 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete