Beispiel #1
0
 def list_user(self):
     userState = self.params.safeGetStringParam("userState")
     k = self.params.safeGetStringParam("k")
     qry = UserQuery(""" u.userId, u.loginName, u.nickName, u.trueName, u.userIcon, u.userStatus, u.email, 
                     u.subjectId, u.gradeId, u.createDate, u.userType   """)
     qry.orderType = 0
     if userState != "" and userState.isdigit() == True:
         qry.userStatus = int(userState)
     else:
         qry.userStatus = None
     if k != "":
         qry.f = "name"
         qry.k = k
         request.setAttribute("k", k)
         
     qry.unitId = self.unit.unitId
     pager = self.params.createPager()
     pager.itemName = u"用户"
     pager.itemUnit = u"个"
     pager.pageSize = 20
     pager.totalRows = qry.count()
     user_list = qry.query_map(pager)
     
     request.setAttribute("pager", pager)
     request.setAttribute("user_list", user_list)
     request.setAttribute("userState", userState)
Beispiel #2
0
 def get_typeduser_list(self, typdId):
     qry = UserQuery(
         """ u.loginName, u.userIcon, u.blogName, u.trueName, u.blogIntroduce, u.createDate, u.visitCount, 
                     u.articleCount, u.resourceCount, u.commentCount,u.userScore, u.userTags """
     )
     qry.orderType = 0
     qry.userStatus = 0
     qry.userTypeId = typdId
     pager = self.params.createPager()
     pager.itemName = u"用户"
     pager.itemUnit = u"个"
     pager.pageSize = 20
     pager.totalRows = qry.count()
     user_list = qry.query_map(pager)
     request.setAttribute("pager", pager)
     request.setAttribute("user_list", user_list)
     user_typename = ""
     userService = __jitar__.userService
     type_list = userService.getAllUserType()
     if type_list != None and len(type_list) > 0:
         for t in type_list:
             if t.typeId == typdId:
                 user_typename = t.typeName
                 break
     request.setAttribute("list_type", user_typename)
Beispiel #3
0
    def get_request(self):
        k = self.params.safeGetStringParam("k")
        f = self.params.safeGetStringParam("f")
        userState = self.params.safeGetStringParam("userState")
        qry = UserQuery(
            """ u.userId, u.loginName, u.nickName, u.trueName, u.userIcon, u.userStatus, 
                            u.subjectId, u.gradeId, u.createDate, u.userType, u.unitId, unit.unitTitle
                         """)
        qry.orderType = 0
        if userState != "" and userState.isdigit() == True:
            qry.userStatus = int(userState)
        else:
            qry.userStatus = None
        qry.delState = None

        request.setAttribute("f", f)
        if k != "":
            qry.k = k
            request.setAttribute("k", k)

        # 不使用unitId 查询过滤
        qry.unitId = None
        qry.custormAndWhere = "(u.unitPathInfo LIKE '%/" + str(
            self.unit.unitId) + "/%') And (u.unitId <> " + str(
                self.unit.unitId) + ")"
        pager = self.params.createPager()
        pager.itemName = u"用户"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        user_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("user_list", user_list)
        request.setAttribute("userState", userState)
Beispiel #4
0
    def query_blog(self):
        qry = UserQuery(
            """ u.userId, u.loginName, u.nickName, u.trueName, u.createDate, u.blogName, 
                        u.blogIntroduce, u.userIcon, u.myArticleCount, u.otherArticleCount, 
                        u.resourceCount, u.commentCount, u.visitCount, u.photoCount,u.articleCount, 
                        subj.subjectName, grad.gradeName, grad.gradeId, unit.unitName """
        )

        qry.userStatus = 0
        pager = self.createPager()

        # 根据页面参数处理.
        type = self.params.getStringParam("type")
        if type == "rcmd":
            qry.userTypeId = 2
        elif type == "hot":
            qry.orderType = 1
        else:
            type = "new"

        request.setAttribute("type", type)

        qry.subjectId = self.get_current_subjectId()
        qry.gradeId = self.get_current_gradeId()
        qry.k = self.params.getStringParam("k")
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        #qry.setSubjectCondition(self.subject)
        qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")

        pager.totalRows = qry.count()
        blog_list = qry.query_map(pager)
        request.setAttribute("blog_list", blog_list)
        request.setAttribute("pager", pager)
        return
