Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117980911
D1069.1775521627.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
26 KB
Referenced Files
None
Subscribers
None
D1069.1775521627.diff
View Options
diff --git a/docker/kolab/kolab-init.sh b/docker/kolab/kolab-init.sh
--- a/docker/kolab/kolab-init.sh
+++ b/docker/kolab/kolab-init.sh
@@ -26,5 +26,6 @@
./18-adjust-kolab-conf.sh
./19-turn-on-vlv-in-roundcube.sh
./20-add-alias-attribute-index.sh
+./21-adjust-postfix-config.sh
touch /tmp/kolab-init.done
diff --git a/docker/kolab/utils/21-adjust-postfix-config.sh b/docker/kolab/utils/21-adjust-postfix-config.sh
new file mode 100755
--- /dev/null
+++ b/docker/kolab/utils/21-adjust-postfix-config.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# new: (inetdomainstatus:1.2.840.113556.1.4.804:=1)
+# active: (inetdomainstatus:1.2.840.113556.1.4.804:=2)
+# suspended: (inetdomainstatus:1.2.840.113556.1.4.804:=4)
+# deleted: (inetdomainstatus:1.2.840.113556.1.4.804:=8)
+# confirmed: (inetdomainstatus:1.2.840.113556.1.4.804:=16)
+# verified: (inetdomainstatus:1.2.840.113556.1.4.804:=32)
+# ready: (inetdomainstatus:1.2.840.113556.1.4.804:=64)
+
+sed -i -r \
+ -e 's/^query_filter.*$/query_filter = (\&(associatedDomain=%s)(inetdomainstatus:1.2.840.113556.1.4.804:=18)(!(inetdomainstatus:1.2.840.113556.1.4.804:=4)))/g' \
+ /etc/postfix/ldap/mydestination.cf
+
+# new: (inetuserstatus:1.2.840.113556.1.4.804:=1)
+# active: (inetuserstatus:1.2.840.113556.1.4.804:=2)
+# suspended: (inetuserstatus:1.2.840.113556.1.4.804:=4)
+# deleted: (inetuserstatus:1.2.840.113556.1.4.804:=8)
+# ldapready: (inetuserstatus:1.2.840.113556.1.4.804:=16)
+# imapready: (inetuserstatus:1.2.840.113556.1.4.804:=32)
+
+sed -i -r \
+ -e 's/^query_filter.*$/query_filter = (\&(|(mail=%s)(alias=%s))(|(objectclass=kolabinetorgperson)(|(objectclass=kolabgroupofuniquenames)(objectclass=kolabgroupofurls))(|(|(objectclass=groupofuniquenames)(objectclass=groupofurls))(objectclass=kolabsharedfolder))(objectclass=kolabsharedfolder))(inetuserstatus:1.2.840.113556.1.4.804:=50)(!(inetuserstatus:1.2.840.113556.1.4.804:=4)))/g' \
+ /etc/postfix/ldap/local_recipient_maps.cf
+
+systemctl restart postfix
diff --git a/src/app/Backends/LDAP.php b/src/app/Backends/LDAP.php
--- a/src/app/Backends/LDAP.php
+++ b/src/app/Backends/LDAP.php
@@ -19,33 +19,33 @@
$config = self::getConfig('admin');
$ldap = self::initLDAP($config);
- $hosted_root_dn = \config('ldap.hosted.root_dn');
- $mgmt_root_dn = \config('ldap.admin.root_dn');
+ $hostedRootDN = \config('ldap.hosted.root_dn');
+ $mgmtRootDN = \config('ldap.admin.root_dn');
- $domain_base_dn = "ou={$domain->namespace},{$hosted_root_dn}";
+ $domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}";
$aci = [
'(targetattr = "*")'
. '(version 3.0; acl "Deny Unauthorized"; deny (all)'
- . '(userdn != "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn
- . ' || ldap:///ou=People,' . $domain_base_dn . '??sub?(objectclass=inetorgperson)") '
- . 'AND NOT roledn = "ldap:///cn=kolab-admin,' . $mgmt_root_dn . '";)',
+ . '(userdn != "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN
+ . ' || ldap:///ou=People,' . $domainBaseDN . '??sub?(objectclass=inetorgperson)") '
+ . 'AND NOT roledn = "ldap:///cn=kolab-admin,' . $mgmtRootDN . '";)',
'(targetattr != "userPassword")'
. '(version 3.0;acl "Search Access";allow (read,compare,search)'
- . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn
- . ' || ldap:///ou=People,' . $domain_base_dn . '??sub?(objectclass=inetorgperson)");)',
+ . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN
+ . ' || ldap:///ou=People,' . $domainBaseDN . '??sub?(objectclass=inetorgperson)");)',
'(targetattr = "*")'
. '(version 3.0;acl "Kolab Administrators";allow (all)'
- . '(roledn = "ldap:///cn=kolab-admin,' . $domain_base_dn
- . ' || ldap:///cn=kolab-admin,' . $mgmt_root_dn . '");)'
+ . '(roledn = "ldap:///cn=kolab-admin,' . $domainBaseDN
+ . ' || ldap:///cn=kolab-admin,' . $mgmtRootDN . '");)'
];
$entry = [
'aci' => $aci,
'associateddomain' => $domain->namespace,
- 'inetdomainbasedn' => $domain_base_dn,
+ 'inetdomainbasedn' => $domainBaseDN,
'objectclass' => [
'top',
'domainrelatedobject',
@@ -72,42 +72,42 @@
$entry['aci'] = array(
'(targetattr = "*")'
. '(version 3.0;acl "Deny Unauthorized"; deny (all)'
- . '(userdn != "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn
- . ' || ldap:///ou=People,' . $domain_base_dn . '??sub?(objectclass=inetorgperson)") '
- . 'AND NOT roledn = "ldap:///cn=kolab-admin,' . $mgmt_root_dn . '";)',
+ . '(userdn != "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN
+ . ' || ldap:///ou=People,' . $domainBaseDN . '??sub?(objectclass=inetorgperson)") '
+ . 'AND NOT roledn = "ldap:///cn=kolab-admin,' . $mgmtRootDN . '";)',
'(targetattr != "userPassword")'
. '(version 3.0;acl "Search Access";allow (read,compare,search,write)'
- . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn
- . ' || ldap:///ou=People,' . $domain_base_dn . '??sub?(objectclass=inetorgperson)");)',
+ . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN
+ . ' || ldap:///ou=People,' . $domainBaseDN . '??sub?(objectclass=inetorgperson)");)',
'(targetattr = "*")'
. '(version 3.0;acl "Kolab Administrators";allow (all)'
- . '(roledn = "ldap:///cn=kolab-admin,' . $domain_base_dn
- . ' || ldap:///cn=kolab-admin,' . $mgmt_root_dn . '");)',
+ . '(roledn = "ldap:///cn=kolab-admin,' . $domainBaseDN
+ . ' || ldap:///cn=kolab-admin,' . $mgmtRootDN . '");)',
- '(target = "ldap:///ou=*,' . $domain_base_dn . '")'
+ '(target = "ldap:///ou=*,' . $domainBaseDN . '")'
. '(targetattr="objectclass || aci || ou")'
. '(version 3.0;acl "Allow Domain sub-OU Registration"; allow (add)'
- . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn . '");)',
+ . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN . '");)',
- '(target = "ldap:///uid=*,ou=People,' . $domain_base_dn . '")(targetattr="*")'
+ '(target = "ldap:///uid=*,ou=People,' . $domainBaseDN . '")(targetattr="*")'
. '(version 3.0;acl "Allow Domain First User Registration"; allow (add)'
- . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn . '");)',
+ . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN . '");)',
- '(target = "ldap:///cn=*,' . $domain_base_dn . '")(targetattr="objectclass || cn")'
+ '(target = "ldap:///cn=*,' . $domainBaseDN . '")(targetattr="objectclass || cn")'
. '(version 3.0;acl "Allow Domain Role Registration"; allow (add)'
- . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmt_root_dn . '");)',
+ . '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN . '");)',
);
- if (!$ldap->get_entry($domain_base_dn)) {
- $ldap->add_entry($domain_base_dn, $entry);
+ if (!$ldap->get_entry($domainBaseDN)) {
+ $ldap->add_entry($domainBaseDN, $entry);
}
foreach (['Groups', 'People', 'Resources', 'Shared Folders'] as $item) {
- if (!$ldap->get_entry("ou={$item},{$domain_base_dn}")) {
+ if (!$ldap->get_entry("ou={$item},{$domainBaseDN}")) {
$ldap->add_entry(
- "ou={$item},{$domain_base_dn}",
+ "ou={$item},{$domainBaseDN}",
[
'ou' => $item,
'description' => $item,
@@ -121,9 +121,9 @@
}
foreach (['kolab-admin', 'imap-user', 'activesync-user', 'billing-user'] as $item) {
- if (!$ldap->get_entry("cn={$item},{$domain_base_dn}")) {
+ if (!$ldap->get_entry("cn={$item},{$domainBaseDN}")) {
$ldap->add_entry(
- "cn={$item},{$domain_base_dn}",
+ "cn={$item},{$domainBaseDN}",
[
'cn' => $item,
'description' => "{$item} role",
@@ -181,6 +181,7 @@
'objectclass' => [
'top',
'inetorgperson',
+ 'inetuser',
'kolabinetorgperson',
'mailrecipient',
'person'
@@ -210,7 +211,19 @@
*/
public static function updateDomain($domain)
{
- //
+ $config = self::getConfig('admin');
+ $ldap = self::initLDAP($config);
+
+ $ldapDomain = $ldap->find_domain($domain->namespace);
+
+ $oldEntry = $ldap->get_entry($ldapDomain['dn']);
+ $newEntry = $oldEntry;
+
+ self::setDomainAttributes($domain, $newEntry);
+
+ $ldap->modify_entry($ldapDomain['dn'], $oldEntry, $newEntry);
+
+ $ldap->close();
}
public static function deleteDomain($domain)
@@ -218,13 +231,13 @@
$config = self::getConfig('admin');
$ldap = self::initLDAP($config);
- $hosted_root_dn = \config('ldap.hosted.root_dn');
- $mgmt_root_dn = \config('ldap.admin.root_dn');
+ $hostedRootDN = \config('ldap.hosted.root_dn');
+ $mgmtRootDN = \config('ldap.admin.root_dn');
- $domain_base_dn = "ou={$domain->namespace},{$hosted_root_dn}";
+ $domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}";
- if ($ldap->get_entry($domain_base_dn)) {
- $ldap->delete_entry_recursive($domain_base_dn);
+ if ($ldap->get_entry($domainBaseDN)) {
+ $ldap->delete_entry_recursive($domainBaseDN);
}
if ($ldap_domain = $ldap->find_domain($domain->namespace)) {
@@ -232,6 +245,8 @@
$ldap->delete_entry($ldap_domain['dn']);
}
}
+
+ $ldap->close();
}
public static function deleteUser($user)
@@ -244,6 +259,7 @@
$domain = $ldap->find_domain($_domain);
if (!$domain) {
+ $ldap->close();
return false;
}
@@ -251,10 +267,13 @@
$dn = "uid={$user->email},ou=People,{$base_dn}";
if (!$ldap->get_entry($dn)) {
+ $ldap->close();
return false;
}
$ldap->delete_entry($dn);
+
+ $ldap->close();
}
/**
@@ -274,18 +293,19 @@
$domain = $ldap->find_domain($_domain);
if (!$domain) {
+ $ldap->close();
return false;
}
$base_dn = $ldap->domain_root_dn($_domain);
$dn = "uid={$user->email},ou=People,{$base_dn}";
- $old_entry = $ldap->get_entry($dn);
- $new_entry = $old_entry;
+ $oldEntry = $ldap->get_entry($dn);
+ $newEntry = $oldEntry;
- self::setUserAttributes($user, $new_entry);
+ self::setUserAttributes($user, $newEntry);
- $ldap->modify_entry($dn, $old_entry, $new_entry);
+ $ldap->modify_entry($dn, $oldEntry, $newEntry);
$ldap->close();
}
@@ -306,6 +326,14 @@
return $ldap;
}
+ /**
+ * Set domain attributes
+ */
+ private static function setDomainAttributes(Domain $domain, array &$entry)
+ {
+ $entry['inetdomainstatus'] = $domain->status;
+ }
+
/**
* Set common user attributes
*/
@@ -341,6 +369,27 @@
$entry['givenname'] = $firstName;
$entry['sn'] = $lastName;
$entry['userpassword'] = $user->password_ldap;
+
+ $entry['inetuserstatus'] = $user->status;
+
+ $entitlements = \App\Entitlement::where(
+ [
+ 'entitleable_id' => $user->id,
+ 'entitleable_type' => \App\User::class
+ ]
+ );
+
+ $entry['mailquota'] = 0;
+
+ foreach ($entitlements->get() as $entitlement) {
+ \Log::debug("Examining {$entitlement->sku->title}");
+
+ switch ($entitlement->sku->title) {
+ case "storage":
+ $entry['mailquota'] += 1048576;
+ break;
+ }
+ }
}
/**
@@ -367,7 +416,11 @@
public static function logHook($level, $msg): void
{
if (
- ($level == LOG_INFO || $level == LOG_DEBUG || $level == LOG_NOTICE)
+ (
+ $level == LOG_INFO
+ || $level == LOG_DEBUG
+ || $level == LOG_NOTICE
+ )
&& !\config('app.debug')
) {
return;
diff --git a/src/app/Console/Commands/DomainCheck.php b/src/app/Console/Commands/DomainCheck.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainCheck.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+
+class DomainCheck extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:check';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Command description';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ //
+ }
+}
diff --git a/src/app/Console/Commands/DomainList.php b/src/app/Console/Commands/DomainList.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainList.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Domain;
+use Illuminate\Console\Command;
+
+class DomainList extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:list';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'List domains';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $domains = Domain::withTrashed()->each(
+ function ($domain) {
+ $this->info($domain->namespace);
+ }
+ );
+ }
+}
diff --git a/src/app/Console/Commands/DomainStatus.php b/src/app/Console/Commands/DomainStatus.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainStatus.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Domain;
+use Illuminate\Console\Command;
+
+class DomainStatus extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:status {domain}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Display the status of a domain';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $domain = Domain::where('namespace', $this->argument('domain'))->first();
+
+ if (!$domain) {
+ return 1;
+ }
+
+ $this->info("Found domain: {$domain->id}");
+
+ $this->info($domain->status);
+ }
+}
diff --git a/src/app/Console/Commands/DomainSuspend.php b/src/app/Console/Commands/DomainSuspend.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainSuspend.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Domain;
+use Illuminate\Console\Command;
+
+class DomainSuspend extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:suspend {domain}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Suspend a domain';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $domain = Domain::where('namespace', $this->argument('domain'))->first();
+
+ if (!$domain) {
+ return 1;
+ }
+
+ $this->info("Found domain: {$domain->id}");
+
+ $domain->suspend();
+ }
+}
diff --git a/src/app/Console/Commands/DomainUnsuspend.php b/src/app/Console/Commands/DomainUnsuspend.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainUnsuspend.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Domain;
+use Illuminate\Console\Command;
+
+class DomainUnsuspend extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:unsuspend {domain}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Remove a domain suspension';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $domain = Domain::where('namespace', $this->argument('domain'))->first();
+
+ if (!$domain) {
+ return 1;
+ }
+
+ $this->info("Found domain {$domain->id}");
+
+ $domain->unsuspend();
+ }
+}
diff --git a/src/app/Console/Commands/UserStatus.php b/src/app/Console/Commands/UserStatus.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/UserStatus.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\User;
+use Illuminate\Console\Command;
+
+class UserStatus extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'user:status {user}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Display the status of a user';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $user = User::where('email', $this->argument('user'))->first();
+
+ if (!$user) {
+ return 1;
+ }
+
+ $this->info("Found user: {$user->id}");
+
+ $this->info($user->status);
+ }
+}
diff --git a/src/app/Console/Commands/UserSuspend.php b/src/app/Console/Commands/UserSuspend.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/UserSuspend.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\User;
+use Illuminate\Console\Command;
+
+class UserSuspend extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'user:suspend {user}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Suspend a user';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $user = User::where('email', $this->argument('user'))->first();
+
+ if (!$user) {
+ return 1;
+ }
+
+ $this->info("Found user: {$user->id}");
+
+ $user->suspend();
+ }
+}
diff --git a/src/app/Console/Commands/UserUnsuspend.php b/src/app/Console/Commands/UserUnsuspend.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/UserUnsuspend.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\User;
+use Illuminate\Console\Command;
+
+class UserUnsuspend extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'user:unsuspend {user}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Remove a user suspension';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $user = User::where('email', $this->argument('user'))->first();
+
+ if (!$user) {
+ return 1;
+ }
+
+ $this->info("Found user {$user->id}");
+
+ $user->unsuspend();
+ }
+}
diff --git a/src/app/Console/Commands/UserVerify.php b/src/app/Console/Commands/UserVerify.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/UserVerify.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+
+class UserVerify extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'user:verify {user}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Verify the state of a user account';
+
+ /**
+ * Create a new command instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $user = \App\User::where('email', $this->argument('user'))->first();
+
+ if (!$user) {
+ return 1;
+ }
+
+ $this->info("Found user: {$user->id}");
+
+ $job = new \App\Jobs\UserVerify($user);
+ $job->handle();
+ }
+}
diff --git a/src/app/Domain.php b/src/app/Domain.php
--- a/src/app/Domain.php
+++ b/src/app/Domain.php
@@ -308,6 +308,36 @@
return $mod === self::HASH_TEXT ? "$cname=$hash" : $hash;
}
+ /**
+ * Suspend this domain.
+ *
+ * @return void
+ */
+ public function suspend(): void
+ {
+ if ($this->isSuspended()) {
+ return;
+ }
+
+ $this->status |= Domain::STATUS_SUSPENDED;
+ $this->save();
+ }
+
+ /**
+ * Unsuspend this domain.
+ *
+ * @return void
+ */
+ public function unsuspend(): void
+ {
+ if (!$this->isSuspended()) {
+ return;
+ }
+
+ $this->status ^= Domain::STATUS_SUSPENDED;
+ $this->save();
+ }
+
/**
* Verify if a domain exists in DNS
*
diff --git a/src/app/Jobs/DomainUpdate.php b/src/app/Jobs/DomainUpdate.php
new file mode 100644
--- /dev/null
+++ b/src/app/Jobs/DomainUpdate.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Backends\LDAP;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class DomainUpdate implements ShouldQueue
+{
+ use Dispatchable;
+ use InteractsWithQueue;
+ use Queueable;
+ use SerializesModels;
+
+ protected $domain_id;
+
+ /**
+ * Create a new job instance.
+ *
+ * @param int $domain_id
+ *
+ * @return void
+ */
+ public function __construct($domain_id)
+ {
+ $this->domain_id = $domain_id;
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ $domain = \App\Domain::find($this->domain_id);
+
+ LDAP::updateDomain($domain);
+ }
+}
diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php
--- a/src/app/Observers/DomainObserver.php
+++ b/src/app/Observers/DomainObserver.php
@@ -77,10 +77,9 @@
*/
public function updated(Domain $domain)
{
- //
+ \App\Jobs\DomainUpdate::dispatch($domain->id);
}
-
/**
* Handle the domain "restored" event.
*
diff --git a/src/app/Observers/EntitlementObserver.php b/src/app/Observers/EntitlementObserver.php
--- a/src/app/Observers/EntitlementObserver.php
+++ b/src/app/Observers/EntitlementObserver.php
@@ -53,4 +53,16 @@
return false;
}
}
+
+ public function created(Entitlement $entitlement)
+ {
+ $entitlement->entitleable->updated_at = Carbon::now();
+ $entitlement->entitleable->save();
+ }
+
+ public function deleted(Entitlement $entitlement)
+ {
+ $entitlement->entitleable->updated_at = Carbon::now();
+ $entitlement->entitleable->save();
+ }
}
diff --git a/src/app/User.php b/src/app/User.php
--- a/src/app/User.php
+++ b/src/app/User.php
@@ -452,6 +452,36 @@
return $this->hasMany('App\UserSetting', 'user_id');
}
+ /**
+ * Suspend this domain.
+ *
+ * @return void
+ */
+ public function suspend(): void
+ {
+ if ($this->isSuspended()) {
+ return;
+ }
+
+ $this->status |= User::STATUS_SUSPENDED;
+ $this->save();
+ }
+
+ /**
+ * Unsuspend this domain.
+ *
+ * @return void
+ */
+ public function unsuspend(): void
+ {
+ if (!$this->isSuspended()) {
+ return;
+ }
+
+ $this->status ^= User::STATUS_SUSPENDED;
+ $this->save();
+ }
+
/**
* Return users controlled by the current user.
*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 7, 12:27 AM (5 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18840241
Default Alt Text
D1069.1775521627.diff (26 KB)
Attached To
Mode
D1069: Progress changes on to LDAP
Attached
Detach File
Event Timeline