| 43 | | // query the database directly: |
|---|
| 44 | | $where=run("users:access_level_sql_where",$user_id); |
|---|
| | 44 | |
|---|
| | 45 | if (isadmin($user_id)) { |
|---|
| | 46 | $where = ' 1=1 '; // allow admins to access any object |
|---|
| | 47 | } else { |
|---|
| | 48 | if (empty($run_result)) { |
|---|
| | 49 | $where = ''; |
|---|
| | 50 | } else { |
|---|
| | 51 | $where .= ' OR '; |
|---|
| | 52 | } |
|---|
| | 53 | |
|---|
| | 54 | $where .= " owner = " . $user_id . " "; |
|---|
| | 55 | $where .= " OR access IN ('PUBLIC', 'LOGGED_IN', 'user" . $user_id . "') "; |
|---|
| | 56 | } |
|---|
| | 57 | |
|---|
| | 58 | |
|---|
| | 59 | $communitieslist = array(); |
|---|
| | 60 | if ($communities = get_records_sql("SELECT u.* FROM ".$CFG->prefix."friends f |
|---|
| | 61 | JOIN ".$CFG->prefix."users u ON u.ident = f.friend |
|---|
| | 62 | WHERE u.user_type = 'community' |
|---|
| | 63 | AND u.owner <> ".$user_id." |
|---|
| | 64 | AND f.owner = ".$user_id)) { |
|---|
| | 65 | |
|---|
| | 66 | foreach($communities as $community) { |
|---|
| | 67 | $communitieslist[] = $community->ident; |
|---|
| | 68 | } |
|---|
| | 69 | } |
|---|
| | 70 | if ($communities = get_records('users','owner',$user_id)) { |
|---|
| | 71 | foreach($communities as $community) { |
|---|
| | 72 | $communitieslist[] = $community->ident; |
|---|
| | 73 | } |
|---|
| | 74 | } |
|---|
| | 75 | if (count($communitieslist) > 0) { |
|---|
| | 76 | $communitieslist = array_unique($communitieslist); |
|---|
| | 77 | if (!empty($where)) |
|---|
| | 78 | $where .= " OR"; |
|---|
| | 79 | $where .= " access IN ('community" . implode("', 'community", $communitieslist) . "') "; |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 82 | |
|---|