2db47680
hexiaodong
chore: 初始提交 php 遗...
|
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
<?php
namespace addons\fastflow\model;
use fastflow\lib\config;
use addons\fastflow\model\lib;
class auth
{
public function checkStartAuth($flow_id)
{
$lib = new lib();
$flowAuth_rows = $lib->getAuthRow(['flow_id' => $flow_id]);
if ($flowAuth_rows) {
$flowAuth_row = $flowAuth_rows[0];
} else {
return false;
}
if ($flowAuth_row['rules'] == '') {
return false;
}
$rules = json_decode($flowAuth_row['rules'], true);
if (!isset($rules['start'])) {
return false;
}
$startRules = $rules['start'];
if ($startRules == '') {
return false;
}
$user_id = $lib->getSessionUid();
$groupAaccess_config = config::getConfig('group_access');
$groupAccess = $lib->getGroupAccess([$groupAaccess_config['uid']=>$user_id]);
foreach ($startRules as $startRule) {
if ($startRule['behavior'] == 1) {
if ($startRule['worker'] == '') {
return true;
}
$startRule['worker'] = explode(',', $startRule['worker']);
if ($startRule['scope'] == 1) {
if (in_array($user_id, $startRule['worker'])) {
return true;
}
} elseif ($startRule['scope'] == 2) {
foreach ($groupAccess as $access) {
$groupId = $access[$groupAaccess_config['group_id']];
if (in_array($groupId, $startRule['worker'])) {
return true;
}
}
}
}
}
return false;
}
//允许编辑的字段 如果为true允许编辑全表字段
public function getCanEditFields($bill, $bill_id, $thread_id = null)
{
$lib = new lib();
$can_edit_fields = [];
$isSuperManager = false;
$user_id = $lib->getSessionUid();
$groupAaccess_config = config::getConfig('group_access');
$groupAccess = $lib->getGroupAccess([$groupAaccess_config['uid']=>$user_id]);
foreach ($groupAccess as $access) {
$groupId = $access[$groupAaccess_config['group_id']];
$group_rows = $lib->getGroup($groupId);
if ($group_rows)
{
$group = $group_rows[0];
}
if ($group['pid'] == 0) {
$isSuperManager = true;
}
}
if ($isSuperManager) {
return true;
}
$bill_row = $lib->getBillRow($bill, $bill_id);
if (!$bill_row) {
return [];
}
$bill_auth_info = $lib->getBillAuthInfo($bill_row['initiator_id'], $bill, $bill_id);
$code = $bill_auth_info['code'];
if ($code == 0) {
return true;
} elseif ($code == 1) {
$thread = $lib->getThreadById($thread_id);
if (!$thread) {
return [];
} else {
if ($thread['status'] != 1) {
return [];
} else {
if ($lib->checkThreadAuth($thread) == false) {
return [];
}
}
}
$bill_process = $lib->getProcessByBill($bill, $bill_id);
$flow_id = $bill_process['flow_id'];
$flowAuth_rows = $lib->getAuthCopyRow(['flow_id' => $flow_id]);
if (!$flowAuth_rows) {
return [];
}
$flowAuth_row = $flowAuth_rows[0];
if ($flowAuth_row['rules'] == '') {
return false;
}
$rules = json_decode($flowAuth_row['rules'], true);
if (!isset($rules['edit'])) {
return false;
}
$editRules = $rules['edit'];
if ($editRules == '') {
return [];
}
foreach ($editRules as $editRule) {
if ($editRule['steps'] == '') {
if ($editRule['fields'] == '') {
return true;
} else {
$can_edit_fields = array_merge($can_edit_fields, explode(',', $editRule['fields']));
}
} else {
if (in_array($thread['step_id'], explode(',', $editRule['steps']))) {
if ($editRule['fields'] == '') {
return true;
} else {
$can_edit_fields = array_merge($can_edit_fields, explode(',', $editRule['fields']));
}
}
}
}
return array_unique($can_edit_fields);
}
return [];
}
public function getBillFields($bill)
{
$lib = new lib();
$bill_fileds = $lib->getFieldsWithComment($bill);
$fields = [];
foreach ($bill_fileds as $bill_filed) {
$fields[] = $bill_filed['field'];
}
return $fields;
}
}
|