diff --git a/src/app/Console/Commands/HKCCPImportLdap.php b/src/app/Console/Commands/HKCCPImportLdap.php index 4672ce61..5cdd1da7 100644 --- a/src/app/Console/Commands/HKCCPImportLdap.php +++ b/src/app/Console/Commands/HKCCPImportLdap.php @@ -1,115 +1,107 @@ syncDomains(); $this->syncUsers(); LDAP::disconnect(); } private function syncDomains() { $domains = \App\Domain::withTrashed()->get(); $bar = $this->createProgressBar(count($domains), "Syncing Domains"); foreach ($domains as $domain) { $bar->advance(); $result = null; try { - $result = LDAP::updateDomain($domain); + LDAP::updateDomain($domain); } catch (\Exception $e) { - \Log::error("Domain {$domain->namespace} failed (exception)"); + \Log::error("Domain {$domain->namespace} failed"); continue; } - if ($result) { - \Log::info("Domain {$domain->namespace} updated"); - } else { - \Log::error("Domain {$domain->namespace} failed"); - } + \Log::info("Domain {$domain->namespace} updated"); } $bar->finish(); $this->info("DONE"); } private function syncUsers() { $users = \App\User::withTrashed()->get(); $bar = $this->createProgressBar(count($users), "Syncing Users"); foreach ($users as $user) { $bar->advance(); $result = null; try { - $result = LDAP::updateUser($user); + LDAP::updateUser($user); } catch (\Exception $e) { - \Log::error("User {$user->email} failed (exception)"); + \Log::error("User {$user->email} failed"); continue; } - if ($result) { - \Log::info("User {$user->email} updated"); - } else { - \Log::error("User {$user->email} failed"); - } + \Log::info("User {$user->email} updated"); } $bar->finish(); $this->info("DONE"); } private function createProgressBar($count, $message = null) { $bar = $this->output->createProgressBar($count); $bar->setFormat( '%current:7s%/%max:7s% [%bar%] %percent:3s%% %elapsed:7s%/%estimated:-7s% %message% ' ); if ($message) { $bar->setMessage($message . " ..."); } $bar->start(); return $bar; } }