From d17352114463c7a17e4326804fd64e194ca89352 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 14 Jul 2005 17:56:30 +0000 Subject: [PATCH] * A new function: editsByNs( $uid ) that uses the SQL from Kate's edit counter --- includes/User.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/includes/User.php b/includes/User.php index 42a6a89970..21d050304e 100644 --- a/includes/User.php +++ b/includes/User.php @@ -242,6 +242,36 @@ class User { ); } + /** + * Count the number of edits of a user by namespace + * + * @param int $uid The user ID to check + * @return array + */ + function editsByNs( $uid ) { + $fname = 'User::editsByNs'; + $nscount = array(); + + $dbr =& wfGetDB( DB_SLAVE ); + $res = $dbr->select( + array( 'user', 'revision', 'page' ), + array( 'page_namespace', 'COUNT(*) as count' ), + array( + 'user_id' => $uid, + 'rev_user' => array( false, 'user_id' ), + 'rev_page' => array( false, 'page_id' ) + ), + $fname, + array( 'GROUP BY' => 'page_namespace' ) + ); + + while( $row = $dbr->fetchObject( $res ) ) { + $nscount[$row->page_namespace] = $row->count; + } + return $nscount; + + } + /** * probably return a random password * @return string probably a random password -- 2.20.1