Adding a thread manually

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unwebman
    New Member
    • Aug 2005
    • 10
    • 3.0.7

    Adding a thread manually

    I've been searching for information on this for a long time, but to no avail.

    I am trying to understand how to manually add a new thread via the DB and have it show up in the forums. However, when I create the record in the thread and post tables, the thread does not show up.

    I'm trying to make an events forum so that people cannot add new threads, but rather, threads are created by an application that I am writing.

    Any help, or even just a point in the right direction, would be awesome. Again, I'm trying to do this only by using raw mysql queries.... if possible.

    Thanks!
  • Removed-836727
    Banned by User Request
    • Apr 2006
    • 1274

    #2
    you cant put it into the db with something like phpmyadmin
    thats more complex...
    so use the datamanager
    PHP Code:
            require_once(DIR '/includes/functions_databuild.php'); /* included to build new thread and update counters */ 
            
    $threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost');
            
    $threadinfo = array();

            
    $threaddm->set_info('forum'$foruminfo);
            
    $threaddm->set_info('thread'$threadinfo);
            
    $threaddm->setr('forumid'$forumid);
            
    $threaddm->setr('userid'$userid);
            
    $threaddm->setr('pagetext'$pagetext);
            
    $threaddm->setr('title'$title);
            
    $threaddm->set('open'$open);
            
    $threaddm->set('allowsmilie'$allowsmilie);
            
    $threaddm->set('visible'$visible);

            
    $threaddm->pre_save();

                
    $threadid $threaddm->save();
                unset(
    $threaddm);
                
    build_thread_counters($threaddm);

            
    build_forum_counters($foruminfo['forumid']); 

    Comment

    • unwebman
      New Member
      • Aug 2005
      • 10
      • 3.0.7

      #3
      Awesome. Just what I'm looking for.

      Questions:
      The $threadinfo variable is to remain an empty array?

      What should the $foruminfo variale contain?

      $pagetext is the post content?

      what is the $open variable?

      THANK YOU!!!

      Comment

      • Removed-836727
        Banned by User Request
        • Apr 2006
        • 1274

        #4
        open=> if the thread should be open/closed(you can delete this... its not necessery)
        i think that $threaddm->set_info('thread', $threadinfo); also can be deleted(just try it out*g*)

        i've just copied the code from an hack

        Comment

        • unwebman
          New Member
          • Aug 2005
          • 10
          • 3.0.7

          #5
          Ok. perfect! that worked great. Now how can I use datamanager to update that post I just made? I'll have no problem getting the postid for that.

          Where is there more detailed information on datamanager? I swear, I can't find very much...

          Comment

          • patrickb
            New Member
            • Jun 2007
            • 27

            #6
            Originally posted by ragtek
            you cant put it into the db with something like phpmyadmin
            thats more complex...
            Is it still possible though to add it with various SQL queries? From the research I did, it should be doable by adding some entries in the thread table and the post table.

            I personally can't use the data manager because I'm not using php for my external site.

            Am I missing something by adding data in those two tables?

            Comment

            • Removed-836727
              Banned by User Request
              • Apr 2006
              • 1274

              #7
              i hope that some developer could say something to that

              i think that it doesn't go, because so no foruminformation is built new
              but i'm not sure

              Comment

              • patrickb
                New Member
                • Jun 2007
                • 27

                #8
                well, the reason I beleive using phpMyAdmin is not a good idea is that the entry in the thread table has the id of the firstpost and the firstpost has an id of the thread in the post table...kind of a circular reference.

                I haven't written the actual code yet, but the way i was thinking of doing it is create the thread in the thread table, then create the firstpost in the post table with the appropriate threadid and then update the thread entry with the id of the post once created.

                Obviously, i would let mySQL generate the the ids as to make sure they are no duplicates.

                Anything missing from this? The only thing that I see is for a brief moment, the thread will have no content...but this could be "fixed" by first setting it to invisible and only putting it visible when the first post is added...

                Comment

                • patrickb
                  New Member
                  • Jun 2007
                  • 27

                  #9
                  I just did a little bit more digging

                  and it would seem that the forum table would need to also be updated with the correct lastpost and lastthread information.

                  Am i missing something else?

                  Comment

                  • Zachery
                    Former vBulletin Support
                    • Jul 2002
                    • 59097

                    #10
                    You guys should really be discussing this at vBulletin.org

                    Comment

                    • patrickb
                      New Member
                      • Jun 2007
                      • 27

                      #11
                      I just started a new thread on vBulletin.org here

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...