use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.
the class ModeratorAction method lockTopic.
/**
* UI Action for locking selected topic(s).
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String lockTopic() {
if (isAnyCheckboxSelected()) {
try {
for (int topicId : checkboxes.keySet()) {
boolean value = checkboxes.get(topicId);
try {
if (value) {
Topic topic = forumsModule.findTopicById(topicId);
updateStatus(topic, TOPIC_LOCKED);
}
} catch (Exception e) {
setWarnBundleMessage("ERR_INTERNAL");
return "";
}
}
setInfoBundleMessage("SUCC_TOPIC_LOCKED");
} catch (Exception e) {
handleException(e);
}
return "";
} else {
setWarnBundleMessage("None_selected");
return "";
}
}
use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.
the class ModeratorAction method unlockTopic.
/**
* UI Action for unlocking selected topic(s).
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String unlockTopic() {
if (isAnyCheckboxSelected()) {
try {
for (int topicId : checkboxes.keySet()) {
boolean value = checkboxes.get(topicId);
try {
if (value) {
Topic topic = forumsModule.findTopicById(topicId);
updateStatus(topic, TOPIC_UNLOCKED);
}
} catch (Exception e) {
setWarnBundleMessage("ERR_INTERNAL");
return "";
}
}
setInfoBundleMessage("SUCC_TOPIC_UNLOCKED");
} catch (Exception e) {
handleException(e);
}
return "";
} else {
setWarnBundleMessage("None_selected");
return "";
}
}
use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.
the class PostAction method setupPoll.
/**
* sets the poll information of a post for the ui from the business object
*
* @param poll
* the poll to configure
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
protected void setupPoll(Poll poll) {
if (poll != null) {
question = poll.getTitle();
activeDuration = poll.getLength();
List<PollOption> pollOptions = poll.getOptions();
if (pollOptions != null && pollOptions.size() > 0) {
options = new TreeMap<String, String>();
int counter = 1;
for (PollOption cour : pollOptions) {
options.put(Integer.toString(counter), cour.getQuestion());
counter++;
}
}
}
}
use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.
the class ReplyTopic method startQuote.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String startQuote() {
String navState = start();
try {
String p = getParameter(p_postId);
if (p != null && p.trim().length() > 0) {
postId = parseInt(p);
}
// setup the quote information
Post post = forumsModule.findPostById(postId);
Poster poster = getPoster(forumsModule, userModule);
String userName = userModule.findUserById(poster.getUserId()).getUserName();
message = userName + "<" + QUOTE + ">" + post.getMessage().getText() + "</" + QUOTE + "></br>";
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.auth.SecureActionForum in project rubia-forums by flashboss.
the class SplitTopic method splitPosts.
/**
* This user interface action is spliting topic bh=y moving all selected by
* user posts into newly created topic.
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String splitPosts() {
// Checking whether topic has only one post, so it can't be splitted
if (posts.size() == 1) {
setWarnBundleMessage("ERR_SPLIT_ONE_POST_TOPIC");
return "";
}
// Removing all not slected posts
Iterator<Integer> selectIt = checkboxes.keySet().iterator();
while (selectIt.hasNext()) {
Boolean postFlag = checkboxes.get(selectIt.next());
if (!postFlag.booleanValue()) {
selectIt.remove();
}
}
// Checking if user selected anything.
if (checkboxes.size() == 0) {
setWarnBundleMessage("ERR_NO_POST_SELECTED");
return "";
}
// Checking if user didn't select all posts.
if (checkboxes.size() == posts.size()) {
setWarnBundleMessage("ERR_SPLIT_ALL");
return "";
}
// Trying to get destination forum for new topic.
String toForumId = getParameter(p_forum_to_id);
if (toForumId == null || toForumId.trim().compareToIgnoreCase("-1") == 0 || toForumId.trim().length() == 0) {
setWarnBundleMessage("ERR_DEST_FORUM");
return "";
}
// Checking if user gave subject for new topic.
if (newTopicTitle == null || newTopicTitle.trim().compareToIgnoreCase("-1") == 0 || newTopicTitle.trim().length() == 0) {
setWarnBundleMessage("ERR_NO_SUBJECT_GIVEN");
return "";
}
try {
Forum destForum = forumsModule.findForumById(new Integer(toForumId));
// Creating new topic in selected destination forum.
Topic newTopic = forumsModule.createTopic(destForum, getUser(userModule).getId().toString(), newTopicTitle, topic.getType());
// Moving all selected posts to new topic.
selectIt = checkboxes.keySet().iterator();
Post movedPost = null;
List<Post> postsToRemove = new ArrayList<Post>();
while (selectIt.hasNext()) {
movedPost = forumsModule.findPostById(selectIt.next());
movedPost.setTopic(newTopic);
forumsModule.update(movedPost);
postsToRemove.add(movedPost);
}
Forum fromForum = topic.getForum();
topic.setReplies(topic.getReplies() - checkboxes.size());
fromForum.setPostCount(fromForum.getPostCount() - checkboxes.size());
posts.removeAll(postsToRemove);
topic.setLastPostDate(posts.get(posts.size() - 1).getCreateDate());
newTopic.setReplies(checkboxes.size() - 1);
List<Post> postsNewTopic = forumsModule.findPostsByTopicId(newTopic);
newTopic.setLastPostDate(postsNewTopic.get(postsNewTopic.size() - 1).getCreateDate());
destForum.addTopicSize();
destForum.setPostCount(destForum.getPostCount() + newTopic.getReplies() + 1);
forumsModule.update(topic);
forumsModule.update(newTopic);
forumsModule.update(fromForum);
forumsModule.update(destForum);
} catch (Exception e) {
log.error(e);
setWarnBundleMessage("ERR_INTERNAL");
return "";
}
// Setting message that everything went smooth.
setInfoBundleMessage("SUCC_TOPIC_SPLITTED");
return "";
}
Aggregations