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

Commit

Permalink
Banks not linking to admin accounts correctly #2
Browse files Browse the repository at this point in the history
  • Loading branch information
KieranFYI committed Feb 8, 2020
1 parent e23fb22 commit a669da9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
23 changes: 16 additions & 7 deletions Entity/Ban.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php

namespace Kieran\Bans\Entity;


use XF;
use XF\Draft;
use XF\Mvc\Entity\Entity;
use XF\Mvc\Entity\Structure;

class Ban extends Entity
{

public function canView() {
$visitor = \XF::visitor();
$visitor = XF::visitor();

if (!$visitor->user_id)
{
Expand Down Expand Up @@ -42,10 +44,17 @@ public function associateUser() {
}

$type = $this->getIdentityTypeRepo()->findIdentityType('steam');

if ($type == null) {
return;
}
}

if ($this->server_ip === $this->admin_ip) {
if (XF::options()->console_user > 0) {
$this->admin_user_id = XF::options()->console_user;
$this->save();
}
return;
}

$identity = $this->getIdentityRepo()->findIdentityByValueByType($this->admin_id, $type->identity_type_id);
if ($identity !== null && $identity->user_id > 0) {
Expand All @@ -55,7 +64,7 @@ public function associateUser() {
}

public function newNote() {
$visitor = \XF::visitor();
$visitor = XF::visitor();
if (!$visitor->user_id) {
return null;
}
Expand All @@ -80,7 +89,7 @@ public function getSteamid32() {

public function getDraftReply()
{
return \XF\Draft::createFromEntity($this, 'DraftReplies');
return Draft::createFromEntity($this, 'DraftReplies');
}

public function getRemaining() {
Expand Down Expand Up @@ -184,7 +193,7 @@ public static function getStructure(Structure $structure)
'ban_status' => ['type' => self::UINT, 'maxLength' => 1, 'default' => 0],
'type_id' => ['type' => self::STR, 'required' => true, 'nullable' => false, 'maxLength' => 25],
'ban_review' => ['type' => self::UINT, 'maxLength' => 1, 'default' => 0],
'timestamp' => ['type' => self::UINT, 'default' => \XF::$time],
'timestamp' => ['type' => self::UINT, 'default' => XF::$time],
];

$structure->getters = [
Expand Down
4 changes: 3 additions & 1 deletion _data/option_groups.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<option_groups/>
<option_groups>
<group group_id="bans" icon="fa-gavel" display_order="1" debug_only="0"/>
</option_groups>
7 changes: 6 additions & 1 deletion _data/options.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<options/>
<options>
<option option_id="console_user" edit_format="username" data_type="integer">
<default_value>0</default_value>
<relation group_id="bans" display_order="1"/>
</option>
</options>
4 changes: 4 additions & 0 deletions _data/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<phrase title="nav.bansCreated" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[Created Bans]]></phrase>
<phrase title="nav.bansManage" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[All Bans]]></phrase>
<phrase title="nav.bansMyBans" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[My Bans]]></phrase>
<phrase title="option.console_user" version_id="1000070" version_string="1.0.0"><![CDATA[Console User]]></phrase>
<phrase title="option_explain.console_user" version_id="1000070" version_string="1.0.0"><![CDATA[The user to set for console bans]]></phrase>
<phrase title="option_group.bans" version_id="1000070" version_string="1.0.0"><![CDATA[Bans]]></phrase>
<phrase title="option_group_description.bans" version_id="1000070" version_string="1.0.0"><![CDATA[]]></phrase>
<phrase title="permission.bans_bans_create" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[Create bans]]></phrase>
<phrase title="permission.bans_bans_manage" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[Manage bans]]></phrase>
<phrase title="permission.bans_bans_view" version_id="1000000" version_string="1.0.0 Alpha"><![CDATA[View bans]]></phrase>
Expand Down

0 comments on commit a669da9

Please sign in to comment.