PublishController.class.php
2.15 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
<?php
/**
* 同事圈-移动端 发布话题
* PublishController
* User: zoulongbo
* Date: 2018/6/27
* Time: 14:17
*/
namespace Api\Controller\Topic;
use Com\PackageValidate;
use Common\Common\Constant;
use Common\Common\Help;
use Common\Service\CircleService;
use Common\Common\AttachOperation;
class PublishController extends \Api\Controller\AbstractController
{
public function Index_post()
{
// 验证规则
$rules = [
'title' => 'require',
'content' => 'require',
'is_all' => 'require|in:0,1',
'is_anonymous' => 'number',
'images'=>'array'
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$postData = $validate->postData;
//判断是否存在images
if (isset($postData['images']) && !$postData['images'][0]['atId']) {
E('_EMPTY_IMAGES_ATID');
}
// 如果是外部人员
if (!$this->uid) {
E('_EMPTY_MEM_TOPIC');
}
// 验证是否有发布权限
$setting=Help::instance()->setting_auth($this->_login->user);
if($setting['anonymous_topic']!=Constant::SETTING_ANONYMOUS_TOPIC&&$postData['is_anonymous']==Constant::SETTING_ANONYMOUS_TOPIC){
E('_ERR_NOT_OPEN_ANONYMOUS_TOPIC');
}
if(Constant::PUSH_TOPIC_AUTH_FALSE == $setting['push_topic_auth']){
E('_ERR_NOT_PUSH_TOPIC_AUTH');
}
$postData['sc_id']=intval(I('sc_id'));
$postData['cover_id']=strval(I('cover_id'));
$circleServ = new CircleService();
$data = $circleServ->publish_new_topic($postData, $this->_login->user, $setting['is_topic_check']);
// 更新附件使用状态
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 = array('id' => intval($data['id']));
}
}