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
f8dd2f09
Commit
f8dd2f09
authored
8 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-2053: apply the same lock on the certification options as for the course editor
parent
cbc677a7
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/course/certificate/ui/CertificatesOptionsController.java
+39
-10
39 additions, 10 deletions
.../course/certificate/ui/CertificatesOptionsController.java
with
39 additions
and
10 deletions
src/main/java/org/olat/course/certificate/ui/CertificatesOptionsController.java
+
39
−
10
View file @
f8dd2f09
...
@@ -61,6 +61,7 @@ import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
...
@@ -61,6 +61,7 @@ import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
import
org.olat.core.util.FileUtils
;
import
org.olat.core.util.FileUtils
;
import
org.olat.core.util.Util
;
import
org.olat.core.util.Util
;
import
org.olat.core.util.coordinate.CoordinatorManager
;
import
org.olat.core.util.coordinate.CoordinatorManager
;
import
org.olat.core.util.coordinate.LockResult
;
import
org.olat.core.util.event.EventBus
;
import
org.olat.core.util.event.EventBus
;
import
org.olat.core.util.vfs.VFSLeaf
;
import
org.olat.core.util.vfs.VFSLeaf
;
import
org.olat.core.util.vfs.VFSMediaResource
;
import
org.olat.core.util.vfs.VFSMediaResource
;
...
@@ -75,9 +76,11 @@ import org.olat.course.config.CourseConfig;
...
@@ -75,9 +76,11 @@ import org.olat.course.config.CourseConfig;
import
org.olat.course.config.CourseConfigEvent
;
import
org.olat.course.config.CourseConfigEvent
;
import
org.olat.course.config.CourseConfigEvent.CourseConfigType
;
import
org.olat.course.config.CourseConfigEvent.CourseConfigType
;
import
org.olat.course.config.ui.CourseOptionsController
;
import
org.olat.course.config.ui.CourseOptionsController
;
import
org.olat.course.run.RunMainController
;
import
org.olat.repository.RepositoryEntry
;
import
org.olat.repository.RepositoryEntry
;
import
org.olat.repository.RepositoryEntryManagedFlag
;
import
org.olat.repository.RepositoryEntryManagedFlag
;
import
org.olat.repository.RepositoryManager
;
import
org.olat.repository.RepositoryManager
;
import
org.olat.user.UserManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
/**
...
@@ -119,7 +122,10 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -119,7 +122,10 @@ public class CertificatesOptionsController extends FormBasicController {
};
};
private
final
String
mapperUrl
;
private
final
String
mapperUrl
;
private
LockResult
lockEntry
;
@Autowired
private
UserManager
userManager
;
@Autowired
@Autowired
private
CertificatesManager
certificatesManager
;
private
CertificatesManager
certificatesManager
;
...
@@ -131,13 +137,32 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -131,13 +137,32 @@ public class CertificatesOptionsController extends FormBasicController {
RepositoryEntry
entry
,
CourseConfig
courseConfig
,
boolean
editable
)
{
RepositoryEntry
entry
,
CourseConfig
courseConfig
,
boolean
editable
)
{
super
(
ureq
,
wControl
);
super
(
ureq
,
wControl
);
setTranslator
(
Util
.
createPackageTranslator
(
CourseOptionsController
.
class
,
getLocale
(),
getTranslator
()));
setTranslator
(
Util
.
createPackageTranslator
(
CourseOptionsController
.
class
,
getLocale
(),
getTranslator
()));
setTranslator
(
Util
.
createPackageTranslator
(
RunMainController
.
class
,
getLocale
(),
getTranslator
()));
this
.
courseConfig
=
courseConfig
;
this
.
courseConfig
=
courseConfig
;
this
.
entry
=
entry
;
this
.
entry
=
entry
;
this
.
editable
=
editable
;
mapperUrl
=
registerMapper
(
ureq
,
new
TemplateMapper
());
mapperUrl
=
registerMapper
(
ureq
,
new
TemplateMapper
());
lockEntry
=
CoordinatorManager
.
getInstance
().
getCoordinator
().
getLocker
()
.
acquireLock
(
entry
.
getOlatResource
(),
getIdentity
(),
CourseFactory
.
COURSE_EDITOR_LOCK
);
this
.
editable
=
(
lockEntry
!=
null
&&
lockEntry
.
isSuccess
())
&&
editable
;
initForm
(
ureq
);
initForm
(
ureq
);
if
(
lockEntry
!=
null
&&
!
lockEntry
.
isSuccess
())
{
String
lockerName
=
"???"
;
if
(
lockEntry
.
getOwner
()
!=
null
)
{
lockerName
=
userManager
.
getUserDisplayName
(
lockEntry
.
getOwner
());
}
showWarning
(
"error.editoralreadylocked"
,
new
String
[]
{
lockerName
});
}
}
@Override
protected
void
doDispose
()
{
if
(
lockEntry
!=
null
&&
lockEntry
.
isSuccess
())
{
CoordinatorManager
.
getInstance
().
getCoordinator
().
getLocker
().
releaseLock
(
lockEntry
);
lockEntry
=
null
;
}
}
}
@Override
@Override
...
@@ -174,6 +199,7 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -174,6 +199,7 @@ public class CertificatesOptionsController extends FormBasicController {
templateCont
.
setLabel
(
"pdf.certificates.template"
,
null
);
templateCont
.
setLabel
(
"pdf.certificates.template"
,
null
);
selectTemplateLink
=
uifactory
.
addFormLink
(
"select"
,
templateCont
,
Link
.
BUTTON
);
selectTemplateLink
=
uifactory
.
addFormLink
(
"select"
,
templateCont
,
Link
.
BUTTON
);
selectTemplateLink
.
setEnabled
(
editable
);
Long
templateId
=
courseConfig
.
getCertificateTemplate
();
Long
templateId
=
courseConfig
.
getCertificateTemplate
();
boolean
hasTemplate
=
templateId
!=
null
&&
templateId
.
longValue
()
>
0
;
boolean
hasTemplate
=
templateId
!=
null
&&
templateId
.
longValue
()
>
0
;
if
(
hasTemplate
)
{
if
(
hasTemplate
)
{
...
@@ -193,6 +219,7 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -193,6 +219,7 @@ public class CertificatesOptionsController extends FormBasicController {
boolean
reCertificationEnabled
=
courseConfig
.
isRecertificationEnabled
();
boolean
reCertificationEnabled
=
courseConfig
.
isRecertificationEnabled
();
reCertificationEl
=
uifactory
.
addCheckboxesHorizontal
(
"recertification"
,
formLayout
,
new
String
[]{
"xx"
},
new
String
[]{
""
});
reCertificationEl
=
uifactory
.
addCheckboxesHorizontal
(
"recertification"
,
formLayout
,
new
String
[]{
"xx"
},
new
String
[]{
""
});
reCertificationEl
.
addActionListener
(
FormEvent
.
ONCHANGE
);
reCertificationEl
.
addActionListener
(
FormEvent
.
ONCHANGE
);
reCertificationEl
.
setEnabled
(
editable
);
if
(
reCertificationEnabled
)
{
if
(
reCertificationEnabled
)
{
reCertificationEl
.
select
(
"xx"
,
true
);
reCertificationEl
.
select
(
"xx"
,
true
);
}
}
...
@@ -206,6 +233,7 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -206,6 +233,7 @@ public class CertificatesOptionsController extends FormBasicController {
reCertificationTimelapseEl
=
uifactory
.
addIntegerElement
(
"timelapse"
,
null
,
timelapse
,
recertificationCont
);
reCertificationTimelapseEl
=
uifactory
.
addIntegerElement
(
"timelapse"
,
null
,
timelapse
,
recertificationCont
);
reCertificationTimelapseEl
.
setDomReplacementWrapperRequired
(
false
);
reCertificationTimelapseEl
.
setDomReplacementWrapperRequired
(
false
);
reCertificationTimelapseEl
.
setDisplaySize
(
4
);
reCertificationTimelapseEl
.
setDisplaySize
(
4
);
reCertificationTimelapseEl
.
setEnabled
(
editable
);
String
[]
timelapseUnitValues
=
new
String
[]
{
String
[]
timelapseUnitValues
=
new
String
[]
{
translate
(
"recertification.day"
),
translate
(
"recertification.week"
),
translate
(
"recertification.day"
),
translate
(
"recertification.week"
),
...
@@ -214,6 +242,7 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -214,6 +242,7 @@ public class CertificatesOptionsController extends FormBasicController {
RecertificationTimeUnit
timelapseUnit
=
courseConfig
.
getRecertificationTimelapseUnit
();
RecertificationTimeUnit
timelapseUnit
=
courseConfig
.
getRecertificationTimelapseUnit
();
reCertificationTimelapseUnitEl
=
uifactory
.
addDropdownSingleselect
(
"timelapse.unit"
,
null
,
recertificationCont
,
timelapseUnitKeys
,
timelapseUnitValues
,
null
);
reCertificationTimelapseUnitEl
=
uifactory
.
addDropdownSingleselect
(
"timelapse.unit"
,
null
,
recertificationCont
,
timelapseUnitKeys
,
timelapseUnitValues
,
null
);
reCertificationTimelapseUnitEl
.
setDomReplacementWrapperRequired
(
false
);
reCertificationTimelapseUnitEl
.
setDomReplacementWrapperRequired
(
false
);
reCertificationTimelapseUnitEl
.
setEnabled
(
editable
);
if
(
timelapseUnit
!=
null
)
{
if
(
timelapseUnit
!=
null
)
{
reCertificationTimelapseUnitEl
.
select
(
timelapseUnit
.
name
(),
true
);
reCertificationTimelapseUnitEl
.
select
(
timelapseUnit
.
name
(),
true
);
}
else
{
}
else
{
...
@@ -234,7 +263,7 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -234,7 +263,7 @@ public class CertificatesOptionsController extends FormBasicController {
boolean
none
=
!
pdfCertificatesEl
.
isAtLeastSelected
(
1
);
boolean
none
=
!
pdfCertificatesEl
.
isAtLeastSelected
(
1
);
templateCont
.
setVisible
(!
none
);
templateCont
.
setVisible
(!
none
);
selectTemplateLink
.
setEnabled
(!
none
);
selectTemplateLink
.
setEnabled
(!
none
&&
editable
);
if
(
none
||
selectedTemplate
==
null
)
{
if
(
none
||
selectedTemplate
==
null
)
{
templateCont
.
contextPut
(
"templateName"
,
translate
(
"default.template"
));
templateCont
.
contextPut
(
"templateName"
,
translate
(
"default.template"
));
previewTemplateLink
.
setEnabled
(
false
);
previewTemplateLink
.
setEnabled
(
false
);
...
@@ -247,13 +276,8 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -247,13 +276,8 @@ public class CertificatesOptionsController extends FormBasicController {
boolean
enableRecertification
=
!
none
&&
reCertificationEl
.
isAtLeastSelected
(
1
);
boolean
enableRecertification
=
!
none
&&
reCertificationEl
.
isAtLeastSelected
(
1
);
recertificationCont
.
setVisible
(
enableRecertification
);
recertificationCont
.
setVisible
(
enableRecertification
);
reCertificationTimelapseEl
.
setEnabled
(
enableRecertification
);
reCertificationTimelapseEl
.
setEnabled
(
enableRecertification
&&
editable
);
reCertificationTimelapseUnitEl
.
setEnabled
(
enableRecertification
);
reCertificationTimelapseUnitEl
.
setEnabled
(
enableRecertification
&&
editable
);
}
@Override
protected
void
doDispose
()
{
//
}
}
@Override
@Override
...
@@ -352,6 +376,11 @@ public class CertificatesOptionsController extends FormBasicController {
...
@@ -352,6 +376,11 @@ public class CertificatesOptionsController extends FormBasicController {
private
void
doChangeConfig
(
UserRequest
ureq
)
{
private
void
doChangeConfig
(
UserRequest
ureq
)
{
OLATResourceable
courseOres
=
entry
.
getOlatResource
();
OLATResourceable
courseOres
=
entry
.
getOlatResource
();
if
(
CourseFactory
.
isCourseEditSessionOpen
(
courseOres
.
getResourceableId
()))
{
showWarning
(
"error.editoralreadylocked"
,
new
String
[]
{
"???"
});
return
;
}
ICourse
course
=
CourseFactory
.
openCourseEditSession
(
courseOres
.
getResourceableId
());
ICourse
course
=
CourseFactory
.
openCourseEditSession
(
courseOres
.
getResourceableId
());
courseConfig
=
course
.
getCourseEnvironment
().
getCourseConfig
();
courseConfig
=
course
.
getCourseEnvironment
().
getCourseConfig
();
...
...
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