mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Merge branch 'develop' of https://github.com/snipe/snipe-it into develop
# Conflicts: # app/Models/Asset.php
This commit is contained in:
commit
f721dac2ca
|
@ -25,12 +25,12 @@ class LdapSync extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:ldap-sync
|
||||
{--location= : A location name }
|
||||
{--location_id= : A location id}
|
||||
{--base_dn= : A diffrent base DN to use }
|
||||
{--summary : Print summary }
|
||||
{--json_summary : Print summary in json format }
|
||||
protected $signature = 'snipeit:ldap-sync
|
||||
{--location= : A location name }
|
||||
{--location_id= : A location id}
|
||||
{--base_dn= : A diffrent base DN to use }
|
||||
{--summary : Print summary }
|
||||
{--json_summary : Print summary in json format }
|
||||
{--dryrun : Run the sync process but don\'t update the database}';
|
||||
|
||||
/**
|
||||
|
@ -142,7 +142,7 @@ class LdapSync extends Command
|
|||
* @return string
|
||||
*/
|
||||
private function getSummary(): string
|
||||
{
|
||||
{
|
||||
if ($this->option('summary') && !$this->dryrun) {
|
||||
$this->summary->each(function ($item) {
|
||||
if ('ERROR' === $item['status']) {
|
||||
|
@ -218,33 +218,29 @@ class LdapSync extends Command
|
|||
*
|
||||
* @param int $page The page to get the result set
|
||||
*/
|
||||
private function processLdapUsers(int $page=0): void
|
||||
{
|
||||
try {
|
||||
$ldapUsers = $this->ldap->getLdapUsers($page);
|
||||
} catch (Exception $e) {
|
||||
$this->outputError($e);
|
||||
exit($e->getMessage());
|
||||
}
|
||||
private function processLdapUsers(): void
|
||||
{
|
||||
try {
|
||||
$ldapUsers = $this->ldap->getLdapUsers();
|
||||
} catch (Exception $e) {
|
||||
$this->outputError($e);
|
||||
exit($e->getMessage());
|
||||
}
|
||||
|
||||
if (0 == $ldapUsers->count()) {
|
||||
$msg = 'ERROR: No users found!';
|
||||
Log::error($msg);
|
||||
if ($this->dryrun) {
|
||||
$this->error($msg);
|
||||
}
|
||||
exit($msg);
|
||||
}
|
||||
if (0 == count($ldapUsers)) {
|
||||
$msg = 'ERROR: No users found!';
|
||||
Log::error($msg);
|
||||
if ($this->dryrun) {
|
||||
$this->error($msg);
|
||||
}
|
||||
exit($msg);
|
||||
}
|
||||
|
||||
// Process each individual users
|
||||
foreach ($ldapUsers as $user) {
|
||||
$this->updateCreateUser($user);
|
||||
}
|
||||
|
||||
if ($ldapUsers->getCurrentPage() < $ldapUsers->getPages()) {
|
||||
$this->processLdapUsers($ldapUsers->getCurrentPage() + 1);
|
||||
}
|
||||
}
|
||||
// Process each individual users
|
||||
foreach ($ldapUsers as $user) {
|
||||
$this->updateCreateUser($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mapped locations if a base_dn is provided.
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Http\Transformers\CompaniesTransformer;
|
|||
use App\Http\Transformers\SelectlistTransformer;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CompaniesController extends Controller
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ class CustomFieldsController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('index', CustomFields::class);
|
||||
$this->authorize('index', CustomField::class);
|
||||
$fields = CustomField::get();
|
||||
return (new CustomFieldsTransformer)->transformCustomFields($fields, $fields->count());
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class CustomFieldsController extends Controller
|
|||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$this->authorize('show', CustomField::class);
|
||||
$this->authorize('view', CustomField::class);
|
||||
if ($field = CustomField::find($id)) {
|
||||
return (new CustomFieldsTransformer)->transformCustomField($field);
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class CustomFieldsController extends Controller
|
|||
{
|
||||
$this->authorize('update', CustomField::class);
|
||||
$field = CustomField::findOrFail($id);
|
||||
|
||||
|
||||
/**
|
||||
* Updated values for the field,
|
||||
* Updated values for the field,
|
||||
* without the "field_encrypted" flag, preventing the change of encryption status
|
||||
* @var array
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,7 @@ class CustomFieldsetsController extends Controller
|
|||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$this->authorize('show', CustomFieldset::class);
|
||||
$this->authorize('view', CustomFieldset::class);
|
||||
if ($fieldset = CustomFieldset::find($id)) {
|
||||
return (new CustomFieldsetsTransformer)->transformCustomFieldset($fieldset);
|
||||
}
|
||||
|
|
|
@ -1068,8 +1068,10 @@ class Asset extends Depreciable
|
|||
|
||||
public function scopeDueOrOverdueForAudit($query, $settings)
|
||||
{
|
||||
$interval = $settings->audit_warning_days ?? 0;
|
||||
|
||||
return $query->whereNotNull('assets.next_audit_date')
|
||||
->whereRaw("DATE_SUB(assets.next_audit_date, INTERVAL $settings->audit_warning_days DAY) <= '".Carbon::now()."'")
|
||||
->whereRaw("DATE_SUB(assets.next_audit_date, INTERVAL $interval DAY) <= '".Carbon::now()."'")
|
||||
->where('assets.archived', '=', 0)
|
||||
->NotArchived();
|
||||
}
|
||||
|
@ -1376,30 +1378,7 @@ class Asset extends Depreciable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* THIS CLUNKY BIT IS VERY IMPORTANT
|
||||
*
|
||||
* Although inelegant, this section matters a lot when querying against fields that do not
|
||||
* exist on the asset table. There's probably a better way to do this moving forward, for
|
||||
* example using the Schema:: methods to determine whether or not a column actually exists,
|
||||
* or even just using the $searchableRelations variable earlier in this file.
|
||||
*
|
||||
* In short, this set of statements tells the query builder to ONLY query against an
|
||||
* actual field that's being passed if it doesn't meet known relational fields. This
|
||||
* allows us to query custom fields directly in the assetsv table
|
||||
* (regardless of their name) and *skip* any fields that we already know can only be
|
||||
* searched through relational searches that we do earlier in this method.
|
||||
*
|
||||
* For example, we do not store "location" as a field on the assets table, we store
|
||||
* that relationship through location_id on the assets table, therefore querying
|
||||
* assets.location would fail, as that field doesn't exist -- plus we're already searching
|
||||
* against those relationships earlier in this method.
|
||||
*
|
||||
* - snipe
|
||||
*
|
||||
*/
|
||||
|
||||
if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='location') && ($fieldname!='supplier')
|
||||
if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='rtd_location') && ($fieldname!='location') && ($fieldname!='supplier')
|
||||
&& ($fieldname!='status_label') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
|
||||
$query->orWhere('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
|
||||
}
|
||||
|
|
|
@ -430,11 +430,9 @@ class LdapAd extends LdapAdConfiguration
|
|||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param int $page The paged results to get
|
||||
*
|
||||
* @return \Adldap\Query\Paginator
|
||||
*/
|
||||
public function getLdapUsers(int $page=0): Paginator
|
||||
public function getLdapUsers(): Paginator
|
||||
{
|
||||
$search = $this->ldap->search()->users()->in($this->getBaseDn());
|
||||
|
||||
|
@ -444,6 +442,6 @@ class LdapAd extends LdapAdConfiguration
|
|||
}
|
||||
|
||||
return $search->select($this->getSelectedFields())
|
||||
->paginate(self::PAGE_SIZE, $page);
|
||||
->paginate(self::PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ Route::group(
|
|||
|
||||
Route::get('audit/due', [
|
||||
'as' => 'assets.audit.due',
|
||||
'uses' => 'AssetsController@dueForAudit'
|
||||
'uses' => 'Assets\AssetsController@dueForAudit'
|
||||
]);
|
||||
|
||||
Route::get('audit/overdue', [
|
||||
'as' => 'assets.audit.overdue',
|
||||
'uses' => 'AssetsController@overdueForAudit'
|
||||
'uses' => 'Assets\AssetsController@overdueForAudit'
|
||||
]);
|
||||
|
||||
Route::get('audit/{id}', [
|
||||
|
|
Loading…
Reference in a new issue