Subversion Repositories SmartDukaan

Rev

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

Rev 14408 Rev 14409
Line 322... Line 322...
322
			}
322
			}
323
		}
323
		}
324
	}
324
	}
325
 
325
 
326
	private function send_push_notification($registatoin_ids, $message) {
326
	private function send_push_notification($registatoin_ids, $message) {
327
		debug(func_get_args());return;
-
 
328
        $msg = array(
327
		$msg = array(
329
            'message'       => $message['message'],
328
		    'message'       => $message['message'],
330
            'title'         => $message['message'],
329
		    'title'         => $message['message'],
331
            'subtitle'      => 'This is a subtitle',
330
		    'subtitle'      => 'This is a subtitle',
332
            'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
331
		    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
333
            'vibrate'       => 1,
332
		    'vibrate'       => 1,
334
            'sound'         => 1,
333
		    'sound'         => 1,
335
            'largeIcon'     => 'large_icon',
334
		    'largeIcon'     => 'large_icon',
336
            'smallIcon'     => 'small_icon'
335
		    'smallIcon'     => 'small_icon'
337
        );
336
		);
338
 
337
 
339
        // Set POST variables
338
		// Set POST variables
340
        $url = 'https://android.googleapis.com/gcm/send';
339
		$url = 'https://android.googleapis.com/gcm/send';
341
 
340
 
342
        $fields = array(
341
		$fields = array(
343
            'registration_ids' => $registatoin_ids,
342
		    'registration_ids' => $registatoin_ids,
344
            'data' => $msg,
343
		    'data' => $msg,
345
        );
344
		);
346
        $headers = array(
345
		$headers = array(
347
            'Authorization: key=' . Configure::read('googleapikey'),
346
		    'Authorization: key=' . Configure::read('googleapikey'),
348
            'Content-Type: application/json'
347
		    'Content-Type: application/json'
349
        );
348
		);
350
        //print_r($headers);
349
		//print_r($headers);
351
        // Open connection
350
		// Open connection
352
        $ch = curl_init();
351
		$ch = curl_init();
353
 
352
 
354
        // Set the url, number of POST vars, POST data
353
		// Set the url, number of POST vars, POST data
355
        curl_setopt($ch, CURLOPT_URL, $url);
354
		curl_setopt($ch, CURLOPT_URL, $url);
356
        curl_setopt($ch, CURLOPT_POST, true);
355
		curl_setopt($ch, CURLOPT_POST, true);
357
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
356
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
358
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
357
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
359
 
358
 
360
        // Disabling SSL Certificate support temporarly
359
		// Disabling SSL Certificate support temporarly
361
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
360
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
362
 
361
 
363
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
362
		curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
364
 
363
 
365
        // Execute post
364
		// Execute post
366
        $result = curl_exec($ch);
365
		$result = curl_exec($ch);
367
        if ($result === FALSE) {
366
		if ($result === FALSE) {
368
            die('Curl failed: ' . curl_error($ch));
367
		    die('Curl failed: ' . curl_error($ch));
369
        }
368
		}
370
 
369
 
371
        // Close connection
370
		// Close connection
372
        curl_close($ch);
371
		curl_close($ch);
373
        // echo $result;die;
372
		$this->log(print_r($result,1),'notifiactions');
374
    }
373
	}
375
 
374
 
376
	public function admin_index() {		
375
	public function admin_index() {		
377
		$this->User->recursive = 0;
376
		$this->User->recursive = 0;
378
		$options = array('limit'=>100,'order'=>array('id'=>'desc'));
377
		$options = array('limit'=>100,'order'=>array('id'=>'desc'));
379
		$this->Paginator->settings = $options;
378
		$this->Paginator->settings = $options;