1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.mandatory; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
import org.xwiki.sheet.SheetBinder; |
29 |
|
|
30 |
|
import com.xpn.xwiki.XWiki; |
31 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
32 |
|
import com.xpn.xwiki.objects.PropertyInterface; |
33 |
|
import com.xpn.xwiki.objects.classes.BaseClass; |
34 |
|
import com.xpn.xwiki.objects.classes.BooleanClass; |
35 |
|
import com.xpn.xwiki.objects.classes.TextAreaClass.ContentType; |
36 |
|
import com.xpn.xwiki.objects.classes.TimezoneClass; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
44 |
|
@Component |
45 |
|
@Named("XWiki.XWikiPreferences") |
46 |
|
@Singleton |
|
|
| 90.1% |
Uncovered Elements: 12 (121) |
Complexity: 9 |
Complexity Density: 0.09 |
|
47 |
|
public class XWikiPreferencesDocumentInitializer extends AbstractMandatoryDocumentInitializer |
48 |
|
{ |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
private static final String TIMEZONE_FIELD = "timezone"; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@Inject |
58 |
|
@Named("class") |
59 |
|
protected SheetBinder classSheetBinder; |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
61 |
public XWikiPreferencesDocumentInitializer()... |
65 |
|
{ |
66 |
61 |
super(XWiki.SYSTEM_SPACE, "XWikiPreferences"); |
67 |
|
} |
68 |
|
|
|
|
| 89.8% |
Uncovered Elements: 12 (118) |
Complexity: 8 |
Complexity Density: 0.08 |
|
69 |
94 |
@Override... |
70 |
|
public boolean updateDocument(XWikiDocument document) |
71 |
|
{ |
72 |
94 |
boolean needsUpdate = false; |
73 |
|
|
74 |
94 |
BaseClass bclass = document.getXClass(); |
75 |
|
|
76 |
94 |
if (!"internal".equals(bclass.getCustomMapping())) { |
77 |
0 |
needsUpdate = true; |
78 |
0 |
bclass.setCustomMapping("internal"); |
79 |
|
} |
80 |
|
|
81 |
94 |
needsUpdate |= bclass.addTextField("parent", "Parent Space", 30); |
82 |
94 |
needsUpdate |= bclass.addBooleanField("multilingual", "Multi-Lingual", "yesno"); |
83 |
94 |
needsUpdate |= bclass.addTextField("default_language", "Default Language", 5); |
84 |
94 |
needsUpdate |= bclass.addBooleanField("authenticate_edit", "Authenticated Edit", "yesno"); |
85 |
94 |
needsUpdate |= bclass.addBooleanField("authenticate_view", "Authenticated View", "yesno"); |
86 |
94 |
needsUpdate |= bclass.addBooleanField("auth_active_check", "Authentication Active Check", "yesno"); |
87 |
|
|
88 |
94 |
needsUpdate |= bclass.addTextField("skin", "Skin", 30); |
89 |
94 |
needsUpdate |= |
90 |
|
bclass.addDBListField("colorTheme", "Color theme", |
91 |
|
"select doc.fullName, doc.title from XWikiDocument as doc, BaseObject as theme " |
92 |
|
+ "where doc.fullName=theme.name and (theme.className='ColorThemes.ColorThemeClass' " |
93 |
|
+ "or theme.className='FlamingoThemesCode.ThemeClass') " |
94 |
|
+ "and doc.fullName<>'ColorThemes.ColorThemeTemplate' " |
95 |
|
+ "and doc.fullName<>'FlamingoThemesCode.ThemeTemplate'"); |
96 |
|
|
97 |
94 |
PropertyInterface baseskinProp = bclass.get("baseskin"); |
98 |
94 |
if (baseskinProp != null) { |
99 |
0 |
bclass.removeField("baseskin"); |
100 |
0 |
needsUpdate = true; |
101 |
|
} |
102 |
94 |
needsUpdate |= |
103 |
|
bclass.addDBListField("iconTheme", "Icon theme", |
104 |
|
"select doc.fullName, propName.value from XWikiDocument as doc, BaseObject as theme, " |
105 |
|
+ "StringProperty propName " |
106 |
|
+ "where doc.fullName=theme.name and theme.className='IconThemesCode.IconThemeClass' " |
107 |
|
+ "and doc.fullName<>'IconThemesCode.IconThemeTemplate' " |
108 |
|
+ "and theme.id = propName.id and propName.name = 'name'"); |
109 |
94 |
needsUpdate |= bclass.addTextField("stylesheet", "Default Stylesheet", 30); |
110 |
94 |
needsUpdate |= bclass.addTextField("stylesheets", "Alternative Stylesheet", 60); |
111 |
94 |
needsUpdate |= bclass.addBooleanField("accessibility", "Enable extra accessibility features", "yesno"); |
112 |
|
|
113 |
94 |
needsUpdate |= bclass.addStaticListField("editor", "Default Editor", "---|Text|Wysiwyg"); |
114 |
|
|
115 |
94 |
needsUpdate |= bclass.addTextField("webcopyright", "Copyright", 30); |
116 |
94 |
needsUpdate |= bclass.addTextField("title", "Title", 30); |
117 |
94 |
needsUpdate |= bclass.addTextField("version", "Version", 30); |
118 |
94 |
needsUpdate |= bclass.addTextAreaField("meta", "HTTP Meta Info", 60, 8, ContentType.PURE_TEXT); |
119 |
94 |
needsUpdate |= bclass.addTextField("dateformat", "Date Format", 30); |
120 |
|
|
121 |
|
|
122 |
94 |
needsUpdate |= bclass.addBooleanField("use_email_verification", "Use eMail Verification", "yesno"); |
123 |
94 |
needsUpdate |= bclass.addTextField("admin_email", "Admin eMail", 30); |
124 |
94 |
needsUpdate |= bclass.addTextField("smtp_server", "SMTP Server", 30); |
125 |
94 |
needsUpdate |= bclass.addTextField("smtp_port", "SMTP Port", 5); |
126 |
94 |
needsUpdate |= bclass.addTextField("smtp_server_username", "Server username (optional)", 30); |
127 |
94 |
needsUpdate |= bclass.addTextField("smtp_server_password", "Server password (optional)", 30); |
128 |
94 |
needsUpdate |= bclass.addTextAreaField("javamail_extra_props", "Additional JavaMail properties", 60, 6, |
129 |
|
ContentType.PURE_TEXT); |
130 |
94 |
needsUpdate |= bclass.addTextAreaField("validation_email_content", "Validation eMail Content", 72, 10, |
131 |
|
ContentType.PURE_TEXT); |
132 |
94 |
needsUpdate |= bclass.addTextAreaField("confirmation_email_content", "Confirmation eMail Content", 72, 10, |
133 |
|
ContentType.PURE_TEXT); |
134 |
94 |
needsUpdate |= bclass.addTextAreaField("invitation_email_content", "Invitation eMail Content", 72, 10, |
135 |
|
ContentType.PURE_TEXT); |
136 |
94 |
needsUpdate |= bclass.addBooleanField("obfuscateEmailAddresses", "Obfuscate Email Addresses", "yesno"); |
137 |
|
|
138 |
94 |
needsUpdate |= bclass.addStaticListField("registration_anonymous", "Anonymous", "---|Image|Text"); |
139 |
94 |
needsUpdate |= bclass.addStaticListField("registration_registered", "Registered", "---|Image|Text"); |
140 |
94 |
needsUpdate |= bclass.addStaticListField("edit_anonymous", "Anonymous", "---|Image|Text"); |
141 |
94 |
needsUpdate |= bclass.addStaticListField("edit_registered", "Registered", "---|Image|Text"); |
142 |
94 |
needsUpdate |= bclass.addStaticListField("comment_anonymous", "Anonymous", "---|Image|Text"); |
143 |
94 |
needsUpdate |= bclass.addStaticListField("comment_registered", "Registered", "---|Image|Text"); |
144 |
|
|
145 |
94 |
needsUpdate |= bclass.addNumberField("upload_maxsize", "Maximum Upload Size", 5, "long"); |
146 |
|
|
147 |
|
|
148 |
94 |
needsUpdate |= |
149 |
|
bclass.addBooleanField("guest_comment_requires_captcha", |
150 |
|
"Enable CAPTCHA in Comments for Unregistered Users", "select"); |
151 |
|
|
152 |
|
|
153 |
94 |
needsUpdate |= bclass.addTextField("core.defaultDocumentSyntax", "Default document syntax", 60); |
154 |
94 |
needsUpdate |= bclass.addBooleanField("xwiki.title.mandatory", "Make document title field mandatory", "yesno"); |
155 |
|
|
156 |
|
|
157 |
94 |
needsUpdate |= bclass.addBooleanField("tags", "Activate the tagging", "yesno"); |
158 |
|
|
159 |
|
|
160 |
94 |
needsUpdate |= bclass.addBooleanField("backlinks", "Activate the backlinks", "yesno"); |
161 |
|
|
162 |
|
|
163 |
94 |
needsUpdate |= bclass.addTextField("leftPanels", "Panels displayed on the left", 60); |
164 |
94 |
needsUpdate |= bclass.addTextField("rightPanels", "Panels displayed on the right", 60); |
165 |
94 |
needsUpdate |= bclass.addBooleanField("showLeftPanels", "Display the left panel column", "yesno"); |
166 |
94 |
needsUpdate |= bclass.addBooleanField("showRightPanels", "Display the right panel column", "yesno"); |
167 |
94 |
needsUpdate |= bclass.addStaticListField("leftPanelsWidth", "Width of the left panel column", |
168 |
|
"---|Small|Medium|Large"); |
169 |
94 |
needsUpdate |= bclass.addStaticListField("rightPanelsWidth", "Width of the right panel column", |
170 |
|
"---|Small|Medium|Large"); |
171 |
94 |
needsUpdate |= bclass.addTextField("languages", "Supported languages", 30); |
172 |
94 |
needsUpdate |= bclass.addTextField("documentBundles", "Internationalization Document Bundles", 60); |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
94 |
if (!(bclass.getField(TIMEZONE_FIELD) instanceof TimezoneClass)) { |
177 |
39 |
bclass.removeField(TIMEZONE_FIELD); |
178 |
39 |
bclass.addTimezoneField(TIMEZONE_FIELD, "Time Zone", 30); |
179 |
39 |
needsUpdate = true; |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
94 |
needsUpdate |= bclass.addBooleanField("ldap", "Ldap", "yesno"); |
185 |
94 |
needsUpdate |= bclass.addTextField("ldap_server", "Ldap server adress", 60); |
186 |
94 |
needsUpdate |= bclass.addTextField("ldap_port", "Ldap server port", 60); |
187 |
94 |
needsUpdate |= bclass.addTextField("ldap_bind_DN", "Ldap login matching", 60); |
188 |
94 |
needsUpdate |= bclass.addTextField("ldap_bind_pass", "Ldap password matching", 60); |
189 |
94 |
needsUpdate |= bclass.addBooleanField("ldap_validate_password", "Validate Ldap user/password", "yesno"); |
190 |
94 |
needsUpdate |= bclass.addTextField("ldap_user_group", "Ldap group filter", 60); |
191 |
94 |
needsUpdate |= bclass.addTextField("ldap_exclude_group", "Ldap group to exclude", 60); |
192 |
94 |
needsUpdate |= bclass.addTextField("ldap_base_DN", "Ldap base DN", 60); |
193 |
94 |
needsUpdate |= bclass.addTextField("ldap_UID_attr", "Ldap UID attribute name", 60); |
194 |
94 |
needsUpdate |= bclass.addTextField("ldap_fields_mapping", "Ldap user fiels mapping", 60); |
195 |
94 |
needsUpdate |= bclass.addBooleanField("ldap_update_user", "Update user from LDAP", "yesno"); |
196 |
94 |
needsUpdate |= bclass.addBooleanField("ldap_update_photo", "Update user photo from LDAP", "yesno"); |
197 |
94 |
needsUpdate |= bclass.addTextField("ldap_photo_attachment_name", "Attachment name to save LDAP photo", 30); |
198 |
94 |
needsUpdate |= bclass.addTextField("ldap_photo_attribute", "Ldap photo attribute name", 60); |
199 |
94 |
needsUpdate |= |
200 |
|
bclass.addTextAreaField("ldap_group_mapping", "Ldap groups mapping", 60, 5, ContentType.PURE_TEXT); |
201 |
94 |
needsUpdate |= bclass.addTextField("ldap_groupcache_expiration", "LDAP groups members cache", 60); |
202 |
94 |
needsUpdate |= bclass.addStaticListField("ldap_mode_group_sync", "LDAP groups sync mode", "|always|create"); |
203 |
94 |
needsUpdate |= bclass.addBooleanField("ldap_trylocal", "Try local login", "yesno"); |
204 |
|
|
205 |
94 |
if (((BooleanClass) bclass.get("showLeftPanels")).getDisplayType().equals("checkbox")) { |
206 |
0 |
((BooleanClass) bclass.get("showLeftPanels")).setDisplayType("yesno"); |
207 |
0 |
((BooleanClass) bclass.get("showRightPanels")).setDisplayType("yesno"); |
208 |
0 |
needsUpdate = true; |
209 |
|
} |
210 |
|
|
211 |
94 |
needsUpdate |= bclass.addBooleanField("showannotations", "Show document annotations", "yesno"); |
212 |
94 |
needsUpdate |= bclass.addBooleanField("showcomments", "Show document comments", "yesno"); |
213 |
94 |
needsUpdate |= bclass.addBooleanField("showattachments", "Show document attachments", "yesno"); |
214 |
94 |
needsUpdate |= bclass.addBooleanField("showhistory", "Show document history", "yesno"); |
215 |
94 |
needsUpdate |= bclass.addBooleanField("showinformation", "Show document information", "yesno"); |
216 |
94 |
needsUpdate |= bclass.addBooleanField("editcomment", "Enable version summary", "yesno"); |
217 |
94 |
needsUpdate |= bclass.addBooleanField("editcomment_mandatory", "Make version summary mandatory", "yesno"); |
218 |
94 |
needsUpdate |= bclass.addBooleanField("minoredit", "Enable minor edits", "yesno"); |
219 |
|
|
220 |
94 |
boolean withoutDocumentSheets = this.documentSheetBinder.getSheets(document).isEmpty(); |
221 |
94 |
if (withoutDocumentSheets) { |
222 |
|
|
223 |
94 |
this.documentSheetBinder.bind(document, document.getDocumentReference()); |
224 |
|
} |
225 |
94 |
needsUpdate |= setClassDocumentFields(document, "XWiki Preferences"); |
226 |
94 |
if (withoutDocumentSheets) { |
227 |
|
|
228 |
94 |
this.documentSheetBinder.unbind(document, document.getDocumentReference()); |
229 |
|
} |
230 |
|
|
231 |
|
|
232 |
94 |
if (this.classSheetBinder.getSheets(document).isEmpty()) { |
233 |
39 |
String wikiName = document.getDocumentReference().getWikiReference().getName(); |
234 |
39 |
DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, "AdminSheet"); |
235 |
39 |
needsUpdate |= this.classSheetBinder.bind(document, sheet); |
236 |
|
} |
237 |
|
|
238 |
94 |
return needsUpdate; |
239 |
|
} |
240 |
|
} |