You are here

function connector_button_form in Connector 7

Same name and namespace in other branches
  1. 6 connector.module \connector_button_form()

Form for the connector buttons.

Parameters

object $account: Account for which to display the button form.

string $label: String to display on the button.

string $action: Action to take when button is clicked.

Return value

array $form Form with connector buttons.

2 string references to 'connector_button_form'
connector_block_view in ./connector.module
Implements hook_block_view().
connector_user_settings in ./connector.pages.inc
Menu callback for the user settings page

File

./connector.module, line 241
Connector module

Code

function connector_button_form($form, &$form_state, $account = FALSE, $label = 'Connect with !title', $action = 'default') {
  $form = array(
    '#theme' => 'connector_buttons',
    '#has_buttons' => FALSE,
  );
  $form['action'] = array(
    '#value' => $action,
    '#type' => 'value',
  );
  $i = 0;
  $connectors = _connector_get_connectors();
  if ($account && $account->uid != 0) {
    $callback = 'connect button callback';
  }
  else {
    $callback = 'button callback';
  }
  foreach ($connectors as $key => $connector) {
    if (user_access('connect with ' . $connector['name']) && isset($connector[$callback]) && is_callable($connector[$callback])) {
      $form[$key] = array(
        '#type' => 'submit',
        '#value' => t($label, array(
          '!title' => $connector['title'],
        )),
        '#submit' => array(
          $connector[$callback],
        ),
        'connector' => array(
          '#type' => 'value',
          '#value' => $connector,
        ),
      );
      $form['#has_buttons'] = TRUE;
    }
  }
  return $form;
}