Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // ============================================================================ //
- // ============================================================================ //
- /**
- * Проверяет досуп пользователь с USER_ID к правилу $access_type
- * $access_type like "comments/delete" or "photo/edit"
- * @param string $access_type
- * @return bool
- */
- public static function isUserCanById($access_type, $user_id){
- $inDB = cmsDatabase::getInstance();
- //получем группу пользователя
- if ($user_id) {
- $sql = "SELECT u.group_id, g.access
- FROM cms_users u
- LEFT JOIN cms_user_groups g ON u.group_id = g.id
- WHERE u.id = $user_id LIMIT 1";
- $result = $inDB->query($sql);
- if ($inDB->num_rows($result)){
- $usr = $inDB->fetch_assoc($result);
- return in_array($access_type, $usr['access']);
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- //usage
- if(cmsUser::isUserCanById('users/paybutton', $usr['id'])){
- $show_pay_button = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement