Subversion Repositories SmartDukaan

Rev

Rev 15403 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15403 manish.sha 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Mobileappsettings Controller
5
 *
6
 * @property Mobileappsetting $Mobileappsetting
7
 * @property PaginatorComponent $Paginator
8
 */
9
class MobileappsettingsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
18
	public function index() {	
15655 anikendra 19
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 20
		$this->layout = 'ajax';
21
		$t = $this->request->query('t');
22
		if(!empty($t) && $t >0){
23
			$options = array('conditions'=>array("unix_timestamp(modified) > "=>$t));
24
		}else{
25
			$options = null;
26
		}
27
		$settings = $this->Mobileappsetting->find('all',$options);
28
		$options = array('fields'=>array("unix_timestamp(modified) t"),'order'=>array('modified'=>'desc'));
29
		$lasttimestamp = $this->Mobileappsetting->find('first',$options);		
30
		$result = array('settings' => $settings,'t'=>$lasttimestamp[0]['t']);
31
		$this->set(array(
32
		    'result' => $result,
33
		    '_serialize' => array('result')
34
		));
35
		$this->render('/Elements/json');
36
	}
37
/**
38
 * admin_index method
39
 *
40
 * @return void
41
 */
42
	public function admin_index() {
15655 anikendra 43
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 44
		$this->Mobileappsetting->recursive = 0;
45
		$this->set('mobileappsettings', $this->Paginator->paginate());
46
	}
47
 
48
/**
49
 * admin_view method
50
 *
51
 * @throws NotFoundException
52
 * @param string $id
53
 * @return void
54
 */
55
	public function admin_view($id = null) {
15655 anikendra 56
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 57
		if (!$this->Mobileappsetting->exists($id)) {
58
			throw new NotFoundException(__('Invalid mobileappsetting'));
59
		}
60
		$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
61
		$this->set('mobileappsetting', $this->Mobileappsetting->find('first', $options));
62
	}
63
 
64
/**
65
 * admin_add method
66
 *
67
 * @return void
68
 */
69
	public function admin_add() {
15655 anikendra 70
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 71
		if ($this->request->is('post')) {
72
			$this->Mobileappsetting->create();
73
			if ($this->Mobileappsetting->save($this->request->data)) {
74
				$this->Session->setFlash(__('The mobileappsetting has been saved.'));
75
				return $this->redirect(array('action' => 'index'));
76
			} else {
77
				$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
78
			}
79
		}
80
	}
81
 
82
/**
83
 * admin_edit method
84
 *
85
 * @throws NotFoundException
86
 * @param string $id
87
 * @return void
88
 */
89
	public function admin_edit($id = null) {
15655 anikendra 90
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 91
		if (!$this->Mobileappsetting->exists($id)) {
92
			throw new NotFoundException(__('Invalid mobileappsetting'));
93
		}
94
		if ($this->request->is(array('post', 'put'))) {
95
			if ($this->Mobileappsetting->save($this->request->data)) {
96
				$this->Session->setFlash(__('The mobileappsetting has been saved.'));
97
				return $this->redirect(array('action' => 'index'));
98
			} else {
99
				$this->Session->setFlash(__('The mobileappsetting could not be saved. Please, try again.'));
100
			}
101
		} else {
102
			$options = array('conditions' => array('Mobileappsetting.' . $this->Mobileappsetting->primaryKey => $id));
103
			$this->request->data = $this->Mobileappsetting->find('first', $options);
104
		}
105
	}
106
 
107
/**
108
 * admin_delete method
109
 *
110
 * @throws NotFoundException
111
 * @param string $id
112
 * @return void
113
 */
114
	public function admin_delete($id = null) {
15655 anikendra 115
		throw new NotFoundException(__('Unauthorized access'));
15403 manish.sha 116
		$this->Mobileappsetting->id = $id;
117
		if (!$this->Mobileappsetting->exists()) {
118
			throw new NotFoundException(__('Invalid mobileappsetting'));
119
		}
120
		$this->request->onlyAllow('post', 'delete');
121
		if ($this->Mobileappsetting->delete()) {
122
			$this->Session->setFlash(__('The mobileappsetting has been deleted.'));
123
		} else {
124
			$this->Session->setFlash(__('The mobileappsetting could not be deleted. Please, try again.'));
125
		}
126
		return $this->redirect(array('action' => 'index'));
15655 anikendra 127
	}
128
}