Subversion Repositories SmartDukaan

Rev

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

Rev 15581 Rev 15583
Line 229... Line 229...
229
				} else{
229
				} else{
230
					debug($this->NotificationCampaign->validationErrors);
230
					debug($this->NotificationCampaign->validationErrors);
231
					$message['cid'] = $message['name'];
231
					$message['cid'] = $message['name'];
232
				}				
232
				}				
233
				$this->loadModel('Pushnotification');
233
				$this->loadModel('Pushnotification');
-
 
234
				$sentUsers = array();
234
				foreach ($users as $key => $value) {									
235
				foreach ($users as $key => $value) {	
-
 
236
					if(!in_array($value['User']['id'], $sentUsers)) {
-
 
237
						$sentUsers[] = $value['User']['id'];								
235
					$data = array('notification_campaign_id'=>$message['cid'],'user_id'=>$value['User']['id'],'type'=>'pending');
238
						$data = array('notification_campaign_id'=>$message['cid'],'user_id'=>$value['User']['id'],'type'=>'pending');
236
					$this->Pushnotification->create();
239
						$this->Pushnotification->create();
237
					$this->Pushnotification->save($data);
240
						$this->Pushnotification->save($data);
-
 
241
					}
238
				}
242
				}
239
				$this->Session->setFlash(__('Push notification scheduled for '.sizeof($users).' users'));
243
				$this->Session->setFlash(__('Push notification scheduled for '.sizeof($users).' users'));
240
				return $this->redirect(array('controller' => 'administration', 'action' => 'dashboard', 'admin' => false));
244
				return $this->redirect(array('controller' => 'administration', 'action' => 'dashboard', 'admin' => false));
241
			}
245
			}
242
		}
246
		}
243
	}
247
	}
244
}
248
}
245
 
-
 
246
249