Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2010, 12:00 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Bitfield confusion

Hi there,

I'm trying to understand vBulletin's use of bitfields and this has confused me. If anyone can clear it up, I'd appreciate it:

Code:
<group name="forumpermissions">
  <bitfield name="canview" group="forum_viewing_permissions" phrase="can_view_forum" install="1,2,3,4,5,6,7">1</bitfield> 
  <bitfield name="canviewthreads" group="forum_viewing_permissions" phrase="can_view_threads" install="1,2,3,4,5,6,7">524288</bitfield> 
  <bitfield name="canviewothers" group="forum_viewing_permissions" phrase="can_view_others_threads" install="1,2,3,4,5,6,7">2</bitfield> 
  <bitfield name="cansearch" group="forum_searching_permissions" phrase="can_search_forums" install="1,2,3,4,5,6,7">4</bitfield> 
  <bitfield name="canemail" group="forum_viewing_permissions" phrase="can_use_email_to_friend" install="1,2,3,4,5,6,7">8</bitfield> 
  <bitfield name="canpostnew" group="post_thread_permissions" phrase="can_post_threads" install="2,5,6,7">16</bitfield> 
  <bitfield name="canreplyown" group="post_thread_permissions" phrase="can_reply_to_own_threads" install="2,5,6,7">32</bitfield> 
  <bitfield name="canreplyothers" group="post_thread_permissions" phrase="can_reply_to_others_threads" install="2,5,6,7">64</bitfield> 
  <bitfield name="caneditpost" group="post_thread_permissions" phrase="can_edit_own_posts" install="2,5,6,7">128</bitfield> 
  <bitfield name="candeletepost" group="post_thread_permissions" phrase="can_delete_own_posts" install="2,5,6,7">256</bitfield> 
  <bitfield name="candeletethread" group="post_thread_permissions" phrase="can_delete_own_threads" install="5,6">512</bitfield> 
  <bitfield name="canopenclose" group="post_thread_permissions" phrase="can_open_close_own_threads" install="5,6">1024</bitfield> 
  <bitfield name="canmove" group="post_thread_permissions" phrase="can_move_own_threads" install="5,6">2048</bitfield> 
  <bitfield name="cangetattachment" group="forum_viewing_permissions" phrase="can_download_attachments" install="2,5,6,7">4096</bitfield> 
  <bitfield name="canpostattachment" group="attachment_permissions" phrase="can_upload_attachments" install="2,5,6,7">8192</bitfield> 
  <bitfield name="attachlimit" intperm="true" group="attachment_permissions" phrase="space_in_bytes_attachlimit">1</bitfield> 
  <bitfield name="canpostpoll" group="poll_permissions" phrase="can_post_polls" install="2,5,6,7">16384</bitfield> 
  <bitfield name="canvote" group="poll_permissions" phrase="can_vote_on_polls" install="2,5,6,7">32768</bitfield> 
  <bitfield name="canthreadrate" group="post_thread_permissions" phrase="can_rate_threads" install="2,5,6,7">65536</bitfield> 
  <bitfield name="followforummoderation" group="post_thread_permissions" phrase="follow_forum_moderation_rules" install="1,2,3,4,5,6,7">131072</bitfield> 
  <bitfield name="canseedelnotice" group="forum_viewing_permissions" phrase="can_see_deletion_notices" install="5,6">262144</bitfield> 
  <bitfield name="cantagown" group="post_thread_permissions" phrase="can_tag_own_threads" install="2,5,6,7">1048576</bitfield> 
  <bitfield name="cantagothers" group="post_thread_permissions" phrase="can_tag_others_threads" install="2,5,6,7">2097152</bitfield> 
  <bitfield name="candeletetagown" group="post_thread_permissions" phrase="can_delete_tags_own_threads" install="5,6">4194304</bitfield> 
  <bitfield name="canseethumbnails" group="forum_viewing_permissions" phrase="can_see_thumbnails" install="2,5,6,7">8388608</bitfield> 
  </group>
Why does it go:
1, 524288, 2, 4, 8

I thought the generic method to go was: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc?
Reply With Quote
  #2  
Old 06-06-2010, 12:03 PM
borbole's Avatar
borbole borbole is offline
 
Join Date: Jan 2010
Posts: 2,559
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have a look at this article:

https://vborg.vbsupport.ru/showthrea...ht=permissions
Reply With Quote
  #3  
Old 06-06-2010, 12:05 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi borbole,

I've read that article, I just want to know why the format of the forumpermissions goes 1, 524288, 2, 4, 8 when the generic method is to go 1, 2, 4, 8, 16
Reply With Quote
  #4  
Old 06-06-2010, 12:52 PM
Guest190829
Guest
 
Posts: n/a
Default

You are correct, however, in terms of the XML file and the mechanics behind how vB parses the xml permissions data into a datastore array, the order doesn't matter. As long as the bitfield value is valid (and 524288 is), you won't run into problems.

From the looks of this, the reason that particular permission is placed out of order is for readability purposes; both 2 and 524288 deal with thread viewing permissions.
Reply With Quote
  #5  
Old 06-06-2010, 01:21 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahh, thanks for that Danny!

I didn't even think of that... I knew it went off of the numbers rather than the actual order, but I didn't expect it to be for readability purposes.
Reply With Quote
  #6  
Old 06-07-2010, 08:27 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It was added at a later stage, when 524288 was the first available number. For readability it was placed at that location in the XML file.

Keep in mind that all these values are already stored/used in the database (in case of an upgrade) so you can not simply renumber the options without also performing an upgrade of the values already in the database when upgrading a vB version.
Reply With Quote
  #7  
Old 06-07-2010, 02:31 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Marco,

I wasn't planning on changing anything anyway; I'm just trying to learn about bitfields!
Reply With Quote
Reply


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 12:07 PM.


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.04690 seconds
  • Memory Usage 2,224KB
  • 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
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (6)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete