正在显示
1 个修改的文件
包含
47 行增加
和
20 行删除
@@ -107,18 +107,29 @@ class Folder extends Base { | @@ -107,18 +107,29 @@ class Folder extends Base { | ||
107 | 107 | ||
108 | // 加密后的文件夹 | 108 | // 加密后的文件夹 |
109 | $origin_folder = MailFun::folderEncoding($formData['folder']); | 109 | $origin_folder = MailFun::folderEncoding($formData['folder']); |
110 | - // 不为空上级 | ||
111 | - if(!empty($formData['pid'])){ | ||
112 | - $parent = db()->first(folderSql::first(['id'=>$formData['pid']])); | ||
113 | - if(!$parent || $parent['email_id'] != $email['id']){ | ||
114 | - app()->e('folder_parent_not_fount'); | ||
115 | - } | ||
116 | - if($parent['pid']){ | ||
117 | - app()->e('folder_tree_max_two'); | 110 | + |
111 | + // 修改 | ||
112 | + $id = app()->request('id',0,'intval'); | ||
113 | + if($id){ | ||
114 | + $folder = db()->first(folderSql::first($id)); | ||
115 | + if(!$folder || $folder['email_id'] != $email['id']){ | ||
116 | + app()->e('folder_not_exist'); | ||
118 | } | 117 | } |
119 | 118 | ||
120 | - // 加密后的文件夹 | ||
121 | - $origin_folder = $parent['origin_folder'].'/'.$origin_folder; | 119 | + }else{ |
120 | + // 不为空上级 | ||
121 | + if(!empty($formData['pid'])){ | ||
122 | + $parent = db()->first(folderSql::first(['id'=>$formData['pid']])); | ||
123 | + if(!$parent || $parent['email_id'] != $email['id']){ | ||
124 | + app()->e('folder_parent_not_fount'); | ||
125 | + } | ||
126 | + if($parent['pid']){ | ||
127 | + app()->e('folder_tree_max_two'); | ||
128 | + } | ||
129 | + | ||
130 | + // 加密后的文件夹 | ||
131 | + $origin_folder = $parent['origin_folder'].'/'.$origin_folder; | ||
132 | + } | ||
122 | } | 133 | } |
123 | 134 | ||
124 | // 判断文件夹是否存在 | 135 | // 判断文件夹是否存在 |
@@ -144,21 +155,37 @@ class Folder extends Base { | @@ -144,21 +155,37 @@ class Folder extends Base { | ||
144 | app()->e('login_error_imap'); | 155 | app()->e('login_error_imap'); |
145 | } | 156 | } |
146 | 157 | ||
147 | - // 远程创建 | ||
148 | - $ret = $mail->client->folderCreate($origin_folder); | 158 | + if($id){ |
159 | + // 远程创建 | ||
160 | + $ret = $mail->client->folderRename($folder['origin_folder'],$origin_folder); | ||
161 | + | ||
162 | + }else{ | ||
163 | + // 远程创建 | ||
164 | + $ret = $mail->client->folderCreate($origin_folder); | ||
165 | + } | ||
149 | 166 | ||
150 | if($ret[0] === false){ | 167 | if($ret[0] === false){ |
151 | app()->e($ret[1]); | 168 | app()->e($ret[1]); |
152 | } | 169 | } |
153 | 170 | ||
154 | - // 插入数据,就算插入失败了,也会把文件夹同步回来 | ||
155 | - $id = db()->insert(folderSql::$table,[ | ||
156 | - 'pid' => $parent['id']??0, | ||
157 | - 'email_id' => $email['id'], | ||
158 | - 'folder' => $formData['folder'], | ||
159 | - 'origin_folder' => $origin_folder, | ||
160 | - 'uuid' => md5($email['id'].$origin_folder), | ||
161 | - ],false); | 171 | + if($id){ |
172 | + // 更新 | ||
173 | + db()->update(folderSql::$table,[ | ||
174 | + 'folder' => $formData['folder'], | ||
175 | + 'origin_folder' => $origin_folder, | ||
176 | + 'uuid' => md5($email['id'].$origin_folder), | ||
177 | + ],dbWhere(['id'=>$id]),false); | ||
178 | + }else{ | ||
179 | + // 插入数据,就算插入失败了,也会把文件夹同步回来 | ||
180 | + $id = db()->insert(folderSql::$table,[ | ||
181 | + 'pid' => $parent['id']??0, | ||
182 | + 'email_id' => $email['id'], | ||
183 | + 'folder' => $formData['folder'], | ||
184 | + 'origin_folder' => $origin_folder, | ||
185 | + 'uuid' => md5($email['id'].$origin_folder), | ||
186 | + ],false); | ||
187 | + | ||
188 | + } | ||
162 | 189 | ||
163 | // if(!$id){ | 190 | // if(!$id){ |
164 | // app()->e('folder_create_save_error'); | 191 | // app()->e('folder_create_save_error'); |
-
请 注册 或 登录 后发表评论