This repository was archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dfccc3b
Showing
38 changed files
with
2,160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.DS_Store | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
_releases | ||
_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Kieran\Bans\Admin\Controller; | ||
|
||
use XF\Mvc\ParameterBag; | ||
use Kieran\Support\Entity\TicketType; | ||
|
||
class Bans extends \XF\Admin\Controller\AbstractController | ||
{ | ||
|
||
public function actionTypes(ParameterBag $params) | ||
{ | ||
return $this->rerouteController('Kieran\Bans:Types', 'index', $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Kieran\Bans\Admin\Controller; | ||
|
||
use XF\Mvc\ParameterBag; | ||
use Kieran\Bans\Entity\BanType; | ||
|
||
class Types extends \XF\Admin\Controller\AbstractController | ||
{ | ||
|
||
public function actionIndex(ParameterBag $params) | ||
{ | ||
return $this->view('Kieran\Bans:BanType', 'kieran_bans_types', ['types' => $this->getTypeRepo()->getTypes()]); | ||
} | ||
|
||
public function actionEdit(ParameterBag $params) | ||
{ | ||
$type = $this->assertTypeExists($params['type_id']); | ||
return $this->typeAddEdit($type); | ||
} | ||
|
||
public function actionAdd(ParameterBag $params) | ||
{ | ||
$type = $this->getTypeRepo()->setupBaseType(); | ||
return $this->typeAddEdit($type); | ||
} | ||
|
||
protected function typeAddEdit(BanType $type) | ||
{ | ||
$viewParams = [ | ||
'type' => $type, | ||
'success' => $this->filter('success', 'bool'), | ||
]; | ||
return $this->view('Kieran\Bans:BanType\Add', 'kieran_bans_types_edit', $viewParams); | ||
} | ||
|
||
public function actionSave(ParameterBag $params) | ||
{ | ||
$this->assertPostOnly(); | ||
|
||
if ($params->type_id) | ||
{ | ||
$type = $this->assertTypeExists($params->type_id); | ||
} | ||
else | ||
{ | ||
$type = $this->getTypeRepo()->setupBaseType(); | ||
} | ||
|
||
$this->typeSaveProcess($type)->run(); | ||
|
||
return $this->redirect($this->buildLink('bans/types')); | ||
} | ||
|
||
public function actionDelete(ParameterBag $params) | ||
{ | ||
$type = $this->assertTypeExists($params->type_id); | ||
|
||
if (!$type->canDelete()) | ||
{ | ||
return $this->error(\XF::phrase('type_cannot_be_deleted_associated_with_ban_explain')); | ||
} | ||
|
||
$type->delete(); | ||
|
||
return $this->redirect($this->buildLink('bans/types')); | ||
} | ||
|
||
protected function typeSaveProcess(BanType $type) | ||
{ | ||
|
||
$form = $this->formAction(); | ||
|
||
$input = $this->filter([ | ||
'type_id' => 'str', | ||
'name' => 'str', | ||
]); | ||
|
||
$form->basicEntitySave($type, $input); | ||
$form->run(); | ||
|
||
return $form; | ||
} | ||
|
||
protected function assertTypeExists($id, $with = null, $phraseKey = null) | ||
{ | ||
return $this->assertRecordExists('Kieran\Bans:BanType', $id, $with, $phraseKey); | ||
} | ||
|
||
protected function getTypeRepo() | ||
{ | ||
return $this->repository('Kieran\Bans:BanType'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Kieran\Bans\Attachment; | ||
|
||
use XF\Attachment\AbstractHandler; | ||
use XF\Entity\Attachment; | ||
use XF\Mvc\Entity\Entity; | ||
|
||
class Ban extends AbstractHandler | ||
{ | ||
public function canView(Attachment $attachment, Entity $container, &$error = null) | ||
{ | ||
return $container->canView(); | ||
} | ||
|
||
public function canManageAttachments(array $context, &$error = null) | ||
{ | ||
return true; | ||
} | ||
|
||
public function onAttachmentDelete(Attachment $attachment, Entity $container = null) | ||
{ | ||
if (!$container) | ||
{ | ||
return; | ||
} | ||
|
||
$container->attach_count--; | ||
$container->save(); | ||
} | ||
|
||
public function getConstraints(array $context) | ||
{ | ||
$constraints = \XF::repository('XF:Attachment')->getDefaultAttachmentConstraints(); | ||
$constraints['extensions'][] = 'dem'; | ||
$constraints['extensions'][] = 'mp4'; | ||
$constraints['size'] = 5242880; | ||
return $constraints; | ||
} | ||
|
||
public function getContainerIdFromContext(array $context) | ||
{ | ||
return isset($context['note_id']) ? intval($context['note_id']) : null; | ||
} | ||
|
||
public function getContainerLink(Entity $container, array $extraParams = []) | ||
{ | ||
return \XF::app()->router('public')->buildLink('bans', $container, $extraParams); | ||
} | ||
|
||
public function getContext(Entity $entity = null, array $extraContext = []) | ||
{ | ||
|
||
if ($entity instanceof \Kieran\Bans\Entity\Ban) | ||
{ | ||
$extraContext['ban_id'] = $entity->ban_id; | ||
} | ||
else if ($entity instanceof \Kieran\Bans\Entity\BanNote) | ||
{ | ||
$extraContext['note_id'] = $entity->note_id; | ||
} | ||
else if (!$entity) | ||
{ | ||
// need nothing | ||
} | ||
else | ||
{ | ||
throw new \InvalidArgumentException("Entity must be ban"); | ||
} | ||
|
||
return $extraContext; | ||
} | ||
} |
Oops, something went wrong.