vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Working with rssposter_parse_rss hook (https://vborg.vbsupport.ru/showthread.php?t=285403)

AndrewRich 07-10-2012 10:30 PM

Working with rssposter_parse_rss hook
 
I'm trying to implement a source blocklist for our RSS feeds - we get newsfeeds from Google News and rather than trying to figure out Google's broken news-source nomenclature, I will just block items from unwanted sources from posting. I'm hooking rssposter_parse_rss and have defined a blocklist as $vbulletin->options['rssitemsourcefilter_blacklist']. Here's my plugin code so far:


PHP Code:

global $vbulletin

if ( 
$vbulletin->options['rssitemsourcefilter_enabled']) { 
  
$blacklistA preg_split '/\s+/'$vbulletin->options['rssitemsourcefilter_blacklist'] ); 
  foreach ( 
$blacklistA as $blacklist ) { 
   if ( 
stripos $item['link'], $blacklist ) !== FALSE ) { 
     
// link source appears in blacklist 
     
if (defined('IN_CONTROL_PANEL')) { 
       echo 
"<p>RSS feed item with source {$blacklist} was blocked.</p>"
     } 
     
$item NULL// nullify the RSS item 
   
// if 
  
// foreach 
// if 

This does "empty out" the particular RSS item but it doesn't actually remove it from the queue, so instead a blank entry with a no-destination "more" link is posted. I've been going through /includes/class_rss_poster.php and /includes/cron/rssposter.php to try to figure out how to actually remove the offending item, but without any luck.

Any help appreciated. Thanks.

kh99 07-10-2012 11:25 PM

Unfortunately, I don't see how you can do what you want to do using that hook, and there really aren't any other hooks in the rss poster code. The only thing I can think of offhand is if you're posting the item as threads, you might be able to use a hook like threadfpdata_doset to set an error as if one of the fields were invalid, then when the rss poster calls save() to post the thread, it will fail. But to do that you need a way to detect that it's the rss poster cron job creating the thread, and you also need to be able to check the source.

Of course editing the vb files is always another option.

AndrewRich 07-11-2012 02:16 AM

Kevin, thanks for your reply. I know I could add a little something to class_rss_poster or rssposter but was hoping to avoid that. I'll look at perhaps setting a flag that another hook might see. Thanks again.


All times are GMT. The time now is 07:11 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.01110 seconds
  • Memory Usage 1,718KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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