コード例 #1
0
ファイル: admin_resource.py プロジェクト: yxxcrtd/jitar2.0
    def recycle_list(self):
        # 构造查询.
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, u.loginName, u.nickName, r.subjectId, r.gradeId, 
        r.href, r.downloadCount, r.commentCount, r.fsize, sc.name as sysCateName, subj.subjectName """
        )
        query.auditState = None
        query.delState = True  # 获得被删除的.
        query.shareMode = None

        query.subjectId = self.params.getIntParamZeroAsNull("su")
        request.setAttribute("su", query.subjectId)
        query.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        request.setAttribute("gradeId", query.gradeId)
        query.sysCateId = self.params.getIntParamZeroAsNull("sc")
        request.setAttribute("sc", query.sysCateId)
        query.kk = self.params.getStringParam("k")
        request.setAttribute("k", query.kk)
        query.f = self.params.getStringParam("f")
        request.setAttribute("f", query.f)

        # 计算总量.
        pager = self.createPager()
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        return self.RECYCLE_LIST
コード例 #2
0
ファイル: resources.py プロジェクト: yxxcrtd/jitar2012
 def get_resource_querylist(self):
     qry = ResourceQuery(
         " r.resourceId, r.href, r.title, r.fsize, r.createDate,r.auditState "
     )
     resId = self.params.getStringParam("id")
     qry.resourceIds = resId
     qry.auditState = None
     resource_list = qry.query_map()
     request.setAttribute("resource_list", resource_list)
コード例 #3
0
    def get_list(self):
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, r.rcmdPathInfo,
            r.delState, r.unitPathInfo, r.approvedPathInfo, r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, r.pushState,
            u.userId, u.loginName, u.nickName, sc.name as sysCateName, subj.subjectName """
        )

        query.unitId = None
        query.auditState = None
        query.delState = None

        multiPushState = self.params.safeGetStringParam("multiPushState")
        recommendState = self.params.safeGetStringParam("recommendState")
        auditState = self.params.safeGetStringParam("auditState")
        delState = self.params.safeGetStringParam("delState")

        custormAndWhereClause = "r.unitId = " + str(self.unit.unitId) + " And"

        if auditState == "0":
            custormAndWhereClause += " r.approvedPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif auditState == "1":
            custormAndWhereClause += " (r.approvedPathInfo Is NUll or r.approvedPathInfo NOT LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if multiPushState == "1":
            custormAndWhereClause += " r.unitPathInfo LIKE '%/" + str(
                self.unit.parentId) + "/%' And"
        elif multiPushState == "0":
            custormAndWhereClause += " r.unitPathInfo NOT LIKE '%/" + str(
                self.unit.parentId) + "/%' And"

        if recommendState == "1":
            custormAndWhereClause += " r.rcmdPathInfo LIKE '%/" + str(
                self.unit.unitId) + "/%' And"
        elif recommendState == "0":
            custormAndWhereClause += " (r.rcmdPathInfo Is NULL or r.rcmdPathInfo NOT LIKE '%/" + str(
                self.unit.unitId) + "/%') And"

        if delState == "0":
            query.delState = False
        elif delState == "1":
            query.delState = True

        if custormAndWhereClause[len(custormAndWhereClause) - 3:] == "And":
            custormAndWhereClause = custormAndWhereClause[
                0:len(custormAndWhereClause) - 3]
        query.custormAndWhereClause = custormAndWhereClause
        #print custormAndWhereClause

        query.shareMode = None
        #query.unitId = self.unit.unitId

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 20
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        request.setAttribute("delState", delState)
        request.setAttribute("multiPushState", multiPushState)
        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
コード例 #4
0
ファイル: unit_resource.py プロジェクト: yxxcrtd/jitar2.0
    def list(self):
        # 构造查询.
        query = ResourceQuery(
            """ r.resourceId, r.title, r.shareMode, r.createDate, r.href, r.subjectId, r.gradeId, 
            r.downloadCount, r.commentCount, r.fsize, r.auditState, r.recommendState, r.tags, r.addIp, r.pushState,
            u.userId, u.loginName, u.nickName, sc.name as sysCateName, subj.subjectName """
        )

        query.auditState = None
        query.delState = False  # 过滤被删除了的.

        recommendState = self.params.safeGetStringParam("recommendState")
        if recommendState == "1":
            query.rcmdState = 1
        elif recommendState == "0":
            query.rcmdState = 0

        auditState = self.params.safeGetStringParam("auditState")
        if auditState == "1":
            query.auditState = 1
        elif auditState == "0":
            query.auditState = 0

        query.shareMode = None
        query.unitId = self.unit.unitId

        # 根据参数设置过滤条件.
        type = self.params.getStringParam("type")
        request.setAttribute("type", type)
        if type == "rcmd":  # 推荐.
            query.rcmdState = True
        elif type == "unaudit":  # 待审核.
            query.auditState = Resource.AUDIT_STATE_WAIT_AUDIT

        query.subjectId = self.params.getIntParamZeroAsNull("su")
        request.setAttribute("su", query.subjectId)
        query.gradeId = self.params.getIntParamZeroAsNull("gradeId")
        request.setAttribute("gradeId", query.gradeId)
        query.sysCateId = self.params.getIntParamZeroAsNull("sc")
        request.setAttribute("sc", query.sysCateId)
        query.kk = self.params.getStringParam("k")
        request.setAttribute("k", query.kk)
        query.f = self.params.getStringParam("f")
        request.setAttribute("f", query.f)

        # 计算总量.
        pager = self.createPager()
        pager.pageSize = 10
        pager.totalRows = query.count()

        # 得到资源.
        resource_list = query.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("resource_list", resource_list)
        self.putSubjectList()
        self.putGradeList()
        self.putResourceCategoryTree()

        request.setAttribute("recommendState", recommendState)
        request.setAttribute("auditState", auditState)
        return "/WEB-INF/unitsmanage/unit_owner_resource.ftl"
コード例 #5
0
ファイル: showResource.py プロジェクト: yxxcrtd/jitar2.0
    def execute(self):
        q = request.getQueryString()
        response.sendRedirect(request.getContextPath() +
                              "/showResource.action?" + q)

        param = ParamUtil(request)
        resourceId = param.getIntParam("resourceId")
        shareMode = param.getIntParam("shareMode")
        if resourceId == None or resourceId == "":
            request.setAttribute("error", u"无效的标识。")
            return "/WEB-INF/ftl/show_resource.ftl"
        self.res_svc = __jitar__.getResourceService()

        # 得到的信息不全啊
        resource = self.res_svc.getResource(resourceId)
        if resource == None:
            request.setAttribute("error", u"无法加载该资源。")
            return "/WEB-INF/ftl/show_resource.ftl"

        punshScore = self.pun_svc.getUPunishScore(
            ObjectType.OBJECT_TYPE_RESOURCE.getTypeId(), resourceId)
        if punshScore != None:
            if punshScore.getScore() < 0:
                request.setAttribute("scoreCreateUserId",
                                     punshScore.getCreateUserId())
                request.setAttribute("scoreCreateUserName",
                                     punshScore.getCreateUserName())
                request.setAttribute("score", -1 * punshScore.getScore())
                request.setAttribute("scoreReason", punshScore.getReason())
                request.setAttribute("scoreDate", punshScore.getPunishDate())
                request.setAttribute("scoreObjId", punshScore.getObjId())
                request.setAttribute("scoreObjTitle", punshScore.getObjTitle())

        qry = ResourceQuery(
            """ r.resourceId, r.title, r.href, r.createDate, r.fsize, r.downloadCount, 
                                r.author, r.publisher, r.summary, u.loginName, r.subjectId, 
                                grad.gradeName, sc.name as scName, r.shareMode,r.userId,r.recommendState """
        )

        # 如果是管理者或者作者自己,则可以浏览
        if self.loginUser != None:
            accessControlService = __spring__.getBean("accessControlService")
            isAdmin = False
            adminList = accessControlService.getAllAccessControlByUser(
                self.loginUser)
            if len(adminList) > 0:
                isAdmin = True

            if self.loginUser.userId == resource.userId or accessControlService.isSystemAdmin(
                    self.loginUser) or isAdmin == True:
                qry.auditState = None
                qry.delState = None
            else:
                if resource.auditState == True or resource.delState == True:
                    request.setAttribute("error", u"该资源未审核或者待删除。")
                    return "/WEB-INF/ftl/show_resource.ftl"
        else:
            if resource.auditState == True or resource.delState == True:
                request.setAttribute("error", u"该资源未审核或者待删除。")
                return "/WEB-INF/ftl/show_resource.ftl"

        qry.resourceId = resource.resourceId
        qry.shareMode = resource.shareMode
        new_resource_list = qry.query_map(1)
        # print "====", new_resource_list

        if (len(new_resource_list) > 0):
            request.setAttribute("resource", new_resource_list[0])
        else:
            return
        res = new_resource_list[0]
        query = AdminCommentQuery(
            " cmt.id, cmt.title, cmt.content, cmt.audit, cmt.createDate, cmt.userId, cmt.userName, cmt.star, cmt.objType, cmt.objId, u.userIcon, u.loginName, u.trueName "
        )
        query.objType = 12
        query.objId = resource.resourceId
        query.audit = 1
        # 调用分页函数.
        pager = self.createPager()
        pager.totalRows = query.count()
        commentList = query.query_map(pager)
        request.setAttribute("comment_list", commentList)
        request.setAttribute("pager", pager)

        conf = JitarContext.getCurrentJitarContext().getConfigService(
        ).getConfigure()
        largefileupload = conf.getValue("resource.download")
        if (largefileupload == 1):
            request.setAttribute("resourcedowload", "true")
        else:
            if self.loginUser == None:
                if self.getMashupUserCookie() == "":
                    request.setAttribute("resourcedowload", "false")
                else:
                    request.setAttribute("resourcedowload", "true")
            else:
                request.setAttribute("resourcedowload", "true")

        response.setContentType("text/html; charset=UTF-8")

        # 增加资源的访问量
        self.res_svc.increaseViewCount(resourceId)
        if self.getImpersonateUser() != None:
            request.setAttribute("resourcedowload", "true")
        filename = res["href"]
        if filename != None and filename != "":
            filename = filename.lower()
            canPreview = False
            if filename.endswith(".jpg") or filename.endswith(
                    ".gif") or filename.endswith(".png") or filename.endswith(
                        ".txt"):
                canPreview = True
            elif filename.endswith(".doc") or filename.endswith(
                    ".docx"
            ) or filename.endswith(".swf") or filename.endswith(
                    ".pdf"
            ):  # or filename.endswith(".xls") or filename.endswith(".xlsx") or filename.endswith(".ppt") or filename.endswith(".pptx"):
                PDF2SWFPath = request.getSession().getServletContext(
                ).getInitParameter("pdf2swfPath")
                if PDF2SWFPath != None and PDF2SWFPath != "":
                    canPreview = True
                prepareCourseFileServer = request.getSession(
                ).getServletContext().getInitParameter(
                    "PrepareCourseFileServer")
                if prepareCourseFileServer != None and prepareCourseFileServer != "":
                    canPreview = False
            if canPreview:
                request.setAttribute("resourceId", resource.resourceId)
                request.setAttribute("canPreview", "true")

        return "/WEB-INF/ftl/show_resource.ftl"