SaveController.class.php
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/27
* Time: 20:35
*/
namespace Apicp\Controller\Invite;
use Common\Common\AttachOperation;
use Common\Service\InviteSettingService;
class SaveController extends AbstractController
{
/**
* 【通讯录】保存邀请函内容
* @author liyifei
*/
public function Index_post()
{
$content = I('post.content', '', 'trim');
$shareContent = I('post.share_content', '', 'trim');
if (empty($content) || empty($shareContent)) {
E('_ERR_PARAM_IS_NULL');
return false;
}
$settingServ = new InviteSettingService();
$setting_data = $settingServ->get_by_conds([]);
$upData = [
'content' => $content,
'share_content' => $shareContent,
];
$settingServ->update_by_conds([], $upData);
$attach_serv = new AttachOperation();
// 匹配内容中的附件ID
$at_ids = $attach_serv->match_at_ids($content);
// 通知uc附件使用情况
$attach_serv->make_active($at_ids);
// 匹配内容中的附件ID
$at_ids_old = $attach_serv->match_at_ids($setting_data['content']);
// 获取不用的附件ID集合
$at_ids_del = array_diff($at_ids_old, $at_ids);
// 删除不用的附件
$attach_serv->deleteFile($at_ids_del);
}
}