(bug 19004) Added support for tags to the API. Patch by Matthew Britton.
[lhc/web/wiklou.git] / includes / api / ApiQueryLogEvents.php
index 04fc366..ca91d92 100644 (file)
@@ -51,6 +51,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->fld_timestamp = in_array('timestamp', $prop);
                $this->fld_comment = in_array('comment', $prop);
                $this->fld_details = in_array('details', $prop);
+               $this->fld_tags = in_array('tags', $prop);
 
                list($tbl_logging, $tbl_page, $tbl_user) = $db->tableNamesN('logging', 'page', 'user');
 
@@ -85,6 +86,16 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->addFieldsIf('log_comment', $this->fld_comment);
                $this->addFieldsIf('log_params', $this->fld_details);
                
+               if($this->fld_tags || !is_null($params['tag'])) {
+                       $this->addTables('tag_summary');
+                       $this->addJoinConds(array('tag_summary' => array('LEFT JOIN', 'log_id=ts_log_id')));
+                       $this->addFields('ts_tags');
+               }
+               
+               if( !is_null($params['tag']) ) {
+                       $this->addWhereFld('ts_tags', $params['tag']);
+               }
+               
                if( !is_null($params['type']) ) {
                        $this->addWhereFld('log_type', $params['type']);
                        $index = 'type_time';
@@ -247,6 +258,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        }
                }
 
+               if ($this->fld_tags && isset($row->ts_tags)) {
+                       $vals['tags'] = $row->ts_tags;
+               }
+               
                return $vals;
        }
 
@@ -265,6 +280,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                        'timestamp',
                                        'comment',
                                        'details',
+                                       'tags'
                                )
                        ),
                        'type' => array (
@@ -285,6 +301,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        ),
                        'user' => null,
                        'title' => null,
+                       'tag' => null,
                        'limit' => array (
                                ApiBase :: PARAM_DFLT => 10,
                                ApiBase :: PARAM_TYPE => 'limit',
@@ -304,6 +321,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        'dir' => 'In which direction to enumerate.',
                        'user' => 'Filter entries to those made by the given user.',
                        'title' => 'Filter entries to those related to a page.',
+                       'tag' => 'Only list entries with this tag',
                        'limit' => 'How many total event entries to return.'
                );
        }