/** * Utility function used by import_entity_plugin_hook() to * process an ODDEntity into an unsaved \ElggEntity. * * @param ODDEntity $element The OpenDD element * * @return \ElggEntity the unsaved entity which should be populated by items. * @todo Remove this. * @access private * * @throws ClassException|InstallationException|ImportException * @deprecated 1.9 */ function oddentity_to_elggentity(ODDEntity $element) { elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', 1.9); $class = $element->getAttribute('class'); $subclass = $element->getAttribute('subclass'); // See if we already have imported this uuid $tmp = get_entity_from_uuid($element->getAttribute('uuid')); if (!$tmp) { // Construct new class with owner from session $classname = get_subtype_class($class, $subclass); if ($classname) { if (class_exists($classname)) { $tmp = new $classname(); if (!$tmp instanceof \ElggEntity) { $msg = $classname . " is not a " . get_class() . "."; throw new \ClassException($msg); } } else { error_log("Class '" . $classname . "' was not found, missing plugin?"); } } else { switch ($class) { case 'object': $tmp = new \ElggObject(); break; case 'user': $tmp = new \ElggUser(); break; case 'group': $tmp = new \ElggGroup(); break; case 'site': $tmp = new \ElggSite(); break; default: $msg = "Type " . $class . " is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."; throw new \InstallationException($msg); } } } if ($tmp) { if (!$tmp->import($element)) { $msg = "Could not import element " . $element->getAttribute('uuid'); throw new \ImportException($msg); } return $tmp; } return NULL; }
/** * Utility function used by import_entity_plugin_hook() to * process an ODDEntity into an unsaved ElggEntity. * * @param ODDEntity $element The OpenDD element * * @return ElggEntity the unsaved entity which should be populated by items. * @todo Remove this. * @access private */ function oddentity_to_elggentity(ODDEntity $element) { $class = $element->getAttribute('class'); $subclass = $element->getAttribute('subclass'); // See if we already have imported this uuid $tmp = get_entity_from_uuid($element->getAttribute('uuid')); if (!$tmp) { // Construct new class with owner from session $classname = get_subtype_class($class, $subclass); if ($classname != "") { if (class_exists($classname)) { $tmp = new $classname(); if (!$tmp instanceof ElggEntity) { $msg = elgg_echo('ClassException:ClassnameNotClass', array($classname, get_class())); throw new ClassException($msg); } } else { error_log(elgg_echo('ClassNotFoundException:MissingClass', array($classname))); } } else { switch ($class) { case 'object': $tmp = new ElggObject($row); break; case 'user': $tmp = new ElggUser($row); break; case 'group': $tmp = new ElggGroup($row); break; case 'site': $tmp = new ElggSite($row); break; default: $msg = elgg_echo('InstallationException:TypeNotSupported', array($class)); throw new InstallationException($msg); } } } if ($tmp) { if (!$tmp->import($element)) { $msg = elgg_echo('ImportException:ImportFailed', array($element->getAttribute('uuid'))); throw new ImportException($msg); } return $tmp; } return NULL; }
/** * Export this class into an array of ODD Elements containing all necessary fields. * Override if you wish to return more information than can be found in * $this->attributes (shouldn't happen) * * @return array * @deprecated 1.9 */ public function export() { elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9); $tmp = array(); // Generate uuid $uuid = guid_to_uuid($this->getGUID()); // Create entity $odd = new ODDEntity($uuid, $this->attributes['type'], get_subtype_from_id($this->attributes['subtype'])); $tmp[] = $odd; $exportable_values = $this->getExportableValues(); // Now add its attributes foreach ($this->attributes as $k => $v) { $meta = null; if (in_array($k, $exportable_values)) { switch ($k) { case 'guid': // Dont use guid in OpenDD // Dont use guid in OpenDD case 'type': // Type and subtype already taken care of // Type and subtype already taken care of case 'subtype': break; case 'time_created': // Created = published $odd->setAttribute('published', date("r", $v)); break; case 'site_guid': // Container $k = 'site_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v); break; case 'container_guid': // Container $k = 'container_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v); break; case 'owner_guid': // Convert owner guid to uuid, this will be stored in metadata $k = 'owner_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v); break; default: $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v); } // set the time of any metadata created if ($meta) { $meta->setAttribute('published', date("r", $this->time_created)); $tmp[] = $meta; } } } // Now we do something a bit special. /* * This provides a rendered view of the entity to foreign sites. */ elgg_set_viewtype('default'); $view = elgg_view_entity($this, array('full_view' => true)); elgg_set_viewtype(); $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, 'renderedentity', $view, 'volatile'); return $tmp; }