diff options
author | MicMee <michael@meer.name> | 2013-01-23 04:55:09 -0800 |
---|---|---|
committer | MicMee <michael@meer.name> | 2013-01-23 04:55:09 -0800 |
commit | 9996d5ee9b7196774cb1d95334507c20f1883428 (patch) | |
tree | 4c10561076f16d9f18b7b5943bc1930814c6d52c /include/security.php | |
parent | fca354aa463e84b67fe62e4067905e8f363c0e80 (diff) | |
parent | 0b18dd15c5377da121f0fb781c0530ca0d328eb9 (diff) | |
download | volse-hubzilla-9996d5ee9b7196774cb1d95334507c20f1883428.tar.gz volse-hubzilla-9996d5ee9b7196774cb1d95334507c20f1883428.tar.bz2 volse-hubzilla-9996d5ee9b7196774cb1d95334507c20f1883428.zip |
Merge pull request #1 from friendica/master
get changes
Diffstat (limited to 'include/security.php')
-rw-r--r-- | include/security.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/security.php b/include/security.php index 0783a3c20..f28174153 100644 --- a/include/security.php +++ b/include/security.php @@ -236,7 +236,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) * default permissions - anonymous user */ - $sql = " AND not (item_flags & " . ITEM_PRIVATE . ") "; + $sql = " AND not item_private "; /** @@ -349,7 +349,7 @@ if(! function_exists('init_groups_visitor')) { function init_groups_visitor($contact_id) { $groups = array(); $r = q("SELECT gid FROM group_member WHERE xchan = '%s' ", - intval($contact_id) + dbesc($contact_id) ); if(count($r)) { foreach($r as $rr) @@ -359,3 +359,36 @@ function init_groups_visitor($contact_id) { }} + + + +// This is used to determine which uid have posts which are visible to the logged in user (from the API) for the +// public_timeline, and we can use this in a community page by making $perms_min = PERMS_NETWORK unless logged in. +// Collect uids of everybody on this site who has opened their posts to everybody on this site (or greater visibility) +// We always include yourself if logged in because you can always see your own posts +// resolving granular permissions for the observer against every person and every post on the site +// will likely be too expensive. +// Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query + +function stream_perms_api_uids($perms_min = PERMS_SITE) { + $ret = array(); + if(local_user()) + $ret[] = local_user(); + $r = q("select channel_id from channel where channel_r_stream <= %d", + intval($perms_min) + ); + if($r) + foreach($r as $rr) + if(! in_array($rr['channel_id'],$ret)) + $ret[] = $rr['channel_id']; + + $str = ''; + if($ret) + foreach($ret as $rr) { + if($str) + $str .= ','; + $str .= intval($rr); + } + return $str; +} + |