Example #1
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()
        self.params = ParamUtil(request)

        if self.loginUser != None:
            loginUserGuid = self.loginUser.userGuid
            servletContext = request.getSession().getServletContext()
            privateKey = servletContext.getInitParameter("privateKey")
            if privateKey == None or privateKey == "":
                privateKey = "www.chinaedustar.com"
            des = EncryptDecrypt(privateKey)
            mashupUserEncryptGuid = des.encrypt(loginUserGuid)
            request.setAttribute("mashupType", "")
        else:
            mashupUserEncryptGuid = self.getMashupUserCookie()
        if mashupUserEncryptGuid != "":
            request.setAttribute("mashupuser", mashupUserEncryptGuid)
        request.setAttribute("head_nav", "mashup")

        self.show_article()
        self.show_resource()
        self.show_blog()
        self.show_platform()

        return "/WEB-INF/mashup/show_mashup.ftl"
Example #2
0
    def getEncryptLogin(self):
        if self.loginUser != None:
            userGuid = self.loginUser.userGuid
            servletContext = request.getSession().getServletContext()
            privateKey = servletContext.getInitParameter("privateKey")
            if privateKey == None or privateKey == "":
                privateKey = "www.chinaedustar.com"

            des = EncryptDecrypt(privateKey)
            userGuid = des.encrypt(userGuid)
            request.setAttribute("encUserGuid", userGuid)
Example #3
0
    def show_platform(self):
        platfotm_list = self.mashupService.getAllMashupPlatform(True)
        if self.loginUser != None:
            userGuid = self.loginUser.userGuid
            servletContext = request.getSession().getServletContext()
            privateKey = servletContext.getInitParameter("privateKey")
            if privateKey == None or privateKey == "":
                privateKey = "www.chinaedustar.com"

            des = EncryptDecrypt(privateKey)
            userGuid = des.encrypt(userGuid)
            request.setAttribute("encUserGuid", userGuid)

        request.setAttribute("platfotm_list", platfotm_list)
Example #4
0
 def execute(self):
     self.params = ParamUtil(request)
     
     self.userGuid = self.params.safeGetStringParam("g")
     servletContext = request.getSession().getServletContext()
     privateKey = servletContext.getInitParameter("privateKey")
     if privateKey == None or privateKey == "":
         privateKey = "www.chinaedustar.com"
     if self.userGuid != "":            
         des = EncryptDecrypt(privateKey)
         self.userGuid = des.decrypt(self.userGuid)
         session.setAttribute("platuser",self.userGuid)
     
     response.sendRedirect(self.get_site_url())
Example #5
0
    def execute(self):
        type = self.params.safeGetStringParam("type")
        orginId = self.params.safeGetIntParam("orginId")
        self.userGuid = self.params.safeGetStringParam("g")
        self.fromType = self.params.safeGetStringParam("from")

        #判断参数
        if type == "" or orginId == 0:
            self.addActionError(u"无效的参数 !")
            return self.ERROR

        cfg_svc = __spring__.getBean("configService")
        config = cfg_svc.getConfigure()
        if config == None:
            self.addActionError(u"不能加载配置对象 !")
            return self.ERROR
        if None == config["topsite_url"]:
            self.addActionError(u" topsite_url 配置项没配置!")
            return self.ERROR

        self.topsiteUrl = str(config["topsite_url"])

        servletContext = request.getSession().getServletContext()
        privateKey = servletContext.getInitParameter("privateKey")
        if privateKey == None or privateKey == "":
            privateKey = "www.chinaedustar.com"
        if self.userGuid != "":
            des = EncryptDecrypt(privateKey)
            self.userGuid = des.decrypt(self.userGuid)
            session.setAttribute("platuser", self.userGuid)

        if type == "article":
            # 文章无权限要求
            response.sendRedirect(self.get_site_url() + "go.py?articleId=" +
                                  str(orginId))
        elif type == "resource":
            # 需要验证
            if self.userGuid == "":
                self.addActionError(u"没有登录信息。")
                return self.ERROR
            if self.validateLoginUser() == False:
                self.addActionError(u"您的登录信息已经失效,请重新回到自己区县的站点登录。")
                return self.ERROR

            response.sendRedirect(self.get_site_url() +
                                  "showResource.py?resourceId=" + str(orginId))
        else:
            self.addActionError(u"不确定的转向。")
            return self.ERROR
