Binary cross-permission micro php:
1. Multi-to-multi-cross scenario allocation;
2. new features of php-use of closures and use of the batch processing function array_walk/array_flip;
3. bitwise operations & use cases;
Use cases:
1. common addition, deletion, modification, and query (the n value of 2 is stored in the database );
2. authentication, third-party account binding, and multi-category selection;
Scene = $ scene; $ this-> case_list = $ this-> case_list (true); if ($ allow_value) {$ this-> allow_value = $ allow_value; $ this-> allow_list = $ this-> allow_list ($ allow_value, true) ;}// obtain the function case_list of all tasks ($ mode = false) {$ case_list = config ($ this-> scene, 'allow'); return $ mode? $ Case_list: array_keys ($ case_list);} // obtain the user task list function allow_list ($ allow_value = 0, $ mode = false) {$ buffer = array (); foreach ($ this-> case_list as $ key => $ value) {if ($ allow_value & pow (2, $ key-1 )) {$ buffer [$ key] = $ value ;}} return $ mode? $ Buffer: array_keys ($ buffer);} // calculate the allowed value function allow_value ($ allow_list = null) {if ($ allow_list = null) $ allow_list = $ this-> allow_list; array_walk ($ allow_list, function ($ value, $ key) use (& $ allow_list) {$ allow_list [$ key] = pow (2, $ value-1 );}); return array_sum ($ allow_list);} // Determine whether function is_allow ($ case) {$ case_list = array_flip ($ this-> case_list); return (bool) ($ this-> allow_value & pow (2, $ case_list [$ case]-1 ));}}
[access]1=add2=del3=read4=list5=mod6=detail7=pub8=collect9=like10=send[cert]1=email2=tel3=qq4=identity_card5=real_name6=business_license[bind]1=qq2=weibo3=taobao4=alipay5=renren6=weichat7=baidu