Subversion Repositories SmartDukaan

Rev

Rev 16720 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
16591 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * AppOffers Controller
5
 *
6
 * @property AppOffer $AppOffer
7
 * @property PaginatorComponent $Paginator
8
 * @property FlashComponent $Flash
9
 * @property SessionComponent $Session
10
 */
11
class AppOffersController extends AppController {
12
 
13
/**
14
 * Components
15
 *
16
 * @var array
17
 */
18
	public $components = array('Paginator', 'Flash', 'Session');
19
 
16942 anikendra 20
	public function beforeFilter() {
21
		$this->Auth->allow('nocode');
22
	}
23
 
16591 anikendra 24
/**
25
 * index method
26
 *
27
 * @return void
28
 */
29
	public function index($slug,$type='android') {
16601 anikendra 30
		$page = $this->request->query('page');
31
		if(!isset($page)){			
32
			$page = 1;
33
		}
16591 anikendra 34
		$slug = $this->params['slug1'];
35
		$type = $this->params['slug2'];
16942 anikendra 36
		if($slug<1984) {
37
			return $this->redirect(array('action' => 'nocode',2,3,4));
38
			exit();
39
		}
16594 anikendra 40
		$me = $slug-1984;
16591 anikendra 41
		$appOffers = array();
16720 anikendra 42
		$url = $this->apihost."appOffers/1";
16591 anikendra 43
		$appOffers = $this->make_request($url,null);
16601 anikendra 44
		$this->set(compact('appOffers','me','slug','type','page'));
16591 anikendra 45
		// $this->set('appOffers', $this->Paginator->paginate());
46
	}
47
 
16942 anikendra 48
	public function nocode($i,$j,$k){
49
 
50
	}
16591 anikendra 51
/**
52
 * view method
53
 *
54
 * @throws NotFoundException
55
 * @param string $id
56
 * @return void
57
 */
58
	public function view($id = null) {
59
		if (!$this->AppOffer->exists($id)) {
60
			throw new NotFoundException(__('Invalid app offer'));
61
		}
62
		$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
63
		$this->set('appOffer', $this->AppOffer->find('first', $options));
64
	}
65
 
66
/**
67
 * add method
68
 *
69
 * @return void
70
 */
71
	public function add() {
72
		if ($this->request->is('post')) {
73
			$this->AppOffer->create();
74
			if ($this->AppOffer->save($this->request->data)) {
75
				$this->Flash->success(__('The app offer has been saved.'));
76
				return $this->redirect(array('action' => 'index'));
77
			} else {
78
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
79
			}
80
		}
81
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
82
		$this->set(compact('appAffiliates'));
83
	}
84
 
85
/**
86
 * edit method
87
 *
88
 * @throws NotFoundException
89
 * @param string $id
90
 * @return void
91
 */
92
	public function edit($id = null) {
93
		if (!$this->AppOffer->exists($id)) {
94
			throw new NotFoundException(__('Invalid app offer'));
95
		}
96
		if ($this->request->is(array('post', 'put'))) {
97
			if ($this->AppOffer->save($this->request->data)) {
98
				$this->Flash->success(__('The app offer has been saved.'));
99
				return $this->redirect(array('action' => 'index'));
100
			} else {
101
				$this->Flash->error(__('The app offer could not be saved. Please, try again.'));
102
			}
103
		} else {
104
			$options = array('conditions' => array('AppOffer.' . $this->AppOffer->primaryKey => $id));
105
			$this->request->data = $this->AppOffer->find('first', $options);
106
		}
107
		$appAffiliates = $this->AppOffer->AppAffiliate->find('list');
108
		$this->set(compact('appAffiliates'));
109
	}
110
 
111
/**
112
 * delete method
113
 *
114
 * @throws NotFoundException
115
 * @param string $id
116
 * @return void
117
 */
118
	public function delete($id = null) {
119
		$this->AppOffer->id = $id;
120
		if (!$this->AppOffer->exists()) {
121
			throw new NotFoundException(__('Invalid app offer'));
122
		}
123
		$this->request->allowMethod('post', 'delete');
124
		if ($this->AppOffer->delete()) {
125
			$this->Flash->success(__('The app offer has been deleted.'));
126
		} else {
127
			$this->Flash->error(__('The app offer could not be deleted. Please, try again.'));
128
		}
129
		return $this->redirect(array('action' => 'index'));
130
	}
131
}