| Line 12... |
Line 12... |
| 12 |
* Components
|
12 |
* Components
|
| 13 |
*
|
13 |
*
|
| 14 |
* @var array
|
14 |
* @var array
|
| 15 |
*/
|
15 |
*/
|
| 16 |
public $components = array('Paginator');
|
16 |
public $components = array('Paginator');
|
| - |
|
17 |
public $apihost;
|
| - |
|
18 |
public $limit;
|
| 17 |
|
19 |
|
| 18 |
public function beforeFilter() {
|
20 |
public function beforeFilter() {
|
| 19 |
parent::beforeFilter();
|
21 |
parent::beforeFilter();
|
| 20 |
$this->Auth->allow('deals');
|
22 |
$this->Auth->allow('deals');
|
| - |
|
23 |
$this->apihost = Configure::read('pythonapihost');
|
| - |
|
24 |
$this->limit = Configure::read('dealsperpage');
|
| 21 |
}
|
25 |
}
|
| 22 |
|
26 |
|
| 23 |
/**
|
27 |
/**
|
| 24 |
* index method
|
28 |
* index method
|
| 25 |
*
|
29 |
*
|
| Line 59... |
Line 63... |
| 59 |
$this->loadModel('User');
|
63 |
$this->loadModel('User');
|
| 60 |
$dbuser = $this->User->findById($userId);
|
64 |
$dbuser = $this->User->findById($userId);
|
| 61 |
$this->Auth->login($dbuser['User']);
|
65 |
$this->Auth->login($dbuser['User']);
|
| 62 |
}
|
66 |
}
|
| 63 |
$likedDeals = $disLikedDeals = array();
|
67 |
$likedDeals = $disLikedDeals = array();
|
| 64 |
$this->loadModel('Api');
|
68 |
// $this->loadModel('Api');
|
| 65 |
$apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);
|
69 |
// $apideals = $this->Api->getCategoryDeals($this->Auth->User('id'),1);
|
| 66 |
$categorydeals = $apideals['products'];
|
70 |
// $categorydeals = $apideals['products'];
|
| - |
|
71 |
$page = $this->request->query('page');
|
| - |
|
72 |
if(!isset($page)){
|
| - |
|
73 |
$page = 1;
|
| - |
|
74 |
}
|
| - |
|
75 |
$offset = ($page - 1) * $this->limit;
|
| - |
|
76 |
$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId=0&limit='.$this->limit.'&offset='.$offset;
|
| - |
|
77 |
$deals = $this->make_request($url,null);
|
| 67 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
78 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| 68 |
if(!empty($myactions)) {
|
79 |
if(!empty($myactions)) {
|
| 69 |
foreach ($myactions['actions'] as $key => $value) {
|
80 |
foreach ($myactions['actions'] as $key => $value) {
|
| 70 |
if($value['UserAction']['action'] == 'like'){
|
81 |
if($value['UserAction']['action'] == 'like'){
|
| 71 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
82 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| Line 98... |
Line 109... |
| 98 |
* @return void
|
109 |
* @return void
|
| 99 |
*/
|
110 |
*/
|
| 100 |
public function view($id = null) {
|
111 |
public function view($id = null) {
|
| 101 |
$this->checkMobileNumber();
|
112 |
$this->checkMobileNumber();
|
| 102 |
$likedDeals = $disLikedDeals = array();
|
113 |
$likedDeals = $disLikedDeals = array();
|
| 103 |
if (!$this->Category->exists($id)) {
|
114 |
// if (!$this->Category->exists($id)) {
|
| 104 |
throw new NotFoundException(__('Invalid category'));
|
115 |
// throw new NotFoundException(__('Invalid category'));
|
| 105 |
}
|
116 |
// }
|
| 106 |
$page = $this->request->query('page');
|
117 |
$page = $this->request->query('page');
|
| 107 |
if(!isset($page)){
|
118 |
if(!isset($page)){
|
| 108 |
$page = 1;
|
119 |
$page = 1;
|
| 109 |
}
|
120 |
}
|
| - |
|
121 |
$offset = ($page - 1) * $this->limit;
|
| - |
|
122 |
$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id.'&limit='.$this->limit.'&offset='.$offset;
|
| - |
|
123 |
$deals = $this->make_request($url,null);
|
| 110 |
$this->loadModel('Api');
|
124 |
$this->loadModel('Api');
|
| 111 |
$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
|
125 |
// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
|
| 112 |
$deals = $apideals['products'];
|
126 |
// $deals = $apideals['products'];
|
| 113 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
127 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| 114 |
if(!empty($myactions)) {
|
128 |
if(!empty($myactions)) {
|
| 115 |
foreach ($myactions['actions'] as $key => $value) {
|
129 |
foreach ($myactions['actions'] as $key => $value) {
|
| 116 |
if($value['UserAction']['action'] == 'like'){
|
130 |
if($value['UserAction']['action'] == 'like'){
|
| 117 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
131 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
| Line 128... |
Line 142... |
| 128 |
$this->layout = 'ajax';
|
142 |
$this->layout = 'ajax';
|
| 129 |
$page = $this->request->query('page');
|
143 |
$page = $this->request->query('page');
|
| 130 |
if(!isset($page)){
|
144 |
if(!isset($page)){
|
| 131 |
$page = 1;
|
145 |
$page = 1;
|
| 132 |
}
|
146 |
}
|
| - |
|
147 |
$offset = ($page - 1) * $this->limit;
|
| - |
|
148 |
$url = $this->apihost.'deals/'.$this->Auth->User('id').'?categoryId='.$id.'&limit='.$this->limit.'&offset='.$offset;
|
| - |
|
149 |
$deals = $this->make_request($url,null);
|
| 133 |
if (!$this->Category->exists($id)) {
|
150 |
// if (!$this->Category->exists($id)) {
|
| 134 |
throw new NotFoundException(__('Invalid category'));
|
151 |
// throw new NotFoundException(__('Invalid category'));
|
| 135 |
}
|
152 |
// }
|
| 136 |
$this->loadModel('Api');
|
153 |
$this->loadModel('Api');
|
| 137 |
$apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
|
154 |
// $apideals = $this->Api->getDealsByCategory($this->Auth->User('id'),$id,$page);
|
| 138 |
$deals = $apideals['products'];
|
155 |
// $deals = $apideals['products'];
|
| 139 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
156 |
$myactions = $this->Api->getMyActions($this->Auth->User('id'));
|
| 140 |
if(!empty($myactions)) {
|
157 |
if(!empty($myactions)) {
|
| 141 |
foreach ($myactions['actions'] as $key => $value) {
|
158 |
foreach ($myactions['actions'] as $key => $value) {
|
| 142 |
if($value['UserAction']['action'] == 'like'){
|
159 |
if($value['UserAction']['action'] == 'like'){
|
| 143 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|
160 |
$likedDeals[$value['UserAction']['store_product_id']] = $value['UserAction']['id'];
|