public function getTopicLink(\Concrete\Core\Tree\Node\Node $topic = null)
 {
     if ($this->cParentID) {
         $c = \Page::getByID($this->cParentID);
     } else {
         $c = \Page::getCurrentPage();
     }
     if ($topic) {
         return \URL::page($c, 'topic', strtolower($topic->getTreeNodeDisplayName()));
     } else {
         return \URL::page($c);
     }
 }
 public function getResult($queryRow)
 {
     $f = Node::getByID($queryRow['treeNodeID']);
     if (is_object($f) && $this->checkPermissions($f)) {
         return $f;
     }
 }
Example #3
0
 public function add()
 {
     $filesystem = new Filesystem();
     if ($this->request->request->has('currentFolder')) {
         $node = Node::getByID($this->request->request->get('currentFolder'));
         if (is_object($node) && $node instanceof FileFolder) {
             $folder = $node;
         }
     }
     if (!isset($folder)) {
         $folder = $filesystem->getRootFolder();
     }
     $permissions = new \Permissions($folder);
     $error = $this->app->make('error');
     $response = new EditResponse();
     $response->setError($error);
     if (!$permissions->canAddTreeSubNode()) {
         $error->add(t('You do not have permission to add a folder here.'));
     }
     if (!$error->has()) {
         $folder = $filesystem->addFolder($folder, $this->request->request->get('folderName'));
         $response->setMessage(t('Folder added.'));
         $response->setAdditionalDataAttribute('folder', $folder);
     }
     $response->outputJSON();
 }
 protected function renderList($treeNodeParentID = null)
 {
     $nodes = null;
     $parent = null;
     if ($treeNodeParentID) {
         $parent = Node::getByID($treeNodeParentID);
         if (is_object($parent)) {
             $tree = $parent->getTreeObject();
             if (!$tree instanceof ExpressEntryResults) {
                 unset($parent);
             }
         }
     }
     if (!isset($parent)) {
         $parent = $this->getResultsTreeNodeObject();
     }
     $this->set('breadcrumb', $this->getBreadcrumb($parent));
     if (isset($parent) && $parent instanceof \Concrete\Core\Tree\Node\Type\ExpressEntryResults) {
         // Get the express entry for which this applies.
         $entity = $this->entityManager->getRepository('Concrete\\Core\\Entity\\Express\\Entity')->findOneByResultsNode($parent);
         $search = new \Concrete\Controller\Search\Express\Entries();
         $search->search($entity);
         $this->set('list', $search->getListObject());
         $this->set('searchController', $search);
         $this->set('entity', $entity);
         $this->render('/dashboard/express/entries/entries', false);
     } else {
         $parent->populateDirectChildrenOnly();
         $this->set('nodes', $parent->getChildNodes());
         $this->render('/dashboard/express/entries/folder', false);
     }
 }
Example #5
0
 public static function add($treeNodeTopicName, $parent = false)
 {
     $db = Loader::db();
     $node = parent::add($parent);
     $node->setTreeNodeTopicName($treeNodeTopicName);
     return $node;
 }
Example #6
0
 public function remove_tree_node()
 {
     if ($this->token->validate('remove_tree_node')) {
         $node = TreeNode::getByID(Loader::helper('security')->sanitizeInt($_POST['treeNodeID']));
         $tree = $node->getTreeObject();
         $treeNodeID = $node->getTreeNodeID();
         if (!is_object($node)) {
             $this->error->add(t('Invalid node.'));
         }
         if ($node->getTreeNodeParentID() == 0) {
             $this->error->add(t('You may not remove the top level node.'));
         }
         $np = new Permissions($node);
         if (!$np->canDeleteTreeNode()) {
             $this->error->add(t('You may not remove this node.'));
         }
         if ($tree->getTreeTypeHandle() != 'topic') {
             $this->error->add(t('Invalid tree type.'));
         }
         if (!$this->error->has()) {
             $node->delete();
             $r = new \stdClass();
             $r->treeNodeID = $treeNodeID;
             Loader::helper('ajax')->sendResult($r);
         }
     } else {
         $this->error->add($this->token->getErrorMessage());
     }
     if ($this->error->has()) {
         Loader::helper('ajax')->sendError($this->error);
     }
 }
