Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
Change ply to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
KieranFYI committed Jan 17, 2020
1 parent dfccc3b commit 8e65045
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
18 changes: 9 additions & 9 deletions Entity/Ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function canView() {

public function createFirst($message='') {
$note = $this->newNote();
$note->user_id = $this->ply_user_id;
$note->user_id = $this->admin_user_id;
$note->timestamp = $this->timestamp;
$note->data = [
'Target UID' => $this->getSteamid32(),
Expand All @@ -38,9 +38,9 @@ public function createFirst($message='') {

public function associateUser() {
$type = $this->getIdentityTypeRepo()->findIdentityType('steam');
$identity = $this->getIdentityRepo()->findIdentityByValueByType($this->ply_id, $type->identity_type_id);
$identity = $this->getIdentityRepo()->findIdentityByValueByType($this->admin_id, $type->identity_type_id);
if ($identity !== null && $identity->user_id > 0) {
$this->ply_user_id = $identity->user_id;
$this->admin_user_id = $identity->user_id;
$this->save();
}
}
Expand Down Expand Up @@ -116,11 +116,11 @@ public function getLength() {

public function getCreatedBy() {

if (!$ban->ply_user_id) {
if (!$ban->admin_user_id) {
$this->associateUser();
}

return $this->em()->find('XF:User', $this->ply_user_id);
return $this->em()->find('XF:User', $this->admin_user_id);
}

public function getStatusIcon() {
Expand Down Expand Up @@ -163,10 +163,10 @@ public static function getStructure(Structure $structure)
$structure->columns = [
'ban_id' => ['type' => self::UINT, 'autoIncrement' => true, 'nullable' => false, 'changeLog' => false],
'server_ip' => ['type' => self::STR, 'maxLength' => 55, 'default' => 'website'],
'ply_id' => ['type' => self::BINARY, 'maxLength' => 64],
'ply_user_id' => ['type' => self::UINT, 'maxLength' => 11, 'default' => 0],
'ply_ip' => ['type' => self::STR, 'maxLength' => 55],
'ply_name' => ['type' => self::STR, 'maxLength' => 64],
'admin_id' => ['type' => self::BINARY, 'maxLength' => 64],
'admin_user_id' => ['type' => self::UINT, 'maxLength' => 11, 'default' => 0],
'admin_ip' => ['type' => self::STR, 'maxLength' => 55],
'admin_name' => ['type' => self::STR, 'maxLength' => 64],
'target_id' => ['type' => self::BINARY, 'maxLength' => 64, 'required' => true],
'target_ip' => ['type' => self::STR, 'maxLength' => 55, 'default' => '0.0.0.0'],
'target_name' => ['type' => self::STR, 'maxLength' => 65, 'required' => true],
Expand Down
28 changes: 14 additions & 14 deletions Pub/Controller/Bans.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function actionCreated(ParameterBag $params) {
$perPage = 25;

$filters = $this->getFilterInput();
$filters['ply_user_id'] = \XF::visitor()->user_id;
$filters['admin_user_id'] = \XF::visitor()->user_id;
$finder = $this->getBanRepo()->findPaged($filters, $page, $perPage);
$total = $finder->total();

Expand Down Expand Up @@ -224,8 +224,8 @@ public function actionFilters(ParameterBag $params)
protected function getFilterInput() {

$input = $this->filter([
'ply_user' => 'str',
'ply_user_id' => 'uint',
'admin_user' => 'str',
'admin_user_id' => 'uint',
'banned_uid' => 'str',
'status' => 'array',
'type' => 'array',
Expand All @@ -234,12 +234,12 @@ protected function getFilterInput() {
'direction' => 'str',
]);

if ($input['ply_user_id']) {
$filters['ply_user_id'] = $input['ply_user_id'];
} else if ($input['ply_user']) {
$user = $this->em()->findOne('XF:User', ['username' => $input['ply_user']]);
if ($input['admin_user_id']) {
$filters['admin_user_id'] = $input['admin_user_id'];
} else if ($input['admin_user']) {
$user = $this->em()->findOne('XF:User', ['username' => $input['admin_user']]);
if ($user) {
$filters['ply_user_id'] = $user->user_id;
$filters['admin_user_id'] = $user->user_id;
}
}

Expand Down Expand Up @@ -297,10 +297,10 @@ public function banSaveProcess($ban) {

$visitor = \XF::visitor();
$form->basicEntitySave($ban, [
'ply_name' => $visitor->username,
'ply_id' => $this->getPrimarySteamID(),
'ply_user_id' => $visitor->user_id,
'ply_ip' => $this->app()->request()->getIp(),
'admin_name' => $visitor->username,
'admin_id' => $this->getPrimarySteamID(),
'admin_user_id' => $visitor->user_id,
'admin_ip' => $this->app()->request()->getIp(),
]);

return $form;
Expand Down Expand Up @@ -385,7 +385,7 @@ public function actionView(ParameterBag $params) {
$ban->createFirst();
}

if ($ban->ply_user_id != \XF::visitor()->user_id && !$this->canView()) {
if ($ban->admin_user_id != \XF::visitor()->user_id && !$this->canView()) {
return $this->noPermission();
}

Expand Down Expand Up @@ -445,7 +445,7 @@ public function actionReinstate(ParameterBag $params) {

public function actionAppeal(ParameterBag $params) {
$ban = $this->assertBanExists($params->ban_id);
if ($ban->ply_user_id != \XF::visitor()->user_id) {
if ($ban->admin_user_id != \XF::visitor()->user_id) {
return $this->noPermission();
}

Expand Down
8 changes: 4 additions & 4 deletions Repository/Ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public function findPaged($filters, $page = 1, $perPage = 25) {
private function buildQuery($filters) {
$finder = $this->finder('Kieran\Bans:Ban')->order('ban_id', 'desc');

if (isset($filters['ply_user_id'])) {
$finder->where('ply_user_id', $filters['ply_user_id']);
if (isset($filters['admin_user_id'])) {
$finder->where('admin_user_id', $filters['admin_user_id']);
}

if (isset($filters['ply_id'])) {
$finder->where('ply_id', $filters['ply_id']);
if (isset($filters['admin_id'])) {
$finder->where('admin_id', $filters['admin_id']);
}

if (isset($filters['banned_uid'])) {
Expand Down
8 changes: 4 additions & 4 deletions Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function installStep1(array $stepParams = [])
{
$table->addColumn('ban_id', 'int')->autoIncrement();
$table->addColumn('server_ip', 'varchar', 55)->setDefault('website');
$table->addColumn('ply_id', 'bigint', 64);
$table->addColumn('ply_user_id', 'int', 11)->setDefault(0);
$table->addColumn('ply_ip', 'varchar', 55);
$table->addColumn('ply_name', 'varchar', 64);
$table->addColumn('admin_id', 'bigint', 64);
$table->addColumn('admin_user_id', 'int', 11)->setDefault(0);
$table->addColumn('admin_ip', 'varchar', 55);
$table->addColumn('admin_name', 'varchar', 64);
$table->addColumn('target_id', 'bigint', 64);
$table->addColumn('target_ip', 'varchar', 55);
$table->addColumn('target_name', 'varchar', 65);
Expand Down
4 changes: 2 additions & 2 deletions _data/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<div class="menu-row menu-row--separated">
{{ phrase('admin:') }}
<div class="u-inputSpacer">
<xf:textbox name="ply_user" value="{{ $adminFilter ? $adminFilter.username : '' }}" ac="single"
<xf:textbox name="admin_user" value="{{ $adminFilter ? $adminFilter.username : '' }}" ac="single"
maxlength="{{ max_length($xf.visitor, 'username') }}" />
</div>
</div>
Expand Down Expand Up @@ -615,7 +615,7 @@
</div>
<div class="block">
<xf:if is="($canManage || $xf.visitor.user_id == $ban.ply_user_id) && $ban.remaining_time >= 0">
<xf:if is="($canManage || $xf.visitor.user_id == $ban.admin_user_id) && $ban.remaining_time >= 0">
<xf:form action="{{ link('bans/reply', $ban) }}"
ajax="true"
draft="{{ link('bans/draft', $ban) }}"
Expand Down

0 comments on commit 8e65045

Please sign in to comment.