includes/log.php
changeset 905 1e40b33f2e3e
parent 901 99ea0b0ac4be
child 909 94c1ff984286
equal deleted inserted replaced
904:10076b28194b 905:1e40b33f2e3e
    48   {
    48   {
    49     switch ( $criterion )
    49     switch ( $criterion )
    50     {
    50     {
    51       case 'user':
    51       case 'user':
    52       case 'page':
    52       case 'page':
       
    53       case 'action':
    53         $this->criteria[] = array($criterion, $value);
    54         $this->criteria[] = array($criterion, $value);
    54         break;
    55         break;
    55       case 'within':
    56       case 'within':
    56         if ( is_int($value) )
    57         if ( is_int($value) )
    57         {
    58         {
   100     global $db, $session, $paths, $template, $plugins; // Common objects
   101     global $db, $session, $paths, $template, $plugins; // Common objects
   101     
   102     
   102     $where_extra = '';
   103     $where_extra = '';
   103     $where_bits = array(
   104     $where_bits = array(
   104         'user' => array(),
   105         'user' => array(),
   105         'page' => array()
   106         'page' => array(),
       
   107         'action' => array()
   106       );
   108       );
   107     foreach ( $this->criteria as $criterion )
   109     foreach ( $this->criteria as $criterion )
   108     {
   110     {
   109       list($type, $value) = $criterion;
   111       list($type, $value) = $criterion;
   110       switch($type)
   112       switch($type)
   111       {
   113       {
   112         case 'user':
   114         case 'user':
   113           $where_bits['user'][] = "author = '" . $db->escape($value) . "'";
   115           $where_bits['user'][] = "author = '" . $db->escape($value) . "'";
       
   116           break;
       
   117         case 'action':
       
   118           $where_bits['action'][] = "action = '" . $db->escape($value) . "'";
   114           break;
   119           break;
   115         case 'page':
   120         case 'page':
   116           list($page_id, $namespace) = RenderMan::strToPageId($value);
   121           list($page_id, $namespace) = RenderMan::strToPageId($value);
   117           $where_bits['page'][] = "page_id = '" . $db->escape($page_id) . "' AND namespace = '" . $db->escape($namespace) . "'";
   122           $where_bits['page'][] = "page_id = '" . $db->escape($page_id) . "' AND namespace = '" . $db->escape($namespace) . "'";
   118           break;
   123           break;
   127       $where_extra .= "\n    AND ( " . implode(" OR ", $where_bits['user']) . " )";
   132       $where_extra .= "\n    AND ( " . implode(" OR ", $where_bits['user']) . " )";
   128     }
   133     }
   129     if ( !empty($where_bits['page']) )
   134     if ( !empty($where_bits['page']) )
   130     {
   135     {
   131       $where_extra .= "\n    AND ( (" . implode(") OR (", $where_bits['page']) . ") )";
   136       $where_extra .= "\n    AND ( (" . implode(") OR (", $where_bits['page']) . ") )";
       
   137     }
       
   138     if ( !empty($where_bits['action']) )
       
   139     {
       
   140       $where_extra .= "\n    AND ( (" . implode(") OR (", $where_bits['action']) . ") )";
   132     }
   141     }
   133     $limit = ( $page_size > 0 ) ? "\n  LIMIT $offset, $page_size" : '';
   142     $limit = ( $page_size > 0 ) ? "\n  LIMIT $offset, $page_size" : '';
   134     $columns = ( $just_page_count ) ? 'COUNT(*)' : 'log_id, action, page_id, namespace, CHAR_LENGTH(page_text) AS revision_size, author, time_id, edit_summary, minor_edit';
   143     $columns = ( $just_page_count ) ? 'COUNT(*)' : 'log_id, action, page_id, namespace, CHAR_LENGTH(page_text) AS revision_size, author, time_id, edit_summary, minor_edit';
   135     $sql = 'SELECT ' . $columns . ' FROM ' . table_prefix . "logs\n"
   144     $sql = 'SELECT ' . $columns . ' FROM ' . table_prefix . "logs\n"
   136          . "  WHERE log_type = 'page' AND is_draft != 1$where_extra\n"
   145          . "  WHERE log_type = 'page' AND is_draft != 1$where_extra\n"
   310         $size_change = "+$size_change";
   319         $size_change = "+$size_change";
   311       
   320       
   312       $html .= "<span style=\"$css\">({$size_change})</span>";
   321       $html .= "<span style=\"$css\">({$size_change})</span>";
   313       $html .= ' . . ';
   322       $html .= ' . . ';
   314     }
   323     }
   315     else
       
   316     {
       
   317       $html .= " FIXME {$row['action']} . . ";
       
   318     }
       
   319     
   324     
   320     // link to userpage
   325     // link to userpage
   321     $cls = ( isPage($paths->nslist['User'] . $row['author']) ) ? '' : ' class="wikilink-nonexistent"';
   326     $cls = ( isPage($paths->nslist['User'] . $row['author']) ) ? '' : ' class="wikilink-nonexistent"';
   322     $rank_info = $session->get_user_rank($row['author']);
   327     $rank_info = $session->get_user_rank($row['author']);
   323     $html .= '<a style="' . $rank_info['rank_style'] . '" href="' . makeUrlNS('User', sanitize_page_id($row['author']), false, true) . '"' . $cls . '>' . htmlspecialchars($row['author']) . '</a> ';
   328     $html .= '<a style="' . $rank_info['rank_style'] . '" href="' . makeUrlNS('User', sanitize_page_id($row['author']), false, true) . '"' . $cls . '>' . htmlspecialchars($row['author']) . '</a> ';
   329     $html .= $lang->get('pagetools_rc_btn_usertalk');
   334     $html .= $lang->get('pagetools_rc_btn_usertalk');
   330     $html .= '</a>';
   335     $html .= '</a>';
   331     $html .= ') . . ';
   336     $html .= ') . . ';
   332     
   337     
   333     // Edit summary
   338     // Edit summary
   334     $html .= '<i>(';
   339     
   335     if ( empty($row['edit_summary']) )
   340     if ( $row['action'] == 'edit' )
   336     {
   341     {
   337       $html .= '<span style="color: #808080;">' . $lang->get('history_summary_none_given') . '</span>';
   342       $html .= '<i>(';
       
   343       if ( empty($row['edit_summary']) )
       
   344       {
       
   345         $html .= '<span style="color: #808080;">' . $lang->get('history_summary_none_given') . '</span>';
       
   346       }
       
   347       else
       
   348       {
       
   349         $html .= RenderMan::parse_internal_links(htmlspecialchars($row['edit_summary']));
       
   350       }
       
   351       $html .= ')</i>';
   338     }
   352     }
   339     else
   353     else
   340     {
   354     {
   341       $html .= RenderMan::parse_internal_links(htmlspecialchars($row['edit_summary']));
   355       switch($row['action'])
   342     }
   356       {
   343     $html .= ')</i>';
   357         default:
       
   358           $html .= $row['action'];
       
   359           break;
       
   360         case 'rename':
       
   361           $html .= $lang->get('log_action_rename', array('old_name' => htmlspecialchars($row['edit_summary'])));
       
   362           break;
       
   363         case 'create':
       
   364           $html .= $lang->get('log_action_create');
       
   365           break;
       
   366         case 'prot':
       
   367         case 'unprot':
       
   368         case 'semiprot':
       
   369         case 'delete':
       
   370           $stringmap = array(
       
   371             'prot' => 'log_action_protect_full',
       
   372             'unprot' => 'log_action_protect_none',
       
   373             'semiprot' => 'log_action_protect_semi',
       
   374             'delete' => 'log_action_delete'
       
   375           );
       
   376         $reason = ( !empty($row['edit_summary']) ) ? htmlspecialchars($row['edit_summary']) : '<span style="color: #808080;">' . $lang->get('log_msg_no_reason_provided') . '</span>';
       
   377         
       
   378         $html .= $lang->get($stringmap[$row['action']], array('reason' => $reason));
       
   379       }
       
   380     }
   344     
   381     
   345     return $html;
   382     return $html;
   346   }
   383   }
   347   
   384   
   348   /**
   385   /**