aboutsummaryrefslogtreecommitdiffstats
path: root/mod/network.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-07 18:44:06 -0700
committerfriendica <info@friendica.com>2012-10-07 18:44:06 -0700
commita56c0425e6f80e77a1e52b13cd5a14cb6e838b9a (patch)
tree181d3e58294b5bd9c62307bd0a5b2447b3f3c625 /mod/network.php
parentc612253627019c146b8a49d6f927b475cac8be2f (diff)
downloadvolse-hubzilla-a56c0425e6f80e77a1e52b13cd5a14cb6e838b9a.tar.gz
volse-hubzilla-a56c0425e6f80e77a1e52b13cd5a14cb6e838b9a.tar.bz2
volse-hubzilla-a56c0425e6f80e77a1e52b13cd5a14cb6e838b9a.zip
start fixing all the item queries
Diffstat (limited to 'mod/network.php')
-rw-r--r--mod/network.php43
1 files changed, 19 insertions, 24 deletions
diff --git a/mod/network.php b/mod/network.php
index 18d5b8e11..3f06ccb3d 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -414,8 +414,8 @@ function network_content(&$a, $update = 0, $load = false) {
$sql_options = (($star) ? " and starred = 1 " : '');
$sql_nets = '';
-
- $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
+// fixme
+ $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE id = parent $sql_options ) ";
if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@@ -604,15 +604,12 @@ function network_content(&$a, $update = 0, $load = false) {
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1
- AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+ o.xchan_name as oname, o.xchan_photo as ophoto, o.xchan_profile as ourl,
+ a.xchan_name as aname, a.xchan_photo as aphoto, a.xchan_profile as aurl,
+ FROM `item` left join xchan as o on xchan_hash = owner_xchan left join xchan as a
+ on xchan_hash = author_xchan
+ WHERE `item`.`uid` = %d AND item_restrict = 0
$simple_update
- AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_nets
ORDER BY `item`.`received` DESC $pager_sql ",
intval($_SESSION['uid'])
@@ -647,10 +644,8 @@ function network_content(&$a, $update = 0, $load = false) {
}
else {
- $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
- FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $r = q("SELECT `item`.`id` AS `item_id`
+ FROM `item` WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
AND `item`.`parent` = `item`.`id`
$sql_extra3 $sql_extra $sql_nets
ORDER BY `item`.$ordering DESC $pager_sql ",
@@ -661,18 +656,16 @@ function network_content(&$a, $update = 0, $load = false) {
// Then fetch all the children of the parents that are on this page
- if(count($r)) {
+ if($r && count($r)) {
$parents_str = ids_to_querystr($r,'item_id');
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, `contact`
- WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id`
- AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ o.xchan_name as oname, o.xchan_photo as ophoto, o.xchan_profile as ourl,
+ a.xchan_name as aname, a.xchan_photo as aphoto, a.xchan_profile as aurl,
+ FROM `item` left join xchan as o on xchan_hash = owner_xchan left join xchan as a
+ on xchan_hash = author_xchan
+ WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
AND `item`.`parent` IN ( %s )
$sql_extra ",
intval(local_user()),
@@ -696,8 +689,10 @@ function network_content(&$a, $update = 0, $load = false) {
// at the top level network page just mark everything seen.
if((! $group) && (! $cid) && (! $star)) {
- $r = q("UPDATE `item` SET `unseen` = 0
- WHERE `unseen` = 1 AND `uid` = %d",
+ $r = q("UPDATE `item` SET item_flags = item_flags & (! %d)
+ WHERE item_flags & %d AND `uid` = %d",
+ intval(ITEM_UNSEEN),
+ intval(ITEM_UNSEEN),
intval(local_user())
);
}