forked from inex/IXP-Manager
-
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.
[NF] - doctrine to eloquent controllers
- Loading branch information
Showing
51 changed files
with
842 additions
and
1,671 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
namespace IXP\Http\Controllers; | ||
|
||
/* | ||
* Copyright (C) 2009 - 2019 Internet Neutral Exchange Association Company Limited By Guarantee. | ||
* Copyright (C) 2009 - 2020 Internet Neutral Exchange Association Company Limited By Guarantee. | ||
* All Rights Reserved. | ||
* | ||
* This file is part of IXP Manager. | ||
|
@@ -23,40 +23,45 @@ | |
* http://www.gnu.org/licenses/gpl-2.0.html | ||
*/ | ||
|
||
use Auth, D2EM; | ||
use Auth; | ||
|
||
use Entities\{ | ||
Customer as CustomerEntity, | ||
User as UserEntity | ||
use Illuminate\Http\{ | ||
JsonResponse, | ||
Response | ||
}; | ||
|
||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\View as FacadeView; | ||
|
||
use Illuminate\View\View; | ||
|
||
use IXP\Models\{ | ||
Customer, | ||
User | ||
}; | ||
|
||
/** | ||
* Content Controller | ||
* | ||
* @author Barry O'Donovan <[email protected]> | ||
* @author Yann Robin <[email protected]> | ||
* @category Controller | ||
* @copyright Copyright (C) 2009 - 2019 Internet Neutral Exchange Association Company Limited By Guarantee | ||
* @copyright Copyright (C) 2009 - 2020 Internet Neutral Exchange Association Company Limited By Guarantee | ||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL V2.0 | ||
*/ | ||
class ContentController extends Controller { | ||
|
||
class ContentController extends Controller | ||
{ | ||
/** | ||
* Display the appropriate static content page (if permissions match) | ||
* | ||
* @param int $priv Required privilege for access to the content | ||
* @param string $page Page to display | ||
* | ||
* @return View | ||
*/ | ||
public function index( int $priv, string $page ): View { | ||
|
||
public function index( int $priv, string $page ): View | ||
{ | ||
// check privilege: | ||
if( $priv != UserEntity::AUTH_PUBLIC ) { | ||
if( $priv !== User::AUTH_PUBLIC ) { | ||
if( Auth::guest() || Auth::user()->getPrivs() < $priv ) { | ||
abort( 403, 'Unauthorized' ); | ||
} | ||
|
@@ -77,9 +82,11 @@ public function index( int $priv, string $page ): View { | |
* Alias for public only content | ||
* | ||
* @param string $page Page to display | ||
* | ||
* @return View | ||
*/ | ||
public function public( string $page ): View { | ||
public function public( string $page ): View | ||
{ | ||
return $this->index( 0, $page ); | ||
} | ||
|
||
|
@@ -88,12 +95,13 @@ public function public( string $page ): View { | |
* | ||
* @param int $priv Required privilege for access to the content | ||
* @param string $page Page to display | ||
* | ||
* @return View|Response|JsonResponse | ||
*/ | ||
public function members( int $priv, string $page ) | ||
{ | ||
// check privilege: | ||
if( $priv != UserEntity::AUTH_PUBLIC ) { | ||
if( $priv !== User::AUTH_PUBLIC ) { | ||
if( Auth::guest() || Auth::user()->getPrivs() < $priv ) { | ||
abort( 403, 'Unauthorized' ); | ||
} | ||
|
@@ -105,7 +113,7 @@ public function members( int $priv, string $page ) | |
$page .= '.html'; | ||
} | ||
|
||
list( $page, $format ) = explode( '.', $page ); | ||
[ $page, $format ] = explode( '.', $page ); | ||
|
||
// sanitise page name: | ||
$page = "content/members/{$priv}/" . preg_replace( '/[^a-z0-9\-_]/', '', $page ); | ||
|
@@ -114,13 +122,12 @@ public function members( int $priv, string $page ) | |
abort( 404, 'Requested page not found' ); | ||
} | ||
|
||
$r = response()->view( $page, [ 'customers' => D2EM::getRepository( CustomerEntity::class )->getCurrentActive() ], 200 ); | ||
$r = response()->view( $page, [ 'customers' => Customer::currentActive() ], 200 ); | ||
|
||
if( $format == 'json' ) { | ||
if( $format === 'json' ) { | ||
$r->header( 'Content-Type', 'application/json' ); | ||
} | ||
|
||
return $r; | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.