예제 #1
0
 /**
  * Print out a slot
  * 
  * @param object $slot
  * @return object Component
  * @access public
  * @since 12/4/07
  */
 public function getSlotComponent(Slot $slot)
 {
     $harmoni = Harmoni::instance();
     ob_start();
     print "\n\t<tr>";
     print "\n\t\t<td>";
     if ($slot->siteExists()) {
         print "\n\t\t\t<a href='";
         print $harmoni->request->quickURL('ui1', 'view', array('site' => $slot->getShortname()));
         print "' target='_blank'>" . $slot->getShortname() . "</a>";
     } else {
         print $slot->getShortname();
     }
     print "</td>";
     print "\n\t\t<td>" . $slot->getType() . "</td>";
     print "\n\t\t<td>" . $slot->getLocationCategory() . "</td>";
     // Media Quota
     print "\n\t\t<td>";
     if ($slot->usesDefaultMediaQuota()) {
         $quota = SlotAbstract::getDefaultMediaQuota()->asString();
         print "<a href='#' title='{$quota}' onclick='alert(\"{$quota}\"); return false;'>";
         print _("Default");
         print "</a>";
     } else {
         print $slot->getMediaQuota()->asString();
     }
     print "</td>";
     print "\n\t\t<td style='text-align: center'>" . ($slot->siteExists() ? "yes" : '') . "</td>";
     print "\n\t\t<td>";
     $owners = $slot->getOwners();
     $ownerStrings = array();
     $agentMgr = Services::getService('Agent');
     foreach ($owners as $ownerId) {
         $ownerStrings[] = $agentMgr->getAgent($ownerId)->getDisplayName();
     }
     print implode("; ", $ownerStrings);
     print "</td>";
     $harmoni->request->passthrough('starting_number');
     $harmoni->request->startNamespace("slots");
     print "\n\t\t<td style='white-space: nowrap;'>";
     print "\n\t\t\t<a href='";
     print $harmoni->request->quickURL('slots', 'edit', array('name' => $slot->getShortname()));
     print "'>" . _("edit") . "</a>";
     if (!$slot->siteExists()) {
         $harmoni->request->startNamespace(null);
         print "\n\t\t\t| <a href='";
         print $harmoni->request->quickURL('dataport', 'import', array('site' => $slot->getShortname()));
         print "'>" . _("import") . "</a>";
         $harmoni->request->endNamespace();
         print "\n\t\t\t| <a href='";
         print $harmoni->request->quickURL('slots', 'delete', array('name' => $slot->getShortname()));
         print "' onclick=\"";
         print "return confirm('" . _('Are you sure you want to delete this placeholder?') . "');";
         print "\">" . _("delete") . "</a>";
     } else {
         $harmoni->request->startNamespace(null);
         print "\n\t\t\t| <a href='";
         print $harmoni->request->quickURL('dataport', 'export', array('node' => $slot->getSiteId()->getIdString()));
         print "'>" . _("export") . "</a>";
         $harmoni->request->endNamespace();
     }
     print "\n\t\t</td>";
     $harmoni->request->endNamespace();
     $harmoni->request->forget('starting_number');
     print "\n\t</tr>";
     return ob_get_clean();
 }
