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 one installation of ours, we are using "favorites" as (also) a way to determine how a content has been "liked". So far, so good. The only issue was that now a person SHOULD NOT vote its own nodes as favorite. I simply added a "create favorites on own nodes" permission. I hope you like it
Comment | File | Size | Author |
---|---|---|---|
#2 | favorite_nodes_flexer.patch | 1.83 KB | flexer |
favorite_nodes_01.patch | 1.51 KB | flexer |
Comments
Comment #1
kbahey CreditAttribution: kbahey commentedI don't like this piece of code. It is very complex and will be a maintenance nightmare.
It has to be more clear with comments. For example:
It has to be a separate function (e.g.
function _favorite_node_can_add()
) Also use && and || as per code guidelines.Comment #2
flexer CreditAttribution: flexer commented"Refactoring" the code as per your suggestions, I found that using permission doesn't work (the user 1 bypasses that check). I moved the option from being a permission to a setting. Patch attached.