Ignore:
Timestamp:
Jan 19, 2011, 3:51:03 PM (13 years ago)
Author:
plg
Message:

feature 1062 added: ability to delete a single photo from its administration
screen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/picture_modify.php

    r8728 r8764  
    3838
    3939// +-----------------------------------------------------------------------+
     40// |                             delete photo                              |
     41// +-----------------------------------------------------------------------+
     42
     43if (isset($_GET['delete']))
     44{
     45  check_pwg_token();
     46
     47  delete_elements(array($_GET['image_id']), true);
     48
     49  // where to redirect the user now?
     50  //
     51  // 1. if a category is available in the URL, use it
     52  // 2. else use the first reachable linked category
     53  // 3. redirect to gallery root
     54
     55  if (isset($_GET['cat_id']))
     56  {
     57    redirect(
     58      make_index_url(
     59        array(
     60          'category' => get_cat_info($_GET['cat_id'])
     61          )
     62        )
     63      );
     64  }
     65
     66  $query = '
     67SELECT category_id
     68  FROM '.IMAGE_CATEGORY_TABLE.'
     69  WHERE image_id = '.$_GET['image_id'].'
     70;';
     71
     72  $authorizeds = array_diff(
     73    array_from_query($query, 'category_id'),
     74    explode(',', calculate_permissions($user['id'], $user['status']))
     75    );
     76 
     77  foreach ($authorizeds as $category_id)
     78  {
     79    redirect(
     80      make_index_url(
     81        array(
     82          'category' => get_cat_info($category_id)
     83          )
     84        )
     85      );
     86  }
     87
     88  redirect(make_index_url());
     89}
     90
     91// +-----------------------------------------------------------------------+
    4092// |                          synchronize metadata                         |
    4193// +-----------------------------------------------------------------------+
     
    210262  );
    211263
     264$admin_url_start = get_root_url().'admin.php?page=picture_modify';
     265$admin_url_start.= '&image_id='.$_GET['image_id'];
     266$admin_url_start.= isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '';
     267
    212268$template->assign(
    213269  array(
    214270    'tags' => $tags,
    215     'U_SYNC' =>
    216         get_root_url().'admin.php?page=picture_modify'.
    217         '&image_id='.$_GET['image_id'].
    218         (isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '').
    219         '&sync_metadata=1',
     271    'U_SYNC' => $admin_url_start.'&sync_metadata=1',
     272    'U_DELETE' => $admin_url_start.'&delete=1&pwg_token='.get_pwg_token(),
    220273
    221274    'PATH'=>$row['path'],
Note: See TracChangeset for help on using the changeset viewer.