/** * Get all child pigeonholes starting from any parent * * @param array $pContentId of the pigoenhole * @param array $pStructureId of the pigeonhole * @access public * @return array of child pigeonholes on success, empty array on failure */ function getSubPigeonholes($pContentId = NULL, $pStructureId = NULL) { global $gStructure; $ret = array(); if (empty($gStructure)) { $struct = new LibertyStructure(); } else { $struct =& $gStructure; } if (@BitBase::verifyId($pContentId) && !@BitBase::verifyId($pStructureId)) { $pigeon = $struct->getNode(NULL, $pContentId); $pStructureId = $pigeon['structure_id']; } if (@BitBase::verifyId($pStructureId)) { $tree = $struct->getSubTree($pStructureId); // weed out duplicates foreach ($tree as $pigeon) { if (!in_array($pigeon['content_id'], array_keys($ret))) { $ret[$pigeon['content_id']] = $pigeon; } } } return $ret; }
if ($gBitSystem->isPackageActive('pigeonholes')) { require_once PIGEONHOLES_PKG_PATH . 'Pigeonholes.php'; $p = new Pigeonholes(); $s = new LibertyStructure(); // Prep get list screws with us. $listHash = array('load_only_root' => TRUE, 'sort_mode' => 'lc.title_asc', 'offset' => 0, 'max_records' => '999999', 'find' => ''); if (!empty($module_params['root_structure_id'])) { $listHash['root_structure_id'] = $module_params['root_structure_id']; } if (!empty($module_params['structure_id'])) { $l = array(array('structure_id' => $module_params['structure_id'])); } else { $l = $p->getList($listHash); } foreach ($l as $e) { $d = $s->getSubTree($e['structure_id']); $d_o = array(); foreach ($d as $c) { $pos_var =& $d_o; if ($c['level'] != 0) { $pos = explode(".", $c['pos']); $pos_var =& $d_o; foreach ($pos as $pos_v) { if (!isset($pos_var['children'])) { $pos_var['children'] = array(); } if (!isset($pos_var['children'][$pos_v - 1])) { $pos_var['children'][$pos_v - 1] = array(); } $pos_var =& $pos_var['children'][$pos_v - 1]; }
/** * Imports a structure from liberty_structures to nexus including hierarchy * @return number of errors encountered */ function importStructure($pStructureId = NULL) { if ($pStructureId || !is_numeric($pStructureId)) { include_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $structure = new LibertyStructure($pStructureId); $structure->load(); // order matters for these conditionals if (empty($structure) || !$structure->isValid()) { $this->mErrors['structure'] = tra('Invalid structure'); } if ($structure->mInfo['root_structure_id'] == $structure->mInfo['structure_id']) { $rootStructure =& $structure; } else { $rootStructure = new LibertyStructure($structure->mInfo['root_structure_id']); $rootStructure->load(); } $structureList = $rootStructure->getSubTree($rootStructure->mInfo['structure_id']); $menuHash['title'] = $rootStructure->mInfo['title']; if ($menu_id = $this->storeMenu($menuHash)) { // we need to insert the structure title manually, as this is not part of the structure $itemHash = array('menu_id' => $menu_id, 'title' => $rootStructure->mInfo['title'], 'pos' => 1, 'parent_id' => 0, 'rsrc' => $rootStructure->mInfo['structure_id'], 'rsrc_type' => 'structure_id'); $storedItem = $this->storeItem($itemHash); // insert all nodes in structure as menu items foreach ($structureList as $structureItem) { if ($structureItem['first']) { // get id of the current item $query = "SELECT MAX(`item_id`) FROM `" . BIT_DB_PREFIX . "nexus_menu_items`"; $parentPath[] = $this->mDb->getOne($query, array()); $parent_id = end($parentPath); } if ($structureItem['last']) { // move up one step in the structure parentPath array_pop($parentPath); $parent_id = end($parentPath); } else { // save the item in the menu $tmpItem = $rootStructure->getNode($structureItem['structure_id']); $itemHash = array('menu_id' => $menu_id, 'title' => $structureItem['title'], 'pos' => $tmpItem['pos'], 'parent_id' => $parent_id, 'rsrc' => isset($structureItem['structure_id']) ? $structureItem['structure_id'] : NULL, 'rsrc_type' => 'structure_id'); $storedItem = $this->storeItem($itemHash); } } } else { $this->mErrors['store_menu'] = tra('The menu could not be stored.'); } } else { $this->mErrors['structure_id'] = tra('No valid structure id was given.'); } return count($this->mErrors) == 0; }
/** * expunge a gallery * * @param array $pParamHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pForceDeleteItems = FALSE) { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // get all items that are part of the sub tree require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure(); $tree = $struct->getSubTree($this->mStructureId); // include the current id as well - needed when there are no sub-galleries $galleryContentIds[] = $this->mContentId; foreach ($tree as $node) { $galleryContentIds[] = $node['content_id']; } $galleryContentIds = array_unique($galleryContentIds); // Create Item Object require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $itemObject = new TreasuryItem(); // Go through all galleries we want to remove foreach ($galleryContentIds as $gid) { // make sure the gallery is fully loaded $this->mContentId = $gid; $this->load(); $itemContentIds = $this->mDb->getCol("SELECT `item_content_id` FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?", array($gid)); $itemContentIds = array_unique($itemContentIds); // Delete items in galleries foreach ($itemContentIds as $iid) { if ($pForceDeleteItems) { // Remove item even if it exists in other galleries $count = 1; } else { // Only delete item if it doesn't exist in other galleries $count = $this->mDb->getOne("SELECT COUNT( `item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `item_content_id`=?", array($iid)); } // Only delete item if it doesn't exist in other galleries if ($count == 1) { $itemObject->mContentId = $iid; $itemObject->load(); if (!$itemObject->expunge()) { $this->mErrors['expunge'][] = $itemObject->mErrors; } } } // Next, we remove any icons if they exist if ($thumbdir = $this->getGalleryThumbBaseUrl()) { @unlink_r(BIT_ROOT_PATH . $thumbdir); } // Now that all the items are gone, we can start nuking gallery entries // remove gallery preferences $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_prefs` WHERE `content_id`=?"; $result = $this->mDb->query($query, array($this->mContentId)); // Remove map entries $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Remove gallery entry $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_gallery` WHERE `content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Let liberty remove all the content entries for this gallery if (!LibertyContent::expunge()) { $errors = TRUE; } // Finally nuke the structure in liberty_structures $struct->removeStructureNode($this->mStructureId, FALSE); } if (empty($errors)) { $this->mDb->CompleteTrans(); $ret = TRUE; } else { $this->mDb->RollbackTrans(); $ret = FALSE; } } return $ret; }
//get pigeonholes list if ($gBitSystem->isPackageActive('pigeonholes')) { //this is just like pigeonholes:list.php without the tpl call $gBitSystem->verifyPermission('p_pigeonholes_view'); include_once PIGEONHOLES_PKG_PATH . 'lookup_pigeonholes_inc.php'; $listHash =& $_REQUEST; $listHash['load_only_root'] = TRUE; $listHash['sort_mode'] = !empty($listHash['sort_mode']) ? $listHash['sort_mode'] : 'title_asc'; $pigeonList = $gContent->getList($listHash); // set up structure related stuff if (!empty($pigeonList)) { foreach ($pigeonList as $key => $pigeonhole) { if (empty($gStructure)) { $gStructure = new LibertyStructure(); } $pigeonList[$key]['subtree'] = $gStructure->getSubTree($pigeonhole['root_structure_id']); // add permissions to all so we know if we can display pages within category // foreach( $pigeonList[$key]['subtree'] as $k => $node ) { // $pigeonList[$key]['subtree'][$k]['preferences'] = $gContent->loadPreferences( $node['content_id'] ); // } } $gBitSmarty->assign('pigeonList', $pigeonList); } $gBitSmarty->assign('listInfo', $listHash['listInfo']); } if ($gBitSystem->isPackageActive('stars')) { //php is annoying, so 0 would be interpretted as null and not trigger the tpl this relates too. $GeoStars = array('stars_pixels' => 1, 'stars_version_pixels' => 1, 'stars_load' => 1); $gBitSmarty->assign('loadStars', TRUE); $gBitSmarty->assign_by_ref('GeoStars', $GeoStars); }