/
View.ascx.cs
135 lines (128 loc) · 5.43 KB
/
View.ascx.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
/*
' Copyright (c) 2014 Plugghest.com
' All rights reserved.
'
' 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.
'
*/
using System;
using System.Web.UI.WebControls;
using Plugghest.Modules.ActionFormReceiver.Components;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.Utilities;
using System.Collections.Specialized;
using Plugghest.Base2;
using System.Web;
using System.Text.RegularExpressions;
namespace Plugghest.Modules.ActionFormReceiver
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The View class displays the content
///
/// Typically your view control would be used to display content or functionality in your module.
///
/// View may be the only control you have in your project depending on the complexity of your module
///
/// Because the control inherits from ActionFormReceiverModuleBase you have access to any custom properties
/// defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
///
/// </summary>
/// -----------------------------------------------------------------------------
public partial class View : PortalModuleBase, IActionable
{
public NameValueCollection nvc;
protected void Page_Load(object sender, EventArgs e)
{
try
{
nvc = Request.Form;
switch (nvc["FormType"])
{
case "CreatePlugg":
CreatePlugg();
break;
case "CreateCourse":
CreateCourse();
break;
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void CreatePlugg()
{
string cultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
PluggContainer pc = new PluggContainer(cultureCode);
pc.ThePlugg.CreatedByUserId = UserId;
pc.ThePlugg.ModifiedByUserId = UserId;
pc.ThePlugg.PluggId = 0;
pc.ThePlugg.CreatedInCultureCode = cultureCode;
pc.SetTitle(Regex.Replace(nvc["Title"], "<[^>]*>", String.Empty));
//string subjectStr = Page.Request.QueryString["s"];
//if (subjectStr != null)
//{
// int subid = Convert.ToInt32(subjectStr);
// pc.ThePlugg.SubjectId = subid;
//}
//else
// pc.ThePlugg.SubjectId = 0;
pc.ThePlugg.SubjectId = 0;
if (nvc["Description"] != "")
pc.SetDescription(Regex.Replace(nvc["Description"], "<[^>]*>", String.Empty));
pc.ThePlugg.WhoCanEdit = EWhoCanEdit.Anyone;
BaseHandler bh = new BaseHandler();
bh.CreateBasicPlugg(pc);
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(pc.ThePlugg.TabId, "", "edit=0"));
}
private void CreateCourse()
{
string cultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
CourseContainer cc = new CourseContainer(cultureCode);
cc.TheCourse.CreatedByUserId = UserId;
cc.TheCourse.ModifiedByUserId = UserId;
cc.TheCourse.CourseId = 0;
cc.TheCourse.CreatedInCultureCode = cultureCode;
cc.SetTitle(Regex.Replace(nvc["Title"], "<[^>]*>", String.Empty));
//string subjectStr = Page.Request.QueryString["s"];
//if (subjectStr != null)
//{
// int subid = Convert.ToInt32(subjectStr);
// pc.ThePlugg.SubjectId = subid;
//}
//else
// pc.ThePlugg.SubjectId = 0;
cc.TheCourse.SubjectId = 0;
if (nvc["Description"] != "")
cc.SetDescription(Regex.Replace(nvc["Description"], "<[^>]*>", String.Empty));
cc.TheCourse.WhoCanEdit = EWhoCanEdit.Anyone;
BaseHandler bh = new BaseHandler();
bh.CreateCourse(cc);
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "edit=0"));
}
public ModuleActionCollection ModuleActions
{
get
{
var actions = new ModuleActionCollection
{
{
GetNextActionID(), Localization.GetString("EditModule", LocalResourceFile), "", "", "",
EditUrl(), false, SecurityAccessLevel.Edit, true, false
}
};
return actions;
}
}
}
}