Просмотр исходного кода

Implement: file upload flag on admin

Sotaro KARASAWA 9 лет назад
Родитель
Сommit
bc8cc1e633
3 измененных файлов с 35 добавлено и 3 удалено
  1. 2 1
      lib/form/admin/app.js
  2. 13 2
      lib/models/config.js
  3. 20 0
      lib/views/admin/app.html

+ 2 - 1
lib/form/admin/app.js

@@ -5,6 +5,7 @@ var form = require('express-form')
 
 
 module.exports = form(
 module.exports = form(
   field('settingForm[app:title]').required(),
   field('settingForm[app:title]').required(),
-  field('settingForm[app:confidential]')
+  field('settingForm[app:confidential]'),
+  field('settingForm[app:fileUpload]').isInt()
 );
 );
 
 

+ 13 - 2
lib/models/config.js

@@ -23,6 +23,8 @@ module.exports = function(crowi) {
       'app:title'         : 'Crowi',
       'app:title'         : 'Crowi',
       'app:confidential'  : '',
       'app:confidential'  : '',
 
 
+      'app:fileUpload'    : false,
+
       'security:registrationMode'      : 'Open',
       'security:registrationMode'      : 'Open',
       'security:registrationWhiteList' : [],
       'security:registrationWhiteList' : [],
 
 
@@ -37,8 +39,6 @@ module.exports = function(crowi) {
       'mail:smtpUser'     : '',
       'mail:smtpUser'     : '',
       'mail:smtpPassword' : '',
       'mail:smtpPassword' : '',
 
 
-      'searcher:url': '',
-
       'google:clientId'     : '',
       'google:clientId'     : '',
       'google:clientSecret' : '',
       'google:clientSecret' : '',
 
 
@@ -180,6 +180,17 @@ module.exports = function(crowi) {
     return method != 'none';
     return method != 'none';
   };
   };
 
 
+  configSchema.statics.fileUploadEnabled = function(config)
+  {
+    const Config = this;
+
+    if (!Config.isUploadable(config)) {
+      return false;
+    }
+
+    return config.crowi['app:fileUpload'] || false;
+  };
+
   configSchema.statics.hasSlackConfig = function(config)
   configSchema.statics.hasSlackConfig = function(config)
   {
   {
     if (!config.notification) {
     if (!config.notification) {

+ 20 - 0
lib/views/admin/app.html

@@ -52,6 +52,26 @@
           </div>
           </div>
         </div>
         </div>
 
 
+        <div class="form-group">
+          <div class="col-xs-offset-3 col-xs-6">
+            <input type="checkbox" name="settingForm[app:fileUpload]" value="1"
+              {% if settingForm['app:fileUpload'] %}
+              checked
+              {% endif %}
+              {% if not isUploadable() %}
+              disabled="disabled"
+              {% else %}
+              {% endif %}
+              >
+              <label for="settingForm[app:fileUpload]" class="">画像以外のファイルアップロードを許可</label>
+
+              <p class="help-block">
+                ファイルアップロードの設定を有効にしている場合にのみ、選択可能です。<br>
+                許可をしている場合、画像以外のファイルをページに添付可能になります。
+              </p>
+          </div>
+        </div>
+
         <div class="form-group">
         <div class="form-group">
           <div class="col-xs-offset-3 col-xs-6">
           <div class="col-xs-offset-3 col-xs-6">
             <input type="hidden" name="_csrf" value="{{ csrf() }}">
             <input type="hidden" name="_csrf" value="{{ csrf() }}">