Jesteś osobą która raczej PHP zna więc pozwól, że pominę tłumaczenia i wkleję fragmnet klasy z własnego cmsu:
<?php
static public function encodeBitmask
($uprawnieniaAsoc,$tabelaNazw){ $liczba = 0;
while($ile--){
$liczba = $liczba<<1;
if($uprawnieniaAsoc[$tabelaNazw[$ile]])$liczba=$liczba+1;
}
return $liczba;
}
static public function decodeBitmask
($liczba,$tabelaNazw){ $uprawnieniaAsoc = array(); foreach($tabelaNazw as $indeks){
if($liczba&1)$uprawnieniaAsoc[$indeks]=true;
else $uprawnieniaAsoc[$indeks]=false;
$liczba = $liczba>>1;
}
return $uprawnieniaAsoc;
}
static public function checkGrpActionRight
($liczba,$uprawnienie) {
if($id===FALSE)return false;
$liczba=$liczba>>$id;
//var_dump($liczba); return;
if($liczba&1)return true;
return false;
}
"user" => array("userLogin", "comment", "adminLogin"), //General right like login "news" => array("list", "listMore", "add", "editOwn", "editOth", "delOwn", "delOth"), //News "ncats" => array("list", "add", "edit", "del"), //News categories "arts" => array("list", "listMore", "add", "publish", "editOwn", "editOth", "delOwn", "delOth"), //Articles "acats" => array("list", "add", "edit", "del"), //Articles categories "spgs" => array("list", "listMore", "add", "editOwn", "editOth", "delOwn", "delOth"), //Subpages "menu" => array("list", "add", "edit", "move", "del"), //Menu "paths" => array("list", "add", "edit", "del"), //Short paths "usrs" => array("list", "add", "edit", "del"), //Users "ugrps" => array("list", "add", "edit", "del"), //User groups "plgs" => array("list", "admin"), //Plugins "sets" => array("list", "edit"), //Settings "mtce" => array("list", "dbBckLst", "dbBckMke", "dbBckDel", "dbBckRes", "mMde", "upView", "upRev", "upMke", "massView", "massPrp", "massSnd", "fPwdCh", "bugRp") //Maintence tab );
static public function bmask2Arr
($arr) { foreach($arr as $key => $val) {
if($val != "" && !is_array($val)) { //You cant use empty() here bcs $val can be (int) 0 $out[$key] = self::decodeBitmask($val, self::$bitmaskRights[$key]);
}
}
return $out;
}
static public function arr2bmask
($arr) { //Translates array to bitmask foreach($arr as $key => $val) {
if(!empty($arr["news"])&&is_array
($arr["news"])) $out[$key] = self::encodeBitmask($val, self::$bitmaskRights[$key]);
}
return $out;
}
static public function convertRightsArr
($groupsData) { //Convert 1-dimissional array of rights to standard format ready to use with arr2bmask() method, for exsample look info adminPanel class, method saveGroup() and ajax.groups.php file (js code, static public function saveGroup()) $trTable = array(); //For translate table geenration
foreach(self::$bitmaskRights as $module => $perms) {
$tmp = &$trTable[$module];
foreach(self::$bitmaskRights[$module] as $pname) {
$value = each($groupsData); if($value === false) return false; //'each()' reach end of data last time but there are more avaible keys to fill in $bitmaskRights, so data is invalid [incomplate]
$tmp[$pname] = $value["value"];
}
}
return $trTable;
}
?>
Co prawda burdelasty ale wiadomo o co chodzi

U mnie tabela uprawnień wygląda tak:

Gdybyś potrzbował jakiś objaśnień do kodu wal śmiało - tu lub na GG/PW.