Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +-- |
| 3 | +-- Schema for UserDailyContribs |
| 4 | +-- |
| 5 | +-- Used in clicktracking to determine how active the user is |
| 6 | +-- |
| 7 | + |
| 8 | +CREATE TABLE IF NOT EXISTS /*_*/user_daily_contribs ( |
| 9 | + -- user id |
| 10 | + user_id integer NOT NULL default 0, |
| 11 | + |
| 12 | + -- day |
| 13 | + day DATE NOT NULL, |
| 14 | + |
| 15 | + -- contributions on that day by that user |
| 16 | + contribs integer NOT NULL default 0, |
| 17 | + |
| 18 | + -- a unique entry for a given user_id and day |
| 19 | + PRIMARY KEY(user_id, day) |
| 20 | +) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 21 | + native |
Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Usability Initiative User Daily Contribtions (for Click Tracking) extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * This file contains the include file for the User Daily Contributions table in the |
| 10 | + * UsabilityInitiative extension of MediaWiki. |
| 11 | + * |
| 12 | + * Usage: Include the following line in your LocalSettings.php |
| 13 | + * require_once( "$IP/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php" ); |
| 14 | + * |
| 15 | + * @author Nimish Gautam <ngautam@wikimedia.org> |
| 16 | + * @license GPL v2 or later |
| 17 | + * @version 0.1.1 |
| 18 | + */ |
| 19 | + |
| 20 | +/* Configuration */ |
| 21 | + |
| 22 | +// Credits |
| 23 | +$wgExtensionCredits['other'][] = array( |
| 24 | + 'path' => __FILE__, |
| 25 | + 'name' => 'User Daily Contributions', |
| 26 | + 'author' => 'Nimish Gautam', |
| 27 | + 'version' => '0.1.1', |
| 28 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative' |
| 29 | +); |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +// Includes parent extension |
| 34 | +require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative.php" ); |
| 35 | + |
| 36 | +// Adds Autoload Classes |
| 37 | +$dir = dirname( __FILE__ ) . '/'; |
| 38 | +$wgAutoloadClasses['UserDailyContribsHooks'] = $dir . 'UserDailyContribs.hooks.php'; |
| 39 | + |
| 40 | +// Hooked functions |
| 41 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'UserDailyContribsHooks::schema'; |
| 42 | +$wgHooks['ArticleSaveComplete'][] = 'UserDailyContribsHooks::storeNewContrib'; |
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 43 | + native |
Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Hooks for Usability Initiative UserDailyContribs extension |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + */ |
| 10 | + |
| 11 | +class UserDailyContribsHooks { |
| 12 | + |
| 13 | + public static function schema() { |
| 14 | + global $wgExtNewTables; |
| 15 | + |
| 16 | + $wgExtNewTables[] = array( |
| 17 | + 'user_daily_contribs', |
| 18 | + dirname( __FILE__ ) . '/UserDailyContribs.sql' |
| 19 | + ); |
| 20 | + |
| 21 | + return true; |
| 22 | + } |
| 23 | + |
| 24 | + |
| 25 | + /** |
| 26 | + * Stores a new contribution |
| 27 | + * @return true |
| 28 | + */ |
| 29 | + public static function storeNewContrib(){ |
| 30 | + global $wgUser; |
| 31 | + $today = gmdate( 'Ymd', time() ); |
| 32 | + $dbw = wfGetDB( DB_MASTER ); |
| 33 | + /* |
| 34 | + //there seems no way to set contribs to contribs+1 in a reasonably fast manner in this framework |
| 35 | + try{ |
| 36 | + $dbw->insert("user_daily_contribs", array("user_id" => $wgUser->getId(), "day" => $today, "contribs" => 1), __METHOD__); |
| 37 | + } |
| 38 | + catch(Exception $e){ |
| 39 | + $dbw->update( "user_daily_contribs", array( "contribs" => "contribs+1"), array("user_id" => $wgUser->getId(), "day" => $today), __METHOD__); |
| 40 | + } |
| 41 | + */ |
| 42 | + $sql = |
| 43 | + "INSERT INTO user_daily_contribs (user_id,day,contribs) VALUES ({$wgUser->getId()},$today,1) ON DUPLICATE KEY UPDATE contribs=contribs+1;"; |
| 44 | + $dbw->query($sql, __METHOD__); |
| 45 | + return true; |
| 46 | + } |
| 47 | + |
| 48 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 49 | + native |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/UserDailyContribs.sql |
— | — | @@ -1,19 +0,0 @@ |
2 | | - |
3 | | -CREATE TABLE IF NOT EXISTS /*_*/user_daily_contribs ( |
4 | | - -- user id |
5 | | - user_id integer NOT NULL default 0, |
6 | | - |
7 | | - -- day |
8 | | - day DATE NOT NULL, |
9 | | - |
10 | | - -- contributions on that day by that user |
11 | | - contribs integer NOT NULL default 0, |
12 | | - |
13 | | - -- a unique entry for a given user_id and day |
14 | | - PRIMARY KEY(user_id, day) |
15 | | -) /*$wgDBTableOptions*/; |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -23,11 +23,6 @@ |
24 | 24 | ); |
25 | 25 | |
26 | 26 | $wgExtNewTables[] = array( |
27 | | - 'user_daily_contribs', |
28 | | - dirname( __FILE__ ) . '/UserDailyContribs.sql' |
29 | | - ); |
30 | | - |
31 | | - $wgExtNewTables[] = array( |
32 | 27 | 'click_tracking_events', |
33 | 28 | dirname( __FILE__ ) . '/ClickTrackingEvents.sql' |
34 | 29 | ); |
— | — | @@ -112,20 +107,6 @@ |
113 | 108 | return $edits; |
114 | 109 | } |
115 | 110 | |
116 | | - /** |
117 | | - * Stores a new contribution |
118 | | - * @return true |
119 | | - */ |
120 | | - public static function storeNewContrib(){ |
121 | | - global $wgUser; |
122 | | - $today = gmdate( 'Ymd', time() ); |
123 | | - $dbw = wfGetDB( DB_MASTER ); |
124 | | - $sql = |
125 | | - "INSERT INTO user_daily_contribs (user_id,day,contribs) VALUES ({$wgUser->getId()},$today,1) ON DUPLICATE KEY UPDATE contribs=contribs+1;"; |
126 | | - $dbw->query($sql, __METHOD__); |
127 | | - |
128 | | - return true; |
129 | | - } |
130 | 111 | |
131 | 112 | /** |
132 | 113 | * Get event ID from name |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php |
— | — | @@ -53,7 +53,6 @@ |
54 | 54 | |
55 | 55 | // Hooked functions |
56 | 56 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema'; |
57 | | -$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::storeNewContrib'; |
58 | 57 | $wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS'; |
59 | 58 | |
60 | 59 | // Set up the new API module |