/** * Initialise * @return */ public function init() { # Prepare $App = $this->getHelper('App'); $App->prepareLog(); $actionName = $this->getRequest()->getActionName(); # Layout $App->setArea('back'); # Login $App->setOption('logged_in_forward', array(array('action' => 'dashboard'), 'back', true))->setOption('logged_out_forward', array(array('action' => 'login'), 'back', true)); # Authenticate / redirect to login if need be if (in_array($actionName, array(false, 'login', 'index'))) { # Within Safe Area, Authenticate WITHOUT Redirects $App->authenticate(false, false); } else { # Outside Safe Area, Authenticate WITH Redirects $App->authenticate(true, false); # Check Permission Access For Admin Area try { $User = $App->getUser(); if (delve($User, 'id') && !$App->hasPermission('admin')) { # Log $Log = Bal_App::getLog(); $log_details = array('User' => $User->toArray(false), 'base_url' => $App->getBaseUrl(), 'front_url' => $App->getAreaUrl('front'), 'back_url' => $App->getAreaUrl('back')); $Log->log(array('log-admin-permission', $log_details), Bal_Log::ERR, array('friendly' => true, 'details' => $log_details)); # Logout $this->getHelper('redirector')->goToRoute(array('action' => 'login'), 'back', true); //$App->logout(true); // ^ Don't log them out, just redirect them back to the login page } } catch (Exception $Exception) { # Log the Event and Continue $Exceptor = new Bal_Exceptor($Exception); $Exceptor->log(); } } # Navigation $App->applyNavigation(); # Done return true; }
public function subscribeAction() { # Prepare $App = $this->getHelper('App'); $Request = $this->getRequest(); $Response = $this->getResponse(); $Log = Bal_App::getLog(); # -------------------------- # Fetch $email = fetch_param('subscribe.email', $Request->getParam('email')); # Subscribe try { $Subscriber = new User(); $Subscriber->email = $email; $Subscriber->setTags('newsletter'); $Subscriber->save(); # Log $log_details = array('Subscriber' => $Subscriber->toArray()); $Log->log(array('log-subscriber-save', $log_details), Bal_Log::NOTICE, array('friendly' => true, 'class' => 'success', 'details' => $log_details)); } catch (Exception $Exception) { # Log the Event $Exceptor = new Bal_Exceptor($Exception); $Exceptor->log(); } # -------------------------- # Done return $this->_forward('index'); }