/** * This class implements the Singleton pattern. There is only ever * one instance of the this class and it is accessed only via the * ClassName::instance() method. * * @return object * @access public * @since 5/26/05 * @static */ public static function instance() { if (!isset(self::$instance)) { self::$instance = new SegueCourseManager(); } return self::$instance; }
/** * Answer an array of courses for this folder * * @return array of course objects * @access protected * @since 4/1/08 */ protected function getCourses() { $courseMgr = SegueCourseManager::instance(); return $courseMgr->getUsersCurrentCourses(SORT_DESC); }
/** * Answer the course associated with this slot. * * @return object SegueCourseSection * @access public * @since 2/17/09 */ public function getCourse() { $idMgr = Services::getService("Id"); return SegueCourseManager::instance()->getCourse($idMgr->getId($this->getShortname())); }
/** * Execute this action. * * @return void * @access public * @since 08/11/08 */ public function execute() { $this->start(); try { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException("You are not authorized to load course listing."); } $semester = RequestContext::value('semester'); $year = strval(RequestContext::value('year')); $courseMgr = SegueCourseManager::instance(); if (!isset($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS']) || !is_array($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS']) || !count($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS'])) { throw new ConfigurationErrorException("\$GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS'] must be an array to enable couse-listing."); } $semesters = $GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS']; if (!in_array($semester, $semesters)) { throw new InvalidArgumentException("'semester' must be one of " . implode(", ", $semesters) . "."); } if (!preg_match('/^(19|20)[0-9]{2,}$/', $year)) { throw new InvalidArgumentException("Year '{$year}' must be four digits."); } if (!defined('SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK')) { throw new ConfigurationErrorException("SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK must be defined to enable couse-listing."); } $func = SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK; $slotMgr = SlotManager::instance(); $agentMgr = Services::getService('Agent'); $slots = $slotMgr->getAllSlots(); while ($slots->hasNext()) { $slot = $slots->next(); if ($slot->siteExists() && $func($slot->getShortname(), $semester, $year)) { print "\n\t<site id=\"" . $slot->getSiteId()->getIdString() . "\">"; print "\n\t\t<shortname>" . $slot->getShortname() . "</shortname>"; $siteAsset = $slot->getSiteAsset(); print "\n\t\t<displayName>" . strip_tags($siteAsset->getDisplayName()) . "</displayName>"; print "\n\t\t<description>" . strip_tags($siteAsset->getDescription()) . "</description>"; print "\n\t\t<url>" . SiteDispatcher::getSitesUrlForSiteId($slot->getSiteId()->getIdString()) . "</url>"; foreach ($slot->getOwners() as $ownerId) { $owner = $agentMgr->getAgent($ownerId); print "\n\t\t<owner id=\"" . $ownerId->getIdString() . "\">"; print "\n\t\t<displayName>" . $owner->getDisplayName() . "</displayName>"; $propertiesIterator = $owner->getProperties(); while ($propertiesIterator->hasNext()) { $properties = $propertiesIterator->next(); $keys = $properties->getKeys(); while ($keys->hasNext()) { $key = $keys->next(); print "\n\t\t<property key=\"" . $key . "\">"; print "<![CDATA[" . $properties->getProperty($key) . "]]>"; print "</property>"; } } print "\n\t\t</owner>"; } print "\n\t</site>"; } } } catch (Exception $e) { $this->error($e->getMessage(), get_class($e)); } $this->end(); }