예제 #1
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     header('Content-Type: text/plain;');
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException("You must be logged in.");
         }
         $mgr = SlotManager::instance();
         $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
         $slot->makeAlias($mgr->getSlotByShortname(RequestContext::value('target_slot')));
         print _("Success");
         /*********************************************************
          * Log the success
          *********************************************************/
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Segue");
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
             $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
             $item = new AgentNodeEntryItem("Alias Made", "'" . $slot->getShortname() . "' has been made an alias of '" . RequestContext::value('target_slot') . "'.");
             $item->addNodeId($slot->getSiteId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     } catch (OperationFailedException $e) {
         print $e->getMessage();
     } catch (UnknownIdException $e) {
         print $e->getMessage();
     }
     exit;
 }
예제 #2
0
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  */
 public function execute()
 {
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException();
         }
         ob_start();
         $harmoni = Harmoni::instance();
         $component = SiteDispatcher::getCurrentNode();
         $site = SiteDispatcher::getCurrentRootNode();
         $slotMgr = SlotManager::instance();
         $slot = $slotMgr->getSlotBySiteId($site->getId());
         $exportDirname = $slot->getShortname() . "-html";
         $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname;
         $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip";
         if (!file_exists($exportDir)) {
             header('HTTP/1.1 404 Not Found');
             print "Not Found";
             exit;
         }
         header("Content-Type: text/html;");
         $this->printStatus($exportDir);
     } catch (PermissionDeniedException $e) {
         header('HTTP/1.1 403 Forbidden');
         header("Content-Type: text/plain;");
         print _("You are not authorized to monitor the export this component.");
         exit;
     }
     exit;
 }
예제 #3
0
 /**
  * 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 SlotManager();
     }
     return self::$instance;
 }
예제 #4
0
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     // Do not allow delete of the root menu.
     if (method_exists($component, 'isRootMenu')) {
         if ($component->isRootMenu()) {
             $this->returnToCallerPage();
             exit;
         }
     }
     $this->findSafeReturnNode($director, $component);
     $organizer = $component->getParentComponent();
     if ($organizer) {
         $organizer->detatchSubcomponent($component);
     }
     $rootSiteComponent = $director->getRootSiteComponent(SiteDispatcher::getCurrentNodeId());
     // If we are deleting the site unhitch it from the slot
     if ($rootSiteComponent->getId() == SiteDispatcher::getCurrentNodeId()) {
         $slotMgr = SlotManager::instance();
         $idMgr = Services::getService("Id");
         try {
             $slot = $slotMgr->getSlotBySiteId($idMgr->getId(SiteDispatcher::getCurrentNodeId()));
             $slot->deleteSiteId();
         } catch (Exception $e) {
         }
     }
     $director->deleteSiteComponent($component);
 }
 /**
  * Run the update
  * 
  * @return boolean
  * @access public
  * @since 1/11/08
  */
 function runUpdate()
 {
     $dbc = Services::getService('DatabaseManager');
     $slotMgr = SlotManager::instance();
     $query = new GenericSQLQuery();
     $query->addSQLQuery("CREATE TABLE segue_plugin_version (\n  version_id int(10) unsigned NOT NULL auto_increment,\n  node_id varchar(170) collate utf8_bin NOT NULL,\n  tstamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n  `comment` varchar(255) collate utf8_bin NOT NULL,\n  agent_id varchar(170) collate utf8_bin NOT NULL,\n  version_xml longblob NOT NULL,\n  PRIMARY KEY  (version_id),\n  KEY node_id (node_id)\n)\nCHARACTER SET utf8\nTYPE=InnoDB;");
     $dbc->query($query);
     return true;
 }
