Пример #1
0
 /**
  * Searches for airports
  * CODE:airport_index
  */
 public function executeIndex(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $this->getUser()->addRecentItem('Airport', 'airport', 'airport/index');
     if ($request->hasParameter('pilot_for')) {
         $this->pilot_for = PilotPeer::retrieveByPK($request->getParameter('pilot_for'));
         $this->can_use = 1;
     } else {
         $this->change_id = null;
     }
     $exclude_ids = array();
     if ($this->pilot_for) {
         $exclude_ids[] = $this->pilot_for->getId();
     }
     # for navigation menu
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     slot('nav_menu', array('mission_coord', 'find-airport'));
     # filter
     $this->processFilter($request);
     if ($request->isMethod('post') || $request->getParameter('page')) {
         $this->pager = AirportPeer::getPager($this->max, $this->page, $this->ident, $this->name, $this->city, $this->state, $this->wing_name, $this->closed, $exclude_ids);
         $this->airports = $this->pager->getResults();
     }
     # one result with member_id search will go to member view
     if (count($this->airports) == 1) {
         if ($request->getParameter('change_id')) {
             if ($this->pilot_for) {
                 $url_add = '&change_id=' . $this->pilot_for->getId();
             } else {
                 $url_add = '';
             }
             $this->redirect('@pilot_view?id=' . $request->getParameter('change_id') . $url_add);
         }
     }
 }