diff --git a/scheduler.module b/scheduler.module index 85e2d52..2f0b90a 100644 --- a/scheduler.module +++ b/scheduler.module @@ -990,13 +990,13 @@ function scheduler_node_insert($node) { 'unpublish_on' => $node->unpublish_on, ))->execute(); - // Invoke the rule events to indicate that a node has been scheduled. + // Invoke the events to indicate that a new node has been scheduled. if (module_exists('rules')) { if (!empty($node->publish_on)) { - rules_invoke_event('scheduler_node_is_scheduled_for_publishing_event', $node, $node->publish_on, $node->unpublish_on); + rules_invoke_event('scheduler_new_node_is_scheduled_for_publishing_event', $node, $node->publish_on, $node->unpublish_on); } if (!empty($node->unpublish_on)) { - rules_invoke_event('scheduler_node_is_scheduled_for_unpublishing_event', $node, $node->publish_on, $node->unpublish_on); + rules_invoke_event('scheduler_new_node_is_scheduled_for_unpublishing_event', $node, $node->publish_on, $node->unpublish_on); } } } @@ -1015,13 +1015,13 @@ function scheduler_node_update($node) { 'unpublish_on' => $node->unpublish_on, ))->execute(); - // Invoke the rule events to indicate that a node has been scheduled. + // Invoke the events to indicate that an existing node has been scheduled. if (module_exists('rules')) { if (!empty($node->publish_on)) { - rules_invoke_event('scheduler_node_is_scheduled_for_publishing_event', $node, $node->publish_on, $node->unpublish_on); + rules_invoke_event('scheduler_existing_node_is_scheduled_for_publishing_event', $node, $node->publish_on, $node->unpublish_on); } if (!empty($node->unpublish_on)) { - rules_invoke_event('scheduler_node_is_scheduled_for_unpublishing_event', $node, $node->publish_on, $node->unpublish_on); + rules_invoke_event('scheduler_existing_node_is_scheduled_for_unpublishing_event', $node, $node->publish_on, $node->unpublish_on); } } } @@ -1139,8 +1139,7 @@ function _scheduler_publish() { $context['node'] = $n; actions_do($actions, $n, $context, NULL, NULL); - // Invoke the rule event to indicate that this node has been published by - // Scheduler. + // Invoke the event to tell Rules that Scheduler has published this node. if (module_exists('rules')) { rules_invoke_event('scheduler_node_has_been_published_event', $n, $publish_on, $n->unpublish_on); } @@ -1222,8 +1221,7 @@ function _scheduler_unpublish() { $context['node'] = $n; actions_do($actions, $n, $context, NULL, NULL); - // Invoke the rule event to indicate that this node has been unpublished - // by Scheduler. + // Invoke event to tell Rules that Scheduler has unpublished this node. if (module_exists('rules')) { rules_invoke_event('scheduler_node_has_been_unpublished_event', $n, $n->publish_on, $unpublish_on); } diff --git a/scheduler.rules.inc b/scheduler.rules.inc index 2a6ed7a..3d745df 100644 --- a/scheduler.rules.inc +++ b/scheduler.rules.inc @@ -37,13 +37,23 @@ function scheduler_rules_event_info() { // Define the events. $items = array( - 'scheduler_node_is_scheduled_for_publishing_event' => array( - 'label' => t('On saving a node that is scheduled for publishing'), + 'scheduler_new_node_is_scheduled_for_publishing_event' => array( + 'label' => t('After saving new content that is scheduled for publishing'), 'group' => t('Scheduler'), 'variables' => $variables, ), - 'scheduler_node_is_scheduled_for_unpublishing_event' => array( - 'label' => t('On saving a node that is scheduled for unpublishing'), + 'scheduler_existing_node_is_scheduled_for_publishing_event' => array( + 'label' => t('After updating existing content that is scheduled for publishing'), + 'group' => t('Scheduler'), + 'variables' => $variables, + ), + 'scheduler_new_node_is_scheduled_for_unpublishing_event' => array( + 'label' => t('After saving new content that is scheduled for unpublishing'), + 'group' => t('Scheduler'), + 'variables' => $variables, + ), + 'scheduler_existing_node_is_scheduled_for_unpublishing_event' => array( + 'label' => t('After updating existing content that is scheduled for unpublishing'), 'group' => t('Scheduler'), 'variables' => $variables, ), @@ -114,13 +124,18 @@ function scheduler_rules_action_info() { * The date for publishing, a unix timestamp integer. */ function scheduler_set_publish_date_action($node, $date) { - $node->publish_on = $date; // When this action is invoked and it operates on the node being editted then // hook_node_presave() and hook_node_update() will be executed anyway. But if // this action is being used to schedule a different node then we need to call // the functions directly here. - scheduler_node_presave($node); - scheduler_node_update($node); + if (variable_get('scheduler_publish_enable_' . $node->type, 0)) { + $node->publish_on = $date; + scheduler_node_presave($node); + scheduler_node_update($node); + } + else { + drupal_set_message(t('Scheduled publishing is not enabeld for %type content. To prevent this message add the condition "Scheduled publishing is enabled" to your rule.', array('%type' => node_type_get_name($node->type))), 'warning'); + } } /** @@ -132,9 +147,14 @@ function scheduler_set_publish_date_action($node, $date) { * The date for unpublishing, a unix timestamp integer. */ function scheduler_set_unpublish_date_action($node, $date) { - $node->unpublish_on = $date; - scheduler_node_presave($node); - scheduler_node_update($node); + if (variable_get('scheduler_unpublish_enable_' . $node->type, 0)) { + $node->unpublish_on = $date; + scheduler_node_presave($node); + scheduler_node_update($node); + } + else { + drupal_set_message(t('Scheduled unpublishing is not enabeld for %type content. To prevent this message add the condition "Scheduled unpublishing is enabled" to your rule.', array('%type' => node_type_get_name($node->type))), 'warning'); + } } /** @@ -144,9 +164,11 @@ function scheduler_set_unpublish_date_action($node, $date) { * The node object from which to remove the publish_on date. */ function scheduler_remove_publish_date_action($node) { - $node->publish_on = 0; - scheduler_node_presave($node); - scheduler_node_update($node); + if (variable_get('scheduler_publish_enable_' . $node->type, 0)) { + $node->publish_on = 0; + scheduler_node_presave($node); + scheduler_node_update($node); + } } /** @@ -156,9 +178,11 @@ function scheduler_remove_publish_date_action($node) { * The node object from which to remove the unpublish_on date. */ function scheduler_remove_unpublish_date_action($node) { - $node->unpublish_on = 0; - scheduler_node_presave($node); - scheduler_node_update($node); + if (variable_get('scheduler_unpublish_enable_' . $node->type, 0)) { + $node->unpublish_on = 0; + scheduler_node_presave($node); + scheduler_node_update($node); + } } /**