aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/picture_modify.php63
-rw-r--r--admin/themes/default/template/picture_modify.tpl2
-rw-r--r--language/en_UK/admin.lang.php1
-rw-r--r--language/fr_FR/admin.lang.php1
4 files changed, 62 insertions, 5 deletions
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index f2438454f..5c1d1186b 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -37,6 +37,58 @@ check_input_parameter('image_id', $_GET, false, PATTERN_ID);
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
// +-----------------------------------------------------------------------+
+// | delete photo |
+// +-----------------------------------------------------------------------+
+
+if (isset($_GET['delete']))
+{
+ check_pwg_token();
+
+ delete_elements(array($_GET['image_id']), true);
+
+ // where to redirect the user now?
+ //
+ // 1. if a category is available in the URL, use it
+ // 2. else use the first reachable linked category
+ // 3. redirect to gallery root
+
+ if (isset($_GET['cat_id']))
+ {
+ redirect(
+ make_index_url(
+ array(
+ 'category' => get_cat_info($_GET['cat_id'])
+ )
+ )
+ );
+ }
+
+ $query = '
+SELECT category_id
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE image_id = '.$_GET['image_id'].'
+;';
+
+ $authorizeds = array_diff(
+ array_from_query($query, 'category_id'),
+ explode(',', calculate_permissions($user['id'], $user['status']))
+ );
+
+ foreach ($authorizeds as $category_id)
+ {
+ redirect(
+ make_index_url(
+ array(
+ 'category' => get_cat_info($category_id)
+ )
+ )
+ );
+ }
+
+ redirect(make_index_url());
+}
+
+// +-----------------------------------------------------------------------+
// | synchronize metadata |
// +-----------------------------------------------------------------------+
@@ -209,14 +261,15 @@ $template->set_filenames(
)
);
+$admin_url_start = get_root_url().'admin.php?page=picture_modify';
+$admin_url_start.= '&image_id='.$_GET['image_id'];
+$admin_url_start.= isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '';
+
$template->assign(
array(
'tags' => $tags,
- 'U_SYNC' =>
- get_root_url().'admin.php?page=picture_modify'.
- '&image_id='.$_GET['image_id'].
- (isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '').
- '&sync_metadata=1',
+ 'U_SYNC' => $admin_url_start.'&sync_metadata=1',
+ 'U_DELETE' => $admin_url_start.'&delete=1&pwg_token='.get_pwg_token(),
'PATH'=>$row['path'],
diff --git a/admin/themes/default/template/picture_modify.tpl b/admin/themes/default/template/picture_modify.tpl
index d047b3233..5b47a554f 100644
--- a/admin/themes/default/template/picture_modify.tpl
+++ b/admin/themes/default/template/picture_modify.tpl
@@ -32,6 +32,8 @@ pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#da
{/if}
{if !url_is_remote($PATH)}
<li><a href="{$U_SYNC}" title="{'synchronize'|@translate}"><img src="{$themeconf.admin_icon_dir}/sync_metadata.png" class="button" alt="{'synchronize'|@translate}"></a></li>
+
+ <li><a href="{$U_DELETE}" title="{'delete photo'|@translate}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'delete photo'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"></a></li>
{/if}
</ul>
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index b369624bd..67f90f0c7 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -215,6 +215,7 @@ $lang['default values'] = "default values";
$lang['default'] = "default";
$lang['delete album'] = "delete album";
$lang['Delete orphan tags'] = 'Delete orphan tags';
+$lang['delete photo'] = 'delete photo';
$lang['Delete Representant'] = "Delete Representant";
$lang['Delete selected photos'] = "Delete selected photos";
$lang['Delete selected tags'] = "Delete selected tags";
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index c001c21e5..3b00cf504 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -784,4 +784,5 @@ $lang['with no tag'] = 'sans tag';
$lang['Week starts on'] = 'La semaine commence le';
$lang['You have %d orphan tags: %s.'] = 'Vous avez %d tags orphelins: %s.';
$lang['Delete orphan tags'] = 'Supprimer les tags orphelins';
+$lang['delete photo'] = 'supprimer la photo';
?>