Commit 3693651e authored by Adrian Rossouw's avatar Adrian Rossouw

Remove the rename feature. Test and fix the clone feature.

parent 4673086f
......@@ -4,11 +4,10 @@
function drush_hosting_clone_pre_hosting_task($task) {
$task =& drush_get_context('HOSTING_TASK');
if ($task->ref->type == 'site' && $task->task_type == 'clone') {
$task->args[2] = '@' . $task->task_args['new_name'];
$task->args[2] = '@' . $task->task_args['new_uri'];
$platform = node_load($task->task_args['target_platform']);
$task->args[3] = hosting_context_name($platform->nid);
$profile_instance = _hosting_migrate_get_target_profile_name($task);
if (sizeof($profile_instance)) {
......@@ -34,7 +33,8 @@ function hosting_clone_post_hosting_clone_task($task, $data) {
foreach (array('type', 'status', 'uid', 'comment', 'promote', 'moderate', 'sticky', 'name', 'format', 'client', 'db_server', 'profile', 'site_status', 'port') as $field) {
$clone->$field = $task->ref->$field;
}
$clone->title = $task->task_args['new_name'];
$clone->title = $task->task_args['new_uri'];
$clone->hosting_name = $clone->title;
$clone->platform = $target;
$clone->import = 1; # make sure the site doesn't reinstall...
$clone->verified = 0; # ... and it does verify
......
......@@ -18,25 +18,14 @@ function hosting_clone_perm() {
}
function hosting_task_clone_form_validate($form, &$form_state) {
if (!$form_state['values']['parameters']['hidden'] && !$form_state['values']['parameters']['target_platform']) {
form_set_error('parameters][target_platform', t('You need to select a valid platform to migrate your site to.'));
}
$url = strtolower($form_state['values']['parameters']['new_name']); // domain names are case-insensitive
if (!_hosting_valid_fqdn($url)) {
form_set_error('title', t("You have not specified a valid url for this site."));
}
if (hosting_site_exists($url)) {
form_set_error('title', t("The domain name you have specified is not unique."));
$site = $form['parameters']['#node'];
$url = strtolower($form_state['values']['parameters']['new_uri']); // domain names are case-insensitive
if ($url == $site->title) {
form_set_error('new_uri', t("To clone a site you need to specify a new Domain name to clone it to."));
}
if ($form_state['values']['parameters']['aliases']) {
$aliases = explode("\n", $form_state['values']['parameters']['aliases']);
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
if (!hosting_domain_allowed($alias, (array) $node)) {
form_set_error('aliases', t('The domain name @alias is already in use', array('@alias' => $alias)));
}
}
}
else {
hosting_task_migrate_form_validate($form, $form_state);
}
}
......@@ -46,28 +35,6 @@ function hosting_clone_theme($existing, $type, $theme, $path) {
function hosting_task_clone_form($node) {
$form = hosting_task_migrate_form($node);
// Don't show the current platform if it's locked
if (!_hosting_platform_is_locked($node->platform)) {
// A profile package dependency check on a target platform is not relevant
// in the case of a clone, as the target may be the current platform
unset($form['no_targets']);
$form['new_name'] = array (
'#title' => t('New site name'),
'#type' => 'textfield',
'#weight' => '-1',
'#required' => TRUE,
'#default_value' => $node->title
);
if (module_exists('hosting_alias')) {
hosting_alias_form_data($form);
}
}
else {
$form['no_targets'] = array (
'#type' => 'item',
'#description' => t('There are no valid platforms to clone this site to. Please add or unlock a valid platform.'),
);
}
return $form;
}
......
<?php
function hosting_rename_hosting_feature() {
$features['rename'] = array(
'title' => t('Site rename'),
'description' => t('Rename a site both in the frontend and in the backend filesystem.'),
'status' => HOSTING_FEATURE_ENABLED,
'module' => 'hosting_rename',
);
return $features;
}
<?php
function drush_hosting_rename_pre_hosting_task($task) {
$task =& drush_get_context('HOSTING_TASK');
if ($task->ref->type == 'site' && $task->task_type == 'rename') {
$task->args[2] = '@' . $task->task_args['new_name'];
$platform = node_load($task->task_args['platform']);
$task->args[3] = hosting_context_name($platform->nid);
if (module_exists('hosting_alias')) {
$task->options['aliases'] = str_replace("\n", ",", $task->task_args['aliases']);
$task->options['redirection'] = $task->task_args['redirection'];
}
}
}
function hosting_rename_post_hosting_rename_task($task, $data) {
if ($task->ref->type == 'site') {
$node = $task->ref;
$node->title = $task->task_args['new_name'];
hosting_context_register($node->nid, $task->task_args['new_name']);
$node->no_verify = TRUE;
$node->aliases = $task->task_args['aliases'];
$node->redirection = $task->task_args['redirection'];
/* @TODO fix Hosting so that it handles revisionning properly -
* currently setting this to TRUE inserts a new row into hosting_site
* with the new vid, and in most places we select from this table by nid
*
* $node->revision = TRUE;
*/
$node->changed = mktime();
node_save($node);
}
}
name = Site rename
description = Rename a site both in the frontend and in the backend filesystem.
package = Hosting
dependencies[] = hosting
core = 6.x
<?php
function hosting_rename_hosting_tasks() {
$options = array();
$options['site']['rename'] = array(
'title' => t('Rename'),
'description' => t('Rename a site.'),
'weight' => 6
);
return $options;
}
function hosting_rename_perm() {
return array(
'create rename task',
);
}
function hosting_task_rename_form_validate($form, &$form_state) {
$url = strtolower($form_state['values']['parameters']['new_name']); // domain names are case-insensitive
if (!_hosting_valid_fqdn($url)) {
form_set_error('title', t("You have not specified a valid url for this site."));
}
if (hosting_site_exists($url)) {
form_set_error('title', t("The domain name you have specified is not unique."));
}
if ($form_state['values']['parameters']['aliases']) {
$aliases = explode("\n", $form_state['values']['parameters']['aliases']);
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
if (!hosting_domain_allowed($alias, (array) $node)) {
form_set_error('aliases', t('The domain name @alias is already in use', array('@alias' => $alias)));
}
}
}
}
}
function hosting_rename_theme($existing, $type, $theme, $path) {
return array('hosting_task_rename_form' => array('arguments' => array('form' => NULL)));
}
function hosting_task_rename_form($node) {
$form['#node'] = $node;
$form['new_name'] = array (
'#title' => t('New site name'),
'#type' => 'textfield',
'#weight' => '-1',
'#required' => TRUE,
'#default_value' => $node->title
);
$form['platform'] = array(
'#type' => 'hidden',
'#value' => $node->platform,
);
if (module_exists('hosting_alias')) {
hosting_alias_form_data($form);
}
return $form;
}
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