You are here

function imagepicker_browse_groups_form_submit in Image Picker 6.2

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_browse_groups_form_submit()
  2. 5 imagepicker.module \imagepicker_browse_groups_form_submit()
  3. 7 imagepicker.functions.inc \imagepicker_browse_groups_form_submit()

Submit browse groups form

File

./imagepicker.functions.inc, line 1628
Imagepicker functions

Code

function imagepicker_browse_groups_form_submit($form, &$form_state) {

  // need to get the users gids
  $account = FALSE;
  if (isset($form_state['values']['uid'])) {
    $account = user_load(array(
      'uid' => $form_state['values']['uid'],
    ));
    if ($form_state['values']['gid']) {
      variable_set('imagepicker_currentgroup', $form_state['values']['gid']);
    }
    else {
      variable_set('imagepicker_currentgroup', 0);
    }
  }
  else {
    $gids = imagepicker_get_groups($account);
    $gids = array_keys($gids);
    foreach ($gids as $gid) {
      $state = 0;
      if ($gid == $form_state['values']['gid']) {
        $state = 1;
      }
      db_query("UPDATE {imagepicker_user_groups} SET state=%d WHERE gid=%d", array(
        $state,
        $gid,
      ));
    }
  }
}