You are here

function popup_maker_update_api_key in Popup Maker - All popup types 7

1 call to popup_maker_update_api_key()
popup_maker_settings_view in ./popup_maker.admin.inc

File

./popup_maker.admin.inc, line 175

Code

function popup_maker_update_api_key() {
  if (!isset($_POST['sgpm-api-key-submit'])) {
    drupal_set_message('Invalid request', 'error');
    return false;
  }
  if (!drupal_valid_token($_POST['_csrf_token'], 'popup_maker')) {
    drupal_set_message('Could not validate the security token', 'error');
    return false;
  }
  if (popup_maker_refresh_data($_POST['sgpm-api-key'])) {
    $config = variable_get('popup_maker_settings', array(
      'api_key' => null,
      'popups' => array(),
      'popupSettings' => array(),
      'user' => array(),
    ));
    $config['api_key'] = $_POST['sgpm-api-key'];
    variable_set('popup_maker_settings', $config);
    drupal_set_message('New api key saved successfully');
  }
  drupal_goto('admin/config/content/popup_maker');
}