Changeset 8422 for trunk/admin


Ignore:
Timestamp:
Jan 1, 2011, 3:35:52 PM (14 years ago)
Author:
plg
Message:

feature 2092 added: Batch Manager can filter all photos with no tag

feature 1866 added: Batch Manager can synchronize metadata

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r8419 r8422  
    193193  }
    194194
     195  if ('with no tag' == $_SESSION['bulk_manager_filter']['prefilter'])
     196  {
     197    $query = '
     198SELECT
     199    id
     200  FROM '.IMAGES_TABLE.'
     201    LEFT JOIN '.IMAGE_TAG_TABLE.' ON id = image_id
     202  WHERE tag_id is null
     203;';
     204    array_push(
     205      $filter_sets,
     206      array_from_query($query, 'id')
     207      );
     208  }
     209
     210
    195211  if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
    196212  {
  • trunk/admin/batch_manager_global.php

    r8417 r8422  
    6565// +-----------------------------------------------------------------------+
    6666
     67// $page['prefilter'] is a shortcut to test if the current filter contains a
     68// given prefilter. The idea is to make conditions simpler to write in the
     69// code.
     70$page['prefilter'] = 'none';
     71if (isset($_SESSION['bulk_manager_filter']['prefilter']))
     72{
     73  $page['prefilter'] = $_SESSION['bulk_manager_filter']['prefilter'];
     74}
     75
     76// $page['category'] is a shortcut to test if the current filter contains a
     77// given category. The idea is the same as for prefilter
     78$page['category'] = -1;
     79if (isset($_SESSION['bulk_manager_filter']['category']))
     80{
     81  $page['category'] = $_SESSION['bulk_manager_filter']['category'];
     82}
     83
     84$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
     85
    6786if (isset($_POST['submit']))
    6887{
     
    86105    pwg_query($query);
    87106
     107    if ('caddie' == $page['prefilter'])
     108    {
     109      redirect($redirect_url);
     110    }
     111   
    88112    // if we are here in the code, it means that the user is currently
    89113    // displaying the caddie content, so we have to remove the current
     
    96120    $tag_ids = get_fckb_tag_ids($_POST['add_tags']);
    97121    add_tags($tag_ids, $collection);
     122
     123    if ('with no tag' == $page['prefilter'])
     124    {
     125      redirect(get_root_url().'admin.php?page='.$_GET['page']);
     126    }
    98127  }
    99128
     
    126155   
    127156    // let's refresh the page because we the current set might be modified
    128     $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
    129     redirect($redirect_url);
     157    if ('with no album' == $page['prefilter'])
     158    {
     159      redirect($redirect_url);
     160    }
     161
     162    if ('with no virtual album' == $page['prefilter'])
     163    {
     164      $category_info = get_cat_info($_POST['associate']);
     165      if (empty($category_info['dir']))
     166      {
     167        redirect($redirect_url);
     168      }
     169    }
    130170  }
    131171
     
    164204     
    165205      // let's refresh the page because we the current set might be modified
    166       $redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
    167206      redirect($redirect_url);
    168207    }
     
    262301      $datas
    263302      );
     303
     304    if (isset($_SESSION['bulk_manager_filter']['level']))
     305    {
     306      if ($_POST['level'] < $_SESSION['bulk_manager_filter']['level'])
     307      {
     308        redirect($redirect_url);
     309      }
     310    }
    264311  }
    265312 
     
    301348      array_push($page['errors'], l10n('You need to confirm deletion'));
    302349    }
     350  }
     351
     352  // synchronize metadata
     353  if ('metadata' == $action)
     354  {
     355    $query = '
     356SELECT id, path
     357  FROM '.IMAGES_TABLE.'
     358  WHERE id IN ('.implode(',', $collection).')
     359;';
     360    $id_to_path = array();
     361    $result = pwg_query($query);
     362    while ($row = pwg_db_fetch_assoc($result))
     363    {
     364      $id_to_path[$row['id']] = $row['path'];
     365    }
     366   
     367    update_metadata($id_to_path);
     368
     369    array_push(
     370      $page['infos'],
     371      l10n('Metadata synchronized from file')
     372      );
    303373  }
    304374}
     
    478548  );
    479549
     550// metadata
     551include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
     552$site_reader = new LocalSiteReader('./');
     553$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
     554
     555$template->assign(
     556    array(
     557      'used_metadata' => $used_metadata,
     558    )
     559  );
     560
    480561// +-----------------------------------------------------------------------+
    481562// |                        global mode thumbnails                         |
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r8419 r8422  
    349349          <option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>{'with no virtual album'|@translate}</option>
    350350{/if}
     351          <option value="with no tag" {if $filter.prefilter eq 'with no tag'}selected="selected"{/if}>{'with no tag'|@translate}</option>
    351352          <option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>{'duplicates'|@translate}</option>
    352 <!--          <option value="with no tag">with no tag</option> -->
    353353        </select>
    354354      </li>
     
    485485      <option value="date_creation">{'Set creation date'|@translate}</option>
    486486      <option value="level">{'Who can see these photos?'|@translate}</option>
     487      <option value="metadata">{'synchronize metadata'|@translate}</option>
    487488  {if ($IN_CADDIE)}
    488489      <option value="remove_from_caddie">{'Remove from caddie'|@translate}</option>
     
    567568    </div>
    568569
     570    <!-- metadata -->
     571    <div id="action_metadata" class="bulkAction">
     572    </div>
     573
    569574    <p id="applyActionBlock" style="display:none" class="actionButtons">
    570575      <input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name="submit"> <span id="applyOnDetails"></span></p>
Note: See TracChangeset for help on using the changeset viewer.