You are here

function bynder_form_updated_api_settings in Bynder 7

Checks if the new API Settings differ from the old ones and triggers reloading derivative and brand information.

1 call to bynder_form_updated_api_settings()
bynder_form_submit in includes/bynder.admin.inc
Admin form submit, force reloading derivatives the first time we save the form.

File

includes/bynder.admin.inc, line 278

Code

function bynder_form_updated_api_settings($new_settings) {
  $changed = false;
  if (!variable_get('bynder_derivatives', false)) {
    variable_set('temp_derivatives_settings', array(
      'consumerKey' => variable_get('bynder_oauth_consumer', $new_settings['bynder_oauth_consumer']),
      'consumerSecret' => variable_get('bynder_oauth_consumer_secret', $new_settings['bynder_oauth_consumer_secret']),
      'token' => variable_get('bynder_oauth_token', $new_settings['bynder_oauth_token']),
      'tokenSecret' => variable_get('bynder_oauth_token_secret', $new_settings['bynder_oauth_token_secret']),
      'baseUrl' => variable_get('bynder_url', $new_settings['bynder_url']),
    ));
    $changed = true;
  }
  foreach ($new_settings as $key => $setting) {
    switch ($key) {
      case 'bynder_url':
      case 'bynder_cdn_url':
      case 'bynder_oauth_consumer':
      case 'bynder_oauth_consumer_secret':
      case 'bynder_oauth_token':
      case 'bynder_oauth_token_secret':
        if ($setting !== variable_get($key, false)) {
          variable_set($key, $setting);
          $changed = true;
        }
    }
  }
  if ($changed) {
    unset($_SESSION['bynder_data']);
    return true;
  }
  return false;
}