This adds support for:
- Drupal Core Actions
- Rules Module
- Workbench Moderation State Triggers
While adding rules and actions integration to workbench_module, I realized that I needed the same things for workbench_access.
I converted my work from the following threads:
- https://drupal.org/node/1226688
- http://drupal.org/node/1079134 (the actions code that I added)
I added support for triggers based on (and using some of the code from):
- http://drupal.org/node/1079134
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | workbench_access-rules-1285110-51.patch | 13.3 KB | cgmonroe |
| #45 | 1285110-wa-rules_1.patch | 11.95 KB | thekevinday |
| #41 | 1285110-wa-rules.patch | 11.63 KB | agentrickard |
| #38 | 1285110-wa-rules.patch | 12.07 KB | agentrickard |
| #35 | workbench_access-rules_support-1285110-35.patch | 11.66 KB | thekevinday |
Comments
Comment #1
thekevinday commentedForgot to set it to "needs review".
Comment #2
thekevinday commentedThis update does the following:
- removes a drupal_set_message() debug statement I forgot to remove.
- defines the provided variable 'workbench_access_states' as an array of taxonomy terms instead of the type called 'unknown'.
Comment #3
agentrickardHuh?
Looks like some of the code comments were copied from another patch.
This is pretty awesome. Does it support VBO as well?
Comment #4
itangalo commentedRe-rolled patch with the "git diff" command – it can now be applied using "git apply". (All cred to thekevinday.)
Comment #5
thekevinday commentedI never tried with VBO (view bulk operations, right?).
The patches I made are with git diff, but I am using the 7.x-1.x branch and not master.
Should I be rolling the patches against master instead of 7.x-1.x?
I fixed the comments to be for workbench_access and not workbench_moderation and also added more description about what the functions do.
I noticed that I was using 'state' and 'states' everywhere. This is because workbench_moderation has 'states'.
I changed the code to use 'section' and 'sections' instead of 'state' and 'states'. This should make it more consistent. The downside is it will mean any existing rules from the previous patch might need to be re-created. A cache-clear may be necessary as well.
There is another area I forgot to address. Workbench access supports multiple kinds of access, namely taxonomy based AND menu based. What I wrote is for taxonomy based. Do I need to do anything differently for menu based and if so, what?
Edit: I noticed a little late that I was searching for 'state' with case-sensitive on.
I found one-more area to cleanup:
line #104 of workbench_access.rules.inc,
'label' => t("Workbench Access States"),should become'label' => t("Workbench Access Sections"),I will add the change to the next patch as I am sure there will be things to fix or add once this current patch gets reviewed..
Comment #6
agentrickard7.x-1.x is the proper branch.
There should be abstraction functions that handle the different access schemes for you. I'll have to look at how Rules actually works before giving you any guidance.
Comment #7
itangalo commentedThanks for the updated patch. Switching to 7.x-1.x instead of master.
(@agentrickard: Realizing I've recorded screencasts with an old version – and with old knowledge – I will re-record the one about WB Access today. It will be published tomorrow.)
Comment #8
marcusx commentedThe patch isn't applying anymore against the latest dev version. It is working with the version from 2011/09/19 the commit before the patch was posted.
http://drupalcode.org/project/workbench_access.git/commit/778894951b3541...
Maybe @thekevinday could repost a new version.
Comment #9
marcusx commentedHere is a new version of #5 which should work with the latest dev. I just copied over the changes from #5 by hand to the latest dev and recreated the patch. So there is no gurantee that the code is still working, I will test the next days.
Comment #11
agentrickardThat test fail is not actually related to this patch, and is a problem with grabbing a random user from an array.
Comment #12
agentrickard#9: 1285110-9-rules_actions_triggers_for_workbench_access.patch queued for re-testing.
Comment #13
drupalmonkey commentedThis patch is not working for me. edit: (patch from #9 btw)
Rule I created:
Event: Before Saving Content
Condition: Contents current access control section
Actions: 1. Assign access control section (presave)
2. Unpublish content
Neither of the 2 actions are completed when I edit/save the node. Also I'm getting 2 notices when I save the node:
Notice: Undefined property: stdClass::$workbench_access_id in workbench_access_rules_condition_contents_current_access_section() (line 148 of /www/sites/all/modules/workbench_access/workbench_access.rules.inc).
Notice: Undefined property: stdClass::$workbench_access_id in workbench_access_rules_condition_contents_current_access_section() (line 152 of /www/sites/all/modules/workbench_access/workbench_access.rules.inc).
Comment #14
thekevinday commentedThe code in question crashes because the property workbench_access_id does not exist in the node object.
First, it may be a good idea to ensure that the said property exists before acting on it.
That is easy to do with a new patch.
Second, the real issue is that the said property does not exist.
It should exist, in fact, because it does not exist we have the following to scenarios that I can think up at the moment:
1) The $node variable that is passed to the function is not a valid node object.
2) The hook_node_load() for workbench_access is not being called and thereby is not making the appropraite changes to the node object.
3) There is a problem with the workbench_access hook_node_load() that is preventing it from altering the node object.
4) Your content type does not have workbench access enabled.
Without the workbench access id, the "contents current control section .. " condition will not function because it cannot tell if the function is associated with some workbench access id.
Now, lets assume #4 is your case.
This means that workbench access id is not enabled and therefore cannot ever match the condition.
The solution will be to test for the object property workbench_access_id and if it does not exist return FALSE.
Doing this will cause cases 1->3 to return FALSE and thus fail silently, but I suspect solving #4 is still the best way to go right now.
I will make a patch shortly.
Could you confirm if you have content that does not have "Enforce workbench access control" enabled?
Comment #15
thekevinday commentedHere is the patch with the change mentioned in #14.
Comment #16
drupalmonkey commentedI have workbench access turned on for all of my content types:
https://skitch.com/rjpeter2/8sckd/workbench-access-wb-test
Here is my rule:
https://skitch.com/rjpeter2/8sck5/editing-reaction-rule-test-wb-test
If content type == Article, then put in Workbench Access section of Education.
I edit and save a Article, and it is not put in the Education section. Seems like I'm doing it right, I was following what the guy does in this screencast: http://dev.nodeone.se/en/workbench-access (at 13:00).
Comment #17
thekevinday commentedTry turning on the rules debugging, which is found under admin/config/workflow/rules/settings.
Either select "Log debug information to the system log " or set "Show debug information" to "Always".
This might help identify where the problem may be.
Comment #18
agentrickardThat error probably depends on when Rules tries to execute, and how it changes the $node. It would also depend on which version of WA you are using. Use 7.x-1.x-dev.
Comment #19
drupalmonkey commentedThe errors were occurring in #13 because workbench_access_node_load() doesn't attach it's data at $node->workbench_access_id anymore, it attaches at $node->workbench_access.
Comment #20
drupalmonkey commentedRe-rolled patch against latest git checkout. This patch works for the Rule I described above for me.
Comment #21
thekevinday commentedgood catch.
Comment #22
agentrickardI think
workbench_access_active_options()duplicates the existingworkbench_access_options()function.Comment #23
thekevinday commentedI am not sure about that.
To get the list of active options, workbench access does the following all over the place:
So, in order to call workbench_access_options() to get what is active, it seems that
those 4 lines must be used every time.
I hope I am wrong with this, I would rather have fewer lines of code and certainly less redundancy.
Perhaps the argument should be to just do those 4 lines every time and not add an additional function whose name can confuse?
Hopefully one of the worbench_access developers can clarify this issue.
Comment #24
agentrickardI agree and would then prefer to replace those lines with the new function. But that patch might need to be separated and put in before the Rules patch.
Comment #25
stevectorI've made a separate issue for workbench_access_active_options()
#1561822: Add workbench_access_active_options()
Comment #26
thekevinday commentedOops, Wrong window/tab.
Comment #27
agentrickardLet's commit the other patch first, then refactor this one (if needed).
Comment #28
jumoke commentedWill this awesome patch be commit to HEAD soon? ; )
Thanks Kevin, drupalmonkey, Itangalo, marcus and thanks all :)
Comment #29
Refineo commentedHello,
Any chance to commit this to HEAD soon?
Comment #30
agentrickard#20: workbench_access-rules_support-1285110-20.patch queued for re-testing.
Comment #32
agentrickardNeeds a re-roll. I think that using the native form support in the dev branch gets you this already.
Comment #33
thekevinday commentedI re-rolled #20's patch.
However, I am wondering about what #22 and then @25 said.
Would it not be better to wait for #1561822: Add workbench_access_active_options() to be committed and then recreate this patch using the new function(s)?
Comment #34
agentrickardYes, we should leverage the other patch.
This doesn't get much attention, frankly, because I never use Rules.
Comment #35
thekevinday commented#32, I've finally looked at the new native form support in dev branch.
In some aspects it can support the functionality added by this patch, but the rules support here adds much more than just form save actions.
These workbench_access rules allows for loading workbench access states for any kind of operation, such as during cron jobs, new account creation, or even page views.
The native forms support is just restricted to forms, so I believe rules support is still needed.
I rerolled the patch against the latest dev.
For simplicity purposes, I have applied the changes from #1561822: Add workbench_access_active_options().
Doing this is likely to make this patch fail during testing.
As soon as the said issue gets commited, I will re-test this patch.
(Drupal really needs "Blocked By" and "Blocks" issue states..)
For those testing this, be sure to apply the patch from #1561822: Add workbench_access_active_options() if it is not yet commited.
Comment #36
thekevinday commentedI thought I found a case in the last patch where I did not, but could, use workbench_access_active_options(). However, it turns out that particular case needed both $tree and $active variables.
I am putting my change below in text, I will wait to re-roll in case more bugs are found.
Comment #37
agentrickardThe blocking patch has been committed. Patch still applies, but needs some love based on #36.
Comment #38
agentrickardI see the little correction in #36. Trying again.
Comment #39
agentrickardActually, let me commit the minor fix first.
Comment #41
agentrickardAnd that's corrected and removed from this patch.
Needs testers who use Rules.
Comment #43
itangalo commented@agentrickard: Don't give up! The test bot is just being mean.
Comment #44
agentrickardI think testbot doesn't like patches with new files in them.
Comment #45
thekevinday commentedThe problem with the patch being applied seems to be that for some reason the patch you supplied is trying to modify an existing workbench_access.rules.inc and this patch is supposed to create that file not modify it.
I have been using this patch for a while to perform accessibility validation on node save and change the workflow state to either Published or Needs Work depending on the pass/fail results of the validation check.
I came across three problems:
1) Using a rule that responds on workflow state change to call another rule that then changes the workflow state to something else gets can cause rules to not call the workflow state change response function a second time to prevent recursion.
- This is not really a problem, but it does fill the logs with warnings (and makes me feel worried).
- Nothing seems to be broken.
2) The quick and easy inline workbench_moderation change moderation state block seems to crash or do something weird while the rules module is running.
- I cannot tell if this is a problem with workbench_moderation, rules, the workbench_* rules patches I made, or some combination of the three.
- However, if I disable the inline block (found ~around line #1789 of workbench_moderation.module), then the rules never have issues.
- As far as I can tell is that the said bug is related to calling drupal_render().
3) When changing states and reacting to states using this rules code, I noticed occasional weirdness with access id's not always being properly reacted to.
- I managed to isolate the problem to how I am processing workbench_access and workbench_access_id.
- It seems that the workbench_access array is the current/previous access_id information and if, on node save, a new value is applied, there is now a workbench_access_id array with the new data. Which means I need to first test for workbench_access_id (in case this is a node_save) and then test for workbench_access.
- I created a patch, but I have since noticed that there have been quite a lot of changes to the workbench_access 7.x-1.x-dev branch. I am not certain if the stuff I used in this patch is still valid for the new code.
In summary:
#1 = design limitation or log irritation.
#2 = unknown problem with workbench_moderation + rules patches that affects workbench_access rules patches.
#3 = fixed mistake with processing workbench_access_id when available and when not available, processing workbench_access.
The attached patch contains the fix from #3 and should commit properly.
Comment #46
agentrickardNice. Do we have documentation for how to roll patches like that? I can't find it. I was using git add -N, which is obviously wrong.
Aside from #1 and #2, is this patch de-coupled from the Workbench Moderation patch?
Comment #47
thekevinday commentedThe workbench moderation patch is completely separate as the *.rules.inc file is on a per-module/per-directory basis. There is no inter-depedency between the workbench_access and the workbench_moderation rules patches.
The actual complete _lack_ of documentation has led me to do the following:
1) git clone (project_url) some_project
2) cd some_project
3) hack..hack...slash...save
4) gid add -A
5) git diff HEAD > ../some_project-version-1.patch
6) upload!
I always felt I might be doing it wrong, but it works...
That said, I still have a lot to learn about git.
I was not aware of this -N process you used.
looking at git-add man page:
It sounds like git -N might be the more proper way to generate a patch than what I am doing.
So, perhaps the following will work better:
1) git clone (project_url) some_project
2) cd some_project
3) hack..hack...slash...save
4) gid add -N
5) git diff HEAD > ../some_project-version-1.patch
6) upload!
Comment #48
agentrickardMaybe. My mistake may be that I didn't do a diff HEAD. I always do "git diff --relative" by default.
Comment #49
cgmonroe commentedBetween the #33 patch and the #35 patch the workbench_access_assign_section_presave_action_form function lost the code that set the section choices in the config form. This loss was carried forward in all subsequent patches.
One effect of this is that when this is used as a VBO action, not section choices are displayed.
Missing code is:
Note that the result of workbench_access_get_active_tree() probably should be check for a valid result here.
Comment #50
cgmonroe commentedMarking as need work because of code dropped between patches.
Comment #51
cgmonroe commentedHere is a new version of the patch that:
Comment #52
delacosta456 commentedhi
Many thanks for all the work people are doing
please what is the actual safe state status of the latest patch upload by @cgmonroe against the latest version of wrkbench_access
Thanks
Comment #53
agentrickard7.x is closed