// echo '<pre>', print_r($controllers), '</pre>'; foreach ($controllers as $controller) { //Register users if they aren't already in the VATeir database. try { if (!$user->find($controller->cid)) { //CID not already in database. New member - register them! if ($controller->rating > 7) { $rating = $user->getRealRating($controller->cid); } else { $rating = $controller->rating; } $pilotRating = $t->pilotRating($controller->pilot_rating); $make = $user->create(array('id' => $controller->cid, 'first_name' => $controller->firstname, 'last_name' => $controller->lastname, 'email' => $controller->email, 'rating' => $rating, 'pilot_rating' => $controller->pilot_rating, 'pratingstring' => $pilotRating, 'regdate_vatsim' => date("Y-m-d H:i:s", strtotime($controller->reg_date)), 'regdate_vateir' => date('Y-m-d H:i:s'), 'vateir_status' => 1)); if (!$t->findStudent($controller->cid)) { $program = $t->program($rating); $studentMake = $t->createStudent(array('cid' => $controller->cid, 'program' => $program)); } $register["registered"][] = $controller->cid; } } catch (Exception $e) { echo $e->getMessage(); $register["regfail"][$controller->cid] = $e->getMessage(); } /////UPDATING DATA FOR USERS THAT ARE ACTIVE////// if (empty($register["registered"]) || !in_array($controller->cid, $register["registered"])) { //CID hasn't just registered above...or no one has registered at all try { //update active user's data if ($user->isActive($controller->cid)) { //check if the user is active if ($controller->rating > 7) {
$delete = $user->delete([['id', '=', Input::get('id')], ['vateir_status', '<>', 1], ['vateir_status', '<>', 2]]); if ($delete) { Session::flash('success', 'Application approved'); Redirect::to('./'); } } elseif (Input::get('approve')) { if (Input::get('vateir_status') == 3) { $test = $user->update(['controllers.vateir_status' => '2', 'controllers.grou' => '10'], [['controllers.id', '=', Input::get('id')]]); if (!$t->findStudent(Input::get('id'))) { if ($controller->rating > 7) { $rating = $user->getRealRating(Input::get('id')); } else { $rating = $controller->rating; } $program = $t->program($rating); $studentMake = $t->createStudent(array('cid' => Input::get('id'), 'program' => $program)); } Session::flash('success', 'Application approved'); Redirect::to('./'); } } } catch (Exception $e) { echo $e->getMessage(); } } else { $controller = $a->incoming(Input::get('id'))[0]; if ($controller) { ?> <div class="row"> <h3 class="text-center">Incoming Student Request</h3><br>
Session::flash('success', 'You are now logged in!'); Redirect::to('../index.php'); } elseif (!$siteLogin && $user->user->division->code == "EUD" && $user->user->subdivision->code == "IRL") { //Possible future feature - create an account apart from CRON here. try { //Try making an account if they are a member of VATeir... if ($user->user->rating->id > 7) { $rating = $u->getRealRating($user->user->id); } else { $rating = $user->user->rating->id; } $pilotRating = $t->pilotRating($user->user->pilot_rating->rating); $make = $u->create(array('id' => $user->user->id, 'alive' => 1, 'first_name' => $user->user->name_first, 'last_name' => $user->user->name_last, 'email' => $user->user->email, 'rating' => $rating, 'pilot_rating' => $user->user->pilot_rating->rating, 'pratingstring' => $pilotRating, 'regdate_vatsim' => date("Y-m-d H:i:s", strtotime($user->user->reg_date)), 'regdate_vateir' => date('Y-m-d H:i:s'), 'grou' => 10)); if (!$t->getStudent($user->user->id)) { $program = $t->program($rating); $studentMake = $t->createStudent(array('cid' => $user->user->id, 'program' => $program)); } $u->login($user->user->id); Session::flash('success', 'You are now logged in!'); Redirect::to('../index.php'); } catch (Exception $x) { echo $x->getMessage(); } } else { $notAllowed = $user->user->rating->id > 2 ? false : true; //Set the rating to be S2 and above for visiting controller applications echo "<h4>Hey " . $user->user->name_first . ",</h4>"; ?> <div style="font-size:16px"> <p>It looks like you're not a member of VATeir.<br> Don't fret though, it's super simple to become a visiting controller or to transfer!</p>