Attached is a patch with several fixes for the DRUPAL-7--1 branch.

  1. Removed the filter_access() check against a node's format; I don't believe this exists in d7, as the body is now a proper field.
  2. Renamed drupal_alter hooks; required as clone was using the fourth argument as a flag, which would no longer be possible unless we pad it out to be the fifth argument. (the fourth argument is passed by reference into drupal_alter
  3. Other minor API updates

Comments

jmiccolis’s picture

StatusFileSize
new3.57 KB

I neglected to change hook_perm -> hook_permission. That is included in this patch.

danielb’s picture

Just for the purposes of discussion, because I have faced this same problem...

Removed the filter_access() check against a node's format; I don't believe this exists in d7, as the body is now a proper field.

The filter formats still do exist under each field at
$node->[field_key][language][n]['format']
Where field_key is the field (such as 'body'), language can be 'und', and n is the field item index.
And then the format id value retrieved from there can be plugged into filter_format_load() and the result of that passed to filter_access().

However I do not know how to get the fields of a node or get the languages available for the field, etc.. so this information is useless. I suspect there is no facility to do this other than to iterate through a node and see if any property is a field, and then to iterate through each language and item index checking for a value in 'format' which seems like a bit of a hassle.

I don't even know if it is really all that important to check this either.

Renamed drupal_alter hooks; required as clone was using the fourth argument as a flag, which would no longer be possible unless we pad it out to be the fifth argument. (the fourth argument is passed by reference into drupal_alter

You can pass the 4th argument by passing it as a variable.

Drupal 6

<?php
  drupal_alter("clone_node", $node, $original_node, "prepopulate");
?>

Drupal 7

<?php
  $op = "prepopulate";
  drupal_alter("clone_node", $node, $original_node, $op);
?>

I think that will work. There is a risk that another module can alter this. The alternative is to do:

<?php
  drupal_alter("clone_node_prepopulate", $node, $original_node);
?>

Also the hook should probably by convention start with "node_clone" (the module short name) as should various other functions and files in this module.

danielb’s picture

Just a note, I've learnt that 'und' is actually LANGUAGE_NONE

will_in_wi’s picture

Subscribe

pwolanin’s picture

Thanks for the patches - looks like the versions here need to be updated too.

The clone link should also become a contextual link and local action on the node rather than a tab.

xacto’s picture

Thumbs up!!

Thanks!!

benanderson’s picture

subscribe

georgedamonkey’s picture

subscribe

pwolanin’s picture

The drupal_alter() API docs suggest possibly using a a $context array to pass in additional parameters.

http://api.drupal.org/api/drupal/includes--module.inc/function/drupal_al...

xacto’s picture

Should this patch be ported to a D7 developer version?
It seems to work well enough for Dev version.
It would make updates and patches easier to track.
Could someone take care of that?

webankit’s picture

+1

jonaswouters’s picture

subscribing

Csabbencs’s picture

I'd like to have a D7 version of this module, too.

chipway’s picture

subscribing

MatthijsG’s picture

Would like to test the Dr7 version :-)

spacereactor’s picture

subscribing

xacto’s picture

You can apply the last patch in this thread.
It will give you a non CVS version that works to some extent.

That patch should be ported to a new 7.x branch.

Anticosti’s picture

subcribing

pwolanin’s picture

@danielb - the module name is clone.module, hence any "hook" should correctly use "clone". The project short name just relates to repo organization.

pwolanin’s picture

Looking at the D7 handing of filter access - looks like you can now edit the node but not the individual field, so I think the patch is ok in terms of removing that check.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new8.95 KB

Patch in #1 was a bit incomplete. This seems to basically work.

pwolanin’s picture

Status: Needs review » Fixed

committed this plus README updates.

Status: Fixed » Closed (fixed)

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

Letharion’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Active

Since this issue is about D7, I guess that there was just no D7 branch when the issue was created, so I change it to 7.x-1.x-dev now.

I'm reopening this issue, because it seems like this patch is not applied to the current dev version?
I came to the issue queue in order to file a bug about the OPs first problem:
"Removed the filter_access() check against a node's format".
This patch clearly fixes this particular issue, but when I clone the repo and checkout 7.x-1.x the incorrect filter access check remains, and as such the module will never successfully clone anything.

Just to be clear about what code I'm currently using, this is the last entry in the commit log.

commit 1fb1a99e31840ba22ceb16a069c683a321195aae
Author: pwolanin <pwolanin@49851.no-reply.drupal.org>
Date:   Wed May 4 21:36:54 2011 -0400

    Issue #1118818 by pwolanin, pabloid: Fix for Cloning a book page result having menu with has_children flagged if the source book have children pages

Since this _should_ already be fixed, I'm just reopening this and asking what has happened? I would gladly roll a new patch if that's the recommended way forward :)

Letharion’s picture

StatusFileSize
new7.58 KB

Since I wanted to use this, I just re-rolled the patch so I could test it out a bit. I've only done rudimentary testing of this, but what little I've seen works well.

Letharion’s picture

Status: Active » Needs review
Letharion’s picture

StatusFileSize
new7.58 KB

I made a mistake in hook_install.

pwolanin’s picture

Thanks for the patch.

pwolanin’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

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

  • Commit 688db3a on 7.x-1.x, 8.x-1.x by pwolanin:
    Issue #986242 by Letharion: further Drupal 7 updates