11<?php
2+
23/**
34 * Acoes do modulo "Call".
45 *
@@ -31,11 +32,17 @@ class DidwwController extends Controller
3132
3233 public function init ()
3334 {
35+
36+
3437 parent ::init ();
3538 $ this ->api_key = $ this ->config ['global ' ]['didww_api_key ' ];
3639 $ this ->url = $ this ->config ['global ' ]['didww_url ' ];
3740 $ this ->profit = '1. ' . $ this ->config ['global ' ]['didww_profit ' ];
3841 $ this ->currency_converter = $ this ->config ['global ' ]['didww_curreny_converter ' ];
42+
43+ if (strlen ($ this ->api_key ) < 10 ) {
44+ exit ;
45+ }
3946 }
4047
4148 public function actionAdd ()
@@ -50,7 +57,6 @@ public function actionAdd()
5057 'status ' => $ this ->orderDid (),
5158
5259 ]);
53-
5460 } else if (isset ($ _POST ['Did ' ]['did ' ])) {
5561
5662 $ this ->render ('confirmation ' , [
@@ -59,34 +65,30 @@ public function actionAdd()
5965 'profit ' => $ this ->profit ,
6066
6167 ]);
62-
6368 } elseif (isset ($ _POST ['Did ' ]['city ' ])) {
6469 $ this ->render ('did ' , [
6570 'did ' => $ did ,
6671 'dids ' => $ this ->getDids ($ _POST ['Did ' ]['city ' ]),
6772
6873 ]);
69-
7074 } else if (isset ($ _POST ['Did ' ]['country ' ])) {
7175
7276 $ this ->render ('city ' , [
7377 'did ' => $ did ,
7478 'cities ' => $ this ->getCities ($ _POST ['Did ' ]['country ' ]),
7579 ]);
76-
7780 } else {
7881 $ this ->render ('country ' , [
7982 'did ' => $ did ,
8083 'countries ' => $ this ->getCountries (),
8184 ]);
8285 }
83-
8486 }
8587
8688 public function confirmeDid ($ id_did )
8789 {
8890
89- if ( ! is_numeric ($ id_did )) {
91+ if (! is_numeric ($ id_did )) {
9092 exit ;
9193 }
9294
@@ -146,14 +148,15 @@ public function orderDid()
146148 'type ' => 'orders ' ,
147149 'attributes ' => [
148150 'allow_back_ordering ' => true ,
149- 'items ' => [[
150- 'type ' => 'did_order_items ' ,
151- 'attributes ' => [
152- 'qty ' => '1 ' ,
153- 'sku_id ' => Yii::app ()->session ['sku_id ' ],
154- ],
151+ 'items ' => [
152+ [
153+ 'type ' => 'did_order_items ' ,
154+ 'attributes ' => [
155+ 'qty ' => '1 ' ,
156+ 'sku_id ' => Yii::app ()->session ['sku_id ' ],
157+ ],
155158
156- ],
159+ ],
157160 ],
158161 ],
159162 ],
@@ -209,13 +212,12 @@ public function orderDid()
209212 }
210213
211214 return $ order ->data ->attributes ->status ;
212-
213215 }
214216
215217 public function getDids ($ id_city )
216218 {
217219
218- if ( ! is_numeric ($ id_city )) {
220+ if (! is_numeric ($ id_city )) {
219221 exit ;
220222 }
221223
@@ -247,7 +249,7 @@ public function getDids($id_city)
247249
248250 $ dids = json_decode ($ result );
249251
250- if ( ! isset ($ dids ->data [0 ]->id )) {
252+ if (! isset ($ dids ->data [0 ]->id )) {
251253
252254 echo 'We not have DID to this city. <a href=" ' . $ _SERVER ['REQUEST_URI ' ] . '"> Click here to restart<a/> ' ;
253255 exit ;
@@ -262,7 +264,6 @@ public function getDids($id_city)
262264 }
263265
264266 return $ result ;
265-
266267 }
267268
268269 public function getCities ($ country_id )
@@ -313,17 +314,15 @@ public function getCities($country_id)
313314 if (count ($ did_groups ->data ) >= 1000 ) {
314315 break ;
315316 }
316-
317317 }
318318
319- if ( ! isset ($ result [0 ])) {
319+ if (! isset ($ result [0 ])) {
320320
321321 echo 'We not have DID to this city. <a href=" ' . $ _SERVER ['REQUEST_URI ' ] . '"> Click here to restart<a/> ' ;
322322 exit ;
323323 }
324324
325325 return $ result ;
326-
327326 }
328327
329328 public function getCountries ()
@@ -377,7 +376,5 @@ public function getCountries()
377376 exit ('Invalid data ' );
378377 }
379378 return $ result ;
380-
381379 }
382-
383380}
0 commit comments