UpdateAuthController.class.php
1.36 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 17/6/26
* Time: 19:51
*/
namespace Frontend\Controller\Index;
use VcySDK\Attach as Att;
use Common\Common\Attach;
use Common\Common\Constant;
use Common\Service\AttachService;
class UpdateAuthController extends AbstractController
{
/**
* 是否必须登录
*/
protected $_require_login = false;
/**
* 更新附件资源权限
* @author liyifei
*/
public function Index()
{
$atServ = new AttachService();
$list = $atServ->list_by_conds([
'at_type' => Constant::ATTACH_TYPE_FILE,
]);
// 鉴权信息
$conf = getResAuthConfig('news');
$attachServ = &Attach::instance();
if (!empty($list)) {
foreach ($list as $file) {
if (empty($file['at_id'])) {
continue;
}
// 查询该附件信息(无附件信息、已加入鉴权时,跳过)
$atInfo = $attachServ->getAttachDetail($file['at_id']);
if (empty($atInfo) || (!empty($atInfo) && $atInfo['atAuthRequired'] == Att::AUTH_REQUIRED_TRUE)) {
continue;
}
$conf['atId'] = $file['at_id'];
$attachServ->updateAuth($conf);
}
}
exit('SUCCESS');
}
}