function revisioning_scheduler_form_alter in Revisioning 6.3
Same name and namespace in other branches
- 8 revisioning_scheduler/revisioning_scheduler.module \revisioning_scheduler_form_alter()
- 7 revisioning_scheduler/revisioning_scheduler.module \revisioning_scheduler_form_alter()
Adds a text field and checkbox to the revisioning form. Implementation of hook_form_alter().
@author Adam Bramley <adam@catalyst.net.nz>
File
- revisioning_scheduler/
revisioning_scheduler.module, line 30 - Allows for revisions to be published at a specified time and date.
Code
function revisioning_scheduler_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'revisioning_publish_confirm':
case 'node_revision_revert_confirm':
$query = db_fetch_array(db_query('SELECT * FROM {revisioning_scheduler} WHERE revision_vid=%d AND revision_nid=%d', arg(3), arg(1)));
if ($query) {
$user = user_load($query['revision_uid']);
drupal_set_message(t('Revision is already scheduled to be published on %date by %username', array(
'%date' => format_date($query['revision_date']),
'%username' => $user->name,
)), 'warning');
}
$form['revisioning_scheduler_date'] = array(
'#title' => t('Date for publication'),
'#type' => 'textfield',
'#description' => t('Enter the date you want this revision to be published.'),
'#maxlength' => 10,
'#size' => 10,
'#default_value' => date('d-m-Y'),
'#weight' => -1,
);
$form['revisioning_scheduler_time'] = array(
'#title' => t('Time for publication'),
'#type' => 'textfield',
'#maxlength' => 5,
'#size' => 5,
'#default_value' => date('H:i'),
'#description' => t('Enter the time you want this revision to be published. Use the 24 hour clock.'),
'#weight' => 0,
);
break;
case 'revisioning_revisions_summary':
$result = db_query('SELECT * FROM {revisioning_scheduler} WHERE revision_nid=%d and revision_date >=%d', arg(1), strtotime('1 hour ago'));
while ($revision = db_fetch_object($result)) {
$form['info'][$revision->revision_vid]['#value'] .= ' ' . t('Publish scheduled for %time.', array(
'%time' => format_date($revision->revision_date, 'long'),
));
}
break;
}
}