Example #7
0
 public function move()
 {
     $this->search();
     $gParentNodeID = Loader::helper('security')->sanitizeInt($_REQUEST['gParentNodeID']);
     if ($gParentNodeID) {
         $node = TreeNode::getByID($gParentNodeID);
     }
     if (!$node instanceof GroupTreeNode) {
         $this->error->add(t("Invalid target parent group."));
     }
     $selectedGroups = array();
     if (is_array($_POST['gID'])) {
         foreach ($_POST['gID'] as $gID) {
             $group = Group::getByID($gID);
             if (is_object($group)) {
                 $selectedGroups[] = $group;
             }
         }
     }
     if (count($selectedGroups) == 0) {
         $this->error->add(t("You must select at least one group to move"));
     }
     if (!$this->error->has()) {
         $gParent = $node->getTreeNodeGroupObject();
         $this->set('selectedGroups', $selectedGroups);
         $this->set('gParent', $gParent);
         $this->set('gParentNode', $node);
     }
 }
Example #8
0
 protected function getNode()
 {
     if (!isset($this->node)) {
         $this->node = \Concrete\Core\Tree\Node\Node::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['treeNodeID']));
     }
     return $this->node;
 }
 protected function getNodes()
 {
     $sourceNodes = array();
     if (!isset($this->nodes)) {
         if (isset($_REQUEST['sourceTreeNodeID'])) {
             $sourceNode = Node::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['sourceTreeNodeID']));
             if (is_object($sourceNode)) {
                 $sourceNodes[] = $sourceNode;
             }
         } else {
             if (isset($_REQUEST['sourceTreeNodeIDs'])) {
                 foreach ($_REQUEST['sourceTreeNodeIDs'] as $sourceTreeNodeID) {
                     $sourceNode = Node::getByID(Loader::helper('security')->sanitizeInt($sourceTreeNodeID));
                     if (is_object($sourceNode)) {
                         $sourceNodes[] = $sourceNode;
                     }
                 }
             }
         }
         $destNode = Node::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['treeNodeParentID']));
         if (is_array($sourceNodes) && count($sourceNodes) && is_object($destNode)) {
             $this->nodes = array($sourceNodes, $destNode);
         } else {
             $this->nodes = false;
         }
     }
     return $this->nodes;
 }
Example #10
0
 /**
  * @param $entity ExpressEntity
  * @param \SimpleXMLElement $xml
  */
 public function export($entity, \SimpleXMLElement $xml)
 {
     $node = $xml->addChild('entity');
     $node->addAttribute('id', $entity->getID());
     $node->addAttribute('handle', $entity->getHandle());
     $node->addAttribute('plural_handle', $entity->getPluralHandle());
     $node->addAttribute('name', $entity->getName());
     $node->addAttribute('include_in_public_list', $entity->getIncludeInPublicList() ? '1' : '');
     $node->addAttribute('description', h($entity->getDescription()));
     $node->addAttribute('default_view_form', $entity->getDefaultViewForm()->getID());
     $node->addAttribute('default_edit_form', $entity->getDefaultEditForm()->getID());
     $results = Node::getByID($entity->getEntityResultsNodeId());
     if (is_object($results)) {
         $parent = $results->getTreeNodeParentObject();
         $path = $parent->getTreeNodeDisplayPath();
         $node->addAttribute('results-folder', $path);
     }
     $associations = $entity->getAssociations();
     if (count($associations)) {
         $asn = $node->addChild('associations');
         foreach ($associations as $association) {
             $exporter = $association->getExporter();
             $exporter->export($association, $asn);
         }
     }
     $forms = $entity->getForms();
     if (count($forms)) {
         $fsn = $node->addChild('forms');
         foreach ($forms as $form) {
             $exporter = $form->getExporter();
             $exporter->export($form, $fsn);
         }
     }
     return $node;
 }
Example #11
0
 public function postRemove(Entity $entity, LifecycleEventArgs $event)
 {
     $node = Node::getByID($entity->getEntityResultsNodeId());
     if (is_object($node)) {
         $node->delete();
     }
 }
Example #12
0
 public function getTopicLink(\Concrete\Core\Tree\Node\Node $topic = null)
 {
     if ($this->cParentID) {
         $c = \Page::getByID($this->cParentID);
     } else {
         $c = \Page::getCurrentPage();
     }
     if ($topic) {
         $nodeName = $topic->getTreeNodeName();
         $nodeName = strtolower($nodeName);
         // convert to lowercase
         $nodeName = Core::make('helper/text')->encodePath($nodeName);
         // urlencode
         return \URL::page($c, 'topic', $topic->getTreeNodeID(), $nodeName);
     } else {
         return \URL::page($c);
     }
 }
Example #13
0
 public static function add($group = false, $parent = false)
 {
     $db = Loader::db();
     $node = parent::add($parent);
     if (is_object($group)) {
         $node->setTreeNodeGroup($group);
     }
     return $node;
 }
Example #14
0
 public function getTreeNodeJSON()
 {
     $node = TreeNode::getTreeNodeJSON();
     if ($node) {
         $node->isFolder = true;
         $node->resultsThumbnailImg = $this->getListFormatter()->getIconElement();
     }
     return $node;
 }
 /**
  * @param TopicTreeNode $node
  */
 public function setPermissionObject($node)
 {
     $this->permissionObject = $node;
     if ($node->overrideParentTreeNodePermissions()) {
         $this->permissionObjectToCheck = $node;
     } else {
         $parent = Node::getByID($node->getTreeNodePermissionsNodeID());
         $this->permissionObjectToCheck = $parent;
     }
 }
Example #16
0
 public function getSelectedTopicNodes()
 {
     $topics = array();
     foreach ($this->topics as $selectedTopic) {
         $node = Node::getByID($selectedTopic->getTreeNodeID());
         if (is_object($node)) {
             $topics[] = $node;
         }
     }
     return $topics;
 }
 protected function getExpressNodePermissions()
 {
     /**
      * @var $entry Entry
      */
     $entity = $this->getPermissionObject();
     if (is_object($entity)) {
         $node = Node::getByID($entity->getEntityResultsNodeId());
         return new Permissions($node);
     }
 }
Example #18
0
 public function load()
 {
     $tree = $this->getTree();
     if (is_array($this->request->request('treeNodeSelectedIDs'))) {
         $selectedIDs = [];
         foreach ($this->request->request('treeNodeSelectedIDs') as $nID) {
             $node = Node::getByID($nID);
             if ($node !== null && $node->getTreeID() == $tree->getTreeID()) {
                 $selectedIDs[] = $node->getTreeNodeID();
             }
         }
         $tree->setSelectedTreeNodeIDs($selectedIDs);
     }
     $tree->setRequest($this->request->request());
     $result = $tree->getJSON();
     return new JsonResponse($result);
 }
Example #19
0
 public function do_add()
 {
     $txt = $this->app->make('helper/text');
     $valt = $this->app->make('helper/validation/token');
     $gName = $txt->sanitize($this->request->post('gName'));
     $gDescription = $this->request->post('gDescription');
     if (!$gName) {
         $this->error->add(t("Name required."));
     }
     if (!$valt->validate('add_or_update_group')) {
         $this->error->add($valt->getErrorMessage());
     }
     if ($this->request->post('gIsBadge')) {
         if (!$this->post('gBadgeDescription')) {
             $this->error->add(t('You must specify a description for this badge. It will be displayed publicly.'));
         }
     }
     $parentGroup = null;
     if ($this->request->post('gParentNodeID')) {
         $parentGroupNode = TreeNode::getByID($this->request->post('gParentNodeID'));
         if ($parentGroupNode instanceof GroupTreeNode) {
             $parentGroup = $parentGroupNode->getTreeNodeGroupObject();
         }
     }
     if (is_object($parentGroup)) {
         $pp = new \Permissions($parentGroup);
         if (!$pp->canAddSubGroup()) {
             $this->error->add(t('You do not have permission to add a group beneath %s', $parentGroup->getGroupDisplayName()));
         }
     }
     if (!$this->error->has()) {
         $g = ConcreteGroup::add($gName, $this->request->post('gDescription'), $parentGroup);
         $this->checkExpirationOptions($g);
         $this->checkBadgeOptions($g);
         $this->checkAutomationOptions($g);
         $this->redirect('/dashboard/users/groups', 'group_added');
     }
     $this->view();
 }
