/** * Restore an object to a certain revision. * * @param string id of revision to restore object to. * @return boolean true on success. */ public function restore_to_revision($revision) { $new = $this->get_revision($revision); try { $object = midcom::get('dbfactory')->get_object_by_guid($this->_guid); } catch (midcom_error $e) { debug_add("{$this->_guid} could not be resolved to object", MIDCOM_LOG_ERROR); return false; } $mapper = new midcom_helper_xml_objectmapper(); $object = $mapper->data2object($new, $object); $object->set_rcs_message("Reverted to revision {$revision}"); if ($object->update()) { return true; } $this->error[] = "Object {$this->_guid} not updated: " . midcom_connection::get_error_string(); return false; }
<?php // This is a style element so the XML output can easily be modified to whatever is needed: DOAP, ... $mapper = new midcom_helper_xml_objectmapper(); $label = $data['datamanager']->schema->name; if ($label == 'default') { $label = 'product'; } $extradata = array(); if (midcom::get('componentloader')->is_installed('net.nehmer.comments')) { $comments_db = net_nehmer_comments_comment::list_by_objectguid_filter_anonymous($data['product']->guid); foreach ($comments_db as $i => $comment) { $extradata['comments'][] = array('guid' => $comment->guid, 'author' => $comment->author, 'title' => $comment->title, 'content' => $comment->content, 'published' => $comment->metadata->published, 'rating' => $comment->rating); } } echo $mapper->dm2data($data['datamanager'], $label, $extradata);