Beispiel #5
0
    def execute(self):
        # 选择类型,单选还是多选?type:1单选,0多选
        type = self.params.safeGetStringParam("type")
        idTag = self.params.safeGetStringParam("idTag")
        titleTag = self.params.safeGetStringParam("titleTag")
        backType = self.params.safeGetStringParam("back")

        qry = UserQuery(
            " u.userId, u.loginName, u.trueName, u.createDate, unit.unitName, unit.unitTitle "
        )
        qry.orderType = 0
        qry.userStatus = 0
        pager = self.params.createPager()
        pager.itemName = u"用户"
        pager.itemUnit = u"个"
        pager.pageSize = 20
        pager.totalRows = qry.count()
        user_list = qry.query_map(pager)
        request.setAttribute("pager", pager)
        request.setAttribute("user_list", user_list)
        request.setAttribute("type", type)
        request.setAttribute("idTag", idTag)
        request.setAttribute("titleTag", titleTag)
        request.setAttribute("back", backType)
        return "/WEB-INF/common/user_select_bottom.ftl"
Beispiel #6
0
    def user_list(self, type):
        # 系统用户管理员可以管理所有用户
        pager = self.createPager()
        qry = UserQuery(
            """ u.userId, u.loginName, u.nickName, u.trueName, u.userIcon, u.userStatus, u.pushState,
                        u.email, u.subjectId, u.gradeId, u.createDate, u.qq, u.idCard, u.positionId, u.userType, subj.subjectName, 
                        grad.gradeName, unit.unitTitle
                         """)
        qry.userStatus = None
        qry.userTypeId = self.typeId
        qry.kk = self.params.getStringParam("k")
        qry.subjectId = self.params.getIntParamZeroAsNull("subjectId")
        qry.f = self.params.getStringParam("f")

        # print("type=" + type)
        # 根据 type 设置过滤.
        if type == "unaudit":
            qry.userStatus = User.USER_STATUS_WAIT_AUTID
        elif type == "locked":
            qry.userStatus = User.USER_STATUS_LOCKED
        elif type == "deleted":
            qry.userStatus = User.USER_STATUS_DELETED

        # 普通管理员不能设置 超级管理员的内容
        if self.loginUser.loginName != "admin":
            qry.custormAndWhere = "u.loginName <> 'admin'"
        pager.totalRows = qry.count()
        user_list = qry.query_map(pager)

        request.setAttribute("pager", pager)
        request.setAttribute("userList", user_list)
        request.setAttribute("k", qry.kk)
        request.setAttribute("f", qry.f)
        request.setAttribute("subjectId", qry.subjectId)
        request.setAttribute("cmdtype", type)

        self.putSubjectList()
        self.putGradeList()

        #判断是否是中教启星的用户系统,使用了别家公司的用户系统,则部分操作需要限制
        #if request.getServletContext().getServletRegistration("CAS-Authentication-Filter") != None:
        if request.getServletContext().getFilterRegistration(
                "CAS-Authentication-Filter") != None:
            request.setAttribute("usermgr3", 1)
        elif request.getServletContext().getFilterRegistration(
                "ssoUserFilter") != None:
            request.setAttribute("usermgr3", 1)
        else:
            request.setAttribute("usermgr3", 0)

        # 不能输入'
        if qry.kk == "'":
            self.addActionError(u"请不要输入非法的字符串。")
            return self.ERROR

        return ADMIN_USER_LIST
Beispiel #7
0
 def query_blog(self):
   qry = UserQuery(""" u.userId, u.loginName, u.nickName, u.createDate, u.blogName, u.blogIntroduce,
         u.userIcon, u.articleCount, u.resourceCount, u.commentCount, u.visitCount, u.photoCount,
         subj.subjectName, unit.unitName """)
   qry.subjectId = self.subject.subjectId
   qry.sysCateId = self.params.getIntParamZeroAsNull("categoryId")
   qry.k = self.params.getStringParam("k")
   
   pager = self.createPager()
   pager.totalRows = qry.count()
   blog_list = qry.query_map(pager)
   request.setAttribute("blog_list", blog_list)
   request.setAttribute("pager", pager)
   return
Beispiel #8
0
 def get_hot_list(self):
     qry = UserQuery(
         """ u.loginName, u.userIcon, u.blogName, u.trueName,u.blogIntroduce,u.createDate, u.visitCount, 
                     u.articleCount, u.resourceCount, u.commentCount,u.userScore, u.userTags """
     )
     qry.orderType = 1
     qry.userStatus = 0
     pager = self.params.createPager()
     pager.itemName = u"用户"
     pager.itemUnit = u"个"
     pager.pageSize = 20
     pager.totalRows = qry.count()
     user_list = qry.query_map(pager)
     request.setAttribute("pager", pager)
     request.setAttribute("user_list", user_list)
     request.setAttribute("list_type", u"热门工作室")
Beispiel #9
0
 def show_list(self):
     qry = UserQuery(""" u.userId, u.loginName, u.nickName, u.trueName, u.userIcon, u.userStatus, u.pushState,u.pushUserId,
                          u.email, u.subjectId, u.gradeId, u.createDate, u.blogIntroduce,
                          subj.subjectName, grad.gradeName, unit.unitName, u.positionId
                           """)
     qry.userStatus = 0
     qry.pushState = 2 # 待推送 
     qry.isFamous = True
     pager = self.params.createPager()
     pager.itemName = u"名师"
     pager.itemUnit = u"位"
     pager.pageSize = 25
     pager.totalRows = qry.count()
     user_list = qry.query_map(pager)
     request.setAttribute("user_list", user_list)
     request.setAttribute("pager", pager)
     return "/WEB-INF/push/admin_push_famous_list.ftl" 
 def execute(self):
     if self.isSystemUserAdmin() == False:
         self.addActionError(u"您不具有用户管理权限。")
         return self.ERROR
     cmd = self.params.getStringParam("cmd")
     if cmd == None or cmd == "":
         cmd = "list"
     if cmd == "edit":
         typeId = self.params.safeGetIntParam("typeId")
         userType = self.userService.getUserTypeById(typeId)
         if userType == None:
             self.addActionError(u"不能加载用户类型对象。")
             return self.ERROR
         request.setAttribute("userType",userType)
         return "/WEB-INF/ftl/admin/admin_usertype_edit.ftl"
     elif cmd == "delete":
         typeId = self.params.safeGetIntParam("typeId")
         userType = self.userService.getUserTypeById(typeId)
         if userType == None:
             self.addActionError(u"不能加载用户类型对象。")
             return self.ERROR
         if userType.isSystem:
             self.addActionError(u"不允许删除系统用户类型定义。")
             return self.ERROR
         # 删除用户表的引用
         qry = UserQuery("u.userId, u.userType")
         qry.orderType = None
         qry.userTypeId = typeId
         user_list = qry.query_map(qry.count())
         if user_list != None and len(user_list) > 0:
             for user in user_list:
                 userTypeId = user["userType"]
                 userTypeId = userTypeId.replace("/" + str(typeId) + "/","/")
                 if userTypeId == "/":
                     userTypeId = None
                 self.userService.updateUserType(int(user["userId"]), userTypeId)
         self.userService.deleteUserType(userType)
         
     if request.getMethod() == "POST":            
         if cmd == "add":
             return self.add_user_type()
         
     user_type_list = self.userService.getAllUserType()
     request.setAttribute("user_type_list",user_type_list)
     return self.user_type_list
Beispiel #11
0
 def get_new_blog_list(self):
     qry = UserQuery(
         """ u.loginName, u.articleCount, u.userIcon, u.blogName, u.trueName, u.blogIntroduce,u.createDate, u.visitCount, 
                     u.myArticleCount, u.otherArticleCount, u.resourceCount, u.commentCount,u.userScore """
     )
     qry.orderType = 0
     qry.userStatus = 0
     qry.unitId = self.unit.unitId
     pager = self.params.createPager()
     pager.itemName = u"用户"
     pager.itemUnit = u"个"
     pager.pageSize = 20
     pager.totalRows = qry.count()
     user_list = qry.query_map(pager)
     request.setAttribute("pager", pager)
     request.setAttribute("user_list", user_list)
     if self.type == "search":
         request.setAttribute("list_type", u"工作室搜索")
     else:
         request.setAttribute("list_type", u"最新工作室")
Beispiel #12
0
    def execute(self):
        if self.unitService == None:
            self.addActionError(
                u"无法加载组织机构服务,请检查 applicationContext.xml 配置文件,是否缺少 unitService 节点。"
            )
            return self.ERROR

        self.unit = self.getUnit()
        if self.unit == None:
            self.addActionError(u"您所访问的机构不存在!")
            return self.ERROR
        if self.unit.delState == True:
            self.addActionError(u"您所访问的机构已经被删除!")
            return self.ERROR
        self.get_backyear_list()

        year = self.params.getIntParamZeroAsNull("year")
        if self.backYearList == None:
            year = None
        if self.backYearList != None:
            IsValidYear = False
            for y in self.backYearList:
                if year == y.backYear:
                    IsValidYear = True
                    break
            if IsValidYear == False:
                year = None

        strWhereClause = "ApprovedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%'"
        strOrderBy = "ArticleId DESC"
        list_type = u"最新文章"
        type = self.params.getStringParam("type")
        if type == "" or type == None:
            type = "new"
        if type == "hot":
            strOrderBy = "ViewCount DESC"
            list_type = u"热门文章"
        elif type == "best":
            strWhereClause = strWhereClause + " And BestState = 1"
            list_type = u"精华文章"
        elif type == "rcmd":
            strWhereClause = strWhereClause + "  And RcmdPathInfo Like '%/" + str(
                self.unit.unitId) + "/%'"
            list_type = u"推荐文章"
        elif type == "cmt":
            strOrderBy = "CommentCount DESC"
            list_type = u"评论最多文章"
        elif type == "famous":
            # 为了不增加额外的表,现在先得到全部名师的 id,然后再去查询。
            qry = UserQuery("u.userId")
            qry.userTypeId = 1
            user_count = qry.count()
            user_list = qry.list(user_count)
            if user_list == None or len(user_list) < 1:
                nodata = True
                strWhereClause = strWhereClause + "  And UserId IN (0)"
            else:
                uid = ""
                for u in user_list:
                    uid += str(u) + ","
                uid = uid[0:len(uid) - 1]
                strWhereClause = strWhereClause + "  And UserId IN (" + uid + ")"
            list_type = u"名师文章"
        elif type == "digg":
            strOrderBy = "Digg DESC"
            list_type = u"按顶排序"
        elif type == "trample":
            strOrderBy = "Trample DESC"
            list_type = u"按踩排序"
        elif type == "star":
            strOrderBy = "(StarCount/CommentCount) DESC"
            list_type = u"按星排序"
            strWhereClause = strWhereClause + " And CommentCount>0"
        else:
            type = 'new'

        k = self.params.getStringParam("k")
        if k != "" and k != None:
            if len(k) > 25 or k.find("'") > -1:
                k = ""
            else:
                strWhereClause = strWhereClause + " And Title Like '%" + k + "%'"
        subjectId = self.params.getIntParamZeroAsNull("subjectId")
        sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        gradeId = self.params.getIntParamZeroAsNull("gradeId")

        if subjectId != None:
            strWhereClause = strWhereClause + " And SubjectId = " + str(
                subjectId)
        if sysCateId != None:
            #只查询分类自己的
            #strWhereClause = strWhereClause + " And SysCateId = " + str(sysCateId)
            #查询包含子孙分类的
            list = self.cate_svc.getCategoryIds(sysCateId)
            cateIds = ""
            for c in list:
                if cateIds == "":
                    cateIds = cateIds + str(c)
                else:
                    cateIds = cateIds + "," + str(c)
            strWhereClause = strWhereClause + " And SysCateId IN (" + cateIds + ")"

        if gradeId != None:
            strWhereClause = strWhereClause + " And GradeId = " + str(gradeId)

        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "ArticleId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.orderByFieldName = strOrderBy
        pagingQuery.spName = "findPagingArticle"
        if year == None:
            pagingQuery.tableName = "Jitar_Article"
        else:
            pagingQuery.tableName = "HtmlArticle" + str(year)
        pagingQuery.whereClause = strWhereClause

        totalCount = self.params.safeGetIntParam("totalCount")
        pager = Pager()
        pager.setCurrentPage(self.params.safeGetIntParam("page", 1))
        pager.setPageSize(20)
        pager.setItemNameAndUnit(u"文章", u"篇")
        pager.setUrlPattern(self.params.generateUrlPattern())
        if totalCount <= 0:
            pager.setTotalRows(pagingService.getRowsCount(pagingQuery))
        else:
            pager.setTotalRows(totalCount)

        article_list = pagingService.getPagingList(pagingQuery, pager)
        request.setAttribute("type", type)
        request.setAttribute("list_type", list_type)
        request.setAttribute("article_list", article_list)
        request.setAttribute("categoryId", sysCateId)
        request.setAttribute("subjectId", subjectId)
        request.setAttribute("k", k)
        request.setAttribute("pager", pager)
        request.setAttribute("year", year)
        # 文章分类.
        blog_cates = self.cate_svc.getCategoryTree("default")
        request.setAttribute("blog_cates", blog_cates)

        request.setAttribute("head_nav", "unit_article")
        request.setAttribute("unit", self.unit)

        self.putGradeList()
        self.putSubjectList()

        templateName = "template1"
        if self.unit.templateName != None:
            templateName = self.unit.templateName
        return "/WEB-INF/unitspage/" + templateName + "/unit_article.ftl"
