Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
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
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
e9bef9a5
Commit
e9bef9a5
authored
12 years ago
by
srosse
Browse files
Options
Downloads
Plain Diff
Merge OpenOLAT 8.2 to OpenOLAT default branch with 32fe77a7a2a0f84f567f81de7c481cc8ef9d0af8
parents
74659a68
c1f7a306
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/notifications/NotificationNewsController.java
+48
-30
48 additions, 30 deletions
...va/org/olat/notifications/NotificationNewsController.java
with
48 additions
and
30 deletions
src/main/java/org/olat/notifications/NotificationNewsController.java
+
48
−
30
View file @
e9bef9a5
...
...
@@ -23,6 +23,7 @@ import java.text.DateFormat;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -59,7 +60,8 @@ import org.olat.core.util.notifications.SubscriptionItem;
*
* @author gnaegi
*/
class
NotificationNewsController
extends
BasicController
implements
Activateable2
{
class
NotificationNewsController
extends
BasicController
implements
Activateable2
{
private
VelocityContainer
newsVC
;
private
Date
compareDate
;
private
String
newsType
;
...
...
@@ -67,22 +69,26 @@ class NotificationNewsController extends BasicController implements Activateable
private
DateChooserController
dateChooserCtr
;
private
Link
emailLink
;
private
Map
<
Subscriber
,
SubscriptionInfo
>
subsInfoMap
;
/**
* Constructor
*
* @param subscriberIdentity The identity which news are displayed
* @param subscriberIdentity
* The identity which news are displayed
* @param ureq
* @param wControl
* @param newsSinceDate The lower date boundary to collect the news or NULL to
* use the user defined notification interval
* @param newsSinceDate
* The lower date boundary to collect the news or NULL to use the
* user defined notification interval
*/
NotificationNewsController
(
Identity
subscriberIdentity
,
UserRequest
ureq
,
WindowControl
wControl
,
Date
newsSinceDate
)
{
NotificationNewsController
(
Identity
subscriberIdentity
,
UserRequest
ureq
,
WindowControl
wControl
,
Date
newsSinceDate
)
{
super
(
ureq
,
wControl
);
this
.
subscriberIdentity
=
subscriberIdentity
;
if
(
newsSinceDate
==
null
)
{
NotificationsManager
man
=
NotificationsManager
.
getInstance
();
compareDate
=
man
.
getCompareDateFromInterval
(
man
.
getUserIntervalOrDefault
(
ureq
.
getIdentity
()));
compareDate
=
man
.
getCompareDateFromInterval
(
man
.
getUserIntervalOrDefault
(
ureq
.
getIdentity
()));
}
else
{
compareDate
=
newsSinceDate
;
}
...
...
@@ -91,7 +97,8 @@ class NotificationNewsController extends BasicController implements Activateable
// Fetch data from DB and update datamodel and reuse subscribers
List
<
Subscriber
>
subs
=
updateNewsDataModel
();
// Add date and type chooser
dateChooserCtr
=
new
DateChooserController
(
ureq
,
getWindowControl
(),
new
Date
());
dateChooserCtr
=
new
DateChooserController
(
ureq
,
getWindowControl
(),
new
Date
());
dateChooserCtr
.
setSubscribers
(
subs
);
listenTo
(
dateChooserCtr
);
newsVC
.
put
(
"dateChosserCtr"
,
dateChooserCtr
.
getInitialComponent
());
...
...
@@ -104,18 +111,23 @@ class NotificationNewsController extends BasicController implements Activateable
/**
* Update the new data model and refresh the GUI
*/
List
<
Subscriber
>
updateNewsDataModel
()
{
protected
List
<
Subscriber
>
updateNewsDataModel
()
{
if
(
compareDate
==
null
)
{
return
Collections
.
emptyList
();
//compare date is mandatory
}
List
<
String
>
notiTypes
=
new
ArrayList
<
String
>();
if
(
StringHelper
.
containsNonWhitespace
(
newsType
))
{
if
(
StringHelper
.
containsNonWhitespace
(
newsType
))
{
notiTypes
.
add
(
newsType
);
}
NotificationsManager
man
=
NotificationsManager
.
getInstance
();
List
<
Subscriber
>
subs
=
man
.
getSubscribers
(
subscriberIdentity
,
notiTypes
);
newsVC
.
contextPut
(
"subs"
,
subs
);
subsInfoMap
=
NotificationHelper
.
getSubscriptionMap
(
getLocale
(),
true
,
compareDate
,
subs
);
NotificationSubscriptionAndNewsFormatter
subsFormatter
=
new
NotificationSubscriptionAndNewsFormatter
(
getTranslator
(),
subsInfoMap
);
subsInfoMap
=
NotificationHelper
.
getSubscriptionMap
(
getLocale
(),
true
,
compareDate
,
subs
);
NotificationSubscriptionAndNewsFormatter
subsFormatter
=
new
NotificationSubscriptionAndNewsFormatter
(
getTranslator
(),
subsInfoMap
);
newsVC
.
contextPut
(
"subsFormatter"
,
subsFormatter
);
return
subs
;
}
...
...
@@ -148,36 +160,42 @@ class NotificationNewsController extends BasicController implements Activateable
List
<
Subscriber
>
subsList
=
new
ArrayList
<
Subscriber
>();
for
(
Subscriber
subscriber
:
subsInfoMap
.
keySet
())
{
subsList
.
add
(
subscriber
);
SubscriptionItem
item
=
man
.
createSubscriptionItem
(
subscriber
,
getLocale
(),
SubscriptionInfo
.
MIME_PLAIN
,
SubscriptionInfo
.
MIME_PLAIN
,
compareDate
);
if
(
item
!=
null
)
{
SubscriptionItem
item
=
man
.
createSubscriptionItem
(
subscriber
,
getLocale
(),
SubscriptionInfo
.
MIME_PLAIN
,
SubscriptionInfo
.
MIME_PLAIN
,
compareDate
);
if
(
item
!=
null
)
{
infoList
.
add
(
item
);
}
}
if
(
man
.
sendMailToUserAndUpdateSubscriber
(
subscriberIdentity
,
infoList
,
getTranslator
(),
subsList
))
{
if
(
man
.
sendMailToUserAndUpdateSubscriber
(
subscriberIdentity
,
infoList
,
getTranslator
(),
subsList
))
{
showInfo
(
"email.ok"
);
}
else
{
showError
(
"email.nok"
);
showError
(
"email.nok"
);
}
}
}
@Override
public
void
activate
(
UserRequest
ureq
,
List
<
ContextEntry
>
entries
,
StateEntry
state
)
{
if
(
entries
==
null
||
entries
.
isEmpty
())
return
;
public
void
activate
(
UserRequest
ureq
,
List
<
ContextEntry
>
entries
,
StateEntry
state
)
{
if
(
entries
==
null
||
entries
.
isEmpty
())
return
;
boolean
changed
=
false
;
String
path
=
entries
.
get
(
0
).
getOLATResourceable
().
getResourceableTypeName
();
if
(
path
.
startsWith
(
"type="
))
{
String
path
=
entries
.
get
(
0
).
getOLATResourceable
()
.
getResourceableTypeName
();
if
(
path
.
startsWith
(
"type="
))
{
newsType
=
extractValue
(
"type="
,
path
);
dateChooserCtr
.
setType
(
newsType
);
changed
=
true
;
//consume the entry
//
consume the entry
entries
=
entries
.
subList
(
1
,
entries
.
size
());
}
if
(!
entries
.
isEmpty
())
{
String
dateEntry
=
entries
.
get
(
0
).
getOLATResourceable
().
getResourceableTypeName
();
if
(
dateEntry
.
startsWith
(
"date="
))
{
if
(!
entries
.
isEmpty
())
{
String
dateEntry
=
entries
.
get
(
0
).
getOLATResourceable
()
.
getResourceableTypeName
();
if
(
dateEntry
.
startsWith
(
"date="
))
{
try
{
String
date
=
extractValue
(
"date="
,
dateEntry
);
DateFormat
format
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
...
...
@@ -189,14 +207,14 @@ class NotificationNewsController extends BasicController implements Activateable
}
}
}
if
(
changed
)
{
if
(
changed
)
{
updateNewsDataModel
();
}
}
private
String
extractValue
(
String
str
,
String
identifier
)
{
if
(
identifier
.
startsWith
(
str
))
{
if
(
identifier
.
startsWith
(
str
))
{
int
sepIndex
=
identifier
.
indexOf
(
':'
);
int
lastIndex
=
(
sepIndex
>
0
?
sepIndex
:
identifier
.
length
());
String
value
=
identifier
.
substring
(
str
.
length
(),
lastIndex
);
...
...
@@ -210,6 +228,6 @@ class NotificationNewsController extends BasicController implements Activateable
*/
@Override
protected
void
doDispose
()
{
// child controllers disposed by basic controller
// child controllers disposed by basic controller
}
}
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