Skip to content

Commit 96effbe

Browse files
committed
setup mail templates
1 parent 1277de5 commit 96effbe

File tree

9 files changed

+202
-33
lines changed

9 files changed

+202
-33
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ repos:
3131
resources/lib/phpopenldaper/.*|
3232
vendor/.*|
3333
resources/lib/.*|
34+
resources/mail/.*|
3435
)$
3536
3637
- repo: https://github.com/rbubley/mirrors-prettier
@@ -47,6 +48,7 @@ repos:
4748
vendor/.*|
4849
resources/templates/.*|
4950
webroot/.*|
51+
resources/mail/.*|
5052
)$
5153
5254
# linters (work required) ########################################################################
@@ -81,6 +83,7 @@ repos:
8183
resources/lib/phpopenldaper/.*|
8284
vendor/.*|
8385
resources/lib/.*|
86+
resources/mail/.*|
8487
)$
8588
- id: php-l
8689
name: php -l

resources/lib/UnityGroup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ public function approveUser(UnityUser $new_user, bool $send_mail = true): void
191191
"org" => $new_user->getOrg(),
192192
]);
193193
}
194-
$new_user->setModifier("qualified", true); // being in a group makes you qualified
194+
// being in a group makes you qualified
195+
$new_user->setModifier("qualified", true, true, false);
195196
}
196197

197198
public function denyUser(UnityUser $new_user, bool $send_mail = true): void

resources/lib/UnityUser.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ public function getModifier($modifier): bool
102102
return $this->LDAP->userModifierGroups[$modifier]->memberUIDExists($this->uid);
103103
}
104104

105-
public function setModifier($modifier, bool $newValue, bool $doSendMail = true): void
106-
{
105+
public function setModifier(
106+
$modifier,
107+
bool $newValue,
108+
bool $doSendMail = true,
109+
bool $doSendMailAdmin = true,
110+
): void {
107111
$oldValue = $this->getModifier($modifier);
108112
if ($oldValue == $newValue) {
109113
return;
@@ -117,6 +121,13 @@ public function setModifier($modifier, bool $newValue, bool $doSendMail = true):
117121
"modifier" => $modifier,
118122
]);
119123
}
124+
if ($doSendMailAdmin) {
125+
$this->MAILER->sendMail($this->getMail(), "user_modifier_added_admin", [
126+
"user" => $this->uid,
127+
"org" => $this->getOrg(),
128+
"modifier" => $modifier,
129+
]);
130+
}
120131
} else {
121132
$this->LDAP->userModifierGroups[$modifier]->removeMemberUID($this->uid);
122133
if ($doSendMail) {
@@ -126,6 +137,13 @@ public function setModifier($modifier, bool $newValue, bool $doSendMail = true):
126137
"modifier" => $modifier,
127138
]);
128139
}
140+
if ($doSendMailAdmin) {
141+
$this->MAILER->sendMail($this->getMail(), "user_modifier_removed_admin", [
142+
"user" => $this->uid,
143+
"org" => $this->getOrg(),
144+
"modifier" => $modifier,
145+
]);
146+
}
129147
}
130148
}
131149

