-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtagAction.class.php
More file actions
334 lines (269 loc) · 8.06 KB
/
tagAction.class.php
File metadata and controls
334 lines (269 loc) · 8.06 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
class tagAction extends Action
{
//管理权限,返回所有的tagID,imagePath, imageID, Name, Desc
//load时候的参数中文名称以及他们的列名称:
//["ID", "图标ID", "图标", "名称", "描述", "上传人"],
//["ID", "imageid", "path", "name", "desc","alias"]
public function loadTagTypes()
{
$tagTypeTable=new Model('tagtype');
$tagTypeResult=$tagTypeTable->query("select * from tagtype");
//根据imageid获取path 根据userid获取上传人的姓名
if($tagTypeResult!=false)
{
reset($tagTypeResult);
$imagetable=new Model('image');
$usertable =new Model('user');
while (list($key, $val) = each($tagTypeResult))
{
$userresult=$usertable->where('ID='.$val['userid'])->select();
$imageresult=$imagetable->where('ID='.$val['imageid'])->select();
$alias=$userresult[0]['alias'];
$tagTypeResult[$key]['alias']=$alias;
$tagTypeResult[$key]['path']=$imageresult[0]['path'];
}
}
$this->success($tagTypeResult);
}
public function addTagType( )
{
$imageID=$_REQUEST['imageID'];
$Name=$_REQUEST['Name'];
$Desc=$_REQUEST['Desc'];
if(!isset($imageID))
{
$this->error("imageID is missing");
}
if(!isset($Name))
{
$this->error("Name is missing");
}
if(!isset($Desc))
{
$this->error("Desc is missing");
}
$uid=Session::get('userid');
$tageTypeTable=new Model('tagtype');
$data['imageid']=$imageID;
$data['name']=$Name;
$data['desc']=$Desc;
$tagID=$tageTypeTable->add($data);
$this->success($tagID);
}
public function removeTagType()
{
$tagID= $_REQUEST['ID'];
if(!isset($tagID))
{
$this->error("ID");
}
$table = New Model('tagtype');
$table->execute("delete from tagtype where ID= '".$tagID."'");
$this->success(true);
}
public function updateItems()
{
$common=new commonAction();
$common->updateItems('tagtype');
$this->success(true);
}
public function modifyTagType()
{
if(!isset($_REQUEST["ID"]))
{
$this->error("ID?");
return;
}
$ID = $_REQUEST["ID"];
if(!isset($_REQUEST["columnName"]))
{
$this->error("columnName?") ;
return;
}
$columnName = $_REQUEST["columnName"];
if(!isset($_REQUEST["value"]))
{
$this->error("value?") ;
return;
}
$value = $_REQUEST["value"];
$vaildColumnName = array("imageid" => true, "name" => true,"desc" => true);
if(!$vaildColumnName[$columnName])
{
$this->error("columnName valid?") ;
return;
}
$table = New Model("tagtype");
$table->execute("update tagtype set `".$columnName."`= '".$value."'"." where ID = ".$ID);
$this->success(true);
}
//input: dataType和dataID
public function getTagInstance()
{
$dataType=$_REQUEST['dataType'];
$dataID=$_REQUEST['dataID'];
$userid=Session::get('userid');
$taginstance=new Model('taginstance');
$condition['dataType']=$dataType;
$condition['dataID']=$dataID;
if($dataType!=5)
{
$condition['userid']=$userid;
}
$result=$taginstance->where($condition)->order('position asc')->select();
//根据tagid找到imageid的path
$tagimage=new Model();
if($result!=false)
{
reset($result);
while (list($key, $val) = each($result))
{
$pathresult=$tagimage->query("select a.ID,a.name,a.imageid,b.imagename,b.path from tagtype a,image b where a.imageid=b.id and a.ID=".$val['tagType']);
$result[$key]['path']=$pathresult[0]['path'];
$result[$key]['tagTypeName']=$pathresult[0]['name'];
$userresult=$tagimage->query("select alias from user where ID = ".$result[$key]['userid']);
$useralias=$userresult[0]['alias'];
$result[$key]['useralias']=$useralias;
}
}
$this->success($result);
}
public function addTagInstance()
{
$tag=$_REQUEST['tag'];
$tagType=$_REQUEST['tagType'];
$dataType=$_REQUEST['dataType'];
$dataID=$_REQUEST['dataID'];
$uid=Session::get('userid');
if(isset($_REQUEST['position']))
{
$position=$_REQUEST['position'];
}
//check priority to add tag
if($dataType==5)
{
$epgversion=new Model('epgversion');
$epgresult=$epgversion->where('ID='.$dataID)->find();
$channleid=$epgresult['channelid'];
$permission=new permissionAction();
$power=$permission->getUserPower($uid, $channleid);
//相应频道编播表权限人才可以增加审核标签代表送审
if($tagType==2)
{
if(($power)&(0x1C)==0)
{
$this->error('该账户没有权限加送审标签');
}
}
//相应频道审核权限的人才可以增加播出标签
if($tagType==1)
{
if(($power)&(0x08)==0)
{
$this->error('该账户没有权限加播出标签');
}
}
}
//commandrecord
$userid=Session::get('userid');
$command=new commonAction();
$commandLine='tagAction/addTagInstance';
$params='tag='.$tag.'&tagType='.$tagType.'&dataType='.$dataType.'&dataID='.$dataID;
$command->recordCommand($commandLine, $params, $userid);
$taginstanceTable=new Model('taginstance');
if(!isset($position))
{
$tmpresult=$taginstanceTable->query("select count(*) as tailnum from taginstance where ".
" userid=".$uid." and dataType=".$dataType." and dataID=".$dataID);
$position=$tmpresult[0]['tailnum'];
}
$data['tag']=$tag;
$data['tagType']=$tagType;
$data['userid']=$uid;
$data['dataType']=$dataType;
$data['dataID']=$dataID;
$data['position']=$position;
$taginstanceTable->execute("update taginstance set position=position+1 where position>=".$position.
" and userid=".$uid." and dataType=".$dataType." and dataID=".$dataID);
$rt=$taginstanceTable->add($data);
$this->success($rt);
}
public function modifyTagInstance()
{
if(!isset($_REQUEST["ID"]))
{
$this->error("ID?");
return;
}
$ID = $_REQUEST["ID"];
if(!isset($_REQUEST["columnName"]))
{
$this->error("columnName?") ;
return;
}
$columnName = $_REQUEST["columnName"];
if(!isset($_REQUEST["value"]))
{
$this->error("value?") ;
return;
}
$value = $_REQUEST["value"];
$vaildColumnName = array("tag" => true, "tagType" => true, "dataType" => true, "dataID" => true);
if(!$vaildColumnName[$columnName])
{
$this->error("columnName valid?") ;
return;
}
//commandrecord
$userid=Session::get('userid');
$command=new commonAction();
$commandLine='tagAction/modifyTagInstance';
$params='ID='.$ID.'&columnName='.$columnName.'&value='.$value;
$command->recordCommand($commandLine, $params, $userid);
$table = New Model("taginstance");
$table->execute("update taginstance set `".$columnName."`= '".$value."'"." where ID = ".$ID);
$this->success(true);
}
public function removeTagInstance()
{
$tagID= $_REQUEST['ID'];
if(!isset($tagID))
{
$this->error("ID");
}
//commandrecord
$userid=Session::get('userid');
$command=new commonAction();
$commandLine='tagAction/removeTagInstance';
$params='ID='.$tagID;
$command->recordCommand($commandLine, $params, $userid);
$table = New Model('taginstance');
$self=$table->where('ID='.$tagID)->find();
$table->where("ID=".$tagID)->delete();
$table->execute("update taginstance set position=position-1 where position>".$self['position'].
" and userid=".$self['userid']." and dataType=".$self['dataType']." and dataID=".$self['dataID']);
$this->success(true);
}
public function moveTagInstance()
{
$tagID = $_REQUEST['ID'];
$position = $_REQUEST['position'];
if(!isset($tagID,$position))
{
$this->error("ID?position");
}
$table = New Model('taginstance');
$self=$table->where('ID='.$tagID)->find();
if(!isset($self))
{
$this->error('not find target tag');
}
$table->execute("update taginstance set position=position-1 where position>".$self['position'].
" and userid=".$self['userid']." and dataType=".$self['dataType']." and dataID=".$self['dataID']);
$table->execute("update taginstance set position=position+1 where position>=".$position.
" and userid=".$self['userid']." and dataType=".$self['dataType']." and dataID=".$self['dataID']);
$table->execute("update taginstance set position=".$position." where ID=".$tagID);
$this->success(true);
}
}