Beispiel #13
0
    def get_article_list(self):
        year = self.params.getIntParamZeroAsNull("year")
        if self.backYearList == None:
            year = None
        if self.backYearList != None:
            IsValidYear = False
            for y in self.backYearList:
                if year == y.backYear:
                    IsValidYear = True
                    break
            if IsValidYear == False:
                year = None
        blogUserId = self.params.getIntParamZeroAsNull("userId")
        strWhereClause = "HideState=0 And AuditState=0 And DraftState=0 And DelState=0 And ApprovedPathInfo Like '%/" + str(
            self.unit.unitId) + "/%'"
        if blogUserId != None:
            strWhereClause += " And UserId=" + str(blogUserId)
        strOrderBy = "ArticleId DESC"
        list_type = u"最新文章"
        type = self.params.getStringParam("type")
        if type == "" or type == None:
            type = "new"
        if type == "hot":
            strOrderBy = "ViewCount DESC"
            list_type = u"热门文章"
        elif type == "best":
            strWhereClause = strWhereClause + " And BestState = 1"
            list_type = u"精华文章"
        elif type == "rcmd":
            strWhereClause = strWhereClause + "  And RcmdPathInfo Like '%/" + str(
                self.unit.unitId) + "/%'"
            list_type = u"推荐文章"
        elif type == "cmt":
            strOrderBy = "CommentCount DESC"
            list_type = u"评论最多文章"
        elif type == "famous":
            # 为了不增加额外的表,现在先得到全部名师的 id,然后再去查询。
            qry = UserQuery("u.userId")
            qry.userTypeId = 1
            user_count = qry.count()
            user_list = qry.list(user_count)
            if user_list == None or len(user_list) < 1:
                nodata = True
            else:
                uid = ""
                for u in user_list:
                    uid += str(u) + ","
                uid = uid[0:len(uid) - 1]
                strWhereClause = strWhereClause + " And UserId IN (" + uid + ")"
            list_type = u"名师文章"
        elif type == "digg":
            strOrderBy = "Digg DESC"
            list_type = u"按顶排序"
        elif type == "trample":
            strOrderBy = "Trample DESC"
            list_type = u"按踩排序"
        elif type == "star":
            strOrderBy = "StarCount/CommentCount DESC"
            strWhereClause = strWhereClause + " And CommentCount > 0"
            list_type = u"按星排序"
        else:
            type = "new"

        k = self.params.getStringParam("k")
        if k != None and k != "":
            newKey = k.replace("'", "''").replace("%", "[%]").replace(
                "_", "[_]").replace("[", "[[]")
            strWhereClause = strWhereClause + " And Title Like '%" + newKey + "%'"
        subjectId = self.params.getIntParamZeroAsNull("subjectId")
        sysCateId = self.params.getIntParamZeroAsNull("categoryId")
        gradeId = self.params.getIntParamZeroAsNull("gradeId")

        if subjectId != None:
            strWhereClause = strWhereClause + " And SubjectId = " + str(
                subjectId)
        if sysCateId != None:
            #只查询分类自己的
            #strWhereClause = strWhereClause + " And SysCateId = " + str(sysCateId)
            #查询包含子孙分类的
            list = self.cate_svc.getCategoryIds(sysCateId)
            cateIds = ""
            for c in list:
                if cateIds == "":
                    cateIds = cateIds + str(c)
                else:
                    cateIds = cateIds + "," + str(c)
            strWhereClause = strWhereClause + " And SysCateId IN (" + cateIds + ")"

        if gradeId != None:
            strWhereClause = strWhereClause + " And GradeId = " + str(gradeId)

        pagingService = __spring__.getBean("pagingService")
        pagingQuery = PagingQuery()
        pagingQuery.keyName = "ArticleId"
        pagingQuery.fetchFieldsName = "*"
        pagingQuery.orderByFieldName = strOrderBy
        pagingQuery.spName = "findPagingArticle"
        if year == None:
            pagingQuery.tableName = "Jitar_Article"
        else:
            pagingQuery.tableName = "HtmlArticle" + str(year)
        pagingQuery.whereClause = strWhereClause

        totalCount = self.params.safeGetIntParam("totalCount")
        pager = Pager()
        pager.setCurrentPage(self.params.safeGetIntParam("page", 1))
        pager.setPageSize(20)
        pager.setItemNameAndUnit(u"文章", u"篇")
        pager.setUrlPattern(self.params.generateUrlPattern())
        if totalCount == 0:
            pager.setTotalRows(pagingService.getRowsCount(pagingQuery))
        else:
            pager.setTotalRows(totalCount)

        article_list = pagingService.getPagingList(pagingQuery, pager)

        request.setAttribute("type", type)
        request.setAttribute("list_type", list_type)
        request.setAttribute("article_list", article_list)
        request.setAttribute("categoryId", sysCateId)
        request.setAttribute("subjectId", subjectId)
        request.setAttribute("k", k)
        request.setAttribute("pager", pager)
        request.setAttribute("year", year)