/** * Maintenance::changepilotid() * * @return */ public function changepilotid() { CodonModule::checkPermission(MAINTENANCE); CodonModule::checkPermission(EDIT_PILOTS); echo '<h3>Change Pilot ID</h3>'; if (isset($this->post->submit)) { $error = false; if (!is_numeric($this->post->new_pilotid)) { $error = true; $this->set('message', 'The pilot ID isn\'t numeric!'); $this->render('core_error.php'); return; } if ($this->post->new_pilotid < 1) { $error = true; $this->set('message', 'You cannot have an ID less than 1'); $this->render('core_error.php'); return; } if (empty($this->post->new_pilotid)) { $error = true; $this->set('message', 'The pilot ID is blank!'); $this->render('core_error.php'); return; } if (empty($this->post->old_pilotid) || $this->post->old_pilotid == 0) { $error = true; $this->set('message', 'No pilot selected'); $this->render('core_error.php'); return; } $pilot = PilotData::getPilotData($this->post->new_pilotid); if (is_object($pilot)) { $error = true; $this->set('message', 'This ID is already used!'); $this->render('core_error.php'); return; } if ($error === false) { PilotData::changePilotID($this->post->old_pilotid, $this->post->new_pilotid); $this->set('message', "Pilot ID changed from {$this->post->old_pilotid} to {$this->post->new_pilotid}"); $this->render('core_success.php'); } } $this->set('allpilots', PilotData::findPilots(array())); $this->render('maintenance_changepilotid.php'); }
public function changepilotid() { echo '<h3>Change Pilot ID</h3>'; if (isset($this->post->submit)) { $error = false; if (!is_numeric($this->post->new_pilotid)) { $error = true; $this->set('message', 'The pilot ID isn\'t numeric!'); $this->render('core_error.tpl'); return; } if ($this->post->new_pilotid < 1) { $error = true; $this->set('message', 'You cannot have an ID less than 1'); $this->render('core_error.tpl'); return; } if (empty($this->post->new_pilotid)) { $error = true; $this->set('message', 'The pilot ID is blank!'); $this->render('core_error.tpl'); return; } if (empty($this->post->old_pilotid) || $this->post->old_pilotid == 0) { $error = true; $this->set('message', 'No pilot selected'); $this->render('core_error.tpl'); return; } $pilot = PilotData::getPilotData($this->post->new_pilotid); if (is_object($pilot)) { $error = true; $this->set('message', 'This ID is already used!'); $this->render('core_error.tpl'); return; } if ($error === false) { PilotData::changePilotID($this->post->old_pilotid, $this->post->new_pilotid); CodonEvent::Dispatch('pilotid_changed', 'Maintenance', array('old_pilotid' => $this->post->old_pilotid, 'new_pilotid' => $this->post->new_pilotid)); $this->set('message', "Pilot ID changed from {$this->post->old_pilotid} to {$this->post->new_pilotid}"); $this->render('core_success.tpl'); } } $this->set('allpilots', PilotData::findPilots(array())); $this->render('maintenance_changepilotid.tpl'); }