public function getDeleteKey($keyID, $delete_all_info = false) { // Ensure that this user may access the data for $keyID if (!\Auth::isSuperUser()) { if (!in_array($keyID, Session::get('valid_keys'))) { App::abort(404); } } // Ensure the user is allowed to delete this key if (!\Auth::hasAccess('key_manager')) { App::abort(404); } // Get the full key and vCode $key = SeatKey::where('keyID', $keyID)->first(); if (!$key) { App::abort(404); } // Based on delete_all_info, we will either just delete the key, // or all of the information associated with it switch ((bool) $delete_all_info) { case true: // Check if we can determine if this is a corporation or account/char key. $type = \EveAccountAPIKeyInfo::where('keyID', $keyID)->pluck('type'); // Check if the type is set if ($type) { // For corporation keys, we will delete corporation stuff, duhr if ($type == "Corporation") { // Most of the data for corporations is stored with the corporationID // as key. To get this ID, we need to find the character attached to // this key, and then the corporation for that character $characters = BaseApi::findKeyCharacters($keyID); $corporationID = BaseApi::findCharacterCorporation($characters[0]); // With the corporationID now known, go ahead and cleanup the database \EveCorporationAccountBalance::where('corporationID', $corporationID)->delete(); \EveCorporationAssetList::where('corporationID', $corporationID)->delete(); \EveCorporationAssetListContents::where('corporationID', $corporationID)->delete(); \EveCorporationAssetListLocations::where('corporationID', $corporationID)->delete(); \EveCorporationContactListAlliance::where('corporationID', $corporationID)->delete(); \EveCorporationContactListCorporate::where('corporationID', $corporationID)->delete(); \EveCorporationContracts::where('corporationID', $corporationID)->delete(); \EveCorporationContractsItems::where('corporationID', $corporationID)->delete(); \EveCorporationCorporationSheet::where('corporationID', $corporationID)->delete(); \EveCorporationCorporationSheetDivisions::where('corporationID', $corporationID)->delete(); \EveCorporationCorporationSheetWalletDivisions::where('corporationID', $corporationID)->delete(); \EveCorporationIndustryJobs::where('corporationID', $corporationID)->delete(); \EveCorporationMarketOrders::where('corporationID', $corporationID)->delete(); \EveCorporationMedals::where('corporationID', $corporationID)->delete(); \EveCorporationMemberMedals::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityGrantableRoles::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityGrantableRolesAtBase::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityGrantableRolesAtHQ::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityGrantableRolesAtOther::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityLog::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityRoles::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityRolesAtBase::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityRolesAtHQ::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityRolesAtOther::where('corporationID', $corporationID)->delete(); \EveCorporationMemberSecurityTitles::where('corporationID', $corporationID)->delete(); \EveCorporationMemberTracking::where('corporationID', $corporationID)->delete(); \EveCorporationShareholderCharacters::where('corporationID', $corporationID)->delete(); \EveCorporationShareholderCorporations::where('corporationID', $corporationID)->delete(); \EveCorporationStandingsAgents::where('corporationID', $corporationID)->delete(); \EveCorporationStandingsFactions::where('corporationID', $corporationID)->delete(); \EveCorporationStandingsNPCCorporations::where('corporationID', $corporationID)->delete(); \EveCorporationStarbaseDetail::where('corporationID', $corporationID)->delete(); \EveCorporationStarbaseList::where('corporationID', $corporationID)->delete(); \EveCorporationWalletJournal::where('corporationID', $corporationID)->delete(); \EveCorporationWalletTransactions::where('corporationID', $corporationID)->delete(); } else { // And for character stuff, we delete character stuff // Here we need to be careful now. It may happen that we have more than 1 key // for a character, so we have to be aware of this. It adds a factor of // complexity to the whole thing. $characters = BaseApi::findKeyCharacters($keyID); // Now that we know about all of the characters, we will loop over them and check // that we only have 1 key for them. If more than one keys have this character, we will // simply ignore the cleanup and add a message about it foreach ($characters as $id => $character) { // Check how many keys know about this character if (\EveAccountAPIKeyInfoCharacters::where('characterID', $character)->count() > 1) { // Write a log entry about this \Log::warning('Character ' . $character . ' is recorded on another key and will not been cleaned up'); // Remove this character from $characters unset($characters[$id]); } } // So we now have an array of characterID's that can be cleaned up. Lets do that if (count($characters) > 0) { \EveCharacterAccountBalance::whereIn('characterID', $characters)->delete(); \EveCharacterAssetList::whereIn('characterID', $characters)->delete(); \EveCharacterAssetListContents::whereIn('characterID', $characters)->delete(); \EveCharacterCharacterSheet::whereIn('characterID', $characters)->delete(); \EveCharacterCharacterSheetSkills::whereIn('characterID', $characters)->delete(); \EveCharacterContactList::whereIn('characterID', $characters)->delete(); \EveCharacterContactListAlliance::whereIn('characterID', $characters)->delete(); \EveCharacterContactListCorporate::whereIn('characterID', $characters)->delete(); \EveCharacterContactNotifications::whereIn('characterID', $characters)->delete(); \EveCharacterContracts::whereIn('characterID', $characters)->delete(); \EveCharacterContractsItems::whereIn('characterID', $characters)->delete(); \EveCharacterIndustryJobs::whereIn('characterID', $characters)->delete(); // Intentionally ignoring the mail related information as this has a lot of overlap // and is almost always usefull \EveCharacterMarketOrders::whereIn('characterID', $characters)->delete(); \EveCharacterPlanetaryColonies::whereIn('characterID', $characters)->delete(); \EveCharacterPlanetaryLinks::whereIn('characterID', $characters)->delete(); \EveCharacterPlanetaryPins::whereIn('characterID', $characters)->delete(); \EveCharacterPlanetaryRoutes::whereIn('characterID', $characters)->delete(); \EveCharacterResearch::whereIn('characterID', $characters)->delete(); \EveCharacterSkillInTraining::whereIn('characterID', $characters)->delete(); \EveCharacterSkillQueue::whereIn('characterID', $characters)->delete(); \EveCharacterStandingsAgents::whereIn('characterID', $characters)->delete(); \EveCharacterStandingsFactions::whereIn('characterID', $characters)->delete(); \EveCharacterStandingsNPCCorporations::whereIn('characterID', $characters)->delete(); \EveCharacterUpcomingCalendarEvents::whereIn('characterID', $characters)->delete(); \EveCharacterWalletJournal::whereIn('characterID', $characters)->delete(); \EveCharacterWalletTransactions::whereIn('characterID', $characters)->delete(); } } // Finally, delete the key and redirect $key->delete(); // Delete the information that we have for this key too \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete(); \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete(); return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted'); } else { // So, we are unable to determine the key type, so maybe this is // a invalid one or whatever. Just get rid of it. // Delete the API Key $key->delete(); // Delete the information that we have for this key too \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete(); \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete(); return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted'); } break; case false: // Delete the API Key $key->delete(); // Delete the information that we have for this key too \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete(); \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete(); return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted'); break; } }
public function getSearch() { if (Request::ajax()) { /* |-------------------------------------------------------------------------- | Check that the user is either a superadmin, or has at least some keys |-------------------------------------------------------------------------- */ if (!Auth::isSuperUser() && count(Session::get('valid_keys')) <= 0) { return View::make('layouts.components.flash')->withErrors('No API Keys are defined to show you any information. Please enter at least one.'); } /* |-------------------------------------------------------------------------- | Search Characters |-------------------------------------------------------------------------- */ $characters = DB::table('account_apikeyinfo_characters')->leftJoin('seat_keys', 'account_apikeyinfo_characters.keyID', '=', 'seat_keys.keyID')->join('character_charactersheet', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('character_skillintraining', 'account_apikeyinfo_characters.characterID', '=', 'character_skillintraining.characterID')->orderBy('seat_keys.isOk', 'asc')->orderBy('account_apikeyinfo_characters.characterName', 'asc')->groupBy('account_apikeyinfo_characters.characterID')->where('characterName', 'like', '%' . Input::get('q') . '%'); // Ensure we only get result for characters we have access to if (!\Auth::hasAccess('recruiter')) { $characters = $characters->whereIn('seat_keys.keyID', Session::get('valid_keys'))->get(); } else { $characters = $characters->get(); } /* |-------------------------------------------------------------------------- | Search Character Assets |-------------------------------------------------------------------------- */ $character_assets = DB::table(DB::raw('character_assetlist as a'))->select(DB::raw("*, CASE\n when a.locationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID-6000000)\n when a.locationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID-6000001)\n when a.locationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID-6000000)\n when a.locationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID)\n when a.locationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID)\n when a.locationID>=61000000 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID)\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.locationID) end\n AS location,a.locationId AS locID"))->join('invTypes', 'a.typeID', '=', 'invTypes.typeID')->join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'a.characterID'); // If the user is not a superuser, filter the results down to keys they own if (!\Auth::isSuperUser()) { $character_assets = $character_assets->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys')); } // Complete the search $character_assets = $character_assets->where('invTypes.typeName', 'like', '%' . Input::get('q') . '%')->orderBy('location')->get(); /* |-------------------------------------------------------------------------- | Search Character Contact Lists |-------------------------------------------------------------------------- */ // Search character contact lists $character_contactlist = DB::table('character_contactlist')->join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_contactlist.characterID')->where('character_contactlist.contactName', 'like', '%' . Input::get('q') . '%'); // Ensure we only get result for characters we have access to if (!\Auth::hasAccess('recruiter')) { $character_contactlist = $character_contactlist->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->get(); } else { $character_contactlist = $character_contactlist->get(); } /* |-------------------------------------------------------------------------- | Search Character Mail |-------------------------------------------------------------------------- */ $character_mail = DB::table('character_mailmessages')->join('account_apikeyinfo_characters', 'character_mailmessages.characterID', '=', 'account_apikeyinfo_characters.characterID')->join('character_mailbodies', 'character_mailmessages.messageID', '=', 'character_mailbodies.messageID')->where(function ($query) { $query->where('character_mailmessages.senderName', 'like', '%' . Input::get('q') . '%')->orWhere('character_mailmessages.title', 'like', '%' . Input::get('q') . '%')->orWhere('character_mailbodies.body', 'like', '%' . Input::get('q') . '%'); }); // Ensure we only get result for characters we have access to if (!\Auth::hasAccess('recruiter')) { $character_mail = $character_mail->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys')); } $character_mail = $character_mail->groupBy('character_mailmessages.messageID')->orderBy('character_mailmessages.sentDate', 'desc')->get(); /* |-------------------------------------------------------------------------- | Search Character Standings |-------------------------------------------------------------------------- */ $character_standings = DB::table('character_standings_factions')->join('account_apikeyinfo_characters', 'character_standings_factions.characterID', '=', 'account_apikeyinfo_characters.characterID')->where('character_standings_factions.fromName', 'like', '%' . Input::get('q') . '%'); // Ensure we only get result for characters we have access to if (!\Auth::hasAccess('recruiter')) { $character_standings = $character_standings->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys')); } $character_standings = $character_standings->orderBy('character_standings_factions.standing', 'desc')->get(); /* |-------------------------------------------------------------------------- | Corporation Names |-------------------------------------------------------------------------- */ $corporation_names = array_flip(DB::table('account_apikeyinfo_characters')->lists('corporationID', 'corporationName')); /* |-------------------------------------------------------------------------- | Search Corporation Assets |-------------------------------------------------------------------------- */ $corporation_assets = DB::table(DB::raw('corporation_assetlist as a'))->select(DB::raw("*, CASE\n when a.locationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID-6000000)\n when a.locationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID-6000001)\n when a.locationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID-6000000)\n when a.locationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID)\n when a.locationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.locationID)\n when a.locationID>=61000000 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.locationID)\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.locationID) end\n AS location,a.locationId AS locID"))->join('invTypes', 'a.typeID', '=', 'invTypes.typeID'); // If the user is not a superuser, filter the results down to keys they own if (!\Auth::hasAccess('asset_manager')) { $corporation_assets = $corporation_assets->whereIn('a.corporationID', Session::get('corporation_affiliations')); } // Complete the search $corporation_assets = $corporation_assets->where('invTypes.typeName', 'like', '%' . Input::get('q') . '%')->orderBy('location')->get(); /* |-------------------------------------------------------------------------- | Search Corporation Standings |-------------------------------------------------------------------------- */ $corporation_standings = DB::table('corporation_standings_factions')->where('corporation_standings_factions.fromName', 'like', '%' . Input::get('q') . '%'); // Ensure we only get result for characters we have access to if (!\Auth::hasAccess('recruiter')) { $corporation_standings = $corporation_standings->whereIn('corporation_standings_factions.corporationID', Session::get('corporation_affiliations')); } $corporation_standings = $corporation_standings->orderBy('corporation_standings_factions.standing', 'desc')->get(); // Return the AJAX response return View::make('search')->with('keyword', Input::get('q'))->with('characters', $characters)->with('character_assets', $character_assets)->with('character_contactlist', $character_contactlist)->with('character_mail', $character_mail)->with('character_standings', $character_standings)->with('corporation_names', $corporation_names)->with('corporation_assets', $corporation_assets)->with('corporation_standings', $corporation_standings); } else { // Not a ajax request? Go away :> App::abort(404); } }
public function getIndustry($corporationID) { // Next, check if the current user has access. Superusers may see all the things, // normal users may only see their own stuffs if (!\Auth::isSuperUser()) { if (!in_array($corporationID, Session::get('valid_keys')) && !\Auth::hasAccess('asset_manager')) { App::abort(404); } } // Get current working jobs $current_jobs = DB::table('corporation_industryjobs as a')->select(DB::raw("\n *, CASE\n when a.stationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000001)\n when a.stationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n when a.stationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID)\n when a.stationID>=61000000 then\n (SELECT IFNULL(\n (SELECT mapName FROM corporation_assetlist_locations WHERE itemID = a.stationID),\n (IFNULL((SELECT stationName FROM eve_conquerablestationlist WHERE stationID = a.stationID),\n (SELECT solarSystemName FROM corporation_industryjobs WHERE id = a.id)\n ))\n ))\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.stationID)\n end\n AS location, a.stationID as locID"))->where('a.corporationID', $corporationID)->where('endDate', '>', date('Y-m-d H:i:s'))->orderBy('endDate', 'asc')->get(); // Get the passed jobs $finished_jobs = DB::table('corporation_industryjobs as a')->select(DB::raw("\n *, CASE\n when a.stationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000001)\n when a.stationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n when a.stationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID)\n when a.stationID>=61000000 then\n (SELECT IFNULL(\n (SELECT mapName FROM corporation_assetlist_locations WHERE itemID = a.stationID),\n (IFNULL((SELECT stationName FROM eve_conquerablestationlist WHERE stationID = a.stationID),\n (SELECT solarSystemName FROM corporation_industryjobs WHERE id = a.id)\n ))\n ))\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.stationID)\n end\n AS location, a.stationID as locID"))->where('a.corporationID', $corporationID)->where('endDate', '<=', date('Y-m-d H:i:s'))->orderBy('endDate', 'desc')->get(); // Get the name of the corporation in question $corporation_name = DB::table('account_apikeyinfo_characters')->where('corporationID', $corporationID)->first(); // Return the view return View::make('corporation.industry.industry')->with('corporation', $corporation_name)->with('current_jobs', $current_jobs)->with('finished_jobs', $finished_jobs); }
public function getAjaxIndustry($characterID) { // Check the character existance $character = DB::table('account_apikeyinfo_characters')->where('characterID', $characterID)->first(); // Check if whave knowledge of this character, else, 404 if (count($character) <= 0) { App::abort(404); } // Next, check if the current user has access. Superusers may see all the things, // normal users may only see their own stuffs. . SuperUser() inherits 'recruiter' if (!\Auth::hasAccess('recruiter')) { if (!in_array(EveAccountAPIKeyInfoCharacters::where('characterID', $characterID)->pluck('keyID'), Session::get('valid_keys'))) { App::abort(404); } } // Get current working jobs $current_jobs = DB::table('character_industryjobs as a')->select(DB::raw("\n *, CASE\n when a.stationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000001)\n when a.stationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n when a.stationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID)\n when a.stationID>=61000000 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.stationID) end\n AS location,a.stationID AS locID"))->where('a.characterID', $characterID)->where('endDate', '>', date('Y-m-d H:i:s'))->orderBy('endDate', 'asc')->get(); // Get the passed jobs $finished_jobs = DB::table('character_industryjobs as a')->select(DB::raw("\n *, CASE\n when a.stationID BETWEEN 66015148 AND 66015151 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 66000000 AND 66014933 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID-6000001)\n when a.stationID BETWEEN 66014934 AND 67999999 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID-6000000)\n when a.stationID BETWEEN 60014861 AND 60014928 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n when a.stationID BETWEEN 60000000 AND 61000000 then\n (SELECT s.stationName FROM staStations AS s\n WHERE s.stationID=a.stationID)\n when a.stationID>=61000000 then\n (SELECT c.stationName FROM `eve_conquerablestationlist` AS c\n WHERE c.stationID=a.stationID)\n else (SELECT m.itemName FROM mapDenormalize AS m\n WHERE m.itemID=a.stationID) end\n AS location,a.stationID AS locID"))->where('a.characterID', $characterID)->where('endDate', '<=', date('Y-m-d H:i:s'))->orderBy('endDate', 'desc')->get(); // Return the view return View::make('character.view.industry')->with('characterID', $characterID)->with('current_jobs', $current_jobs)->with('finished_jobs', $finished_jobs); }