You are here

function tweet_feed_import_form_submit in Tweet Feed 7.3

tweet_feed_import_form_submit() Process the json provided in the form for importing.

File

./tweet_feed_admin.inc, line 745

Code

function tweet_feed_import_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $data = json_decode($values['import_block']);
  if ($data !== NULL) {
    foreach ($data as $key => $data) {
      $account = $data->account;
      $feeds = $data->feeds;

      // Define our array of data provided by the form
      $data = array(
        'account_name' => $account->account_name,
        'consumer_key' => $account->consumer_key,
        'consumer_secret' => $account->consumer_secret,
        'oauth_token' => $account->oauth_token,
        'oauth_token_secret' => $account->oauth_token_secret,
      );
      $status = drupal_write_record('tweet_accounts', $data);
      $aid = $data['aid'];
      foreach ($feeds as $feed) {

        // Define our array of data provided by the form
        $data = array(
          'aid' => $aid,
          'feed_name' => $feed->feed_name,
          'query_type' => $feed->query_type,
          'timeline_id' => $feed->timeline_id,
          'search_term' => $feed->search_term,
          'list_name' => $feed->list_name,
          'pull_count' => $feed->pull_count,
          'clear_prior' => $feed->clear_prior,
          'new_window' => $feed->new_window,
          'hash_taxonomy' => 0,
        );
        $status = drupal_write_record('tweet_feeds', $data);
      }
    }
  }
  else {
    drupal_set_message('Settings could not be imported.');
    return FALSE;
  }
  drupal_set_message('Settings imported.');
  drupal_goto('admin/config/services/tweet_feed/accounts');
}