aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/element_set_global.php27
-rw-r--r--admin/include/functions.php50
-rw-r--r--admin/themes/default/template/element_set_global.tpl3
3 files changed, 40 insertions, 40 deletions
diff --git a/admin/element_set_global.php b/admin/element_set_global.php
index f2c708022..87efab452 100644
--- a/admin/element_set_global.php
+++ b/admin/element_set_global.php
@@ -77,33 +77,20 @@ if (isset($_POST['delete']))
}
}
- // filter selection on photos that have no storage_category_id (ie that
- // were added via pLoader)
if (count($collection) > 0)
{
- $query = '
-SELECT
- id
- FROM '.IMAGES_TABLE.'
- WHERE id IN ('.implode(',', $collection).')
- AND storage_category_id IS NULL
-;';
- $deletables = array_from_query($query, 'id');
-
- if (count($deletables) > 0)
+ $deleted_count = delete_elements($collection, true);
+ if ($deleted_count > 0)
{
- $physical_deletion = true;
- delete_elements($deletables, $physical_deletion);
-
array_push(
$page['infos'],
sprintf(
l10n_dec(
'%d photo was deleted',
'%d photos were deleted',
- count($deletables)
+ $deleted_count
),
- count($deletables)
+ $deleted_count
)
);
}
@@ -321,9 +308,7 @@ $template->assign('IN_CADDIE', 'caddie' == $_GET['cat'] ? true : false );
// | deletion form |
// +-----------------------------------------------------------------------+
-// we can only remove photos that have no storage_category_id, in other
-// word, it currently (Butterfly) means that the photo was added with
-// pLoader
+// we can only remove photos that are not remote
if (count($page['cat_elements_id']) > 0)
{
$query = '
@@ -331,7 +316,7 @@ SELECT
COUNT(*)
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $page['cat_elements_id']).')
- AND storage_category_id IS NULL
+ AND path NOT LIKE "http%"
;';
list($counter) = pwg_db_fetch_row(pwg_query($query));
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 8b3861253..d169dfb80 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -131,50 +131,67 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
// - all the comments related to elements
// - all the links between categories and elements
// - all the favorites associated to elements
+// @return number of deleted elements
function delete_elements($ids, $physical_deletion=false)
{
if (count($ids) == 0)
{
- return;
+ return 0;
}
trigger_action('begin_delete_elements', $ids);
if ($physical_deletion)
{
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
+ $new_ids=array();
- // we can currently delete physically only photo with no
- // storage_category_id (added via pLoader)
- //
- // we assume that the element is a photo, with no representative
$query = '
SELECT
id,
path,
tn_ext,
- has_high
+ has_high,
+ representative_ext
FROM '.IMAGES_TABLE.'
WHERE id IN ('.implode(',', $ids).')
- AND storage_category_id IS NULL
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
- $file_path = $row['path'];
- $thumbnail_path = get_thumbnail_path($row);
- $high_path = null;
- if (isset($row['has_high']) and get_boolean($row['has_high']))
+ if (url_is_remote($row['path']))
+ continue;
+ $files = array();
+ $files[] = get_element_path($row);
+ if (!empty($row['tn_ext']))
+ $files[] = get_thumbnail_path($row);
+ if (!empty($row['has_high']) and get_boolean($row['has_high']))
+ $files[] = get_high_path($row);
+ if (!empty($row['representative_ext']))
{
- $high_path = get_high_path($row);
+ $pi = pathinfo($row['path']);
+ $file_wo_ext = get_filename_wo_extension($pi['basename']);
+ $files[] = PHPWG_ROOT_PATH.$pi['dirname'].'/pwg_representative/'.$file_wo_ext.'.'.$element_info['representative_ext'];
}
- foreach (array($file_path, $thumbnail_path, $high_path) as $path)
+ $ok = true;
+ foreach ($files as $path)
{
- if (isset($path) and is_file($path) and !unlink($path))
+ if (is_file($path) and !unlink($path))
{
- die('"'.$path.'" cannot be removed');
+ $ok = false;
+ trigger_error('"'.$path.'" cannot be removed', E_USER_WARNING);
+ break;
}
}
+ if ($ok)
+ $new_ids[] += $row['id'];
+ else
+ break;
+ }
+ $ids = $new_ids;
+ if (count($ids)==0)
+ {
+ return 0;
}
}
@@ -249,6 +266,7 @@ SELECT
}
trigger_action('delete_elements', $ids);
+ return count($ids);
}
// The delete_user function delete a user identified by the $user_id
@@ -2004,4 +2022,4 @@ function get_fckb_tag_ids($raw_tags)
return $tag_ids;
}
-?> \ No newline at end of file
+?>
diff --git a/admin/themes/default/template/element_set_global.tpl b/admin/themes/default/template/element_set_global.tpl
index 35e047942..b357cae54 100644
--- a/admin/themes/default/template/element_set_global.tpl
+++ b/admin/themes/default/template/element_set_global.tpl
@@ -85,9 +85,6 @@
{if isset($show_delete_form) }
<fieldset>
<legend>{'Deletions'|@translate}</legend>
-{if $ENABLE_SYNCHRONIZATION}
- <p style="font-style:italic">{'Note: photo deletion does not apply to photos added by synchronization. For photos added by synchronization, remove them from the filesystem and then perform another synchronization.'|@translate}</p>
-{/if}
<p>
{'target'|@translate}
<label><input type="radio" name="target_deletion" value="all"> {'all'|@translate}</label>