예제 #1
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;
 }
예제 #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
 /**
  * Answer an HTML block that describes the migration status of the slot
  * 
  * @param Slot $slot
  * @return null
  */
 public function printMigrationStatus(Slot $slot)
 {
     if (!defined('DATAPORT_ENABLE_EXPORT_REDIRECT') || !DATAPORT_ENABLE_EXPORT_REDIRECT) {
         return;
     }
     // Just work with the primary slot if aliases are involved.
     if ($slot->isAlias()) {
         $slot = $slot->getAliasTarget();
     }
     print "\n\t<div class='portal_list_migration_status'>\n\t\t";
     print "Migration Status: ";
     $status = $slot->getMigrationStatus();
     print "<span class='status_line'>";
     switch ($status['type']) {
         case 'archived':
             print '<span class="status status_archived">Archived</span>';
             break;
         case 'migrated':
             print '<span class="status status_migrated">Migrated</span>';
             if (!empty($status['url'])) {
                 print ' to <a href="' . htmlentities($status['url']) . '">' . htmlentities($status['url']) . '</a>';
             }
             break;
         case 'unneeded':
             if ($slot->siteExists()) {
                 print '<span class="status status_unneeded">No Longer Needed</span>';
             } else {
                 print '<span class="status status_unneeded_empty">No Longer Needed</span>';
             }
             break;
         default:
             print '<span class="status status_incomplete">Incomplete</span>';
     }
     print " </span>";
     if ($this->canChangeSlotStatus($slot)) {
         print "<button onclick='MigrationPanel.run(\"" . $slot->getShortname() . "\", \"" . $status['type'] . "\", \"" . $status['url'] . "\", this); return false;' class='create_site_link'>" . _("change") . "</button>";
     }
     print "\n\t</div>";
 }