예제 #2
0
 /**
  * Merge this slot with one defined internally to the system.
  * Any updates to the internal storage will be made based on the external data.
  * 
  * @param object Slot $intSlot
  * @return void
  * @access public
  * @since 8/14/07
  */
 public final function mergeWithInternal(Slot $intSlot)
 {
     if ($this->getShortname() != $intSlot->getShortname()) {
         throw new Exception("Cannot merge slots with differing shortnames. '" . $this->getShortname() . "' != '" . $intSlot->getShortname() . "'");
     }
     if ($intSlot->isAlias()) {
         $this->populateAlias($intSlot->getAliasTarget()->getShortname());
     } else {
         $this->populateSiteId($intSlot->getSiteId());
     }
     foreach ($this->getOwners() as $key => $ownerId) {
         // If this owner was intentionally removed, don't list them.
         if ($intSlot->isRemovedOwner($ownerId)) {
             unset($this->owners[$key]);
         } else {
             if (!$intSlot->isOwner($ownerId)) {
                 $this->addOwner($ownerId);
             }
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     // Add owners that only appear in the internal slot
     foreach ($intSlot->getOwners() as $ownerId) {
         // If this owner was intentionally removed, populate that
         if (!$this->isOwner($ownerId)) {
             $this->populateOwnerId($ownerId);
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     // Add in "Removed owners" that only appear in the internal slot
     foreach ($intSlot->getRemovedOwners() as $ownerId) {
         // If this owner was intentionally removed, populate that
         if (!$this->isRemovedOwner($ownerId)) {
             $this->populateRemovedOwnerId($ownerId);
         }
         // Otherwise, the owner appears as valid in both definitions and
         // can be ignored for the purposes of merging.
     }
     $this->isInDB = true;
 }
예제 #3
0
 /**
  * AuthZ
  * 
  * @return boolean
  * @access public
  * @since 3/14/08
  */
 protected function canChangeSlotStatus(Slot $slot)
 {
     if (!$slot->siteExists()) {
         return $slot->isUserOwner();
     }
     // get siteRoot node and check that
     $idMgr = Services::getService('Id');
     $azMgr = Services::getService('AuthZ');
     // Since view AZs cascade up, just check at the node.
     return $azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $slot->getSiteId());
 }
예제 #4
0
 /**
  * Convert a slot to another type. The object passed on will no longer be valid.
  * 
  * @param object Slot $slot
  * @param string $type
  * @return object Slot
  * @access public
  * @since 1/4/08
  */
 public function convertSlotToType(Slot $slot, $type)
 {
     if (!isset($this->slotTypes[$type])) {
         throw new Exception("Unknown SlotType, '{$type}'. Should be one of (" . implode(", ", array_keys($this->slotTypes)) . ").");
     }
     $shortname = $slot->getShortname();
     $dbc = Services::getService("DatabaseManager");
     try {
         // Add a row to the slot table
         $query = new InsertQuery();
         $query->setTable('segue_slot');
         $query->addValue('shortname', $shortname);
         if ($slot->getSiteId()) {
             $query->addValue('site_id', $slot->getSiteId()->getIdString());
         }
         if ($slot->isAlias()) {
             $query->addValue('alias_target', $slot->getAliasTarget()->getShortname());
         }
         $query->addValue('type', $type);
         $query->addValue('location_category', $slot->getLocationCategory());
         if (!$slot->usesDefaultMediaQuota()) {
             $query->addValue('media_quota', $slot->getMediaQuota());
         }
         $dbc->query($query, IMPORTER_CONNECTION);
     } catch (DuplicateKeyDatabaseException $e) {
         // Update row to the slot table
         $query = new UpdateQuery();
         $query->setTable('segue_slot');
         $query->addWhereEqual('shortname', $shortname);
         $query->addValue('type', $type);
         $dbc->query($query, IMPORTER_CONNECTION);
     }
     // Clear our cache
     unset($this->slots[$shortname]);
     $slot = $this->getSlotByShortname($shortname);
     return $slot;
 }
예제 #5
0
 /**
  * Print info about a Slot
  * 
  * @param object Slot $slot
  * @return void
  * @access private
  * @since 3/13/08
  */
 private function printSlotInfo(Slot $slot)
 {
     $harmoni = Harmoni::instance();
     if ($slot->siteExists()) {
         $asset = $slot->getSiteAsset();
         try {
             $authZ = Services::getService('AuthZ');
             $idMgr = Services::getService('Id');
             if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $slot->getSiteId())) {
                 print "\n<div class='site_info'>";
                 print "\n\t<div class='site_description'>";
                 print _("A site has been created for this placeholder, but you do not have authorization to view it.");
                 print "</div>";
                 print "\n</div>";
                 return;
             }
         } catch (UnknownIdException $e) {
         }
         $viewUrl = SiteDispatcher::quickURL('view', 'html', array('site' => $slot->getShortname()));
         print "\n<div class='site_info'>";
         print "\n\t<div class='site_title'>";
         print "\n\t\t<a href='" . $viewUrl . "' target='_blank'>";
         print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>";
         print "\n\t\t</a>";
         print "\n\t</div>";
         $description = HtmlString::withValue($asset->getDescription());
         $description->trim(25);
         print "\n\t<div class='site_description'>" . $description->asString() . "</div>";
         print "\n</div>";
     }
     print "\n\t<div class='slotname'>";
     print $slot->getShortname();
     print "\n\t</div>";
 }