/** * Pull banners from the database */ function getQueryInfo() { $notice = $this->mRequest->getVal('notice'); $noticeId = CentralNotice::getNoticeId($notice); if ($noticeId) { // Return all the banners not already assigned to the current campaign return array('tables' => array('cn_assignments', 'cn_templates'), 'fields' => array('cn_templates.tmp_name', 'cn_templates.tmp_id'), 'conds' => array('cn_assignments.tmp_id IS NULL'), 'join_conds' => array('cn_assignments' => array('LEFT JOIN', "cn_assignments.tmp_id = cn_templates.tmp_id " . "AND cn_assignments.not_id = {$noticeId}"))); } else { // Return all the banners in the database return array('tables' => 'cn_templates', 'fields' => array('tmp_name', 'tmp_id')); } }
function updateWeight($noticeName, $templateId, $weight) { $dbw = wfGetDB(DB_MASTER); $noticeId = CentralNotice::getNoticeId($noticeName); $dbw->update('cn_assignments', array('tmp_weight' => $weight), array('tmp_id' => $templateId, 'not_id' => $noticeId)); }
public function testGetCampaignBanners() { $campaignId = CentralNotice::getNoticeId('PHPUnitTestCampaign'); $this->assertEquals('[{"name":"PHPUnitTestBanner","weight":25,"display_anon":1,"display_account":1,"fundraising":1,"landing_pages":"JA1, JA2","campaign":"PHPUnitTestCampaign"}]', json_encode(CentralNoticeDB::getCampaignBanners($campaignId))); }