Integrating with vBulletin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • drisley
    Member
    • Jul 2000
    • 39
    • 3.8.x

    Integrating with vBulletin

    I am working on a CMS which is to integrate with VB. What I am doing is pulling in forums from the VB database into the CMS database so that the user can choose which forums for the CMS to post threads to. However, the problem I am having is that I don't know how to differntiate between a forum which acts as a category and one which allows posts. Obviously posting a thread to a forum which is a category is a waste because it would never show up.

    I see the "forums" table has a "options" field which seems to contain settings for that forum. However, it is just an integer value and I have avsolutely no idea how to decipher that. How can I look at this number and determine what the settings are for that forum?

    Thanks for some insight.
    David Risley
    http://www.davidrisley.com
    http://www.pcmech.com
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    The options are stored using a binary scheme. For example, this query will fetch all forum records that are not categories:

    Code:
    SELECT *
    FROM forum
    WHERE options & 4

    Comment

    • drisley
      Member
      • Jul 2000
      • 39
      • 3.8.x

      #3
      Thanks. How can I find out how to work with this options field? For example, how did you know that it was 4 (other than the fact that you work with VB, of course)?
      David Risley
      http://www.davidrisley.com
      http://www.pcmech.com

      Comment

      • Jake Bunce
        Senior Member
        • Dec 2000
        • 46598
        • 3.6.x

        #4
        includes/xml/bitfield_vbulletin.xml

        Comment

        • feldon23
          Senior Member
          • Nov 2001
          • 11291
          • 3.7.x

          #5
          vBulletin makes extensive use of bitfields. Instead of having a separate table column in MySQL for each option, you can store several options in one column by use of bitfields. The values are stored as a potentially large binary number. Without turning into a full lesson on the difference between binary and decimal, let's see what I can explain...

          Imagine that you have 8 true/false options (switches). The first switch could be Users can post Attachments. The second switch could be Users can make Sticky threads, etc. In binary, those 8 light switches all set to No or OFF would look like this:
          00000000

          the typical forum with 4 settings turned ON and 4 settings turned OFF might look like:
          10010110

          Now, let's turn to decimal. When you mix and match numbers of two different bases, you append the base. 100b (binary) and 100d (decimal) are two entirely different numbers.

          In decimal, each digit/place/column multiplies by 10. For example:
          4,302d means (4 x 1000) + (4 x 100) + (4 x 10) + (4 x 1)

          In binary, each digit/place/column multiplies by 2. For example:
          10010110b means (1 x 128) + (0 x 64) + (0 x 32) + (1 x 16) + (0 x 8) + (1 x 4) + (1 x 2) + (0 x 1).

          Converted into decimal:
          10010110b would be 150d.

          So when you pull the 'options' table for that forum, you might see a value of 279. But in actual practice, it's binary 100010111 which specifies 9 options and their on/off status. Here's an example of 24 options alternating between ON and OFF:

          101010101010101010101010b

          (1 x 8,388,608) + (0 x 4,194,304) + (1 x 2,097,152) + (0 x 1,048,576) +
          (1 x 524,288) + (0 x 262,144) + (1 x 131,072) + (0 x 65,536) +
          (1 x 32,768) + (0 x 16,384) + (1 x 8,192) + (0 x 4,096) +
          (1 x 2,056) + (0 x 1,024) + (1 x 512) + (0 x 256)
          (1 x 128) + (0 x 64) + (1 x 32) + (0 x 16) +
          (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1) =

          11,184,810d


          And as Jake so helpfully posted, the bitfields used by vBulletin can be found in /includes/xml/bitfield_vbulletin.xml

          P.S. To read the bitfields presently set, instead of querying the database, you look at the value of variables like $vbulletin->bf_misc_forumoptions[].
          Last edited by feldon23; Fri 10 Feb '06, 1:44pm.

          Comment

          • Jake Bunce
            Senior Member
            • Dec 2000
            • 46598
            • 3.6.x

            #6
            Show off.

            The second post in this thread details another application of binary fields.

            Comment

            • feldon23
              Senior Member
              • Nov 2001
              • 11291
              • 3.7.x

              #7
              Your explanation in that thread is more relevant than my math lesson.

              Comment

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