feature 2309 added: ability to "move photos" into an album from the Batch

Manager, ie "dissociate from all albums" + "associate" in a single action.


git-svn-id: http://piwigo.org/svn/trunk@13064 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall 2012-02-09 10:16:56 +00:00
commit e1b5e45c12
4 changed files with 66 additions and 4 deletions

View file

@ -44,6 +44,7 @@ trigger_action('loc_begin_element_set_global');
check_input_parameter('del_tags', $_POST, true, PATTERN_ID); check_input_parameter('del_tags', $_POST, true, PATTERN_ID);
check_input_parameter('associate', $_POST, false, PATTERN_ID); check_input_parameter('associate', $_POST, false, PATTERN_ID);
check_input_parameter('move', $_POST, false, PATTERN_ID);
check_input_parameter('dissociate', $_POST, false, PATTERN_ID); check_input_parameter('dissociate', $_POST, false, PATTERN_ID);
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
@ -176,6 +177,49 @@ DELETE
} }
} }
if ('move' == $action)
{
// let's first break links with all albums but their "storage album"
$query = '
DELETE '.IMAGE_CATEGORY_TABLE.'.*
FROM '.IMAGE_CATEGORY_TABLE.'
JOIN '.IMAGES_TABLE.' ON image_id=id
WHERE id IN ('.implode(',', $collection).')
AND (storage_category_id IS NULL OR storage_category_id != category_id)
;';
pwg_query($query);
associate_images_to_categories(
$collection,
array($_POST['move'])
);
$_SESSION['page_infos'] = array(
l10n('Information data registered in database')
);
// let's refresh the page because we the current set might be modified
if ('with no album' == $page['prefilter'])
{
redirect($redirect_url);
}
if ('with no virtual album' == $page['prefilter'])
{
$category_info = get_cat_info($_POST['move']);
if (empty($category_info['dir']))
{
redirect($redirect_url);
}
}
if (isset($_SESSION['bulk_manager_filter']['category'])
and $_POST['move'] != $_SESSION['bulk_manager_filter']['category'])
{
redirect($redirect_url);
}
}
if ('dissociate' == $action) if ('dissociate' == $action)
{ {
// physical links must not be broken, so we must first retrieve image_id // physical links must not be broken, so we must first retrieve image_id
@ -203,13 +247,11 @@ DELETE
'; ';
pwg_query($query); pwg_query($query);
update_category($_POST['dissociate']);
$_SESSION['page_infos'] = array( $_SESSION['page_infos'] = array(
l10n('Information data registered in database') l10n('Information data registered in database')
); );
// let's refresh the page because we the current set might be modified // let's refresh the page because the current set might be modified
redirect($redirect_url); redirect($redirect_url);
} }
} }
@ -528,6 +570,7 @@ SELECT id,name,uppercats,global_rank
FROM '.CATEGORIES_TABLE.' FROM '.CATEGORIES_TABLE.'
;'; ;';
display_select_cat_wrapper($query, array(), 'associate_options', true); display_select_cat_wrapper($query, array(), 'associate_options', true);
display_select_cat_wrapper($query, array(), 'move_options', true);
display_select_cat_wrapper($query, array(), 'category_parent_options'); display_select_cat_wrapper($query, array(), 'category_parent_options');
// in the filter box, which category to select by default // in the filter box, which category to select by default

View file

@ -194,6 +194,13 @@ $(document).ready(function() {
$("[id^=action_]").hide(); $("[id^=action_]").hide();
$("#action_"+$(this).attr("value")).show(); $("#action_"+$(this).attr("value")).show();
/* make sure the #albumSelect is on the right select box so that the */
/* "add new album" popup fills the right select box */
if ("associate" == $(this).attr("value") || "move" == $(this).attr("value")) {
jQuery("#albumSelect").removeAttr("id");
jQuery("#action_"+$(this).attr("value")+" select").attr("id", "albumSelect");
}
if ($(this).val() != -1) { if ($(this).val() != -1) {
$("#applyActionBlock").show(); $("#applyActionBlock").show();
} }
@ -612,6 +619,7 @@ jQuery(window).load(function() {
<option value="delete">{'Delete selected photos'|@translate}</option> <option value="delete">{'Delete selected photos'|@translate}</option>
{/if} {/if}
<option value="associate">{'Associate to album'|@translate}</option> <option value="associate">{'Associate to album'|@translate}</option>
<option value="move">{'Move to album'|@translate}</option>
{if !empty($dissociate_options)} {if !empty($dissociate_options)}
<option value="dissociate">{'Dissociate from album'|@translate}</option> <option value="dissociate">{'Dissociate from album'|@translate}</option>
{/if} {/if}
@ -645,12 +653,21 @@ jQuery(window).load(function() {
<!-- associate --> <!-- associate -->
<div id="action_associate" class="bulkAction"> <div id="action_associate" class="bulkAction">
<select id="albumSelect" style="width:400px" name="associate" size="1"> <select style="width:400px" name="associate" size="1">
{html_options options=$associate_options } {html_options options=$associate_options }
</select> </select>
<br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a> <br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
</div> </div>
<!-- move -->
<div id="action_move" class="bulkAction">
<select style="width:400px" name="move" size="1">
{html_options options=$move_options }
</select>
<br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
</div>
<!-- dissociate --> <!-- dissociate -->
<div id="action_dissociate" class="bulkAction"> <div id="action_dissociate" class="bulkAction">
<select style="width:400px" name="dissociate" size="1"> <select style="width:400px" name="dissociate" size="1">

View file

@ -846,4 +846,5 @@ $lang['administrators'] = 'administrators';
$lang['This album contains %d photos, added on %s.'] = 'This album contains %d photos, added on %s.'; $lang['This album contains %d photos, added on %s.'] = 'This album contains %d photos, added on %s.';
$lang['This album contains %d photos, added between %s and %s.'] = 'This album contains %d photos, added between %s and %s.'; $lang['This album contains %d photos, added between %s and %s.'] = 'This album contains %d photos, added between %s and %s.';
$lang['This album contains no photo.'] = 'This album contains no photo.'; $lang['This album contains no photo.'] = 'This album contains no photo.';
$lang['Move to album'] = 'Move to album';
?> ?>

View file

@ -846,4 +846,5 @@ $lang['This album contains %d photos, added on %s.'] = 'Cet album contient %d ph
$lang['This album contains %d photos, added between %s and %s.'] = 'Cet album contient %d photos, ajoutées entre le %s et le %s.'; $lang['This album contains %d photos, added between %s and %s.'] = 'Cet album contient %d photos, ajoutées entre le %s et le %s.';
$lang['This album contains no photo.'] = 'Cet album ne contient pas de photo.'; $lang['This album contains no photo.'] = 'Cet album ne contient pas de photo.';
$lang['%s has been successfully updated.'] = '%s a été mis à jour avec succès.'; $lang['%s has been successfully updated.'] = '%s a été mis à jour avec succès.';
$lang['Move to album'] = 'Déplacer vers l\'album';
?> ?>