/**
 * Returns pages from the current page object/search/or parent pages based on context
 * Updates $_zp_zenpage_curent_page and returns true if there is another page to be delivered
 * @return boolean
 */
function next_page()
{
    global $_zp_zenpage, $_zp_next_pagelist, $_zp_current_search, $_zp_current_zenpage_page, $_zp_current_page_restore;
    if (func_num_args() != 0) {
        //	These parameters are deprecated
        Zenpage_internal_deprecations::next_page();
    }
    if (is_null($_zp_next_pagelist)) {
        if (in_context(ZP_SEARCH)) {
            $_zp_next_pagelist = $_zp_current_search->getPages(NULL, false, NULL, NULL, NULL);
        } else {
            if (in_context(ZP_ZENPAGE_PAGE)) {
                if (!is_null($_zp_current_zenpage_page)) {
                    $_zp_next_pagelist = $_zp_current_zenpage_page->getPages(NULL, false, NULL, NULL, NULL);
                }
            } else {
                $_zp_next_pagelist = $_zp_zenpage->getPages(NULL, true, NULL, NULL, NULL);
            }
        }
        save_context();
        add_context(ZP_ZENPAGE_PAGE);
        $_zp_current_page_restore = $_zp_current_zenpage_page;
    }
    while (!empty($_zp_next_pagelist)) {
        $page = new ZenpagePage(array_shift($_zp_next_pagelist));
        if (zp_loggedin() && $page->isMyItem(LIST_RIGHTS) || $page->checkForGuest()) {
            $_zp_current_zenpage_page = $page;
            return true;
        }
    }
    $_zp_next_pagelist = NULL;
    $_zp_current_zenpage_page = $_zp_current_page_restore;
    restore_context();
    return false;
}