diff options
-rw-r--r-- | actions/photos/album/set_cover.php | 23 | ||||
-rw-r--r-- | languages/en.php | 4 | ||||
-rw-r--r-- | start.php | 32 |
3 files changed, 57 insertions, 2 deletions
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/languages/en.php b/languages/en.php index efae155b3..0d6ea2db8 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", @@ -252,6 +253,7 @@ 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:upgrade:success' => 'Upgrade of Tidypics a success', @@ -277,6 +279,8 @@ The photo can be viewed here: %s", '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', 'tidypics:upgrade:failed' => "The upgrade of Tidypics failed", ); @@ -88,17 +88,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 +297,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'])); |