vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Creating a Visitor Message from external script (https://vborg.vbsupport.ru/showthread.php?t=259650)

Calash 03-01-2011 11:51 AM

Creating a Visitor Message from external script
 
My site bridges eFiction, a story archive software, and vBulletin. The bridge calls global.php to pull session variables and pass this to the eFiction side for authentication.

My current project is to improve upon the review system that eFiction currently has. My though it to leverage the Visitor Message and conversation system to create a more interactive review/response system.

Here is where I am stuck. I have code for creating a forum thread thanks to the article posted here but I cannot find any such guidance for the Visitor Message system. My goal is that on a author reply to a Review it will create a visitor message on the reviewers profile, then add a link to the conversation on the review.

Can anybody guide me in the right direction for creating visitor messages via an external script? Should I just dump the data in the table or is there a better solution?

Calash 03-02-2011 11:59 AM

I ended up pulling some code from a plugin to get this done by directly dumping the info into the database, then updating the unread vm count for the users. Quick and it works fairly well.

Here is the code if anybody else runs into this.

Code:

$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "visitormessage
                                (userid, postuserid, dateline, state, pagetext, allowsmilie)
                        VALUES
                                ('" . $uid . "','" .$reviewerid  . "','" . TIMENOW . "','visible','" . $vm_text. "','1')
                ");
               
                list($unread) = $vbulletin->db->query_first("
                        SELECT COUNT(*) AS unread
                        FROM " . TABLE_PREFIX . "visitormessage
                        WHERE userid = $authoruid AND state = 'visible' AND messageread = 0", DBARRAY_NUM
                );
               
                $vbulletin->db->query_write("
                        UPDATE " . TABLE_PREFIX . "user
                        SET vmunreadcount = " . intval($unread) . "
                        WHERE userid = $authoruid
                ");


BirdOPrey5 03-03-2011 08:15 PM

Very cool of you to share the answer :up: thanks.


All times are GMT. The time now is 10:27 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.02790 seconds
  • Memory Usage 1,712KB
  • 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_code_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