Index: branches/wmf/1.17wmf1/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -121,6 +121,9 @@ |
122 | 122 | |
123 | 123 | $wgSpecialPages['BannerAllocation'] = 'SpecialBannerAllocation'; |
124 | 124 | $wgAutoloadClasses['SpecialBannerAllocation'] = $specialDir . 'SpecialBannerAllocation.php'; |
| 125 | + |
| 126 | + $wgSpecialPages['CentralNoticeLogs'] = 'SpecialCentralNoticeLogs'; |
| 127 | + $wgAutoloadClasses['SpecialCentralNoticeLogs'] = $specialDir . 'SpecialCentralNoticeLogs.php'; |
125 | 128 | } |
126 | 129 | } |
127 | 130 | |
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/CentralNotice.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
128 | 131 | Merged /trunk/extensions/CentralNotice/CentralNotice.php:r91146 |
Index: branches/wmf/1.17wmf1/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -179,7 +179,8 @@ |
180 | 180 | $pages = array( |
181 | 181 | 'CentralNotice' => wfMsg( 'centralnotice-notices' ), |
182 | 182 | 'NoticeTemplate' => wfMsg ( 'centralnotice-templates' ), |
183 | | - 'BannerAllocation' => wfMsg ( 'centralnotice-allocation' ) |
| 183 | + 'BannerAllocation' => wfMsg ( 'centralnotice-allocation' ), |
| 184 | + 'CentralNoticeLogs' => wfMsg ( 'centralnotice-logs' ) |
184 | 185 | ); |
185 | 186 | $htmlOut = Xml::openElement( 'ul', array( 'id' => 'preftoc' ) ); |
186 | 187 | foreach ( $pages as $page => $msg ) { |
— | — | @@ -1230,6 +1231,23 @@ |
1231 | 1232 | } |
1232 | 1233 | |
1233 | 1234 | $dbw->commit(); |
| 1235 | + |
| 1236 | + // Log the creation of the campaign |
| 1237 | + $beginSettings = array(); |
| 1238 | + $endSettings = array( |
| 1239 | + 'notlog_end_name' => $noticeName, |
| 1240 | + 'notlog_end_projects' => implode( ", ", $projects ), |
| 1241 | + 'notlog_end_languages' => implode( ", ", $project_languages ), |
| 1242 | + 'notlog_end_countries' => implode( ", ", $geo_countries ), |
| 1243 | + 'notlog_end_start' => $dbw->timestamp( $startTs ), |
| 1244 | + 'notlog_end_end' => $dbw->timestamp( $endTs ), |
| 1245 | + 'notlog_end_enabled' => $enabled, |
| 1246 | + 'notlog_end_preferred' => 0, |
| 1247 | + 'notlog_end_locked' => 0, |
| 1248 | + 'notlog_end_geo' => $geotargeted |
| 1249 | + ); |
| 1250 | + $this->logCampaignChange( 'created', $not_id, $beginSettings, $endSettings ); |
| 1251 | + |
1234 | 1252 | return; |
1235 | 1253 | } |
1236 | 1254 | } |
— | — | @@ -1256,6 +1274,10 @@ |
1257 | 1275 | $res = $dbw->delete( 'cn_notices', array ( 'not_name' => $noticeName ) ); |
1258 | 1276 | $res = $dbw->delete( 'cn_notice_languages', array ( 'nl_notice_id' => $noticeId ) ); |
1259 | 1277 | $dbw->commit(); |
| 1278 | + |
| 1279 | + // Log the removal of the campaign |
| 1280 | + $this->logCampaignChange( 'removed', $noticeId ); |
| 1281 | + |
1260 | 1282 | return; |
1261 | 1283 | } |
1262 | 1284 | } |
— | — | @@ -1775,6 +1797,36 @@ |
1776 | 1798 | } |
1777 | 1799 | return $htmlOut; |
1778 | 1800 | } |
| 1801 | + |
| 1802 | + /** |
| 1803 | + * Log any changes related to a campaign |
| 1804 | + * @param $action string: 'created', 'modified', or 'removed' |
| 1805 | + * @param $campaign integer: id of campaign |
| 1806 | + * @param $beginSettings array of campaign settings before changes (optional) |
| 1807 | + * @param $endSettings array of campaign settings after changes (optional) |
| 1808 | + * @param $beginAssignments array of banner assignments before changes (optional) |
| 1809 | + * @param $endAssignments array of banner assignments after changes (optional) |
| 1810 | + */ |
| 1811 | + function logCampaignChange( $action, $campaign, $beginSettings = array(), |
| 1812 | + $endSettings = array(), $beginAssignments = array(), $endAssignments = array() ) |
| 1813 | + { |
| 1814 | + global $wgUser; |
| 1815 | + |
| 1816 | + $dbw = wfGetDB( DB_MASTER ); |
| 1817 | + |
| 1818 | + $log = array( |
| 1819 | + 'notlog_timestamp' => $dbw->timestamp(), |
| 1820 | + 'notlog_user_id' => $wgUser->getId(), |
| 1821 | + 'notlog_action' => $action, |
| 1822 | + 'notlog_not_id' => $campaign |
| 1823 | + ); |
| 1824 | + |
| 1825 | + $log = array_merge($log, $beginSettings, $endSettings); |
| 1826 | + |
| 1827 | + $res = $dbw->insert( 'cn_notice_log', $log ); |
| 1828 | + $log_id = $dbw->insertId(); |
| 1829 | + return $log_id; |
| 1830 | + } |
1779 | 1831 | } |
1780 | 1832 | |
1781 | 1833 | class CentralNoticePager extends TemplatePager { |
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice/CentralNotice.sql |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1782 | 1834 | Merged /trunk/extensions/CentralNotice/CentralNotice.sql:r91146 |
Property changes on: branches/wmf/1.17wmf1/extensions/CentralNotice |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1783 | 1835 | Merged /trunk/extensions/CentralNotice:r91146 |