Skip to content

Commit 56058c6

Browse files
committed
Issues-498: fixed threaded/flat mode for anonymous
1 parent a9cc020 commit 56058c6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

config/vanilla/bootstrap.before.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,4 +875,34 @@ function writeInlineCommentOptions($comment) {
875875
echo '</div>';
876876

877877
}
878+
}
879+
880+
if (!function_exists('discussionUrl')) {
881+
/**
882+
* Return a URL for a discussion. This function is in here and not functions.general so that plugins can override.
883+
*
884+
* @param object|array $discussion
885+
* @param int|string $page
886+
* @param bool $withDomain
887+
* @return string
888+
*/
889+
function discussionUrl($discussion, $page = '', $withDomain = true) {
890+
$discussion = (object)$discussion;
891+
$name = Gdn_Format::url($discussion->Name);
892+
893+
// Disallow an empty name slug in discussion URLs.
894+
if (empty($name)) {
895+
$name = 'x';
896+
}
897+
898+
$result = '/discussion/'.$discussion->DiscussionID.'/'.$name;
899+
900+
if ($page) {
901+
//if ($page > 1 || Gdn::session()->UserID) {
902+
$result .= '/p'.$page;
903+
// }
904+
}
905+
906+
return url($result, $withDomain);
907+
}
878908
}

0 commit comments

Comments
 (0)