You are here

function follow_links_form in Follow 5

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

The form for editing follow links.

Parameters

$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
Implementation of hook_menu().

File

./follow.module, line 338
Allows users to add links to their social network profiles.

Code

function follow_links_form($uid = 0) {
  $form = array();
  $form['uid'] = array(
    '#type' => 'hidden',
    '#value' => $uid,
  );
  $form['follow_links']['#tree'] = TRUE;
  $form['follow_links']['#theme'] = 'follow_links_form';
  $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;
}