예제 #6
0
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  */
 public function execute()
 {
     ob_start();
     $harmoni = Harmoni::instance();
     $component = SiteDispatcher::getCurrentNode();
     $site = SiteDispatcher::getCurrentRootNode();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotBySiteId($site->getId());
     $exportDirname = $slot->getShortname() . "-files";
     $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname;
     mkdir($exportDir);
     $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip";
     try {
         // Do the export
         $visitor = new FileExportSiteVisitor($exportDir);
         $component->acceptVisitor($visitor);
         $archive = new ZipArchive();
         if ($archive->open($archivePath, ZIPARCHIVE::CREATE) !== TRUE) {
             throw new Exception("Could not create zip archive.");
         }
         foreach (scandir($exportDir) as $file) {
             if (!is_dir($exportDir . '/' . $file)) {
                 $archive->addFile($exportDir . '/' . $file, $exportDirname . '/' . $file);
             }
         }
         $archive->close();
         // Remove the directory
         $this->deleteRecursive($exportDir);
         if ($output = ob_get_clean()) {
             print $output;
             throw new Exeception("Errors occurred, output wasn't clean.");
         }
         header("Content-Type: application/zip;");
         header('Content-Disposition: attachment; filename="' . basename($archivePath) . '"');
         header('Content-Length: ' . filesize($archivePath));
         print file_get_contents($archivePath);
         // Clean up the archive
         unlink($archivePath);
     } catch (PermissionDeniedException $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($archivePath)) {
             unlink($archivePath);
         }
         return new Block(_("You are not authorized to export this component."), ALERT_BLOCK);
     } catch (Exception $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($archivePath)) {
             unlink($archivePath);
         }
         throw $e;
     }
     error_reporting(0);
     exit;
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slots = array();
     $slotMgr = SlotManager::instance();
     foreach (Segue_AccessLog::instance()->getRecentSlots() as $shortname) {
         try {
             $slots[] = $slotMgr->getSlotByShortname($shortname);
         } catch (UnknownIdException $e) {
         }
     }
     return $slots;
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slotMgr = SlotManager::instance();
     $courses = $this->getCourses();
     $slots = array();
     if (count($courses)) {
         foreach ($courses as $course) {
             $slots[] = $slotMgr->getSlotByShortname($course->getId()->getIdString());
         }
     }
     return $slots;
 }
예제 #9
0
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  * @since 1/17/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException("You are not authorized to update this slot.");
     }
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotByShortname(RequestContext::value('slot'));
     $slot->setMigrationStatus(RequestContext::value('status'), RequestContext::value('url'));
     header("Content-Type: text/plain");
     print "Success.";
     exit;
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slotMgr = SlotManager::instance();
     // process of elimination.
     $otherCategorizedSlotNames = $this->getOtherCategorizedSlotNames();
     $slots = array();
     foreach ($slotMgr->getSlots() as $slot) {
         if (!in_array($slot->getShortName(), $otherCategorizedSlotNames)) {
             $slots[] = $slot;
         }
     }
     return $slots;
 }
예제 #11
0
 /**
  * Build a list of the sites for which users are admins
  * 
  * @return null
  */
 protected function buildUserSiteList()
 {
     $slotMgr = SlotManager::instance();
     $slots = $slotMgr->getAllSlots();
     $roleMgr = SegueRoleManager::instance();
     $agentMgr = Services::getService('Agent');
     $increment = round($slots->count() / 100);
     $i = 0;
     $numSites = 0;
     $incomplete = 0;
     $this->slots = array();
     // Get the users who can adminster each slot.
     while ($slots->hasNext()) {
         $i++;
         if ($i % $increment == 0) {
             print '.';
             flush();
         }
         $slot = $slots->next();
         if (!$slot->isAlias() && $slot->siteExists()) {
             $this->slots[$slot->getShortname()] = array('slot' => $slot, 'users' => array());
             $adminIds = $roleMgr->getAgentsWithExplicitRoleAtLeast($roleMgr->getRole('admin'), $slot->getSiteId(), true);
             $numAdmins = 0;
             foreach ($adminIds as $adminId) {
                 // Skip the special groups of
                 // 	edu.middlebury.institute
                 // 	edu.middlebury.agents.users
                 // 	edu.middlebury.agents.anonymous
                 // etc.
                 if (preg_match('/^edu\\.middlebury\\./', $adminId->getIdString())) {
                     continue;
                 }
                 try {
                     $agent = $agentMgr->getAgentOrGroup($adminId);
                     if ($agent->isGroup()) {
                         $numAdmins = $numAdmins + $this->addSlotForGroup($agent, $slot);
                     } else {
                         $numAdmins = $numAdmins + $this->addSlotForAgent($agent, $slot);
                     }
                 } catch (UnknownIdException $e) {
                 }
             }
             if (!$numAdmins) {
                 $this->slotsWithoutAdmins[] = $slot->getShortname();
             }
         }
     }
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slotMgr = SlotManager::instance();
     // process of elimination.
     $slots = array();
     foreach ($this->getSiteIds() as $siteId) {
         try {
             $slots[] = $slotMgr->getSlotBySiteId($siteId);
         } catch (UnknownIdException $e) {
             $slot = new CustomSlot(null);
             $slot->populateSiteId($siteId);
             $slots[] = $slot;
         }
     }
     return $slots;
 }
예제 #13
0
 /**
  * Execute
  * 
  * @return void
  * @access public
  * @since 3/26/08
  */
 public function execute()
 {
     $slotMgr = SlotManager::instance();
     if (is_null(RequestContext::value('site'))) {
         throw new NullArgumentException("No site specified.");
     }
     $slot = $slotMgr->getSlotByShortname(RequestContext::value('site'));
     $exists = $slot->siteExists();
     header("Content-Type: text/plain");
     if ($exists) {
         print "true";
     } else {
         print "false";
     }
     exit;
 }
 /**
  * Check Authorizations
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function isAuthorizedToExecute()
 {
     // Check that the user can create an asset here.
     if (RequestContext::value("slot")) {
         $slotMgr = SlotManager::instance();
         $slot = $slotMgr->getSlotByShortname(RequestContext::value("slot"));
         if ($slot->isUserOwner()) {
             return true;
         } else {
             return false;
         }
     } else {
         $authZ = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         return $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $idManager->getId("edu.middlebury.segue.sites_repository"));
     }
 }
예제 #15
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException("You must be logged in.");
     }
     header('Content-Type: text/xml;');
     print "<ul>";
     $search = RequestContext::value('search');
     if ($search && preg_match('/^[a-z0-9\\._-]+$/i', $search)) {
         $slots = SlotManager::instance()->getSlotsWithSitesBySearch($search . '*');
         foreach ($slots as $slot) {
             print "\n\t<li>" . $slot->getShortName() . "</li>";
         }
     }
     print "\n</ul>";
     exit;
 }
예제 #16
0
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  * @since 1/17/08
  */
 public function execute()
 {
     $harmoni = Harmoni::instance();
     $component = SiteDispatcher::getCurrentNode();
     $site = SiteDispatcher::getCurrentRootNode();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotBySiteId($site->getId());
     $exportDir = DATAPORT_TMP_DIR . "/" . $slot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString());
     mkdir($exportDir);
     try {
         // Do the export
         $visitor = new DomExportSiteVisitor($exportDir);
         $component->acceptVisitor($visitor);
         // Validate the result
         // 			printpre(htmlentities($visitor->doc->saveXMLWithWhitespace()));
         // 			$tmp = new Harmoni_DomDocument;
         // 			$tmp->loadXML($visitor->doc->saveXMLWithWhitespace());
         // 			$tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
         $visitor->doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
         // Write out the XML
         $visitor->doc->saveWithWhitespace($exportDir . "/site.xml");
         $archive = new Archive_Tar($exportDir . ".tar.gz");
         $archive->createModify($exportDir, '', DATAPORT_TMP_DIR);
         // Remove the directory
         $this->deleteRecursive($exportDir);
         header("Content-Type: application/x-gzip;");
         header('Content-Disposition: attachment; filename="' . basename($exportDir . ".tar.gz") . '"');
         print file_get_contents($exportDir . ".tar.gz");
         // Clean up the archive
         unlink($exportDir . ".tar.gz");
     } catch (PermissionDeniedException $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($exportDir . ".tar.gz")) {
             unlink($exportDir . ".tar.gz");
         }
         return new Block(_("You are not authorized to export this component."), ALERT_BLOCK);
     } catch (Exception $e) {
         $this->deleteRecursive($exportDir);
         if (file_exists($exportDir . ".tar.gz")) {
             unlink($exportDir . ".tar.gz");
         }
         throw $e;
     }
     error_reporting(0);
     exit;
 }
