-
Notifications
You must be signed in to change notification settings - Fork 11
/
PrinterFriendly.aspx.cs
160 lines (138 loc) · 6.07 KB
/
PrinterFriendly.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// <copyright file="PrinterFriendly.aspx.cs" company="Engage Software">
// Engage: Publish
// Copyright (c) 2004-2013
// by Engage Software ( http://www.engagesoftware.com )
// </copyright>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace Engage.Dnn.Publish
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Web;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using Engage.Dnn.Publish.Util;
public partial class PrinterFriendly : PageBase
{
public string CssStyle = "module.css";
public static string ApplicationUrl
{
get { return HttpContext.Current.Request.ApplicationPath == "/" ? string.Empty : HttpContext.Current.Request.ApplicationPath; }
}
public int ItemId
{
get
{
object i = this.Request.Params["itemId"];
if (i != null)
{
// look up the itemType if ItemId passed in.
this.ItemType = Item.GetItemType(Convert.ToInt32(i, CultureInfo.InvariantCulture)).ToUpperInvariant();
return Convert.ToInt32(i, CultureInfo.InvariantCulture);
}
return -1;
}
}
public string ItemType { get; set; }
public int PortalId
{
get
{
object i = this.Request.Params["portalId"];
if (i != null)
{
return Convert.ToInt32(i, CultureInfo.InvariantCulture);
}
return -1;
}
}
public int TabId
{
get
{
string value = this.Request.QueryString["TabId"];
int tabId;
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out tabId))
{
return tabId;
}
return -1;
}
}
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Method has side effect of setting public member CssStyle")]
protected string GetCssStyle()
{
var ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
this.CssStyle = ps.ActiveTab.SkinPath + "skin.css";
return this.CssStyle;
}
protected override void OnInit(EventArgs e)
{
this.Load += this.Page_Load;
base.OnInit(e);
}
private void Page_Load(object sender, EventArgs e)
{
try
{
Article a = Article.GetArticle(this.ItemId, this.PortalId);
if (a != null && ((!a.ForceDisplayOnPage() && this.UserHasRights(this.TabId)) || this.UserHasRights(a.DisplayTabId)))
{
this.lblArticleTitle.Text = this.pageTitle.Text = a.Name;
this.lblArticleText.Text = a.ArticleText.Replace("[PAGE]", string.Empty);
// TODO: configure this page to allow for displaying author, date, etc based on the itemversionsettings
// ItemVersionSetting auSetting = ItemVersionSetting.GetItemVersionSetting(article.ItemVersionId, "pnlAuthor", "Visible", PortalId);
// if (auSetting != null)
// {
// ShowAuthor = Convert.ToBoolean(auSetting.PropertyValue, CultureInfo.InvariantCulture);
// }
this.lnkPortalLogo.NavigateUrl = "http://" + this.PortalSettings.PortalAlias.HTTPAlias;
this.lnkPortalLogo.ImageUrl = this.PortalSettings.HomeDirectory + this.PortalSettings.LogoFile;
this.CssStyle = this.PortalSettings.ActiveTab.SkinPath + "skin.css";
}
else
{
this.lblArticleTitle.Text = this.pageTitle.Text = Localization.GetString("Permission", this.LocalResourceFile);
}
}
catch (Exception exc)
{
Exceptions.ProcessPageLoadException(exc);
}
}
private bool UserHasRights(int tabId)
{
var modules = new ModuleController();
Dictionary<int, ModuleInfo> tabModules = modules.GetTabModules(tabId);
foreach (ModuleInfo module in tabModules.Values)
{
if (module.DesktopModule.FriendlyName.Equals(Utility.DnnFriendlyModuleName))
{
bool overrideable;
object overrideableObj = modules.GetTabModuleSettings(module.TabModuleID)["Overrideable"];
if (overrideableObj != null && bool.TryParse(overrideableObj.ToString(), out overrideable) && overrideable)
{
// keep checking until there is an overrideable module that the user is authorized to see. BD
if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.View, string.Empty, module))
{
return true;
}
}
}
}
return false;
}
}
}