Example #6
0
 def execute(self):
     site_config = SiteConfig()
     site_config.get_config()
     
     type = self.params.safeGetStringParam("type")        
     qry = MashupContentQuery("""
             mc.mashupContentId,mc.pushUserName,mc.mashupContentState,mc.platformName,
             mc.title,mc.unitName,mc.unitTitle,mc.unitTitle,mc.author,mc.orginId,mc.href,mc.pushDate
             """)
     documentType = "article"
     itemName = u"文章"
     itemUnit = u"篇"        
     if type == "resource":
         documentType = "resource"
         itemName = u"资源"
         itemUnit = u"个"
     elif type == "blog":
         return self.show_mingshi()
         
         
     qry.documentType = documentType
     pager = self.params.createPager()        
     pager.itemName = itemName
     pager.itemUnit = itemUnit
     pager.pageSize = 25
     pager.totalRows = qry.count()
     article_list = qry.query_map(pager)
     request.setAttribute("article_list", article_list)
     request.setAttribute("pager", pager)       
     request.setAttribute("documentType", documentType)
     
     if self.loginUser != None:
         loginUserGuid = self.loginUser.userGuid
         servletContext = request.getSession().getServletContext()
         privateKey = servletContext.getInitParameter("privateKey")
         if privateKey == None or privateKey == "":
             privateKey = "www.chinaedustar.com"
         des = EncryptDecrypt(privateKey)
         mashupUserEncryptGuid = des.encrypt(loginUserGuid)
         request.setAttribute("mashupType", "")
     else:
         mashupUserEncryptGuid = self.getMashupUserCookie()
     if mashupUserEncryptGuid != "":
         request.setAttribute("mashupuser", mashupUserEncryptGuid)
     request.setAttribute("head_nav", "mashup")
     return "/WEB-INF/mashup/show_more_mashup.ftl"
Example #7
0
    def execute(self):
        site_config = SiteConfig()
        site_config.get_config()

        self.mashupService = __spring__.getBean("mashupService")
        platfotm_list = self.mashupService.getAllMashupPlatform(True)
        if self.loginUser != None:
            userGuid = self.loginUser.userGuid
            servletContext = request.getSession().getServletContext()
            privateKey = servletContext.getInitParameter("privateKey")
            if privateKey == None or privateKey == "":
                privateKey = "www.chinaedustar.com"

            des = EncryptDecrypt(privateKey)
            userGuid = des.encrypt(userGuid)
            request.setAttribute("encUserGuid", userGuid)

        request.setAttribute("platfotm_list", platfotm_list)
        request.setAttribute("head_nav", "platform")
        return "/WEB-INF/mashup/platform_mashup.ftl"
