Here is a patch updating the clone link views field handler to work with views 3.
Patches are against both dev and beta1.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tnightingale’s picture

Whoops, forgot to roll patches with latest changes!
Here are working patches

Summit’s picture

Hi, When will a new dev for 7 will be made. I see a version from february 2011..
thanks for going into that.
Subscribing, greetings, Martijn

peterjlord’s picture

Great already done. I was just going to have a go at this one rather than doing at theme level.
Thanks job well done.

RobLoach’s picture

Title: Views "Clone link" field handler update to views 3 » Views "Clone link" field handler for Views 3
Status: Needs review » Reviewed & tested by the community
Issue tags: +Release blocker
FileSize
2.86 KB

Updated, tested, works.

kristof.bourgeois@telenet.be’s picture

Hi,

After installing the patch i get an error when I try to get the clone link into my view.
I've made a table view with all my nodes and I trying to get the posibility to edit , copy and delete the nodes.

the error says:

The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.

Thanks for any help

RobLoach’s picture

Views 3?

kristof.bourgeois@telenet.be’s picture

Yes, I use the last version of Drupal (7.10)

RobLoach’s picture

Status: Reviewed & tested by the community » Needs work
lokolo’s picture

Patch doesnt work for me, after enabling it in views I get an AJAX Error:

Fatal error: Cannot access empty property in /sites/all/modules/node_clone/views/views_handler_field_node_link_clone.inc on line 18

and after saving the view the whole site is unreachable, just get a blank page with the same fatal error message.

Drupal 7 and all Contribute Modules are up to date

kristof.bourgeois@telenet.be’s picture

I had a look at the module but i am not able to fixed it.
I guess we have to wait till it fixed of another module shown up...

kristof.bourgeois@telenet.be’s picture

Hi guys,

This module works perfect with views 3!
The problem was I was forgotten to add the path at the .info file.

jbiechele’s picture

The patch from #4 doesn't work on my project, using node_clone 7.x-1.x-dev and patch #4 applied.
Function clone_access() could not be found.

A suggestion for the code in views_handler_field_node_link_clone.inc:

/**
* Field handler to present a clone node link.
*
* Closely modeled after views/modules/node/views_handler_field_node_link_edit.inc
*/
class views_handler_field_node_link_clone extends views_handler_field_node_link {
 
  /**
   * Renders the link.
   */
  function render_link($node, $values) {
    // Ensure user has permission to clone this node.
    if (!user_access('clone own nodes')) {
      return;
    }

    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['path'] = "node/$node->nid/clone";
    $this->options['alter']['query'] = drupal_get_destination();

    $text = !empty($this->options['text']) ? $this->options['text'] : t('clone');
    return $text;
	}
}

This version works for me as users only have the permission to clone their own nodes.
May be user_access() should be adjusted like that?

    // Ensure user has permission to clone this node.
    if (!user_access('clone any nodes') || !user_access('clone own nodes')) {
      return;
    }
morbiD’s picture

May be user_access() should be adjusted like that?

// Ensure user has permission to clone this node.
if (!user_access('clone any nodes') || !user_access('clone own nodes')) {
  return;
}

Shouldn't that use AND rather than OR? Otherwise a user will need both permissions to see the link. I changed it to the following and it seems to work:

// Ensure user has permission to clone this node.
if (!user_access('clone any nodes') && !user_access('clone own nodes')) {
  return;
}
johnv’s picture

Title: Views "Clone link" field handler for Views 3 » Views 3 "Clone link" field handler
Status: Needs work » Needs review
FileSize
3.2 KB

See attached patch against latest Views -dev version.
It respects 'clone' permissions and resembles more the default 'Edit link'.

pwolanin’s picture

Status: Needs review » Needs work

Looks ok, but there are some commented out lines that shoudl be removed in the views handler:

+  function render_link($node, $values) {
+    // Ensure user has access to edit this node.
+//    if (!node_access('update', $node)) {
+//      return;
+//    }
pwolanin’s picture

Status: Needs work » Fixed
FileSize
3.05 KB

committing this patch

pwolanin’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

backport?

  • Commit 03f8cf1 on 7.x-1.x, 8.x-1.x by pwolanin:
    Issue #1246894 by johnv: updated Clone link field handler for Views 3
    
pwolanin’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes
Status: Patch (to be ported) » Closed (fixed)

I think no backport is worth while