-
Notifications
You must be signed in to change notification settings - Fork 11
/
ModuleBase.cs
1467 lines (1225 loc) · 51.5 KB
/
ModuleBase.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
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
// <copyright file="ModuleBase.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.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;
using System.Web;
using System.Web.UI;
using DotNetNuke.Common;
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Host;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using Engage.Dnn.Publish.Util;
#if TRIAL
using Engage.Licensing;
#endif
/// <summary>
/// Base functionality for Publish controls
/// </summary>
public class ModuleBase : Framework.ModuleBase
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private bool allowTitleUpdate = true;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int externallySetItemId = -1;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private int pageId;
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private bool useCache = true;
private readonly IHostController hostController = HostController.Instance;
public ModuleBase()
{
this.Overrideable = true;
this.LogBreadcrumb = true;
}
public static new string ApplicationUrl
{
get
{
if (HttpContext.Current != null)
{
return HttpContext.Current.Request.ApplicationPath == "/" ? string.Empty : HttpContext.Current.Request.ApplicationPath;
}
return string.Empty;
}
}
public static bool IsHostMailConfigured
{
get
{
return Engage.Utility.HasValue(Host.SMTPServer);
}
}
public static new string DesktopModuleFolderName
{
get { return Utility.DesktopModuleFolderName; }
}
public override string DesktopModuleName
{
get { return Utility.DnnFriendlyModuleName; }
}
public bool UseUrls { get; set; }
public Item VersionInfoObject { get; set; }
public bool LogBreadcrumb { get; set; }
public bool Overrideable { get; set; }
public bool UseCache
{
get { return this.useCache && this.CacheTime > 0; }
[DebuggerStepThrough]
set { this.useCache = value; }
}
public bool AllowTitleUpdate
{
get
{
object o = this.Settings["AllowTitleUpdate"];
if (o == null || !bool.TryParse(o.ToString(), out this.allowTitleUpdate))
{
this.allowTitleUpdate = true;
}
return this.allowTitleUpdate;
}
}
public int PageId
{
get
{
this.pageId = 1;
if (this.VersionInfoObject != null)
{
// TODO: this needs changed. We need to know what we're loading in the querystring first, check the ItemID
object o = this.Request.QueryString["pageid"];
object c = this.Request.QueryString["catpageid"];
if (o != null && this.VersionInfoObject.ItemTypeId == ItemType.Article.GetId())
{
this.pageId = Convert.ToInt32(o, CultureInfo.InvariantCulture);
}
else if (c != null &&
(this.VersionInfoObject.ItemTypeId == ItemType.Category.GetId() ||
this.VersionInfoObject.ItemTypeId == ItemType.TopLevelCategory.GetId()))
{
this.pageId = Convert.ToInt32(c, CultureInfo.InvariantCulture);
}
}
return this.pageId;
}
}
// TODO: cache all the HostSetting values
public bool IsSetup
{
get
{
string s = this.hostController.GetString(Utility.PublishSetup + this.PortalId);
string d = this.hostController.GetString(Utility.PublishDefaultDisplayPage + this.PortalId);
return !string.IsNullOrEmpty(s) && !string.IsNullOrEmpty(d);
}
}
public int ArticleEditWidth
{
get
{
string s = this.hostController.GetString(Utility.PublishArticleEditWidth + this.PortalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 500;
}
}
public int ArticleEditHeight
{
get
{
string s = this.hostController.GetString(Utility.PublishArticleEditHeight + this.PortalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 400;
}
}
public int ItemEditDescriptionHeight
{
get
{
string s = this.hostController.GetString(Utility.PublishDescriptionEditHeight + this.PortalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 300;
}
}
public int ItemEditDescriptionWidth
{
get
{
string s = this.hostController.GetString(Utility.PublishDescriptionEditWidth + this.PortalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 500;
}
}
public bool IsCommentsEnabled
{
get { return IsCommentsEnabledForPortal(this.PortalId); }
}
public bool IsCommentAuthorNotificationEnabled
{
get { return IsCommentAuthorNotificationEnabledForPortal(this.PortalId); }
}
public bool AllowAnonymousComments
{
get { return AllowAnonymousCommentsForPortal(this.PortalId); }
}
public bool AreCommentsModerated
{
get { return AreCommentsModeratedForPortal(this.PortalId); }
}
public bool AutoApproveComments
{
get { return AutoApproveCommentsForPortal(this.PortalId); }
}
public bool AreRatingsEnabled
{
get { return AreRatingsEnabledForPortal(this.PortalId); }
}
public bool AllowAnonymousRatings
{
get { return AllowAnonymousRatingsForPortal(this.PortalId); }
}
public bool IsViewTrackingEnabled
{
get { return IsViewTrackingEnabledForPortal(this.PortalId); }
}
public bool EnablePublishFriendlyUrls
{
get { return EnablePublishFriendlyUrlsForPortal(this.PortalId); }
}
public bool AllowArticlePaging
{
get { return AllowArticlePagingForPortal(this.PortalId); }
}
public bool AllowVenexusSearch
{
get { return AllowVenexusSearchForPortal(this.PortalId); }
}
public bool AllowSimpleGalleryIntegration
{
get { return AllowSimpleGalleryIntegrationForPortal(this.PortalId); }
}
public bool AllowUltraMediaGalleryIntegration
{
get { return AllowUltraMediaGalleryIntegrationForPortal(this.PortalId); }
}
public bool EnableDisplayNameAsHyperlink
{
get { return EnableDisplayNameAsHyperlinkForPortal(this.PortalId); }
}
public bool AllowTags
{
get { return AllowTagsForPortal(this.PortalId); }
}
public int PopularTagCount
{
get { return PopularTagCountForPortal(this.PortalId); }
}
public int DefaultDisplayTabId
{
get { return DefaultDisplayTabIdForPortal(this.PortalId); }
}
public int DefaultTagDisplayTabId
{
get { return DefaultTagDisplayTabIdForPortal(this.PortalId); }
}
public int DefaultTextHtmlCategory
{
get { return DefaultTextHtmlCategoryForPortal(this.PortalId); }
}
public bool AllowRichTextDescriptions
{
get { return AllowRichTextDescriptionsForPortal(this.PortalId); }
}
public bool DefaultRichTextDescriptions
{
get { return DefaultRichTextDescriptionsForPortal(this.PortalId); }
}
public bool UseApprovals
{
get { return UseApprovalsForPortal(this.PortalId); }
}
public bool UseEmbeddedArticles
{
get { return UseEmbeddedArticlesForPortal(this.PortalId); }
}
public bool ShowItemIds
{
get { return ShowItemIdsForPortal(this.PortalId); }
}
public string ThumbnailSubdirectory
{
get { return ThumbnailSubdirectoryForPortal(this.PortalId); }
}
public string ThumbnailSelectionOption
{
get { return ThumbnailSelectionOptionForPortal(this.PortalId); }
}
public int MaximumRating
{
get { return MaximumRatingForPortal(this.PortalId); }
}
public new bool IsAdmin
{
get
{
return this.Request.IsAuthenticated &&
(PortalSecurity.IsInRole(this.hostController.GetString(Utility.PublishAdminRole + this.PortalId)) || this.UserInfo.IsSuperUser);
}
}
public new bool IsConfigured
{
get { return this.Settings.Contains("DisplayType"); }
}
public bool IsAuthor
{
get { return this.Request.IsAuthenticated && PortalSecurity.IsInRole(this.hostController.GetString(Utility.PublishAuthorRole + this.PortalId)); }
}
public bool IsPingEnabled
{
get { return Utility.IsPingEnabledForPortal(this.PortalId); }
}
public bool IsWlwEnabled
{
get { return this.GetWlwSupportForPortal(this.PortalId); }
}
public bool IsPublishCommentType
{
get { return IsPublishCommentTypeForPortal(this.PortalId); }
}
public string ForumProviderType
{
get { return ForumProviderTypeForPortal(this.PortalId); }
}
public ItemType TypeOfItem
{
get
{
int typeId = Item.GetItemTypeId(this.ItemId, this.PortalId);
return ItemType.GetFromId(typeId, typeof(ItemType));
}
}
public int ItemId
{
get
{
// someone called the public method and set the ItemID (externally).
if (this.externallySetItemId > 0)
{
return this.externallySetItemId;
}
// ItemId has not been set externally now we need to look at settings.
// if the querystring has the ItemId on it and the settings are to override
string i = this.Request.QueryString["itemId"];
// we need to look if we're in admin mode, if so forget the reference about IsOverridable, it's always overridable.
string ctl = this.Request.QueryString["ctl"];
int modid = -1;
object o = this.Request.Params["modid"];
if (o != null)
{
modid = Convert.ToInt32(o.ToString(), CultureInfo.InvariantCulture);
}
// if (!string.IsNullOrEmpty(ctl) && ctl.Equals(Utility.AdminContainer))
if (!string.IsNullOrEmpty(ctl) && ctl.ToUpperInvariant().Equals(Utility.AdminContainer.ToUpperInvariant()))
{
if (!string.IsNullOrEmpty(i))
{
return Convert.ToInt32(i, CultureInfo.InvariantCulture);
}
if (this.ItemVersionId > 0)
{
return Item.GetItemIdFromVersion(this.ItemVersionId, this.PortalId);
}
}
var manager = new ItemManager(this);
// Check if there's a moduleid
if (modid > 0)
{
if (Convert.ToInt32(o, CultureInfo.InvariantCulture) == this.ModuleId || this.Overrideable)
{
// if we found the moduleid in the querystring we are trying to force the article here.
if (!string.IsNullOrEmpty(i))
{
return Convert.ToInt32(i, CultureInfo.InvariantCulture);
}
// The local variable ItemVersionId is set so resolve the ItemVersionid to an Itemid
if (this.ItemVersionId > 0)
{
return Item.GetItemIdFromVersion(this.ItemVersionId, this.PortalId);
}
return manager.ResolveId();
}
// if we don't match the moduleid then we should get the module settings from DNN to use
return manager.ResolveId();
}
if (!string.IsNullOrEmpty(i) && manager.IsOverrideable)
{
return Convert.ToInt32(i, CultureInfo.InvariantCulture);
}
// The local variable ItemVersionId is set so resolve the ItemVersionid to an Itemid
if (manager.IsOverrideable && this.ItemVersionId > 0 && modid == this.ModuleId)
{
return Item.GetItemIdFromVersion(this.ItemVersionId, this.PortalId);
}
// none of the above have scenarios have been met, need to ask the Manager class to
// determine the itemid. The manager contains logic to check module settings and
// backward capatibility settings. hk
return manager.ResolveId();
}
}
// This is the cachetime used by Publish modules
public int CacheTime
{
get
{
object o = this.Settings["CacheTime"];
if (o != null)
{
return Convert.ToInt32(o.ToString(), CultureInfo.InvariantCulture);
}
if (GetDefaultCacheSetting(this.PortalId) > 0)
{
return GetDefaultCacheSetting(this.PortalId);
}
return 0;
}
}
public int DefaultAdminPagingSize
{
get { return GetAdminDefaultPagingSize(this.PortalId); }
}
public int ItemVersionId
{
get
{
string s = this.Request.QueryString["VersionId"];
if (s == null)
{
return -1;
}
object o = this.Request.Params["modid"];
if (o != null)
{
// check to see if we're on the right module id, otherwise return -1
if (Convert.ToInt32(o.ToString(), CultureInfo.InvariantCulture) == this.ModuleId)
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
}
public int CommentId
{
get
{
string s = this.Request.QueryString["CommentId"];
return s == null ? -1 : Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
}
public static bool ApprovalEmailsEnabled(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEmail + portalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s);
}
return false;
}
public static bool IsCommentsEnabledForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishComment + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool IsCommentAuthorNotificationEnabledForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishCommentEmailAuthor + portalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s);
}
return false;
}
public static bool UseSessionForReturnToList(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishSessionReturnToList + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool AllowAuthorEditCategory(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishAuthorCategoryEdit + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool AllowAnonymousCommentsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishCommentAnonymous + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool AreCommentsModeratedForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishCommentApproval + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool AutoApproveCommentsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishCommentAutoApprove + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool AreRatingsEnabledForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishRating + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool AllowAnonymousRatingsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishRatingAnonymous + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool IsViewTrackingEnabledForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnableViewTracking + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool EnablePublishFriendlyUrlsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnablePublishFriendlyUrls + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool AllowVenexusSearchForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnableVenexusSearch + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool AllowSimpleGalleryIntegrationForPortal(int portalId)
{
if (Utility.IsSimpleGalleryInstalled)
{
string s = HostController.Instance.GetString(
Utility.PublishEnableSimpleGalleryIntegration + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
}
return false;
}
public static bool AllowUltraMediaGalleryIntegrationForPortal(int portalId)
{
if (Utility.IsUltraMediaGalleryInstalled)
{
string s =
HostController.Instance.GetString(Utility.PublishEnableUltraMediaGalleryIntegration + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
}
return false;
}
public static bool AllowArticlePagingForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnableArticlePaging + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool EnableDisplayNameAsHyperlinkForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnableDisplayNameAsHyperlink + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool AllowTagsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishEnableTags + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static int PopularTagCountForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishPopularTagCount + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
public static int DefaultDisplayTabIdForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultDisplayPage + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
public static int DefaultTagDisplayTabIdForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultTagPage + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
public static int DefaultTextHtmlCategoryForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultTextHtmlCategory + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
public static int DefaultCategoryForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultCategory + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return -1;
}
public static bool AllowRichTextDescriptionsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishAllowRichTextDescriptions + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool DefaultRichTextDescriptionsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultRichTextDescriptions + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool UseApprovalsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishUseApprovals + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static bool UseEmbeddedArticlesForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishUseEmbeddedArticles + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return false;
}
public static bool ShowItemIdsForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishShowItemId + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return Convert.ToBoolean(s, CultureInfo.InvariantCulture);
}
return true;
}
public static string ThumbnailSubdirectoryForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishThumbnailSubdirectory + portalId.ToString(CultureInfo.InvariantCulture));
if (!Engage.Utility.HasValue(s))
{
s = "PublishThumbnails/";
}
else if (s.StartsWith("/", StringComparison.Ordinal))
{
s = s.Substring(1);
}
return s;
}
public static string ThumbnailSelectionOptionForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishThumbnailDisplayOption + portalId.ToString(CultureInfo.InvariantCulture));
return s;
}
public static int MaximumRatingForPortal(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishRatingMaximum + portalId.ToString(CultureInfo.InvariantCulture));
if (Engage.Utility.HasValue(s))
{
return int.Parse(s, CultureInfo.InvariantCulture);
}
return UserFeedback.Rating.DefaultMaximumRating;
}
public static bool IsUserAdmin(int portalId)
{
if (HttpContext.Current != null)
{
return HttpContext.Current.Request.IsAuthenticated &&
PortalSecurity.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + portalId));
}
return false;
}
public static bool IsPublishCommentTypeForPortal(int portalId)
{
return
string.IsNullOrEmpty(HostController.Instance.GetString(Utility.PublishForumProviderType + portalId.ToString(CultureInfo.InvariantCulture)));
}
public static string ForumProviderTypeForPortal(int portalId)
{
return HostController.Instance.GetString(Utility.PublishForumProviderType + portalId.ToString(CultureInfo.InvariantCulture));
}
public static bool UseCachePortal(int portalId)
{
if (CacheTimePortal(portalId) > 0)
{
return true;
}
return false;
}
public static int CacheTimePortal(int portalId)
{
if (GetDefaultCacheSetting(portalId) > 0)
{
return GetDefaultCacheSetting(portalId);
}
return 0;
}
public static int GetDefaultCacheSetting(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishCacheTime + portalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 0;
}
public static int GetAdminDefaultPagingSize(int portalId)
{
string s = HostController.Instance.GetString(Utility.PublishDefaultAdminPagingSize + portalId);
if (Engage.Utility.HasValue(s))
{
return Convert.ToInt32(s, CultureInfo.InvariantCulture);
}
return 25;
}
public static string GetRssLinkUrl(object itemId, int maxDisplayItems, int itemTypeId, int portalId, string displayType)
{
var url = new StringBuilder(128);
url.Append(ApplicationUrl);
url.Append(DesktopModuleFolderName);
url.Append("eprss.aspx?itemId=");
url.Append(itemId);
url.Append("&numberOfItems=");
url.Append(maxDisplayItems);
url.Append("&itemtypeid=");
url.Append(itemTypeId);
url.Append("&portalid=");
url.Append(portalId);
url.Append("&DisplayType=");
url.Append(displayType);
return url.ToString();
}
public static string GetRssLinkUrl(int portalId, string displayType, string tags)
{
var url = new StringBuilder(128);
url.Append(ApplicationUrl);
url.Append(DesktopModuleFolderName);
url.Append("eprss.aspx?");
url.Append("portalid=");
url.Append(portalId);
url.Append("&DisplayType=");
url.Append(displayType);
url.Append("&Tags=");
url.Append(HttpUtility.UrlEncode(tags));
return url.ToString();
}
public bool GetWlwSupportForPortal(int portalId)
{
if (this.Settings.Contains("SupportWLW"))
{
string supportwlw = this.Settings["SupportWLW"].ToString();
return Convert.ToBoolean(supportwlw);
}
return false;
}