| 1 |
<?php
|
| 2 |
|
| 3 |
// PROVISIONATOR CLIENT NODE FUNCTIONS
|
| 4 |
|
| 5 |
/**
|
| 6 |
* Implementation of hook_form().
|
| 7 |
*/
|
| 8 |
function provisionatorclient_form(&$node, &$param) {
|
| 9 |
$form['title'] = array(
|
| 10 |
'#type' => 'textfield',
|
| 11 |
'#title' => t('Title'),
|
| 12 |
'#required' => TRUE,
|
| 13 |
'#default_value' => $node->title,
|
| 14 |
'#weight' => -5
|
| 15 |
);
|
| 16 |
|
| 17 |
$form['body_filter']['body'] = array(
|
| 18 |
'#type' => 'textarea',
|
| 19 |
'#title' => t('Description'),
|
| 20 |
'#default_value' => $node->body,
|
| 21 |
'#required' => TRUE
|
| 22 |
);
|
| 23 |
|
| 24 |
$form['body_filter']['filter'] = filter_form($node->format);
|
| 25 |
|
| 26 |
$form['domainprefix'] = array(
|
| 27 |
'#type' => 'textfield',
|
| 28 |
'#title' => t('Domain Prefix'),
|
| 29 |
'#required' => TRUE,
|
| 30 |
'#default_value' => $node->domainprefix,
|
| 31 |
'#description' => t('The first part of the domain (URL) to be used for sites created for this client. Could be something like www.server.com/sites - all sites will be added after this prefix')
|
| 32 |
);
|
| 33 |
|
| 34 |
$form['symlinkpath'] = array(
|
| 35 |
'#type' => 'textfield',
|
| 36 |
'#title' => t('Symlink Path'),
|
| 37 |
'#default_value' => $node->symlinkpath,
|
| 38 |
'#required' => TRUE,
|
| 39 |
'#description' => t('Directory to contain the symlink from Drupal, which is used to expose the deployed site to Apache.')
|
| 40 |
);
|
| 41 |
|
| 42 |
$form['dbprefix'] = array(
|
| 43 |
'#type' => 'textfield',
|
| 44 |
'#title' => t('Database Prefix'),
|
| 45 |
'#default_value' => $node->dbprefix,
|
| 46 |
'#required' => TRUE,
|
| 47 |
'#description' => t('Prefix to use before database names in MySQL. Could be something like drupalsites_')
|
| 48 |
);
|
| 49 |
|
| 50 |
$form['apachetargetdir'] = array(
|
| 51 |
'#type' => 'textfield',
|
| 52 |
'#title' => t('Apache Target Directory'),
|
| 53 |
'#default_value' => $node->apachetargetdir,
|
| 54 |
'#required' => TRUE,
|
| 55 |
'#description' => t('Filesystem path of the directory to contain the symlink used by Apache to serve this site.')
|
| 56 |
);
|
| 57 |
|
| 58 |
// TODO: Enter additional form elements
|
| 59 |
|
| 60 |
return $form;
|
| 61 |
}
|
| 62 |
|
| 63 |
|
| 64 |
/**
|
| 65 |
* Implementation of hook_insert().
|
| 66 |
*/
|
| 67 |
function provisionatorclient_insert( $node ) {
|
| 68 |
db_query("INSERT INTO {provisionatorclient} (nid, domainprefix, symlinkpath, dbprefix, apachetargetdir) VALUES (%d, '%s', '%s', '%s', '%s')", $node->nid, $node->domainprefix, $node->symlinkpath, $node->dbprefix, $node->apachetargetdir);
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 72 |
* Implementation of hook_load().
|
| 73 |
*/
|
| 74 |
function provisionatorclient_load( $node ) {
|
| 75 |
$additions = db_fetch_object(db_query('SELECT domainprefix, symlinkpath, dbprefix, apachetargetdir FROM {provisionatorclient} WHERE nid = %d', $node->nid));
|
| 76 |
return $additions;
|
| 77 |
}
|
| 78 |
|
| 79 |
/**
|
| 80 |
* Implementation of hook_delete().
|
| 81 |
*/
|
| 82 |
function provisionatorclient_delete( $node ) {
|
| 83 |
db_query("DELETE FROM {provisionatorclient} WHERE nid = %d", $node->nid);
|
| 84 |
}
|
| 85 |
|
| 86 |
/**
|
| 87 |
* Implementation of hook_prepare().
|
| 88 |
*/
|
| 89 |
function provisionatorclient_prepare(&$node) {
|
| 90 |
|
| 91 |
}
|
| 92 |
|
| 93 |
/**
|
| 94 |
* Implementation of hook_submit().
|
| 95 |
*/
|
| 96 |
function provisionatorclient_submit(&$node) {
|
| 97 |
|
| 98 |
}
|
| 99 |
|
| 100 |
/**
|
| 101 |
* Implementation of hook_update().
|
| 102 |
*/
|
| 103 |
function provisionatorclient_update($node) {
|
| 104 |
if ($node->revision) {
|
| 105 |
provisionatorclient_insert($node);
|
| 106 |
}
|
| 107 |
else {
|
| 108 |
// TODO: Enter database update query here, for example:
|
| 109 |
// db_query("UPDATE {node_example} SET color = '%s', quantity = %d WHERE vid = %d", $node->color, $node->quantity, $node->vid);
|
| 110 |
db_query("UPDATE {provisionatorclient} SET domainprefix = '%s', symlinkpath = '%s', dbprefix = '%s', apachetargetdir = '%s' WHERE nid = %d", $node->domainprefix, $node->symlinkpath, $node->dbprefix, $node->apachetargetdir, $node->nid);
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
/**
|
| 115 |
* Implementation of hook_validate().
|
| 116 |
*/
|
| 117 |
function provisionatorclient_validate(&$node) {
|
| 118 |
// TODO: Enter form validation code here
|
| 119 |
}
|
| 120 |
|
| 121 |
/**
|
| 122 |
* Implementation of hook_view().
|
| 123 |
*/
|
| 124 |
function provisionatorclient_view(&$node, $teaser = FALSE, $page = FALSE) {
|
| 125 |
// TODO: Insert additional code (call to theme functions, etc.) to execute when viewing a node, for example:
|
| 126 |
// $node = node_prepare($node, $teaser);
|
| 127 |
// $order_info = theme('node_example_order_info', $node);
|
| 128 |
// $node->body .= $order_info;
|
| 129 |
// $node->teaser .= $order_info;
|
| 130 |
|
| 131 |
$node = node_prepare( $node, $teaser );
|
| 132 |
|
| 133 |
$client_info = '';
|
| 134 |
$client_info .= t('<br />Domain Prefix: ').$node->domainprefix;
|
| 135 |
$client_info .= t('<br />Symlink Path: ').$node->symlinkpath;
|
| 136 |
$client_info .= t('<br />DB Prefix: ').$node->dbprefix;
|
| 137 |
$client_info .= t('<br />Apache Symlink Directory: ').$node->apachetargetdir;
|
| 138 |
$node->body .= $client_info;
|
| 139 |
$node->teaser .= $client_info;
|
| 140 |
}
|
| 141 |
|
| 142 |
?>
|