forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucSubmitNews.ascx.vb
executable file
·2221 lines (1688 loc) · 112 KB
/
ucSubmitNews.ascx.vb
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.UI.UserControls
Imports DotNetNuke.Security.Roles
Imports Ventrian.NewsArticles.Components.Social
Imports Ventrian.NewsArticles.Components.CustomFields
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Services.FileSystem
Imports DotNetNuke.Security.Permissions
Imports System.IO
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ucSubmitNews
Inherits NewsArticleModuleBase
#Region " Private Members "
Private _articleID As Integer = Null.NullInteger
Private _returnUrl As String = Null.NullString
Private _richTextValues As New NameValueCollection
#End Region
#Region " Private Properties "
Private Property PublishDate(ByVal defaultHour As Integer, ByVal defaultMinute As Integer) As DateTime
Get
Dim year As Integer = Convert.ToDateTime(txtPublishDate.Text).Year
Dim month As Integer = Convert.ToDateTime(txtPublishDate.Text).Month
Dim day As Integer = Convert.ToDateTime(txtPublishDate.Text).Day
Dim hour As Integer = defaultHour
If (IsNumeric(txtPublishHour.Text)) Then
If (hour >= 0 And hour <= 23) Then
hour = Convert.ToInt32(txtPublishHour.Text)
End If
End If
Dim minute As Integer = defaultMinute
If (IsNumeric(txtPublishMinute.Text)) Then
If (minute >= 0 And minute <= 60) Then
minute = Convert.ToInt32(txtPublishMinute.Text)
End If
End If
Return New DateTime(year, month, day, hour, minute, 0)
End Get
Set(ByVal Value As DateTime)
txtPublishHour.Text = Value.Hour.ToString()
txtPublishMinute.Text = Value.Minute.ToString()
txtPublishDate.Text = New DateTime(Value.Year, Value.Month, Value.Day).ToShortDateString()
End Set
End Property
Private Property ExpiryDate(ByVal defaultHour As Integer, ByVal defaultMinute As Integer) As DateTime
Get
If (txtExpiryDate.Text.Length = 0) Then
Return Null.NullDate
End If
Dim year As Integer = Convert.ToDateTime(txtExpiryDate.Text).Year
Dim month As Integer = Convert.ToDateTime(txtExpiryDate.Text).Month
Dim day As Integer = Convert.ToDateTime(txtExpiryDate.Text).Day
Dim hour As Integer = defaultHour
If (IsNumeric(txtExpiryHour.Text)) Then
If (hour >= 0 And hour <= 23) Then
hour = Convert.ToInt32(txtExpiryHour.Text)
End If
End If
Dim minute As Integer = defaultMinute
If (IsNumeric(txtExpiryMinute.Text)) Then
If (minute >= 0 And minute <= 60) Then
minute = Convert.ToInt32(txtExpiryMinute.Text)
End If
End If
Return New DateTime(year, month, day, hour, minute, 0)
End Get
Set(ByVal Value As DateTime)
If (Value = Null.NullDate) Then
txtExpiryDate.Text = ""
Return
End If
txtExpiryHour.Text = Value.Hour.ToString()
txtExpiryMinute.Text = Value.Minute.ToString()
txtExpiryDate.Text = New DateTime(Value.Year, Value.Month, Value.Day).ToShortDateString()
End Set
End Property
Private ReadOnly Property Details() As TextEditor
Get
Return CType(txtDetails, TextEditor)
End Get
End Property
Private ReadOnly Property UrlLink() As UrlControl
Get
Return CType(ctlUrlLink, UrlControl)
End Get
End Property
Private ReadOnly Property ExcerptRich() As DotNetNuke.UI.UserControls.TextEditor
Get
Return CType(txtExcerptRich, TextEditor)
End Get
End Property
#End Region
#Region " Private Methods "
Private Function IsInRole(ByVal roleName As String, ByVal roles As String()) As Boolean
For Each role As String In roles
If (roleName = role) Then
Return True
End If
Next
Return False
End Function
Private Sub BindArticle()
If (_articleID <> Null.NullInteger) Then
Dim objArticleController As ArticleController = New ArticleController
Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID)
lblAuthor.Text = objArticle.AuthorDisplayName
txtTitle.Text = objArticle.Title
If (ArticleSettings.TextEditorSummaryMode = Components.Types.TextEditorModeType.Basic) Then
txtExcerptBasic.Text = objArticle.Summary.Replace("<br />", vbCrLf)
Else
ExcerptRich.Text = objArticle.Summary
End If
chkFeatured.Checked = objArticle.IsFeatured
chkSecure.Checked = objArticle.IsSecure
txtMetaTitle.Text = objArticle.MetaTitle
txtMetaDescription.Text = objArticle.MetaDescription
txtMetaKeyWords.Text = objArticle.MetaKeywords
txtPageHeadText.Text = objArticle.PageHeadText
If Not (drpStatus.Items.FindByValue(objArticle.Status.ToString()) Is Nothing) Then
drpStatus.SelectedValue = objArticle.Status.ToString()
End If
PublishDate(objArticle.StartDate.Hour, objArticle.EndDate.Minute) = objArticle.StartDate
If Not (objArticle.EndDate = Null.NullDate) Then
ExpiryDate(objArticle.EndDate.Hour, objArticle.EndDate.Minute) = objArticle.EndDate
End If
If (ArticleSettings.IsImagesEnabled) Then
If Not (objArticle.ImageUrl = Null.NullString) Then
If (objArticle.ImageUrl.ToLower().StartsWith("http://") Or objArticle.ImageUrl.ToLower().StartsWith("https://")) Then
If (ArticleSettings.EnableExternalImages) Then
ucUploadImages.ImageExternalUrl = objArticle.ImageUrl
End If
End If
End If
End If
UrlLink.Url = objArticle.Url
chkNewWindow.Checked = objArticle.IsNewWindow
Dim categories As ArrayList = objArticleController.GetArticleCategories(_articleID)
For Each category As CategoryInfo In categories
Dim li As ListItem = lstCategories.Items.FindByValue(category.CategoryID.ToString())
If Not (li Is Nothing) Then
li.Selected = True
End If
Next
txtTags.Text = objArticle.Tags
Dim objPageController As New PageController
Dim pages As ArrayList = objPageController.GetPageList(_articleID)
If (pages.Count > 0) Then
Details.Text = CType(pages(0), PageInfo).PageText
End If
cmdDelete.Visible = True
cmdDelete.OnClientClick = "return confirm('" & DotNetNuke.Services.Localization.Localization.GetString("Delete.Text", LocalResourceFile) & "');"
Dim objMirrorArticleController As New MirrorArticleController
Dim objMirrorArticleInfo As MirrorArticleInfo = objMirrorArticleController.GetMirrorArticle(_articleID)
If (objMirrorArticleInfo IsNot Nothing) Then
phMirrorText.Visible = True
If (objMirrorArticleInfo.AutoUpdate) Then
lblMirrorText.Text = Localization.GetString("MirrorTextUpdate", Me.LocalResourceFile)
If (lblMirrorText.Text.IndexOf("{0}") <> -1) Then
lblMirrorText.Text = lblMirrorText.Text.Replace("{0}", objMirrorArticleInfo.PortalName)
End If
phCreate.Visible = False
phOrganize.Visible = False
phPublish.Visible = False
cmdPublishArticle.Visible = False
cmdAddEditPages.Visible = False
Else
lblMirrorText.Text = Localization.GetString("MirrorText", Me.LocalResourceFile)
If (lblMirrorText.Text.IndexOf("{0}") <> -1) Then
lblMirrorText.Text = lblMirrorText.Text.Replace("{0}", objMirrorArticleInfo.PortalName)
End If
End If
End If
Dim objMirrorArticleLinked As ArrayList = objMirrorArticleController.GetMirrorArticleList(_articleID)
If (objMirrorArticleLinked.Count > 0) Then
phMirrorText.Visible = True
lblMirrorText.Text = Localization.GetString("MirrorTextLinked", Me.LocalResourceFile)
If (lblMirrorText.Text.IndexOf("{0}") <> -1) Then
lblMirrorText.Text = lblMirrorText.Text.Replace("{0}", objMirrorArticleLinked.Count.ToString())
End If
End If
Else
chkFeatured.Checked = ArticleSettings.IsAutoFeatured
chkSecure.Checked = ArticleSettings.IsAutoSecured
If (ArticleSettings.AuthorDefault <> Null.NullInteger) Then
Dim objUser As UserInfo = UserController.Instance.GetUser(PortalId, ArticleSettings.AuthorDefault)
If (objUser IsNot Nothing) Then
lblAuthor.Text = objUser.Username
Else
lblAuthor.Text = Me.UserInfo.Username
End If
Else
lblAuthor.Text = Me.UserInfo.Username
End If
PublishDate(DateTime.Now.Hour, DateTime.Now.Minute) = DateTime.Now
cmdDelete.Visible = False
If (Settings.Contains(ArticleConstants.DEFAULT_CATEGORIES_SETTING)) Then
If Not (Settings(ArticleConstants.DEFAULT_CATEGORIES_SETTING).ToString = Null.NullString) Then
Dim categories As String() = Settings(ArticleConstants.DEFAULT_CATEGORIES_SETTING).ToString().Split(Char.Parse(","))
For Each category As String In categories
If Not (lstCategories.Items.FindByValue(category) Is Nothing) Then
lstCategories.Items.FindByValue(category).Selected = True
End If
Next
End If
End If
End If
End Sub
Private Sub BindCategories()
Dim objCategoryController As CategoryController = New CategoryController
Dim objCategoriesSelected As New List(Of CategoryInfo)
Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(ModuleId, Null.NullInteger, ArticleSettings.CategorySortType)
If (ArticleSettings.CategoryFilterSubmit) Then
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim objSelectedCategories As New List(Of CategoryInfo)()
For Each objCategory As CategoryInfo In objCategories
If (objCategory.CategoryID = ArticleSettings.FilterSingleCategory) Then
objSelectedCategories.Add(objCategory)
Exit For
End If
Next
objCategories = objSelectedCategories
End If
If (ArticleSettings.FilterCategories IsNot Nothing) Then
If (ArticleSettings.FilterCategories.Length > 0) Then
Dim objSelectedCategories As New List(Of CategoryInfo)()
For Each i As Integer In ArticleSettings.FilterCategories
For Each objCategory As CategoryInfo In objCategories
If (objCategory.CategoryID = i) Then
objSelectedCategories.Add(objCategory)
Exit For
End If
Next
Next
objCategories = objSelectedCategories
End If
End If
End If
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity) Then
objCategoriesSelected.Add(objCategory)
Else
If (Request.IsAuthenticated) Then
If (Settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_SUBMIT_SETTING)) Then
If (PortalSecurity.IsInRoles(Settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_SUBMIT_SETTING).ToString())) Then
objCategoriesSelected.Add(objCategory)
End If
End If
End If
End If
Next
lstCategories.DataSource = objCategoriesSelected
lstCategories.DataBind()
If (Settings.Contains(ArticleConstants.REQUIRE_CATEGORY)) Then
valCategory.Enabled = Convert.ToBoolean(Settings(ArticleConstants.REQUIRE_CATEGORY).ToString())
End If
End Sub
Private Sub BindCustomFields()
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As ArrayList = objCustomFieldController.List(Me.ModuleId)
If (objCustomFields.Count = 0) Then
phCustomFields.Visible = False
Else
phCustomFields.Visible = True
rptCustomFields.DataSource = objCustomFields
rptCustomFields.DataBind()
End If
End Sub
Private Sub BindStatus()
For Each value As Integer In System.Enum.GetValues(GetType(StatusType))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(StatusType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(StatusType), value), Me.LocalResourceFile)
drpStatus.Items.Add(li)
Next
End Sub
Private Sub CheckSecurity()
If (HasEditRights(_articleID, Me.ModuleId, Me.TabId) = False) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End If
End Sub
Public Function GetAuthorList(ByVal moduleID As Integer) As ArrayList
Dim moduleSettings As Hashtable = Common.GetModuleSettings(moduleId)
Dim distributionList As String = ""
Dim userList As New ArrayList
If (moduleSettings.Contains(ArticleConstants.PERMISSION_SUBMISSION_SETTING)) Then
Dim roles As String = moduleSettings(ArticleConstants.PERMISSION_SUBMISSION_SETTING).ToString()
Dim rolesArray() As String = roles.Split(Convert.ToChar(";"))
Dim userIDs As New Hashtable
For Each role As String In rolesArray
If (role.Length > 0) Then
Dim objRoleController As New DotNetNuke.Security.Roles.RoleController
Dim objRole As DotNetNuke.Security.Roles.RoleInfo = objRoleController.GetRoleByName(PortalSettings.PortalId, role)
If Not (objRole Is Nothing) Then
Dim objUsers As List(Of UserInfo) = RoleController.Instance.GetUsersByRole(PortalSettings.PortalId, objRole.RoleName)
For Each objUser As UserInfo In objUsers
If (userIDs.Contains(objUser.UserID) = False) Then
Dim objUserController As DotNetNuke.Entities.Users.UserController = New DotNetNuke.Entities.Users.UserController
Dim objSelectedUser As DotNetNuke.Entities.Users.UserInfo = objUserController.GetUser(PortalSettings.PortalId, objUser.UserID)
If Not (objSelectedUser Is Nothing) Then
If (objSelectedUser.Email.Length > 0) Then
userIDs.Add(objUser.UserID, objUser.UserID)
userList.Add(objSelectedUser)
End If
End If
End If
Next
End If
End If
Next
End If
Return userList
End Function
Private Sub PopulateAuthorList()
ddlAuthor.DataSource = GetAuthorList(Me.ModuleId)
ddlAuthor.DataBind()
ddlAuthor.Items.Insert(0, New ListItem(Localization.GetString("SelectAuthor.Text", Me.LocalResourceFile), "-1"))
End Sub
Private Sub ReadQueryString()
If (Request("ArticleID") <> "") Then
If (IsNumeric(Request("ArticleID"))) Then
_articleID = Convert.ToInt32(Request("ArticleID"))
End If
End If
If (Request("ReturnUrl") <> "") Then
_returnUrl = Request("ReturnUrl")
End If
End Sub
Private Function SaveArticle() As Integer
If (_articleID <> Null.NullInteger) Then
Dim objArticleController As New ArticleController
Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID)
If Not (objArticle Is Nothing) Then
Return SaveArticle(objArticle.Status)
End If
Else
Return SaveArticle(StatusType.Draft)
End If
End Function
Private Function SaveArticle(ByVal status As StatusType) As Integer
Dim objArticleController As ArticleController = New ArticleController
Dim objArticle As ArticleInfo = New ArticleInfo
Dim statusChanged As Boolean = False
Dim publishArticle As Boolean = False
If (_articleID = Null.NullInteger) Then
If (pnlAuthor.Visible = False) Then
Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, lblAuthor.Text)
If (objUser IsNot Nothing) Then
objArticle.AuthorID = objUser.UserID
Else
objArticle.AuthorID = Me.UserId
End If
Else
Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, txtAuthor.Text)
If (objUser IsNot Nothing) Then
objArticle.AuthorID = objUser.UserID
Else
objArticle.AuthorID = Me.UserId
End If
End If
If (ddlAuthor.Visible) Then
objArticle.AuthorID = Convert.ToInt32(ddlAuthor.SelectedValue)
End If
objArticle.CreatedDate = DateTime.Now
objArticle.Status = StatusType.Draft
objArticle.CommentCount = 0
objArticle.RatingCount = 0
objArticle.Rating = 0
objArticle.ShortUrl = ""
Else
objArticle = objArticleController.GetArticle(_articleID)
objArticleController.DeleteArticleCategories(_articleID)
If (objArticle.Status <> StatusType.Published And status = StatusType.Published) Then
' Article now approved, notify if not an Approver.
If (objArticle.AuthorID <> Me.UserId) Then
statusChanged = True
End If
End If
If (pnlAuthor.Visible) Then
Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, txtAuthor.Text)
If (objUser IsNot Nothing) Then
objArticle.AuthorID = objUser.UserID
End If
End If
If (ddlAuthor.Visible) Then
objArticle.AuthorID = Convert.ToInt32(ddlAuthor.SelectedValue)
End If
End If
objArticle.MetaTitle = txtMetaTitle.Text.Trim()
objArticle.MetaDescription = txtMetaDescription.Text.Trim()
objArticle.MetaKeywords = txtMetaKeyWords.Text.Trim()
objArticle.PageHeadText = txtPageHeadText.Text.Trim()
If (chkMirrorArticle.Checked And drpMirrorArticle.Items.Count > 0) Then
Dim objLinkedArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(drpMirrorArticle.SelectedValue))
If (objLinkedArticle IsNot Nothing) Then
objArticle.Title = objLinkedArticle.Title
objArticle.Summary = objLinkedArticle.Summary
objArticle.Url = objLinkedArticle.Url
objArticle.IsNewWindow = objLinkedArticle.IsNewWindow
objArticle.ImageUrl = objLinkedArticle.ImageUrl
objArticle.MetaTitle = objLinkedArticle.MetaTitle
objArticle.MetaDescription = objLinkedArticle.MetaDescription
objArticle.MetaKeywords = objLinkedArticle.MetaKeywords
objArticle.PageHeadText = objLinkedArticle.PageHeadText
End If
Else
objArticle.Title = txtTitle.Text
If (ArticleSettings.TextEditorSummaryMode = Components.Types.TextEditorModeType.Basic) Then
objArticle.Summary = txtExcerptBasic.Text.Replace(vbCrLf, "<br />")
Else
If (ExcerptRich.Text <> "" AndAlso StripHtml(ExcerptRich.Text).Length > 0 AndAlso ExcerptRich.Text <> "<p>&#160;</p>") Then
objArticle.Summary = ExcerptRich.Text
Else
objArticle.Summary = Null.NullString
End If
End If
objArticle.Url = UrlLink.Url
objArticle.IsNewWindow = chkNewWindow.Checked
If (ArticleSettings.IsImagesEnabled = True) Then
objArticle.ImageUrl = ucUploadImages.ImageExternalUrl
End If
End If
objArticle.IsFeatured = chkFeatured.Checked
objArticle.IsSecure = chkSecure.Checked
objArticle.LastUpdate = DateTime.Now
objArticle.LastUpdateID = Me.UserId
objArticle.ModuleID = Me.ModuleId
objArticle.Status = status
If (objArticle.StartDate <> Null.NullDate) Then
objArticle.StartDate = PublishDate(objArticle.StartDate.Hour, objArticle.StartDate.Minute)
Else
objArticle.StartDate = PublishDate(DateTime.Now.Hour, DateTime.Now.Minute)
End If
If (ExpiryDate(0, 0) = Null.NullDate) Then
objArticle.EndDate = Null.NullDate
Else
If (objArticle.EndDate <> Null.NullDate) Then
objArticle.EndDate = ExpiryDate(objArticle.EndDate.Hour, objArticle.EndDate.Minute)
Else
objArticle.EndDate = ExpiryDate(0, 0)
End If
End If
If (_articleID = Null.NullInteger) Then
objArticle.ArticleID = objArticleController.AddArticle(objArticle)
ucUploadImages.UpdateImages(objArticle.ArticleID)
ucUploadFiles.UpdateFiles(objArticle.ArticleID)
objArticleController.UpdateArticle(objArticle)
If (chkMirrorArticle.Checked And drpMirrorArticle.Items.Count > 0) Then
' Mirrored Article
Dim objMirrorArticleInfo As New MirrorArticleInfo
objMirrorArticleInfo.ArticleID = objArticle.ArticleID
objMirrorArticleInfo.LinkedArticleID = Convert.ToInt32(drpMirrorArticle.SelectedValue)
objMirrorArticleInfo.LinkedPortalID = Convert.ToInt32(drpMirrorModule.SelectedValue.Split("-"c)(0))
objMirrorArticleInfo.AutoUpdate = chkMirrorAutoUpdate.Checked
Dim objMirrorArticleController As New MirrorArticleController()
objMirrorArticleController.AddMirrorArticle(objMirrorArticleInfo)
'Copy Files
Dim folderLinked As String = ""
Dim objModuleController As New ModuleController()
Dim objSettingsLinked As Hashtable = Common.GetModuleSettings(drpMirrorModule.SelectedValue.Split("-"c)(1))
If (objSettingsLinked.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then
If (IsNumeric(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folderLinked = objFolder.FolderPath
End If
End If
End If
Dim objPortalController As New PortalController
Dim objPortalLinked As PortalInfo = objPortalController.GetPortal(Convert.ToInt32(drpMirrorModule.SelectedValue.Split("-"c)(0)))
Dim filePathLinked As String = objPortalLinked.HomeDirectoryMapPath & folderLinked.Replace("/", "\")
Dim folder As String = ""
Dim objSettings As Hashtable = Common.GetModuleSettings(ModuleId)
If (objSettings.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then
If (IsNumeric(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folder = objFolder.FolderPath
End If
End If
End If
Dim objFileController As New FileController
Dim objFiles As List(Of FileInfo) = objFileController.GetFileList(objMirrorArticleInfo.LinkedArticleID, Null.NullString)
For Each objFile As FileInfo In objFiles
If (File.Exists(filePathLinked & objFile.FileName)) Then
Dim finalCopyPath = filePathLinked & objFile.FileName
Dim filePath As String = PortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\")
If Not (Directory.Exists(filePath)) Then
Directory.CreateDirectory(filePath)
End If
If (File.Exists(filePath & objFile.FileName)) Then
For i As Integer = 1 To 100
If (File.Exists(filePath & i.ToString() & "_" & objFile.FileName) = False) Then
objFile.FileName = i.ToString() & "_" & objFile.FileName
Exit For
End If
Next
End If
File.Copy(finalCopyPath, filePath & objFile.FileName)
objFile.ArticleID = objArticle.ArticleID
objFileController.Add(objFile)
End If
Next
'Copy Images
Dim folderImagesLinked As String = ""
If (objSettingsLinked.ContainsKey(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING)) Then
If (IsNumeric(objSettingsLinked(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettingsLinked(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folderImagesLinked = objFolder.FolderPath
End If
End If
End If
Dim filePathImagesLinked As String = objPortalLinked.HomeDirectoryMapPath & folderImagesLinked.Replace("/", "\")
Dim folderImages As String = ""
If (objSettings.ContainsKey(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING)) Then
If (IsNumeric(objSettings(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettings(ArticleConstants.DEFAULT_IMAGES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folderImages = objFolder.FolderPath
End If
End If
End If
Dim objImageController As New ImageController
Dim objImages As List(Of ImageInfo) = objImageController.GetImageList(objMirrorArticleInfo.LinkedArticleID, Null.NullString)
For Each objImage As ImageInfo In objImages
Dim objNewImage As ImageInfo = objImage.Clone
If (File.Exists(filePathImagesLinked & objNewImage.FileName)) Then
Dim finalCopyPath = filePathImagesLinked & objNewImage.FileName
Dim filePath As String = PortalSettings.HomeDirectoryMapPath & folderImages.Replace("/", "\")
If Not (Directory.Exists(filePath)) Then
Directory.CreateDirectory(filePath)
End If
If (File.Exists(filePath & objNewImage.FileName)) Then
For i As Integer = 1 To 100
If (File.Exists(filePath & i.ToString() & "_" & objNewImage.FileName) = False) Then
objNewImage.FileName = i.ToString() & "_" & objNewImage.FileName
Exit For
End If
Next
End If
File.Copy(finalCopyPath, filePath & objNewImage.FileName)
objNewImage.ImageID = Null.NullInteger
objNewImage.Folder = folderImages
objNewImage.ArticleID = objArticle.ArticleID
objImageController.Add(objNewImage)
End If
Next
End If
objArticleController.UpdateArticle(objArticle)
If (objArticle.Status = StatusType.Published) Then
publishArticle = True
End If
Else
objArticleController.UpdateArticle(objArticle)
If (statusChanged) Then
publishArticle = True
End If
End If
SaveCategories(objArticle.ArticleID)
SaveTags(objArticle.ArticleID)
SaveDetails(objArticle.ArticleID, objArticle.Title)
SaveCustomFields(objArticle.ArticleID)
' Re-init.
objArticle = objArticleController.GetArticle(objArticle.ArticleID)
If (publishArticle) Then
If (objArticle.IsApproved) Then
If (ArticleSettings.JournalIntegration) Then
Dim objJournal As New Journal
objJournal.AddArticleToJournal(objArticle, PortalId, TabId, Me.UserId, Null.NullInteger, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False))
End If
If (ArticleSettings.JournalIntegrationGroups) Then
Dim objCategories As ArrayList = objArticleController.GetArticleCategories(objArticle.ArticleID)
If (objCategories.Count > 0) Then
Dim objRoleController As New RoleController()
Dim objRoles As IList(Of RoleInfo) = RoleController.Instance.GetRoles(PortalId)
For Each objRole As RoleInfo In objRoles
Dim roleAccess As Boolean = False
If (objRole.SecurityMode = SecurityMode.SocialGroup Or objRole.SecurityMode = SecurityMode.Both) Then
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False) Then
If (objCategory.CategorySecurityType = CategorySecurityType.Loose) Then
roleAccess = False
Exit For
Else
If (Settings.Contains(objCategory.CategoryID.ToString() & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (IsInRole(objRole.RoleName, Settings(objCategory.CategoryID.ToString() & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString().Split(";"c))) Then
roleAccess = True
End If
End If
End If
End If
Next
End If
If (roleAccess) Then
Dim objJournal As New Journal
objJournal.AddArticleToJournal(objArticle, PortalId, TabId, Me.UserId, objRole.RoleID, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False))
End If
Next
End If
End If
' Notify Smart Thinker
If (ArticleSettings.EnableSmartThinkerStoryFeed) Then
Dim objStoryFeed As New wsStoryFeed.StoryFeedWS
objStoryFeed.Url = AddHTTP(Request.ServerVariables("HTTP_HOST") & Me.ResolveUrl("~/DesktopModules/Smart-Thinker%20-%20UserProfile/StoryFeed.asmx"))
Dim val As String = GetSharedResource("StoryFeed-AddArticle")
val = val.Replace("[AUTHOR]", objArticle.AuthorDisplayName)
val = val.Replace("[AUTHORID]", objArticle.AuthorID.ToString())
val = val.Replace("[ARTICLELINK]", Common.GetArticleLink(objArticle, Me.PortalSettings.ActiveTab, ArticleSettings, False))
val = val.Replace("[ARTICLETITLE]", objArticle.Title)
Try
objStoryFeed.AddAction(80, _articleID, val, objArticle.AuthorID, "VE6457624576460436531768")
Catch
End Try
End If
If (ArticleSettings.EnableActiveSocialFeed) Then
If (ArticleSettings.ActiveSocialSubmitKey <> "") Then
If IO.File.Exists(HttpContext.Current.Server.MapPath("~/bin/active.modules.social.dll")) Then
Dim ai As Object = Nothing
Dim asm As System.Reflection.Assembly
Dim ac As Object = Nothing
Try
asm = System.Reflection.Assembly.Load("Active.Modules.Social")
ac = asm.CreateInstance("Active.Modules.Social.API.Journal")
If Not ac Is Nothing Then
ac.AddProfileItem(New Guid(ArticleSettings.ActiveSocialSubmitKey), objArticle.AuthorID, Common.GetArticleLink(objArticle, Me.PortalSettings.ActiveTab, ArticleSettings, False), objArticle.Title, objArticle.Summary, objArticle.Body, 1, "")
End If
Catch ex As Exception
End Try
End If
End If
End If
End If
End If
If (_articleID <> Null.NullInteger And statusChanged = False) Then
If (objArticle.Status = StatusType.Published) Then
' Check to see if any articles have been linked
Dim objEmailTemplateController As New EmailTemplateController
Dim objMirrorArticleController As New MirrorArticleController
Dim objMirrorArticleLinked As ArrayList = objMirrorArticleController.GetMirrorArticleList(_articleID)
Dim objEventLog As New DotNetNuke.Services.Log.EventLog.EventLogController
objEventLog.AddLog("Article Linked Update", objMirrorArticleLinked.Count.ToString(), PortalSettings, -1, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT)
If (objMirrorArticleLinked.Count > 0) Then
For Each objMirrorArticleInfo As MirrorArticleInfo In objMirrorArticleLinked
Dim objArticleMirrored As ArticleInfo = objArticleController.GetArticle(objMirrorArticleInfo.ArticleID)
If (objArticleMirrored IsNot Nothing) Then
If (objArticleMirrored.AuthorEmail <> "") Then
objEmailTemplateController.SendFormattedEmail(Me.ModuleId, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), objArticle, EmailTemplateType.ArticleUpdateMirrored, objArticleMirrored.AuthorEmail, ArticleSettings)
End If
If (objMirrorArticleInfo.AutoUpdate) Then
objArticleMirrored.Title = objArticle.Title
objArticleMirrored.Summary = objArticle.Summary
objArticleMirrored.Url = objArticle.Url
objArticleMirrored.IsNewWindow = objArticle.IsNewWindow
objArticleMirrored.ImageUrl = objArticle.ImageUrl
objArticleMirrored.MetaTitle = objArticle.MetaTitle
objArticleMirrored.MetaDescription = objArticle.MetaDescription
objArticleMirrored.MetaKeywords = objArticle.MetaKeywords
objArticleMirrored.PageHeadText = objArticle.PageHeadText
' Save Custom Fields
Dim fieldsToUpdate As New Hashtable
Dim objCustomValueController As New CustomValueController
Dim objCustomValues As List(Of CustomValueInfo) = objCustomValueController.List(objArticleMirrored.ArticleID)
For Each objCustomValue As CustomValueInfo In objCustomValues
objCustomValueController.Delete(objArticleMirrored.ArticleID, objCustomValue.CustomFieldID)
Next
Dim objCustomFieldController As New CustomFieldController
Dim objCustomFields As ArrayList = objCustomFieldController.List(ModuleId)
Dim objCustomFieldsLinked As ArrayList = objCustomFieldController.List(objArticleMirrored.ModuleID)
For Each objCustomFieldLinked As CustomFieldInfo In objCustomFieldsLinked
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomFieldLinked.Name.ToLower() = objCustomField.Name.ToLower()) Then
If (objArticle.CustomList.Contains(objCustomField.CustomFieldID)) Then
fieldsToUpdate.Add(objCustomFieldLinked.CustomFieldID.ToString(), objArticle.CustomList(objCustomField.CustomFieldID).ToString())
End If
End If
Next
Next
For Each key As String In fieldsToUpdate.Keys
Dim val As String = fieldsToUpdate(key).ToString()
Dim objCustomValue As CustomValueInfo = New CustomValueInfo
objCustomValue.CustomFieldID = Convert.ToInt32(key)
objCustomValue.CustomValue = val
objCustomValue.ArticleID = objArticleMirrored.ArticleID
objCustomValueController.Add(objCustomValue)
Next
' Details
Dim objPageController As PageController = New PageController
Dim currentPages As ArrayList = objPageController.GetPageList(objArticleMirrored.ArticleID)
For Each objPage As PageInfo In currentPages
objPageController.DeletePage(objPage.PageID)
Next
Dim pages As ArrayList = objPageController.GetPageList(objArticle.ArticleID)
For Each objPage As PageInfo In pages
objPage.ArticleID = objArticleMirrored.ArticleID
objPage.PageID = Null.NullInteger
objPageController.AddPage(objPage)
Next
' Save Tags
Dim objTagController As New TagController
objTagController.DeleteArticleTag(objArticleMirrored.ArticleID)
Dim tagsCurrent As String = objArticle.Tags
If (tagsCurrent <> "") Then
Dim tags As String() = tagsCurrent.Split(","c)
For Each tag As String In tags
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(objArticleMirrored.ModuleID, tag)
If (objTag Is Nothing) Then
objTag = New TagInfo
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.ModuleID = objArticleMirrored.ModuleID
objTag.TagID = objTagController.Add(objTag)
End If
objTagController.Add(objArticleMirrored.ArticleID, objTag.TagID)
End If
Next
End If
'Copy Files
Dim folderLinked As String = ""
Dim objSettingsLinked As Hashtable = Common.GetModuleSettings(objArticleMirrored.ModuleID)
If (objSettingsLinked.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then
If (IsNumeric(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folderLinked = objFolder.FolderPath
End If
End If
End If
Dim objPortalController As New PortalController
Dim objPortalLinked As PortalInfo = objPortalController.GetPortal(objMirrorArticleInfo.PortalID)
Dim filePathLinked As String = objPortalLinked.HomeDirectoryMapPath & folderLinked.Replace("/", "\")
Dim folder As String = ""
Dim objSettings As Hashtable = Common.GetModuleSettings(ModuleId)
If (objSettings.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then
If (IsNumeric(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then
Dim folderID As Integer = Convert.ToInt32(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))
Dim objFolder As FolderInfo = FolderManager.Instance.GetFolder(folderID)
If (objFolder IsNot Nothing) Then
folder = objFolder.FolderPath
End If
End If
End If
Dim objFileController As New FileController
Dim objFilesCurrent As List(Of FileInfo) = objFileController.GetFileList(objArticleMirrored.ArticleID, Null.NullString)
For Each objFile As FileInfo In objFilesCurrent
objFileController.Delete(objFile.FileID)
Next
Dim objFiles As List(Of FileInfo) = objFileController.GetFileList(objArticle.ArticleID, Null.NullString)