Commit f11757b9 authored by Steven Jones's avatar Steven Jones

Issue #1260066 by Steven Jones: Added Allow use of the working copy option...

Issue #1260066 by Steven Jones: Added Allow use of the working copy option when creating a platform.
parent 52d1167b
......@@ -15,6 +15,12 @@ function hosting_hosting_platform_context_options(&$task) {
if ($task->ref->makefile) {
$task->context_options['makefile'] = $task->ref->makefile;
}
if (isset($task->ref->make_working_copy) && !empty($task->ref->make_working_copy)) {
$task->context_options['make_working_copy'] = $task->ref->make_working_copy;
}
else {
$task->context_options['make_working_copy'] = 'null';
}
}
/**
......@@ -25,7 +31,10 @@ function hosting_platform_drush_context_import($context, &$node) {
$node->title = str_replace('platform_', '', trim($context->name, '@'));
$node->web_server = hosting_drush_import($context->web_server);
$node->publish_path = $context->root;
$node->makefile = $context->makefile;
$node->makefile = $context->makefile;
if (isset($context->make_working_copy) && !empty($context->make_working_copy)) {
$node->make_working_copy = $context->make_working_copy;
}
}
}
......
......@@ -53,6 +53,12 @@ function hosting_platform_schema() {
'not null' => TRUE,
'default' => 0,
),
'make_working_copy' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('vid'),
);
......@@ -141,3 +147,22 @@ function hosting_platform_update_6004() {
variable_set('hosting_platform_update_6004_run', true);
}
}
/**
* Add the 'make_working_copy' column.
*/
function hosting_platform_update_6205() {
$ret = array();
$spec = array(
'make_working_copy' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
);
foreach ($spec as $field => $field_spec) {
db_add_field($ret, 'hosting_platform', $field, $field_spec);
}
return $ret;
}
(function($) {
Drupal.behaviors.aegir_make_working_copy = function (context) {
$('.hosting-platform-working-copy-source:not(.hosting-platform-working-copy-processed)', context)
.addClass('hosting-platform-working-copy-processed')
.bind('change', function() {
Drupal.hosting_platform_working_copy.update_visibility($(this));
})
.bind('keyup', function() {
Drupal.hosting_platform_working_copy.update_visibility($(this));
})
.each(function() {
Drupal.hosting_platform_working_copy.update_visibility($(this));
});
}
Drupal.hosting_platform_working_copy = Drupal.hosting_platform_working_copy || {};
Drupal.hosting_platform_working_copy.update_visibility = function($elem) {
if ($elem.val()) {
$('.hosting-platform-working-copy-target').parents('.form-item')
.show();
}
else {
$('.hosting-platform-working-copy-target').parents('.form-item')
.hide();
}
}
})(jQuery);
......@@ -208,6 +208,18 @@ function hosting_platform_form(&$node) {
'#default_value' => $node->makefile,
'#maxlength' => 255,
);
$form['make_working_copy'] = array(
'#type' => 'radios',
'#title' => t('Drush make option'),
'#default_value' => isset($form['#node']->make_working_copy) ? $form['#node']->make_working_copy : FALSE,
'#options' => array(
FALSE => t('Normal - Discards SCM files'),
TRUE => t('Working copy - preserves SCM files'),
),
);
$form['#after_build'][] = 'hosting_platform_form_platform_after_build';
$servers = hosting_get_servers('http');
if (sizeof($servers) > 1) {
......@@ -233,6 +245,26 @@ function hosting_platform_form(&$node) {
return $form;
}
function hosting_platform_form_platform_after_build($form) {
drupal_add_js(drupal_get_path('module', 'hosting_platform') . '/hosting_platform.js');
if (isset($form['makefile']['#attributes']['class'])) {
$form['makefile']['#attributes']['class'] .= ' hosting-platform-working-copy-source';
}
else {
$form['makefile']['#attributes']['class'] = ' hosting-platform-working-copy-source';
}
if (isset($form['make_working_copy']['#attributes']['class'])) {
$form['make_working_copy']['#attributes']['class'] .= ' hosting-platform-working-copy-target';
}
else {
$form['make_working_copy']['#attributes']['class'] = ' hosting-platform-working-copy-target';
}
return $form;
}
/**
* Hide the delete button on platform nodes.
*/
......@@ -253,8 +285,8 @@ function hosting_platform_insert($node) {
if (!isset($node->no_verify)) {
hosting_add_task($node->nid, 'verify');
}
db_query("INSERT INTO {hosting_platform} (vid, nid, publish_path, makefile, verified, web_server, status) VALUES (%d, %d, '%s', '%s', %d, %d, %d)",
$node->vid, $node->nid, $node->publish_path, $node->makefile, $node->verified, $node->web_server, $node->platform_status);
db_query("INSERT INTO {hosting_platform} (vid, nid, publish_path, makefile, verified, web_server, status, make_working_copy) VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d)",
$node->vid, $node->nid, $node->publish_path, $node->makefile, $node->verified, $node->web_server, $node->platform_status, $node->make_working_copy);
if (!$node->old_vid) {
hosting_context_register($node->nid, 'platform_' . preg_replace("/[!\W]/", "", $node->title));
}
......@@ -275,8 +307,8 @@ function hosting_platform_update($node) {
if ($node->platform_status == HOSTING_PLATFORM_DELETED) {
$node->no_verify = TRUE;
}
db_query("UPDATE {hosting_platform} SET publish_path = '%s', makefile = '%s', web_server = %d, verified = %d, status= %d WHERE nid=%d",
$node->publish_path, $node->makefile, $node->web_server, $node->verified, $node->platform_status, $node->nid);
db_query("UPDATE {hosting_platform} SET publish_path = '%s', makefile = '%s', web_server = %d, verified = %d, status= %d, make_working_copy = %d WHERE nid=%d",
$node->publish_path, $node->makefile, $node->web_server, $node->verified, $node->platform_status, $node->make_working_copy, $node->nid);
}
if (!$node->no_verify) {
hosting_add_task($node->nid, 'verify');
......@@ -329,7 +361,7 @@ function hosting_platform_validate($node, &$form) {
* Node object
*/
function hosting_platform_load($node) {
$additions = db_fetch_object(db_query('SELECT publish_path, makefile, verified, web_server, status AS platform_status FROM {hosting_platform} WHERE vid = %d', $node->vid));
$additions = db_fetch_object(db_query('SELECT publish_path, makefile, verified, web_server, status AS platform_status, make_working_copy FROM {hosting_platform} WHERE vid = %d', $node->vid));
$iid = db_result(db_query("SELECT iid FROM {hosting_package_instance} i left join {hosting_package} p on p.nid=i.package_id WHERE p.package_type='platform' AND i.rid=%d", $node->nid));
$additions->release = hosting_package_instance_load($iid);
$additions->profiles = hosting_get_profiles($node->nid, 'short_name');
......
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