2017-02-18 01:23:27 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 04:43:01 +02:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-02-18 01:23:27 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Observers;
|
|
|
|
|
|
|
|
use Pterodactyl\Events;
|
|
|
|
use Pterodactyl\Models\Subuser;
|
|
|
|
use Pterodactyl\Notifications\AddedToServer;
|
|
|
|
use Pterodactyl\Notifications\RemovedFromServer;
|
|
|
|
|
|
|
|
class SubuserObserver
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser creating event.
|
|
|
|
*
|
2017-08-22 05:10:48 +02:00
|
|
|
* @param \Pterodactyl\Models\Subuser $subuser
|
2017-02-18 01:23:27 +01:00
|
|
|
*/
|
|
|
|
public function creating(Subuser $subuser)
|
|
|
|
{
|
|
|
|
event(new Events\Subuser\Creating($subuser));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser created event.
|
|
|
|
*
|
2017-08-22 05:10:48 +02:00
|
|
|
* @param \Pterodactyl\Models\Subuser $subuser
|
2017-02-18 01:23:27 +01:00
|
|
|
*/
|
|
|
|
public function created(Subuser $subuser)
|
|
|
|
{
|
|
|
|
event(new Events\Subuser\Created($subuser));
|
|
|
|
|
|
|
|
$subuser->user->notify((new AddedToServer([
|
|
|
|
'user' => $subuser->user->name_first,
|
|
|
|
'name' => $subuser->server->name,
|
|
|
|
'uuidShort' => $subuser->server->uuidShort,
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser deleting event.
|
|
|
|
*
|
2017-08-22 05:10:48 +02:00
|
|
|
* @param \Pterodactyl\Models\Subuser $subuser
|
2017-02-18 01:23:27 +01:00
|
|
|
*/
|
|
|
|
public function deleting(Subuser $subuser)
|
|
|
|
{
|
|
|
|
event(new Events\Subuser\Deleting($subuser));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser deleted event.
|
|
|
|
*
|
2017-08-22 05:10:48 +02:00
|
|
|
* @param \Pterodactyl\Models\Subuser $subuser
|
2017-02-18 01:23:27 +01:00
|
|
|
*/
|
|
|
|
public function deleted(Subuser $subuser)
|
|
|
|
{
|
|
|
|
event(new Events\Subuser\Deleted($subuser));
|
|
|
|
|
|
|
|
$subuser->user->notify((new RemovedFromServer([
|
|
|
|
'user' => $subuser->user->name_first,
|
|
|
|
'name' => $subuser->server->name,
|
|
|
|
])));
|
|
|
|
}
|
|
|
|
}
|