/**
 * Public API to page locks: Determine
 * if the page is locked or not
 *
 * @param object $page The page to test
 * @return boolean
 **/
function page_is_locked($page)
{
    global $CFG;
    static $cache = array();
    static $include = false;
    if (!isset($cache[$page->id])) {
        if (!empty($page->locks) and !has_capability('format/page:editpages', get_context_instance(CONTEXT_COURSE, $page->courseid))) {
            if (!$include) {
                require_once $CFG->dirroot . '/course/format/page/plugin/lock.php';
                $include = true;
            }
            $cache[$page->id] = format_page_lock::is_locked($page);
        } else {
            $cache[$page->id] = false;
        }
    }
    return $cache[$page->id];
}