Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-07-2007, 10:26 AM
NolF's Avatar
NolF NolF is offline
 
Join Date: Nov 2006
Location: You don't wanna know
Posts: 119
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to modify a function (PHP) between hooks

Ok hi
I'm trying to write my first product, and it would be a small extension to the thank you hack... Is a very small thing and can be achieve by just changing a line in the code, but I wanted to do it by using the product system... Things is I don't exactly know exactly how

to begin with the thing I want to modify is
PHP Code:
function can_delete_all_thanks()
{
    global 
$vbulletin;

    (
$hook vBulletinHook::fetch_hook('post_thanks_function_can_delete_all_thanks_start')) ? eval($hook) : false;

    if (
$vbulletin->userinfo['usergroupid'] == '6')
    {
        return 
true;
    }

    (
$hook vBulletinHook::fetch_hook('post_thanks_function_can_delete_all_thanks_end')) ? eval($hook) : false;

    return 
false;

and it would basically be to change
PHP Code:
"if ($vbulletin->userinfo['usergroupid'] == '6')" 
into
PHP Code:
if (is_member_of($vbulletin->userinfo['usergroupid'], explode("|"$vbulletin->options['post_thanks_who_delete_all']))) 
(pS: options['post_thanks_who_delete_all'] is an option created by the modification which is used to insert the usergroups)

[See attachment for the whole modification]

I', not sure if I'm being clear enough... I just can figure out what to put in the hooks to make the thing work...

I hope someone can lend me just few mins to teach me how to do it ^^
Thank you mates
Attached Files
File Type: xml Thank you dall v0.1.xml (1.9 KB, 3 views)
Reply With Quote
  #2  
Old 06-07-2007, 10:56 AM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If the function you posted doesn't have any extra code you can comment out the statement.

In the first hook add
Code:
/*


In the second hook add
Code:
*/
if (is_member_of($vbulletin->userinfo['usergroupid'], explode("|", $vbulletin->options['post_thanks_who_delete_all'])))
{
   return true;
}
Reply With Quote
  #3  
Old 06-07-2007, 11:43 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice workaround, I wouldn't have ever though of that.
Reply With Quote
  #4  
Old 06-07-2007, 02:36 PM
NolF's Avatar
NolF NolF is offline
 
Join Date: Nov 2006
Location: You don't wanna know
Posts: 119
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had tried that idea /* */ problem is you get an error message at evaluation (see attachment) obviously those two lines are the ones related to the hooks ^^

Besides that I couldn't think of anything else. Any other solution?

I really appreciate the help
Attached Images
File Type: jpg eval.jpg (6.7 KB, 0 views)
Reply With Quote
  #5  
Old 06-07-2007, 06:42 PM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the second hook add

PHP Code:
if ($vbulletin->userinfo['usergroupid'] == '6')
{
     return 
false;


if (
is_member_of($vbulletin->userinfo['usergroupid'], explode("|"$vbulletin->options['post_thanks_who_delete_all'])))
{
   return 
true;

Reply With Quote
  #6  
Old 06-07-2007, 07:06 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why not just place this in the first hook location?

PHP Code:
if (is_member_of($vbulletin->userinfo['usergroupid'], explode("|"$vbulletin->options['post_thanks_who_delete_all'])))
{
   return 
true;

1) If it returns true the code below it doesn't matter anyway.
2) usergroupid 6 is the admin group so there is no real reason to work around that code. Either way it's sitting there doing nothing (assuming usergroupid 6 is in $vbulletin->options['post_thanks_who_delete_all'])

The work around is nice but it won't play well in an enviroment using multiple products.
Reply With Quote
  #7  
Old 06-08-2007, 11:17 AM
NolF's Avatar
NolF NolF is offline
 
Join Date: Nov 2006
Location: You don't wanna know
Posts: 119
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

THANK YOU ALOT!!!!!!!!!!!!!!
Both solutions work perfectly ^^ Thank you guys ^^
Reply With Quote
  #8  
Old 06-09-2007, 03:29 AM
Carnage Carnage is offline
 
Join Date: Jan 2005
Location: uk
Posts: 760
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well, you could always change the value of usergroup id to say 'a' in the first hook then change it back in the second.

1st hook
PHP Code:
if ($vbulletin->userinfo['usergroupid'] == '6')
{
     
$vbulletin->userinfo['usergroupid'] = 'a'

2nd hook

PHP Code:
if ($vbulletin->userinfo['usergroupid'] == 'a')
{
     
$vbulletin->userinfo['usergroupid'] = '6';


if (
is_member_of($vbulletin->userinfo['usergroupid'], explode("|"$vbulletin->options['post_thanks_who_delete_all'])))
{
   return 
true;

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 02:38 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03994 seconds
  • Memory Usage 2,272KB
  • Queries Executed 12 (?)
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
  • (2)bbcode_code
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (2)postbit_attachment
  • (8)postbit_onlinestatus
  • (8)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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete