Skip to content

Commit 41543dd

Browse files
authored
Merge pull request #514 from topcoder-platform/develop
Version 1.4
2 parents 8426668 + adf7ed6 commit 41543dd

File tree

20 files changed

+1803
-81
lines changed

20 files changed

+1803
-81
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,10 @@ RUN if [ "$ENV" = "dev" ]; then \
8181
apt-get clean && \
8282
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
8383
echo 'extension=tideways.so\ntideways.connection=tcp://tideways-daemon:9135\ntideways.enable_cli=0\n' >> opt/docker/etc/php/php.ini; \
84-
fi
84+
fi
85+
86+
# Copy custom supervisor's configs and scripts
87+
# Netcat is used to connect to a memcached server
88+
RUN apt-get update && apt-get install -y netcat
89+
COPY ./services/flush_cache.conf /opt/docker/etc/supervisor.d/
90+
COPY ./services/flush_cache.sh /opt/docker/bin/service.d/

config/vanilla/bootstrap.before.php

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,14 @@ function_exists('topcoderRoleCssStyles')) {
299299
*/
300300
function dateUpdated($row, $wrap = null) {
301301
$result = '';
302+
$insertUserID = val('InsertUserID', $row);
302303
$dateUpdated = val('DateUpdated', $row);
303304
$updateUserID = val('UpdateUserID', $row);
304305

305306
if ($dateUpdated) {
306307
$updateUser = Gdn::userModel()->getID($updateUserID);
307308
$dateUpdatedFormatted = Gdn::getContainer()->get(DateTimeFormatter::class)->formatDate($dateUpdated, false, DateTimeFormatter::FORCE_FULL_FORMAT);
308-
if ($updateUser) {
309+
if ($updateUser && $insertUserID != $updateUserID) {
309310
$title = sprintf(t('Edited %s by %s.'), $dateUpdatedFormatted, val('Name', $updateUser));
310311
$link = userAnchor($updateUser);
311312
$text = sprintf(t('edited %s by %s'), $dateUpdatedFormatted, $link);
@@ -803,4 +804,105 @@ function myDraftsMenuItem($CountDrafts) {
803804
$cssClass .= $CountDrafts == 0 ? ' hidden': '';
804805
return sprintf('<li id="MyDrafts" class="%s">%s</li>', $cssClass, anchor(sprite('SpMyDrafts').$Drafts, '/drafts'));
805806
}
807+
}
808+
809+
if(!function_exists('writeInlineDiscussionOptions')) {
810+
function writeInlineDiscussionOptions($discussionRow) {
811+
$discussionID = val('DiscussionID', $discussionRow);
812+
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
813+
//Gdn_Theme::bulletRow();
814+
echo '<div class="Controls flex">';
815+
echo '<div class="left">';
816+
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
817+
Gdn::controller()->fireEvent('InlineDiscussionOptionsLeft');
818+
echo '</div>';
819+
echo '<div class="center"></div>';
820+
echo '<div class="right">';
821+
822+
// Write the items.
823+
// DropdownModule
824+
$discussionDropdown = getDiscussionOptionsDropdown($discussionRow);
825+
826+
// Allow plugins to edit the dropdown.
827+
$sender = Gdn::controller();
828+
$sender->EventArguments['DiscussionOptions'] = &$discussionDropdown ;
829+
$sender->EventArguments['Discussion'] = $discussionRow;
830+
$sender->fireEvent('InlineDiscussionOptions');
831+
832+
$discussionDropdownItems = $discussionDropdown->toArray()['items'];
833+
834+
unset($discussionDropdownItems['announce']);
835+
unset($discussionDropdownItems['sink']);
836+
unset($discussionDropdownItems['close']);
837+
unset($discussionDropdownItems['dismiss']);
838+
unset($discussionDropdownItems['move']);
839+
unset($discussionDropdownItems['tag']);
840+
841+
if (!empty($discussionDropdownItems) && is_array($discussionDropdownItems)) {
842+
array_walk($discussionDropdownItems, function(&$value, $key) {
843+
$anchor = anchor($value['text'], $value['url'], val('cssClass', $value, $key));
844+
$value = '<span class="" style="">'.$anchor.'</span>';
845+
});
846+
847+
echo implode('<span class="MiddleDot">·</span>', $discussionDropdownItems);
848+
}
849+
echo '</div>';
850+
echo '</div>';
851+
852+
}
853+
}
854+
855+
if(!function_exists('writeInlineCommentOptions')) {
856+
function writeInlineCommentOptions($comment) {
857+
$iD = val('CommentID', $comment);
858+
Gdn::controller()->EventArguments['RecordID'] = $iD;
859+
//Gdn_Theme::bulletRow();
860+
echo '<div class="Controls flex">';
861+
echo '<div class="left"></div>';
862+
echo '<div class="center"></div>';
863+
echo '<div class="right">';
864+
865+
// Write the items.
866+
$items = getCommentOptions($comment);
867+
if (!empty($items) && is_array($items)) {
868+
array_walk($items, function(&$value, $key) {
869+
$anchor = anchor($value['Label'], $value['Url'], val('Class', $value, $key));
870+
$value = '<span class="" style="">'.$anchor.'</span>';
871+
});
872+
echo implode('<span class="MiddleDot">·</span>', $items);
873+
}
874+
echo '</div>';
875+
echo '</div>';
876+
877+
}
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+
}
806908
}

services/flush_cache.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[group:flush_cache]
2+
programs=flush_cache
3+
priority=1
4+
5+
[program:flush_cache]
6+
command=/opt/docker/bin/service.d/flush_cache.sh
7+
process_name=%(program_name)s
8+
startsecs=0
9+
startretries=0
10+
autostart=true
11+
autorestart=false
12+
stdout_logfile=/dev/stdout
13+
stdout_logfile_maxbytes=0
14+
stderr_logfile=/dev/stderr
15+
stderr_logfile_maxbytes=0

services/flush_cache.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
MEMCACHED_SERVER_HOST=$(echo $MEMCACHED_SERVER| cut -d':' -f 1)
3+
MEMCACHED_SERVER_PORT=$(echo $MEMCACHED_SERVER| cut -d':' -f 2)
4+
echo flush_cache.sh: connecting to $MEMCACHED_SERVER
5+
echo flush_all | nc -q5 $MEMCACHED_SERVER_HOST $MEMCACHED_SERVER_PORT
6+
nc_exit_code=$?
7+
if [ $nc_exit_code != 0 ]; then
8+
echo flush_cache.sh: exit code $nc_exit_code
9+
else
10+
echo flush_cache.sh: connection was made and completed successfully
11+
fi

vanilla/applications/dashboard/views/email/email-basic.tpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@
156156
<p class="message" style='margin: 0;Margin-bottom: 10px;padding: 0;color: {$email.textColor};text-align: left;margin-top: 10px;
157157
margin-bottom: 15px'>{$email.message}</p>
158158
{if $email.button}
159-
<div style="margin: 0;padding: 0; text-align: center">
160-
<a class="button" href="{$email.button.url}" style="margin: 0;padding: 0;color: {$email.button.textColor};
161-
cursor: pointer;display: inline-block;" rel=" noopener noreferrer" target="_blank">{$email.button.text}</a>
159+
<div style="margin: 5px 0px;padding: 0;text-align: center">
160+
<a class="button" href="{$email.button.url}" style="font-size: 12px;
161+
border: 1px solid #137D60;min-width: 36px;background: #137D60;color: #FAFAFB;line-height: 30px;min-height: 30px;text-decoration: none;
162+
white-space: nowrap;text-align: center;font-weight: 700 !important;letter-spacing: .69px !important; text-transform: uppercase;
163+
border-radius: 20px !important; padding: 10px 20px !important;" rel=" noopener noreferrer" target="_blank">{$email.button.text}</a>
162164
</div>
163165
{/if}
164166

vanilla/applications/vanilla/controllers/api/CategoriesApiController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function __construct(
5151
*/
5252
public function categoryPostSchema($type = '', array $extra = []) {
5353
if ($this->categoryPostSchema === null) {
54-
$fields = ['name', 'parentCategoryID?', 'urlcode', 'displayAs?', 'customPermissions?', 'groupID?'];
54+
$fields = ['name', 'parentCategoryID?', 'urlcode', 'displayAs?', 'customPermissions?',
55+
'groupID?', 'archived?'];
5556
$this->categoryPostSchema = $this->schema(
5657
Schema::parse(array_merge($fields, $extra))->add($this->schemaWithParent()),
5758
'CategoryPost'
@@ -129,7 +130,7 @@ protected function fullSchema() {
129130
'parentCategoryID:i|n' => 'Parent category ID.',
130131
'groupID:i|n' => 'Group ID.',
131132
'customPermissions:b' => 'Are custom permissions set for this category?',
132-
'isArchived:b' => 'The archived state of this category.',
133+
'archived:b' => 'The archived state of this category.',
133134
'urlcode:s' => 'The URL code of the category.',
134135
'url:s' => 'The URL to the category.',
135136
'displayAs:s' => [
@@ -551,9 +552,6 @@ public function normalizeOutput(array $dbRecord) {
551552
if (!empty($dbRecord['Children']) && is_array($dbRecord['Children'])) {
552553
$dbRecord['Children'] = array_map([$this, 'normalizeOutput'], $dbRecord['Children']);
553554
}
554-
555-
$dbRecord['isArchived'] = $dbRecord['Archived'];
556-
557555
$schemaRecord = ApiUtils::convertOutputKeys($dbRecord);
558556
return $schemaRecord;
559557
}

vanilla/applications/vanilla/controllers/class.categoriescontroller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public function all($Category = '', $displayAs = '') {
539539
if ($Title) {
540540
$this->title($Title, '');
541541
} else {
542-
$this->title(t('Roundtables'));
542+
$this->title(t('Public Forums'));
543543
}
544544
}
545545
Gdn_Theme::section('CategoryList');
@@ -614,7 +614,7 @@ public function all($Category = '', $displayAs = '') {
614614
}
615615
// FIX: https://github.com/topcoder-platform/forums/issues/422
616616
// Sorting for Flat type in SQL
617-
if($displayAs != 'Flat') {
617+
if($displayAs != 'Flat' && $Category) {
618618
if ($this->data('CategorySort')) {
619619
if ($this->data('CategorySort') == self::SORT_OLDEST_POST) {
620620
usort($categoryTree, function ($a, $b) {
@@ -677,7 +677,7 @@ public function discussions($Category = '') {
677677
if ($Title) {
678678
$this->title($Title, '');
679679
} else {
680-
$this->title(t('Roundtables'));
680+
$this->title(t('Public Forums'));
681681
}
682682
}
683683

vanilla/applications/vanilla/controllers/class.vanillacontroller.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414
class VanillaController extends Gdn_Controller {
1515

16-
const ROOT_CATEGORY = ['Name' => 'Roundtables', 'Url'=>'/'];
17-
16+
const ROOT_CATEGORY = ['Name' => 'Public Forums', 'Url'=>'/'];
17+
const CHALLENGE_FORUMS_URLCODE = 'challenges-forums';
1818
/**
1919
* Include JS, CSS, and modules used by all methods.
2020
*
@@ -81,15 +81,27 @@ protected function buildBreadcrumbs($CategoryID) {
8181
if($ancestor['GroupID'] > 0) {
8282
$temp[$ancestor['CategoryID']] = $ancestor;
8383
} else {
84-
if($ancestor['UrlCode'] == 'challenges-forums') {
85-
array_push($temp, ['Name' => 'Challenge Discussions', 'Url'=>'/groups/mine?filter=challenge']);
84+
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
85+
array_push($temp, ['Name' => 'Challenge Forums', 'Url'=>'/groups/mine?filter=challenge']);
8686
}else if($ancestor['UrlCode'] == 'groups') {
87-
array_push($temp, ['Name' => 'Group Discussions', 'Url'=>'/groups/mine?filter=regular']);
87+
array_push($temp, ['Name' => 'Group Forums', 'Url'=>'/groups/mine?filter=regular']);
8888
}
8989
}
9090
}
9191
return $temp;
9292
} else {
93+
$urlCode = val('UrlCode', $Category);
94+
if($urlCode == self::CHALLENGE_FORUMS_URLCODE) {
95+
return $ancestors;
96+
}
97+
98+
// Check if ancestors contains 'challenges-forums'
99+
foreach ($ancestors as $id => $ancestor) {
100+
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
101+
return $ancestors;
102+
}
103+
}
104+
93105
array_unshift($ancestors, self::ROOT_CATEGORY);
94106
return $ancestors;
95107
}

vanilla/applications/vanilla/js/discussion.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ jQuery(document).ready(function($) {
310310
$(container).addClass('Editing');
311311
var parent = $(container).find('div.Comment');
312312
var msg = $(parent).find('div.Message').first();
313+
var commentControls = $(container).find('.Controls');
313314
$(parent).find('div.Meta span:last').after('<span class="TinyProgress">&#160;</span>');
314315
if (!parent.find('.EditCommentForm').length) {
315316
$.ajax({
@@ -323,6 +324,7 @@ jQuery(document).ready(function($) {
323324
success: function(json) {
324325
$(msg).afterTrigger(json.Data);
325326
$(msg).hide();
327+
$(commentControls).hide();
326328
$(document).trigger('EditCommentFormLoaded', [container]);
327329

328330
// Dispatch a native event for things that don't use jquery
@@ -341,6 +343,7 @@ jQuery(document).ready(function($) {
341343
$(parent).find('div.EditCommentForm').remove();
342344
$(parent).find('span.TinyProgress').remove();
343345
$(msg).show();
346+
$(commentControls).show();
344347
}
345348

346349
$(document).trigger('CommentEditingComplete', [msg]);
@@ -352,6 +355,7 @@ jQuery(document).ready(function($) {
352355
var $container = $(btn).closest('.ItemComment');
353356
$(btn).closest('.Comment').find('.MenuItems').attr('style', '');
354357
$(btn).closest('.Comment').find('div.Message').show();
358+
$(btn).closest('.Comment').find('.Controls').show();
355359
$(btn).closest('.CommentForm, .EditCommentForm').remove();
356360
$container.removeClass('Editing');
357361
return false;

0 commit comments

Comments
 (0)