function avatar_selection_user in Avatar Selection 5.2
Same name and namespace in other branches
- 5 avatar_selection.module \avatar_selection_user()
Implementation of hook_user().
Validate and upload the user's picture.
File
- ./
avatar_selection.module, line 237 - The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.
Code
function avatar_selection_user($op, &$edit, &$user, $category = 'account') {
global $form_values;
switch ($op) {
case 'validate':
$file = file_check_upload('picture_upload');
if (!$file && $edit['select_avatar']) {
unset($edit['picture_delete']);
$path = file_create_path('avatar_selection') . '/';
$form_values['picture'] = $path . $edit['select_avatar'];
}
elseif (!$file && variable_get('avatar_selection_set_random_default', FALSE)) {
if ($user->picture && $edit['picture_delete'] != 1) {
$form_values['picture'] = $user->picture;
}
else {
unset($edit['picture_delete']);
$form_values['picture'] = avatar_selection_get_random_image($user);
}
}
break;
}
}