Example #20
0
 public function move()
 {
     $this->search();
     $gParentNodeID = $this->app->make('helper/security')->sanitizeInt($this->request('gParentNodeID'));
     $gParentNode = $gParentNodeID ? TreeNode::getByID($gParentNodeID) : null;
     if (!$gParentNode instanceof GroupTreeNode) {
         $gParentNode = null;
         $this->error->add(t("Invalid target parent group."));
     }
     $selectedGroups = [];
     if (is_array($this->post('gID'))) {
         foreach ($this->post('gID') as $gID) {
             $group = Group::getByID($gID);
             if ($group !== null) {
                 $groupNode = GroupTreeNode::getTreeNodeByGroupID($group->getGroupID());
                 if ($groupNode !== null) {
                     if ($gParentNode !== null) {
                         $error = $groupNode->checkMove($gParentNode);
                         if ($error !== null) {
                             $this->error->add($error);
                         }
                     }
                     $selectedGroups[] = $group;
                 }
             }
         }
     }
     if (empty($selectedGroups)) {
         $this->error->add(t("You must select at least one group to move"));
     }
     if (!$this->error->has()) {
         $gParent = $gParentNode->getTreeNodeGroupObject();
         $this->set('selectedGroups', $selectedGroups);
         $this->set('gParent', $gParent);
         $this->set('gParentNode', $gParentNode);
     }
 }
