Skip to content
Snippets Groups Projects
Commit e50158d2 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fix activity feed retrieval, fixes #1557

Closes #1557

Merge request studip/studip!979
parent 1db3d29e
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ class Activity extends \RESTAPI\RouteMap
*
* @param string $user_id the user to get the activities for
*
* @return Array the activities as array('collection' => array(...), 'pagination' => array())
* @return array the activities as array('collection' => array(...), 'pagination' => array())
*/
public function getActivities($user_id)
{
......@@ -29,11 +29,8 @@ class Activity extends \RESTAPI\RouteMap
// failsafe einbauen - falls es keine älteren Aktivitäten mehr im System gibt, Abbruch!
if ($oldest_activity = \Studip\Activity\Activity::getOldestActivity()) {
$max_age = array_pop($oldest_activity)->mkdate;
} else {
$max_age = time();
}
$oldest_activity = \Studip\Activity\Activity::getOldestActivity();
$max_age = $oldest_activity ? $oldest_activity->mkdate : time();
$contexts = [];
......@@ -70,16 +67,16 @@ class Activity extends \RESTAPI\RouteMap
$scrollfrom = \Request::int('scrollfrom', false);
$filtertype = \Request::get('filtertype', '');
$objectType = \Request::get('object_type', '');
$objectType = \Request::get('object_type');
$filter->setObjectType($objectType);
$objectId = \Request::get('object_id', '');
$objectId = \Request::get('object_id');
$filter->setObjectId($objectId);
$context = \Request::get('context_type', '');
$context = \Request::get('context_type');
$filter->setContext($context);
$contextId = \Request::get('context_id', '');
$contextId = \Request::get('context_id');
$filter->setContextId($contextId);
if (!empty($filtertype)) {
......
......@@ -169,15 +169,15 @@ class Activity extends \SimpleORMap
/**
* Returns the oldest existing activity
*
* @return Array
* @return Activity|false
*/
public static function getOldestActivity()
{
$cache = \StudipCacheFactory::getCache();
$cache_key = 'activity/oldest_activity';
$cache_key = 'activity/oldest-activity';
if (!$activity = unserialize($cache->read($cache_key))) {
$activity = self::findBySQL('1 ORDER BY mkdate ASC LIMIT 1');
$activity = self::findOneBySQL('1 ORDER BY mkdate ASC LIMIT 1');
if (!empty($activity)) {
$cache->write($cache_key, serialize($activity));
......
......@@ -50,7 +50,7 @@ const ActivityFeed = {
STUDIP.api.GET(['user', STUDIP.ActivityFeed.user_id, 'activitystream'], {
data: {
filtertype: filtertype,
filtertype: JSON.stringify(filtertype),
scrollfrom: STUDIP.ActivityFeed.scrolledfrom
}
}).done(function (activities) {
......
......@@ -3,7 +3,7 @@
jQuery(document).ready(function() {
STUDIP.ActivityFeed.user_id = '<?= $user_id ?>';
STUDIP.ActivityFeed.scrolledfrom = '<?= $scrolledfrom ?>';
STUDIP.ActivityFeed.filter = '<?= json_encode($config) ?>';
STUDIP.ActivityFeed.filter = <?= json_encode($config) ?>;
STUDIP.ActivityFeed.init();
});
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment