Hello,

I've config node_gallery and created galleries that have several images. However, I noticed that when I unpublish the gallery node the images in the gallery remain published, so they still show up on the search results and views.

Thanks in advance for your help,

KH

Comments

scroogie’s picture

Status: Active » Needs review
StatusFileSize
new1.44 KB

Mhm, we can do this with Triggers/Actions Bulk API, some manual loading and saving of nodes, or directly in the database. I'll leave this decision to justin. Here is a patch to directly do it in the database.

Greetings
scroogie

3dloco’s picture

Thanks Scroogie for your patch, really appreciate it! Your patch does effectively unpublish all the images when the gallery is unpublished.

However, when the images in a gallery are unpublished they disappear from the manage images tab (node/*/images). Also, on views the image count field is displaying 0 when unpublished and the right image count when published.

Thank you very much for your help,

KH

scroogie’s picture

Ah, you're right indeed. I guess the manage and sort images tab should show unpublished images.

The image count is correct in my opinion, because unpublished images are just that: unpublished. They shouldn't be counted for images in a gallery, or do you think differently?

For now, you can change the manage images thing in the related View, but I guess we should change the default. Justin, what do you think about that?

justintime’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

OK, so for the manage and sort issue, I created #956638: Unpublished images don't show up in Manage and Sort tabs.

Agree with the image count being correct. Anonymous users should not see any data related to unpublished nodes.

Regarding your patch, it works, but there's problems with going the direct to the db route. The problem is that other modules may want to perform operations on these nodes when they are unpublished, and you're bypassing nodeapi by going that route. Instead, we should node_load()/node_save() each image that needs modified. Since that's a fairly expensive operation and there's the potential for 100's or even 1,000's of images here, we should use batch API. Code similar to the cascading deletion should do well here.

Also bumping this to critical so it makes the alpha.

scroogie’s picture

Assigned: Unassigned » scroogie
Status: Needs work » Needs review
StatusFileSize
new3.7 KB

So perhaps we should show a confirmation dialog for this?

This one is with batch API. I reused the node_gallery_batch_node_save function that was already there.

Greetings
scroogie

3dloco’s picture

Status: Needs review » Reviewed & tested by the community

Thanks Scroogie! This is currently working for me!

--After saving the gallery (changing status from published to unpublished and viceversa) the progress bar (batch API) show the progress and all the images for the gallery are unpublished or published, respectively.

--Also, the images now appear on the manage images page even when the gallery is unpublished.

Thank you very much for your help, really appreciate your hard work :-)

justintime’s picture

StatusFileSize
new2.33 KB

Nice patch @scroogie - I didn't know PHP had anonymous functions - reminds me of my Perl days :)

I cleaned a bunch of stuff up and rerolled it. Not much functional difference, just a lot less repeating ourselves. @3dloco (or anyone else), could you test the updated patch and report back?

justintime’s picture

Status: Reviewed & tested by the community » Needs review

setting status back to needs review

scroogie’s picture

Ah, yes, thats better indeed. But are the escaped variables on purpose?

justintime’s picture

Yeah, that's intentional. I needed $status to be interpolated, but the other variables to not be. The php.net docs for create_function explain that variable interpolation is usually prevented by using single quotes, but I had to switch to double quotes to allow interpolation of $status. Thinking about it now, I probably should have used $status as an argument. Oh well.

3dloco’s picture

Status: Needs review » Reviewed & tested by the community

Hello Justintime

Patch #7 is currently working for me. Thanks a lot for help!!

Regards,

KH

justintime’s picture

Status: Reviewed & tested by the community » Fixed

Sweet. Committed to dev with the changes mentioned in #10 for clarity

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.