/** * Update a banner */ private function editTemplate($name, $body, $displayAnon, $displayAccount, $fundraising, $autolink, $landingPages) { if ($body == '' || $name == '') { $this->showError('centralnotice-null-string'); return; } $initialBannerSettings = CentralNoticeDB::getBannerSettings($name, true); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('cn_templates', 'tmp_name', array('tmp_name' => $name), __METHOD__); if ($dbr->numRows($res) == 1) { $dbw = wfGetDB(DB_MASTER); $res = $dbw->update('cn_templates', array('tmp_display_anon' => $displayAnon, 'tmp_display_account' => $displayAccount, 'tmp_fundraising' => $fundraising, 'tmp_autolink' => $autolink, 'tmp_landing_pages' => $landingPages), array('tmp_name' => $name)); // Perhaps these should move into the db as blob $article = new Article(Title::newFromText("centralnotice-template-{$name}", NS_MEDIAWIKI)); $article->doEdit($body, '', EDIT_FORCE_BOT); $bannerId = SpecialNoticeTemplate::getTemplateId($name); $finalBannerSettings = CentralNoticeDB::getBannerSettings($name, true); // If there are any difference between the old settings and the new settings, log them. $diffs = array_diff_assoc($initialBannerSettings, $finalBannerSettings); if ($diffs) { $this->logBannerChange('modified', $bannerId, $initialBannerSettings, $finalBannerSettings); } return; } }