fix checkbox entryproperties re-sets

References  and  and commit 8b51c37
Closes 
This commit is contained in:
Ian 2015-12-11 17:07:48 +01:00
parent bb0bae1cd9
commit 7fe8d91bc2

@ -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;
}