purge wiki button update

This commit is contained in:
2020-05-07 01:46:04 -05:00
parent 3c50143dd4
commit e0f83179fd
3 changed files with 27 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ use Log;
//Libraries
use Seat\Eseye\Exceptions\RequestFailedException;
use App\Library\Esi\Esi;
use App\Library\Wiki\WikiHelper;
//Models
use App\Models\User\User;
@@ -18,6 +19,8 @@ use App\Models\Esi\EsiToken;
use App\Models\User\UserPermission;
use App\Models\User\UserRole;
use App\Models\Admin\AllowedLogin;
use App\Models\Doku\DokuMember;
use App\Models\Doku\DokuUser;
/**
@@ -184,6 +187,13 @@ class PurgeUsers extends Command
EsiToken::where([
'character_id' => $user->character_id,
])->delete();
//Delete the user from the wiki
$wikiHelper = new WikiHelper;
//Get the uid from the wiki tables utilizing the character's name
$uid = DokuUser::where(['name' => $user->name])->first();
$wikiHelper->DeleteWikiUser($uid);
}
}
}

View File

@@ -470,19 +470,24 @@ class AdminController extends Controller
$lookup = new LookupHelper;
$wikiHelper = new WikiHelper;
//Get all of the users from the database
$users = User::all();
//Search the names and verify against the lookup table
//to find the corporation and / or alliance they belong to.
foreach($users as $user) {
//Let's look up the character in the user table by their name.
//If no name is found, then delete the user and have them start over with the wiki permissions
$count = User::where(['name' => $user])->count();
$count = DokuUser::where(['name' => $user->name])->count();
//If the user is found, then check if they are allowed on the wiki.
//If the the count == 0, then the user wasn't found on the wiki, so do nothing.
if($count > 0) {
//If the user is not allowed, then delete the user, otherwise, leave the user untouched
if(!$wikiHelper->AllowedUser($user)) {
$wikiHelper->DeleteWikiUser($user);
if(!$wikiHelper->AllowedUser($user->name)) {
$uid = $wikiHelper->GetUID($user->name);
$wikiHelper->DeleteWikiUser($uid);
}
} else {
$wikiHelper->DeleteWikiUser($user);
}
}

View File

@@ -152,4 +152,11 @@ class WikiHelper {
//Delete the user from the user table
DokuUser::where(['id' => $userId])->delete();
}
/**
* Get uid from name
*/
public function GetUID($name) {
return DokuUser::where(['name' => $name])->first();
}
}