Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -1160,7 +1160,6 @@ |
1161 | 1161 | // Log the creation of the campaign |
1162 | 1162 | $beginSettings = array(); |
1163 | 1163 | $endSettings = array( |
1164 | | - 'name' => $noticeName, |
1165 | 1164 | 'projects' => implode( ", ", $projects ), |
1166 | 1165 | 'languages' => implode( ", ", $project_languages ), |
1167 | 1166 | 'countries' => implode( ", ", $geo_countries ), |
— | — | @@ -1192,17 +1191,19 @@ |
1193 | 1192 | $this->showError( 'centralnotice-notice-is-locked' ); |
1194 | 1193 | return; |
1195 | 1194 | } else { |
| 1195 | + // Log the removal of the campaign |
| 1196 | + $noticeId = $this->getNoticeId( $noticeName ); |
| 1197 | + $this->logCampaignChange( 'removed', $noticeId ); |
| 1198 | + |
1196 | 1199 | $dbw = wfGetDB( DB_MASTER ); |
1197 | 1200 | $dbw->begin(); |
1198 | | - $noticeId = htmlspecialchars( $this->getNoticeId( $noticeName ) ); |
1199 | 1201 | $res = $dbw->delete( 'cn_assignments', array ( 'not_id' => $noticeId ) ); |
1200 | 1202 | $res = $dbw->delete( 'cn_notices', array ( 'not_name' => $noticeName ) ); |
1201 | 1203 | $res = $dbw->delete( 'cn_notice_languages', array ( 'nl_notice_id' => $noticeId ) ); |
| 1204 | + $res = $dbw->delete( 'cn_notice_projects', array ( 'np_notice_id' => $noticeId ) ); |
| 1205 | + $res = $dbw->delete( 'cn_notice_countries', array ( 'nc_notice_id' => $noticeId ) ); |
1202 | 1206 | $dbw->commit(); |
1203 | 1207 | |
1204 | | - // Log the removal of the campaign |
1205 | | - $this->logCampaignChange( 'removed', $noticeId ); |
1206 | | - |
1207 | 1208 | return; |
1208 | 1209 | } |
1209 | 1210 | } |
— | — | @@ -1678,13 +1679,13 @@ |
1679 | 1680 | /** |
1680 | 1681 | * Log any changes related to a campaign |
1681 | 1682 | * @param $action string: 'created', 'modified', or 'removed' |
1682 | | - * @param $campaign integer: id of campaign |
| 1683 | + * @param $campaignId integer: ID of campaign |
1683 | 1684 | * @param $beginSettings array of campaign settings before changes (optional) |
1684 | 1685 | * @param $endSettings array of campaign settings after changes (optional) |
1685 | 1686 | * @param $beginAssignments array of banner assignments before changes (optional) |
1686 | 1687 | * @param $endAssignments array of banner assignments after changes (optional) |
1687 | 1688 | */ |
1688 | | - function logCampaignChange( $action, $campaign, $beginSettings = array(), |
| 1689 | + function logCampaignChange( $action, $campaignId, $beginSettings = array(), |
1689 | 1690 | $endSettings = array(), $beginAssignments = array(), $endAssignments = array() ) |
1690 | 1691 | { |
1691 | 1692 | global $wgUser; |
— | — | @@ -1695,7 +1696,8 @@ |
1696 | 1697 | 'notlog_timestamp' => $dbw->timestamp(), |
1697 | 1698 | 'notlog_user_id' => $wgUser->getId(), |
1698 | 1699 | 'notlog_action' => $action, |
1699 | | - 'notlog_not_id' => $campaign |
| 1700 | + 'notlog_not_id' => $campaignId, |
| 1701 | + 'notlog_not_name' => $this->getNoticeName( $campaignId ) |
1700 | 1702 | ); |
1701 | 1703 | |
1702 | 1704 | foreach ( $beginSettings as $key => $value ) { |
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -68,21 +68,62 @@ |
69 | 69 | * Show a log. |
70 | 70 | */ |
71 | 71 | function showLog( $logType ) { |
72 | | - global $wgOut; |
| 72 | + global $wgOut, $wgLang; |
73 | 73 | |
74 | 74 | $htmlOut = ''; |
75 | 75 | |
76 | 76 | // Begin log fieldset |
77 | 77 | $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) ); |
78 | 78 | |
79 | | - $htmlOut .= Xml::tags( 'p', null, |
80 | | - '<i>Coming soon...</i>' |
81 | | - ); |
| 79 | + $campaignLogs = $this->getCampaignLogs(); |
82 | 80 | |
| 81 | + foreach( $campaignLogs as $campaignLog ) { |
| 82 | + $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-log-entry' ) ); |
| 83 | + |
| 84 | + // Timestamp |
| 85 | + $htmlOut .= Xml::tags( 'span', null, |
| 86 | + $wgLang->date( $campaignLog['timestamp'] ) . ' ' . $wgLang->time( $campaignLog['timestamp'] ) |
| 87 | + ); |
| 88 | + // User |
| 89 | + $cnUser = User::newFromId( $campaignLog['user_id'] ); |
| 90 | + $htmlOut .= Xml::tags( 'span', null, $cnUser->getName() ); |
| 91 | + // Action |
| 92 | + $htmlOut .= Xml::tags( 'span', null, $campaignLog['action'] ); |
| 93 | + // Campaign |
| 94 | + $htmlOut .= Xml::tags( 'span', null, $campaignLog['campaign_name'] ); |
| 95 | + |
| 96 | + $htmlOut .= Xml::closeElement( 'div', array( 'class' => 'cn-log-entry' ) ); |
| 97 | + } |
| 98 | + |
83 | 99 | // End log fieldset |
84 | 100 | $htmlOut .= Xml::closeElement( 'fieldset' ); |
85 | 101 | |
86 | 102 | $wgOut->addHTML( $htmlOut ); |
87 | 103 | } |
| 104 | + |
| 105 | + function getCampaignLogs() { |
| 106 | + global $wgCentralDBname; |
| 107 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
| 108 | + $logs = array(); |
88 | 109 | |
| 110 | + $results = $dbr->select( 'cn_notice_log', array( |
| 111 | + 'notlog_timestamp', |
| 112 | + 'notlog_user_id', |
| 113 | + 'notlog_action', |
| 114 | + 'notlog_not_id', |
| 115 | + 'notlog_not_name', |
| 116 | + ) |
| 117 | + ); |
| 118 | + foreach ( $results as $row ) { |
| 119 | + $logs[] = array( |
| 120 | + 'timestamp' => $row->notlog_timestamp, |
| 121 | + 'user_id' => $row->notlog_user_id, |
| 122 | + 'action' => $row->notlog_action, |
| 123 | + 'campaign_id' => $row->notlog_not_id, |
| 124 | + 'campaign_name' => $row->notlog_not_name, |
| 125 | + ); |
| 126 | + } |
| 127 | + return $logs; |
| 128 | + } |
| 129 | + |
89 | 130 | } |
Index: trunk/extensions/CentralNotice/patches/patch-notice_logs.sql |
— | — | @@ -1,34 +0,0 @@ |
2 | | - |
3 | | -CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_log ( |
4 | | - `notlog_id` int unsigned NOT NULL PRIMARY KEY auto_increment, |
5 | | - `notlog_timestamp` binary(14) NOT NULL, |
6 | | - `notlog_user_id` int unsigned NOT NULL, |
7 | | - `notlog_action` enum('created','modified','removed') NOT NULL DEFAULT 'modified', |
8 | | - `notlog_not_id` int unsigned NOT NULL, |
9 | | - `notlog_begin_name` varchar(255) DEFAULT NULL, |
10 | | - `notlog_end_name` varchar(255) DEFAULT NULL, |
11 | | - `notlog_begin_projects` varchar(255) DEFAULT NULL, |
12 | | - `notlog_end_projects` varchar(255) DEFAULT NULL, |
13 | | - `notlog_begin_languages` text, |
14 | | - `notlog_end_languages` text, |
15 | | - `notlog_begin_countries` text, |
16 | | - `notlog_end_countries` text, |
17 | | - `notlog_begin_start` char(14) DEFAULT NULL, |
18 | | - `notlog_end_start` char(14) DEFAULT NULL, |
19 | | - `notlog_begin_end` char(14) DEFAULT NULL, |
20 | | - `notlog_end_end` char(14) DEFAULT NULL, |
21 | | - `notlog_begin_enabled` tinyint(1) DEFAULT NULL, |
22 | | - `notlog_end_enabled` tinyint(1) DEFAULT NULL, |
23 | | - `notlog_begin_preferred` tinyint(1) DEFAULT NULL, |
24 | | - `notlog_end_preferred` tinyint(1) DEFAULT NULL, |
25 | | - `notlog_begin_locked` tinyint(1) DEFAULT NULL, |
26 | | - `notlog_end_locked` tinyint(1) DEFAULT NULL, |
27 | | - `notlog_begin_geo` tinyint(1) DEFAULT NULL, |
28 | | - `notlog_end_geo` tinyint(1) DEFAULT NULL, |
29 | | - `notlog_begin_banners` text, |
30 | | - `notlog_end_banners` text |
31 | | -) /*$wgDBTableOptions*/; |
32 | | -CREATE INDEX /*i*/notlog_timestamp ON /*_*/cn_notice_log (notlog_timestamp); |
33 | | -CREATE INDEX /*i*/notlog_user_id ON /*_*/cn_notice_log (notlog_user_id, notlog_timestamp); |
34 | | -CREATE INDEX /*i*/notlog_not_id ON /*_*/cn_notice_log (notlog_not_id, notlog_timestamp); |
\ No newline at end of file |
Index: trunk/extensions/CentralNotice/patches/patch-notice_log.sql |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +-- Update to allow for logging of changes to campaign settings. |
| 3 | + |
| 4 | +CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/cn_notice_log ( |
| 5 | + `notlog_id` int unsigned NOT NULL PRIMARY KEY auto_increment, |
| 6 | + `notlog_timestamp` binary(14) NOT NULL, |
| 7 | + `notlog_user_id` int unsigned NOT NULL, |
| 8 | + `notlog_action` enum('created','modified','removed') NOT NULL DEFAULT 'modified', |
| 9 | + `notlog_not_id` int unsigned NOT NULL, |
| 10 | + `notlog_begin_name` varchar(255) DEFAULT NULL, |
| 11 | + `notlog_end_name` varchar(255) DEFAULT NULL, |
| 12 | + `notlog_begin_projects` varchar(255) DEFAULT NULL, |
| 13 | + `notlog_end_projects` varchar(255) DEFAULT NULL, |
| 14 | + `notlog_begin_languages` text, |
| 15 | + `notlog_end_languages` text, |
| 16 | + `notlog_begin_countries` text, |
| 17 | + `notlog_end_countries` text, |
| 18 | + `notlog_begin_start` char(14) DEFAULT NULL, |
| 19 | + `notlog_end_start` char(14) DEFAULT NULL, |
| 20 | + `notlog_begin_end` char(14) DEFAULT NULL, |
| 21 | + `notlog_end_end` char(14) DEFAULT NULL, |
| 22 | + `notlog_begin_enabled` tinyint(1) DEFAULT NULL, |
| 23 | + `notlog_end_enabled` tinyint(1) DEFAULT NULL, |
| 24 | + `notlog_begin_preferred` tinyint(1) DEFAULT NULL, |
| 25 | + `notlog_end_preferred` tinyint(1) DEFAULT NULL, |
| 26 | + `notlog_begin_locked` tinyint(1) DEFAULT NULL, |
| 27 | + `notlog_end_locked` tinyint(1) DEFAULT NULL, |
| 28 | + `notlog_begin_geo` tinyint(1) DEFAULT NULL, |
| 29 | + `notlog_end_geo` tinyint(1) DEFAULT NULL, |
| 30 | + `notlog_begin_banners` text, |
| 31 | + `notlog_end_banners` text |
| 32 | +) /*$wgDBTableOptions*/; |
| 33 | +CREATE INDEX /*i*/notlog_timestamp ON /*_*/cn_notice_log (notlog_timestamp); |
| 34 | +CREATE INDEX /*i*/notlog_user_id ON /*_*/cn_notice_log (notlog_user_id, notlog_timestamp); |
| 35 | +CREATE INDEX /*i*/notlog_not_id ON /*_*/cn_notice_log (notlog_not_id, notlog_timestamp); |
\ No newline at end of file |
Property changes on: trunk/extensions/CentralNotice/patches/patch-notice_log.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -136,7 +136,6 @@ |
137 | 137 | $row = $dbr->selectRow( 'cn_notices', |
138 | 138 | array( |
139 | 139 | 'not_id', |
140 | | - 'not_name', |
141 | 140 | 'not_start', |
142 | 141 | 'not_end', |
143 | 142 | 'not_enabled', |
— | — | @@ -149,7 +148,6 @@ |
150 | 149 | ); |
151 | 150 | if ( $row ) { |
152 | 151 | $campaign = array( |
153 | | - 'name' => $row->not_name, |
154 | 152 | 'start' => $row->not_start, |
155 | 153 | 'end' => $row->not_end, |
156 | 154 | 'enabled' => $row->not_enabled, |