aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2010-07-25 02:01:36 +0000
committerCash Costello <cash.costello@gmail.com>2010-07-25 02:01:36 +0000
commit73403645808a81425381f43c25e0ea2c92705312 (patch)
tree83fb73e9a122054f6f4c2e1c44e399572ee13e28 /actions
parent791ec4925346cb38ecca9a2f2574b012ab64a88a (diff)
downloadelgg-73403645808a81425381f43c25e0ea2c92705312.tar.gz
elgg-73403645808a81425381f43c25e0ea2c92705312.tar.bz2
first go at brining tidypics up to code standards
Diffstat (limited to 'actions')
-rw-r--r--actions/addalbum.php128
-rw-r--r--actions/addtag.php170
-rw-r--r--actions/create_thumbnails.php115
-rw-r--r--actions/delete.php211
-rw-r--r--actions/deletetag.php97
-rw-r--r--actions/edit.php135
-rw-r--r--actions/edit_multi.php113
-rw-r--r--actions/flickrImportPhotoset.php7
-rw-r--r--actions/flickrSetup.php2
-rw-r--r--actions/imtest.php35
-rw-r--r--actions/settings.php135
-rw-r--r--actions/upgrade.php55
12 files changed, 599 insertions, 604 deletions
diff --git a/actions/addalbum.php b/actions/addalbum.php
index 8df488a92..accdd082b 100644
--- a/actions/addalbum.php
+++ b/actions/addalbum.php
@@ -1,74 +1,72 @@
<?php
- /**
- * Tidypics Add New Album Action
- *
- */
+/**
+ * Tidypics Add New Album Action
+ *
+ */
- // Make sure we're logged in
- gatekeeper();
+// Make sure we're logged in
+gatekeeper();
- // Get input data
- $title = get_input('tidypicstitle');
- $body = get_input('tidypicsbody');
- $tags = get_input('tidypicstags');
- $access = get_input('access_id');
- $container_guid = get_input('container_guid', $_SESSION['user']->getGUID());
+// Get input data
+$title = get_input('tidypicstitle');
+$body = get_input('tidypicsbody');
+$tags = get_input('tidypicstags');
+$access = get_input('access_id');
+$container_guid = get_input('container_guid', get_loggedin_userid());
- // Cache to the session
- $_SESSION['tidypicstitle'] = $title;
- $_SESSION['tidypicsbody'] = $body;
- $_SESSION['tidypicstags'] = $tags;
+// Cache to the session
+$_SESSION['tidypicstitle'] = $title;
+$_SESSION['tidypicsbody'] = $body;
+$_SESSION['tidypicstags'] = $tags;
- // Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags);
- // Make sure the title isn't blank
- if (empty($title)) {
- register_error(elgg_echo("album:blank"));
- forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
- // Otherwise, save the album
- } else {
-
- // Initialise a new ElggObject
- $album = new ElggObject();
- // Tell the system it's an album
- $album->subtype = "album";
-
- // Set its owner to the current user
- $album->container_guid = $container_guid;
- $album->owner_guid = $_SESSION['user']->getGUID();
- $album->access_id = $access;
- // Set its title and description appropriately
- $album->title = $title;
- $album->description = $body;
-
- // we catch the adding images to new albums in the upload action and throw a river new album event
- $album->new_album = TP_NEW_ALBUM;
-
- // Before we can set metadata, we need to save the album
- if (!$album->save()) {
- register_error(elgg_echo("album:error"));
- forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
- }
-
- // Now let's add tags
- if (is_array($tagarray)) {
- $album->tags = $tagarray;
- }
-
-
-
- // Success message
- system_message(elgg_echo("album:created"));
-
- // Remove the album post cache
- unset($_SESSION['tidypicstitle']);
- unset($_SESSION['tidypicsbody']);
- unset($_SESSION['tidypicstags']);
+// Convert string of tags into a preformatted array
+$tagarray = string_to_tag_array($tags);
+// Make sure the title isn't blank
+if (empty($title)) {
+ register_error(elgg_echo("album:blank"));
+ forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
+ // Otherwise, save the album
+} else {
- // plugins can register to be told when a new Tidypics album has been created
- trigger_elgg_event('add', 'tp_album', $album);
+ // Initialise a new ElggObject
+ $album = new ElggObject();
+ // Tell the system it's an album
+ $album->subtype = "album";
- forward("pg/photos/upload/" . $album->guid);
+ // Set its owner to the current user
+ $album->container_guid = $container_guid;
+ $album->owner_guid = $_SESSION['user']->getGUID();
+ $album->access_id = $access;
+ // Set its title and description appropriately
+ $album->title = $title;
+ $album->description = $body;
+
+ // we catch the adding images to new albums in the upload action and throw a river new album event
+ $album->new_album = TP_NEW_ALBUM;
+
+ // Before we can set metadata, we need to save the album
+ if (!$album->save()) {
+ register_error(elgg_echo("album:error"));
+ forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page
}
-?> \ No newline at end of file
+ // Now let's add tags
+ if (is_array($tagarray)) {
+ $album->tags = $tagarray;
+ }
+
+
+
+ // Success message
+ system_message(elgg_echo("album:created"));
+
+ // Remove the album post cache
+ unset($_SESSION['tidypicstitle']);
+ unset($_SESSION['tidypicsbody']);
+ unset($_SESSION['tidypicstags']);
+
+ // plugins can register to be told when a new Tidypics album has been created
+ trigger_elgg_event('add', 'tp_album', $album);
+
+ forward("pg/photos/upload/" . $album->guid);
+}
diff --git a/actions/addtag.php b/actions/addtag.php
index 56268783e..115a81bc6 100644
--- a/actions/addtag.php
+++ b/actions/addtag.php
@@ -1,104 +1,106 @@
<?php
- /**
- * Tidypics Add Photo Tag
- *
- */
+/**
+ * Tidypics Add Photo Tag
+ *
+ */
- gatekeeper();
- action_gatekeeper();
+gatekeeper();
+action_gatekeeper();
- $coordinates_str = get_input('coordinates');
+$coordinates_str = get_input('coordinates');
- $user_id = get_input('user_id');
- $image_guid = get_input('image_guid');
- $word = get_input('word');
+$user_id = get_input('user_id');
+$image_guid = get_input('image_guid');
+$word = get_input('word');
- if ($image_guid == 0) {
- register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
- }
+if ($image_guid == 0) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+}
- $image = get_entity($image_guid);
- if (!$image)
- {
- register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
- }
+$image = get_entity($image_guid);
+if (!$image) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+// test for empty tag
+if ($user_id == 0 && empty($word)) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+}
- // test for empty tag
- if ($user_id == 0 && empty($word)) {
- register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
- }
+$new_word_tag = false;
+if ($user_id != 0) {
+ $relationships_type = 'user';
+ $value = $user_id;
+} else {
+ $relationships_type = 'word';
+ $value = $word;
- $new_word_tag = false;
- if ($user_id != 0) {
- $relationships_type = 'user';
- $value = $user_id;
+ // check to see if the photo has this tag and add if not
+ if (!is_array($image->tags)) {
+ if ($image->tags != $word) {
+ $new_word_tag = true;
+ $tagarray = $image->tags . ',' . $word;
+ $tagarray = string_to_tag_array($tagarray);
+ }
} else {
- $relationships_type = 'word';
- $value = $word;
-
- // check to see if the photo has this tag and add if not
- if (!is_array($image->tags)) {
- if ($image->tags != $word) {
- $new_word_tag = true;
- $tagarray = $image->tags . ',' . $word;
- $tagarray = string_to_tag_array($tagarray);
- }
- } else {
- if (!in_array($word, $image->tags)) {
- $new_word_tag = true;
- $tagarray = $image->tags;
- $tagarray[] = $word;
- }
+ if (!in_array($word, $image->tags)) {
+ $new_word_tag = true;
+ $tagarray = $image->tags;
+ $tagarray[] = $word;
}
}
-
- // add new tag now so it is available in search
- if ($new_word_tag) {
- $image->clearMetadata('tags');
- $image->tags = $tagarray;
- }
+}
+
+// add new tag now so it is available in search
+if ($new_word_tag) {
+ $image->clearMetadata('tags');
+ $image->tags = $tagarray;
+}
+
+// create string for javascript tag object
+$tag->coords = $coordinates_str;
+$tag->type = $relationships_type;
+$tag->value = $value;
+
+$access_id = $image->getAccessID();
+$owner_id = get_loggedin_userid();
+$tagger = get_loggedin_user();
- // create string for javascript tag object
- $tag->coords = $coordinates_str;
- $tag->type = $relationships_type;
- $tag->value = $value;
-
- $access_id = $image->getAccessID();
- $owner_id = get_loggedin_userid();
- $tagger = get_loggedin_user();
-
- //Save annotation
- if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) {
- // if tag is a user id, add relationship for searching (find all images with user x)
- if ($relationships_type === 'user') {
- if (!check_entity_relationship($user_id, 'phototag', $image_guid)) {
- add_entity_relationship($user_id, 'phototag', $image_guid);
-
- // also add this to the river - subject is image, object is the tagged user
- if (function_exists('add_to_river'))
- add_to_river('river/object/image/tag', 'tag', $image_guid, $user_id, $access_id);
-
- // notify user of tagging as long as not self
- if ($owner_id != $user_id)
- notify_user($user_id, $owner_id, elgg_echo('tidypics:tag:subject'),
+//Save annotation
+if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) {
+ // if tag is a user id, add relationship for searching (find all images with user x)
+ if ($relationships_type === 'user') {
+ if (!check_entity_relationship($user_id, 'phototag', $image_guid)) {
+ add_entity_relationship($user_id, 'phototag', $image_guid);
+
+ // also add this to the river - subject is image, object is the tagged user
+ if (function_exists('add_to_river')) {
+ add_to_river('river/object/image/tag', 'tag', $image_guid, $user_id, $access_id);
+ }
+
+ // notify user of tagging as long as not self
+ if ($owner_id != $user_id) {
+ notify_user(
+ $user_id,
+ $owner_id,
+ elgg_echo('tidypics:tag:subject'),
sprintf(
- elgg_echo('tidypics:tag:body'),
- $image->title,
- $tagger->name,
- $image->getURL()
- )
- );
+ elgg_echo('tidypics:tag:body'),
+ $image->title,
+ $tagger->name,
+ $image->getURL()
+ )
+ );
}
}
-
- system_message(elgg_echo("tidypics:phototagging:success"));
}
+ system_message(elgg_echo("tidypics:phototagging:success"));
+}
- forward($_SERVER['HTTP_REFERER']);
-?>
+forward($_SERVER['HTTP_REFERER']);
diff --git a/actions/create_thumbnails.php b/actions/create_thumbnails.php
index 09743eef6..18dae6b78 100644
--- a/actions/create_thumbnails.php
+++ b/actions/create_thumbnails.php
@@ -1,61 +1,60 @@
<?php
- /**
- * Tidypics Thumbnail Creation Test
- *
- * Called through ajax
- */
-
- include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
- include dirname(dirname(__FILE__)) . "/lib/resize.php";
-
- global $CONFIG;
-
- $guid = $_GET['guid'];
-
- $image = get_entity($guid);
- if (!$image || !($image instanceof TidypicsImage)) {
- echo "Unable to get original image";
- return;
+/**
+ * Tidypics Thumbnail Creation Test
+ *
+ * Called through ajax
+ */
+
+include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
+include dirname(dirname(__FILE__)) . "/lib/resize.php";
+
+global $CONFIG;
+
+$guid = get_input('guid');
+
+$image = get_entity($guid);
+if (!$image || !($image instanceof TidypicsImage)) {
+ echo "Unable to get original image";
+ return;
+}
+
+$filename = $image->getFilename();
+$container_guid = $image->container_guid;
+if (!$filename || !$container_guid) {
+ echo "Error retrieving information about the image";
+ return;
+}
+
+$title = $image->title;
+$prefix = "image/$container_guid/";
+$filestorename = substr($filename, strlen($prefix));
+
+$image_lib = get_plugin_setting('image_lib', 'tidypics');
+if (!$image_lib) {
+ $image_lib = "GD";
+}
+
+if ($image_lib == 'ImageMagick') { // ImageMagick command line
+
+ if (tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename) != true) {
+ trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING);
+ echo "Failed to create thumbnails";
+ }
+
+} else if ($image_lib == 'ImageMagickPHP') { // imagick PHP extension
+
+ if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) {
+ trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING);
+ echo "Failed to create thumbnails";
}
-
- $filename = $image->getFilename();
- $container_guid = $image->container_guid;
- if (!$filename || !$container_guid) {
- echo "Error retrieving information about the image";
- return;
+
+} else {
+
+ if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) {
+ trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING);
+ echo "Failed to create thumbnails";
}
-
- $title = $image->title;
- $prefix = "image/" . $container_guid . "/";
- $filestorename = substr($filename, strlen($prefix));
-
- $image_lib = get_plugin_setting('image_lib', 'tidypics');
- if (!$image_lib)
- $image_lib = "GD";
-
- if ($image_lib == 'ImageMagick') { // ImageMagick command line
-
- if (tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename) != true) {
- trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING);
- echo "Failed to create thumbnails";
- }
-
- } else if ($image_lib == 'ImageMagickPHP') { // imagick PHP extension
-
- if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) {
- trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING);
- echo "Failed to create thumbnails";
- }
-
- } else {
-
- if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) {
- trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING);
- echo "Failed to create thumbnails";
- }
-
- } // end of image library selector
-
- echo "<img id=\"tidypics_image\" src=\"{$CONFIG->wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&amp;size=large\" alt=\"{$title}\" />";
-
-?>
+
+} // end of image library selector
+
+echo "<img id=\"tidypics_image\" src=\"{$CONFIG->wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&amp;size=large\" alt=\"{$title}\" />";
diff --git a/actions/delete.php b/actions/delete.php
index cab996ec5..c1e0ed59e 100644
--- a/actions/delete.php
+++ b/actions/delete.php
@@ -1,121 +1,120 @@
<?php
- /**
- * Tidypics Delete Action for Images and Albums
- *
- */
+/**
+ * Tidypics Delete Action for Images and Albums
+ *
+ */
- // must be logged in
- gatekeeper();
+// must be logged in
+gatekeeper();
- $forward_url = 'pg/photos/world'; // by default forward to world photos
+$forward_url = 'pg/photos/world'; // by default forward to world photos
- $guid = (int) get_input('guid');
+$guid = (int) get_input('guid');
- $entity = get_entity($guid);
- if (!$entity) { // unable to get Elgg entity
- register_error(elgg_echo("tidypics:deletefailed"));
- forward($forward_url);
- }
-
- if (!$entity->canEdit()) { // user doesn't have permissions
- register_error(elgg_echo("tidypics:deletefailed"));
- forward($forward_url);
- }
+$entity = get_entity($guid);
+if (!$entity) { // unable to get Elgg entity
+ register_error(elgg_echo("tidypics:deletefailed"));
+ forward($forward_url);
+}
- $subtype = $entity->getSubtype();
- $container = get_entity($entity->container_guid);
-
- if ($subtype != 'image' && $subtype != 'album') { // how did we even get here?
- register_error(elgg_echo("tidypics:deletefailed"));
- forward($forward_url);
- }
+if (!$entity->canEdit()) { // user doesn't have permissions
+ register_error(elgg_echo("tidypics:deletefailed"));
+ forward($forward_url);
+}
+
+$subtype = $entity->getSubtype();
+$container = get_entity($entity->container_guid);
+
+if ($subtype != 'image' && $subtype != 'album') { // how did we even get here?
+ register_error(elgg_echo("tidypics: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('delete', 'tp_image', $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);
+ // plugins can register to be told when a Tidypics album has been deleted
+ trigger_elgg_event('delete', '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;
- $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('delete', 'tp_image', $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);
- // plugins can register to be told when a Tidypics album has been deleted
- trigger_elgg_event('delete', 'tp_album', $entity);
+//loop through all images and delete them
+foreach($images as $im) {
+ $thumbnail = $im->thumbnail;
+ $smallthumb = $im->smallthumb;
+ $largethumb = $im->largethumb;
+
+ if ($thumbnail) { //delete standard thumbnail image
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $im->getOwner();
+ $delfile->setFilename($thumbnail);
+ $delfile->delete();
+ }
+ if ($smallthumb) { //delete small thumbnail image
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $im->getOwner();
+ $delfile->setFilename($smallthumb);
+ $delfile->delete();
+ }
+ if ($largethumb) { //delete large thumbnail image
+ $delfile = new ElggFile();
+ $delfile->owner_guid = $im->getOwner();
+ $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();
- // 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;
- $smallthumb = $im->smallthumb;
- $largethumb = $im->largethumb;
-
- if ($thumbnail) { //delete standard thumbnail image
- $delfile = new ElggFile();
- $delfile->owner_guid = $im->getOwner();
- $delfile->setFilename($thumbnail);
- $delfile->delete();
- }
- if ($smallthumb) { //delete small thumbnail image
- $delfile = new ElggFile();
- $delfile->owner_guid = $im->getOwner();
- $delfile->setFilename($smallthumb);
- $delfile->delete();
- }
- if ($largethumb) { //delete large thumbnail image
- $delfile = new ElggFile();
- $delfile->owner_guid = $im->getOwner();
- $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 (!$delfile->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
- }
- } //end delete actual image file
- } //end looping through each image to delete it
-
- //now that all images have been deleted, delete the album
- if ($subtype == 'album') {
- //delete the album's directory manually; first create a temp file to get the directory path
- $tmpfile = new ElggFile();
- $tmpfile->setFilename('image/' . $guid . '/._tmp_del_tidypics_album_');
- $tmpfile->subtype = 'image';
- $tmpfile->container_guid = $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);
-
- //delete object from database
- if (!$entity->delete()) {
- register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
+ if (!$delfile->delete()) {
+ if ($subtype=='image') register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
} else {
- system_message(elgg_echo("tidypics:deleted")); //successfully deleted object
+ if ($subtype=='image') system_message(elgg_echo("tidypics:deleted")); //successfully deleted object
}
- } //end of delete album
+ } //end delete actual image file
+} //end looping through each image to delete it
- create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid);
+//now that all images have been deleted, delete the album
+if ($subtype == 'album') {
+ //delete the album's directory manually; first create a temp file to get the directory path
+ $tmpfile = new ElggFile();
+ $tmpfile->setFilename('image/' . $guid . '/._tmp_del_tidypics_album_');
+ $tmpfile->subtype = 'image';
+ $tmpfile->container_guid = $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);
+ }
- forward($forward_url);
+ //delete object from database
+ if (!$entity->delete()) {
+ register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object
+ } else {
+ system_message(elgg_echo("tidypics:deleted")); //successfully deleted object
+ }
+} //end of delete album
+
+create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid);
-?> \ No newline at end of file
+forward($forward_url);
diff --git a/actions/deletetag.php b/actions/deletetag.php
index becf1fedb..97c1081f8 100644
--- a/actions/deletetag.php
+++ b/actions/deletetag.php
@@ -1,57 +1,54 @@
<?php
- /**
- * Tidypics Delete Photo Tag
- *
- */
-
- gatekeeper();
- action_gatekeeper();
-
- $image_guid = get_input('image_guid');
- $tags = get_input('tags');
-
-
- if ($image_guid == 0) {
- register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
- }
+/**
+ * Tidypics Delete Photo Tag
+ *
+ */
- $image = get_entity($image_guid);
- if (!$image)
- {
- register_error(elgg_echo("tidypics:phototagging:error"));
- forward($_SERVER['HTTP_REFERER']);
- }
-
- foreach ($tags as $id => $value) {
- // delete normal tag if it exists
- if (is_array($image->tags)) {
- $index = array_search($value, $image->tags);
- if ($index !== false) {
- $tagarray = $image->tags;
- unset($tagarray[$index]);
- $image->clearMetadata('tags');
- $image->tags = $tagarray;
- }
- } else {
- if ($value === $image->tags) {
- $image->clearMetadata('tags');
- }
+gatekeeper();
+action_gatekeeper();
+
+$image_guid = get_input('image_guid');
+$tags = get_input('tags');
+
+
+if ($image_guid == 0) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+$image = get_entity($image_guid);
+if (!$image) {
+ register_error(elgg_echo("tidypics:phototagging:error"));
+ forward($_SERVER['HTTP_REFERER']);
+}
+
+foreach ($tags as $id => $value) {
+ // delete normal tag if it exists
+ if (is_array($image->tags)) {
+ $index = array_search($value, $image->tags);
+ if ($index !== false) {
+ $tagarray = $image->tags;
+ unset($tagarray[$index]);
+ $image->clearMetadata('tags');
+ $image->tags = $tagarray;
}
-
- // delete relationship if this tag is a user
- $annotation = get_annotation($id);
- $photo_tag = unserialize($annotation->value);
- if ($photo_tag->type == 'user') {
- remove_entity_relationship($photo_tag->value, 'phototag', $image_guid);
+ } else {
+ if ($value === $image->tags) {
+ $image->clearMetadata('tags');
}
-
- // delete the photo tag annotation
- delete_annotation($id);
}
-
- system_message(elgg_echo("tidypics:deletetag:success"));
- forward($_SERVER['HTTP_REFERER']);
+ // delete relationship if this tag is a user
+ $annotation = get_annotation($id);
+ $photo_tag = unserialize($annotation->value);
+ if ($photo_tag->type == 'user') {
+ remove_entity_relationship($photo_tag->value, 'phototag', $image_guid);
+ }
+
+ // delete the photo tag annotation
+ delete_annotation($id);
+}
+
+system_message(elgg_echo("tidypics:deletetag:success"));
-?>
+forward($_SERVER['HTTP_REFERER']);
diff --git a/actions/edit.php b/actions/edit.php
index cdf9420b2..db6e26ab9 100644
--- a/actions/edit.php
+++ b/actions/edit.php
@@ -1,81 +1,82 @@
<?php
- /**
- * Tidypics edit album/image action
- *
- */
-
- // Make sure we're logged in
- gatekeeper();
+/**
+ * Tidypics edit album/image action
+ *
+ */
- // Get input data
- $guid = (int) get_input('guid'); // guid of image or album
- $title = get_input('tidypicstitle');
- $body = get_input('tidypicsbody');
- $access = get_input('access_id');
- $tags = get_input('tidypicstags');
- $subtype = get_input('subtype');
- $cover = get_input('cover');
- if (is_array($cover)) $cover = $cover[0];
-
- $container_guid = get_input('container_guid');
+// Make sure we're logged in
+gatekeeper();
- // Make sure we actually have permission to edit
- $entity = get_entity($guid);
- if (!$entity->canEdit()) {
- forward();
- }
+// Get input data
+$guid = (int) get_input('guid'); // guid of image or album
+$title = get_input('tidypicstitle');
+$body = get_input('tidypicsbody');
+$access = get_input('access_id');
+$tags = get_input('tidypicstags');
+$subtype = get_input('subtype');
+$cover = get_input('cover');
+if (is_array($cover)) {
+ $cover = $cover[0];
+}
- // Get owning user/group
- $owner = get_entity($entity->getOwner());
+$container_guid = get_input('container_guid');
- // change access only if access is different from current
- if ($subtype == 'album' && $entity->access_id != $access) {
- $entity->access_id = $access;
-
- //get images from album and update access on image entities
- $images = get_entities("object","image", $guid, '', 999, '', false);
- foreach ($images as $im) {
- $im->access_id = $access;
- $im->save();
- }
- }
+// Make sure we actually have permission to edit
+$entity = get_entity($guid);
+if (!$entity->canEdit()) {
+ forward();
+}
+// Get owning user/group
+$owner = get_entity($entity->getOwner());
- // Set its title and description appropriately
- $entity->title = $title;
- $entity->description = $body;
+// change access only if access is different from current
+if ($subtype == 'album' && $entity->access_id != $access) {
+ $entity->access_id = $access;
- // Before we can set metadata, we need to save the entity
- if (!$entity->save()) {
- register_error(elgg_echo("album:error"));
- $entity->delete();
- forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
+ //get images from album and update access on image entities
+ $images = get_entities("object","image", $guid, '', 999, '', false);
+ foreach ($images as $im) {
+ $im->access_id = $access;
+ $im->save();
}
+}
- // Now let's add tags
- $tagarray = string_to_tag_array($tags);
- $entity->clearMetadata('tags');
- if (is_array($tagarray)) {
- $entity->tags = $tagarray;
- }
- //if cover meta is sent from image save as metadata
- if ($subtype == 'image' && $cover == elgg_echo('album:cover')) {
- $album = get_entity($container_guid);
- $album->cover = $entity->guid;
- }
+// Set its title and description appropriately
+$entity->title = $title;
+$entity->description = $body;
- // Success message
- if ($subtype == 'album') {
- system_message(elgg_echo("album:edited"));
- // plugins can register to be told when a Tidypics album has been updated
- trigger_elgg_event('update', 'tp_album', $entity);
- } else {
- system_message(elgg_echo('images:edited'));
- // plugins can register to be told when a Tidypics image has been updated
- trigger_elgg_event('update', 'tp_image', $entity);
- }
+// Before we can set metadata, we need to save the entity
+if (!$entity->save()) {
+ register_error(elgg_echo("album:error"));
+ $entity->delete();
+ forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page
+}
+
+// Now let's add tags
+$tagarray = string_to_tag_array($tags);
+$entity->clearMetadata('tags');
+if (is_array($tagarray)) {
+ $entity->tags = $tagarray;
+}
+
+//if cover meta is sent from image save as metadata
+if ($subtype == 'image' && $cover == elgg_echo('album:cover')) {
+ $album = get_entity($container_guid);
+ $album->cover = $entity->guid;
+}
+
+// Success message
+if ($subtype == 'album') {
+ system_message(elgg_echo("album:edited"));
+ // plugins can register to be told when a Tidypics album has been updated
+ trigger_elgg_event('update', 'tp_album', $entity);
+} else {
+ system_message(elgg_echo('images:edited'));
+ // plugins can register to be told when a Tidypics image has been updated
+ trigger_elgg_event('update', 'tp_image', $entity);
+}
- forward($entity->getURL());
-?>
+forward($entity->getURL());
diff --git a/actions/edit_multi.php b/actions/edit_multi.php
index c7099e6db..c938e6065 100644
--- a/actions/edit_multi.php
+++ b/actions/edit_multi.php
@@ -1,66 +1,65 @@
<?php
- /**
- * Elgg album: multi image edit action
- *
- * This is called when uploading images
- */
-
- // Make sure we're logged in
- gatekeeper();
+/**
+ * Elgg album: multi image edit action
+ *
+ * This is called when uploading images
+ */
- // Get input data
- $title_array = get_input('title');
- $caption_array = get_input('caption');
- $tags_array = get_input('tags');
- $image_guid_array = get_input('image_guid');
- $container_guid = get_input('container_guid');
- $album_entity = get_entity($container_guid);
- $cover = get_input('cover');
- $not_updated = array();
+// Make sure we're logged in
+gatekeeper();
- foreach($image_guid_array as $key => $im) {
- $image = get_entity($im);
-
- if ($image->canEdit()) {
-
- // Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags_array[$key]);
+// Get input data
+$title_array = get_input('title');
+$caption_array = get_input('caption');
+$tags_array = get_input('tags');
+$image_guid_array = get_input('image_guid');
+$container_guid = get_input('container_guid');
+$album_entity = get_entity($container_guid);
+$cover = get_input('cover');
+$not_updated = array();
- //set title appropriately
- if ($title_array[$key])
- $image->title = $title_array[$key];
- else
- $image->title = substr($image->originalfilename, 0, strrpos($image->originalfilename, '.'));
-
- //set description appropriately
- $image->description = $caption_array[$key];
+foreach($image_guid_array as $key => $im) {
+ $image = get_entity($im);
- // Before we can set metadata, we need to save the image
- if (!$image->save()) {
- array_push($not_updated, $image->guid);
- }
+ if ($image->canEdit()) {
- // Now let's add tags. We can pass an array directly to the object property! Easy.
- $image->clearMetadata('tags');
- if (is_array($tagarray)) {
- $image->tags = $tagarray;
- }
-
- //if cover meta is sent from image save as metadata
- if ($cover == $im) {
- $album_entity->cover = $im;
- }
+ // Convert string of tags into a preformatted array
+ $tagarray = string_to_tag_array($tags_array[$key]);
+
+ //set title appropriately
+ if ($title_array[$key]) {
+ $image->title = $title_array[$key];
+ } else {
+ $image->title = substr($image->originalfilename, 0, strrpos($image->originalfilename, '.'));
+ }
+
+ //set description appropriately
+ $image->description = $caption_array[$key];
+
+ // Before we can set metadata, we need to save the image
+ if (!$image->save()) {
+ array_push($not_updated, $image->guid);
+ }
+
+ // Now let's add tags. We can pass an array directly to the object property! Easy.
+ $image->clearMetadata('tags');
+ if (is_array($tagarray)) {
+ $image->tags = $tagarray;
+ }
+
+ //if cover meta is sent from image save as metadata
+ if ($cover == $im) {
+ $album_entity->cover = $im;
}
}
-
- // Success message
- if (count($not_updated) > 0) {
- register_error(elgg_echo("images:notedited"));
- } else {
- system_message(elgg_echo("images:edited"));
- }
-
- // Forward to the main album page
- forward($album_entity->getURL());
+}
+
+// Success message
+if (count($not_updated) > 0) {
+ register_error(elgg_echo("images:notedited"));
+} else {
+ system_message(elgg_echo("images:edited"));
+}
-?> \ No newline at end of file
+// Forward to the main album page
+forward($album_entity->getURL());
diff --git a/actions/flickrImportPhotoset.php b/actions/flickrImportPhotoset.php
index ec0d65b5d..fd6769e3a 100644
--- a/actions/flickrImportPhotoset.php
+++ b/actions/flickrImportPhotoset.php
@@ -28,11 +28,11 @@ $photos_url = $f->urls_getUserPhotos( $flickr_id->value );
$photos = $f->photosets_getPhotos( $set_id, null, null, 10, $page_pp );
$photos_to_upload = array();
-foreach( $photos["photoset"]["photo"] as $photo ) {
+foreach ($photos["photoset"]["photo"] as $photo) {
//check if we already have this image
$meta = get_metadata_byname( $user->guid, $photo["id"] );
- if( $meta->value == 1 ) { //we've downloaded this already
+ if ($meta->value == 1) { //we've downloaded this already
register_error( elgg_echo( 'flickr:errorimageimport' ));
continue;
}
@@ -41,7 +41,7 @@ foreach( $photos["photoset"]["photo"] as $photo ) {
$photo_info = $f->photos_getInfo( $photo["id"], $photo["secret"] );
$tags = array();
- foreach( $photo_info["tags"]["tag"] as $tag ) {
+ foreach ($photo_info["tags"]["tag"] as $tag) {
$tags[] = $tag["raw"];
}
$tags = implode( ", ", $tags );
@@ -337,4 +337,3 @@ trigger_elgg_event('upload', 'tp_album', $album);
$url = $CONFIG->wwwroot . 'mod/tidypics/pages/edit_multiple.php?files=' . implode('-', $uploaded_images);
forward($url);
-?>
diff --git a/actions/flickrSetup.php b/actions/flickrSetup.php
index fbc519b02..ee31b8c34 100644
--- a/actions/flickrSetup.php
+++ b/actions/flickrSetup.php
@@ -34,5 +34,3 @@ if( empty( $flickr_username )) {
forward($_SERVER['HTTP_REFERER']);
//echo "<pre>"; var_dump( array($flickr_username, $return_url )); echo "</pre>";
-
-?> \ No newline at end of file
diff --git a/actions/imtest.php b/actions/imtest.php
index cbe15a1c1..293a9b2e8 100644
--- a/actions/imtest.php
+++ b/actions/imtest.php
@@ -1,19 +1,18 @@
<?php
- /**
- * Tidypics ImageMagick Location Test
- *
- * Called through ajax
- */
-
- $location = $_GET['location'];
-
- $command = $location . "convert -version";
-
- $result = system($command, $return_val);
-
- if ($return_val == 0) {
- echo $result;
- } else {
- echo "Unable to run ImageMagick. Please check the path.";
- }
-?>
+/**
+ * Tidypics ImageMagick Location Test
+ *
+ * Called through ajax
+ */
+
+$location = $_GET['location'];
+
+$command = $location . "convert -version";
+
+$result = system($command, $return_val);
+
+if ($return_val == 0) {
+ echo $result;
+} else {
+ echo "Unable to run ImageMagick. Please check the path.";
+}
diff --git a/actions/settings.php b/actions/settings.php
index a4f102b89..2c529d950 100644
--- a/actions/settings.php
+++ b/actions/settings.php
@@ -1,72 +1,77 @@
<?php
- /**
- * Save settings of Tidypics
- *
- */
+/**
+ * Save settings of Tidypics
+ *
+ */
- global $CONFIG;
+global $CONFIG;
- admin_gatekeeper();
- action_gatekeeper();
+admin_gatekeeper();
+action_gatekeeper();
- // Params array (text boxes and drop downs)
- $params = get_input('params');
- $result = false;
- foreach ($params as $k => $v) {
- if (!set_plugin_setting($k, $v, 'tidypics')) {
- register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics'));
- forward($_SERVER['HTTP_REFERER']);
- }
+// Params array (text boxes and drop downs)
+$params = get_input('params');
+$result = false;
+foreach ($params as $k => $v) {
+ if (!set_plugin_setting($k, $v, 'tidypics')) {
+ register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics'));
+ forward($_SERVER['HTTP_REFERER']);
}
+}
- // check boxes
- if (is_array(get_input('download_link'))) // this can be done due to way Elgg uses checkboxes
- set_plugin_setting('download_link', 'enabled', 'tidypics');
- else
- set_plugin_setting('download_link', 'disabled', 'tidypics');
-
- if (is_array(get_input('tagging')))
- set_plugin_setting('tagging', 'enabled', 'tidypics');
- else
- set_plugin_setting('tagging', 'disabled', 'tidypics');
-
- if (is_array(get_input('photo_ratings')))
- set_plugin_setting('photo_ratings', 'enabled', 'tidypics');
- else
- set_plugin_setting('photo_ratings', 'disabled', 'tidypics');
-
- if (is_array(get_input('exif')))
- set_plugin_setting('exif', 'enabled', 'tidypics');
- else
- set_plugin_setting('exif', 'disabled', 'tidypics');
-
- if (is_array(get_input('view_count')))
- set_plugin_setting('view_count', 'enabled', 'tidypics');
- else
- set_plugin_setting('view_count', 'disabled', 'tidypics');
-
- if (is_array(get_input('grp_perm_override')))
- set_plugin_setting('grp_perm_override', 'enabled', 'tidypics');
- else
- set_plugin_setting('grp_perm_override', 'disabled', 'tidypics');
-
-
- // image sizes
- $image_sizes = array();
- $image_sizes['large_image_width'] = get_input('large_thumb_width');
- $image_sizes['large_image_height'] = get_input('large_thumb_height');
- $image_sizes['small_image_width'] = get_input('small_thumb_width');
- //$image_sizes['small_image_height'] = get_input('small_thumb_height');
- $image_sizes['small_image_height'] = get_input('small_thumb_width');
- $image_sizes['thumb_image_width'] = get_input('thumb_width');
- //$image_sizes['thumb_image_height'] = get_input('thumb_height');
- $image_sizes['thumb_image_height'] = get_input('thumb_width');
- set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics');
-
-
-
- system_message(elgg_echo('tidypics:settings:save:ok'));
-
- forward($_SERVER['HTTP_REFERER']);
-?>
+// check boxes
+if (is_array(get_input('download_link'))) { // this can be done due to way Elgg uses checkboxes
+ set_plugin_setting('download_link', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('download_link', 'disabled', 'tidypics');
+}
+
+if (is_array(get_input('tagging'))) {
+ set_plugin_setting('tagging', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('tagging', 'disabled', 'tidypics');
+}
+
+if (is_array(get_input('photo_ratings'))) {
+ set_plugin_setting('photo_ratings', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('photo_ratings', 'disabled', 'tidypics');
+}
+
+if (is_array(get_input('exif'))) {
+ set_plugin_setting('exif', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('exif', 'disabled', 'tidypics');
+}
+
+if (is_array(get_input('view_count'))) {
+ set_plugin_setting('view_count', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('view_count', 'disabled', 'tidypics');
+}
+
+if (is_array(get_input('grp_perm_override'))) {
+ set_plugin_setting('grp_perm_override', 'enabled', 'tidypics');
+} else {
+ set_plugin_setting('grp_perm_override', 'disabled', 'tidypics');
+}
+
+
+// image sizes
+$image_sizes = array();
+$image_sizes['large_image_width'] = get_input('large_thumb_width');
+$image_sizes['large_image_height'] = get_input('large_thumb_height');
+$image_sizes['small_image_width'] = get_input('small_thumb_width');
+//$image_sizes['small_image_height'] = get_input('small_thumb_height');
+$image_sizes['small_image_height'] = get_input('small_thumb_width');
+$image_sizes['thumb_image_width'] = get_input('thumb_width');
+//$image_sizes['thumb_image_height'] = get_input('thumb_height');
+$image_sizes['thumb_image_height'] = get_input('thumb_width');
+set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics');
+
+
+
+system_message(elgg_echo('tidypics:settings:save:ok'));
+
+forward($_SERVER['HTTP_REFERER']);
diff --git a/actions/upgrade.php b/actions/upgrade.php
index cb200380a..596b90a22 100644
--- a/actions/upgrade.php
+++ b/actions/upgrade.php
@@ -6,35 +6,34 @@
*
*********************************************/
- include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
-
- admin_gatekeeper();
-
- $result = true;
-
- // add image class
- $id = get_subtype_id("object", "image");
- if ($id != 0) {
- $table = $CONFIG->dbprefix . 'entity_subtypes';
- $result = update_data("UPDATE {$table} set class='TidypicsImage' where id={$id}");
- if (!result) {
- register_error(elgg_echo('tidypics:upgrade:failed'));
- forward($_SERVER['HTTP_REFERER']);
- }
+include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
+
+admin_gatekeeper();
+
+$result = true;
+
+// add image class
+$id = get_subtype_id("object", "image");
+if ($id != 0) {
+ $table = $CONFIG->dbprefix . 'entity_subtypes';
+ $result = update_data("UPDATE {$table} set class='TidypicsImage' where id={$id}");
+ if (!result) {
+ register_error(elgg_echo('tidypics:upgrade:failed'));
+ forward($_SERVER['HTTP_REFERER']);
}
+}
- // add album class
- $id = get_subtype_id("object", "album");
- if ($id != 0) {
- $table = $CONFIG->dbprefix . 'entity_subtypes';
- $result = update_data("UPDATE {$table} set class='TidypicsAlbum' where id={$id}");
- if (!result) {
- register_error(elgg_echo('tidypics:upgrade:failed'));
- forward($_SERVER['HTTP_REFERER']);
- }
+// add album class
+$id = get_subtype_id("object", "album");
+if ($id != 0) {
+ $table = $CONFIG->dbprefix . 'entity_subtypes';
+ $result = update_data("UPDATE {$table} set class='TidypicsAlbum' where id={$id}");
+ if (!result) {
+ register_error(elgg_echo('tidypics:upgrade:failed'));
+ forward($_SERVER['HTTP_REFERER']);
}
+}
+
+system_message(elgg_echo('tidypics:upgrade:success'));
- system_message(elgg_echo('tidypics:upgrade:success'));
-
- forward($_SERVER['HTTP_REFERER']);
-?> \ No newline at end of file
+forward($_SERVER['HTTP_REFERER']);