Example #1
0
/**
 * SolidWorks (entry point)
 *
 * This function serves as the entry point for the entire application.  It opens
 * the session, loads the Page object, processes any forms, and invokes any actions
 * for the page.
 *
 * @package SolidWorks
 * @author John Diamond <*****@*****.**>
 */
function solidworks(&$conf, $smarty)
{
    global $page;
    // Make the Page object available to smarty_extensions
    global $translations;
    // Make sure the client is logged in as a valid user before proceeding
    validate_client();
    // Load the user's language preference
    $language = isset($_SESSION['client']['userdbo']) ? $_SESSION['client']['userdbo']->getLanguage() : null;
    if ($language != null) {
        TranslationParser::load("language/" . $language);
        Translator::getTranslator()->setActiveLanguage($language);
    }
    if ($_SESSION['currentpage'] != $_GET['page']) {
        $_SESSION['lastpage'] = $_SESSION['currentpage'];
    }
    // Get a Page object for the page being requested
    $page = null;
    $page = get_page_object($conf, $smarty);
    if ($page == null) {
        // Delete current session
        session_destroy();
        // Instantiate a generic page object
        $page = new Page();
    }
    // Make sure the client has access to this page
    if (!$page->control_access()) {
        // Access denied
        $page->setError(array("type" => "ACCESS_DENIED"));
        $page->goback(1);
    }
    // Process any forms
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
        handle_post_request();
    }
    // Execute any action if present in the URL
    if (isset($_GET['action'])) {
        $page->action($_GET['action']);
    }
    // Display
    display_page($page);
    // Push page onto the navigation stack
    $_SESSION['navstack'][] = array("page" => $page->getName(), "url" => $page->getURL());
}