--- twitter_actions.module +++ (clipboard) @@ -36,8 +36,8 @@ function twitter_actions_set_status_action_form($context = array()) { // Set default values for form. $context += array( + 'account_id' => -1, 'screen_name' => '', - 'password' => '', 'message' => '', ); @@ -49,13 +49,6 @@ '#required' => TRUE, ); - $form['password'] = array( - '#title' => t('Twitter password'), - '#type' => 'password', - '#size' => 25, - '#required' => TRUE, - ); - $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), @@ -69,27 +62,22 @@ } function twitter_actions_set_status_action_validate($form, $form_state) { - module_load_include('inc', 'twitter'); - $verify = FALSE; - - $pass = $form_state['values']['password']; - $name = $form_state['values']['screen_name']; - - module_load_include('inc', 'twitter'); - - $valid = twitter_authenticate($name, $pass); - if (!$valid) { - form_set_error('password', t('Twitter authentication failed. Please check your account name and try again.')); + if (!_twitter_use_oauth()) { + form_set_error('screen_name', t('Oath has not yet been setup.')); + } + if (!db_result(db_query("SELECT twitter_uid FROM {twitter_account} WHERE screen_name = '%s'", $form_state['values']['screen_name']))) { + form_set_error('screen_name', t('Twitter authentication failed. Please check your account name and try again.')); } } function twitter_actions_set_status_action_submit($form, $form_state) { $form_values = $form_state['values']; + $twitter_uid = db_result(db_query("SELECT twitter_uid FROM {twitter_account} WHERE screen_name = '%s'", $form_values['screen_name'])); // Process the HTML form to store configuration. The keyed array that // we return will be serialized to the database. $params = array( + 'twitter_uid' => $twitter_uid, 'screen_name' => $form_values['screen_name'], - 'password' => $form_values['password'], 'message' => $form_values['message'], ); return $params; @@ -173,5 +161,6 @@ $message = strtr($context['message'], $variables); module_load_include('inc', 'twitter'); - twitter_set_status($context['screen_name'], $context['password'], $message); + $twitter_account = twitter_account_load($context['twitter_uid']); + twitter_set_status($twitter_account, $message); }