예제 #1
0
파일: demo.php 프로젝트: echoOly/jomo
<?php

require 'Timer.class.php';
$timer = new Timer();
$timer->start();
$timer->start('program1');
usleep(mt_rand(100000, 500000));
$timer->end('program1');
$timer->printTime('program1');
$timer->start('program2');
usleep(mt_rand(100000, 500000));
$timer->end('program2');
$timer->printTime('program2');
$timer->end();
$timer->printTime();
예제 #2
0
파일: test.php 프로젝트: adamfranco/harmoni
/*		require_once(CONCERTO.'/tests/dbconnect.inc.php'); */
/*	} */
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
$errorHandler = Services::getService("ErrorHandler");
$context = new OsidContext();
$configuration = new ConfigurationProperties();
Services::startManagerAsService("DatabaseManager", $context, $configuration);
$test = new GroupTest('CourseManagementTest');
$test->addTestFile(dirname(__FILE__) . '/CanonicalCourseTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseGroupTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseOfferingTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/TermTest.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseSectionTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/EnrollmentRecordTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseGradeRecordTest.class.php');
$test->attachObserver(new DoboTestHtmlDisplay());
$test->run();
$timer->end();
print "\n<br />Harmoni Load Time: " . $harmonyLoadupTimer->printTime();
print "\n<br />Overall Time: " . $timer->printTime();
$dbhandler = Services::getService("DBHandler");
printpre("NumQueries: " . $dbhandler->getTotalNumberOfQueries());
print "\n</p>";
// $num = $dbHandler->getTotalNumberOfQueries();
// debug::output("Total # of queries: ".$num,1,"DBHandler");
//debug::printAll();
// unset($dbHandler,$errorHandler, $userError);
// unset($num);
//	$errorHandler->printErrors(HIGH_DETAIL);
//	print "<pre>";
//	print_r($errorHandler);
<?php

