]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixed invalid SQL caused by sorting an empty album.
authorBrett Profitt <brett.profitt@gmail.com>
Fri, 8 Jun 2012 22:23:47 +0000 (15:23 -0700)
committerBrett Profitt <brett.profitt@gmail.com>
Fri, 8 Jun 2012 22:23:47 +0000 (15:23 -0700)
Also hiding slideshow and sort links for albums with no images.

actions/photos/album/sort.php
classes/TidypicsAlbum.php
languages/en.php
pages/photos/album/sort.php
start.php
views/default/photos/group_module.php

index 453f51ac5b111e50cb5658b80208d1d90b2db9b0..fd62a7ba79a27bcdbca0689974447d0454a8e164 100644 (file)
@@ -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->getTitle())));
 forward($album->getURL());
\ No newline at end of file
index 1fd98c76b6bf54276aa5e6fa4436459d4241a24a..57bdcf70762bf2fb04d942aa07ab522ceec0c246 100644 (file)
@@ -207,7 +207,7 @@ class TidypicsAlbum extends ElggObject {
                $list = unserialize($listString);
 
                // if empty don't need to check the permissions.
-               if (!$list) {
+               if (!$list || $list[0] == '') {
                        return array();
                }
 
@@ -231,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;
        }
 
        /**
index 0f7aa8d6911535e7a2dd02767b28f9f618837db1..624b5234c69d9ab0551905e44f9a16fca9a80b31 100644 (file)
@@ -172,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',
@@ -256,6 +257,7 @@ The photo can be viewed here: %s",
                        '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
index 8b6d1bfc773f786e23c5e667d6a085f498305c9a..005205dd502a2f30e97ede8a50377a45e208052c 100644 (file)
@@ -33,8 +33,18 @@ if (elgg_instanceof($owner, 'group')) {
 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,
index c56382655d97de75ca4a13ad817d543fc139692a..13a9e2d85ca1fef14b0ecfa6e5971a682a13fce4 100644 (file)
--- a/start.php
+++ b/start.php
@@ -347,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'})";
index aa0e7b3fff78f07fce46ee23ec33436d48d39019..de7a451c4594d125cb9f590cfbc1e2254f335789 100644 (file)
@@ -3,7 +3,7 @@
  * Group blog module
  */
 
-$group = elgg_get_page_owner_entity();
+$group = $vars['entity'];
 
 if ($group->photos_enable == "no") {
        return true;