예제 #1
0
 /**
  * Copy a resource node.
  *
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $newParent
  * @param \Claroline\CoreBundle\Entity\User                  $user
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $last
  * @param boolean $withRights
  * Defines if the rights of the copied node have to be created
  * @param array $rights
  * If defined, the copied node will have exactly the given rights
  *
  * @return \Claroline\CoreBundle\Entity\Resource\ResourceNode
  */
 private function copyNode(ResourceNode $node, ResourceNode $newParent, User $user, $withRights = true, array $rights = array(), $index = null)
 {
     $newNode = $this->om->factory('Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode');
     $newNode->setResourceType($node->getResourceType());
     $newNode->setCreator($user);
     $newNode->setWorkspace($newParent->getWorkspace());
     $newNode->setParent($newParent);
     $newParent->addChild($newNode);
     $newNode->setName($this->getUniqueName($node, $newParent, true));
     $newNode->setIcon($node->getIcon());
     $newNode->setClass($node->getClass());
     $newNode->setMimeType($node->getMimeType());
     $newNode->setAccessibleFrom($node->getAccessibleFrom());
     $newNode->setAccessibleUntil($node->getAccessibleUntil());
     $newNode->setPublished($node->isPublished());
     $newNode->setLicense($node->getLicense());
     $newNode->setAuthor($node->getAuthor());
     $newNode->setIndex($index);
     if ($withRights) {
         //if everything happens inside the same workspace and no specific rights have been given,
         //rights are copied
         if ($newParent->getWorkspace() === $node->getWorkspace() && count($rights) === 0) {
             $this->rightsManager->copy($node, $newNode);
         } else {
             //otherwise we use the parent rights or the given rights if not empty
             $this->setRights($newNode, $newParent, $rights);
         }
     }
     $this->om->persist($newNode);
     return $newNode;
 }
예제 #2
0
 /**
  * Check that all Activities and Resources as at least same rights than the Path
  * @return \Innova\PathBundle\Manager\PublishingManager
  */
 protected function manageRights()
 {
     // Grab Resources and Activities
     $nodes = $this->retrieveAllNodes($this->path->getSteps()->toArray());
     if (!empty($nodes)) {
         $pathRights = $this->path->getResourceNode()->getRights();
         foreach ($nodes as $node) {
             foreach ($pathRights as $right) {
                 if ($right->getMask() & 1) {
                     $this->rightsManager->editPerms($right->getMask(), $right->getRole(), $node, true);
                 }
             }
         }
     }
     return $this;
 }