Changeset 1890


Ignore:
Timestamp:
Mar 11, 2007, 3:48:17 PM (17 years ago)
Author:
plg
Message:

New: history can be filtered on a user.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r1883 r1890  
    9999
    100100  $search['fields']['types'] = $_POST['types'];
     101
     102  $search['fields']['user'] = $_POST['user'];
    101103 
    102104  // echo '<pre>'; print_r($search); echo '</pre>';
     
    169171
    170172  $page['search'] = unserialize($serialized_rules);
     173
     174  if (isset($_GET['user_id']))
     175  {
     176    if (!is_numeric($_GET['user_id']))
     177    {
     178      die('user_id GET parameter must be an integer value');
     179    }
     180
     181    $page['search']['fields']['user'] = $_GET['user_id'];
     182   
     183    $query ='
     184INSERT INTO '.SEARCH_TABLE.'
     185  (rules)
     186  VALUES
     187  (\''.serialize($page['search']).'\')
     188;';
     189    pwg_query($query);
     190
     191    $search_id = mysql_insert_id();
     192   
     193    redirect(
     194      PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
     195      );
     196  }
    171197
    172198  // echo '<pre>'; print_r($page['search']); echo '</pre>';
     
    218244    }
    219245  }
     246
     247  if (isset($page['search']['fields']['user'])
     248      and $page['search']['fields']['user'] != -1)
     249  {
     250    array_push(
     251      $clauses,
     252      'user_id = '.$page['search']['fields']['user']
     253      );
     254  }
    220255 
    221256  $clauses = prepend_append_array_items($clauses, '(', ')');
     
    378413      continue;
    379414    }
     415
     416    $user_string = '';
     417    if (isset($username_of[$line['user_id']]))
     418    {
     419      $user_string.= $username_of[$line['user_id']];
     420    }
     421    else
     422    {
     423      $user_string.= $line['user_id'];
     424    }
     425    $user_string.= '&nbsp;<a href="';
     426    $user_string.= PHPWG_ROOT_PATH.'admin.php?page=history';
     427    $user_string.= '&amp;search_id='.$page['search_id'];
     428    $user_string.= '&amp;user_id='.$line['user_id'];
     429    $user_string.= '">+</a>';
    380430   
    381431    $template->assign_block_vars(
     
    384434        'DATE'      => $line['date'],
    385435        'TIME'      => $line['time'],
    386         'USER'      => isset($username_of[$line['user_id']])
    387           ? $username_of[$line['user_id']]
    388           : $line['user_id']
    389         ,
     436        'USER'      => $user_string,
    390437        'IP'        => $line['IP'],
    391438        'IMAGE'     => isset($line['image_id'])
     
    480527
    481528  $form['types'] = $page['search']['fields']['types'];
     529
     530  if (isset($page['search']['fields']['user']))
     531  {
     532    $form['user'] = $page['search']['fields']['user'];
     533  }
     534  else
     535  {
     536    $form['user'] = null;
     537  }
    482538}
    483539else
     
    523579    );
    524580}
     581
     582$template->assign_block_vars(
     583  'user_option',
     584  array(
     585    'VALUE'=> -1,
     586    'CONTENT' => '------------',
     587    'SELECTED' => ''
     588    )
     589  );
     590
     591$query = '
     592SELECT
     593    '.$conf['user_fields']['id'].' AS id,
     594    '.$conf['user_fields']['username'].' AS username
     595  FROM '.USERS_TABLE.'
     596  ORDER BY username ASC
     597;';
     598$result = pwg_query($query);
     599
     600while ($row = mysql_fetch_array($result))
     601{
     602  $selected = '';
     603
     604  if ($row['id'] == $form['user'])
     605  {
     606    $selected = 'selected="selected"';
     607  }
     608 
     609  $template->assign_block_vars(
     610    'user_option',
     611    array(
     612      'VALUE' => $row['id'],
     613      'CONTENT' => $row['username'],
     614      'SELECTED' => $selected,
     615      )
     616    );
     617}
    525618 
    526619// +-----------------------------------------------------------------------+
  • trunk/template/yoga/admin/history.tpl

    r1883 r1890  
    6262  </label>
    6363
     64  <label>
     65    {lang:User}
     66    <select name="user">
     67      <!-- BEGIN user_option -->
     68      <option value="{user_option.VALUE}" {user_option.SELECTED}>
     69        {user_option.CONTENT}
     70      </option>
     71      <!-- END user_option -->
     72    </select>
     73  </label>
     74
    6475  <input class="submit" type="submit" name="submit" value="{lang:submit}" />
    6576</fieldset>
Note: See TracChangeset for help on using the changeset viewer.