Skip to content

Commit

Permalink
Address issue s9y#261
Browse files Browse the repository at this point in the history
Prevent resetting entryproperties when using serendipity_updertEntry
  • Loading branch information
garvinhicking committed Jan 15, 2015
1 parent 0cce75c commit 8b51c37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Version 2.0 ()
------------------------------------------------------------------------

* Fix entryproperties being removed when publishing an article
from the dashboard and by specific plugins (freetag, trackback)
that modify entry data.

* Fix deleting comments when user is not an admin, but the entry
belongs to him. Thanks to berberic.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function introspect(&$propbag)
$propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.35');
$propbag->add('version', '1.36');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
Expand Down Expand Up @@ -210,6 +210,7 @@ function applyProperties(&$properties) {

function addProperties(&$properties, &$eventData) {
global $serendipity;

// Get existing data
$property = serendipity_fetchEntryProperties($eventData['id']);
$supported_properties = serendipity_event_entryproperties::getSupportedProperties();
Expand All @@ -233,6 +234,15 @@ function addProperties(&$properties, &$eventData) {
serendipity_plugin_api::hook_event('backend_entryproperties', $supported_properties);

foreach($supported_properties AS $prop_key) {
// Do not delete a property if it is not subbmitted to this function, because serendipity_updertEntry
// 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)
if (!isset($properties[$prop_key]) && !isset($serendipity['POST']['propertyform'])) {
continue;
}

$prop_val = (isset($properties[$prop_key]) ? $properties[$prop_key] : null);
$prop_key = 'ep_' . $prop_key;

Expand Down Expand Up @@ -561,6 +571,7 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {

?>
<fieldset class="entryproperties">
<input type="hidden" name="serendipity[propertyform]" value="true" />
<span class="wrap_legend"><legend><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_TITLE; ?></legend></span>
<?php

Expand Down

0 comments on commit 8b51c37

Please sign in to comment.