You are here

function path_redirect_save in Path redirect 5

Same name and namespace in other branches
  1. 6 path_redirect.module \path_redirect_save()
3 calls to path_redirect_save()
path_redirect_action_create in ./path_redirect_workflow.inc
Action implementation: Create a URL redirect
path_redirect_edit_submit in ./path_redirect.module
path_redirect_nodeapi in ./path_redirect.module

File

./path_redirect.module, line 337

Code

function path_redirect_save($edit) {
  if (empty($edit['rid'])) {
    $edit['rid'] = db_next_id('{path_redirect}_rid');
  }
  else {
    path_redirect_delete(NULL, NULL, $edit['rid']);
  }
  if (empty($edit['type'])) {
    $edit['type'] = PATH_REDIRECT_DEFAULT_TYPE;
  }
  if (empty($edit['query'])) {
    $edit['query'] = '';
  }
  if (empty($edit['fragment'])) {
    $edit['fragment'] = '';
  }

  // Remove any other redirects from the same path
  db_query("DELETE FROM {path_redirect} WHERE path = '%s'", $edit['path']);
  return db_query("INSERT INTO {path_redirect} (rid, path, redirect, query, fragment, type) VALUES (%d, '%s', '%s', '%s', '%s', '%s')", $edit['rid'], $edit['path'], $edit['redirect'], $edit['query'], $edit['fragment'], $edit['type']);
}