Many people would like scheduler to schedule more that just publishing/unpublishing.
Examples:
- delete nodes (#207311: delete instead of unpublish)
- promote/demote nodes #14159: Schedule promote/demote of nodes
Instead of implementing every action we can think of, we could provide triggers and let the user attach the appropriate actions to them. Scheduler would only provide timed triggers. Scheduler for D6 does already make use of several actions for (un-)publishing of nodes.
I have no idea if this would work, since I have never used any triggers or actions, so take it with a grain of salt (make it a spoonful):
The administrator would use scheduler to create new custom triggers. Every custom trigger would be accompanied by an action that sets the time when the trigger fires. These actions can be tied to any other trigger. The custom triggers would also have either a fixed time until they fire or a user supplied time (e.g. via the node form).
Example: For providing scheduled publishing one would create a trigger and call it scheduler_publish_trigger (or whatever). Anlong with this trigger goes an action called scheduler_publish_action. This action needs to be tied to the "After saving a new post" trigger. scheduler_publish_trigger needs to be configured to be a node-trigger with user definable time. The "publish node" action needs to be assigned to the scheduler_publish_action.
Now this is what happens: A time entry widget will be inserted in every node form for the user to supply a publish date/time. If the user saves a new node the scheduler_publish_action will be executed which checks if a time was set and writes an scheduler entry to the database. Scheduler will check during cron runs if any triggers need to be fired. If the publish time of a scheduled node is past due the scheduler_publish_trigger will be fired which will execute the "publish node" action.
You can imagine how easy it would be to "implement" the two feature requests mentioned at the top of this post with this new scheduler.
Scheduler could allow other modules to create custom scheduler triggers. I dont know if actions can be assigned to triggers programmatically, but if they do, modules can use scheduler for all kinds of useful things. Think of a classifieds module which sends emails to the author if his node is about to expire. All time based "features" of http://drupal.org/project/ed_classified could be implemented with scheduler.
What do you think? Stupid idea? Doesn't work because of $reason? Tell me your opinion, please.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Scheduler2Mock.png | 11.09 KB | eric-alexander schaefer |
Comments
Comment #1
eric-alexander schaefer commentedEvery custom trigger should have its own permission. Although don't know how to do that yet.
Since there is a D6 compatible actions module for D5 we could even support D5 which has a large installation base.
Comment #2
oadaeh commentedSo, in essence, what you're proposing is a trigger where the triggering event is the passage of time, rather than some specific action being performed by a user.
Scheduler probably wouldn't need to provide any actions, unless you wanted to add the node deletion action, which doesn't exist in Actions (at least for the 5.x versions).
After playing with the 5.x-1.x and 5.x-2.x versions of Actions, Triggers and Workflow (and Triggerunlock, which is necessary for the 5.x-2.x & 6.x versions), the only two drawbacks I can see to this idea is 1) it seems as though a user can only schedule one state change at a time, and 2) the user can't edit the workflow at node creation time, which is when I would want to make that happen. If I were to use the Actions/Triggers/Workflow modules exclusively, I would have to create the node, edit it to set the timing for the first state change, wait for that change to happen, then set the timing for the next state change.
If what you are proposing can overcome the drawbacks, then I think it would be a fine idea.
Comment #3
eric-alexander schaefer commentedI think it would overcome the drawbacks you describe.
Comment #4
gregglessubscribe...
Comment #5
yang_yi_cn commentedHi man, you don't need a customer trigger. Doesn't admin/build/trigger/cron for this purpose?
Comment #6
yang_yi_cn commentedGenerall, I think the current schedule module is too confusing. I'll suggest a total rewrite.
My idea of a schedule module should be some thing like this (in very pseudo code):
?>
Comment #7
eric-alexander schaefer commentedI created a little mock. Thats what I am thinking about. Would be much simpler that the original post. The button would allow the user to use more that one action (e.g publishing, unpublishing and demote).
Scheduler permissions should include the available actions. E.g. certain user roles would be allowed to use "publish post" and "unpublish post", but not "delete post" or "make post sticky".
Comment #8
eric-alexander schaefer commentedBTW: I would also like to schedule actions without a node relation. Think "point-and-click-cron"...
(At "2008/12/24 08:00:00" send me an email with the body "Last day to get christmas presents. Get moving...")
(At "2009/01/01 00:00:00" display a message to users "Happy new year!")
Comment #9
eric-alexander schaefer commentedThere should also be a facility to define action assignments that can not be altered by the user. E.g. "unpublish the node 20 days after creation".
Comment #10
asimmonds commentedWhat are the differences between this proposal and the Scheduled Actions module? http://drupal.org/project/sched_act
Comment #11
eric-alexander schaefer commentedWell I don't know. I didn't know something like it exists. One apparent difference: Scheduler is alive and ScheduledActions is somewhat dead. We might need to look at SA a bit deeper. Maybe the two projects could merge.
Comment #12
fagoI'd suggest you also have a look at the rules module, as it already offers scheduled execution of rule sets and so execution of arbitrary actions.
An additional UI like the mockup http://drupal.org/files/issues/Scheduler2Mock.png would fit perfectly. As so users would have an UI for configuring the scheduled actions on nodes. One could list all by rules supported actions in the dropdown box and once the form is submitted, just configure a rule set and its schedule programmatically and rules will do it.
Comment #13
fago>BTW: I would also like to schedule actions without a node relation. Think "point-and-click-cron"...
I also had this idea.. Basically you can do it already with rules, however there is no user friendly UI for manually scheduling stuff. Currently things get scheduled just by actions.
So the rules scheduling stuff is great for automatically created schedules like "unpublish the node in 10 days".
Comment #14
drewish commentedsubscribing.
Comment #15
gregglesI was working with the Workflow module the other day and noted that it can do scheduled workflow state transitions.
It's also possible to trigger actions based on state changes. So, Workflow + Schedule state change + Workflow actions is one way to do this already. It's a bit more cumbersome than the way that scheduler currently works, but I thought I would mention it as similar prior art.
Comment #16
momper commented"Make scheduler more generic" - sounds very good ...
thanks momper
Comment #17
thekevinday commentedsubscribing.
Comment #18
jackbravo commentedsubscribing
Comment #19
designerbrent commentedsubscribing
Comment #20
mnp commentedsubscribing
Comment #21
ErwanF commentedSubscribing
Comment #22
thekevinday commentedIt occurred to me that this might be best solved via a CCK field.
The CCK field already provides the option to do permissions and numerous hooks are integrated with different modules already.
In particular, CCK is integrated with the rules module.
The rules module supports responding to CCK field changes and also change them.
I then discovered that the Date module provides this already.
http://drupal.org/project/date
With this, the publish and unpublish scheduling functionality can be provided without doing any sort of code rewrites.
I think that the date+cck+rules replaces this project.
If this project is to be continue with a re-write, it might be more beneficial to find a way to wrap the data+cck+rules and simplify the use and management thereof.
(like a user-friendly UI suggested from #13)
At the same time, it may be better to have this project be separate from date+cck+rules.
There are probably users out that who do not want to or need to add date, cck, or even rules and want the simple & straight-forward solution that scheduler currently provides.
If this is the case, it may be best for this project to stay simple and not provide the requested functionality that is apparently already provided from date+cck+rules.
Perhaps not adding any new functionality and simply cleaning up, stabilizing, and perfecting the current functionality may be best for this project.
This sums up to two possibilities:
1) make scheduler a user friendly management UI to date+cck+rules.
or
2) do not make scheduler more generic, just keep it simple, clean, and stable.
Comment #23
gregglesI agree. The workflow module has a generic action scheduler but it is quite complex. I think that the goal of this module should be "light weight node publish/unpublish scheduler" and nothing more.
Comment #24
wiredescape commented+1 - keep scheduler simple, clean, and stable.
Comment #25
eric-alexander schaefer commentedOK. Lets take this a bit further.
Thats how it could work:
- We keep scheduler a simple tool to publish/unpublish nodes.
- We write a book page for the drupal handbook which describes how to do all kinds of neat advanced scheduled stuff with actions/triggers/workflow/cck/date/rules/whatever.
There are a lot of people subscribed to this. Let us hear your opinion. Yes, I mean YOU! I know you are reading this ;-)
Comment #26
scottrigby@Eric Schaefer: completely agree.
There do seem to be some handbook pages with a few different methods for doing this, but the ones I've run across so far seem to be outdated, like this one: http://drupal.org/node/175319.
It might be a good idea to post other similar links (maybe there are more updated methods described somewhere I haven't seen), which could help get the ball rolling on the handbook page?
@greggles: is there a any link for how to set up workflow's generic action scheduler (Workflow + Schedule state change + Workflow actions method)?
@thekevinday: similar Q... is there any description about how the date+cck+rules method works already? my question is how can this be done automatically (i understand a rule can trigger on 'content is going to be viewed', but for instance how can nodes be unpublished X days after datefield value without having to visit each one? I think Fago mentioned somewhere
@fago: maybe the last part of the above question is for you fago... in #13 you mention this possibility, but elsewhere someone said this can't work because "during cron maintenance tasks, Rules doesn't have a node object" (#4 in #366539: Rule sets on cron execution)-- is this right? or is there another way to do this using Rules?
Anyway, hope responses may go some distance toward putting togehter a provisinoal updated handbook page Eric mentioned...
Comment #27
eric-alexander schaefer commentedI will check out all the related modules and figure out how difficult it is to employ them for all the requested scheduled actions escpecially from a users view.
Comment #28
thekevinday commented@scottrigby: It was very awkward for me to do and was not obvious at first.
Heres what I did:
*I am using Workflow here as the example action to perform on the scheduler update. (That is, to change the workflow of a node to a new state..)
1) Create a new content_type
2) Create a cck field of the type "date"
3) Create your workflow as needed and enable it for your content type created in step #1
4) Create a Rule Set, supplying an Argument of type Number with a label of nid and a machine readable name of nid
- This seems to be possible only on creation so if the Argument is not supplied, you will have to recreate the rule set
5) Edit the rule set and add a rule
6) With this rule add a "Load content by id" with a Content ID:
<?php print $nid;?>- This nid is the name of the Argument passed to the rule set
7) In this rule add the action "Populate a field", select your CCK field created in step #2, expand "Advanced: Specify the fields value with PHP code" and inside of the "Code:" box add the following code:
return array();- This deletes the existing scheduled date, but I wasn't sure if I should return NULL instead of array() (returning array() still works however)
8) Add an action to change the workflow to whatever workflow you desired
9) You are done with Rule Sets, the next step is to create 2 more rules; These rules are done through the normal rules page and not to the rule sets.
10) Create 2 separate rules: "After saving new content", "After updating existing content" that do the same thing, but one is on creation only and the other is on updates only
11) Inside of both of the said rules, I added the condition "Check a truth value" with the following PHP snippet:
<?php if (empty($node->field_change_workflow[0]['value'])) print("0"); else print("1"); ?>- The print()'s may be an unnecessary extra step, but I felt safer doing them directly..
- field_change_workflow should be replaced by the machine name of the CCK field you created in step #2
12) Inside of both of the said rules, I added the action to call the Rule Scheduler for the rule sets created in Steps 4-8.
- The Rule set should appear in the drop down list under the bolded "Rule Scheduler".
- If it does not appear, then you may need to either refresh or double check that you create a "Rule Set"
What happens is that whenever the cck_field gets populated with some date for the custom content type, one of the two rules from #10 will schedule the Rule Set created by steps 4-8.
Then on the specified date, the Rule set will fire, delete the data in the CCK field from step #2 and then change the workflow.
Comment #29
eric-alexander schaefer commentedSo it has been decided. Scheduler stays small and tidy. All the "advanced scheduling tasks" can be implemented with actions/triggers/workflow/rules/whatever. => won't fix
Comment #30
momper commentedthanks to all for their involvement ...
Comment #31
eric-alexander schaefer commentedYes, thanks everybody.
I will start a new book page or something like that, explaining how most of the requested features can be accomplished with actions, rules and workflow. I will post a link to the result here...
Comment #32
AdrianB commentedSubscribing
Comment #33
iharley commentedSubscribing
Comment #34
1kenthomas commentedI am entirely unconvinced.
Scheduler is not currently a 'Scheduler.' It's a 'Schedule Node Publish/Unpublish' module.
The above, describes a series of somewhat bizarre hacks to accomplish Scheduling, AFAIKT. This is not the Drupal Way.
There is a need for a general Scheduler, which allows setting a time and making things happen. The best way is probably via Rules.
This would not be difficult to implement-- see Node Expire for example code.
Comment #35
eric-alexander schaefer commentedWe are expecting your patches.
Seriously, make some suggestions, figure out how scheduler can integrate better with related modules and document it here. If you know some php and possibly drupal module development, give it a shot and try to implement some of your ideas and post the results.
Comment #36
fago>There is a need for a general Scheduler, which allows setting a time and making things happen. The best way is probably via Rules.
So what about trying the rules scheduler then?
Comment #37
eric-alexander schaefer commentedFrom the rules project page:
"Flexible scheduling system that allows scheduling any component / action."
Comment #38
zilverdistel commentedAllow me to reopen this issue.
I agree to keep this module real simple, that is, for the end-user.
But in my opinion, all "Publish options" should be handled by this module, to be fully featured. The publishing options in drupal core are:
This trio has been in drupal core for ages now, and this won't probably change in the near future.
Anyway, I'm working on a patch that adds in the promoted to front scheduling for the scheduler-7.x-1.x branch.
Comment #39
eric-alexander schaefer commentedPlease open a new issue for the feature you want to implement. In some countries it is illegal to wake the dead... ;-)
BTW: I am planning to implement the options you mention anyway. That's why the node type options have been splitted to separate fieldsets (one for publishing, one for unpublishing). Every "publish option" would have its own fieldset with its own options. So for "promote to front" there would be a fieldset for "promote" and one for "demote".
Comment #40
nancydru#1092934: Scheduled promotion / demotion from Front page
Comment #41
thekevinday commentedThe same functionality already exists in rules module.
Just set the rule to trigger a promotion/unpromotion for a given date. (such as +7 days).
Comment #42
k_zoltan commentedJust as a help for others who got here after hours of search.
There is module for Drupal 7 that does all the general actions (publish, unpublish, promote, denote ... etc) for nodes as you can see it in this video
Screencast video
https://www.youtube.com/watch?v=LeqU4Qyh3l4
Module page
https://www.drupal.org/project/scheduled_actions