Archive for June, 2007
For those of you know don’t know, I’m taking a vacation. I’ll be up at Tahoe for a week. I’ll post pictures if my camera doesn’t screw up again (like last time
)
See you guys back in a week! ![]()
A long while ago Chris had made a blog post on “Bitwise Operators“. Now, just to make it crystal clear, Bitwise Operators are not in MyBB 1.4. MyBB 1.2 was more focused on the code. MyBB 1.4 is focused more on features. Sorry folks, but there isn’t just enough time in the world!
However, I’d like to bring them up again and revisit the idea of what they are and how they work.
To re-iterate what Chris stated on his blog post, Bitwise operators are operators that work on a bit-level. You can assign “levels” to a number. This number indicates the level and later on, will be able to provide us with what users have what permissions. In turn you have an array of users each assigned a specific value.
We’ll use Chris’s crisp and clean example to show how bitwise operators work:
<?php
$notices['can_view'] = 1;
$notices['can_post_threads'] = 2;
$notices['can_post_replies'] = 4;
$notices['can_edit'] = 8;$testers[1] = 1;
$testers[2] = 5;
$testers[3] = 9;
$testers[4] = 14;foreach($testers as $key => $tester)
{
echo “$key”;
foreach($notices as $key => $notice)
{
if($tester & $notice)
{
echo ” - $key”;
}
}
echo “<br />”;
}
?>
Now this code will print out the following:
1 - can_view
2 - can_view - can_post_replies
3 - can_view - can_edit
4 - can_post_threads - can_post_replies - can_edit
Now you may be asking how we got that? In case you missed it, tester 4 has a value of 14. Now look at what the tester got: “can_post_threads - can_post_replies - can_edit". can_posts_threads has a value of 2, can_post_replies has a value of 4, and can_edit has a value of 8. Now what does that all add up to? 14! And so on and so forth; See? Simple!
This system can make our most difficult permissions night-mares as easy as the above example. If our course doesn’t change, I believe you will be seeing a lot more of Mr. Bitwise in 2.0 than ever before.
Search
About
You are currently browsing the Tikitiki’s Web blog weblog archives for June, 2007.
Longer entries are truncated. Click the headline of an entry to read it in its entirety.Latest
Archives
Categories
- Forums (3)
- General (3)
- Life (3)
- MyBB (19)
- NCAAbbs (1)
- Online (7)
- programming (5)
- School (2)
- Sports (1)
- Uncategorized (1)

