PublishController.class.php
2.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* PublishController.class.php
* 发布同事圈
* User: heyuelong
* Date:2017年4月24日10:40:17
*/
namespace Api\Controller\Replies;
use Common\Common\AttachOperation;
use Common\Common\Config;
use Common\Common\Constant;
use Common\Service\CircleService;
use Common\Common\TaskCenter;
class PublishController extends \Api\Controller\AbstractController
{
public function Index_post()
{
set_time_limit(0);
// 获取请求参数
$params = I('post.');
// 实例化同事圈帖子信息表
$service = new CircleService();
// 验证数据
if (!$service->publish_validate($params, $this->uid)) {
return false;
}
// 话题id
$c_id = 0;
if (isset($params['c_id']) && !empty($params['c_id'])) {
$c_id = rintval($params['c_id']);
}
// 帖子
$type = Constant::CIRCLE_NOTE_TYPE;
if ($c_id) {
// 回帖
$type = Constant::CIRCLE_REPLIES_TOPIC_TYPE;
}
$params['pid'] = $c_id;
$params['type'] = $type;
$setting = Config::instance()->getCacheData();
// 写入数据
$data = $service->insert_data($params, $this->_login->user, $setting['release']);
// 常规任务埋点:发表话题(如果没有开启审核直接触发埋点,开启审核则在审核通过后触发)
if (!$this->_setting['release']) {
$params = [
'uid' => $this->uid,
'app_data_id' => $data['id'],
'action_key' => 'workmate_send_circle',
'description' => $c_id ? '发布话题回帖' : '发布帖子'
];
$taskCenter = &TaskCenter::instance();
$taskCenter->triggerDailytask($params);
}
// 更新附件使用状态
if (!empty($params['images'])) {
$at_ids = array_column($params['images'], 'atId');
$attach_serv = new AttachOperation();
$attach_serv->insert_attach(
APP_DIR,
'circle',
$data['id'],
['attach_ids' => $at_ids]
);
}
$this->_result = [
'id' => intval($data['id']),
'data' => $data['data']
];
}
}