Example #8
0
    def execute(self):
        self.getBaseData()
        response.setContentType("text/html; charset=UTF-8")
        if self.loginUser == None:
            backUrl = request.getAttribute('javax.servlet.forward.request_uri')
            if backUrl == None or backUrl == "": backUrl = request.requestURI
            response.sendRedirect(
                CommonUtil.getSiteUrl(request) + "login.jsp?redUrl=" +
                CommonUtil.urlUtf8Encode(
                    CommonUtil.getSiteServer(request) + backUrl))
            return

        if self.prepareCourseId == 0:
            self.printer.write(u"无效的课程标识。")
            return
        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        if self.canView(prepareCourse) == False:
            self.printer.write(u"您无权查看本内容。")
            return

        if self.isPrepareCourseMember() == False:
            self.printer.write(u"您无权编辑备课内容。")
            return

        page = self.getPrepareCoursePageWithCustomSkin(prepareCourse)
        widgets = [{
            "id": "1",
            "pageId": 0,
            "columnIndex": 1,
            "title": u"备课基本信息",
            "module": "show_preparecourse_info",
            "ico": "",
            "data": ""
        }, {
            "id": "placerholder1",
            "pageId": 0,
            "columnIndex": 2,
            "title": "",
            "module": "placeholder",
            "ico": "",
            "data": ""
        }]

        request.setAttribute("widget_list", widgets)
        request.setAttribute("page", page)
        request.setAttribute("prepareCourse", prepareCourse)
        request.setAttribute("prepareCourseId", self.prepareCourseId)

        self.prepareCourseMember = self.pc_svc.getPrepareCourseMemberByCourseIdAndUserId(
            self.prepareCourseId, self.loginUser.userId)
        if self.prepareCourseMember == None:
            operation_result = u"您不是该课的成员,或者加载对象失败。"
            request.setAttribute("operation_result", operation_result)
            return "/WEB-INF/ftl/course/show_preparecourse_ok_info.ftl"

        if request.getMethod() == "POST":
            return self.saveOrUpdate()

        if self.prepareCourseMember.contentType == 0:
            return "/WEB-INF/ftl/course/show_preparecourse_user_edit_first.ftl"
            #if (self.pdf2swfPath != None and self.pdf2swfPath != "") or (self.PrepareCourseFileServer != None and self.PrepareCourseFileServer != ""):
            #    return "/WEB-INF/ftl/course/show_preparecourse_user_edit_first.ftl"
            #else:
            #    self.prepareCourseMember.contentType = 1
            #    self.pc_svc.updatePrepareCourseMember(self.prepareCourseMember)
            #    response.sendRedirect("show_preparecourse_user_edit.py")

        else:
            ed = EncryptDecrypt()
            strPrepareCourseId = ed.encrypt(str(self.prepareCourseId) + "|0")
            ed = None
            request.setAttribute("EncryptPrepareCourseId", strPrepareCourseId)
            request.setAttribute("prepareCourseMember",
                                 self.prepareCourseMember)

            prepareCourseFileServer = request.getSession().getServletContext(
            ).getInitParameter("PrepareCourseFileServer")
            if prepareCourseFileServer != None and prepareCourseFileServer != "":
                request.setAttribute("prepareCourseFileServer",
                                     prepareCourseFileServer)
                request.setAttribute("userTicket", self.getUserTicket())

            return "/WEB-INF/ftl/course/show_preparecourse_user_edit.ftl"
