mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-12 16:44:08 -08:00
Cleanup namespaces a bit
This commit is contained in:
parent
e7405e8d89
commit
90d4a8b2e3
|
@ -142,7 +142,7 @@ class AssetModelsController extends Controller
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
//COPYPASTA!!!! FIXME
|
//COPYPASTA!!!! FIXME
|
||||||
$model = new \App\Models\AssetModel;
|
$model = new AssetModel;
|
||||||
|
|
||||||
$settings=Input::all();
|
$settings=Input::all();
|
||||||
$settings['eol']=0;
|
$settings['eol']=0;
|
||||||
|
|
|
@ -136,7 +136,7 @@ class AssetsController extends Controller
|
||||||
|
|
||||||
$asset->name = e(Input::get('name'));
|
$asset->name = e(Input::get('name'));
|
||||||
$asset->serial = e(Input::get('serial'));
|
$asset->serial = e(Input::get('serial'));
|
||||||
$asset->company_id = \App\Models\Company::getIdForCurrentUser(e(Input::get('company_id')));
|
$asset->company_id = Company::getIdForCurrentUser(e(Input::get('company_id')));
|
||||||
$asset->model_id = e(Input::get('model_id'));
|
$asset->model_id = e(Input::get('model_id'));
|
||||||
$asset->order_number = e(Input::get('order_number'));
|
$asset->order_number = e(Input::get('order_number'));
|
||||||
$asset->notes = e(Input::get('notes'));
|
$asset->notes = e(Input::get('notes'));
|
||||||
|
@ -799,7 +799,7 @@ class AssetsController extends Controller
|
||||||
$fixed_filename = str_replace(' ', '-', $file->getClientOriginalName());
|
$fixed_filename = str_replace(' ', '-', $file->getClientOriginalName());
|
||||||
$file->move($path, $date.'-'.$fixed_filename);
|
$file->move($path, $date.'-'.$fixed_filename);
|
||||||
$name = date('Y-m-d-his').'-'.$fixed_filename;
|
$name = date('Y-m-d-his').'-'.$fixed_filename;
|
||||||
$filesize = \App\Models\Setting::fileSizeConvert(filesize($path.'/'.$name));
|
$filesize = Setting::fileSizeConvert(filesize($path.'/'.$name));
|
||||||
$results[] = compact('name', 'filesize');
|
$results[] = compact('name', 'filesize');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1115,7 @@ class AssetsController extends Controller
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
if ($settings->qr_code=='1') {
|
if ($settings->qr_code=='1') {
|
||||||
|
|
||||||
$assets = \App\Models\Asset::find($asset_ids);
|
$assets = Asset::find($asset_ids);
|
||||||
$assetcount = count($assets);
|
$assetcount = count($assets);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ namespace App\Http\Controllers\Auth;
|
||||||
use Validator;
|
use Validator;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||||
//use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
use App\Models\Setting;
|
||||||
//use Socialite;
|
use App\Models\User;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Config;
|
use Config;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -14,7 +14,6 @@ use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Log;
|
use Log;
|
||||||
use View;
|
use View;
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -77,13 +76,13 @@ class AuthController extends Controller
|
||||||
function ldap($username, $password, $returnUser = false)
|
function ldap($username, $password, $returnUser = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$ldaphost = \App\Models\Setting::getSettings()->ldap_server;
|
$ldaphost = Setting::getSettings()->ldap_server;
|
||||||
$ldaprdn = \App\Models\Setting::getSettings()->ldap_uname;
|
$ldaprdn = Setting::getSettings()->ldap_uname;
|
||||||
$ldappass = \Crypt::decrypt(\App\Models\Setting::getSettings()->ldap_pword);
|
$ldappass = \Crypt::decrypt(Setting::getSettings()->ldap_pword);
|
||||||
$baseDn = \App\Models\Setting::getSettings()->ldap_basedn;
|
$baseDn = Setting::getSettings()->ldap_basedn;
|
||||||
$filterQuery = \App\Models\Setting::getSettings()->ldap_auth_filter_query . $username;
|
$filterQuery = Setting::getSettings()->ldap_auth_filter_query . $username;
|
||||||
$ldapversion = \App\Models\Setting::getSettings()->ldap_version;
|
$ldapversion = Setting::getSettings()->ldap_version;
|
||||||
$ldap_server_cert_ignore = \App\Models\Setting::getSettings()->ldap_server_cert_ignore;
|
$ldap_server_cert_ignore = Setting::getSettings()->ldap_server_cert_ignore;
|
||||||
|
|
||||||
// If we are ignoring the SSL cert we need to setup the environment variable
|
// If we are ignoring the SSL cert we need to setup the environment variable
|
||||||
// before we create the connection
|
// before we create the connection
|
||||||
|
@ -128,11 +127,11 @@ class AuthController extends Controller
|
||||||
function createUserFromLdap($ldapatttibutes)
|
function createUserFromLdap($ldapatttibutes)
|
||||||
{
|
{
|
||||||
//Get LDAP attribute config
|
//Get LDAP attribute config
|
||||||
$ldap_result_username = \App\Models\Setting::getSettings()->ldap_username_field;
|
$ldap_result_username = Setting::getSettings()->ldap_username_field;
|
||||||
$ldap_result_emp_num = \App\Models\Setting::getSettings()->ldap_emp_num;
|
$ldap_result_emp_num = Setting::getSettings()->ldap_emp_num;
|
||||||
$ldap_result_last_name = \App\Models\Setting::getSettings()->ldap_lname_field;
|
$ldap_result_last_name = Setting::getSettings()->ldap_lname_field;
|
||||||
$ldap_result_first_name = \App\Models\Setting::getSettings()->ldap_fname_field;
|
$ldap_result_first_name = Setting::getSettings()->ldap_fname_field;
|
||||||
$ldap_result_email = \App\Models\Setting::getSettings()->ldap_email;
|
$ldap_result_email = Setting::getSettings()->ldap_email;
|
||||||
|
|
||||||
//Get LDAP user data
|
//Get LDAP user data
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@ -157,7 +156,7 @@ class AuthController extends Controller
|
||||||
'permissions' => ["user" => 1], //'{"user":1}',
|
'permissions' => ["user" => 1], //'{"user":1}',
|
||||||
'notes' => 'Imported from LDAP'
|
'notes' => 'Imported from LDAP'
|
||||||
);
|
);
|
||||||
\App\Models\User::save($newuser);
|
User::save($newuser);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new Cartalyst\Sentry\Users\UserNotFoundException();
|
throw new Cartalyst\Sentry\Users\UserNotFoundException();
|
||||||
|
@ -186,11 +185,11 @@ class AuthController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should we even check for LDAP users?
|
// Should we even check for LDAP users?
|
||||||
if (\App\Models\Setting::getSettings()->ldap_enabled=='1') {
|
if (Setting::getSettings()->ldap_enabled=='1') {
|
||||||
|
|
||||||
LOG::debug("LDAP is enabled.");
|
LOG::debug("LDAP is enabled.");
|
||||||
// Check if the user exists in the database
|
// Check if the user exists in the database
|
||||||
$user = \App\Models\User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->first();
|
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->first();
|
||||||
LOG::debug("Auth lookup complete");
|
LOG::debug("Auth lookup complete");
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ class AuthController extends Controller
|
||||||
|
|
||||||
if ($this->ldap(Input::get('username'), Input::get('password'))) {
|
if ($this->ldap(Input::get('username'), Input::get('password'))) {
|
||||||
LOG::debug("Valid LDAP login. Updating the local data.");
|
LOG::debug("Valid LDAP login. Updating the local data.");
|
||||||
$user = \App\Models\User::find($user->id); //need the Sentry object, not the Eloquent object, to access critical password hashing functions
|
$user = User::find($user->id); //need the Sentry object, not the Eloquent object, to access critical password hashing functions
|
||||||
$user->password = bcrypt(Input::get('password'));
|
$user->password = bcrypt(Input::get('password'));
|
||||||
$user->ldap_import = 1;
|
$user->ldap_import = 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
|
@ -15,7 +15,7 @@ use App\Models\CustomField;
|
||||||
use Input;
|
use Input;
|
||||||
use Validator;
|
use Validator;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use AssetModel;
|
use App\Models\AssetModel;
|
||||||
use Lang;
|
use Lang;
|
||||||
use Auth;
|
use Auth;
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ class CustomFieldsController extends Controller
|
||||||
//
|
//
|
||||||
$fieldset=CustomFieldset::find($id);
|
$fieldset=CustomFieldset::find($id);
|
||||||
|
|
||||||
$models=\App\Models\AssetModel::where("fieldset_id", "=", $id);
|
$models = AssetModel::where("fieldset_id", "=", $id);
|
||||||
if ($models->count()==0) {
|
if ($models->count()==0) {
|
||||||
$fieldset->delete();
|
$fieldset->delete();
|
||||||
return Redirect::route("admin.custom_fields.index")->with("success", Lang::get('admin/custom_fields/message.fieldset.delete.success'));
|
return Redirect::route("admin.custom_fields.index")->with("success", Lang::get('admin/custom_fields/message.fieldset.delete.success'));
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Redirect;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Validator;
|
use Validator;
|
||||||
use View;
|
use View;
|
||||||
|
use App\Models\Group;
|
||||||
|
|
||||||
class GroupsController extends Controller
|
class GroupsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ class GroupsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getCreate()
|
public function getCreate()
|
||||||
{
|
{
|
||||||
$group = new \App\Models\Group;
|
$group = new Group;
|
||||||
// Get all the available permissions
|
// Get all the available permissions
|
||||||
$permissions = config('permissions');
|
$permissions = config('permissions');
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ class GroupsController extends Controller
|
||||||
public function postCreate()
|
public function postCreate()
|
||||||
{
|
{
|
||||||
// create a new group instance
|
// create a new group instance
|
||||||
$group = new \App\Models\Group();
|
$group = new Group();
|
||||||
// Update the consumable data
|
// Update the consumable data
|
||||||
$group->name = e(Input::get('name'));
|
$group->name = e(Input::get('name'));
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ class GroupsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getEdit($id = null)
|
public function getEdit($id = null)
|
||||||
{
|
{
|
||||||
$group = \App\Models\Group::find($id);
|
$group = Group::find($id);
|
||||||
$group->name = e(Input::get('name'));
|
$group->name = e(Input::get('name'));
|
||||||
$group->permissions = json_decode($group->permissions, true);
|
$group->permissions = json_decode($group->permissions, true);
|
||||||
$permissions = config('permissions');
|
$permissions = config('permissions');
|
||||||
|
@ -97,7 +98,7 @@ class GroupsController extends Controller
|
||||||
public function postEdit($id = null)
|
public function postEdit($id = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$group = \App\Models\Group::find($id)) {
|
if (!$group = Group::find($id)) {
|
||||||
return Redirect::route('groups')->with('error', Lang::get('admin/groups/message.group_not_found', compact('id')));
|
return Redirect::route('groups')->with('error', Lang::get('admin/groups/message.group_not_found', compact('id')));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,7 +170,7 @@ class GroupsController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab all the groups
|
// Grab all the groups
|
||||||
$groups = \App\Models\Group::with('users')->orderBy('name', 'ASC');
|
$groups = Group::with('users')->orderBy('name', 'ASC');
|
||||||
//$users = Company::scopeCompanyables($users);
|
//$users = Company::scopeCompanyables($users);
|
||||||
|
|
||||||
if (Input::has('search')) {
|
if (Input::has('search')) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ class LicensesController extends Controller
|
||||||
$insertedId = $license->id;
|
$insertedId = $license->id;
|
||||||
// Save the license seat data
|
// Save the license seat data
|
||||||
for ($x=0; $x<$license->seats; $x++) {
|
for ($x=0; $x<$license->seats; $x++) {
|
||||||
$license_seat = new \App\Models\LicenseSeat();
|
$license_seat = new LicenseSeat();
|
||||||
$license_seat->license_id = $insertedId;
|
$license_seat->license_id = $insertedId;
|
||||||
$license_seat->user_id = Auth::user()->id;
|
$license_seat->user_id = Auth::user()->id;
|
||||||
$license_seat->assigned_to = null;
|
$license_seat->assigned_to = null;
|
||||||
|
@ -785,7 +785,7 @@ class LicensesController extends Controller
|
||||||
|
|
||||||
if (isset($license->id)) {
|
if (isset($license->id)) {
|
||||||
|
|
||||||
if (!\App\Models\Company::isCurrentUserHasAccess($license)) {
|
if (!Company::isCurrentUserHasAccess($license)) {
|
||||||
return Redirect::to('admin/licenses')->with('error', Lang::get('general.insufficient_permissions'));
|
return Redirect::to('admin/licenses')->with('error', Lang::get('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
return View::make('licenses/view', compact('license'));
|
return View::make('licenses/view', compact('license'));
|
||||||
|
|
|
@ -579,7 +579,7 @@ class ReportsController extends Controller
|
||||||
public function getAssetMaintenancesReport()
|
public function getAssetMaintenancesReport()
|
||||||
{
|
{
|
||||||
// Grab all the improvements
|
// Grab all the improvements
|
||||||
$assetMaintenances = \App\Models\AssetMaintenance::with('asset', 'supplier', 'asset.company')
|
$assetMaintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company')
|
||||||
->orderBy('created_at', 'DESC')
|
->orderBy('created_at', 'DESC')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use Response;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Crypt;
|
use Crypt;
|
||||||
use Mail;
|
use Mail;
|
||||||
use App\User;
|
use App\Models\User;
|
||||||
use App\Http\Requests\SetupUserRequest;
|
use App\Http\Requests\SetupUserRequest;
|
||||||
use App\Http\Requests\SettingRequest;
|
use App\Http\Requests\SettingRequest;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$user = new \App\Models\User;
|
$user = new User;
|
||||||
$user->first_name = $data['first_name']= e(Input::get('first_name'));
|
$user->first_name = $data['first_name']= e(Input::get('first_name'));
|
||||||
$user->last_name = e(Input::get('last_name'));
|
$user->last_name = e(Input::get('last_name'));
|
||||||
$user->email = $data['email'] = e(Input::get('email'));
|
$user->email = $data['email'] = e(Input::get('email'));
|
||||||
|
@ -174,7 +174,7 @@ class SettingsController extends Controller
|
||||||
$user->password = bcrypt(Input::get('password'));
|
$user->password = bcrypt(Input::get('password'));
|
||||||
$data['password'] = Input::get('password');
|
$data['password'] = Input::get('password');
|
||||||
|
|
||||||
$settings = new \App\Models\Setting;
|
$settings = new Setting;
|
||||||
$settings->site_name = e(Input::get('site_name'));
|
$settings->site_name = e(Input::get('site_name'));
|
||||||
$settings->alert_email = e(Input::get('email'));
|
$settings->alert_email = e(Input::get('email'));
|
||||||
$settings->alerts_enabled = 1;
|
$settings->alerts_enabled = 1;
|
||||||
|
|
|
@ -105,7 +105,7 @@ class UsersController extends Controller
|
||||||
public function postCreate(SetupUserRequest $request)
|
public function postCreate(SetupUserRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = new \App\Models\User;
|
$user = new User;
|
||||||
$user->first_name = $data['first_name']= e(Input::get('first_name'));
|
$user->first_name = $data['first_name']= e(Input::get('first_name'));
|
||||||
$user->last_name = e(Input::get('last_name'));
|
$user->last_name = e(Input::get('last_name'));
|
||||||
$user->email = $data['email'] = e(Input::get('email'));
|
$user->email = $data['email'] = e(Input::get('email'));
|
||||||
|
@ -1201,8 +1201,8 @@ class UsersController extends Controller
|
||||||
|
|
||||||
// User exists
|
// User exists
|
||||||
$item["createorupdate"] = 'updated';
|
$item["createorupdate"] = 'updated';
|
||||||
if (!$user = \App\Models\User::where('username', $item["username"])->first()) {
|
if (!$user = User::where('username', $item["username"])->first()) {
|
||||||
$user = new \App\Models\User;
|
$user = new User;
|
||||||
$item["createorupdate"] = 'created';
|
$item["createorupdate"] = 'created';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Config;
|
use Config;
|
||||||
use Route;
|
use Route;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
class CheckForSetup
|
class CheckForSetup
|
||||||
{
|
{
|
||||||
|
@ -12,7 +13,7 @@ class CheckForSetup
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$usercount = \App\Models\User::withTrashed()->count();
|
$usercount = User::withTrashed()->count();
|
||||||
if (($usercount > 0) && (Route::is('setup*'))) {
|
if (($usercount > 0) && (Route::is('setup*'))) {
|
||||||
return redirect(config('app.url'));
|
return redirect(config('app.url'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Http\Middleware;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Config;
|
use Config;
|
||||||
use Route;
|
use Route;
|
||||||
|
use App\Models\Setting;
|
||||||
|
|
||||||
class CheckLocale
|
class CheckLocale
|
||||||
{
|
{
|
||||||
|
@ -25,8 +26,8 @@ class CheckLocale
|
||||||
\App::setLocale($request->user()->locale);
|
\App::setLocale($request->user()->locale);
|
||||||
|
|
||||||
// App setting preference
|
// App setting preference
|
||||||
} elseif ((\App\Models\Setting::getSettings()) && (\App\Models\Setting::getSettings()->locale!='')) {
|
} elseif ((Setting::getSettings()) && (Setting::getSettings()->locale!='')) {
|
||||||
\App::setLocale(\App\Models\Setting::getSettings()->locale);
|
\App::setLocale(Setting::getSettings()->locale);
|
||||||
|
|
||||||
// Default app setting
|
// Default app setting
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\AssetModel;
|
||||||
|
|
||||||
class AssetRequest extends Request
|
class AssetRequest extends Request
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ class AssetRequest extends Request
|
||||||
'status' => 'integer',
|
'status' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
$model = \App\Models\AssetModel::find($this->request->get('model_id'));
|
$model = AssetModel::find($this->request->get('model_id'));
|
||||||
|
|
||||||
if ($model->fieldset)
|
if ($model->fieldset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
use App\Models\Statuslabel;
|
||||||
|
use App\Models\Location;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -22,7 +23,7 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||||
Route::resource('/', 'StatuslabelsController');
|
Route::resource('/', 'StatuslabelsController');
|
||||||
Route::get('{statuslabelId}/deployable', function ($statuslabelId) {
|
Route::get('{statuslabelId}/deployable', function ($statuslabelId) {
|
||||||
|
|
||||||
$statuslabel = \App\Models\Statuslabel::find($statuslabelId);
|
$statuslabel = Statuslabel::find($statuslabelId);
|
||||||
if (( $statuslabel->deployable == '1' ) && ( $statuslabel->pending != '1' )
|
if (( $statuslabel->deployable == '1' ) && ( $statuslabel->pending != '1' )
|
||||||
&& ( $statuslabel->archived != '1' )
|
&& ( $statuslabel->archived != '1' )
|
||||||
) {
|
) {
|
||||||
|
@ -109,7 +110,7 @@ Route::group([ 'prefix' => 'api', 'middleware' => 'auth' ], function () {
|
||||||
Route::resource('/', 'LocationsController');
|
Route::resource('/', 'LocationsController');
|
||||||
Route::get('{locationID}/check', function ($locationID) {
|
Route::get('{locationID}/check', function ($locationID) {
|
||||||
|
|
||||||
$location = \App\Models\Location::find($locationID);
|
$location = Location::find($locationID);
|
||||||
|
|
||||||
return $location;
|
return $location;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue