function testDeleteUser()
 {
     $result = PilotData::DeletePilot($this->pilotid);
     $this->assertTrue($result, 'Deleting pilot');
     # Verify deletion
     $data = PilotData::GetPilotData($this->pilotid);
     $this->assertFalse($data, "Pilot still exists");
     # Last test, add a line break
     echo "<br />";
 }
示例#2
0
 public function viewpilots()
 {
     /* This function is called for *ANYTHING* in that popup box
        
        Preset all of the template items in this function and
        call them in the subsequent templates
        
        Confusing at first, but easier than loading each tab
        independently via AJAX. Though may be an option later
        on, but can certainly be done by a plugin (Add another
        tab through AJAX). The hook is available for whoever
        wants to use it
        */
     switch ($this->post->action) {
         case 'changepassword':
             $this->ChangePassword();
             return;
             break;
         case 'deletepilot':
             $pilotid = $this->post->pilotid;
             $pilotinfo = PilotData::getPilotData($pilotid);
             PilotData::DeletePilot($pilotid);
             CodonEvent::Dispatch('pilot_deleted', 'PilotAdmin', $pilot);
             $this->set('message', Lang::gs('pilot.deleted'));
             $this->render('core_success.tpl');
             LogData::addLog(Auth::$userinfo->pilotid, 'Deleted pilot ' . PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid) . ' ' . $pilotinfo->firstname . ' ' . $pilotinfo->lastname);
             break;
             /* These are reloaded into the #pilotgroups ID
                so the entire groups list is refreshed
                */
         /* These are reloaded into the #pilotgroups ID
            so the entire groups list is refreshed
            */
         case 'addgroup':
             $this->AddPilotToGroup();
             $this->SetGroupsData($this->post->pilotid);
             $this->render('pilots_groups.tpl');
             return;
             break;
         case 'removegroup':
             $this->RemovePilotGroup();
             $this->SetGroupsData($this->post->pilotid);
             $this->render('pilots_groups.tpl');
             return;
             break;
         case 'saveprofile':
             if ($this->post->firstname == '' || $this->post->lastname == '') {
                 $this->set('message', 'The first or lastname cannot be blank!');
                 $this->render('core_error.tpl');
                 return;
             }
             if (intval($this->post->retired) == 1) {
                 $retired = true;
             } else {
                 $retired = false;
             }
             $params = array('code' => $this->post->code, 'firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'location' => $this->post->location, 'hub' => $this->post->hub, 'retired' => $retired, 'totalhours' => $this->post->totalhours, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'payadjust' => floatval($this->post->payadjust), 'transferhours' => $this->post->transferhours, 'comment' => $this->post->comment);
             PilotData::updateProfile($this->post->pilotid, $params);
             PilotData::SaveFields($this->post->pilotid, $_POST);
             /* Don't calculate a pilot's rank if this is set */
             if (Config::Get('RANKS_AUTOCALCULATE') == false) {
                 PilotData::changePilotRank($this->post->pilotid, $this->post->rank);
             } else {
                 RanksData::calculateUpdatePilotRank($this->post->pilotid);
             }
             StatsData::UpdateTotalHours();
             $this->set('message', 'Profile updated successfully');
             $this->render('core_success.tpl');
             $pilot = PilotData::getPilotData($this->post->pilotid);
             LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname);
             return;
             break;
     }
     if ($this->get->action == 'viewoptions') {
         $this->ViewPilotDetails();
         return;
     }
     $this->ShowPilotsList();
 }