# ===== v 4.3.9 =====

INSERT INTO ImportScripts VALUES (DEFAULT, 'Articles from CSV file [In-News]', '', 'n', 'In-News', '', 'CSV', '1');

# ===== v 5.0.0 =====
ALTER TABLE News ADD INDEX (StartDate), ADD INDEX (Archived);

UPDATE Category SET Template = '/in-news/designs/section' WHERE Template = 'innews/index';
UPDATE Category SET CachedTemplate = '/in-news/designs/section' WHERE CachedTemplate = 'innews/index';

UPDATE ConfigurationValues SET VariableValue = '/in-news/designs/section' WHERE VariableName = 'n_CategoryTemplate';
UPDATE ConfigurationValues SET VariableValue = 'in-news/designs/detail' WHERE VariableName = 'n_ItemTemplate';

INSERT INTO Permissions VALUES (DEFAULT, 'in-news:articles.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-news:setting_folder.view', 11, 1, 1, 0);
DELETE FROM Permissions WHERE Permission LIKE 'in-news:innews_general.%';

UPDATE Phrase SET Module = 'In-News' WHERE ((Phrase LIKE '%Article%' OR Phrase LIKE '%News%') AND (Module = 'Core') AND Phrase NOT IN ('la_ToolTip_NewSearchConfig', 'la_tooltip_newstylesheet'));

UPDATE Phrase SET Module = 'In-News' WHERE Phrase = 'la_title_In-News';

# ===== v 5.0.1 =====
UPDATE ConfigurationValues SET VariableValue = 'in-news/articles/article_detail' WHERE VariableName = 'n_ItemTemplate';

UPDATE ConfigurationAdmin
SET ValueList = 'ReviewText=la_opt_CommentText,CreatedOn=la_opt_CreatedOn'
WHERE VariableName IN ('News_SortReviews', 'News_SortReviews2');

UPDATE ConfigurationAdmin SET ValueList = 'ASC=la_common_Ascending,DESC=la_common_Descending'
WHERE VariableName IN ('News_SortReviewsOrder', 'News_SortReviewsOrder2');

UPDATE ConfigurationAdmin
SET ValueList = '1=la_opt_Sec,60=la_opt_Min,3600=la_opt_Hour,86400=la_opt_Day,604800=la_opt_Week,2419200=la_opt_Month,29030400=la_opt_Year'
WHERE VariableName IN ('News_ReviewDelay_Interval', 'News_RatingDelay_Interval');

UPDATE CustomField SET FieldLabel = 'la_fld_RssSource', Prompt = 'la_fld_RssSource' WHERE FieldName = 'RssSource';
UPDATE CustomField SET FieldLabel = 'la_fld_RssDefaultExpiration', Prompt = 'la_fld_RssDefaultExpiration' WHERE FieldName = 'RssDefaultExpiration';
UPDATE CustomField SET FieldLabel = 'la_fld_RssUpdateInterval', Prompt = 'la_fld_RssUpdateInterval' WHERE FieldName = 'RssUpdateInterval';
UPDATE CustomField SET FieldLabel = 'la_fld_RssExpireInterval', Prompt = 'la_fld_RssExpireInterval' WHERE FieldName = 'RssExpireInterval';
UPDATE CustomField SET FieldLabel = 'la_fld_RssDeleteExpired', Prompt = 'la_fld_RssDeleteExpired' WHERE FieldName = 'RssDeleteExpired';

UPDATE CustomField SET FieldLabel = 'la_fld_RssLastExpired', Prompt = 'la_fld_RssLastExpired' WHERE FieldName = 'RssLastExpired';
UPDATE CustomField SET FieldLabel = 'la_fld_RssDefaultExpirationType', Prompt = 'la_fld_RssDefaultExpirationType' WHERE FieldName = 'RssDefaultExpirationType';
UPDATE CustomField SET FieldLabel = 'la_fld_RssExpireIntervalType', Prompt = 'la_fld_RssExpireIntervalType' WHERE FieldName = 'RssExpireIntervalType';
UPDATE CustomField SET FieldLabel = 'la_fld_RssUpdateIntervalType', Prompt = 'la_fld_RssUpdateIntervalType' WHERE FieldName = 'RssUpdateIntervalType';
UPDATE CustomField SET FieldLabel = 'la_fld_RssLastUpdated', Prompt = 'la_fld_RssLastUpdated' WHERE FieldName = 'RssLastUpdated';
UPDATE CustomField SET FieldLabel = 'la_fld_RssArticleCRC', Prompt = 'la_fld_RssArticleCRC' WHERE FieldName = 'RssArticleCRC';
UPDATE CustomField SET FieldLabel = 'la_fld_cust_n_ItemTemplate', Prompt = 'la_fld_cust_n_ItemTemplate' WHERE FieldName = 'n_ItemTemplate';

