/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $idManager = Services::getService("Id"); $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-authorizations"); $actionRows->add(new Block(" " . _("Below is a listing of all of the Users/Groups who are authorized to do various functions in the system. Click on a name to edit the authorizations for that User/Group") . "<br /><br />", STANDARD_BLOCK)); // Buttons to go back to edit auths for a different user, or to go home ob_start(); print "<table width='100%'><tr><td align='left'>"; print "</td><td align='right'>"; print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'><button>" . _("Return to the Admin Tools") . "</button></a>"; print "</td></tr></table>"; $nav = new Block(ob_get_contents(), STANDARD_BLOCK); $actionRows->add($nav, "100%", null, LEFT, CENTER); ob_end_clean(); // Get all hierarchies and their root qualifiers $authZManager = Services::getService("AuthorizationManager"); $hierarchyIds = $authZManager->getQualifierHierarchies(); $hierarchyManager = Services::getService("Hierarchy"); while ($hierarchyIds->hasNext()) { $hierarchyId = $hierarchyIds->next(); $hierarchy = $hierarchyManager->getHierarchy($hierarchyId); $header = new Heading($hierarchy->getDisplayName() . " - <em>" . $hierarchy->getDescription() . "</em>", 2); $actionRows->add($header, "100%", null, LEFT, CENTER); // Get the root qualifiers for the Hierarchy $qualifiers = $authZManager->getRootQualifiers($hierarchyId); while ($qualifiers->hasNext()) { $qualifier = $qualifiers->next(); //print get_class($qualifier); // Create a layout for this qualifier if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $qualifier->getId())) { ob_start(); HierarchyPrinter::printNode($qualifier, $harmoni, 2, array($this, "printQualifier"), array($this, "hasChildQualifiers"), array($this, "getChildQualifiers"), new HTMLColor("#ddd")); $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); } } } // Buttons to go back to edit auths for a different user, or to go home $actionRows->add($nav, "100%", null, LEFT, CENTER); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); }
/** * Print a node and the expanded children * * @param object $node * @param string $printFunction Function that prints the current node's info. * @param string $hasChildrenFunction Function that returns true if the node * has children. * @param string $getChildrenFunction Function that returns an array of the * children of this node. * @return void * @access public * @since 11/8/04 */ public static function printNode($node, $harmoni, $startingPathInfoKey, $printFunction, $hasChildrenFunction, $getChildrenFunction, $color = NULL) { print "\n<div"; if ($color !== NULL) { print " style='"; // print " border: 1px solid #000;"; print " padding-top: 5px; padding-left: 5px; padding-bottom: 10px;"; print " background-color: " . $color->getHTMLcolor() . ";'"; } print ">"; // Get a string of our nodeIds $nodeId = $node->getId(); // Break the path info into parts for the enviroment and parts that // designate which nodes to expand. $expandedNodes = explode("!", $harmoni->request->get('expanded_nodes')); print "\n\n<table>\n\t<tr><td valign='top'>"; // Print The node $hasChildren = call_user_func_array($hasChildrenFunction, array($node)); if ($hasChildren) { ?> <div style=' border: 1px solid #000; width: 15px; height: 15px; text-align: center; text-decoration: none; font-weight: bold; '> <?php /** * @package polyphony.library. */ // The child nodes are already expanded for this node. // Show option to collapse the list. if (in_array($nodeId->getIdString(), $expandedNodes)) { $newExpandedNodes = array_diff($expandedNodes, array($nodeId->getIdString())); $symbol = '-'; $expanded = TRUE; // The node is not already expanded. Show option to expand. } else { $newExpandedNodes = array_merge($expandedNodes, array($nodeId->getIdString())); $symbol = '+'; $expanded = FALSE; } $url = $harmoni->request->mkURLWithPassthrough(); $url->setValue('expanded_nodes', implode('!', $newExpandedNodes)); print "<a style='text-decoration: none;' href='" . $url->write() . "'>" . $symbol . "</a>"; print "\n\t\t</div>"; // Make a vertical line to connect to the line in front of the children if ($expanded) { print <<<END \t\t<div style=' \t\t\t\theight: 100%; \t\t\t\tborder-left: 1px #000 solid; \t\t\t\tmargin-left: 10px; \t\t\t\tmargin-right: 0px; \t\t\t\tmargin-top:0px; \t\t'> </div> END; } // The node has no children. Do not show options to expand/collapse. } else { print "\n\t\t<div style='width: 15px;'> </div>"; } print "\n\t</td><td valign='top'>\n\t\t"; call_user_func_array($printFunction, array($node)); print "\n\t</td></tr>\n</table>"; // Recursively print the children. if (in_array($nodeId->getIdString(), $expandedNodes)) { print <<<END <div style=' \tmargin-left: 13px; \tmargin-right: 0px; \tmargin-top:0px; \tpadding-left: 10px; \tborder-left: 1px solid #000; END; print "'>"; if ($color !== NULL) { $childColor = $color->replicate(); $childColor->darken(20); } else { $childColor = NULL; } $children = call_user_func_array($getChildrenFunction, array($node)); foreach ($children as $child) { HierarchyPrinter::printNode($child, $harmoni, $startingPathInfoKey, $printFunction, $hasChildrenFunction, $getChildrenFunction, $childColor); } print "\n</div>"; } print "\n</div>"; }