You are here

function _sheetnode_google_import_form_validate in Sheetnode 7.2

Same name and namespace in other branches
  1. 6 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_form_validate()
  2. 7 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_form_validate()

Internal googlt import form validation.

File

modules/sheetnode_google/sheetnode_google.import.inc, line 72
Extension to sheetnode for importing from Google sheets.

Code

function _sheetnode_google_import_form_validate($form, $form_state) {
  if ($form_state['clicked_button']['#value'] == $form['fetch']['#value']) {
    return;
  }
  if (empty($form_state['values']['key'])) {
    form_set_error('key', t('Please enter or select a Google Spreadsheet that you want to import.'));
  }
  if (!empty($form_state['values']['username'])) {
    try {
      $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
      $client = Zend_Gdata_ClientLogin::getHttpClient($form_state['values']['username'], $form_state['values']['password'], $service);
    } catch (Exception $e) {
      form_set_error('username', $e
        ->getMessage());
    }
  }
}