resources/mail/user_dequalified.php

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php switch ($data["modifier"]):
2+
case "qualified": ?>
3+
<?php $this->Subject = "User Activated"; ?>
4+
<p>Hello,</p>
5+
<p>Your account on the Unity cluster has been activated. Your account details are below:</p>
6+
<p>
7+
<strong>Username</strong> <?php echo $data["user"]; ?>
8+
<br>
9+
<strong>Organization</strong> <?php echo $data["org"]; ?>
10+
</p>
11+
<p>
12+
Please login to the web portal to access Unity.
13+
If you need console access, you will need to set your SSH keys in the
14+
<a href="<?php echo $this->MSG_LINKREF; ?>/panel/account.php">account settings</a>
15+
page.
16+
</p>
17+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
18+
<?php break; ?>
19+
20+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
21+
<?php case "ghost": ?>
22+
<?php $this->Subject = "User Deleted"; ?>
23+
<p>Hello,</p>
24+
<p>Your account on the Unity cluster has been deleted.</p>
25+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
26+
<?php break; ?>
27+
28+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
29+
<?php case "locked": ?>
30+
<?php $this->Subject = "User Locked"; ?>
31+
<p>Hello,</p>
32+
<p>Your account on the Unity cluster has been locked.</p>
33+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
34+
<?php break; ?>
35+
36+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
37+
<?php case "idlelocked": ?>
38+
<?php $this->Subject = "User Locked"; ?>
39+
<p>Hello,</p>
40+
<p>Your account on the Unity cluster has been locked due to inactivity.</p>
41+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
42+
<?php break; ?>
43+
44+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
45+
<?php case "admin": ?>
46+
<?php $this->Subject = "User Promoted"; ?>
47+
<p>Hello,</p>
48+
<p>Your account on the Unity cluster has been promoted to admin.</p>
49+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
50+
<?php break; ?>
51+
52+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
53+
<?php default: ?>
54+
<?php throw new \Exception("unknown modifier: " . $data["modifier"]) ?>
55+
<?php endswitch; ?>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php switch ($data["modifier"]):
2+
case "qualified": ?>
3+
<?php $this->Subject = "User Qualified"; ?>
4+
<p>Hello,</p>
5+
<p>User "<?php echo $data["user"] ?>" has been qualified. </p>
6+
<?php break; ?>
7+
8+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
9+
<?php case "ghost": ?>
10+
<?php $this->Subject = "User Ghosted"; ?>
11+
<p>Hello,</p>
12+
<p>User "<?php echo $data["user"] ?>" has been marked as ghost. </p>
13+
<?php break; ?>
14+
15+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
16+
<?php case "locked": ?>
17+
<?php $this->Subject = "User Locked"; ?>
18+
<p>Hello,</p>
19+
<p>User "<?php echo $data["user"] ?>" has been locked. </p>
20+
<?php break; ?>
21+
22+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
23+
<?php case "idlelocked": ?>
24+
<?php $this->Subject = "User Idle Locked"; ?>
25+
<p>Hello,</p>
26+
<p>User "<?php echo $data["user"] ?>" has been idle locked. </p>
27+
<?php break; ?>
28+
29+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
30+
<?php case "admin": ?>
31+
<?php $this->Subject = "User Promoted"; ?>
32+
<p>Hello,</p>
33+
<p>User "<?php echo $data["user"] ?>" has been promoted to admin. </p>
34+
<?php break; ?>
35+
36+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
37+
<?php default: ?>
38+
<?php throw new \Exception("unknown modifier: " . $data["modifier"]) ?>
39+
<?php endswitch; ?>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php switch ($data["modifier"]):
2+
case "qualified": ?>
3+
<?php $this->Subject = "User Deactivated"; ?>
4+
<p>Hello,</p>
5+
<p>Your account on the Unity cluster has been deactivated.</p>
6+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
7+
<?php break; ?>
8+
9+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
10+
<?php case "ghost": ?>
11+
<?php $this->Subject = "User Resurrected"; ?>
12+
<p>Hello,</p>
13+
<p>Your account on the Unity cluster has been resurrected.</p>
14+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
15+
<?php break; ?>
16+
17+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
18+
<?php case "locked": ?>
19+
<?php $this->Subject = "User Unlocked"; ?>
20+
<p>Hello,</p>
21+
<p>Your account on the Unity cluster has been unlocked.</p>
22+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
23+
<?php break; ?>
24+
25+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
26+
<?php case "idlelocked": ?>
27+
<?php $this->Subject = "User Unlocked"; ?>
28+
<p>Hello,</p>
29+
<p>Your account on the Unity cluster has been unlocked.</p>
30+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
31+
<?php break; ?>
32+
33+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
34+
<?php case "admin": ?>
35+
<?php $this->Subject = "User Demoted"; ?>
36+
<p>Hello,</p>
37+
<p>Your account on the Unity cluster has been demoted from admin.</p>
38+
<p>If you believe this to be a mistake, please reply to this email as soon as possible.</p>
39+
<?php break; ?>
40+
41+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
42+
<?php default: ?>
43+
<?php throw new \Exception("unknown modifier: " . $data["modifier"]) ?>
44+
<?php endswitch; ?>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php switch ($data["modifier"]):
2+
case "qualified": ?>
3+
<?php $this->Subject = "User Dequalified"; ?>
4+
<p>Hello,</p>
5+
<p>User "<?php echo $data["user"] ?>" has been dequalified. </p>
6+
<?php break; ?>
7+
8+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
9+
<?php case "ghost": ?>
10+
<?php $this->Subject = "User Resurrected"; ?>
11+
<p>Hello,</p>
12+
<p>User "<?php echo $data["user"] ?>" has been resurrected (no longer marked as ghost). </p>
13+
<?php break; ?>
14+
15+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
16+
<?php case "locked": ?>
17+
<?php $this->Subject = "User Unlocked"; ?>
18+
<p>Hello,</p>
19+
<p>User "<?php echo $data["user"] ?>" has been unlocked. </p>
20+
<?php break; ?>
21+
22+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
23+
<?php case "idlelocked": ?>
24+
<?php $this->Subject = "User Idle Unlocked"; ?>
25+
<p>Hello,</p>
26+
<p>User "<?php echo $data["user"] ?>" has been idle unlocked. </p>
27+
<?php break; ?>
28+
29+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
30+
<?php case "admin": ?>
31+
<?php $this->Subject = "User Demoted"; ?>
32+
<p>Hello,</p>
33+
<p>User "<?php echo $data["user"] ?>" has been demoted from admin. </p>
34+
<?php break; ?>
35+
36+
<?php /////////////////////////////////////////////////////////////////////////////////////////// ?>
37+
<?php default: ?>
38+
<?php throw new \Exception("unknown modifier: " . $data["modifier"]) ?>
39+
<?php endswitch; ?>

resources/mail/user_qualified.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)