1 package net.sourceforge.blogentis.modules.actions;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import net.sourceforge.blogentis.om.Blog;
26 import net.sourceforge.blogentis.om.StoredBlog;
27 import net.sourceforge.blogentis.om.StoredBlogPeer;
28 import net.sourceforge.blogentis.turbine.BlogParameterParser;
29 import net.sourceforge.blogentis.turbine.SecureBlogAction;
30 import net.sourceforge.blogentis.utils.BlogConstants;
31 import net.sourceforge.blogentis.utils.MappedConfiguration;
32
33 import org.apache.commons.configuration.SubsetConfiguration;
34 import org.apache.turbine.util.RunData;
35 import org.apache.velocity.context.Context;
36
37 public class BlogPropMod
38 extends SecureBlogAction {
39 protected String[] getPermissions() {
40 return new String[] {BlogConstants.PERM_ADMIN_BLOG};
41 }
42
43 public void doPerform(RunData data, Context context)
44 throws Exception {
45 data.setMessage("Hmm... Unknown action requested!");
46 }
47
48 public void doTitle(RunData data, Context context)
49 throws Exception {
50 BlogParameterParser pp = (BlogParameterParser)data.getParameters();
51 StoredBlog blog = StoredBlogPeer.retrieveByPK(pp.getBlog().getBlogId());
52 blog.setTitle(pp.getString("title", blog.getTitle()));
53 blog.setDescription(pp.getString("description", blog.getDescription()));
54 blog.save();
55 }
56
57 public void doAppearance(RunData data, Context context)
58 throws Exception {
59 BlogParameterParser pp = (BlogParameterParser)data.getParameters();
60 Blog blog = pp.getBlog();
61 int state = pp.getInt("s", -1);
62 String prefix;
63 switch (state) {
64 case 1:
65 prefix = "blog";
66 break;
67 case 2:
68 prefix = "section";
69 break;
70 case 3:
71 prefix = "post";
72 break;
73 case 4:
74 prefix = "edit";
75 break;
76 default:
77 data.setMessage("Invalid object specified");
78 return;
79 }
80 MappedConfiguration master = blog.getConfiguration();
81 SubsetConfiguration conf = new SubsetConfiguration(master, prefix, ".");
82
83 conf.setProperty("enableShort", pp.getBooleanObject("enableShort",
84 new Boolean(true)));
85 conf.setProperty("enableFullText", pp
86 .getBooleanObject("enableFullText", new Boolean(false)));
87 conf.setProperty("showComments", pp
88 .getBooleanObject("showComments", new Boolean(false)));
89 conf.setProperty("enableDetails", pp
90 .getBooleanObject("enableDetails", new Boolean(true)));
91 conf.setProperty("detailEnableBlog", pp
92 .getBooleanObject("detailEnableBlog", new Boolean(true)));
93 conf.setProperty("detailEnableAuthor", pp
94 .getBooleanObject("detailEnableAuthor", new Boolean(true)));
95 conf.setProperty("detailEnableSections", pp
96 .getBooleanObject("detailEnableSections", new Boolean(true)));
97 conf.setProperty("detailEnablePerma", pp
98 .getBooleanObject("detailEnablePerma", new Boolean(true)));
99 conf.setProperty("detailEnableCommentCount",
100 pp.getBooleanObject("detailEnableCommentCount",
101 new Boolean(true)));
102 conf.setProperty("detailEnableCommentCount",
103 pp.getBooleanObject("detailEnableCommentCount",
104 new Boolean(true)));
105 conf.setProperty("feedSize", pp.getIntObject("feedSize",
106 new Integer(10)));
107 master.toString();
108 master.save();
109 }
110 }