正在显示
4 个修改的文件
包含
23 行增加
和
11 行删除
@@ -189,15 +189,19 @@ class Folder extends Base { | @@ -189,15 +189,19 @@ class Folder extends Base { | ||
189 | public function delete(){ | 189 | public function delete(){ |
190 | $email = $this->getEmail(); | 190 | $email = $this->getEmail(); |
191 | 191 | ||
192 | - $folder_id = app()->request('folder_id'); | 192 | + $folder_id = app()->request('id'); |
193 | 193 | ||
194 | - $folder = db()->first(folderSql::first(dbWhere(['id'=>$folder_id,'email_id'=>$email['id']]))); | 194 | + $folder = db()->first(folderSql::first(['id'=>$folder_id,'email_id'=>$email['id']])); |
195 | 195 | ||
196 | if(!$folder){ | 196 | if(!$folder){ |
197 | app()->e('folder_not_fount'); | 197 | app()->e('folder_not_fount'); |
198 | } | 198 | } |
199 | + // 是否是不可删除的 | ||
200 | + if(in_array($folder['folder'],array_values(folderAliasMap()))){ | ||
201 | + app()->e('folder_not_allowed_to_delete'); | ||
202 | + } | ||
199 | // 是否存在下级 | 203 | // 是否存在下级 |
200 | - if(db()->count(folderSql::first(dbWhere(['pid'=>$folder['pid'],'email_id'=>$email['id']])))){ | 204 | + if(db()->count(folderSql::first(['pid'=>$folder['pid'],'email_id'=>$email['id']]))){ |
201 | app()->e('folder_delete_exist_child'); | 205 | app()->e('folder_delete_exist_child'); |
202 | } | 206 | } |
203 | 207 |
@@ -303,16 +303,13 @@ function start_now_mail(){ | @@ -303,16 +303,13 @@ function start_now_mail(){ | ||
303 | 303 | ||
304 | } | 304 | } |
305 | 305 | ||
306 | - | ||
307 | /** | 306 | /** |
308 | - * 固定文件夹的名称,统一 | ||
309 | - * @param $folder | ||
310 | - * @return string | 307 | + * @return string[] |
311 | * @author:dc | 308 | * @author:dc |
312 | - * @time 2023/3/21 16:00 | 309 | + * @time 2023/4/13 11:02 |
313 | */ | 310 | */ |
314 | -function folderAlias($folder){ | ||
315 | - $folder_map = [ | 311 | +function folderAliasMap():array { |
312 | + return [ | ||
316 | 'INBOX' => '收件箱', | 313 | 'INBOX' => '收件箱', |
317 | // qq的 | 314 | // qq的 |
318 | 'Sent Messages' => '发件箱', | 315 | 'Sent Messages' => '发件箱', |
@@ -330,7 +327,17 @@ function folderAlias($folder){ | @@ -330,7 +327,17 @@ function folderAlias($folder){ | ||
330 | '草稿' => '草稿箱', | 327 | '草稿' => '草稿箱', |
331 | 328 | ||
332 | ]; | 329 | ]; |
330 | +} | ||
331 | +/** | ||
332 | + * 固定文件夹的名称,统一 | ||
333 | + * @param $folder | ||
334 | + * @return string | ||
335 | + * @author:dc | ||
336 | + * @time 2023/3/21 16:00 | ||
337 | + */ | ||
338 | +function folderAlias(string $folder):string { | ||
333 | 339 | ||
340 | + $folder_map = folderAliasMap(); | ||
334 | 341 | ||
335 | foreach ($folder_map as $key=>$name){ | 342 | foreach ($folder_map as $key=>$name){ |
336 | if(strtolower($folder) == strtolower($key)){ | 343 | if(strtolower($folder) == strtolower($key)){ |
@@ -90,6 +90,7 @@ return [ | @@ -90,6 +90,7 @@ return [ | ||
90 | 90 | ||
91 | 'folder_move_to_draft_error' => '无法移动到草稿箱', | 91 | 'folder_move_to_draft_error' => '无法移动到草稿箱', |
92 | 'folder_move_to_send_error' => '无法移动到发件箱', | 92 | 'folder_move_to_send_error' => '无法移动到发件箱', |
93 | + 'folder_not_allowed_to_delete' => '此文件夹不允许删除', | ||
93 | 94 | ||
94 | 95 | ||
95 | 96 |
@@ -43,7 +43,7 @@ class folderSql { | @@ -43,7 +43,7 @@ class folderSql { | ||
43 | * @author:dc | 43 | * @author:dc |
44 | * @time 2023/3/14 11:49 | 44 | * @time 2023/3/14 11:49 |
45 | */ | 45 | */ |
46 | - public static function first(array|string $where,$filed = '*'):string { | 46 | + public static function first(array|string|int $where,$filed = '*'):string { |
47 | $where = is_numeric($where) ? ['id'=>$where] : $where; | 47 | $where = is_numeric($where) ? ['id'=>$where] : $where; |
48 | return "select {$filed} from `".self::$table."` where ".dbWhere($where)." limit 1"; | 48 | return "select {$filed} from `".self::$table."` where ".dbWhere($where)." limit 1"; |
49 | } | 49 | } |
-
请 注册 或 登录 后发表评论