Example #9
0
    def execute(self):
        self.getBaseData()        
        response.setContentType("text/html; charset=UTF-8")
        if self.loginUser == None:
            backUrl = request.getAttribute('javax.servlet.forward.request_uri')
            if backUrl == None or backUrl == "":backUrl = request.requestURI    
            response.sendRedirect(CommonUtil.getSiteUrl(request) + "login.jsp?redUrl=" + CommonUtil.urlUtf8Encode(CommonUtil.getSiteServer(request) + backUrl))
            return
        
        if self.prepareCourseId == 0:
            self.printer.write(u"无效的课程标识。")
            return
        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.printer.write(u"没有加载到所请求的备课。")
            return
        if self.canView(prepareCourse) == False:
            self.printer.write(u"您无权查看本内容。")
            return
        
        if self.isPrepareCourseMember() == False:
            self.printer.write(u"您无权编辑备课内容。")
            return
        
        
        page = self.getPrepareCoursePageWithCustomSkin(prepareCourse)
        widgets = [
                   {"id": "1", "pageId":0, "columnIndex":1, "column":1, "title":u"备课基本信息", "module":"show_preparecourse_info", "ico":"", "data":""},
                   {"id": "placerholder1", "pageId":0, "columnIndex":2, "column":2, "title":"", "module":"placeholder", "ico":"", "data":""}
                  ]

        if self.prepareCourse.lockedUserId > 0 and self.prepareCourse.lockedUserId != self.loginUser.userId:
            user = self.user_svc.getUserById(self.prepareCourse.lockedUserId)
            if user == None:
                self.printer.write(u"此备课已经被 未知的人 签出,你暂时不能进行编辑该备课。")
            else:
                d = self.prepareCourse.lockedDate
                f = SimpleDateFormat(u"yyyy年M月d日 H点m分s秒")
                d = f.format(d)
                self.printer.write(u"此备课已经被 " + user.trueName + u" 于 " + d + u" 签出,你暂时不能进行编辑该备课。")
            return
        else:
            # 设置锁标记,
            if prepareCourse.contentType == None or (prepareCourse.contentType != 2 and prepareCourse.contentType != 3 and prepareCourse.contentType != 4):
                self.prepareCourse.setLockedUserId(self.loginUser.userId)
                self.prepareCourse.setLockedDate(Date())
                self.pc_svc.updatePrepareCourse(self.prepareCourse)
        request.setAttribute("widget_list", widgets)
        request.setAttribute("page", page)
        request.setAttribute("prepareCourse", prepareCourse)
        request.setAttribute("prepareCourseId", self.prepareCourseId)
        ed = EncryptDecrypt()
        strPrepareCourseId = ed.encrypt(str(self.prepareCourseId) + "|1")
        ed = None            
        request.setAttribute("EncryptPrepareCourseId", strPrepareCourseId)
        
        prepareCourseFileServer = request.getSession().getServletContext().getInitParameter("PrepareCourseFileServer")
        if prepareCourseFileServer != None and prepareCourseFileServer != "":
            request.setAttribute("prepareCourseFileServer", prepareCourseFileServer)
            request.setAttribute("userTicket", self.getUserTicket())
        if request.getMethod() == "POST":
            return self.saveOrUpdate()        
        
        return "/WEB-INF/ftl/course/show_preparecourse_common_edit.ftl"
    def execute(self):
        self.getBaseData()

        if self.loginUser == None:
            self.showAlert(u"请先登录。")
            return
        if CommonUtil.GetPrepareCourseFolder(request)[0] == "":
            self.printer.write(
                String(
                    u"<script>alert(\"服务器没有配置文件存储路径 preparecoursefolder,不能采用这种方法进行备课。\")</script>"
                ).getBytes())
            return
        if self.prepareCourseId == 0:
            self.showAlert(u"无效的课程标识。")
            return
        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.showAlert(u"没有加载到所请求的备课。")
            return
        if self.canView(prepareCourse) == False:
            self.showAlert(u"您无权查看本内容。")
            return

        if self.isPrepareCourseMember() == False:
            self.showAlert(u"您无权编辑备课内容。")
            return

        self.getCookie()
        if self.sessionId == None or self.userTicket == None:
            self.showAlert(u"登录信息已经失效,请重新登录。")
            return

        privateCourseMember = pc_svc.getPrepareCourseMemberByCourseIdAndUserId(
            prepareCourse.prepareCourseId, self.loginUser.userId)
        if privateCourseMember == None or privateCourseMember.status != 0:
            self.showAlert(u"不是该集备的成员,或者状态不正常。")
            return

        if privateCourseMember.contentType != 2 and privateCourseMember.contentType != 3 and privateCourseMember.contentType != 4:
            self.showAlert(u"不是文档类型的个案。")
            return

        # 如果是分开的服务器,就转向另外的服务器进行处理。
        prepareCourseFileServer = request.getSession().getServletContext(
        ).getInitParameter("PrepareCourseFileServer")
        if prepareCourseFileServer != None and prepareCourseFileServer != "":
            url = prepareCourseFileServer
        else:
            url = self.get_site_url()

        url = Base64.encode(String(url).getBytes("utf-8"))
        url = url.replace("/", "_").replace("+", "-").replace("=", "~")

        oldFilePath = CommonUtil.GetPrepareCourseFolder(request)[0] + str(
            prepareCourse.prepareCourseId) + File.separator
        #print "oldFilePath=",oldFilePath
        #print "privateCourseMember.privateContent=",privateCourseMember.privateContent
        hasPrivateFile = False
        if privateCourseMember.privateContent != None and privateCourseMember.privateContent != "":
            hasPrivateFile = True
            oldFilePath = oldFilePath + privateCourseMember.privateContent
        ed = EncryptDecrypt()
        strPrepareCourseId = ed.encrypt(str(self.prepareCourseId) + "|0")
        ed = None
        fileExt = ".doc"
        if privateCourseMember.contentType == 3 or privateCourseMember.contentType == 4 or privateCourseMember.contentType == 5:
            fileExt = ".docx"
        #if privateCourseMember.privateContent.find(".") > -1:
        #    fileExt = privateCourseMember.privateContent[privateCourseMember.privateContent.find("."):]
        f = File(oldFilePath)
        # 如果客户端已经存在相同的文件,则不同的浏览器会在文件名尾部加-1等这样的内容,所以,需要间隔符类间隔我们的数据
        docFileName = self.sessionId + "!" + self.userTicket + "!" + strPrepareCourseId + "!" + url + "!0!x" + fileExt

        if prepareCourseFileServer != None and prepareCourseFileServer != "" and privateCourseMember.privateContent != None and privateCourseMember.privateContent != "":
            if prepareCourseFileServer.endswith("/") == False:
                prepareCourseFileServer += "/"
            response.sendRedirect(prepareCourseFileServer +
                                  "downloadCourseFile?returnFileName=" +
                                  docFileName + "&courseId=" +
                                  str(self.prepareCourseId) +
                                  "&courseType=0&fileName=" +
                                  privateCourseMember.privateContent)
            return

        if fileExt == ".doc":
            response.setContentType("application/msword")
        elif fileExt == ".docx":
            response.setContentType(
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            )
        elif fileExt == ".ppt":
            response.setContentType("application/vnd.ms-powerpoint")
        elif fileExt == ".pptx":
            response.setContentType(
                "application/vnd.openxmlformats-officedocument.presentationml.presentation"
            )
        else:
            response.setContentType("application/x-download")

        response.setHeader("Content-Disposition",
                           "attachment;filename=\"" + docFileName + "\"")

        if hasPrivateFile == False or f.exists() == False or f.isFile(
        ) == False:
            response.setHeader("Content-Length", "0")
            response.getOutputStream().close()
            return
        else:
            outputStream = None
            inputStream = None
            try:
                inputStream = FileInputStream(f)
                length = f.length()
                response.setHeader("Content-Length", str(length))
                bytes = jarray.zeros(length, 'b')
                offset = 0
                numRead = 0
                outputStream = response.getOutputStream()
                while offset < length:
                    if numRead >= 0:
                        numRead = inputStream.read(bytes, offset,
                                                   length - offset)
                        outputStream.write(bytes, 0, numRead)
                        offset = offset + numRead
                outputStream.flush()

            except BaseException, err:
                print "下载文件错误:", err
            finally:
