Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Illuminate\Support\Facades\Log;
use Mail;
use Response;
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -44,10 +44,9 @@ class Handler extends ExceptionHandler
*/
public function report(Throwable $exception)
{

$enableEmailExceptions = config('exceptions.emailExceptionEnabled');

if ($enableEmailExceptions === "") {
if ($enableEmailExceptions === '') {
$enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
}

Expand Down Expand Up @@ -75,10 +74,10 @@ public function render($request, Throwable $exception)

if ($userLevelCheck) {
if ($request->expectsJson()) {
return Response::json(array(
'error' => 403,
'message' => 'Unauthorized.'
), 403);
return Response::json([
'error' => 403,
'message' => 'Unauthorized.',
], 403);
}

abort(403);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/ActivateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function activationRequired()
return $rCheck;
}

if ($user->activated == false) {
if ($user->activated === false) {
$activationsCount = Activation::where('user_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod')))
->count();
Expand Down Expand Up @@ -235,7 +235,7 @@ public function resend()
$lastActivation = Activation::where('user_id', $user->id)->get()->last();
$currentRoute = Route::currentRouteName();

if ($user->activated == false) {
if ($user->activated === false) {
$activationsCount = Activation::where('user_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod')))
->count();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function validator(array $data)
{
$data['captcha'] = $this->captchaCheck();

if (!config('settings.reCaptchStatus')) {
if (! config('settings.reCaptchStatus')) {
$data['captcha'] = true;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ protected function create(array $data)
'password' => Hash::make($data['password']),
'token' => str_random(64),
'signup_ip_address' => $ipAddress->getClientIp(),
'activated' => !config('settings.activation'),
'activated' => ! config('settings.activation'),
]);

$user->attachRole($role);
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/Auth/SocialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getSocialRedirect($provider)
*/
public function getSocialHandle($provider, Request $request)
{
if ($request->get('denied') != '') {
if ($request->get('denied') !== '') {
return redirect()->to('login')
->with('status', 'danger')
->with('message', trans('socials.denied'));
Expand All @@ -60,7 +60,7 @@ public function getSocialHandle($provider, Request $request)

$email = $socialUserObject->email;

if (!$socialUserObject->email) {
if (! $socialUserObject->email) {
$email = 'missing'.str_random(10).'@'.str_random(10).'.example.org';
}

Expand All @@ -75,12 +75,12 @@ public function getSocialHandle($provider, Request $request)
$profile = new Profile();
$role = Role::where('slug', '=', 'user')->first();
$fullname = explode(' ', $socialUserObject->name);
if (count($fullname) == 1) {
if (count($fullname) === 1) {
$fullname[1] = '';
}
$username = $socialUserObject->nickname;

if ($username == null) {
if ($username === null) {
foreach ($fullname as $name) {
$username .= $name;
}
Expand Down Expand Up @@ -110,12 +110,12 @@ public function getSocialHandle($provider, Request $request)
$user->profile()->save($profile);
$user->save();

if ($socialData->provider == 'github') {
if ($socialData->provider === 'github') {
$user->profile->github_username = $socialUserObject->nickname;
}

// Twitter User Object details: https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/user-object
if ($socialData->provider == 'twitter') {
if ($socialData->provider === 'twitter') {
//$user->profile()->twitter_username = $socialUserObject->screen_name;
//If the above fails try (The documentation shows screen_name however so Twitters docs may be out of date.):
$user->profile()->twitter_username = $socialUserObject->nickname;
Expand Down Expand Up @@ -159,12 +159,12 @@ public function checkUserName($username, $email)
$username = $this->generateUserName($username);
$newCheck = User::where('name', '=', $username)->first();

if ($newCheck == null) {
if ($newCheck === null) {
$newCheck = 0;
} else {
$newCheck = count($newCheck);
}
} while ($newCheck != 0);
} while ($newCheck !== 0);
}

return $username;
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/ProfilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function update(UpdateUserProfile $request, $username)

$ipAddress = new CaptureIpTrait();

if ($user->profile == null) {
if ($user->profile === null) {
$profile = new Profile();
$profile->fill($input);
$user->profile()->save($profile);
Expand All @@ -149,11 +149,11 @@ public function updateUserAccount(Request $request, $id)
{
$currentUser = \Auth::user();
$user = User::findOrFail($id);
$emailCheck = ($request->input('email') != '') && ($request->input('email') != $user->email);
$emailCheck = ($request->input('email') !== '') && ($request->input('email') !== $user->email);
$ipAddress = new CaptureIpTrait();
$rules = [];

if ($user->name != $request->input('name')) {
if ($user->name !== $request->input('name')) {
$usernameRules = [
'name' => 'required|max:255|unique:users',
];
Expand Down Expand Up @@ -212,7 +212,7 @@ public function updateUserPassword(UpdateUserPasswordRequest $request, $id)
$user = User::findOrFail($id);
$ipAddress = new CaptureIpTrait();

if ($request->input('password') != null) {
if ($request->input('password') !== null) {
$user->password = bcrypt($request->input('password'));
}

Expand Down Expand Up @@ -282,7 +282,7 @@ public function deleteUserAccount(DeleteUserAccount $request, $id)
$user = User::findOrFail($id);
$ipAddress = new CaptureIpTrait();

if ($user->id != $currentUser->id) {
if ($user->id !== $currentUser->id) {
return redirect('profile/'.$user->name.'/edit')->with('error', trans('profile.errorDeleteNotYour'));
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RestoreUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function userReActivate(Request $request, $token)
$userId = $level1[0][1] / $userIdKey;
$user = SoftDeletesController::getDeletedUser($userId);

if (!is_object($user)) {
if (! is_object($user)) {
abort(500);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SoftDeletesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()
public static function getDeletedUser($id)
{
$user = User::onlyTrashed()->where('id', $id)->get();
if (count($user) != 1) {
if (count($user) !== 1) {
return redirect('/users/deleted/')->with('error', trans('usersmanagement.errorUserNotFound'));
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ThemesManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function destroy(Theme $theme)
{
$default = Theme::findOrFail(Theme::default);

if ($theme->id != $default->id) {
if ($theme->id !== $default->id) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 12 spaces, found 8

$theme->delete();

return redirect('themes')->with('success', trans('themes.deleteSuccess'));
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Controllers/UsersManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function edit(User $user)
*/
public function update(Request $request, User $user)
{
$emailCheck = ($request->input('email') != '') && ($request->input('email') != $user->email);
$emailCheck = ($request->input('email') !== '') && ($request->input('email') !== $user->email);
$ipAddress = new CaptureIpTrait();

if ($emailCheck) {
Expand Down Expand Up @@ -186,12 +186,12 @@ public function update(Request $request, User $user)
$user->email = $request->input('email');
}

if ($request->input('password') != null) {
if ($request->input('password') !== null) {
$user->password = bcrypt($request->input('password'));
}

$userRole = $request->input('role');
if ($userRole != null) {
if ($userRole !== null) {
$user->detachAllRoles();
$user->attachRole($userRole);
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public function destroy(User $user)
$currentUser = Auth::user();
$ipAddress = new CaptureIpTrait();

if ($user->id != $currentUser->id) {
if ($user->id !== $currentUser->id) {
$user->deleted_ip_address = $ipAddress->getClientIp();
$user->save();
$user->delete();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use Auth;
use Closure;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckCurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CheckCurrentUser
*/
public function handle($request, Closure $next)
{
if (!$request->user()) {
if (! $request->user()) {
abort(403, 'Unauthorized action.');
}

Expand Down
10 changes: 5 additions & 5 deletions app/Http/Middleware/CheckIsUserActivated.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function handle($request, Closure $next)
'welcome',
];

if (!in_array($currentRoute, $routesAllowed)) {
if ($user && $user->activated != 1) {
if (! in_array($currentRoute, $routesAllowed)) {
if ($user && $user->activated !== 1) {
Log::info('Non-activated user attempted to visit '.$currentRoute.'. ', [$user]);

return redirect()->route('activation-required')
Expand All @@ -51,7 +51,7 @@ public function handle($request, Closure $next)
}
}

if ($user && $user->activated != 1) {
if ($user && $user->activated !== 1) {
$activationsCount = Activation::where('user_id', $user->id)
->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod')))
->count();
Expand All @@ -62,7 +62,7 @@ public function handle($request, Closure $next)
}

if (in_array($currentRoute, $routesAllowed)) {
if ($user && $user->activated == 1) {
if ($user && $user->activated === 1) {
Log::info('Activated user attempted to visit '.$currentRoute.'. ', [$user]);

if ($user->isAdmin()) {
Expand All @@ -72,7 +72,7 @@ public function handle($request, Closure $next)
return redirect('home');
}

if (!$user) {
if (! $user) {
Log::info('Non registered visit to '.$currentRoute.'. ');

return redirect()->route('welcome');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/ViewComposers/ThemeComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function compose(View $view)
if ($user->profile) {
$theme = Theme::find($user->profile->theme_id);

if ($theme->status == 0) {
if ($theme->status === 0) {
$theme = Theme::find(Theme::default);
}
}
Expand Down
14 changes: 7 additions & 7 deletions app/Logic/Macros/HtmlMacros.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* @return string
*/
HTML::macro('image_link', function ($url = '', $img = '', $alt = '', $link_name = '', $param = '', $active = true, $ssl = false) {
$url = $ssl == true ? URL::to_secure($url) : URL::to($url);
$url = $ssl === true ? URL::to_secure($url) : URL::to($url);
$img = HTML::image($img, $alt);
$img .= $link_name;
$link = $active == true ? HTML::link($url, '#', $param) : $img;
$link = $active === true ? HTML::link($url, '#', $param) : $img;
$link = str_replace('#', $img, $link);

return $link;
Expand All @@ -36,9 +36,9 @@
* @return string
*/
HTML::macro('icon_link', function ($url = '', $icon = '', $link_name = '', $param = '', $active = true, $ssl = false) {
$url = $ssl == true ? URL::to_secure($url) : URL::to($url);
$url = $ssl === true ? URL::to_secure($url) : URL::to($url);
$icon = '<i class="'.$icon.'" aria-hidden="true"></i>'.$link_name;
$link = $active == true ? HTML::link($url, '#', $param) : $icon;
$link = $active === true ? HTML::link($url, '#', $param) : $icon;
$link = str_replace('#', $icon, $link);

return $link;
Expand All @@ -57,16 +57,16 @@
* @return string
*/
HTML::macro('icon_btn', function ($url = '', $icon = '', $link_name = '', $param = '', $active = true, $ssl = false) {
$url = $ssl == true ? URL::to_secure($url) : URL::to($url);
$url = $ssl === true ? URL::to_secure($url) : URL::to($url);
$icon = $link_name.' <i class="'.$icon.'" aria-hidden="true"></i>';
$link = $active == true ? HTML::link($url, '#', $param) : $icon;
$link = $active === true ? HTML::link($url, '#', $param) : $icon;
$link = str_replace('#', $icon, $link);

return $link;
});

/**
* Show Username
* Show Username.
*
* @return string
*/
Expand Down
10 changes: 5 additions & 5 deletions app/Mail/ExceptionOccured.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ public function build()
$fromSender = config('exceptions.emailExceptionFrom');
$subject = config('exceptions.emailExceptionSubject');

if ($emailsTo[0] == null) {
if ($emailsTo[0] === null) {
$emailsTo = config('exceptions.emailExceptionsToDefault');
}

if ($ccEmails[0] == null) {
if ($ccEmails[0] === null) {
$ccEmails = config('exceptions.emailExceptionCCtoDefault');
}

if ($bccEmails[0] == null) {
if ($bccEmails[0] === null) {
$bccEmails = config('exceptions.emailExceptionBCCtoDefault');
}

if (!$fromSender) {
if (! $fromSender) {
$fromSender = config('exceptions.emailExceptionFromDefault');
}

if (!$subject) {
if (! $subject) {
$subject = config('exceptions.emailExceptionSubjectDefault');
}

Expand Down
Loading