You are here

function follow_links_form in Follow 7.2

Same name and namespace in other branches
  1. 5 follow.module \follow_links_form()
  2. 6 follow.module \follow_links_form()
  3. 7 follow.module \follow_links_form()

The form for editing follow links.

Parameters

$form_state: A keyed array containing the current state of the form.

$uid: The uid of the user account. Defaults to the site form, $uid = 0.

1 string reference to 'follow_links_form'
follow_menu in ./follow.module
Implements hook_menu().

File

./follow.module, line 456

Code

function follow_links_form($form, &$form_state, $uid = 0) {
  $form = array();
  $form['uid'] = array(
    '#type' => 'hidden',
    '#value' => $uid,
  );
  $form['follow_links']['#tree'] = TRUE;

  // List all the available links.
  $links = follow_links_load($uid);
  $networks = follow_networks_load($uid, TRUE);

  // Put all our existing links at the top, sorted by weight.
  if (is_array($links)) {
    foreach ($links as $name => $link) {
      $title = $networks[$name]['title'];
      $form['follow_links'][$name] = _follow_links_form_link($link, $title, $uid);

      // Unset this specific network so we don't add the same one again below.
      unset($networks[$name]);
    }
  }

  // Now add all the empty ones.
  foreach ($networks as $name => $info) {
    $link = new stdClass();
    $link->name = $name;
    $form['follow_links'][$name] = _follow_links_form_link($link, $info['title'], $uid);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}