From 3bc141471d85c3fb1435cba199fe3b58dbd22d3e Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 5 Jun 2024 22:11:05 +0800 Subject: [PATCH] improve share dir save --- plugins/Common.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/Common.php b/plugins/Common.php index fe4ec33..8e22683 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -51,7 +51,11 @@ Class Common { //保存用户多收藏夹目录映射关系 public static function saveUserDirMap($cellphone, $username, $new_dir) { $my_user_map = self::getMyDirs($cellphone, $username); - array_push($my_user_map, $new_dir); + if (!in_array($new_dir, $my_user_map)) { + array_push($my_user_map, $new_dir); + }else { + return true; + } $my_id = self::getUserId($cellphone); $rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; @@ -89,7 +93,7 @@ Class Common { } } - return $map; + return array_unique($map, SORT_NUMERIC); } //保存用户共享目录记录 @@ -124,7 +128,7 @@ Class Common { if(!empty($shareDirs[$friends_cellphone]) && in_array($share_dir, $shareDirs[$friends_cellphone])) { $shareDirs[$friends_cellphone] = array_diff($shareDirs[$friends_cellphone], array($share_dir)); }else { - return false; + return true; } $my_id = self::getUserId($cellphone); @@ -325,7 +329,7 @@ Class Common { array_merge($map, $tajian_user_map[$cellphone]) : array_push($map, $tajian_user_map[$cellphone]); } - return array_unique($map); + return array_unique($map, SORT_NUMERIC); } public static function getNicknameByDir($dir, $username){