Commit a5ca4cd4 authored by anarcat's avatar anarcat Committed by anarcat

renamed hook_load() implementations to be more sensible

for example, hosting_task_site_load() is now hosting_site_node_load()
added hosting_client_node_load()
parent 8bb1e8d5
File mode changed from 100755 to 100644
......@@ -345,12 +345,34 @@ function hosting_client_delete($node) {
/**
* Implementation of hook_load().
*
* @param node
* Node object
*/
function hosting_client_load($node) {
$additions = db_fetch_object(db_query('SELECT name as client_name, organization, email FROM {hosting_client} WHERE vid = %d', $node->vid));
return $additions;
}
/**
* Implementation of hook_load().
*
* @param arg
* Node's numeric nid
*/
function hosting_client_node_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type == 'client') {
return $node;
}
}
return FALSE;
}
/**
* Return a list of users for a given client.
*
......
......@@ -17,12 +17,11 @@ function hosting_migrate_menu() {
$items['hosting/migrate/compare'] = array(
'title' => 'Compare packages',
'page callback' => 'hosting_migrate_comparison',
'access arguments' => array('create migrate task'),
'type' => MENU_CALLBACK
);
/*
$items['node/%hosting_task_platform/task_migrate'] = array(
$items['node/%hosting_platform_node/task_migrate'] = array(
'title' => t('Migrate'),
'description' => t('Migrate sites to a new platform'),
'page callback' => 'drupal_get_form',
......
......@@ -306,6 +306,9 @@ function hosting_platform_validate($node, &$form) {
/**
* Implementation of hook_load().
*
* @param node
* Node object
*/
function hosting_platform_load($node) {
$additions = db_fetch_object(db_query('SELECT publish_path, verified, web_server, status AS platform_status FROM {hosting_platform} WHERE vid = %d', $node->vid));
......@@ -314,6 +317,24 @@ function hosting_platform_load($node) {
return $additions;
}
/**
* Implementation of hook_load().
*
* @param arg
* Node's numeric nid
*/
function hosting_platform_node_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type == 'platform') {
return $node;
}
}
return FALSE;
}
/**
* Implementation of hook_view().
*/
......
......@@ -308,6 +308,24 @@ function hosting_server_load($node) {
return $additions;
}
/**
* Menu callback; loads a hosting_task_server node
*
* @arg $arg a numeric nid
*/
function hosting_server_node_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type === 'server') {
return $node;
}
}
return FALSE;
}
/**
* Implementation of hook_view().
*/
......
......@@ -528,12 +528,33 @@ function hosting_site_update(&$node) {
/**
* Implementation of hook_load().
*
* @param node
* Node object
*/
function hosting_site_load($node) {
$additions = db_fetch_object(db_query('SELECT client, db_server, platform, profile, language as site_language, last_cron, status AS site_status, verified, port, `ssl`, ssl_redirect FROM {hosting_site} WHERE vid = %d', $node->vid));
return $additions;
}
/**
* Implementation of hook_load().
*
* @param arg
* Node's numeric nid
*/
function hosting_site_node_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type == 'site') {
return $node;
}
}
return FALSE;
}
/**
* Implementation of hook_nodeapi_delete_revision().
*/
......@@ -895,7 +916,7 @@ function hosting_site_menu() {
'access arguments' => array('access content'),
);
$items['node/%hosting_task_site/goto_site'] = array(
$items['node/%hosting_site_node/goto_site'] = array(
'page callback' => 'hosting_site_goto',
'page arguments' => array(1),
'access callback' => 'node_access',
......
......@@ -11,7 +11,7 @@ function hosting_task_menu() {
foreach (array('site', 'platform', 'server') as $type) {
foreach (hosting_available_tasks($type) as $task => $info) {
if (empty($info['hidden'])) {
$path = sprintf("node/%%hosting_task_%s/%s_%s", $type, $type, $task);
$path = sprintf("node/%%hosting_%s_node/%s_%s", $type, $type, $task);
$items[$path] = array(
'title' => $info['title'],
'description' => $info['description'],
......@@ -126,42 +126,6 @@ function hosting_task_menu_access($node, $task) {
return FALSE;
}
function hosting_task_site_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type == 'site') {
return $node;
}
}
return FALSE;
}
function hosting_task_platform_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type == 'platform') {
return $node;
}
}
return FALSE;
}
function hosting_task_server_load($arg) {
if (!is_numeric($arg)) {
return FALSE;
}
if ($node = node_load($arg)) {
if ($node->type === 'server') {
return $node;
}
}
return FALSE;
}
/**
* Implementation of hook_node_info()
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment