Beispiel #1
0
 public static function Update()
 {
     // Learn about all of the banned calls that
     // we are aware of
     $banned_calls = \EveBannedCall::all();
     // For every banned call that we have, prepare
     // a notification to send
     foreach ($banned_calls as $banned_call) {
         // Super users will be receiving this notification,
         // so loop over the current superusers that we
         // have
         foreach (\Auth::findAllUsersWithAccess('superuser') as $super_user) {
             // Compile the full notification
             $notification_type = 'API';
             $notification_title = 'Banned Call';
             $notification_text = 'The SeAT backend has banned the ' . $banned_call->scope . '\\' . $banned_call->api . ' API call for key ' . $banned_call->ownerID . '. Reason: ' . $banned_call->reason . PHP_EOL . 'Key characters: ' . PHP_EOL;
             // Add some information about the characters on this key
             foreach (\EveAccountAPIKeyInfoCharacters::where('keyID', $banned_call->ownerID)->get() as $character) {
                 $notification_text .= ' - ' . $character->characterName . PHP_EOL;
             }
             // Send the notification
             BaseNotify::sendNotification($super_user->id, $notification_type, $notification_title, $notification_text);
         }
     }
 }
Beispiel #2
0
 public static function Update()
 {
     // Before we even bother getting to the point of
     // determining which members are inactive
     // check if there are any users
     // configured that have
     // the required roles
     $recruiters = \Auth::findAllUsersWithAccess('recruiter');
     // If there are none with the role, just stop
     if (count($recruiters) <= 0) {
         return;
     }
     // Now we will loop over the recruiters and send
     // a notification about the member inactivity.
     // We should actually batch the members so
     // that we dont spam a 100 entries per
     // recruiter for inactivities. But
     // that can come later :D
     foreach ($recruiters as $recruiter) {
         // Do a lookup to see how many months without a login should
         // be considered as a inactive member
         (int) ($inactive_months = SettingHelper::getSetting('seatnotify_member_inactivity_months'));
         // Now, get a list of members that have not
         // logged in for 1 month.
         $members = \EveCorporationMemberTracking::where('logoffDateTime', '<', \DB::raw('date_sub(NOW(), INTERVAL ' . $inactive_months . ' MONTH)'))->get();
         // If there are no members, continue
         if (!$members) {
             continue;
         }
         // For every member that we have found, we want
         // to send a notification for.
         foreach ($members as $member) {
             // Determine if this recruiter that we have
             // has access to the corporation that the
             // member is a part of.
             //
             // Is this step really needed?
             if (BaseNotify::canAccessCorp($recruiter->id, $member->corporationID)) {
                 // Get the corporation name for the notification
                 $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $member->corporationID)->pluck('corporationName');
                 // Prepare the total notification
                 $notification_type = 'Corporation';
                 $notification_title = 'Member Inactivity';
                 $notification_text = $member->name . ' in ' . $corporation_name . ' has been inactive ' . 'for ' . $inactive_months . ' month(s). The last logon time was ' . \Carbon\Carbon::parse($member->logonDateTime)->diffFOrHumans() . ' with the last ' . 'known location being ' . $member->location . '.';
                 // Send the notification
                 BaseNotify::sendNotification($recruiter->id, $notification_type, $notification_title, $notification_text);
             }
         }
     }
 }
Beispiel #3
0
 public static function Update()
 {
     // Grab all of the API keys that SeAT
     // is aware of
     $seat_keys = \SeatKey::all();
     // Looping over all of the keys, we will find
     // the superusers and send them the
     // notification about this
     foreach ($seat_keys as $seat_key) {
         if ($seat_key->isOk == 0) {
             // We have a key that is not OK, find
             // some people to tell about this!
             foreach (\Auth::findAllUsersWithAccess('superuser') as $super_user) {
                 // Compile the full notification
                 $notification_type = 'API';
                 $notification_title = 'Disabled Key';
                 $notification_text = 'The SeAT backend has disabled API key ' . $seat_key->keyID . '. ' . 'The last error was: ' . $seat_key->lastError;
                 // Send the Notification
                 BaseNotify::sendNotification($super_user->id, $notification_type, $notification_title, $notification_text);
             }
         }
     }
 }
