Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MatrixPlugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
studip-plugins-oeffentlich
MatrixPlugin
Commits
0dc2c4c0
Commit
0dc2c4c0
authored
1 year ago
by
Thomas Hackl
Browse files
Options
Downloads
Patches
Plain Diff
check for news expiration in cronjob
parent
63aa7084
No related branches found
Branches containing commit
Tags
v1.4.4
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MatrixPostNewsCronjob.php
+29
-22
29 additions, 22 deletions
MatrixPostNewsCronjob.php
plugin.manifest
+1
-1
1 addition, 1 deletion
plugin.manifest
with
30 additions
and
23 deletions
MatrixPostNewsCronjob.php
+
29
−
22
View file @
0dc2c4c0
...
...
@@ -77,34 +77,41 @@ class MatrixPostNewsCronjob extends CronJob
print_r
(
$news
);
}
foreach
(
StudipNews
::
findMany
(
$news
)
as
$one
)
{
foreach
(
$one
->
news_ranges
as
$range
)
{
$success
=
false
;
if
(
$range
->
course
&&
MatrixRoom
::
hasRoom
(
$range
->
course
->
id
))
{
$room
=
MatrixRoom
::
find
(
$range
->
course
->
id
);
if
(
$one
->
date
+
$one
->
expire
>=
time
())
{
foreach
(
$one
->
news_ranges
as
$range
)
{
$success
=
false
;
if
(
$range
->
course
&&
MatrixRoom
::
hasRoom
(
$range
->
course
->
id
))
{
$room
=
MatrixRoom
::
find
(
$range
->
course
->
id
);
$success
=
MatrixClient
::
get
()
->
postMessage
(
MatrixAccount
::
requireSystemAccount
(),
$room
->
getLinkedRoom
(),
'Ankündigung: '
.
$one
->
topic
.
' '
.
strip_tags
(
$one
->
body
),
'<strong>Ankündigung: '
.
$one
->
topic
.
'</strong><br>'
.
$one
->
body
);
$success
=
MatrixClient
::
get
()
->
postMessage
(
MatrixAccount
::
requireSystemAccount
(),
$room
->
getLinkedRoom
(),
'Ankündigung: '
.
$one
->
topic
.
' '
.
strip_tags
(
$one
->
body
),
'<strong>Ankündigung: '
.
$one
->
topic
.
'</strong><br>'
.
$one
->
body
);
// Mark entry as done after message has been posted to Matrix room successfully.
if
(
$success
)
{
// Verbose output
if
(
$parameters
[
'verbose'
])
{
echo
sprintf
(
"Posted news entry $1%s to Matrix room $2%s in course $3%s.
\n
"
,
$one
->
id
,
$room
->
matrix_room_id
,
$room
->
range_id
);
}
// Mark entry as done after message has been posted to Matrix room successfully.
if
(
$success
)
{
// Verbose output
if
(
$parameters
[
'verbose'
])
{
echo
sprintf
(
"Posted news entry $1%s to Matrix room $2%s in course $3%s.
\n
"
,
$news
->
id
,
$room
->
matrix_room_id
,
$room
->
range_id
DBManager
::
get
()
->
execute
(
"UPDATE `matrix_upcoming_news` SET `posted` = 1 WHERE `news_id` = :id AND `range_id` = :range"
,
[
'id'
=>
$one
->
id
,
'range'
=>
$range
->
course
->
id
]
);
}
DBManager
::
get
()
->
execute
(
"UPDATE `matrix_upcoming_news` SET `posted` = 1 WHERE `news_id` = :id AND `range_id` = :range"
,
[
'id'
=>
$one
->
id
,
'range'
=>
$range
->
course
->
id
]
);
}
}
}
else
{
DBManager
::
get
()
->
execute
(
"DELETE FROM `matrix_upcoming_news` WHERE `news_id` = :id"
,
[
'id'
=>
$one
->
id
]
);
}
}
...
...
This diff is collapsed.
Click to expand it.
plugin.manifest
+
1
−
1
View file @
0dc2c4c0
pluginname=Matrix-Chat
pluginclassname=MatrixPlugin
origin=data-quest
version=1.4.
3
version=1.4.
4
screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses
studipMinVersion=4.5
...
...
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