Add display of a thread to channel module using channel/<channel>/?mid=<mid>
This commit is contained in:
parent
73102f0c26
commit
9762b264cc
@ -47,6 +47,8 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
|
|
||||||
$category = $datequery = $datequery2 = '';
|
$category = $datequery = $datequery2 = '';
|
||||||
|
|
||||||
|
$mid = $_GET['mid'];
|
||||||
|
|
||||||
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
|
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
|
||||||
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
|
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
|
||||||
|
|
||||||
@ -102,7 +104,7 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if($perms['post_wall']) {
|
if($perms['post_wall'] && (!$mid)) {
|
||||||
|
|
||||||
$x = array(
|
$x = array(
|
||||||
'is_owner' => $is_owner,
|
'is_owner' => $is_owner,
|
||||||
@ -132,19 +134,24 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
|
|
||||||
|
|
||||||
if(($update) && (! $load)) {
|
if(($update) && (! $load)) {
|
||||||
|
if ($mid) {
|
||||||
$r = q("SELECT distinct parent AS `item_id` from item
|
$r = q("SELECT parent AS item_id from item where mid = '%s' limit 1",
|
||||||
left join abook on item.author_xchan = abook.abook_xchan
|
dbesc($mid)
|
||||||
WHERE uid = %d AND item_restrict = 0
|
);
|
||||||
AND (item_flags & %d) AND ( item_flags & %d )
|
} else {
|
||||||
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
|
$r = q("SELECT distinct parent AS `item_id` from item
|
||||||
$sql_extra
|
left join abook on item.author_xchan = abook.abook_xchan
|
||||||
ORDER BY created DESC",
|
WHERE uid = %d AND item_restrict = 0
|
||||||
intval($a->profile['profile_uid']),
|
AND (item_flags & %d) AND ( item_flags & %d )
|
||||||
intval(ITEM_WALL),
|
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
|
||||||
intval(ITEM_UNSEEN),
|
$sql_extra
|
||||||
intval(ABOOK_FLAG_BLOCKED)
|
ORDER BY created DESC",
|
||||||
);
|
intval($a->profile['profile_uid']),
|
||||||
|
intval(ITEM_WALL),
|
||||||
|
intval(ITEM_UNSEEN),
|
||||||
|
intval(ABOOK_FLAG_BLOCKED)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -166,19 +173,24 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||||
|
|
||||||
if($load || ($_COOKIE['jsAvailable'] != 1)) {
|
if($load || ($_COOKIE['jsAvailable'] != 1)) {
|
||||||
$r = q("SELECT distinct id AS item_id FROM item
|
if ($mid) {
|
||||||
left join abook on item.author_xchan = abook.abook_xchan
|
$r = q("SELECT parent AS item_id from item where mid = '%s' limit 1",
|
||||||
WHERE uid = %d AND item_restrict = 0
|
dbesc($mid)
|
||||||
AND (item_flags & %d) and (item_flags & %d)
|
);
|
||||||
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
|
} else {
|
||||||
$sql_extra $sql_extra2
|
$r = q("SELECT distinct id AS item_id FROM item
|
||||||
ORDER BY created DESC $pager_sql ",
|
left join abook on item.author_xchan = abook.abook_xchan
|
||||||
intval($a->profile['profile_uid']),
|
WHERE uid = %d AND item_restrict = 0
|
||||||
intval(ITEM_WALL),
|
AND (item_flags & %d) and (item_flags & %d)
|
||||||
intval(ITEM_THREAD_TOP),
|
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
|
||||||
intval(ABOOK_FLAG_BLOCKED)
|
$sql_extra $sql_extra2
|
||||||
|
ORDER BY created DESC $pager_sql ",
|
||||||
);
|
intval($a->profile['profile_uid']),
|
||||||
|
intval(ITEM_WALL),
|
||||||
|
intval(ITEM_THREAD_TOP),
|
||||||
|
intval(ABOOK_FLAG_BLOCKED)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$r = array();
|
$r = array();
|
||||||
@ -202,6 +214,14 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
$items = fetch_post_tags($items, true);
|
$items = fetch_post_tags($items, true);
|
||||||
$items = conv_sort($items,'created');
|
$items = conv_sort($items,'created');
|
||||||
|
|
||||||
|
if ($mid && (! count($items))) {
|
||||||
|
// This will happen if channel is called with a mid from another
|
||||||
|
// channel, if we don't have sufficient permissions to view the
|
||||||
|
// item, or if it doesn't exist.
|
||||||
|
// Do we need separate error messages for that?
|
||||||
|
notice( t('Item not found.') . EOL);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$items = array();
|
$items = array();
|
||||||
}
|
}
|
||||||
@ -235,7 +255,7 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
'$order' => '',
|
'$order' => '',
|
||||||
'$file' => '',
|
'$file' => '',
|
||||||
'$cats' => (($category) ? $category : ''),
|
'$cats' => (($category) ? $category : ''),
|
||||||
'$mid' => '',
|
'$mid' => $mid,
|
||||||
'$dend' => $datequery,
|
'$dend' => $datequery,
|
||||||
'$dbegin' => $datequery2
|
'$dbegin' => $datequery2
|
||||||
));
|
));
|
||||||
|
Reference in New Issue
Block a user