Subversion Repositories SmartDukaan

Rev

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