aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-07-14 08:10:28 -0400
committerCash Costello <cash.costello@gmail.com>2012-07-14 08:10:28 -0400
commit4761adf8eee9feadd77599682ef192b56520d11d (patch)
tree022a921d20ddd26fb226351cadedf9a8dfe9e971
parent4448f072dc6149a62b602e60e766fd00c2b6af89 (diff)
parentc1da32e6a7e2f4a15a3b2d69cd38a1c0c164a99d (diff)
downloadelgg-4761adf8eee9feadd77599682ef192b56520d11d.tar.gz
elgg-4761adf8eee9feadd77599682ef192b56520d11d.tar.bz2
Pulling in several small fixes from Brett's fork
-rw-r--r--actions/photos/admin/create_thumbnails.php2
-rw-r--r--actions/photos/album/set_cover.php23
-rw-r--r--actions/photos/album/sort.php7
-rw-r--r--actions/photos/image/ajax_upload.php4
-rw-r--r--actions/photos/image/ajax_upload_complete.php2
-rw-r--r--actions/photos/image/save.php2
-rw-r--r--actions/photos/image/tag.php2
-rw-r--r--actions/photos/image/upload.php4
-rw-r--r--classes/TidypicsAlbum.php15
-rw-r--r--classes/TidypicsImage.php11
-rw-r--r--languages/en.php16
-rw-r--r--lib/exif.php2
-rw-r--r--pages/photos/album/sort.php14
-rw-r--r--pages/photos/batch/edit.php2
-rw-r--r--pages/photos/image/view.php8
-rw-r--r--start.php42
-rw-r--r--views/default/forms/photos/batch/edit.php1
-rw-r--r--views/default/js/photos/uploading.php3
-rw-r--r--views/default/object/image.php2
-rw-r--r--views/default/photos/group_module.php2
-rw-r--r--views/default/photos/tagging/tag.php2
-rw-r--r--views/default/river/object/image/tag.php2
22 files changed, 136 insertions, 32 deletions
diff --git a/actions/photos/admin/create_thumbnails.php b/actions/photos/admin/create_thumbnails.php
index f2e9b26e2..dfb5d4ed1 100644
--- a/actions/photos/admin/create_thumbnails.php
+++ b/actions/photos/admin/create_thumbnails.php
@@ -23,7 +23,7 @@ if (!$filename || !$container_guid) {
forward(REFERER);
}
-$title = $image->title;
+$title = $image->getTitle();
$prefix = "image/$container_guid/";
$filestorename = substr($filename, strlen($prefix));
diff --git a/actions/photos/album/set_cover.php b/actions/photos/album/set_cover.php
new file mode 100644
index 000000000..b37bb9c90
--- /dev/null
+++ b/actions/photos/album/set_cover.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Set album cover image
+ */
+
+// Get input data
+$album_guid = get_input('album_guid');
+$image_guid = get_input('image_guid');
+
+$album = get_entity($album_guid);
+
+if (!elgg_instanceof($album, 'object', 'album')) {
+ register_error(elgg_echo('album:invalid_album'));
+ forward(REFERER);
+}
+
+if ($album->setCoverImageGuid($image_guid)) {
+ system_message(elgg_echo('album:save_cover_image'));
+ forward(REFERER);
+} else {
+ register_error(elgg_echo('album:cannot_save_cover_image'));
+ forward(REFERER);
+} \ No newline at end of file
diff --git a/actions/photos/album/sort.php b/actions/photos/album/sort.php
index 613747784..fd62a7ba7 100644
--- a/actions/photos/album/sort.php
+++ b/actions/photos/album/sort.php
@@ -12,7 +12,10 @@ if (!$album) {
$guids = get_input('guids');
$guids = explode(',', $guids);
-$album->setImageList($guids);
+if ($album->setImageList($guids)) {
+ system_message(elgg_echo('tidypics:album:sorted', array($album->getTitle())));
+} else {
+ register_error(elgg_echo('tidypics:album:could_not_sort', array($album->getTitle())));
+}
-system_message(elgg_echo('tidypics:album:sorted', array($album->title)));
forward($album->getURL()); \ No newline at end of file
diff --git a/actions/photos/image/ajax_upload.php b/actions/photos/image/ajax_upload.php
index d6b083cf6..312bc598c 100644
--- a/actions/photos/image/ajax_upload.php
+++ b/actions/photos/image/ajax_upload.php
@@ -22,7 +22,7 @@ if (empty($_FILES)) {
exit;
}
-$file = $_FILES['Image'];
+$file = $_FILES[$file_var_name];
$mime = tp_upload_get_mimetype($file['name']);
if ($mime == 'unknown') {
@@ -44,7 +44,7 @@ try {
$album->prependImageList(array($image->guid));
if (elgg_get_plugin_setting('img_river_view', 'tidypics') === "all") {
- add_to_river('river/object/image/create', 'create', $image->getObjectOwnerGUID(), $image->getGUID());
+ add_to_river('river/object/image/create', 'create', $image->getOwnerGUID(), $image->getGUID());
}
echo elgg_echo('success');
diff --git a/actions/photos/image/ajax_upload_complete.php b/actions/photos/image/ajax_upload_complete.php
index 6d398b3aa..358a4fc6f 100644
--- a/actions/photos/image/ajax_upload_complete.php
+++ b/actions/photos/image/ajax_upload_complete.php
@@ -41,7 +41,7 @@ if ($images) {
// "added images to album" river
if ($img_river_view == "batch" && $album->new_album == false) {
- add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+ add_to_river('river/object/tidypics_batch/create', 'create', $batch->getOwnerGUID(), $batch->getGUID());
}
// "created album" river
diff --git a/actions/photos/image/save.php b/actions/photos/image/save.php
index 535ae8bbb..1cb65b1e8 100644
--- a/actions/photos/image/save.php
+++ b/actions/photos/image/save.php
@@ -16,7 +16,7 @@ $guid = get_input('guid');
elgg_make_sticky_form('tidypics');
if (empty($title)) {
- register_error(elgg_echo("album:blank"));
+ register_error(elgg_echo("image:blank"));
forward(REFERER);
}
diff --git a/actions/photos/image/tag.php b/actions/photos/image/tag.php
index 20f476944..e623bd546 100644
--- a/actions/photos/image/tag.php
+++ b/actions/photos/image/tag.php
@@ -92,7 +92,7 @@ if ($annotation_id) {
elgg_echo('tidypics:tag:subject'),
sprintf(
elgg_echo('tidypics:tag:body'),
- $image->title,
+ $image->getTitle(),
$tagger->name,
$image->getURL()
)
diff --git a/actions/photos/image/upload.php b/actions/photos/image/upload.php
index b917a1598..cb0a2f90d 100644
--- a/actions/photos/image/upload.php
+++ b/actions/photos/image/upload.php
@@ -68,7 +68,7 @@ foreach ($_FILES['images']['name'] as $index => $value) {
array_push($uploaded_images, $image->getGUID());
if ($img_river_view == "all") {
- add_to_river('river/object/image/create', 'create', $image->getObjectOwnerGUID(), $image->getGUID());
+ add_to_river('river/object/image/create', 'create', $image->getOwnerGUID(), $image->getGUID());
}
}
}
@@ -89,7 +89,7 @@ if (count($uploaded_images)) {
// "added images to album" river
if ($img_river_view == "batch" && $album->new_album == false) {
- add_to_river('river/object/tidypics_batch/create', 'create', $batch->getObjectOwnerGUID(), $batch->getGUID());
+ add_to_river('river/object/tidypics_batch/create', 'create', $batch->getOwnerGUID(), $batch->getGUID());
}
// "created album" river
diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php
index ad1a357de..57bdcf707 100644
--- a/classes/TidypicsAlbum.php
+++ b/classes/TidypicsAlbum.php
@@ -206,8 +206,14 @@ class TidypicsAlbum extends ElggObject {
}
$list = unserialize($listString);
+ // if empty don't need to check the permissions.
+ if (!$list || $list[0] == '') {
+ return array();
+ }
+
// check access levels
$guidsString = implode(',', $list);
+
$options = array(
'wheres' => array("e.guid IN ($guidsString)"),
'order_by' => "FIELD(e.guid, $guidsString)",
@@ -225,8 +231,15 @@ class TidypicsAlbum extends ElggObject {
* @param array $list An indexed array of image guids
*/
public function setImageList($list) {
+ // validate data
+ foreach ($list as $guid) {
+ if (!filter_var($guid, FILTER_VALIDATE_INT)) {
+ return false;
+ }
+ }
+
$listString = serialize($list);
- $this->orderedImages = $listString;
+ return $this->orderedImages = $listString;
}
/**
diff --git a/classes/TidypicsImage.php b/classes/TidypicsImage.php
index c0b5de723..26a3483a9 100644
--- a/classes/TidypicsImage.php
+++ b/classes/TidypicsImage.php
@@ -90,7 +90,11 @@ class TidypicsImage extends ElggFile {
* @return string
*/
public function getTitle() {
- return $this->title;
+ if ($this->title) {
+ return $this->title;
+ } else {
+ return $this->originalfilename;
+ }
}
/**
@@ -244,6 +248,11 @@ class TidypicsImage extends ElggFile {
trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING);
throw new Exception(elgg_echo('tidypics:image_pixels'));
}
+
+ // make sure file fits quota
+ if (!tp_upload_check_quota($data['size'], elgg_get_logged_in_user_guid())) {
+ throw new Exception(elgg_echo('tidypics:cannot_upload_exceeds_quota'));
+ }
}
/**
diff --git a/languages/en.php b/languages/en.php
index efae155b3..624b5234c 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -163,6 +163,7 @@ $english = array(
'album:desc' => "Description",
'album:tags' => "Tags",
'album:cover' => "Make image album cover?",
+ 'album:cover_link' => 'Set cover image',
'tidypics:quota' => "Quota usage:",
'tidypics:uploader:choose' => "Choose photos",
'tidypics:uploader:upload' => "Upload photos",
@@ -171,6 +172,7 @@ $english = array(
'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: choosing, uploading, and describing them. If you do not have Flash, there is also a <a href="%s">basic uploader</a> available.',
'tidypics:uploader:basic' => 'You can upload up to 10 photos at a time (%s MB maximum per photo)',
'tidypics:sort:instruct' => 'Sort the album photos by dragging and dropping the images. Then click the save button.',
+ 'tidypics:sort:no_images' => 'No images found to sort. Upload images using the link above.',
// albums
'album:num' => '%s photos',
@@ -252,8 +254,10 @@ The photo can be viewed here: %s",
'album:deleted' => "Your album was successfully deleted.",
'album:delete:confirm' => "Are you sure you want to delete this album?",
'album:created' => "Your new album has been created.",
+ 'album:save_cover_image' => 'Cover image saved.',
'tidypics:settings:save:ok' => 'Successfully saved the Tidypics plugin settings',
'tidypics:album:sorted' => 'The album %s is sorted',
+ 'tidypics:album:could_not_sort' => 'Could not sort the album %s. Make sure there are images in the album and try again.',
'tidypics:upgrade:success' => 'Upgrade of Tidypics a success',
//Error messages
@@ -269,14 +273,22 @@ The photo can be viewed here: %s",
'tidypics:not_image' => "This is not a recognized image type",
'tidypics:deletefailed' => "Sorry. Deletion failed.",
'tidypics:deleted' => "Successful deletion.",
- 'image:downloadfailed' => "Sorry; this image is not available.",
'tidypics:nosettings' => "Admin of this site has not set photo album settings.",
'tidypics:exceed_quota' => "You have exceeded the quota set by the administrator",
- 'images:notedited' => "Not all images were successfully updated",
+ 'tidypics:cannot_upload_exceeds_quota' => 'Image not uploaded. File size exceeds available quota.',
+
'album:none' => "No albums have been created yet.",
'album:uploadfailed' => "Sorry; we could not save your album.",
'album:deletefailed' => "Your album could not be deleted.",
'album:blank' => "Please give this album a title.",
+ 'album:invalid_album' => 'Invalid album',
+ 'album:cannot_save_cover_image' => 'Cannot save cover image',
+
+ 'image:downloadfailed' => "Sorry; this image is not available.",
+ 'images:notedited' => "Not all images were successfully updated",
+ 'image:blank' => 'Please give this image a title.',
+ 'image:error' => 'Could not save image.',
+
'tidypics:upgrade:failed' => "The upgrade of Tidypics failed",
);
diff --git a/lib/exif.php b/lib/exif.php
index 55612a433..43a640336 100644
--- a/lib/exif.php
+++ b/lib/exif.php
@@ -24,7 +24,7 @@ function td_get_exif($file) {
$filename = $file->getFilenameOnFilestore();
$exif = exif_read_data($filename);
- create_metadata($file->getGUID(), "tp_exif", serialize($exif), "text", $file->getObjectOwnerGUID(), ACCESS_PUBLIC);
+ create_metadata($file->getGUID(), "tp_exif", serialize($exif), "text", $file->getOwnerGUID(), ACCESS_PUBLIC);
}
/**
diff --git a/pages/photos/album/sort.php b/pages/photos/album/sort.php
index a1d890be1..005205dd5 100644
--- a/pages/photos/album/sort.php
+++ b/pages/photos/album/sort.php
@@ -30,11 +30,21 @@ if (elgg_instanceof($owner, 'group')) {
} else {
elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
}
-elgg_push_breadcrumb($album->title, $album->getURL());
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
elgg_push_breadcrumb(elgg_echo('album:sort'));
+elgg_register_menu_item('title', array(
+ 'name' => 'upload',
+ 'href' => 'photos/upload/' . $album->getGUID(),
+ 'text' => elgg_echo('images:upload'),
+ 'link_class' => 'elgg-button elgg-button-action',
+));
-$content = elgg_view_form('photos/album/sort', array(), array('album' => $album));
+if ($album->getSize()) {
+ $content = elgg_view_form('photos/album/sort', array(), array('album' => $album));
+} else {
+ $content = elgg_echo('tidypics:sort:no_images');
+}
$body = elgg_view_layout('content', array(
'filter' => false,
diff --git a/pages/photos/batch/edit.php b/pages/photos/batch/edit.php
index b96ddf408..ca9a55b18 100644
--- a/pages/photos/batch/edit.php
+++ b/pages/photos/batch/edit.php
@@ -29,7 +29,7 @@ $title = elgg_echo('tidypics:editprops');
elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
-elgg_push_breadcrumb($album->title, $album->getURL());
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
elgg_push_breadcrumb($title);
$content = elgg_view_form('photos/batch/edit', array(), array('batch' => $batch));
diff --git a/pages/photos/image/view.php b/pages/photos/image/view.php
index 6db9ff529..6bd0257e0 100644
--- a/pages/photos/image/view.php
+++ b/pages/photos/image/view.php
@@ -36,8 +36,8 @@ if (elgg_instanceof($owner, 'group')) {
} else {
elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
}
-elgg_push_breadcrumb($album->title, $album->getURL());
-elgg_push_breadcrumb($photo->title);
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($photo->getTitle());
if (elgg_get_plugin_setting('download_link', 'tidypics')) {
// add download button to title menu
@@ -54,11 +54,11 @@ $content = elgg_view_entity($photo, array('full_view' => true));
$body = elgg_view_layout('content', array(
'filter' => false,
'content' => $content,
- 'title' => $photo->title,
+ 'title' => $photo->getTitle(),
'sidebar' => elgg_view('tidypics/sidebar', array(
'page' => 'view',
'image' => $photo,
)),
));
-echo elgg_view_page($photo->title, $body);
+echo elgg_view_page($photo->getTitle(), $body);
diff --git a/start.php b/start.php
index 1129c7f2f..13a9e2d85 100644
--- a/start.php
+++ b/start.php
@@ -78,7 +78,8 @@ function tidypics_init() {
elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'tidypics_notify_message');
// ajax handler for uploads when use_only_cookies is set
- elgg_register_plugin_hook_handler('forward', 'csrf', 'tidypics_ajax_session_handler');
+ // using the all forward hook to work with walled gardens.
+ elgg_register_plugin_hook_handler('forward', 'all', 'tidypics_ajax_session_handler');
/*
// Register for notifications
@@ -88,17 +89,21 @@ function tidypics_init() {
*/
// Register actions
$base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
+ elgg_register_action("photos/delete", "$base_dir/delete.php");
+
elgg_register_action("photos/album/save", "$base_dir/album/save.php");
elgg_register_action("photos/album/sort", "$base_dir/album/sort.php");
- elgg_register_action("photos/delete", "$base_dir/delete.php");
+ elgg_register_action("photos/album/set_cover", "$base_dir/album/set_cover.php");
+
elgg_register_action("photos/image/upload", "$base_dir/image/upload.php");
elgg_register_action("photos/image/save", "$base_dir/image/save.php");
- elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
elgg_register_action("photos/image/ajax_upload", "$base_dir/image/ajax_upload.php", 'logged_in');
elgg_register_action("photos/image/ajax_upload_complete", "$base_dir/image/ajax_upload_complete.php", 'logged_in');
elgg_register_action("photos/image/tag", "$base_dir/image/tag.php");
elgg_register_action("photos/image/untag", "$base_dir/image/untag.php");
+ elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
+
elgg_register_action("photos/admin/settings", "$base_dir/admin/settings.php", 'admin');
elgg_register_action("photos/admin/create_thumbnails", "$base_dir/admin/create_thumbnails.php", 'admin');
elgg_register_action("photos/admin/upgrade", "$base_dir/admin/upgrade.php", 'admin');
@@ -293,6 +298,30 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) {
}
if (elgg_instanceof($entity, 'object', 'image')) {
+ $album = $entity->getContainerEntity();
+ $cover_guid = $album->getCoverImageGuid();
+ if ($cover_guid != $entity->getGUID() && $album->canEdit()) {
+ $url = 'action/photos/album/set_cover'
+ . '?image_guid=' . $entity->getGUID()
+ . '&album_guid=' . $album->getGUID();
+
+ $params = array(
+ 'href' => $url,
+ 'text' => elgg_echo('album:cover_link'),
+ 'is_action' => true,
+ 'is_trusted' => true,
+ 'confirm' => elgg_echo('album:cover')
+ );
+ $text = elgg_view('output/confirmlink', $params);
+
+ $options = array(
+ 'name' => 'set_cover',
+ 'text' => $text,
+ 'priority' => 80,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
if (elgg_get_plugin_setting('view_count', 'tidypics')) {
$view_info = $entity->getViewInfo();
$text = elgg_echo('tidypics:views', array((int)$view_info['total']));
@@ -318,7 +347,8 @@ function tidypics_entity_menu_setup($hook, $type, $return, $params) {
}
}
- if (elgg_instanceof($entity, 'object', 'album')) {
+ // only show these options if there are images
+ if (elgg_instanceof($entity, 'object', 'album') && $entity->getSize() > 0) {
$url = $entity->getURL() . '?limit=50&view=rss';
$url = elgg_format_url($url);
$slideshow_link = "javascript:PicLensLite.start({maxScale:0, feedUrl:'$url'})";
@@ -394,14 +424,14 @@ function tidypics_notify_message($hook, $type, $result, $params) {
if ($entity->first_upload) {
$descr = $entity->description;
- $title = $entity->title;
+ $title = $entity->getTitle();
$owner = $entity->getOwnerEntity();
return elgg_echo('tidypics:newalbum', array($owner->name))
. ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL();
} else {
if ($entity->shouldNotify()) {
$descr = $entity->description;
- $title = $entity->title;
+ $title = $entity->getTitle();
$owner = $entity->getOwnerEntity();
return elgg_echo('tidypics:updatealbum', array($owner->name, $title)) . ': ' . $entity->getURL();
diff --git a/views/default/forms/photos/batch/edit.php b/views/default/forms/photos/batch/edit.php
index fa017ac96..d843d8349 100644
--- a/views/default/forms/photos/batch/edit.php
+++ b/views/default/forms/photos/batch/edit.php
@@ -17,6 +17,7 @@ $images = elgg_get_entities_from_relationship(array(
'relationship' => 'belongs_to_batch',
'relationship_guid' => $batch->getGUID(),
'inverse_relationship' => true,
+ 'limit' => 0
));
echo '<ul>';
diff --git a/views/default/js/photos/uploading.php b/views/default/js/photos/uploading.php
index 4330ae5ba..465f937ab 100644
--- a/views/default/js/photos/uploading.php
+++ b/views/default/js/photos/uploading.php
@@ -76,6 +76,9 @@ elgg.tidypics.uploading.init = function() {
if (data.fileCount == 0) {
$("#tidypics-upload-button").addClass('tidypics-disable');
}
+ },
+ 'onError' : function (event, ID, fileObj, errorObj) {
+ // @todo do something useful with the limited information in the errorObj.
}
});
diff --git a/views/default/object/image.php b/views/default/object/image.php
index 12d58440d..2aa76d48f 100644
--- a/views/default/object/image.php
+++ b/views/default/object/image.php
@@ -25,7 +25,7 @@ include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/lib/exif.php";
$image = $vars['entity'];
$image_guid = $image->getGUID();
$tags = $image->tags;
-$title = $image->title;
+$title = $image->getTitle();
$desc = $image->description;
$owner = $image->getOwnerEntity();
$friendlytime = friendly_time($image->time_created);
diff --git a/views/default/photos/group_module.php b/views/default/photos/group_module.php
index aa0e7b3ff..de7a451c4 100644
--- a/views/default/photos/group_module.php
+++ b/views/default/photos/group_module.php
@@ -3,7 +3,7 @@
* Group blog module
*/
-$group = elgg_get_page_owner_entity();
+$group = $vars['entity'];
if ($group->photos_enable == "no") {
return true;
diff --git a/views/default/photos/tagging/tag.php b/views/default/photos/tagging/tag.php
index 6f6af968a..6bdc0db02 100644
--- a/views/default/photos/tagging/tag.php
+++ b/views/default/photos/tagging/tag.php
@@ -29,7 +29,7 @@ if ($vars['tag']->type == 'user') {
}
$delete = '';
-$annotation = get_annotation($vars['tag']->annotation_id);
+$annotation = elgg_get_annotation_from_id($vars['tag']->annotation_id);
if ($annotation->canEdit()) {
$url = elgg_http_add_url_query_elements('action/photos/image/untag', array(
diff --git a/views/default/river/object/image/tag.php b/views/default/river/object/image/tag.php
index a59066c67..7e6f0313d 100644
--- a/views/default/river/object/image/tag.php
+++ b/views/default/river/object/image/tag.php
@@ -11,7 +11,7 @@ if ($annotation) {
return;
}
- $image_title = $image->title;
+ $image_title = $image->getTitle();
}
$tagger_link = "<a href=\"{$tagger->getURL()}\">$tagger->name</a>";