X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fnetwork.php;h=30e31cea3c6ec579379b7b44884c90eb9b0ec05d;hb=6c341962648b73c935c2de26996b07332b776a1f;hp=a71447e5e5f9bbf5af8fe002d47f7195edf6ae74;hpb=070aa016e0915c6bba9326a94f7394acd2b21e7f;p=friendica.git diff --git a/mod/network.php b/mod/network.php index a71447e5e5..30e31cea3c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -24,6 +24,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Profile; +use Friendica\Model\Term; use Friendica\Module\Login; use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy as ProxyUtils; @@ -314,7 +315,7 @@ function networkSetSeen($condition) $unseen = Item::exists($condition); if ($unseen) { - $r = Item::update(['unseen' => false], $condition); + Item::update(['unseen' => false], $condition); } } @@ -407,12 +408,6 @@ function networkFlatView(App $a, $update = 0) // Rawmode is used for fetching new content at the end of the page $rawmode = (isset($_GET['mode']) && ($_GET['mode'] == 'raw')); - if (isset($_GET['last_id'])) { - $last_id = intval($_GET['last_id']); - } else { - $last_id = 0; - } - $o = ''; $file = defaults($_GET, 'file', ''); @@ -449,14 +444,15 @@ function networkFlatView(App $a, $update = 0) $pager = new Pager($a->query_string); - /// @TODO Figure out why this variable is unused - $pager_sql = networkPager($a, $pager, $update); + networkPager($a, $pager, $update); + + $item_params = ['order' => ['id' => true]]; if (strlen($file)) { - $condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?", - $file, TERM_OBJ_POST, TERM_FILE, local_user()]; - $params = ['order' => ['tid' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; - $result = DBA::select('term', ['oid'], $condition); + $term_condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?", + $file, Term::OBJECT_TYPE_POST, Term::FILE, local_user()]; + $term_params = ['order' => ['tid' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; + $result = DBA::select('term', ['oid'], $term_condition, $term_params); $posts = []; while ($term = DBA::fetch($result)) { @@ -467,18 +463,16 @@ function networkFlatView(App $a, $update = 0) if (count($posts) == 0) { return ''; } - $condition = ['uid' => local_user(), 'id' => $posts]; + $item_condition = ['uid' => local_user(), 'id' => $posts]; } else { - $condition = ['uid' => local_user()]; + $item_condition = ['uid' => local_user()]; + $item_params['limit'] = [$pager->getStart(), $pager->getItemsPerPage()]; + + networkSetSeen(['unseen' => true, 'uid' => local_user()]); } - $params = ['order' => ['id' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; - $result = Item::selectForUser(local_user(), [], $condition, $params); + $result = Item::selectForUser(local_user(), [], $item_condition, $item_params); $items = Item::inArray($result); - - $condition = ['unseen' => true, 'uid' => local_user()]; - networkSetSeen($condition); - $o .= networkConversation($a, $items, $pager, 'network-new', $update); return $o; @@ -532,7 +526,7 @@ function networkThreadedView(App $a, $update, $parent) } } elseif (intval($a->argv[$x])) { $gid = intval($a->argv[$x]); - $default_permissions = ['allow_gid' => '<' . $gid . '>']; + $default_permissions['allow_gid'] = [$gid]; } } } @@ -546,20 +540,28 @@ function networkThreadedView(App $a, $update, $parent) $order = Strings::escapeTags(defaults($_GET, 'order', 'comment')); $nets = defaults($_GET, 'nets' , ''); + $allowedCids = []; if ($cid) { - $default_permissions = ['allow_cid' => '<' . intval($cid) . '>']; + $allowedCids[] = (int) $cid; + } elseif ($nets) { + $condition = [ + 'uid' => local_user(), + 'network' => $nets, + 'self' => false, + 'blocked' => false, + 'pending' => false, + 'archive' => false, + 'rel' => [Contact::SHARING, Contact::FRIEND], + ]; + $contactStmt = DBA::select('contact', ['id'], $condition); + while ($contact = DBA::fetch($contactStmt)) { + $allowedCids[] = (int) $contact['id']; + } + DBA::close($contactStmt); } - if ($nets) { - $r = DBA::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]); - - $str = ''; - while ($rr = DBA::fetch($r)) { - $str .= '<' . $rr['id'] . '>'; - } - if (strlen($str)) { - $default_permissions = ['allow_cid' => $str]; - } + if (count($allowedCids)) { + $default_permissions['allow_cid'] = $allowedCids; } if (!$update && !$rawmode) { @@ -621,7 +623,6 @@ function networkThreadedView(App $a, $update, $parent) $sql_extra3 = ''; $sql_table = '`thread`'; $sql_parent = '`iid`'; - $sql_order = ''; if ($update) { $sql_table = '`item`';