예제 #17
0
 /**
  * Execute the action
  * 
  * @return mixed
  * @access public
  * @since 1/17/08
  */
 public function execute()
 {
     $harmoni = Harmoni::instance();
     $component = SiteDispatcher::getCurrentNode();
     $site = SiteDispatcher::getCurrentRootNode();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotBySiteId($site->getId());
     $this->setupTextTemplates();
     $pluginManager = Services::getService('PluginManager');
     $audioType = new Type('SeguePlugins', 'edu.middlebury', 'AudioPlayer');
     $pluginManager->_loadPlugins();
     // Ensure that the original plugin is loaded.
     require_once MYDIR . '/plugins-dist/SeguePlugins/edu.middlebury/AudioPlayer/WordpressExportAudioPlayerPlugin.class.php';
     $pluginManager->setPluginClass($audioType, 'WordpressExportAudioPlayerPlugin');
     $textType = new Type('SeguePlugins', 'edu.middlebury', 'TextBlock');
     require_once MYDIR . '/plugins-dist/SeguePlugins/edu.middlebury/TextBlock/WordpressExportTextBlockPlugin.class.php';
     $pluginManager->setPluginClass($textType, 'WordpressExportTextBlockPlugin');
     try {
         // Do the export
         $visitor = new WordpressExportSiteVisitor();
         $component->acceptVisitor($visitor);
         // Validate the result
         // 			printpre(htmlentities($visitor->doc->saveXMLWithWhitespace()));
         // 			$tmp = new Harmoni_DomDocument;
         // 			$tmp->loadXML($visitor->doc->saveXMLWithWhitespace());
         // 			$tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
         // 			$visitor->doc->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd");
         header("Content-Type: text/xml");
         header('Content-Disposition: attachment; filename="' . basename($slot->getShortname() . ".xml") . '"');
         $xml = $visitor->doc->saveXMLWithWhitespace();
         header('Content-Length: ' . strlen($xml));
         print $xml;
     } catch (PermissionDeniedException $e) {
         return new Block(_("You are not authorized to export this component."), ALERT_BLOCK);
     } catch (Exception $e) {
         throw $e;
     }
     error_reporting(0);
     exit;
 }
예제 #18
0
 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException("You must be logged in.");
     }
     $mgr = SlotManager::instance();
     $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
     $oldTarget = $slot->getAliasTarget();
     $slot->makeNotAlias();
     /*********************************************************
      * Log the success
      *********************************************************/
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Alias Removed", "'" . $slot->getShortname() . "' is no longer an alias of '" . $oldTarget->getShortname() . "'.");
         $item->addNodeId($oldTarget->getSiteId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni = Harmoni::instance();
     RequestContext::sendTo($harmoni->request->quickURL('portal', 'list'));
 }
예제 #19
0
 /**
  * Execute
  * 
  * @return void
  * @access public
  * @since 12/7/07
  */
 public function buildContent()
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("slots");
     $name = strtolower(RequestContext::value("name"));
     $harmoni->request->passthrough("name");
     $harmoni->request->endNamespace();
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotByShortname($name);
     if ($slot->siteExists()) {
         throw new PermissionDeniedException("You cannot delete a placeholder that has an existing site.");
     }
     $slotMgr->deleteSlot($name);
     // Log this change
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Delete Placeholder", "Placeholder deleted:  '" . $name . "'.");
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni->request->sendTo($this->getReturnUrl());
 }
 /**
  * Run the update
  * 
  * @return boolean
  * @access public
  * @since 7/9/07
  */
 function runUpdate()
 {
     $dbc = Services::getService('DatabaseManager');
     $slotMgr = SlotManager::instance();
     $query = new GenericSQLQuery();
     $query->addSQLQuery("ALTER TABLE `segue_slot_owner` ADD UNIQUE `unique_owner` ( `shortname` , `owner_id` ) ;");
     $dbc->query($query);
     return true;
 }
