Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
        public static string Histories(
            SiteSettings ss, int deptId, Message message = null)
        {
            var deptModel = new DeptModel(ss, deptId);

            ss.SetColumnAccessControls(deptModel.Mine());
            var columns = ss.GetHistoryColumns(checkPermission: true);

            if (!ss.CanRead())
            {
                return(Error.Types.HasNotPermission.MessageJson());
            }
            var hb = new HtmlBuilder();

            hb
            .HistoryCommands(ss: ss)
            .Table(
                attributes: new HtmlAttributes().Class("grid history"),
                action: () => hb
                .THead(action: () => hb
                       .GridHeader(
                           columns: columns,
                           sort: false,
                           checkRow: true))
                .TBody(action: () => hb
                       .HistoriesTableBody(
                           ss: ss,
                           columns: columns,
                           deptModel: deptModel)));
            return(new DeptsResponseCollection(deptModel)
                   .Html("#FieldSetHistories", hb)
                   .Message(message)
                   .ToJson());
        }
Ejemplo n.º 3
0
 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);
     }
 }
 public static Error.Types OnGetting(SiteSettings ss)
 {
     if (!ss.CanRead())
     {
         return(Error.Types.HasNotPermission);
     }
     return(Error.Types.None);
 }
Ejemplo n.º 5
0
 public static Error.Types OnReading(SiteSettings ss)
 {
     if (!DefinitionAccessor.Parameters.Service.ShowProfiles)
     {
         return(Error.Types.InvalidRequest);
     }
     return(ss.CanRead()
         ? Error.Types.None
         : Error.Types.HasNotPermission);
 }
Ejemplo n.º 6
0
        public static string Histories(SiteSettings ss, long wikiId)
        {
            var wikiModel = new WikiModel(ss, wikiId);

            ss.SetColumnAccessControls(wikiModel.Mine());
            var columns = ss.GetHistoryColumns(checkPermission: true);

            if (!ss.CanRead())
            {
                return(Error.Types.HasNotPermission.MessageJson());
            }
            var hb = new HtmlBuilder();

            hb.Table(
                attributes: new HtmlAttributes().Class("grid"),
                action: () => hb
                .THead(action: () => hb
                       .GridHeader(
                           columns: columns,
                           sort: false,
                           checkRow: false))
                .TBody(action: () =>
                       new WikiCollection(
                           ss: ss,
                           column: HistoryColumn(columns),
                           where : Rds.WikisWhere().WikiId(wikiModel.WikiId),
                           orderBy: Rds.WikisOrderBy().Ver(SqlOrderBy.Types.desc),
                           tableType: Sqls.TableTypes.NormalAndHistory)
                       .ForEach(wikiModelHistory => hb
                                .Tr(
                                    attributes: new HtmlAttributes()
                                    .Class("grid-row history not-link")
                                    .DataAction("History")
                                    .DataMethod("post")
                                    .DataVer(wikiModelHistory.Ver)
                                    .DataLatest(1, _using:
                                                wikiModelHistory.Ver == wikiModel.Ver),
                                    action: () => columns
                                    .ForEach(column => hb
                                             .TdValue(
                                                 ss: ss,
                                                 column: column,
                                                 wikiModel: wikiModelHistory))))));
            return(new WikisResponseCollection(wikiModel)
                   .Html("#FieldSetHistories", hb).ToJson());
        }
Ejemplo n.º 7
0
 public static SqlWhereCollection CanRead(SiteSettings ss, SqlWhereCollection where)
 {
     return(!ss.CanRead(site: true)
         ? where.Add(
                subLeft: Rds.SelectPermissions(
                    column: Rds.PermissionsColumn().PermissionsCount(),
                    where : Rds.PermissionsWhere()
                    .ReferenceId(raw: ss.IdColumnBracket())
                    .PermissionType(_operator: " & 1 = 1")
                    .Or(Rds.PermissionsWhere()
                        .GroupId_In(sub: Rds.SelectGroupMembers(
                                        column: Rds.GroupMembersColumn().GroupId(),
                                        where : Rds.GroupMembersWhere()
                                        .Add(raw: DeptOrUser("GroupMembers"))))
                        .Add(raw: DeptOrUser("Permissions")))),
                _operator: ">0")
         : where);
 }
Ejemplo n.º 8
0
        public static Error.Types OnEditing(SiteSettings ss, DeptModel deptModel)
        {
            switch (deptModel.MethodType)
            {
            case BaseModel.MethodTypes.Edit:
                return
                    (ss.CanRead() &&
                     deptModel.AccessStatus != Databases.AccessStatuses.NotFound
                            ? Error.Types.None
                            : Error.Types.NotFound);

            case BaseModel.MethodTypes.New:
                return(ss.CanCreate()
                        ? Error.Types.None
                        : Error.Types.HasNotPermission);

            default:
                return(Error.Types.NotFound);
            }
        }
Ejemplo n.º 9
0
        public static Error.Types OnEditing(SiteSettings ss, UserModel userModel)
        {
            if (!DefinitionAccessor.Parameters.Service.ShowProfiles)
            {
                return(Error.Types.InvalidRequest);
            }
            switch (userModel.MethodType)
            {
            case BaseModel.MethodTypes.Edit:
                return
                    (ss.CanRead() &&
                     userModel.AccessStatus != Databases.AccessStatuses.NotFound
                            ? Error.Types.None
                            : Error.Types.NotFound);

            case BaseModel.MethodTypes.New:
                return(ss.CanCreate()
                        ? Error.Types.None
                        : Error.Types.HasNotPermission);

            default:
                return(Error.Types.NotFound);
            }
        }
