Example #1
0
 /**
  * @param string $permission
  * @param Wiki   $wiki
  *
  * @return bool
  */
 public function isUserGranted($permission, Wiki $wiki, $collection = null)
 {
     if ($collection === null) {
         $collection = new ResourceCollection([$wiki->getResourceNode()]);
     }
     $checkPermission = false;
     if ($this->get('security.authorization_checker')->isGranted($permission, $collection)) {
         $checkPermission = true;
     }
     return $checkPermission;
 }
 /**
  * @param Wiki    $wiki
  * @param Section $section
  */
 public function __construct(Wiki $wiki, Section $section)
 {
     $details = array('section' => array('wiki' => $wiki->getId(), 'id' => $section->getId(), 'title' => $section->getActiveContribution()->getTitle(), 'text' => $section->getActiveContribution()->getText(), 'author' => $section->getAuthor()->getFirstName() . ' ' . $section->getAuthor()->getLastName()));
     parent::__construct($wiki->getResourceNode(), $details);
 }
 /**
  * @param Wiki    $wiki
  * @param Section $section
  * @param array   $changeSet
  */
 public function __construct(Wiki $wiki, Section $section, $changeSet)
 {
     $details = array('section' => array('wiki' => $wiki->getId(), 'id' => $section->getId(), 'title' => $section->getActiveContribution()->getTitle(), 'text' => $section->getActiveContribution()->getText(), 'visible' => $section->getVisible(), 'changeSet' => $changeSet));
     parent::__construct($wiki->getResourceNode(), $details);
 }
 /**
  * @param Wiki    $wiki
  * @param Section $section
  */
 public function __construct(Wiki $wiki, Section $section)
 {
     $this->wiki = $wiki;
     $this->details = array('section' => array('wiki' => $wiki->getId(), 'id' => $section->getId(), 'title' => $section->getActiveContribution()->getTitle(), 'text' => $section->getActiveContribution()->getText(), 'visible' => $section->getVisible()));
     parent::__construct($wiki->getResourceNode(), $this->details);
 }
 /**
  * @param Wiki    $wiki
  * @param Section $section
  * @param array   $changeSet
  */
 public function __construct(Wiki $wiki, $changeSet)
 {
     $details = array('wiki' => array('wiki' => $wiki->getId(), 'changeSet' => $changeSet));
     parent::__construct($wiki->getResourceNode(), $details);
 }
Example #6
0
 /**
  * Exports a Wiki resource
  * according to the description found in WikiImporter.
  *
  * @param Workspace $workspace
  * @param array     $files
  * @param Wiki      $object
  *
  * @return array
  */
 public function exportWiki(Workspace $workspace, array &$files, Wiki $object)
 {
     // Getting all sections and building array
     $rootSection = $object->getRoot();
     $sections = $this->sectionRepository->children($rootSection);
     array_unshift($sections, $rootSection);
     $sectionsArray = array();
     foreach ($sections as $section) {
         //Getting all contributions and building contributions array
         $activeContribution = $section->getActiveContribution();
         $contributions = $this->contributionRepository->findAllButActiveForSection($section);
         $contributionsArray = array();
         array_unshift($contributions, $activeContribution);
         foreach ($contributions as $contribution) {
             $uid = uniqid() . '.txt';
             $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $uid;
             file_put_contents($tmpPath, $contribution->getText());
             $files[$uid] = $tmpPath;
             $contributionArray = array('is_active' => $contribution->getId() == $activeContribution->getId(), 'title' => $contribution->getTitle(), 'contributor' => $contribution->getContributor()->getUsername(), 'creation_date' => $contribution->getCreationDate(), 'path' => $uid);
             $contributionsArray[] = array('contribution' => $contributionArray);
         }
         $sectionArray = array('id' => $section->getId(), 'parent_id' => $section->getParent() !== null ? $section->getParent()->getId() : null, 'is_root' => $section->isRoot(), 'visible' => $section->getVisible(), 'creation_date' => $section->getCreationDate(), 'author' => $section->getAuthor()->getUsername(), 'deleted' => $section->getDeleted(), 'deletion_date' => $section->getDeletionDate(), 'contributions' => $contributionsArray);
         $sectionsArray[] = $sectionArray;
     }
     $data = array('options' => array('mode' => $object->getMode()), 'sections' => $sectionsArray);
     return $data;
 }
 /**
  * @param Wiki         $wiki
  * @param Section      $section
  * @param Contribution $contribution
  */
 public function __construct(Wiki $wiki, Section $section, Contribution $contribution)
 {
     $this->wiki = $wiki;
     $this->details = array('contribution' => array('wiki' => $wiki->getId(), 'section' => $section->getId(), 'id' => $contribution->getId(), 'title' => $contribution->getTitle(), 'text' => $contribution->getText(), 'contributor' => $contribution->getContributor()->getFirstName() . ' ' . $contribution->getContributor()->getLastName()));
     parent::__construct($wiki->getResourceNode(), $this->details);
 }
 public function findDeletedSectionsQuery(Wiki $wiki)
 {
     $queryBuilder = $this->createQueryBuilder('section')->join('section.activeContribution', 'contribution')->select('section, contribution')->andWhere('section.root = :rootId')->andWhere('section.deleted = :deleted')->orderBy('section.deletionDate', 'ASC')->setParameter('deleted', true)->setParameter('rootId', $wiki->getRoot()->getId());
     return $queryBuilder->getQuery();
 }
Example #9
0
 /**
  * @param Wiki  $wiki
  * @param array $changeSet
  *
  * @return Controller
  */
 protected function dispatchWikiUpdateEvent(Wiki $wiki, $changeSet)
 {
     $event = new LogResourceUpdateEvent($wiki->getResourceNode(), $changeSet);
     return $this->dispatch($event);
 }