allow zotfeed to create a firehose of a site.
This commit is contained in:
parent
bd7be38da5
commit
79f5fd8e2a
@ -109,6 +109,15 @@ function get_sys_channel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_sys_channel($channel_id) {
|
||||
$r = q("select channel_pageflags from channel where channel_id = %d limit 1",
|
||||
intval($channel_id)
|
||||
);
|
||||
if(($r) && ($r[0]['channel_pageflags'] & PAGE_SYSTEM))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @channel_total()
|
||||
|
@ -3763,24 +3763,33 @@ function zot_feed($uid,$observer_xchan,$mindate) {
|
||||
|
||||
$items = array();
|
||||
|
||||
$r = q("SELECT item.*, item.id as item_id from item
|
||||
WHERE uid = %d AND item_restrict = 0 and id = parent
|
||||
AND (item_flags & %d)
|
||||
$sql_extra ORDER BY created ASC $limit",
|
||||
intval($uid),
|
||||
intval(ITEM_WALL)
|
||||
);
|
||||
if($r) {
|
||||
if(is_sys_channel($uid)) {
|
||||
$r = q("SELECT item.*, item.id as item_id from item
|
||||
WHERE uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 and id = parent
|
||||
AND (item_flags & %d)
|
||||
$sql_extra ORDER BY created ASC $limit",
|
||||
intval($uid),
|
||||
intval(ITEM_WALL)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$r = q("SELECT item.*, item.id as item_id from item
|
||||
WHERE uid = %d AND item_restrict = 0 and id = parent
|
||||
AND (item_flags & %d)
|
||||
$sql_extra ORDER BY created ASC $limit",
|
||||
intval($uid),
|
||||
intval(ITEM_WALL)
|
||||
);
|
||||
}
|
||||
|
||||
if($r) {
|
||||
$parents_str = ids_to_querystr($r,'id');
|
||||
|
||||
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
|
||||
WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
|
||||
WHERE `item`.`item_restrict` = 0
|
||||
AND `item`.`parent` IN ( %s ) ",
|
||||
intval($uid),
|
||||
dbesc($parents_str)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if($items) {
|
||||
|
@ -346,8 +346,9 @@ 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 > 0 and channel_r_stream <= %d",
|
||||
intval($perms_min)
|
||||
$r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d) ",
|
||||
intval($perms_min),
|
||||
intval(PAGE_ADULT)
|
||||
);
|
||||
if($r)
|
||||
foreach($r as $rr)
|
||||
@ -361,7 +362,7 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) {
|
||||
$str .= ',';
|
||||
$str .= intval($rr);
|
||||
}
|
||||
logger('stream_perms_api_uids: ' . $str);
|
||||
logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
|
||||
return $str;
|
||||
}
|
||||
|
||||
@ -370,8 +371,9 @@ function stream_perms_xchans($perms_min = PERMS_SITE) {
|
||||
if(local_user())
|
||||
$ret[] = get_observer_hash();
|
||||
|
||||
$r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d",
|
||||
intval($perms_min)
|
||||
$r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d)",
|
||||
intval($perms_min),
|
||||
intval(PAGE_ADULT)
|
||||
);
|
||||
if($r)
|
||||
foreach($r as $rr)
|
||||
@ -385,6 +387,6 @@ function stream_perms_xchans($perms_min = PERMS_SITE) {
|
||||
$str .= ',';
|
||||
$str .= "'" . dbesc($rr) . "'";
|
||||
}
|
||||
logger('stream_perms_xchans: ' . $str);
|
||||
logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG);
|
||||
return $str;
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ function zotfeed_init(&$a) {
|
||||
dbesc(argv(1))
|
||||
);
|
||||
}
|
||||
else {
|
||||
$x = get_sys_channel();
|
||||
if($x)
|
||||
$r = array($x);
|
||||
}
|
||||
if(! $r) {
|
||||
$result['message'] = 'Channel not found.';
|
||||
json_return_and_die($result);
|
||||
|
@ -1 +1 @@
|
||||
2014-03-25.627
|
||||
2014-03-26.628
|
||||
|
Reference in New Issue
Block a user