Subversion Repositories SmartDukaan

Rev

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

Rev 20465 Rev 20466
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
			if(!$device) {
57
			if(!$device) {
57
				$cachekey = 'webnotifications-'.$this->request->data['user_id'];
58
				$cachekey = 'webnotifications-'.$this->request->data['user_id'];
58
				$activeNotifications = Cache::read($cachekey,$config = 'hour');
59
				$activeNotifications = Cache::read($cachekey,$config = 'hour');
59
				$this->log(print_r($activeNotifications,1),'checknotification');
60
				$this->log(print_r($activeNotifications,1),'checknotification');
60
				if(!empty($activeNotifications)){
61
				if(!empty($activeNotifications)){
Line 65... Line 66...
65
					$result = array('success'=>true,'message'=>__('Record Saved.'));
66
					$result = array('success'=>true,'message'=>__('Record Saved.'));
66
				} else {
67
				} else {
67
					$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
68
					$result = array('success'=>false,'message'=>print_r($this->Device->validationErrors,1));
68
				}
69
				}
69
			} else {
70
			} else {
-
 
71
				$this->log(print_r($device, 1, 'devices');
70
				$device->modified=time();
72
				$device->modified=time();
71
				$this->Device->save($device);
73
				$this->Device->save($device);
72
				$result = array('success'=>false,'message'=>__('Identical record found. Updating.'));
74
				$result = array('success'=>false,'message'=>__('Identical record found. Updating.'));
73
			}
75
			}
74
			$this->response->type('json');
76
			$this->response->type('json');