INSERT INTO Events VALUES(DEFAULT, 'NEWS.REVIEW.ADD.PENDING', NULL, 1, 0, NULL, 'In-News', 'la_event_article.review.add.pending', 1);

UPDATE ConfigurationAdmin SET ValueList = 'style="width: 50px;"' WHERE VariableName IN ('News_ReviewDelay_Value', 'News_RatingDelay_Value');

# ===== v 5.0.2-B1 =====
ALTER TABLE News
	CHANGE CreatedOn CreatedOn INT(11) NULL DEFAULT NULL,
	CHANGE StartDate StartDate INT(11) NULL DEFAULT NULL,
	CHANGE Modified Modified INT(11) NULL DEFAULT NULL;

# ===== v 5.0.2-B2 =====

# ===== v 5.0.2-RC1 =====

# ===== v 5.0.2 =====

# ===== v 5.0.3-B1 =====

# ===== v 5.0.3-B2 =====

# ===== v 5.0.3-RC1 =====

# ===== v 5.0.3 =====

# ===== v 5.0.4-B1 =====

# ===== v 5.0.4-B2 =====

# ===== v 5.0.4 =====

# ===== v 5.1.0-B1 =====
UPDATE Modules SET Path = 'modules/in-news/' WHERE `Name` = 'In-News';
DELETE FROM ConfigurationValues WHERE VariableName IN (
	'Article_Root', 'News_PopCount', 'News_ArticleSort', 'News_CatSort', 'News_ShowMulti',
	'News_Admin_Notice_New', 'News_Admin_Notice_Modify', 'News_Admin_Notice_Suggest',
	'News_User_Notice_New', 'News_User_Notice_Approve', 'News_User_Notice_Deny',
	'News_User_Notice_Modify', 'News_User_Notice_Modify_Approve', 'News_User_Notice_Modify_Deny'
);

DELETE FROM Permissions WHERE Permission LIKE 'in-news:configuration_email%';

# ===== v 5.1.0-RC1 =====

# ===== v 5.1.0 =====

# ===== v 5.1.1-B1 =====
ALTER TABLE News
	CHANGE CreatedById CreatedById INT(11) NULL DEFAULT NULL ,
	CHANGE ModifiedById ModifiedById INT(11) NULL DEFAULT NULL;

# ===== v 5.1.1-RC1 =====

# ===== v 5.1.1 =====

# ===== v 5.1.2-B1 =====

# ===== v 5.1.2-RC1 =====

# ===== v 5.1.2 =====

# ===== v 5.1.3-B1 =====

# ===== v 5.1.3-RC1 =====
UPDATE ConfigurationValues
SET VariableValue = 'in-news/articles/article_detail'
WHERE VariableName = 'n_ItemTemplate' AND VariableValue = 'in-news/designs/detail';

# ===== v 5.1.3-RC2 =====

# ===== v 5.1.3 =====
UPDATE Phrase
SET `Module` = 'Core'
WHERE PhraseKey = 'LA_FLD_STARTDATE';

# ===== v 5.2.0-B1 =====
DELETE FROM SystemSettings
WHERE VariableName IN ('News_Highlight_OpenTag', 'News_Highlight_CloseTag');

# ===== v 5.2.0-B2 =====
UPDATE News main_table
SET main_table.CachedReviewsQty = (SELECT COUNT(*) FROM <%TABLE_PREFIX%>CatalogReviews review_table WHERE review_table.ItemId = main_table.ResourceId);

# ===== v 5.2.0-B3 =====

# ===== v 5.2.0-RC1 =====

# ===== v 5.2.0 =====
INSERT INTO Permissions VALUES(DEFAULT, 'in-news:configuration_output.add', 11, 1, 1, 0);

# ===== v 5.2.1-B1 =====
UPDATE SystemSettings
SET DisplayOrder = 20.04
WHERE VariableName = 'Perpage_NewsReviews';

# ===== v 5.2.1-B2 =====
UPDATE Modules
SET ClassNamespace = 'Intechnic\\InPortal\\Modules\\InNews'
WHERE `Name` = 'In-News';

# ===== v 5.2.1-RC1 =====

# ===== v 5.2.1 =====

# ===== v 5.2.2-B1 =====

# ===== v 5.2.2-B2 =====
UPDATE Modules
SET ClassNamespace = 'InPortal\\Modules\\InNews'
WHERE `Name` = 'In-News';

# ===== v 5.3.0-B1 =====
# Backported in http://jira.in-portal.org/browse/INP-1690.
# UPDATE Modules
# SET ClassNamespace = 'InPortal\\Modules\\InNews'
# WHERE `Name` = 'In-News';

INSERT INTO SearchConfig VALUES ('News', 'MetaKeywords', 0, 1, '', 'lc_field_MetaKeywords', 'In-News', 'la_text_article', 27, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO SearchConfig VALUES ('News', 'MetaDescription', 0, 1, '', 'lc_field_MetaDescription', 'In-News', 'la_text_article', 28, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
