bcaa11fd495405310cfca324038dbc74d13e037e
[friendica.git/.git] / src / Module / Update / Network.php
1 <?php
2
3 namespace Friendica\Module\Update;
4
5 use Friendica\Core\System;
6 use Friendica\DI;
7 use Friendica\Model\Item;
8 use Friendica\Model\Post;
9 use Friendica\Module\Conversation\Network as NetworkModule;
10
11 class Network extends NetworkModule
12 {
13         public static function rawContent(array $parameters = [])
14         {
15                 if (!isset($_GET['p']) || !isset($_GET['item'])) {
16                         exit();
17                 }
18
19                 self::parseRequest($parameters, $_GET);
20
21                 $profile_uid = intval($_GET['p']);
22
23                 $o = '';
24
25                 if (!DI::pConfig()->get($profile_uid, 'system', 'no_auto_update') || ($_GET['force'] == 1)) {
26                         if (!empty($_GET['item'])) {
27                                 $item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
28                                 $parent = $item['parent'] ?? 0;
29                         } else {
30                                 $parent = 0;
31                         }
32
33                         $conditionFields = [];
34                         if (!empty($parent)) {
35                                 // Load only a single thread
36                                 $conditionFields['parent'] = $parent;
37                         } elseif (self::$order === 'received') {
38                                 // Only load new toplevel posts
39                                 $conditionFields['unseen'] = true;
40                                 $conditionFields['gravity'] = GRAVITY_PARENT;
41                         } else {
42                                 // Load all unseen items
43                                 $conditionFields['unseen'] = true;
44                         }
45
46                         $params = ['limit' => 100];
47                         $table = 'network-item-view';
48
49                         $items = self::getItems($table, $params, $conditionFields);
50
51                         if (self::$order === 'received') {
52                                 $ordering = '`received`';
53                         } else {
54                                 $ordering = '`commented`';
55                         }
56
57                         $o = conversation(DI::app(), $items, 'network', $profile_uid, false, $ordering, local_user());
58                 }
59
60                 System::htmlUpdateExit($o);
61         }
62 }