]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2668 adding getOwnerGUID()
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 13:31:46 +0000 (13:31 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 13:31:46 +0000 (13:31 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7378 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggData.php
engine/classes/ElggEntity.php
engine/classes/ElggExtender.php
engine/classes/ElggUser.php
engine/classes/Loggable.php
engine/lib/entities.php
engine/lib/extender.php
engine/tests/objects/entities.php
mod/groups/actions/forums/edittopic.php
mod/groups/actions/leave.php
mod/thewire/actions/delete.php

index a6cf7d21f6b31b344c6f909e63895dafb115b3f4..a904cb923e9546979f80f0fa93c0688570ed12a7 100644 (file)
@@ -141,10 +141,10 @@ abstract class ElggData implements
         * Return the GUID of the owner of this object.
         *
         * @return int
-        * @deprecated 1.8 Use getOwner() instead
+        * @deprecated 1.8 Use getOwnerGUID() instead
         */
        public function getObjectOwnerGUID() {
-               elgg_deprecated_notice("getObjectOwnerGUID() was deprecated.  Use getOwner().", 1.8);
+               elgg_deprecated_notice("getObjectOwnerGUID() was deprecated.  Use getOwnerGUID().", 1.8);
                return $this->owner_guid;
        }
 
index 667302c30f1acf13ce516ccb7c65dfbb0bc02e8c..de57d7a078ac3c59767c63ad528e7847ee5e071d 100644 (file)
@@ -297,7 +297,7 @@ abstract class ElggEntity extends ElggData implements
                                if ((int) $this->guid > 0) {
                                        $multiple = true;
                                        if (!create_metadata($this->getGUID(), $name, $v, $value_type,
-                                       $this->getOwner(), $this->getAccessID(), $multiple)) {
+                                       $this->getOwnerGUID(), $this->getAccessID(), $multiple)) {
                                                return false;
                                        }
                                } else {
@@ -320,7 +320,7 @@ abstract class ElggEntity extends ElggData implements
                        unset($this->temp_metadata[$name]);
                        if ((int) $this->guid > 0) {
                                $result = create_metadata($this->getGUID(), $name, $value, $value_type,
-                                       $this->getOwner(), $this->getAccessID(), $multiple);
+                                       $this->getOwnerGUID(), $this->getAccessID(), $multiple);
                                return (bool)$result;
                        } else {
                                if (($multiple) && (isset($this->temp_metadata[$name]))) {
@@ -704,19 +704,30 @@ abstract class ElggEntity extends ElggData implements
                return get_subtype_from_id($this->get('subtype'));
        }
 
+       /**
+        * Get the guid of the entity's owner.
+        *
+        * @return int The owner GUID
+        */
+       public function getOwnerGUID() {
+               return $this->owner_guid;
+       }
+
        /**
         * Return the guid of the entity's owner.
         *
         * @return int The owner GUID
+        * @deprecated 1.8 Use getOwnerGUID()
         */
        public function getOwner() {
-               return $this->owner_guid;
+               elgg_deprecated_notice("ElggEntity::getOwner deprecated for ElggEntity::getOwnerGUID", 1.8);
+               return $this->getOwnerGUID();
        }
 
        /**
-        * Returns the ElggEntity or child object of the owner of the entity.
+        * Gets the ElggEntity that owns this entity.
         *
-        * @return ElggEntity The owning user
+        * @return ElggEntity The owning entity
         */
        public function getOwnerEntity() {
                return get_entity($this->owner_guid);
index 95a4d3de3c3137a42e74516dd619f7426172650a..6ab9ff3ce5a381f1ba7f33ffc0510130e22af666 100644 (file)
@@ -79,28 +79,39 @@ abstract class ElggExtender extends ElggData
                return true;
        }
 
+       /**
+        * Get the GUID of the extender's owner entity.
+        *
+        * @return int The owner GUID
+        */
+       public function getOwnerGUID() {
+               return $this->owner_guid;
+       }
+
        /**
         * Return the guid of the entity's owner.
         *
         * @return int The owner GUID
+        * @deprecated 1.8 Use getOwnerGUID
         */
        public function getOwner() {
-               return $this->owner_guid;
+               elgg_deprecated_notice("ElggExtender::getOwner deprecated for ElggExtender::getOwnerGUID", 1.8);
+               return $this->getOwnerGUID();
        }
 
        /**
-        * Returns the ElggEntity or child object of the owner of the entity.
+        * Get the entity that owns this extender
         *
-        * @return ElggEntity The owning user
+        * @return ElggEntity
         */
        public function getOwnerEntity() {
                return get_entity($this->owner_guid);
        }
 
        /**
-        * Return the entity this describes.
+        * Get the entity this describes.
         *
-        * @return ElggEntity The enttiy
+        * @return ElggEntity The entity
         */
        public function getEntity() {
                return get_entity($this->entity_guid);
index 8f30be37e5b05966cabec8caebc8795a62094bd0..ab1bd71a0c11303bae501d1e4aebb333011b4c63 100644 (file)
@@ -420,18 +420,31 @@ class ElggUser extends ElggEntity
        }
 
        /**
-        * If a user's owner is blank, return its own GUID as the owner
+        * Get a user's owner GUID
         *
-        * @return int User GUID
+        * Returns it's own GUID if the user is not owned.
+        *
+        * @return int
         */
-       function getOwner() {
+       function getOwnerGUID() {
                if ($this->owner_guid == 0) {
-                       return $this->getGUID();
+                       return $this->guid;
                }
 
                return $this->owner_guid;
        }
 
+       /**
+        * If a user's owner is blank, return its own GUID as the owner
+        *
+        * @return int User GUID
+        * @deprecated 1.8 Use getOwnerGUID()
+        */
+       function getOwner() {
+               elgg_deprecated_notice("ElggUser::getOwner deprecated for ElggUser::getOwnerGUID", 1.8);
+               $this->getOwnerGUID();
+       }
+
        // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////
 
        /**
index 36db8a692d79fa31d69db1b977c49313883f20bf..40690f87a881c9be662623b003262219ded2beef 100644 (file)
@@ -59,7 +59,7 @@ interface Loggable {
         * Return the GUID of the owner of this object.
         *
         * @return int
-        * @deprecated 1.8 Use getOwner() instead
+        * @deprecated 1.8 Use getOwnerGUID() instead
         */
        public function getObjectOwnerGUID();
 }
\ No newline at end of file
index cac2e2959fefe32d1e4f2b1c035b402e76826b75..57a98ae40f6328fadd0b9b889fbcd2e41b2750db 100644 (file)
@@ -1930,7 +1930,7 @@ function can_edit_entity($entity_guid, $user_guid = 0) {
 
                // Test user if possible - should default to false unless a plugin hook says otherwise
                if ($user) {
-                       if ($entity->getOwner() == $user->getGUID()) {
+                       if ($entity->getOwnerGUID() == $user->getGUID()) {
                                $return = true;
                        }
                        if ($entity->container_guid == $user->getGUID()) {
index b894c5e59ccbef3435056a88e0abb4b02420afb5..8df207767a3373228f4c17f9e33c2f5a52652d33 100644 (file)
@@ -144,7 +144,7 @@ function can_edit_extender($extender_id, $type, $user_guid = 0) {
        }
 
        // If the owner is the specified user, great! They can edit.
-       if ($extender->getOwner() == $user->getGUID()) {
+       if ($extender->getOwnerGUID() == $user->getGUID()) {
                return true;
        }
 
index 97cf44392540b3f492ba6e1eb84b58102cf5fc57..56c8f79471108e7a3ffae84bfa3b295b0a5e2c8e 100644 (file)
@@ -77,7 +77,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
                $this->assertIdentical($this->entity->getGUID(), $this->entity->guid );
                $this->assertIdentical($this->entity->getType(), $this->entity->type );
                $this->assertIdentical($this->entity->getSubtype(), $this->entity->subtype );
-               $this->assertIdentical($this->entity->getOwner(), $this->entity->owner_guid );
+               $this->assertIdentical($this->entity->getOwnerGUID(), $this->entity->owner_guid );
                $this->assertIdentical($this->entity->getAccessID(), $this->entity->access_id );
                $this->assertIdentical($this->entity->getTimeCreated(), $this->entity->time_created );
                $this->assertIdentical($this->entity->getTimeUpdated(), $this->entity->time_updated );
index 247c06c8c052532ba0be07685e7946e6bcdb0867..b032e37d7332e32bdc11d8718ebc6353082bdfc3 100644 (file)
@@ -26,7 +26,7 @@ $tagarray = string_to_tag_array($tags);
 // Make sure we actually have permission to edit
 $topic = get_entity($topic_guid);
 if ($topic){
-       $user = $topic->getOwner(); 
+       $user = $topic->getOwnerGUID();
        if ($topic->getSubtype() == "groupforumtopic") {
                
                // Convert string of tags into a preformatted array
index 5ed2bf6484fc9927b56c176ded972296b1ef56ab..78431961a8cef6d91c6b5c7cd7d219f16507e0d2 100644 (file)
@@ -24,7 +24,7 @@
        
        if (($user instanceof ElggUser) && ($group instanceof ElggGroup))
        {
-               if ($group->getOwner() != get_loggedin_userid()) {
+               if ($group->getOwnerGUID() != get_loggedin_userid()) {
                        if ($group->leave($user))
                                system_message(elgg_echo("groups:left"));
                        else
index 98b5114ccfe739fa245b52edebd3628bde681344..9b6bf4a99d1e5df377f822854c10212b5de38e50 100644 (file)
@@ -17,7 +17,7 @@
                if ($thewire->getSubtype() == "thewire" && $thewire->canEdit()) {
        
                // Get owning user
-                               $owner = get_entity($thewire->getOwner());
+                               $owner = $thewire->getOwnerEntity();
                // Delete it!
                                $rowsaffected = $thewire->delete();
                                if ($rowsaffected > 0) {