/**
  * 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($params)
 {
     DebugManager::Log("Got a logout request!", '@');
     $params['start'] = date('c', strtotime($params['start']));
     $params['end'] = date('c', strtotime($params['end']));
     $Account = SessionManager::GetAccount();
     try {
         $Event = EventController::Create($params);
     } catch (Exception $e) {
         return new ResponseObject("Error", 1);
     }
     if (isset($params['acts']) && is_array($params['acts'])) {
         foreach ($params['acts'] as $pos => $act) {
             try {
                 $Act = ActController::Create(array('title' => $act));
             } catch (Exception $e) {
                 $Acts = ActController::Search(array('title' => $act));
                 $Act = reset($Acts);
             }
             try {
                 if (isset($params['slots'][$pos])) {
                     $slot = date('c', strtotime($params['slots'][$pos]));
                 } else {
                     if (isset($slot)) {
                         $slot = date('c', strtotime('+1 hour', $slot));
                     } else {
                         $slot = date('c', strtotime('+30 minutes', $params['start']));
                     }
                 }
                 $Performance = PerformanceController::Create(array('act_id' => $Act['id'], 'event_id' => $Event['id'], 'position' => $pos, 'slot' => $slot));
             } catch (Exception $e) {
             }
         }
     }
     if (isset($params['venue'])) {
         try {
             $Venue = VenueController::Create(array('title' => $params['venue']));
         } catch (Exception $e) {
             $Venues = VenueController::Search(array('title' => $params['venue']));
             $Venue = reset($Venues);
         }
         try {
             $Hoster = HosterController::Create(array('venue_id' => $Venue['id'], 'event_id' => $Event['id']));
         } catch (Exception $e) {
         }
     }
     $Attendee = AttendeeController::Create(array('account_id' => $Account['id'], 'event_id' => $Event['id'], 'privilege_level' => 3, 'role' => 3, 'type' => 3));
     self::$defaultRedirect = 'event/' . $Event['id'];
     return new ResponseObject();
 }
 public static function Init($params)
 {
     DebugManager::Log("Got a logout request!", '@');
     $Account = SessionManager::GetAccount();
     try {
         $Location = LocationController::Create($params);
     } catch (Exception $e) {
         $Locations = LocationController::Search($params);
         $Location = reset($Locations);
     }
     try {
         $Venue = VenueController::Update(array('ids' => $params['venue_id'], 'location_id' => $Location['id']));
     } catch (Exception $e) {
     }
     self::$defaultRedirect = 'venue/' . $Venue['id'];
     return new ResponseObject();
 }