@@ -20,8 +20,7 @@ public function __construct()
20
20
21
21
public function index_f ()
22
22
{
23
- if (!$ this ->popedom ["list " ])
24
- {
23
+ if (!$ this ->popedom ["list " ]){
25
24
error (P_Lang ('无权限,请联系超级管理员开放权限 ' ),'' ,'error ' );
26
25
}
27
26
$ pageid = $ this ->get ($ this ->config ["pageid " ],"int " );
@@ -32,15 +31,13 @@ public function index_f()
32
31
$ condition = "1=1 " ;
33
32
$ keywords = $ this ->get ("keywords " );
34
33
$ pageurl = $ this ->url ("admin " );
35
- if ($ keywords )
36
- {
34
+ if ($ keywords ){
37
35
$ condition .= " AND account LIKE '% " .$ keywords ."%' " ;
38
36
$ pageurl .= '&keywords= ' .rawurlencode ($ keywords );
39
37
}
40
38
$ rslist = $ this ->model ('admin ' )->get_list ($ condition ,$ offset ,$ psize );
41
39
$ total = $ this ->model ('admin ' )->get_total ($ condition );
42
- if ($ total > $ psize )
43
- {
40
+ if ($ total > $ psize ){
44
41
$ pagelist = phpok_page ($ pageurl ,$ total ,$ pageid ,$ psize ,"home=首页&prev=上一页&next=下一页&last=尾页&half=5&add=(total)/(psize)&always=1 " );
45
42
$ this ->assign ("pagelist " ,$ pagelist );
46
43
}
@@ -53,33 +50,25 @@ public function set_f()
53
50
{
54
51
$ id = $ this ->get ("id " ,"int " );
55
52
$ plist = array ();
56
- if ($ id )
57
- {
58
- if (!$ this ->popedom ["modify " ])
59
- {
53
+ if ($ id ){
54
+ if (!$ this ->popedom ["modify " ]){
60
55
error (P_Lang ('无权限,请联系超级管理员开放权限 ' ),'' ,'error ' );
61
56
}
62
- if ($ id == $ _SESSION ["admin_id " ])
63
- {
57
+ if ($ id == $ _SESSION ["admin_id " ]){
64
58
error (P_Lang ('您不能操作自己的信息 ' ),$ this ->url ("admin " ),"error " );
65
59
}
66
60
$ this ->assign ("id " ,$ id );
67
61
$ rs = $ this ->model ('admin ' )->get_one ($ id );
68
- if ($ rs ["if_system " ] && !$ _SESSION ["admin_rs " ]["if_system " ])
69
- {
62
+ if ($ rs ["if_system " ] && !$ _SESSION ["admin_rs " ]["if_system " ]){
70
63
error (P_Lang ("非系统管理员不能编辑系统管理员信息 " ),$ this ->url ("admin " ),"error " );
71
64
}
72
65
$ this ->assign ("rs " ,$ rs );
73
- if (!$ rs ["if_system " ])
74
- {
66
+ if (!$ rs ["if_system " ]){
75
67
$ plist = $ this ->model ('admin ' )->get_popedom_list ($ id );
76
68
}
77
69
$ category = $ rs ['category ' ] ? explode (", " ,$ rs ['category ' ]) : array ('all ' );
78
- }
79
- else
80
- {
81
- if (!$ this ->popedom ["add " ])
82
- {
70
+ }else {
71
+ if (!$ this ->popedom ["add " ]){
83
72
error (P_Lang ('无权限,请联系超级管理员开放权限 ' ),'' ,'error ' );
84
73
}
85
74
$ category = array ('all ' );
@@ -94,17 +83,12 @@ public function set_f()
94
83
$ c_rs = $ this ->model ('sysmenu ' )->get_one_condition ("appfile='list' AND parent_id>0 " );
95
84
$ this ->assign ("c_rs " ,$ c_rs );
96
85
$ sitelist = $ this ->model ('site ' )->get_all_site ();
97
- if ($ sitelist )
98
- {
99
- foreach ($ sitelist AS $ key =>$ value )
100
- {
86
+ if ($ sitelist ){
87
+ foreach ($ sitelist AS $ key =>$ value ){
101
88
$ all_project = $ this ->model ('project ' )->get_all_project ($ value ["id " ]);
102
- if ($ all_project )
103
- {
104
- foreach ($ all_project AS $ k =>$ v )
105
- {
106
- if ($ clist [$ v ["id " ]])
107
- {
89
+ if ($ all_project ){
90
+ foreach ($ all_project AS $ k =>$ v ){
91
+ if ($ clist [$ v ["id " ]]){
108
92
$ all_project [$ k ]["_popedom " ] = $ clist [$ v ["id " ]];
109
93
}
110
94
}
@@ -122,12 +106,9 @@ public function check_if_system_f()
122
106
{
123
107
$ id = $ this ->get ("id " ,"int " );
124
108
$ exit = $ this ->check_system ($ id );
125
- if ($ exit == "ok " )
126
- {
109
+ if ($ exit == "ok " ){
127
110
$ this ->json ("ok " ,true );
128
- }
129
- else
130
- {
111
+ }else {
131
112
$ this ->json ($ exit );
132
113
}
133
114
}
@@ -136,20 +117,16 @@ public function check_system($id=0)
136
117
{
137
118
$ condition = "if_system=1 AND status=1 " ;
138
119
$ rslist = $ this ->model ('admin ' )->get_list ($ condition ,0 ,100 );
139
- if (!$ rslist )
140
- {
120
+ if (!$ rslist ){
141
121
return P_Lang ('没有系统管理员,请检查 ' );
142
122
}
143
123
$ if_system = false ;
144
- foreach ($ rslist AS $ key =>$ value )
145
- {
146
- if ($ value ["id " ] != $ id )
147
- {
124
+ foreach ($ rslist AS $ key =>$ value ){
125
+ if ($ value ["id " ] != $ id ){
148
126
$ if_system = true ;
149
127
}
150
128
}
151
- if (!$ if_system )
152
- {
129
+ if (!$ if_system ){
153
130
return P_Lang ('至少需要有一位可登录的系统管理员,请检查! ' );
154
131
}
155
132
return "ok " ;
@@ -158,18 +135,15 @@ public function check_system($id=0)
158
135
//删除管理员
159
136
public function delete_f ()
160
137
{
161
- if (!$ this ->popedom ['delete ' ])
162
- {
138
+ if (!$ this ->popedom ['delete ' ]){
163
139
$ this ->json (P_Lang ('无权限,请联系超级管理员开放权限 ' ));
164
140
}
165
141
$ id = $ this ->get ('id ' ,'int ' );
166
- if (!$ id )
167
- {
142
+ if (!$ id ){
168
143
$ this ->json (P_Lang ('未指定ID ' ));
169
144
}
170
145
$ exit = $ this ->check_system ($ id );
171
- if ($ exit != "ok " )
172
- {
146
+ if ($ exit != "ok " ){
173
147
$ this ->json ($ exit );
174
148
}
175
149
$ this ->model ('admin ' )->delete ($ id );
@@ -182,22 +156,19 @@ public function check_account_f()
182
156
$ id = $ this ->get ("id " ,"int " );
183
157
$ account = $ this ->get ("account " );
184
158
$ str = $ this ->check_account ($ account ,$ id );
185
- if ($ str == "ok " )
186
- {
159
+ if ($ str == "ok " ){
187
160
$ this ->json ("ok " ,true );
188
161
}
189
162
$ this ->json ($ str );
190
163
}
191
164
192
165
public function check_account ($ account ,$ id =0 )
193
166
{
194
- if (!$ account )
195
- {
167
+ if (!$ account ){
196
168
return P_Lang ('账号不能为空 ' );
197
169
}
198
170
$ rs = $ this ->model ('admin ' )->check_account ($ account ,$ id );
199
- if ($ rs )
200
- {
171
+ if ($ rs ){
201
172
return P_Lang ('账号已存在 ' );
202
173
}
203
174
return "ok " ;
@@ -207,86 +178,64 @@ public function check_account($account,$id=0)
207
178
public function save_f ()
208
179
{
209
180
$ id = $ this ->get ("id " ,"int " );
210
- if ($ id && $ id == $ _SESSION ["admin_id " ])
211
- {
181
+ if ($ id && $ id == $ _SESSION ["admin_id " ]){
212
182
error (P_Lang ('您不能操作自己的信息 ' ),$ this ->url ("admin " ),"error " );
213
183
}
214
- if ($ id )
215
- {
216
- if (!$ this ->popedom ["modify " ])
217
- {
184
+ if ($ id ){
185
+ if (!$ this ->popedom ["modify " ]){
218
186
error (P_Lang ('无权限,请联系超级管理员开放权限 ' ),'' ,'error ' );
219
187
}
220
- }
221
- else
222
- {
223
- if (!$ this ->popedom ["add " ])
224
- {
188
+ }else {
189
+ if (!$ this ->popedom ["add " ]){
225
190
error (P_Lang ('无权限,请联系超级管理员开放权限 ' ),'' ,'error ' );
226
191
}
227
192
}
228
193
$ account = $ this ->get ("account " );
229
- if (!$ account )
230
- {
194
+ if (!$ account ){
231
195
error (P_Lang ('账号不能为空 ' ),$ this ->url ("admin " ,"set " ,"id= " .$ id ),"error " );
232
196
}
233
197
$ check_str = $ this ->check_account ($ account ,$ id );
234
- if ($ check_str != "ok " )
235
- {
198
+ if ($ check_str != "ok " ){
236
199
error ($ check_str ,$ this ->url ("admin " ,"set " ,"id= " .$ id ),"error " );
237
200
}
238
201
$ array = array ();
239
202
$ array ["account " ] = $ account ;
240
203
$ pass = $ this ->get ("pass " );
241
- if (!$ pass && !$ id )
242
- {
204
+ if (!$ pass && !$ id ){
243
205
error (P_Lang ('密码不能为空 ' ),$ this ->url ("admin " ,"set " ,"id= " .$ id ),"error " );
244
206
}
245
- if ($ pass )
246
- {
247
- if (strlen ($ pass ) < 4 )
248
- {
207
+ if ($ pass ){
208
+ if (strlen ($ pass ) < 4 ){
249
209
error (P_Lang ('密码长度不能少于4位 ' ),$ this ->url ("admin " ,"set " ,"id= " .$ id ),"error " );
250
210
}
251
211
$ array ["pass " ] = password_create ($ pass );
252
212
}
253
213
$ array ['email ' ] = $ this ->get ("email " );
254
- if ($ this ->popedom ["status " ])
255
- {
214
+ if ($ this ->popedom ["status " ]){
256
215
$ array ["status " ] = $ this ->get ("status " ,"int " );
257
216
}
258
217
$ if_system = $ this ->get ("if_system " ,"int " );
259
- if (!$ _SESSION ["admin_rs " ]["if_system " ])
260
- {
218
+ if (!$ _SESSION ["admin_rs " ]["if_system " ]){
261
219
$ if_system = 0 ;
262
220
}
263
221
$ array ["if_system " ] = $ if_system ;
264
222
$ is_edit = false ;
265
- if ($ id )
266
- {
223
+ if ($ id ){
267
224
$ st = $ this ->model ('admin ' )->save ($ array ,$ id );
268
- if (!$ st )
269
- {
225
+ if (!$ st ){
270
226
error (P_Lang ('管理员信息更新失败,请检查 ' ),$ this ->url ("admin " ,"set " ,"id= " .$ id ),"error " );
271
227
}
272
228
$ is_edit = true ;
273
- }
274
- else
275
- {
229
+ }else {
276
230
$ id = $ this ->model ('admin ' )->save ($ array );
277
- if (!$ id )
278
- {
231
+ if (!$ id ){
279
232
error (P_Lang ('管理员信息添加失败,请检查 ' ),$ this ->url ("admin " ,"set " ),"error " );
280
233
}
281
234
}
282
- //清空权限信息
283
235
$ this ->model ('admin ' )->clear_popedom ($ id );
284
- //更新普通管理员权限
285
- if (!$ if_system )
286
- {
236
+ if (!$ if_system ){
287
237
$ popedom = $ this ->get ("popedom " );
288
- if ($ popedom )
289
- {
238
+ if ($ popedom ){
290
239
$ popedom = array_unique ($ popedom );
291
240
$ this ->model ('admin ' )->save_popedom ($ popedom ,$ id );
292
241
}
@@ -298,28 +247,22 @@ public function save_f()
298
247
//更新管理员状态
299
248
public function status_f ()
300
249
{
301
- if (!$ this ->popedom ['status ' ])
302
- {
250
+ if (!$ this ->popedom ['status ' ]){
303
251
$ this ->json (P_Lang ('无权限,请联系超级管理员开放权限 ' ));
304
252
}
305
253
$ id = $ this ->get ('id ' ,'int ' );
306
- if (!$ id )
307
- {
254
+ if (!$ id ){
308
255
$ this ->json (P_Lang ('未指定ID ' ));
309
256
}
310
- if ($ id == $ _SESSION ["admin_id " ])
311
- {
257
+ if ($ id == $ _SESSION ["admin_id " ]){
312
258
$ this ->json (P_Lang ('您不能操作自己的信息 ' ));
313
259
}
314
260
$ rs = $ this ->model ('admin ' )->get_one ($ id );
315
261
$ status = $ rs ["status " ] ? 0 : 1 ;
316
262
$ action = $ this ->model ('admin ' )->update_status ($ id ,$ status );
317
- if (!$ action )
318
- {
263
+ if (!$ action ){
319
264
$ this ->json (P_Lang ('更新状态失败 ' ));
320
- }
321
- else
322
- {
265
+ }else {
323
266
$ this ->json ($ status ,true );
324
267
}
325
268
}
0 commit comments