/** * @PublicPage * @NoCSRFRequired * * @return TemplateResponse */ public function show() { try { $user = $this->activityManager->getCurrentUserId(); $userLang = $this->config->getUserValue($user, 'core', 'lang'); // Overwrite user and language in the helper $l = Util::getL10N('activity', $userLang); $l->forceLanguage($userLang); $this->helper->setL10n($l); $this->helper->setUser($user); $description = (string) $l->t('Personal activity feed for %s', $user); $activities = $this->data->read($this->helper, $this->settings, 0, self::DEFAULT_PAGE_SIZE, 'all', $user); } catch (\UnexpectedValueException $e) { $l = Util::getL10N('activity'); $description = (string) $l->t('Your feed URL is invalid'); $activities = [['activity_id' => -1, 'timestamp' => time(), 'subject' => true, 'subjectformatted' => ['full' => $description]]]; } $response = new TemplateResponse('activity', 'rss', ['rssLang' => $l->getLanguageCode(), 'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'), 'rssPubDate' => date('r'), 'description' => $description, 'activities' => $activities], ''); if ($this->request->getHeader('accept') !== null && stristr($this->request->getHeader('accept'), 'application/rss+xml')) { $response->addHeader('Content-Type', 'application/rss+xml'); } else { $response->addHeader('Content-Type', 'text/xml; charset=UTF-8'); } return $response; }
/** * @NoAdminRequired * * @param int $page * @param string $filter * @param string $objecttype * @param int $objectid * @return JSONResponse */ public function fetch($page, $filter = 'all', $objecttype = '', $objectid = 0) { $pageOffset = $page - 1; $filter = $this->data->validateFilter($filter); $activities = $this->data->read($this->helper, $this->settings, $pageOffset * self::DEFAULT_PAGE_SIZE, self::DEFAULT_PAGE_SIZE, $filter, '', $objecttype, $objectid); $preparedActivities = []; foreach ($activities as $activity) { if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) { // We do not link the subject as we create links for the parameters instead $activity['link'] = ''; } $activity['previews'] = []; if ($activity['object_type'] === 'files' && !empty($activity['files'])) { foreach ($activity['files'] as $objectId => $objectName) { if ((int) $objectId === 0 || $objectName === '') { // No file, no preview continue; } $activity['previews'][] = $this->getPreview($activity['affecteduser'], (int) $objectId, $objectName); if (sizeof($activity['previews']) >= self::MAX_NUM_THUMBNAILS) { // Don't want to clutter the page, so we stop after a few thumbnails break; } } } else { if ($activity['object_type'] === 'files' && $activity['object_id']) { $activity['previews'][] = $this->getPreview($activity['affecteduser'], (int) $activity['object_id'], $activity['file']); } } $preparedActivities[] = $activity; } return new JSONResponse($preparedActivities); }
/** * @brief Registers the filesystem hooks for basic filesystem operations. All other events has to be triggered by the apps. */ public static function getActivities() { $start = isset($_GET['start']) ? $_GET['start'] : 0; $count = isset($_GET['count']) ? $_GET['count'] : 30; $data = Data::read($start, $count); $activities = array(); foreach ($data as $d) { $activity = array(); $activity['id'] = $d['activity_id']; $activity['subject'] = $d['subject']; $activity['message'] = $d['message']; $activity['file'] = $d['file']; $activity['link'] = $d['link']; $activity['date'] = date('c', $d['timestamp']); $activities[] = $activity; } return new OC_OCS_Result($activities); }
/** * @NoAdminRequired * * @param int $page * @param string $filter * @return TemplateResponse */ public function fetch($page, $filter = 'all') { $pageOffset = $page - 1; $filter = $this->data->validateFilter($filter); return new TemplateResponse('activity', 'activities.part', ['activity' => $this->data->read($this->helper, $this->settings, $pageOffset * self::DEFAULT_PAGE_SIZE, self::DEFAULT_PAGE_SIZE, $filter)], ''); }
/** * @NoAdminRequired * * @param int $page * @param string $filter * @return TemplateResponse */ public function fetch($page, $filter = 'all') { $pageOffset = $page - 1; $filter = $this->data->validateFilter($filter); return new TemplateResponse('activity', 'stream.list', ['activity' => $this->data->read($this->helper, $this->settings, $pageOffset * self::DEFAULT_PAGE_SIZE, self::DEFAULT_PAGE_SIZE, $filter), 'displayHelper' => $this->display, 'dateTimeFormatter' => $this->dateTimeFormatter], ''); }