/** * Initialize Page Manager * * ## Overview * * @uses SatanBarbaraApp * @uses SessionManager * @uses ViewManager * @uses DebugManager * @uses RouteManager * @uses PageView * * @see RouteManager * * @param array An array of creds for SendGrid API. * @return true Always unless fatal error or exception is thrown. * * @version 2015-07-05.1 * @since 0.5.1b * @author TronNet DevOps [Sean Murray] <*****@*****.**> */ public static function Init($params) { DebugManager::Log("Initializing Page Manager", '@'); DebugManager::Log($params); $appConfig = SatanBarbaraApp::GetConfig(); /** * @todo have config in it's own 'config' position instead of array_merge */ $data = array('app' => array_merge($appConfig[SATANBARBARA_CURRENT_ENVIRONMENT], array()), 'page' => $params); DebugManager::Log("checking if logged in...", null, 3); if (SessionManager::IsLoggedIn()) { $data['session'] = array('is_auth' => true, 'account' => SessionManager::GetAccount()); DebugManager::Log("Got an account, checking for a saved program...", null, 3); } $Page = ucfirst($params['page']) . 'View'; DebugManager::Log("Searching for view with class name: " . $Page); if ($Page::HasAccess(SessionManager::GetAccessLevel())) { $Page::Init($data); ViewManager::Render($Page); } else { DebugManager::Log("looks like this page requires auth but user isn't authenticated!"); RouteManager::GoToPageURI('login'); } return true; }
public static function Init() { DebugManager::Log("Initializing Sendgrid Email Connector", '@'); $appConfig = SatanBarbaraApp::GetConfig(); self::SetCreds($appConfig['sendgrid']); DebugManager::Log("Creating new SendGrid Interface!"); $interface = new SendGrid(self::$_credentials['username'], self::$_credentials['password']); self::SetInterface($interface); if (SATANBARBARA_CURRENT_ENVIRONMENT == 'dev') { self::$dry_run = true; } return true; }
public static function Init($requestParams) { $appConfig = SatanBarbaraApp::GetConfig(); $data = $requestParams['params']; DebugManager::Log("Got a " . $requestParams['request']['action'] . " request!", '@'); DebugManager::Log("Got some data"); DebugManager::Log($data); $requestName = ucfirst($requestParams['request']['action']) . 'Request'; DebugManager::Log("Searching for view with class name: " . $requestName); if ($requestName::HasAccess(SessionManager::GetAccessLevel())) { $response = $requestName::Init($data); } else { DebugManager::Log("looks like this page requires auth but user isn't authenticated!"); RouteManager::GoToPageURI('login', array("message" => "That page requires authenticated access!")); } if (isset($data['_format']) && $data['_format'] == 'json') { self::AJAXResponse($response); } else { $format = isset($data['_format']) ? $data['_format'] : 'html'; if (isset($data['_redirect'])) { $redirect = $data['_redirect']; } else { if (isset($requestName::$defaultRedirect)) { $redirect = $requestName::$defaultRedirect; } else { $redirect = 'home'; // $requestParams['uri']; <-- can't do this, it will cause circular loop because it's getting current URI and not last URI. } } $redirectURI = $redirect; $HTTPVars = array(); if ($response->message != 'Success!') { if ($response->code) { $HTTPVars['error'] = $response->message; } else { $HTTPVars['success'] = $response->message; } } RouteManager::GoToPageURI($redirectURI, $HTTPVars); } }
/** * Set Application Config Data * * @param array An array of app settings. * @return true Always unless fatal error or exception is thrown. * * @version 2015-07-05.1 * @since 0.5.1b * @author TronNet DevOps [Sean Murray] <*****@*****.**> */ public static function SetConfig($appConfig) { DebugManager::Log("Setting Application Configurations"); DebugManager::Log($appConfig); self::$appConfig = $appConfig; return true; }
* * Loads the application PHP config file. This file will determine the * current environment setup as well as define global constants and paths * that are utilized in the Metalsite Application Core. */ require_once SATANBARBARA_PATH . '/www/lib/config.php'; /** * Metalsite Application PHP Class Autoloader. * * Defines the paths to search for Application specific classes and loads * them if found. All classes in the Application Core are loaded by this * mechanism. */ require_once SATANBARBARA_APP_PATH . '/lib/autoloader.php'; DebugManager::Log(SATANBARBARA_APP_PACKAGE_NAME . " Entry Point", '@'); /** * Metalsite API PHP Class Autoloader. * * Defines the paths to search for API specific classes and loads them * if found. All classes in the API are loaded by this mechanism. */ require_once SATANBARBARA_API_PATH . '/lib/autoloader.php'; /** * Initialize Metalsite Application. * * Utilizing the constants and autoloaders included above, initialize the * Metalsite Application. This is where all session, routing, data and * requests are handled. */ SatanBarbaraApp::Init();
public static function Init() { $appConfig = SatanBarbaraApp::GetConfig(); self::SetLogFile($appConfig[SATANBARBARA_CURRENT_ENVIRONMENT]['basePath'] . $appConfig['logs']['app']['path']); return true; }