diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/course/overview.php | 4 | ||||
| -rw-r--r-- | app/controllers/institute/overview.php | 2 | ||||
| -rw-r--r-- | app/controllers/news.php | 7 | ||||
| -rw-r--r-- | app/views/news/display.php | 4 |
4 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/course/overview.php b/app/controllers/course/overview.php index 4313cdc..c467ccf 100644 --- a/app/controllers/course/overview.php +++ b/app/controllers/course/overview.php @@ -49,7 +49,7 @@ class Course_OverviewController extends AuthenticatedController } // Fetch news - $response = $this->relayWithRedirect('news/display/' . $this->course_id); + $response = $this->relayWithRedirect('news/display/' . $this->course_id . '/true'); $this->news = $response->body; // Fetch votes @@ -109,7 +109,7 @@ class Course_OverviewController extends AuthenticatedController } $connections = StudygroupCourse::countBySql( - "`studygroup_id` = :cid OR `course_id` = :cid", + "`studygroup_id` = :cid OR `course_id` = :cid", [ 'cid' => $this->course_id ] diff --git a/app/controllers/institute/overview.php b/app/controllers/institute/overview.php index 603e632..41459f9 100644 --- a/app/controllers/institute/overview.php +++ b/app/controllers/institute/overview.php @@ -141,7 +141,7 @@ class Institute_OverviewController extends AuthenticatedController } // Fetch news - $response = $this->relayWithRedirect('news/display/' . $this->institute_id); + $response = $this->relayWithRedirect('news/display/' . $this->institute_id . '/true'); $this->news = $response->body; // Fetch votes diff --git a/app/controllers/news.php b/app/controllers/news.php index 53fdd43..bbb589f 100644 --- a/app/controllers/news.php +++ b/app/controllers/news.php @@ -81,8 +81,11 @@ class NewsController extends StudipController * * @param String $range_id range id of the news to get displayed */ - public function display_action($range_id) + public function display_action($range_id, $new_news = false) { + + $this->mark_as_read = $new_news; + if (!$range_id) { $this->set_status(400); $this->render_nothing(); @@ -164,6 +167,8 @@ class NewsController extends StudipController $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id === 'nobody'; $this->visit(); + + // TODO how do I set all news to read? } private function visit() diff --git a/app/views/news/display.php b/app/views/news/display.php index c8f271e..06185f7 100644 --- a/app/views/news/display.php +++ b/app/views/news/display.php @@ -31,7 +31,9 @@ <? foreach ($news as $new): ?> <? $is_new = ($new['chdate'] >= object_get_visit($new->id, 'news', false, false)) && ($new['user_id'] != $GLOBALS['user']->id); ?> - <article class="studip toggle <?= ContentBoxHelper::classes($new->id, $is_new) ?>" id="<?= $new->id ?>" data-visiturl="<?=URLHelper::getScriptLink('dispatch.php/news/visit')?>"> + + <!-- toggle open and mark as read if in course or institute context --> + <article class="studip toggle <?= ContentBoxHelper::classes($new->id, $is_new) ?> <?= $mark_as_read ? 'open' : ''?>" id="<?= $new->id ?>" data-visiturl="<?=URLHelper::getScriptLink('dispatch.php/news/visit')?>"> <header> <h1> <a href="<?= ContentBoxHelper::href($new->id, ['contentbox_type' => 'news']) ?>"> |
