From 7fe8d91bc2ffa7501832013d1debcfdc2016f75c Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 11 Dec 2015 17:07:48 +0100 Subject: [PATCH] fix checkbox entryproperties re-sets References #260 and #261 and commit 8b51c37 Closes #376 --- .../serendipity_event_entryproperties.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 4a4edea1..8a993fc9 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -15,7 +15,7 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '1.38'); + $propbag->add('version', '1.39'); $propbag->add('requirements', array( 'serendipity' => '1.6', 'smarty' => '2.6.27', @@ -215,12 +215,21 @@ class serendipity_event_entryproperties extends serendipity_event $property = serendipity_fetchEntryProperties($eventData['id']); $supported_properties = serendipity_event_entryproperties::getSupportedProperties(); - // cleanup properties first, if none disable_markups plugins were set or a previous selected was reset + // Cleanup properties first, if none disable_markups plugins were set, or a previous selected one was re-set if (is_array($serendipity['POST']['properties']) && !is_array($serendipity['POST']['properties']['disable_markups'])) { $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'"; serendipity_db_query($q); } + // Special case for input type checkbox entryproperties + $reset_properties = array('is_sticky', 'no_frontpage', 'hiderss'); + foreach($reset_properties AS $property) { + if (!isset($serendipity['POST']['propertyform']) && is_array($serendipity['POST']['properties']) && !in_array($property, $serendipity['POST']['properties'])) { + $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = 'ep_{$property}'"; + serendipity_db_query($q); + } + } + // Special case for disable markups. if (is_array($properties['disable_markups'])) { $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property LIKE 'ep_disable_markup_%'"; @@ -238,7 +247,7 @@ class serendipity_event_entryproperties extends serendipity_event // possibly only wants to update entry metadata and left out any specific properties, which need to be kept. // An empty string like "" will properly remove an entryproperty, and POST values will always set an array index to an empty string. // $serendipipty['POST']['propertyform'] will be set whenever the entryeditor was properly displayed and unticked checkboxes shall remain. - // (Not for checkboxes, but checkboxes are not used for entryproperties) + // (Not for checkboxes, but checkboxes are not used for entryproperties) - (Edit: Well, actually we do have some, see reset special case checkboxed properties above!) if (!isset($properties[$prop_key]) && !isset($serendipity['POST']['propertyform'])) { continue; }