/** * Return the announcment(s) for the given scope. * If no scope is given, the global announcment will * be returned. In any case, a published global announcment * will be stored in the "global" attribute in the bean. * If the published flag is set, the method will return the * content value if published or an empty string if not. * * @param string $scope (e.g. Exhibition, Program, Course, Global) * @param boolean $published Return just the published value? [false] * @param boolean $global Also set and return the published global content? [false] * @return bean The announcment bean for the given scope */ public function getAnnouncement($scope, $published = false, $global = false) { global $logger; $logger->debug(get_class($this) . "::getAnnouncment({$scope})"); $notice = new Announcement(); // get the scoped announcement if ($scope != null) { $section = $this->fetch($scope); $snotice = $section->content; if ($published && !$section->published) { $snotice = ""; } } // get the global announcement if ($global) { $global = $this->fetch('Global'); $gnotice = $global->content; if ($published && !$global->published) { $gnotice = ""; } $notice->setGlobal($gnotice); } $notice->setContent($snotice); $notice->setScope($scope); if ($section != null) { $notice->setPublished($section->getPublished()); $notice->setOid($section->getOid()); } return $notice; }
public function testPut() { $announcement = new Announcement(); $announcement->setId('1'); $announcement->setTitle('Annonce test'); $announcement->setSubtitle('Description modifiée'); $announcement->setContent('Besoin de mécanicien contre cours de cuisine'); $announcement->setPostDate('2012-12-14 18:07:27'); $announcement->setConclued('0'); $announcementMapper = new AnnouncementMapper(); $announcementMapper->setId(1); $announcementMapper->updateAnnouncement($announcement); $this->assertEquals($announcement, $announcementMapper->selectAnnouncement()); }
public function testGetSetContent() { $announcement = new Announcement(); $announcement->setContent('J\'échange une PS3 slim contre une Wii U.'); $this->assertEquals('J\'échange une PS3 slim contre une Wii U.', $announcement->getContent()); }
/** * Gets the list of announcment beans from the request * * @return array of announcment beans */ private function getBeanFromRequest() { $sections = array('Global', 'Exhibition', 'Program', 'Course', 'Venue'); $beans = array(); foreach ($sections as $scope) { $bean = new Announcement(); $pub_key = $scope . "_published"; $oid_key = $scope . "_oid"; $bean->setPublished($_REQUEST[$pub_key]); $bean->setOid($_REQUEST[$oid_key]); $bean->setScope($scope); $bean->setContent($_REQUEST[$scope]); $beans[$scope] = $bean; } return $beans; }