示例#1
0
 public function preDispatch()
 {
     parent::preDispatch();
     // Disable session creation.
     \DF\Session::disable();
     // Disable rendering.
     $this->doNotRender();
     // Allow AJAX retrieval.
     $this->response->setHeader('Access-Control-Allow-Origin', '*');
     // Fix the base URL prefixed with '//'.
     \DF\Url::forceSchemePrefix(true);
     $this->_time_start = microtime(true);
     // Set all API calls to be public cache-controlled by default.
     $this->setCachePrivacy('public');
     $this->setCacheLifetime(30);
 }
示例#2
0
 protected function preDispatch()
 {
     parent::preDispatch();
     $this->forceSecure();
     $user = $this->auth->getLoggedInUser();
     // Compile list of visible stations.
     $all_stations = Station::fetchAll();
     $stations = array();
     foreach ($all_stations as $station) {
         if ($station->canManage($user)) {
             $stations[$station->id] = $station;
         }
     }
     $this->stations = $stations;
     $this->view->stations = $stations;
     // Assign a station if one is selected.
     if ($this->hasParam('station')) {
         $station_id = (int) $this->getParam('station');
         if (isset($stations[$station_id])) {
             $this->station = $stations[$station_id];
             $this->view->station = $this->station;
             $this->view->hide_title = true;
         } else {
             throw new \DF\Exception\PermissionDenied();
         }
     } else {
         if (count($this->stations) == 1) {
             // Convenience auto-redirect for single-station admins.
             $this->redirectFromHere(array('station' => key($this->stations)));
             return false;
         }
     }
     // Force a redirect to the "Select" page if no station ID is specified.
     if (!$this->station) {
         throw new \DF\Exception\PermissionDenied();
     }
 }
示例#3
0
 protected function preDispatch()
 {
     parent::preDispatch();
     $this->forceSecure();
     return true;
 }