예제 #1
0
function includes_psu_autoload($class)
{
    static $base_dir = null;
    if (null === $base_dir) {
        $base_dir = dirname(__FILE__);
    }
    // translate namespaces: PSU\Foo becomes PSU_Foo
    $class = str_replace('\\', '_', $class);
    // whitelisting for now, maybe later we just check for the file
    $prefix_whitelist = includes_psu_register();
    $prefix = null;
    if (($pos = strpos($class, '_')) !== false) {
        $prefix = substr($class, 0, $pos);
    } else {
        $prefix = $class;
    }
    if (isset($prefix_whitelist[$prefix])) {
        $file = $prefix_whitelist[$prefix] . '/' . str_replace('_', '/', $class) . '.php';
        if (file_exists($file)) {
            require_once $file;
            return;
        }
    }
    if (file_exists($file = $base_dir . '/' . $class . '.class.php')) {
        require_once $file;
        return;
    }
}
예제 #2
0
    // Have the APP_BUILD_TYPE global reflect the current server/code status
    $GLOBALS['APP_BUILD_TYPE'] .= '-prod';
    // Set a global for easier access from templates
    $GLOBALS['IS_DEV'] = false;
}
// Include my custom mobile smarty class
require_once $GLOBALS['BASE_DIR'] . '/includes/MobileTemplate.class.php';
// Include my custom mobile smarty class
require_once $GLOBALS['BASE_DIR'] . '/includes/MobileParams.class.php';
// Include the Klein PHP routing engine
require_once 'klein/klein.php';
if (file_exists($GLOBALS['BASE_DIR'] . '/debug.php')) {
    include $GLOBALS['BASE_DIR'] . '/debug.php';
}
// Register my directory into the autoloader
includes_psu_register('Mobile', $GLOBALS['BASE_DIR'] . '/includes');
/**
 * Routing provided by klein.php (https://github.com/chriso/klein.php)
 */
// Make some objects available elsewhere
respond(function ($request, $response, $app) {
    // Initialize the custom parameters
    $app->params = new MobileParams();
    // Initialize the PSU smarty templating
    $app->tpl = new MobileTemplate();
    // Add the parameters object to the template
    $app->tpl->assign('params', $app->params);
});
// Generic request
respond('/', function ($request, $response, $app) {
    // Grab a couple of the request parameters
예제 #3
0
if (file_exists('dev-environment.php')) {
    include 'dev-environment.php';
}
require_once 'autoload.php';
PSU::session_start();
// force ssl + start a session
if (!$GLOBALS['BASE_URL']) {
    $GLOBALS['BASE_URL'] = '/webapp/training-tracker';
}
$GLOBALS['BASE_DIR'] = __DIR__;
$GLOBALS['TITLE'] = 'Training Tracker';
$GLOBALS['TEMPLATES'] = $GLOBALS['BASE_DIR'] . '/templates';
if (file_exists($GLOBALS['BASE_DIR'] . '/debug.php')) {
    include $GLOBALS['BASE_DIR'] . '/debug.php';
}
includes_psu_register('TrainingTracker', $GLOBALS['BASE_DIR'] . '/includes');
require_once 'klein/klein.php';
require_once $GLOBALS['BASE_DIR'] . '/includes/TrainingTrackerAPI.class.php';
IDMObject::authN();
/**
 * Routing provided by klein.php (https://github.com/chriso/klein.php)
 * Make some objects available elsewhere.
 */
//Catch all
respond(function ($request, $response, $app) {
    // get the logged in user
    $app->user = PSUPerson::get($_SESSION['wp_id']);
    $memcache = new \PSUMemcache('training-tracker_teams');
    if (!($cached_results = $memcache->get('is_admin'))) {
        $staff_collection = new TrainingTracker\StaffCollection();
        $staff_collection->load();