You are here

function imagepicker_browse_groups_form_submit in Image Picker 5.2

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

Submit browse groups form

File

./imagepicker.module, line 3162
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_browse_groups_form_submit($form_id, $form_values) {

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