aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/admin/upgrade.php2
-rw-r--r--actions/delete.php21
-rw-r--r--lib/album.php19
-rw-r--r--lib/image.php13
4 files changed, 45 insertions, 10 deletions
diff --git a/actions/admin/upgrade.php b/actions/admin/upgrade.php
index 9c4aef1cf..334e9588e 100644
--- a/actions/admin/upgrade.php
+++ b/actions/admin/upgrade.php
@@ -11,6 +11,8 @@ if ($version <= $local_version) {
forward($_SERVER['HTTP_REFERER']);
}
+set_time_limit(0);
+
$base_dir = $CONFIG->pluginspath . 'tidypics/upgrades';
// taken from engine/lib/version.php
diff --git a/actions/delete.php b/actions/delete.php
index c1e0ed59e..9b8c6ac6f 100644
--- a/actions/delete.php
+++ b/actions/delete.php
@@ -53,7 +53,7 @@ $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) {
+foreach ($images as $im) {
$thumbnail = $im->thumbnail;
$smallthumb = $im->smallthumb;
$largethumb = $im->largethumb;
@@ -76,16 +76,17 @@ foreach($images as $im) {
$delfile->setFilename($largethumb);
$delfile->delete();
}
- if ($im) { //delete actual image file
- $delfile = new ElggFile($im->getGUID());
- $delfile->owner_guid = $im->getOwner();
- //$delfile->setFilename($im->originalfilename);
- $image_repo_size -= $delfile->size();
+ if ($im) {
+ $image_repo_size -= $im->size();
- if (!$delfile->delete()) {
- if ($subtype=='image') register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
+ if (!$im->delete()) {
+ if ($subtype=='image') {
+ register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
+ }
} else {
- if ($subtype=='image') system_message(elgg_echo("tidypics:deleted")); //successfully deleted object
+ if ($subtype=='image') {
+ system_message(elgg_echo("tidypics:deleted")); //successfully deleted object
+ }
}
} //end delete actual image file
} //end looping through each image to delete it
@@ -107,7 +108,7 @@ if ($subtype == 'album') {
rmdir($albumdir);
}
- //delete object from database
+ //delete album object from database
if (!$entity->delete()) {
register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
} else {
diff --git a/lib/album.php b/lib/album.php
index 87bb715f4..15450049a 100644
--- a/lib/album.php
+++ b/lib/album.php
@@ -138,4 +138,23 @@ class TidypicsAlbum extends ElggObject {
}
return $imageList[$key];
}
+
+ /**
+ * Remove an image from the album list
+ *
+ * @param int $imageGuid
+ * @return bool
+ */
+ public function removeImage($imageGuid) {
+ $imageList = $this->getImageList();
+ $key = array_search($imageGuid, $imageList);
+ if ($key === FALSE) {
+ return FALSE;
+ }
+
+ unset($imageList[$key]);
+ $this->setImageList($imageList);
+
+ return TRUE;
+ }
}
diff --git a/lib/image.php b/lib/image.php
index 4100f3f7b..c60eabfc0 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -18,6 +18,19 @@ class TidypicsImage extends ElggFile {
}
/**
+ * delete image
+ *
+ * @return bool
+ */
+ public function delete() {
+
+ $album = get_entity($this->container_guid);
+ $album->removeImage($this->guid);
+
+ return parent::delete();
+ }
+
+ /**
* Has the photo been tagged with "in this photo" tags
*
* @return true/false