Skip to content
Snippets Groups Projects
Commit cb8947e7 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fix for BIESt #1064

Merge request !642
parent 70be627f
No related branches found
No related tags found
No related merge requests found
Showing with 137 additions and 119 deletions
......@@ -41,5 +41,11 @@ abstract class ForumController extends StudipController {
}
$this->seminar_id = $this->getId();
$this->no_entries = false;
$this->highlight = [];
$this->highlight_topic = '';
$this->edit_posting = '';
$this->js = '';
}
}
......@@ -52,13 +52,18 @@
</td>
<td class="actions">
<?= ActionMenu::get()->addLink(
<?
$issue_id = ForumIssue::getIssueIdForThread($entry['topic_id']);
$action_menu = ActionMenu::get();
if (!empty($entry['last_posting']['topic_id'])) {
$action_menu->addLink(
$controller->url_for("course/forum/index/index/{$entry['last_posting']['topic_id']}#{$entry['last_posting']['topic_id']}"),
_('Zur letzten Antwort'),
Icon::create('forum'),
is_array($entry['last_posting']) ? ['class' => 'hidden-small-up'] : ['disabled' => '']
)->condition(ForumPerm::has('edit_area', $seminar_id) && $issue_id = ForumIssue::getIssueIdForThread($entry['topic_id']))
->addLink(
)->condition(ForumPerm::has('edit_area', $seminar_id) && $issue_id);
}
$action_menu->addLink(
URLHelper::getURL("dispatch.php/course/topics/edit/{$issue_id}"),
_('Zum Ablaufplan'),
Icon::create('info-circle', Icon::ROLE_STATUS_RED),
......@@ -82,6 +87,7 @@
'onclick' => "STUDIP.Forum.deleteArea(this, '{$entry['topic_id']}'); return false;",
]
) ?>
<?= $action_menu ?>
</td>
</tr>
<? if (is_array($entry['last_posting'])) : ?>
<? if (is_array($entry['last_posting']) && count($entry['last_posting'])) : ?>
<?= _('von') ?>
<? if ($entry['last_posting']['anonymous']): ?>
<? if (!empty($entry['last_posting']['anonymous'])): ?>
<?= _('Anonym') ?>
<? endif; ?>
<? if (!$entry['last_posting']['anonymous'] || $entry['last_posting']['user_id'] == $GLOBALS['user']->id || $GLOBALS['perm']->have_perm('root')): ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $entry['last_posting']['username']]) ?>">
<?= htmlReady(($temp_user = User::find($entry['last_posting']['user_id'])) ? $temp_user->getFullname() : $entry['last_posting']['user_fullname']) ?>
<? if (empty($entry['last_posting']['anonymous']) || $entry['last_posting']['user_id'] == $GLOBALS['user']->id || $GLOBALS['perm']->have_perm('root')): ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $entry['last_posting']['username'] ?? '']) ?>">
<?= htmlReady(($temp_user = User::find($entry['last_posting']['user_id'])) ? $temp_user->getFullname() : $entry['last_posting']['user_fullname'] ?? '') ?>
</a>
<? endif; ?>
<br>
......
......@@ -32,8 +32,8 @@ shuffle($likes);
}
$text .= ' <br>';
echo $text;
endif ?>
<?= $text ?>
<!-- like/dislike links -->
<? if (!in_array($GLOBALS['user']->id, $likes)) : ?>
......
......@@ -5,14 +5,14 @@
<form action="<?= $controller->link_for('course/forum/index/add_entry') ?>" method="post" id="forum_new_entry" onSubmit="$(window).off('beforeunload')" class="default">
<fieldset>
<legend>
<? if ($constraint['depth'] == 1) : ?>
<? if (!empty($constraint['depth']) && ($constraint['depth'] == 1)) : ?>
<?= _('Neues Thema erstellen') ?>
<? else : ?>
<?= _('Antworten') ?>
<? endif ?>
</legend>
<? if ($constraint['depth'] == 1) : ?>
<? if (!empty($constraint['depth']) && ($constraint['depth'] == 1)) : ?>
<? if ($GLOBALS['user']->id == 'nobody') : ?>
<label>
<?= _('Ihr Name') ?>
......@@ -24,7 +24,7 @@
<label>
<?= _('Titel') ?>
<input class="size-l" type="text" name="name" style="width: 99%" value=""
<?= $constraint['depth'] == 1 ? 'required' : '' ?> placeholder="<?= _('Titel') ?>" tabindex="2">
<?= !empty($constraint['depth']) && ($constraint['depth'] == 1) ? 'required' : '' ?> placeholder="<?= _('Titel') ?>" tabindex="2">
</label>
<? elseif ($GLOBALS['user']->id == 'nobody') : ?>
<label>
......
<? if (!is_array($highlight)) $highlight = []; ?>
<? $is_new = ((isset($visitdate) && $post['mkdate'] >= $visitdate) || !(isset($visitdate))) ?>
<? if (!$constraint) $constraint = ForumEntry::getConstraints (ForumEntry::getParentTopicId($post['topic_id'])) ?>
<? if (empty($constraint)) $constraint = ForumEntry::getConstraints (ForumEntry::getParentTopicId($post['topic_id'])) ?>
<? $can_edit_closed = !ForumEntry::isClosed($constraint['topic_id'])
|| (ForumEntry::isClosed($constraint['topic_id']) && ForumPerm::has('edit_closed', $constraint['seminar_id'])) ?>
......@@ -12,7 +11,7 @@
] ?>
<!-- Anker, um zu diesem Posting springen zu können -->
<a name="<?= $post['topic_id'] ?>"></a>
<a id="<?= $post['topic_id'] ?>"></a>
<form method="post" data-topicid="<?= $post['topic_id'] ?>" action="<?= $controller->link_for('course/forum/index/update_entry/' . $post['topic_id']) ?>">
<?= CSRFProtection::tokenTag() ?>
......@@ -132,7 +131,7 @@
]) ?>
<? endif ?>
<span <?= (!$perms['edit_close'] && !$perms['remove_entry']) ? 'class="hideWhenClosed"': '' ?>
<span <?= (empty($perms['edit_close']) && empty($perms['remove_entry'])) ? 'class="hideWhenClosed"': '' ?>
<?= (!$perms['edit'] && !$perms['remove_entry']) ? 'style="display: none"' : '' ?>>
<? $confirmLink = $controller->url_for('course/forum/index/delete_entry/' . $post['topic_id']) ?>
<? $confirmLinkApproved = $controller->url_for('course/forum/index/delete_entry/' .
......
......@@ -122,6 +122,8 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) {
Icon::create('file-pdf', 'clickable'));
$sidebar->addWidget($export);
}
$pagechooser = null;
?>
<!-- Breadcrumb navigation -->
......@@ -153,11 +155,13 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) {
<? endif ?>
<!-- Bereiche / Themen darstellen -->
<? if (!empty($constraint['depth'])) : ?>
<? if ($constraint['depth'] == 0) : ?>
<?= $this->render_partial('course/forum/index/_areas') ?>
<? elseif ($constraint['depth'] == 1) : ?>
<?= $this->render_partial('course/forum/index/_threads') ?>
<? endif ?>
<? endif ?>
<? if (!empty($postings)) : ?>
<!-- Beiträge für das ausgewählte Thema darstellen -->
......@@ -172,6 +176,7 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) {
<? endif ?>
<!-- Erstellen eines neuen Elements (Kategorie, Thema, Beitrag) -->
<? if (!empty($constraint['depth'])) : ?>
<? if ($constraint['depth'] == 0) : ?>
<div style="clear: right; text-align: center">
<div class="button-group">
......@@ -237,10 +242,9 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) {
<? endif ?>
</div>
</div>
</div>
<? endif ?>
<? endif ?>
<? endif ?>
<? if ( (ForumPerm::has('add_area', $this->seminar_id))
......
......@@ -420,7 +420,7 @@ class ForumEntry implements PrivacyObject
'user_id' => $data['user_id'],
'raw_title' => $data['name'],
'raw_description' => ForumEntry::killEdit($data['content']),
'fav' => ($data['fav'] == 'fav'),
'fav' => (!empty($data['fav']) && ($data['fav'] == 'fav')),
'depth' => $data['depth'],
'anonymous' => $data['anonymous'],
'closed' => $data['closed'],
......@@ -550,7 +550,9 @@ class ForumEntry implements PrivacyObject
*/
public static function getLastPostings($postings)
{
foreach ($postings as $key => $posting) {
foreach ($postings as $key => $posting)
{
$last_posting = [];
if ($data = ForumEntry::getLatestPosting($posting['topic_id'])) {
$last_posting['topic_id'] = $data['topic_id'];
......@@ -574,7 +576,7 @@ class ForumEntry implements PrivacyObject
$postings[$key]['last_posting'] = $last_posting;
if (!$postings[$key]['last_unread'] = ForumEntry::getLastUnread($posting['topic_id'])) {
$postings[$key]['last_unread'] = $last_posting['topic_id'];
$postings[$key]['last_unread'] = $last_posting['topic_id'] ?? '';
}
$postings[$key]['num_postings'] = ForumEntry::countEntries($posting['topic_id']);
......@@ -735,7 +737,7 @@ class ForumEntry implements PrivacyObject
'user_id' => $data['user_id'],
'raw_title' => $data['name'],
'raw_description' => ForumEntry::killEdit($data['content']),
'fav' => ($data['fav'] == 'fav'),
'fav' => (!empty($data['fav']) && $data['fav'] == 'fav'),
'depth' => $data['depth'],
'seminar_id' => $data['seminar_id']
];
......@@ -906,7 +908,7 @@ class ForumEntry implements PrivacyObject
{
static $entries;
if (!$entries[$user_id]) {
if (empty($entries[$user_id])) {
$stmt = DBManager::get()->prepare("SELECT COUNT(*)
FROM forum_entries
WHERE user_id = ? AND seminar_id = IFNULL(?, seminar_id)");
......@@ -953,7 +955,7 @@ class ForumEntry implements PrivacyObject
VALUES (? ,?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, ?, ?, ?, ?, ?)");
$stmt->execute([$data['topic_id'], $data['seminar_id'], $data['user_id'],
$data['name'], transformBeforeSave($data['content']), $data['author'], $data['author_host'],
$constraint['rgt'], $constraint['rgt'] + 1, $constraint['depth'] + 1, $data['anonymous'] ? : 0]);
$constraint['rgt'], $constraint['rgt'] + 1, $constraint['depth'] + 1, $data['anonymous'] ?? 0]);
// update "latest_chdate" for easier sorting of actual threads
DBManager::get()->exec("UPDATE forum_entries SET latest_chdate = UNIX_TIMESTAMP()
......
......@@ -35,8 +35,10 @@ class ForumLike {
restoreLanguage();
PersonalNotifications::add(
$data['user_id'], URLHelper::getURL('dispatch.php/course/forum/index/index/' . $topic_id .'?highlight_topic='. $topic_id .'#'. $topic_id),
$notification, $topic_id,
$data['user_id'],
URLHelper::getURL('dispatch.php/course/forum/index/index/' . $topic_id .'?highlight_topic='. $topic_id .'#'. $topic_id),
$notification,
$topic_id,
Icon::create('forum', 'clickable')
);
}
......@@ -82,7 +84,7 @@ class ForumLike {
{
static $entries;
if (!$entries[$user_id]) {
if (empty($entries[$user_id])) {
$stmt = DBManager::get()->prepare("SELECT COUNT(*)
FROM forum_entries
LEFT JOIN forum_likes USING (topic_id)
......
......@@ -58,7 +58,7 @@ class ForumPerm {
}
// get the status for the user in the passed seminar
if (!$permissions[$seminar_id][$user_id]) {
if (empty($permissions[$seminar_id][$user_id])) {
$permissions[$seminar_id][$user_id] = $GLOBALS['perm']->get_studip_perm($seminar_id, $user_id);
}
......@@ -155,7 +155,7 @@ class ForumPerm {
{
static $perms = [];
if (!$perms[$topic_id]) {
if (empty($perms[$topic_id])) {
// find out if the posting is the last in the thread
$constraints = ForumEntry::getConstraints($topic_id);
......
......@@ -157,6 +157,6 @@ class ForumVisit {
static function getVisit($seminar_id)
{
$visit = self::getVisitDates($seminar_id);
return $visit['visitdate'];
return $visit['visitdate'] ?? 0;
}
}
......@@ -49,8 +49,8 @@ class SmileyFormat extends TextFormat
static function short($markup, $matches)
{
$smileys = Smiley::getShort();
$name = $smileys[$matches[2]];
return isset($name)
$name = $smileys[$matches[2]] ?? '';
return $name
? $matches[1] . Smiley::getByName($name)->getImageTag() . $matches[3]
: $matches[0];
}
......
......@@ -55,13 +55,13 @@ class PersonalNotifications extends SimpleORMap
protected $unseen = null;
protected function cbExpireCache($notification)
protected function cbExpireCache()
{
$query = "SELECT user_id
FROM personal_notifications_user
WHERE personal_notification_id = :id";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':id', $notification->id);
$statement->bindValue(':id', $this->id);
$statement->execute();
$user_ids = $statement->fetchAll(PDO::FETCH_COLUMN);
......
......@@ -32,9 +32,8 @@ class AutoNavigation extends Navigation
// if URL is set, try to guess whether active or not
if (isset($url)) {
list($request_path, $query) = explode('?', Request::path());
list($request_url, $query) = explode('?', Request::url());
list($url, $query) = explode('?', $url);
$request_path = explode('?', Request::path())[0];
$request_url = explode('?', Request::url())[0];
if (!preg_match('%^[a-z]+:%', $url) && $url[0] !== '/') {
$url = $GLOBALS['CANONICAL_RELATIVE_PATH_STUDIP'].$url;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment