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