function avatar_selection_edit_form in Avatar Selection 5
Same name and namespace in other branches
- 5.2 avatar_selection.module \avatar_selection_edit_form()
- 6 avatar_selection.admin.inc \avatar_selection_edit_form()
- 7 avatar_selection.admin.inc \avatar_selection_edit_form()
2 string references to 'avatar_selection_edit_form'
- avatar_selection_menu in ./
avatar_selection.module - Implementation of hook_menu().
- avatar_selection_settings_page in ./
avatar_selection.module
File
- ./
avatar_selection.module, line 398
Code
function avatar_selection_edit_form($form_values = NULL) {
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/user/settings'),
)));
}
drupal_add_css(drupal_get_path('module', 'avatar_selection') . '/avatar_selection.css');
$selects = _avatar_selection_image_list();
if (!count($selects['avatars'])) {
drupal_set_message(t('There are no images configured.'));
}
else {
if (!isset($form_values)) {
$step = "list";
}
else {
$step = "edit";
}
$form['step'] = array(
'#type' => 'hidden',
'#value' => $step,
);
$form['#multistep'] = TRUE;
if ($step == "list") {
$form['#redirect'] = FALSE;
$form['select_avatar'] = array(
'#type' => 'radios',
'#title' => t('Select an avatar to edit'),
'#options' => $selects['avatars'],
'#required' => TRUE,
'#attributes' => array(
'class' => 'user_avatar_select',
),
);
$form['search'] = array(
'#type' => 'submit',
'#value' => t('Edit'),
);
$num_images_per_page = variable_get('avatar_selection_avatar_per_page', 30);
$js_settings = array(
'num_images_per_page' => $num_images_per_page ? $num_images_per_page : 1,
'num_images' => $selects['total'],
);
drupal_add_js(array(
'avatar_selection' => $js_settings,
), 'setting');
drupal_add_js(drupal_get_path('module', 'avatar_selection') . '/js/avatar_selection.js', 'module', 'header');
}
else {
if ($step == "edit") {
$form['#redirect'] = array(
'admin/settings/avatar_selection/edit',
);
$roles = avatar_selection_handler_filter_role();
$result = db_query("SELECT avatar, access, og_access FROM {avatar_selection} avs WHERE avatar = '%s'", $form_values['select_avatar']);
while ($avatar = db_fetch_object($result)) {
$avs_access = preg_split('/\\s*,\\s*/', $avatar->access);
$og_access = preg_split('/\\s*,\\s*/', $avatar->og_access);
}
$image = theme('image', $form_values['select_avatar']);
$form['avatar_image'] = array(
'#value' => $image,
);
$form['select_avatar'] = array(
'#type' => 'hidden',
'#default_value' => $form_values['select_avatar'],
);
$form['permissions'] = array(
'#type' => 'fieldset',
'#title' => t('Permissions'),
'#weight' => 1,
);
$form['permissions']['access'] = array(
'#type' => 'checkboxes',
'#title' => t('User Roles'),
'#default_value' => $avs_access,
'#options' => $roles,
'#description' => t('Only the checked roles will be able to see this avatar icon; if no roles are checked, access will not be restricted.'),
);
if (module_exists("og")) {
$form['permissions']['og_access'] = array(
'#type' => 'checkboxes',
'#title' => t('Organic Groups'),
'#default_value' => $og_access,
'#options' => og_all_groups_options(),
'#description' => t('Only users in the checked organic groups will be able to see this avatar icon; if no groups are checked, access will not be restricted.'),
);
}
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#weight' => 9,
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 10,
);
}
}
}
return $form;
}