You are here

function space_setting_logo::submit in Spaces 6.2

Overrides space_setting::submit

File

spaces_design/spaces_design.spaces.inc, line 51

Class

space_setting_logo
Provides a logo setting for each space.

Code

function submit($space, $value) {

  // Always clear out upload key -- not used
  unset($value['upload']);

  // Delete logo if specified
  if (!empty($value['delete']) && !empty($value['file'])) {
    file_delete($value['file']->filepath);
    db_query('DELETE FROM {files} WHERE fid = %d', $value['file']->fid);

    // Clear out fields
    if ($value['file']->fid == $value['fid']) {
      unset($value['fid']);
    }
    unset($value['delete']);
    unset($value['file']);
  }

  // Flush imagecache images
  if (!empty($value['fid'])) {
    $file = db_fetch_object(db_query('SELECT * FROM {files} f WHERE f.fid = %d', $value['fid']));
    if ($file) {
      imagecache_image_flush($file->filepath);
    }
  }
  else {
    unset($value['fid']);
  }
  return $value;
}