Commit aa22879e911355c65cdcb25daf09ea340ac2f3ff
1 parent
1d8bef6c
Admin
Showing
2 changed files
with
41 additions
and
29 deletions
Show diff stats
frontend/controllers/CabinetController.php
... | ... | @@ -82,7 +82,7 @@ |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | |
85 | - public function actionSales($id = NULL) | |
85 | + public function actionSales($id = null) | |
86 | 86 | { |
87 | 87 | $newRecord = false; |
88 | 88 | if ($id) { |
... | ... | @@ -132,13 +132,19 @@ |
132 | 132 | |
133 | 133 | public function actionList() |
134 | 134 | { |
135 | - $table = IntellectualProperty::find() | |
136 | - ->where( | |
137 | - [ | |
138 | - 'user_id' => \Yii::$app->user->id, | |
139 | - ] | |
140 | - ) | |
141 | - ->all(); | |
135 | + /** | |
136 | + * @var User $user | |
137 | + */ | |
138 | + $user = \Yii::$app->user->identity; | |
139 | + $tableQuery = IntellectualProperty::find(); | |
140 | + if (!$user->isAdmin()) { | |
141 | + $tableQuery->where( | |
142 | + [ | |
143 | + 'user_id' => \Yii::$app->user->id, | |
144 | + ] | |
145 | + ); | |
146 | + } | |
147 | + $table = $tableQuery->all(); | |
142 | 148 | return $this->render( |
143 | 149 | 'list', |
144 | 150 | [ |
... | ... | @@ -155,13 +161,13 @@ |
155 | 161 | $user = \Yii::$app->user->identity; |
156 | 162 | if ($user->isAdmin()) { |
157 | 163 | $reports = Report::find() |
158 | - ->with('intellectualProperty') | |
159 | - ->all(); | |
164 | + ->with('intellectualProperty') | |
165 | + ->all(); | |
160 | 166 | } else { |
161 | 167 | $reports = Report::find() |
162 | - ->joinWith('intellectualProperty.creativeRoles') | |
163 | - ->where([ 'creative_role.user_id' => $user->id ]) | |
164 | - ->all(); | |
168 | + ->joinWith('intellectualProperty.creativeRoles') | |
169 | + ->where([ 'creative_role.user_id' => $user->id ]) | |
170 | + ->all(); | |
165 | 171 | } |
166 | 172 | return $this->render( |
167 | 173 | 'arrivals', |
... | ... | @@ -179,13 +185,13 @@ |
179 | 185 | $user = \Yii::$app->user->identity; |
180 | 186 | if ($user->isAdmin()) { |
181 | 187 | $table = Report::find() |
182 | - ->with('intellectualProperty') | |
183 | - ->all(); | |
188 | + ->with('intellectualProperty') | |
189 | + ->all(); | |
184 | 190 | } else { |
185 | 191 | $table = Report::find() |
186 | - ->joinWith('intellectualProperty.creativeRoles') | |
187 | - ->where([ 'creative_role.user_id' => $user->id ]) | |
188 | - ->all(); | |
192 | + ->joinWith('intellectualProperty.creativeRoles') | |
193 | + ->where([ 'creative_role.user_id' => $user->id ]) | |
194 | + ->all(); | |
189 | 195 | } |
190 | 196 | return $this->render( |
191 | 197 | 'notifications', |
... | ... | @@ -323,7 +329,7 @@ |
323 | 329 | $response = \Yii::$app->response; |
324 | 330 | $response->format = $response::FORMAT_JSON; |
325 | 331 | |
326 | - if (!empty($request->post('id'))) { | |
332 | + if (!empty( $request->post('id') )) { | |
327 | 333 | $role = IntellectualProperty::findOne($request->post('id')); |
328 | 334 | if ($role->delete()) { |
329 | 335 | return [ |
... | ... | @@ -405,7 +411,7 @@ |
405 | 411 | $response = \Yii::$app->response; |
406 | 412 | $response->format = $response::FORMAT_JSON; |
407 | 413 | |
408 | - if (!empty($request->post('id'))) { | |
414 | + if (!empty( $request->post('id') )) { | |
409 | 415 | $role = CreativeRole::findOne($request->post('id')); |
410 | 416 | if ($role->delete()) { |
411 | 417 | return [ |
... | ... | @@ -428,14 +434,20 @@ |
428 | 434 | |
429 | 435 | public function findProperty($id) |
430 | 436 | { |
431 | - $model = IntellectualProperty::find() | |
432 | - ->where( | |
433 | - [ | |
434 | - 'id' => $id, | |
435 | - 'user_id' => \Yii::$app->user->id, | |
436 | - ] | |
437 | - ) | |
438 | - ->one(); | |
437 | + /** | |
438 | + * @var User $user | |
439 | + */ | |
440 | + $user = \Yii::$app->user->identity; | |
441 | + $modelQuery = IntellectualProperty::find(); | |
442 | + if (!$user->isAdmin()) { | |
443 | + $modelQuery->where( | |
444 | + [ | |
445 | + 'id' => $id, | |
446 | + 'user_id' => \Yii::$app->user->id, | |
447 | + ] | |
448 | + ); | |
449 | + } | |
450 | + $model = $modelQuery->one(); | |
439 | 451 | if (empty( $model )) { |
440 | 452 | throw new NotFoundHttpException(); |
441 | 453 | } | ... | ... |
frontend/views/cabinet/index.php