作者 邓超

删除文件夹

... ... @@ -189,15 +189,19 @@ class Folder extends Base {
public function delete(){
$email = $this->getEmail();
$folder_id = app()->request('folder_id');
$folder_id = app()->request('id');
$folder = db()->first(folderSql::first(dbWhere(['id'=>$folder_id,'email_id'=>$email['id']])));
$folder = db()->first(folderSql::first(['id'=>$folder_id,'email_id'=>$email['id']]));
if(!$folder){
app()->e('folder_not_fount');
}
// 是否是不可删除的
if(in_array($folder['folder'],array_values(folderAliasMap()))){
app()->e('folder_not_allowed_to_delete');
}
// 是否存在下级
if(db()->count(folderSql::first(dbWhere(['pid'=>$folder['pid'],'email_id'=>$email['id']])))){
if(db()->count(folderSql::first(['pid'=>$folder['pid'],'email_id'=>$email['id']]))){
app()->e('folder_delete_exist_child');
}
... ...
... ... @@ -303,16 +303,13 @@ function start_now_mail(){
}
/**
* 固定文件夹的名称,统一
* @param $folder
* @return string
* @return string[]
* @author:dc
* @time 2023/3/21 16:00
* @time 2023/4/13 11:02
*/
function folderAlias($folder){
$folder_map = [
function folderAliasMap():array {
return [
'INBOX' => '收件箱',
// qq的
'Sent Messages' => '发件箱',
... ... @@ -330,7 +327,17 @@ function folderAlias($folder){
'草稿' => '草稿箱',
];
}
/**
* 固定文件夹的名称,统一
* @param $folder
* @return string
* @author:dc
* @time 2023/3/21 16:00
*/
function folderAlias(string $folder):string {
$folder_map = folderAliasMap();
foreach ($folder_map as $key=>$name){
if(strtolower($folder) == strtolower($key)){
... ...
... ... @@ -90,6 +90,7 @@ return [
'folder_move_to_draft_error' => '无法移动到草稿箱',
'folder_move_to_send_error' => '无法移动到发件箱',
'folder_not_allowed_to_delete' => '此文件夹不允许删除',
... ...
... ... @@ -43,7 +43,7 @@ class folderSql {
* @author:dc
* @time 2023/3/14 11:49
*/
public static function first(array|string $where,$filed = '*'):string {
public static function first(array|string|int $where,$filed = '*'):string {
$where = is_numeric($where) ? ['id'=>$where] : $where;
return "select {$filed} from `".self::$table."` where ".dbWhere($where)." limit 1";
}
... ...