diff -r 44302dd20d62 -r 94c1ff984286 plugins/SpecialLog.php --- a/plugins/SpecialLog.php Mon Apr 13 17:28:24 2009 -0400 +++ b/plugins/SpecialLog.php Tue Apr 14 21:02:13 2009 -0400 @@ -39,16 +39,52 @@ global $lang; global $output; + // FIXME: This doesn't currently prohibit viewing of aggregate logs that might include a page for which + // + + // FIXME: This is a real hack. We're trying to get permissions on a random non-existent article, which + // effectively forces calculation to occur based on site-wide permissions. + $pid = ''; + for ( $i = 0; $i < 32; $i++ ) + { + $pid .= chr(mt_rand(32, 126)); + } + $perms = $session->fetch_page_acl($pid, 'Article'); + $perms_changed = false; + require_once(ENANO_ROOT . '/includes/log.php'); $log = new LogDisplay(); $page = 1; $pagesize = 50; + $fmt = 'full'; - if ( $params = explode('/', $paths->getAllParams()) ) + if ( $params = $paths->getAllParams() ) { + if ( $params === 'AddFilter' && !empty($_POST['type']) && !empty($_POST['value']) ) + { + $type = $_POST['type']; + if ( $type == 'within' ) + $value = strval(intval($_POST['value']['within'])) . $_POST['value']['withinunits']; + else + $value = $_POST['value'][$type]; + + $value = str_replace('/', '.2f', sanitize_page_id($value)); + + if ( empty($value) || ( $type == 'within' && intval($value) == 0 ) ) + { + $adderror = $lang->get('log_err_addfilter_field_empty'); + } + + $append = ( !empty($_POST['existing_filters']) ) ? "{$_POST['existing_filters']}/" : ''; + $url = makeUrlNS('Special', "Log/{$append}{$type}={$value}"); + + redirect($url, '', '', 0); + } + $params = explode('/', $params); foreach ( $params as $param ) { - if ( preg_match('/^([a-z]+)=(.+?)$/', $param, $match) ) + $param = str_replace('.2f', '/', dirtify_page_id($param)); + if ( preg_match('/^([a-z!]+)=(.+?)$/', $param, $match) ) { $name =& $match[1]; $value =& $match[2]; @@ -60,27 +96,301 @@ case 'size': $pagesize = intval($value); break; + case 'fmt': + switch($value) + { + case 'barenaked': + case 'ajax': + $fmt = 'naked'; + $output = new Output_Naked(); + break; + } + break; + case 'page': + if ( get_class($perms) == 'sessionManager' ) + { + unset($perms); + list($pid, $ns) = RenderMan::strToPageID($value); + $perms = $session->fetch_page_acl($pid, $ns); + if ( !$perms->get_permissions('history_view') ) + { + die_friendly($lang->get('etc_access_denied_short'), '
' . $lang->get('log_err_access_denied') . '
'); + } + } + // no break here on purpose default: - $log->add_criterion($name, $value); + try + { + $log->add_criterion($name, $value); + } + catch ( Exception $e ) + { + } break; } } } } - + if ( !$perms->get_permissions('history_view') ) + { + die_friendly($lang->get('etc_access_denied_short'), '' . $lang->get('log_err_access_denied') . '
'); + } + $page--; $rowcount = $log->get_row_count(); - $result_url = makeUrlNS('Special', 'Log/' . rtrim(preg_replace('|/?resultpage=(.+?)/?|', '/', $paths->getAllParams()), '/') . '/resultpage=%s', false, true); + $result_url = makeUrlNS('Special', 'Log/' . rtrim(preg_replace('|/?resultpage=([0-9]+)/?|', '/', $paths->getAllParams()), '/') . '/resultpage=%s', false, true); $paginator = generate_paginator($page, ceil($rowcount / $pagesize), $result_url); $dataset = $log->get_data($page * $pagesize, $pagesize); $output->header(); - echo $paginator; - foreach ( $dataset as $row ) + + // breadcrumbs + if ( $fmt != 'naked' ) { - echo LogDisplay::render_row($row) . '