make updertEntry not loose category associations

This commit is contained in:
Garvin Hicking 2014-03-05 15:40:47 +01:00
parent 19192b289d
commit f1418ebe7d
4 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,7 @@
3.47:
-----
Make updertEntry not loose possible category associations
3.46:
-----

View file

@ -72,7 +72,7 @@ class serendipity_event_freetag extends serendipity_event
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('version', '3.46');
$propbag->add('version', '3.47');
$propbag->add('event_hooks', array(
'frontend_fetchentries' => true,
'frontend_fetchentry' => true,
@ -1715,6 +1715,12 @@ class serendipity_event_freetag extends serendipity_event
unset($entry['email']);
printf('%d - "%s"<br />', $entry['id'], htmlspecialchars($entry['title']));
$serendipity['POST']['properties']['fake'] = 'fake';
$current_cat = $entry['categories'];
$entry['categories'] = array();
foreach($current_cat AS $categoryidx => $category_data) {
$entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
}
$up = serendipity_updertEntry($entry);
if (is_string($up)) {
echo "<div>$up</div>\n";

View file

@ -1,3 +1,6 @@
1.16:
* Fixed error when saving an entry, which would loose its category association
1.15:
* Fixed foreach warning in some cases

View file

@ -26,7 +26,7 @@ class serendipity_event_trackback extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_MTRACKBACK_TITLEDESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Malte Paskuda');
$propbag->add('version', '1.15');
$propbag->add('version', '1.16');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
@ -286,6 +286,13 @@ class serendipity_event_trackback extends serendipity_event
unset($stored_entry['email']);
}
# Convert fetched categories to storable categories.
$current_cat = $stored_entry['categories'];
$stored_entry['categories'] = array();
foreach($current_cat AS $categoryidx => $category_data) {
$stored_entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
}
ob_start();
serendipity_updertEntry($stored_entry);
ob_end_clean();