Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In Rules 2, the conditions are stored as separate entities -- much in the same way as access rules in CTools' Page manager.
This is an issue to discuss the possibility of making Rules conditions and Page manager's access rules one and the same.
(I hope to pursue a module that makes it possible to use Rules conditions as CTools access rules and vice versa -- but the issue here is to actually make them one and the same. In a distant future.)
Comment | File | Size | Author |
---|---|---|---|
#36 | interdiff-1061550-28-36.txt | 6.47 KB | MegaChriz |
#36 | entity-entity-ctools-access-plugin-1061550-36.patch | 8.65 KB | MegaChriz |
| |||
#29 | 1061550-entity-ctools-access-plugin-28.patch | 8.35 KB | amitaibu |
#16 | 1061550-entity-ctools-access-plugin-16.patch | 4.31 KB | amitaibu |
#14 | Node template | Site-Install-2.jpg | 30.36 KB | amitaibu |
Comments
Comment #1
Itangalo CreditAttribution: Itangalo commented(There is now a cross-post in the Rules issue queue: #1061554: Make Rules conditions and Page manager's access rules one and the same.)
Comment #2
fagoMakes sense to me.
Rules features an API for re-using single conditions as well as condition sets, including a way to embed the UI. So if desired, making use of Rules conditions in panels shouldn't be hard, however we'd need to manage to get rules variables from of the ctools context.
Anyway, doing the "compatibility" module sounds like a good start.
Comment #3
Itangalo CreditAttribution: Itangalo commentedGreat!
I think the hardest part in the compatibility module (now codename "Rules in Panels") will be to bridge the two ways of handling objects in Rules and Page manager. A possible side effect of this could be that proper Tokens could be used inside Panels – but that is too early to say.
I'll post here when I get time to actually do some code. (Meanwhile, anyone else should feel free to start if the spirit arises.)
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedThere's a token context in CTools if that helps. :)
Comment #5
Itangalo CreditAttribution: Itangalo commentedWohoo! I really should look closer into the D7 versions of the CTools modules.
Thanks for the update.
Comment #6
amitaibu@Itangalo,
Checkout #1138708: Auto create "content-type" CTools plugins from tokens -- it's a start in this direction of creating a content-type plugin for Entity API's metadata. I think It's very similar to the way we can do access plugins.
Comment #7
amitaibuMoving this issue to Entity API:
Patch auto creates access plugins from metadata properties that define 'access callback'.
Comment #8
amitaibu#1138708: Auto create "content-type" CTools plugins from tokens is now committed :). This means all tokens, including the ones declared by entity-metadata are exposed as CTools content-type plugins.
So now this patch will complete it by adding the CTools access plugin.
Comment #9
fagoSounds good + patch looks basically good.
However, there is another way to specify access information - via the 'setter callback' property. Then, it is assumed the access information is complete, thus if there is no access metadata the API will grant you access to a property based on entity level access. So we could just go and all entity properties.
>+ * Settings form for the 'by entity_bundle' access plugin
I think this comment needs to be updated.
>+ 'title' => t("Entity: metadata"),
>+ 'description' => t('Control access by entity-metadata.'),
I think this description is just going to confuse people. Perhaps we just say "Entity property" and "Control access by entity property" ?
Beside that, I'm not sure about adding CTools integration to the entity API as I'm just slowly diving into ctools, so I'd probably be a bad maintainer for that.
Comment #10
amitaibu> However, there is another way to specify access information - via the 'setter callback' property
Is there an example for this in entity API?
Comment #11
fagouhm, sry I meant 'setter permission'. E.g. see the node author property.
Comment #12
amitaibuFinally got back to it.
Comment #13
fagoIs plugins the default name for that? Else, I'd prefer "ctools" as plugins isn't really connected to ctools as term in general.
I'm not sure this is clear to everyone.
Let's also cover bundle-properties? -> use entity_get_all_property_info()
We should also check whether the property still exists, i.e. use isset($wrapper->property).
Let's catch metadata wrapper exceptions caused by that and return FALSE in case of an exception. That would cover the not existing property case too.
bundle?
What is @s supposed to be?
Comment #14
amitaibu> Is plugins the default name for that?
Yes, this is the convention.
> Let's catch metadata wrapper exceptions caused by that and return FALSE in case of an exception. That would cover the not existing property case too.
Isn't this redundant if we already check before isset($wrapper->property)?
> What is @s supposed to be?
This @s is copied from CTools plugins. The output is in the attached image.
Comment #15
fagoStill, let's go with "ctools/$plugin". That makes it clear to which module the stuff belongs.
Why are you adding trailing whitespaces here? But indeed "an all" is wrong, I guess it should be "in all"
deprecated
Maybe we should call "Entity property access" ?
Uhm, again that ugly "entity_entity" prefix. y that?
Also we should implement this function without relying on multiple as this is performance relevant. (Yes, I got some ctools experience.. :D)
Whitespace in empty line.
Indeed. As we've fixed entity loading now to not throw exceptions, it's fine now without catching it.
Why not just return it?
Uhm, that's an ugly, undescriptive replacement. Still, let's go with it so any existing translation for it applies here too.
Comment #16
amitaibure white-spaces, Oops, sorry - Aptana doesn't have the trim whitespace feature, and I keep forgetting that :/
> Also we should implement this function without relying on multiple as this is performance relevant. (Yes, I got some ctools experience.. :D)
Can you explain what you mean, as we are defining multiple access under a single access plugin.
Attached patch with other fixes.
Comment #17
fagoctools uses the 'get child' method to get the plugin-child-info when executing it at run-time. Thus for performance it's not good to load all possible childrens there (via multiple) but only the necessary on. I guess that's the cause for its existence.
Comment #18
merlinofchaos CreditAttribution: merlinofchaos commentedIt is sometimes necessary to load all, but yes, whenever possible, 'get child' should be implemented correctly to avoid loading them all.
Comment #19
fagoJusted tested #1261044: Add a direct support of entity in ctools page manager - for that having an access plugin for entity_access() would be nice. I guess thats more often needed than property based access? Let's just add it too.
Comment #20
amitaibuentity_metadata_ctools_access_get_child() now extracts the entity_type and property name from the $child.
Also fixed access callback to return the expected result ;)
Comment #21
amitaibuSlightly better patch -- using the limit option in explode()
Comment #22
fagoI'd expect entity_access() integration from a plugin "access/entity.inc". Maybe better call it "entity_property.inc"? So we can use "entity.inc" for entity_access() integration.
It doesn't make much sense to me (from a user perspective) to have rather sophisticated entity-property-access integration, but no simple entity-access integration. So let's add an entity.inc plugin at the same time - that shouldn't be hard to do.
Let's just use the entity_ctools namespace, the entity_metadata namespace is pretty much deprecated.
Above you are using only one underscore as separator. Also, why not just use a colon as separator again?
hm, which other settings?
Comment #23
amitaibuI think we are getting closer ;)
Comment #24
fagoIndeed :)
We should just use all entity-types that have an access callback here, see entity_type_supports().
entity_access has more/different operations.
based on entity_access
Why do we need that clone?
Again, why clone?
Comment #25
amitaibu> Why do we need that clone?
This is something I've seen in Ctools. I guess it fits some plugins where we might change the entity itself, and we don't want to manipulate the original entity. Anyway, removed.
Other things fixed as-well.
Comment #26
amitaibubump :)
Comment #27
Itangalo CreditAttribution: Itangalo commentedComment #28
fagoOh, sry for letting this lie so long.
Let's skip the wrapper here and just use entity_access() as the wrapper isn't really used.
Then, this just checks access for the global user. Shouldn't we allow passing in a user just like the node_access plugin?
We are not controlling access *of* the property. I'd say "control access by property"? Still, we should clarify it with an example.
Shouldn't we use the entity type label here?
I don't think we have to list the options again in the description.
Comment #29
amitaibuFixed #28
> + $plugin['required context'] = new ctools_context_required(t(ucfirst($entity_type)), 'entity:' . $entity_type);
btw, let it be noted I really hate passing those variables inside a t() :)
Comment #30
Itangalo CreditAttribution: Itangalo commentedNoted!
Comment #31
fubhy CreditAttribution: fubhy commentedThose functions are missing documentation blocks.
Plugin declaration for what?
Same here.
Form callback for what?
In general the code looks okay to me but it lacks documentation and the existing documentation could be improved (a lot of @param and @return declarations are missing). Just a minor additional note: I like to document functions in a "What does it do?" manner instead of a "Do this!" manner (if you know what I mean). That means, instead of having a doc block that reads "Check for access based on access to entity property." I would probably phrase it like this: "Callback function for checking access to the entity based on access to an entity property." (same content but still slightly different). I often use comments like the one that you used there to describe single lines of code though.
Comment #32
fagoAccording to the coding standards comment should start with a verb ala:
Checks access based on access to an entity property.
> + $plugin['required context'] = new ctools_context_required(t(ucfirst($entity_type)), 'entity:' . $entity_type);
Yep, that's really ugly. I'd say it shuold use the entity type label, but let's follow CTools "style" here in order to go with existing UI.
Comment #33
Yuri CreditAttribution: Yuri commentedLast comment 3 years ago...will this issue be completed? Interesting with regard to Rules Panels integration.
Comment #34
geek-merlinTested #29, it does what it announces. More docstrings (while formally making sense) will not make the code more readable, so setting RTBC. YMMV.
Comment #35
fagoSry for letting this lie so long. As this still needed / wanted functionality? Seems there were not many people interested into it during the last year? But if so, I'd be happy to add it.
Some quick remarks:
Missing function docblocks.
Comment #36
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedThe patch in #29 no longer applied, so here's a reroll. I looked at the code to get a sense of what
entity_ctools_entity_property_access_get_child()
does, but I'm not entirely sure. As I've more sites to update because of the new Drupal core security release, I'll only made some code style fixes that were obvious enough for me. For the rest I leave the patch as is for now.