Commit 652bf6d9 authored by Fredric Mitchell's avatar Fredric Mitchell

Issue #1479380 by fmitchell: fix schedule to not use JS; use write_history()

parent 77d1a63b
STATE_FLOW_SCHEDULE = { };
(function($){
STATE_FLOW_SCHEDULE.schedulingHelper = {
init:function(){
$.datepicker.setDefaults(
{
onSelect:function(date){
$(this).parent().next().find('input').val(STATE_FLOW_SCHEDULE.scheduledTimeContainer);
current_log_text = $('#edit-event-comment').val();
$('#edit-event-comment').val(current_log_text + date + ' ' + STATE_FLOW_SCHEDULE.scheduledTimeContainer);
}
}
);
$('#edit-selected-date-timeEntry-popup-1').focusout(function(){
current_log_text = $('#edit-event-comment').val();
new_log_text = current_log_text.replace(STATE_FLOW_SCHEDULE.scheduledTimeContainer, this.value);
STATE_FLOW_SCHEDULE.scheduledTimeContainer = this.value;
$('#edit-event-comment').val(new_log_text);
});
}
};
STATE_FLOW_SCHEDULE.adminHelper = {
init:function(){
$('#edit-operation').children().each(function(index, value){
if (value.value == 'change_state_publish' || value.value == 'change_state_unpublish') {
$(this).remove();
}
});
}
};
STATE_FLOW_SCHEDULE.scheduledTimeContainer = '12:00 am';
STATE_FLOW_SCHEDULE.schedulingHelper.init();
})(jQuery);
\ No newline at end of file
......@@ -38,10 +38,6 @@ function state_flow_schedule_form_state_flow_events_revision_alter(&$form, &$for
drupal_alter('state_flow_schedule_events', $scheduled_events);
if (in_array($event_name, $scheduled_events)) {
drupal_add_js(drupal_get_path('module', 'state_flow_schedule') . '/state_flow_schedule.js', 'file');
$message = t('This content has been scheduled to be published on ');
$form['selected-date'] = array(
'#type' => 'date_popup',
'#title' => 'Select a date and time',
......@@ -71,9 +67,7 @@ function state_flow_schedule_form_state_flow_events_revision_alter(&$form, &$for
$form['#submit'][] = 'state_flow_schedule_content';
}
if (!empty($message)) {
$form['event_comment']['#default_value'] = $message;
}
$form['event_comment']['#default_value'] = 'Scheduled.';
}
}
......@@ -115,12 +109,19 @@ function state_flow_scheduled_content_validate($form, &$form_state) {
* @param array $form_state
*/
function state_flow_schedule_content($form, &$form_state) {
global $user;
$values = $form_state['values'];
$selected_date = strtotime($values['selected-date']);
$event_name = $values['event-name'];
$nid = $values['nid'];
$vid = $values['vid'];
state_flow_schedule_schedule($nid, $vid, $selected_date);
//set message
$node = node_load($nid);
$message = t('This content has been scheduled to be published on !date', array('!date' => $values['selected-date']));
$state_flow = state_flow_load_state_machine($node);
$state_flow->write_history($user->uid, $message);
}
/**
......
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