use of net.jforum.context.RequestContext in project jforum2 by rafaelsteil.
the class ViewCommon method contextToLogin.
/**
* Prepares the template context to show the login page, using the current URI as return path.
* @return TemplateKeys.USER_LOGIN
*/
public static String contextToLogin() {
RequestContext request = JForumExecutionContext.getRequest();
String uri = request.getRequestURI();
String query = request.getQueryString();
String returnPath = query == null ? uri : uri + "?" + query;
return contextToLogin(returnPath);
}
use of net.jforum.context.RequestContext in project jforum2 by rafaelsteil.
the class ModerationHelper method moveTopicsSave.
public int moveTopicsSave(String successUrl) {
int status = SUCCESS;
if (!SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_TOPIC_MOVE)) {
status = FAILURE;
} else {
RequestContext request = JForumExecutionContext.getRequest();
String topics = request.getParameter("topics");
if (topics != null) {
int fromForumId = Integer.parseInt(request.getParameter("forum_id"));
int toForumId = Integer.parseInt(request.getParameter("to_forum"));
String[] topicList = topics.split(",");
DataAccessDriver.getInstance().newForumDAO().moveTopics(topicList, fromForumId, toForumId);
ModerationLog log = this.buildModerationLogFromRequest();
for (int i = 0; i < topicList.length; i++) {
int topicId = Integer.parseInt(topicList[i]);
log.setTopicId(topicId);
this.saveModerationLog(log);
}
ForumRepository.reloadForum(fromForumId);
ForumRepository.reloadForum(toForumId);
TopicRepository.clearCache(fromForumId);
TopicRepository.clearCache(toForumId);
TopicRepository.loadMostRecentTopics();
TopicRepository.loadHottestTopics();
}
}
if (status == FAILURE) {
this.denied();
} else {
this.moderationDone(successUrl);
}
return status;
}
use of net.jforum.context.RequestContext in project jforum2 by rafaelsteil.
the class ModerationHelper method doModeration.
public int doModeration(String returnUrl) {
int status = FAILURE;
if (SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION)) {
// Deleting topics
RequestContext request = JForumExecutionContext.getRequest();
if (request.getParameter("topicRemove") != null) {
if (SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_POST_REMOVE)) {
this.removeTopics();
status = SUCCESS;
}
} else if (request.getParameter("topicMove") != null) {
if (SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_TOPIC_MOVE)) {
this.moveTopics();
status = IGNORE;
}
} else if (request.getParameter("topicLock") != null) {
if (SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_TOPIC_LOCK_UNLOCK)) {
this.lockUnlockTopics(Topic.STATUS_LOCKED);
status = SUCCESS;
}
} else if (request.getParameter("topicUnlock") != null) {
if (SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_TOPIC_LOCK_UNLOCK)) {
this.lockUnlockTopics(Topic.STATUS_UNLOCKED);
status = SUCCESS;
}
}
}
if (status == ModerationHelper.FAILURE) {
this.denied();
} else if (status == ModerationHelper.SUCCESS && returnUrl != null) {
JForumExecutionContext.setRedirect(returnUrl);
}
return status;
}
use of net.jforum.context.RequestContext in project jforum2 by rafaelsteil.
the class OnlineUsersTest method setUp.
protected void setUp() throws Exception {
new SessionFacade().setCacheEngine(new DefaultCacheEngine());
RequestContext requestContext = new WebRequestContext(new FakeHttpRequest());
ResponseContext responseContext = new WebResponseContext(new FakeHttpResponse());
ForumContext forumContext = new JForumContext(requestContext.getContextPath(), SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION), requestContext, responseContext, false);
JForumExecutionContext ex = JForumExecutionContext.get();
ex.setForumContext(forumContext);
JForumExecutionContext.set(ex);
SystemGlobals.setValue(ConfigKeys.ANONYMOUS_USER_ID, Integer.toString(ANONYMOUS));
}
use of net.jforum.context.RequestContext in project jforum2 by rafaelsteil.
the class PollCommon method fillPollFromRequest.
public static Poll fillPollFromRequest() {
RequestContext request = JForumExecutionContext.getRequest();
String label = request.getParameter("poll_label");
if (label == null || label.length() == 0) {
return null;
}
Poll poll = new Poll();
poll.setStartTime(new Date());
poll.setLabel(label);
int count = request.getIntParameter("poll_option_count");
for (int i = 0; i <= count; i++) {
String option = request.getParameter("poll_option_" + i);
if (option == null) {
continue;
}
option = option.trim();
if (option.length() > 0) {
PollOption po = new PollOption();
po.setId(i);
po.setText(option);
poll.addOption(po);
}
}
String pollLength = request.getParameter("poll_length");
if (pollLength != null && pollLength.length() > 0) {
poll.setLength(Integer.parseInt(pollLength));
}
return poll;
}
Aggregations