Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2012, 10:03 PM
omerfarukak omerfarukak is offline
 
Join Date: Jan 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default About RSS Poster Hooks

Hi i want to write a plugin which is adds my wordpress posts a link which is rss posted on forum. And now i'm using rssfeeddata_postsave hook but how can i take new forum posts link?
Reply With Quote
  #2  
Old 01-28-2012, 10:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).
Reply With Quote
  #3  
Old 01-28-2012, 10:41 PM
omerfarukak omerfarukak is offline
 
Join Date: Jan 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).
so, which hook i can use?
Reply With Quote
  #4  
Old 01-28-2012, 11:01 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.
Reply With Quote
  #5  
Old 01-28-2012, 11:25 PM
omerfarukak omerfarukak is offline
 
Join Date: Jan 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.
Well, i'm trying again to explain. I'm using rss poster in vBulletin, it's getting data from my wordpress's rss feed. And opens a thread for each one. And i want to add this thread's link to end of my wordpress posts'. Is it sufficently clear?
Reply With Quote
  #6  
Old 01-28-2012, 11:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK - there are no hooks in the rss poster code, but you might be able to use threadfpdata_postsave. That gets called every time a thread is created so you have to check something to make sure it's one of your wordpress threads. I think the feed url might be available using something like:

Code:
global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{
   // add your link 
}
Reply With Quote
  #7  
Old 01-29-2012, 07:13 AM
omerfarukak omerfarukak is offline
 
Join Date: Jan 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What about the rssposter_parse_rss? Is there any guide about hooks?

--------------- Added [DATE]1327827918[/DATE] at [TIME]1327827918[/TIME] ---------------

Is this code works? Or what i have to do?
Code:
global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{  if (!empty($threadinfo['item_id'])) {
         require_once(DIR . '/includes/class_bbcode.php');
         $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
         mysql_connect('localhost', 'root', '');
         mysql_select_db('_wp');
         mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br>                                                          {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
    mysql_close();
}
Reply With Quote
  #8  
Old 01-29-2012, 12:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by omerfarukak View Post
What about the rssposter_parse_rss? Is there any guide about hooks?
You're right, I missed that. You might be able to do something in rssposter_parse_rss. But the problem may be that you don't have the threadid yet so I'm not sure how you'd create a link.

I don't know of any guide to hooks, but there could be one. I just look at the php code to see where they are.


Quote:
Is this code works? Or what i have to do?
Code:
global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{  if (!empty($threadinfo['item_id'])) {
         require_once(DIR . '/includes/class_bbcode.php');
         $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
         mysql_connect('localhost', 'root', '');
         mysql_select_db('_wp');
         mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br>                                                          {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
    mysql_close();
}
I'm not sure - I don't see how {feed:title} or {feed:link} will be substituted for the actual values. If you're trying to link back to the vb thread that gets created, then I think you'd want to do something like:

PHP Code:
if (is_array($feed) AND strncmp($feed['url'], 'something'len) == 0)
{  
    
$title $this->thread['title'];
    
$link '</ br></ br></ br> <a href="' $this->registry->options['bburl'] . '/showthread.php?t=' $this->thread['threadid'] . '">' htmlentities($title) . '</a>';
    
         
mysql_connect('localhost''root''');
         
mysql_select_db('_wp');
         
mysql_query("update wp_posts set post_content=concat(post_content,'" mysql_real_escape_string($link) . "') where post_title = '" mysql_real_escape_string($title) . "'");
    
mysql_close();


Also, you need to replace 'something' and 'len' in the above if statement to be something that would check to see if the feed url is the url of your wordpress feed.
Reply With Quote
  #9  
Old 01-30-2012, 06:03 PM
omerfarukak omerfarukak is offline
 
Join Date: Jan 2011
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
ini_set('display_errors'1);
    if(!
$link mysql_connect('localhost''root'''))
        echo 
fails_connection;
mysql_set_charset('utf8',$link);
        if(!
mysql_select_db('_wp'$link))
        echo 
fails_selection;
$link2 '<a href="http://bburl.co/showthread.php?t=threadid">link</a>';
        
mysql_query("update wp_posts set post_content = concat(post_content,"mysql_real_escape_string($link2) .") where id = 1794");
        echo 
mysql_error();
        
mysql_close(); 
When i try something like this, i get this error
Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<a href=\"http://bburl.co/showthread.php?t=threadid\">link</a>) where id = 1794' at line 1
What can we do?
Reply With Quote
  #10  
Old 01-30-2012, 06:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, I think the mysql line is missing quotes around the link string. So something like:

PHP Code:
mysql_query("update wp_posts set post_content = concat(post_content,'"mysql_real_escape_string($link2) ."') where id = 1794"); 

(I fixed it above as well).
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 01:00 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.06029 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
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
  • (4)bbcode_code
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete