You are here

function imagepicker_browse_public_groups_form in Image Picker 7

Same name and namespace in other branches
  1. 6.2 imagepicker.functions.inc \imagepicker_browse_public_groups_form()

Submit public browse groups form

Parameters

$account: Optional,

$admin: Optional, sets where the form is coming from

Return value

Returns the form.

2 string references to 'imagepicker_browse_public_groups_form'
_imagepicker_browse_admin in ./imagepicker.functions.inc
_imagepicker_browse_public in ./imagepicker.functions.inc

File

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

Code

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

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

    // check it
    if (!imagepicker_group_exists($enabledlist)) {
      imagepicker_variable_del("imagepicker_public_currentgroup");
      $enabledlist = '';
    }
  }
  else {
    $enabledlist = imagepicker_variable_get('imagepicker_public_currentgroup', 0, $user->uid);

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