...
|
...
|
@@ -107,18 +107,29 @@ class Folder extends Base { |
|
|
|
|
|
// 加密后的文件夹
|
|
|
$origin_folder = MailFun::folderEncoding($formData['folder']);
|
|
|
// 不为空上级
|
|
|
if(!empty($formData['pid'])){
|
|
|
$parent = db()->first(folderSql::first(['id'=>$formData['pid']]));
|
|
|
if(!$parent || $parent['email_id'] != $email['id']){
|
|
|
app()->e('folder_parent_not_fount');
|
|
|
}
|
|
|
if($parent['pid']){
|
|
|
app()->e('folder_tree_max_two');
|
|
|
|
|
|
// 修改
|
|
|
$id = app()->request('id',0,'intval');
|
|
|
if($id){
|
|
|
$folder = db()->first(folderSql::first($id));
|
|
|
if(!$folder || $folder['email_id'] != $email['id']){
|
|
|
app()->e('folder_not_exist');
|
|
|
}
|
|
|
|
|
|
// 加密后的文件夹
|
|
|
$origin_folder = $parent['origin_folder'].'/'.$origin_folder;
|
|
|
}else{
|
|
|
// 不为空上级
|
|
|
if(!empty($formData['pid'])){
|
|
|
$parent = db()->first(folderSql::first(['id'=>$formData['pid']]));
|
|
|
if(!$parent || $parent['email_id'] != $email['id']){
|
|
|
app()->e('folder_parent_not_fount');
|
|
|
}
|
|
|
if($parent['pid']){
|
|
|
app()->e('folder_tree_max_two');
|
|
|
}
|
|
|
|
|
|
// 加密后的文件夹
|
|
|
$origin_folder = $parent['origin_folder'].'/'.$origin_folder;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 判断文件夹是否存在
|
...
|
...
|
@@ -144,21 +155,37 @@ class Folder extends Base { |
|
|
app()->e('login_error_imap');
|
|
|
}
|
|
|
|
|
|
// 远程创建
|
|
|
$ret = $mail->client->folderCreate($origin_folder);
|
|
|
if($id){
|
|
|
// 远程创建
|
|
|
$ret = $mail->client->folderRename($folder['origin_folder'],$origin_folder);
|
|
|
|
|
|
}else{
|
|
|
// 远程创建
|
|
|
$ret = $mail->client->folderCreate($origin_folder);
|
|
|
}
|
|
|
|
|
|
if($ret[0] === false){
|
|
|
app()->e($ret[1]);
|
|
|
}
|
|
|
|
|
|
// 插入数据,就算插入失败了,也会把文件夹同步回来
|
|
|
$id = db()->insert(folderSql::$table,[
|
|
|
'pid' => $parent['id']??0,
|
|
|
'email_id' => $email['id'],
|
|
|
'folder' => $formData['folder'],
|
|
|
'origin_folder' => $origin_folder,
|
|
|
'uuid' => md5($email['id'].$origin_folder),
|
|
|
],false);
|
|
|
if($id){
|
|
|
// 更新
|
|
|
db()->update(folderSql::$table,[
|
|
|
'folder' => $formData['folder'],
|
|
|
'origin_folder' => $origin_folder,
|
|
|
'uuid' => md5($email['id'].$origin_folder),
|
|
|
],dbWhere(['id'=>$id]),false);
|
|
|
}else{
|
|
|
// 插入数据,就算插入失败了,也会把文件夹同步回来
|
|
|
$id = db()->insert(folderSql::$table,[
|
|
|
'pid' => $parent['id']??0,
|
|
|
'email_id' => $email['id'],
|
|
|
'folder' => $formData['folder'],
|
|
|
'origin_folder' => $origin_folder,
|
|
|
'uuid' => md5($email['id'].$origin_folder),
|
|
|
],false);
|
|
|
|
|
|
}
|
|
|
|
|
|
// if(!$id){
|
|
|
// app()->e('folder_create_save_error');
|
...
|
...
|
|