Beispiel #1
0
 function buildContent()
 {
     $harmoni = Harmoni::Instance();
     $basket = Basket::instance();
     $basket->removeAllItems();
     RequestContext::locationHeader($harmoni->request->quickURL("basket", "view"));
 }
Beispiel #2
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 5/5/06
  */
 function execute()
 {
     $harmoni = Harmoni::Instance();
     $basket = Basket::instance();
     $basket->removeAllItems();
     print $basket->getSmallBasketHtml();
     exit;
 }
Beispiel #3
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("basket");
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $basket = Basket::instance();
     $assetId = $idManager->getId(RequestContext::value("asset_id"));
     $basket->moveUp($assetId);
     $harmoni->request->endNamespace();
     RequestContext::locationHeader($harmoni->request->quickURL("basket", "view"));
 }
 /**
  * Answer the assets to display in the slideshow
  * 
  * @return object AssetIterator
  * @access public
  * @since 5/4/06
  */
 function getAssets()
 {
     $assets = array();
     $repositoryManager = Services::getService("Repository");
     $basket = Basket::instance();
     $basket->clean();
     $basket->reset();
     while ($basket->hasNext()) {
         $assets[] = $repositoryManager->getAsset($basket->next());
     }
     $iterator = new HarmoniIterator($assets);
     return $iterator;
 }
 /**
  * Tells the wizard component to update itself - this may include getting
  * form post data or validation - whatever this particular component wants to
  * do every pageload. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return boolean - TRUE if everything is OK
  */
 function update($fieldName)
 {
     $idManager = Services::getService("Id");
     $ok = parent::update($fieldName);
     // then, check if any "buttons" or anything were pressed to add/remove elements
     $this->_addFromBasketButton->update($fieldName . "_addfrombasket");
     if ($this->_addFromBasketButton->getAllValues()) {
         $basket = Basket::instance();
         $basket->reset();
         while ($basket->hasNext()) {
             $assetId = $basket->next();
             $element =& $this->_addElement();
             $element['_assetId'] = new AssetComponent();
             $element['_assetId']->setParent($this);
             $element['_assetId']->setValue($assetId);
         }
         $basket->removeAllItems();
         $this->rebuildPositionSelects();
     }
     return $ok;
 }
Beispiel #6
0
 /**
  * Check Authorizations
  * 
  * @return boolean
  * @access public
  * @since 9/27/05
  */
 function isAuthorizedToExecute()
 {
     $harmoni = Harmoni::instance();
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $basket = Basket::instance();
     $basket->reset();
     $view = $idManager->getId("edu.middlebury.authorization.view");
     $this->_exportList = array();
     while ($basket->hasNext()) {
         $id = $basket->next();
         if ($authZ->isUserAuthorized($view, $id)) {
             $this->_exportList[] = $id;
         }
     }
     if (count($this->_exportList) > 0) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #7
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("basket");
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $basket = Basket::instance();
     $viewAZ = $idManager->getId("edu.middlebury.authorization.view");
     $assetIdList = RequestContext::value("assets");
     $assetIdArray = explode(",", trim($assetIdList));
     foreach ($assetIdArray as $id) {
         $assetId = $idManager->getId($id);
         try {
             if ($authZ->isUserAuthorized($viewAZ, $assetId)) {
                 $basket->addItem($assetId);
             }
         } catch (UnknownIdException $e) {
             $basket->addItem($assetId);
         }
     }
     $harmoni->request->endNamespace();
     $harmoni->history->goBack("polyphony/basket");
 }
Beispiel #8
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("basket");
     $idManager = Services::getService("Id");
     $authZ = Services::getService("AuthZ");
     $basket = Basket::instance();
     $viewAZ = $idManager->getId("edu.middlebury.authorization.view");
     $assetIdList = RequestContext::value("assets");
     $assetIdArray = explode(",", trim($assetIdList));
     foreach ($assetIdArray as $id) {
         $assetId = $idManager->getId($id);
         try {
             if ($authZ->isUserAuthorized($viewAZ, $assetId)) {
                 $basket->addItem($assetId);
             }
         } catch (UnknownIdException $e) {
             $basket->addItem($assetId);
         }
     }
     $harmoni->request->endNamespace();
     print $basket->getSmallBasketHtml();
     exit;
 }
