You are here

function imagepicker_browse_groups_form in Image Picker 7

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_browse_groups_form()
  2. 5 imagepicker.module \imagepicker_browse_groups_form()
  3. 6.2 imagepicker.functions.inc \imagepicker_browse_groups_form()
2 string references to 'imagepicker_browse_groups_form'
_imagepicker_browse in ./imagepicker.functions.inc
_imagepicker_browse_admin in ./imagepicker.functions.inc

File

./imagepicker.functions.inc, line 1576
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function imagepicker_browse_groups_form($form, &$form_state, $account = FALSE) {
  if ($account) {
    $user = $account;
  }
  else {
    global $user;
  }

  // all the groups for the current user which have images attached
  $grouplist = imagepicker_get_grouplist($user);
  if ($account) {
    $enabledlist = imagepicker_variable_get('imagepicker_currentgroup', 0);

    // check it
    if (!imagepicker_group_exists($enabledlist)) {
      imagepicker_variable_del("imagepicker_currentgroup");
      $enabledlist = '';
    }
  }
  else {
    $enabledlist = imagepicker_get_enabled_group($user);

    // check it
    if (!imagepicker_group_exists($enabledlist)) {
      imagepicker_variable_del("imagepicker_currentgroup", $user->uid);
      $enabledlist = '';
    }
  }
  $form['gid'] = array(
    '#type' => 'select',
    '#default_value' => $enabledlist,
    '#options' => $grouplist,
    '#title' => t('Group'),
  );
  if ($account) {
    $form['uid'] = array(
      '#type' => 'value',
      '#value' => $user->uid,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Go'),
  );
  return $form;
}