Subversion Repositories SmartDukaan

Rev

Rev 20466 | Rev 20468 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20466 Rev 20467
Line 51... Line 51...
51
 */
51
 */
52
	public function add() {
52
	public function add() {
53
		if ($this->request->is('post')) {
53
		if ($this->request->is('post')) {
54
			$this->log(print_r($this->request->data,1),'devices');
54
			$this->log(print_r($this->request->data,1),'devices');
55
			$device = $this->Device->find('first',array('conditions'=>$this->request->data));
55
			$device = $this->Device->find('first',array('conditions'=>$this->request->data));
56
			$this->log(print_r($this->request->data,1),'devices');			
56
			$this->log(print_r($device,1),'devices');			
57
			if(!$device) {
57
			if(!$device) {
58
				$cachekey = 'webnotifications-'.$this->request->data['user_id'];
58
				$cachekey = 'webnotifications-'.$this->request->data['user_id'];
59
				$activeNotifications = Cache::read($cachekey,$config = 'hour');
59
				$activeNotifications = Cache::read($cachekey,$config = 'hour');
60
				$this->log(print_r($activeNotifications,1),'checknotification');
60
				$this->log(print_r($activeNotifications,1),'checknotification');
61
				if(!empty($activeNotifications)){
61
				if(!empty($activeNotifications)){
Line 66... Line 66...
66
					$result = array('success'=>true,'message'=>__('Record Saved.'));
66
					$result = array('success'=>true,'message'=>__('Record Saved.'));
67
				} else {
67
				} else {
68
					$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
68
					$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
69
				}
69
				}
70
			} else {
70
			} else {
71
				$this->log(print_r($device, 1, 'devices');
-
 
72
				$device->modified=time();
71
				$device->modified=time();
73
				$this->Device->save($device);
72
				$this->Device->save($device);
74
				$result = array('success'=>false,'message'=>__('Identical record found. Updating.'));
73
				$result = array('success'=>false,'message'=>__('Identical record found. Updating.'));
75
			}
74
			}
76
			$this->response->type('json');
75
			$this->response->type('json');