Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Ldap Company as option and FMCS Notification #14650

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Console/Commands/LdapSync.php
Expand Up @@ -63,6 +63,7 @@ public function handle()
$ldap_result_jobtitle = Setting::getSettings()->ldap_jobtitle;
$ldap_result_country = Setting::getSettings()->ldap_country;
$ldap_result_location = Setting::getSettings()->ldap_location;
$ldap_result_company = Setting::getSettings()->ldap_company;
$ldap_result_dept = Setting::getSettings()->ldap_dept;
$ldap_result_manager = Setting::getSettings()->ldap_manager;
$ldap_default_group = Setting::getSettings()->ldap_default_group;
Expand Down Expand Up @@ -230,13 +231,19 @@ public function handle()
$item['department'] = $results[$i][$ldap_result_dept][0] ?? '';
$item['manager'] = $results[$i][$ldap_result_manager][0] ?? '';
$item['location'] = $results[$i][$ldap_result_location][0] ?? '';
$item['company'] = $results[$i][$ldap_result_company][0] ?? '';

// ONLY if you are using the "ldap_location" option *AND* you have an actual result
if ($ldap_result_location && $item['location']) {
$location = Location::firstOrCreate([
'name' => $item['location'],
]);
}
if ($ldap_result_company && $item['company']) {
$company = Company::firstOrCreate([
'name' => $item['company'],
]);
}
$department = Department::firstOrCreate([
'name' => $item['department'],
]);
Expand Down Expand Up @@ -284,6 +291,9 @@ public function handle()
if($ldap_result_location != null){
$user->location_id = $location ? $location->id : null;
}
if($ldap_result_company != null){
$user->company_id = $company ? $company->id : null;
}

if($ldap_result_manager != null){
if($item['manager'] != null) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/SettingsController.php
Expand Up @@ -973,6 +973,7 @@ public function postLdapSettings(Request $request)
$setting->ldap_jobtitle = $request->input('ldap_jobtitle');
$setting->ldap_country = $request->input('ldap_country');
$setting->ldap_location = $request->input('ldap_location');
$setting->ldap_company = $request->input('ldap_company');
$setting->ldap_dept = $request->input('ldap_dept');
$setting->ldap_client_tls_cert = $request->input('ldap_client_tls_cert');
$setting->ldap_client_tls_key = $request->input('ldap_client_tls_key');
Expand Down
1 change: 1 addition & 0 deletions app/Models/Setting.php
Expand Up @@ -356,6 +356,7 @@ public static function getLdapSettings(): Collection
'ldap_phone_field',
'ldap_jobtitle',
'ldap_manager',
'ldap_company',
'ldap_country',
'ldap_location',
])->first()->getAttributes();
Expand Down
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddLdapCompanyToSettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->string('ldap_company')->after('ldap_jobtitle')->nullable()->default(null);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('ldap_company');

});
}
}
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/settings/general.php
Expand Up @@ -104,6 +104,7 @@
'ldap_phone' => 'LDAP Telephone Number',
'ldap_jobtitle' => 'LDAP Job Title',
'ldap_country' => 'LDAP Country',
'ldap_company' => 'LDAP Company',
'ldap_pword' => 'LDAP Bind Password',
'ldap_basedn' => 'Base Bind DN',
'ldap_filter' => 'LDAP Filter',
Expand Down
13 changes: 13 additions & 0 deletions resources/views/settings/ldap.blade.php
Expand Up @@ -500,6 +500,19 @@
@endif
</div>
</div>
<!-- LDAP Company -->
<div class="form-group {{ $errors->has('ldap_company') ? 'error' : '' }}">
<div class="col-md-3">
{{ Form::label('ldap_company', trans('admin/settings/general.ldap_company')) }}
</div>
<div class="col-md-8">
{{ Form::text('ldap_company', Request::old('ldap_company', $setting->ldap_company), ['class' => 'form-control','placeholder' => trans('general.example') .'company', $setting->demoMode]) }}
{!! $errors->first('ldap_company', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
@if (config('app.lock_passwords')===true)
<p class="text-warning"><i class="fas fa-lock" aria-hidden="true"></i> {{ trans('general.feature_disabled') }}</p>
@endif
</div>
</div>
<!-- LDAP Location -->
<div class="form-group {{ $errors->has('ldap_location') ? 'error' : '' }}">
<div class="col-md-3">
Expand Down