$gBitSmarty->assign('contentTypes', $contentTypes);
$gBitSmarty->assign('contentSelect', $contentSelect = !isset($_REQUEST['content_type']) ? NULL : $_REQUEST['content_type']);
$listHash = array('find' => empty($_REQUEST['find']) ? NULL : $_REQUEST['find'], 'sort_mode' => empty($_REQUEST['sort_mode']) ? NULL : $_REQUEST['sort_mode'], 'max_records' => @BitBase::verifyId($_REQUEST['max_records']) ? $_REQUEST['max_records'] : 10, 'include_members' => !empty($_REQUEST['include']) && $_REQUEST['include'] == 'members' ? TRUE : FALSE, 'content_type' => $contentSelect);
// We need to handle insert and next where we are NOT actually doing an insert
if (!empty($_REQUEST['insert_content']) || !empty($_REQUEST['insert_content_and_next'])) {
    $listHash['list_page'] = empty($_REQUEST['list_page']) ? 2 : $_REQUEST['list_page'] + 1;
} else {
    $listHash['list_page'] = empty($_REQUEST['list_page']) ? NULL : $_REQUEST['list_page'];
}
$assignableContent = $gContent->getAssignableContent($listHash);
if (!empty($_REQUEST['insert_content']) || !empty($_REQUEST['insert_content_and_next'])) {
    // here we need to limit all killing to the selected structure
    $deletableParentIds = array();
    if (empty($gStructure) && @BitBase::verifyId($_REQUEST['root_structure_id'])) {
        $gStructure = new LibertyStructure();
        $struct = $gStructure->getStructure($_REQUEST);
        foreach ($struct as $node) {
            $deletableParentIds[] = $node['content_id'];
        }
    }
    // make an array that can be stored
    foreach ($assignableContent as $item) {
        if (!empty($_REQUEST['pigeonhole'][$item['content_id']])) {
            foreach ($_REQUEST['pigeonhole'][$item['content_id']] as $parent_id) {
                $memberHash[$parent_id][] = array('parent_id' => $parent_id, 'content_id' => $item['content_id']);
            }
        }
        if (!empty($_REQUEST['include']) && $_REQUEST['include'] == 'members') {
            if (!empty($item['content_id']) && !$gContent->expungePigeonholeMember(array('member_id' => $item['content_id'], 'deletables' => $deletableParentIds))) {
                $feedback['error'] = 'The content could not be deleted before insertion.';
            }