From cb8947e7f88ea07a15689bcfd7c4f400bb4ed004 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Fri, 27 May 2022 09:04:31 +0000 Subject: [PATCH] fix for BIESt #1064 Merge request studip/studip!642 --- .../course/forum/forum_controller.php | 6 + app/views/course/forum/area/add.php | 20 ++- app/views/course/forum/index/_last_post.php | 10 +- app/views/course/forum/index/_like.php | 4 +- app/views/course/forum/index/_new_entry.php | 6 +- app/views/course/forum/index/_post.php | 7 +- app/views/course/forum/index/index.php | 132 +++++++++--------- lib/classes/ForumEntry.php | 14 +- lib/classes/ForumLike.php | 38 ++--- lib/classes/ForumPerm.php | 4 +- lib/classes/ForumVisit.php | 2 +- lib/classes/SmileyFormat.php | 4 +- lib/models/PersonalNotifications.class.php | 4 +- lib/navigation/AutoNavigation.php | 5 +- 14 files changed, 137 insertions(+), 119 deletions(-) diff --git a/app/controllers/course/forum/forum_controller.php b/app/controllers/course/forum/forum_controller.php index d826b25f62f..71d1aa094fe 100644 --- a/app/controllers/course/forum/forum_controller.php +++ b/app/controllers/course/forum/forum_controller.php @@ -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 = ''; } } diff --git a/app/views/course/forum/area/add.php b/app/views/course/forum/area/add.php index 01cf3dc95ef..9524a6596b6 100644 --- a/app/views/course/forum/area/add.php +++ b/app/views/course/forum/area/add.php @@ -52,13 +52,18 @@ </td> <td class="actions"> - <?= ActionMenu::get()->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( + <? + $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); + } + $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> diff --git a/app/views/course/forum/index/_last_post.php b/app/views/course/forum/index/_last_post.php index 50c5eb204b2..2f3a38b9ee8 100644 --- a/app/views/course/forum/index/_last_post.php +++ b/app/views/course/forum/index/_last_post.php @@ -1,11 +1,11 @@ -<? 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> diff --git a/app/views/course/forum/index/_like.php b/app/views/course/forum/index/_like.php index eac19a27636..6d11acbfadd 100644 --- a/app/views/course/forum/index/_like.php +++ b/app/views/course/forum/index/_like.php @@ -30,10 +30,10 @@ shuffle($likes); } $text .= '</span></span>'; } - + $text .= ' <br>'; + echo $text; endif ?> -<?= $text ?> <!-- like/dislike links --> <? if (!in_array($GLOBALS['user']->id, $likes)) : ?> diff --git a/app/views/course/forum/index/_new_entry.php b/app/views/course/forum/index/_new_entry.php index 7c2a9abe39e..64f1c142c0d 100644 --- a/app/views/course/forum/index/_new_entry.php +++ b/app/views/course/forum/index/_new_entry.php @@ -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> diff --git a/app/views/course/forum/index/_post.php b/app/views/course/forum/index/_post.php index 2e78b113425..5052c2e8af6 100644 --- a/app/views/course/forum/index/_post.php +++ b/app/views/course/forum/index/_post.php @@ -1,6 +1,5 @@ -<? 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/' . diff --git a/app/views/course/forum/index/index.php b/app/views/course/forum/index/index.php index 69f4b946734..0fc7f8fe715 100644 --- a/app/views/course/forum/index/index.php +++ b/app/views/course/forum/index/index.php @@ -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,10 +155,12 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) { <? endif ?> <!-- Bereiche / Themen darstellen --> -<? if ($constraint['depth'] == 0) : ?> - <?= $this->render_partial('course/forum/index/_areas') ?> -<? elseif ($constraint['depth'] == 1) : ?> - <?= $this->render_partial('course/forum/index/_threads') ?> +<? 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)) : ?> @@ -172,75 +176,75 @@ if ($section === 'index' && ForumPerm::has('pdfexport', $seminar_id)) { <? endif ?> <!-- Erstellen eines neuen Elements (Kategorie, Thema, Beitrag) --> -<? if ($constraint['depth'] == 0) : ?> - <div style="clear: right; text-align: center"> - <div class="button-group"> - <? if (ForumPerm::has('abo', $seminar_id) && $section == 'index') : ?> - <span id="abolink"> - <?= $this->render_partial('course/forum/index/_abo_link', compact('constraint')) ?> - </span> - <? endif ?> - - <? if (ForumPerm::has('pdfexport', $seminar_id) && $section == 'index') : ?> - <?= Studip\LinkButton::create(_('Beiträge als PDF exportieren'), $controller->url_for('course/forum/index/pdfexport'), ['target' => '_blank']) ?> - <? endif ?> - </div> - </div> - - <? if ($section == 'index' && $constraint['depth'] == 0 && ForumPerm::has('add_category', $seminar_id)) : ?> - <?= $this->render_partial('course/forum/index/_new_category') ?> - <? endif ?> -<? else : ?> - <? if (!$flash['edit_entry'] && ForumPerm::has('add_entry', $seminar_id)) : ?> - <? $constraint['depth'] == 1 ? $button_face = _('Neues Thema erstellen') : $button_face = _('Antworten') ?> - <div id="new_entry_button"> +<? if (!empty($constraint['depth'])) : ?> + <? if ($constraint['depth'] == 0) : ?> <div style="clear: right; text-align: center"> <div class="button-group"> - <? if ($constraint['depth'] <= 1 || ($constraint['closed'] == 0)) : ?> - <?= Studip\LinkButton::create($button_face, $controller->url_for('course/forum/index/index/'. $topic_id .'?answer=1'), - ['onClick' => 'STUDIP.Forum.answerEntry(); return false;', - 'class' => 'hideWhenClosed',]) ?> - <? endif ?> - - <? if ($constraint['depth'] > 1 && ($constraint['closed'] == 1)) : ?> - <?= Studip\LinkButton::create($button_face, $controller->url_for('course/forum/index/index/' . $topic_id. '?answer=1'), - ['onClick' => 'STUDIP.Forum.answerEntry(); return false;', - 'class' => 'hideWhenClosed', - 'style' => 'display:none;' - ]) ?> - <? endif ?> - - <? if (ForumPerm::has('close_thread', $seminar_id) && $constraint['depth'] > 1) : ?> - <? if ($constraint['closed'] == 0): ?> - <?= Studip\LinkButton::create(_('Thema schließen'), - $controller->url_for('course/forum/index/close_thread/' . $topic_id .'/'. $topic_id .'/'. ForumHelpers::getPage()), [ - 'onClick' => 'STUDIP.Forum.closeThreadFromThread("'. $topic_id .'"); return false;', - 'class' => 'closeButtons'] - ) ?> - <? else: ?> - <?= Studip\LinkButton::create(_('Thema öffnen'), - $controller->url_for('course/forum/index/open_thread/' . $topic_id .'/'. $topic_id .'/'. ForumHelpers::getPage()), [ - 'onClick' => 'STUDIP.Forum.openThreadFromThread("'. $topic_id .'"); return false;', - 'class' => 'closeButtons'] - ) ?> - <? endif ?> - <? endif ?> - - <? if ($constraint['depth'] > 0 && ForumPerm::has('abo', $seminar_id)) : ?> - <span id="abolink"> - <?= $this->render_partial('course/forum/index/_abo_link', compact('constraint')) ?> - </span> + <? if (ForumPerm::has('abo', $seminar_id) && $section == 'index') : ?> + <span id="abolink"> + <?= $this->render_partial('course/forum/index/_abo_link', compact('constraint')) ?> + </span> <? endif ?> - <? if (ForumPerm::has('pdfexport', $seminar_id)) : ?> - <?= Studip\LinkButton::create(_('Beiträge als PDF exportieren'), $controller->url_for('course/forum/index/pdfexport/' . $topic_id), ['target' => '_blank']) ?> + <? if (ForumPerm::has('pdfexport', $seminar_id) && $section == 'index') : ?> + <?= Studip\LinkButton::create(_('Beiträge als PDF exportieren'), $controller->url_for('course/forum/index/pdfexport'), ['target' => '_blank']) ?> <? endif ?> </div> </div> - </div> + <? if ($section == 'index' && $constraint['depth'] == 0 && ForumPerm::has('add_category', $seminar_id)) : ?> + <?= $this->render_partial('course/forum/index/_new_category') ?> + <? endif ?> + <? else : ?> + <? if (!$flash['edit_entry'] && ForumPerm::has('add_entry', $seminar_id)) : ?> + <? $constraint['depth'] == 1 ? $button_face = _('Neues Thema erstellen') : $button_face = _('Antworten') ?> + <div id="new_entry_button"> + <div style="clear: right; text-align: center"> + <div class="button-group"> + <? if ($constraint['depth'] <= 1 || ($constraint['closed'] == 0)) : ?> + <?= Studip\LinkButton::create($button_face, $controller->url_for('course/forum/index/index/'. $topic_id .'?answer=1'), + ['onClick' => 'STUDIP.Forum.answerEntry(); return false;', + 'class' => 'hideWhenClosed',]) ?> + <? endif ?> + + <? if ($constraint['depth'] > 1 && ($constraint['closed'] == 1)) : ?> + <?= Studip\LinkButton::create($button_face, $controller->url_for('course/forum/index/index/' . $topic_id. '?answer=1'), + ['onClick' => 'STUDIP.Forum.answerEntry(); return false;', + 'class' => 'hideWhenClosed', + 'style' => 'display:none;' + ]) ?> + <? endif ?> + + <? if (ForumPerm::has('close_thread', $seminar_id) && $constraint['depth'] > 1) : ?> + <? if ($constraint['closed'] == 0): ?> + <?= Studip\LinkButton::create(_('Thema schließen'), + $controller->url_for('course/forum/index/close_thread/' . $topic_id .'/'. $topic_id .'/'. ForumHelpers::getPage()), [ + 'onClick' => 'STUDIP.Forum.closeThreadFromThread("'. $topic_id .'"); return false;', + 'class' => 'closeButtons'] + ) ?> + <? else: ?> + <?= Studip\LinkButton::create(_('Thema öffnen'), + $controller->url_for('course/forum/index/open_thread/' . $topic_id .'/'. $topic_id .'/'. ForumHelpers::getPage()), [ + 'onClick' => 'STUDIP.Forum.openThreadFromThread("'. $topic_id .'"); return false;', + 'class' => 'closeButtons'] + ) ?> + <? endif ?> + <? endif ?> + + <? if ($constraint['depth'] > 0 && ForumPerm::has('abo', $seminar_id)) : ?> + <span id="abolink"> + <?= $this->render_partial('course/forum/index/_abo_link', compact('constraint')) ?> + </span> + <? endif ?> + + <? if (ForumPerm::has('pdfexport', $seminar_id)) : ?> + <?= Studip\LinkButton::create(_('Beiträge als PDF exportieren'), $controller->url_for('course/forum/index/pdfexport/' . $topic_id), ['target' => '_blank']) ?> + <? endif ?> + </div> + </div> + </div> + <? endif ?> <? endif ?> - <? endif ?> <? if ( (ForumPerm::has('add_area', $this->seminar_id)) diff --git a/lib/classes/ForumEntry.php b/lib/classes/ForumEntry.php index bd62b08326b..7bfbd18d9c9 100644 --- a/lib/classes/ForumEntry.php +++ b/lib/classes/ForumEntry.php @@ -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() diff --git a/lib/classes/ForumLike.php b/lib/classes/ForumLike.php index 24cb478524e..b964ceabae0 100644 --- a/lib/classes/ForumLike.php +++ b/lib/classes/ForumLike.php @@ -13,11 +13,11 @@ */ class ForumLike { - + /** * Set the posting denoted by the passed topic_id as liked for the * currently logged in user - * + * * @param string $topic_id */ static function like($topic_id) { @@ -25,64 +25,66 @@ class ForumLike { forum_likes (topic_id, user_id) VALUES (?, ?)"); $stmt->execute([$topic_id, $GLOBALS['user']->id]); - + // get posting owner $data = ForumEntry::getConstraints($topic_id); - + // notify owner of posting about the like setTempLanguage($data['user_id']); $notification = get_fullname($GLOBALS['user']->id) . _(' gefällt einer deiner Forenbeiträge!'); 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') ); } - + /** * Revoke the liking of the posting denoted by the passed topic_id for the * currently logged in user - * + * * @param string $topic_id */ static function dislike($topic_id) { $stmt = DBManager::get()->prepare("DELETE FROM forum_likes WHERE topic_id = ? AND user_id = ?"); - $stmt->execute([$topic_id, $GLOBALS['user']->id]); + $stmt->execute([$topic_id, $GLOBALS['user']->id]); } - + /** * Get the user_id for all likers of the topic denoted by the passed id - * + * * @param string $topic_id * @return array an array of user_id's */ static function getLikes($topic_id) { - $stmt = DBManager::get()->prepare("SELECT + $stmt = DBManager::get()->prepare("SELECT auth_user_md5.user_id FROM forum_likes LEFT JOIN auth_user_md5 USING (user_id) LEFT JOIN user_info USING (user_id) WHERE topic_id = ?"); $stmt->execute([$topic_id]); - + return $stmt->fetchAll(PDO::FETCH_COLUMN); } - + /** * count the number of likes the user has received - system-wide - * + * * @staticvar type $entries * @param string $user_id the user's id to count the received likes for - * + * * @return int the number of likes received */ static function receivedForUser($user_id) { 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) diff --git a/lib/classes/ForumPerm.php b/lib/classes/ForumPerm.php index a5441fa0d21..20ee1952a4a 100644 --- a/lib/classes/ForumPerm.php +++ b/lib/classes/ForumPerm.php @@ -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); diff --git a/lib/classes/ForumVisit.php b/lib/classes/ForumVisit.php index befe116978a..05b4b5a5ac3 100644 --- a/lib/classes/ForumVisit.php +++ b/lib/classes/ForumVisit.php @@ -157,6 +157,6 @@ class ForumVisit { static function getVisit($seminar_id) { $visit = self::getVisitDates($seminar_id); - return $visit['visitdate']; + return $visit['visitdate'] ?? 0; } } diff --git a/lib/classes/SmileyFormat.php b/lib/classes/SmileyFormat.php index 9bcf9af966e..5b52df8e08b 100644 --- a/lib/classes/SmileyFormat.php +++ b/lib/classes/SmileyFormat.php @@ -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]; } diff --git a/lib/models/PersonalNotifications.class.php b/lib/models/PersonalNotifications.class.php index 2c8c4ea5366..f403316caeb 100644 --- a/lib/models/PersonalNotifications.class.php +++ b/lib/models/PersonalNotifications.class.php @@ -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); diff --git a/lib/navigation/AutoNavigation.php b/lib/navigation/AutoNavigation.php index 5a9c155e0a3..d91edfcf116 100644 --- a/lib/navigation/AutoNavigation.php +++ b/lib/navigation/AutoNavigation.php @@ -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; -- GitLab