From 063e3bbea65d537b459e5af6f50331ea386aac83 Mon Sep 17 00:00:00 2001 From: Strand McCutchen Date: Fri, 19 Jun 2015 10:15:05 -0600 Subject: [PATCH 1/9] Update Code of Conduct to Contributor Covenant 1.1.0 --- CODE_OF_CONDUCT.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index cd046319e5..c2ebaabcf8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,4 @@ -## Contributor Code of Conduct +# Contributor Code of Conduct As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. @@ -8,6 +8,8 @@ Examples of unacceptable behavior by participants include the use of sexual lang Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. +This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. + Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. -This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) \ No newline at end of file +This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.1.0, available at [http://contributor-covenant.org/version/1/1/0/](http://contributor-covenant.org/version/1/1/0/) From 588ff742fe93b1c0bbe573c081069843f523c097 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 19:15:43 -0700 Subject: [PATCH 2/9] Add manufacturer to models listing for clarity --- app/controllers/admin/ModelsController.php | 15 +++++++++------ app/views/backend/models/index.blade.php | 7 ++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 8a8fcb7d4a..7e22d05b93 100755 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -236,7 +236,7 @@ class ModelsController extends AdminController return Redirect::to('hardware/models')->with('success', Lang::get('admin/models/message.delete.success')); } } - + public function getRestore($modelId = null) { @@ -308,7 +308,7 @@ class ModelsController extends AdminController return $view; } - + public function getDatatable($status = null) { $models = Model::orderBy('created_at', 'DESC')->with('category','assets','depreciation'); @@ -324,6 +324,9 @@ class ModelsController extends AdminController }); return Datatable::collection($models) + ->addColumn('manufacturer', function($models) { + return $models->manufacturer->name; + }) ->addColumn('name', function ($models) { return link_to('/hardware/models/'.$models->id.'/view', $models->name); }) @@ -345,15 +348,15 @@ class ModelsController extends AdminController ->orderColumns('name','modelno','asset_count','depreciation','category','eol','actions') ->make(); } - - + + public function getDataView($modelID) { $model = Model::withTrashed()->find($modelID); $modelassets = $model->assets; - $actions = new \Chumper\Datatable\Columns\FunctionColumn('actions', function ($modelassets) - { + $actions = new \Chumper\Datatable\Columns\FunctionColumn('actions', function ($modelassets) + { if (($modelassets->assigned_to !='') && ($modelassets->assigned_to > 0)) { return ''.Lang::get('general.checkin').''; } else { diff --git a/app/views/backend/models/index.blade.php b/app/views/backend/models/index.blade.php index 749e86ab31..9695b6c0da 100755 --- a/app/views/backend/models/index.blade.php +++ b/app/views/backend/models/index.blade.php @@ -23,12 +23,13 @@
{{ Datatable::table() - ->addColumn(Lang::get('admin/models/table.title'), + ->addColumn(Lang::get('general.manufacturer'), + Lang::get('admin/models/table.title'), Lang::get('admin/models/table.modelnumber'), Lang::get('admin/models/table.numassets'), Lang::get('general.depreciation'), Lang::get('general.category'), - Lang::get('general.eol'), + Lang::get('general.eol'), Lang::get('table.actions')) ->setOptions( array( @@ -37,7 +38,7 @@ 'lengthMenu' => Lang::get('general.page_menu'), 'loadingRecords' => Lang::get('general.loading'), 'zeroRecords' => Lang::get('general.no_results'), - 'info' => Lang::get('general.pagination_info'), + 'info' => Lang::get('general.pagination_info'), 'processing' => Lang::get('general.processing'), 'paginate'=> array( 'first'=>Lang::get('general.first'), From 95920be8ea5608f0b3da831f3bac369b05d5aafe Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:04:05 -0700 Subject: [PATCH 3/9] Fixed weird commenting --- app/models/Model.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/Model.php b/app/models/Model.php index cd43ee0ef4..802b83acbc 100755 --- a/app/models/Model.php +++ b/app/models/Model.php @@ -40,13 +40,13 @@ class Model extends Elegant { return $this->belongsTo('Manufacturer','manufacturer_id'); } - + /** - ----------------------------------------------- - BEGIN QUERY SCOPES - ----------------------------------------------- + * ----------------------------------------------- + * BEGIN QUERY SCOPES + * ----------------------------------------------- **/ - + /** * Query builder scope for Deleted assets * From 0766ae2d1711b0c724b457079d8f3f9513f5f73c Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:04:48 -0700 Subject: [PATCH 4/9] Disallow group edit for demo --- app/controllers/admin/GroupsController.php | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/app/controllers/admin/GroupsController.php b/app/controllers/admin/GroupsController.php index 00b5c59963..8f550b79f7 100755 --- a/app/controllers/admin/GroupsController.php +++ b/app/controllers/admin/GroupsController.php @@ -161,21 +161,27 @@ class GroupsController extends AdminController return Redirect::back()->withInput()->withErrors($validator); } - try { - // Update the group data - $group->name = Input::get('name'); - $group->permissions = Input::get('permissions'); + if (!Config::get('app.lock_passwords')) { - // Was the group updated? - if ($group->save()) { - // Redirect to the group page - return Redirect::route('update/group', $id)->with('success', Lang::get('admin/groups/message.success.update')); - } else { - // Redirect to the group page - return Redirect::route('update/group', $id)->with('error', Lang::get('admin/groups/message.error.update')); + try { + // Update the group data + $group->name = Input::get('name'); + $group->permissions = Input::get('permissions'); + + // Was the group updated? + if ($group->save()) { + // Redirect to the group page + return Redirect::route('update/group', $id)->with('success', Lang::get('admin/groups/message.success.update')); + } else { + // Redirect to the group page + return Redirect::route('update/group', $id)->with('error', Lang::get('admin/groups/message.error.update')); + } + } catch (NameRequiredException $e) { + $error = Lang::get('admin/group/message.group_name_required'); } - } catch (NameRequiredException $e) { - $error = Lang::get('admin/group/message.group_name_required'); + + } else { + return Redirect::route('update/group', $id)->withInput()->with('error', 'Denied! Editing groups is not allowed in the demo.'); } // Redirect to the group page From 62f8d002e36d69623341af21f76d13d2eb9f4557 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:05:21 -0700 Subject: [PATCH 5/9] Temp commented out some stuff --- app/controllers/admin/AssetsController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index e78cfdc9af..bf77e431e9 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -54,9 +54,14 @@ class AssetsController extends AdminController public function getCreate($model_id = null) { + /* // Grab the dropdown list of models //$model_list = array('' => 'Select a Model') + Model::orderBy('name', 'asc')->lists('name'.' '. 'modelno', 'id'); + $model_list = Model::select(DB::raw('concat(manufacturers.name," ",name) as name, id'))->orderBy('name', 'asc')->with('manufacturer')->lists('name', 'id'); + //$model_list = array('' => Lang::get('general.select_model')); + */ + $model_list = array('' => Lang::get('general.select_model')) + DB::table('models') ->select(DB::raw('concat(name," / ",modelno) as name, id'))->orderBy('name', 'asc') ->orderBy('modelno', 'asc') From f2abbd0e8f134a4e33e5108866a494e307cf6953 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:10:23 -0700 Subject: [PATCH 6/9] Deny editing users on demo --- app/controllers/admin/UsersController.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php index 44252d67af..5f510b0216 100755 --- a/app/controllers/admin/UsersController.php +++ b/app/controllers/admin/UsersController.php @@ -245,6 +245,11 @@ class UsersController extends AdminController $this->decodePermissions($permissions); app('request')->request->set('permissions', $permissions); + // Only update the email address if locking is set to false + if (Config::get('app.lock_passwords')) { + return Redirect::route('users')->with('error', 'Denied! You cannot update user information on the demo.'); + } + try { // Get the user information $user = Sentry::getUserProvider()->findById($id); @@ -277,11 +282,6 @@ class UsersController extends AdminController return Redirect::back()->withInput()->withErrors($validator); } - // Only update the email address if locking is set to false - if (!Config::get('app.lock_passwords')) { - $user->email = Input::get('email'); - } - try { // Update the user $user->first_name = Input::get('first_name'); @@ -325,7 +325,6 @@ class UsersController extends AdminController // Assign the user to groups foreach ($groupsToAdd as $groupId) { $group = Sentry::getGroupProvider()->findById($groupId); - $user->addGroup($group); } From 3a44a7e8bbf23bbdc5345353639b747d71707617 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:38:12 -0700 Subject: [PATCH 7/9] Disable logo upload for demo --- app/views/backend/settings/edit.blade.php | 56 +++++++++++++---------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/app/views/backend/settings/edit.blade.php b/app/views/backend/settings/edit.blade.php index fea38471d1..59ee9629b0 100755 --- a/app/views/backend/settings/edit.blade.php +++ b/app/views/backend/settings/edit.blade.php @@ -19,7 +19,7 @@ padding: 0px 20px; - +
{{ Form::label('slack_channel', Lang::get('admin/settings/general.slack_channel')) }} @@ -247,13 +253,13 @@ padding: 0px 20px;
@if (Config::get('app.lock_passwords')===true) {{ Form::text('slack_channel', Input::old('slack_channel', $setting->slack_channel), array('class' => 'form-control','disabled'=>'disabled','placeholder' => '#IT-Ops')) }} - @else + @else {{ Form::text('slack_channel', Input::old('slack_channel', $setting->slack_channel), array('class' => 'form-control','placeholder' => '#IT-Ops')) }} - @endif + @endif {{ $errors->first('slack_channel', '
:message') }}
- +
{{ Form::label('slack_botname', Lang::get('admin/settings/general.slack_botname')) }} @@ -261,9 +267,9 @@ padding: 0px 20px;
@if (Config::get('app.lock_passwords')===true) {{ Form::text('slack_botname', Input::old('slack_botname', $setting->slack_botname), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'Snipe-IT Bot')) }} - @else + @else {{ Form::text('slack_botname', Input::old('slack_botname', $setting->slack_botname), array('class' => 'form-control','placeholder' => 'Snipe-IT Bot')) }} - @endif + @endif {{ $errors->first('slack_botname', '
:message') }}
@@ -280,10 +286,10 @@ padding: 0px 20px;
- - + +
- + From 6915987239afa274384e16f2e617ace07e980104 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:38:19 -0700 Subject: [PATCH 8/9] Added demo language string --- app/lang/en/general.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/lang/en/general.php b/app/lang/en/general.php index 18c306569b..5ca8eff2cf 100755 --- a/app/lang/en/general.php +++ b/app/lang/en/general.php @@ -66,6 +66,7 @@ return array( 'licenses' => 'Licenses', 'list_all' => 'List All', 'loading' => 'Loading', + 'lock_passwords' => 'This field cannot be edited in this installation.', 'location' => 'Location', 'locations' => 'Locations', 'logout' => 'Logout', From 1d4cfcfd5881cb49852e3dc581ea77019696e0f6 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 30 Jun 2015 22:38:40 -0700 Subject: [PATCH 9/9] Only save uploaded logo if not in demo mode --- app/controllers/admin/SettingsController.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/SettingsController.php b/app/controllers/admin/SettingsController.php index a328c46746..58de37e080 100755 --- a/app/controllers/admin/SettingsController.php +++ b/app/controllers/admin/SettingsController.php @@ -64,7 +64,7 @@ class SettingsController extends AdminController // Declare the rules for the form validation - + $rules = array( "per_page" => 'required|min:1|numeric', "qr_text" => 'min:1|max:31', @@ -74,12 +74,12 @@ class SettingsController extends AdminController "slack_channel" => 'regex:/(? 'alpha_dash', ); - + if (Config::get('app.lock_passwords')==false) { $rules['site_name'] = 'required|min:3'; - } - + } + // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $rules); @@ -93,6 +93,7 @@ class SettingsController extends AdminController if (Input::get('clear_logo')=='1') { $setting->logo = NULL; } elseif (Input::file('logo')) { + if (!Config::get('app.lock_passwords')) { $image = Input::file('logo'); $file_name = "logo.".$image->getClientOriginalExtension(); $path = public_path('uploads/'.$file_name); @@ -101,16 +102,17 @@ class SettingsController extends AdminController $constraint->upsize(); })->save($path); $setting->logo = $file_name; + } } // Update the asset data $setting->id = '1'; - + if (Config::get('app.lock_passwords')==false) { $setting->site_name = e(Input::get('site_name')); - } - + } + $setting->per_page = e(Input::get('per_page')); $setting->qr_code = e(Input::get('qr_code', '0')); $setting->barcode_type = e(Input::get('barcode_type'));