Ejemplo n.º 10
0
 public static Error.Types OnReading(SiteSettings ss)
 {
     return(ss.CanRead()
         ? Error.Types.None
         : Error.Types.HasNotPermission);
 }
Ejemplo n.º 11
0
        public static HtmlBuilder MainCommands(
            this HtmlBuilder hb,
            SiteSettings ss,
            long siteId,
            Versions.VerTypes verType,
            long referenceId  = 0,
            bool backButton   = true,
            bool updateButton = false,
            bool copyButton   = false,
            bool moveButton   = false,
            bool mailButton   = false,
            bool deleteButton = false,
            Action extensions = null)
        {
            return(hb.Div(id: "MainCommandsContainer", action: () => hb
                          .Div(id: "MainCommands", action: () =>
            {
                if (backButton)
                {
                    hb.Button(
                        controlId: "GoBack",
                        text: Displays.GoBack(),
                        controlCss: "button-icon",
                        accessKey: "q",
                        onClick: "$p.back();",
                        icon: "ui-icon-circle-arrow-w");
                }
                if (Routes.Action() == "new")
                {
                    hb.Button(
                        text: Displays.Create(),
                        controlCss: "button-icon validate",
                        accessKey: "s",
                        onClick: "$p.send($(this));",
                        icon: "ui-icon-disk",
                        action: "Create",
                        method: "post");
                }
                else if (ss.CanRead() && verType == Versions.VerTypes.Latest)
                {
                    hb
                    .Button(
                        text: Displays.Update(),
                        controlCss: "button-icon validate",
                        accessKey: "s",
                        onClick: "$p.send($(this));",
                        icon: "ui-icon-disk",
                        action: "Update",
                        method: "put",
                        _using: updateButton && ss.CanUpdate())
                    .Button(
                        text: Displays.Copy(),
                        controlCss: "button-icon open-dialog",
                        accessKey: "c",
                        onClick: "$p.openDialog($(this));",
                        icon: "ui-icon-copy",
                        selector: "#CopyDialog",
                        _using: copyButton && ss.CanCreate())
                    .Button(
                        text: Displays.Move(),
                        controlCss: "button-icon open-dialog",
                        accessKey: "o",
                        onClick: "$p.moveTargets($(this));",
                        icon: "ui-icon-transferthick-e-w",
                        selector: "#MoveDialog",
                        action: "MoveTargets",
                        method: "get",
                        _using: moveButton && ss.CanUpdate())
                    .Button(
                        controlId: "EditOutgoingMail",
                        text: Displays.Mail(),
                        controlCss: "button-icon",
                        onClick: "$p.openOutgoingMailDialog($(this));",
                        icon: "ui-icon-mail-closed",
                        action: "Edit",
                        method: "put",
                        accessKey: "m",
                        _using: mailButton && ss.CanSendMail())
                    .Button(
                        text: Displays.Delete(),
                        controlCss: "button-icon",
                        accessKey: "r",
                        onClick: "$p.send($(this));",
                        icon: "ui-icon-trash",
                        action: "Delete",
                        method: "delete",
                        confirm: "ConfirmDelete",
                        _using: deleteButton && ss.CanDelete() && !ss.IsSite())
                    .Button(
                        text: Displays.DeleteSite(),
                        controlCss: "button-icon",
                        accessKey: "r",
                        onClick: "$p.openDeleteSiteDialog($(this));",
                        icon: "ui-icon-trash",
                        _using: deleteButton && ss.CanDelete() && ss.IsSite());
                    if (Routes.Controller() == "items" && ss.ReferenceType != "Sites")
                    {
                        switch (Routes.Action())
                        {
                        case "index":
                            hb
                            .Button(
                                text: Displays.BulkMove(),
                                controlCss: "button-icon open-dialog",
                                accessKey: "o",
                                onClick: "$p.moveTargets($(this));",
                                icon: "ui-icon-transferthick-e-w",
                                selector: "#MoveDialog",
                                action: "MoveTargets",
                                method: "get",
                                _using: ss.CanUpdate())
                            .Button(
                                text: Displays.BulkDelete(),
                                controlCss: "button-icon",
                                accessKey: "r",
                                onClick: "$p.send($(this));",
                                icon: "ui-icon-trash",
                                action: "BulkDelete",
                                method: "delete",
                                confirm: "ConfirmDelete",
                                _using: ss.CanDelete())
                            .Button(
                                controlId: "EditImportSettings",
                                text: Displays.Import(),
                                controlCss: "button-icon",
                                accessKey: "w",
                                onClick: "$p.openImportSettingsDialog($(this));",
                                icon: "ui-icon-arrowreturnthick-1-e",
                                selector: "#ImportSettingsDialog",
                                _using: ss.CanImport())
                            .Button(
                                text: Displays.Export(),
                                controlCss: "button-icon",
                                accessKey: "x",
                                onClick: "$p.openExportSelectorDialog($(this));",
                                icon: "ui-icon-arrowreturnthick-1-w",
                                action: "OpenExportSelectorDialog",
                                method: "post",
                                _using: ss.CanExport());
                            break;

                        case "crosstab":
                            hb.Button(
                                text: Displays.Export(),
                                controlCss: "button-icon",
                                accessKey: "x",
                                onClick: "$p.exportCrosstab();",
                                icon: "ui-icon-arrowreturnthick-1-w",
                                _using: ss.CanExport());
                            break;
                        }
                    }
                }
                extensions?.Invoke();
            })));
        }