Beispiel #9
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  * @since 4/25/05
  */
 function execute()
 {
     $xLayout = new XLayout();
     $yLayout = new YLayout();
     $harmoni = Harmoni::instance();
     $mainScreen = new Container($yLayout, BLOCK, 1);
     // :: Top Row ::
     // The top row for the logo and status bar.
     $headRow = new Container($xLayout, HEADER, 1);
     // The logo
     $logo = new Component("\n<a href='" . MYPATH . "/'> <img src='" . LOGO_URL . "' \n\t\t\t\t\t\t\tstyle='border: 0px;' alt='" . _("Concerto Logo'") . "/> </a>", BLANK, 1);
     $headRow->add($logo, null, null, LEFT, TOP);
     // Language Bar
     $harmoni->history->markReturnURL("polyphony/language/change");
     $languageText = "\n<form action='" . $harmoni->request->quickURL("language", "change") . "' method='post'>";
     $harmoni->request->startNamespace("polyphony");
     $languageText .= "\n\t<div style='text-align: center'>\n\t<select name='" . $harmoni->request->getName("language") . "'>";
     $harmoni->request->endNamespace();
     $langLoc = Services::getService('Lang');
     $currentCode = $langLoc->getLanguage();
     $languages = $langLoc->getLanguages();
     ksort($languages);
     foreach ($languages as $code => $language) {
         $languageText .= "\n\t\t<option value='" . $code . "'" . ($code == $currentCode ? " selected='selected'" : "") . ">";
         $languageText .= $language . "</option>";
     }
     $languageText .= "\n\t</select>";
     $languageText .= "\n\t<input type='submit' />";
     $languageText .= "\n\t</div>\n</form>";
     $languageBar = new Component($languageText, BLANK, 1);
     $headRow->add($languageBar, null, null, LEFT, TOP);
     // Pretty Login Box
     $loginRow = new Container($yLayout, OTHER, 1);
     $headRow->add($loginRow, null, null, RIGHT, TOP);
     ob_start();
     $authN = Services::getService("AuthN");
     $agentM = Services::getService("Agent");
     $idM = Services::getService("Id");
     $authTypes = $authN->getAuthenticationTypes();
     $users = '';
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         $id = $authN->getUserId($authType);
         if (!$id->isEqual($idM->getId('edu.middlebury.agents.anonymous'))) {
             $agent = $agentM->getAgent($id);
             $exists = false;
             foreach (explode("+", $users) as $user) {
                 if ($agent->getDisplayName() == $user) {
                     $exists = true;
                 }
             }
             if (!$exists) {
                 if ($users == '') {
                     $users .= $agent->getDisplayName();
                 } else {
                     $users .= " + " . $agent->getDisplayName();
                 }
             }
         }
     }
     if ($users != '') {
         print "\n<div style='text-align: right'><small>";
         if (count(explode("+", $users)) == 1) {
             print _("User: "******"\t";
         } else {
             print _("Users: ") . $users . "\t";
         }
         print "<a href='" . $harmoni->request->quickURL("auth", "logout") . "'>" . _("Log Out") . "</a></small></div>";
     } else {
         // set bookmarks for success and failure
         $harmoni->history->markReturnURL("polyphony/display_login");
         $harmoni->history->markReturnURL("polyphony/login_fail", $harmoni->request->quickURL("user", "main"));
         $harmoni->request->startNamespace("harmoni-authentication");
         $usernameField = $harmoni->request->getName("username");
         $passwordField = $harmoni->request->getName("password");
         $harmoni->request->endNamespace();
         $harmoni->request->startNamespace("polyphony");
         print "\n<div style='text-align: right'>" . "\n<form action='" . $harmoni->request->quickURL("auth", "login") . "' align='right' method='post'><small>" . "\n\t" . _("Username:"******" <input type='text' size='8' \n\t\t\t\t\tname='{$usernameField}'/>" . "\n\t" . _("Password:"******" <input type='password' size ='8' \n\t\t\t\t\tname='{$passwordField}'/>" . "\n\t <input type='submit' value='Log In' />" . "\n</small></form></div>\n";
         $harmoni->request->endNamespace();
     }
     $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, TOP);
     // User tools
     ob_start();
     print "<div style='font-size: small; margin-top: 8px;'>";
     print "<a href='" . $harmoni->request->quickURL("user", "main") . "'>";
     print _("User Tools");
     print "</a>";
     print " | ";
     print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'>";
     print _("Admin Tools");
     print "</a>";
     print "</div>";
     $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, BOTTOM);
     //Add the headerRow to the mainScreen
     $mainScreen->add($headRow, "100%", null, LEFT, TOP);
     // :: Center Pane ::
     $centerPane = $mainScreen->add(new Container($xLayout, OTHER, 1), "100%", null, LEFT, TOP);
     // use the result from previous actions
     if ($harmoni->printedResult) {
         $contentDestination = new Container($yLayout, OTHER, 1);
         $centerPane->add($contentDestination, null, null, LEFT, TOP);
         $contentDestination->add(new Block($harmoni->printedResult, 1), null, null, TOP, CENTER);
         $harmoni->printedResult = '';
     } else {
         $contentDestination = $centerPane;
     }
     // use the result from previous actions
     if (is_object($harmoni->result)) {
         $contentDestination->add($harmoni->result, null, null, CENTER, TOP);
     } else {
         if (is_string($harmoni->result)) {
             $contentDestination->add(new Block($harmoni->result, STANDARD_BLOCK), null, null, CENTER, TOP);
         }
     }
     // Menu Column
     $menuColumn = $centerPane->add(new Container($yLayout, OTHER, 1), "140px", null, LEFT, TOP);
     // Main menu
     $menuGenerator = new ConcertoMenuGenerator();
     $menuColumn->add($menuGenerator->generateMainMenu(), "140px", null, LEFT, TOP);
     // RSS Links
     $outputHandler = $harmoni->getOutputHandler();
     if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction()) && RequestContext::value('collection_id')) {
         ob_start();
         print "<div style='font-size: small; padding-left: 5px;'>";
         $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id')));
         $title = _("RSS feed of the most recently added Assets");
         $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>");
         print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>";
         print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>";
         print "\n\t\t\t" . _("RSS: newest");
         print "\n\t\t</a><br/>";
         $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'), 'order' => 'modification'));
         $title = _("RSS feed of the most recently changed Assets");
         $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>");
         print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>";
         print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>";
         print "\n\t\t\t" . _("RSS: recently updated");
         print "\n\t\t</a>";
         print "\n</div>";
         $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP);
     }
     /*		if (preg_match("/^collections\..+$/", $harmoni->getCurrentAction())) {
     			ob_start();
     			print "<div style='font-size: small; padding-left: 5px;'>";
     			
     			$url = $harmoni->request->quickURL('collection', 'rss_all_latest');
     			$title = _("RSS feed of the most recently added Assets across all Collections");
     			
     			$outputHandler->setHead($outputHandler->getHead()
     				."\n\t\t<link rel='alternate' type='application/rss+xml'"
     				." title='".$title."' href='".$url."'/>");
     			print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>";
     			print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>";
     			print "\n\t\t\t"._("RSS: all newest");
     			print "\n\t\t</a><br/>";
     			
     			
     			$url = $harmoni->request->quickURL('collections', 'rss_all_latest', 
     				array('order' => 'modification'));
     			$title = _("RSS feed of the most recently changed Assets across all Collections");
     			
     			$outputHandler->setHead($outputHandler->getHead()
     				."\n\t\t<link rel='alternate' type='application/rss+xml'"
     				." title='".$title."' href='".$url."'/>");
     			print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>";
     			print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>";
     			print "\n\t\t\t"._("RSS: all recently updated");
     			print "\n\t\t</a>";
     			print "\n</div>";
     			$menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP);
     		}
     */
     if (preg_match("/^exhibitions\\.browse_exhibition\$/", $harmoni->getCurrentAction()) && RequestContext::value('exhibition_id')) {
         ob_start();
         print "<div style='font-size: small; padding-left: 5px;'>";
         $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('exhibition_id' => RequestContext::value('exhibition_id')));
         $title = _("RSS feed of the most recently added Slideshows in this Exhibition");
         $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>");
         print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>";
         print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>";
         print "\n\t\t\t" . _("RSS: newest");
         print "\n\t\t</a><br/>";
         $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification', 'exhibition_id' => RequestContext::value('exhibition_id')));
         $title = _("RSS feed of the most recently changed Slideshows in this Exhibition");
         $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>");
         print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>";
         print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>";
         print "\n\t\t\t" . _("RSS: recently updated");
         print "\n\t\t</a>";
         print "\n</div>";
         $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP);
     }
     /*		if (preg_match("/^exhibitions\.browse$/", $harmoni->getCurrentAction())) {
     			ob_start();
     			print "<div style='font-size: small; padding-left: 5px;'>";
     			
     			$url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows');
     			$title = _("RSS feed of the most recently added Slideshows across all Exhibitions");
     			
     			$outputHandler->setHead($outputHandler->getHead()
     				."\n\t\t<link rel='alternate' type='application/rss+xml'"
     				." title='".$title."' href='".$url."'/>");
     			print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>";
     			print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>";
     			print "\n\t\t\t"._("RSS: all newest");
     			print "\n\t\t</a><br/>";
     			
     			$url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', 
     				array('order' => 'modification'));
     			$title = _("RSS feed of the most recently changed Slideshows across all Exhibitions");
     			
     			$outputHandler->setHead($outputHandler->getHead()
     				."\n\t\t<link rel='alternate' type='application/rss+xml'"
     				." title='".$title."' href='".$url."'/>");
     			print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>";
     			print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>";
     			print "\n\t\t\t"._("RSS: all recently updated");
     			print "\n\t\t</a>";
     			print "\n</div>";
     			$menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP);
     		}
     */
     // Basket
     $basket = Basket::instance();
     if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction())) {
         $menuColumn->add(AssetPrinter::getMultiEditOptionsBlock(), "100%", null, LEFT, TOP);
     }
     $menuColumn->add($basket->getSmallBasketBlock(EMPHASIZED_BLOCK), "100%", null, LEFT, TOP);
     // Collection Tags
     if (preg_match("/^(collection|asset|tags)\\./", $harmoni->getCurrentAction()) && $this->getCurrentRepository()) {
         $harmoni->request->passthrough("collection_id");
         $harmoni->request->passthrough("asset_id");
         $menuColumn->add(new Block("<strong>" . _("Tags in this Collection: ") . "</strong>" . TagAction::getTagCloudForRepository($this->getCurrentRepository(), 'concerto'), EMPHASIZED_BLOCK), "100%", null, LEFT, TOP);
         $harmoni->request->forget("collection_id");
         $harmoni->request->forget("asset_id");
     }
     // :: Footer ::
     $footer = new Container(new XLayout(), FOOTER, 1);
     $helpText = "<a target='_blank' href='";
     $helpText .= $harmoni->request->quickURL("help", "browse_help");
     $helpText .= "'>" . _("Help") . "</a>";
     $footer->add(new UnstyledBlock($helpText), "50%", null, LEFT, BOTTOM);
     if (!isset($_SESSION['ConcertoVersion'])) {
         $document = new DOMDocument();
         // attempt to load (parse) the xml file
         if ($document->load(MYDIR . "/doc/raw/changelog/changelog.xml")) {
             $versionElems = $document->getElementsByTagName("version");
             $latest = $versionElems->item(0);
             $_SESSION['ConcertoVersion'] = $latest->getAttribute('number');
             if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $latest->getAttribute('date'), $matches)) {
                 $_SESSION['ConcertoCopyrightYear'] = $matches[1];
             } else {
                 $_SESSION['ConcertoCopyrightYear'] = $latest->getAttribute('date');
             }
         } else {
             $_SESSION['ConcertoVersion'] = "2.x.x";
             $_SESSION['ConcertoCopyrightYear'] = "2006";
         }
     }
     $footerText = "<a href='" . $harmoni->request->quickURL('window', 'changelog') . "' target='_blank'>Concerto v." . $_SESSION['ConcertoVersion'] . "</a> &nbsp; &nbsp; &nbsp; ";
     $footerText .= "&copy;" . $_SESSION['ConcertoCopyrightYear'] . " Middlebury College  &nbsp; &nbsp; &nbsp; <a href='http://concerto.sourceforge.net'>";
     $footerText .= _("about");
     $footerText .= "</a>";
     $footer->add(new UnstyledBlock($footerText), "50%", null, RIGHT, BOTTOM);
     $mainScreen->add($footer, "100%", null, RIGHT, BOTTOM);
     return $mainScreen;
 }
 /**
  * Print links for the various functions that are possible to do with this
  * Asset.
  * 
  * @param object Asset $asset The Asset to print the links for.
  * @return void
  * @access public
  * @date 8/6/04
  * @static
  */
 static function printAssetFunctionLinks($harmoni, $asset, $repositoryId = NULL, $assetNum = 0, $includeEditDelete = true)
 {
     $actionString = $harmoni->getCurrentAction();
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $assetId = $asset->getId();
     $repository = $asset->getRepository();
     $repositoryId = $repository->getId();
     $links = array();
     /*********************************************************
      * Parameters to pass on through our links
      *********************************************************/
     $params = self::getUrlParams($asset);
     // Authorization Icon
     print AuthZPrinter::getAZIcon($assetId);
     print " &nbsp; ";
     //===== View Links =====/
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         //===== Viewer Link =====//
         // Add the options panel script to the header
         // Add the options panel script to the header
         if (!defined('ASSET_PANEL_LOADED')) {
             $outputHandler = $harmoni->getOutputHandler();
             $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . MYPATH . "/javascript/AssetOptionsPanel.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . MYPATH . "/javascript/AssetOptionsPanel.css' />");
             define('ASSET_PANEL_LOADED', true);
         }
         ob_start();
         print "<a href='#' onclick=\"Javascript:AssetOptionsPanel.run('" . $repositoryId->getIdString() . "', '" . $assetId->getIdString() . "', this, [";
         $toShow = array();
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $toShow[] = "'view'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             try {
                 $children = $asset->getAssets();
                 if ($children->hasNext()) {
                     if ($actionString != "asset.browse" || $assetId->getIdString() != $harmoni->request->get('asset_id')) {
                         $toShow[] = "'browse'";
                     }
                 }
             } catch (Exception $e) {
             }
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $harmoni->history->markReturnURL("concerto/asset/edit-return");
             $toShow[] = "'edit'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             // If we are viewing the asset and we delete it, we can't return
             // to viewing it.
             if (preg_match("/^asset\\..*\$/", $actionString) && $harmoni->request->get("asset_id") == $assetId->getIdString()) {
                 $deleteParams = $params;
                 unset($deleteParams['asset_id']);
                 $harmoni->history->markReturnURL("concerto/asset/delete-return", $harmoni->request->mkURL('collection', 'browse', $deleteParams));
             } else {
                 $harmoni->history->markReturnURL("concerto/asset/delete-return", $harmoni->request->mkURL(null, null, $params));
             }
             $toShow[] = "'delete'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $toShow[] = "'add_children'";
         }
         print implode(", ", $toShow);
         print "], '" . self::getSlideshowLink($asset, $assetNum) . "'); return false;\">" . _("Options...") . "</a> ";
         $links[] = ob_get_clean();
         //===== Details Link =====//
         // 			if ($actionString != "asset.view") {
         // 				$links[] = "<a href='".$harmoni->request->quickURL(
         // 					"asset", "view",
         // 					array("collection_id" => $repositoryId->getIdString(),
         // 					"asset_id" => $assetId->getIdString()))."'>";
         // 				$links[count($links) - 1] .= _("Details")."</a>";
         // 			} else
         // 				$links[] = _("Details");
         //===== Export Link =====//
         // 			if (preg_match("/^asset\..*$/", $actionString) &&
         // 					$harmoni->request->get("asset_id") ==
         // 					$assetId->getIdString()) {
         // 				$harmoni->request->startNamespace('export');
         // 				$links[] = "<a href='".$harmoni->request->quickURL(
         // 					"asset", "export",
         // 					array("collection_id" => $repositoryId->getIdString(),
         // 					"asset_id" => $assetId->getIdString()))."'>";
         // 				$links[count($links) - 1] .= _("Export")."</a>";
         // 				$harmoni->request->endNamespace();
         // 			}
     }
     //===== Browse Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         try {
             $children = $asset->getAssets();
             if ($children->hasNext()) {
                 if ($actionString != "asset.browse" || $assetId->getIdString() != $harmoni->request->get('asset_id')) {
                     $links[] = "<a href='" . $harmoni->request->quickURL("asset", "browseAsset", array("collection_id" => $repositoryId->getIdString(), "asset_id" => $assetId->getIdString())) . "'>";
                     $links[count($links) - 1] .= _("Browse") . "</a>";
                 } else {
                     $links[] = _("Browse");
                 }
             }
         } catch (UnimplementedException $e) {
             //
         }
     }
     //===== Edit Link =====//
     // 		$harmoni->history->markReturnURL("concerto/asset/edit-return",
     // 			$harmoni->request->mkURL(null, null, $params));
     //
     // 		if ($includeEditDelete) {
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.modify"),
     // 					$assetId)) {
     // 				if ($actionString != "asset.edit") {
     // 					$links[] = "<a href='".$harmoni->request->quickURL(
     // 						"asset", "edit",
     // 						array("collection_id" => $repositoryId->getIdString(),
     // 						"assets" => $assetId->getIdString()))."'>";
     // 					$links[count($links) - 1] .= _("Edit")."</a>";
     // 				} else
     // 					$links[] = _("Edit");
     // 			}
     //===== Delete Link =====//
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.delete"),
     // 					$assetId))
     // 			{
     // 				// If we are viewing the asset and we delete it, we can't return
     // 				// to viewing it.
     // 				if (preg_match("/^asset\..*$/", $actionString) &&
     // 						$harmoni->request->get("asset_id") ==
     // 						$assetId->getIdString())
     // 				{
     // 					$deleteParams = $params;
     // 					unset ($deleteParams['asset_id']);
     // 					$harmoni->history->markReturnURL("concerto/asset/delete-return",
     // 						$harmoni->request->mkURL('collection', 'browse', $deleteParams));
     // 				}
     // 				// otherwise, go bact to where we are.
     // 				else {
     // 					$harmoni->history->markReturnURL("concerto/asset/delete-return",
     // 						$harmoni->request->mkURL(null, null, $params));
     // 				}
     // 				ob_start();
     // 				print "<a href='Javascript:deleteAsset(\"".$assetId->getIdString().
     // 					"\", \"".$repositoryId->getIdString()."\", \"".
     // 					$harmoni->request->quickURL("asset", "delete",
     // 					array("collection_id" => $repositoryId->getIdString(),
     // 					"asset_id" => $assetId->getIdString()))."\");'>";
     // 				print _("Delete")."</a>";
     // 				$links[] = ob_get_contents();
     // 				ob_end_clean();
     //
     // 				print "\n<script type='text/javascript'>\n//<![CDATA[";
     // 				print "\n	function deleteAsset(assetId, repositoryId, url) {";
     // 				print "\n		if (confirm(\""._("Are you sure you want to delete this Asset?")."\")) {";
     // 				print "\n			window.location = url;";
     // 				print "\n		}";
     // 				print "\n	}";
     // 				print "\n//]]>\n</script>\n";
     // 			}
     //===== Add Child Asset Link =====//
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.add_children"),
     // 					$assetId)) {
     // 				if (preg_match("/^asset\..*$/", $actionString) &&
     // 						$harmoni->request->get("asset_id") ==
     // 						$assetId->getIdString()) {
     // 					$links[] = "<a href='".$harmoni->request->quickURL(
     // 						"asset", "add",
     // 						array("collection_id" => $repositoryId->getIdString(),
     // 						"parent" => $assetId->getIdString()))."'>";
     // 					$links[count($links) - 1] .= _("Add Child <em>Asset</em>").
     // 						"</a>";
     // 		//===== Import Link =====//
     // 	// 				$harmoni->request->startNamespace("import");
     // 	// 				$links[] = "<a href='".$harmoni->request->quickURL(
     // 	// 					"asset", "import",
     // 	// 					array("collection_id" => $repositoryId->getIdString(),
     // 	// 					"asset_id" => $assetId->getIdString()))."'>".
     // 	// 					_("Import Child <em>Asset(s)</em>")."</a>";
     // 	// 				$harmoni->request->endNamespace();
     // 				}
     // 			}
     // 		}
     //===== Basket Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         $basket = Basket::instance();
         $links[] = $basket->getAddLink($assetId);
     }
     print implode("\n\t | ", $links);
 }
Beispiel #11
0
 public static function canView($assetId)
 {
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     try {
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId)) {
             return TRUE;
         } else {
             $basket = Basket::instance();
             $basket->removeItem($assetId);
             return FALSE;
         }
     } catch (UnknownIdException $e) {
         return true;
     }
 }