-
Notifications
You must be signed in to change notification settings - Fork 11
/
EditProperty.ascx.vb
executable file
·2229 lines (1766 loc) · 126 KB
/
EditProperty.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
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Framework
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.UI.UserControls
Imports System.IO
Imports System.Globalization
Imports Ventrian.PropertyAgent.Social
Namespace Ventrian.PropertyAgent
Partial Public Class EditProperty
Inherits PropertyAgentBase
#Region " Controls "
#End Region
#Region " Private Members "
Private _propertyID As Integer = Null.NullInteger
Private _propertyTypeID As Integer = Null.NullInteger
Private _returnUrl As String = Null.NullString
Private _property As PropertyInfo
Private _richTextValues As New NameValueCollection
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
Dim propertyParam As String = PropertySettings.SEOPropertyID
If (Request(propertyParam) = "") Then
propertyParam = "PropertyID"
End If
If Not (Request(propertyParam) Is Nothing) Then
_propertyID = Convert.ToInt32(Request(propertyParam))
End If
If Not (Request("ReturnUrl") Is Nothing) Then
_returnUrl = Server.UrlDecode(Request("ReturnUrl"))
End If
If (Page.IsPostBack) Then
If (IsNumeric(Request(drpTypes.ClientID.ToString().Replace("_", "$")))) Then
_propertyTypeID = Convert.ToInt32(Request(drpTypes.ClientID.ToString().Replace("_", "$")))
End If
End If
End Sub
Private Function StripNonAlphaNumericCharacters(ByVal Text As String) As String
Dim sb As New System.Text.StringBuilder(Text.Length)
Dim chr As Char
For Each chr In Text
If Char.IsLetterOrDigit(chr) Then
sb.Append(chr)
End If
Next chr
Return sb.ToString()
End Function
Private Function RenderControlAsString(ByVal objControl As Control) As String
Dim sb As New StringBuilder
Dim tw As New StringWriter(sb)
Dim hw As New HtmlTextWriter(tw)
objControl.RenderControl(hw)
Return sb.ToString()
End Function
Private Sub CheckSecurity()
If (Request.IsAuthenticated = False) Then
' Only authenticated people can edit.
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=AccessDenied"), True)
End If
If (IsEditable = False And PortalSecurity.IsInRoles(PropertySettings.PermissionSubmit) = False And PortalSecurity.IsInRoles(PropertySettings.PermissionBroker) = False) Then
If (_propertyID = Null.NullInteger Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove) = False) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=AccessDenied"), True)
End If
End If
If (IsEditable = False And (PortalSecurity.IsInRoles(PropertySettings.PermissionSubmit) = True Or PortalSecurity.IsInRoles(PropertySettings.PermissionBroker) = True) And PortalSecurity.IsInRoles(PropertySettings.PermissionApprove) = False) Then
If (_propertyID <> Null.NullInteger) Then
Dim objPropertyController As New PropertyController
Dim objProperty As PropertyInfo = objPropertyController.Get(_propertyID)
If Not (objProperty Is Nothing) Then
If (objProperty.AuthorID <> UserId And objProperty.BrokerID <> UserId) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=AccessDenied"), True)
End If
Else
Response.Redirect(NavigateURL(), True)
End If
End If
End If
If (_propertyID = Null.NullInteger And CheckLimit() = False) Then
Response.Redirect(NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=PropertyManager"), True)
End If
End Sub
Private Sub BindPropertyTypes()
Dim objPropertyTypeController As New PropertyTypeController
drpTypes.DataSource = objPropertyTypeController.ListAll(Me.ModuleId, True, PropertySettings.TypesSortBy, Null.NullString())
drpTypes.DataBind()
drpTypes.Items.Insert(0, New ListItem(GetResourceString("SelectType"), "-1"))
If (_propertyTypeID <> Null.NullInteger) Then
If (drpTypes.Items.FindByValue(_propertyTypeID.ToString()) IsNot Nothing) Then
drpTypes.SelectedValue = _propertyTypeID.ToString()
End If
End If
For Each objCustomField As CustomFieldInfo In CustomFields
If (objCustomField.IsPublished AndAlso objCustomField.FieldType = CustomFieldType.DropDownList AndAlso objCustomField.FieldElementType = FieldElementType.LinkedToPropertyType) Then
drpTypes.AutoPostBack = True
End If
Next
End Sub
Private Sub BindDetails()
trOwner.Visible = IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)
If (trOwner.Visible = False) Then
If (PortalSecurity.IsInRoles(PropertySettings.PermissionBroker)) Then
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
Dim objAgents As ArrayList = objAgentController.ListSelected(PortalId, ModuleId, Me.UserId)
If (objAgents.Count > 0) Then
trOwner.Visible = True
End If
End If
End If
phAuthorDetails.Visible = Not Me.PropertySettings.PropertyManagerHideAuthorDetails
phPublishingDetails.Visible = IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionPublishDetail)
If (PropertySettings.AgentDropdownDefault) Then
lblOwner.Visible = False
cmdChange.Visible = False
drpOwner.Visible = True
PopulateOwnerList()
End If
If _propertyID <> Null.NullInteger Then
Dim objPropertyController As New PropertyController
_property = objPropertyController.Get(_propertyID)
If (_property Is Nothing) Then
Response.Redirect(NavigateURL(), True)
End If
If (Page.IsPostBack = False) Then
cmdClone.Visible = PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)
If (PropertySettings.AgentDropdownDefault) Then
If (drpOwner.Items.FindByValue(_property.AuthorID.ToString()) IsNot Nothing) Then
drpOwner.SelectedValue = _property.AuthorID.ToString()
End If
End If
If Not (drpTypes.Items.FindByValue(_property.PropertyTypeID.ToString()) Is Nothing) Then
drpTypes.SelectedValue = _property.PropertyTypeID.ToString()
End If
txtCreationDate.Text = _property.DateCreated.ToShortDateString()
drpCreationTimeHour.SelectedValue = _property.DateCreated.Hour.ToString()
drpCreationTimeMinute.SelectedValue = _property.DateCreated.Minute.ToString()
If (_property.Latitude <> Null.NullDouble) Then
txtLatitude.Text = _property.Latitude.ToString(CultureInfo.InvariantCulture.NumberFormat)
End If
If (_property.Longitude <> Null.NullDouble) Then
txtLongitude.Text = _property.Longitude.ToString(CultureInfo.InvariantCulture.NumberFormat)
End If
If (txtLatitude.Text <> "" And txtLongitude.Text <> "") Then
phMapLoad.Visible = True
Else
phMapLoad.Visible = False
End If
If (_property.DatePublished <> Null.NullDate) Then
txtPublishDate.Text = _property.DatePublished.ToShortDateString()
drpPublishTimeHour.SelectedValue = _property.DatePublished.Hour.ToString()
drpPublishTimeMinute.SelectedValue = _property.DatePublished.Minute.ToString()
Else
drpPublishTimeHour.SelectedValue = "-"
drpPublishTimeMinute.SelectedValue = "-"
End If
If (_property.DateExpired <> Null.NullDate) Then
txtExpiryDate.Text = _property.DateExpired.ToShortDateString()
If Not (drpExpiryTimeHour.Items.FindByValue(_property.DateExpired.Hour.ToString()) Is Nothing) Then
drpExpiryTimeHour.SelectedValue = _property.DateExpired.Hour.ToString()
End If
If Not (drpExpiryTimeMinute.Items.FindByValue(_property.DateExpired.Minute.ToString()) Is Nothing) Then
drpExpiryTimeMinute.SelectedValue = _property.DateExpired.Minute.ToString()
End If
Else
drpExpiryTimeHour.SelectedValue = "-"
drpExpiryTimeMinute.SelectedValue = "-"
End If
Select Case _property.Status
Case StatusType.Draft
chkPublished.Checked = False
chkApproved.Checked = False
Case StatusType.AwaitingApproval
chkPublished.Checked = True
chkApproved.Checked = False
Case StatusType.Published
chkPublished.Checked = True
chkApproved.Checked = True
End Select
If (PortalSecurity.IsInRoles(PropertySettings.PermissionSubmit) And (IsEditable = False Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove) = False)) Then
chkApproved.Enabled = False
chkApproved.Checked = False
End If
If (PortalSecurity.IsInRoles(PropertySettings.PermissionAutoApprove) And (IsEditable = False Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove) = False)) Then
chkApproved.Enabled = False
chkApproved.Checked = True
End If
If (IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)) Then
chkApproved.Enabled = True
End If
chkFeatured.Checked = _property.IsFeatured
chkOnlyForAuthenticated.Checked = _property.OnlyForAuthenticated
If (_property.Username <> "") Then
lblOwner.Text = _property.DisplayName & " (" & _property.Username & ")"
If (_property.BrokerID <> Null.NullInteger) Then
lblOwner.Text = _property.Username & " (" & PropertyUtil.FormatPropertyLabel(Localization.GetString("Broker", Me.LocalResourceFile), Me.PropertySettings) & " " & _property.BrokerUsername & ")"
End If
Else
lblOwner.Text = Localization.GetString("None_Specified")
End If
lblUsername.Text = _property.Username
lblDisplayName.Text = _property.DisplayName
lblEmail.Text = "<a href='mailto:" & _property.Email & "'>" + _property.Email + "</a>"
End If
Else
phMapLoad.Visible = False
txtCreationDate.Text = DateTime.Now.ToShortDateString()
drpCreationTimeHour.SelectedValue = DateTime.Now.Hour.ToString()
drpCreationTimeMinute.SelectedValue = DateTime.Now.Minute.ToString()
txtPublishDate.Text = DateTime.Now.ToShortDateString()
drpPublishTimeHour.SelectedValue = DateTime.Now.Hour.ToString()
drpPublishTimeMinute.SelectedValue = DateTime.Now.Minute.ToString()
If (PropertySettings.DefaultExpiration <> Null.NullInteger) Then
Dim expirationDate As DateTime = DateTime.Now
Select Case PropertySettings.DefaultExpirationPeriod
Case "D"
expirationDate = expirationDate.AddDays(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
Case "M"
expirationDate = expirationDate.AddMonths(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
Case "Y"
expirationDate = expirationDate.AddYears(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
Case Else
End Select
txtExpiryDate.Text = expirationDate.ToShortDateString()
If Not (drpExpiryTimeHour.Items.FindByValue(expirationDate.Hour.ToString()) Is Nothing) Then
drpExpiryTimeHour.SelectedValue = expirationDate.Hour.ToString()
End If
If Not (drpExpiryTimeMinute.Items.FindByValue(expirationDate.Minute.ToString()) Is Nothing) Then
drpExpiryTimeMinute.SelectedValue = expirationDate.Minute.ToString()
End If
End If
If (PortalSecurity.IsInRoles(PropertySettings.PermissionSubmit)) Then
chkApproved.Enabled = False
chkApproved.Checked = False
End If
If (PortalSecurity.IsInRoles(PropertySettings.PermissionAutoApprove)) Then
chkApproved.Enabled = False
chkApproved.Checked = True
End If
If (IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)) Then
chkApproved.Enabled = True
chkApproved.Checked = True
End If
If (PortalSecurity.IsInRoles(PropertySettings.PermissionAutoFeature)) Then
chkFeatured.Enabled = True
chkFeatured.Checked = True
End If
chkPublished.Checked = True
phAuthorDetails.Visible = False
lblOwner.Text = Me.UserInfo.DisplayName & " (" & Me.UserInfo.Username & ")"
If (drpTypes.Items.Count = 2) Then
drpTypes.SelectedIndex = 1
End If
cmdClone.Visible = False
If (PropertySettings.AgentDropdownDefault) Then
If (drpOwner.Items.FindByValue(DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.UserID.ToString) IsNot Nothing) Then
drpOwner.SelectedValue = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.UserID.ToString
End If
End If
End If
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = PropertySettings.MainLabel
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
If (Request.IsAuthenticated) Then
Dim objCrumbPropertyManager As New CrumbInfo
objCrumbPropertyManager.Caption = GetResourceString("PropertyManager")
objCrumbPropertyManager.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=PropertyManager")
crumbs.Add(objCrumbPropertyManager)
End If
Dim objCrumbProperty As New CrumbInfo
If (_propertyID <> Null.NullInteger) Then
objCrumbProperty.Caption = GetResourceString("EditProperty")
objCrumbProperty.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditProperty", PropertySettings.SEOPropertyID & "=" & _propertyID.ToString())
Else
objCrumbProperty.Caption = GetResourceString("AddNewProperty")
objCrumbProperty.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=EditProperty")
End If
crumbs.Add(objCrumbProperty)
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Portal) Then
For i As Integer = 0 To crumbs.Count - 1
Dim objCrumb As CrumbInfo = crumbs(i)
If (i > 0) Then
Dim objTab As New DotNetNuke.Entities.Tabs.TabInfo
objTab.TabID = -8888 + i
objTab.TabName = objCrumb.Caption
objTab.Url = objCrumb.Url
PortalSettings.ActiveTab.BreadCrumbs.Add(objTab)
End If
Next
End If
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Module) Then
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End If
rptDetails.DataSource = Me.CustomFields
rptDetails.DataBind()
End Sub
Private Function FormatDefaultValue(ByVal defaultValue As String) As String
'val = val.Replace("[DISPLAYNAME]", Me.UserInfo.DisplayName)
'val = val.Replace("[FIRSTNAME]", Me.UserInfo.FirstName)
'val = val.Replace("[EMAIL]", Me.UserInfo.Email)
'val = val.Replace("[LASTNAME]", Me.UserInfo.LastName)
'val = val.Replace("[USERID]", Me.UserInfo.UserID)
'val = val.Replace("[USERNAME]", Me.UserInfo.Username)
Dim objPlaceHolder As New PlaceHolder
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim layoutArray As String() = defaultValue.Split(delimiter)
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
objPlaceHolder.Controls.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1).ToUpper()
Case "DISPLAYNAME"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.DisplayName
objPlaceHolder.Controls.Add(objLiteral)
Case "EMAIL"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.Email
objPlaceHolder.Controls.Add(objLiteral)
Case "FIRSTNAME"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.FirstName
objPlaceHolder.Controls.Add(objLiteral)
Case "LASTNAME"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.LastName
objPlaceHolder.Controls.Add(objLiteral)
Case "USERID"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.UserID
objPlaceHolder.Controls.Add(objLiteral)
Case "USERNAME"
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.Username
objPlaceHolder.Controls.Add(objLiteral)
Case Else
If (layoutArray(iPtr + 1).ToUpper().StartsWith("PROFILE:")) Then
Dim field As String = layoutArray(iPtr + 1).Substring(8, layoutArray(iPtr + 1).Length - 8)
Dim objLiteral As New Literal
objLiteral.Text = UserInfo.Profile.GetPropertyValue(field)
objPlaceHolder.Controls.Add(objLiteral)
End If
End Select
End If
Next
Return RenderControlAsString(objPlaceHolder)
End Function
Private Sub SetLockDown()
If Me.PropertySettings.LockDownPropertyType AndAlso Not PortalSecurity.IsInRoles(PropertySettings.PermissionLockDown) Then
drpTypes.Enabled = False
End If
If Me.PropertySettings.LockDownPropertyDates AndAlso Not PortalSecurity.IsInRoles(PropertySettings.PermissionLockDown) Then
' Creation date
drpCreationTimeHour.Enabled = False
drpCreationTimeMinute.Enabled = False
txtCreationDate.Enabled = False
cmdCreationDate.Enabled = False
' Start date
drpPublishTimeHour.Enabled = False
drpPublishTimeMinute.Enabled = False
txtPublishDate.Enabled = False
cmdPublishDate.Enabled = False
' End date
drpExpiryTimeHour.Enabled = False
drpExpiryTimeMinute.Enabled = False
txtExpiryDate.Enabled = False
cmdExpiryDate.Enabled = False
End If
If Me.PropertySettings.LockDownFeatured AndAlso Not PortalSecurity.IsInRoles(PropertySettings.PermissionLockDown) Then
chkFeatured.Enabled = False
End If
End Sub
Private Sub LocalizeLabels()
CType(dshPropertyDetails, SectionHeadControl).Text = GetResourceString("PropertyDetails")
lblPropertyDetailsHelp.Text = GetResourceString("PropertyDetailsDescription")
CType(plType, LabelControl).Text = GetResourceString("Type") & "*:"
CType(plType, LabelControl).HelpText = GetResourceString("Type.Help")
valPropertyType.ErrorMessage = GetResourceString("valTypeRequired")
lblPublishDetails.Text = GetResourceString("PublishDetailsDescription")
CType(plPublishDate, LabelControl).HelpText = GetResourceString("PublishDate.Help")
CType(plExpiryDate, LabelControl).HelpText = GetResourceString("ExpiryDate.Help")
lblAuthorDetails.Text = GetResourceString("AuthorDetailsDescription")
CType(plOwner, LabelControl).Text = GetResourceString("Agent")
CType(plOwner, LabelControl).HelpText = GetResourceString("AgentHelp")
cmdChange.Text = GetResourceString("cmdChangeOwner")
valPropertyTypeSubmission.ErrorMessage = GetResourceString("valPropertyTypeSubmission.ErrorMessage")
End Sub
Private Sub PopulateOwnerList()
If (IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)) Then
Dim objUsers As ArrayList = UserController.GetUsers(PortalId)
For Each objUser As UserInfo In objUsers
drpOwner.Items.Add(New ListItem(objUser.DisplayName & " (" & objUser.Username & ")", objUser.UserID.ToString()))
Next
'drpOwner.DataSource = UserController.GetUsers(PortalId)
'drpOwner.DataBind()
'Dim objSuperUser As DotNetNuke.Entities.Users.UserInfo
'For Each objSuperUser In UserController.GetUsers(Null.NullInteger)
' drpOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(objSuperUser.DisplayName & " (" & objSuperUser.Username & ")", objSuperUser.UserID.ToString))
'Next
drpOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Localization.GetString("None_Specified"), "-1"))
Else
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
Dim objUsers As ArrayList = objAgentController.ListSelected(PortalId, ModuleId, UserId)
For Each objUser As UserInfo In objUsers
drpOwner.Items.Add(New ListItem(objUser.DisplayName & " (" & objUser.Username & ")", objUser.UserID.ToString()))
Next
'drpOwner.DataSource = objAgentController.ListSelected(PortalId, ModuleId, UserId)
'drpOwner.DataBind()
drpOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Me.UserInfo.DisplayName & " (" & Me.UserInfo.Username & ")", Me.UserId))
drpOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Localization.GetString("None_Specified"), "-1"))
If Not (drpOwner.Items.FindByValue(Me.UserId.ToString()) Is Nothing) Then
drpOwner.SelectedValue = Me.UserId.ToString()
End If
End If
End Sub
Private Sub SetVisibility()
cmdDelete.Visible = (_propertyID <> Null.NullInteger)
If (cmdDelete.Visible) Then
cmdDelete.Visible = (IsEditor Or PortalSecurity.IsInRoles(PropertySettings.PermissionDelete))
End If
End Sub
Private Sub Update(ByRef MaxUploadLimit As Boolean)
Dim hostSettings As Dictionary(Of String, String) = DotNetNuke.Entities.Controllers.HostController.Instance.GetSettingsDictionary()
If (_propertyID = Null.NullInteger) Then
_property = New PropertyInfo
_property.ModuleID = Me.ModuleId
End If
_property.DateModified = DateTime.Now
_property.PropertyTypeID = Convert.ToInt32(drpTypes.SelectedValue)
Dim dateCreated As DateTime = DateTime.Parse(txtCreationDate.Text)
dateCreated = dateCreated.AddHours(Convert.ToInt32(drpCreationTimeHour.SelectedValue))
dateCreated = dateCreated.AddMinutes(Convert.ToInt32(drpCreationTimeMinute.SelectedValue))
_property.DateCreated = dateCreated
If (txtPublishDate.Text.Length > 0) Then
Dim datePublished As DateTime = DateTime.Parse(txtPublishDate.Text)
If (drpPublishTimeHour.SelectedValue <> "-") Then
datePublished = datePublished.AddHours(Convert.ToInt32(drpPublishTimeHour.SelectedValue))
End If
If (drpPublishTimeMinute.SelectedValue <> "-") Then
datePublished = datePublished.AddMinutes(Convert.ToInt32(drpPublishTimeMinute.SelectedValue))
End If
_property.DatePublished = datePublished
Else
_property.DatePublished = Null.NullDate
End If
If (txtExpiryDate.Text.Length > 0) Then
Dim dateExpiry As DateTime = DateTime.Parse(txtExpiryDate.Text)
If (drpExpiryTimeHour.SelectedValue <> "-") Then
dateExpiry = dateExpiry.AddHours(Convert.ToInt32(drpExpiryTimeHour.SelectedValue))
End If
If (drpExpiryTimeMinute.SelectedValue <> "-") Then
dateExpiry = dateExpiry.AddMinutes(Convert.ToInt32(drpExpiryTimeMinute.SelectedValue))
End If
_property.DateExpired = dateExpiry
Else
_property.DateExpired = Null.NullDate
End If
Dim objStatusType As StatusType = StatusType.Draft
If (chkPublished.Checked = True And chkApproved.Checked = False) Then
objStatusType = StatusType.AwaitingApproval
End If
If (chkPublished.Checked And chkApproved.Checked) Then
objStatusType = StatusType.Published
End If
_property.Status = objStatusType
_property.IsFeatured = chkFeatured.Checked
_property.OnlyForAuthenticated = chkOnlyForAuthenticated.Checked
_property.ModifiedID = Me.UserId
If (txtLatitude.Text <> "") Then
If (IsNumeric(txtLatitude.Text)) Then
_property.Latitude = Double.Parse(txtLatitude.Text, CultureInfo.InvariantCulture.NumberFormat)
Else
If (IsNumeric(txtLatitude.Text.Replace("."c, ","c))) Then
_property.Latitude = txtLatitude.Text.Replace("."c, ","c)
Else
_property.Latitude = Null.NullDouble
End If
End If
Else
_property.Latitude = Null.NullDouble
End If
If (txtLongitude.Text <> "") Then
If (IsNumeric(txtLongitude.Text)) Then
_property.Longitude = Double.Parse(txtLongitude.Text, CultureInfo.InvariantCulture.NumberFormat)
Else
If (IsNumeric(txtLongitude.Text.Replace("."c, ","c))) Then
_property.Longitude = txtLongitude.Text.Replace("."c, ","c)
Else
_property.Longitude = Null.NullDouble
End If
End If
Else
_property.Longitude = Null.NullDouble
End If
Dim addJournal As Boolean = False
Dim objPropertyController As New PropertyController
If (_propertyID <> Null.NullInteger) Then
If drpOwner.Visible Then
If drpOwner.SelectedValue <> "" Then
_property.AuthorID = Convert.ToInt32(drpOwner.SelectedValue)
Else
_property.AuthorID = Null.NullInteger
End If
Else
' User never clicked "change", leave authorid as is
End If
objPropertyController.Update(_property)
Else
_property.AuthorID = Me.UserId
If drpOwner.Visible Then
If drpOwner.SelectedValue <> "" Then
_property.AuthorID = Convert.ToInt32(drpOwner.SelectedValue)
Else
_property.AuthorID = Null.NullInteger
End If
Else
' User never clicked "change", leave authorid as is
End If
_propertyID = objPropertyController.Add(_property)
_property = objPropertyController.Get(_propertyID)
addJournal = True
If (PropertySettings.ImagesEnabled AndAlso ((IsEditable = True OrElse PortalSecurity.IsInRoles(PropertySettings.PermissionAddImages) = True OrElse PortalSecurity.IsInRoles(PropertySettings.PermissionApprove) = True))) Then
If (PropertySettings.UploadPlacement = UploadPlacementType.InlineTop) Then
Dim objPhotoController As New PhotoController
Dim objPhotos As ArrayList = objPhotoController.List(Null.NullInteger, CType(phTop.Controls(1), Controls.EditPropertyPhotos).PropertyGuid)
For Each objPhoto As PhotoInfo In objPhotos
objPhoto.PropertyID = _property.PropertyID
objPhoto.PropertyGuid = Null.NullString
objPhotoController.Update(objPhoto)
Next
End If
If (PropertySettings.UploadPlacement = UploadPlacementType.InlineBottom) Then
Dim objPhotoController As New PhotoController
Dim objPhotos As ArrayList = objPhotoController.List(Null.NullInteger, CType(phBottom.Controls(1), Controls.EditPropertyPhotos).PropertyGuid)
For Each objPhoto As PhotoInfo In objPhotos
objPhoto.PropertyID = _property.PropertyID
objPhoto.PropertyGuid = Null.NullString
objPhotoController.Update(objPhoto)
Next
End If
End If
End If
If (_property.Status = StatusType.AwaitingApproval) Then
If Not (IsEditable Or PortalSecurity.IsInRoles(PropertySettings.PermissionApprove)) Then
' Send Approval Email
Dim objLayoutController As New LayoutController(PortalSettings, PropertySettings, Page, Nothing, False, TabId, ModuleId, ModuleKey)
' Get the layout for subject and body
Dim objLayoutSubject As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Submission_Subject_Html)
Dim objLayoutBody As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Submission_Body_Html)
' Get the processed layout for subject and body
Dim phProperty As New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutSubject.Tokens, _property, CustomFields, Nothing, False)
Dim subject As String = RenderControlAsString(phProperty)
phProperty = New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutBody.Tokens, _property, CustomFields, Nothing, False)
Dim body As String = RenderControlAsString(phProperty)
phProperty = Nothing
If (Me.PropertySettings.NotificationEmail <> "") Then
Try
DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, Me.PropertySettings.NotificationEmail, "", "",
DotNetNuke.Services.Mail.MailPriority.Normal,
subject,
DotNetNuke.Services.Mail.MailFormat.Text, System.Text.Encoding.UTF8, body,
"", hostSettings("SMTPServer"), hostSettings("SMTPAuthentication"), hostSettings("SMTPUsername"), hostSettings("SMTPPassword"))
Catch
End Try
End If
If (Me.PropertySettings.NotificationNotifyApprovers) Then
Dim emails As New Hashtable
Dim objAgentController As New AgentController(Me.PortalSettings, Me.PropertySettings, Me.PortalId)
Dim objApprovers As ArrayList = objAgentController.ListApprovers()
For Each objApprover As UserInfo In objApprovers
If (emails.ContainsKey(objApprover.Email) = False) Then
emails.Add(objApprover.Email, objApprover.Email)
End If
Next
For Each item As DictionaryEntry In emails
Try
DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, item.Value.ToString(), "", "",
DotNetNuke.Services.Mail.MailPriority.Normal,
subject,
DotNetNuke.Services.Mail.MailFormat.Text, System.Text.Encoding.UTF8, body,
"", hostSettings("SMTPServer"), hostSettings("SMTPAuthentication"), hostSettings("SMTPUsername"), hostSettings("SMTPPassword"))
Catch
End Try
Next
End If
End If
End If
If (Me.PropertySettings.NotificationNotifyOwner) Then
If (Request.IsAuthenticated AndAlso Me.UserId <> _property.AuthorID) Then
Dim objLayoutController As New LayoutController(PortalSettings, PropertySettings, Page, Nothing, False, TabId, ModuleId, ModuleKey)
Dim objLayoutSubject As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.ContactOwner_Subject_Html)
Dim objLayoutBody As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.ContactOwner_Body_Html)
Dim phProperty As New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutSubject.Tokens, _property, CustomFields, Nothing, False)
Dim subject As String = RenderControlAsString(phProperty)
phProperty = New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutBody.Tokens, _property, CustomFields, Nothing, False)
Dim body As String = RenderControlAsString(phProperty)
phProperty = Nothing
If (_property.Email <> "") Then
Try
DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, _property.Email, "", "",
DotNetNuke.Services.Mail.MailPriority.Normal,
subject,
DotNetNuke.Services.Mail.MailFormat.Text, System.Text.Encoding.UTF8, body,
"", hostSettings("SMTPServer"), hostSettings("SMTPAuthentication"), hostSettings("SMTPUsername"), hostSettings("SMTPPassword"))
Catch
End Try
End If
End If
End If
If (Me.PropertySettings.NotificationNotifyBroker) Then
If (Request.IsAuthenticated AndAlso Me.UserId <> _property.BrokerID) Then
Dim objLayoutController As New LayoutController(PortalSettings, PropertySettings, Page, Nothing, False, TabId, ModuleId, ModuleKey)
Dim objLayoutSubject As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.ContactBroker_Subject_Html)
Dim objLayoutBody As LayoutInfo = objLayoutController.GetLayout(Me.PropertySettings.Template, LayoutType.ContactBroker_Body_Html)
Dim phProperty As New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutSubject.Tokens, _property, CustomFields, Nothing, False)
Dim subject As String = RenderControlAsString(phProperty)
phProperty = New System.Web.UI.WebControls.PlaceHolder
objLayoutController.ProcessItem(phProperty.Controls, objLayoutBody.Tokens, _property, CustomFields, Nothing, False)
Dim body As String = RenderControlAsString(phProperty)
phProperty = Nothing
If (_property.BrokerEmail <> "") Then
Try
DotNetNuke.Services.Mail.Mail.SendMail(PortalSettings.Email, _property.BrokerEmail, "", "",
DotNetNuke.Services.Mail.MailPriority.Normal,
subject,
DotNetNuke.Services.Mail.MailFormat.Text, System.Text.Encoding.UTF8, body,
"", hostSettings("SMTPServer"), hostSettings("SMTPAuthentication"), hostSettings("SMTPUsername"), hostSettings("SMTPPassword"))
Catch
End Try
End If
End If
End If
PropertyTypeController.RemoveCache(Me.ModuleId)
Dim fieldsToUpdate As New Hashtable
Dim objCustomFields As List(Of CustomFieldInfo) = Me.CustomFields
For Each item As RepeaterItem In rptDetails.Items
Dim phValue As PlaceHolder = CType(item.FindControl("phValue"), PlaceHolder)
If Not (phValue Is Nothing) Then
If (phValue.Controls.Count > 0) Then
Dim objControl As System.Web.UI.Control = phValue.Controls(0)
Dim customFieldID As Integer = Convert.ToInt32(objControl.ID.Split("_")(0))
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.CustomFieldID = customFieldID) Then
Select Case objCustomField.FieldType
Case CustomFieldType.OneLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
If objTextBox.Enabled Then
'Only if could be modified - not read-only (lockdown)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
If (PropertySettings.CustomFieldExpiration <> Null.NullInteger) Then
If (objCustomField.ValidationType = CustomFieldValidationType.Date) Then
If (objCustomField.CustomFieldID = PropertySettings.CustomFieldExpiration) Then
If (objTextBox.Text <> "") Then
Try
Dim expirationDate As DateTime = Convert.ToDateTime(objTextBox.Text)
If (PropertySettings.DefaultExpiration <> Null.NullInteger And PropertySettings.DefaultExpirationPeriod <> "") Then
Select Case PropertySettings.DefaultExpirationPeriod
Case "D"
expirationDate = expirationDate.AddDays(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
Case "M"
expirationDate = expirationDate.AddMonths(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
Case "Y"
expirationDate = expirationDate.AddYears(Convert.ToInt32(PropertySettings.DefaultExpiration))
Exit Select
End Select
End If
_property.DateExpired = expirationDate
objPropertyController.Update(_property)
Catch
End Try
End If
End If
End If
End If
End If
Case CustomFieldType.MultiLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
If objTextBox.Enabled Then
'Only if could be modified - not read-only (lockdown)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
End If
Case CustomFieldType.RichTextBox
Try
'If is a TextEditor, is not read-only
Dim objTextBox As TextEditor = CType(objControl, TextEditor)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Catch
'When LockDown, it's a Label instead of a TextEditor
Dim objTextBox As Label = CType(objControl, Label)
If objTextBox.Enabled Then
'Only if could be modified - not read-only (lockdown)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
End If
End Try
Case CustomFieldType.DropDownList
Dim objDropDownList As DropDownList = CType(objControl, DropDownList)
If objDropDownList.Enabled Then
'Only if could be modified - not read-only (lockdown)
If (objDropDownList.SelectedValue = "-1") Then
fieldsToUpdate.Add(customFieldID.ToString(), "")
Else
fieldsToUpdate.Add(customFieldID.ToString(), objDropDownList.SelectedValue)
End If
End If
Case CustomFieldType.CheckBox
Dim objCheckBox As CheckBox = CType(objControl, CheckBox)
If objCheckBox.Enabled Then
'Only if could be modified - not read-only (lockdown)
fieldsToUpdate.Add(customFieldID.ToString(), objCheckBox.Checked.ToString())
End If
Case CustomFieldType.MultiCheckBox
Dim objCheckBoxList As CheckBoxList = CType(objControl, CheckBoxList)
If objCheckBoxList.Enabled Then
'Only if could be modified - not read-only (lockdown)
Dim values As String = ""
For Each objCheckBox As ListItem In objCheckBoxList.Items
If (objCheckBox.Selected) Then
If (values = "") Then
values = objCheckBox.Value
Else
values = values & "|" & objCheckBox.Value
End If
End If
Next
fieldsToUpdate.Add(customFieldID.ToString(), values)
End If
Case CustomFieldType.RadioButton
Dim objRadioButtonList As RadioButtonList = CType(objControl, RadioButtonList)
If objRadioButtonList.Enabled Then
'Only if could be modified - not read-only (lockdown)
fieldsToUpdate.Add(customFieldID.ToString(), objRadioButtonList.SelectedValue)
End If
Case CustomFieldType.FileUpload
Dim objFileUpload As HtmlInputFile = CType(objControl, HtmlInputFile)
If Not (objFileUpload.PostedFile Is Nothing) Then
' Delete old one
Dim objPropertyValueController As New PropertyValueController
Dim objPropertyValue As PropertyValueInfo = objPropertyValueController.GetByCustomField(_propertyID, Convert.ToInt32(customFieldID.ToString()), Me.ModuleId)
If Not (objPropertyValue Is Nothing) Then
Dim fileToDelete = PortalSettings.HomeDirectoryMapPath & objPropertyValue.CustomValue
If (File.Exists(fileToDelete)) Then
File.Delete(fileToDelete)
End If
objPropertyValueController.Delete(_propertyID, objPropertyValue.PropertyValueID)
End If
If (objFileUpload.PostedFile.ContentLength > 0) Then
If (Me.PropertySettings.MaxUploadLimit <> "") AndAlso (CInt(Me.PropertySettings.MaxUploadLimit) > 0) Then
Dim LimitKBFileUpload As Long = (Me.PropertySettings.MaxUploadLimit * 1024 * 1024)
Dim TotalFolderSize As Long = FolderSize(PortalSettings.HomeDirectoryMapPath & "PropertyAgent\" & ModuleId.ToString() & "\Files\") + objFileUpload.PostedFile.ContentLength
' Upload new one if I've no reached maximum upload size
If TotalFolderSize <= LimitKBFileUpload Then
Dim filePath As String = PortalSettings.HomeDirectoryMapPath & "PropertyAgent\" & ModuleId.ToString() & "\Files\" & _propertyID.ToString() & "\"
Dim fileName As String = Path.GetFileName(objFileUpload.PostedFile.FileName)
Dim relativePath As String = "PropertyAgent\" & ModuleId.ToString() & "\Files\" & _propertyID.ToString() & "\" & fileName
If (Directory.Exists(filePath) = False) Then
Directory.CreateDirectory(filePath)
End If
objFileUpload.PostedFile.SaveAs(filePath & fileName)
fieldsToUpdate.Add(customFieldID.ToString(), relativePath)
Else
MaxUploadLimit = True
Dim valMaxUploadLimitExcedeed As New CustomValidator
valMaxUploadLimitExcedeed = phValue.FindControl(objControl.ID.Split("_")(0) & "_valMaxUploadLimitExcedeed")
valMaxUploadLimitExcedeed.ErrorMessage = "File not uploaded. Folder Max Size Exceeded." & " Actual folder total size (MB): " & CType(FolderSize(PortalSettings.HomeDirectoryMapPath & "PropertyAgent\" & ModuleId.ToString() & "\Files\"), Integer) / 1024 / 1024 & " Max Allowed (MB):" & Me.PropertySettings.MaxUploadLimit
valMaxUploadLimitExcedeed.IsValid = False
valMaxUploadLimitExcedeed.SetFocusOnError = True
End If
End If
End If
End If