Пример #1
0
 public static SqlWhereCollection SetCanReadWhere(
     SiteSettings ss,
     SqlWhereCollection where,
     bool checkPermission = true)
 {
     if (ss.ColumnHash.ContainsKey("SiteId"))
     {
         if (ss.AllowedIntegratedSites != null)
         {
             where.Or(new SqlWhereCollection()
                      .Add(
                          tableName: ss.ReferenceType,
                          raw: "#TableBracket#.[SiteId] in ({0})".Params(
                              ss.AllowedIntegratedSites.Join()))
                      .CheckRecordPermission(ss, ss.IntegratedSites));
         }
         else
         {
             where.Add(
                 tableName: ss.ReferenceType,
                 raw: "#TableBracket#.[SiteId]={0}".Params(ss.SiteId));
             if (!ss.CanRead(site: true) && checkPermission)
             {
                 where.CheckRecordPermission(ss);
             }
         }
     }
     return(where);
 }
Пример #2
0
        private void CsBoolColumns(Column column, string value, SqlWhereCollection where)
        {
            switch (column.CheckFilterControlType)
            {
            case ColumnUtilities.CheckFilterControlTypes.OnOnly:
                if (value.ToBool())
                {
                    where.Bool(column, "=1");
                }
                break;

            case ColumnUtilities.CheckFilterControlTypes.OnAndOff:
                switch ((ColumnUtilities.CheckFilterTypes)value.ToInt())
                {
                case ColumnUtilities.CheckFilterTypes.On:
                    where.Bool(column, "=1");
                    break;

                case ColumnUtilities.CheckFilterTypes.Off:
                    where.Or(or: new SqlWhereCollection()
                             .Bool(column, " is null")
                             .Bool(column, "=0"));
                    break;
                }
                break;
            }
        }
 public static SqlWhereCollection SetCanReadWhere(SiteSettings ss, SqlWhereCollection where)
 {
     if (ss.AllowedIntegratedSites != null)
     {
         return(where.Or(new SqlWhereCollection()
                         .Add(raw: "[SiteId] in ({0})".Params(
                                  ss.AllowedIntegratedSites.Join()))
                         .Add(
                             subLeft: ExistsPermissions(ss),
                             _operator: string.Empty)));
     }
     else if (!ss.CanRead(site: true))
     {
         return(where
                .Add(raw: "[SiteId]={0}".Params(ss.SiteId))
                .Add(
                    subLeft: ExistsPermissions(ss),
                    _operator: string.Empty));
     }
     else
     {
         return(Routes.Controller() == "items"
             ? where.Add(raw: "[SiteId]={0}".Params(ss.SiteId))
             : where);
     }
 }
Пример #4
0
 private static SqlWhereCollection PermissionsWhere(this SqlWhereCollection where)
 {
     return(where.Or(Rds.PermissionsWhere()
                     .GroupId_In(sub: Rds.SelectGroupMembers(
                                     column: Rds.GroupMembersColumn().GroupId(),
                                     where : Rds.GroupMembersWhere()
                                     .Add(raw: DeptOrUser("GroupMembers"))))
                     .Add(raw: DeptOrUser("Permissions"))));
 }
Пример #5
0
 public static SqlWhereCollection SetCanReadWhere(
     IContext context,
     SiteSettings ss,
     SqlWhereCollection where,
     bool checkPermission = true)
 {
     if (ss.IsSite(context: context) && ss.ReferenceType == "Sites")
     {
         where.Add(
             tableName: "Sites",
             raw: $"[Sites].[ParentId] in ({ss.SiteId})");
     }
     else
     {
         if (ss.ColumnHash.ContainsKey("SiteId"))
         {
             if (ss.AllowedIntegratedSites != null)
             {
                 where.Or(new SqlWhereCollection()
                          .Add(
                              tableName: ss.ReferenceType,
                              raw: "[{0}].[SiteId] in ({1})".Params(
                                  ss.ReferenceType, ss.AllowedIntegratedSites.Join()))
                          .CheckRecordPermission(ss, ss.IntegratedSites));
             }
             else
             {
                 where.Add(
                     tableName: ss.ReferenceType,
                     raw: "[{0}].[SiteId] in ({1})".Params(
                         ss.ReferenceType, ss.SiteId));
                 if (!context.CanRead(ss: ss, site: true) && checkPermission)
                 {
                     where.CheckRecordPermission(ss);
                 }
             }
         }
     }
     return(where);
 }