1 | <?php |
||
31 | class Api |
||
32 | { |
||
33 | const DEFAULT_LIMIT = 30; |
||
34 | |||
35 | 5 | static public function get() { |
|
36 | 5 | $app = new AppInfo\Application(); |
|
37 | /** @var Data $data */ |
||
38 | 5 | $data = $app->getContainer()->query('ActivityData'); |
|
39 | |||
40 | 5 | $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
41 | 5 | $count = isset($_GET['count']) ? (int) $_GET['count'] : self::DEFAULT_LIMIT; |
|
42 | 5 | $user = $app->getContainer()->getServer()->getUserSession()->getUser()->getUID(); |
|
43 | |||
44 | 5 | if ($start !== 0) { |
|
45 | 2 | $start = self::getSinceFromOffset($user, $start); |
|
46 | 2 | } |
|
47 | |||
48 | 5 | $activities = $data->get( |
|
49 | 5 | $app->getContainer()->query('GroupHelper'), |
|
50 | 5 | $app->getContainer()->query('UserSettings'), |
|
51 | 5 | $user, $start, $count, 'desc', 'all' |
|
52 | 5 | ); |
|
53 | 5 | $parser = new PlainTextParser(\OC::$server->getL10NFactory()->get('activity')); |
|
54 | |||
55 | 5 | $entries = array(); |
|
56 | 5 | foreach($activities['data'] as $entry) { |
|
57 | 4 | $entries[] = array( |
|
58 | 4 | 'id' => $entry['activity_id'], |
|
59 | 4 | 'subject' => $parser->parseMessage($entry['subject_prepared']), |
|
60 | 4 | 'message' => $parser->parseMessage($entry['message_prepared']), |
|
61 | 4 | 'file' => $entry['object_name'], |
|
62 | 4 | 'link' => $entry['link'], |
|
63 | 4 | 'date' => date('c', $entry['timestamp']), |
|
64 | ); |
||
65 | 5 | } |
|
66 | |||
67 | 5 | return new \OC_OCS_Result($entries); |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param string $user |
||
72 | * @param int $offset |
||
73 | * @return int |
||
74 | */ |
||
75 | 2 | protected static function getSinceFromOffset($user, $offset) { |
|
94 | } |
||
95 |