...
|
...
|
@@ -7,6 +7,7 @@ use Lib\Err; |
|
|
use Lib\Mail\Mail;
|
|
|
use Lib\Mail\MailFun;
|
|
|
use Model\folderSql;
|
|
|
use Model\listsSql;
|
|
|
|
|
|
/**
|
|
|
* 文件夹管理
|
...
|
...
|
@@ -158,7 +159,54 @@ class Folder extends Base { |
|
|
* @time 2023/3/3 17:38
|
|
|
*/
|
|
|
public function delete(){
|
|
|
$email = $this->getEmail();
|
|
|
|
|
|
$folder_id = app()->request('folder_id');
|
|
|
|
|
|
$folder = db()->first(folderSql::first(dbWhere(['id'=>$folder_id,'email_id'=>$email['id']])));
|
|
|
|
|
|
if(!$folder){
|
|
|
app()->e('folder_not_fount');
|
|
|
}
|
|
|
// 是否存在下级
|
|
|
if(db()->count(folderSql::first(dbWhere(['pid'=>$folder['pid'],'email_id'=>$email['id']])))){
|
|
|
app()->e('folder_delete_exist_child');
|
|
|
}
|
|
|
|
|
|
// 是否存在邮件
|
|
|
if(db()->count(listsSql::first(dbWhere(['folder_id'=>$folder['id'],'email_id'=>$email['id']])))){
|
|
|
app()->e('folder_delete_exist_mail');
|
|
|
}
|
|
|
|
|
|
// 远程创建
|
|
|
$mail = new Mail(
|
|
|
$email['email'],
|
|
|
base64_decode($email['password']),
|
|
|
$email['imap']
|
|
|
);
|
|
|
|
|
|
if(!$mail->login()){
|
|
|
app()->e('login_error_imap');
|
|
|
}
|
|
|
|
|
|
// 远程创建
|
|
|
$ret = $mail->client->folderDelete($folder['origin_folder']);
|
|
|
|
|
|
if($ret[0] === false){
|
|
|
app()->e($ret[1]);
|
|
|
}
|
|
|
|
|
|
// 插入数据
|
|
|
$row = db()->delete(folderSql::$table,[
|
|
|
'id' => $folder['id']
|
|
|
]);
|
|
|
|
|
|
if(!$row){
|
|
|
app()->e('folder_delete_error');
|
|
|
}
|
|
|
|
|
|
// 返回数据
|
|
|
app()->_json($folder);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|