...
|
...
|
@@ -186,17 +186,81 @@ class Home extends Base { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 邮件回收站,进行回收,恢复邮件
|
|
|
* 邮件移动
|
|
|
* @author:dc
|
|
|
* @time 2023/3/21 11:41
|
|
|
*/
|
|
|
public function recycle(){
|
|
|
$this->setFlags('deleted');
|
|
|
public function move(){
|
|
|
$emails = $this->getEmails();
|
|
|
|
|
|
$mail_ids = app()->request('mail_ids');
|
|
|
foreach ($mail_ids as $k=>$id){
|
|
|
if(!is_numeric($id)){
|
|
|
unset($mail_ids[$k]);
|
|
|
}
|
|
|
}
|
|
|
// 移动到的文件夹
|
|
|
$folder = app()->request('folder');
|
|
|
|
|
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`'));
|
|
|
if($data){
|
|
|
// 查询邮箱
|
|
|
$emails = array_column($emails,null,'id');
|
|
|
$uids = [];
|
|
|
foreach ($data as $datum){
|
|
|
if(empty($uids[$datum['email_id']])){
|
|
|
$uids[$datum['email_id']][$datum['folder_id']] = [];
|
|
|
}
|
|
|
$uids[$datum['email_id']][$datum['folder_id']][] = [
|
|
|
'uid' => $datum['uid'],
|
|
|
'id' => $datum['id'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
foreach ($uids as $eid=>$arr){
|
|
|
foreach ($arr as $fid=>$uid){
|
|
|
// 查询目录
|
|
|
$folder = db()->first(folderSql::first($fid));
|
|
|
if($folder){
|
|
|
// 开始远程
|
|
|
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
|
|
|
|
|
if($mailInstance->login()){
|
|
|
|
|
|
$mailInstance->move();
|
|
|
|
|
|
$mailInstance = null;
|
|
|
// 更新数据
|
|
|
// db()->update(listsSql::$table,[
|
|
|
// $d => $fv
|
|
|
// ],dbWhere([
|
|
|
// 'id' => array_column($uid,'id')
|
|
|
// ]));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
$folder = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
app()->_json([
|
|
|
'mail_id' => $mail_ids
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 远程标签
|
|
|
* @param $d
|
|
|
* @throws \Lib\Err
|
|
|
* @author:dc
|
|
|
* @time 2023/3/21 14:28
|
|
|
*/
|
|
|
private function setFlags($d){
|
|
|
$emails = $this->getEmails();
|
|
|
|
...
|
...
|
@@ -210,7 +274,7 @@ class Home extends Base { |
|
|
$fv = (int) app()->request($d);
|
|
|
$fv = $fv ? 1 : 0;
|
|
|
|
|
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')])));
|
|
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`'));
|
|
|
if($data){
|
|
|
// 查询邮箱
|
|
|
$emails = array_column($emails,null,'id');
|
...
|
...
|
@@ -241,10 +305,10 @@ class Home extends Base { |
|
|
break;
|
|
|
}
|
|
|
// 回收站,已删 未删,软删
|
|
|
case 'deleted':{
|
|
|
$mailInstance->recycle(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
|
|
break;
|
|
|
}
|
|
|
// case 'deleted':{
|
|
|
// $mailInstance->recycle(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
|
|
// break;
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
$mailInstance = null;
|
...
|
...
|
|