|
@@ -42,19 +42,35 @@ class Home extends Base { |
|
@@ -42,19 +42,35 @@ class Home extends Base { |
42
|
}
|
42
|
}
|
43
|
}
|
43
|
}
|
44
|
|
44
|
|
45
|
- // 邮件文件夹的id
|
|
|
46
|
- $folder_id = (int) app()->request('folder_id');
|
|
|
47
|
// 附件
|
45
|
// 附件
|
48
|
$attachment = app()->request('attachment');
|
46
|
$attachment = app()->request('attachment');
|
49
|
// 已读/未读
|
47
|
// 已读/未读
|
50
|
$seen = app()->request('seen',-1,'intval');
|
48
|
$seen = app()->request('seen',-1,'intval');
|
|
|
49
|
+ // 软删
|
|
|
50
|
+ $deleted = app()->request('deleted',0,'intval');
|
51
|
|
51
|
|
52
|
|
52
|
|
53
|
$where = ['email_id'=>$this->getEmails('id')];
|
53
|
$where = ['email_id'=>$this->getEmails('id')];
|
|
|
54
|
+
|
|
|
55
|
+ // 目录
|
|
|
56
|
+ $folder = app()->request('folder','INBOX');
|
|
|
57
|
+ $folderList = db()->all(folderSql::all($where['email_id']));
|
|
|
58
|
+ $folder_id = [];
|
|
|
59
|
+ // 文件夹id
|
|
|
60
|
+ if($folderList){
|
|
|
61
|
+ foreach ($folderList as $item){
|
|
|
62
|
+ if($item['folder'] == $folder){
|
|
|
63
|
+ $folder_id[] = $item['id'];
|
|
|
64
|
+ }
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
|
67
|
+
|
54
|
//目录
|
68
|
//目录
|
55
|
if($folder_id) $where['folder_id'] = $folder_id;
|
69
|
if($folder_id) $where['folder_id'] = $folder_id;
|
56
|
if($ids) $where['id'] = $ids;
|
70
|
if($ids) $where['id'] = $ids;
|
57
|
if($attachment) $where['is_file'] = 1; //附件
|
71
|
if($attachment) $where['is_file'] = 1; //附件
|
|
|
72
|
+ // 软删
|
|
|
73
|
+ $where['deleted'] = $deleted;
|
58
|
// 已读/未读
|
74
|
// 已读/未读
|
59
|
if(in_array($seen,[0,1])){
|
75
|
if(in_array($seen,[0,1])){
|
60
|
$where['seen'] = $seen;
|
76
|
$where['seen'] = $seen;
|
|
@@ -164,6 +180,24 @@ class Home extends Base { |
|
@@ -164,6 +180,24 @@ class Home extends Base { |
164
|
* @time 2023/3/17 16:15
|
180
|
* @time 2023/3/17 16:15
|
165
|
*/
|
181
|
*/
|
166
|
public function seen_2_unseen(){
|
182
|
public function seen_2_unseen(){
|
|
|
183
|
+ $this->setFlags('seen');
|
|
|
184
|
+ }
|
|
|
185
|
+
|
|
|
186
|
+
|
|
|
187
|
+
|
|
|
188
|
+ /**
|
|
|
189
|
+ * 邮件回收站,进行回收,恢复邮件
|
|
|
190
|
+ * @author:dc
|
|
|
191
|
+ * @time 2023/3/21 11:41
|
|
|
192
|
+ */
|
|
|
193
|
+ public function recycle(){
|
|
|
194
|
+ $this->setFlags('deleted');
|
|
|
195
|
+ }
|
|
|
196
|
+
|
|
|
197
|
+
|
|
|
198
|
+
|
|
|
199
|
+
|
|
|
200
|
+ private function setFlags($d){
|
167
|
$emails = $this->getEmails();
|
201
|
$emails = $this->getEmails();
|
168
|
|
202
|
|
169
|
$mail_ids = app()->request('mail_ids');
|
203
|
$mail_ids = app()->request('mail_ids');
|
|
@@ -173,8 +207,8 @@ class Home extends Base { |
|
@@ -173,8 +207,8 @@ class Home extends Base { |
173
|
}
|
207
|
}
|
174
|
}
|
208
|
}
|
175
|
// 已读或未读
|
209
|
// 已读或未读
|
176
|
- $seen = (int) app()->request('seen');
|
|
|
177
|
- $seen = $seen ? 1 : 0;
|
210
|
+ $fv = (int) app()->request($d);
|
|
|
211
|
+ $fv = $fv ? 1 : 0;
|
178
|
|
212
|
|
179
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')])));
|
213
|
$data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')])));
|
180
|
if($data){
|
214
|
if($data){
|
|
@@ -200,12 +234,23 @@ class Home extends Base { |
|
@@ -200,12 +234,23 @@ class Home extends Base { |
200
|
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
234
|
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
|
201
|
|
235
|
|
202
|
if($mailInstance->login()){
|
236
|
if($mailInstance->login()){
|
203
|
- $mailInstance->seen(array_column($uid,'uid'),$folder['origin_folder'],$seen);
|
237
|
+ switch ($d){
|
|
|
238
|
+ // 已读 未读
|
|
|
239
|
+ case 'seen':{
|
|
|
240
|
+ $mailInstance->seen(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
|
|
241
|
+ break;
|
|
|
242
|
+ }
|
|
|
243
|
+ // 回收站,已删 未删,软删
|
|
|
244
|
+ case 'deleted':{
|
|
|
245
|
+ $mailInstance->recycle(array_column($uid,'uid'),$folder['origin_folder'],$fv);
|
|
|
246
|
+ break;
|
|
|
247
|
+ }
|
|
|
248
|
+ }
|
204
|
|
249
|
|
205
|
$mailInstance = null;
|
250
|
$mailInstance = null;
|
206
|
// 更新数据
|
251
|
// 更新数据
|
207
|
db()->update(listsSql::$table,[
|
252
|
db()->update(listsSql::$table,[
|
208
|
- 'seen' => $seen
|
253
|
+ $d => $fv
|
209
|
],dbWhere([
|
254
|
],dbWhere([
|
210
|
'id' => array_column($uid,'id')
|
255
|
'id' => array_column($uid,'id')
|
211
|
]));
|
256
|
]));
|
|
@@ -223,7 +268,6 @@ class Home extends Base { |
|
@@ -223,7 +268,6 @@ class Home extends Base { |
223
|
'mail_id' => $mail_ids
|
268
|
'mail_id' => $mail_ids
|
224
|
]);
|
269
|
]);
|
225
|
|
270
|
|
226
|
-
|
|
|
227
|
}
|
271
|
}
|
228
|
|
272
|
|
229
|
|
273
|
|