function comment_deploy_operations_add_now_form_submit in Deploy - Content Staging 6
Submit handler for comment_deploy_operations_add_now_form().
File
- modules/
comment_deploy/ comment_deploy.pages.inc, line 102 - Deployment API which enables modules to deploy items between servers.
Code
function comment_deploy_operations_add_now_form_submit($form, &$form_state) {
$sid = $form_state['values']['sid'];
// If there is already a plan for these comments, then empty it and use it.
// Otherwise create one. Every deployment needs to be attached to a plan, so
// under the hood we make a plan called 'Comments Now' and mark it as internal
// only, which forces it to be hidden from the user-facing deployment plan admin.
$pid = deploy_plan_exists('Comments Now');
if (!$pid) {
$pid = deploy_create_plan('Comments Now', 'Internal plan to deploy comments', 1);
}
else {
deploy_empty_plan($pid);
}
$result = db_query("SELECT cid, subject FROM {comments} WHERE cid IN (%s)", $form_state['values']['cids']);
while ($row = db_fetch_array($result)) {
if (!deploy_item_is_in_plan($pid, 'comment', $row['cid'])) {
deploy_add_to_plan($pid, 'comment', $row['subject'], $row['cid'], 0, DEPLOY_COMMENT_GROUP_WEIGHT);
}
}
// Now do the deployment
if (deploy_plan_init($pid, $sid, $form_state['values'])) {
// Redirect to the log overview page for this push.
$form_state['redirect'] = "admin/build/deploy/deploy_check_batch";
}
else {
$dlid = variable_get('deploy_log_id', '');
deploy_plan_cleanup();
// Redirect to the log overview page for this push.
$form_state['redirect'] = "admin/build/deploy/logs/details/{$dlid}";
}
}