diff options
Diffstat (limited to 'engine/classes')
24 files changed, 287 insertions, 168 deletions
diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 62128e34f..3d01133fa 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -92,7 +92,7 @@ class ElggBatch /** * Stop after this many results. * - * @var unknown_type + * @var int */ private $limit = 0; @@ -147,7 +147,9 @@ class ElggBatch * * @param string $getter The function used to get objects. Usually * an elgg_get_*() function, but can be any valid PHP callback. - * @param array $options The options array to pass to the getter function + * @param array $options The options array to pass to the getter function. If limit is + * not set, 10 is used as the default. In most cases that is not + * what you want. * @param mixed $callback An optional callback function that all results will be passed * to upon load. The callback needs to accept $result, $getter, * $options. @@ -234,13 +236,11 @@ class ElggBatch } // if original limit < chunk size, set limit to original limit + // else if the number of results we'll fetch if greater than the original limit if ($this->limit < $this->chunkSize) { $limit = $this->limit; - } - - // if the number of results we'll fetch is greater than the original limit, - // set the limit to the number of results remaining in the original limit - elseif ($this->retrievedResults + $this->chunkSize > $this->limit) { + } elseif ($this->retrievedResults + $this->chunkSize > $this->limit) { + // set the limit to the number of results remaining in the original limit $limit = $this->limit - $this->retrievedResults; } } @@ -319,13 +319,13 @@ class ElggBatch */ public function next() { // if we'll be at the end. - if ($this->processedResults + 1 >= $this->limit && $this->limit > 0) { + if (($this->processedResults + 1) >= $this->limit && $this->limit > 0) { $this->results = array(); return false; } // if we'll need new results. - if ($this->resultIndex + 1 >= $this->chunkSize) { + if (($this->resultIndex + 1) >= $this->chunkSize) { if (!$this->getNextResultsChunk()) { $this->results = array(); return false; @@ -356,4 +356,4 @@ class ElggBatch $key = key($this->results); return ($key !== NULL && $key !== FALSE); } -}
\ No newline at end of file +} diff --git a/engine/classes/ElggCache.php b/engine/classes/ElggCache.php index 5c2cafcb7..4317f4be9 100644 --- a/engine/classes/ElggCache.php +++ b/engine/classes/ElggCache.php @@ -29,7 +29,7 @@ abstract class ElggCache implements ArrayAccess { * * @return void * - * @deprecated 1.8 Use ElggAccess:setVariable() + * @deprecated 1.8 Use ElggCache:setVariable() */ public function set_variable($variable, $value) { elgg_deprecated_notice('ElggCache::set_variable() is deprecated by ElggCache::setVariable()', 1.8); @@ -191,8 +191,8 @@ abstract class ElggCache implements ArrayAccess { * * @see ArrayAccess::offsetSet() * - * @param mixed $key The key (offset) to assign the value to. - * @param mixed $value The value to set. + * @param mixed $key The key (offset) to assign the value to. + * @param mixed $value The value to set. * * @return void */ @@ -205,7 +205,7 @@ abstract class ElggCache implements ArrayAccess { * * @see ArrayAccess::offsetGet() * - * @param mixed $offset The key (offset) to retrieve. + * @param mixed $key The key (offset) to retrieve. * * @return mixed */ diff --git a/engine/classes/ElggDiskFilestore.php b/engine/classes/ElggDiskFilestore.php index 11b2bd947..f00376481 100644 --- a/engine/classes/ElggDiskFilestore.php +++ b/engine/classes/ElggDiskFilestore.php @@ -205,7 +205,7 @@ class ElggDiskFilestore extends ElggFilestore { $owner = elgg_get_logged_in_user_entity(); } - if ((!$owner) || (!$owner->username)) { + if (!$owner) { $msg = elgg_echo('InvalidParameterException:MissingOwner', array($file->getFilename(), $file->guid)); throw new InvalidParameterException($msg); diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index df87082fe..2fa8e9939 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -1583,36 +1583,36 @@ abstract class ElggEntity extends ElggData implements foreach ($this->attributes as $k => $v) { $meta = NULL; - if (in_array( $k, $exportable_values)) { + if (in_array($k, $exportable_values)) { switch ($k) { - case 'guid' : // Dont use guid in OpenDD - case 'type' : // Type and subtype already taken care of - case 'subtype' : - break; + case 'guid': // Dont use guid in OpenDD + case 'type': // Type and subtype already taken care of + case 'subtype': + break; - case 'time_created' : // Created = published + case 'time_created': // Created = published $odd->setAttribute('published', date("r", $v)); - break; + break; - case 'site_guid' : // Container + case 'site_guid': // Container $k = 'site_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + break; - case 'container_guid' : // Container + case 'container_guid': // Container $k = 'container_uuid'; $v = guid_to_uuid($v); $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); - break; + break; - case 'owner_guid' : // Convert owner guid to uuid, this will be stored in metadata + 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; + break; - default : + default: $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v); } diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php index d6f79d18d..d94bad837 100644 --- a/engine/classes/ElggExtender.php +++ b/engine/classes/ElggExtender.php @@ -3,8 +3,7 @@ * The base class for ElggEntity extenders. * * Extenders allow you to attach extended information to an - * ElggEntity. Core supports two: ElggAnnotation, ElggMetadata, - * and ElggRelationship + * ElggEntity. Core supports two: ElggAnnotation and ElggMetadata. * * Saving the extender data to database is handled by the child class. * @@ -16,9 +15,24 @@ * @link http://docs.elgg.org/DataModel/Extenders * @see ElggAnnotation * @see ElggMetadata + * + * @property string $type annotation or metadata (read-only after save) + * @property int $id The unique identifier (read-only) + * @property int $entity_guid The GUID of the entity that this extender describes + * @property int $access_id Specifies the visibility level of this extender + * @property string $name The name of this extender + * @property mixed $value The value of the extender (int or string) + * @property int $time_created A UNIX timestamp of when the extender was created (read-only, set on first save) */ -abstract class ElggExtender extends ElggData -{ +abstract class ElggExtender extends ElggData { + + /** + * (non-PHPdoc) + * + * @see ElggData::initializeAttributes() + * + * @return void + */ protected function initializeAttributes() { parent::initializeAttributes(); diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 0190e5eac..ab223e1a4 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -5,6 +5,9 @@ * * @package Elgg.Core * @subpackage Groups + * + * @property string $name A short name that captures the purpose of the group + * @property string $description A longer body of content that gives more details about the group */ class ElggGroup extends ElggEntity implements Friendable { diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index a54c29723..f27b017d0 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -114,27 +114,11 @@ class ElggMemcache extends ElggSharedMemoryCache { * Combine a key with the namespace. * Memcache can only accept <250 char key. If the given key is too long it is shortened. * - * @deprecated 1.8 Use ElggMemcache::_makeMemcacheKey() - * - * @param string $key The key - * - * @return string The new key. - */ - private function make_memcache_key($key) { - elgg_deprecated_notice('ElggMemcache::make_memcache_key() is deprecated by ::_makeMemcacheKey()', 1.8); - - return $this->_makeMemcacheKey($key); - } - - /** - * Combine a key with the namespace. - * Memcache can only accept <250 char key. If the given key is too long it is shortened. - * * @param string $key The key * * @return string The new key. */ - private function _makeMemcacheKey($key) { + private function makeMemcacheKey($key) { $prefix = $this->getNamespace() . ":"; if (strlen($prefix . $key) > 250) { @@ -154,7 +138,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return bool */ public function save($key, $data, $expires = null) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); if ($expires === null) { $expires = $this->expires; @@ -178,7 +162,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return mixed */ public function load($key, $offset = 0, $limit = null) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); $result = $this->memcache->get($key); if ($result === false) { @@ -196,7 +180,7 @@ class ElggMemcache extends ElggSharedMemoryCache { * @return bool */ public function delete($key) { - $key = $this->_makeMemcacheKey($key); + $key = $this->makeMemcacheKey($key); return $this->memcache->delete($key, 0); } diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php index cadfee7f5..de0017599 100644 --- a/engine/classes/ElggMenuBuilder.php +++ b/engine/classes/ElggMenuBuilder.php @@ -4,8 +4,7 @@ * * @package Elgg.Core * @subpackage Navigation - * - * @since 1.8.0 + * @since 1.8.0 */ class ElggMenuBuilder { @@ -16,16 +15,16 @@ class ElggMenuBuilder { /** * ElggMenuBuilder constructor * - * @param string $name Identifier of the menu + * @param array $menu Array of ElggMenuItem objects */ - public function __construct($menu) { + public function __construct(array $menu) { $this->menu = $menu; } /** * Get a prepared menu array * - * @param mixed $sort_by + * @param mixed $sort_by Method to sort the menu by. @see ElggMenuBuilder::sort() * @return array */ public function getMenu($sort_by = 'text') { @@ -80,6 +79,7 @@ class ElggMenuBuilder { /** * Group the menu items into sections + * * @return void */ protected function setupSections() { diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 62547134a..4bc9144d4 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -2,12 +2,11 @@ /** * Elgg Menu Item * - * @package Elgg.Core - * @subpackage Navigation - * * To create a menu item that is not a link, pass false for $href. * - * @since 1.8.0 + * @package Elgg.Core + * @subpackage Navigation + * @since 1.8.0 */ class ElggMenuItem { @@ -70,9 +69,9 @@ class ElggMenuItem { /** * ElggMenuItem constructor * - * @param string $name Identifier of the menu item - * @param string $text Display text of the menu item - * @param string $href URL of the menu item (false if not a link) + * @param string $name Identifier of the menu item + * @param string $text Display text of the menu item + * @param string $href URL of the menu item (false if not a link) */ public function __construct($name, $text, $href) { //$this->name = $name; @@ -182,7 +181,7 @@ class ElggMenuItem { /** * Set the identifier of the menu item * - * @param string Unique identifier + * @param string $name Unique identifier * @return void */ public function setName($name) { @@ -491,7 +490,7 @@ class ElggMenuItem { /** * Set the parent menu item * - * @param ElggMenuItem $parent + * @param ElggMenuItem $parent The parent of this menu item * @return void */ public function setParent($parent) { @@ -510,7 +509,7 @@ class ElggMenuItem { /** * Add a child menu item * - * @param ElggMenuItem $item + * @param ElggMenuItem $item A child menu item * @return void */ public function addChild($item) { @@ -549,9 +548,8 @@ class ElggMenuItem { /** * Get the menu item content (usually a link) * - * @params array $vars Options to pass to output/url if a link + * @param array $vars Options to pass to output/url if a link * @return string - * * @todo View code in a model. How do we feel about that? */ public function getContent(array $vars = array()) { diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php index 32e7b32f1..634a122e5 100644 --- a/engine/classes/ElggMetadata.php +++ b/engine/classes/ElggMetadata.php @@ -9,6 +9,13 @@ */ class ElggMetadata extends ElggExtender { + /** + * (non-PHPdoc) + * + * @see ElggData::initializeAttributes() + * + * @return void + */ protected function initializeAttributes() { parent::initializeAttributes(); diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php index 0b8340697..649e32490 100644 --- a/engine/classes/ElggObject.php +++ b/engine/classes/ElggObject.php @@ -14,6 +14,10 @@ * * @package Elgg.Core * @subpackage DataModel.Object + * + * @property string $title The title, name, or summary of this object + * @property string $description The body, description, or content of the object + * @property array $tags Array of tags that describe the object */ class ElggObject extends ElggEntity { diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index c4d6ec034..33f14ae37 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -707,9 +707,9 @@ class ElggPlugin extends ElggObject { * @throws PluginException */ public function start($flags) { -// if (!$this->canActivate()) { -// return false; -// } + //if (!$this->canActivate()) { + // return false; + //} // include classes if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index d240af477..2dc4bdb3d 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -303,6 +303,8 @@ class ElggPluginPackage { /** * Returns an array of present and readable text files + * + * @return array */ public function getTextFilenames() { return $this->textFiles; diff --git a/engine/classes/ElggRelationship.php b/engine/classes/ElggRelationship.php index 2d9a32cbd..efc0f7eff 100644 --- a/engine/classes/ElggRelationship.php +++ b/engine/classes/ElggRelationship.php @@ -4,6 +4,12 @@ * * @package Elgg.Core * @subpackage Core + * + * @property int $id The unique identifier (read-only) + * @property int $guid_one The GUID of the subject of the relationship + * @property string $relationship The name of the relationship + * @property int $guid_two The GUID of the object of the relationship + * @property int $time_created A UNIX timestamp of when the relationship was created (read-only, set on first save) */ class ElggRelationship extends ElggData implements Importable diff --git a/engine/classes/ElggRiverItem.php b/engine/classes/ElggRiverItem.php index fcc8f9c85..d3d09cd91 100644 --- a/engine/classes/ElggRiverItem.php +++ b/engine/classes/ElggRiverItem.php @@ -4,9 +4,19 @@ * * @package Elgg.Core * @subpackage Core + * + * @property int $id The unique identifier (read-only) + * @property int $subject_guid The GUID of the actor + * @property int $object_guid The GUID of the object + * @property int $annotation_id The ID of the annotation involved in the action + * @property string $type The type of one of the entities involved in the action + * @property string $subtype The subtype of one of the entities involved in the action + * @property string $action_type The name of the action + * @property string $view The view for displaying this river item + * @property int $access_id The visibility of the river item + * @property int $posted UNIX timestamp when the action occurred */ -class ElggRiverItem -{ +class ElggRiverItem { public $id; public $subject_guid; public $object_guid; diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 2d6238a19..ac0c87bf7 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -21,6 +21,10 @@ * @package Elgg.Core * @subpackage DataMode.Site * @link http://docs.elgg.org/DataModel/Sites + * + * @property string $name The name or title of the website + * @property string $description A motto, mission statement, or description of the website + * @property string $url The root web address for the site, including trailing slash */ class ElggSite extends ElggEntity { @@ -192,7 +196,7 @@ class ElggSite extends ElggEntity { * * @note You cannot disable the current site. * - * @param string $reason Optional reason for disabling + * @param string $reason Optional reason for disabling * @param bool $recursive Recursively disable all contained entities? * * @return bool @@ -215,7 +219,7 @@ class ElggSite extends ElggEntity { * accepted by elgg_get_entities(). Common parameters * include 'limit', and 'offset'. * Note: this was $limit before version 1.8 - * @param int $offset Offset @deprecated parameter + * @param int $offset Offset @deprecated parameter * * @todo remove $offset in 2.0 * @@ -231,6 +235,7 @@ class ElggSite extends ElggEntity { } $defaults = array( + 'site_guids' => ELGG_ENTITIES_ANY_VALUE, 'relationship' => 'member_of_site', 'relationship_guid' => $this->getGUID(), 'inverse_relationship' => TRUE, @@ -254,6 +259,7 @@ class ElggSite extends ElggEntity { */ public function listMembers($options = array()) { $defaults = array( + 'site_guids' => ELGG_ENTITIES_ANY_VALUE, 'relationship' => 'member_of_site', 'relationship_guid' => $this->getGUID(), 'inverse_relationship' => TRUE, diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index a1c7147a5..bdf57c2c3 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -6,6 +6,15 @@ * * @package Elgg.Core * @subpackage DataModel.User + * + * @property string $name The display name that the user will be known by in the network + * @property string $username The short, reference name for the user in the network + * @property string $email The email address to which Elgg will send email notifications + * @property string $language The language preference of the user (ISO 639-1 formatted) + * @property string $banned 'yes' if the user is banned from the network, 'no' otherwise + * @property string $admin 'yes' if the user is an administrator of the network, 'no' otherwise + * @property string $password The hashed password of the user + * @property string $salt The salt used to secure the password before hashing */ class ElggUser extends ElggEntity implements Friendable { @@ -96,7 +105,7 @@ class ElggUser extends ElggEntity * * @param int $guid ElggUser GUID * - * @return true|false + * @return bool */ protected function load($guid) { // Test to see if we have the generic stuff @@ -132,7 +141,7 @@ class ElggUser extends ElggEntity /** * Saves this user to the database. * - * @return true|false + * @return bool */ public function save() { // Save generic stuff @@ -252,7 +261,7 @@ class ElggUser extends ElggEntity * @param int $limit The number of results to return * @param int $offset Any indexing offset * - * @return bool + * @return array */ function getSites($subtype = "", $limit = 10, $offset = 0) { return get_user_sites($this->getGUID(), $subtype, $limit, $offset); @@ -263,7 +272,7 @@ class ElggUser extends ElggEntity * * @param int $site_guid The guid of the site to add it to * - * @return true|false + * @return bool */ function addToSite($site_guid) { return add_site_user($site_guid, $this->getGUID()); @@ -274,7 +283,7 @@ class ElggUser extends ElggEntity * * @param int $site_guid The guid of the site to remove it from * - * @return true|false + * @return bool */ function removeFromSite($site_guid) { return remove_site_user($site_guid, $this->getGUID()); @@ -285,7 +294,7 @@ class ElggUser extends ElggEntity * * @param int $friend_guid The GUID of the user to add * - * @return true|false Depending on success + * @return bool */ function addFriend($friend_guid) { return user_add_friend($this->getGUID(), $friend_guid); @@ -296,7 +305,7 @@ class ElggUser extends ElggEntity * * @param int $friend_guid The GUID of the user to remove * - * @return true|false Depending on success + * @return bool */ function removeFriend($friend_guid) { return user_remove_friend($this->getGUID(), $friend_guid); @@ -305,8 +314,7 @@ class ElggUser extends ElggEntity /** * Determines whether or not this user is a friend of the currently logged in user * - * - * @return true|false + * @return bool */ function isFriend() { return $this->isFriendOf(elgg_get_logged_in_user_guid()); @@ -317,7 +325,7 @@ class ElggUser extends ElggEntity * * @param int $user_guid The GUID of the user to check against * - * @return true|false + * @return bool */ function isFriendsWith($user_guid) { return user_is_friend($this->getGUID(), $user_guid); @@ -328,7 +336,7 @@ class ElggUser extends ElggEntity * * @param int $user_guid The GUID of the user to check against * - * @return true|false + * @return bool */ function isFriendOf($user_guid) { return user_is_friend($user_guid, $this->getGUID()); diff --git a/engine/classes/ElggWidget.php b/engine/classes/ElggWidget.php index 0eb83913b..7914fa140 100644 --- a/engine/classes/ElggWidget.php +++ b/engine/classes/ElggWidget.php @@ -115,6 +115,8 @@ class ElggWidget extends ElggObject { $options = array( 'type' => 'object', 'subtype' => 'widget', + 'container_guid' => $this->container_guid, + 'limit' => false, 'private_setting_name_value_pairs' => array( array('name' => 'context', 'value' => $this->getContext()), array('name' => 'column', 'value' => $column) @@ -132,17 +134,30 @@ class ElggWidget extends ElggObject { if ($rank == 0) { // top of the column $this->order = $widgets[0]->order - 10; - } elseif ($rank == count($widgets)) { + } elseif ($rank == (count($widgets) - 1)) { // bottom of the column $this->order = end($widgets)->order + 10; } else { - // reorder widgets that are below - $this->order = $widgets[$rank]->order; - for ($index = $rank; $index < count($widgets); $index++) { - if ($widgets[$index]->guid != $this->guid) { - $widgets[$index]-> order += 10; + // reorder widgets + + // remove the widget that's being moved from the array + foreach ($widgets as $index => $widget) { + if ($widget->guid == $this->guid) { + unset($widgets[$index]); } } + + // split the array in two and recombine with the moved array in middle + $before = array_slice($widgets, 0, $rank); + array_push($before, $this); + $after = array_slice($widgets, $rank); + $widgets = array_merge($before, $after); + ksort($widgets); + $order = 0; + foreach ($widgets as $widget) { + $widget->order = $order; + $order += 10; + } } $this->column = $column; } diff --git a/engine/classes/ODDDocument.php b/engine/classes/ODDDocument.php index 4d185aba5..540c35a3b 100644 --- a/engine/classes/ODDDocument.php +++ b/engine/classes/ODDDocument.php @@ -70,8 +70,8 @@ class ODDDocument implements Iterator { public function addElement(ODD $element) { if (!is_array($this->elements)) { $this->elements = array(); - $this->elements[] = $element; } + $this->elements[] = $element; } /** diff --git a/engine/classes/ODDEntity.php b/engine/classes/ODDEntity.php index ab3a49168..e9bb5da6a 100644 --- a/engine/classes/ODDEntity.php +++ b/engine/classes/ODDEntity.php @@ -32,75 +32,3 @@ class ODDEntity extends ODD { return "entity"; } } - -/** - * ODD Metadata class. - * - * @package Elgg.Core - * @subpackage ODD - */ -class ODDMetaData extends ODD { - - /** - * New ODD metadata - * - * @param unknown_type $uuid Unique ID - * @param unknown_type $entity_uuid Another unique ID - * @param unknown_type $name Name - * @param unknown_type $value Value - * @param unknown_type $type Type - * @param unknown_type $owner_uuid Owner ID - */ - function __construct($uuid, $entity_uuid, $name, $value, $type = "", $owner_uuid = "") { - parent::__construct(); - - $this->setAttribute('uuid', $uuid); - $this->setAttribute('entity_uuid', $entity_uuid); - $this->setAttribute('name', $name); - $this->setAttribute('type', $type); - $this->setAttribute('owner_uuid', $owner_uuid); - $this->setBody($value); - } - - /** - * Returns 'metadata' - * - * @return 'metadata' - */ - protected function getTagName() { - return "metadata"; - } -} - -/** - * ODD Relationship class. - * - * @package Elgg - * @subpackage Core - */ -class ODDRelationship extends ODD { - - /** - * New ODD Relationship - * - * @param unknown_type $uuid1 First UUID - * @param unknown_type $type Type of telationship - * @param unknown_type $uuid2 Second UUId - */ - function __construct($uuid1, $type, $uuid2) { - parent::__construct(); - - $this->setAttribute('uuid1', $uuid1); - $this->setAttribute('type', $type); - $this->setAttribute('uuid2', $uuid2); - } - - /** - * Returns 'relationship' - * - * @return 'relationship' - */ - protected function getTagName() { - return "relationship"; - } -} diff --git a/engine/classes/ODDMetaData.php b/engine/classes/ODDMetaData.php new file mode 100644 index 000000000..58862e0fb --- /dev/null +++ b/engine/classes/ODDMetaData.php @@ -0,0 +1,39 @@ +<?php +/** + * ODD Metadata class. + * + * @package Elgg.Core + * @subpackage ODD + */ +class ODDMetaData extends ODD { + + /** + * New ODD metadata + * + * @param unknown_type $uuid Unique ID + * @param unknown_type $entity_uuid Another unique ID + * @param unknown_type $name Name + * @param unknown_type $value Value + * @param unknown_type $type Type + * @param unknown_type $owner_uuid Owner ID + */ + function __construct($uuid, $entity_uuid, $name, $value, $type = "", $owner_uuid = "") { + parent::__construct(); + + $this->setAttribute('uuid', $uuid); + $this->setAttribute('entity_uuid', $entity_uuid); + $this->setAttribute('name', $name); + $this->setAttribute('type', $type); + $this->setAttribute('owner_uuid', $owner_uuid); + $this->setBody($value); + } + + /** + * Returns 'metadata' + * + * @return 'metadata' + */ + protected function getTagName() { + return "metadata"; + } +} diff --git a/engine/classes/ODDRelationship.php b/engine/classes/ODDRelationship.php new file mode 100644 index 000000000..2906b1c73 --- /dev/null +++ b/engine/classes/ODDRelationship.php @@ -0,0 +1,33 @@ +<?php +/** + * ODD Relationship class. + * + * @package Elgg + * @subpackage Core + */ +class ODDRelationship extends ODD { + + /** + * New ODD Relationship + * + * @param unknown_type $uuid1 First UUID + * @param unknown_type $type Type of telationship + * @param unknown_type $uuid2 Second UUId + */ + function __construct($uuid1, $type, $uuid2) { + parent::__construct(); + + $this->setAttribute('uuid1', $uuid1); + $this->setAttribute('type', $type); + $this->setAttribute('uuid2', $uuid2); + } + + /** + * Returns 'relationship' + * + * @return 'relationship' + */ + protected function getTagName() { + return "relationship"; + } +} diff --git a/engine/classes/SuccessResult.php b/engine/classes/SuccessResult.php index c8578a2cf..ab5468ad8 100644 --- a/engine/classes/SuccessResult.php +++ b/engine/classes/SuccessResult.php @@ -15,7 +15,7 @@ class SuccessResult extends GenericResult { * * @param string $result The result */ - public function SuccessResult($result) { + public function __construct($result) { $this->setResult($result); $this->setStatusCode(SuccessResult::$RESULT_SUCCESS); } diff --git a/engine/classes/XMLRPCCall.php b/engine/classes/XMLRPCCall.php new file mode 100644 index 000000000..fd28f1e3e --- /dev/null +++ b/engine/classes/XMLRPCCall.php @@ -0,0 +1,62 @@ +<?php +/** + * An XMLRPC call + * + * @package Elgg.Core + * @subpackage XMLRPC + */ +class XMLRPCCall { + /** Method name */ + private $methodname; + + /** Parameters */ + private $params; + + /** + * Construct a new XML RPC Call + * + * @param string $xml XML + */ + function __construct($xml) { + $this->parse($xml); + } + + /** + * Return the method name associated with the call. + * + * @return string + */ + public function getMethodName() { return $this->methodname; } + + /** + * Return the parameters. + * Returns a nested array of XmlElement. + * + * @see XmlElement + * @return array + */ + public function getParameters() { return $this->params; } + + /** + * Parse the xml into its components according to spec. + * This first version is a little primitive. + * + * @param string $xml XML + * + * @return void + */ + private function parse($xml) { + $xml = xml_to_object($xml); + + // sanity check + if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall") != 0)) { + throw new CallException(elgg_echo('CallException:NotRPCCall')); + } + + // method name + $this->methodname = $xml->children[0]->content; + + // parameters + $this->params = $xml->children[1]->children; + } +} |