aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2010-10-23 13:35:24 +0000
committerCash Costello <cash.costello@gmail.com>2010-10-23 13:35:24 +0000
commit18d83390fc4fe643a7747d212c491ab88418c1bb (patch)
treebba2811d54b2024a99b2b9497ca75e140c05fb88 /lib
parente0834b7d8b2b79ce230ca56601c7851aba4abe88 (diff)
downloadelgg-18d83390fc4fe643a7747d212c491ab88418c1bb.tar.gz
elgg-18d83390fc4fe643a7747d212c491ab88418c1bb.tar.bz2
cleaned up album deletion
Diffstat (limited to 'lib')
-rw-r--r--lib/album.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/album.php b/lib/album.php
index 15450049a..472bf69d8 100644
--- a/lib/album.php
+++ b/lib/album.php
@@ -18,6 +18,19 @@ class TidypicsAlbum extends ElggObject {
}
/**
+ * Delete album
+ *
+ * @return bool
+ */
+ public function delete() {
+
+ $this->deleteImages();
+ $this->deleteAlbumDir();
+
+ return parent::delete();
+ }
+
+ /**
* Get an array of image objects
*
* @param int $limit
@@ -157,4 +170,31 @@ class TidypicsAlbum extends ElggObject {
return TRUE;
}
+
+ protected function deleteImages() {
+ // get all the images from this album as long as less than 999 images
+ $images = get_entities("object", "image", $this->guid, '', 999);
+ foreach ($images as $image) {
+ if ($image) {
+ $image->delete();
+ }
+ }
+ }
+
+ protected function deleteAlbumDir() {
+ $tmpfile = new ElggFile();
+ $tmpfile->setFilename('image/' . $this->guid . '/._tmp_del_tidypics_album_');
+ $tmpfile->subtype = 'image';
+ $tmpfile->owner_guid = $this->owner_guid;
+ $tmpfile->container_guid = $this->guid;
+ $tmpfile->open("write");
+ $tmpfile->write('');
+ $tmpfile->close();
+ $tmpfile->save();
+ $albumdir = eregi_replace('/._tmp_del_tidypics_album_', '', $tmpfile->getFilenameOnFilestore());
+ $tmpfile->delete();
+ if (is_dir($albumdir)) {
+ rmdir($albumdir);
+ }
+ }
}