package hudson.plugins.copyProjectLink;

import hudson.model.Action;
import hudson.model.AbstractProject;
import hudson.model.Hudson;

public class CopyProjectAction implements Action {

	final private AbstractProject<?, ?> project;

	public CopyProjectAction(AbstractProject project) {
		this.project = project;
	}

	public String getCloneName() {
		return project.getDisplayName() + "-clone";
	}

	public String getProjectName() {
		return project.getDisplayName();
	}

	public String getIconFileName() {
		if (hasPermission()) {
			return "/plugin/copy-project-link/img/edit-copy.png";
		}
		return null;
	}

	public String getDisplayName() {
		if (hasPermission()) {
			return "Copy project";
		}
		return null;
	}

	public String getUrlName() {
		if(hasPermission()) {
			return "copy-project";
		}
		return null;
	}

	private boolean hasPermission(){
		return Hudson.getInstance().hasPermission(project.CONFIGURE);
	}
	
}

@@ -62,16 +62,73 @@
 Action;%0A
+import hudson.model.Item;%0Aimport hudson.model.ItemGroup;%0A
 import h
@@ -183,16 +183,57 @@
 .Hudson;
+%0Aimport hudson.security.AccessControlled;
 %0A%0Apublic
@@ -948,18 +948,242 @@
 sion()%7B%0A
-%09%09
+    ItemGroup parent = project.getParent();%0A    if (parent instanceof AccessControlled) %7B%0A      AccessControlled accessControlled = (AccessControlled)parent;%0A      return accessControlled.hasPermission(Item.CREATE);%0A    %7D%0A    
 return H
@@ -1220,24 +1220,18 @@
 ion(
-project.CONFIGUR
+Item.CREAT
 E);%0A

Use static Item.CREATE rather than Item.CONFIGURE and check permission from the given container.