Ejemplo n.º 1
0
 /**
  * Answer a link to move/copy items from the selection into an organizer
  * 
  * @param object FlowOrganizerSiteComponent $siteComponent
  * @return string
  * @access public
  * @since 8/4/08
  */
 public function getMoveCopyLink(FlowOrganizerSiteComponent $siteComponent)
 {
     $this->addHeadJavascript();
     $ancestorIds = "[";
     $parent = $siteComponent->getParentComponent();
     while ($parent) {
         $ancestorIds .= "'" . $parent->getId() . "'";
         $parent = $parent->getParentComponent();
         if ($parent) {
             $ancestorIds .= ", ";
         }
     }
     $ancestorIds .= "]";
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("selection");
     ob_start();
     print "<a ";
     print " style='cursor: pointer;'";
     print " class='Selection_MoveCopy_Link' ";
     print " onclick=\"MoveCopyPanel.run('" . $siteComponent->getId() . "', '" . $siteComponent->getComponentClass() . "', " . $ancestorIds . ", this); return false;\"";
     print " title=\"" . _("Paste from your Selection") . "\"";
     print ">" . _('Paste');
     print "</a>";
     $harmoni->request->endNamespace();
     return ob_get_clean();
 }
 /**
  * Import an exported subtree below the site component passed.
  * The root of the subtree must be apropriate for importing below
  * the node.
  * 
  * @param object FlowOrganizerSiteComponent $organizer
  * @return object SiteComponent The root of the newly created subtree.
  * @access public
  * @since 8/5/08
  */
 public function importSubtreeUnderOrganizer(FlowOrganizerSiteComponent $organizer)
 {
     // Check Authorization
     $authZ = Services::getService("AuthZ");
     $idMgr = Services::getService("Id");
     if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.add_children'), $organizer->getQualifierId())) {
         throw new PermissionDeniedException("You are not authorized to import at '" . $organizer->getQualifierId()->getIdString() . "'.");
     }
     // Check for a valid number of elements of the right type.
     switch ($organizer->getComponentClass()) {
         case 'FlowOrganizer':
             $elements = $this->xpath->evaluate('/Segue2/Block');
             $allowedString = "Content Block";
             $destString = "Content Organizer";
             break;
         case 'MenuOrganizer':
             $elements = $this->xpath->evaluate('/Segue2/Block | /Segue2/NavBlock');
             $allowedString = "Content Block or Page";
             $destString = "Page Organizer";
             break;
         default:
             throw new InvalidArgumentException("Importing under " . $organizer->getComponentClass() . " site components is not currently supported.");
     }
     if ($elements->length !== 1) {
         throw new Exception("Import source has " . $elements->length . " " . $allowedString . " elements. There must be one and only one for importing under a " . $destString . ".");
     }
     $element = $elements->item(0);
     $newComponent = $this->createComponent($element, $organizer);
     try {
         // give the editor role on the new component
         $roleMgr = SegueRoleManager::instance();
         $editorRole = $roleMgr->getRole('editor');
         $editorRole->applyToUser($newComponent->getQualifierId(), true);
         $this->importComponent($element, $newComponent);
         $this->updateMenuTargets();
         $this->updateStoredIds();
         // In case the editor role got removed from the user or they just had author, add it.
         $editorRole->applyToUser($newComponent->getQualifierId(), true);
     } catch (Exception $e) {
         // Ensure that we don't have a partially created site floating out there.
         $this->director->deleteSiteComponent($newComponent);
         throw $e;
     }
     return $newComponent;
 }