function flatcomments_existing_form_submit_2 in Flatcomments 6
Same name and namespace in other branches
- 6.2 flatcomments_existing/flatcomments_existing.admin.inc \flatcomments_existing_form_submit_2()
Form submit handler - second pass. Starts a batch of required operations.
1 string reference to 'flatcomments_existing_form_submit_2'
- flatcomments_existing_form in flatcomments_existing/
flatcomments_existing.admin.inc - This is a multi-pass form, the confirmation being second pass.
File
- flatcomments_existing/
flatcomments_existing.admin.inc, line 82 - Administrative callbacks to provide the functionality of flattening previously existing comments.
Code
function flatcomments_existing_form_submit_2($form, &$form_state) {
// Reset the form to show first pass when finished.
$form_state['storage'] = NULL;
$content_types = node_get_types('names');
$processed_types = array();
$batch = array(
'file' => __FILE__,
);
// Add operations to the batch
foreach ($form_state['values']['types'] as $type => $value) {
if (!empty($value)) {
$processed_types[$type] = $content_types[$type];
$nodes = db_query("SELECT DISTINCT c.nid FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE n.type = '%s'", $type);
while ($node = db_fetch_array($nodes)) {
$batch['operations'][] = array(
'flatcomments_existing_one',
array(
$node['nid'],
),
);
}
}
}
// This is a replacement for 'finished' callback, so that we can pass $processed_types
$batch['operations'][] = array(
'flatcomments_existing_finished',
array(
$processed_types,
),
);
// Execute the batch.
batch_set($batch);
// batch_process() is not needed here, because we're inside a form
// submit handler.
}