@@ -236,17 +236,20 @@ |
||
236 | 236 | * @return boolean|\Users\User |
237 | 237 | */ |
238 | 238 | public function get($idn, $ltype = 'id') { |
239 | - if (!$idn) |
|
240 | - return false; |
|
239 | + if (!$idn) { |
|
240 | + return false; |
|
241 | + } |
|
241 | 242 | |
242 | - if (is_numeric($idn) && $ltype != 'login') |
|
243 | - $user = Users\User::get($idn, 'id'); |
|
244 | - elseif ($ltype == 'login') |
|
245 | - $user = Users\User::get($idn, 'login'); |
|
246 | - else |
|
247 | - $user = Users\User::get($idn, 'mail'); |
|
248 | - if (!$user) |
|
249 | - return []; |
|
243 | + if (is_numeric($idn) && $ltype != 'login') { |
|
244 | + $user = Users\User::get($idn, 'id'); |
|
245 | + } elseif ($ltype == 'login') { |
|
246 | + $user = Users\User::get($idn, 'login'); |
|
247 | + } else { |
|
248 | + $user = Users\User::get($idn, 'mail'); |
|
249 | + } |
|
250 | + if (!$user) { |
|
251 | + return []; |
|
252 | + } |
|
250 | 253 | |
251 | 254 | return $user; |
252 | 255 | } |
@@ -258,6 +258,10 @@ |
||
258 | 258 | return $user; |
259 | 259 | } |
260 | 260 | |
261 | + /** |
|
262 | + * @param string $err |
|
263 | + * @param boolean $msg |
|
264 | + */ |
|
261 | 265 | private function msgOrErr($err, $msg) { |
262 | 266 | if ($msg) { |
263 | 267 | Msg::add($err, 'danger'); |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | public function activationAction($userId = 0, $hash = '') { |
115 | - $user = \Users\User::get((int)$userId); |
|
116 | - if (!$user || !$hash || $user->activation !== (string)$hash) { |
|
115 | + $user = \Users\User::get((int) $userId); |
|
116 | + if (!$user || !$hash || $user->activation !== (string) $hash) { |
|
117 | 117 | Tools::redirect('/', 'Во время активации произошли ошибки', 'danger'); |
118 | 118 | } |
119 | 119 | $user->activation = ''; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | public function resendActivationAction($userId = 0) { |
159 | - $user = \Users\User::get((int)$userId); |
|
159 | + $user = \Users\User::get((int) $userId); |
|
160 | 160 | if (!$user) { |
161 | 161 | Tools::redirect('/', 'Не указан пользователь', 'danger'); |
162 | 162 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | public function getPartnerInfoAction($userId = 0) { |
175 | - $userId = (int)$userId; |
|
175 | + $userId = (int) $userId; |
|
176 | 176 | $result = new \Server\Result(); |
177 | 177 | if (!$userId) { |
178 | 178 | $result->success = false; |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | public function changeWarehouse($count) { |
103 | 103 | $warehouse = Offer\Warehouse::get([['count', '0', '>'], ['item_offer_id', $this->id]]); |
104 | 104 | if ($warehouse) { |
105 | - $warehouse->count += (float)$count; |
|
105 | + $warehouse->count += (float) $count; |
|
106 | 106 | $warehouse->save(); |
107 | 107 | } else { |
108 | 108 | $warehouse = Offer\Warehouse::get([['item_offer_id', $this->id]]); |
109 | 109 | if ($warehouse) { |
110 | - $warehouse->count += (float)$count; |
|
110 | + $warehouse->count += (float) $count; |
|
111 | 111 | $warehouse->save(); |
112 | 112 | } |
113 | 113 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | \App::$cur->db->cols = 'COALESCE(sum(' . \Ecommerce\Warehouse\Block::colPrefix() . 'count) ,0) as `sum` '; |
135 | 135 | \App::$cur->db->where(\Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Item\Offer::index(), $this->id); |
136 | 136 | if ($cart_id) { |
137 | - \App::$cur->db->where(\Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Cart::index(), (int)$cart_id, '!='); |
|
137 | + \App::$cur->db->where(\Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Cart::index(), (int) $cart_id, '!='); |
|
138 | 138 | } |
139 | 139 | $on = ' |
140 | 140 | ' . \Ecommerce\Cart::index() . ' = ' . \Ecommerce\Warehouse\Block::colPrefix() . \Ecommerce\Cart::index() . ' AND ( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | $blocked = \App::$cur->db->select(\Ecommerce\Warehouse\Block::table())->fetch(); |
149 | - return (float)$warehouse['sum'] - (float)$blocked['sum']; |
|
149 | + return (float) $warehouse['sum'] - (float) $blocked['sum']; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public function beforeDelete() { |