You are here

function imagepicker_groups_form in Image Picker 5.2

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

groups form

4 string references to 'imagepicker_groups_form'
imagepicker_admin_groups in ./imagepicker.module
imagepicker_groups in ./imagepicker.module
imagepicker_group_edit in ./imagepicker.module
imagepicker_user_groups in ./imagepicker.module

File

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

Code

function imagepicker_groups_form($record = 0, $account = FALSE) {
  $form['groupsave'] = array(
    '#type' => 'fieldset',
    '#title' => $record->gid ? t('Edit group') : t('Add group'),
    '#description' => t('Give your group a brief name and optionally put any additional information in the group description box'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['groupsave']['group_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Group name'),
    '#size' => 20,
    '#default_value' => $record->group_name ? $record->group_name : '',
    '#description' => t(''),
    '#required' => TRUE,
  );
  $form['groupsave']['group_description'] = array(
    '#type' => 'textfield',
    '#title' => t('group description'),
    '#size' => 50,
    '#maxlength' => 50,
    '#default_value' => $record->group_description ? $record->group_description : '',
    '#description' => t('Maximum 50 characters'),
    '#required' => FALSE,
  );
  if (user_access('use public imagepicker') && user_access('create public groups') && variable_get('imagepicker_public_enabled', 1)) {
    $form['groupsave']['group_public'] = array(
      '#type' => 'checkbox',
      '#title' => t('Public'),
      '#return_value' => 1,
      '#default_value' => $record->public ? $record->public : '',
      '#description' => t('Make this group publicly available'),
    );

    // Create role restrictions
    if (variable_get('imagepicker_publicroles_enabled', 1)) {
      $form['groupsave']['group_public_roles'] = array(
        '#type' => 'fieldset',
        '#title' => $record->gid ? t('Edit group roles') : t('Add public group roles'),
        '#description' => t('Add roles for public access to your group. (Don\'t check anything to make it available to all groups.)'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
      );

      // Output a list of available roles as checkboxes
      $form['groupsave']['group_public_roles']['roles']['#tree'] = TRUE;
      if ($record->avail_roles) {
        if ($record->avail_roles != 'all') {
          $availroles = explode(':', $record->avail_roles);
        }
      }
      foreach (user_roles(TRUE) as $rid => $role) {
        if (imagepicker_role_has_permission($rid)) {
          if (is_array($availroles) && in_array($role, array_values($availroles))) {
            $checked = TRUE;
          }
          else {
            $checked = FALSE;
          }
          $form['groupsave']['group_public_roles']['roles'][$rid] = array(
            '#type' => 'checkbox',
            '#title' => check_plain($role),
            '#return_value' => $role,
            '#default_value' => $checked ? 1 : '',
          );
        }
      }
    }
  }
  if ($account) {
    $form['groupsave']['account'] = array(
      '#type' => 'hidden',
      '#value' => $account->uid,
    );
  }
  if ($record->gid) {
    $form['groupsave']['gid'] = array(
      '#type' => 'hidden',
      '#value' => $record->gid,
    );
  }
  $form['groupsave']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save group'),
  );
  return $form;
}