1+ // <copyright>
2+ // Copyright by the Spark Development Network
3+ //
4+ // Licensed under the Rock Community License (the "License");
5+ // you may not use this file except in compliance with the License.
6+ // You may obtain a copy of the License at
7+ //
8+ // http://www.rockrms.com/license
9+ //
10+ // Unless required by applicable law or agreed to in writing, software
11+ // distributed under the License is distributed on an "AS IS" BASIS,
12+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ // See the License for the specific language governing permissions and
14+ // limitations under the License.
15+ // </copyright>
16+
17+ using System ;
18+
19+ using Rock . Model ;
20+
21+ namespace Rock . Plugin . HotFixes
22+ {
23+ /// <summary>
24+ /// Plug-in migration
25+ /// </summary>
26+ /// <seealso cref="Rock.Plugin.Migration" />
27+ [ MigrationNumber ( 270 , "18.1" ) ]
28+ public class MigrationRollupsForV18_1_0 : Migration
29+ {
30+ /// <summary>
31+ /// Operations to be performed during the upgrade process.
32+ /// </summary>
33+ public override void Up ( )
34+ {
35+ UpdateCommunicationPageBlockAttributeForPersonBioBlock ( ) ;
36+ NA_ConvertBlockSettingsToNotUseObsidianComponentsUp ( ) ;
37+ NA_FixBrokenCampusPickerLavaShortcodeUp ( ) ;
38+ DH_FixMissingTablerIconInNextGenThemes ( ) ;
39+ }
40+
41+ /// <summary>
42+ /// Operations to be performed during the downgrade process.
43+ /// </summary>
44+ public override void Down ( )
45+ {
46+ NA_ConvertBlockSettingsToNotUseObsidianComponentsDown ( ) ;
47+ }
48+
49+ #region KH: Update Communication Page Block Attribute for Person Bio Block
50+
51+ private void UpdateCommunicationPageBlockAttributeForPersonBioBlock ( )
52+ {
53+ // Update the Communication Page Attribute Value if it is set to the old "Simple Communication" page.
54+ Sql ( @"
55+ UPDATE [dbo].[AttributeValue]
56+ SET [Value] = '9F7AE226-CC95-4E6A-B333-C0294A2024BC,01A3891B-9998-7E30-20DC-58081A239D65',
57+ [IsPersistedValueDirty] = 1
58+ WHERE [Value] = '7e8408b2-354c-4a5a-8707-36754ae80b9a'
59+ AND [AttributeId] = (SELECT [Id] FROM [dbo].[Attribute] WHERE [Guid] = '66CFDF24-8D19-4885-8C09-31DBE8C4126D' )
60+ " ) ;
61+ }
62+
63+ #endregion
64+
65+ #region [Beta v18.0.14] NA: v18.1 Migration to Set Data View Controls back to Webforms for DataViewDetail, ReportDetail, and DynamicReport block
66+
67+ /// <summary>
68+ /// Change any existing UseObsidianComponents block setting value for the
69+ /// Data View Detail, Report Detail and Dynamic Report blocks to False.
70+ /// </summary>
71+ public void NA_ConvertBlockSettingsToNotUseObsidianComponentsUp ( )
72+ {
73+ Sql ( @"
74+ UPDATE av
75+ SET
76+ av.[Value] = 'False',
77+ av.[PersistedTextValue] = 'No',
78+ av.[PersistedCondensedTextValue] = 'N',
79+ av.[PersistedCondensedHtmlValue] = 'N',
80+ av.[IsPersistedValueDirty] = 1,
81+ av.ValueAsBoolean = 0
82+ FROM dbo.[AttributeValue] AS av
83+ INNER JOIN dbo.[Attribute] AS a
84+ ON a.[Id] = av.[AttributeId]
85+ INNER JOIN dbo.[BlockType] AS bt
86+ ON bt.[Id] = TRY_CAST(a.[EntityTypeQualifierValue] AS INT)
87+ WHERE
88+ a.[Key] = 'UseObsidianComponents'
89+ AND a.[EntityTypeId] = 9
90+ AND a.[EntityTypeQualifierColumn] = 'BlockTypeId'
91+ AND bt.[Guid] IN (
92+ 'EB279DF9-D817-4905-B6AC-D9883F0DA2E4', -- Data View Detail
93+ 'E431DBDF-5C65-45DC-ADC5-157A02045CCD', -- Report Detail
94+ 'C7C069DB-9EEE-4245-9DF2-34E3A1FF4CCB' -- Dynamic Report
95+ )
96+ AND av.[Value] = 'True';
97+ " ) ;
98+ }
99+
100+ /// <summary>
101+ /// Change any existing UseObsidianComponents block setting value for the
102+ /// Data View Detail, Report Detail and Dynamic Report blocks back to True.
103+ /// </summary>
104+ public void NA_ConvertBlockSettingsToNotUseObsidianComponentsDown ( )
105+ {
106+ Sql ( @"
107+ UPDATE av
108+ SET
109+ av.[Value] = 'True',
110+ av.[PersistedTextValue] = 'Yes',
111+ av.[PersistedCondensedTextValue] = 'Y',
112+ av.[PersistedCondensedHtmlValue] = 'Y',
113+ av.[IsPersistedValueDirty] = 1,
114+ av.ValueAsBoolean = 1
115+ FROM dbo.[AttributeValue] AS av
116+ INNER JOIN dbo.[Attribute] AS a
117+ ON a.[Id] = av.[AttributeId]
118+ INNER JOIN dbo.[BlockType] AS bt
119+ ON bt.[Id] = TRY_CAST(a.[EntityTypeQualifierValue] AS INT)
120+ WHERE
121+ a.[Key] = 'UseObsidianComponents'
122+ AND a.[EntityTypeId] = 9
123+ AND a.[EntityTypeQualifierColumn] = 'BlockTypeId'
124+ AND bt.[Guid] IN (
125+ 'EB279DF9-D817-4905-B6AC-D9883F0DA2E4', -- Data View Detail
126+ 'E431DBDF-5C65-45DC-ADC5-157A02045CCD', -- Report Detail
127+ 'C7C069DB-9EEE-4245-9DF2-34E3A1FF4CCB' -- Dynamic Report
128+ )
129+ AND av.[Value] = 'False';
130+ " ) ;
131+ }
132+
133+ #endregion
134+
135+ #region NA: Fix broken CampusPicker Lava Shortcode
136+
137+ private const string HelixCategoryGuid = "5874AE45-B5EE-4D10-A274-26B5D69E6283" ;
138+
139+ #region Campus Picker
140+
141+ private const string CampusPickerTagName = "campuspicker" ;
142+ private const string CampusPickerGuid = "E787B188-2E0F-479E-A855-0E4ABA75C91B" ;
143+ private const string CampusPickerMarkup = @"//- Prep configuration settings
144+ {% assign sc-statusList = campusstatuses | Split:',' %}
145+ {% assign sc-typeList = campustypes | Split:',',true %}
146+ {% assign sc-selectableList = selectablecampuses | Split:',' %}
147+ {% assign sc-currentValues = value | Split:',' %} //- Note we're supporting the possibility that there could be multiple values.
148+ {% assign includeinactive = includeinactive | AsBoolean %}
149+ {% assign allowmultiple = allowmultiple | AsBoolean %}
150+
151+ //- Get source data
152+ {% assign sc-campuses = 'All' | FromCache:'Campus' %}
153+
154+ //- Filtering works by selecting all campuses that should not be shown
155+ //- and then removing them from the list. This means that configuration
156+ //- filters are AND not OR (which matches the C# logic).
157+
158+ //- Filter by type
159+ {% if sc-typeList != empty %}
160+
161+ {% for campus in sc-campuses reversed %}
162+ {% assign campusTypeId = campus.CampusTypeValueId | ToString %}
163+ {% assign isConfiguredType = sc-typeList | Contains:campusTypeId %}
164+ {% if isConfiguredType == false %}
165+ {% assign sc-campuses = sc-campuses | RemoveFromArray:campus %}
166+ {% endif %}
167+ {% endfor %}
168+
169+ {% endif %}
170+
171+ //- Filter by status
172+ {% if sc-statusList != empty %}
173+
174+ {% for campus in sc-campuses reversed %}
175+ {% assign campusStatusId = campus.CampusStatusValueId | ToString %}
176+ {% assign isConfiguredStatus = sc-statusList | Contains:campusStatusId %}
177+ {% if isConfiguredStatus == false %}
178+ {% assign sc-campuses = sc-campuses | RemoveFromArray:campus %}
179+ {% endif %}
180+ {% endfor %}
181+
182+ {% endif %}
183+
184+ //- Filter by selected
185+ {% if sc-selectableList != empty %}
186+
187+ {% for campus in sc-campuses reversed %}
188+ {% assign campusId = campus.Id | ToString %}
189+ {% assign isSelected = sc-selectableList | Contains:campusId %}
190+ {% if isSelected == false %}
191+ {% assign sc-campuses = sc-campuses | RemoveFromArray:campus %}
192+ {% endif %}
193+ {% endfor %}
194+
195+ {% endif %}
196+
197+ //- Remove inactive campuses
198+ {% if includeinactive == false %}
199+ {% assign sc-campuses = sc-campuses | Where:'IsActive',true %}
200+ {% endif %}
201+
202+ //- Ensure current values are still in the list, the value can be either a campus id or guid
203+ {% assign allCampuses = 'All' | FromCache:'Campus' %}
204+ {% for currentValue in sc-currentValues %}
205+ {% for campus in allCampuses %}
206+ {% assign campusId = campus.Id | ToString %}
207+ {% assign campusGuid = campus.Guid | ToString %}
208+ {% if campusId == currentValue or campusGuid == currentValue %}
209+ //- Ensure the campus list has this campus, if not add it
210+ {% assign isInCampusList = sc-campuses | Contains:campus %}
211+
212+ {% if isInCampusList == false %}
213+ {% assign sc-campuses = sc-campuses | AddToArray:campus %}
214+ {% endif %}
215+ {% endif %}
216+ {% endfor %}
217+ {% endfor %}
218+
219+ //- Sort Campuses
220+ {% assign sc-campuses = sc-campuses | OrderBy:'Order' %}
221+
222+ //- Control formatting
223+ {% if allowmultiple %}
224+ {[ checkboxlist label:'{{ label }}' showlabel:'{{ showlabel }}' name:'{{ name }}' isrequired:'{{ isrequired }}' value:'{{ value }}' columns:'4' controltype:'campus-picker' id:'{{ id }}' validationmessage:'{{ validationmessage }}' additionalattributes:'{{ additionalattributes}}' ]}
225+
226+ {% for campus in sc-campuses %}
227+ [[ item value:'{% if valuefield == 'id' %}{{ campus.Id }}{% else %}{{ campus.Guid }}{% endif %}' text:'{{ campus.Name }}' ]][[ enditem]]
228+ {% endfor %}
229+
230+ {[ endcheckboxlist ]}
231+ {% else %}
232+ {[ dropdown label:'{{ label }}' showlabel:'{{ showlabel }}' name:'{{ name }}' longlistenabled:'{{ longlistenabled }}' value:'{{ value }}' controltype:'campus-picker' isrequired:'{{ isrequired }}' id:'{{ id }}' validationmessage:'{{ validationmessage }}' additionalattributes:'{{ additionalattributes}}' ]}
233+
234+ {% for campus in sc-campuses %}
235+ [[ item value:'{% if valuefield == 'id' %}{{ campus.Id }}{% else %}{{ campus.Guid }}{% endif %}' text:'{{ campus.Name }}' ]][[ enditem]]
236+ {% endfor %}
237+
238+ {[ enddropdown ]}
239+ {% endif %}" ;
240+ private const string CampusPickerParameters = @"value^|includeinactive^false|campustypes^|campusstatuses^|selectablecampuses^|name^campus|isrequired^false|label^Campus|validationmessage^Please select a campus.|longlistenabled^false|valuefield^id|allowmultiple^false|additionalattributes^|showlabel^true" ;
241+ private const string CampusPickerDocumentation = @"<p>This control allows you to select a campus.</p>
242+
243+ <h5>Example Usage</h5>
244+ <pre>{[ campuspicker label:'Primary Campus' value:'1,2' allowmultiple:'true' campustypes:'768' campusstatuses:'765' selectablecampuses:'1,2,5' ]}</pre>
245+
246+ <h5>Parameters</h5>
247+ <p>Below are the parameters for the campus picker shortcode.</p>
248+ <ul>
249+ <li><strong>label</strong> - The label to display above the control.</li><li><b>showlabel </b>(true) - Whether to display label.</li>
250+ <li><strong>name</strong> (campus) - The name for the campus picker control.</li>
251+ <li><strong>value</strong> - The ID or Guid of the currently selected campus(es).</li>
252+ <li><strong>valuefield</strong> (id) - Specifies whether the picker's value should correspond to the campus' <code>id</code> or <code>guid</code>.</li>
253+ <li><strong>includeinactive</strong> (false) - Determines if inactive campuses should be displayed.</li>
254+ <li><strong>campustypes</strong> - Filters the campus list by type (comma separated list of defined value ids).</li>
255+ <li><strong>campusstatuses</strong> - Filters the campus list by status (comma separated list of defined value ids).</li>
256+ <li><strong>selectablecampuses</strong> - List of specific campuses to display (comma separated list of campus ids).</li>
257+ <li><strong>longlistenabled</strong> (false) - Enhances the functionality to include a search feature, facilitating swift and efficient selection of the preferred item from the list.</li>
258+ <li><strong>allowmultiple</strong> (false) - Determines if the selection of multiple values is allowed.</li><li><b>isrequired </b>(false) - Establishes whether making a selection is necessary.
259+ </li><li><b>validationmessage </b>(Please provide a campus.) - Message to display when the value is not valid.</li>
260+ <li><strong>additionalattributes</strong> - Additional attributes to include on the input control.</li>
261+ </ul>
262+
263+ <p>
264+ The above settings enable a wide range of filtering options for the list. Regardless of the filter configurations, the
265+ current value will consistently be shown.
266+ </p>" ;
267+ private const string CampusPickerDescription = "Displays a campus picker." ;
268+ private const int CampusPickerTagType = ( int ) TagType . Inline ;
269+
270+ #endregion
271+
272+ /// <summary>
273+ /// Change the typo in the CampusPicker Lava Shortcode to fix issue #6574.
274+ /// </summary>
275+ public void NA_FixBrokenCampusPickerLavaShortcodeUp ( )
276+ {
277+ RockMigrationHelper . AddOrUpdateLavaShortcode ( "Campus Picker" , CampusPickerTagName , CampusPickerDescription , CampusPickerDocumentation , CampusPickerMarkup , CampusPickerParameters , CampusPickerTagType , HelixCategoryGuid , CampusPickerGuid ) ;
278+ }
279+
280+ #endregion
281+
282+ #region DH: Fix missing Tabler icon in next-gen themes.
283+
284+ private void DH_FixMissingTablerIconInNextGenThemes ( )
285+ {
286+ Sql ( @"UPDATE [Theme]
287+ SET [AdditionalSettingsJson] = JSON_MODIFY([AdditionalSettingsJson], '$.ThemeCustomizationSettings.EnabledIconSets', 2 | JSON_VALUE([AdditionalSettingsJson], 'lax $.ThemeCustomizationSettings.EnabledIconSets'))
288+ WHERE ISJSON([AdditionalSettingsJson]) = 1
289+ AND JSON_VALUE([AdditionalSettingsJson], 'lax $.ThemeCustomizationSettings.EnabledIconSets') IS NOT NULL
290+ AND JSON_VALUE([AdditionalSettingsJson], 'lax $.ThemeCustomizationSettings.EnabledIconSets') & 2 = 0" ) ;
291+ }
292+
293+ #endregion
294+ }
295+ }
0 commit comments