aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-12 21:47:24 -0700
committerredmatrix <git@macgirvin.com>2016-07-12 21:47:24 -0700
commitf4e4e734de001de50b2a1a3119997b444bf12134 (patch)
treeec7d33b651aa7da3d6edc3b9026bb351fadb6da2 /include
parent6424bac47ce7f81991d23d2407cbb4c08dbfdf69 (diff)
downloadvolse-hubzilla-f4e4e734de001de50b2a1a3119997b444bf12134.tar.gz
volse-hubzilla-f4e4e734de001de50b2a1a3119997b444bf12134.tar.bz2
volse-hubzilla-f4e4e734de001de50b2a1a3119997b444bf12134.zip
more work on perms
Diffstat (limited to 'include')
-rw-r--r--include/security.php41
-rw-r--r--include/widgets.php11
2 files changed, 34 insertions, 18 deletions
diff --git a/include/security.php b/include/security.php
index 212690d91..2ab6bf075 100644
--- a/include/security.php
+++ b/include/security.php
@@ -89,6 +89,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
*
* @return bool|array false or channel record of the new channel
*/
+
function change_channel($change_channel) {
$ret = false;
@@ -438,14 +439,19 @@ function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) {
$random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : '');
if(local_channel())
$ret[] = local_channel();
- $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 $random_sql $limit_sql ",
- intval($perms),
- intval(PAGE_ADULT|PAGE_CENSORED)
+ $x = q("select uid from pconfig where cat = 'perm_limits' and k = 'view_stream' and ( v & %d ) > 0 ",
+ intval($perms)
);
- if($r) {
- foreach($r as $rr)
- if(! in_array($rr['channel_id'], $ret))
- $ret[] = $rr['channel_id'];
+ if($x) {
+ $ids = ids_to_querystr($x,'uid');
+ $r = q("select channel_id from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 $random_sql $limit_sql ",
+ intval(PAGE_ADULT|PAGE_CENSORED)
+ );
+ if($r) {
+ foreach($r as $rr)
+ if(! in_array($rr['channel_id'], $ret))
+ $ret[] = $rr['channel_id'];
+ }
}
$str = '';
@@ -471,16 +477,21 @@ function stream_perms_xchans($perms = NULL ) {
if(local_channel())
$ret[] = get_observer_hash();
- $r = q("select channel_hash from channel where channel_r_stream > 0 and (channel_r_stream & %d)>0 and not (channel_pageflags & %d)>0 and channel_system = 0 and channel_removed = 0 ",
- intval($perms),
- intval(PAGE_ADULT|PAGE_CENSORED)
+ $x = q("select uid from pconfig where cat = 'perm_limits' and k = 'view_stream' and ( v & %d ) > 0 ",
+ intval($perms)
);
- if($r) {
- foreach($r as $rr)
- if(! in_array($rr['channel_hash'], $ret))
- $ret[] = $rr['channel_hash'];
- }
+ if($x) {
+ $ids = ids_to_querystr($x,'uid');
+ $r = q("select channel_hash from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 ",
+ intval(PAGE_ADULT|PAGE_CENSORED)
+ );
+ if($r) {
+ foreach($r as $rr)
+ if(! in_array($rr['channel_hash'], $ret))
+ $ret[] = $rr['channel_hash'];
+ }
+ }
$str = '';
if($ret) {
foreach($ret as $rr) {
diff --git a/include/widgets.php b/include/widgets.php
index 2d4d5b799..dbcaef409 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1347,9 +1347,14 @@ function widget_forums($arr) {
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
- $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and xchan_deleted = 0 and abook_channel = %d order by xchan_name $limit ",
- intval(PERMS_W_TAGWALL),
- intval(PERMS_W_STREAM),
+ /**
+ * We used to try and find public forums with custom permissions by checking to see if
+ * send_stream was false and tag_deliver was true. However with the newer extensible
+ * permissions infrastructure this makes for a very complicated query. Now we're only
+ * checking channels that report themselves specifically as pubforums
+ */
+
+ $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_pubforum = 1 and xchan_deleted = 0 and abook_channel = %d order by xchan_name $limit ",
intval(local_channel())
);
if(! $r1)