You are here

function custom_search_blocks_block_save in Custom Search 7

Implements hook_block_save().

File

modules/custom_search_blocks/custom_search_blocks.module, line 91
Bring additional search blocks

Code

function custom_search_blocks_block_save($delta = '', $edit = array()) {
  foreach ($edit as $key => $value) {
    if (drupal_substr($key, 0, 20) == 'custom_search_blocks') {
      variable_set($key, $value);
    }
  }
  foreach ($edit['custom_search_blocks_' . $delta . '_order'] as $key => $data) {
    variable_set('custom_search_blocks_' . $delta . '_' . $key . '_weight', $data['sort']);
    variable_set('custom_search_blocks_' . $delta . '_' . $key . '_region', $data['region']);
  }

  // Submit image?
  $directory_path = 'public://custom_search';
  file_prepare_directory($directory_path, FILE_CREATE_DIRECTORY);

  // Check for a new uploaded image.
  if ($file = file_save_upload('custom_search_image', array(
    'file_validate_is_image' => array(),
  ))) {
    if ($filepath = file_unmanaged_copy($file->uri, $directory_path)) {
      variable_set('custom_search_blocks_' . $delta . '_image_path', $filepath);
    }
  }
}