public static GetCurrentUsername ( ) : string | ||
return | string |
/// <summary> /// Returns a value indicating whether the current user can manage categories in the selected namespace. /// </summary> /// <returns><c>true</c> if the user can manage categories, <c>false</c> otherwise.</returns> private bool CanManageCategoriesInCurrentNamespace() { string currentWiki = DetectWiki(); NamespaceInfo nspace = Pages.FindNamespace(currentWiki, lstNamespace.SelectedValue); AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki)); bool canManageCategories = authChecker.CheckActionForNamespace(nspace, Actions.ForNamespaces.ManageCategories, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki)); return(canManageCategories); }
/// <summary> /// Sets up the buttons visibility based on the current user's permissions. /// </summary> /// <param name="wiki">The wiki.</param> private void SetupButtonsVisibility(string currentWiki) { string currentUser = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki); // Categories (can manage categories in at least one NS) lnkSelectCategories.Visible = CanManageCategories(currentUser, currentGroups); // Configuration (can manage config) lnkSelectConfig.Visible = CanManageConfiguration(currentUser, currentGroups); // Content (can manage config) lnkSelectContent.Visible = CanManageMetaFiles(currentUser, currentGroups); // Groups (can manage groups) lnkSelectGroups.Visible = CanManageGroups(currentUser, currentGroups); // Home (can manage config) lnkSelectAdminHome.Visible = CanManageConfiguration(currentUser, currentGroups); // Namespaces (can manage namespaces) lnkSelectNamespaces.Visible = CanManageNamespaces(currentUser, currentGroups); // Nav. Paths (can manage pages in at least one NS) lnkSelectNavPaths.Visible = CanManagePages(currentUser, currentGroups); // Pages // Always displayed because checking every page can take too much time // Providers (can manage providers) lnkSelectPluginsConfiguration.Visible = CanManageProviders(currentUser, currentGroups); // Snippets (can manage snippets) lnkSelectSnippets.Visible = CanManageSnippetsAndTemplates(currentUser, currentGroups); // Accounts (can manage user accounts) lnkSelectAccounts.Visible = CanManageUsers(currentUser, currentGroups); // Log (can manage config) lnkSelectLog.Visible = CanManageGlobalConfiguration(currentUser, currentGroups); // Global Home (can manage global config) lnkSelectAdminGlobalHome.Visible = CanManageGlobalConfiguration(currentUser, currentGroups); // Global Configuration (can manage global config) lnkSelectGlobalConfig.Visible = CanManageGlobalConfiguration(currentUser, currentGroups); // Providers Management (can manage global config) lnkSelectPluginsManagement.Visible = CanManageGlobalConfiguration(currentUser, currentGroups); // Import export (can manage global config) lnkSelectImportExport.Visible = CanManageGlobalConfiguration(currentUser, currentGroups); }
/// <summary> /// Prepares the title of an item for display. /// </summary> /// <param name="title">The input title.</param> /// <param name="forIndexing">A value indicating whether the formatting is being done for content indexing.</param> /// <param name="context">The context information.</param> /// <param name="current">The current page, if any.</param> /// <returns>The prepared title, properly sanitized.</returns> public static string PrepareTitle(string title, bool forIndexing, FormattingContext context, PageInfo current) { var temp = title; var info = new ContextInformation(forIndexing, false, context, current, System.Threading.Thread.CurrentThread.CurrentCulture.Name, HttpContext.Current, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()); foreach (IFormatterProviderV30 prov in GetSortedFormatters()) { temp = prov.PrepareTitle(temp, info); } return(PrepareItemTitle(temp)); }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); string currentWiki = DetectWiki(); if (!AdminMaster.CanManageGlobalConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki))) { UrlTools.Redirect("AccessDenied.aspx"); } PrintSystemStatus(); }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageNamespaces(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(DetectWiki()))) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { rptNamespaces.DataBind(); } }
/// <summary> /// Detects the permissions of the current user for the current directory. /// </summary> private void DetectPermissions() { var currentUser = SessionFacade.GetCurrentUsername(); var currentGroups = SessionFacade.GetCurrentGroupNames(); canList = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.List, currentUser, currentGroups); canDownload = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DownloadFiles, currentUser, currentGroups); canUpload = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.UploadFiles, currentUser, currentGroups); canCreateDirs = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.CreateDirectories, currentUser, currentGroups); canDeleteFiles = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DeleteFiles, currentUser, currentGroups); canDeleteDirs = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DeleteDirectories, currentUser, currentGroups); canSetPerms = AuthChecker.CheckActionForGlobals(Actions.ForGlobals.ManagePermissions, currentUser, currentGroups); isAdmin = currentGroups.Contains(Settings.AdministratorsGroup); }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageSnippetsAndTemplates(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { // Load snippets rptSnippetsTemplates.DataBind(); } }
/// <summary> /// Detects the permissions of the current user for the current directory. /// </summary> private void DetectPermissions() { string currentUser = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(); canList = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.List, currentUser, currentGroups); canDownload = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DownloadFiles, currentUser, currentGroups); canUpload = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.UploadFiles, currentUser, currentGroups); canCreateDirs = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.CreateDirectories, currentUser, currentGroups); canDeleteFiles = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DeleteFiles, currentUser, currentGroups); canDeleteDirs = AuthChecker.CheckActionForDirectory(provider, CurrentDirectory, Actions.ForDirectories.DeleteDirectories, currentUser, currentGroups); canSetPerms = AuthChecker.CheckActionForGlobals(Actions.ForGlobals.ManagePermissions, currentUser, currentGroups); isAdmin = Array.Find(currentGroups, delegate(string g) { return(g == Settings.AdministratorsGroup); }) != null; }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { // Load log entries rptLog.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { string currentWiki = Tools.DetectCurrentWiki(); Response.ClearContent(); Response.ContentType = "text/xml;charset=UTF-8"; Response.ContentEncoding = System.Text.UTF8Encoding.UTF8; string mainUrl = Settings.GetMainUrl(currentWiki); string rootDefault = Settings.GetDefaultPage(currentWiki).ToLowerInvariant(); using (XmlWriter writer = XmlWriter.Create(Response.OutputStream)) { writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); writer.WriteAttributeString("xsi", "schemaLocation", null, "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd"); string user = SessionFacade.GetCurrentUsername(); string[] groups = SessionFacade.GetCurrentGroupNames(currentWiki); AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki)); foreach (PageContent page in Pages.GetPages(currentWiki, null)) { if (authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ReadPage, user, groups)) { WritePage(mainUrl, page.FullName, page.FullName.ToLowerInvariant() == rootDefault, writer); } } foreach (NamespaceInfo nspace in Pages.GetNamespaces(currentWiki)) { string nspaceDefault = nspace.DefaultPageFullName.ToLowerInvariant(); foreach (PageContent page in Pages.GetPages(currentWiki, nspace)) { if (authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ReadPage, user, groups)) { WritePage(mainUrl, page.FullName, page.FullName.ToLowerInvariant() == nspaceDefault, writer); } } } writer.WriteEndElement(); writer.WriteEndDocument(); } }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageProviders(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { lblResult.CssClass = ""; lblResult.Text = ""; // Load providers and related data rptProviders.DataBind(); } }
protected void lstNamespace_SelectedIndexChanged(object sender, EventArgs e) { currentPages = GetPages(); pageSelector.ItemCount = currentPages.Count; pageSelector.SelectPage(0); rptPages.DataBind(); var currentUser = SessionFacade.GetCurrentUsername(); var currentGroups = SessionFacade.GetCurrentGroupNames(); var canManageAllPages = AuthChecker.CheckActionForNamespace( Pages.FindNamespace(lstNamespace.SelectedValue), Actions.ForNamespaces.ManagePages, currentUser, currentGroups); btnBulkMigrate.Enabled = canManageAllPages; }
protected void Page_Load(object sender, EventArgs e) { currentWiki = DetectWiki(); AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageGlobalConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki))) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { LoadWikis(); LoadDestinationStorageProviders(); } }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); currentWiki = DetectWiki(); if (!AdminMaster.CanManageProviders(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki))) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { // Load themes and related data LoadThemes(); } }
protected void Page_Load(object sender, EventArgs e) { Response.ClearContent(); Response.ContentType = "text/xml;charset=UTF-8"; Response.ContentEncoding = System.Text.UTF8Encoding.UTF8; var mainUrl = Settings.MainUrl; var rootDefault = Settings.DefaultPage.ToLowerInvariant(); using (var writer = XmlWriter.Create(Response.OutputStream)) { writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance"); writer.WriteAttributeString("xsi", "schemaLocation", null, "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd"); var user = SessionFacade.GetCurrentUsername(); var groups = SessionFacade.GetCurrentGroupNames(); foreach (PageInfo page in Pages.GetPages(null)) { if (AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadPage, user, groups)) { WritePage(mainUrl, page, page.FullName.ToLowerInvariant() == rootDefault, writer); } } foreach (NamespaceInfo nspace in Pages.GetNamespaces()) { var nspaceDefault = nspace.DefaultPage.FullName.ToLowerInvariant(); foreach (PageInfo page in Pages.GetPages(nspace)) { if (AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadPage, user, groups)) { WritePage(mainUrl, page, page.FullName.ToLowerInvariant() == nspaceDefault, writer); } } } writer.WriteEndElement(); writer.WriteEndDocument(); } }
/// <summary> /// Enters a sub-directory of the current directory. /// </summary> /// <param name="name">The name of the current directory.</param> private void EnterDirectory(string name) { string newDirectory = CurrentDirectory + name + "/"; bool canListThisSubDir = AuthChecker.CheckActionForDirectory(provider, newDirectory, Actions.ForDirectories.List, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()); if (!canListThisSubDir) { return; } CurrentDirectory += name + "/"; DetectPermissions(); SetupControlsForPermissions(); rptItems.DataBind(); PopulateBreadcrumb(); }
protected void btnExportAll_Click(object sender, EventArgs e) { Log.LogEntry("Data export requested.", EntryType.General, SessionFacade.GetCurrentUsername(), lstWiki.SelectedValue); string tempDir = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempDir); string zipFileName = Path.Combine(tempDir, "Backup.zip"); int numberOfRevisions = -1; int.TryParse(txtRevisions.Text, out numberOfRevisions); if (numberOfRevisions > 0) { bool backupFileSucceded = BackupRestore.BackupRestore.BackupAll(numberOfRevisions, zipFileName, lstWiki.SelectedValue, GlobalSettings.Provider.ListPluginAssemblies(), Collectors.CollectorsBox.GetSettingsProvider(lstWiki.SelectedValue), (from p in Collectors.CollectorsBox.PagesProviderCollector.GetAllProviders(lstWiki.SelectedValue) where !p.ReadOnly select p).ToArray(), (from p in Collectors.CollectorsBox.UsersProviderCollector.GetAllProviders(lstWiki.SelectedValue) where IsUsersProviderFullWriteEnabled(p) select p).ToArray(), (from p in Collectors.CollectorsBox.FilesProviderCollector.GetAllProviders(lstWiki.SelectedValue) where !p.ReadOnly select p).ToArray()); FileInfo file = new FileInfo(zipFileName); Response.Clear(); Response.AddHeader("content-type", GetMimeType(zipFileName)); Response.AddHeader("content-disposition", "attachment;filename=\"Backup-" + lstWiki.SelectedValue + ".zip\""); Response.AddHeader("content-length", file.Length.ToString()); Response.TransmitFile(zipFileName); Response.Flush(); Directory.Delete(tempDir, true); Log.LogEntry("Data export completed.", EntryType.General, SessionFacade.GetCurrentUsername(), lstWiki.SelectedValue); } else { lblImportBackupResult.CssClass = "resulterror"; lblImportBackupResult.Text = Properties.Messages.VoidOrInvalidFile; } }
protected void btnReject_Click(object sender, EventArgs e) { PageInfo page = Pages.FindPage(txtCurrentPage.Value); if (!AdminMaster.CanApproveDraft(page, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { return; } Log.LogEntry("Page draft reject requested for " + page.FullName, EntryType.General, SessionFacade.CurrentUsername); Pages.DeleteDraft(page); lblApproveResult.CssClass = "resultok"; lblApproveResult.Text = Properties.Messages.DraftRejected; lblDraftPreview.Text = ""; ReturnToList(); }
protected void btnDeleteBackups_Click(object sender, EventArgs e) { PageInfo page = Pages.FindPage(txtCurrentPage.Value); if (!AuthChecker.CheckActionForPage(page, Actions.ForPages.ManagePage, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { return; } int targetRevision = -1; // This should never occur if (!int.TryParse(lstBackup.SelectedValue, out targetRevision)) { return; } Log.LogEntry("Page backup deletion requested for " + txtCurrentPage.Value, EntryType.General, Log.SystemUsername); bool done = false; if (rdoAllBackups.Checked) { done = Pages.DeleteBackups(page); } else { done = Pages.DeleteBackups(page, targetRevision); } if (done) { RefreshList(); lblBackupResult.CssClass = "resultok"; lblBackupResult.Text = Properties.Messages.PageBackupsDeleted; ReturnToList(); } else { lblBackupResult.CssClass = "resulterror"; lblBackupResult.Text = Properties.Messages.CouldNotDeletePageBackups; } }
/// <summary> /// Detects the permissions of the current user. /// </summary> private void DetectPermissions() { if (CurrentPage != null) { string currentUser = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(); canDownload = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.DownloadAttachments, currentUser, currentGroups); canUpload = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.UploadAttachments, currentUser, currentGroups); canDelete = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.DeleteAttachments, currentUser, currentGroups); isAdmin = Array.Find(currentGroups, delegate(string g) { return(g == Settings.AdministratorsGroup); }) != null; } else { canDownload = false; canUpload = false; canDelete = false; isAdmin = false; } lstProviders.Visible = isAdmin; }
protected void rptPages_ItemCommand(object sender, RepeaterCommandEventArgs e) { txtCurrentPage.Value = e.CommandArgument as string; if (e.CommandName == "Select") { // Permissions are checked in ActivatePageEditor() ActivatePageEditor(); } else if (e.CommandName == "Perms") { if (!AdminMaster.CanManagePermissions(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { return; } ActivatePagePermissionsManager(); } }
/// <summary> /// Detects the permissions of the current user. /// </summary> private void DetectPermissions() { if (CurrentPage != null) { var currentUser = SessionFacade.GetCurrentUsername(); var currentGroups = SessionFacade.GetCurrentGroupNames(); canDownload = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.DownloadAttachments, currentUser, currentGroups); canUpload = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.UploadAttachments, currentUser, currentGroups); canDelete = AuthChecker.CheckActionForPage(CurrentPage, Actions.ForPages.DeleteAttachments, currentUser, currentGroups); isAdmin = currentGroups.Contains(Settings.AdministratorsGroup); } else { canDownload = false; canUpload = false; canDelete = false; isAdmin = false; } lstProviders.Visible = isAdmin; }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageNamespaces(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { rptNamespaces.DataBind(); // Populate themes string[] themes = Tools.AvailableThemes; foreach (string theme in themes) { lstTheme.Items.Add(new ListItem(theme, theme)); } } }
/// <summary> /// Verifies read permissions for the current user, redirecting to the appropriate page if no valid permissions are found. /// </summary> public static void VerifyReadPermissionsForCurrentNamespace() { var currentUsername = SessionFacade.GetCurrentUsername(); var currentGroups = SessionFacade.GetCurrentGroupNames(); var canViewNamespace = AuthChecker.CheckActionForNamespace( Tools.DetectCurrentNamespaceInfo(), Actions.ForNamespaces.ReadPages, currentUsername, currentGroups); if (!canViewNamespace) { if (SessionFacade.CurrentUsername == null) { UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed())); } else { UrlTools.Redirect("AccessDenied.aspx"); } } }
protected void lstNamespace_SelectedIndexChanged(object sender, EventArgs e) { NamespaceInfo nspace = Pages.FindNamespace(currentWiki, lstNamespace.SelectedValue); currentPages = GetPages(nspace); pageSelector.ItemCount = currentPages.Count; pageSelector.SelectPage(0); rptPages.DataBind(); string currentUser = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki); AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki)); bool canManageAllPages = authChecker.CheckActionForNamespace( Pages.FindNamespace(currentWiki, lstNamespace.SelectedValue), Actions.ForNamespaces.ManagePages, currentUser, currentGroups); btnBulkMigrate.Enabled = canManageAllPages; }
/// <summary> /// Loads target namespaces for bulk migration. /// </summary> private void LoadTargetNamespaces() { // Load valid namespaces, filtering the current one lstBulkMigrateTargetNamespace.Items.Clear(); bool canManageAllPages = false; string currentUser = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki); AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki)); if (!string.IsNullOrEmpty(lstNamespace.SelectedValue)) { // Root namespace canManageAllPages = authChecker.CheckActionForNamespace(null, Actions.ForNamespaces.ManagePages, currentUser, currentGroups); if (canManageAllPages) { lstBulkMigrateTargetNamespace.Items.Add(new ListItem("<root>", ".")); } } foreach (NamespaceInfo ns in Pages.GetNamespaces(currentWiki).FindAll(n => n.Provider.GetType().FullName == providerSelector.SelectedProvider)) { // All sub-namespaces if (ns.Name != lstNamespace.SelectedValue) { canManageAllPages = authChecker.CheckActionForNamespace(ns, Actions.ForNamespaces.ManagePages, currentUser, currentGroups); if (canManageAllPages) { lstBulkMigrateTargetNamespace.Items.Add(new ListItem(ns.Name, ns.Name)); } } } }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); var currentUser = SessionFacade.GetCurrentUsername(); var currentGroups = SessionFacade.GetCurrentGroupNames(); if (!AdminMaster.CanManageGroups(currentUser, currentGroups)) { UrlTools.Redirect("AccessDenied.aspx"); } aclActionsSelector.Visible = AdminMaster.CanManagePermissions(currentUser, currentGroups); revName.ValidationExpression = Settings.UsernameRegex; if (!Page.IsPostBack) { rptGroups.DataBind(); providerSelector.Reload(); btnNewGroup.Enabled = providerSelector.HasProviders; } }
protected void Page_Load(object sender, EventArgs e) { AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageMetaFiles(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("AccessDenied.aspx"); } if (!Page.IsPostBack) { // Load namespaces // Add root namespace lstNamespace.Items.Add(new ListItem("<root>", "")); List <NamespaceInfo> namespaces = Pages.GetNamespaces(); foreach (NamespaceInfo ns in namespaces) { lstNamespace.Items.Add(new ListItem(ns.Name, ns.Name)); } } }
protected void Page_Load(object sender, EventArgs e) { var context = this.Context; context.Response.ContentType = "text/plain"; AdminMaster.RedirectToLoginIfNeeded(); if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames())) { UrlTools.Redirect("~/AccessDenied.aspx"); } var qs = context.Request.QueryString; var ns = qs["NS"]; var nspace = Pages.GetNamespaces().FirstOrDefault(x => x.Name == ns); if (nspace == null) { context.Response.Write(string.Format("Namespace \"{0}\" not found", ns)); return; } // Liste des pages orphelines var candidates = Pages.GetOrphanedPages(nspace) // récupération contenu .Select(p => new { PageInfo = p, PageContent = p.Provider.GetContent(p) }) // qui n'ont pas été modifées depuis plus d'un mois .Where(p => p.PageContent != null && p.PageContent.LastModified < DateTime.Today.AddMonths(-1)) .OrderBy(p => p.PageInfo.FullName); foreach (var candidate in candidates) { context.Response.Write(string.Format("[url=/Wiki/{0}.ashx]{0}[/url] \"{1}\"\r\n", candidate.PageInfo.FullName, candidate.PageContent.Title)); } }
/// <summary> /// Verifies read permissions for the current user, redirecting to the appropriate page if no valid permissions are found. /// </summary> public static void VerifyReadPermissionsForCurrentNamespace() { string currentUsername = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(); bool canViewNamespace = AuthChecker.CheckActionForNamespace( Tools.DetectCurrentNamespaceInfo(), Actions.ForNamespaces.ReadPages, currentUsername, currentGroups); if (!canViewNamespace) { if (SessionFacade.CurrentUsername == null) { UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(HttpContext.Current.Request.Url.ToString())); } else { UrlTools.Redirect("AccessDenied.aspx"); } } }