$gStructure = new LibertyStructure($_REQUEST["structure_id"]); $gStructure->load(); // order matters for these conditionals if (empty($gStructure) || !$gStructure->isValid()) { $gBitSystem->fatalError(tra('Invalid structure')); } if ($gStructure->mInfo['root_structure_id'] == $gStructure->mInfo['structure_id']) { $rootStructure =& $gStructure; } else { $rootStructure = new LibertyStructure($gStructure->mInfo['root_structure_id']); $rootStructure->load(); $rootStructure->loadNavigation(); $rootStructure->loadPath(); } if (empty($gContent)) { $gContent = LibertyContent::getLibertyObject($gStructure->getField('content_id')); $gContent->verifyUpdatePermission(); } $gBitSmarty->assign_by_ref('gStructure', $gStructure); $gBitSmarty->assign('editingStructure', TRUE); $gBitSmarty->assign('structureInfo', $gStructure->mInfo); // Store the actively stored structure name $gBitUser->storePreference('edit_structure_name', $rootStructure->mInfo['title']); $gBitUser->storePreference('edit_structure_id', $rootStructure->mStructureId); if (isset($_REQUEST["action"]) && $_REQUEST["action"] == 'remove' || !empty($_REQUEST["confirm"])) { $gBitUser->verifyTicket(); if ($_REQUEST["action"] == 'remove' && ($gBitThemes->isAjaxRequest() || !empty($_REQUEST["confirm"]))) { $gBitUser->verifyTicket(); if ($gStructure->removeStructureNode($_REQUEST["structure_id"], false)) { if ($gBitThemes->isAjaxRequest()) { $feedback['success'] = tra("removed from") . ' ' . $gContent->getContentTypeName();
} $nodeHash['content_id'] = $nodePage->mContentId; $nodeHash['after_ref_id'] = $gStructure->storeNode($nodeHash); } } header("location: " . WIKI_PKG_URL . "edit_book.php?structure_id=" . $structure_id); } else { $gBitSmarty->assignByRef('errors', $gContent->mErrors); $gBitSmarty->assign('name', $_REQUEST['name']); $gBitSmarty->assign('chapters', $_REQUEST['chapters']); $mid = 'bitpackage:wiki/create_book.tpl'; } } elseif ($gContent->isValid()) { // Get all wiki pages for the select box $_REQUEST['content_type_guid'] = !isset($_REQUEST['content_type_guid']) ? 'bitpage' : $_REQUEST['content_type_guid']; // verify the book permission on structure load $verifyStructurePermission = 'p_wiki_admin_book'; // set the correct display template $mid = 'bitpackage:wiki/edit_book.tpl'; include_once LIBERTY_PKG_PATH . 'edit_structure_inc.php'; if ($gBitThemes->isAjaxRequest()) { $gBitSmarty->display('bitpackage:kernel/feedback_inc.tpl'); } } else { // user is just trying to create a new book - give them the form $gBitSystem->setBrowserTitle('Create Wiki Book'); $mid = 'bitpackage:wiki/create_book.tpl'; } $gBitSystem->setBrowserTitle(!empty($gStructure) && $gStructure->isValid() ? 'Edit Wiki Book:' . $gStructure->getField('title') : NULL); // Display the template $gBitSystem->display($mid, NULL, array('display_mode' => 'edit'));