Example #21
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$form = Loader::helper('form');
$node = \Concrete\Core\Tree\Node\Node::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['treeNodeID']));
$np = new Permissions($node);
$tree = $node->getTreeObject();
$canEdit = is_object($node) && $node->getTreeNodeTypeHandle() == 'topic' && $np->canEditTreeNode();
$url = View::url('/dashboard/system/attributes/topics', 'update_topic_node');
$al = Loader::helper("concrete/asset_library");
if ($canEdit) {
    ?>

	<div class="ccm-ui">
		<form method="post" data-topic-form="update-topic-node" class="form-horizontal" action="<?php 
    echo $url;
    ?>
">
			<?php 
    echo Loader::helper('validation/token')->output('update_topic_node');
    ?>
			<input type="hidden" name="treeNodeID" value="<?php 
    echo $node->getTreeNodeID();
    ?>
" />
			<div class="form-group">
				<?php 
    echo $form->label('treeNodeTopicName', t('Topic'));
    ?>
				<?php 
    echo $form->text('treeNodeTopicName', $node->getTreeNodeDisplayName(), array('class' => 'span4'));
Example #22
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Tree\Node\Node as TreeNode;
if ($_REQUEST['treeNodeID'] > 0) {
    $node = TreeNode::getByID($_REQUEST['treeNodeID']);
    $np = new Permissions($node);
    if ($np->canEditTreeNodePermissions()) {
        Loader::element('permission/details/tree/node', array("node" => $node));
    }
}
Example #23
0
 public function getValue()
 {
     $nodes = $this->getSelectedOptions();
     $topics = array();
     foreach ($nodes as $node) {
         $topic = Node::getByID($node);
         if (is_object($topic)) {
             $topics[] = $topic;
         }
     }
     return $topics;
 }
Example #24
0
 public function upload()
 {
     /** @type ResponseFactory $responseFactory */
     $responseFactory = $this->app->make(ResponseFactory::class);
     try {
         $folder = null;
         if ($this->request->request->has('currentFolder')) {
             $node = Node::getByID($this->request->request->get('currentFolder'));
             if ($node instanceof FileFolder) {
                 $folder = $node;
             }
         }
         if ($folder) {
             $fp = new \Permissions($folder);
         } else {
             $fp = FilePermissions::getGlobal();
         }
         if (!$fp->canAddFiles()) {
             throw new Exception(t("Unable to add files."), 400);
         }
         if ($post_max_size = \Loader::helper('number')->getBytes(ini_get('post_max_size'))) {
             if ($post_max_size < $_SERVER['CONTENT_LENGTH']) {
                 throw new Exception(FileImporter::getErrorMessage(Importer::E_FILE_EXCEEDS_POST_MAX_FILE_SIZE), 400);
             }
         }
         if (!Loader::helper('validation/token')->validate()) {
             throw new Exception(Loader::helper('validation/token')->getErrorMessage(), 401);
         }
         if (isset($_FILES['file'])) {
             $files = $this->handleUpload('file', $folder);
         }
         if (isset($_FILES['files']['tmp_name'][0])) {
             $files = array();
             for ($i = 0; $i < count($_FILES['files']['tmp_name']); ++$i) {
                 $files = array_merge($files, $this->handleUpload('files', $folder, $i));
             }
         }
     } catch (Exception $e) {
         if ($code = $e->getCode()) {
             return $responseFactory->error($e->getMessage(), $code);
         }
         // This error doesn't have a code, it's likely not what we're wanting.
         throw $e;
     }
     return $responseFactory->json($files);
 }
Example #25
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Tree\Node\Node as TreeNode;
?>
<div id="topics-tree-node-permissions">
<?php 
$handle = $node->getPermissionObjectKeyCategoryHandle();
$enablePermissions = false;
if (!$node->overrideParentTreeNodePermissions()) {
    $permNode = TreeNode::getByID($node->getTreeNodePermissionsNodeID());
    ?>

	<div class="alert alert-info">
	<?php 
    echo t("Permissions for this node are currently inherited from <strong>%s</strong>.", $permNode->getTreeNodeDisplayName());
    ?>
	<br/><br/>
	<a href="javascript:void(0)" class="btn btn-sm btn-warning" onclick="TopicsPermissions.setTreeNodePermissionsToOverride()"><?php 
    echo t('Override Permissions');
    ?>
</a>
	</div>
	
<?php 
} else {
    $enablePermissions = true;
    ?>

	<div class="alert alert-info">
	<?php 
Example #26
0
 public function edit()
 {
     $this->loadResultsFolderInformation();
     $this->requireAsset('core/tree');
     $this->clearSessionControls();
     $list = Type::getList();
     $attribute_fields = array();
     foreach ($list as $type) {
         $attribute_fields[] = ['id' => 'attribute_key|' . $type->getAttributeTypeID(), 'displayName' => $type->getAttributeTypeDisplayName()];
     }
     $select = array();
     $select[0] = new \stdClass();
     $select[0]->label = t('Input Field Types');
     $select[0]->fields = $attribute_fields;
     $other_fields = array();
     $other_fields[] = ['id' => 'entity_property|text', 'displayName' => t('Display Text')];
     $select[1] = new \stdClass();
     $select[1]->label = t('Other Fields');
     $select[1]->fields = $other_fields;
     $controls = array();
     $form = $this->getFormEntity();
     if (is_object($form)) {
         $entity = $form->getEntity();
         $controls = $form->getControls();
         $this->set('formName', $entity->getName());
         $this->set('submitLabel', $this->submitLabel);
         $node = Node::getByID($entity->getEntityResultsNodeId());
         if (is_object($node)) {
             $folder = $node->getTreeNodeParentObject();
             $this->set('resultsFolder', $folder->getTreeNodeID());
         }
     }
     $this->set('controls', $controls);
     $this->set('types_select', $select);
     $tree = ExpressEntryResults::get();
     $this->set('tree', $tree);
 }
Example #27
0
 public function move(Node $newParent)
 {
     $db = Loader::db();
     $treeNodeDisplayOrder = $db->GetOne('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', array($newParent->getTreeNodeID()));
     if (!$treeNodeDisplayOrder) {
         $treeNodeDisplayOrder = 0;
     }
     $db->Execute('update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?', array($newParent->getTreeNodeID(), $treeNodeDisplayOrder, $this->treeNodeID));
     if (!$this->overrideParentTreeNodePermissions()) {
         $db->Execute('update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?', array($newParent->getTreeNodePermissionsNodeID(), $this->treeNodeID));
     }
     $oldParent = $this->getTreeNodeParentObject();
     if (is_object($oldParent)) {
         $oldParent->rescanChildrenDisplayOrder();
     }
     $newParent->rescanChildrenDisplayOrder();
     $this->treeNodeParentID = $newParent->getTreeNodeID();
     $this->treeNodeDisplayOrder = $treeNodeDisplayOrder;
 }
Example #28
0
 public static function add($treeNodeCategoryName = '', $parent = false)
 {
     $node = parent::add($parent);
     $node->setTreeNodeCategoryName($treeNodeCategoryName);
     return $node;
 }
Example #29
0
 public static function add($file = false, $parent = false)
 {
     $node = parent::add($parent);
     if (is_object($file)) {
         $node->setTreeNodeFile($file);
     }
     return $node;
 }
Example #30
0
 protected static function create(TreeNode $rootNode)
 {
     $app = Application::getFacadeApplication();
     $db = $app->make('database')->connection();
     $date = $app->make('date')->getOverridableNow();
     $treeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\'));
     $type = TreeType::getByHandle($treeTypeHandle);
     $db->executeQuery('insert into Trees (treeDateAdded, rootTreeNodeID, treeTypeID) values (?, ?, ?)', [$date, $rootNode->getTreeNodeID(), $type->getTreeTypeID()]);
     $treeID = $db->lastInsertId();
     $rootNode->setTreeNodeTreeID($treeID);
     return $treeID;
 }