vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to modify a function (PHP) between hooks (https://vborg.vbsupport.ru/showthread.php?t=149123)

NolF 06-07-2007 10:26 AM

How to modify a function (PHP) between hooks
 
1 Attachment(s)
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

harmor19 06-07-2007 10:56 AM

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;
}


Dismounted 06-07-2007 11:43 AM

Nice workaround, I wouldn't have ever though of that.

NolF 06-07-2007 02:36 PM

1 Attachment(s)
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 :)

harmor19 06-07-2007 06:42 PM

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;



Brad 06-07-2007 07:06 PM

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.

NolF 06-08-2007 11:17 AM

THANK YOU ALOT!!!!!!!!!!!!!!
Both solutions work perfectly ^^ Thank you guys ^^

Carnage 06-09-2007 03:29 AM

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;




All times are GMT. The time now is 09:34 AM.

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.01102 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete