You are here

function kaltura_settings_form_submit in Kaltura 6.2

Same name and namespace in other branches
  1. 7.2 includes/kaltura.admin.inc \kaltura_settings_form_submit()

Submit handler for kaltura_settings_form()

1 string reference to 'kaltura_settings_form_submit'
kaltura_settings_form in includes/kaltura.admin.inc
determine how the general settings form will look like.

File

includes/kaltura.admin.inc, line 368

Code

function kaltura_settings_form_submit($form, &$form_state) {
  if ($form_state['values']['kaltura_notification_type']) {
  }
  if (isset($form_state['values']['kaltura_notification_type']) && $form_state['values']['kaltura_partner_url2']) {

    // TODO: update partner settings with notification type
    $url2 = url('kaltura/notification_handler', array(
      'absolute' => TRUE,
    ));
    if ($form_state['values']['kaltura_notification_type'] == 1) {
      $not_type = 3;
    }
    else {
      $not_type = 2;
    }
    try {
      $result = kaltura_update_kaltura_partner($not_type, $url2);
      if (!$result->id) {
        if (isset($result['error']['code'])) {
          throw new Exception($result['error']['desc'], $result['error']['code']);
        }
        else {
          throw new Exception('Updating notification settings on Kaltura server failed.');
        }
      }

      /* if notification URL has changed, or notification type is 3 */
      if ($form_state['values']['last_notification_url'] != $form_state['values']['kaltura_partner_url2'] || $not_type == 3) {
        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.')); /* Uncomment when [#1025090] is resolved. */
        }
      }
    } catch (Exception $ex) {
      drupal_set_message(t('Error: %message when updating notification settings.', array(
        '%message' => $ex
          ->getMessage(),
      )), 'error');
      watchdog('kaltura', 'Error @message updating notification settings.<br />Backtrace:<pre>!trace</pre>', array(
        '@message' => $ex
          ->getMessage(),
        '!trace' => $ex
          ->getTrace(),
      ));
    }
  }
}