You are here

function kaltura_notifications_settings_form in Kaltura 5

Same name and namespace in other branches
  1. 6.2 includes/kaltura.admin.inc \kaltura_notifications_settings_form()
  2. 6 includes/kaltura.admin.inc \kaltura_notifications_settings_form()
1 call to kaltura_notifications_settings_form()
kaltura_settings_form in includes/kaltura.admin.inc

File

includes/kaltura.admin.inc, line 803

Code

function kaltura_notifications_settings_form() {
  global $base_url;
  $notification_types = array(
    //'1' => 'only server side notifications',
    '2' => 'only client side notifications',
    '3' => 'both server & client notifications',
  );
  if (isset($_REQUEST['kaltura_notification_type']) && $_REQUEST['kaltura_partner_url2']) {

    // TODO: update partner settings with notification type
    $url2 = $_REQUEST['kaltura_partner_url2'] . '/?q=kaltura/notification_handler';
    if ($_REQUEST['kaltura_notification_type'] == 1) {
      $not_type = 3;
    }
    else {
      $not_type = 2;
    }
    $result = kaltura_update_kaltura_partner($not_type, $url2);
    if ($_REQUEST['last_notification_url'] != $_REQUEST['kaltura_partner_url2']) {
      variable_set('kaltura_notification_status', 0);
      list($status, $text) = kaltura_test_notification_config();
      if ($status == FALSE) {
        drupal_set_message(t('Notification test failed. The URL you specified is not valid. Please make sure it is correct and save the settings again.'), 'error');
      }
      else {
        drupal_set_message(t('Notification test was successful.'));
      }
    }
    if (!$result['partner']['id']) {
      drupal_set_message('Updating kaltura\'s server faild.<br />' . $result['error']['code'] . ': ' . $result['error']['desc'], 'error');
    }
    else {
      drupal_set_message('Updating kaltura\'s server was successful ' . l($url2, $url2));
    }
  }
  $notification_type_description = t('Enabling server notifications allows the Kaltura video platform to update your Drupal server about the status of ' . 'the media content. This is especially useful when uploading content in various formats that needs to be transcoded. ' . 'In order to support server side notifications, your server must be publicly available on the internet.');
  $form['kaltura_notification_type'] = array(
    '#type' => 'checkbox',
    '#options' => 'Enable server side notifications',
    '#description' => $notification_type_description,
    '#title' => t('Enable server side notifications'),
    '#default_value' => variable_get('kaltura_notification_type', 0),
  );
  $not_url = variable_get('kaltura_partner_url2', '') != '' ? variable_get('kaltura_partner_url2', '') : $base_url;
  $form['kaltura_partner_url2'] = array(
    '#type' => 'textfield',
    '#title' => 'Notification URL',
    '#description' => t('Your drupal base URL.') . ' /?q=kaltura/notification_handler ' . t('will be added to this base URL.'),
    '#default_value' => $not_url,
  );
  $form['last_notification_url'] = array(
    '#type' => 'hidden',
    '#value' => variable_get('kaltura_partner_url2', ''),
  );
  return $form;
  return system_settings_form($form);
}