Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 08-16-2007, 03:59 PM
projectego's Avatar
projectego projectego is offline
 
Join Date: Feb 2006
Location: UK
Posts: 724
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need help tweaking a plugin's php code

Hi all,

PHP newbie here. I hope a member of the community can help lend a hand and possibly find a solution to this.

I'm currently using Kall's rel="nofollow" attribute in parsed URLs hack and it is fantastic. Definite candidate for plugin of the century in my opinion.

However, I'm currently trying to tweak the plugin's php code so that the 'rel="external nofollow" tag applies to everyone's links except the primary Super Administrator with the userid of 1. At the moment, the code looks like:

Code:
$this->tag_list['no_option']['url']['callback'] = 'handle_external';
$this->tag_list['no_option']['url']['external_callback'] = 'handle_bbcode_url_relnofollow';
$this->tag_list['option']['url']['callback'] = 'handle_external';
$this->tag_list['option']['url']['external_callback'] = 'handle_bbcode_url_relnofollow';

if (!function_exists('handle_bbcode_url_relnofollow'))
{
    function handle_bbcode_url_relnofollow(&$parser, $text, $link)
    {
        global $post;
        // Excempt Admins with more than 395 posts
        $parsedurl = $parser->handle_bbcode_url($text, $link);
        if (is_member_of($post, 6) AND $post['posts'] > 395) 
        {
            return $parsedurl;
        }
        else
        {
            return str_replace('href="', 'rel="external nofollow" href="', $parsedurl); 
        }
    }
}
This will exempt all admins from having a rel="nofollow" attribute added to their links - I however would prefer for only me to be exempt from this. So, if possible, I would basically like the 'usergoup' altered to a 'userid'... part.

Would anyone be so kind as to post what might area might need to be altered in order to accomplish this? I also wouldn't mind if the minimum post count limit was removed from there too. I unfortunately can't seem to do this without causing an error! Heh.

I would be eternally grateful and be forever in love with you; Wish I could offer more but that's all I've got!

Thank you very much for reading.
Reply With Quote
  #2  
Old 08-16-2007, 08:31 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

replace this

if (is_member_of($post, 6) AND $post['posts'] > 395)

with this

if ($vbulletin->userinfo['userid'] == 1)
Reply With Quote
  #3  
Old 08-16-2007, 08:39 PM
projectego's Avatar
projectego projectego is offline
 
Join Date: Feb 2006
Location: UK
Posts: 724
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome! Thank you very much.

Just one last quick question: If I wanted to add additional userids to the equation - would this work?

Code:
if ($vbulletin->userinfo['userid'] == 1,2,666)
Reply With Quote
  #4  
Old 08-16-2007, 09:07 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if(in_array($vbulletin->userinfo['userid'], array(1,2,3,4))) 
There might be a parse error in there its late so :P
Reply With Quote
  #5  
Old 08-17-2007, 10:30 AM
projectego's Avatar
projectego projectego is offline
 
Join Date: Feb 2006
Location: UK
Posts: 724
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I just realised after testing both that neither work. Even links contained within my own posts have an rel="external follow" tagged on. Is there anything else that might work?
Reply With Quote
  #6  
Old 08-17-2007, 11:02 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Replace:
PHP Code:
if (is_member_of($post6) AND $post['posts'] > 395
With:
PHP Code:
if (in_array($post['userid'], array(1,2,3,4))) 
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 11:50 AM.


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.04769 seconds
  • Memory Usage 2,211KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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