| [ PHPXref.com ] | [ Generated: Thu Jul 24 12:24:35 2008 ] | [ Concerto 2.1.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package concerto.install 4 * 5 * @copyright Copyright © 2005, Middlebury College 6 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL) 7 * 8 * @version $Id: dev_install.inc.php,v 1.23 2006/06/16 20:25:03 adamfranco Exp $ 9 */ 10 11 /********************************************************* 12 * Please note that this install script should be included 13 * by the config 14 * - After the HierarchyManager has been started 15 * - Before the RepositoryManager is started 16 * This script will print out a series of values that you 17 * will then need to copy to your config. 18 *********************************************************/ 19 20 if (!isset($_SESSION['table_setup_complete'])) { 21 22 /********************************************************* 23 * Check for existing data in the database 24 *********************************************************/ 25 $dbHandler = Services::getService("DatabaseManager"); 26 $tables = $dbHandler->getTableList($dbID); 27 28 if (count ($tables)) { 29 $_SESSION['table_setup_complete'] = TRUE; 30 RequestContext::locationHeader($_SERVER['REQUEST_URI']); 31 32 print "<h2>Tables exist in the database. Not creating tables.</h2>"; 33 print "<h2>If you have just run the installer, comment out it's line in the config to start using Concerto.</h2>"; 34 exit; 35 } 36 37 print "<h1>Creating tables and default data set.</h1>"; 38 39 /********************************************************* 40 * Create the needed database tables 41 *********************************************************/ 42 $sqlFiles = array ( 43 HARMONI_BASE."/SQL/Agent/MySQL_Agent.sql", 44 HARMONI_BASE."/SQL/AuthN/MySQL_Example_Authentication.sql", 45 HARMONI_BASE."/SQL/AuthN/MySQL_AgentTokenMapping.sql", 46 HARMONI_BASE."/SQL/AuthZ/MySQL_AuthZ.sql", 47 HARMONI_BASE."/SQL/dataManager/MySQL_dataManager.sql", 48 HARMONI_BASE."/SQL/DigitalRepository/MySQL_DigitalRepository.sql", 49 HARMONI_BASE."/SQL/hierarchy/MySQL_hierarchy.sql", 50 HARMONI_BASE."/SQL/Id/MySQL_Id.sql", 51 HARMONI_BASE."/SQL/logging/MySQL_Logging.sql", 52 HARMONI_BASE."/SQL/sets/MySQL_sets.sql", 53 HARMONI_BASE."/SQL/shared/MySQL_shared.sql", 54 ); 55 56 foreach ($sqlFiles as $file) { 57 SQLUtils::runSQLfile($file, $dbID); 58 } 59 60 61 /********************************************************* 62 * Script for setting up the Authorization Hierarchy 63 *********************************************************/ 64 $hierarchyManager =& Services::getService("HierarchyManager"); 65 $idManager =& Services::getService("IdManager"); 66 67 // Create the Hierarchy 68 $nodeTypes = array(); 69 $authorizationHierarchyId =& $idManager->getId("edu.middlebury.authorization.hierarchy"); 70 $authorizationHierarchy =& $hierarchyManager->createHierarchy( 71 "Concerto Qualifier Hierarchy", 72 $nodeTypes, 73 "A Hierarchy to hold all Qualifiers known to Concerto.", 74 TRUE, 75 FALSE, 76 $authorizationHierarchyId); 77 78 // Create nodes for Qualifiers 79 $allOfConcertoId =& $idManager->getId("edu.middlebury.authorization.root"); 80 $authorizationHierarchy->createRootNode($allOfConcertoId, new DefaultQualifierType, "All of Concerto", "The top level of all of Concerto."); 81 82 83 84 /********************************************************* 85 * Script for setting up the RepositoryManager Hierarchy 86 *********************************************************/ 87 // Create nodes for Qualifiers 88 $collectionsId =& $idManager->getId("edu.middlebury.concerto.collections_root"); 89 $authorizationHierarchy->createNode($collectionsId, $allOfConcertoId, new DefaultQualifierType, "Concerto Collections", "All Collections in Concerto."); 90 91 /********************************************************* 92 * Script for setting up the AgentManager Hierarchy 93 *********************************************************/ 94 // Create nodes for Qualifiers 95 $systemAgentType =& new Type ("Agents", "edu.middlebury.harmoni", "System", "Agents/Groups required by the Agent system."); 96 97 $everyoneId =& $idManager->getId("edu.middlebury.agents.everyone"); 98 $authorizationHierarchy->createNode($everyoneId, $allOfConcertoId, $systemAgentType, "Everyone", "All Agents and Groups in the system."); 99 100 $allGroupsId =& $idManager->getId("edu.middlebury.agents.all_groups"); 101 $authorizationHierarchy->createNode($allGroupsId, $everyoneId, $systemAgentType, "All Groups", "All Groups in the system."); 102 103 $allAgentsId =& $idManager->getId("edu.middlebury.agents.all_agents");; 104 $authorizationHierarchy->createNode($allAgentsId, $everyoneId, $systemAgentType, "All Agents", "All Agents in the system."); 105 106 107 if (file_exists(MYDIR.'/config/agent.conf.php')) 108 require_once (MYDIR.'/config/agent.conf.php'); 109 else 110 require_once (MYDIR.'/config/agent_default.conf.php'); 111 112 // The anonymous Agent 113 $agentManager =& Services::getService("AgentManager"); 114 $anonymousId =& $idManager->getId("edu.middlebury.agents.anonymous"); 115 require_once(HARMONI."oki2/shared/NonReferenceProperties.class.php"); 116 $agentProperties =& new NonReferenceProperties($systemAgentType); 117 $agentManager->createAgent("Anonymous", $systemAgentType, $agentProperties, $anonymousId); 118 119 /********************************************************* 120 * Script for setting up some default Groups and Users 121 *********************************************************/ 122 $agentManager =& Services::getService("AgentManager"); 123 $idManager =& Services::getService("IdManager"); 124 125 $groupType =& new Type ("System", "edu.middlebury.harmoni", "SystemGroups", "Groups for administrators and others with special privileges."); 126 $nullType =& new Type ("System", "edu.middlebury.harmoni", "NULL"); 127 $properties =& new HarmoniProperties($nullType); 128 $adminGroup =& $agentManager->createGroup("Administrators", $groupType, "Users that have access to every function in the system.", $properties); 129 $auditorGroup =& $agentManager->createGroup("Auditors", $groupType, "Users that can view all content in the system but not modify it.", $properties); 130 131 132 // default administrator account 133 $authNMethodManager =& Services::getService("AuthNMethodManager"); 134 $dbAuthType =& new Type ("Authentication", "edu.middlebury.harmoni", "Harmoni DB"); 135 $dbAuthMethod =& $authNMethodManager->getAuthNMethodForType($dbAuthType); 136 // Create the representation 137 138 $tokensArray = array("username" => "jadministrator", 139 "password" => "password"); 140 141 $adminAuthNTokens =& $dbAuthMethod->createTokens($tokensArray); 142 // Add it to the system 143 $dbAuthMethod->addTokens($adminAuthNTokens); 144 145 // Create an agent 146 $agentType =& new Type ("System", "edu.middlebury.harmoni", "Default Agents", "Default agents created for install and setup. They should be removed on production systems."); 147 require_once(HARMONI."oki2/shared/NonReferenceProperties.class.php"); 148 $agentProperties =& new NonReferenceProperties($agentType); 149 $agentProperties->addProperty("name", "Administrator, John"); 150 $agentProperties->addProperty("first_name", "John"); 151 $agentProperties->addProperty("last_name", "Administrator"); 152 $agentProperties->addProperty("email", "jadministrator@xxxxxxxxx.edu"); 153 $agentProperties->addProperty("status", "Not a real person."); 154 $adminAgent =& $agentManager->createAgent("John Administrator", $agentType, $agentProperties); 155 156 157 // map the agent to the tokens 158 $agentTokenMappingManager =& Services::getService("AgentTokenMappingManager"); 159 $agentTokenMappingManager->createMapping($adminAgent->getId(), $adminAuthNTokens, $dbAuthType); 160 161 // Add the agent to the Administrators group. 162 $adminGroup->add($adminAgent); 163 164 if (defined('ENABLE_DWARVES') && ENABLE_DWARVES) { 165 $dwarfGroup =& $agentManager->createGroup("Dwarves", $groupType, 166 "Test users with varying privileges", $properties); 167 168 $arrayOfTokens = array(); 169 $arrayOfTokens[] = array("username" => "sleepy", 170 "password" => "disney"); 171 $arrayOfTokens[] = array("username" => "doc", 172 "password" => "disney"); 173 $arrayOfTokens[] = array("username" => "bashful", 174 "password" => "disney"); 175 $arrayOfTokens[] = array("username" => "dopey", 176 "password" => "disney"); 177 $arrayOfTokens[] = array("username" => "sneezy", 178 "password" => "disney"); 179 $arrayOfTokens[] = array("username" => "grumpy", 180 "password" => "disney"); 181 $arrayOfTokens[] = array("username" => "happy", 182 "password" => "disney"); 183 184 $dwarfAuthNTokens = array(); 185 foreach ($arrayOfTokens as $key => $tokenArray) { 186 $dwarfAuthNTokens[$key] =& $dbAuthMethod->createTokens($tokenArray); 187 // Add it to the system 188 $dbAuthMethod->addTokens($dwarfAuthNTokens[$key]); 189 } 190 191 // the last 3 steps for the dwarves 192 foreach ($arrayOfTokens as $key => $tokens) { 193 $dwarfProperties =& new NonReferenceProperties($agentType); 194 $dwarfProperties->addProperty("name", 195 $tokens['username']); 196 $dwarfProperties->addProperty("first_name", 197 $tokens['username']); 198 $dwarfProperties->addProperty("email", 199 $tokens['username']."@xxxxxxxxx.edu"); 200 $dwarfProperties->addProperty("status", 201 "Not a real Dwarf"); 202 $dAgent =& $agentManager->createAgent( 203 $tokens['username'], $agentType, $dwarfProperties); 204 $agentTokenMappingManager->createMapping($dAgent->getId(), 205 $dwarfAuthNTokens[$key], $dbAuthType); 206 $dwarfGroup->add($dAgent); 207 } 208 } 209 210 /********************************************************* 211 * Script for setting up the AuthorizationFunctions that Concerto will use 212 *********************************************************/ 213 214 if (file_exists(MYDIR.'/config/authorization.conf.php')) 215 require_once (MYDIR.'/config/authorization.conf.php'); 216 else 217 require_once (MYDIR.'/config/authorization_default.conf.php'); 218 219 220 $authZManager =& Services::getService("AuthorizationManager"); 221 $idManager =& Services::getService("IdManager"); 222 $qualifierHierarchyId =& $authorizationHierarchyId; // Id from above 223 224 225 // View/Use Functions 226 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "View/Use", "Functions for viewing and using."); 227 228 $id =& $idManager->getId("edu.middlebury.authorization.access"); 229 $function =& $authZManager->createFunction($id, "Access", "Access a qualifier.", $type, $qualifierHierarchyId); 230 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 231 232 $id =& $idManager->getId("edu.middlebury.authorization.view"); 233 $function =& $authZManager->createFunction($id, "View", "View a qualifier.", $type, $qualifierHierarchyId); 234 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 235 236 $id =& $idManager->getId("edu.middlebury.authorization.comment"); 237 $function =& $authZManager->createFunction($id, "Comment", "Comment on a qualifier.", $type, $qualifierHierarchyId); 238 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 239 240 241 // Editing Functions 242 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "Editing", "Functions for editing."); 243 244 $id =& $idManager->getId("edu.middlebury.authorization.modify"); 245 $function =& $authZManager->createFunction($id, "Modify", "Modify a qualifier.", $type, $qualifierHierarchyId); 246 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 247 248 $id =& $idManager->getId("edu.middlebury.authorization.delete"); 249 $function =& $authZManager->createFunction($id, "Delete", "Delete a qualifier.", $type, $qualifierHierarchyId); 250 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 251 252 $id =& $idManager->getId("edu.middlebury.authorization.add_children"); 253 $function =& $authZManager->createFunction($id, "Add Children", "Add children to this qualifier.", $type, $qualifierHierarchyId); 254 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 255 256 $id =& $idManager->getId("edu.middlebury.authorization.remove_children"); 257 $function =& $authZManager->createFunction($id, "Remove Children", "Remove children from this qualifier.", $type, $qualifierHierarchyId); 258 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 259 260 // Schema Editing Functions 261 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "RecordStructures", "Functions for managing RecordStructures (a.k.a Schemas)."); 262 263 $id =& $idManager->getId("edu.middlebury.authorization.modify_rec_struct"); 264 $function =& $authZManager->createFunction($id, "Modify RecordStructures", "Modify RecordStructures (a.k.a. Schemas) in a Repository (a.k.a. Collection).", $type, $qualifierHierarchyId); 265 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 266 267 $id =& $idManager->getId("edu.middlebury.authorization.delete_rec_struct"); 268 $function =& $authZManager->createFunction($id, "Delete RecordStructures", "Delete RecordStructures (a.k.a. Schemas) in a Repository (a.k.a. Collection).", $type, $qualifierHierarchyId); 269 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 270 271 $id =& $idManager->getId("edu.middlebury.authorization.convert_rec_struct"); 272 $function =& $authZManager->createFunction($id, "Convert RecordStructures", "Convert the data types/properties of RecordStructures (a.k.a. Schemas) in a Repository (a.k.a. Collection).", $type, $qualifierHierarchyId); 273 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 274 275 $id =& $idManager->getId("edu.middlebury.authorization.modify_authority_list"); 276 $function =& $authZManager->createFunction($id, "Modify Authority List", "Modify the values that appear in the Authority Lists of a Repository (a.k.a. Collection).", $type, $qualifierHierarchyId); 277 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 278 279 280 // Administration Functions 281 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "Administration", "Functions for administering."); 282 283 $id =& $idManager->getId("edu.middlebury.authorization.view_authorizations"); 284 $function =& $authZManager->createFunction($id, "View Authorizations", "View Authorizations at a qualifier.", $type, $qualifierHierarchyId); 285 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 286 287 $id =& $idManager->getId("edu.middlebury.authorization.modify_authorizations"); 288 $function =& $authZManager->createFunction($id, "Modify Authorizations", "Modify Authorizations at qualifier.", $type, $qualifierHierarchyId); 289 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 290 291 // Administration Functions 292 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "User Administration", "Functions for administering users."); 293 294 $id =& $idManager->getId("edu.middlebury.authorization.create_agent"); 295 $function =& $authZManager->createFunction($id, "Create Agents", "Add Agents to the system.", $type, $qualifierHierarchyId); 296 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 297 298 $id =& $idManager->getId("edu.middlebury.authorization.delete_agent"); 299 $function =& $authZManager->createFunction($id, "Delete Agents", "Remove Agents from the system.", $type, $qualifierHierarchyId); 300 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 301 302 $id =& $idManager->getId("edu.middlebury.authorization.modify_agent"); 303 $function =& $authZManager->createFunction($id, "Modify Agents", "Modify Agent properties.", $type, $qualifierHierarchyId); 304 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 305 306 // Administration Functions 307 $type =& new Type ("Authorization", "edu.middlebury.harmoni", "Group Administration", "Functions for administering groups."); 308 309 $id =& $idManager->getId("edu.middlebury.authorization.create_group"); 310 $function =& $authZManager->createFunction($id, "Create Groups", "Add Groups to the system.", $type, $qualifierHierarchyId); 311 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 312 313 $id =& $idManager->getId("edu.middlebury.authorization.delete_group"); 314 $function =& $authZManager->createFunction($id, "Delete Groups", "Remove Groups from the system.", $type, $qualifierHierarchyId); 315 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 316 317 $id =& $idManager->getId("edu.middlebury.authorization.modify_group_membership"); 318 $function =& $authZManager->createFunction($id, "Modify Group Membership", "Modify Group membership.", $type, $qualifierHierarchyId); 319 $authZManager->createAuthorization($adminGroup->getId(), $function->getId(), $allOfConcertoId); 320 321 print "\n<br> ...done"; 322 $_SESSION['table_setup_complete'] = TRUE; 323 324 RequestContext::locationHeader($_SERVER['REQUEST_URI']); 325 } 326 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |