/** * Check if this member can move archive into the environment. * * @param DNEnvironment $targetEnv Environment to check. * @param Member|null $member The {@link Member} object to test against. If null, uses Member::currentMember(); * * @return boolean true if $member can upload archives linked to this environment, false if they can't. */ public function canMoveTo($targetEnv, $member = null) { if ($this->Environment()->Project()->ID != $targetEnv->Project()->ID) { // We don't permit moving snapshots between projects at this stage. return false; } if (!$member) { $member = Member::currentUser(); } // Must be logged in to check permissions if (!$member) { return false; } // Admin can always move. if (Permission::checkMember($member, 'ADMIN')) { return true; } // Checks if the user can actually access the archive. if (!$this->canDownload($member)) { return false; } // Hooks into ArchiveUploaders permission to prevent proliferation of permission checkboxes. // Bypasses the quota check - we don't need to check for it as long as we move the snapshot within the project. return $targetEnv->ArchiveUploaders()->byID($member->ID) || $member->inGroups($targetEnv->ArchiveUploaderGroups()); }