public function isSharedWith(Bubble $bubble = null, $depth = 0)
 {
     if ($depth > 20) {
         return false;
     }
     if (!$bubble) {
         return true;
     }
     if (!$this->getAuthService()->hasIdentity()) {
         return false;
     }
     if (empty($bubble->getShares())) {
         return false;
     }
     foreach ($bubble->getShares() as $share) {
         /* @var $share \BubblePle\Entity\BubbleShare */
         if ($share->getSharedWith() == $this->getAuthService()->getIdentity()) {
             return true;
         }
     }
     $parents = $bubble->getParents();
     foreach ($parents as $parent) {
         if ($this->isSharedWith($parent->getFrom(), $depth + 1)) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Returns data to show in json
  * @return array
  */
 public function jsonSerialize()
 {
     $data = parent::jsonSerialize();
     return array_merge($data, array('year' => $this->getYear(), 'isWinter' => $this->getIsWinter()));
 }
Exemplo n.º 3
0
 /**
  * Returns data to show in json
  * @return array
  */
 public function jsonSerialize()
 {
     $data = parent::jsonSerialize();
     return array_merge($data, array('courseroom' => $this->getCourseroom()));
 }
Exemplo n.º 4
0
 protected function syncMaterialTree($materialTree, Bubble $parent, $cid)
 {
     $em = $this->getEntityManager();
     $l2p = $this->getClient();
     $owner = $this->getAuthService()->getIdentity();
     foreach ($materialTree as $material) {
         // find child matching material
         $children = $parent->getChildren();
         $found = null;
         if ($children) {
             foreach ($children as $child) {
                 /* @var $child Edge */
                 $childBubble = $child->getTo();
                 if ($material->isDirectory && $childBubble instanceof L2PMaterialFolder && $childBubble->getL2pItemId() == $material->itemId || !$material->isDirectory && $childBubble instanceof L2PMaterialAttachment && $childBubble->getL2pItemId() == $material->itemId) {
                     $found = $childBubble;
                     break;
                 }
             }
         }
         if (!$found) {
             if ($material->isDirectory) {
                 $instance = new L2PMaterialFolder();
             } else {
                 $instance = new L2PMaterialAttachment();
                 $instance->setFilename($this->getMaterialDownloadUrl($material, $cid));
             }
             $instance->setL2pItemId($material->itemId)->setTitle($material->name)->setOwner($owner);
             $em->persist($instance);
             $em->flush($instance);
             $edge = new Edge();
             $edge->setFrom($parent)->setTo($instance);
             $em->persist($edge);
             $em->flush($edge);
             $found = $instance;
         } else {
             $found->setTitle($material->name);
             if (!$material->isDirectory) {
                 $found->setFilename($this->getMaterialDownloadUrl($material, $cid));
             }
             $em->flush($found);
         }
         if ($material->isDirectory) {
             $this->syncMaterialTree($material->children, $found, $cid);
         }
     }
     return true;
 }