Example #11
0
    def execute(self):
        self.getBaseData()

        if self.loginUser == None:
            self.showAlert(u"请先登录。")
            return
        if CommonUtil.GetPrepareCourseFolder(request)[0] == "":
            self.printer.write(
                String(
                    u"<script>alert(\"服务器没有配置文件存储路径 preparecoursefolder,不能采用这种方法进行备课。\")</script>"
                ).getBytes())
            return

        if self.prepareCourseId == 0:
            self.showAlert(u"无效的课程标识。")
            return
        prepareCourse = self.getBasePrepareCourse()
        if prepareCourse == None:
            self.showAlert(u"没有加载到所请求的备课。")
            return

        if self.canView(prepareCourse) == False:
            self.showAlert(u"您无权查看本内容。")
            return

        if self.isPrepareCourseMember() == False:
            self.showAlert(u"您不是本课的成员,无权编辑备课内容。")
            return

        self.getCookie()
        #if self.sessionId == None or self.userTicket == None:
        if self.sessionId == None or self.getLoginUser() == None:
            self.showAlert(u"登录信息已经失效,请重新登录.")
            return

        privateCourseMember = pc_svc.getPrepareCourseMemberByCourseIdAndUserId(
            prepareCourse.prepareCourseId, self.loginUser.userId)
        if privateCourseMember == None or privateCourseMember.status != 0:
            self.showAlert(u"不是该集备的成员,或者状态不正常。")
            return

        if prepareCourse.contentType != 2 and prepareCourse.contentType != 3 and prepareCourse.contentType != 4 and prepareCourse.contentType != 5:
            self.showAlert(u"该共案不是Word类型的。")
            return

        if prepareCourse.lockedUserId > 0 and prepareCourse.lockedUserId != self.loginUser.userId:
            d = prepareCourse.lockedDate
            f = SimpleDateFormat(u"yyyy年M月d日 H点m分s秒")
            d = f.format(d)
            self.showAlert(u"该共案已经被  id=" + str(prepareCourse.lockedUserId) +
                           u" 的用户于 " + d + u" 签出编辑。需要等别的用户签入之后才能进行编辑。")
            return
        else:
            prepareCourse.setLockedUserId(self.loginUser.userId)
            prepareCourse.setLockedDate(Date())
            pc_svc.updatePrepareCourse(prepareCourse)

        # 如果是分开的服务器,就转向另外的服务器进行处理。
        prepareCourseFileServer = request.getSession().getServletContext(
        ).getInitParameter("PrepareCourseFileServer")
        if prepareCourseFileServer != None and prepareCourseFileServer != "":
            url = prepareCourseFileServer
        else:
            url = self.get_site_url()

        url = Base64.encode(String(url).getBytes("utf-8"))
        # base64 字符集  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
        # 作为文件名,要把/替换掉啊
        url = url.replace("/", "_").replace("+", "-").replace("=", "~")
        oldFilePath = CommonUtil.GetPrepareCourseFolder(request)[0] + str(
            prepareCourse.prepareCourseId) + File.separator
        hasCommonFile = False
        if prepareCourse.commonContent != None and prepareCourse.commonContent != "":
            hasCommonFile = True
            oldFilePath = oldFilePath + prepareCourse.commonContent

        fileExt = ".doc"
        if prepareCourse.contentType == 3 or prepareCourse.contentType == 4 or prepareCourse.contentType == 5:
            fileExt = ".docx"

        # 如果客户端已经存在相同的文件,则不同的浏览器会在文件名尾部加-1等这样的内容,所以,需要间隔符类间隔我们的数据
        ed = EncryptDecrypt()
        strPrepareCourseId = ed.encrypt(str(self.prepareCourseId) + "|1")
        ed = None

        docFileName = self.sessionId + "!" + self.userTicket + "!" + strPrepareCourseId + "!" + url + "!1!x" + fileExt

        if prepareCourseFileServer != None and prepareCourseFileServer != "" and prepareCourse.commonContent != None and prepareCourse.commonContent != "":
            if prepareCourseFileServer.endswith("/") == False:
                prepareCourseFileServer += "/"
            response.sendRedirect(prepareCourseFileServer +
                                  "downloadCourseFile?returnFileName=" +
                                  docFileName + "&courseId=" +
                                  str(self.prepareCourseId) +
                                  "&courseType=1&fileName=" +
                                  prepareCourse.commonContent)
            return

        if fileExt == ".doc":
            response.setContentType("application/msword")
        elif fileExt == ".docx":
            response.setContentType(
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            )
        elif fileExt == ".ppt":
            response.setContentType("application/vnd.ms-powerpoint")
        elif fileExt == ".pptx":
            response.setContentType(
                "application/vnd.openxmlformats-officedocument.presentationml.presentation"
            )
        else:
            response.setContentType("application/x-download")
        response.setHeader("Content-Disposition",
                           "attachment;filename=\"" + docFileName + "\"")

        f = File(oldFilePath)
        if hasCommonFile == False or f.exists() == False or f.isFile(
        ) == False:
            response.setHeader("Content-Length", "0")
            response.getOutputStream().close()
            return None
        else:
            outputStream = None
            inputStream = None
            try:
                outputStream = response.getOutputStream()
                inputStream = FileInputStream(f)
                length = f.length()
                response.setHeader("Content-Length", str(length))
                bytes = jarray.zeros(length, 'b')
                offset = 0
                numRead = 0
                while offset < length:
                    if numRead >= 0:
                        numRead = inputStream.read(bytes, offset,
                                                   length - offset)
                        outputStream.write(bytes, 0, numRead)
                        offset = offset + numRead
                outputStream.flush()
            except BaseException, err:
                print "下载文件错误:", err
            finally: