Skip to content

Commit

Permalink
Push initial code base
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenBaines committed Jun 5, 2022
0 parents commit f7ecc3b
Show file tree
Hide file tree
Showing 112 changed files with 33,181 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
34 changes: 34 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
APP_ENV=production
APP_DEBUG=false
APP_URL=https://reports.miraheze.org/
APP_KEY=<32 characters>

CACHE_DRIVER=file

DB_HOST=hostname
DB_PORT=port
DB_DATABASE=db
DB_USERNAME=user
DB_PASSWORD=password
MYSQL_ATTR_SSL_CA=/ca.crt

FILESYSTEM_DRIVER=public

LOG_CHANNEL=stack
LOG_LEVEL=debug

MAIL_MAILER=smtp
MAIL_HOST=host
MAIL_PORT=0000
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME=From Name

MEDIAWIKI_IDENTIFIER=
MEDIAWIKI_SECRET=
MEDIAWIKI_CALLBACK=
MEDIAWIKI_BASE=https://meta.miraheze.org

SESSION_DRIVER=file
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.idea
/.vscode
/tests
identifier.sqlite
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Release Notes

TSPortal follows a basic numerical increase system for releases and not Semantic Versioning.
The main reasoning behind this choice is the software is not built to be extended upon, therefore no stable public API exists.

## [Unreleased](https://github.com/miraheze/TSPortal/compare/v1...master)

## Version 1 (2022-05-30)

Initial commit of all base code!
19 changes: 19 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Miraheze TSPortal

Miraheze TSPortal is the platform Miraheze is transitioning over to use as its in-house built platform for handling reports, investigations, appeals and transparency.

It is designed by [Owen Baines](https://github.com/OwenBaines) and is managed on [Phabricator](https://phabricator.miraheze.org/project/board/71/).

## Code of Conduct

In order to ensure that the community is welcoming to all, please review and abide by the [Code of Conduct](https://meta.miraheze.org/wiki/Code_of_Conduct).

## Security Vulnerabilities

Please review [our security policy](https://meta.miraheze.org/wiki/Security) on how to report security vulnerabilities.

## License

This software is open-sourced software licensed under the [MIT license](LICENSE.md).
7 changes: 7 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Console;

use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel { }
7 changes: 7 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler { }
13 changes: 13 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
138 changes: 138 additions & 0 deletions app/Http/Controllers/DPAController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

namespace App\Http\Controllers;

use App\Models\DPA;
use App\Models\User;
use App\Rules\MirahezeUsernameRule;
use App\Rules\SameAccountRule;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;

/**
* Controller class for DPA request and actions
*/
class DPAController extends Controller
{
/**
* Indexes and shows all DPA requests that are open, filtered for non-privileged users
*
* @param Request $request
*
* @return Application|Factory|View
*/
public function index( Request $request )
{
$allDPAs = DPA::all();

if ( !$request->user()->hasFlag( 'ts' ) ) {
$allDPAs = $allDPAs->where( 'user', $request->user()->id )->whereNull( 'underage' );
}

return view( 'dpa' )->with( 'dpas', $allDPAs->whereNull( 'completed' ) );
}

/**
* Shows a specific DPA request
*
* @param DPA $dpa
*
* @return Application|Factory|View
*/
public function show( DPA $dpa )
{
return view( 'dpa.view' )->with( 'dpa', $dpa );
}

/**
* Stores a processed new DPA request
*
* @param DPA $dpa
* @param Request $request
*
* @return Application|RedirectResponse|Redirector
*/
public function store( DPA $dpa, Request $request )
{
$request->validate(
[
'username' => [ new MirahezeUsernameRule ]
]
);

$dpaUser = User::findOrCreate( $request->input( 'username' ) );

if ( $request->input( 'username-type' ) == 'own-removal' ) {
$request->validate(
[
'username' => [ new SameAccountRule ]
]
);

$dpa::factory()->create(
[
'user' => $dpaUser,
'statutory' => (bool)$request->input( 'dpa' )
]
);
} else {
$dpa::factory()->create(
[
'user' => $dpaUser,
'underage' => $request->input( 'evidence' ),
'statutory' => true
]
);
}

$event = ( count( $dpaUser->events ) == 0 ) ? 'created-dpa' : 'new-dpa';

$dpaUser->newEvent( $event );

return redirect( '/dpa' );
}

/**
* Shows the form to create a new DPA request
*
* @return Application|Factory|View
*/
public function create()
{
return view( 'dpa.new' );
}

/**
* Processor for updating a request once processed
*
* @param DPA $dpa
* @param Request $request
*
* @return RedirectResponse
*/
public function update( DPA $dpa, Request $request ): RedirectResponse
{
if ( $request->input( 'approve' ) ?? false ) {
$dpa->update( [
'completed' => now()
] );

$dpa->subject->update( [
'username' => 'MirahezeGDPR ' . $dpa->id
] );
} else {
$dpa->update( [
'completed' => now(),
'reject' => $request->input( 'reason' )
] );
}

$dpa->subject->newEvent( 'closed-dpa', $request->user() );

return back();
}
}
Loading

0 comments on commit f7ecc3b

Please sign in to comment.