postingFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDoneTemplate");
postingFormDupeTemplate = MirConfig.getProp("ServletModule.OpenIndy.PostingDupeTemplate");
directOp = MirConfig.getProp("DirectOpenposting").toLowerCase();
- passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
+ passwdProtection = MirConfig.getProp("PasswdProtection").toLowerCase();
mainModule = new ModuleComment(DatabaseComment.getInstance());
contentModule = new ModuleContent(DatabaseContent.getInstance());
themenModule = new ModuleTopics(DatabaseTopics.getInstance());
public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
{
String aid = req.getParameter("aid"); // the article id the comment will belong to
+ String language = req.getParameter("language");
+
if (aid!=null && !aid.equals(""))
{
- SimpleHash mergeData = new SimpleHash();
+ SimpleHash mergeData = new SimpleHash();
+
+ // onetimepasswd
+ if(passwdProtection.equals("yes")){
+ String passwd = this.createOneTimePasswd();
+ System.out.println(passwd);
+ HttpSession session = req.getSession(false);
+ session.setAttribute("passwd",passwd);
+ mergeData.put("passwd", passwd);
+ }
- // onetimepasswd
- if(passwdProtection.equals("yes")){
- String passwd = this.createOneTimePasswd();
- System.out.println(passwd);
- HttpSession session = req.getSession(false);
- session.setAttribute("passwd",passwd);
- mergeData.put("passwd", passwd);
- }
+ if (language!=null) {
+ HttpSession session = req.getSession(false);
+ session.setAttribute("Locale", new Locale(language, ""));
+ session.setAttribute("passwd",language);
+ }
mergeData.put("aid", aid);
deliver(req, res, mergeData, commentFormTemplate);
*/
public void inscomment(HttpServletRequest req, HttpServletResponse res)
- throws ServletModuleException,ServletModuleUserException
+ throws ServletModuleException,ServletModuleUserException
{
String aid = req.getParameter("to_media"); // the article id the comment will belong to
if (aid!=null && !aid.equals(""))
}
withValues.put("is_published","1");
- //checking the onetimepasswd
- if(passwdProtection.equals("yes")){
- HttpSession session = req.getSession(false);
- String sessionPasswd = (String)session.getAttribute("passwd");
- if ( sessionPasswd == null){
- throw new ServletModuleUserException("Lost password");
- }
- String passwd = req.getParameter("passwd");
- if ( passwd == null || (!sessionPasswd.equals(passwd))) {
- throw new ServletModuleUserException("Missing password");
- }
- session.invalidate();
- }
+ //checking the onetimepasswd
+ if(passwdProtection.equals("yes")){
+ HttpSession session = req.getSession(false);
+ String sessionPasswd = (String)session.getAttribute("passwd");
+ if ( sessionPasswd == null){
+ throw new ServletModuleUserException("Lost password");
+ }
+ String passwd = req.getParameter("passwd");
+ if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+ throw new ServletModuleUserException("Missing password");
+ }
+ session.invalidate();
+ }
// inserting into database
String id = mainModule.add(withValues);
if(id==null){
deliver(req, res, new SimpleHash(), commentFormDupeTemplate);
}
+ else {
+ DatabaseContent.getInstance().setUnproduced("id="+aid);
+ MirGlobal.localizer().openPostings().afterCommentPosting();
- MirGlobal.localizer().openPostings().afterCommentPosting();
+ }
// redirecting to url
// should implement back to article
throws ServletModuleException {
SimpleHash mergeData = new SimpleHash();
- // onetimepasswd
- if(passwdProtection.equals("yes")){
- String passwd = this.createOneTimePasswd();
- System.out.println(passwd);
- HttpSession session = req.getSession(false);
- session.setAttribute("passwd",passwd);
- mergeData.put("passwd", passwd);
- }
+ // onetimepasswd
+ if(passwdProtection.equals("yes")){
+ String passwd = this.createOneTimePasswd();
+ System.out.println(passwd);
+ HttpSession session = req.getSession(false);
+ session.setAttribute("passwd",passwd);
+ mergeData.put("passwd", passwd);
+ }
String maxMedia = MirConfig.getProp("ServletModule.OpenIndy.MaxMediaUploadItems");
String numOfMedia = req.getParameter("medianum");
SimpleList popUpData = DatabaseLanguage.getInstance().getPopupData();
extraInfo.put("languagePopUpData", popUpData );
extraInfo.put("themenPopupData", themenModule.getTopicsAsSimpleList());
+
+// ML: Bolivia specific, will move it towards localization
+ extraInfo.put("topics", themenModule.getTopicsList());
+ String defaultCity = req.getParameter("city");
+ if(defaultCity!=null && !defaultCity.equals("")){
+ extraInfo.put("city", defaultCity);
+ }
+
} catch (Exception e) {
theLog.printError("languagePopUpData or getTopicslist failed "
+e.toString());
throw new ServletModuleException("OpenIndy -- failed getting language or topics: "+e.toString());
}
+
+
deliver(req, res, mergeData, extraInfo, postingFormTemplate);
}
{
SimpleHash mergeData = new SimpleHash();
boolean setMedia=false;
- boolean setTopic = false;
+ boolean setTopic = false;
try {
WebdbMultipartRequest mp = new WebdbMultipartRequest(req);
HashMap withValues = mp.getParameters();
- //checking the onetimepasswd
- if(passwdProtection.equals("yes")){
- HttpSession session = req.getSession(false);
- String sessionPasswd = (String)session.getAttribute("passwd");
- if ( sessionPasswd == null){
- throw new ServletModuleUserException("Lost password");
- }
- String passwd = (String)withValues.get("passwd");
- if ( passwd == null || (!sessionPasswd.equals(passwd))) {
- throw new ServletModuleUserException("Missing password");
- }
- session.invalidate();
- }
+ //checking the onetimepasswd
+ if(passwdProtection.equals("yes")){
+ HttpSession session = req.getSession(false);
+ String sessionPasswd = (String)session.getAttribute("passwd");
+ if ( sessionPasswd == null){
+ throw new ServletModuleUserException("Lost password");
+ }
+ String passwd = (String)withValues.get("passwd");
+ if ( passwd == null || (!sessionPasswd.equals(passwd))) {
+ throw new ServletModuleUserException("Missing password");
+ }
+ session.invalidate();
+ }
if ((((String)withValues.get("title")).length() == 0) ||
(((String)withValues.get("description")).length() == 0) ||
// if op direct article-type == newswire
if (directOp.equals("yes")) withValues.put("to_article_type","1");
- // owner is openposting user
withValues.put("to_publisher","1");
- if (withValues.get("creator").toString().equals(""))
- withValues.put("creator","Anonym");
+
+ // owner is openposting user
+// ML: this is not multi-language friendly and this can be done in a template
+// if (withValues.get("creator").toString().equals(""))
+// withValues.put("creator","Anonym");
// inserting content into database
String cid = contentModule.add(withValues);
String[] to_topicsArr = mp.getParameterValues("to_topic");
- if (to_topicsArr != null && to_topicsArr.length > 0) {
+ if (to_topicsArr != null && to_topicsArr.length > 0) {
try{
DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
setTopic = true;
String mediaTypeId = null;
MirMedia mediaHandler;
Database mediaStorage;
- ProducerMedia mediaProducer;
+// ProducerMedia mediaProducer;
//if we didn't find an entry matching the
//content-type int the table.
mediaHandler = MediaHelper.getHandler(mediaType);
mediaStorage = MediaHelper.getStorage(mediaType,
"mircoders.storage.Database");
- Class prodCls = Class.forName("mircoders.producer.Producer"
- +mediaType.getValue("tablename"));
- mediaProducer = (ProducerMedia)prodCls.newInstance();
+// Class prodCls = Class.forName("mircoders.producer.Producer"
+// +mediaType.getValue("tablename"));
+// mediaProducer = (ProducerMedia)prodCls.newInstance();
} catch (Exception e) {
theLog.printError("getting media handler failed: "+e.toString());
contentModule.deleteById(cid);
mediaEnt.setValueForProperty("is_published","1");
mediaEnt.update();
//produce it
- mediaProducer.handle(null, null, false, false, mediaId);
+// mediaProducer.handle(null, null, false, false, mediaId);
DatabaseContentToMedia.getInstance().addMedia(cid,mediaId);
} catch (Exception e) {
theLog.printError("setting media failed: "+e.toString());
+"Error One or more files of unrecognized type. Sorry");
}
- protected String createOneTimePasswd(){
- Random r = new Random();
- int random = r.nextInt();
- long l = System.currentTimeMillis();
- l = (l*l*l*l)/random;
- if(l<0) l = l * -1;
- String returnString = ""+l;
- return returnString.substring(5);
- }
+ protected String createOneTimePasswd(){
+ Random r = new Random();
+ int random = r.nextInt();
+ long l = System.currentTimeMillis();
+ l = (l*l*l*l)/random;
+ if(l<0) l = l * -1;
+ String returnString = ""+l;
+ return returnString.substring(5);
+ }
}