Beispiel #4
0
 public static function sendNotification($user_id, $type, $title, $text)
 {
     // Generate a hash to lookup
     $hash = BaseNotify::makeNotificationHash($user_id, $type, $title, $text);
     // Check the existance of the hash in the notifications table
     if (!\SeatNotification::where('hash', '=', $hash)->exists()) {
         // Send the new noticiation
         $notification = new \SeatNotification();
         $notification->user_id = $user_id;
         $notification->type = $type;
         $notification->title = $title;
         $notification->text = $text;
         $notification->hash = $hash;
         $notification->save();
         // Check if the user is configured to receive the
         // notifications via email
         if (SettingHelper::getSetting('email_notifications', false, $user_id) == 'true') {
             // Prepare data to be sent along with the email. These
             // are accessed by their keys in the email template
             $data = array('type' => $type, 'title' => $title, 'text' => $text, 'notification_id' => $notification->id);
             // Send the notifications email
             \Mail::send('emails.notifications.notify', $data, function ($message) use($user_id, $title) {
                 $message->to(\Auth::findUserById($user_id)->email, \Auth::findUserById($user_id)->username)->subject('New SeAT ' . $title . ' notification.');
             });
         }
         return true;
     }
     return false;
 }
Beispiel #5
0
 public static function Update()
 {
     // Before we even bother getting to the point of
     // determining which starbases would need a
     // notification to be sent, check if there
     // are any users configured that have
     // ther required roles
     $pos_role_users = \Auth::findAllUsersWithAccess('pos_manager');
     // If there are none with the role, just stop
     if (count($pos_role_users) <= 0) {
         return;
     }
     // Next, grab the starbases that we know of
     $starbases = \DB::table('corporation_starbaselist')->select('corporation_starbaselist.corporationID', 'corporation_starbaselist.itemID', 'corporation_starbaselist.moonID', 'corporation_starbaselist.state', 'corporation_starbaselist.stateTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbasedetail.useStandingsFrom', 'corporation_starbasedetail.onAggression', 'corporation_starbasedetail.onCorporationWar', 'corporation_starbasedetail.allowCorporationMembers', 'corporation_starbasedetail.allowAllianceMembers', 'corporation_starbasedetail.fuelBlocks', 'corporation_starbasedetail.strontium', 'corporation_starbasedetail.starbaseCharter', 'invTypes.typeID', 'invTypes.typeName', 'mapDenormalize.itemName', 'mapDenormalize.security', 'invNames.itemName', 'map_sovereignty.solarSystemName', 'corporation_starbasedetail.updated_at')->join('corporation_starbasedetail', 'corporation_starbaselist.itemID', '=', 'corporation_starbasedetail.itemID')->join('mapDenormalize', 'corporation_starbaselist.locationID', '=', 'mapDenormalize.itemID')->join('invNames', 'corporation_starbaselist.moonID', '=', 'invNames.itemID')->join('invTypes', 'corporation_starbaselist.typeID', '=', 'invTypes.typeID')->leftJoin('map_sovereignty', 'corporation_starbaselist.locationID', '=', 'map_sovereignty.solarSystemID')->orderBy('invNames.itemName', 'asc')->get();
     $state_needed = array();
     // Looping over the starbases, check what the status of it.
     // Currently we only send a notification if it went
     // offline or has been re-inforced
     foreach ($starbases as $starbase) {
         // Check the status of the starbase and
         // switch between them, updating the
         // state of the tower for a message
         $starbase_status = null;
         switch ($starbase->state) {
             case 1:
                 $starbase_status = 'Anchored / Offline';
                 break;
             case 3:
                 $starbase_status = 'Reinforced';
             default:
                 # code...
                 break;
         }
         // If the starbase was in any of the statusses
         // that we case about, attempt to find users
         // to notify
         if (!is_null($starbase_status)) {
             foreach ($pos_role_users as $pos_user) {
                 // A last check is done now to make sure we
                 // don't let everyone for every corp know
                 // about a specific corp. No, we first
                 // check that the user we want to
                 // send to has the role for that
                 // specific corp too!
                 if (BaseNotify::canAccessCorp($pos_user->id, $starbase->corporationID)) {
                     // Ok! Time to finally get to pushing the
                     // notification out! :D
                     // Get the corporation name for the notification
                     $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $starbase->corporationID)->pluck('corporationName');
                     // Prepare the total notification
                     $notification_type = 'Starbase';
                     $notification_title = 'Dangerous Status';
                     $notification_text = 'The ' . $starbase->typeName . ' at ' . $starbase->itemName . ' owned by ' . $corporation_name . ' is now ' . $starbase_status;
                     // Send the notification
                     BaseNotify::sendNotification($pos_user->id, $notification_type, $notification_title, $notification_text);
                 }
             }
         }
     }
 }
