Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
d24f4748
Commit
d24f4748
authored
3 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
set sender for consultation mails, fixes #616
parent
910f14df
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/classes/ConsultationMailer.php
+38
-28
38 additions, 28 deletions
lib/classes/ConsultationMailer.php
lib/models/ConsultationBooking.php
+6
-6
6 additions, 6 deletions
lib/models/ConsultationBooking.php
with
44 additions
and
34 deletions
lib/classes/ConsultationMailer.php
+
38
−
28
View file @
d24f4748
...
...
@@ -23,13 +23,14 @@ class ConsultationMailer
/**
* Sends a consultation information message.
*
* @param User $user Recipient
* @param ConsultationSlot $slot Slot in question
* @param string $subject Subject of the message
* @param string $reason Reason for a booking or cancelation
* @param User $sender Sender of the message
* @param User|null $sender Sender
* @param User $user Recipient
* @param ConsultationSlot $slot Slot in question
* @param string $subject Subject of the message
* @param string $reason Reason for a booking or cancelation
* @param User $sender Sender of the message
*/
public
static
function
sendMessage
(
User
$user
,
ConsultationBooking
$booking
,
$subject
,
$reason
=
''
)
public
static
function
sendMessage
(
?User
$sender
,
User
$user
,
ConsultationBooking
$booking
,
string
$subject
,
string
$reason
=
''
)
{
// Don't send message if user doesn't want it
if
(
!
UserConfig
::
get
(
$user
->
id
)
->
CONSULTATION_SEND_MESSAGES
)
{
...
...
@@ -44,7 +45,12 @@ class ConsultationMailer
'reason'
=>
$reason
?:
_
(
'Kein Grund angegeben'
),
]);
messaging
::
sendSystemMessage
(
$user
,
$subject
,
$message
);
if
(
$sender
===
null
)
{
messaging
::
sendSystemMessage
(
$user
,
$subject
,
$message
);
}
else
{
$messaging
=
new
messaging
();
$messaging
->
insert_message
(
$message
,
$user
->
username
,
$sender
->
id
,
''
,
''
,
''
,
''
,
$subject
);
}
restoreLanguage
();
}
...
...
@@ -52,9 +58,10 @@ class ConsultationMailer
/**
* Send a booking information message to the teacher of the booked slot.
*
* @param ConsultationBooking $booking The booking
* @param User|null $sender
* @param ConsultationBooking $booking The booking
*/
public
static
function
sendBookingMessageToResponsibilities
(
ConsultationBooking
$booking
)
public
static
function
sendBookingMessageToResponsibilities
(
?User
$sender
,
ConsultationBooking
$booking
)
{
foreach
(
$booking
->
slot
->
block
->
responsible_persons
as
$user
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
...
...
@@ -62,10 +69,10 @@ class ConsultationMailer
}
self
::
sendMessage
(
$sender
,
$user
,
$booking
,
sprintf
(
_
(
'Termin von %s zugesagt'
),
$booking
->
user
->
getFullName
()),
$booking
->
reason
sprintf
(
_
(
'Termin von %s zugesagt'
),
$booking
->
user
->
getFullName
()),
$booking
->
reason
);
}
}
...
...
@@ -73,15 +80,16 @@ class ConsultationMailer
/**
* Send a booking information message to the user of the booked slot.
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
*/
public
static
function
sendBookingMessageToUser
(
ConsultationBooking
$booking
)
public
static
function
sendBookingMessageToUser
(
?User
$sender
,
ConsultationBooking
$booking
)
{
self
::
sendMessage
(
$sender
,
$booking
->
user
,
$booking
,
sprintf
(
_
(
'Termin bei %s zugesagt'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
sprintf
(
_
(
'Termin bei %s zugesagt'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
);
}
...
...
@@ -89,27 +97,28 @@ class ConsultationMailer
* Send an information message about a changed reason to a user of the
* booked slot.
*
* @param
ConsultationBooking $booking The booking
* @param
User $receiver The receiver of the message
* @param
User $
send
er
The
send
er of the message
* @param
User $sender The sender of the message
* @param
ConsultationBooking $booking The booking
* @param User $
receiv
er The
receiv
er of the message
*/
public
static
function
sendReasonMessage
(
ConsultationBooking
$booking
,
User
$receiver
)
public
static
function
sendReasonMessage
(
?User
$sender
,
ConsultationBooking
$booking
,
User
$receiver
)
{
self
::
sendMessage
(
$sender
,
$receiver
,
$booking
,
sprintf
(
_
(
'Grund des Termins bei %s bearbeitet'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
sprintf
(
_
(
'Grund des Termins bei %s bearbeitet'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
);
}
/**
* Send a cancelation message to the teacher of the booked slot.
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
* @param
String $reason Reason of the cancelation
* @param String
$reason Reason of the cancelation
*/
public
static
function
sendCancelMessageToResponsibilities
(
ConsultationBooking
$booking
,
$reason
=
''
)
public
static
function
sendCancelMessageToResponsibilities
(
?User
$sender
,
ConsultationBooking
$booking
,
string
$reason
=
''
)
{
foreach
(
$booking
->
slot
->
block
->
responsible_persons
as
$user
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
...
...
@@ -117,10 +126,10 @@ class ConsultationMailer
}
self
::
sendMessage
(
$sender
,
$user
,
$booking
,
sprintf
(
_
(
'Termin von %s abgesagt'
),
$booking
->
user
->
getFullName
()),
trim
(
$reason
)
sprintf
(
_
(
'Termin von %s abgesagt'
),
$booking
->
user
->
getFullName
()),
trim
(
$reason
)
);
}
}
...
...
@@ -128,16 +137,17 @@ class ConsultationMailer
/**
* Send a cancelation message to the user of the booked slot.
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
* @param
String $reason Reason of the cancelation
* @param String
$reason Reason of the cancelation
*/
public
static
function
sendCancelMessageToUser
(
ConsultationBooking
$booking
,
$reason
)
public
static
function
sendCancelMessageToUser
(
?User
$sender
,
ConsultationBooking
$booking
,
string
$reason
)
{
self
::
sendMessage
(
$sender
,
$booking
->
user
,
$booking
,
sprintf
(
_
(
'Termin bei %s abgesagt'
),
$booking
->
slot
->
block
->
range_display
),
trim
(
$reason
)
sprintf
(
_
(
'Termin bei %s abgesagt'
),
$booking
->
slot
->
block
->
range_display
),
trim
(
$reason
)
);
}
}
This diff is collapsed.
Click to expand it.
lib/models/ConsultationBooking.php
+
6
−
6
View file @
d24f4748
...
...
@@ -59,20 +59,20 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
};
$config
[
'registered_callbacks'
][
'after_create'
][]
=
function
(
ConsultationBooking
$booking
)
{
ConsultationMailer
::
sendBookingMessageToUser
(
$booking
);
ConsultationMailer
::
sendBookingMessageToResponsibilities
(
$booking
);
ConsultationMailer
::
sendBookingMessageToUser
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
);
ConsultationMailer
::
sendBookingMessageToResponsibilities
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
);
};
$config
[
'registered_callbacks'
][
'before_store'
][]
=
function
(
ConsultationBooking
$booking
)
{
if
(
!
$booking
->
isNew
()
&&
$booking
->
isFieldDirty
(
'reason'
))
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$booking
->
user_id
)
{
ConsultationMailer
::
sendReasonMessage
(
$booking
,
$booking
->
user
);
ConsultationMailer
::
sendReasonMessage
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
,
$booking
->
user
);
}
$responsible_persons
=
$booking
->
slot
->
block
->
responsible_persons
;
foreach
(
$responsible_persons
as
$user
)
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$user
->
id
)
{
ConsultationMailer
::
sendReasonMessage
(
$booking
,
$user
);
ConsultationMailer
::
sendReasonMessage
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
,
$user
);
}
}
}
...
...
@@ -97,10 +97,10 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
public
function
cancel
(
$reason
=
''
)
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$this
->
user_id
)
{
ConsultationMailer
::
sendCancelMessageToUser
(
$this
,
$reason
);
ConsultationMailer
::
sendCancelMessageToUser
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$this
,
$reason
);
}
ConsultationMailer
::
sendCancelMessageToResponsibilities
(
$this
,
$reason
);
ConsultationMailer
::
sendCancelMessageToResponsibilities
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$this
,
$reason
);
return
$this
->
delete
()
?
1
:
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment