Commit 09c41fad authored by Liang Ding's avatar Liang Ding

🎨 Fix #12699

parent 0b721591
...@@ -162,11 +162,6 @@ public final class Option { ...@@ -162,11 +162,6 @@ public final class Option {
*/ */
public static final String ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "allowVisitDraftViaPermalink"; public static final String ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "allowVisitDraftViaPermalink";
/**
* Key of allow register.
*/
public static final String ID_C_ALLOW_REGISTER = "allowRegister";
/** /**
* Key of version. * Key of version.
*/ */
...@@ -396,11 +391,6 @@ public final class Option { ...@@ -396,11 +391,6 @@ public final class Option {
*/ */
public static final String DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "false"; public static final String DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "false";
/**
* Default allow register.
*/
public static final String DEFAULT_ALLOW_REGISTER = "true";
/** /**
* Default allow comment article/page. * Default allow comment article/page.
*/ */
......
...@@ -290,13 +290,6 @@ public class B3Receiver { ...@@ -290,13 +290,6 @@ public class B3Receiver {
final JSONObject commenter = userRepository.getByUserName(commentName); final JSONObject commenter = userRepository.getByUserName(commentName);
if (null == commenter) { if (null == commenter) {
// 社区回帖同步博客评论 https://github.com/b3log/solo/issues/12691 // 社区回帖同步博客评论 https://github.com/b3log/solo/issues/12691
if (!optionQueryService.allowRegister()) {
ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not allow register");
return;
}
final JSONObject addUserReq = new JSONObject(); final JSONObject addUserReq = new JSONObject();
addUserReq.put(User.USER_NAME, commentName); addUserReq.put(User.USER_NAME, commentName);
addUserReq.put(UserExt.USER_AVATAR, commentThumbnailURL); addUserReq.put(UserExt.USER_AVATAR, commentThumbnailURL);
...@@ -314,6 +307,13 @@ public class B3Receiver { ...@@ -314,6 +307,13 @@ public class B3Receiver {
} }
} }
if (!optionQueryService.allowComment() || !article.optBoolean(Article.ARTICLE_COMMENTABLE)) {
ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not allow comment");
return;
}
String commentContent = symCmt.getString("content"); // Markdown String commentContent = symCmt.getString("content"); // Markdown
final Transaction transaction = commentRepository.beginTransaction(); final Transaction transaction = commentRepository.beginTransaction();
......
...@@ -190,13 +190,6 @@ public class OAuthProcessor { ...@@ -190,13 +190,6 @@ public class OAuthProcessor {
} else { } else {
user = userQueryService.getUserByName(userName); user = userQueryService.getUserByName(userName);
if (null == user) { if (null == user) {
if (!optionQueryService.allowRegister()) {
context.attr(Keys.MSG, langPropsService.get("notAllowRegisterLabel"));
context.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONObject addUserReq = new JSONObject(); final JSONObject addUserReq = new JSONObject();
addUserReq.put(User.USER_NAME, userName); addUserReq.put(User.USER_NAME, userName);
addUserReq.put(UserExt.USER_AVATAR, userAvatar); addUserReq.put(UserExt.USER_AVATAR, userAvatar);
......
...@@ -162,7 +162,6 @@ public class PreferenceConsole { ...@@ -162,7 +162,6 @@ public class PreferenceConsole {
* "signHTML": "" * "signHTML": ""
* }, ...]", * }, ...]",
* "allowVisitDraftViaPermalink": boolean, * "allowVisitDraftViaPermalink": boolean,
* "allowRegister": boolean,
* "version": "", * "version": "",
* "articleListStyle": "", // Optional values: "titleOnly"/"titleAndContent"/"titleAndAbstract" * "articleListStyle": "", // Optional values: "titleOnly"/"titleAndContent"/"titleAndAbstract"
* "commentable": boolean, * "commentable": boolean,
...@@ -241,7 +240,6 @@ public class PreferenceConsole { ...@@ -241,7 +240,6 @@ public class PreferenceConsole {
* "signHTML": "" * "signHTML": ""
* }, ...], * }, ...],
* "allowVisitDraftViaPermalink": boolean, * "allowVisitDraftViaPermalink": boolean,
* "allowRegister": boolean,
* "articleListStyle": "", * "articleListStyle": "",
* "commentable": boolean, * "commentable": boolean,
* "feedOutputMode: "", * "feedOutputMode: "",
......
...@@ -605,12 +605,6 @@ public class InitService { ...@@ -605,12 +605,6 @@ public class InitService {
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK); allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
optionRepository.add(allowVisitDraftViaPermalinkOpt); optionRepository.add(allowVisitDraftViaPermalinkOpt);
final JSONObject allowRegisterOpt = new JSONObject();
allowRegisterOpt.put(Keys.OBJECT_ID, Option.ID_C_ALLOW_REGISTER);
allowRegisterOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
allowRegisterOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_ALLOW_REGISTER);
optionRepository.add(allowRegisterOpt);
final JSONObject commentableOpt = new JSONObject(); final JSONObject commentableOpt = new JSONObject();
commentableOpt.put(Keys.OBJECT_ID, Option.ID_C_COMMENTABLE); commentableOpt.put(Keys.OBJECT_ID, Option.ID_C_COMMENTABLE);
commentableOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); commentableOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
......
...@@ -63,17 +63,17 @@ public class OptionQueryService { ...@@ -63,17 +63,17 @@ public class OptionQueryService {
} }
/** /**
* Checks whether allow register. * Checks whether allow comment globally.
* *
* @return {@code true} to allow register, returns {@code false} otherwise * @return {@code true} to allow comment, returns {@code false} otherwise
*/ */
public boolean allowRegister() { public boolean allowComment() {
try { try {
final JSONObject opt = optionRepository.get(Option.ID_C_ALLOW_REGISTER); final JSONObject opt = optionRepository.get(Option.ID_C_COMMENTABLE);
return opt.optBoolean(Option.OPTION_VALUE); return opt.optBoolean(Option.OPTION_VALUE);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Checks allow register failed", e); LOGGER.log(Level.ERROR, "Checks allow comment failed", e);
return false; return false;
} }
......
...@@ -191,10 +191,6 @@ public class PreferenceMgmtService { ...@@ -191,10 +191,6 @@ public class PreferenceMgmtService {
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK)); allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK));
optionRepository.update(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK, allowVisitDraftViaPermalinkOpt); optionRepository.update(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK, allowVisitDraftViaPermalinkOpt);
final JSONObject allowRegisterOpt = optionRepository.get(Option.ID_C_ALLOW_REGISTER);
allowRegisterOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_REGISTER));
optionRepository.update(Option.ID_C_ALLOW_REGISTER, allowRegisterOpt);
final JSONObject articleListDisplayCountOpt = optionRepository.get(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT); final JSONObject articleListDisplayCountOpt = optionRepository.get(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT);
articleListDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT)); articleListDisplayCountOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT));
optionRepository.update(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT, articleListDisplayCountOpt); optionRepository.update(Option.ID_C_ARTICLE_LIST_DISPLAY_COUNT, articleListDisplayCountOpt);
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.upgrade;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.FilterOperator;
import org.b3log.latke.repository.PropertyFilter;
import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.OptionRepository;
import org.json.JSONObject;
import java.sql.Connection;
import java.sql.Statement;
import java.util.List;
/**
* Upgrade script from v3.2.0 to v3.3.0.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Mar 6, 2019
* @since 3.3.0
*/
public final class V320_330 {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(V320_330.class);
/**
* Performs upgrade from v3.2.0 to v3.3.0.
*
* @throws Exception upgrade fails
*/
public static void perform() throws Exception {
final String fromVer = "3.2.0";
final String toVer = "3.3.0";
LOGGER.log(Level.INFO, "Upgrading from version [" + fromVer + "] to version [" + toVer + "]....");
final BeanManager beanManager = BeanManager.getInstance();
final OptionRepository optionRepository = beanManager.getReference(OptionRepository.class);
final ArticleRepository articleRepository = beanManager.getReference(ArticleRepository.class);
try {
final Transaction transaction = optionRepository.beginTransaction();
optionRepository.remove("allowRegister");
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_VALUE, toVer);
optionRepository.update(Option.ID_C_VERSION, versionOpt);
transaction.commit();
LOGGER.log(Level.INFO, "Upgraded from version [" + fromVer + "] to version [" + toVer + "] successfully");
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Upgrade failed!", e);
throw new Exception("Upgrade failed from version [" + fromVer + "] to version [" + toVer + "]");
}
}
}
...@@ -70,8 +70,6 @@ dynamicLabel=Dynamic ...@@ -70,8 +70,6 @@ dynamicLabel=Dynamic
exportSQLLabel=Export SQL file exportSQLLabel=Export SQL file
exportJSONLabel=Export JSON file exportJSONLabel=Export JSON file
exportHexoLabel=Export Hexo file exportHexoLabel=Export Hexo file
notAllowRegisterLabel=Not allow register
allowRegister1Label=Allow Register:
footerContent1Label=Footer: footerContent1Label=Footer:
userAvatar1Label=Avatar: userAvatar1Label=Avatar:
staticErrorLabel=<h2>Latke Configuraton Error</h2>\ staticErrorLabel=<h2>Latke Configuraton Error</h2>\
......
...@@ -70,8 +70,6 @@ dynamicLabel=\u52A8\u6001 ...@@ -70,8 +70,6 @@ dynamicLabel=\u52A8\u6001
exportSQLLabel=\u5BFC\u51FA SQL \u6587\u4EF6 exportSQLLabel=\u5BFC\u51FA SQL \u6587\u4EF6
exportJSONLabel=\u5BFC\u51FA JSON \u6587\u4EF6 exportJSONLabel=\u5BFC\u51FA JSON \u6587\u4EF6
exportHexoLabel=\u5BFC\u51FA Hexo \u6587\u4EF6 exportHexoLabel=\u5BFC\u51FA Hexo \u6587\u4EF6
notAllowRegisterLabel=\u6682\u4E0D\u5F00\u653E\u6CE8\u518C\uFF01
allowRegister1Label=\u5141\u8BB8\u6CE8\u518C\uFF1A
footerContent1Label=\u9875\u811A\uFF1A footerContent1Label=\u9875\u811A\uFF1A
userAvatar1Label=\u5934\u50CF\uFF1A userAvatar1Label=\u5934\u50CF\uFF1A
staticErrorLabel=<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> \u914D\u7F6E\u9519\u8BEF</h2>\ staticErrorLabel=<h2><a href='https://hacpai.com/tag/Latke' target='_blank'>Latke</a> \u914D\u7F6E\u9519\u8BEF</h2>\
......
...@@ -23,18 +23,18 @@ ...@@ -23,18 +23,18 @@
# #
#### H2 runtime #### #### H2 runtime ####
runtimeDatabase=H2 #runtimeDatabase=H2
jdbc.username=root #jdbc.username=root
jdbc.password= #jdbc.password=
jdbc.driver=org.h2.Driver #jdbc.driver=org.h2.Driver
jdbc.URL=jdbc:h2:~/solo_h2/db #jdbc.URL=jdbc:h2:~/solo_h2/db
#### MySQL runtime #### #### MySQL runtime ####
#runtimeDatabase=MYSQL runtimeDatabase=MYSQL
#jdbc.username=root jdbc.username=root
#jdbc.password=123456 jdbc.password=123456
#jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.driver=com.mysql.cj.jdbc.Driver
#jdbc.URL=jdbc:mysql://localhost:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC jdbc.URL=jdbc:mysql://localhost:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC
# The minConnCnt MUST larger or equal to 3 # The minConnCnt MUST larger or equal to 3
jdbc.minConnCnt=5 jdbc.minConnCnt=5
......
...@@ -106,8 +106,6 @@ ...@@ -106,8 +106,6 @@
<input id="allowVisitDraftViaPermalink" type="checkbox" class="normalInput"/> <input id="allowVisitDraftViaPermalink" type="checkbox" class="normalInput"/>
<label for="commentable">${allowComment1Label}</label> <label for="commentable">${allowComment1Label}</label>
<input id="commentable" type="checkbox" class="normalInput"/> <input id="commentable" type="checkbox" class="normalInput"/>
<label for="allowRegister">${allowRegister1Label}</label>
<input id="allowRegister" type="checkbox" class="normalInput"/>
<label for="feedOutputMode">${feedOutputModel1Label}</label> <label for="feedOutputMode">${feedOutputModel1Label}</label>
<select id="feedOutputMode"> <select id="feedOutputMode">
<option value="abstract">${abstractLabel}</option> <option value="abstract">${abstractLabel}</option>
......
This diff is collapsed.
...@@ -78,9 +78,6 @@ admin.preference = { ...@@ -78,9 +78,6 @@ admin.preference = {
'true' === preference.allowVisitDraftViaPermalink ? $( 'true' === preference.allowVisitDraftViaPermalink ? $(
'#allowVisitDraftViaPermalink').attr('checked', 'checked') : $( '#allowVisitDraftViaPermalink').attr('checked', 'checked') : $(
'allowVisitDraftViaPermalink').removeAttr('checked') 'allowVisitDraftViaPermalink').removeAttr('checked')
'true' === preference.allowRegister ? $('#allowRegister').
attr('checked', 'checked') : $('#allowRegister').
removeAttr('checked')
'true' === preference.commentable ? $('#commentable'). 'true' === preference.commentable ? $('#commentable').
attr('checked', 'checked') : $('commentable').removeAttr('checked') attr('checked', 'checked') : $('commentable').removeAttr('checked')
...@@ -258,7 +255,6 @@ admin.preference = { ...@@ -258,7 +255,6 @@ admin.preference = {
'feedOutputMode': $('#feedOutputMode').val(), 'feedOutputMode': $('#feedOutputMode').val(),
'feedOutputCnt': $('#feedOutputCnt').val(), 'feedOutputCnt': $('#feedOutputCnt').val(),
'commentable': $('#commentable').prop('checked'), 'commentable': $('#commentable').prop('checked'),
'allowRegister': $('#allowRegister').prop('checked'),
'customVars': $('#customVars').val(), 'customVars': $('#customVars').val(),
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment