Skip to content

Commit 03e039f

Browse files
committed
Fixed forums-plugins/issues-6
1 parent 065374e commit 03e039f

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ RUN git clone https://github.com/topcoder-platform/forums-plugins.git /tmp/forum
1414
# Copy all plugins to the Vanilla plugins folder
1515
RUN cp -r /tmp/forums-plugins/. /vanillapp/plugins
1616
# Copy Vanilla boostrap file
17-
COPY ./config/vanilla/bootstrap.early.php /vanillapp/conf/bootstrap.early.php
17+
COPY ./config/vanilla/. /vanillapp/conf/.

config/vanilla/bootstrap.before.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
function formatString($string, $args = []) {
2626
_formatStringCallback($args, true);
2727
$result = preg_replace_callback('/{([^\s][^}]+[^\s]?)}/', '_formatStringCallback', $string);
28-
2928
return $result;
3029
}
3130
}
@@ -204,7 +203,6 @@ function _formatStringCallback($match, $setArgs = false) {
204203
case 'his':
205204
case 'her':
206205
case 'your':
207-
// $Result = print_r($Value, true);
208206
$argsBak = $args;
209207
if (is_array($value) && count($value) == 1) {
210208
$value = array_shift($value);
@@ -214,7 +212,6 @@ function _formatStringCallback($match, $setArgs = false) {
214212
if (isset($value['UserID'])) {
215213
$user = $value;
216214
$user['Name'] = formatUsername($user, $format, $contextUserID);
217-
218215
$result = userAnchor($user);
219216
} else {
220217
$max = c('Garden.FormatUsername.Max', 5);
@@ -260,7 +257,13 @@ function _formatStringCallback($match, $setArgs = false) {
260257
// Store this name separately because of special 'You' case.
261258
$name = formatUsername($user, $format, $contextUserID);
262259
// Manually build instead of using userAnchor() because of special 'You' case.
263-
$result = anchor(htmlspecialchars($name), userUrl($user));
260+
if(function_exists('topcoderRatingCssClass')) {
261+
$ratingCssClass = topcoderRatingCssClass($user->Name);
262+
$result = anchor(htmlspecialchars($name), userUrl($user), $ratingCssClass);
263+
} else {
264+
$result = anchor(htmlspecialchars($name), userUrl($user));
265+
}
266+
264267
} else {
265268
$result = '';
266269
}

config/vanilla/bootstrap.early.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php if (!defined('APPLICATION')) exit();
22

3-
$Database = Gdn::database();
4-
$SQL = $Database->sql();
3+
if (c('Garden.Installed')) {
4+
$Database = Gdn::database();
5+
$SQL = $Database->sql();
56

6-
// use Vanilla\Web\CacheControlMiddleware;
7+
// Logging
8+
// saveToConfig('DebugAssets', true);
9+
// saveToConfig('Debug', true);
710

8-
if (c('Garden.Installed')) {
911
//Disable plugins
1012
saveToConfig('EnabledPlugins.stubcontent', false);
1113

@@ -26,18 +28,24 @@
2628
saveToConfig('Garden.ThemeOptions.Options.panelToLeft',true);
2729

2830
// Add settings for the Topcoder plugin
29-
saveToConfig('Plugins.Topcoder.BaseApiURL', 'https://api.topcoder-dev.com');
30-
saveToConfig('Plugins.Topcoder.MemberApiURI', '/v3/members');
31-
saveToConfig('Plugins.Topcoder.MemberProfileURL', 'https://www.topcoder.com/members');
31+
if(c('Plugins.Topcoder.BaseApiURL') === false) {
32+
saveToConfig('Plugins.Topcoder.BaseApiURL', 'https://api.topcoder-dev.com');
33+
saveToConfig('Plugins.Topcoder.MemberApiURI', '/v3/members');
34+
saveToConfig('Plugins.Topcoder.MemberProfileURL', 'https://www.topcoder.com/members');
35+
}
3236

3337
// Add settings for the Editor plugin
34-
saveToConfig('Plugins.editor.ForceWysiwyg', false);
38+
if(c('Plugins.editor.ForceWysiwyg') === false) {
39+
saveToConfig('Plugins.editor.ForceWysiwyg', false);
40+
}
3541

3642
// Add settings for the Syntax Prettifier plugin
37-
saveToConfig('Plugins.GooglePrettify.LineNumbers', '');
38-
saveToConfig('Plugins.GooglePrettify.NoCssFile', '');
39-
saveToConfig('Plugins.GooglePrettify.UseTabby', '');
40-
saveToConfig('Plugins.GooglePrettify.Language','');
43+
if(c('Plugins.GooglePrettify.LineNumbers') === false) {
44+
saveToConfig('Plugins.GooglePrettify.LineNumbers', '');
45+
saveToConfig('Plugins.GooglePrettify.NoCssFile', '');
46+
saveToConfig('Plugins.GooglePrettify.UseTabby', '');
47+
saveToConfig('Plugins.GooglePrettify.Language', '');
48+
}
4149

4250
//Add settings for the OAuth 2 SSO plugin
4351
if ($SQL->getWhere('UserAuthenticationProvider', ['AuthenticationKey' => 'oauth2'])->numRows() == 0) {
@@ -55,6 +63,4 @@
5563
'IsDefault' => 1
5664
]);
5765
}
58-
}
59-
60-
66+
}

0 commit comments

Comments
 (0)