fix the forum widget for forums with custom perms
This commit is contained in:
parent
5b6e731f37
commit
e2660eaad3
@ -2049,7 +2049,7 @@ function ids_to_array($arr,$idx = 'id') {
|
|||||||
$t = array();
|
$t = array();
|
||||||
if($arr) {
|
if($arr) {
|
||||||
foreach($arr as $x) {
|
foreach($arr as $x) {
|
||||||
if(array_key_exists($idx,$x) && strlen($x[$idx]) && (! in_array($x[$idx],$t))) {
|
if(array_key_exists($idx,$x) && strlen($x[$idx]) && (! in_array($x[$idx],$t))) {
|
||||||
$t[] = $x[$idx];
|
$t[] = $x[$idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2060,12 +2060,15 @@ function ids_to_array($arr,$idx = 'id') {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ids_to_querystr($arr,$idx = 'id') {
|
function ids_to_querystr($arr,$idx = 'id',$quote = false) {
|
||||||
$t = array();
|
$t = array();
|
||||||
if($arr) {
|
if($arr) {
|
||||||
foreach($arr as $x) {
|
foreach($arr as $x) {
|
||||||
if(! in_array($x[$idx],$t)) {
|
if(! in_array($x[$idx],$t)) {
|
||||||
$t[] = $x[$idx];
|
if($quote)
|
||||||
|
$t[] = "'" . dbesc($x[$idx]) . "'";
|
||||||
|
else
|
||||||
|
$t[] = $x[$idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,14 +1473,23 @@ function widget_forums($arr) {
|
|||||||
|
|
||||||
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
|
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
|
||||||
|
|
||||||
/**
|
$xf = false;
|
||||||
* 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 ",
|
$x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = 0",
|
||||||
|
intval(local_channel())
|
||||||
|
);
|
||||||
|
if($x1) {
|
||||||
|
$xc = ids_to_querystr($x1,'xchan',true);
|
||||||
|
$x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = 1 and xchan in (" . $xc . ") ",
|
||||||
|
intval(local_channel())
|
||||||
|
);
|
||||||
|
if($x2)
|
||||||
|
$xf = ids_to_querystr($x2,'xchan',true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 ");
|
||||||
|
|
||||||
|
$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_deleted = 0 and abook_channel = %d $sql_extra order by xchan_name $limit ",
|
||||||
intval(local_channel())
|
intval(local_channel())
|
||||||
);
|
);
|
||||||
if(! $r1)
|
if(! $r1)
|
||||||
|
Reference in New Issue
Block a user