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
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
308bd662
Commit
308bd662
authored
3 years ago
by
Jan-Hendrik Willms
Committed by
David Siegfried
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
set sender for consultation mails, fixes #616
parent
ec3b5747
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 @
308bd662
...
@@ -23,13 +23,14 @@ class ConsultationMailer
...
@@ -23,13 +23,14 @@ class ConsultationMailer
/**
/**
* Sends a consultation information message.
* Sends a consultation information message.
*
*
* @param User $user Recipient
* @param User|null $sender Sender
* @param ConsultationSlot $slot Slot in question
* @param User $user Recipient
* @param string $subject Subject of the message
* @param ConsultationSlot $slot Slot in question
* @param string $reason Reason for a booking or cancelation
* @param string $subject Subject of the message
* @param User $sender Sender 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
// Don't send message if user doesn't want it
if
(
!
UserConfig
::
get
(
$user
->
id
)
->
CONSULTATION_SEND_MESSAGES
)
{
if
(
!
UserConfig
::
get
(
$user
->
id
)
->
CONSULTATION_SEND_MESSAGES
)
{
...
@@ -44,7 +45,12 @@ class ConsultationMailer
...
@@ -44,7 +45,12 @@ class ConsultationMailer
'reason'
=>
$reason
?:
_
(
'Kein Grund angegeben'
),
'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
();
restoreLanguage
();
}
}
...
@@ -52,9 +58,10 @@ class ConsultationMailer
...
@@ -52,9 +58,10 @@ class ConsultationMailer
/**
/**
* Send a booking information message to the teacher of the booked slot.
* 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
)
{
foreach
(
$booking
->
slot
->
block
->
responsible_persons
as
$user
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
...
@@ -62,10 +69,10 @@ class ConsultationMailer
...
@@ -62,10 +69,10 @@ class ConsultationMailer
}
}
self
::
sendMessage
(
self
::
sendMessage
(
$sender
,
$user
,
$user
,
$booking
,
$booking
,
sprintf
(
_
(
'Termin von %s zugesagt'
),
$booking
->
user
->
getFullName
()),
sprintf
(
_
(
'Termin von %s zugesagt'
),
$booking
->
user
->
getFullName
()),
$booking
->
reason
$booking
->
reason
);
);
}
}
}
}
...
@@ -73,15 +80,16 @@ class ConsultationMailer
...
@@ -73,15 +80,16 @@ class ConsultationMailer
/**
/**
* Send a booking information message to the user of the booked slot.
* Send a booking information message to the user of the booked slot.
*
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
* @param ConsultationBooking $booking The booking
*/
*/
public
static
function
sendBookingMessageToUser
(
ConsultationBooking
$booking
)
public
static
function
sendBookingMessageToUser
(
?User
$sender
,
ConsultationBooking
$booking
)
{
{
self
::
sendMessage
(
self
::
sendMessage
(
$sender
,
$booking
->
user
,
$booking
->
user
,
$booking
,
$booking
,
sprintf
(
_
(
'Termin bei %s zugesagt'
),
$booking
->
slot
->
block
->
range_display
),
sprintf
(
_
(
'Termin bei %s zugesagt'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
$booking
->
reason
);
);
}
}
...
@@ -89,27 +97,28 @@ class ConsultationMailer
...
@@ -89,27 +97,28 @@ class ConsultationMailer
* Send an information message about a changed reason to a user of the
* Send an information message about a changed reason to a user of the
* booked slot.
* booked slot.
*
*
* @param
ConsultationBooking $booking The booking
* @param
User $sender The sender of the message
* @param
User $receiver The receiver of the message
* @param
ConsultationBooking $booking The booking
* @param
User $
send
er
The
send
er of the message
* @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
(
self
::
sendMessage
(
$sender
,
$receiver
,
$receiver
,
$booking
,
$booking
,
sprintf
(
_
(
'Grund des Termins bei %s bearbeitet'
),
$booking
->
slot
->
block
->
range_display
),
sprintf
(
_
(
'Grund des Termins bei %s bearbeitet'
),
$booking
->
slot
->
block
->
range_display
),
$booking
->
reason
$booking
->
reason
);
);
}
}
/**
/**
* Send a cancelation message to the teacher of the booked slot.
* Send a cancelation message to the teacher of the booked slot.
*
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
* @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
)
{
foreach
(
$booking
->
slot
->
block
->
responsible_persons
as
$user
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
if
(
$user
->
id
===
$GLOBALS
[
'user'
]
->
id
)
{
...
@@ -117,10 +126,10 @@ class ConsultationMailer
...
@@ -117,10 +126,10 @@ class ConsultationMailer
}
}
self
::
sendMessage
(
self
::
sendMessage
(
$sender
,
$user
,
$user
,
$booking
,
$booking
,
sprintf
(
_
(
'Termin von %s abgesagt'
),
$booking
->
user
->
getFullName
()),
sprintf
(
_
(
'Termin von %s abgesagt'
),
$booking
->
user
->
getFullName
()),
trim
(
$reason
)
trim
(
$reason
)
);
);
}
}
}
}
...
@@ -128,16 +137,17 @@ class ConsultationMailer
...
@@ -128,16 +137,17 @@ class ConsultationMailer
/**
/**
* Send a cancelation message to the user of the booked slot.
* Send a cancelation message to the user of the booked slot.
*
*
* @param User|null $sender
* @param ConsultationBooking $booking The booking
* @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
(
self
::
sendMessage
(
$sender
,
$booking
->
user
,
$booking
->
user
,
$booking
,
$booking
,
sprintf
(
_
(
'Termin bei %s abgesagt'
),
$booking
->
slot
->
block
->
range_display
),
sprintf
(
_
(
'Termin bei %s abgesagt'
),
$booking
->
slot
->
block
->
range_display
),
trim
(
$reason
)
trim
(
$reason
)
);
);
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/models/ConsultationBooking.php
+
6
−
6
View file @
308bd662
...
@@ -59,20 +59,20 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
...
@@ -59,20 +59,20 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
};
};
$config
[
'registered_callbacks'
][
'after_create'
][]
=
function
(
ConsultationBooking
$booking
)
{
$config
[
'registered_callbacks'
][
'after_create'
][]
=
function
(
ConsultationBooking
$booking
)
{
ConsultationMailer
::
sendBookingMessageToUser
(
$booking
);
ConsultationMailer
::
sendBookingMessageToUser
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
);
ConsultationMailer
::
sendBookingMessageToResponsibilities
(
$booking
);
ConsultationMailer
::
sendBookingMessageToResponsibilities
(
$GLOBALS
[
'user'
]
->
getAuthenticatedUser
(),
$booking
);
};
};
$config
[
'registered_callbacks'
][
'before_store'
][]
=
function
(
ConsultationBooking
$booking
)
{
$config
[
'registered_callbacks'
][
'before_store'
][]
=
function
(
ConsultationBooking
$booking
)
{
if
(
!
$booking
->
isNew
()
&&
$booking
->
isFieldDirty
(
'reason'
))
{
if
(
!
$booking
->
isNew
()
&&
$booking
->
isFieldDirty
(
'reason'
))
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$booking
->
user_id
)
{
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
;
$responsible_persons
=
$booking
->
slot
->
block
->
responsible_persons
;
foreach
(
$responsible_persons
as
$user
)
{
foreach
(
$responsible_persons
as
$user
)
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$user
->
id
)
{
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
...
@@ -97,10 +97,10 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
public
function
cancel
(
$reason
=
''
)
public
function
cancel
(
$reason
=
''
)
{
{
if
(
$GLOBALS
[
'user'
]
->
id
!==
$this
->
user_id
)
{
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
;
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