예제 #21
0
 /**
  * Answer the slot.
  * 
  * @return object Slot
  * @access protected
  * @since 7/28/08
  */
 protected function getDestSlot()
 {
     if (!preg_match('/^[a-z0-9_\\.-]+$/i', RequestContext::value('destSlot'))) {
         throw new InvalidArgumentException("Invalid slot name.");
     }
     $slotMgr = SlotManager::instance();
     $slot = $slotMgr->getSlotByShortname(RequestContext::value('destSlot'));
     if ($slot->siteExists()) {
         throw new OperationFailedException("Cannot copy site, slot already full.");
     }
     return $slot;
 }
예제 #22
0
 /**
  * Answer a component containing either all slots or the search results.
  *
  * @return object Component
  * @access private
  * @since 12/4/07
  */
 private function getSlotList()
 {
     $slotMgr = SlotManager::instance();
     if ($this->getSearchTerm()) {
         $slots = $this->getSlotsBySearch($this->getSearchTerm());
     } else {
         $slots = $slotMgr->getAllSlots();
     }
     $headRow = "\n\t<tr>\n\t\t<th>" . _("Placeholder Name") . "</th>\n\t\t<th>" . _("Type") . "</th>\n\t\t<th>" . _("Category") . "</th>\n\t\t<th>" . _("Media Quota") . "</th>\n\t\t<th>" . _("Site Exists") . "</th>\n\t\t<th>" . _("Owners") . "</th>\n\t\t<th>" . _("Actions") . "</th>\n\t</tr>";
     $printer = new TableIteratorResultPrinter($slots, $headRow, 50, array($this, 'getSlotComponent'));
     return new Block($printer->getTable(), STANDARD_BLOCK);
 }
예제 #23
0
 /**
  * Answer the slot for the site.
  *
  * @return object Slot
  * @access protected
  * @since 3/26/08
  */
 protected function getSlot()
 {
     if (!isset($this->slot)) {
         $slotMgr = SlotManager::instance();
         $this->slot = $slotMgr->getSlotBySiteId($this->getSiteAsset($this->getContentAsset())->getId());
     }
     return $this->slot;
 }
예제 #24
0
 /**
  * Convert a single wiki link [[SomeTitle]] to an html link.
  *
  * Forms:
  *		[[Some Title]]
  *		[[Some Title|alternate text to display]]
  *		[[site:my_other_slot_name Some Title]]
  *		[[site:my_other_slot_name Some Title|alternate text to display]]
  *		[[node:12345 Some Title]]
  *		[[node:12345|alternate text to display]]
  *
  * Local URL form:
  *		[[localurl:module=modName&amp;action=actName&amp;param1=value1]]
  * File URL form:
  *		[[fileurl:repository_id=123&amp;asset_id=1234&amp;record_id=12345]]
  * Unlike other forms, the local URL form and the file URL form do not write link tags. 
  * They gets replaced with only the URL string itself.
  * 
  * @param string $wikiText
  * @param object SiteComponent $startingSiteComponent
  * @return string An HTML version of the link
  * @access private
  * @since 11/30/07
  */
 private function makeHtmlLink($wikiText, SiteComponent $startingSiteComponent)
 {
     $regexp = "/\n\n^\t\t# Anchor for the beginning of the line\n\\[\\[\t# The opening link tags\n\n\t\\s*\t\t# optional whitespace\n\n\t(?: site:([a-z0-9_\\-]+) \\s+ )?\t# An optional designator for linking to another site\n\t\n\t([^\\]#\\|]+)\t# The Title of the linked section, page, story\n\t\t\n\t(?: \\s*\\|\\s* ([^\\]]+) )?\t# The optional link-text to display instead of the title\n\n\t\\s*\t\t# optional whitespace\n\n\\]\\]\t# The closing link tags\n\$\t\t# Anchor for the end of the line\n\n/xi";
     $siteOnlyRegexp = "/\n\n^\t\t# Anchor for the beginning of the line\n\\[\\[\t# The opening link tags\n\n\t\\s*\t\t# optional whitespace\n\n\t(?: site:([a-z0-9_\\-]+) )?\t# A designator for linking to another site\n\t\n\t(?: \\s*\\|\\s* ([^\\]]+) )?\t# The optional link-text to display instead of the title\n\n\t\\s*\t\t# optional whitespace\n\n\\]\\]\t# The closing link tags\n\$\t\t# Anchor for the end of the line\n\n/xi";
     $nodeRegexp = "/\n\n^\t\t# Anchor for the beginning of the line\n\\[\\[\t# The opening link tags\n\n\t\\s*\t\t# optional whitespace\n\n\t(?: node:([a-z0-9_\\-]+) )?\t# A designator for linking to a particular node\n\t\n\t(?: \\s*\\|\\s* ([^\\]]+) )?\t# The optional link-text to display instead of the title\n\n\t\\s*\t\t# optional whitespace\n\n\\]\\]\t# The closing link tags\n\$\t\t# Anchor for the end of the line\n\n/xi";
     $localUrlRegexp = "/\n\n^\t\t# Anchor for the beginning of the line\n\\[\\[\t# The opening link tags\n\n\t\\s*\t\t# optional whitespace\n\n\t(?: localurl:([^\\]]+) )?\t# A designator for linking to a local url\n\n\\]\\]\t# The closing link tags\n\$\t\t# Anchor for the end of the line\n\n/xi";
     $fileUrlRegexp = "/\n\n^\t\t# Anchor for the beginning of the line\n\\[\\[\t# The opening link tags\n\n\t\\s*\t\t# optional whitespace\n\n\t(?: fileurl:([^\\]]+) )?\t# A designator for linking to a local file\n\n\\]\\]\t# The closing link tags\n\$\t\t# Anchor for the end of the line\n\n/xi";
     // Check for a link only to a site [[site:my_other_site]]
     if (preg_match($siteOnlyRegexp, $wikiText, $matches)) {
         $slotName = $matches[1];
         if (isset($matches[2]) && $matches[2]) {
             $display = $matches[2];
             $slotMgr = SlotManager::instance();
             $slot = $slotMgr->getSlotByShortName($slotName);
             if (!$slot->siteExists()) {
                 return $display . " ?";
             }
         } else {
             $slotMgr = SlotManager::instance();
             $slot = $slotMgr->getSlotByShortName($slotName);
             if ($slot->siteExists()) {
                 $director = $startingSiteComponent->getDirector();
                 $site = $director->getSiteComponentById($slot->getSiteId()->getIdString());
                 if (strlen($site->getDisplayName())) {
                     $display = $site->getDisplayName();
                 } else {
                     $display = $slotName;
                 }
             } else {
                 return $slotName . " ?";
             }
         }
         return $this->getSlotLink($slotName, $display);
     }
     // Check for a link to a node [[node:12345]]
     if (preg_match($nodeRegexp, $wikiText, $matches)) {
         $nodeIdString = $matches[1];
         try {
             if (isset($matches[2]) && $matches[2]) {
                 $display = $matches[2];
                 // Try getting the title to check if the node exists
                 $title = $this->getNodeTitle($nodeIdString, $startingSiteComponent);
             } else {
                 $display = $this->getNodeTitle($nodeIdString, $startingSiteComponent);
             }
         } catch (UnknownIdException $e) {
             if (isset($display)) {
                 return $display . " ?";
             } else {
                 return $nodeIdString . " ?";
             }
         }
         return $this->getNodeLink($nodeIdString, $display);
     }
     // Check for a link to a local url:
     // [[localurl:module=modName&amp;action=actName&amp;param1=value1]]
     if (preg_match($localUrlRegexp, $wikiText, $matches)) {
         preg_match_all('/(&(amp;)?)?([^&=]+)=([^&=]+)/', $matches[1], $paramMatches);
         $args = array();
         for ($i = 0; $i < count($paramMatches[1]); $i++) {
             $key = $paramMatches[3][$i];
             $value = $paramMatches[4][$i];
             if ($key == 'module') {
                 $module = $value;
             } else {
                 if ($key == 'action') {
                     $action = $value;
                 } else {
                     $args[$key] = $value;
                 }
             }
         }
         // If no params are specified, return our base url
         if (!count($args) && !isset($module) && !isset($action)) {
             return MYURL;
         }
         if (!isset($module)) {
             $module = 'ui1';
         }
         if (!isset($action)) {
             $action = 'view';
         }
         // Convert thumbnail urls
         if ($module == 'repository' && $action == 'viewthumbnail' && !empty($args['polyphony-repository___repository_id']) && !empty($args['polyphony-repository___asset_id']) && !empty($args['polyphony-repository___record_id'])) {
             $repositoryId = $args['polyphony-repository___repository_id'];
             $assetId = $args['polyphony-repository___asset_id'];
             $recordId = $args['polyphony-repository___record_id'];
             $file = MediaFile::withIdStrings($repositoryId, $assetId, $recordId);
             return $file->getThumbnailUrl();
         }
         $harmoni = Harmoni::instance();
         $harmoni->request->startNamespace(null);
         $newUrl = $harmoni->request->mkURLWithoutContext($module, $action, $args);
         $harmoni->request->endNamespace();
         return $newUrl->write();
     }
     // Check for a link to a file url:
     // [[fileurl:repository_id=123&amp;asset_id=1234&amp;record_id=12345]]
     if (preg_match($fileUrlRegexp, $wikiText, $matches)) {
         try {
             return MediaFile::withIdString($matches[1])->getUrl();
         } catch (InvalidArgumentException $e) {
         } catch (UnknownIdException $e) {
         }
     }
     // Links of the form [[Assignments]]
     if (preg_match($regexp, $wikiText, $matches)) {
         if (isset($matches[1]) && $matches[1]) {
             $slotMgr = SlotManager::instance();
             $slot = $slotMgr->getSlotByShortName($matches[1]);
             if ($slot->siteExists()) {
                 $director = $startingSiteComponent->getDirector();
                 $startingSiteComponent = $director->getSiteComponentById($slot->getSiteId()->getIdString());
             } else {
                 $title = $matches[2];
                 if (isset($matches[3]) && $matches[3]) {
                     $display = $matches[3];
                 } else {
                     $display = $title;
                 }
                 return $display . " ?";
             }
         }
         $title = $matches[2];
         if (isset($matches[3]) && $matches[3]) {
             $display = $matches[3];
         } else {
             $display = $title;
         }
         try {
             $nodeIdString = $this->titleSearcher->getNodeId($title, $startingSiteComponent);
             return $this->getNodeLink($nodeIdString, $display);
         } catch (UnknownTitleException $e) {
             return $this->getAddLink($title, $display, $startingSiteComponent);
         }
     }
     // If invalid, just return the wiki text.
     return $wikiText;
 }
