diff options
author | Cash Costello <cash.costello@gmail.com> | 2009-06-13 23:53:17 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2009-06-13 23:53:17 +0000 |
commit | 8f5aa6a87b15ecee226f46539b1400710c9c9047 (patch) | |
tree | 4c9f0b01c00ab654f0e972723f419ef92db6288a /actions/delete.php | |
parent | fde85445cf67f7e0033bb761a547e36ebcf068a8 (diff) | |
download | elgg-8f5aa6a87b15ecee226f46539b1400710c9c9047.tar.gz elgg-8f5aa6a87b15ecee226f46539b1400710c9c9047.tar.bz2 |
added disk quota for users and groups
Diffstat (limited to 'actions/delete.php')
-rw-r--r-- | actions/delete.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/actions/delete.php b/actions/delete.php index f6b677c55..3deb69c5b 100644 --- a/actions/delete.php +++ b/actions/delete.php @@ -30,13 +30,17 @@ register_error(elgg_echo("file:deletefailed"));
forward($forward_url);
}
-
+
+ $owner_guid = 0; // group or user
if ($subtype == 'image') { //deleting an image
+ $album = get_entity($entity->container_guid);
+ $owner_guid = $album->container_guid;
$forward_url = $container->getURL(); //forward back to album after deleting pictures
$images = array($entity);
// plugins can register to be told when a Tidypics image has been deleted
trigger_elgg_event('upload', 'tp_album', $entity);
} else { //deleting an album
+ $owner_guid = $entity->container_guid;
$forward_url = 'pg/photos/owned/' . $container->username;
//get all the images from this album as long as less than 999 images
$images = get_entities("object", "image", $guid, '', 999);
@@ -44,6 +48,10 @@ trigger_elgg_event('upload', 'tp_album', $entity);
}
+ // make sure we decrease the repo size for the size quota
+ $image_repo_size_md = get_metadata_byname($owner_guid, "image_repo_size");
+ $image_repo_size = (int)$image_repo_size_md->value;
+
//loop through all images and delete them
foreach($images as $im) {
$thumbnail = $im->thumbnail;
@@ -72,6 +80,8 @@ $delfile = new ElggFile($im->getGUID());
$delfile->owner_guid = $im->getOwner();
//$delfile->setFilename($im->originalfilename);
+ $image_repo_size -= $delfile->size();
+
if (!$delfile->delete()) {
if ($subtype=='image') register_error(elgg_echo("file:deletefailed")); //unable to delete object
} else {
@@ -104,6 +114,7 @@ }
} //end of delete album
+ create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid);
forward($forward_url);
|