You are here

function user_badges_images_form_submit in User Badges 6.2

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_images_form_submit()
  2. 6 user_badges.admin.inc \user_badges_images_form_submit()
  3. 7 user_badges.admin.inc \user_badges_images_form_submit()
  4. 7.2 user_badges.admin.inc \user_badges_images_form_submit()
  5. 7.3 user_badges.admin.inc \user_badges_images_form_submit()

Submission action for user_badges_images_form

Save the uploaded file or delete the selected one

File

./user_badges.admin.inc, line 438
@brief User Badges admin functions

Code

function user_badges_images_form_submit($form, &$form_state) {
  $op = $form_state['clicked_button']['#value'];

  // Save uploaded files.
  if ($op == t('Upload')) {
    $file = $form_state['values']['file_image'];
    file_set_status($file, FILE_STATUS_PERMANENT);
  }
  elseif ($op == t('Delete')) {
    foreach ($form_state['values']['images'] as $path => $is_removed) {
      if ($is_removed) {
        $to_delete[] = $path;
      }
    }
    if (is_array($to_delete)) {
      user_badges_image_delete($to_delete);
    }
  }
}