Beispiel #6
0
 public static function Update()
 {
     // Before we even bother getting to the point of
     // determining which starbases would need a
     // notification to be sent, check if there
     // are any users configured that have
     // ther required roles
     $pos_role_users = \Auth::findAllUsersWithAccess('pos_manager');
     // If there are none with the role, just stop
     if (count($pos_role_users) <= 0) {
         return;
     }
     // Next, grab the list of starbases that we are aware of
     $starbases = \DB::table('corporation_starbaselist')->select('corporation_starbaselist.corporationID', 'corporation_starbaselist.itemID', 'corporation_starbaselist.moonID', 'corporation_starbaselist.state', 'corporation_starbaselist.stateTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbasedetail.useStandingsFrom', 'corporation_starbasedetail.onAggression', 'corporation_starbasedetail.onCorporationWar', 'corporation_starbasedetail.allowCorporationMembers', 'corporation_starbasedetail.allowAllianceMembers', 'corporation_starbasedetail.fuelBlocks', 'corporation_starbasedetail.strontium', 'corporation_starbasedetail.starbaseCharter', 'invTypes.typeID', 'invTypes.typeName', 'mapDenormalize.itemName', 'mapDenormalize.security', 'invNames.itemName', 'map_sovereignty.solarSystemName', 'corporation_starbasedetail.updated_at')->join('corporation_starbasedetail', 'corporation_starbaselist.itemID', '=', 'corporation_starbasedetail.itemID')->join('mapDenormalize', 'corporation_starbaselist.locationID', '=', 'mapDenormalize.itemID')->join('invNames', 'corporation_starbaselist.moonID', '=', 'invNames.itemID')->join('invTypes', 'corporation_starbaselist.typeID', '=', 'invTypes.typeID')->leftJoin('map_sovereignty', 'corporation_starbaselist.locationID', '=', 'map_sovereignty.solarSystemID')->orderBy('invNames.itemName', 'asc')->get();
     // To determine the fuel needed, we need to get some
     // values out there that tell us *how* much fuel
     // certain towers need. So, we will set a base
     // amount for each of them. Should this
     // change in the future, then we can
     // simply edit the value here
     // The final usage once we have determined the tower
     // type
     $usage = 0;
     $stront_usage = 0;
     // The base values for the tower sizes
     // ... fuel for non sov towers ...
     $large_usage = 40;
     $medium_usage = 20;
     $small_usage = 10;
     // ... and sov towers
     $sov_large_usage = 30;
     $sov_medium_usage = 15;
     $sov_small_usage = 8;
     // Stront usage
     $stront_large = 400;
     $stront_medium = 200;
     $stront_small = 100;
     // Now, we will loop over the starbases that we know if and determine
     // the size of the tower, along with the location of the tower.
     // Towers anchored in sov space get to use less fuel.
     //
     // The result of this loop should have $usage and $stront_usage
     // populated with the correct value for the tower in question
     foreach ($starbases as $starbase) {
         // Lets check if the tower is anchored in space where the
         // owner of it holds sov.
         $sov_tower = false;
         // Get the allianceID that the corporation is a member of
         $alliance_id = \DB::table('corporation_corporationsheet')->where('corporationID', $starbase->corporationID)->pluck('allianceID');
         // Check if the alliance_id was actually determined. If so,
         // do the sov_towers loop, else we just set the
         if ($alliance_id) {
             // Lets see if this tower is in a sov system
             $sov_location = \DB::table('corporation_starbaselist')->whereIn('locationID', function ($location) use($alliance_id) {
                 $location->select('solarSystemID')->from('map_sovereignty')->where('factionID', 0)->where('allianceID', $alliance_id);
             })->where('corporationID', $starbase->corporationID)->where('itemID', $starbase->itemID)->first();
             if ($sov_location) {
                 $sov_tower = true;
             }
         }
         // With the soverenity status known, move on to
         // determine the size of the tower.
         if (strpos($starbase->typeName, 'Small') !== false) {
             $stront_usage = $stront_small;
             $usage = $sov_tower ? $sov_small_usage : $small_usage;
         } elseif (strpos($starbase->typeName, 'Medium') !== false) {
             $stront_usage = $stront_medium;
             $usage = $sov_tower ? $sov_medium_usage : $medium_usage;
         } else {
             $stront_usage = $stront_large;
             $usage = $sov_tower ? $sov_large_usage : $large_usage;
         }
         // Now we finally have $usage and $stront_usage known!
         // Lets get to the part where we finally check if
         // there is enough reserves. If not, do what
         // we came for and notify someone
         // If now plus (the fuel amount devided by the usage) muliplied
         // by hours is less than the configured days, send a
         // notification
         // Retreive the configured days ...
         (int) ($warning_days = SettingHelper::getSetting('seatnotify_fuel_warning_days'));
         // ... and process a notification if required
         if (\Carbon\Carbon::now()->addHours($starbase->fuelBlocks / $usage)->lte(\Carbon\Carbon::now()->addDays($warning_days))) {
             // OK! We need to tell someone that their towers fuel is
             // going to be running out soon!
             foreach ($pos_role_users as $pos_user) {
                 // A last check is done now to make sure we
                 // don't let everyone for every corp know
                 // about a specific corp. No, we first
                 // check that the user we want to
                 // send to has the role for that
                 // specific corp too!
                 if (BaseNotify::canAccessCorp($pos_user->id, $starbase->corporationID)) {
                     // Ok! Time to finally get to pushing the
                     // notification out! :D
                     // Get the corporation name for the notification
                     $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $starbase->corporationID)->pluck('corporationName');
                     // Prepare the total notification
                     $notification_type = 'Starbase';
                     $notification_title = 'Low Fuel Reserve';
                     $notification_text = 'The ' . $starbase->typeName . ' at ' . $starbase->itemName . ' owned by ' . $corporation_name . ' has ' . $starbase->fuelBlocks . ' fuel blocks left. The estimated offline time is ' . \Carbon\Carbon::now()->addHours($starbase->fuelBlocks / $usage)->diffForHumans() . '.';
                     // Send the notification
                     BaseNotify::sendNotification($pos_user->id, $notification_type, $notification_title, $notification_text);
                 }
             }
         }
         // End fuel left over if()
         // Check how many starbase charters are left. We
         // will have to check the security of the
         // anchored system to ensure we dont
         // spazz out and notifify about
         // 0sec towers.
         //
         // If the security status of the system the tower
         // is anchored in is > 5, check the charters
         if ($starbase->security >= 5) {
             if (Carbon\Carbon::now()->addHours($starbase->starbaseCharter / 1)->lte(Carbon\Carbon::now()->addDays($warning_days))) {
                 // OK! We need to tell someone that their towers charters is
                 // going to be running out soon!
                 foreach ($pos_role_users as $pos_user) {
                     // A last check is done now to make sure we
                     // don't let everyone for every corp know
                     // about a specific corp. No, we first
                     // check that the user we want to
                     // send to has the role for that
                     // specific corp too!
                     if (BaseNotify::canAccessCorp($pos_user->id, $starbase->corporationID)) {
                         // Ok! Time to finally get to pushing the
                         // notification out! :D
                         // Get the corporation name for the notification
                         $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $starbase->corporationID)->pluck('corporationName');
                         // Prepare the total notification
                         $notification_type = 'Starbase';
                         $notification_title = 'Low Charter Reserve';
                         $notification_text = 'The ' . $starbase->typeName . ' at ' . $starbase->itemName . ' owned by ' . $corporation_name . ' has ' . $starbase->fuelBlocks . ' starbase charters left. The estimated offline time is ' . \Carbon\Carbon::now()->addHours($starbase->starbaseCharter / 1)->diffForHumans() . '.';
                         // Send the notification
                         BaseNotify::sendNotification($pos_user->id, $notification_type, $notification_title, $notification_text);
                     }
                 }
             }
         }
         // End charters left over if()
     }
 }