I noticed today that many (or perhaps all) of the node family relationship functions that load the related nodes (such as nodefamily_relation_load_by_type, nodefamily_relation_load, etc.) only return nodes where the status is >0. I was wondering what the reason for this is. It seems like it would be better for the user's function (in the template, for example) to check if status > 0 before displaying rather than have the module handle this. Or, you could add in an additional flag to these functions that had a default value of do not return unpublished nodes but with an optional value that would cause all (published and unpublished nodes) to be returned.

I'm asking because I wrote an additional function that automatically creates a nodeprofile type for each new user. That is, the function looks at the relationships established with node family and then creates the nodes I'm using to replace the profile module. However, some of these nodes aren't relevant to certain users, based on the roles granted to the user. Thus, I'm keeping those node types to default to not being published. However, when a user is later granted that role, I want the corresponding nodes to become published. To do that, I'm using the nodefamily_relation_load_by_type function to load all the related nodes, but this doesn't return the unpublished nodes.

I would have no problem changing this myself in the code, but I would rather not have patched modules to maintain myself. If you're not opposed to the addition of another parameter to the functions, I could submit a patch that gives the user the option to get all nodes, not just published nodes. But maybe there's a good reason not to do this that I'm not thinking of.

Thanks
AC

Comments

fago’s picture

no, there is no good reason for this. I just thought it's convenient.

So a patch, which creates an optional argument for all the loader functions would be great!

aclight’s picture

Status: Active » Needs review
StatusFileSize
new4.56 KB

Here's a patch that creates an optional argument with a default value such that the default behavior of the functions is not changed.

fago’s picture

Status: Needs review » Needs work

thanks, looks fine.
But could you please rename the argument to $status? It just looks a bit cleaner.

Thanks!

aclight’s picture

StatusFileSize
new4.5 KB

Here's the patch with $min_status ---> $status

AC

aclight’s picture

Status: Needs work » Needs review
fago’s picture

hm, please roll it against the latest CVS version (4.7 or HEAD, they are the same), otherwise there will be conflicts.

thanks

aclight’s picture

StatusFileSize
new4.47 KB

ok, here's a version rolled against HEAD. sorry about that.

fago’s picture

Status: Needs review » Fixed

finally committed to HEAD and DRUPAL-4-7.
thanks :)

Anonymous’s picture

Status: Fixed » Closed (fixed)