You are here

function avatar_selection_config_form in Avatar Selection 7

Same name and namespace in other branches
  1. 5.2 avatar_selection.module \avatar_selection_config_form()
  2. 5 avatar_selection.module \avatar_selection_config_form()
  3. 6 avatar_selection.admin.inc \avatar_selection_config_form()

Create the form structure for configuring the avatar module settings; seen in the 'Configure' tab under the Avatar Selection administration page.

Return value

Return the structure of the form.

2 string references to 'avatar_selection_config_form'
avatar_selection_menu in ./avatar_selection.module
Implements hook_menu().
avatar_selection_settings_page in ./avatar_selection.admin.inc
Select which form will be shown to the user, according to the permissions.

File

./avatar_selection.admin.inc, line 148
Administrative page callbacks for the avatar_selection module.

Code

function avatar_selection_config_form($form) {
  if (!variable_get('user_pictures', 0)) {
    drupal_set_message(t('User Pictures option is disabled.  You will need to enable this option before you can use the Avatar Selection module.  You may configure this setting on the <a href="@url">User settings</a> page.', array(
      '@url' => url('admin/config/people/accounts'),
    )));
  }

  // To store how many avatars per page are displayed.
  $form['update']['avatar_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('How many avatars per page'),
    '#description' => t('The number of avatars to show per page.'),
    '#default_value' => variable_get('avatar_selection_avatar_per_page', 30),
    '#size' => 3,
  );
  $form['update']['disable_user_upload'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable users uploading pictures to profile'),
    '#description' => t('Allow users to pick their avatar from the selection but prevent them from uploading new avatars when editing their account.'),
    '#default_value' => variable_get('avatar_selection_disable_user_upload', FALSE),
  );
  $form['update']['force_set_image_reg'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force users to select an avatar image on user registration.'),
    '#description' => t('This only applies on the user registration screen.'),
    '#default_value' => variable_get('avatar_selection_force_user_avatar_reg', FALSE),
  );
  $form['update']['force_set_image'] = array(
    '#type' => 'checkbox',
    '#title' => t('Force users to select an avatar image when editing their account'),
    '#description' => t('This only applies when the user is editing their account details and image uploads are disabled.'),
    '#default_value' => variable_get('avatar_selection_force_user_avatar', FALSE),
  );
  $form['update']['set_random_default'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable random default avatar image'),
    '#description' => t("Automatically set a random avatar image to be used when the user doesn't set one for their account."),
    '#default_value' => variable_get('avatar_selection_set_random_default', FALSE),
  );
  $form['update']['distinctive_avatars'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable unique avatars'),
    '#description' => t("Only allow users to pick an avatar that isn't already in use by another user.  If there are no available avatars left, the default avatar image will be used."),
    '#default_value' => variable_get('avatar_selection_distinctive_avatars', FALSE),
  );
  if (module_exists('image')) {
    $form['update']['imagecache_preset'] = array(
      '#type' => 'select',
      '#title' => t('Picture display style'),
      '#options' => image_style_options(TRUE),
      '#default_value' => variable_get('avatar_selection_imagecache_preset', ''),
      '#description' => t('Choose an display style for avatars in the selection list. Styles may be configured in the <a href="@config">Image styles</a> administration area. The <a href="@profiles">ImageCache Profiles</a> module can be used to format the avatars in other locations.', array(
        '@config' => url('admin/config/media/image-styles'),
        '@profiles' => url('http://drupal.org/project/imagecache_profiles'),
      )),
    );
  }
  $form['update']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}