Changeset 1892


Ignore:
Timestamp:
Mar 11, 2007, 4:53:25 PM (17 years ago)
Author:
plg
Message:

New: history search can be filtered on image id and filename.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r1891 r1892  
    7272// +-----------------------------------------------------------------------+
    7373
    74 $errors = array();
     74$page['errors'] = array();
    7575$search = array();
    7676
     
    101101
    102102  $search['fields']['user'] = $_POST['user'];
     103
     104  if (!empty($_POST['image_id']))
     105  {
     106    $search['fields']['image_id'] = intval($_POST['image_id']);
     107  }
     108 
     109  if (!empty($_POST['filename']))
     110  {
     111    $search['fields']['filename'] = str_replace(
     112      '*',
     113      '%',
     114      mysql_escape_string($_POST['filename'])
     115      );
     116  }
     117
     118  // TODO manage inconsistency of having $_POST['image_id'] and
     119  // $_POST['filename'] simultaneously
    103120 
    104121  // echo '<pre>'; print_r($search); echo '</pre>';
     
    124141  else
    125142  {
    126     array_push($errors, $lang['search_one_clause_at_least']);
     143    array_push($page['errors'], $lang['search_one_clause_at_least']);
    127144  }
    128145}
     
    196213  }
    197214
     215 
     216  if (isset($page['search']['fields']['filename']))
     217  {
     218    $query = '
     219SELECT
     220    id
     221  FROM '.IMAGES_TABLE.'
     222  WHERE file LIKE \''.$page['search']['fields']['filename'].'\'
     223;';
     224    $page['search']['image_ids'] = array_from_query($query, 'id');
     225  }
     226 
    198227  // echo '<pre>'; print_r($page['search']); echo '</pre>';
    199228 
     
    252281      'user_id = '.$page['search']['fields']['user']
    253282      );
     283  }
     284
     285  if (isset($page['search']['fields']['image_id']))
     286  {
     287    array_push(
     288      $clauses,
     289      'image_id = '.$page['search']['fields']['image_id']
     290      );
     291  }
     292 
     293  if (isset($page['search']['fields']['filename']))
     294  {
     295    if (count($page['search']['image_ids']) == 0)
     296    {
     297      // a clause that is always false
     298      array_push($clauses, '1 = 2 ');
     299    }
     300    else
     301    {
     302      array_push(
     303        $clauses,
     304        'image_id IN ('.implode(', ', $page['search']['image_ids']).')'
     305        );
     306    }
    254307  }
    255308 
     
    512565}
    513566
    514 // $groups_string = preg_replace(
    515 //     '/(\d+)/e',
    516 //     "\$groups['$1']",
    517 //     implode(
    518 //       ', ',
    519 //       $local_user['groups']
    520 //       )
    521 //     );
    522 
    523567// +-----------------------------------------------------------------------+
    524568// |                            navigation bar                             |
     
    578622    $form['user'] = null;
    579623  }
     624
     625  $form['image_id'] = @$page['search']['fields']['image_id'];
     626  $form['filename'] = @$page['search']['fields']['filename'];
    580627}
    581628else
     
    600647    'START_YEAR' => @$form['start_year'],
    601648    'END_YEAR'   => @$form['end_year'],
     649    'IMAGE_ID' => @$form['image_id'],
     650    'FILENAME' => @$form['filename'],
    602651    )
    603652  );
  • trunk/template/yoga/admin/history.tpl

    r1890 r1892  
    7373  </label>
    7474
     75  <label>
     76    {lang:Image id}
     77    <input name="image_id" value="{IMAGE_ID}" type="text" size="5">
     78  </label>
     79
     80  <label>
     81    {lang:File name}
     82    <input name="filename" value="{FILENAME}" type="text">
     83  </label>
     84
    7585  <input class="submit" type="submit" name="submit" value="{lang:submit}" />
    7686</fieldset>
Note: See TracChangeset for help on using the changeset viewer.