You are here

function follow_links_form_submit in Follow 6

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

Submit handler for the follow_links_form.

File

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

Code

function follow_links_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $links = $values['follow_links'];
  foreach ($links as $name => $link) {
    $link = (object) $link;
    $link->url = trim($link->url);

    // Check to see if there's actually a link
    if (empty($link->url)) {

      // If there's an lid, delete the link.
      if (isset($link->lid)) {
        follow_link_delete($link->lid);
      }

      // Continue to the next link.
      continue;
    }
    else {
      $link->uid = $values['uid'];
      $link->name = $name;
      follow_link_save($link);
    }
  }

  // Save the Follow icon style.
  $icon_style = $values['follow_icon_style'];
  if (in_array($icon_style, array(
    'small',
    'large',
  ))) {
    variable_set('follow_icon_style', $icon_style);
  }
}