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
9dd46ca4
Commit
9dd46ca4
authored
2 years ago
by
André Noack
Committed by
Jan-Hendrik Willms
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
resolve #964 Tägliche Mail Benachrichtigungen funktionieren nicht
Closes #964 Merge request
studip/studip!591
parent
4d4ec44c
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/ModulesNotification.class.php
+15
-140
15 additions, 140 deletions
lib/classes/ModulesNotification.class.php
lib/models/CourseMember.class.php
+7
-0
7 additions, 0 deletions
lib/models/CourseMember.class.php
with
22 additions
and
140 deletions
lib/classes/ModulesNotification.class.php
+
15
−
140
View file @
9dd46ca4
...
@@ -35,15 +35,14 @@
...
@@ -35,15 +35,14 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +---------------------------------------------------------------------------+
// +---------------------------------------------------------------------------+
require_once
'lib/meine_seminare_func.inc.php'
;
class
ModulesNotification
class
ModulesNotification
{
{
public
$registered_notification_modules
=
[];
public
$registered_notification_modules
=
[];
public
$subject
;
public
$subject
;
function
__construct
()
{
function
__construct
()
{
foreach
(
MyRealmModel
::
getDefaultModules
()
as
$id
=>
$module
)
{
foreach
(
MyRealmModel
::
getDefaultModules
()
as
$id
=>
$module
)
{
if
(
!
is_object
(
$module
))
continue
;
if
(
!
is_object
(
$module
))
continue
;
$this
->
registered_notification_modules
[
$id
]
=
[
$this
->
registered_notification_modules
[
$id
]
=
[
...
@@ -75,9 +74,8 @@ class ModulesNotification
...
@@ -75,9 +74,8 @@ class ModulesNotification
function
getAllNotifications
(
$user_id
=
NULL
)
// only range = 'sem' is implemented
{
function
getAllNotifications
(
$user_id
=
NULL
)
{
if
(
is_null
(
$user_id
))
{
if
(
is_null
(
$user_id
))
{
$user_id
=
$GLOBALS
[
'user'
]
->
id
;
$user_id
=
$GLOBALS
[
'user'
]
->
id
;
...
@@ -97,30 +95,31 @@ class ModulesNotification
...
@@ -97,30 +95,31 @@ class ModulesNotification
while
(
$row
=
$statement
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
while
(
$row
=
$statement
->
fetch
(
PDO
::
FETCH_ASSOC
))
{
$seminar_id
=
$row
[
'Seminar_id'
];
$seminar_id
=
$row
[
'Seminar_id'
];
$tools
=
ToolActivation
::
findbyRange_id
(
$seminar_id
);
$tools
=
ToolActivation
::
findbyRange_id
(
$seminar_id
);
$notification
=
CourseMemberNotification
::
find
([
$user_id
,
$seminar_id
]);
$my_sem
[
$seminar_id
]
=
[
$my_sem
[
$seminar_id
]
=
[
'name'
=>
$row
[
'Name'
],
'name'
=>
$row
[
'Name'
],
'chdate'
=>
$row
[
'chdate'
],
'chdate'
=>
$row
[
'chdate'
],
'start_time'
=>
$row
[
'start_time'
],
'start_time'
=>
$row
[
'start_time'
],
'tools'
=>
new
SimpleCollection
(
$tools
),
'tools'
=>
new
SimpleCollection
(
$tools
),
'visitdate'
=>
$row
[
'visitdate'
],
'visitdate'
=>
$row
[
'visitdate'
],
'notification'
=>
CourseMemberNotification
::
find
([
$user_id
,
$seminar_id
]),
'notification'
=>
$notification
?
$notification
->
notification_data
->
getArrayCopy
()
:
[]
];
];
}
}
$visit_data
=
get_objects_visits
(
array_keys
(
$my_sem
),
'sem'
,
null
,
$user_id
,
array_keys
(
$this
->
registered_notification_modules
));
$visit_data
=
get_objects_visits
(
array_keys
(
$my_sem
),
'sem'
,
null
,
$user_id
,
array_keys
(
$this
->
registered_notification_modules
));
$news
=
[];
$news
=
[];
foreach
(
$my_sem
as
$seminar_id
=>
$s_data
)
{
foreach
(
$my_sem
as
$seminar_id
=>
$s_data
)
{
if
(
!
count
(
$s_data
->
notification
))
continue
;
if
(
!
count
(
$s_data
[
'notification'
]))
{
$navigation
=
MyRealmModel
::
getAdditionalNavigations
(
$seminar_id
,
$s_data
,
null
,
$user_id
,
$visit_data
);
continue
;
}
$navigation
=
MyRealmModel
::
getAdditionalNavigations
(
$seminar_id
,
$s_data
,
null
,
$user_id
,
$visit_data
[
$seminar_id
]);
$n_data
=
[];
$n_data
=
[];
foreach
(
$this
->
registered_notification_modules
as
$id
=>
$m_data
)
{
foreach
(
$this
->
registered_notification_modules
as
$id
=>
$m_data
)
{
if
(
in_array
(
$id
,
$s_data
->
notification
->
notification_data
)
if
(
in_array
(
$id
,
$s_data
[
'
notification
'
]
)
&&
isset
(
$navigation
[
$id
])
&&
isset
(
$navigation
[
$id
])
&&
$navigation
[
$id
]
->
getImage
()
&&
$navigation
[
$id
]
->
getImage
()
&&
$navigation
[
$id
]
->
getImage
()
->
getRole
()
===
Icon
::
ROLE_ATTENTION
&&
$navigation
[
$id
]
->
getImage
()
->
getRole
()
===
Icon
::
ROLE_ATTENTION
)
{
)
{
$data
=
$this
->
getPluginText
(
$navigation
,
$seminar_id
,
$id
);
$data
=
$this
->
getPluginText
(
$navigation
[
$id
]
,
$seminar_id
,
$id
);
if
(
$data
)
{
if
(
$data
)
{
$n_data
[]
=
$data
;
$n_data
[]
=
$data
;
}
}
...
@@ -143,9 +142,7 @@ class ModulesNotification
...
@@ -143,9 +142,7 @@ class ModulesNotification
$template_text
=
$GLOBALS
[
'template_factory'
]
->
open
(
'mail/notification_text'
);
$template_text
=
$GLOBALS
[
'template_factory'
]
->
open
(
'mail/notification_text'
);
$template_text
->
set_attribute
(
'news'
,
$news
);
$template_text
->
set_attribute
(
'news'
,
$news
);
$template_text
->
set_attribute
(
'sso'
,
$auth_plugin
);
$template_text
->
set_attribute
(
'sso'
,
$auth_plugin
);
return
[
'text'
=>
$template_text
->
render
(),
'html'
=>
$template
->
render
()];;
return
[
'text'
=>
$template_text
->
render
(),
'html'
=>
$template
->
render
()];
}
else
{
return
FALSE
;
}
}
}
}
...
@@ -158,132 +155,10 @@ class ModulesNotification
...
@@ -158,132 +155,10 @@ class ModulesNotification
$icon
=
$nav
->
getImage
();
$icon
=
$nav
->
getImage
();
$text
=
$nav
->
getTitle
();
$text
=
$nav
->
getTitle
();
if
(
!
$text
)
{
if
(
!
$text
)
{
$text
=
$this
->
registered_modules
[
$id
][
'name'
];
$text
=
$this
->
registered_
notification_
modules
[
$id
][
'name'
];
}
}
$text
.
=
' - '
.
$
icon
->
getAttributes
()[
'title'
];
$text
.
=
' - '
.
$
nav
->
get
Link
Attributes
()[
'title'
];
return
compact
(
'text'
,
'url'
,
'icon'
,
'seminar_id'
);
return
compact
(
'text'
,
'url'
,
'icon'
,
'seminar_id'
);
}
}
}
}
// only range = 'sem' is implemented
function
getModuleText
(
$m_name
,
$range_id
,
$r_data
,
$range
)
{
global
$SEM_CLASS
,
$SEM_TYPE
;
$text
=
''
;
$sem_class
=
$SEM_CLASS
[
$SEM_TYPE
[
$r_data
[
'sem_status'
]][
"class"
]];
$slot_mapper
=
[
'files'
=>
"documents"
,
'elearning'
=>
"elearning_interface"
];
if
(
$sem_class
)
{
$slot
=
isset
(
$slot_mapper
[
$m_name
])
?
$slot_mapper
[
$m_name
]
:
$m_name
;
$module
=
$sem_class
->
getModule
(
$slot
);
if
(
is_a
(
$module
,
"StandardPlugin"
))
{
return
$this
->
getPluginText
(
$module
,
$range_id
,
$r_data
,
$m_name
);
}
}
switch
(
$m_name
)
{
case
'participants'
:
if
(
in_array
(
$r_data
[
'status'
],
words
(
'dozent tutor'
)))
{
if
(
$r_data
[
'new_accepted_participants'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue vorläufige Teilnehmende, "
),
$r_data
[
'newparticipants'
]);
}
else
if
(
$r_data
[
'new_accepted_participants'
]
>
0
)
{
$text
=
_
(
"1 neue Person, "
);
}
if
(
$r_data
[
'newparticipants'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Personen:"
),
$r_data
[
'newparticipants'
]);
}
else
if
(
$r_data
[
'newparticipants'
]
>
0
)
{
$text
=
_
(
"1 neue Person:"
);
}
if
(
$sem_class
[
'studygroup_mode'
])
{
$redirect
=
'&redirect_to=dispatch.php/course/studygroup/members/'
;
}
else
{
$redirect
=
'&redirect_to=dispatch.php/course/members/index'
;
}
$icon
=
Icon
::
create
(
"persons"
,
"clickable"
);
}
break
;
case
'documents'
:
if
(
$r_data
[
'neuedokumente'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Dokumente hochgeladen:"
),
$r_data
[
'neuedokumente'
]);
}
else
if
(
$r_data
[
'neuedokumente'
]
>
0
)
{
$text
=
_
(
"1 neues Dokument hochgeladen:"
);
}
$redirect
=
'&redirect_to=dispatch.php/course/files/flat'
;
$icon
=
Icon
::
create
(
"files"
,
"clickable"
);
break
;
case
'schedule'
:
if
(
$r_data
[
'neuetermine'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Termine angelegt:"
),
$r_data
[
'neuetermine'
]);
}
else
if
(
$r_data
[
'neuetermine'
]
>
0
)
{
$text
=
_
(
"1 neuer Termin angelegt:"
);
}
$redirect
=
'&redirect_to=dispatch.php/course/dates#a'
;
$icon
=
Icon
::
create
(
"date"
,
"clickable"
);
break
;
case
'elearning_interface'
:
if
(
Config
::
get
()
->
ELEARNING_INTERFACE_ENABLE
)
{
if
(
$r_data
[
'neuecontentmodule'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Content-Module angelegt"
),
$r_data
[
'neuecontentmodule'
]);
}
else
if
(
$r_data
[
'neuecontentmodule'
]
>
0
)
{
$text
=
_
(
"1 neues Content-Modul angelegt"
);
}
$redirect
=
"&redirect_to=dispatch.php/course/elearning/show"
;
$icon
=
Icon
::
create
(
"learnmodule"
,
"clickable"
);
}
break
;
case
'wiki'
:
if
(
$r_data
[
'neuewikiseiten'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s Wikiseiten wurden angelegt oder bearbeitet:"
),
$r_data
[
'neuewikiseiten'
]);
}
else
if
(
$r_data
[
'neuewikiseiten'
]
>
0
)
{
$text
=
_
(
"1 Wikiseite wurde angelegt oder bearbeitet:"
);
}
$redirect
=
'&redirect_to=wiki.php&view=listnew'
;
$icon
=
Icon
::
create
(
"wiki"
,
"clickable"
);
break
;
case
'scm'
:
if
(
$r_data
[
'neuscmcontent'
])
{
$text
=
sprintf
(
_
(
"Die Seite
\"
%s
\"
wurde neu angelegt oder bearbeitet:"
),
$r_data
[
'scmtabname'
]);
}
$redirect
=
'&redirect_to=dispatch.php/course/scm'
;
$icon
=
Icon
::
create
(
"infopage"
,
"clickable"
);
break
;
case
'votes'
:
if
(
Config
::
get
()
->
VOTE_ENABLE
)
{
if
(
$r_data
[
'neuevotes'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Umfragen oder Evaluationen wurden angelegt:"
),
$r_data
[
'neuevotes'
]);
}
else
if
(
$r_data
[
'neuevotes'
]
>
0
)
{
$text
=
_
(
"1 neue Umfrage oder Evaluation wurde angelegt:"
);
}
}
$redirect
=
'#votes'
;
$icon
=
Icon
::
create
(
"vote"
,
"clickable"
);
break
;
case
'news'
:
if
(
$r_data
[
'neuenews'
]
>
1
)
{
$text
=
sprintf
(
_
(
"%s neue Ankündigungen wurden angelegt:"
),
$r_data
[
'neuenews'
]);
}
else
if
(
$r_data
[
'neuenews'
])
{
$text
=
_
(
"Eine neue Ankündigung wurde angelegt:"
);
}
$redirect
=
''
;
$icon
=
Icon
::
create
(
"news"
,
"clickable"
);
break
;
case
'basic_data'
:
if
(
$r_data
[
'chdate'
]
>
$r_data
[
'visitdate'
])
{
$text
=
_
(
"Die Grunddaten wurden geändert:"
);
}
$redirect
=
'&redirect_to=dispatch.php/course/details/'
;
$icon
=
Icon
::
create
(
"home"
,
"clickable"
);
break
;
default
:
$redirect
=
''
;
}
if
(
$range
==
'sem'
&&
$text
!=
''
)
{
$url
=
'seminar_main.php?again=yes&auswahl='
.
$range_id
.
$redirect
;
return
compact
(
'text'
,
'url'
,
'icon'
,
'range_id'
);
}
return
$text
;
}
}
}
This diff is collapsed.
Click to expand it.
lib/models/CourseMember.class.php
+
7
−
0
View file @
9dd46ca4
...
@@ -75,6 +75,8 @@ class CourseMember extends SimpleORMap implements PrivacyObject
...
@@ -75,6 +75,8 @@ class CourseMember extends SimpleORMap implements PrivacyObject
$config
[
'additional_fields'
][
'course_name'
]
=
[];
$config
[
'additional_fields'
][
'course_name'
]
=
[];
$config
[
'registered_callbacks'
][
'after_delete'
][]
=
'cbRemoveNotifications'
;
parent
::
configure
(
$config
);
parent
::
configure
(
$config
);
}
}
...
@@ -148,6 +150,11 @@ class CourseMember extends SimpleORMap implements PrivacyObject
...
@@ -148,6 +150,11 @@ class CourseMember extends SimpleORMap implements PrivacyObject
))
->
getFullname
(
$format
);
))
->
getFullname
(
$format
);
}
}
public
function
cbRemoveNotifications
()
{
CourseMemberNotification
::
deleteBySQL
(
'user_id = ?'
,
[
$this
->
user_id
]);
}
/**
/**
* Export available data of a given user into a storage object
* Export available data of a given user into a storage object
* (an instance of the StoredUserData class) for that user.
* (an instance of the StoredUserData class) for that user.
...
...
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