You are here

function kaltura_notification_handler in Kaltura 6

Same name and namespace in other branches
  1. 5 includes/kaltura.notification.inc \kaltura_notification_handler()
  2. 6.2 includes/kaltura.notification.inc \kaltura_notification_handler()
  3. 7.3 includes/kaltura.notification.inc \kaltura_notification_handler()
  4. 7.2 includes/kaltura.notification.inc \kaltura_notification_handler()
1 string reference to 'kaltura_notification_handler'
kaltura_menu in ./kaltura.module

File

includes/kaltura.notification.inc, line 21

Code

function kaltura_notification_handler() {
  $admin_secret = variable_get('kaltura_admin_secret', '');

  //$params = $_REQUEST;
  $params = $_POST;
  watchdog('kaltura NH', print_r($params, TRUE));
  unset($params['q']);
  $noti = new KalturaNotificationClient($params, $admin_secret);
  if ($noti->valid_signature === NULL) {
    watchdog('kaltura', 'notification params empty');
    return FALSE;
  }
  elseif ($noti->valid_signature === FALSE) {
    watchdog('kaltura', 'notification signature not valid');
    return FALSE;
  }
  else {
    watchdog('kaltura', 'hooray!!! notification signature valid');
  }
  echo 'OK';
  foreach ($noti->data as $notification_data) {
    $times = kaltura_notification_received($notification_data['notification_id']);
    if (!$times || $notification_data['notification_type'] == 'test') {
      kaltura_notification_save($notification_data['notification_id'], $notification_data);
      kaltura_forward_notification($notification_data);
      kaltura_invoke('notification_handler', $notification_data);
    }
    else {
      watchdog('notification', 'This notification (' . $notification_data['notification_id'] . ') was already received');
    }
  }
}