diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/entities.php | 21 | ||||
-rw-r--r-- | engine/lib/group.php | 37 | ||||
-rw-r--r-- | engine/lib/objects.php | 37 | ||||
-rw-r--r-- | engine/lib/sites.php | 22 | ||||
-rw-r--r-- | engine/lib/users.php | 39 |
5 files changed, 47 insertions, 109 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 156f552f4..ff4487570 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -723,8 +723,7 @@ */
public function delete()
{
- $res = delete_entity($this->get('guid'));
- return $res;
+ return delete_entity($this->get('guid'));
}
// LOCATABLE INTERFACE /////////////////////////////////////////////////////////////
@@ -1845,7 +1844,23 @@ $entity->clearRelationships();
remove_from_river_by_subject($guid);
remove_from_river_by_object($guid);
- $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
+ $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}"); + if ($res) + { + $sub_table = ""; + + // Where appropriate delete the sub table + switch ($entity->type) + { + case 'object' : $sub_table = $CONFIG->dbprefix . 'objects_entity'; break; + case 'user' : $sub_table = $CONFIG->dbprefix . 'users_entity'; break; + case 'group' : $sub_table = $CONFIG->dbprefix . 'groups_entity'; break; + case 'site' : $sub_table = $CONFIG->dbprefix . 'sites_entity'; break; + } + + if ($sub_table) + delete_data("DELETE from $sub_table where guid={$guid}"); + }
return $res;
}
diff --git a/engine/lib/group.php b/engine/lib/group.php index 9863a7b7b..9e0843776 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -254,19 +254,7 @@ public function leave(ElggUser $user)
{
return leave_group($this->getGUID(), $user->getGUID());
- }
-
- /**
- * Delete this group.
- */
- public function delete()
- {
- if (parent::delete())
- return delete_group_entity($this->get('guid'));
-
- return false;
- }
-
+ }
/**
* Override the load function.
@@ -409,28 +397,19 @@ }
- /**
+ /** + * THIS FUNCTION IS DEPRECATED. + *
* Delete a group's extra data.
*
* @param int $guid The guid of the group
* @return bool
*/
function delete_group_entity($guid)
- {
- global $CONFIG;
-
- $guid = (int)$guid;
-
- $row = get_entity_as_row($guid);
-
- // Check to see if we have access and it exists
- if ($row)
- {
- // Delete any existing stuff
- return delete_data("DELETE from {$CONFIG->dbprefix}groups_entity where guid=$guid");
- }
-
- return false;
+ { + system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + + return 1; // Always return that we have deleted one row in order to not break existing code.
}
/**
diff --git a/engine/lib/objects.php b/engine/lib/objects.php index 7ae8b6cff..7d888f9a6 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -120,21 +120,9 @@ // Now save specific stuff
return create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'), $this->get('container_guid')); - }
+ } /**
- * Delete this object.
- * @return true|false
- */
- public function delete()
- { - if (parent::delete()) - return delete_object_entity($this->get('guid')); - - return false;
- }
-
- /**
* Get sites that this object is a member of
*
* @param string $subtype Optionally, the subtype of result we want to limit to
@@ -302,27 +290,18 @@ return false;
}
- /**
+ /** + * THIS FUNCTION IS DEPRECATED. + *
* Delete a object's extra data.
*
* @param int $guid
*/
function delete_object_entity($guid)
- {
- global $CONFIG;
-
- $guid = (int)$guid;
-
- $row = get_object_entity_as_row($guid);
-
- // Check to see if we have access and it exists
- if ($row)
- {
- // Delete any existing stuff
- return delete_data("DELETE from {$CONFIG->dbprefix}objects_entity where guid=$guid");
- }
-
- return false;
+ { + system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + + return 1; // Always return that we have deleted one row in order to not break existing code.
} /** diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 037a5f331..711637d33 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -139,10 +139,7 @@ if ($CONFIG->site->getGUID() == $this->guid) throw new SecurityException('SecurityException:deletedisablecurrentsite'); - if (parent::delete) - return delete_site_entity($this->get('guid')); - - return false; + return parent::delete; } /** @@ -318,26 +315,17 @@ } /** + * THIS FUNCTION IS DEPRECATED. + * * Delete a site's extra data. * * @param int $guid */ function delete_site_entity($guid) { - global $CONFIG; + system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); - $guid = (int)$guid; - - $row = get_entity_as_row($guid); - - // Check to see if we have access and it exists - if ($row) - { - // Delete any existing stuff - return delete_data("DELETE from {$CONFIG->dbprefix}sites_entity where guid=$guid"); - } - - return false; + return 1; // Always return that we have deleted one row in order to not break existing code. } /** diff --git a/engine/lib/users.php b/engine/lib/users.php index 630be8d80..283f5efcc 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -146,19 +146,6 @@ }
/**
- * Delete this user.
- * @return true|false
- */
- public function delete()
- { - if (parent::delete())
- return delete_user_entity($this->get('guid'));
-
- return false;
-
- }
-
- /**
* Ban this user.
*
* @param string $reason Optional reason
@@ -496,28 +483,18 @@ return false;
}
- /**
- * Delete a user's extra data.
+ /** + * THIS FUNCTION IS DEPRECATED. + *
+ * Delete a user's extra data.
*
* @param int $guid
*/
function delete_user_entity($guid)
- {
- global $CONFIG;
-
- $guid = (int)$guid;
-
- $row = get_entity_as_row($guid);
-
- // Check to see if we have access and it exists
- if ($row)
- {
- //disable_user_entities($guid);
- // Delete any existing stuff
- return delete_data("DELETE from {$CONFIG->dbprefix}users_entity where guid=$guid");
- }
-
- return false;
+ { + system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity')); + + return 1; // Always return that we have deleted one row in order to not break existing code.
}
/**
|