protected function add(TreeNode $node, Node $parent)
 {
     $type = NodeType::getByHandle($node->getType());
     $class = $type->getTreeNodeTypeClass();
     $new = call_user_func_array(array($class, 'add'), array($node->getTitle(), $parent));
     foreach ($node->getChildren() as $child) {
         $this->add($child, $new);
     }
 }
Example #2
0
 protected function setUp()
 {
     parent::setUp();
     TreeNodeType::add('group');
     TreeType::add('group');
     GroupTreeType::add();
     $g1 = Group::add(tc("GroupName", "Guest"), tc("GroupDescription", "The guest group represents unregistered visitors to your site."), false, false, GUEST_GROUP_ID);
     $g2 = Group::add(tc("GroupName", "Registered Users"), tc("GroupDescription", "The registered users group represents all user accounts."), false, false, REGISTERED_GROUP_ID);
     $g3 = Group::add(tc("GroupName", "Administrators"), "", false, false, ADMIN_GROUP_ID);
 }
 public static function getListByPackage($pkg)
 {
     $db = Loader::db();
     $list = array();
     $r = $db->Execute('select treeNodeTypeID from TreeNodeTypes where pkgID = ? order by treeNodeTypeID asc', array($pkg->getPackageID()));
     while ($row = $r->FetchRow()) {
         $list[] = TreeNodeType::getByID($row['treeNodeTypeID']);
     }
     $r->Close();
     return $list;
 }
Example #4
0
 /**
  * Creates everything necessary to store files in folders.
  */
 public function create()
 {
     $type = NodeType::getByHandle('file');
     if (!is_object($type)) {
         NodeType::add('file');
     }
     $type = NodeType::getByHandle('file_folder');
     if (!is_object($type)) {
         NodeType::add('file_folder');
     }
     $type = NodeType::getByHandle('search_preset');
     if (!is_object($type)) {
         NodeType::add('search_preset');
     }
     $type = TreeType::getByHandle('file_manager');
     if (!is_object($type)) {
         TreeType::add('file_manager');
     }
     $manager = FileManager::get();
     if (!is_object($manager)) {
         $manager = FileManager::add();
     }
     return $manager;
 }
 public function add_users()
 {
     // Firstly, install the core authentication types
     $cba = AuthenticationType::add('concrete', 'Standard');
     $coa = AuthenticationType::add('community', 'concrete5.org');
     $fba = AuthenticationType::add('facebook', 'Facebook');
     $twa = AuthenticationType::add('twitter', 'Twitter');
     $gat = AuthenticationType::add('google', 'Google');
     $fba->disable();
     $twa->disable();
     $coa->disable();
     $gat->disable();
     \Concrete\Core\Tree\TreeType::add('group');
     \Concrete\Core\Tree\Node\NodeType::add('group');
     $tree = GroupTree::get();
     $tree = GroupTree::add();
     // insert the default groups
     // create the groups our site users
     // specify the ID's since auto increment may not always be +1
     $g1 = Group::add(tc("GroupName", "Guest"), tc("GroupDescription", "The guest group represents unregistered visitors to your site."), false, false, GUEST_GROUP_ID);
     $g2 = Group::add(tc("GroupName", "Registered Users"), tc("GroupDescription", "The registered users group represents all user accounts."), false, false, REGISTERED_GROUP_ID);
     $g3 = Group::add(tc("GroupName", "Administrators"), "", false, false, ADMIN_GROUP_ID);
     // insert admin user into the user table
     if (defined('INSTALL_USER_PASSWORD')) {
         $hasher = new PasswordHash(Config::get('concrete.user.password.hash_cost_log2'), Config::get('concrete.user.password.hash_portable'));
         $uPassword = INSTALL_USER_PASSWORD;
         $uPasswordEncrypted = $hasher->HashPassword($uPassword);
     } else {
         $uPasswordEncrypted = INSTALL_USER_PASSWORD_HASH;
     }
     $uEmail = INSTALL_USER_EMAIL;
     $superuser = UserInfo::addSuperUser($uPasswordEncrypted, $uEmail);
     $u = User::getByUserID(USER_SUPER_ID, true, false);
     MailImporter::add(array('miHandle' => 'private_message'));
     UserPointAction::add('won_badge', t('Won a Badge'), 5, false, true);
     // Install conversation default email
     \Conversation::setDefaultSubscribedUsers(array($superuser));
 }
Example #6
0
 public static function getByID($treeNodeID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select * from TreeNodes where treeNodeID = ?', array($treeNodeID));
     if (is_array($row) && $row['treeNodeID']) {
         $tt = TreeNodeType::getByID($row['treeNodeTypeID']);
         $node = Core::make($tt->getTreeNodeTypeClass());
         $node->setPropertiesFromArray($row);
         $node->loadDetails();
         return $node;
     }
 }
Example #7
0
 public function importChildren(\SimpleXMLElement $sx)
 {
     $xnodes = $sx->children();
     foreach ($xnodes as $xn) {
         $type = NodeType::getByHandle($xn->getName());
         $class = $type->getTreeNodeTypeClass();
         $node = call_user_func_array(array($class, 'importNode'), array($xn, $this));
         call_user_func_array(array($node, 'importChildren'), array($xn));
     }
 }
 protected function addTreeNodeTypes()
 {
     $this->output(t('Adding tree node types...'));
     $this->connection->Execute('update TreeNodeTypes set treeNodeTypeHandle = ? where treeNodeTypeHandle = ?', array('category', 'topic_category'));
     $this->connection->Execute('update PermissionKeys set pkHandle = ? where pkHandle = ?', array('view_category_tree_node', 'view_topic_category_tree_node'));
     $this->connection->Execute('update PermissionKeyCategories set pkCategoryHandle = ? where pkCategoryHandle = ?', array('category_tree_node', 'topic_category_tree_node'));
     $results = NodeType::getByHandle('express_entry_results');
     if (!is_object($results)) {
         NodeType::add('express_entry_results');
     }
     $category = NodeType::getByHandle('express_entry_category');
     if (!is_object($category)) {
         NodeType::add('express_entry_category');
     }
     $results = TreeType::getByHandle('express_entry_results');
     if (!is_object($results)) {
         TreeType::add('express_entry_results');
         $tree = ExpressEntryResults::add();
         $node = $tree->getRootTreeNodeObject();
         // Add forms node beneath it.
         \Concrete\Core\Tree\Node\Type\ExpressEntryCategory::add(ExpressFormBlockController::FORM_RESULTS_CATEGORY_NAME, $node);
     }
 }
Example #9
0
 public static function getNodeByName($name)
 {
     $db = Database::connection();
     $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\'));
     $type = TreeNodeType::getByHandle($treeNodeTypeHandle);
     $treeNodeID = $db->fetchColumn('select treeNodeID from TreeNodes where treeNodeName = ? and treeNodeTypeID = ?', [$name, $type->getTreeNodeTypeID()]);
     if ($treeNodeID) {
         return static::getByID($treeNodeID);
     }
 }