diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index 83c86c470..39cc6678c 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -25,7 +25,7 @@ class SystemController extends AbstractController * @apiParam {String} type * - get: 获取(默认) * - all: 获取所有(需要管理员权限) - * - save: 保存设置(参数:reg、reg_invite、login_code、password_policy、project_invite、chat_nickname、auto_archived、archived_day、start_home、home_footer) + * - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'start_home', 'home_footer']) * @apiSuccess {Number} ret 返回状态码(1正确、0错误) * @apiSuccess {String} msg 返回信息(错误描述) @@ -41,7 +41,18 @@ public function setting() User::auth('admin'); $all = Request::input(); foreach ($all AS $key => $value) { - if (!in_array($key, ['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'start_home', 'home_footer'])) { + if (!in_array($key, [ + 'reg', + 'reg_invite', + 'login_code', + 'password_policy', + 'project_invite', + 'chat_nickname', + 'auto_archived', + 'archived_day', + 'start_home', + 'home_footer' + ])) { unset($all[$key]); } } @@ -78,7 +89,7 @@ public function setting() } /** - * @api {get} api/system/setting/email 02. 获取邮箱设置、保存邮箱设置 + * @api {get} api/system/setting/email 02. 获取邮箱设置、保存邮箱设置(限管理员) * * @apiVersion 1.0.0 * @apiGroup system @@ -86,23 +97,32 @@ public function setting() * * @apiParam {String} type * - get: 获取(默认) - * - all: 获取所有(需要管理员权限) - * - save: 保存设置(参数:smtp_server port account password reg_verify notice task_remind_hours task_remind_hours2) + * - save: 保存设置(参数:['smtp_server', 'port', 'account', 'password', 'reg_verify', 'notice', 'task_remind_hours', 'task_remind_hours2']) * @apiSuccess {Number} ret 返回状态码(1正确、0错误) * @apiSuccess {String} msg 返回信息(错误描述) * @apiSuccess {Object} data 返回数据 */ public function setting__email() { + User::auth('admin'); + // $type = trim(Request::input('type')); if ($type == 'save') { if (env("SYSTEM_SETTING") == 'disabled') { return Base::retError('当前环境禁止修改'); } - User::auth('admin'); $all = Request::input(); foreach ($all as $key => $value) { - if (!in_array($key, ['smtp_server', 'port', 'account', 'password', 'reg_verify', 'notice', 'task_remind_hours', 'task_remind_hours2'])) { + if (!in_array($key, [ + 'smtp_server', + 'port', + 'account', + 'password', + 'reg_verify', + 'notice', + 'task_remind_hours', + 'task_remind_hours2' + ])) { unset($all[$key]); } } @@ -111,13 +131,6 @@ public function setting__email() $setting = Base::setting('emailSetting'); } // - if ($type == 'all' || $type == 'save') { - User::auth('admin'); - $setting['reg_invite'] = $setting['reg_invite'] ?: Base::generatePassword(8); - } else { - if (isset($setting['reg_invite'])) unset($setting['reg_invite']); - } - // $setting['smtp_server'] = $setting['smtp_server'] ?: ''; $setting['port'] = $setting['port'] ?: ''; $setting['account'] = $setting['account'] ?: ''; @@ -533,7 +546,6 @@ public function fileupload() return $data; } - /** * @api {get} api/system/get/starthome 14. 启动首页设置信息 * diff --git a/app/Module/Base.php b/app/Module/Base.php index c45399815..1a8135003 100755 --- a/app/Module/Base.php +++ b/app/Module/Base.php @@ -1218,11 +1218,12 @@ public static function strReplaceLimit($search, $replace, $subject, $limit = -1) /** * 获取或设置 - * @param $setname //配置名称 - * @param bool $array //保存内容 + * @param $setname // 配置名称 + * @param bool $array // 保存内容 + * @param false $isUpdate // 保存内容为更新模式,默认否 * @return array */ - public static function setting($setname, $array = false) + public static function setting($setname, $array = false, $isUpdate = false) { global $_A; if (empty($setname)) { @@ -1233,15 +1234,19 @@ public static function setting($setname, $array = false) } $setting = []; $row = Setting::whereName($setname)->first(); - if (!empty($row)) { + if ($row) { $setting = Base::string2array($row->setting); } else { $row = Setting::createInstance(['name' => $setname]); $row->save(); } if ($array !== false) { - $setting = $array; - $row->updateInstance(['setting' => $array]); + if ($isUpdate && is_array($array)) { + $setting = array_merge($setting, $array); + } else { + $setting = $array; + } + $row->updateInstance(['setting' => $setting]); $row->save(); } $_A["__static_setting_" . $setname] = $setting; diff --git a/composer.json b/composer.json index 5156e792d..3dc3b9408 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "ext-simplexml": "*", "fideloper/proxy": "^4.4.1", "fruitcake/laravel-cors": "^2.0.4", + "guanguans/notify": "^1.20", "guzzlehttp/guzzle": "^7.3.0", "laravel/framework": "^v8.48.1", "laravel/tinker": "^v2.6.1", diff --git a/composer.lock b/composer.lock index 9c0da4233..b4e15d7fa 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "82a2e2c4b376522e3a13c16949e1a5d3", + "content-hash": "ea9cf5820d67b47b3ade5df2398c7365", "packages": [ { "name": "brick/math", @@ -758,6 +758,132 @@ ], "time": "2021-11-21T21:41:47+00:00" }, + { + "name": "guanguans/notify", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/guanguans/notify.git", + "reference": "9ca088680bf4e5b489a94c80a635db39e10dda63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guanguans/notify/zipball/9ca088680bf4e5b489a94c80a635db39e10dda63", + "reference": "9ca088680bf4e5b489a94c80a635db39e10dda63", + "shasum": "" + }, + "require": { + "ext-json": "*", + "overtrue/http": "^1.2", + "php": ">=7.2.5", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "symfony/mailer": "^5.3 || ^6.0", + "symfony/options-resolver": "^5.3 || ^6.0", + "textalk/websocket": "^1.5" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.7", + "friendsofphp/php-cs-fixer": "^3.0", + "mockery/mockery": "^1.2", + "overtrue/phplint": "^3.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "vimeo/psalm": "^4.10" + }, + "type": "library", + "extra": { + "hooks": { + "pre-commit": [ + "composer style-lint", + "composer test" + ], + "pre-push": [ + "composer style-lint", + "composer test" + ] + } + }, + "autoload": { + "files": [ + "src/Support/helpers.php" + ], + "psr-4": { + "Guanguans\\Notify\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "guanguans", + "email": "ityaozm@gmail.com", + "homepage": "https://www.guanguans.cn", + "role": "developer" + } + ], + "description": "推送通知 sdk(Bark、Chanify、钉钉群机器人、Discord、邮件、飞书群机器人、Gitter、Google Chat、iGot、Logger、Mattermost、Now Push、PushBack、Push、PushDeer、PushPlus、QQ 频道机器人、Rocket Chat、Server 酱、Showdoc Push、Slack、Telegram、Webhook、企业微信群机器人、息知、Zulip)。", + "homepage": "https://github.com/guanguans/notify", + "keywords": [ + "Bark", + "Feishu", + "Mattermost", + "PushDeer", + "QQ Bot", + "QQ 机器人", + "QQ 频道", + "QQ 频道机器人", + "Server酱", + "chanify", + "dingtalk", + "discord", + "email", + "gitter", + "googleChat", + "iGot", + "logger", + "notification", + "notifier", + "notify", + "now push", + "push", + "pushBack", + "pushPlus", + "qq", + "rocketchat", + "sdk", + "serverChan", + "showdoc push", + "slack", + "telegram", + "webhook", + "wework", + "xiZhi", + "zulip", + "企业微信", + "企业微信群机器人", + "微信", + "息知", + "机器人", + "邮件", + "钉钉", + "钉钉群", + "钉钉群机器人", + "飞书", + "飞书群机器人" + ], + "support": { + "issues": "https://github.com/guanguans/notify/issues", + "source": "https://github.com/guanguans/notify" + }, + "funding": [ + { + "url": "https://www.guanguans.cn/images/wechat.jpeg", + "type": "wechat" + } + ], + "time": "2022-03-31T07:00:37+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.4.1", @@ -2777,6 +2903,64 @@ }, "time": "2022-02-11T07:31:08+00:00" }, + { + "name": "overtrue/http", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/overtrue/http.git", + "reference": "e6e4c2ff274b1050d681288495878ee8fd3f1209" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/http/zipball/e6e4c2ff274b1050d681288495878ee8fd3f1209", + "reference": "e6e4c2ff274b1050d681288495878ee8fd3f1209", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.3 || ^7.0", + "php": ">=7.0" + }, + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.7", + "friendsofphp/php-cs-fixer": "^2.15 || ^3.0", + "mockery/mockery": "^1.0", + "overtrue/phplint": "^1.1 || ^2.0 || ^3.0", + "phpunit/phpunit": "^6.5 || ^8.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Overtrue\\Http\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "A simple http client wrapper.", + "support": { + "issues": "https://github.com/overtrue/http/issues", + "source": "https://github.com/overtrue/http/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "time": "2022-03-14T06:24:13+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.22.0", @@ -4461,6 +4645,80 @@ ], "time": "2022-01-29T18:08:07+00:00" }, + { + "name": "symfony/mailer", + "version": "v6.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/mailer.git", + "reference": "f7343f94e7afecca2ad840b078f9d80200e1bd27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/mailer/zipball/f7343f94e7afecca2ad840b078f9d80200e1bd27", + "reference": "f7343f94e7afecca2ad840b078f9d80200e1bd27", + "shasum": "" + }, + "require": { + "egulias/email-validator": "^2.1.10|^3", + "php": ">=8.0.2", + "psr/event-dispatcher": "^1", + "psr/log": "^1|^2|^3", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/mime": "^5.4|^6.0", + "symfony/service-contracts": "^1.1|^2|^3" + }, + "conflict": { + "symfony/http-kernel": "<5.4" + }, + "require-dev": { + "symfony/http-client-contracts": "^1.1|^2|^3", + "symfony/messenger": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Mailer\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Helps sending emails", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/mailer/tree/v6.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-03-18T16:06:28+00:00" + }, { "name": "symfony/mime", "version": "v5.4.3", @@ -4544,6 +4802,73 @@ ], "time": "2022-01-02T09:53:40+00:00" }, + { + "name": "symfony/options-resolver", + "version": "v6.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "51f7006670febe4cbcbae177cbffe93ff833250d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/51f7006670febe4cbcbae177cbffe93ff833250d", + "reference": "51f7006670febe4cbcbae177cbffe93ff833250d", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:55:41+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.24.0", @@ -5942,6 +6267,55 @@ ], "time": "2022-01-17T16:30:37+00:00" }, + { + "name": "textalk/websocket", + "version": "1.5.7", + "source": { + "type": "git", + "url": "https://github.com/Textalk/websocket-php.git", + "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Textalk/websocket-php/zipball/1712325e99b6bf869ccbf9bf41ab749e7328ea46", + "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46", + "shasum": "" + }, + "require": { + "php": "^7.2 | ^8.0", + "psr/log": "^1 | ^2 | ^3" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.0", + "phpunit/phpunit": "^8.0|^9.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "WebSocket\\": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "ISC" + ], + "authors": [ + { + "name": "Fredrik Liljegren" + }, + { + "name": "Sören Jensen", + "email": "soren@abicart.se" + } + ], + "description": "WebSocket client and server", + "support": { + "issues": "https://github.com/Textalk/websocket-php/issues", + "source": "https://github.com/Textalk/websocket-php/tree/1.5.7" + }, + "time": "2022-03-29T09:46:59+00:00" + }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "2.2.4", diff --git a/resources/assets/sass/pages/page-setting.scss b/resources/assets/sass/pages/page-setting.scss index 48708d188..6b25eaa10 100755 --- a/resources/assets/sass/pages/page-setting.scss +++ b/resources/assets/sass/pages/page-setting.scss @@ -194,7 +194,7 @@ height: 0; .ivu-tabs-tabpane { position: relative; - .setting-system-item { + .setting-component-item { position: absolute; top: 0; left: 0;