Jump to content

Gofast77

Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by Gofast77

  1. I also have this error : Warning: Missing argument 8 for RanksData::updateRank()
  2. class RanksData extends CodonData { public function getranks() { $sql = "SELECT * FROM " . TABLE_PREFIX . "ranks ORDER BY minhours"; return DB::get_results($sql); } public function getaircrafts($rankid) { $sql= "SELECT distinct icao FROM " . TABLE_PREFIX . "aircraft WHERE minrank=" . $rankid; return DB::get_results($sql); } static $lasterror; /** * Return information about the rank, given the ID */ public static function getRankInfo($rankid) { $sql = 'SELECT * FROM '.TABLE_PREFIX.'ranks WHERE rankid='.$rankid; return DB::get_row($sql); } /** * Returns all the ranks, and the total number of pilots * on each rank */ public static function getAllRanks() { $allranks = CodonCache::read('all_ranks'); if($allranks === false) { $sql = 'SELECT r.*, (SELECT COUNT(*) FROM '.TABLE_PREFIX.'pilots WHERE rank=r.rank) as totalpilots FROM ' .TABLE_PREFIX.'ranks r ORDER BY r.minhours ASC'; $allranks = DB::get_results($sql); CodonCache::write('all_ranks', $allranks, 'long'); } return $allranks; } public static function getRankImage($rank) { $sql = 'SELECT `rankimage` FROM '.TABLE_PREFIX.'ranks WHERE rank="'.$rank.'"'; return DB::get_var($sql); } /** * Get the level the passed rank is in the list */ public static function getRankLevel($rankid) { if($rankid == 0) { return 0; } $all_ranks = self::getAllRanks(); $i=0; foreach($all_ranks as $rank) { $i++; if($rank->rankid == $rankid) { return $i; } } return 0; } /** * Give the number of hours, return the next rank */ public static function getNextRank($hours) { $sql = "SELECT * FROM ".TABLE_PREFIX."ranks WHERE minhours>$hours ORDER BY minhours ASC LIMIT 1"; return DB::get_row($sql); } /** * Add a ranking. This will automatically call * CalculatePilotRanks() at the end */ public static function addRank($title, $minhours, $imageurl, $description, $payrate, $exams, $briefing) { $minhours = intval($minhours); $payrate = floatval($payrate); $sql = "INSERT INTO ".TABLE_PREFIX."ranks (rank, rankimage, minhours, description, payrate, exams, briefing) VALUES('$title', '$imageurl', '$description', '$minhours', '$payrate','$exams', '$briefing')"; $ret = DB::query($sql); if(DB::$errno == 1062) { self::$lasterror = 'This already exists'; return false; } CodonCache::delete('all_ranks'); self::CalculatePilotRanks(); return true; } /** * Update a certain rank */ public static function updateRank($rankid, $title, $minhours, $imageurl, $description, $payrate, $exams, $briefing) { $minhours = intval($minhours); $payrate = floatval($payrate); $sql = "UPDATE ".TABLE_PREFIX."ranks SET rank='$title', rankimage='$imageurl', minhours='$minhours', description='$description', payrate='$payrate', exams='$exams', briefing='$briefing' WHERE rankid=$rankid"; $res = DB::query($sql); if(DB::errno() != 0) return false; CodonCache::delete('all_ranks'); self::CalculatePilotRanks(); return true; } /** * Delete a rank, and then recalculate */ public static function deleteRank($rankid) { $sql = 'DELETE FROM '.TABLE_PREFIX.'ranks WHERE rankid='.$rankid; DB::query($sql); if(DB::errno() != 0) return false; CodonCache::delete('all_ranks'); self::CalculatePilotRanks(); return true; } /** * Go through each pilot, check their hours, and see where they * stand in the rankings. If they are above the minimum hours * for that rank level, then make $last_rank that text. At the * end, update that */ public static function calculatePilotRanks() { /* Don't calculate a pilot's rank if this is set */ if(Config::Get('RANKS_AUTOCALCULATE') === false) { return; } $allranks = self::getAllRanks(); $pilots = PilotData::getAllPilots(); if(count($pilots) == 0 || !is_array($pilots)) { return; } foreach($pilots as $pilot) { $last_rank = ''; $pilothours = intval($pilot->totalhours); if(Config::Get('TRANSFER_HOURS_IN_RANKS') == true) { $pilothours += $pilot->transferhours; } $i = 1; foreach($allranks as $rank) { if($pilothours >= intval($rank->minhours)) { $rank_level = $i; $last_rank = $rank->rank; $last_rankid = $rank->rankid; } $i++; } $update = array( 'rankid' => $last_rankid, 'rank' => $last_rank, 'ranklevel' => $rank_level, ); PilotData::updateProfile($pilot->pilotid, $update); } } public static function calculateUpdatePilotRank($pilotid) { /* Don't calculate a pilot's rank if this is set */ if(Config::Get('RANKS_AUTOCALCULATE') == false) { return; } $pilotid = intval($pilotid); $allranks = self::GetAllRanks(); $pilot = PilotData::GetPilotData($pilotid); $pilothours = $pilot->totalhours; if(Config::Get('TRANSFER_HOURS_IN_RANKS') == true) { $pilothours += $pilot->transferhours; } $i = 0; foreach($allranks as $rank) { $i++; if($pilothours >= intval($rank->minhours)) { $rank_level = $i; $last_rank = $rank->rank; $last_rankid = $rank->rankid; } } $update = array( 'rankid' => $last_rankid, 'rank' => $last_rank, 'ranklevel' => $rank_level, ); PilotData::updateProfile($pilot->pilotid, $update); } }
  3. Hi guys, There are some days I wanted to add fields for the ranks (description, etc) but I got this error : Error updating the rank: You have an error in your SQL syntax; check the manual That corresponds to your MySQL server version for the right syntax to use near 'Pilot' at line 3 Can you help me ? Thanks, Gofast
  4. Hi, can you explain to me how it's done with phpVMS because I not know too much phpVMS API ?
  5. Hi, thanks for answers but the topic is resolved thanks
  6. Another question for the modules as the module "Rules and Regulations" PHP Mods, how do since it is based on a SQL query ?
  7. Ok, thanks, I going to try this. What is the folder ? templates ?
  8. Yes I can, but I would like to have the site in two languages
  9. Hi all, Can you help me, I would like two languages on a same phpVMS website without "Google Translate". I would like a very good alternative not a simple link or drop down to Google Translate. Waiting for your answers. Gofast
  10. Hello, This addon is very good but the same for phpBB or other it would be nice.
  11. @Vansers Hello, can you help me for this ?
×
×
  • Create New...