예제 #25
0
 /**
  * Answer the slot for this action.
  * 
  * @return object SegueSlot
  * @access protected
  * @since 1/28/08
  */
 protected function getSlot()
 {
     $slotMgr = SlotManager::instance();
     return $slotMgr->getSlotByShortname($this->getSlotName());
 }
예제 #26
0
 /**
  * Answer true if this site should be included
  * 
  * @param object Asset $asset
  * @return boolean
  * @access protected
  * @since 4/1/08
  */
 protected function includeSite(Asset $asset)
 {
     $matches = false;
     if ($this->match($asset->getDisplayName())) {
         $matches = true;
     } else {
         if ($this->match($asset->getDescription())) {
             $matches = true;
         }
     }
     if (!$matches) {
         $slotMgr = SlotManager::instance();
         try {
             $slot = $slotMgr->getSlotBySiteId($asset->getId());
         } catch (UnknownIdException $e) {
         }
         if (isset($slot) && $this->match($slot->getShortname())) {
             $matches = true;
         }
     }
     if (!$matches) {
         return false;
     }
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     // Since View AZs now cascade up, we don't need to check isAuthorizedBelow()
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $asset->getId())) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
예제 #27
0
 /**
  * Answer the slot that is the target if this slot is an alias.
  * 
  * @return object Slot
  * @access public
  * @since 10/8/08
  */
 public function getAliasTarget()
 {
     if (!$this->isAlias()) {
         printpre($this);
         throw new OperationFailedException("Cannot get a target for a slot (" . get_class($this) . ": " . $this->getShortname() . ") that is not an alias.");
     }
     return SlotManager::instance()->getSlotByShortname($this->aliasTarget);
 }
 /**
  * Run the update
  * 
  * @return boolean
  * @access public
  * @since 3/20/08
  */
 function runUpdate()
 {
     $dbc = Services::getService('DatabaseManager');
     $slotMgr = SlotManager::instance();
     try {
         $query = new GenericSQLQuery();
         $query->addSQLQuery("ALTER TABLE `segue_slot` ADD `media_quota` INT;");
         $dbc->query($query);
     } catch (QueryDatabaseException $e) {
         print "<p>" . $e->getMessage() . "</p>";
     }
     try {
         $query = new GenericSQLQuery();
         $query->addSQLQuery("CREATE TABLE segue1_id_map (\n  segue1_slot_name varchar(50) NOT NULL,\n  segue1_id varchar(50) NOT NULL,\n  segue2_slot_name varchar(50) NOT NULL,\n  segue2_id varchar(170) NOT NULL,\n  PRIMARY KEY  (segue1_id),\n  UNIQUE KEY old_id_unique (segue1_slot_name,segue1_id),\n  UNIQUE KEY new_id_unique (segue2_slot_name,segue2_id),\n  KEY segue2_id (segue2_id)\n) ENGINE=InnoDB COMMENT='Mapping between segue1 and segue2 ids for auto-redirects.';");
         $dbc->query($query);
     } catch (QueryDatabaseException $e) {
         print "<p>" . $e->getMessage() . "</p>";
     }
     return $this->isInPlace();
 }
 /**
  * Answer an array of the slots in this category.
  * 
  * @return array of Slot objects
  * @access public
  * @since 4/1/08
  */
 public function getSlots()
 {
     $slotMgr = SlotManager::instance();
     return $slotMgr->getSlotsByType(Slot::personal);
 }
예제 #30
0
        $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId);
        // Administration Functions
        $type = new Type("Authorization", "edu.middlebury.harmoni", "Group Administration", "Functions for administering groups.");
        $id = $idManager->getId("edu.middlebury.authorization.create_group");
        $function = $authZManager->createFunction($id, "Create Groups", "Add Groups to the system.", $type, $qualifierHierarchyId);
        $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId);
        $id = $idManager->getId("edu.middlebury.authorization.delete_group");
        $function = $authZManager->createFunction($id, "Delete Groups", "Remove Groups from the system.", $type, $qualifierHierarchyId);
        $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId);
        $id = $idManager->getId("edu.middlebury.authorization.modify_group_membership");
        $function = $authZManager->createFunction($id, "Modify Group Membership", "Modify Group membership.", $type, $qualifierHierarchyId);
        $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfSegueId);
        /*********************************************************
         * Add a site for the administrator user to use for testing
         * new installations.
         *********************************************************/
        $slotMgr = SlotManager::instance();
        $testSlot = $slotMgr->getSlotByShortname('jadministrator-test_site');
        $testSlot->addOwner($adminAgent->getId());
        $testSlot->setLocationCategory('community');
        $slotMgr->convertSlotToType($testSlot, Slot::personal);
        // Set the 'personal' folder as the last visited so that admins logging into
        // a new install will see their personal test site.
        UserData::instance()->setPreference('segue_portal_last_folder', 'personal');
        // 		print "\n<br> ...done";
        $_SESSION['table_setup_complete'] = TRUE;
        unset($_SESSION['installation_underway']);
        // 		$dbHandler->commitTransaction($dbID);
        RequestContext::locationHeader($_SERVER['REQUEST_URI']);
    }
}