You are here

function hosting_context_register in Hosting 6.2

Same name and namespace in other branches
  1. 7.4 hosting.module \hosting_context_register()
  2. 7.3 hosting.module \hosting_context_register()

Add a node to the context lookup db.

Parameters

$nid: The nid of the node to associate to the given provision context name.

$name: The name of the provision context.

8 calls to hosting_context_register()
drush_hosting_resume in ./resume.hosting.inc
Drush command to resume the Aegir frontend site.
hosting_migrate_post_hosting_migrate_task in migrate/hosting_migrate.drush.inc
hosting_package_update_6004 in package/hosting_package.install
hosting_platform_insert in platform/hosting_platform.module
Implementation of hook_insert().
hosting_platform_update_6004 in platform/hosting_platform.install

... See full list

File

./hosting.module, line 870
Hosting module.

Code

function hosting_context_register($nid, $name) {

  // Check first to see if this nid exists in the system. If so, update its name
  $result = db_query("SELECT nid FROM {hosting_context} WHERE nid=%d", $nid);
  if ($obj = db_fetch_object($result)) {
    db_query("UPDATE {hosting_context} SET name = '%s' WHERE nid = %d", $name, $nid);
  }
  else {

    // It's a new item
    db_query("INSERT INTO {hosting_context} (nid, name) VALUES (%d, '%s')", $nid, $name);
  }

  // We include the file instead of enabling the module,
  // because we do not want the overhead of having all the
  // path UI stuff on nodes.
  require_once "./modules/path/path.module";

  // Delete an existing alias, could be left behind after migrating a site from this name.
  path_set_alias(NULL, "hosting/c/{$name}");

  // Add the new alias.
  path_set_alias("node/{$nid}", "hosting/c/{$name}");
}