include 'dbpedia.php';
error_reporting(E_ALL);
Timer::start("main::Runtime");
// Setup the language version of Wikipedia
$language = Options::getOption('language');
$pageTitles = new AllTemplatesSqlIterator($language);
$job = new ExtractionJob(new DatabaseWikipediaCollection($language), $pageTitles);
$groupInfoboxes = new ExtractionGroup(new NullDestination());
$groupInfoboxes->addExtractor(new TemplateRedirectExtractor());
// Add the ExtractionGroups to the ExtractionJob
$job->addExtractionGroup($groupInfoboxes);
//Execute the Extraction Job
$manager = new ExtractionManager();
$manager->execute($job);
Timer::stop("main::Runtime");
Timer::printTime();
예제 #4
0
 /**
  * Update a record table for a set of harvesters and repositories
  * 
  * @param string $table
  * @param array $allowedRepositoryIdStrings
  * @param array $authGroupIdStrings	The ids of the groups to check view authorization for,
  *	May be one of the following or another group Id string:
  *		edu.middlebury.agents.everyone
  *		edu.middlebury.agents.all_agents
  *	If empty, all assets in the specified repositories will be added regardless of
  *	their visibility.
  *
  * @return void
  * @access public
  * @since 3/9/07
  */
 function updateTable($table, $allowedRepositoryIdStrings, $authGroupIdStrings)
 {
     ArgumentValidator::validate($table, StringValidatorRule::getRule());
     ArgumentValidator::validate($allowedRepositoryIdStrings, ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     ArgumentValidator::validate($authGroupIdStrings, ArrayValidatorRuleWithRule::getRule(StringValidatorRule::getRule()));
     $harmoni = Harmoni::instance();
     $config = $harmoni->getAttachedData('OAI_CONFIG');
     $repositoryManager = Services::getService('Repository');
     $authorizationManager = Services::getService('AuthZ');
     $idManager = Services::getService("IdManager");
     $dbc = Services::getService("DatabaseManager");
     $authGroupIds = array();
     foreach ($authGroupIdStrings as $id) {
         $authGroupIds[] = $idManager->getId($id);
     }
     $baseCheckQuery = new SelectQuery();
     $baseCheckQuery->addTable('oai_' . $table);
     $baseCheckQuery->addColumn('datestamp');
     $baseCheckQuery->addColumn('deleted');
     $baseUpdateQuery = new UpdateQuery();
     $baseUpdateQuery->setTable('oai_' . $table);
     $baseUpdateColumns = array('datestamp', 'deleted', 'oai_set', 'dc_title', 'dc_description');
     $dcUpdateColumns = array('datestamp', 'deleted', 'oai_set', 'dc_title', 'dc_description', 'dc_creator', 'dc_subject', 'dc_contributor', 'dc_publisher', 'dc_date', 'dc_type', 'dc_format', 'dc_identifier', 'dc_source', 'dc_language', 'dc_relation', 'dc_coverage', 'dc_rights');
     $baseInsertQuery = new InsertQuery();
     $baseInsertQuery->setTable('oai_' . $table);
     $baseInsertColumns = array('datestamp', 'oai_identifier', 'deleted', 'oai_set', 'dc_title', 'dc_description');
     $dcInsertColumns = array('datestamp', 'oai_identifier', 'deleted', 'oai_set', 'dc_title', 'dc_description', 'dc_creator', 'dc_subject', 'dc_contributor', 'dc_publisher', 'dc_date', 'dc_type', 'dc_format', 'dc_identifier', 'dc_source', 'dc_language', 'dc_relation', 'dc_coverage', 'dc_rights');
     $baseDeleteQuery = new UpdateQuery();
     $baseDeleteQuery->setTable('oai_' . $table);
     $baseDeleteQuery->addValue('deleted', 'true');
     $baseDeleteQuery->addRawValue('datestamp', 'NOW()');
     $baseUndeleteQuery = new UpdateQuery();
     $baseUndeleteQuery->setTable('oai_' . $table);
     $baseUndeleteQuery->addValue('deleted', 'false');
     $baseUndeleteQuery->addRawValue('datestamp', 'NOW()');
     $forceUpdate = false;
     $repositories = $repositoryManager->getRepositories();
     $r = 0;
     if (count($allowedRepositoryIdStrings)) {
         $numR = count($allowedRepositoryIdStrings);
     } else {
         $numR = $repositories->count();
     }
     $numUpdates = 0;
     $numDeleted = 0;
     $message = _('Updating OAI records for repository (%1 of %2) : ');
     $message = str_replace('%2', $numR, $message);
     $instituteId = $idManager->getId('edu.middlebury.agents.users');
     $viewId = $idManager->getId('edu.middlebury.authorization.view');
     require_once HARMONI . "/utilities/Timer.class.php";
     $timer = new Timer();
     $timer->start();
     $existingRepositoryIds = array();
     while ($repositories->hasNext()) {
         $updatesInRepository = 0;
         $repository = $repositories->next();
         $repositoryId = $repository->getId();
         // Only work with allowed repositories
         if (count($allowedRepositoryIdStrings) && !in_array($repositoryId->getIdString(), $allowedRepositoryIdStrings)) {
             continue;
         }
         $r++;
         $existingRepositoryIds[] = $repositoryId->getIdString();
         $assets = $repository->getAssets();
         $status = new CLIStatusStars(str_replace('%1', $r, $message) . $repository->getDisplayName());
         $status->initializeStatistics($assets->count());
         $existingAssetIds = array();
         while ($assets->hasNext()) {
             $asset = $assets->next();
             $assetId = $asset->getId();
             $existingAssetIds[] = $assetId->getIdString();
             try {
                 $modificationDate = $asset->getModificationDate();
             } catch (UnimplementedException $e) {
                 $modificationDate = DateAndTime::now();
             }
             $query = $baseCheckQuery->copy();
             $query->addWhereEqual("oai_set", $repositoryId->getIdString());
             $query->addWhereEqual("oai_identifier", $assetId->getIdString());
             $result = $dbc->query($query, $config->getProperty('OAI_DBID'));
             if (!$result->getNumberOfRows()) {
                 // 					printpre("Doesn't exist:\t".$asset->getDisplayName()."");
                 $query = $baseInsertQuery->copy();
                 $query->addValue('oai_set', $repositoryId->getIdString());
                 $query->addValue('oai_identifier', $assetId->getIdString());
             } else {
                 // 					printpre("Exists:\t".$asset->getDisplayName()."");
                 if ($modificationDate->isGreaterThan(DateAndTime::fromString($result->field('datestamp'))) || $forceUpdate) {
                     // 						printpre("\tUpdating:\t".$asset->getDisplayName());
                     $query = $baseUpdateQuery->copy();
                     $query->addWhereEqual("oai_set", $repositoryId->getIdString());
                     $query->addWhereEqual("oai_identifier", $assetId->getIdString());
                 } else {
                     $query = null;
                 }
             }
             if ($query) {
                 $query->addRawValue('datestamp', 'NOW()');
             }
             $isCurrentlyDeleted = $result->getNumberOfRows() && $result->field('deleted') == 'true' ? true : false;
             $result->free();
             if (!count($authGroupIds)) {
                 $isVisible = true;
             } else {
                 $isVisible = false;
                 try {
                     foreach ($authGroupIds as $id) {
                         if ($authorizationManager->isAuthorized($id, $viewId, $assetId)) {
                             $isVisible = true;
                             break;
                         }
                     }
                 } catch (UnknownIdException $e) {
                     $isVisible = true;
                 }
             }
             if ($query) {
                 //Add the data fields
                 // Deleted
                 if ($isVisible) {
                     $query->addValue('deleted', 'false');
                 } else {
                     $query->addValue('deleted', 'true');
                 }
                 $query->addValue('dc_title', $asset->getDisplayName());
                 $query->addValue('dc_description', $asset->getDescription());
                 $this->addDublinCoreValues($asset, $query);
                 $dbc->query($query, $config->getProperty('OAI_DBID'));
                 $updatesInRepository++;
                 $numUpdates++;
             } else {
                 if ($isCurrentlyDeleted && $isVisible) {
                     $query = $baseUndeleteQuery->copy();
                 } else {
                     if (!$isCurrentlyDeleted && !$isVisible) {
                         $query = $baseDeleteQuery->copy();
                     } else {
                         $query = null;
                     }
                 }
                 if ($query) {
                     $query->addWhereEqual("oai_set", $repositoryId->getIdString());
                     $query->addWhereEqual("oai_identifier", $assetId->getIdString());
                     $dbc->query($query, $config->getProperty('OAI_DBID'));
                     $updatesInRepository++;
                     $numUpdates++;
                 }
             }
             $status->updateStatistics();
         }
         // Update any missing assets as deleted
         $query = $baseDeleteQuery->copy();
         $query->addWhereEqual("oai_set", $repositoryId->getIdString());
         if (count($existingAssetIds)) {
             $query->addWhereEqual("deleted", "false");
             $query->addWhereNotIn("oai_identifier", $existingAssetIds);
         }
         $result = $dbc->query($query, $config->getProperty('OAI_DBID'));
         if ($result->getNumberOfRows()) {
             $updatesInRepository = $updatesInRepository + $result->getNumberOfRows();
             $numUpdates = $numUpdates + $result->getNumberOfRows();
         }
         print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
         print "Elapsed Time:\t";
         $timer->end();
         printf("%1.2f", $timer->printTime());
         print " seconds";
         print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "";
         print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
         print "Updates: " . $updatesInRepository;
         print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "\n";
     }
     // Update any missing repositories as deleted
     $query = $baseDeleteQuery->copy();
     $query->addWhereEqual("deleted", "false");
     if (count($existingRepositoryIds)) {
         $query->addWhereNotIn("oai_set", $existingRepositoryIds);
     }
     $result = $dbc->query($query, $config->getProperty('OAI_DBID'));
     if ($result->getNumberOfRows()) {
         $updatesInRepository = $updatesInRepository + $result->getNumberOfRows();
         $numUpdates = $numUpdates + $result->getNumberOfRows();
     }
     print OAI_UPDATE_OUTPUT_HTML ? "<pre>" : "\n";
     print "Total Updates:\t" . $numUpdates;
     print OAI_UPDATE_OUTPUT_HTML ? "</pre>" : "\n";
 }
예제 #5
0
require_once MYDIR . "/main/include/setup.inc.php";
/*********************************************************
 * Execute our actions
 *********************************************************/
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
    require_once HARMONI . "/utilities/Timer.class.php";
    $execTimer = new Timer();
    $execTimer->start();
}
require_once HARMONI . "architecture/output/CommandLineOutputHandler.class.php";
$harmoni->attachOutputHandler(new CommandLineOutputHandler());
require_once HARMONI . "architecture/request/CommandLineRequestHandler.class.php";
$harmoni->request->assignRequestHandler(new CommandLineRequestHandler($_SERVER['argv']));
try {
    $harmoni->execute();
} catch (UnknownActionException $e) {
    print HELP_TEXT;
} catch (HelpRequestedException $e) {
    print $e->getMessage();
}
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
    $execTimer->end();
    print "\n<table>\n<tr><th align='right'>Execution Time:</th>\n<td align='right'><pre>";
    printf("%1.6f", $execTimer->printTime());
    print "</pre></td></tr>\n</table>";
    $dbhandler = Services::getService("DBHandler");
    printpre("NumQueries: " . $dbhandler->getTotalNumberOfQueries());
    // 	printpreArrayExcept($_SESSION, array('__temporarySets'));
    // debug::output(session_id());
    // Debug::printAll();
}
 /**
  * Auxilliary private function that returns Authorizations according to a
  * criteria. Null values are interpreted as wildmarks. Warning: $returnExplicitOnly = false
  * will increase the running time significantly - USE SPARINGLY!
  * @access public
  * @param string aId The string id of an agent.
  * @param string fId The string id of a function.
  * @param string qId The string id of a qualifier. This parameter can not be null
  * and used as a wildmark.
  * @param object fType The type of a function.
  * @param boolean returnExplicitOnly If True, only explicit Authorizations
  *		will be returned.
  * @param boolean searchUp If true, the ancester nodes of the qualifier will
  *		be checked as well
  * @param boolean isActiveNow If True, only active Authorizations will be returned.
  * @return ref object An AuthorizationIterator.
  **/
 function getAZs($aId, $fId, $qId, $fType, $returnExplicitOnly, $searchUp, $isActiveNow, $groupIds = array())
 {
     // 		printpre (func_get_args());
     // ** parameter validation
     $rule = StringValidatorRule::getRule();
     ArgumentValidator::validate($groupIds, ArrayValidatorRuleWithRule::getRule(OptionalRule::getRule($rule)), true);
     ArgumentValidator::validate($aId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($qId, OptionalRule::getRule($rule), true);
     ArgumentValidator::validate($fType, OptionalRule::getRule(ExtendsValidatorRule::getRule("Type")), true);
     ArgumentValidator::validate($returnExplicitOnly, BooleanValidatorRule::getRule(), true);
     ArgumentValidator::validate($isActiveNow, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $idManager = Services::getService("Id");
     // the parameter that influences the result most is $returnExplicitOnly
     // 1) If $returnExplicitOnly is TRUE, then we only need to check for Authorizations
     // that have been explicitly created, i.e. no need to look for inherited
     // authorizations
     // 2) If $returnExplicitOnly is FALSE, then we need to include inherited Authorizations
     // as well.
     // this array will store the ids of all qualifiers to be checked for authorizations
     $qualifiers = array();
     // check all ancestors of given qualifier
     $hierarchyManager = Services::getService("Hierarchy");
     if (isset($qId)) {
         $qualifierId = $idManager->getId($qId);
         $node = $hierarchyManager->getNode($qualifierId);
         $hierarchy = $hierarchyManager->getHierarchyForNode($node);
         if ($searchUp) {
             // these are the ancestor nodes
             $nodes = $hierarchy->traverse($qualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_UP, Hierarchy::TRAVERSE_LEVELS_ALL);
             // now get the id of each node and store in array
             while ($nodes->hasNext()) {
                 $info = $nodes->next();
                 $id = $info->getNodeId();
                 $qualifiers[] = $id->getIdString();
             }
         } else {
             $qualifiers = array($qId);
         }
     }
     //		print_r($qualifiers);
     // setup the query
     $dbHandler = Services::getService("DatabaseManager");
     $query = new SelectQuery();
     $query->addColumn("authorization_id", "id");
     $query->addColumn("fk_agent", "aid");
     $query->addColumn("fk_function", "fid");
     $query->addColumn("fk_qualifier", "qid");
     $query->addColumn("authorization_effective_date", "eff_date");
     $query->addColumn("authorization_expiration_date", "exp_date");
     $query->addTable("az_authorization");
     // now include criteria
     // the qualifiers criteria
     if (isset($qualifiers) && count($qualifiers)) {
         $query->addWhereIn('az_authorization.fk_qualifier', $qualifiers);
     }
     // Agents/Groups
     if (isset($aId)) {
         $agentIds = array($aId);
     } else {
         $agentIds = array();
     }
     $allAgentIds = array_merge($agentIds, $groupIds);
     // the agent criteria
     if (count($allAgentIds)) {
         $query->addWhereIn('az_authorization.fk_agent', $allAgentIds);
     }
     // the function criteria
     if (isset($fId)) {
         $joinc = "az_authorization.fk_function = az_function.function_id";
         $query->addTable("az_function", INNER_JOIN, $joinc);
         $query->addWhereEqual("az_authorization.fk_function", $fId);
     }
     // the function type criteria
     if (isset($fType)) {
         // do not join with az_function if we did already
         if (!isset($fId)) {
             $joinc = "az_authorization.fk_function = az_function.function_id";
             $query->addTable("az_function", INNER_JOIN, $joinc);
         }
         // now join with type
         $joinc = "az_function.fk_type = type.type_id";
         $query->addTable("type", INNER_JOIN, $joinc);
         $query->addWhereEqual("type.type_domain", $fType->getDomain());
         $query->addWhereEqual("type.type_authority", $fType->getAuthority());
         $query->addWhereEqual("type.type_keyword", $fType->getKeyword());
     }
     // the isActiveNow criteria
     if ($isActiveNow) {
         $where = "(authorization_effective_date IS NULL OR (NOW() >= authorization_effective_date))";
         $query->addWhere($where);
         $where = "(authorization_expiration_date IS NULL OR (NOW() < authorization_expiration_date))";
         $query->addWhere($where);
     }
     $query->addOrderBy("authorization_id");
     //		echo "<pre>\n";
     //		echo MySQL_SQLGenerator::generateSQLQuery($query);
     //		echo "</pre>\n";
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     // this array will store the authorizations that will be returned
     $authorizations = array();
     // we only want to create one implicitAZ for a given Agent/Function/Qualifier
     // combo, so maintain a list of already created ones to skip
     $createdImplicitAZs = array();
     $i = 0;
     // process all rows and create the explicit authorizations
     while ($queryResult->hasMoreRows()) {
         $row = $queryResult->getCurrentRow();
         // 			printpre($row);
         $idValue = $row['id'];
         $id = $idManager->getId($idValue);
         if (isset($this->_authorizations[$idValue])) {
             $authorization = $this->_authorizations[$idValue];
         } else {
             $agentId = $idManager->getId($row['aid']);
             $functionId = $idManager->getId($row['fid']);
             $explicitQualifierId = $idManager->getId($row['qid']);
             $effectiveDate = $dbHandler->fromDBDate($row['eff_date'], $this->_dbIndex);
             $expirationDate = $dbHandler->fromDBDate($row['exp_date'], $this->_dbIndex);
             // create the explicit authorization (each explicit authorization
             // has a corresponding row in the authorization db table)
             $authorization = new HarmoniAuthorization($idValue, $agentId, $functionId, $explicitQualifierId, true, $this, $effectiveDate, $expirationDate);
             $this->_authorizations[$idValue] = $authorization;
         }
         // Explicit AZ for ancestor qualifiers and groups should have
         // corresponding implicit AZs
         // in decendents, but not appear in their AZs directly.
         // Therefore, only add the explicit AZ if it is for the requested
         // qualifier and agent if we are fetching more than just the explicitAZs.
         if ($row['qid'] == $qId && $row['aid'] == $aId || $returnExplicitOnly) {
             $authorizations[] = $authorization;
         }
         // now create the implicit authorizations
         // the implicit authorizations will be created for all nodes
         // on the hierarchy path(s) between the node with the explicit authorization
         // and the node on which getAZs() was called.
         // If the row's qualifier and agent are what we asked for however,
         // then the AZ is explicit and doesn't need an implicit AZ as well.
         if ((!$returnExplicitOnly || $searchUp) && ($row['qid'] != $qId || $aId && $row['aid'] != $aId)) {
             // 				printpre("Building Implicit AZs...");
             // 				var_dump($returnExplicitOnly);
             // 				var_dump($searchUp);
             // if this is an AZ that is implicit because of a group instead
             // of because of the hierarchy, create it.
             if ($row['qid'] == $qId && $row['aid'] != $aId) {
                 // 					printpre("In first clause (AuthorizationCache)");
                 $qualifierId = $idManager->getId($qId);
                 // If we are getting implicit AZs for a given agent, make sure
                 // that the implicit AZ has their Id.
                 if ($aId) {
                     $agentId = $idManager->getId($aId);
                 } else {
                     $agentId = $authorization->getAgentId();
                 }
                 $function = $authorization->getFunction();
                 $functionId = $function->getId();
                 $effectiveDate = $authorization->getEffectiveDate();
                 $expirationDate = $authorization->getExpirationDate();
                 $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $qualifierId, false, $this, $effectiveDate, $expirationDate);
                 $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $qualifierId->getIdString();
                 if (!in_array($azHash, $createdImplicitAZs)) {
                     $authorizations[] = $implicit;
                     $createdImplicitAZs[] = $azHash;
                 }
             } else {
                 if (!$returnExplicitOnly && $qId) {
                     // 					printpre("In second clause (AuthorizationCache)");
                     // If we are getting implicit AZs for a given agent, make sure
                     // that the implicit AZ has their Id.
                     if ($aId) {
                         $agentId = $idManager->getId($aId);
                     } else {
                         $agentId = $authorization->getAgentId();
                     }
                     $function = $authorization->getFunction();
                     $functionId = $function->getId();
                     $effectiveDate = $authorization->getEffectiveDate();
                     $expirationDate = $authorization->getExpirationDate();
                     $implicitQualifierId = $idManager->getId($qId);
                     $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $implicitQualifierId, false, $this, $effectiveDate, $expirationDate);
                     $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $implicitQualifierId->getIdString();
                     if (!in_array($azHash, $createdImplicitAZs)) {
                         $authorizations[] = $implicit;
                         $createdImplicitAZs[] = $azHash;
                     }
                 } else {
                     if (!$returnExplicitOnly) {
                         printpre($row);
                         printpre("In third clause (AuthorizationCache)");
                         $explicitQualifier = $authorization->getQualifier();
                         $explicitQualifierId = $explicitQualifier->getId();
                         // If we are getting implicit AZs for a given agent, make sure
                         // that the implicit AZ has their Id.
                         if ($aId) {
                             $agentId = $idManager->getId($aId);
                         } else {
                             $agentId = $authorization->getAgentId();
                         }
                         $function = $authorization->getFunction();
                         $functionId = $function->getId();
                         $effectiveDate = $authorization->getEffectiveDate();
                         $expirationDate = $authorization->getExpirationDate();
                         // this is set 2
                         $authZManager = Services::getService("AuthZ");
                         $hierarchies = $authZManager->getQualifierHierarchies();
                         while ($hierarchies->hasNext()) {
                             $hierarchyId = $hierarchies->next();
                             $hierarchy = $hierarchyManager->getHierarchy($hierarchyId);
                             $timer = new Timer();
                             $timer->start();
                             $nodes = $hierarchy->traverse($explicitQualifierId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL);
                             $timer->end();
                             printf("LoadAZTime: %1.6f <br/>", $timer->printTime());
                             // now get the id of each node and store in array
                             $set2 = array();
                             // skip the first node
                             $nodes->next();
                             while ($nodes->hasNext()) {
                                 $info = $nodes->next();
                                 $nodeId = $info->getNodeId();
                                 $implicit = new HarmoniAuthorization(null, $agentId, $functionId, $nodeId, false, $this, $effectiveDate, $expirationDate);
                                 $azHash = $agentId->getIdString() . "::" . $functionId->getIdString() . "::" . $nodeId->getIdString();
                                 // 							printpre($azHash);
                                 // Weird bugs were happening, with $createdImplicitAZs
                                 // but I can't figure out what is going on.
                                 if (!in_array($azHash, $createdImplicitAZs)) {
                                     $authorizations[] = $implicit;
                                     // 								$createdImplicitAZs[] = $azHash;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $queryResult->advanceRow();
     }
     $queryResult->free();
     return $authorizations;
 }
예제 #7
0
    /**
     * Build the content for this action
     * 
     * @return void
     * @access public
     * @since 4/26/05
     */
    function buildContent()
    {
        require_once HARMONI . "/utilities/Timer.class.php";
        $execTimer = new Timer();
        $execTimer->start();
        $harmoni = Harmoni::instance();
        $idManager = Services::getService("Id");
        $slideshowAsset = $this->getAsset();
        /*********************************************************
         * First print the header, then the xml content, then exit before
         * the GUI system has a chance to try to theme the output.
         *********************************************************/
        header("Content-Type: text/xml; charset=\"utf-8\"");
        print <<<END
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE slideshow PUBLIC "- //Middlebury College//Slide-Show//EN" "http://concerto.sourceforge.net/dtds/viewer/2.0/slideshow.dtd">
<slideshow>

END;
        print "\t<title>" . $slideshowAsset->getDisplayName() . "</title>\n";
        print "\t<default_size>medium</default_size>\n";
        $setManager = Services::getService("Sets");
        $slideshowSet = $setManager->getPersistentSet($slideshowAsset->getId());
        $slideIterator = $slideshowAsset->getAssets();
        $orderedSlides = array();
        $unorderedSlides = array();
        while ($slideIterator->hasNext()) {
            $slideAsset = $slideIterator->next();
            $slideAssetId = $slideAsset->getId();
            if ($slideshowSet->isInSet($slideAssetId)) {
                $orderedSlides[$slideshowSet->getPosition($slideAssetId)] = $slideAsset;
            } else {
                $unorderedSlides[] = $slideAsset;
            }
        }
        ksort($orderedSlides);
        $slides = array_merge($orderedSlides, $unorderedSlides);
        unset($orderedSlides, $unorderedSlides);
        foreach (array_keys($slides) as $key) {
            $this->printSlide($slides[$key]);
        }
        $execTimer->end();
        print "\n\n<ExecutionTime>";
        printf("%1.6f", $execTimer->printTime());
        print "</ExecutionTime>\n";
        $dbhandler = Services::getService("DBHandler");
        print "<NumQueries>" . $dbhandler->getTotalNumberOfQueries() . "</NumQueries>\n";
        print "</slideshow>\n";
        exit;
    }