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

fixes #3644

Closes #3644

Merge request studip/studip!2522
parent e278ef0a
No related branches found
No related tags found
No related merge requests found
<? use Studip\Button, Studip\LinkButton; ?> <?php
/**
* @var NewsController $controller
* @var string $area_type
* @var Trails_Flash $flash
* @var string $news_searchterm
* @var string $news_startdate
* @var string $news_enddate
* @var string|null $filter_text
* @var array<string, array<string, array{title: string, object: StudipNews}>> $news_items
* @var array $area_structure
*/
?>
<? if (!empty($flash['question_text'])) : ?> <? if (!empty($flash['question_text'])) : ?>
<?= QuestionBox::create( <?= QuestionBox::create(
htmlReady($flash['question_text']), htmlReady($flash['question_text']),
...@@ -52,9 +64,9 @@ ...@@ -52,9 +64,9 @@
</label> </label>
</fieldset> </fieldset>
<footer> <footer>
<?= Button::create(_('Filter anwenden'), 'apply_news_filter', ['aria-label' => _('Liste mit Suchbegriff und/oder Zeitraum filtern')]) ?> <?= Studip\Button::create(_('Filter anwenden'), 'apply_news_filter', ['aria-label' => _('Liste mit Suchbegriff und/oder Zeitraum filtern')]) ?>
<? if ($filter_text) : ?> <? if ($filter_text) : ?>
<?= Button::create(_('Filter zurücksetzen'), 'reset_filter') ?> <?= Studip\Button::create(_('Filter zurücksetzen'), 'reset_filter') ?>
<? endif ?> <? endif ?>
</footer> </footer>
<br> <br>
...@@ -74,12 +86,13 @@ ...@@ -74,12 +86,13 @@
</caption> </caption>
<? endif ?> <? endif ?>
<colgroup> <colgroup>
<col width="20"> <col style="width: 20px">
<col> <col>
<col width="25%"> <col style="width: 25%">
<col width="10%"> <col style="width: 10%">
<col width="10%"> <col style="width: 10%">
<col width="80"> <col style="width: 5%">
<col style="width: 80px">
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
...@@ -88,6 +101,7 @@ ...@@ -88,6 +101,7 @@
<th><?= _('Autor') ?></th> <th><?= _('Autor') ?></th>
<th><?= _('Einstelldatum') ?></th> <th><?= _('Einstelldatum') ?></th>
<th><?= _('Ablaufdatum') ?></th> <th><?= _('Ablaufdatum') ?></th>
<th><?= _('Aufrufe') ?></th>
<th class="actions"><?= _('Aktion') ?></th> <th class="actions"><?= _('Aktion') ?></th>
</tr> </tr>
</thead> </thead>
...@@ -99,18 +113,18 @@ ...@@ -99,18 +113,18 @@
<tr> <tr>
<th> <th>
<input type="checkbox" <input type="checkbox"
data-proxyfor=".news_<?= $news['range_id'] ?>" data-proxyfor=".news_<?= htmlReady($news['range_id']) ?>"
aria-labelledby="<?= _('Alle auswählen') ?>"> aria-labelledby="<?= _('Alle auswählen') ?>">
</th> </th>
<th colspan="5"><?= mila(htmlReady($news['title'] ?? '')) . ' ' . htmlReady($news['semester'] ?? '') ?></th> <th colspan="6"><?= mila(htmlReady($news['title'] ?? '')) . ' ' . htmlReady($news['semester'] ?? '') ?></th>
</tr> </tr>
<? endif ?> <? endif ?>
<? $last_title = $title ?> <? $last_title = $title ?>
<? endif ?> <? endif ?>
<tr> <tr>
<td> <td>
<input type="checkbox" class="news_<?= $news['range_id'] ?>" name="mark_news[]" <input type="checkbox" class="news_<?= htmlReady($news['range_id']) ?>" name="mark_news[]"
value="<?= $news['object']->news_id . '_' . $news['range_id'] ?>" value="<?= htmlReady($news['object']->news_id . '_' . $news['range_id']) ?>"
aria-label="<?= _('Diese Ankündigung zum Entfernen vormerken') ?>" <?= tooltip(_("Diese Ankündigung zum Entfernen vormerken"), false) ?>> aria-label="<?= _('Diese Ankündigung zum Entfernen vormerken') ?>" <?= tooltip(_("Diese Ankündigung zum Entfernen vormerken"), false) ?>>
</td> </td>
<td><?= htmlReady($news['object']->topic) ?></td> <td><?= htmlReady($news['object']->topic) ?></td>
...@@ -119,9 +133,19 @@ ...@@ -119,9 +133,19 @@
$body = $parts[0]; $body = $parts[0];
$admin_msg = $parts[1] ?? ';' $admin_msg = $parts[1] ?? ';'
?> ?>
<td><?= htmlReady($news['object']->author) ?></td> <td>
<? if ($news['object']->owner): ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $news['object']->owner->username]) ?>">
<?= Avatar::getAvatar($news['object']->user_id)->getImageTag(Avatar::SMALL) ?>
<?= htmlReady($news['object']->owner->getFullName()) ?>
</a>
<? else: ?>
<?= htmlReady($news['object']->author) ?>
<? endif; ?>
</td>
<td><?= strftime("%d.%m.%y", $news['object']->date) ?></td> <td><?= strftime("%d.%m.%y", $news['object']->date) ?></td>
<td><?= strftime("%d.%m.%y", $news['object']->date + $news['object']->expire) ?></td> <td><?= strftime("%d.%m.%y", $news['object']->date + $news['object']->expire) ?></td>
<td><?= $news['object']->views ?></td>
<td class="actions"> <td class="actions">
<? <?
$menu = ActionMenu::get()->setContext($news['object']->topic); $menu = ActionMenu::get()->setContext($news['object']->topic);
...@@ -158,8 +182,8 @@ ...@@ -158,8 +182,8 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="6"> <td colspan="7">
<?= Button::create(_('Alle markierten Ankündigungen entfernen'), 'remove_marked_news') ?> <?= Studip\Button::create(_('Alle markierten Ankündigungen entfernen'), 'remove_marked_news') ?>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>
......
...@@ -44,6 +44,7 @@ require_once 'lib/object.inc.php'; ...@@ -44,6 +44,7 @@ require_once 'lib/object.inc.php';
* @property SimpleORMapCollection|StudipComment[] $comments has_many StudipComment * @property SimpleORMapCollection|StudipComment[] $comments has_many StudipComment
* @property SimpleORMapCollection|NewsRoles[] $news_roles has_many NewsRoles * @property SimpleORMapCollection|NewsRoles[] $news_roles has_many NewsRoles
* @property User $owner belongs_to User * @property User $owner belongs_to User
* @property int $views additional field
*/ */
class StudipNews extends SimpleORMap implements PrivacyObject class StudipNews extends SimpleORMap implements PrivacyObject
{ {
...@@ -72,8 +73,15 @@ class StudipNews extends SimpleORMap implements PrivacyObject ...@@ -72,8 +73,15 @@ class StudipNews extends SimpleORMap implements PrivacyObject
'on_delete' => 'delete' 'on_delete' => 'delete'
]; ];
$config['i18n_fields']['topic'] = true; $config['additional_fields'] = [
$config['i18n_fields']['body'] = true; 'views' => [
'get' => function (StudipNews $news): int {
return object_return_views($news->id);
},
],
];
$config['i18n_fields'] = ['topic', 'body'];
// Strip <admin_msg> from news body // Strip <admin_msg> from news body
$config['registered_callbacks']['after_initialize'][] = function ($news) { $config['registered_callbacks']['after_initialize'][] = function ($news) {
...@@ -307,8 +315,7 @@ class StudipNews extends SimpleORMap implements PrivacyObject ...@@ -307,8 +315,7 @@ class StudipNews extends SimpleORMap implements PrivacyObject
} elseif ($area === 'user') { } elseif ($area === 'user') {
if ($GLOBALS['user']->id === $result['userid']) { if ($GLOBALS['user']->id === $result['userid']) {
$objects[$area][$id]['title'] = _('Ankündigungen auf Ihrer Profilseite'); $objects[$area][$id]['title'] = _('Ankündigungen auf Ihrer Profilseite');
} } else {
else {
$objects[$area][$id]['title'] = sprintf(_('Ankündigungen auf der Profilseite von %s'), get_fullname($result['userid'])); $objects[$area][$id]['title'] = sprintf(_('Ankündigungen auf der Profilseite von %s'), get_fullname($result['userid']));
} }
} elseif ($area === 'global') { } elseif ($area === 'global') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment